Re: Data Loss from SQL SELECT (vs. COPY/pg_dump) - Mailing list pgsql-sql

From Kong Man
Subject Re: Data Loss from SQL SELECT (vs. COPY/pg_dump)
Date
Msg-id DUB116-W175B9735F113E336895E098BDA0@phx.gbl
Whole thread Raw
In response to Data Loss from SQL SELECT (vs. COPY/pg_dump)  (Kong Man <kong_mansatiansin@hotmail.com>)
List pgsql-sql
This seems to answer my question.  I completely forgot about the behavior of NULL  value in the text concatenation.

http://www.postgresql.org/docs/9.1/static/plpgsql-statements.html#PLPGSQL-QUOTE-LITERAL-EXAMPLE

 

Because quote_literal is labelled STRICT, it will always return null when called with a null argument. In the above example, if newvalue or keyvalue were null, the entire dynamic query string would become null, leading to an error from EXECUTE. You can avoid this problem by using the quote_nullable function, which works the same as quote_literal except that when called with a null argument it returns the string NULL. For example,

pgsql-sql by date:

Previous
From: Kong Man
Date:
Subject: Data Loss from SQL SELECT (vs. COPY/pg_dump)
Next
From: Bhanu Murthy
Date:
Subject: Encrypting PGBouncer to Postgres DB connections