============================================================================
                        POSTGRESQL BUG REPORT 
============================================================================


Your name               : Oliver Meyer
Your email address      : [EMAIL PROTECTED]


System Configuration
---------------------
  Architecture                                  : x86

  Operating System                              : Linux 2.2.14  (ELF)

  PostgreSQL version                            : PostgreSQL-6.5.1 (binary 
distribution)

  Compiler used (example:  gcc 2.8.0)           : n/a


Please enter a FULL description of your problem:
------------------------------------------------

Given a RULE that UPDATEs a table on an INSERT to another table,
and then multiple tuples are inserted simultaneously, only the first
INSERT triggers an UPDATE.

Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible: 
----------------------------------------------------------------------

CREATE TABLE test1 (field1 INT4, field2 INT4);
CREATE TABLE test2 (field3 INT4, field4 INT4);
INSERT INTO test1 VALUES (1, 0);

CREATE RULE test_rule AS ON INSERT TO test2 DO
UPDATE test1 SET field2 = field2 + new.field4 WHERE field1 = new.field3;

INSERT INTO test2 VALUES (1, 1);

SELECT * FROM test1;

field1|field2
------+------
     1|     1

(this output is correct)

INSERT INTO test2 
SELECT 1,1 UNION 
SELECT 1,1;

field1|field2
------+------
     1|     2

(this output is wrong as field2 should be 3 after the second and third insert)

Reply via email to