Re: Libpq: PQftype, PQfsize
От | Bozena Potempa |
---|---|
Тема | Re: Libpq: PQftype, PQfsize |
Дата | |
Msg-id | E1Oj8Sd-0002UT-BJ@ns.otc.pl обсуждение исходный текст |
Ответ на | Re: Libpq: PQftype, PQfsize (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: Libpq: PQftype, PQfsize
|
Список | pgsql-hackers |
>From: Tom Lane [mailto:tgl@sss.pgh.pa.us] [..] >"Bozena Potempa" <Bozena.Potempa@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
В списке pgsql-hackers по дате отправления: