From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Brendan Jurd <direvus(at)gmail(dot)com> |
Cc: | pgsql-patches(at)postgresql(dot)org |
Subject: | Re: [HACKERS] quote_literal with NULL |
Date: | 2007-11-04 22:32:48 |
Message-ID: | 200711042232.lA4MWmD04805@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-patches |
This has been saved for the 8.4 release:
http://momjian.postgresql.org/cgi-bin/pgpatches_hold
---------------------------------------------------------------------------
Brendan Jurd wrote:
> Hi patchers,
>
> Per discussion on -hackers, I've implemented a new internal function
> quote_nullable, as an alternative to quote_literal. The difference is
> that quote_nullable returns the text value 'NULL' on NULL input, which
> is suitable for insertion into an SQL statement.
>
> The idea is that when you're writing a plpgsql function with dynamic
> queries, you can use quote_nullable for values which are
> possibly-null. You're still responsible for handling NULLs sensibly
> within your query, but at least you get a syntactically valid SQL
> statement.
>
> I've included doc updates but no new regression tests. I did not add
> tests because there are currently no tests for quote_literal and when
> I recently suggested addition of tests for quote_ident [1] they were
> rejected. I still don't fully understand the criteria for inclusion
> of regression tests, but this is a similar situation, so I'm following
> the same guidance.
>
> Patch compiles cleanly and passes make check on x86 gentoo.
>
> Thanks for your time,
> BJ
>
> [1] http://archives.postgresql.org/pgsql-patches/2007-10/msg00080.php
>
> On 10/11/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > Well, it's clearly useful in INSERT and UPDATE. For WHERE cases, you
> > might or might not be able to use it, but I note that quote_nullable()
> > would work much more like what happens if you use a parameter symbol
> > and then bind NULL as the actual parameter value ...
> >
> > In hindsight we should probably have done quote_literal the way the OP
> > suggests, but I concur that it's too late to change it. An additional
> > function seems a reasonable compromise.
[ Attachment, skipping... ]
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://postgres.enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
From | Date | Subject | |
---|---|---|---|
Next Message | Neil Conway | 2007-11-05 00:03:38 | Re: "bad key in cancel request" |
Previous Message | Bruce Momjian | 2007-11-04 22:24:10 | Re: type money causes unrestorable dump |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2007-11-04 22:36:48 | Re: Avoid needless copy in nodeMaterial |
Previous Message | Bruce Momjian | 2007-11-04 21:58:08 | Re: [HACKERS] Text <-> C string |