Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-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

pgsql-hackers by date

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

pgsql-patches by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group