Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When creating a node, the Subscriptions module throws the following error after the node is created:
warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error at or near "last_sent" at character 320 in /apps/git/libi/drupal/includes/database.pgsql.inc on line 138.
user warning: query: subscriptions_queue INSERT INTO subscriptions_queue (uid, name, language, module, field, value, author_uid, send_interval, digest, last_sent, load_function, load_args, is_new, suspended) SELECT u.uid, u.name, u.language, s.module, s.field, s.value, s.author_uid, s.send_interval, su.digest, COALESCE(sls.last_sent, 0) last_sent, 'subscriptions_content_node_load', '11467', '1', su.suspended FROM subscriptions s INNER JOIN subscriptions_user su ON s.recipient_uid = su.uid INNER JOIN users u ON su.uid = u.uid INNER JOIN term_node tn ON s.value = CAST(tn.tid AS VARCHAR) LEFT JOIN subscriptions_last_sent sls ON su.uid = sls.uid AND s.send_interval = sls.send_interval WHERE s.module = 'node' AND s.field = 'tid' AND s.author_uid IN (1, -1) AND tn.nid = 11467 GROUP BY u.uid, tn.nid, s.module, s.field, s.value, s.author_uid, s.send_interval, su.digest, last_sent, su.suspended in /apps/git/libi/drupal/sites/all/modules/subscriptions/subscriptions.module on line 360.
If the above error is addressed, then the following error occurs in the same situation:
warning: pg_query() [function.pg-query]: Query failed: ERROR: column "u.name" must appear in the GROUP BY clause or be used in an aggregate function in /apps/git/libi/drupal/includes/database.pgsql.inc on line 138.
user warning: query: subscriptions_queue INSERT INTO subscriptions_queue (uid, name, language, module, field, value, author_uid, send_interval, digest, last_sent, load_function, load_args, is_new, suspended) SELECT u.uid, u.name, u.language, s.module, s.field, s.value, s.author_uid, s.send_interval, su.digest, COALESCE(sls.last_sent, 0) AS last_sent, 'subscriptions_content_node_load', '11468', '1', su.suspended FROM subscriptions s INNER JOIN subscriptions_user su ON s.recipient_uid = su.uid INNER JOIN users u ON su.uid = u.uid INNER JOIN term_node tn ON s.value = CAST(tn.tid AS VARCHAR) LEFT JOIN subscriptions_last_sent sls ON su.uid = sls.uid AND s.send_interval = sls.send_interval WHERE s.module = 'node' AND s.field = 'tid' AND s.author_uid IN (1, -1) AND tn.nid = 11468 GROUP BY u.uid, tn.nid, s.module, s.field, s.value, s.author_uid, s.send_interval, su.digest, last_sent, su.suspended in /apps/git/libi/drupal/sites/all/modules/subscriptions/subscriptions.module on line 360.
Both of these errors appear to be caused by SQL dialect differences in PostgreSQL versus MySQL. Specifically, in Postgres:
- "AS" must appear in output column aliases
- Any output columns must be used in aggregate functions or appear in the "GROUP BY" clause when a query has a "GROUP BY" clause
The errors occur:
- When logged in as any user with permissions to create nodes
- When submitting the form to create a node (/node/add/{content-type})
- Drupal Core 6.33
- Subscriptions 6.x-1.5
- PostgreSQL 8.1.23
The attached patch fixes both of these errors.
Comment | File | Size | Author |
---|---|---|---|
subscriptions_1.5-postgresql.diff | 2.16 KB | peichman-umd | |
Comments
Comment #1
salvisThank you for the analysis and patch. Let's see what the testbot says.
(I'm not sure whether it needs the extension .patch to get triggered...)
Comment #2
salvisYes, it does...
Comment #4
salvisNever mind, the testbot did run after all, but the patch fails to apply.
Comment #5
salvis