Closed (duplicate)
Project:
Drupal core
Version:
5.1
Component:
database system
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
26 Feb 2007 at 13:59 UTC
Updated:
31 May 2007 at 06:51 UTC
Jump to comment: Most recent file
Comments
Comment #1
dries commentedI don't have a PostgreSQL install so I can't double-check this. Can someone confirm this problem, and its patch. Thanks.
Comment #2
drummComment #3
takashi commentedI think rewrite 'SELECT DISTINCT ON (table.field) table.field ...' to 'SELECT DISTINCT (table.field) ...' may not be enough.
The issue is related to the issue I've reported (http://drupal.org/node/128846#comment-218906), isn't it?
Comment #4
takashi commentedI think rewrite 'SELECT DISTINCT ON (table.field) table.field ...' to 'SELECT DISTINCT (table.field) ...' may not be enough.
The issue is related to the issue I've reported (http://drupal.org/node/128846#comment-218906), isn't it?
Comment #5
PMunn commentedI've run queries on my node table looking for duplicate NIDs and don't see any. Perhaps this is a problem with MySql?
Either way, I'd rather not hold up this fix in the face of a larger one. It's hard enough to get action on PostgreSQL patches due to its severe minority status in the Drupal world. Please don't chain anything to it that will hold it down longer. Nobody likes to remake the same patch over and over again.
Comment #6
takashi commentedI'm talking about PostgreSQL issue, not MySQL. I want to say that
#1: SELECT DISTINCT ON (n.nid) n.nid, n.sticky FROM node n;
and
#2: SELECT DISTINCT (n.nid), n.sticky FROM node n;
is not equal. I think the patch
'database.pgsql_.inc_.20070225.pgsql_.patch' modifies behaviour of
db_distinct_field() from #1 to #2.
With #1 SQL, SELECT keeps only the first row of each set of rows where
nid is equal (this might be what we want to do in db_distinct_field()).
With #2 SQL, duplicated rows (not only nid, but also sticky are equal)
are removed from the result set.
SELECT + distinct-clause + select-list + from-clause
#1
distinct-clause => DISTINCT ON (n.nid)
select-list => n.nid, n.sticky
from-clause => FROM node.n
#2
distinct-clause => DISTINCT
select-list => (n.nid), n.sticky == n.nid, n.sticky
from-clause => FROM node n;
P.S. I'm very sorry that I posted the same comment twice, it was a
technical problem (I was using mobile environment, and it was not
stable).
P.S. The following is a segment from PostgreSQL manual page
(http://www.postgresql.org/docs/8.2/interactive/sql-select.html).
Synopsis
SELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]
* | expression [ AS output_name ] [, ...]
[ FROM from_item [, ...] ]
[ WHERE condition ]
[ GROUP BY expression [, ...] ]
[ HAVING condition [, ...] ]
[ { UNION | INTERSECT | EXCEPT } [ ALL ] select ]
[ ORDER BY expression [ ASC | DESC | USING operator ] [, ...] ]
[ LIMIT { count | ALL } ]
[ OFFSET start ]
[ FOR { UPDATE | SHARE } [ OF table_name [, ...] ] [ NOWAIT ] [...] ]
DISTINCT Clause
If DISTINCT is specified, all duplicate rows are removed from the
result set (one row is kept from each group of duplicates).
DISTINCT ON ( expression [, ...] ) keeps only the first row of each
set of rows where the given expressions evaluate to equal.
Note that the "first row" of each set is unpredictable unless ORDER BY
is used to ensure that the desired row appears first.
Comment #7
wedge commentedNot sure if it's of any help but I have the same issue. The patch supresses the SQL error but the nodes are sorted in the wrong order on my startpage when the patch is applied.
Comment #8
wedge commentedDoh!
the patch attached in http://drupal.org/node/128846#comment-218906 seems to solve the sorting issue as well. Thanks takashi, this has been bugging me for a while.
Comment #9
wedge commentedSorry about the spam...
Did some more testing and have run into issues. Will post another update tomorrow.
Comment #10
wedge commentedI will continue discussion in http://drupal.org/node/128846 since it's related to the patch posted there.
Comment #11
PMunn commentedYes, the patch here appears to fix the problem, as well as the ones at the core of that issue. See my comments there on other issues.
I'd close this item only once that other patch is accepted.
Comment #12
drummhttp://drupal.org/node/128846 is more-recently updated and has well-commented code.