Running Postgresql 8.4 here, and ran across two SQL syntax issues blocking search_by_page from actually searching.
One is basically the same issue as http://drupal.org/node/293504 - Postgresql does not treat bare '0' or '1' as a BOOLEAN value. Simple fix (as in linked issue) is converting 1 -> 1=1 and 0 -> 0=1. (Perhaps a better solution would be dropping the cases of " ... AND 1 AND ... " and " ... 0 OR ... ", but that seems a bit more involved.)
The other is two spots that end up returning "INNER JOIN (node sbpa_n)" and "LEFT JOIN (node sbpn_n)" - in the code, there is "$stuff[0]" (filled search_by_page_unique_rewrite() ) being referenced inside the parens, but the contents always seem to be empty, and Postgresql is choking on the parens... Not sure what the intent is here, but removing the parens appears to result in a functional module. (Perhaps the parens need to be conditional on search_by_page_unique_rewrite() actually returning something?)
Patch containing both changes attached:
| Comment | File | Size | Author |
|---|---|---|---|
| search_by_page-postgresqlcompat.diff | 1.71 KB | iv |
Comments
Comment #1
jhodgdonThanks for the testing on PostgreSQL and the patch! I will run this through its paces and get it into SBP as soon as I can.
Setting to Needs Review so the testing bot can test it...
Comment #2
jhodgdonI took a look at your suggested patch.
There is a problem with the chunk here:
In the general case (if you are using node access modules) those parentheses are actually needed, because that will be a complex join. So we can't actually leave out the parentheses.
There's a similar issue farther down in the patch.
I am not familiar enough with PostgreSQL to know what to do about this... any thoughts?
Comment #3
jhodgdonOh I see, you are saying that if $stuff is empty, to leave out the parens... Do you think PostgreSQL will be happy with that?
Comment #4
iv commentedYup. When $stuff is empty, postgres chokes on the parens, but when the parens are actually required, they are accepted just fine.
(I couldn't see any cases where that particular invocation of search_by_page_unique_rewrite() was actually returning anything in $stuff, but I'm only using the built-in access controls...)
Comment #5
jhodgdonOK, I'll see what I can do. Thanks for the report and information.
Comment #6
jhodgdonAnd yes, you have to be using a custom or contributed access control module in order to see something happening in there other than an empty $stuff.
Comment #7
jhodgdonJust an update: I've set up a PostgreSQL testing box, and I am seeing multiple problems running the Search by Page tests in Postgres, with both D6 and D7 versions of Search by Page.
I'm working on fixing all the errors, and will report back...
Comment #8
jhodgdonI have just committed fixes to Search by Page for PostgreSQL compatibility to the development branch in 6.x. You can get them from CVS now, or wait several hours and download from the project page (they dont' update the zip files there immediately - just check the time stamp and make sure it's after this comment was submitted, i.e. Aug 17 or later).
I will probably make a 6.x-1.12 release in the next week or two, but feel free to test.
Next task: get 7.x working with PostgreSQL also.
Comment #9
jhodgdonUpdate: 7.x is not working with PostgreSQL yet. I believe the tests are failing due to one or two core Drupal issues. More investigation coming...
Meanwhile, 7.x does work fine with SQLite and MySQL (all the tests pass).
Comment #10
jhodgdonOh, one other note on Postgres in 6.x - if you are running Drupal 6.19, you will also need the fix here http://drupal.org/node/488166#comment-3339748 to do much with the Search module (i.e. the core Search module is broken for Postgres).
Comment #11
jhodgdonUpdate on Drupal 7:
- I've committed some changes to the Drupal 7 development version for PostgreSQL compatibility.
- In the process of testing on PostgreSQL, I uncovered two core Drupal issues. Until they are fixed, the Search by Page module family will not work quite right in Drupal 7, at least in PostgreSQL, although one of the issues probably affects MySQL and SQLite as well (but only for the case of using Search by Page Attachments along with a node permissions/access module such as Content Access or Workflow Access).
The Drupal core issues that need to be fixed for Search by Page to work correctly in PostgreSQL:
#886970: DB API putting wrong db placeholders in complex queries
#886752: SQL error on PostgreSQL in comment.module
Comment #12
jhodgdonMeanwhile, the Search by Page module itself is now PostgreSQL (D6 and D7) and SQLite (D7) compatible, as far as I can tell (it at least passes all the automated tests for all 5 combinations of version and database, at least with the latest development versions of Drupal and Search by Page). So I will go ahead and mark this issue fixed.
Comment #13
jhodgdonOh, one more note: If you are running Drupal 6.19, you may be affected by this issue in PostgreSQL:
#488166: Search relevance calculation fails if last_comment_timestamp is NULL
Comment #14
iv commentedThank you! That was remarkably ...comprehensive. Very much appreciated.
I've been running 6.x-1.x-dev from August 17th for the past week or so, and it's been working great.
Thanks again!