vorax 0.4.2 → 5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. data/README.md +4 -29
  2. data/vorax.gemspec +3 -11
  3. metadata +4 -92
  4. data/.rspec +0 -1
  5. data/Rakefile +0 -30
  6. data/lib/vorax.rb +0 -60
  7. data/lib/vorax/base_funnel.rb +0 -30
  8. data/lib/vorax/output/html_convertor.rb +0 -120
  9. data/lib/vorax/output/html_funnel.rb +0 -79
  10. data/lib/vorax/output/pagezip_convertor.rb +0 -20
  11. data/lib/vorax/output/tablezip_convertor.rb +0 -22
  12. data/lib/vorax/output/vertical_convertor.rb +0 -53
  13. data/lib/vorax/output/zip_convertor.rb +0 -117
  14. data/lib/vorax/parser/argument.rb~ +0 -125
  15. data/lib/vorax/parser/conn_string.rb +0 -104
  16. data/lib/vorax/parser/grammars/alias.rb +0 -904
  17. data/lib/vorax/parser/grammars/alias.rl +0 -138
  18. data/lib/vorax/parser/grammars/column.rb +0 -454
  19. data/lib/vorax/parser/grammars/column.rl +0 -64
  20. data/lib/vorax/parser/grammars/common.rl +0 -107
  21. data/lib/vorax/parser/grammars/declare.rb +0 -9606
  22. data/lib/vorax/parser/grammars/declare.rl +0 -160
  23. data/lib/vorax/parser/grammars/for_block.rb +0 -440
  24. data/lib/vorax/parser/grammars/for_block.rl +0 -73
  25. data/lib/vorax/parser/grammars/plsql_def.rb +0 -539
  26. data/lib/vorax/parser/grammars/plsql_def.rl +0 -73
  27. data/lib/vorax/parser/grammars/statement.rb +0 -925
  28. data/lib/vorax/parser/grammars/statement.rl +0 -83
  29. data/lib/vorax/parser/parser.rb +0 -344
  30. data/lib/vorax/parser/plsql_structure.rb +0 -222
  31. data/lib/vorax/parser/plsql_walker.rb +0 -143
  32. data/lib/vorax/parser/statement_inspector.rb~ +0 -52
  33. data/lib/vorax/parser/stmt_inspector.rb +0 -78
  34. data/lib/vorax/parser/target_ref.rb +0 -110
  35. data/lib/vorax/sqlplus.rb +0 -273
  36. data/lib/vorax/version.rb +0 -7
  37. data/lib/vorax/vorax_io.rb +0 -70
  38. data/spec/column_spec.rb +0 -40
  39. data/spec/conn_string_spec.rb +0 -53
  40. data/spec/declare_spec.rb +0 -281
  41. data/spec/pagezip_spec.rb +0 -153
  42. data/spec/parser_spec.rb +0 -352
  43. data/spec/plsql_structure_spec.rb +0 -68
  44. data/spec/spec_helper.rb +0 -13
  45. data/spec/sql/create_objects.sql +0 -69
  46. data/spec/sql/dbms_crypto.spc +0 -339
  47. data/spec/sql/dbms_stats.spc +0 -4097
  48. data/spec/sql/drop_user.sql +0 -10
  49. data/spec/sql/muci.spc +0 -26
  50. data/spec/sql/setup_user.sql +0 -22
  51. data/spec/sql/test.fnc +0 -12
  52. data/spec/sql/test.pkg +0 -83
  53. data/spec/sqlplus_spec.rb +0 -52
  54. data/spec/stmt_inspector_spec.rb +0 -96
  55. data/spec/tablezip_spec.rb +0 -111
  56. data/spec/vertical_spec.rb +0 -150
@@ -1,10 +0,0 @@
1
- set verify off
2
- set feedback off
3
-
4
- prompt Dropping VORAX_TEST user...
5
-
6
- drop user vorax_test cascade;
7
-
8
- prompt Done.
9
-
10
- quit
@@ -1,26 +0,0 @@
1
- create or replace package muci as
2
-
3
- MY_CONSTANT1 constant varchar2(100) := 'abc';
4
- MY_CONSTANT2 constant integer := 10;
5
-
6
- ex_no_data_found exception;
7
- pragma exception_init(ex_no_data_found, -20000);
8
-
9
- ex_custom exception;
10
- pragma exception_init(ex_custom, -20001);
11
-
12
- cursor my_cursor is
13
- select * from user_tables;
14
-
15
- type population_type is table of varchar2(100);
16
-
17
- g_var1 integer;
18
- g_var2 varchar2(100) := 'xyz';
19
- g_var3 dual.dummy%type;
20
- g_var4 all_objects%rowtype;
21
-
22
- procedure my_proc(p1 integer);
23
- function my_func(param1 varchar2, param2 boolean := true) return boolean;
24
-
25
- end;
26
- /
@@ -1,22 +0,0 @@
1
- set verify off
2
- set feedback off
3
-
4
- prompt Create VORAX_TEST user
5
-
6
- grant create session,
7
- create table,
8
- create view,
9
- create sequence,
10
- create procedure,
11
- create type,
12
- create synonym,
13
- unlimited tablespace
14
- to vorax_test identified by xxx;
15
-
16
- grant select on v_$sesstat to vorax_test;
17
- grant select on v_$statname to vorax_test;
18
- grant select on v_$mystat to vorax_test;
19
-
20
- prompt Done.
21
-
22
- quit
@@ -1,12 +0,0 @@
1
- create or replace function test return boolean as
2
-
3
- l_local varchar2(100);
4
-
5
- procedure muci as
6
- begin
7
- null;
8
- end;
9
-
10
- begin
11
- null;
12
- end;
@@ -1,83 +0,0 @@
1
- create or replace package test as
2
-
3
- g_var varchar2(100);
4
-
5
- procedure test(p1 integer);
6
- function muci(x varchar2, y clob) return boolean;
7
-
8
- end test;
9
- /
10
-
11
- create or replace package body test as
12
-
13
- lg_var_private varchar2(100);
14
-
15
- procedure private_proc(p integer) as
16
-
17
- l_var varchar2(100);
18
-
19
- /* local function */
20
- function abc return boolean as
21
- begin
22
- return true;
23
- end;
24
-
25
- procedure xyz as
26
- begin
27
- null;
28
- end;
29
-
30
- begin
31
- l_var := 'abc';
32
- for x in (select * from v$session) loop
33
- dbms_output.put_line(x.);
34
- if x.dummy = 'X' then
35
- dbms_output.put_line('Great!');
36
- end if;
37
- if 1 = 0 then
38
- if 1 = 1 then
39
- for y in (select * from cat) loop
40
- dbms_output.put_line(y.table_name);
41
- dbms_output.put_line('------------------------------');
42
- end loop;
43
- dbms_output.put_line('not here ever!');
44
- end if;
45
- if 1 = 0 then
46
- dbms_output.put_line('OMG!');
47
- end if;
48
- end if;
49
- null;
50
- end loop;
51
- select dummy into l_var from dual;
52
- if l_var is not null then
53
- dbms_output.put_line('yessss baby!');
54
- end if;
55
- dbms_output.put_line('a loop is following');
56
- loop
57
- exit when l_var = 'X';
58
- dbms_output.put_line('should not be here');
59
- end loop;
60
- dbms_output.put_line('that''s all folks!');
61
- end;
62
-
63
- procedure test(p1 integer) as
64
- begin
65
- dbms_output.put_line('just a test');
66
- begin
67
- null;
68
- exception
69
- when others then
70
- null;
71
- end;
72
- end;
73
-
74
- function muci(x varchar2, y clob) return boolean as
75
- begin
76
- return false;
77
- end;
78
-
79
- begin
80
- g_var := 'test';
81
- end test;
82
- /
83
-
@@ -1,52 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- include Vorax
4
-
5
- describe 'sqlplus' do
6
-
7
- before(:each) do# {{{
8
- @sp = Sqlplus.new('sqlplus')
9
- @prep = [VORAX_CSTR,
10
- "set tab off",
11
- "set linesize 10000",
12
- "set echo off",
13
- "set pause off",
14
- "set define &",
15
- "set termout on",
16
- "set verify off",
17
- "set pagesize 4"].join("\n")
18
- @result = ""
19
- end# }}}
20
-
21
- it 'should work with utf8' do# {{{
22
- @sp.exec('select name from employees where id=1;', :prep => @prep + "\ncolumn name format a20")
23
- @result << @sp.read_output(32767) while @sp.busy?
24
- expected = "
25
- SQL>
26
- NAME
27
- --------------------
28
- Tică Șerban
29
-
30
- SQL> "
31
- @result.should eq(expected)
32
- end# }}}
33
-
34
- it 'should work with substitution variables' do# {{{
35
- begin
36
- pack_file = Tempfile.new(['vorax', '.sql'])
37
- @sp.exec("accept var prompt \"Enter var: \"\nprompt &var", :prep => @prep, :pack_file => pack_file.path)
38
- Timeout::timeout(10) {
39
- @result << @sp.read_output(32767) while @result !~ /Enter var: \z/
40
- @sp.send_text("muci\n")
41
- @result << @sp.read_output(32767) while @result !~ /muci\n\z/
42
- }
43
- ensure
44
- pack_file.unlink
45
- end
46
- end# }}}
47
-
48
- after(:each) do# {{{
49
- @sp.terminate
50
- end# }}}
51
-
52
- end
@@ -1,96 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- include Vorax
4
- include Parser
5
-
6
- describe 'stmt_inspector' do
7
-
8
- it 'should work with delete statements' do
9
- text = "\n delete from bskcmptre d where itmidn = d.\n end loop;"
10
- inspector = StmtInspector.new(text)
11
- inspector.find_alias('d', 0).columns.should == ['bskcmptre.*']
12
- end
13
-
14
- it 'should work with hierarchical queries' do
15
- text = "select * from (select level as lvl, bskcmptre_tbl.*\n from bskcmptre_tbl\n start with itmidn = pi_nodidn\n connect by prior itmidn = bskprnidn\n order by itmidn desc) v_crtrec"
16
- inspector = StmtInspector.new(text)
17
- inspector.find_alias('v_crtrec', 0).columns.should == ["lvl", "bskcmptre_tbl.*"]
18
- end
19
-
20
- it 'should work with a complex query' do# {{{
21
- text = '
22
- with
23
- tab as (select * from dba_users),
24
- t2 as (select * from v$session)
25
- select d.*, c.table_name
26
- from sys.dual d inner join
27
- (select c. from cat c) c on (d.c = c.c) outer join
28
- dba_tables on (x=y)
29
- union
30
- select t.*, x
31
- from muci t, buci
32
- where 1=2;
33
- '
34
- #puts text
35
- inspector = StmtInspector.new(text)
36
- #pp inspector.data_source
37
- inspector.data_source.size.should == 7
38
- inspector.data_source.should include(ExprRef.new("select * from dba_users", (29..51), "tab"))
39
- inspector.data_source.should include(ExprRef.new("select * from v$session", (71..93), "t2"))
40
- inspector.data_source.should include(TableRef.new("sys.dual", "d"));
41
- inspector.data_source.should include(ExprRef.new("select c. from cat c", (179..198), 'c'));
42
- inspector.data_source.should include(TableRef.new("dba_tables", nil));
43
- inspector.data_source.should include(TableRef.new("muci", "t"));
44
- inspector.data_source.should include(TableRef.new("buci", nil));
45
- inspector.query_fields.should eq(["d.*", "c.table_name"])
46
- end# }}}
47
-
48
- it 'should get alias on an inner context' do# {{{
49
- text = '
50
- with
51
- tab as (select * from dba_users),
52
- t2 as (select * from v$session)
53
- select d.*, c.table_name
54
- from sys.dual d inner join
55
- (select * from (select * from cat) c) c on (d.c = c.c) outer join
56
- dba_tables on (x=y)
57
- union
58
- select t.*, x
59
- from muci t, buci
60
- where 1=2;
61
- '
62
- inspector = StmtInspector.new(text)
63
- ds = inspector.data_source(186);
64
- ds.size.should == 8
65
- ds.should include(ExprRef.new("select * from cat", (15..31), "c"))
66
- ds.should include(ExprRef.new("select * from dba_users", (29..51), "tab"))
67
- ds.should include(ExprRef.new("select * from v$session", (71..93), "t2"))
68
- ds.should include(TableRef.new("sys.dual", "d"));
69
- ds.should include(ExprRef.new("select * from (select * from cat) c", (179..213), 'c'));
70
- ds.should include(TableRef.new("dba_tables", nil));
71
- ds.should include(TableRef.new("muci", "t"));
72
- ds.should include(TableRef.new("buci", nil));
73
- end# }}}
74
-
75
- it 'should get columns for the provided alias' do# {{{
76
- text = '
77
- with
78
- tab as (select * from (select user_id, user_name, password, x.* from dba_users, (select c1, c2, from dual) x)),
79
- t2 as (select * from v$session)
80
- select d.*, c.table_name
81
- from sys.dual d inner join
82
- (select * from (select * from cat) c) c on (d.c = c.c) outer join
83
- dba_tables on (x=y)
84
- union
85
- select t.*, x.*
86
- from muci t, buci x
87
- where 1=2;
88
- '
89
- inspector = StmtInspector.new(text)
90
- inspector.find_alias('x', 0).columns.should eq(["buci.*"])
91
- inspector.find_alias('x', 63).columns.should eq(["c1", "c2"])
92
- inspector.find_alias('tab', 0).columns.should eq(["user_id", "user_name", "password", "c1", "c2"])
93
- end# }}}
94
-
95
- end
96
-
@@ -1,111 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- include Vorax
4
-
5
- describe 'tablezip layout' do
6
-
7
- before(:each) do# {{{
8
- @sp = Sqlplus.new('sqlplus')
9
- @sp.default_convertor = :tablezip
10
- @prep = [VORAX_CSTR,
11
- "set tab off",
12
- "set linesize 10000",
13
- "set markup html on",
14
- "set echo off",
15
- "set pause off",
16
- "set define &",
17
- "set termout on",
18
- "set verify off",
19
- "set pagesize 4"].join("\n")
20
- @result = ""
21
- end# }}}
22
-
23
- it 'should work with multiple statements' do# {{{
24
- @sp.exec("select * from dual;\nselect * from departments where id <= 2;", :prep => @prep)
25
- @result << @sp.read_output(32767) while @sp.busy?
26
- expected = <<OUTPUT
27
-
28
- SQL>
29
-
30
- DUM
31
- ---
32
- X
33
-
34
- SQL>
35
-
36
- ID NAME DESCRIPTION
37
- -- ----------- -----------------------------------
38
- 1 Bookkeeping This department is responsible for:
39
- - financial reporting
40
- - analysis
41
- - other boring tasks
42
- 2 Marketing  
43
-
44
- SQL>
45
- OUTPUT
46
- #puts @result
47
- @result.should eq(expected)
48
- end# }}}
49
-
50
- it 'should work with multi line records' do# {{{
51
- @sp.exec("select * from departments where id <= 10;", :prep => @prep)
52
- @result << @sp.read_output(32767) while @sp.busy?
53
- expected = <<OUTPUT
54
-
55
- SQL>
56
-
57
- ID NAME DESCRIPTION
58
- -- ---------------- -----------------------------------
59
- 1 Bookkeeping This department is responsible for:
60
- - financial reporting
61
- - analysis
62
- - other boring tasks
63
- 2 Marketing  
64
- 3 Deliveries  
65
- 4 CRM  
66
-
67
- ID NAME DESCRIPTION
68
- -- ---------------- -----------------------------------
69
- 5 Legal Stuff  
70
- 6 Management The bad guys department
71
- 7 Cooking  
72
- 8 Public Relations  
73
-
74
- ID NAME DESCRIPTION
75
- -- ---------------- -----------------------------------
76
- 9 Aquisitions  
77
- 10 Cleaning  
78
-
79
- 10 rows selected.
80
-
81
- SQL>
82
- OUTPUT
83
- @result.should eq(expected)
84
- end# }}}
85
-
86
- it 'should work with accept prompts' do# {{{
87
- begin
88
- pack_file = Tempfile.new(['vorax', '.sql'])
89
- @sp.exec("accept var prompt \"Enter var: \"\nprompt &var", :prep => @prep, :pack_file => pack_file.path)
90
- Timeout::timeout(10) {
91
- @result << @sp.read_output(32767) while @result !~ /Enter var:\z/
92
- @sp.send_text("muci\n")
93
- @result << @sp.read_output(32767) while @result !~ /muci\n\z/
94
- }
95
- ensure
96
- pack_file.unlink
97
- end
98
- end# }}}
99
-
100
- it 'should work with <pre> tags' do# {{{
101
- @sp.exec("set autotrace traceonly explain\nselect * from dual;", :prep => @prep)
102
- @result << @sp.read_output(32767) while @sp.busy?
103
- @result.should match(/SELECT STATEMENT/)
104
- end# }}}
105
-
106
- after(:each) do# {{{
107
- @sp.terminate
108
- end# }}}
109
-
110
- end
111
-
@@ -1,150 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- include Vorax
4
-
5
- describe 'vertical layout' do
6
-
7
- before(:each) do# {{{
8
- @sp = Sqlplus.new('sqlplus')
9
- @sp.default_convertor = :vertical
10
- @prep = [VORAX_CSTR,
11
- "set tab off",
12
- "set linesize 10000",
13
- "set markup html on",
14
- "set echo off",
15
- "set pause off",
16
- "set define &",
17
- "set termout on",
18
- "set verify off",
19
- "set pagesize 4"].join("\n")
20
- @result = ""
21
- end# }}}
22
-
23
- it 'should work with pagesize=0' do# {{{
24
- @sp.exec("select * from departments where id<=3;", :prep => @prep + "\nset pagesize 0")
25
- @result << @sp.read_output(32767) while @sp.busy?
26
- expected = <<OUTPUT
27
-
28
- SQL>
29
-
30
- : 1
31
- : Bookkeeping
32
- : This department is responsible for:
33
- - financial reporting
34
- - analysis
35
- - other boring tasks
36
- ------------------------------------------------------------
37
- : 2
38
- : Marketing
39
- :  
40
- ------------------------------------------------------------
41
- : 3
42
- : Deliveries
43
- :  
44
- ------------------------------------------------------------
45
-
46
- SQL>
47
- OUTPUT
48
- @result.should eq(expected)
49
- end# }}}
50
-
51
- it 'should work with unicode special chars' do# {{{
52
- @sp.exec("select * from employees where id=1;", :prep => @prep)
53
- @result << @sp.read_output(32767) while @sp.busy?
54
- expected = <<OUTPUT
55
-
56
- SQL>
57
-
58
- ID : 1
59
- NAME : Tică Șerban
60
- SALARY : 570
61
- DEPARTMENT_ID : 1
62
- ------------------------------------------------------------
63
-
64
- SQL>
65
- OUTPUT
66
- #puts @result
67
- @result.should eq(expected)
68
- end# }}}
69
-
70
- it 'should work with one single line record' do# {{{
71
- @sp.exec("select * from departments where id=2;", :prep => @prep)
72
- @result << @sp.read_output(32767) while @sp.busy?
73
- expected = <<OUTPUT
74
-
75
- SQL>
76
-
77
- ID : 2
78
- NAME : Marketing
79
- DESCRIPTION :  
80
- ------------------------------------------------------------
81
-
82
- SQL>
83
- OUTPUT
84
- @result.should eq(expected)
85
- end# }}}
86
-
87
- it 'should work with one multiline record' do# {{{
88
- @sp.exec("select * from departments where id=1;", :prep => @prep)
89
- @result << @sp.read_output(32767) while @sp.busy?
90
- expected = <<OUTPUT
91
-
92
- SQL>
93
-
94
- ID : 1
95
- NAME : Bookkeeping
96
- DESCRIPTION : This department is responsible for:
97
- - financial reporting
98
- - analysis
99
- - other boring tasks
100
- ------------------------------------------------------------
101
-
102
- SQL>
103
- OUTPUT
104
- @result.should eq(expected)
105
- end# }}}
106
-
107
- it 'should work with multiple lines' do# {{{
108
- @sp.exec("select * from departments where id in (1, 2);", :prep => @prep)
109
- @result << @sp.read_output(32767) while @sp.busy?
110
- expected = <<OUTPUT
111
-
112
- SQL>
113
-
114
- ID : 1
115
- NAME : Bookkeeping
116
- DESCRIPTION : This department is responsible for:
117
- - financial reporting
118
- - analysis
119
- - other boring tasks
120
- ------------------------------------------------------------
121
- ID : 2
122
- NAME : Marketing
123
- DESCRIPTION :  
124
- ------------------------------------------------------------
125
-
126
- SQL>
127
- OUTPUT
128
- @result.should eq(expected)
129
- end# }}}
130
-
131
- it 'should work with accept prompts' do# {{{
132
- begin
133
- pack_file = Tempfile.new(['vorax', '.sql'])
134
- @sp.exec("accept var prompt \"Enter var: \"\nprompt &var", :prep => @prep, :pack_file => pack_file.path)
135
- Timeout::timeout(10) {
136
- @result << @sp.read_output(32767) while @result !~ /Enter var:\z/
137
- @sp.send_text("muci\n")
138
- @result << @sp.read_output(32767) while @result !~ /muci\n\z/
139
- }
140
- ensure
141
- pack_file.unlink
142
- end
143
- end# }}}
144
-
145
- after(:each) do# {{{
146
- @sp.terminate
147
- end# }}}
148
-
149
- end
150
-