Re: Planning error in dynamic string creation in plpgsql

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: Keith Fiske <keith(at)omniti(dot)com>
Cc: PGSQL Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Planning error in dynamic string creation in plpgsql
Date: 2014-01-06 04:49:57
Message-ID: 52CA35F5.3010705@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 01/05/2014 08:43 PM, Keith Fiske wrote:
> I can't remove the quote_literal() because the value could potentially
> be a string, time, or number. Without the loop, quote_literal() handles
> the variable being any one of those types without any issues and quotes
> (or doesn't) as needed.

Well I tried it in your example function and it seemed to work. I don't
think it is quote_literal that is the problem, it is the assignment to
v_sql. In the FOREACH it seems v_sql is not being replanned. In the
other loop there two instances of it and they segregated by type at the
start so they do not suffer the planning issue with types.

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

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jayadevan M 2014-01-06 04:52:01 Re: authentication failure
Previous Message Adrian Klaver 2014-01-06 04:44:49 Re: Planning error in dynamic string creation in plpgsql