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:

  1. "AS" must appear in output column aliases
  2. 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.

CommentFileSizeAuthor
subscriptions_1.5-postgresql.diff2.16 KBpeichman-umd
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

salvis’s picture

Version: 6.x-1.5 » 6.x-1.x-dev
Status: Active » Needs review

Thank 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...)

salvis’s picture

Status: Needs review » Needs work

Yes, it does...

The last submitted patch, subscriptions_1.5-postgresql.diff, failed testing.

salvis’s picture

Never mind, the testbot did run after all, but the patch fails to apply.

salvis’s picture

Status: Needs work » Closed (outdated)