>From: Tom Lane [mailto:t...@sss.pgh.pa.us] [..] >"Bozena Potempa" <bozena.pote...@otc.pl> writes: >> I have a test table with varchar(40) column. After executing the >> following >> query: >> select substr(fc,1,2) from test >> PQftype returns for the result column PG_TYPE_TEXT and >PQfsize returns -1. >> Is it the expected behaviour? > >Yes. substr() returns text. But even if it returned varchar, >you'd probably get -1 for the fsize. PG does not make any >attempt to predict the result width of functions.
Thank you. In this case (substring) there is no much to predict, just a simple calculation, but I understand that it is a part of larger and more complicated functionality. I tried to find a workaround with a type cast: select substr(fc,1,2)::varchar(2) from test Now the type returned is varchar, but the size is still -1. I think that it is not a correct return: the size is specified explicitly in the query and could be used by PQfsize. Bozena -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers