Thread: [HACKERS] Prepared statements assume text type in PG10

[HACKERS] Prepared statements assume text type in PG10

From
Jack Christensen
Date:
The test suite for the Go PostgreSQL driver pgx 
(https://github.com/jackc/pgx) found an unexpected behavior change in 
PG10. Previously, it was impossible to prepare a statement with a 
unknown or ambiguous parameter type.

Pre-version 10:

jack=# prepare ps as select $1;
ERROR:  could not determine data type of parameter $1

But on PG10 the type defaults to text:

jack=# prepare ps as select $1;
PREPARE
Time: 0.183 ms
jack=# execute ps('Hello, there');   ?column?
-------------- Hello, there
(1 row)

Time: 0.437 ms

I looked through the git log and couldn't find any commits referencing 
this. Is this an intended behavior change?

Jack





-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [HACKERS] Prepared statements assume text type in PG10

From
Peter Geoghegan
Date:
On Sat, Oct 7, 2017 at 2:56 PM, Jack Christensen
<jack@jackchristensen.com> wrote:
> The test suite for the Go PostgreSQL driver pgx
> (https://github.com/jackc/pgx) found an unexpected behavior change in PG10.
> Previously, it was impossible to prepare a statement with a unknown or
> ambiguous parameter type.
>
> Pre-version 10:
>
> jack=# prepare ps as select $1;
> ERROR:  could not determine data type of parameter $1
>
> But on PG10 the type defaults to text:
>
> jack=# prepare ps as select $1;
> PREPARE
> Time: 0.183 ms
> jack=# execute ps('Hello, there');
>    ?column?
> --------------
>  Hello, there
> (1 row)
>
> Time: 0.437 ms
>
> I looked through the git log and couldn't find any commits referencing this.
> Is this an intended behavior change?

I suspect commit d8d32d9 is involved here, though I haven't verified that.

-- 
Peter Geoghegan


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [HACKERS] Prepared statements assume text type in PG10

From
Peter Geoghegan
Date:
On Sat, Oct 7, 2017 at 4:27 PM, Peter Geoghegan <pg@bowt.ie> wrote:
> I suspect commit d8d32d9 is involved here, though I haven't verified that.

Weirdly, there is a git hash collision here, so you'll have to put in
d8d32d9a (8 characters -- the default of 7 for a short git hash isn't
cutting it).

-- 
Peter Geoghegan


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [HACKERS] Prepared statements assume text type in PG10

From
Tom Lane
Date:
Jack Christensen <jack@jackchristensen.com> writes:
> Pre-version 10:

> jack=# prepare ps as select $1;
> ERROR:  could not determine data type of parameter $1

> But on PG10 the type defaults to text:

> jack=# prepare ps as select $1;
> PREPARE

> I looked through the git log and couldn't find any commits referencing 
> this. Is this an intended behavior change?

Yes, it is; we no longer allow any SELECT output column to remain
unresolved as unknown type.  If it would have come out like that
before, we force it to text instead.  Peter misidentified the
responsible commit though: it was 1e7c4bb00.  (I guess the commit
log message is a bit misleading, because it only talks about unknown
literals ... but undetermined parameters and undecorated NULL constants
would receive the same force-to-text-type treatment.)
        regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers