PostgreSQL uses double quotes to escape table and column names so using double quotes around strings is not a good idea. These fail on PostgreSQL

db_query('INSERT INTO {search_files_helpers} VALUES(NULL, "%s", "%s", "%s")', "PDF", "pdf", "/usr/bin/env pdftotext %file% -");
db_query('INSERT INTO {search_files_helpers} VALUES(NULL, "%s", "%s", "%s")', "Text", "txt", "/usr/bin/env cat %file%");

Should be

db_query("INSERT INTO {search_files_helpers} VALUES(NULL, '%s', '%s', '%s')", "PDF", "pdf", "/usr/bin/env pdftotext %file% -");
db_query("INSERT INTO {search_files_helpers} VALUES(NULL, '%s', '%s', '%s')", "Text", "txt", "/usr/bin/env cat %file%");

Now that search files is becoming an api, other modules are starting to use it. more the reason to have good support.

CommentFileSizeAuthor
#1 494890.patch1.98 KBjhodgdon

Comments

jhodgdon’s picture

Status: Active » Needs review
StatusFileSize
new1.98 KB

Here is a patch against the 6.2 branch of Search Files. I only patched the Search Files API module. I have tested that it still installs and uninstalls fine under MySQL -- hopefully someone who has PostgreSQL can test on that platform?

jhodgdon’s picture

And by the way, although the patch only affects the .install file, I did look at the .module file, and there doesn't appear to be any quote problem there.

josh waihi’s picture

Status: Needs review » Reviewed & tested by the community

I like it.

jhodgdon’s picture

Is there some way we could get this fix into Search Files HEAD, and then into a Beta or RC release sometime soon? I am hoping to use Search Files API as a dependency of a new version of my Search by Page module, and it is holding me up that Search Files API cannot be installed on PostgreSQL. (see #460942: Add file indexing support.)

Thanks!

thl’s picture

Assigned: Unassigned » thl
Status: Reviewed & tested by the community » Fixed

Fixed in 6.x-2.0-beta2, see name space and visible text cleanup: SQL statement unification ...
Won't fix 6.x-1.x which currently occupies HEAD

jhodgdon’s picture

Excellent - thanks very much!

Status: Fixed » Closed (fixed)
Issue tags: -PostgreSQL

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