When you do a search with the ob_vocab installed, you will have this SQL WARNING:

user warning: Unknown column 'v.vid' in 'on clause' query: SELECT t.tid FROM vocabulary v, term_data t LEFT JOIN og_vocab ov ON v.vid = ov.vid WHERE (v.module = 'og_vocab' AND ov.nid != 0) AND t.vid=v.vid in /home/mainapa/workspace/water-drupal/includes/database.mysql.inc on line 172.

The query:

$sql = "SELECT t.tid FROM {vocabulary} v, {term_data} t LEFT JOIN {og_vocab} ov ON v.vid = ov.vid WHERE (v.module = 'og_vocab' AND ov.nid != %d) AND t.vid=v.vid";

I think that is only MYSQL 5 bug, because it give more precedence to JOIN statement.

So the fix is simple:

$sql = "SELECT t.tid FROM ({vocabulary} v, {term_data} t) LEFT JOIN {og_vocab} ov ON v.vid = ov.vid WHERE (v.module = 'og_vocab' AND ov.nid != %d) AND t.vid=v.vid";

First, give precedence to NATURAL JOIN for v and t and then LEFT JOIN with og_vocab, that is the beahvoiur of MYSQL 4.

That's all

CommentFileSizeAuthor
#2 search_config-288098.patch979 bytesjbomb

Comments

paolomainardi’s picture

From MYSQL 5 Manual:

Previously, the comma operator (,) and JOIN both had the same precedence, so the join expression t1, t2 JOIN t3 was interpreted as ((t1, t2) JOIN t3). Now JOIN has higher precedence, so the expression is interpreted as (t1, (t2 JOIN t3)). This change affects statements that use an ON clause, because that clause can refer only to columns in the operands of the join, and the change in precedence changes interpretation of what those operands are.

Link: http://dev.mysql.com/doc/refman/5.0/en/join.html

jbomb’s picture

Version: 5.x-1.3 » 6.x-1.x-dev
StatusFileSize
new979 bytes

This is still relevant for the 6.x branch. Here's a patch for paolomainardi's solution.

jbomb’s picture

Status: Active » Patch (to be ported)

Committed to 6.x branch.

jbomb’s picture

Status: Patch (to be ported) » Fixed

committed to 5.x branch.

Status: Fixed » Closed (fixed)

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