Unix Technical Forum

BUG #1436: not null condition is not respected

This is a discussion on BUG #1436: not null condition is not respected within the pgsql Bugs forums, part of the PostgreSQL category; --> The following bug has been logged online: Bug reference: 1436 Logged by: Florin Borsa Email address: fborsa@saratoga.ro PostgreSQL version: ...


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, 09:29 AM
Florin Borsa
 
Posts: n/a
Default BUG #1436: not null condition is not respected


The following bug has been logged online:

Bug reference: 1436
Logged by: Florin Borsa
Email address: fborsa@saratoga.ro
PostgreSQL version: 8.0
Operating system: Windows XP
Description: not null condition is not respected
Details:

I ceate a table with some integer fields in this way:

create table homes ( nr int not null, name char(4))

I can insert in this table zero and null values for nr field.

where is the error, because I do not want to permit insertion of zero or
null values for nr field in homes table ?

Thank you !

---------------------------(end of broadcast)---------------------------
TIP 3: 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
  #2 (permalink)  
Old 04-10-2008, 09:29 AM
Michael Fuhr
 
Posts: n/a
Default Re: BUG #1436: not null condition is not respected

On Sun, Jan 23, 2005 at 05:39:05PM +0000, Florin Borsa wrote:

> I ceate a table with some integer fields in this way:
>
> create table homes ( nr int not null, name char(4))
>
> I can insert in this table zero and null values for nr field.


Zero isn't null, so a NOT NULL constraint wouldn't prohibit it as
a value. If you don't want to allow zero then use a CHECK constraint
(or a domain with a CHECK constraint):

CREATE TABLE homes (
nr integer NOT NULL CHECK (nr <> 0),
name char(4)
);

INSERT INTO homes (name) VALUES ('test');
ERROR: null value in column "nr" violates not-null constraint

INSERT INTO homes (nr, name) VALUES (NULL, 'test');
ERROR: null value in column "nr" violates not-null constraint

INSERT INTO homes (nr, name) VALUES (0, 'test');
ERROR: new row for relation "homes" violates check constraint "homes_nr_check"

INSERT INTO homes (nr, name) VALUES (1, 'test');
INSERT 0 1

Can you provide a test case demonstrating the insertion of NULL
into a column with a NOT NULL constraint?

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---------------------------(end of broadcast)---------------------------
TIP 9: 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
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 02:56 AM.


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