Re: Planning error in dynamic string creation in plpgsql

From: Keith Fiske <keith(at)omniti(dot)com>
To: PGSQL Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Planning error in dynamic string creation in plpgsql
Date: 2014-01-08 16:58:43
Message-ID: CAG1_KcAwJkfUQ-uQrVjVOA2uiUje_hx7pUr5t5p8tEOYkL6tTw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Just wanted to say thanks again for the help to those that responded. For
anyone curious, this helped me get a more advanced constraint exclusion
feature finished for the partition manager I've been working on

http://www.keithf4.com/managing-constraint-exclusion-in-table-partitioning/

--
Keith Fiske
Database Administrator
OmniTI Computer Consulting, Inc.
http://www.keithf4.com

On Mon, Jan 6, 2014 at 11:33 AM, Keith Fiske <keith(at)omniti(dot)com> wrote:

> David,
>
> That seems to have fixed it! I was going down a path of grabbing the
> column's type from pg_attribute and trying to work from there, but was
> still having some of the same issues.
>
> Thanks everyone else that replied as well!
>
> --
> Keith Fiske
> Database Administrator
> OmniTI Computer Consulting, Inc.
> http://www.keithf4.com
>
>
> On Mon, Jan 6, 2014 at 10:42 AM, David Johnston <polobo(at)yahoo(dot)com> 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.
>>
>> David J.
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://postgresql.1045698.n5.nabble.com/Planning-error-in-dynamic-string-creation-in-plpgsql-tp5785421p5785523.html
>> Sent from the PostgreSQL - general mailing list archive at Nabble.com.
>>
>>
>> --
>> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-general
>>
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message George Weaver 2014-01-08 17:26:24 argument of CASE/WHEN must not return a set
Previous Message Tom Lane 2014-01-08 16:22:40 Re: Last inserted row id with complex PK