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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-bugs by date

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