Skip to content

Commit 8b91dee

Browse files
authored
Merge pull request IvorySQL#920 from bigplaice/refine_pli_code_v5
PLiSQL code for function and procedure
2 parents 89e4b15 + 5f10c2a commit 8b91dee

20 files changed

Lines changed: 380 additions & 405 deletions

‎src/backend/oracle_parser/ora_gram.y‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9104,7 +9104,7 @@ implementation_package:
91049104
{
91059105
$$ = NIL;
91069106
}
9107-
/* reuse implementation_type temporary */
9107+
/* reuse implementation_type temporarily */
91089108
| implementation_package_type POLYMORPHIC implementation_type
91099109
{
91109110
$$ = $3;
@@ -9202,7 +9202,7 @@ opt_ora_func_args_with_defaults:
92029202
* In order to avoid reduce/reduce conflict, we are compatible with Oracle
92039203
* based on the original CREATE PROCEUDRE grammar rules of PG. The purpose
92049204
* of adding this nonterminal is to try not to destroy the syntax of PG.
9205-
* Although we can switch to the gram.y of native PG, try our best to Stick
9205+
* Although we can switch to the gram.y of native PG, try our best to stick
92069206
* to this principle.
92079207
*/
92089208
opt_procedure_args_with_defaults:

‎src/include/nodes/parsenodes.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4394,21 +4394,21 @@ typedef struct AccessibleByClause
43944394
} AccessibleByClause;
43954395

43964396
/*
4397-
* support alter a function like
4397+
* support alter a function like:
43984398
* alter function func editable|noneditable or compile
4399-
* we doesn't use the AlterFunctionStmt, because we doesn't
4399+
* we don't use the AlterFunctionStmt, because we don't
44004400
* want to use AlterFunction function, which will modify the
44014401
* pg_proc catalog table,compile doesn't change the system catalog.
4402-
* another reason is AlterFunction which fun should
4402+
* another reason is AlterFunction which should
44034403
* bring function arguments and find function rely on its
4404-
* arguments, this struct will doesn't consider function arguments.
4404+
* arguments, this struct will not consider function arguments.
44054405
*/
44064406
typedef struct CompileFunctionStmt
44074407
{
44084408
NodeTag type;
44094409
ObjectType objtype;
44104410
ObjectWithArgs *func; /* name and args of function */
4411-
bool is_compile; /* if false, it is change the editable|noneditable */
4411+
bool is_compile;
44124412
bool editable;
44134413
List *parameters;
44144414
} CompileFunctionStmt;

‎src/include/pg_config.h.in‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
/* Saved arguments from configure */
3434
#undef CONFIGURE_ARGS
3535

36-
/* Define to the default TCP port number on which the server listens and to
36+
/* Define the default TCP port number on which the server listens and to
3737
which clients will try to connect. This can be overridden at run-time, but
3838
it's convenient if your clients have the right default compiled in.
3939
(--with-oraport=PORTNUM) */

‎src/oracle_fe_utils/ora_psqlscan.l‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1869,7 +1869,7 @@ is_oracle_slash(PsqlScanState state, const char *line)
18691869
len = strlen(line);
18701870
for (i = 0; i < len; i++)
18711871
{
1872-
/* allowed special char */
1872+
/* allow special char */
18731873
if (line[i] == '\t' ||
18741874
line[i] == '\n' ||
18751875
line[i] == '\r' ||

‎src/oracle_test/regress/expected/ora_plisql.out‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--
22
-- PLISQL
33
--
4-
-- return is a non-reserved keyword, Can be used as object name.
4+
-- return is a non-reserved keyword, can be used as object name.
55
CREATE TABLE RETURN (fooid INT, foosubid INT, fooname TEXT);
66
INSERT INTO RETURN VALUES (1, 2, 'three');
77
INSERT INTO RETURN VALUES (4, 5, 'six');
@@ -936,7 +936,7 @@ SELECT pg_get_functiondef('test_subproc_func'::regproc) from dual;
936936
end;
937937
(1 row)
938938

939-
-- ivy_get_plisql_functiondef is only using get plisql func/proc definition.
939+
-- ivy_get_plisql_functiondef is only used to get plisql func/proc definition.
940940
SELECT ivy_get_plisql_functiondef('test_func'::regproc) from dual;
941941
ivy_get_plisql_functiondef
942942
-----------------------------------------------
@@ -1142,7 +1142,7 @@ EXEC test_proc6(2, 3, 4);
11421142
(1 row)
11431143

11441144
DROP PROCEDURE test_proc6;
1145-
-- recursive with output arguments
1145+
-- recursion with output arguments
11461146
CREATE OR REPLACE PROCEDURE test_proc7(x int, INOUT a int, INOUT b numeric)
11471147
AS
11481148
BEGIN

‎src/oracle_test/regress/sql/ora_plisql.sql‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-- PLISQL
33
--
44

5-
-- return is a non-reserved keyword, Can be used as object name.
5+
-- return is a non-reserved keyword, can be used as object name.
66
CREATE TABLE RETURN (fooid INT, foosubid INT, fooname TEXT);
77
INSERT INTO RETURN VALUES (1, 2, 'three');
88
INSERT INTO RETURN VALUES (4, 5, 'six');
@@ -934,7 +934,7 @@ SELECT pg_get_functiondef('test_func'::regproc) from dual;
934934
SELECT pg_get_functiondef('test_proc'::regproc) from dual;
935935
SELECT pg_get_functiondef('test_subproc_func'::regproc) from dual;
936936

937-
-- ivy_get_plisql_functiondef is only using get plisql func/proc definition.
937+
-- ivy_get_plisql_functiondef is only used to get plisql func/proc definition.
938938
SELECT ivy_get_plisql_functiondef('test_func'::regproc) from dual;
939939
SELECT ivy_get_plisql_functiondef('test_proc'::regproc) from dual;
940940
SELECT ivy_get_plisql_functiondef('test_subproc_func'::regproc) from dual;
@@ -1056,7 +1056,7 @@ END;
10561056
CALL test_proc6(2, 3, 4);
10571057
EXEC test_proc6(2, 3, 4);
10581058
DROP PROCEDURE test_proc6;
1059-
-- recursive with output arguments
1059+
-- recursion with output arguments
10601060

10611061
CREATE OR REPLACE PROCEDURE test_proc7(x int, INOUT a int, INOUT b numeric)
10621062
AS

‎src/pl/plisql/src/expected/plisql_nested_subproc.out‎

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ INFO: 529
204204
--print we are in main function
205205
--res = 45 a square function assign 11
206206
--
207-
--there originial not like oracle
207+
--the originial not like oracle
208208
--for out argmuments
209209
do $$
210210
declare
@@ -447,7 +447,7 @@ begin
447447
end;$$ language plisql;
448448
INFO: 23
449449
INFO: xiexie
450-
-- test subproc function'argument has default value
450+
-- test that subproc function'argument has default value
451451
--test ok
452452
--print 529
453453
do $$
@@ -788,7 +788,7 @@ begin
788788
end; $$ language plisql;
789789
INFO: text mds2=abc
790790
INFO: 529
791-
---global variable the name as local variable
791+
---global variable has the name as local variable
792792
--test ok
793793
create or replace function test_subproc_func(a in out integer) returns integer AS
794794
$$
@@ -836,7 +836,7 @@ INFO: 101
836836

837837
drop function test_subproc_func(integer);
838838
set ivorysql.allow_out_parameter_const = false;
839-
--function the name as global variable
839+
--function has the name as global variable
840840
--test failed
841841
do $$
842842
declare
@@ -890,8 +890,8 @@ end; $$ language plisql;
890890
INFO: var=(1,101)
891891
INFO: var2 = (2,102)
892892
--ok
893-
--this because out parameter we have don't handle
894-
-- so it doesn't like oracle
893+
--this is because we don't handle out parameter,
894+
-- so it is not like oracle
895895
-- test out name=must be assign to null
896896
-- test_out.test_out name=must be assign to null
897897
-- name1= must be assign to null
@@ -929,7 +929,7 @@ INFO: test out name=must be assign to null
929929
INFO: test_out.test_out name=must be assign to null
930930
INFO: name1=must be assign to null
931931
INFO: declare name=must be assign to null
932-
---schema function and subproc function as the same name
932+
---schema function and subproc function has the same name
933933
create or replace function test_subproc(id integer) returns integer
934934
AS $$
935935
declare
@@ -990,7 +990,7 @@ drop function test_subproc(integer);
990990
---subproc function return object_type
991991
create type test_subproc_type as (id integer,name varchar(23));
992992
--test ok
993-
--print var1=(23, "a object type")
993+
--print var1=(23, "an object type")
994994
do $$
995995
declare
996996
var1 test_subproc_type;
@@ -1000,16 +1000,16 @@ declare
10001000
var1 test_subproc_type;
10011001
begin
10021002
var1.id := 23;
1003-
var1.name := 'a object type';
1003+
var1.name := 'an object type';
10041004
return var1;
10051005
end;
10061006
begin
10071007
var1 := test_subproc(23);
10081008
raise info 'var1=%', var1;
10091009
end;$$ language plisql;
1010-
INFO: var1=(23,"a object type")
1010+
INFO: var1=(23,"an object type")
10111011
--print id = (1, "welcome to beiing")
1012-
--print var1=(23, "a object type")
1012+
--print var1=(23, "an object type")
10131013
do $$
10141014
declare
10151015
var1 test_subproc_type;
@@ -1019,7 +1019,7 @@ declare
10191019
var1 test_subproc_type;
10201020
begin
10211021
var1.id := 23;
1022-
var1.name := 'a object type';
1022+
var1.name := 'an object type';
10231023
raise info 'id = %',id;
10241024
return var1;
10251025
end;
@@ -1030,7 +1030,7 @@ BEGIN
10301030
raise info 'var1=%', var1;
10311031
end;$$ language plisql;
10321032
INFO: id = (1,"welcome to beiing")
1033-
INFO: var1=(23,"a object type")
1033+
INFO: var1=(23,"an object type")
10341034
drop type test_subproc_type;
10351035
--test function and procedure properties
10361036
--test ok
@@ -1967,7 +1967,7 @@ end; $$ language plisql;
19671967
ERROR: duplicate declaration at or near ";"
19681968
LINE 4: procedure mds(id integer);
19691969
^
1970-
--only declare but no define raise error
1970+
--only declare but no definition, raise error
19711971
do $$
19721972
DECLARE
19731973
var1 integer;
@@ -1989,7 +1989,7 @@ end; $$ language plisql;
19891989
ERROR: A subprogram body must be defined for the forward declaration of mds
19901990
LINE 4: function mds(id integer) return integer;
19911991
^
1992-
--define before declare faield
1992+
--define before declare failed
19931993
do $$
19941994
declare
19951995
function mds(id integer) return integer IS
@@ -2104,9 +2104,9 @@ INFO: proc3
21042104
INFO: proc3 out 2
21052105
--
21062106
--
2107-
-- subproc function support polymorphic type
2107+
-- subproc function supports polymorphic type
21082108
--
2109-
--point raise error others is ok
2109+
--point raise error, others is ok
21102110
do $$
21112111
DECLARE
21122112
var1 integer;
@@ -2368,8 +2368,7 @@ BEGIN
23682368
raise info '%,%',duplic(int4range(42,49), NULL,NULL),duplic(int4range('23', '45'), NULL,NULL);
23692369
end; $$ language plisql;
23702370
INFO: (42,"{42,49}"),(23,"{23,45}")
2371-
--test extral
2372-
--error test_f is is out of scope
2371+
--error test_f is out of scope
23732372
do $$
23742373
declare
23752374
var1 integer;
@@ -2506,7 +2505,7 @@ begin
25062505
end; $$ language plisql;
25072506
INFO: var1=23
25082507
INFO: var1 = 24
2509-
--oracle raise error,but we success
2508+
--oracle raise error,but we succeed
25102509
do $$
25112510
declare
25122511
var1 integer;
@@ -2531,7 +2530,7 @@ declare
25312530
begin
25322531
var1 := test_f(23);
25332532
end; $$ language plisql;
2534-
--oracle raiser error,but we sucess
2533+
--oracle raiser error,but we succeed
25352534
create or replace function test_f(id integer) returns integer as
25362535
$$
25372536
declare
@@ -2735,7 +2734,7 @@ declare
27352734
begin
27362735
var1 := test_f();
27372736
end;$$ language plisql;
2738-
--dynamic include subproc function ok var1=25
2737+
--dynamically include subproc function ok var1=25
27392738
do $$
27402739
declare
27412740
var1 integer;
@@ -2898,7 +2897,7 @@ end; $$ language plisql;
28982897
ERROR: Only schema-level programs allow AUTHID at or near "definer"
28992898
LINE 4: procedure test_p(id integer) authid definer;
29002899
^
2901-
--oracle failed, but we sucess
2900+
--oracle failed, but we succeed
29022901
do $$
29032902
declare
29042903
var1 integer;
@@ -2951,7 +2950,7 @@ LINE 1: var1 := test_proc1(23)
29512950
HINT: To call a procedure, use CALL.
29522951
QUERY: var1 := test_proc1(23)
29532952
CONTEXT: PL/iSQL function inline_code_block line 11 at assignment
2954-
--surcess
2953+
--success
29552954
do $$
29562955
declare
29572956
var1 integer;
@@ -2985,7 +2984,7 @@ LINE 1: CALL test_func1(var1)
29852984
HINT: To call a function, use SELECT.
29862985
QUERY: CALL test_func1(var1)
29872986
CONTEXT: PL/iSQL function inline_code_block line 9 at CALL
2988-
--sucess
2987+
--success
29892988
do $$
29902989
declare
29912990
var1 integer;
@@ -3027,7 +3026,7 @@ declare
30273026
BEGIN
30283027
trigger := 1;
30293028
end; $$ language plisql;
3030-
--oracle failed,but we sucess
3029+
--oracle failed,but we succeed
30313030
do $$
30323031
DECLARE
30333032
type integer;
@@ -3049,7 +3048,7 @@ begin
30493048
end; $$ language plisql;
30503049
INFO: test_f
30513050
INFO: test_f
3052-
--oracle failed,but we success
3051+
--oracle failed,but we succeed
30533052
do $$
30543053
declare
30553054
var1 integer;
@@ -3232,7 +3231,6 @@ INFO: test_event_trigger: ddl_command_start CREATE TABLE
32323231
DROP event TRIGGER regress_event_trigger;
32333232
DROP FUNCTION test_event_trigger();
32343233
drop table test_subproc_system;
3235-
--requite documents example
32363234
--ok and print test_subprocproc and test_linefunc
32373235
do $$
32383236
declare
@@ -3705,7 +3703,7 @@ declare
37053703
end; $$ language plisql;
37063704
INFO: 24
37073705
INFO: 25.1
3708-
--oracle raise error,but we sucess
3706+
--oracle raise error,but we succeed
37093707
CREATE TABLE mds(id integer,name varchar2(256));
37103708
ERROR: relation "mds" already exists
37113709
do $$

0 commit comments

Comments
 (0)