Re: BUG #1083: Insert query reordering interacts badly with

From: Martin Langhoff <martin(at)catalyst(dot)net(dot)nz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Bugs List <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #1083: Insert query reordering interacts badly with
Date: 2004-02-24 10:47:48
Message-ID: 403B2BD4.1060908@catalyst.net.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-sql

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
-----------------------------------------------------------------------

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andreas Pflug 2004-02-24 13:17:21 Re: BUG #1082: Order by doesn't sort correctly.
Previous Message Gary WAN 2004-02-24 10:07:46 The syntax about CREATE DOMAIN

Browse pgsql-sql by date

  From Date Subject
Next Message Sumita Biswas (sbiswas) 2004-02-24 11:51:16 CURSORS - Please help urgent.
Previous Message George A.J 2004-02-24 10:02:00 Enterprice support in PostgreSQL