Unix Technical Forum

BUG #1839: insert into table (column) values (nullif('',''));

This is a discussion on BUG #1839: insert into table (column) values (nullif('','')); within the pgsql Bugs forums, part of the PostgreSQL category; --> The following bug has been logged online: Bug reference: 1839 Logged by: Matt Email address: survivedsushi@yahoo.com PostgreSQL version: 8.0.3 ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Bugs

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 10:08 AM
Matt
 
Posts: n/a
Default BUG #1839: insert into table (column) values (nullif('',''));


The following bug has been logged online:

Bug reference: 1839
Logged by: Matt
Email address: survivedsushi@yahoo.com
PostgreSQL version: 8.0.3
Operating system: linux
Description: insert into table (column) values (nullif('',''));
Details:

insert into table (column) values (nullif('',''));
ERROR: column "column" is of type boolean but
expression is of type text.

inserting NULL works. nullif('','') should return NULL
if both values are equal? It works in MSSQL.

Is there different function to accomplish a insert
nullif('','') test.

Thanks
Matt

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 10:08 AM
Stephan Szabo
 
Posts: n/a
Default Re: BUG #1839: insert into table (column) values (nullif('',''));

On Sun, 21 Aug 2005, Matt wrote:

>
> The following bug has been logged online:
>
> Bug reference: 1839
> Logged by: Matt
> Email address: survivedsushi@yahoo.com
> PostgreSQL version: 8.0.3
> Operating system: linux
> Description: insert into table (column) values (nullif('',''));
> Details:
>
> insert into table (column) values (nullif('',''));
> ERROR: column "column" is of type boolean but
> expression is of type text.
>
> inserting NULL works. nullif('','') should return NULL
> if both values are equal? It works in MSSQL.


It does return a NULL AFAICS, however it looks like it returns a NULL cast
to a textual type (since if they were different, it would return its first
argument according to the docs).

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-10-2008, 10:08 AM
Michael Fuhr
 
Posts: n/a
Default Re: BUG #1839: insert into table (column) values (nullif('',''));

On Sun, Aug 21, 2005 at 06:17:28PM +0100, Matt wrote:
>
> insert into table (column) values (nullif('',''));
> ERROR: column "column" is of type boolean but
> expression is of type text.
>
> inserting NULL works. nullif('','') should return NULL
> if both values are equal? It works in MSSQL.


NULLIF's return type is derived from the argument types; for more
information see "UNION, CASE, and ARRAY Constructs" in the "Type
Conversion" chapter of the documentation (NULLIF is a CASE construct):

http://www.postgresql.org/docs/8.0/s...nion-case.html

The type resolution behavior is defined in the SQL standard (9.3
"Set operation result data types" in SQL92; 9.3 "Data types of
results of aggregations" in SQL:1999).

> Is there different function to accomplish a insert
> nullif('','') test.


What are the possible values of NULLIF's arguments? It's not
clear what should happen if they're *not* equal. What value
should the boolean column receive in the following case?

INSERT INTO table (column) VALUES (NULLIF('abc', ''));

Can you tell us more about what the NULLIF is trying to achieve?

--
Michael Fuhr

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-10-2008, 10:08 AM
Tom Lane
 
Posts: n/a
Default Re: BUG #1839: insert into table (column) values (nullif('',''));

"Matt" <survivedsushi@yahoo.com> writes:
> insert into table (column) values (nullif('',''));
> ERROR: column "column" is of type boolean but
> expression is of type text.


Seems reasonable to me. What type would you expect '' to be?

> It works in MSSQL.


If you think silent conversions from text to boolean are a good idea,
use MSSQL. (Or create a cast to make PG do it ... but implicit
conversions across datatype categories are generally a bad idea in
my experience. They tend to fire in cases where you didn't expect it.)

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:27 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com