Make procedure OUT parameters work with JDBC
authorPeter Eisentraut <[email protected]>
Tue, 27 Oct 2020 07:58:48 +0000 (08:58 +0100)
committerPeter Eisentraut <[email protected]>
Tue, 27 Oct 2020 08:01:54 +0000 (09:01 +0100)
The JDBC driver sends OUT parameters with type void.  This makes sense
when calling a function, so that the parameters are ignored in
ParseFuncOrColumn().  For a procedure call we want to treat them as
unknown.

Reviewed-by: Andrew Dunstan <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/d7e49540-ea92-b4e2-5fff-42036102f968%402ndquadrant.com

src/backend/parser/parse_param.c

index 17a96abfa8c323fc73ba73571741b3265eab554d..93c9d82d017d5325cdad6a3202cc802d2c01c523 100644 (file)
@@ -163,6 +163,15 @@ variable_paramref_hook(ParseState *pstate, ParamRef *pref)
    if (*pptype == InvalidOid)
        *pptype = UNKNOWNOID;
 
+   /*
+    * If the argument is of type void and it's procedure call, interpret it
+    * as unknown.  This allows the JDBC driver to not have to distinguish
+    * function and procedure calls.  See also another component of this hack
+    * in ParseFuncOrColumn().
+    */
+   if (*pptype == VOIDOID && pstate->p_expr_kind == EXPR_KIND_CALL_ARGUMENT)
+       *pptype = UNKNOWNOID;
+
    param = makeNode(Param);
    param->paramkind = PARAM_EXTERN;
    param->paramid = paramno;