Re: [HACKERS] quote_literal with NULL - Mailing list pgsql-patches

From Simon Riggs
Subject Re: [HACKERS] quote_literal with NULL
Date
Msg-id 1192170177.4233.476.camel@ebony.site
Whole thread Raw
In response to Re: [HACKERS] quote_literal with NULL  ("Brendan Jurd" <direvus@gmail.com>)
Responses Re: [HACKERS] quote_literal with NULL  ("Brendan Jurd" <direvus@gmail.com>)
Re: [HACKERS] quote_literal with NULL  ("Brendan Jurd" <direvus@gmail.com>)
List pgsql-patches
On Fri, 2007-10-12 at 02:11 +1000, Brendan Jurd wrote:

> 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.

Patch looks fine.

> 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 think you should add some examples to show how we would handle an
INSERT or an UPDATE SET with quite_nullable() and a SELECT WHERE clause
with quote_literal. The difference is a subtle one, which is why nobody
mentioned it before, so it needs some better docs too.

A cross-ref to the functions page would help also.

--
  Simon Riggs
  2ndQuadrant  http://www.2ndQuadrant.com


pgsql-patches by date:

Previous
From: "Marko Kreen"
Date:
Subject: Re: txid cleanup
Next
From: "Brendan Jurd"
Date:
Subject: Re: [HACKERS] quote_literal with NULL