vorax 0.3.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,8 +17,12 @@ action for_var {
17
17
  @for_var = data[(@start..@end)]
18
18
  }
19
19
 
20
- action cursor_var {
21
- @cursor_var = data[(@start..@end)]
20
+ action start_capture_cursor {
21
+ @cursor_var_start = p
22
+ }
23
+
24
+ action end_capture_cursor {
25
+ @cursor_var = data[(@cursor_var_start..p-1)]
22
26
  }
23
27
 
24
28
  action start_identifier {
@@ -33,9 +37,11 @@ action end_identifier {
33
37
  expression = '(' >expr_start;
34
38
  id = identifier >start_identifier %end_identifier;
35
39
 
40
+ cursor_var = qualified_identifier - K_REVERSE;
41
+
36
42
  for_stmt_range = ws+ (K_REVERSE ws+)? digit+ ws* '..' ws* digit+ ws+;
37
43
  for_stmt_query = ws* expression ws*;
38
- for_stmt_cursor = ws+ (id - K_REVERSE) %cursor_var ws+;
44
+ for_stmt_cursor = ws+ cursor_var >start_capture_cursor %end_capture_cursor ws+;
39
45
  for_stmt := (K_FOR ws+ id %for_var ws+ K_IN (for_stmt_range | for_stmt_query | for_stmt_cursor) K_LOOP ws+) @mark_end;
40
46
 
41
47
  }%%
@@ -58,7 +58,7 @@ module Vorax
58
58
  #@root.each { |t| t.content.end_pos = @text.length if t.content && t.content.end_pos == 0 }
59
59
  @root
60
60
  end
61
-
61
+
62
62
  private
63
63
 
64
64
  def assign_parent(node)
data/lib/vorax/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Vorax
4
4
 
5
- VERSION = '0.3.1' unless defined?(VERSION)
5
+ VERSION = '0.4.2' unless defined?(VERSION)
6
6
 
7
7
  end
data/spec/declare_spec.rb CHANGED
@@ -5,44 +5,277 @@ include Parser
5
5
 
6
6
  describe 'package_spec' do
7
7
 
8
- it 'should work with a simple package' do
8
+ it 'should get the vim format' do
9
9
  text = File.open("spec/sql/muci.spc", 'rb') { |file| file.read }
10
- parser = Vorax::Parser::Declare.new
11
- parser.walk(text)
10
+ parser = Vorax::Parser::Declare.new(text)
11
+ parser.to_vim.should == %q[[ {'name' : "MY_CONSTANT1", 'is_a' : "constant", 'type' : "varchar2", 'captured_text' : "MY_CONSTANT1 constant varchar2(100) := 'abc';"},{'name' : "MY_CONSTANT2", 'is_a' : "constant", 'type' : "integer", 'captured_text' : "MY_CONSTANT2 constant integer := 10;"},{'name' : "ex_no_data_found", 'is_a' : "exception", 'type' : "exception", 'captured_text' : "ex_no_data_found exception;"},{'name' : "ex_custom", 'is_a' : "exception", 'type' : "exception", 'captured_text' : "ex_custom exception;"},{'name' : "my_cursor", 'is_a' : "cursor", 'type' : "", 'captured_text' : "cursor my_cursor is\n select * from user_tables;"},{'name' : "population_type", 'is_a' : "type", 'type' : "table", 'captured_text' : "type population_type is table of varchar2(100);"},{'name' : "g_var1", 'is_a' : "variable", 'type' : "integer", 'captured_text' : "g_var1 integer;"},{'name' : "g_var2", 'is_a' : "variable", 'type' : "varchar2", 'captured_text' : "g_var2 varchar2(100) := 'xyz';"},{'name' : "g_var3", 'is_a' : "variable", 'type' : "dual.dummy%type", 'captured_text' : "g_var3 dual.dummy%type;"},{'name' : "g_var4", 'is_a' : "variable", 'type' : "all_objects%rowtype", 'captured_text' : "g_var4 all_objects%rowtype;"},{'name' : "my_proc", 'is_a' : "procedure", 'type' : "", 'captured_text' : "procedure my_proc(p1 integer);"},{'name' : "my_func", 'is_a' : "function", 'type' : "", 'captured_text' : "function my_func(param1 varchar2, param2 boolean := true) return boolean;"} ]]
12
+ end
12
13
 
13
- parser.constants.should eq(Set.new(["MY_CONSTANT1", "MY_CONSTANT2"]))
14
- parser.exceptions.should eq(Set.new(["ex_no_data_found", "ex_custom"]))
15
- parser.cursors.should eq(Set.new(["my_cursor"]))
16
- parser.types.should eq(Set.new(["population_type"]))
17
- parser.variables.should eq(Set.new(["g_var1", "g_var2"]))
18
- parser.procedures.should eq(Set.new(["my_proc"]))
19
- parser.functions.should eq(Set.new(["my_func"]))
14
+ it 'should work with a simple package' do
15
+ text = File.open("spec/sql/muci.spc", 'rb') { |file| file.read }
16
+ parser = Vorax::Parser::Declare.new(text)
17
+ parser.items.length.should == 12
18
+ parser.items.include?(DeclareItem.new("MY_CONSTANT1",
19
+ :constant,
20
+ "varchar2",
21
+ "MY_CONSTANT1 constant varchar2(100) := 'abc';")).should be_true
22
+ parser.items.include?(DeclareItem.new("MY_CONSTANT2",
23
+ :constant,
24
+ "integer",
25
+ "MY_CONSTANT2 constant integer := 10;")).should be_true
26
+ parser.items.include?(DeclareItem.new("ex_no_data_found",
27
+ :exception,
28
+ "exception",
29
+ "ex_no_data_found exception;")).should be_true
30
+ parser.items.include?(DeclareItem.new("ex_custom",
31
+ :exception,
32
+ "exception",
33
+ "ex_custom exception;")).should be_true
34
+ parser.items.include?(DeclareItem.new("my_cursor",
35
+ :cursor,
36
+ nil,
37
+ "cursor my_cursor is\n select * from user_tables;")).should be_true
38
+ parser.items.include?(DeclareItem.new("population_type",
39
+ :type,
40
+ "table",
41
+ "type population_type is table of varchar2(100);")).should be_true
42
+ parser.items.include?(DeclareItem.new("g_var1",
43
+ :variable,
44
+ "integer",
45
+ "g_var1 integer;")).should be_true
46
+ parser.items.include?(DeclareItem.new("g_var2",
47
+ :variable,
48
+ "varchar2",
49
+ "g_var2 varchar2(100) := 'xyz';")).should be_true
50
+ parser.items.include?(DeclareItem.new("g_var3",
51
+ :variable,
52
+ "dual.dummy%type",
53
+ "g_var3 dual.dummy%type;")).should be_true
54
+ parser.items.include?(DeclareItem.new("g_var4",
55
+ :variable,
56
+ "all_objects%rowtype",
57
+ "g_var4 all_objects%rowtype;")).should be_true
58
+ parser.items.include?(DeclareItem.new("my_proc",
59
+ :procedure,
60
+ nil,
61
+ "procedure my_proc(p1 integer);")).should be_true
62
+ parser.items.include?(DeclareItem.new("my_func",
63
+ :function,
64
+ nil,
65
+ "function my_func(param1 varchar2, param2 boolean := true) return boolean;")).should be_true
20
66
  end
21
67
 
22
68
  it 'should work with a big package spec' do
23
69
  text = File.open('spec/sql/dbms_stats.spc', 'rb') { |file| file.read }
24
- parser = Vorax::Parser::Declare.new
25
- parser.walk(text)
26
- parser.constants.should eq(Set.new(["AUTO_CASCADE", "AUTO_INVALIDATE", "AUTO_SAMPLE_SIZE", "DEFAULT_DEGREE", "AUTO_DEGREE", "DEFAULT_CASCADE", "DEFAULT_DEGREE_VALUE", "DEFAULT_ESTIMATE_PERCENT", "DEFAULT_METHOD_OPT", "DEFAULT_NO_INVALIDATE", "DEFAULT_GRANULARITY", "DEFAULT_PUBLISH", "DEFAULT_INCREMENTAL", "DEFAULT_STALE_PERCENT", "DEFAULT_AUTOSTATS_TARGET", "DEFAULT_STAT_CATEGORY", "PURGE_ALL"]))
27
- parser.exceptions.should eq(Set.new([]))
28
- parser.cursors.should eq(Set.new([]))
29
- parser.types.should eq(Set.new(["numarray", "datearray", "chararray", "rawarray", "fltarray", "dblarray", "StatRec", "ObjectElem", "ObjectTab", "DiffRepElem", "DiffRepTab", "CContext"]))
30
- parser.variables.should eq(Set.new([]))
31
- parser.procedures.should eq(Set.new(["prepare_column_values", "prepare_column_values_nvarchar", "prepare_column_values_rowid", "set_param", "reset_param_defaults", "reset_global_pref_defaults", "set_global_prefs", "set_table_prefs", "delete_table_prefs", "export_table_prefs", "import_table_prefs", "set_schema_prefs", "delete_schema_prefs", "export_schema_prefs", "import_schema_prefs", "set_database_prefs", "delete_database_prefs", "export_database_prefs", "import_database_prefs", "init_package", "publish_pending_stats", "export_pending_stats", "delete_pending_stats", "resume_gather_stats", "set_column_stats", "set_index_stats", "set_table_stats", "convert_raw_value", "convert_raw_value_nvarchar", "convert_raw_value_rowid", "get_column_stats", "get_index_stats", "get_table_stats", "delete_column_stats", "delete_index_stats", "delete_table_stats", "delete_schema_stats", "delete_database_stats", "create_stat_table", "drop_stat_table", "upgrade_stat_table", "export_column_stats", "export_index_stats", "export_table_stats", "export_schema_stats", "export_database_stats", "import_column_stats", "import_index_stats", "import_table_stats", "import_schema_stats", "import_database_stats", "gather_index_stats", "gather_table_stats", "gather_schema_stats", "gather_database_stats", "generate_stats", "flush_database_monitoring_info", "alter_schema_tab_monitoring", "alter_database_tab_monitoring", "gather_system_stats", "get_system_stats", "set_system_stats", "delete_system_stats", "import_system_stats", "export_system_stats", "gather_fixed_objects_stats", "delete_fixed_objects_stats", "export_fixed_objects_stats", "import_fixed_objects_stats", "gather_dictionary_stats", "delete_dictionary_stats", "export_dictionary_stats", "import_dictionary_stats", "lock_table_stats", "lock_partition_stats", "lock_schema_stats", "unlock_table_stats", "unlock_partition_stats", "unlock_schema_stats", "restore_table_stats", "restore_schema_stats", "restore_database_stats", "restore_fixed_objects_stats", "restore_dictionary_stats", "restore_system_stats", "purge_stats", "alter_stats_history_retention", "copy_table_stats", "drop_extended_stats", "merge_col_usage", "seed_col_usage", "reset_col_usage", "gather_database_stats_job_proc", "cleanup_stats_job_proc"]))
32
- parser.functions.should eq(Set.new(["get_param", "get_prefs", "to_cascade_type", "to_estimate_percent_type", "to_degree_type", "to_no_invalidate_type", "to_publish_type", "get_stats_history_retention", "get_stats_history_availability", "diff_table_stats_in_stattab", "diff_table_stats_in_history", "diff_table_stats_in_pending", "create_extended_stats", "show_extended_stats_name", "report_col_usage"]))
70
+ parser = Vorax::Parser::Declare.new(text)
71
+ parser.items.include?(DeclareItem.new("numarray", :type, "varray", "type numarray is varray(256) of number;")).should be_true
72
+ parser.items.include?(DeclareItem.new("datearray", :type, "varray", "type datearray is varray(256) of date;")).should be_true
73
+ parser.items.include?(DeclareItem.new("chararray", :type, "varray", "type chararray is varray(256) of varchar2(4000);")).should be_true
74
+ parser.items.include?(DeclareItem.new("rawarray", :type, "varray", "type rawarray is varray(256) of raw(2000);")).should be_true
75
+ parser.items.include?(DeclareItem.new("fltarray", :type, "varray", "type fltarray is varray(256) of binary_float;")).should be_true
76
+ parser.items.include?(DeclareItem.new("dblarray", :type, "varray", "type dblarray is varray(256) of binary_double;")).should be_true
77
+ parser.items.include?(DeclareItem.new("StatRec", :type, "record", "type StatRec is record (\r\n epc number,\r\n minval raw(2000),\r\n maxval raw(2000),\r\n bkvals numarray,\r\n novals numarray,\r\n chvals chararray,\r\n eavs number);")).should be_true
78
+ parser.items.include?(DeclareItem.new("ObjectElem", :type, "record", "type ObjectElem is record (\r\n ownname varchar2(32), objtype varchar2(6), objname varchar2(32), partname varchar2(32), subpartname varchar2(32) );")).should be_true
79
+ parser.items.include?(DeclareItem.new("ObjectTab", :type, "table", "type ObjectTab is table of ObjectElem;")).should be_true
80
+ parser.items.include?(DeclareItem.new("DiffRepElem", :type, "record", "type DiffRepElem is record (\r\n report clob, maxdiffpct number);")).should be_true
81
+ parser.items.include?(DeclareItem.new("DiffRepTab", :type, "table", "type DiffRepTab is table of DiffRepElem;")).should be_true
82
+ parser.items.include?(DeclareItem.new("CContext", :type, "varray", "type CContext is varray(10) of varchar2(100);")).should be_true
83
+ parser.items.include?(DeclareItem.new("AUTO_CASCADE", :constant, "BOOLEAN", "AUTO_CASCADE CONSTANT BOOLEAN := null;")).should be_true
84
+ parser.items.include?(DeclareItem.new("AUTO_INVALIDATE", :constant, "BOOLEAN", "AUTO_INVALIDATE CONSTANT BOOLEAN := null;")).should be_true
85
+ parser.items.include?(DeclareItem.new("AUTO_SAMPLE_SIZE", :constant, "NUMBER", "AUTO_SAMPLE_SIZE CONSTANT NUMBER := 0;")).should be_true
86
+ parser.items.include?(DeclareItem.new("DEFAULT_DEGREE", :constant, "NUMBER", "DEFAULT_DEGREE CONSTANT NUMBER := 32767;")).should be_true
87
+ parser.items.include?(DeclareItem.new("AUTO_DEGREE", :constant, "NUMBER", "AUTO_DEGREE CONSTANT NUMBER := 32768;")).should be_true
88
+ parser.items.include?(DeclareItem.new("DEFAULT_CASCADE", :constant, "BOOLEAN", "DEFAULT_CASCADE CONSTANT BOOLEAN := null;")).should be_true
89
+ parser.items.include?(DeclareItem.new("DEFAULT_DEGREE_VALUE", :constant, "NUMBER", "DEFAULT_DEGREE_VALUE CONSTANT NUMBER := 32766;")).should be_true
90
+ parser.items.include?(DeclareItem.new("DEFAULT_ESTIMATE_PERCENT", :constant, "NUMBER", "DEFAULT_ESTIMATE_PERCENT CONSTANT NUMBER := 101;")).should be_true
91
+ parser.items.include?(DeclareItem.new("DEFAULT_METHOD_OPT", :constant, "VARCHAR2", "DEFAULT_METHOD_OPT CONSTANT VARCHAR2(1) := 'Z';")).should be_true
92
+ parser.items.include?(DeclareItem.new("DEFAULT_NO_INVALIDATE", :constant, "BOOLEAN", "DEFAULT_NO_INVALIDATE CONSTANT BOOLEAN := null;")).should be_true
93
+ parser.items.include?(DeclareItem.new("DEFAULT_GRANULARITY", :constant, "VARCHAR2", "DEFAULT_GRANULARITY CONSTANT VARCHAR2(1) := 'Z';")).should be_true
94
+ parser.items.include?(DeclareItem.new("DEFAULT_PUBLISH", :constant, "BOOLEAN", "DEFAULT_PUBLISH CONSTANT BOOLEAN := true;")).should be_true
95
+ parser.items.include?(DeclareItem.new("DEFAULT_INCREMENTAL", :constant, "BOOLEAN", "DEFAULT_INCREMENTAL CONSTANT BOOLEAN := false;")).should be_true
96
+ parser.items.include?(DeclareItem.new("DEFAULT_STALE_PERCENT", :constant, "NUMBER", "DEFAULT_STALE_PERCENT CONSTANT NUMBER := 10;")).should be_true
97
+ parser.items.include?(DeclareItem.new("DEFAULT_AUTOSTATS_TARGET", :constant, "VARCHAR2", "DEFAULT_AUTOSTATS_TARGET CONSTANT VARCHAR2(1) := 'Z';")).should be_true
98
+ parser.items.include?(DeclareItem.new("DEFAULT_STAT_CATEGORY", :constant, "VARCHAR2", "DEFAULT_STAT_CATEGORY CONSTANT VARCHAR2(20) := 'OBJECT_STATS';")).should be_true
99
+ parser.items.include?(DeclareItem.new("PURGE_ALL", :constant, "TIMESTAMP", "PURGE_ALL CONSTANT TIMESTAMP WITH TIME ZONE :=\r\n TO_TIMESTAMP_TZ('1001-01-0101:00:00-00:00','YYYY-MM-DDHH:MI:SSTZH:TZM');")).should be_true
100
+ parser.items.include?(DeclareItem.new("prepare_column_values", :procedure, nil, "procedure prepare_column_values(\r\n srec in out StatRec, charvals chararray);")).should be_true
101
+ parser.items.include?(DeclareItem.new("prepare_column_values", :procedure, nil, "procedure prepare_column_values(\r\n srec in out StatRec, datevals datearray);")).should be_true
102
+ parser.items.include?(DeclareItem.new("prepare_column_values", :procedure, nil, "procedure prepare_column_values(\r\n srec in out StatRec, numvals numarray);")).should be_true
103
+ parser.items.include?(DeclareItem.new("prepare_column_values", :procedure, nil, "procedure prepare_column_values(\r\n srec in out StatRec, fltvals fltarray);")).should be_true
104
+ parser.items.include?(DeclareItem.new("prepare_column_values", :procedure, nil, "procedure prepare_column_values(\r\n srec in out StatRec, dblvals dblarray);")).should be_true
105
+ parser.items.include?(DeclareItem.new("prepare_column_values", :procedure, nil, "procedure prepare_column_values(\r\n srec in out StatRec, rawvals rawarray);")).should be_true
106
+ parser.items.include?(DeclareItem.new("prepare_column_values_nvarchar", :procedure, nil, "procedure prepare_column_values_nvarchar(\r\n srec in out StatRec, nvmin nvarchar2, nvmax nvarchar2);")).should be_true
107
+ parser.items.include?(DeclareItem.new("prepare_column_values_rowid", :procedure, nil, "procedure prepare_column_values_rowid(\r\n srec in out StatRec, rwmin rowid, rwmax rowid);")).should be_true
108
+ parser.items.include?(DeclareItem.new("set_param", :procedure, nil, "procedure set_param(\r\n pname in varchar2,\r\n pval in varchar2);")).should be_true
109
+ parser.items.include?(DeclareItem.new("get_param", :function, nil, "function get_param(\r\n pname in varchar2)\r\n return varchar2;")).should be_true
110
+ parser.items.include?(DeclareItem.new("reset_param_defaults", :procedure, nil, "procedure reset_param_defaults;")).should be_true
111
+ parser.items.include?(DeclareItem.new("reset_global_pref_defaults", :procedure, nil, "procedure reset_global_pref_defaults;")).should be_true
112
+ parser.items.include?(DeclareItem.new("set_global_prefs", :procedure, nil, "procedure set_global_prefs(\r\n pname varchar2,\r\n pvalue varchar2);")).should be_true
113
+ parser.items.include?(DeclareItem.new("get_prefs", :function, nil, "function get_prefs(\r\n pname in varchar2,\r\n ownname in varchar2 default null,\r\n tabname in varchar2 default null)\r\n return varchar2;")).should be_true
114
+ parser.items.include?(DeclareItem.new("set_table_prefs", :procedure, nil, "procedure set_table_prefs(\r\n ownname varchar2,\r\n tabname varchar2,\r\n pname varchar2,\r\n pvalue varchar2);")).should be_true
115
+ parser.items.include?(DeclareItem.new("delete_table_prefs", :procedure, nil, "procedure delete_table_prefs(\r\n ownname varchar2,\r\n tabname varchar2,\r\n pname varchar2);")).should be_true
116
+ parser.items.include?(DeclareItem.new("export_table_prefs", :procedure, nil, "procedure export_table_prefs(\r\n ownname varchar2,\r\n tabname varchar2,\r\n stattab varchar2,\r\n statid varchar2 default null,\r\n statown varchar2 default null);")).should be_true
117
+ parser.items.include?(DeclareItem.new("import_table_prefs", :procedure, nil, "procedure import_table_prefs(\r\n ownname varchar2,\r\n tabname varchar2,\r\n stattab varchar2,\r\n statid varchar2 default null,\r\n statown varchar2 default null);")).should be_true
118
+ parser.items.include?(DeclareItem.new("set_schema_prefs", :procedure, nil, "procedure set_schema_prefs(\r\n ownname varchar2,\r\n pname varchar2,\r\n pvalue varchar2);")).should be_true
119
+ parser.items.include?(DeclareItem.new("delete_schema_prefs", :procedure, nil, "procedure delete_schema_prefs(\r\n ownname varchar2,\r\n pname varchar2);")).should be_true
120
+ parser.items.include?(DeclareItem.new("export_schema_prefs", :procedure, nil, "procedure export_schema_prefs(\r\n ownname varchar2,\r\n stattab varchar2,\r\n statid varchar2 default null,\r\n statown varchar2 default null);")).should be_true
121
+ parser.items.include?(DeclareItem.new("import_schema_prefs", :procedure, nil, "procedure import_schema_prefs(\r\n ownname varchar2,\r\n stattab varchar2,\r\n statid varchar2 default null,\r\n statown varchar2 default null);")).should be_true
122
+ parser.items.include?(DeclareItem.new("set_database_prefs", :procedure, nil, "procedure set_database_prefs(\r\n pname varchar2,\r\n pvalue varchar2,\r\n add_sys boolean default false);")).should be_true
123
+ parser.items.include?(DeclareItem.new("delete_database_prefs", :procedure, nil, "procedure delete_database_prefs(\r\n pname varchar2,\r\n add_sys boolean default false);")).should be_true
124
+ parser.items.include?(DeclareItem.new("export_database_prefs", :procedure, nil, "procedure export_database_prefs(\r\n stattab varchar2,\r\n statid varchar2 default null,\r\n statown varchar2 default null,\r\n add_sys boolean default false);")).should be_true
125
+ parser.items.include?(DeclareItem.new("import_database_prefs", :procedure, nil, "procedure import_database_prefs(\r\n stattab varchar2,\r\n statid varchar2 default null,\r\n statown varchar2 default null,\r\n add_sys boolean default false);")).should be_true
126
+ parser.items.include?(DeclareItem.new("to_cascade_type", :function, nil, "function to_cascade_type(cascade varchar2) return boolean;")).should be_true
127
+ parser.items.include?(DeclareItem.new("to_estimate_percent_type", :function, nil, "function to_estimate_percent_type(estimate_percent varchar2) return number;")).should be_true
128
+ parser.items.include?(DeclareItem.new("to_degree_type", :function, nil, "function to_degree_type(degree varchar2) return number;")).should be_true
129
+ parser.items.include?(DeclareItem.new("to_no_invalidate_type", :function, nil, "function to_no_invalidate_type(no_invalidate varchar2) return boolean;")).should be_true
130
+ parser.items.include?(DeclareItem.new("to_publish_type", :function, nil, "function to_publish_type(publish varchar2) return boolean;")).should be_true
131
+ parser.items.include?(DeclareItem.new("init_package", :procedure, nil, "procedure init_package;")).should be_true
132
+ parser.items.include?(DeclareItem.new("publish_pending_stats", :procedure, nil, "procedure publish_pending_stats(\r\n ownname varchar2 default USER,\r\n tabname varchar2,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n force boolean default FALSE);")).should be_true
133
+ parser.items.include?(DeclareItem.new("export_pending_stats", :procedure, nil, "procedure export_pending_stats(\r\n ownname varchar2 default USER,\r\n tabname varchar2,\r\n stattab varchar2,\r\n statid varchar2 default null,\r\n statown varchar2 default USER);")).should be_true
134
+ parser.items.include?(DeclareItem.new("delete_pending_stats", :procedure, nil, "procedure delete_pending_stats(\r\n ownname varchar2 default USER,\r\n tabname varchar2 default null);")).should be_true
135
+ parser.items.include?(DeclareItem.new("resume_gather_stats", :procedure, nil, "procedure resume_gather_stats;")).should be_true
136
+ parser.items.include?(DeclareItem.new("set_column_stats", :procedure, nil, "procedure set_column_stats(\r\n ownname varchar2, tabname varchar2, colname varchar2,\r\n partname varchar2 default null,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n distcnt number default null, density number default null,\r\n nullcnt number default null, srec StatRec default null,\r\n avgclen number default null, flags number default null,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n force boolean default FALSE);")).should be_true
137
+ parser.items.include?(DeclareItem.new("set_column_stats", :procedure, nil, "procedure set_column_stats(\r\n ownname varchar2, tabname varchar2, colname varchar2,\r\n partname varchar2 default null,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n ext_stats raw,\r\n stattypown varchar2 default null,\r\n stattypname varchar2 default null,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n force boolean default FALSE);")).should be_true
138
+ parser.items.include?(DeclareItem.new("set_index_stats", :procedure, nil, "procedure set_index_stats(\r\n ownname varchar2, indname varchar2,\r\n partname varchar2 default null,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n numrows number default null, numlblks number default null,\r\n numdist number default null, avglblk number default null,\r\n avgdblk number default null, clstfct number default null,\r\n indlevel number default null, flags number default null,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n guessq number default null,\r\n cachedblk number default null,\r\n cachehit number default null,\r\n force boolean default FALSE);")).should be_true
139
+ parser.items.include?(DeclareItem.new("set_index_stats", :procedure, nil, "procedure set_index_stats(\r\n ownname varchar2, indname varchar2,\r\n partname varchar2 default null,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n ext_stats raw,\r\n stattypown varchar2 default null,\r\n stattypname varchar2 default null,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n force boolean default FALSE);")).should be_true
140
+ parser.items.include?(DeclareItem.new("set_table_stats", :procedure, nil, "procedure set_table_stats(\r\n ownname varchar2,\r\n tabname varchar2,\r\n partname varchar2 default null,\r\n stattab varchar2 default null,\r\n statid varchar2 default null,\r\n numrows number default null,\r\n numblks number default null,\r\n avgrlen number default null,\r\n flags number default null,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n cachedblk number default null,\r\n cachehit number default null,\r\n force boolean default FALSE);")).should be_true
141
+ parser.items.include?(DeclareItem.new("convert_raw_value", :procedure, nil, "procedure convert_raw_value(\r\n rawval raw, resval out varchar2);")).should be_true
142
+ parser.items.include?(DeclareItem.new("convert_raw_value", :procedure, nil, "procedure convert_raw_value(\r\n rawval raw, resval out date);")).should be_true
143
+ parser.items.include?(DeclareItem.new("convert_raw_value", :procedure, nil, "procedure convert_raw_value(\r\n rawval raw, resval out number);")).should be_true
144
+ parser.items.include?(DeclareItem.new("convert_raw_value", :procedure, nil, "procedure convert_raw_value(\r\n rawval raw, resval out binary_float);")).should be_true
145
+ parser.items.include?(DeclareItem.new("convert_raw_value", :procedure, nil, "procedure convert_raw_value(\r\n rawval raw, resval out binary_double);")).should be_true
146
+ parser.items.include?(DeclareItem.new("convert_raw_value_nvarchar", :procedure, nil, "procedure convert_raw_value_nvarchar(\r\n rawval raw, resval out nvarchar2);")).should be_true
147
+ parser.items.include?(DeclareItem.new("convert_raw_value_rowid", :procedure, nil, "procedure convert_raw_value_rowid(\r\n rawval raw, resval out rowid);")).should be_true
148
+ parser.items.include?(DeclareItem.new("get_column_stats", :procedure, nil, "procedure get_column_stats(\r\n ownname varchar2, tabname varchar2, colname varchar2,\r\n partname varchar2 default null,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n distcnt out number, density out number,\r\n nullcnt out number, srec out StatRec,\r\n avgclen out number,\r\n statown varchar2 default null);")).should be_true
149
+ parser.items.include?(DeclareItem.new("get_column_stats", :procedure, nil, "procedure get_column_stats(\r\n ownname varchar2, tabname varchar2, colname varchar2,\r\n partname varchar2 default null,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n ext_stats out raw,\r\n stattypown out varchar2, stattypname out varchar2,\r\n statown varchar2 default null);")).should be_true
150
+ parser.items.include?(DeclareItem.new("get_index_stats", :procedure, nil, "procedure get_index_stats(\r\n ownname varchar2, indname varchar2,\r\n partname varchar2 default null,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n numrows out number, numlblks out number,\r\n numdist out number, avglblk out number,\r\n avgdblk out number, clstfct out number,\r\n indlevel out number,\r\n statown varchar2 default null,\r\n guessq out number,\r\n cachedblk out number,\r\n cachehit out number);")).should be_true
151
+ parser.items.include?(DeclareItem.new("get_index_stats", :procedure, nil, "procedure get_index_stats(\r\n ownname varchar2, indname varchar2,\r\n partname varchar2 default null,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n numrows out number, numlblks out number,\r\n numdist out number, avglblk out number,\r\n avgdblk out number, clstfct out number,\r\n indlevel out number,\r\n statown varchar2 default null,\r\n guessq out number);")).should be_true
152
+ parser.items.include?(DeclareItem.new("get_index_stats", :procedure, nil, "procedure get_index_stats(\r\n ownname varchar2, indname varchar2,\r\n partname varchar2 default null,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n numrows out number, numlblks out number,\r\n numdist out number, avglblk out number,\r\n avgdblk out number, clstfct out number,\r\n indlevel out number,\r\n statown varchar2 default null);")).should be_true
153
+ parser.items.include?(DeclareItem.new("get_index_stats", :procedure, nil, "procedure get_index_stats(\r\n ownname varchar2, indname varchar2,\r\n partname varchar2 default null,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n ext_stats out raw,\r\n stattypown out varchar2, stattypname out varchar2,\r\n statown varchar2 default null);")).should be_true
154
+ parser.items.include?(DeclareItem.new("get_table_stats", :procedure, nil, "procedure get_table_stats(\r\n ownname varchar2, tabname varchar2,\r\n partname varchar2 default null,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n numrows out number, numblks out number,\r\n avgrlen out number,\r\n statown varchar2 default null);")).should be_true
155
+ parser.items.include?(DeclareItem.new("get_table_stats", :procedure, nil, "procedure get_table_stats(\r\n ownname varchar2,\r\n tabname varchar2,\r\n partname varchar2 default null,\r\n stattab varchar2 default null,\r\n statid varchar2 default null,\r\n numrows out number,\r\n numblks out number,\r\n avgrlen out number,\r\n statown varchar2 default null,\r\n cachedblk out number,\r\n cachehit out number);")).should be_true
156
+ parser.items.include?(DeclareItem.new("delete_column_stats", :procedure, nil, "procedure delete_column_stats(\r\n ownname varchar2, tabname varchar2, colname varchar2,\r\n partname varchar2 default null,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n cascade_parts boolean default true,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n force boolean default FALSE,\r\n col_stat_type varchar2 default 'ALL');")).should be_true
157
+ parser.items.include?(DeclareItem.new("delete_index_stats", :procedure, nil, "procedure delete_index_stats(\r\n ownname varchar2, indname varchar2,\r\n partname varchar2 default null,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n cascade_parts boolean default true,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n stattype varchar2 default 'ALL',\r\n force boolean default FALSE);")).should be_true
158
+ parser.items.include?(DeclareItem.new("delete_table_stats", :procedure, nil, "procedure delete_table_stats(\r\n ownname varchar2, tabname varchar2,\r\n partname varchar2 default null,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n cascade_parts boolean default true,\r\n cascade_columns boolean default true,\r\n cascade_indexes boolean default true,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n stattype varchar2 default 'ALL',\r\n force boolean default FALSE);")).should be_true
159
+ parser.items.include?(DeclareItem.new("delete_schema_stats", :procedure, nil, "procedure delete_schema_stats(\r\n ownname varchar2,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n stattype varchar2 default 'ALL',\r\n force boolean default FALSE);")).should be_true
160
+ parser.items.include?(DeclareItem.new("delete_database_stats", :procedure, nil, "procedure delete_database_stats(\r\n stattab varchar2 default null, statid varchar2 default null,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n stattype varchar2 default 'ALL',\r\n force boolean default FALSE);")).should be_true
161
+ parser.items.include?(DeclareItem.new("create_stat_table", :procedure, nil, "procedure create_stat_table(\r\n ownname varchar2, stattab varchar2,\r\n tblspace varchar2 default null,\r\n global_temporary boolean default false);")).should be_true
162
+ parser.items.include?(DeclareItem.new("drop_stat_table", :procedure, nil, "procedure drop_stat_table(\r\n ownname varchar2, stattab varchar2);")).should be_true
163
+ parser.items.include?(DeclareItem.new("upgrade_stat_table", :procedure, nil, "procedure upgrade_stat_table(\r\n ownname varchar2, stattab varchar2);")).should be_true
164
+ parser.items.include?(DeclareItem.new("export_column_stats", :procedure, nil, "procedure export_column_stats(\r\n ownname varchar2, tabname varchar2, colname varchar2,\r\n partname varchar2 default null,\r\n stattab varchar2, statid varchar2 default null,\r\n statown varchar2 default null);")).should be_true
165
+ parser.items.include?(DeclareItem.new("export_index_stats", :procedure, nil, "procedure export_index_stats(\r\n ownname varchar2, indname varchar2,\r\n partname varchar2 default null,\r\n stattab varchar2, statid varchar2 default null,\r\n statown varchar2 default null);")).should be_true
166
+ parser.items.include?(DeclareItem.new("export_table_stats", :procedure, nil, "procedure export_table_stats(\r\n ownname varchar2, tabname varchar2,\r\n partname varchar2 default null,\r\n stattab varchar2, statid varchar2 default null,\r\n cascade boolean default true,\r\n statown varchar2 default null,\r\n stat_category varchar2 default DEFAULT_STAT_CATEGORY\r\n);")).should be_true
167
+ parser.items.include?(DeclareItem.new("export_schema_stats", :procedure, nil, "procedure export_schema_stats(\r\n ownname varchar2,\r\n stattab varchar2, statid varchar2 default null,\r\n statown varchar2 default null,\r\n stat_category varchar2 default DEFAULT_STAT_CATEGORY);")).should be_true
168
+ parser.items.include?(DeclareItem.new("export_database_stats", :procedure, nil, "procedure export_database_stats(\r\n stattab varchar2, statid varchar2 default null,\r\n statown varchar2 default null,\r\n stat_category varchar2 default DEFAULT_STAT_CATEGORY);")).should be_true
169
+ parser.items.include?(DeclareItem.new("import_column_stats", :procedure, nil, "procedure import_column_stats(\r\n ownname varchar2, tabname varchar2, colname varchar2,\r\n partname varchar2 default null,\r\n stattab varchar2, statid varchar2 default null,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n force boolean default FALSE);")).should be_true
170
+ parser.items.include?(DeclareItem.new("import_index_stats", :procedure, nil, "procedure import_index_stats(\r\n ownname varchar2, indname varchar2,\r\n partname varchar2 default null,\r\n stattab varchar2, statid varchar2 default null,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n force boolean default FALSE);")).should be_true
171
+ parser.items.include?(DeclareItem.new("import_table_stats", :procedure, nil, "procedure import_table_stats(\r\n ownname varchar2, tabname varchar2,\r\n partname varchar2 default null,\r\n stattab varchar2, statid varchar2 default null,\r\n cascade boolean default true,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n force boolean default FALSE,\r\n stat_category varchar2 default DEFAULT_STAT_CATEGORY);")).should be_true
172
+ parser.items.include?(DeclareItem.new("import_schema_stats", :procedure, nil, "procedure import_schema_stats(\r\n ownname varchar2,\r\n stattab varchar2, statid varchar2 default null,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n force boolean default FALSE,\r\n stat_category varchar2 default DEFAULT_STAT_CATEGORY);")).should be_true
173
+ parser.items.include?(DeclareItem.new("import_database_stats", :procedure, nil, "procedure import_database_stats(\r\n stattab varchar2, statid varchar2 default null,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n force boolean default FALSE,\r\n stat_category varchar2 default DEFAULT_STAT_CATEGORY\r\n );")).should be_true
174
+ parser.items.include?(DeclareItem.new("gather_index_stats", :procedure, nil, "procedure gather_index_stats\r\n (ownname varchar2, indname varchar2, partname varchar2 default null,\r\n estimate_percent number default DEFAULT_ESTIMATE_PERCENT,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n statown varchar2 default null,\r\n degree number default to_degree_type(get_param('DEGREE')),\r\n granularity varchar2 default DEFAULT_GRANULARITY,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n stattype varchar2 default 'DATA',\r\n force boolean default FALSE);")).should be_true
175
+ parser.items.include?(DeclareItem.new("gather_table_stats", :procedure, nil, "procedure gather_table_stats\r\n (ownname varchar2, tabname varchar2, partname varchar2 default null,\r\n estimate_percent number default DEFAULT_ESTIMATE_PERCENT,\r\n block_sample boolean default FALSE,\r\n method_opt varchar2 default DEFAULT_METHOD_OPT,\r\n degree number default to_degree_type(get_param('DEGREE')),\r\n granularity varchar2 default DEFAULT_GRANULARITY,\r\n cascade boolean default DEFAULT_CASCADE,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n stattype varchar2 default 'DATA',\r\n force boolean default FALSE,\r\n context dbms_stats.CContext default null);")).should be_true
176
+ parser.items.include?(DeclareItem.new("gather_schema_stats", :procedure, nil, "procedure gather_schema_stats\r\n (ownname varchar2,\r\n estimate_percent number default DEFAULT_ESTIMATE_PERCENT,\r\n block_sample boolean default FALSE,\r\n method_opt varchar2 default DEFAULT_METHOD_OPT,\r\n degree number default to_degree_type(get_param('DEGREE')),\r\n granularity varchar2 default DEFAULT_GRANULARITY,\r\n cascade boolean default DEFAULT_CASCADE,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n options varchar2 default 'GATHER', objlist out ObjectTab,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n gather_temp boolean default FALSE,\r\n gather_fixed boolean default FALSE,\r\n stattype varchar2 default 'DATA',\r\n force boolean default FALSE,\r\n obj_filter_list ObjectTab default null);")).should be_true
177
+ parser.items.include?(DeclareItem.new("gather_schema_stats", :procedure, nil, "procedure gather_schema_stats\r\n (ownname varchar2,\r\n estimate_percent number default DEFAULT_ESTIMATE_PERCENT,\r\n block_sample boolean default FALSE,\r\n method_opt varchar2 default DEFAULT_METHOD_OPT,\r\n degree number default to_degree_type(get_param('DEGREE')),\r\n granularity varchar2 default DEFAULT_GRANULARITY,\r\n cascade boolean default DEFAULT_CASCADE,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n options varchar2 default 'GATHER', statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n gather_temp boolean default FALSE,\r\n gather_fixed boolean default FALSE,\r\n stattype varchar2 default 'DATA',\r\n force boolean default FALSE,\r\n obj_filter_list ObjectTab default null);")).should be_true
178
+ parser.items.include?(DeclareItem.new("gather_database_stats", :procedure, nil, "procedure gather_database_stats\r\n (estimate_percent number default DEFAULT_ESTIMATE_PERCENT,\r\n block_sample boolean default FALSE,\r\n method_opt varchar2 default DEFAULT_METHOD_OPT,\r\n degree number default to_degree_type(get_param('DEGREE')),\r\n granularity varchar2 default DEFAULT_GRANULARITY,\r\n cascade boolean default DEFAULT_CASCADE,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n options varchar2 default 'GATHER', objlist out ObjectTab,\r\n statown varchar2 default null,\r\n gather_sys boolean default TRUE,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n gather_temp boolean default FALSE,\r\n gather_fixed boolean default FALSE,\r\n stattype varchar2 default 'DATA',\r\n obj_filter_list ObjectTab default null);")).should be_true
179
+ parser.items.include?(DeclareItem.new("gather_database_stats", :procedure, nil, "procedure gather_database_stats\r\n (estimate_percent number default DEFAULT_ESTIMATE_PERCENT,\r\n block_sample boolean default FALSE,\r\n method_opt varchar2 default DEFAULT_METHOD_OPT,\r\n degree number default to_degree_type(get_param('DEGREE')),\r\n granularity varchar2 default DEFAULT_GRANULARITY,\r\n cascade boolean default DEFAULT_CASCADE,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n options varchar2 default 'GATHER', statown varchar2 default null,\r\n gather_sys boolean default TRUE,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n gather_temp boolean default FALSE,\r\n gather_fixed boolean default FALSE,\r\n stattype varchar2 default 'DATA',\r\n obj_filter_list ObjectTab default null);")).should be_true
180
+ parser.items.include?(DeclareItem.new("generate_stats", :procedure, nil, "procedure generate_stats\r\n (ownname varchar2, objname varchar2,\r\n organized number default 7,\r\n force boolean default FALSE);")).should be_true
181
+ parser.items.include?(DeclareItem.new("flush_database_monitoring_info", :procedure, nil, "procedure flush_database_monitoring_info;")).should be_true
182
+ parser.items.include?(DeclareItem.new("alter_schema_tab_monitoring", :procedure, nil, "procedure alter_schema_tab_monitoring\r\n (ownname varchar2 default NULL, monitoring boolean default TRUE);")).should be_true
183
+ parser.items.include?(DeclareItem.new("alter_database_tab_monitoring", :procedure, nil, "procedure alter_database_tab_monitoring\r\n (monitoring boolean default TRUE, sysobjs boolean default FALSE);")).should be_true
184
+ parser.items.include?(DeclareItem.new("gather_system_stats", :procedure, nil, "procedure gather_system_stats (\r\n gathering_mode varchar2 default 'NOWORKLOAD',\r\n interval integer default 60,\r\n stattab varchar2 default null,\r\n statid varchar2 default null,\r\n statown varchar2 default null);")).should be_true
185
+ parser.items.include?(DeclareItem.new("get_system_stats", :procedure, nil, "procedure get_system_stats (\r\n status out varchar2,\r\n dstart out date,\r\n dstop out date,\r\n pname varchar2,\r\n pvalue out number,\r\n stattab varchar2 default null,\r\n statid varchar2 default null,\r\n statown varchar2 default null);")).should be_true
186
+ parser.items.include?(DeclareItem.new("set_system_stats", :procedure, nil, "procedure set_system_stats (\r\n pname varchar2,\r\n pvalue number,\r\n stattab varchar2 default null,\r\n statid varchar2 default null,\r\n statown varchar2 default null);")).should be_true
187
+ parser.items.include?(DeclareItem.new("delete_system_stats", :procedure, nil, "procedure delete_system_stats (\r\n stattab varchar2 default nulL,\r\n statid varchar2 default nulL,\r\n statown varchar2 default null);")).should be_true
188
+ parser.items.include?(DeclareItem.new("import_system_stats", :procedure, nil, "procedure import_system_stats (\r\n stattab varchar2,\r\n statid varchar2 default null,\r\n statown varchar2 default null);")).should be_true
189
+ parser.items.include?(DeclareItem.new("export_system_stats", :procedure, nil, "procedure export_system_stats (\r\n stattab varchar2,\r\n statid varchar2 default null,\r\n statown varchar2 default null);")).should be_true
190
+ parser.items.include?(DeclareItem.new("gather_fixed_objects_stats", :procedure, nil, "procedure gather_fixed_objects_stats\r\n (stattab varchar2 default null, statid varchar2 default null,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')));")).should be_true
191
+ parser.items.include?(DeclareItem.new("delete_fixed_objects_stats", :procedure, nil, "procedure delete_fixed_objects_stats(\r\n stattab varchar2 default null, statid varchar2 default null,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n force boolean default FALSE);")).should be_true
192
+ parser.items.include?(DeclareItem.new("export_fixed_objects_stats", :procedure, nil, "procedure export_fixed_objects_stats(\r\n stattab varchar2, statid varchar2 default null,\r\n statown varchar2 default null);")).should be_true
193
+ parser.items.include?(DeclareItem.new("import_fixed_objects_stats", :procedure, nil, "procedure import_fixed_objects_stats(\r\n stattab varchar2, statid varchar2 default null,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n force boolean default FALSE);")).should be_true
194
+ parser.items.include?(DeclareItem.new("gather_dictionary_stats", :procedure, nil, "procedure gather_dictionary_stats\r\n (comp_id varchar2 default null,\r\n estimate_percent number default DEFAULT_ESTIMATE_PERCENT,\r\n block_sample boolean default FALSE,\r\n method_opt varchar2 default DEFAULT_METHOD_OPT,\r\n degree number default to_degree_type(get_param('DEGREE')),\r\n granularity varchar2 default DEFAULT_GRANULARITY,\r\n cascade boolean default DEFAULT_CASCADE,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n options varchar2 default 'GATHER AUTO', objlist out ObjectTab,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n stattype varchar2 default 'DATA',\r\n obj_filter_list ObjectTab default null);")).should be_true
195
+ parser.items.include?(DeclareItem.new("gather_dictionary_stats", :procedure, nil, "procedure gather_dictionary_stats\r\n (comp_id varchar2 default null,\r\n estimate_percent number default DEFAULT_ESTIMATE_PERCENT,\r\n block_sample boolean default FALSE,\r\n method_opt varchar2 default DEFAULT_METHOD_OPT,\r\n degree number default to_degree_type(get_param('DEGREE')),\r\n granularity varchar2 default DEFAULT_GRANULARITY,\r\n cascade boolean default DEFAULT_CASCADE,\r\n stattab varchar2 default null, statid varchar2 default null,\r\n options varchar2 default 'GATHER AUTO', statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n stattype varchar2 default 'DATA',\r\n obj_filter_list ObjectTab default null);")).should be_true
196
+ parser.items.include?(DeclareItem.new("delete_dictionary_stats", :procedure, nil, "procedure delete_dictionary_stats(\r\n stattab varchar2 default null, statid varchar2 default null,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n stattype varchar2 default 'ALL',\r\n force boolean default FALSE);")).should be_true
197
+ parser.items.include?(DeclareItem.new("export_dictionary_stats", :procedure, nil, "procedure export_dictionary_stats(\r\n stattab varchar2, statid varchar2 default null,\r\n statown varchar2 default null,\r\n stat_category varchar2 default DEFAULT_STAT_CATEGORY);")).should be_true
198
+ parser.items.include?(DeclareItem.new("import_dictionary_stats", :procedure, nil, "procedure import_dictionary_stats(\r\n stattab varchar2, statid varchar2 default null,\r\n statown varchar2 default null,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')),\r\n force boolean default FALSE,\r\n stat_category varchar2 default DEFAULT_STAT_CATEGORY);")).should be_true
199
+ parser.items.include?(DeclareItem.new("lock_table_stats", :procedure, nil, "procedure lock_table_stats(\r\n ownname varchar2,\r\n tabname varchar2,\r\n stattype varchar2 default 'ALL');")).should be_true
200
+ parser.items.include?(DeclareItem.new("lock_partition_stats", :procedure, nil, "procedure lock_partition_stats(\r\n ownname varchar2,\r\n tabname varchar2,\r\n partname varchar2);")).should be_true
201
+ parser.items.include?(DeclareItem.new("lock_schema_stats", :procedure, nil, "procedure lock_schema_stats(\r\n ownname varchar2,\r\n stattype varchar2 default 'ALL');")).should be_true
202
+ parser.items.include?(DeclareItem.new("unlock_table_stats", :procedure, nil, "procedure unlock_table_stats(\r\n ownname varchar2,\r\n tabname varchar2,\r\n stattype varchar2 default 'ALL');")).should be_true
203
+ parser.items.include?(DeclareItem.new("unlock_partition_stats", :procedure, nil, "procedure unlock_partition_stats(\r\n ownname varchar2,\r\n tabname varchar2,\r\n partname varchar2);")).should be_true
204
+ parser.items.include?(DeclareItem.new("unlock_schema_stats", :procedure, nil, "procedure unlock_schema_stats(\r\n ownname varchar2,\r\n stattype varchar2 default 'ALL');")).should be_true
205
+ parser.items.include?(DeclareItem.new("restore_table_stats", :procedure, nil, "procedure restore_table_stats(\r\n ownname varchar2,\r\n tabname varchar2,\r\n as_of_timestamp timestamp with time zone,\r\n restore_cluster_index boolean default FALSE,\r\n force boolean default FALSE,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')));")).should be_true
206
+ parser.items.include?(DeclareItem.new("restore_schema_stats", :procedure, nil, "procedure restore_schema_stats(\r\n ownname varchar2,\r\n as_of_timestamp timestamp with time zone,\r\n force boolean default FALSE,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')));")).should be_true
207
+ parser.items.include?(DeclareItem.new("restore_database_stats", :procedure, nil, "procedure restore_database_stats(\r\n as_of_timestamp timestamp with time zone,\r\n force boolean default FALSE,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')));")).should be_true
208
+ parser.items.include?(DeclareItem.new("restore_fixed_objects_stats", :procedure, nil, "procedure restore_fixed_objects_stats(\r\n as_of_timestamp timestamp with time zone,\r\n force boolean default FALSE,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')));")).should be_true
209
+ parser.items.include?(DeclareItem.new("restore_dictionary_stats", :procedure, nil, "procedure restore_dictionary_stats(\r\n as_of_timestamp timestamp with time zone,\r\n force boolean default FALSE,\r\n no_invalidate boolean default\r\n to_no_invalidate_type(get_param('NO_INVALIDATE')));")).should be_true
210
+ parser.items.include?(DeclareItem.new("restore_system_stats", :procedure, nil, "procedure restore_system_stats(\r\n as_of_timestamp timestamp with time zone);")).should be_true
211
+ parser.items.include?(DeclareItem.new("purge_stats", :procedure, nil, "procedure purge_stats(\r\n before_timestamp timestamp with time zone);")).should be_true
212
+ parser.items.include?(DeclareItem.new("alter_stats_history_retention", :procedure, nil, "procedure alter_stats_history_retention(\r\n retention in number);")).should be_true
213
+ parser.items.include?(DeclareItem.new("get_stats_history_retention", :function, nil, "function get_stats_history_retention return number;")).should be_true
214
+ parser.items.include?(DeclareItem.new("get_stats_history_availability", :function, nil, "function get_stats_history_availability\r\n return timestamp with time zone;")).should be_true
215
+ parser.items.include?(DeclareItem.new("copy_table_stats", :procedure, nil, "procedure copy_table_stats(\r\n ownname varchar2,\r\n tabname varchar2,\r\n srcpartname varchar2,\r\n dstpartname varchar2,\r\n scale_factor number DEFAULT 1,\r\n flags number DEFAULT null,\r\n force boolean DEFAULT FALSE);")).should be_true
216
+ parser.items.include?(DeclareItem.new("diff_table_stats_in_stattab", :function, nil, "function diff_table_stats_in_stattab(\r\n ownname varchar2,\r\n tabname varchar2,\r\n stattab1 varchar2,\r\n stattab2 varchar2 default null,\r\n pctthreshold number default 10,\r\n statid1 varchar2 default null,\r\n statid2 varchar2 default null,\r\n stattab1own varchar2 default null,\r\n stattab2own varchar2 default null)\r\n return DiffRepTab pipelined;")).should be_true
217
+ parser.items.include?(DeclareItem.new("diff_table_stats_in_history", :function, nil, "function diff_table_stats_in_history(\r\n ownname varchar2,\r\n tabname varchar2,\r\n time1 timestamp with time zone,\r\n time2 timestamp with time zone default null,\r\n pctthreshold number default 10)\r\n return DiffRepTab pipelined;")).should be_true
218
+ parser.items.include?(DeclareItem.new("diff_table_stats_in_pending", :function, nil, "function diff_table_stats_in_pending(\r\n ownname varchar2,\r\n tabname varchar2,\r\n time_stamp timestamp with time zone default null,\r\n pctthreshold number default 10)\r\n return DiffRepTab pipelined;")).should be_true
219
+ parser.items.include?(DeclareItem.new("create_extended_stats", :function, nil, "function create_extended_stats(\r\n ownname varchar2,\r\n tabname varchar2,\r\n extension varchar2)\r\n return varchar2;")).should be_true
220
+ parser.items.include?(DeclareItem.new("create_extended_stats", :function, nil, "function create_extended_stats(\r\n ownname varchar2,\r\n tabname varchar2)\r\n return clob;")).should be_true
221
+ parser.items.include?(DeclareItem.new("show_extended_stats_name", :function, nil, "function show_extended_stats_name(\r\n ownname varchar2,\r\n tabname varchar2,\r\n extension varchar2)\r\n return varchar2;")).should be_true
222
+ parser.items.include?(DeclareItem.new("drop_extended_stats", :procedure, nil, "procedure drop_extended_stats(\r\n ownname varchar2,\r\n tabname varchar2,\r\n extension varchar2);")).should be_true
223
+ parser.items.include?(DeclareItem.new("merge_col_usage", :procedure, nil, "procedure merge_col_usage(\r\n dblink varchar2);")).should be_true
224
+ parser.items.include?(DeclareItem.new("seed_col_usage", :procedure, nil, "procedure seed_col_usage(\r\n sqlset_name IN VARCHAR2,\r\n owner_name IN VARCHAR2,\r\n time_limit IN POSITIVE DEFAULT NULL);")).should be_true
225
+ parser.items.include?(DeclareItem.new("reset_col_usage", :procedure, nil, "procedure reset_col_usage(\r\n ownname varchar2,\r\n tabname varchar2);")).should be_true
226
+ parser.items.include?(DeclareItem.new("report_col_usage", :function, nil, "function report_col_usage(\r\n ownname varchar2,\r\n tabname varchar2) return clob;")).should be_true
227
+ parser.items.include?(DeclareItem.new("gather_database_stats_job_proc", :procedure, nil, "procedure gather_database_stats_job_proc;")).should be_true
228
+ parser.items.include?(DeclareItem.new("cleanup_stats_job_proc", :procedure, nil, "procedure cleanup_stats_job_proc(\r\n ctx number, job_owner varchar2, job_name varchar2,\r\n sesid number, sesser number);")).should be_true
33
229
  end
34
230
 
35
231
  it 'should work with a SYS package spec' do
36
232
  text = File.open('spec/sql/dbms_crypto.spc', 'rb') { |file| file.read }
37
- parser = Vorax::Parser::Declare.new
38
- parser.walk(text)
39
- parser.constants.should eq(Set.new(["HASH_MD4", "HASH_MD5", "HASH_SH1", "HMAC_MD5", "HMAC_SH1", "ENCRYPT_DES", "ENCRYPT_3DES_2KEY", "ENCRYPT_3DES", "ENCRYPT_AES", "ENCRYPT_PBE_MD5DES", "ENCRYPT_AES128", "ENCRYPT_AES192", "ENCRYPT_AES256", "CHAIN_CBC", "CHAIN_CFB", "CHAIN_ECB", "CHAIN_OFB", "PAD_PKCS5", "PAD_NONE", "PAD_ZERO", "PAD_ORCL", "ENCRYPT_RC4", "DES_CBC_PKCS5", "DES3_CBC_PKCS5", "AES_CBC_PKCS5"]))
40
- parser.exceptions.should eq(Set.new(["CipherSuiteInvalid", "CipherSuiteNull", "KeyNull", "KeyBadSize", "DoubleEncryption"]))
41
- parser.cursors.should eq(Set.new([]))
42
- parser.types.should eq(Set.new([]))
43
- parser.variables.should eq(Set.new([]))
44
- parser.procedures.should eq(Set.new(["Encrypt", "Decrypt"]))
45
- parser.functions.should eq(Set.new(["Encrypt", "Decrypt", "Hash", "Mac", "RandomBytes", "RandomNumber", "RandomInteger"]))
233
+ parser = Vorax::Parser::Declare.new(text)
234
+ DeclareItem.new("HASH_MD4", :constant, "PLS_INTEGER", "HASH_MD4 CONSTANT PLS_INTEGER := 1;")
235
+ DeclareItem.new("HASH_MD5", :constant, "PLS_INTEGER", "HASH_MD5 CONSTANT PLS_INTEGER := 2;")
236
+ DeclareItem.new("HASH_SH1", :constant, "PLS_INTEGER", "HASH_SH1 CONSTANT PLS_INTEGER := 3;")
237
+ DeclareItem.new("HMAC_MD5", :constant, "PLS_INTEGER", "HMAC_MD5 CONSTANT PLS_INTEGER := 1;")
238
+ DeclareItem.new("HMAC_SH1", :constant, "PLS_INTEGER", "HMAC_SH1 CONSTANT PLS_INTEGER := 2;")
239
+ DeclareItem.new("ENCRYPT_DES", :constant, "PLS_INTEGER", "ENCRYPT_DES CONSTANT PLS_INTEGER := 1;")
240
+ DeclareItem.new("ENCRYPT_3DES_2KEY", :constant, "PLS_INTEGER", "ENCRYPT_3DES_2KEY CONSTANT PLS_INTEGER := 2;")
241
+ DeclareItem.new("ENCRYPT_3DES", :constant, "PLS_INTEGER", "ENCRYPT_3DES CONSTANT PLS_INTEGER := 3;")
242
+ DeclareItem.new("ENCRYPT_AES", :constant, "PLS_INTEGER", "ENCRYPT_AES CONSTANT PLS_INTEGER := 4;")
243
+ DeclareItem.new("ENCRYPT_PBE_MD5DES", :constant, "PLS_INTEGER", "ENCRYPT_PBE_MD5DES CONSTANT PLS_INTEGER := 5;")
244
+ DeclareItem.new("ENCRYPT_AES128", :constant, "PLS_INTEGER", "ENCRYPT_AES128 CONSTANT PLS_INTEGER := 6;")
245
+ DeclareItem.new("ENCRYPT_AES192", :constant, "PLS_INTEGER", "ENCRYPT_AES192 CONSTANT PLS_INTEGER := 7;")
246
+ DeclareItem.new("ENCRYPT_AES256", :constant, "PLS_INTEGER", "ENCRYPT_AES256 CONSTANT PLS_INTEGER := 8;")
247
+ DeclareItem.new("CHAIN_CBC", :constant, "PLS_INTEGER", "CHAIN_CBC CONSTANT PLS_INTEGER := 256;")
248
+ DeclareItem.new("CHAIN_CFB", :constant, "PLS_INTEGER", "CHAIN_CFB CONSTANT PLS_INTEGER := 512;")
249
+ DeclareItem.new("CHAIN_ECB", :constant, "PLS_INTEGER", "CHAIN_ECB CONSTANT PLS_INTEGER := 768;")
250
+ DeclareItem.new("CHAIN_OFB", :constant, "PLS_INTEGER", "CHAIN_OFB CONSTANT PLS_INTEGER := 1024;")
251
+ DeclareItem.new("PAD_PKCS5", :constant, "PLS_INTEGER", "PAD_PKCS5 CONSTANT PLS_INTEGER := 4096;")
252
+ DeclareItem.new("PAD_NONE", :constant, "PLS_INTEGER", "PAD_NONE CONSTANT PLS_INTEGER := 8192;")
253
+ DeclareItem.new("PAD_ZERO", :constant, "PLS_INTEGER", "PAD_ZERO CONSTANT PLS_INTEGER := 12288;")
254
+ DeclareItem.new("PAD_ORCL", :constant, "PLS_INTEGER", "PAD_ORCL CONSTANT PLS_INTEGER := 16384;")
255
+ DeclareItem.new("ENCRYPT_RC4", :constant, "PLS_INTEGER", "ENCRYPT_RC4 CONSTANT PLS_INTEGER := 129;")
256
+ DeclareItem.new("DES_CBC_PKCS5", :constant, "PLS_INTEGER", "DES_CBC_PKCS5 CONSTANT PLS_INTEGER := ENCRYPT_DES\r\n + CHAIN_CBC\r\n + PAD_PKCS5;")
257
+ DeclareItem.new("DES3_CBC_PKCS5", :constant, "PLS_INTEGER", "DES3_CBC_PKCS5 CONSTANT PLS_INTEGER := ENCRYPT_3DES\r\n + CHAIN_CBC\r\n + PAD_PKCS5;")
258
+ DeclareItem.new("AES_CBC_PKCS5", :constant, "PLS_INTEGER", "AES_CBC_PKCS5 CONSTANT PLS_INTEGER := ENCRYPT_AES\r\n + CHAIN_CBC\r\n + PAD_PKCS5;")
259
+ DeclareItem.new("CipherSuiteInvalid", :exception, "EXCEPTION", "CipherSuiteInvalid EXCEPTION;")
260
+ DeclareItem.new("CipherSuiteNull", :exception, "EXCEPTION", "CipherSuiteNull EXCEPTION;")
261
+ DeclareItem.new("KeyNull", :exception, "EXCEPTION", "KeyNull EXCEPTION;")
262
+ DeclareItem.new("KeyBadSize", :exception, "EXCEPTION", "KeyBadSize EXCEPTION;")
263
+ DeclareItem.new("DoubleEncryption", :exception, "EXCEPTION", "DoubleEncryption EXCEPTION;")
264
+ DeclareItem.new("Encrypt", :function, nil, "FUNCTION Encrypt (src IN RAW,\r\n typ IN PLS_INTEGER,\r\n key IN RAW,\r\n iv IN RAW DEFAULT NULL)\r\n RETURN RAW;")
265
+ DeclareItem.new("Encrypt", :procedure, nil, "PROCEDURE Encrypt (dst IN OUT NOCOPY BLOB,\r\n src IN BLOB,\r\n typ IN PLS_INTEGER,\r\n key IN RAW,\r\n iv IN RAW DEFAULT NULL);")
266
+ DeclareItem.new("Encrypt", :procedure, nil, "PROCEDURE Encrypt (dst IN OUT NOCOPY BLOB,\r\n src IN CLOB CHARACTER SET ANY_CS,\r\n typ IN PLS_INTEGER,\r\n key IN RAW,\r\n iv IN RAW DEFAULT NULL);")
267
+ DeclareItem.new("Decrypt", :function, nil, "FUNCTION Decrypt (src IN RAW,\r\n typ IN PLS_INTEGER,\r\n key IN RAW,\r\n iv IN RAW DEFAULT NULL)\r\n RETURN RAW;")
268
+ DeclareItem.new("Decrypt", :procedure, nil, "PROCEDURE Decrypt (dst IN OUT NOCOPY BLOB,\r\n src IN BLOB,\r\n typ IN PLS_INTEGER,\r\n key IN RAW,\r\n iv IN RAW DEFAULT NULL);")
269
+ DeclareItem.new("Decrypt", :procedure, nil, "PROCEDURE Decrypt (dst IN OUT NOCOPY CLOB CHARACTER SET ANY_CS,\r\n src IN BLOB,\r\n typ IN PLS_INTEGER,\r\n key IN RAW,\r\n iv IN RAW DEFAULT NULL);")
270
+ DeclareItem.new("Hash", :function, nil, "FUNCTION Hash (src IN RAW,\r\n typ IN PLS_INTEGER)\r\n RETURN RAW DETERMINISTIC;")
271
+ DeclareItem.new("Hash", :function, nil, "FUNCTION Hash (src IN BLOB,\r\n typ IN PLS_INTEGER)\r\n RETURN RAW DETERMINISTIC;")
272
+ DeclareItem.new("Hash", :function, nil, "FUNCTION Hash (src IN CLOB CHARACTER SET ANY_CS,\r\n typ IN PLS_INTEGER)\r\n RETURN RAW DETERMINISTIC;")
273
+ DeclareItem.new("Mac", :function, nil, "FUNCTION Mac (src IN RAW,\r\n typ IN PLS_INTEGER,\r\n key IN RAW)\r\n RETURN RAW;")
274
+ DeclareItem.new("Mac", :function, nil, "FUNCTION Mac (src IN BLOB,\r\n typ IN PLS_INTEGER,\r\n key IN RAW)\r\n RETURN RAW;")
275
+ DeclareItem.new("Mac", :function, nil, "FUNCTION Mac (src IN CLOB CHARACTER SET ANY_CS,\r\n typ IN PLS_INTEGER,\r\n key IN RAW)\r\n RETURN RAW;")
276
+ DeclareItem.new("RandomBytes", :function, nil, "FUNCTION RandomBytes (number_bytes IN PLS_INTEGER)\r\n RETURN RAW;")
277
+ DeclareItem.new("RandomNumber", :function, nil, "FUNCTION RandomNumber\r\n RETURN NUMBER;")
278
+ DeclareItem.new("RandomInteger", :function, nil, "FUNCTION RandomInteger\r\n RETURN BINARY_INTEGER;")
46
279
  end
47
280
 
48
281
  end
data/spec/parser_spec.rb CHANGED
@@ -343,6 +343,10 @@ STRING
343
343
  Parser.describe_for(text).should == {:cursor_var=>nil, :for_var=>"x", :expr=>"(select * from dual)", :end_pos=>32}
344
344
  text = "for x in reverse 1..10 loops "
345
345
  Parser.describe_for(text)[:end_pos].should == -1
346
+ text = "for x in p.cursor loop "
347
+ Parser.describe_for(text).should == {:cursor_var=>"p.cursor", :for_var=>"x", :expr=>nil, :end_pos=>22}
348
+ text = "for x in user.p.cursor loop "
349
+ Parser.describe_for(text).should == {:cursor_var=>"user.p.cursor", :for_var=>"x", :expr=>nil, :end_pos=>27}
346
350
  end# }}}
347
351
 
348
352
  end
data/spec/sql/muci.spc CHANGED
@@ -16,6 +16,8 @@ create or replace package muci as
16
16
 
17
17
  g_var1 integer;
18
18
  g_var2 varchar2(100) := 'xyz';
19
+ g_var3 dual.dummy%type;
20
+ g_var4 all_objects%rowtype;
19
21
 
20
22
  procedure my_proc(p1 integer);
21
23
  function my_func(param1 varchar2, param2 boolean := true) return boolean;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vorax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-22 00:00:00.000000000 Z
12
+ date: 2013-02-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -130,7 +130,6 @@ files:
130
130
  - spec/spec_helper.rb
131
131
  - spec/sql/create_objects.sql
132
132
  - spec/sql/dbms_crypto.spc
133
- - spec/sql/dbms_crypto.~spc
134
133
  - spec/sql/dbms_stats.spc
135
134
  - spec/sql/drop_user.sql
136
135
  - spec/sql/muci.spc
@@ -176,7 +175,6 @@ test_files:
176
175
  - spec/spec_helper.rb
177
176
  - spec/sql/create_objects.sql
178
177
  - spec/sql/dbms_crypto.spc
179
- - spec/sql/dbms_crypto.~spc
180
178
  - spec/sql/dbms_stats.spc
181
179
  - spec/sql/drop_user.sql
182
180
  - spec/sql/muci.spc
@@ -1,339 +0,0 @@
1
- PACKAGE DBMS_CRYPTO AS
2
-  
3
- ---------------------------------------------------------------------------
4
- --
5
- -- PACKAGE NOTES
6
- --
7
- -- DBMS_CRYPTO contains basic cryptographic functions and
8
- -- procedures. To use correctly and securely, a general level of
9
- -- security expertise is assumed.
10
- --
11
- -- VARCHAR2 datatype is not supported. Cryptographic operations
12
- -- on this type should be prefaced with conversions to a uniform
13
- -- character set (AL32UTF8) and conversion to RAW type.
14
- --
15
- -- Prior to encryption, hashing or keyed hashing, CLOB datatype is
16
- -- converted to AL32UTF8. This allows cryptographic data to be
17
- -- transferred and understood between databases with different
18
- -- character sets, across character set changes and between
19
- -- separate processes (for example, Java programs).
20
- --
21
- ---------------------------------------------------------------------------
22
-  
23
-  
24
- -------------------------- ALGORITHM CONSTANTS ----------------------------
25
- -- The following constants refer to various types of cryptographic
26
- -- functions available from this package. Some of the constants
27
- -- represent modifiers to these algorithms.
28
- ---------------------------------------------------------------------------
29
-  
30
- -- Hash Functions
31
- HASH_MD4 CONSTANT PLS_INTEGER := 1;
32
- HASH_MD5 CONSTANT PLS_INTEGER := 2;
33
- HASH_SH1 CONSTANT PLS_INTEGER := 3;
34
-  
35
- -- MAC Functions
36
- HMAC_MD5 CONSTANT PLS_INTEGER := 1;
37
- HMAC_SH1 CONSTANT PLS_INTEGER := 2;
38
-  
39
- -- Block Cipher Algorithms
40
- ENCRYPT_DES CONSTANT PLS_INTEGER := 1; -- 0x0001
41
- ENCRYPT_3DES_2KEY CONSTANT PLS_INTEGER := 2; -- 0x0002
42
- ENCRYPT_3DES CONSTANT PLS_INTEGER := 3; -- 0x0003
43
- ENCRYPT_AES CONSTANT PLS_INTEGER := 4; -- 0x0004
44
- ENCRYPT_PBE_MD5DES CONSTANT PLS_INTEGER := 5; -- 0x0005
45
- ENCRYPT_AES128 CONSTANT PLS_INTEGER := 6; -- 0x0006
46
- ENCRYPT_AES192 CONSTANT PLS_INTEGER := 7; -- 0x0007
47
- ENCRYPT_AES256 CONSTANT PLS_INTEGER := 8; -- 0x0008
48
-  
49
- -- Block Cipher Chaining Modifiers
50
- CHAIN_CBC CONSTANT PLS_INTEGER := 256; -- 0x0100
51
- CHAIN_CFB CONSTANT PLS_INTEGER := 512; -- 0x0200
52
- CHAIN_ECB CONSTANT PLS_INTEGER := 768; -- 0x0300
53
- CHAIN_OFB CONSTANT PLS_INTEGER := 1024; -- 0x0400
54
-  
55
- -- Block Cipher Padding Modifiers
56
- PAD_PKCS5 CONSTANT PLS_INTEGER := 4096; -- 0x1000
57
- PAD_NONE CONSTANT PLS_INTEGER := 8192; -- 0x2000
58
- PAD_ZERO CONSTANT PLS_INTEGER := 12288; -- 0x3000
59
- PAD_ORCL CONSTANT PLS_INTEGER := 16384; -- 0x4000
60
-  
61
- -- Stream Cipher Algorithms
62
- ENCRYPT_RC4 CONSTANT PLS_INTEGER := 129; -- 0x0081
63
-  
64
-  
65
- -- Convenience Constants for Block Ciphers
66
- DES_CBC_PKCS5 CONSTANT PLS_INTEGER := ENCRYPT_DES
67
- + CHAIN_CBC
68
- + PAD_PKCS5;
69
-  
70
- DES3_CBC_PKCS5 CONSTANT PLS_INTEGER := ENCRYPT_3DES
71
- + CHAIN_CBC
72
- + PAD_PKCS5;
73
-  
74
- AES_CBC_PKCS5 CONSTANT PLS_INTEGER := ENCRYPT_AES
75
- + CHAIN_CBC
76
- + PAD_PKCS5;
77
-  
78
-  
79
- ----------------------------- EXCEPTIONS ----------------------------------
80
- -- Invalid Cipher Suite
81
- CipherSuiteInvalid EXCEPTION;
82
- PRAGMA EXCEPTION_INIT(CipherSuiteInvalid, -28827);
83
-  
84
- -- Null Cipher Suite
85
- CipherSuiteNull EXCEPTION;
86
- PRAGMA EXCEPTION_INIT(CipherSuiteNull, -28829);
87
-  
88
- -- Key Null
89
- KeyNull EXCEPTION;
90
- PRAGMA EXCEPTION_INIT(KeyNull, -28239);
91
-  
92
- -- Key Bad Size
93
- KeyBadSize EXCEPTION;
94
- PRAGMA EXCEPTION_INIT(KeyBadSize, -28234);
95
-  
96
- -- Double Encryption
97
- DoubleEncryption EXCEPTION;
98
- PRAGMA EXCEPTION_INIT(DoubleEncryption, -28233);
99
-  
100
-  
101
- ---------------------- FUNCTIONS AND PROCEDURES ------------------------
102
-  
103
- ------------------------------------------------------------------------
104
- --
105
- -- NAME: Encrypt
106
- --
107
- -- DESCRIPTION:
108
- --
109
- -- Encrypt plain text data using stream or block cipher with user
110
- -- supplied key and optional iv.
111
- --
112
- -- PARAMETERS
113
- --
114
- -- plaintext - Plaintext data to be encrypted
115
- -- crypto_type - Stream or block cipher type plus modifiers
116
- -- key - Key to be used for encryption
117
- -- iv - Optional IV for block ciphers. Default all zeros.
118
- --
119
- -- USAGE NOTES:
120
- --
121
- -- Block ciphers may be modified with chaining type (CBC most
122
- -- common) and padding type (PKCS5 recommended). Of the four
123
- -- common data formats, three have been provided: RAW, BLOB,
124
- -- CLOB. For VARCHAR2 encryption, callers should first convert
125
- -- to AL32UTF8 character set and then encrypt.
126
- --
127
- -- Encrypt(UTL_RAW.CAST_TO_RAW(CONVERT(src,'AL32UTF8')),typ,key);
128
- --
129
- -- As return type for encrypt is RAW, callers should consider
130
- -- encoding it with RAWTOHEX or UTL_ENCODE.BASE64_ENCODE to make
131
- -- it suitable for VARCHAR2 storage. These functions expand
132
- -- data size by 2 and 4/3, respectively.
133
- --
134
- -- To improve readability, callers should define their own
135
- -- package level constants to represent the ciphersuites used
136
- -- for encryption and decryption.
137
- --
138
- -- For example:
139
- --
140
- -- DES_CBC_PKCS5 CONSTANT PLS_INTEGER := DBMS_CRYPTO.ENCRYPT_DES
141
- -- + DBMS_CRYPTO.CHAIN_CBC
142
- -- + DBMS_CRYPTO.PAD_PKCS5;
143
- --
144
- --
145
- -- STREAM CIPHERS (RC4) ARE NOT RECOMMENDED FOR STORED DATA ENCRYPTION.
146
- --
147
- --
148
- ------------------------------------------------------------------------
149
-  
150
- FUNCTION Encrypt (src IN RAW,
151
- typ IN PLS_INTEGER,
152
- key IN RAW,
153
- iv IN RAW DEFAULT NULL)
154
- RETURN RAW;
155
-  
156
- PROCEDURE Encrypt (dst IN OUT NOCOPY BLOB,
157
- src IN BLOB,
158
- typ IN PLS_INTEGER,
159
- key IN RAW,
160
- iv IN RAW DEFAULT NULL);
161
-  
162
- PROCEDURE Encrypt (dst IN OUT NOCOPY BLOB,
163
- src IN CLOB CHARACTER SET ANY_CS,
164
- typ IN PLS_INTEGER,
165
- key IN RAW,
166
- iv IN RAW DEFAULT NULL);
167
-  
168
-  
169
- ------------------------------------------------------------------------
170
- --
171
- -- NAME: Decrypt
172
- --
173
- -- DESCRIPTION:
174
- --
175
- -- Decrypt crypt text data using stream or block cipher with user
176
- -- supplied key and optional iv.
177
- --
178
- -- PARAMETERS
179
- --
180
- -- cryptext - Crypt text data to be decrypted
181
- -- crypto_type - Stream or block cipher type plus modifiers
182
- -- key - Key to be used for encryption
183
- -- iv - Optional IV for block ciphers. Default all zeros.
184
- --
185
- -- USAGE NOTES:
186
- -- To retrieve original plain text data, Decrypt must be called
187
- -- with the same cipher, modifiers, key and iv used for
188
- -- encryption. If crypt text data was converted to hex or
189
- -- base64 prior to storage, it must be decoded using HEXTORAW or
190
- -- UTL_ENCODE.BASE64_DECODE prior to decryption.
191
- --
192
- ------------------------------------------------------------------------
193
-  
194
- FUNCTION Decrypt (src IN RAW,
195
- typ IN PLS_INTEGER,
196
- key IN RAW,
197
- iv IN RAW DEFAULT NULL)
198
- RETURN RAW;
199
-  
200
- PROCEDURE Decrypt (dst IN OUT NOCOPY BLOB,
201
- src IN BLOB,
202
- typ IN PLS_INTEGER,
203
- key IN RAW,
204
- iv IN RAW DEFAULT NULL);
205
-  
206
- PROCEDURE Decrypt (dst IN OUT NOCOPY CLOB CHARACTER SET ANY_CS,
207
- src IN BLOB,
208
- typ IN PLS_INTEGER,
209
- key IN RAW,
210
- iv IN RAW DEFAULT NULL);
211
-  
212
-  
213
- ------------------------------------------------------------------------
214
- --
215
- -- NAME: Hash
216
- --
217
- -- DESCRIPTION:
218
- --
219
- -- Hash source data by cryptographic hash type.
220
- --
221
- -- PARAMETERS
222
- --
223
- -- source - Source data to be hashed
224
- -- hash_type - Hash algorithm to be used
225
- --
226
- -- USAGE NOTES:
227
- -- SHA-1 (HASH_SH1) is recommended. Consider encoding returned
228
- -- raw value to hex or base64 prior to storage.
229
- --
230
- ------------------------------------------------------------------------
231
-  
232
- FUNCTION Hash (src IN RAW,
233
- typ IN PLS_INTEGER)
234
- RETURN RAW DETERMINISTIC;
235
-  
236
- FUNCTION Hash (src IN BLOB,
237
- typ IN PLS_INTEGER)
238
- RETURN RAW DETERMINISTIC;
239
-  
240
- FUNCTION Hash (src IN CLOB CHARACTER SET ANY_CS,
241
- typ IN PLS_INTEGER)
242
- RETURN RAW DETERMINISTIC;
243
-  
244
-  
245
- ------------------------------------------------------------------------
246
- --
247
- -- NAME: Mac
248
- --
249
- -- DESCRIPTION:
250
- --
251
- -- Message Authentication Code algorithms provide keyed message
252
- -- protection.
253
- --
254
- -- PARAMETERS
255
- --
256
- -- source - Source data to be mac-ed
257
- -- mac_type - Mac algorithm to be used
258
- -- key - Key to be used for mac
259
- --
260
- -- USAGE NOTES:
261
- -- Callers should consider encoding returned raw value to hex or
262
- -- base64 prior to storage.
263
- --
264
- ------------------------------------------------------------------------
265
- FUNCTION Mac (src IN RAW,
266
- typ IN PLS_INTEGER,
267
- key IN RAW)
268
- RETURN RAW;
269
-  
270
- FUNCTION Mac (src IN BLOB,
271
- typ IN PLS_INTEGER,
272
- key IN RAW)
273
- RETURN RAW;
274
-  
275
- FUNCTION Mac (src IN CLOB CHARACTER SET ANY_CS,
276
- typ IN PLS_INTEGER,
277
- key IN RAW)
278
- RETURN RAW;
279
-  
280
-  
281
- ------------------------------------------------------------------------
282
- --
283
- -- NAME: RandomBytes
284
- --
285
- -- DESCRIPTION:
286
- --
287
- -- Returns a raw value containing a pseudo-random sequence of
288
- -- bytes.
289
- --
290
- -- PARAMETERS
291
- --
292
- -- number_bytes - Number of pseudo-random bytes to be generated.
293
- --
294
- -- USAGE NOTES:
295
- -- number_bytes should not exceed maximum RAW length.
296
- --
297
- ------------------------------------------------------------------------
298
- FUNCTION RandomBytes (number_bytes IN PLS_INTEGER)
299
- RETURN RAW;
300
-  
301
-  
302
- ------------------------------------------------------------------------
303
- --
304
- -- NAME: RandomNumber
305
- --
306
- -- DESCRIPTION:
307
- --
308
- -- Returns a random Oracle Number.
309
- --
310
- -- PARAMETERS
311
- --
312
- -- None.
313
- --
314
- ------------------------------------------------------------------------
315
- FUNCTION RandomNumber
316
- RETURN NUMBER;
317
-  
318
-  
319
- ------------------------------------------------------------------------
320
- --
321
- -- NAME: RandomInteger
322
- --
323
- -- DESCRIPTION:
324
- --
325
- -- Returns a random BINARY_INTEGER.
326
- --
327
- -- PARAMETERS
328
- --
329
- -- None.
330
- --
331
- ------------------------------------------------------------------------
332
- FUNCTION RandomInteger
333
- RETURN BINARY_INTEGER;
334
-  
335
-  
336
- PRAGMA RESTRICT_REFERENCES(DEFAULT, WNDS, RNDS, WNPS, RNPS);
337
-  
338
- END DBMS_CRYPTO;
339
-