dbTalk Databases Forums  

[BUGS]

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default [BUGS] - 06-01-2006 , 07:35 AM






UPDATE with SUBSELECT and ORDER BY
---------------------------------------------

Hi @ Postgres BUGS...

SITUATION:

I have a Table

id groupid orderby

1 1 10
2 1 20
3 1 30
4 1 40
5 2 10
6 2 20
10 2 30
11 2 40

and a UNIQUE INDEX on columns "groupid,orderby"

now i want to update

UPDATE
orderby SET orderby = orderby +10
WHERE groupid = 1;

-> FAILS because of UNIQUE INDEX

NOW I WANTED TO UPDATE REVERSE:

UPDATE
orderby SET orderby = orderby +10
WHERE groupid IN
( SELECT groupid
FROM TABLE WHERE group_id = 1
ORDER BY orderby DESC )
;

-> FAILS TOO... SEEMS LIKE THE ORDER BY "DESC" WONT BE USED ?!?


This is with Postgres Version 8.0.3


Regards,
Claus Pruefer


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply With Quote
  #2  
Old   
AT
 
Posts: n/a

Default Re: [BUGS] - 06-01-2006 , 09:13 AM






claus.pruefer (AT) webcodex (DOT) de wrote:

Quote:
and a UNIQUE INDEX on columns "groupid,orderby"

now i want to update

UPDATE
orderby SET orderby = orderby +10
WHERE groupid = 1;

-> FAILS because of UNIQUE INDEX
This is a Known Issue(tm). (A "gotcha", some would say).

http://archives.postgresql.org/pgsql...0/msg00146.php
Surely you can find better references in the archives, but I'm too lazy.
(keywords: "deferrable unique constraint")

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.