[HACKERS] smallint out of range EXECUTEing prepared statement - Mailing list pgsql-hackers

From Justin Pryzby
Subject [HACKERS] smallint out of range EXECUTEing prepared statement
Date
Msg-id 20170118221530.GH3033@telsasoft.com
Whole thread Raw
In response to Re: [HACKERS] ALTER TABLE .. ALTER COLUMN .. ERROR: attribute .. has wrong type  (Justin Pryzby <pryzby@telsasoft.com>)
List pgsql-hackers
Is this expected behavior ?

ts=# SELECT * FROM t WHERE site_id=32768 LIMIT 1;
(0 rows)

ts=# PREPARE x AS SELECT * FROM t WHERE site_id=$1 LIMIT 1;
PREPARE
ts=# EXECUTE x(32768);
ERROR:  smallint out of range

ts=# PREPARE y AS SELECT * FROM t WHERE site_id::int=$1 LIMIT 1;
PREPARE
ts=# EXECUTE y(32768);
(0 rows)

Note, we also sometimes get small/int out of range when SELECTing from a view,
and we end up as a workaround putting a ::big/int cast into the view or
multiplying by 1.

Thanks,
Justin



pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: [HACKERS] PoC: Grouped base relation
Next
From: "David G. Johnston"
Date:
Subject: Re: [HACKERS] smallint out of range EXECUTEing prepared statement