From: | Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com> |
---|---|
To: | David Johnston <polobo(at)yahoo(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Planning error in dynamic string creation in plpgsql |
Date: | 2014-01-06 16:18:53 |
Message-ID: | 52CAD76D.4090002@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 01/06/2014 07:42 AM, David Johnston wrote:
> Adrian Klaver-3 wrote
>>>
>>>
>>> In the real function I'm writing, the columns to be used in the string
>>> being created are pulled from a configuration table, so their types
>>> could be anything. So casting the quote_literal() calls is not really an
>>> option here.
>>>
>>> Any help would be appreciated.
>>
>> Cast before the quote_literal?
>>
>> Example:
>>
>> EXECUTE 'SELECT min('||v_col||'::text) as min, max('||v_col||'::text) as
>> max FROM test_temp' INTO v_record;
>
> Right idea if the loss of original type in the min/max query is acceptable
> (which it should be). But the cast wants to be of the min/max RESULT not
> the min/max INPUT.
>
> SELECT min(' || v_col || ')::text AS min_text, max(' || v_col || ')::text AS
> max_text FROM ...
>
> Min/Max logic wants to be done by the rules for the original type, not
> according to string collation rules.
Yes, that would be the way to do it.
>
> David J.
>
>
>
>
>
--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2014-01-06 16:28:23 | Re: file system level backup |
Previous Message | Adrian Klaver | 2014-01-06 16:17:37 | Re: WAL archive cleanup om master |