pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Martin Langhoff <martin@catalyst.net.nz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL Bugs List <pgsql-bugs@postgresql.org>
Subject: Re: BUG #1083: Insert query reordering interacts badly with
Date: Tue, 24 Feb 2004 23:47:48 +1300
Message-ID: <403B2BD4.1060908@catalyst.net.nz> (raw)
In-Reply-To: <18920.1077605515@sss.pgh.pa.us>
References: <20040224012657.B86E5CF4A21@www.postgresql.com>
	<18400.1077601067@sss.pgh.pa.us>
	<403AF354.5030901@catalyst.net.nz>
	<18920.1077605515@sss.pgh.pa.us>

Tom Lane wrote:

>How about
>
>SELECT nextval('seq');       -- ignore result
>
>INSERT INTO ... VALUES (currval('seq'), currval('seq'));
>  
>

Well, it works for my sample case, I have to agree. Maybe I should 
mention that I tried to boil down the bugreport to the simplest repro 
case I could.

My actual SQL looks roughly like

    INSERT INTO destination (record_id, page, row)
    SELECT
        (SELECT record_id FROM record ORDERED BY name),
        (NEXTVAL('seq') / 200),
        (CURRVAL('seq') % 200)

While I have a workaround, I am definitely curious as to whether there 
is actually a way to do it. Thanks for your patience.



regards,





martin

-- 
-----------------------------------------------------------------------
Martin @ Catalyst .Net .NZ  Ltd, PO Box 11-053, Manners St,  Wellington
WEB: http://catalyst.net.nz/           PHYS: Level 2, 150-154 Willis St
OFFICE: +64(4)916-7224                              MOB: +64(21)364-017
      Make things as simple as possible, but no simpler - Einstein
-----------------------------------------------------------------------




view thread (7+ messages)  latest in thread

Message-ID: <403B2BD4.1060908@catalyst.net.nz>
Permalink:  ../403B2BD4.1060908@catalyst.net.nz/
Also on:    postgresql.org/message-id/403B2BD4.1060908@catalyst.net.nz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: martin@catalyst.net.nz, tgl@sss.pgh.pa.us, pgsql-bugs@postgresql.org
  Subject: Re: BUG #1083: Insert query reordering interacts badly with
  In-Reply-To: <403B2BD4.1060908@catalyst.net.nz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox