BUG #3945: unexpected ON INSERT rule behaviour

Поиск
Список
Период
Сортировка
От Holger Klawitter
Тема BUG #3945: unexpected ON INSERT rule behaviour
Дата
Msg-id 200802082220.m18MKIM1032932@wwwmaster.postgresql.org
обсуждение исходный текст
Ответы Re: BUG #3945: unexpected ON INSERT rule behaviour  ("Gurjeet Singh" <singh.gurjeet@gmail.com>)
Список pgsql-bugs
The following bug has been logged online:

Bug reference:      3945
Logged by:          Holger Klawitter
Email address:      info@klawitter.de
PostgreSQL version: 8.2.6
Operating system:   Linux/i386
Description:        unexpected ON INSERT rule behaviour
Details:

Well,
this is probably not really a bug, more a feature
deeply buried in the query-tree-concept worth placed as a pitfall warning in
the documentation :-)

The following code:
CREATE TABLE a (a int);
CREATE TABLE b (b int);

CREATE OR REPLACE RULE a_to_b
AS ON INSERT TO a
DO ALSO INSERT INTO b VALUES (NEW.a);

INSERT INTO a VALUES ( 1 );
INSERT INTO a VALUES ((SELECT max(a)+1 from a));

SELECT * from b;

Produces the following output:
 b
---
 1
 3         <---- 2 expected here
(2 rows)

One would expect 1 and 2 to be stored in b.

The problem is that NEW.a is not the *value* being inserted. Instead, NEW
reproduces the unevaluated
selected statement.

Regards
  Holger

В списке pgsql-bugs по дате отправления:

Предыдущее
От: "Heikki Linnakangas"
Дата:
Сообщение: Re: BUG #3944: Unable to create a database using SQL_ASCII encoding
Следующее
От: Tomas Szepe
Дата:
Сообщение: 8.3.0: vacuum full analyze: "invalid memory alloc request size"