pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #6295: Update fails on empty concatenated strings
3+ messages / 2 participants
[nested] [flat]
* BUG #6295: Update fails on empty concatenated strings
@ 2011-11-16 08:47 Jonas Forsman <jfo123@hotmail.com>
2011-11-16 15:37 ` Re: BUG #6295: Update fails on empty concatenated strings Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 3+ messages in thread
From: Jonas Forsman @ 2011-11-16 08:47 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged online:
Bug reference: 6295
Logged by: Jonas Forsman
Email address: jfo123@hotmail.com
PostgreSQL version: 8.4.9
Operating system: Ubuntu 10.04 LTS
Description: Update fails on empty concatenated strings
Details:
Field description (note the field name is "comment") :
comment character varying(2048)
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.
This works:
UPDATE user SET comment= E'[2011-11-16] Note to myself no: 171\\n' ||
comment || '' WHERE userid=1
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #6295: Update fails on empty concatenated strings
2011-11-16 08:47 BUG #6295: Update fails on empty concatenated strings Jonas Forsman <jfo123@hotmail.com>
@ 2011-11-16 15:37 ` Tom Lane <tgl@sss.pgh.pa.us>
2011-11-16 15:44 ` Re: BUG #6295: Update fails on empty concatenated strings Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2011-11-16 15:37 UTC (permalink / raw)
To: Jonas Forsman <jfo123@hotmail.com>; +Cc: pgsql-bugs
"Jonas Forsman" <jfo123@hotmail.com> 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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #6295: Update fails on empty concatenated strings
2011-11-16 08:47 BUG #6295: Update fails on empty concatenated strings Jonas Forsman <jfo123@hotmail.com>
2011-11-16 15:37 ` Re: BUG #6295: Update fails on empty concatenated strings Tom Lane <tgl@sss.pgh.pa.us>
@ 2011-11-16 15:44 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 3+ messages in thread
From: Tom Lane @ 2011-11-16 15:44 UTC (permalink / raw)
To: Jonas Forsman <jfo123@hotmail.com>; +Cc: pgsql-bugs
I wrote:
> You might possibly want to spell
> the above as SET comment = '...' || coalesce(comment, null) ...
Sheesh. coalesce(comment, '') of course. Need more caffeine.
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2011-11-16 15:44 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-11-16 08:47 BUG #6295: Update fails on empty concatenated strings Jonas Forsman <jfo123@hotmail.com>
2011-11-16 15:37 ` Tom Lane <tgl@sss.pgh.pa.us>
2011-11-16 15:44 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox