Skip site navigation (1) Skip section navigation (2)

Bogus reporting of non-null value in function call.

From: "James Finch" <James(at)VolumeFour(dot)com>
To: <pgsql-bugs(at)postgresql(dot)org>
Subject: Bogus reporting of non-null value in function call.
Date: 2000-04-24 22:40:44
Message-ID: 000601bfae3e$21d55e20$0a02a8c0@volumefour.com (view raw or flat)
Thread:
Lists: pgsql-bugs
Platform: Linux-2.2.12-20 (RH 6.1)
PostgreSQL: 7.0RC1

Description:
Arguments to a function seem to be incorrectly validated against constraints
on the table on which it operates. For example: I have a table that defines
one column (id) as a primary key, and also specifies the NOT NULL
constraint. I then have a function performs an insert into this table. The
function parameters basically map to the columns in this table. If I pass in
null in any argument to the function, I always get the spurious error
message "ERROR:  ExecAppend: Fail to add null value in not null attribute
...", even though I'm not passing in null for the parameter that maps to the
column to which the error message applies.


To reproduce.

CREATE TABLE atom (
       id               VARCHAR(256) NOT NULL,
       name             VARCHAR(256),
       domain           VARCHAR(256),
       definition    	VARCHAR(256),
       value            VARCHAR(4000),
       num_value        FLOAT8,
       date_value       DATE,
       objtype          INT2,
       PRIMARY KEY (id)
);



DROP FUNCTION createAtom( INT2, VARCHAR, VARCHAR, VARCHAR, VARCHAR,
VARCHAR );
CREATE FUNCTION createAtom( INT2, VARCHAR, VARCHAR, VARCHAR, VARCHAR,
VARCHAR )
	RETURNS BOOL AS '
		DECLARE
			p_objtype ALIAS FOR $1;
			p_idThis ALIAS FOR $2;
			p_name ALIAS FOR $3;
			p_domain ALIAS FOR $4;
			p_definition ALIAS FOR $5;
			p_value ALIAS FOR $6;
		BEGIN
			INSERT INTO atom ( objtype, id, name, domain, definition, num_value,
value )
			VALUES ( p_objtype, p_idThis, p_name, p_domain, p_definition, p_value,
p_value ) ;
			RETURN TRUE;
		END;
	' LANGUAGE 'plpgsql';

select createAtom( 'abc', 'Fred', 'NT', 'Fred', 'a', 1.0, null, 2 );


Responses

pgsql-bugs by date

Next:From: James FinchDate: 2000-04-24 22:45:16
Subject: RE: Bogus reporting of non-null value in function call.
Previous:From: Tom LaneDate: 2000-04-24 22:00:41
Subject: Re: Index opclass checking (was Re: Crash in PostgreSQL 7.0.b5.)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group