Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 7A5051A16BD4 for ; Wed, 16 Nov 2011 11:37:54 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 60002-06 for ; Wed, 16 Nov 2011 15:37:48 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id AD0661A16BD3 for ; Wed, 16 Nov 2011 11:37:48 -0400 (AST) Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RQhYZ-0001xN-H1 for pgsql-bugs@postgresql.org; Wed, 16 Nov 2011 15:37:48 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id pAGFbX8Y023408; Wed, 16 Nov 2011 10:37:33 -0500 (EST) To: "Jonas Forsman" cc: pgsql-bugs@postgresql.org Subject: Re: BUG #6295: Update fails on empty concatenated strings In-reply-to: <201111160847.pAG8lCdx067272@wwwmaster.postgresql.org> References: <201111160847.pAG8lCdx067272@wwwmaster.postgresql.org> Comments: In-reply-to "Jonas Forsman" message dated "Wed, 16 Nov 2011 08:47:12 +0000" Date: Wed, 16 Nov 2011 10:37:33 -0500 Message-ID: <23407.1321457853@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201111/115 X-Sequence-Number: 31710 "Jonas Forsman" writes: > sql: > UPDATE user SET comment= E'[2011-11-16] Note to myself no: 171\\n' || > comment WHERE userid=1 > This query fails if comment is an empty string or null. Define "fails". Personally I'm wondering whether you remembered that concatenation of a null with something else yields null. You might possibly want to spell the above as SET comment = '...' || coalesce(comment, null) ..., if you want to pretend that a null is the same thing as an empty string. regards, tom lane