| From: | "Bozena Potempa" <Bozena(dot)Potempa(at)otc(dot)pl> | 
|---|---|
| To: | "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us> | 
| Cc: | <pgsql-hackers(at)postgresql(dot)org> | 
| Subject: | Re: Libpq: PQftype, PQfsize | 
| Date: | 2010-08-11 10:20:14 | 
| Message-ID: | E1Oj8Sd-0002UT-BJ@ns.otc.pl | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
>From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us] 
[..]
>"Bozena Potempa" <Bozena(dot)Potempa(at)otc(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Marko Tiikkaja | 2010-08-11 10:23:40 | Re: assertions and constraint triggers | 
| Previous Message | Peter Eisentraut | 2010-08-11 10:18:43 | Re: assertions and constraint triggers |