Re: stringtype=unspecified is null check problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Martin Handsteiner <martin(dot)handsteiner(at)sibvisions(dot)com>, "pgsql-jdbc(at)lists(dot)postgresql(dot)org" <pgsql-jdbc(at)lists(dot)postgresql(dot)org>
Subject: Re: stringtype=unspecified is null check problem
Date: 2023-01-12 03:13:13
Message-ID: 865715.1673493193@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> Yes, the non-determinism of the above (i.e., reversing the order of the
> tests removes the error), which implies the error is not sufficiently
> delayed to give other parts of the statement a chance to provide context,
> is also annoying. Which I suppose is why you are saying a second pass
> would be needed to get that delay in a minimally-invasive way.

Actually ... looking closer at the relevant code, there already *is*
two-pass processing. We're just using it to throw an error though.
I wonder if we can get away with retroactively changing the types
of Params that didn't get resolved from local context, along the
lines of the attached. The main issues I can see with this are:

* Is there any case where we'd copy UNKNOWNOID as the type of a
parse node just above an unresolved Param? I can't think of a
reason to do that offhand, because any such context would force
identification of the Param's type; but maybe I'm missing something.
If that did happen, this code would not fix the type of the upper
parse node. But maybe that wouldn't matter anyway??

* There is a very gross hack "for JDBC compatibility" right
adjacent to this:

/*
* 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;

I'm not sure if this change breaks that, and have no idea how to test.

regards, tom lane

Attachment Content-Type Size
resolve-unknown-params-better-0.1.patch text/x-diff 4.4 KB

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Martin Handsteiner 2023-01-12 08:32:29 AW: stringtype=unspecified is null check problem
Previous Message David G. Johnston 2023-01-12 01:59:59 Re: stringtype=unspecified is null check problem