I have a new Drupal installation using a table prefix of "prj_". When I try to use the OG search box (the one in the group information block) I get this error:
user warning: Table 'projects.prj_temp_search_results' doesn't exist query: SELECT count( DISTINCT(node.nid)) FROM prj_node node LEFT JOIN prj_temp_search_results temp_search_results ON node.nid = temp_search_results.sid LEFT JOIN prj_og_ancestry og_ancestry ON node.nid = og_ancestry.nid WHERE (temp_search_results.sid IS NOT NULL) AND (node.status = '1') AND (og_ancestry.group_nid = 3) in /var/www/projectserver/includes/database.mysql.inc on line 172.
Use the site-wide search box works fine. I can work around the problem by adding this to my settings.php:
$db_prefix = array(
'default' => 'prj_',
'temp_search_results' => ''
);
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | prefix_temp_table.patch | 1.13 KB | schuyler1d |
| #7 | views_query_table_prefix.patch | 2.43 KB | David Lesieur |
Comments
Comment #1
moshe weitzman commentedcan you try a View that doesn't involve og but does involve Search index? I think this is a views_search.inc bug
Comment #2
starkos commentedSorry, I'm a bit of a newbie - can you give me an example of a view to try? I'm afraid that I'm not clear what views drive what content. Thanks for the assist.
Comment #3
moshe weitzman commentedMake a View using Search in the Filter section. See if it works with prefixes.
Comment #4
moshe weitzman commentedMoving to Views project. I think some part of Views thinks that temp tables are prefixed - they are not AFAIK since they are only valid to the caller and thus can't collide.
Comment #5
mlncn commentedConfirming this bug with a (not-so-clean) install of Organic Groups, Views 1.6.
Probably the error is coming from this line number:
/var/www/wsf2008/modules/contributed/views-5.x-1.6/views/views.module: 412
Comment #6
mlncn commentedWish it were that simple...
This is where the table prefixes are added, near as I can tell, for every views query:
Line 599 of views_query.inc:
But I don't see any way to turn this off for the temporary table except with an ugly conditional statement. Would it be easier to prefix the temporary table when it's created (wherever that may be)?
Comment #7
David Lesieur commentedI have the same issue with an argument handler that needs to join a temporary table. Would this patch be a good idea?
Comment #8
freakalis commentedI have applied your patch but still get errors. Do you have do change anything else then apply this patch?
Comment #9
David Lesieur commentedThis patch does not actually fix the problem some modules might have at the moment, but provides them a way to say "add this database table to the view, but please, do not prefix it". If this patch is accepted in Views, modules will then be able to specify an additional
$use_table_prefixargument when callingadd_table().Comment #10
moshe weitzman commentedthis is hurting more than a few people.
Comment #11
merlinofchaos commentedAs a workaround I suggest you set that particular table not to prefix in settings.php using the $db_prefix array. I believe that workaround will get around the problem.
Comment #12
geek-merlinthis really hurts.
subscribing.
Comment #13
jackspiv commentedany progress on this?
A related question that may belong here, but probably in OG
Any way to simply remove the broken search box from the Organic Groups group details block?
Comment #14
merlinofchaos commentedRelax. I suggested a workaround, it should alleviate your problems.
Comment #15
geek-merlinMerlins Workaround does work here for me!
Comment #16
jackspiv commentedOops,
I forgot to check back in and thank merlin.
The workaround also works for me.
Thankyou! (belatedly)
Comment #17
schuyler1d commentedwell, this doesn't fix the temporary tables issue in general, but this patch does fix the issue for the search filter's use of temporary tables, and suggests a pattern when using them.
Anyone who implemented the workaround should also be safe patching, even if they don't reconfig the $db_prefix
Comment #18
EvanDonovan commentedI have tested to see if this error still occurs in Views 2 for Drupal 6.x, and it appears to do so.
Has anyone else had the same experience with Views 2, and, if so, is it possible for a patch to be created? I am grateful to merlinofchaos for the suggestion in #11, but I would ideally not like to have to set a separate prefix setting for dozens of temporary tables, as I am currently doing.
Comment #19
merlinofchaos commentedDrupal core in D6 no longer utilizes temporary tables, so there isn't really a problem anymore.
In Views 2, you can create a new join handler, which can be utilized to create the join without the prefixing, if desired. You can then use that handler in your join definitions when adding temporary tables.
Also, there's a sitting patch for 5.x here, so moving this issue to 6.x causes unnecessary confusion.
Comment #20
EvanDonovan commentedmerlin, thanks for the update. So you're saying that the way to handle temporary tables in Views 2 is to use a join handler?
The views that I created to integrate with faceted search (see Faceted Search issue #227634: Views tries to prefix temporary tables) still have issues without changes to my settings.php, but I converted them straight from Views 1 so they don't use a join handler.
As far as the issue's version number, I wasn't sure whether I should bump it or not. I only bumped it because I was encountering the issue in 6.x, and I know that the practice for core at least is to bump issues to the highest version number, and then backport. If your practice is different, I apologize for creating confusion.
Comment #21
merlinofchaos commentedYes, create a custom join handler for the temporary table. While custom join handlers are extremely uncommon, that's the way to deal with it without needing to patch Views.
Comment #22
esmerel commentedAt this time, only security fixes will be made to the 5.x version of Views.