Hi

There are a problen with this query in postgresql
db_query('DELETE ta FROM {term_access} ta LEFT JOIN {term_data} td ON ta.tid = td.tid WHERE ta.tid <> 0 AND ISNULL(td.tid)');

In postgresql is only possible "Delete from", not "delete xxx from"

Thanks

CommentFileSizeAuthor
#4 taxonomy_access.patch2.69 KBplj

Comments

cpugeniusmv’s picture

Status: Active » Fixed

Fixed in 5.x-2.x-dev and 6.x-1.x-dev.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

plj’s picture

Version: 5.x-2.x-dev » 6.x-1.x-dev
Priority: Normal » Critical
Status: Closed (fixed) » Active

This is NOT fixed in 6.x-1.x-dev. Not even close.

The following MySQL-specific features (among others) cannot be used in PostgreSQL:

  • Table aliases in DELETE or UPDATE statements (only in SELECTs)
  • JOINs in DELETE or UPDATE statements (only in SELECTs)
  • ISNULL function (the right syntax is “…WHERE td.tid IS NULL”)

Building a DELETE query for data that is selected by join would be rather complicated and end up using PostgreSQL-specific code; better way would be to run “SELECT ta.tid FROM {term_access} ta LEFT JOIN {term_data} td ON ta.tid = td.tid WHERE ta.tid <> 0 AND td.tid IS NULL” and then use the result set of that query in a foreach loop that deletes the relevant rows.

The problematic function is taxonomy_access_enable().

plj’s picture

Status: Active » Needs review
StatusFileSize
new2.69 KB

OK, here is a patch that really squashes this bug.

Note that this could still be better because it might work on all DBs, but I don't currently have any MySQL setup to test it on, so I left the MySQL code as it is, as I didn't want to break anything.

cpugeniusmv’s picture

Status: Needs review » Fixed
plj’s picture

Phew, you had actually noticed that I had forgotten my table prefixes into the patch! I only realised it now, after you'd already committed it. Thanks for fixing that!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.