Re: [BUGS] Double sequence increase on single insert with RULE on

2005-11-18 Thread Sarunas Krisciukaitis
Ok :) Then I found the solution in this partical case: CREATE RULE test1_on_insert AS ON INSERT TO test1 DO INSERT INTO test_log1 (qid) VALUES ( (SELECT lastval()) ); With this rule all inserts are working as expected :) Thank you for you advise :) Sarunas Michael Fuhr wrote: On Wed, Nov 16

Re: [BUGS] Double sequence increase on single insert with RULE on targeted table

2005-11-16 Thread Michael Fuhr
On Wed, Nov 16, 2005 at 10:31:10AM +0200, Sarunas Krisciukaitis wrote: > I understand that RULES are like macros. > Strangest thing here is that INSERT to test1 will touch only one > sequence: test1_id_seq. > And it increments test1_id_seq twice during insert with RULE. Yes, that's a well-known e

Re: [BUGS] Double sequence increase on single insert with RULE on

2005-11-16 Thread Sarunas Krisciukaitis
I understand that RULES are like macros. Strangest thing here is that INSERT to test1 will touch only one sequence: test1_id_seq. And it increments test1_id_seq twice during insert with RULE. Then all sequence procedures like lastval() and currval() will return number (as stated in report), wh

Re: [BUGS] Double sequence increase on single insert with RULE on targeted table

2005-11-15 Thread Tomas Zerolo
On Tue, Nov 15, 2005 at 10:51:10PM -0700, Michael Fuhr wrote: > On Wed, Nov 16, 2005 at 06:29:40AM +0100, Tomas Zerolo wrote: > > AFAIK, serials are not guaranteed to produce sequential values; tehy > > will produce unique values. That means that they can (and sometimes > > will) jump. > > In this

Re: [BUGS] Double sequence increase on single insert with RULE on targeted table

2005-11-15 Thread Michael Fuhr
On Wed, Nov 16, 2005 at 06:29:40AM +0100, Tomas Zerolo wrote: > AFAIK, serials are not guaranteed to produce sequential values; tehy > will produce unique values. That means that they can (and sometimes > will) jump. In this particular case, however, the behavior is due to the rule on test1: CREA

Re: [BUGS] Double sequence increase on single insert with RULE on targeted table

2005-11-15 Thread Tomas Zerolo
On Tue, Nov 15, 2005 at 11:39:37AM +0200, Sarunas Krisciukaitis wrote: > Dear All, > > A program produces the wrong output for any given input. > Here comes bug report: > 1. Database dump is attached. > 2. Input: "BEGIN; INSERT INTO test1(some_text) VALUES ('test1'); SELECT > lastval() as id; END

[BUGS] Double sequence increase on single insert with RULE on targeted table

2005-11-15 Thread Sarunas Krisciukaitis
Dear All, A program produces the wrong output for any given input. Here comes bug report: 1. Database dump is attached. 2. Input: "BEGIN; INSERT INTO test1(some_text) VALUES ('test1'); SELECT lastval() as id; END;" 3. Output: INSERT 0 1 id 3 (1 row) 4. Exspected Output: id 2 (1 row)