Skip to content

Commit 0d49ac2

Browse files
committed
development for OUT parameter
Modify the create and call behavior of the function, if the function has the out parameter. If the function has the out parameter, the return datatype of the function can be any datatype, and the function return datatype has no relationship with out pararmeter datatype. If the function return datatype is not VOID, must specify the RETURN statement in the function body. When calling a function in plisql, must specify a variable to receive the out parameter value. If turn the guc ivorysql.allow_out_parameter_const off, call a function in SQL will report an error if the constant or NULL is passed for the out parameter. If turn the guc ivorysql.allow_out_parameter_const on, call a function a SQL, you can pass constant or NULL for the out parameter. Add a new grammer for anonymous_block, DO [LANGUAGE lang_name] code [USING IN|OUT|INOUT|IN OUT, ...] Libpq supports binding parameters by position and name when calling a function. Some interface functions similar to OCI are implemented.
1 parent 00e95cc commit 0d49ac2

122 files changed

Lines changed: 15117 additions & 412 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

GNUmakefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ GNUmakefile: GNUmakefile.in $(top_builddir)/config.status
9595

9696
$(call recurse,oracle-pg-check-world,src/test,oracle-pg-check)
9797
#add oracle regression
98-
$(call recurse,oracle-check-world,src/oracle_test src/pl src/interfaces/ecpg contrib contrib/ivorysql_ora contrib/ora_btree_gist contrib/ora_btree_gin src/bin,oracle-check)
98+
$(call recurse,oracle-check-world,src/oracle_test src/pl src/interfaces/ecpg src/interfaces/libpq/ivytest contrib contrib/ivorysql_ora contrib/ora_btree_gist contrib/ora_btree_gin src/bin,oracle-check)
9999
$(call recurse,oracle-checkprep, src/oracle_test src/pl src/interfaces/ecpg contrib src/bin)
100100

101101
$(call recurse,oracle-installcheck-world,src/oracle_test src/pl src/interfaces/ecpg contrib src/bin,oracle-installcheck)

configure

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18309,19 +18309,22 @@ $as_echo_n "checking which semaphore API to use... " >&6; }
1830918309
$as_echo "#define USE_NAMED_POSIX_SEMAPHORES 1" >>confdefs.h
1831018310

1831118311
SEMA_IMPLEMENTATION="src/backend/port/posix_sema.c"
18312+
LIBPQ_SEMA_IMPLEMENTATION="src/interfaces/libpq/posix_ivysema.c"
1831218313
sematype="named POSIX"
1831318314
else
1831418315
if test x"$USE_UNNAMED_POSIX_SEMAPHORES" = x"1" ; then
1831518316

1831618317
$as_echo "#define USE_UNNAMED_POSIX_SEMAPHORES 1" >>confdefs.h
1831718318

1831818319
SEMA_IMPLEMENTATION="src/backend/port/posix_sema.c"
18320+
LIBPQ_SEMA_IMPLEMENTATION="src/interfaces/libpq/posix_ivysema.c"
1831918321
sematype="unnamed POSIX"
1832018322
else
1832118323

1832218324
$as_echo "#define USE_SYSV_SEMAPHORES 1" >>confdefs.h
1832318325

1832418326
SEMA_IMPLEMENTATION="src/backend/port/sysv_sema.c"
18327+
LIBPQ_SEMA_IMPLEMENTATION="src/interfaces/libpq/sysv_ivysema.c"
1832518328
sematype="System V"
1832618329
fi
1832718330
fi
@@ -18332,6 +18335,7 @@ else
1833218335
$as_echo "#define USE_WIN32_SEMAPHORES 1" >>confdefs.h
1833318336

1833418337
SEMA_IMPLEMENTATION="src/backend/port/win32_sema.c"
18338+
LIBPQ_SEMA_IMPLEMENTATION="src/interfaces/libpq/win32_ivyxsema.c"
1833518339
fi
1833618340

1833718341

@@ -19407,7 +19411,7 @@ fi
1940719411
ac_config_files="$ac_config_files GNUmakefile src/Makefile.global"
1940819412

1940919413

19410-
ac_config_links="$ac_config_links src/backend/port/pg_sema.c:${SEMA_IMPLEMENTATION} src/backend/port/pg_shmem.c:${SHMEM_IMPLEMENTATION} src/include/pg_config_os.h:src/include/port/${template}.h src/Makefile.port:src/makefiles/Makefile.${template}"
19414+
ac_config_links="$ac_config_links src/backend/port/pg_sema.c:${SEMA_IMPLEMENTATION} src/interfaces/libpq/ivy_sema.c:${LIBPQ_SEMA_IMPLEMENTATION} src/backend/port/pg_shmem.c:${SHMEM_IMPLEMENTATION} src/include/pg_config_os.h:src/include/port/${template}.h src/Makefile.port:src/makefiles/Makefile.${template}"
1941119415

1941219416

1941319417
if test "$PORTNAME" = "win32"; then
@@ -20130,6 +20134,7 @@ do
2013020134
"GNUmakefile") CONFIG_FILES="$CONFIG_FILES GNUmakefile" ;;
2013120135
"src/Makefile.global") CONFIG_FILES="$CONFIG_FILES src/Makefile.global" ;;
2013220136
"src/backend/port/pg_sema.c") CONFIG_LINKS="$CONFIG_LINKS src/backend/port/pg_sema.c:${SEMA_IMPLEMENTATION}" ;;
20137+
"src/interfaces/libpq/ivy_sema.c") CONFIG_LINKS="$CONFIG_LINKS src/interfaces/libpq/ivy_sema.c:${LIBPQ_SEMA_IMPLEMENTATION}" ;;
2013320138
"src/backend/port/pg_shmem.c") CONFIG_LINKS="$CONFIG_LINKS src/backend/port/pg_shmem.c:${SHMEM_IMPLEMENTATION}" ;;
2013420139
"src/include/pg_config_os.h") CONFIG_LINKS="$CONFIG_LINKS src/include/pg_config_os.h:src/include/port/${template}.h" ;;
2013520140
"src/Makefile.port") CONFIG_LINKS="$CONFIG_LINKS src/Makefile.port:src/makefiles/Makefile.${template}" ;;

configure.ac

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2336,22 +2336,26 @@ if test "$PORTNAME" != "win32"; then
23362336
if test x"$USE_NAMED_POSIX_SEMAPHORES" = x"1" ; then
23372337
AC_DEFINE(USE_NAMED_POSIX_SEMAPHORES, 1, [Define to select named POSIX semaphores.])
23382338
SEMA_IMPLEMENTATION="src/backend/port/posix_sema.c"
2339+
LIBPQ_SEMA_IMPLEMENTATION="src/interfaces/libpq/posix_ivysema.c"
23392340
sematype="named POSIX"
23402341
else
23412342
if test x"$USE_UNNAMED_POSIX_SEMAPHORES" = x"1" ; then
23422343
AC_DEFINE(USE_UNNAMED_POSIX_SEMAPHORES, 1, [Define to select unnamed POSIX semaphores.])
23432344
SEMA_IMPLEMENTATION="src/backend/port/posix_sema.c"
2345+
LIBPQ_SEMA_IMPLEMENTATION="src/interfaces/libpq/posix_ivysema.c"
23442346
sematype="unnamed POSIX"
23452347
else
23462348
AC_DEFINE(USE_SYSV_SEMAPHORES, 1, [Define to select SysV-style semaphores.])
23472349
SEMA_IMPLEMENTATION="src/backend/port/sysv_sema.c"
2350+
LIBPQ_SEMA_IMPLEMENTATION="src/interfaces/libpq/sysv_ivysema.c"
23482351
sematype="System V"
23492352
fi
23502353
fi
23512354
AC_MSG_RESULT([$sematype])
23522355
else
23532356
AC_DEFINE(USE_WIN32_SEMAPHORES, 1, [Define to select Win32-style semaphores.])
23542357
SEMA_IMPLEMENTATION="src/backend/port/win32_sema.c"
2358+
LIBPQ_SEMA_IMPLEMENTATION="src/interfaces/libpq/win32_ivysema.c"
23552359
fi
23562360

23572361

@@ -2580,6 +2584,7 @@ AC_CONFIG_FILES([GNUmakefile src/Makefile.global])
25802584

25812585
AC_CONFIG_LINKS([
25822586
src/backend/port/pg_sema.c:${SEMA_IMPLEMENTATION}
2587+
src/interfaces/libpq/ivy_sema.c:${LIBPQ_SEMA_IMPLEMENTATION}
25832588
src/backend/port/pg_shmem.c:${SHMEM_IMPLEMENTATION}
25842589
src/include/pg_config_os.h:src/include/port/${template}.h
25852590
src/Makefile.port:src/makefiles/Makefile.${template}

contrib/hstore/expected/ivy_hstore.out

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,9 @@ select f2['d'], f2['x'] is null as x_isnull from test_json_agg;
16081608
select f2['d']['e'] from test_json_agg; -- error
16091609
ERROR: hstore allows only one subscript
16101610
select f2['d':'e'] from test_json_agg; -- error
1611-
ERROR: hstore allows only one subscript
1611+
ERROR: syntax error at or near ":"
1612+
LINE 1: select f2['d':'e'] from test_json_agg;
1613+
^
16121614
update test_json_agg set f2['d'] = f2['e'], f2['x'] = 'xyzzy';
16131615
select f2 from test_json_agg;
16141616
f2

contrib/ivorysql_ora/expected/datatype_and_func_bugs.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ begin
5151
return 1;
5252
end;
5353
/
54-
create function s1.f_alter(arg1 OUT number)
54+
create function s1.f_alter(arg1 OUT int)
5555
return number
5656
is
5757
begin
@@ -77,7 +77,7 @@ ERROR: function name "s1.f_alter" is not unique
7777
HINT: Specify the argument list to select the function unambiguously.
7878
alter function s1.f_alter(arg1 number) compile;
7979
alter function s1.f_alter(arg1 number, arg2 number) compile;
80-
alter function s1.f_alter(arg1 OUT number) compile;
80+
alter function s1.f_alter(arg1 OUT int) compile;
8181
alter function s1.f_alter(arg1 text) compile;
8282
alter function s1.f_alter(arg1 number, arg2 number, arg3 number default 10) compile;
8383
ERROR: syntax error at or near "default"
@@ -91,6 +91,6 @@ drop table char_tb;
9191
drop function f_noparam();
9292
drop function s1.f_alter(arg1 number);
9393
drop function s1.f_alter(arg1 number, arg2 number);
94-
drop function s1.f_alter(arg1 OUT number);
94+
drop function s1.f_alter(arg1 OUT int);
9595
drop function s1.f_alter(arg1 text);
9696
drop function s1.f_alter(arg1 number, arg2 number, arg3 number);

contrib/ivorysql_ora/expected/ora_sysview.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ CREATE OR REPLACE FUNCTION FUNC_WITH_DEFAULT
110110
(
111111
ARG1 IN INT DEFAULT 10,
112112
ARG2 OUT INT,
113-
ARG3 IN OUT INT DEFAULT 20,
113+
ARG3 IN OUT INT,
114114
ARG4 IN VARCHAR2(10) DEFAULT NULL
115115
)
116-
RETURN RECORD IS
116+
RETURN void IS
117117
BEGIN
118118
ARG2 := ARG1 + 10;
119119
ARG3 := ARG1 / 2;

contrib/ivorysql_ora/sql/datatype_and_func_bugs.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ return 1;
4040
end;
4141
/
4242

43-
create function s1.f_alter(arg1 OUT number)
43+
create function s1.f_alter(arg1 OUT int)
4444
return number
4545
is
4646
begin
@@ -67,7 +67,7 @@ end;
6767
alter function s1.f_alter compile;
6868
alter function s1.f_alter(arg1 number) compile;
6969
alter function s1.f_alter(arg1 number, arg2 number) compile;
70-
alter function s1.f_alter(arg1 OUT number) compile;
70+
alter function s1.f_alter(arg1 OUT int) compile;
7171
alter function s1.f_alter(arg1 text) compile;
7272
alter function s1.f_alter(arg1 number, arg2 number, arg3 number default 10) compile;
7373
alter function s1.f_alter(arg1 number, arg2 number, arg3 number) compile;
@@ -78,6 +78,6 @@ drop table char_tb;
7878
drop function f_noparam();
7979
drop function s1.f_alter(arg1 number);
8080
drop function s1.f_alter(arg1 number, arg2 number);
81-
drop function s1.f_alter(arg1 OUT number);
81+
drop function s1.f_alter(arg1 OUT int);
8282
drop function s1.f_alter(arg1 text);
8383
drop function s1.f_alter(arg1 number, arg2 number, arg3 number);

contrib/ivorysql_ora/sql/ora_sysview.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ CREATE OR REPLACE FUNCTION FUNC_WITH_DEFAULT
6868
(
6969
ARG1 IN INT DEFAULT 10,
7070
ARG2 OUT INT,
71-
ARG3 IN OUT INT DEFAULT 20,
71+
ARG3 IN OUT INT,
7272
ARG4 IN VARCHAR2(10) DEFAULT NULL
7373
)
74-
RETURN RECORD IS
74+
RETURN void IS
7575
BEGIN
7676
ARG2 := ARG1 + 10;
7777
ARG3 := ARG1 / 2;

src/backend/access/common/printtup.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,3 +513,35 @@ debugtup(TupleTableSlot *slot, DestReceiver *self)
513513

514514
return true;
515515
}
516+
517+
/*
518+
* ChangeDestSendDescription:
519+
* During PBE executing a anonymous block which includes some out parameters,
520+
* we should change it to send description
521+
*/
522+
void
523+
ChangeDestSendDescription(DestReceiver *dest)
524+
{
525+
DR_printtup *myState = (DR_printtup *) dest;
526+
527+
Assert(dest->mydest == DestRemoteExecute);
528+
529+
myState->sendDescrip = true;
530+
}
531+
532+
/*
533+
* Set sendDescrip for a DestRemote (or DestRemoteExecute) receiver
534+
*/
535+
void
536+
SetRemoteDestReceiverSendDescr(DestReceiver *self, bool send_info)
537+
{
538+
DR_printtup *myState = (DR_printtup *) self;
539+
540+
Assert(myState->pub.mydest == DestRemote ||
541+
myState->pub.mydest == DestRemoteExecute);
542+
543+
myState->sendDescrip = send_info;
544+
545+
return;
546+
}
547+

src/backend/catalog/dependency.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2338,6 +2338,8 @@ find_expr_references_walker(Node *node,
23382338
context->addrs);
23392339
/* fall through to examine arguments */
23402340
}
2341+
else if (IsA(node, NonDefValNode))
2342+
return false;
23412343

23422344
return expression_tree_walker(node, find_expr_references_walker,
23432345
(void *) context);

0 commit comments

Comments
 (0)