Re: quote_literal with NULL - Mailing list pgsql-hackers

From Tom Lane
Subject Re: quote_literal with NULL
Date
Msg-id 18985.1192035095@sss.pgh.pa.us
Whole thread Raw
In response to Re: quote_literal with NULL  ("Greg Sabino Mullane" <greg@turnstep.com>)
Responses Re: quote_literal with NULL
List pgsql-hackers
"Greg Sabino Mullane" <greg@turnstep.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


pgsql-hackers by date:

Previous
From: "Hiroshi Saito"
Date:
Subject: Re: permission denied for tablespace pg_global?
Next
From: Michael Glaesemann
Date:
Subject: Re: quote_literal with NULL