Re: [HACKERS] quote_literal with NULL

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Brendan Jurd <direvus(at)gmail(dot)com>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] quote_literal with NULL
Date: 2007-10-12 06:22:57
Message-ID: 1192170177.4233.476.camel@ebony.site
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gokulakannan Somasundaram 2007-10-12 06:29:22 Re: Including Snapshot Info with Indexes
Previous Message Simon Riggs 2007-10-12 06:17:51 Re: First steps with 8.3 and autovacuum launcher

Browse pgsql-patches by date

  From Date Subject
Next Message Gokulakannan Somasundaram 2007-10-12 06:29:22 Re: Including Snapshot Info with Indexes
Previous Message Tom Lane 2007-10-11 20:50:45 Re: [PATCHES] Eliminate more detoast copies for packed varlenas