Postgres compatibility
socki - August 4, 2008 - 15:53
| Project: | Nodequeue |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | needs work |
| Issue tags: | postgres |
Description
Hey,
There are a few queries that don't work properly in Postgres because they take advantage of some of MySQL's leniency of SQL.
Basically, the group bys on Select * fail in Postgres.
This patch will correct them, as well as one other minor bug fix.
| Attachment | Size |
|---|---|
| nodequeue_pgsql.patch | 3.96 KB |

#1
Also the insert statement in nodequeue_arrange_subqueue_form_submit needs to be broken up into individual insert statements. I"m using postgresql 7.4.x.
I missed a couple of the other issues you dug up and did the field list slightly differently. I did do basic testing of these changes on both mysql and postgres.
Cheers
Cal
PS I've included an ed style diff and the full file can be found at http://placeofdreams.org/nodequeue.module
#2
Thanks Cal.
You identified a couple items I had missed. I've noticed some additional issues when using actions which i'm including with this patch.
This should include all the changes we've both discussed plus those for actions.
-T
#3
@cwoodruf, or another Postgres user, can you confirm that the revised patch in #2 is RTBC?
#4
As a postgres user I confirm that these changes work.
Rerolled patch from #2 against CVS HEAD. This reroll also applies cleanly to nodequeue-6.x-2.0-rc3 (offset of -1).
The changes to nodequeue.actions.inc are already in HEAD, as well as hunk 4 of nodequeue.module in the patch from #2, so these are not included in the reroll.
Changing priority to critical as the module is unusable for postgres users without this patch.
#5
subscribing
#6
Does this patch make #269459: PgSQL unnecessary?
#7
It would be great if someone with postgres familiarity could comment on the relation between this patch and the following additional postgres issues:
#286918: Schema mismatch errors reported by schema.module
#269541: PgSQL for insert statements.
Should these other issues be marked as dupes? Does this patch need work? Leaving as CNR.
#8
It looks like all three are related. There seems to be two separate issues, but some mix e two in the same issue. The first is just the syntax of SQL statements, which I think my patch addresses completely (at least in the main module).
The second issue looks like the nodequeue_subqueue table is missing from D5 for pgsql. The code supplied in #269459: PgSQL looks like it address (only) this issue.
Between a proper patch for #269459, and a reroll or rework of this patch for D5, all of these issues can probably be resolved.
#9
It looks like this patch changes the insert for saving new values into the nodequeue_nodes table from a single insert per-queue to one insert per-node. On a site with a lot of queues, that could add up to many additional queries. Is there any alternative to that?
#10
Seems like the
INSERT INTO {nodequeue_nodes}...would be better done via drupal_write_record()...the rest of the query changes look correct to me.
#11
The above patch worked for me however the node names were not getting displayed as a query was failing
* warning: pg_query() [function.pg-query]: Query failed: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list in database.pgsql.inc on line 139.
* user warning: query: SELECT DISTINCT(n.nid) FROM node n LEFT JOIN nodequeue_nodes nq ON nq.nid = n.nid WHERE nq.sqid = 2 ORDER BY nq.position ASC in nodequeue.module on line 1046.
Changing line 1046 in nodequeue.module fixed this issue:
$query_restricted = db_query(db_rewrite_sql("SELECT n.nid FROM {node} n LEFT JOIN {nodequeue_nodes} nq ON nq.nid = n.nid WHERE nq.sqid = %d$node_status_sql GROUP BY n.nid, nq.position ORDER BY nq.position $order"), $sqid);
#12
Thanks for pointing this out. Could you submit this change as a patch?
#13
The patch in this thread breaks latest version of nodequeue with postgres. Here is a patch that should work with postgres and nodequeue 2.3
#14
Just rolled my own patch using subqueries. Seems fairly similar to the others here otherwise. I am pretty sure this should work in MySQL 4.1 and up.
Does anyone know why PostgreSQL support has not been merged into nodequeue proper? This thread seems to have been going for ages.
#15
This no longer applies.
#16
Marked http://drupal.org/node/269459 as a duplicate.
#17
I struck an issue with nodequeue 2.3 and postgres 8.1 on line 1345 there is a db_query that attempts to do multiple inserts in a single statement. Postgres 8.1 fails on this (8.3 is ok).
Here is a patch that should fix this issue with pg8.1
@ezra-g what do you mean by this no longer applies? latest (v2.4 ) nodequeue did not fix the postgres issues in my testing...
#18
No longer applies means a patch no longer applies to the HEAD version of a module.
Also, please roll all of the postgres fixes into a single patch. Thanks!
#19
to be more clear, it means the patch cannot be applied, not that the issue is no longer relevant.
#20
Hello.
I applied the modifications outlined in #14 and I generated the patch for the version 6.x-2.x-dev.
I hope it was helpful.
Greetings
Leandro
#21
Hello.
I added some corrections to my previous patch. I replaced "| |" for "OR" for some queries.
#22
Thanks for the patch. Unfortunately it patch is unreviewable because it was rolled without the cvs diff -up options. Please see http://drupal.org/patch/create.
Also, it doesn't seem to take into account any of the changes in the previous patches.