Bug tracker

This ticket has been moved to our new tracker. Open Ticket PHPBB3-1986 now.

Every derived table must have its own alias [1248] (fix completed in vcs)

I've got all settings on default for the search and when I wanted to search for the word "bla" I got this:

General Error
SQL ERROR [ mysql ]

Every derived table must have its own alias [1248]

SQL

SELECT COUNT(post_id) as total_results FROM (SELECT DISTINCT p.post_id FROM (phpbb2_search_wordmatch m0, phpbb2_posts p) WHERE m0.post_id = p.post_id AND m0.word_id = 16)

BACKTRACE

FILE: includes/db/mysql.php
LINE: 130
CALL: dbal->sql_error()

FILE: includes/search/fulltext_native.php
LINE: 622
CALL: dbal_mysql->sql_query()

FILE: search.php
LINE: 398
CALL: fulltext_native->keyword_search()

When it doesn't find anything it displays correctly that there are no posts matching that criteria.

Comments / History

Posted by Acyd Burn (Server Manager) on Nov 3rd 2006, 17:42

Nils, while fixing the sql_layer (it should be mysql4 instead of mysql Smile) i also saw this in fultext_native:

Code: Select all
$sql_array_count['SELECT'] = ($type == 'posts') ? 'DISTINCT p.post_id' : 'DISTINCT p.topic_id';
$sql = 'SELECT COUNT(' . (($type == 'posts') ? 'post_id' : 'topic_id') . ') as total_results
FROM (' . $db->sql_build_query('SELECT', $sql_array_count) . ')';



I am not sure, but subselects are only supported in mysql >= 4.1 and this code has been introduced for mysql3 as a replacement for SQL_CALC_FOUND_ROWS? Smile Something is not right here. Smile

Posted by Acyd Burn (Server Manager) on Nov 3rd 2006, 17:44

Oh, and if you really use a subselect you need to ensure that every table is having an alias:

Code: Select all
SELECT COUNT(p2.post_id) AS total_results
FROM (SELECT DISTINCT p.post_id FROM (phpbb_search_wordmatch m0, phpbb_posts p)
WHERE m0.post_id = p.post_id AND m0.word_id =16)
p2

Posted by DavidMJ (Former Team Member) on Nov 4th 2006, 05:12

For older versions, they should be rewritten as some sort of join like this

Posted by naderman (Development Team Leader) on Nov 4th 2006, 13:02

I did not make MySQL use subselects, subselects were only for sqlite in that case. While changing the Layer stuff it appears you have accidently changed it to handle mysql as if it was sqlite.

Linked ticket with changeset: r6559

Action performed by naderman (Development Team Leader) on Nov 5th 2006, 20:52

Ticket details

Related SVN changesets