Re: quote_literal with NULL

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: quote_literal with NULL
Date: 2007-10-10 16:51:35
Message-ID: 18985.1192035095@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

"Greg Sabino Mullane" <greg(at)turnstep(dot)com> writes:
>> Perhaps have quote_nullable() then as well?
>>
>> You then use quote_nullable() in INSERT and UPDATE SET clauses and
>> quote_literal() in SELECT WHERE clauses.

> I still don't see the use case. Wouldn't your app still need to check
> for nullability anyway, to avoid " = NULL"?

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.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hiroshi Saito 2007-10-10 16:54:17 Re: permission denied for tablespace pg_global?
Previous Message Michael Glaesemann 2007-10-10 16:51:28 Re: quote_literal with NULL

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2007-10-10 17:06:32 Re: Preliminary GSSAPI Patches
Previous Message Michael Glaesemann 2007-10-10 16:51:28 Re: quote_literal with NULL