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.
| Comment | File | Size | Author |
|---|---|---|---|
| #37 | nodequeue-290969-37.patch | 4.56 KB | cedarm |
| #37 | nodequeue-290969-37b.patch | 4.01 KB | cedarm |
| #30 | nodequeue-6.x-2.9-postgresql.patch | 9.69 KB | macedigital |
| #27 | nodequeue-6.x-2.9-postgresql.patch | 9.78 KB | macedigital |
| #26 | 290969_nodequeue.module_pgsql_compatible_ver2.patch | 3.85 KB | xmarket |
Comments
Comment #1
cwoodruf commentedAlso 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
Comment #2
socki commentedThanks 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
Comment #3
ezra-g commented@cwoodruf, or another Postgres user, can you confirm that the revised patch in #2 is RTBC?
Comment #4
cedarm commentedAs 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.
Comment #5
tuffnatty commentedsubscribing
Comment #6
ezra-g commentedDoes this patch make #269459: PgSQL unnecessary?
Comment #7
ezra-g commentedIt 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.
Comment #8
cedarm commentedIt 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.
Comment #9
ezra-g commentedIt 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?
Comment #10
drewish commentedSeems like the
INSERT INTO {nodequeue_nodes}...would be better done via drupal_write_record()...the rest of the query changes look correct to me.
Comment #11
groklem commentedThe 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);
Comment #12
ezra-g commentedThanks for pointing this out. Could you submit this change as a patch?
Comment #13
groklem commentedThe patch in this thread breaks latest version of nodequeue with postgres. Here is a patch that should work with postgres and nodequeue 2.3
Comment #14
jamespharaoh commentedJust 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.
Comment #15
ezra-g commentedThis no longer applies.
Comment #16
ezra-g commentedMarked http://drupal.org/node/269459 as a duplicate.
Comment #17
groklem commentedI 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...
Comment #18
ezra-g commentedNo 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!
Comment #19
ezra-g commentedto be more clear, it means the patch cannot be applied, not that the issue is no longer relevant.
Comment #20
eltrufa commentedHello.
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
Comment #21
eltrufa commentedHello.
I added some corrections to my previous patch. I replaced "| |" for "OR" for some queries.
Comment #22
ezra-g commentedThanks 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.
Comment #23
xmarket commentedHi,
subscibe
Please keep on this task the good work! If you need a person to test the patches, let me know. I really would like to get rid of mysql.
Cheers,
xmarket
Comment #24
xmarket commentedHi,
Here is the nodequeue.module postgresql compatible patch. I use PostgreSQL 8.4.2. Patch based on #21. Patch works good with Nodequeue and Generate nodequeue assignments module according to the postmaster.log and my tests. I didn't test Smartqueue module. Querys remained compatible with mysql too, tested with mysql 5.0.90.
I noticed, that you use the COUNT so much in the querys. It would be nice, if you could rewrite the querys to use LIMIT, instead of COUNT.
Here is a nice topic about COUNT vs LIMIT:
http://drupal.org/node/196862#comment-649928
http://drupal.org/node/196862#comment-1595084
Cheers,
xmarket
Comment #25
xmarket commentedPatch in #24 is wrong! Please ignore it!
Here is the FIXED patch! Sorry...
Comment #26
xmarket commentedPlease do not neglect this topic!
Here is a patch against latest dev. Still works! Please test it!
Comment #27
macedigital commentedHi,
I stumbled upon a few problems with nodequeue-6.x-2.9 while trying to get it running for a site powered by postgresql in the backend and I think I fixed them so far, so I attach a patch (made with svn but should work with any version of patch) addressing all the issues that I found. Maybe these changes could be incorporated into the next release ...
More detailed Explanations:
* use curly braces in function 'nodequeue_generate_rehash' (nodequeue/nodequeue_generate.module) so table prefixes are honored as well
* alter naming for creating indexes
CODE EXAMPLE:
'indexes' => array('{nodequeue_subqueue}_qid_idx' => array('qid'));
EXPECTED INDEX NAME:
'staging_nodequeue_subqueue_qid_idx'
CREATED INDEX NAME:
'staging_nodequeue_subqueue_staging_nodequeue_subqueue_qid_idx_idx' (which in turn may become problematic if you run into the postgresql-specific issue of max 63 allowed characters for keywords and identifiers ... @see http://www.postgresql.org/docs/8.4/static/sql-syntax-lexical.html)
* create primary key for 'nodequeue_types' (nodequeue/nodequeue.install)
* regarding line 150/151 in patch file, postgresql will throw the following error:
"ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list"
* postgresql is also very picky about "group by" clauses omitting all selected columns:
QUERY:
SELECT s.*, COUNT(n.position) AS count FROM staging_nodequeue_subqueue s LEFT JOIN staging_nodequeue_nodes n ON n.sqid = s.sqid WHERE s.sqid IN (1,2,3,5,6) GROUP BY s.sqid
ERROR:
column "s.qid" must appear in the GROUP BY clause or be used in an aggregate function
* regarding : @@ -1867,10 +1867,12 @@ in patch file:
Maybe I misinterpret the intended logic here, but I made the OR conditional more explicit
cheers,
matthias
Comment #28
maartendeblock commented#27 fixed it for me, tnx
Comment #30
macedigital commentedmmh, seems like the automated tests expect patch indexes to be relative to a modules root directory, so i changed to filepath related sections of the patch file (applying reverse patch worked locally)
Comment #31
mhefernan commented#30 worked for me,
Im upgrading from D5, i tried 6.x-2.9 had errors, then tried 6.x-2.x-dev still had errors, removed the files put back 6.x-2.9 update.php ran from Version 1. Errored again
so i patched the files, & ran update again, still had the error relating to columns not being in group by, the column was q.name.
Was weird not sure why this was there as it does not seem to be referenced anywhere in the code, so i deleted that column from the table. and all is well i can see me data again :)
Thanks heaps guys!!
Comment #32
amateescu commentedGo testbot :)
Comment #34
amateescu commentedIt seems that some hunks from nodequeue.install were fixed in #286918: Schema mismatch errors reported by schema.module. Can you roll a patch with all the other changes?
Comment #35
amateescu commentedPosptoning until someone with postgres experience can re-roll the patch from #30.
Comment #36
amateescu commentedMoving to 7.x-2.x.
Comment #37
cedarm commentedIssues I see as of 6.x-2.11:
I'm just keeping a D6 site running..
Comment #38
amateescu commentedCommitted #37b to 6.x-2.x and 7.x-2.x. Finally! Thanks for all the work on this :)
http://drupalcode.org/project/nodequeue.git/commit/dd45955
http://drupalcode.org/project/nodequeue.git/commit/2d396db
Comment #40
liam morlandTagging