Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 2C0C99FB3FC for ; Fri, 7 Sep 2007 10:41:08 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 00374-05-3 for ; Fri, 7 Sep 2007 10:40:42 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.169]) by postgresql.org (Postfix) with ESMTP id 771399FB38E for ; Fri, 7 Sep 2007 10:40:39 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id j3so152556ugf for ; Fri, 07 Sep 2007 06:40:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:subject:content-type:content-transfer-encoding; bh=S2rpefcpNifMt7DPA2u2BrHjpAuLHBglOAOHmN7aY3A=; b=No0G8w/I6TYcs3OO4M3TqihgLjT7wyyKeJxVqer1D3xQi1KTE1kYeDDI8U8BICSAkDAwh+ZAYQfR5G7ufDNpW9AiNQ4dPXoeZNmToZ+iXD44KxfY2ZCGgLSk1wQh/mgyyYog31a70WHeverG7FerBfJ0cNzV61gnkDVvbnBFcs8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:subject:content-type:content-transfer-encoding; b=TJKMnrH4vZNjmoazo4tJ0l34URBp73J2h/4k30RAP6OYPriIcWr8gzSPG8tM4uZSxbb+SdDn+/3+0yDLph7FpumkSx8RBY4uEKNUPhj+Zlk25Jh/M9Fm63l18edCc590BstUyw7H5LWyVLDrcUJ7rgdYTMYlJYvqXqLCqIjdxws= Received: by 10.66.237.9 with SMTP id k9mr1346116ugh.1189172436588; Fri, 07 Sep 2007 06:40:36 -0700 (PDT) Received: from ?10.0.0.75? ( [213.170.101.138]) by mx.google.com with ESMTPS id 19sm3805400ugl.2007.09.07.06.40.34 (version=SSLv3 cipher=RC4-MD5); Fri, 07 Sep 2007 06:40:34 -0700 (PDT) Message-ID: <46E154D2.8040203@gmail.com> Date: Fri, 07 Sep 2007 17:40:34 +0400 From: Aleksandr Vinokurov User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: SERIAL type's sequence is double-called or ? Content-Type: text/plain; charset=windows-1251; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/64 X-Sequence-Number: 29277 Hello all, I have a question with the SERIAL type. I want to use it for default identification of table entries: create table chuwee ( num serial primary key, mesg varchar(50) not null ); And all the inserts to this table I'm gonna log to this table: create table chuwee_log ( id serial primary key, date timestamp default current_timestamp, num integer not null, mesg varchar(50) not null ); Logging will be done with this rule: create or replace rule chuwee_rule as on insert to chuwee do insert into chuwee_log (num, mesg) values (new.num, new.mesg); And all seems to work, but a sequence is called twice for inserts, and logged "num"-s get a +1 value: sunline=# insert into chuwee (mesg) values ('Hello, world!'); INSERT 9596671 1 sunline=# insert into chuwee (mesg) values ('Aquarium full of tequilla'); INSERT 9596673 1 sunline=# select * from chuwee_log; id | date | num | mesg ----+----------------------------+-----+--------------------------- 1 | 2007-09-08 16:18:26.707384 | 2 | Hello, world! 2 | 2007-09-08 16:18:58.711599 | 4 | Aquarium full of tequilla (2 rows) sunline=# select * from chuwee; num | mesg -----+--------------------------- 1 | Hello, world! 3 | Aquarium full of tequilla (2 rows) How it can be cured, if any? Best dishes, Aleksandr.