From: | Gevik Babakhani <pgdev(at)xs4all(dot)nl> |
---|---|
To: | Greg Stark <stark(at)enterprisedb(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Question about STRICT |
Date: | 2009-06-03 10:04:52 |
Message-ID: | 4A264AC4.2040902@xs4all.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
>> Shouldn't we raise an error when calling a function with NULL arguments
>> values if the function is created as STRICT?
>
> No, what they do is return NULL automatically. The function doesn't
> have to check for NULL arguments itself.
The "RETURNS NULL ON NULL INPUT" is logical and does the above
accordingly. But when a function is STRICT you kind of expect to have an
notification, perhaps an error if a value for an argument is NULL.
STRICT is sort of puzzling when you want to make sure a function is only
called if none of the arguments are NULL.
With STRICT, the function is "called" anyway and returns NULL, witch
results the application code to happily execute further without noticing
that calling the function did not do anything.
I am thinking about the following situation:
create table table1
(
col1 int,
col2 varchar
);
create or replace function insert_test(int,varchar) returns void as
$$
insert into table1 (col1,col2) values ($1,$2);
$$
language sql strict;
select * from insert_test(null,'a');
select * from table1;
--
Regards,
Gevik
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Stark | 2009-06-03 10:15:52 | Re: Question about STRICT |
Previous Message | Greg Stark | 2009-06-03 09:57:55 | Re: Managing multiple branches in git |