Обсуждение: BUG #1381: invalid input syntax for integer: ""

Поиск
Список
Период
Сортировка

BUG #1381: invalid input syntax for integer: ""

От
"Nicolas Addington"
Дата:
The following bug has been logged online:

Bug reference:      1381
Logged by:          Nicolas Addington
Email address:      adding@math.wisc.edu
PostgreSQL version: 8.0
Operating system:   aix
Description:        invalid input syntax for integer: ""
Details:

When a pl/perl trigger for an insert event changes an integer column in the
new row to null, it fails.  Interestingly, it doesn't have a problem if the
column was originally null.

create table tbl ( id integer primary key, n integer );

create function trg() returns trigger as $$
  undef $_TD->{new}{n};
  return 'MODIFY';
$$ language 'plperlu';

create trigger trg before insert on tbl for each row execute procedure
trg();

insert into tbl values (1, null);
INSERT 17997 1

insert into tbl values (2, 0);
ERROR:  invalid input syntax for integer: ""

Re: BUG #1381: invalid input syntax for integer: ""

От
Tom Lane
Дата:
"Nicolas Addington" <adding@math.wisc.edu> writes:
> PostgreSQL version: 8.0

tsk, tsk --- it's not 8.0.  Yet.

> When a pl/perl trigger for an insert event changes an integer column in the
> new row to null, it fails.  Interestingly, it doesn't have a problem if the
> column was originally null.

Looks like we have to check *both* SvOK() and SvTYPE() everywhere.
Sigh.  Done --- thanks for the report.

            regards, tom lane