PostgreSQL DISTINCT ORDER BY CLAUSE causes break during installation

jmpoure - October 17, 2008 - 20:27
Project:Translation Overview
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

In PostgreSQL and probably SQL99, you can only ORDER BY flields in a SELECT DISTINCT clause if the fields are part of the SELECT DISTINCT clause.

Example:

SELECT DISTINCT (nid) FROM node
WHERE nid = tnid OR tnid = 0 OR tnid IS NULL
ORDER BY tnid

Correct would be:

SELECT DISTINCT (nid, tnid) FROM node
WHERE nid = tnid OR tnid = 0 OR tnid IS NULL
ORDER BY tnid

Of course, this does work during the installation.
Because data is inserted, there is no need to ORDER BY.

Therefore,

INSERT INTO translation_overview_priority (tnid)
SELECT DISTINCT (nid) FROM node WHERE nid = tnid OR tnid = 0 OR tnid IS NULL ORDER BY tnid

whould be replace with:

INSERT INTO translation_overview_priority (tnid)
SELECT DISTINCT (nid) FROM node WHERE nid = tnid OR tnid = 0 OR tnid IS NULL

Cheers,
Jean-Michel

#1

drewish - October 17, 2008 - 23:53
Status:active» needs review

good call, the order isn't needed, i'd copied and pasted the code from elsewhere and didn't clean that up. would you mind testing this and ensuring that it works?

AttachmentSize
translation_overview_322796.patch 908 bytes

#2

drewish - October 17, 2008 - 23:57
Status:needs review» fixed

simple enough change so i went ahead and committed it. thanks!

#3

Anonymous (not verified) - November 1, 2008 - 00:02
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.