It seems that postgresql backend is not supported.
For example i get this error:
SELECT COUNT(fid) FROM files WHERE filepath REGEXP '^private_upload';

and i think that in psql should be:
SELECT COUNT(fid) FROM files WHERE filepath like 'private_upload%';

CommentFileSizeAuthor
#8 postgresfix.patch2.75 KBclaar
#9 postgresfix.patch2.75 KBclaar
#6 postgresfix.patch2.75 KBclaar
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

starbow’s picture

Bummer. If someone wants to create a patch, or event just give me equivalent sql querys that work for postgres for all the lines with REGEXP in them, I will roll them into a future version, but I don't have a postgres setup myself to test with.

lifepillar’s picture

The standard (SQL-99) operators for regular expression pattern matching are LIKE and SIMILAR TO. The following changes should do:

line 185:
$old_file_count = db_result( db_query("SELECT COUNT(fid) FROM {files} WHERE filepath LIKE 'private_upload%'") );

line 508:
$db_private_file_count = db_result( db_query("SELECT COUNT(fid) FROM {files} WHERE filepath LIKE '%s%'", $private_path) );

lines 527-529:
$count = db_result( db_query('SELECT COUNT(DISTINCT(f.fid)) '.
'FROM {files} f INNER JOIN {upload} u ON f.fid=u.fid INNER JOIN {node_access} na ON u.nid=na.nid '.
"WHERE na.gid != 0 AND f.filepath NOT LIKE '%s%'", $private_path));

line 584-586:
$result = db_query('SELECT f.* FROM {files} f, {node_access} na '.
" WHERE f.nid = na.nid AND na.gid != 0 AND f.filepath NOT LIKE '%s%' ".
' GROUP BY f.fid', $private_path );

For the differences between LIKE and REGEXP, take a look at http://bugs.mysql.com/bug.php?id=746.

Regards

starbow’s picture

Status: Active » Postponed (maintainer needs more info)

Will this use of LIKE work in both mysql and postgres?

lifepillar’s picture

As far as I am aware, yes, LIKE is supported by both MySQL and PostgreSQL.

http://dev.mysql.com/doc/refman/4.1/en/string-comparison-functions.html

starbow’s picture

Assigned: Unassigned » starbow
Status: Postponed (maintainer needs more info) » Patch (to be ported)
claar’s picture

Category: feature » bug
Status: Patch (to be ported) » Active
FileSize
2.75 KB

I believe this is a bug report, not a feature request.

Anyway, very simple patch against version 6.x-1.0-beta2 attached. I haven't tested this on MySQL, but it works great in PostgreSQL, and the patch uses standard SQL so it should work on MySQL as well. LIKE may be slightly faster than REGEXP as well.

Thanks for a great module!

claar’s picture

Status: Active » Needs review
claar’s picture

FileSize
2.75 KB

Thanks to webchick and davereid, a bug in my patch is now fixed. Attached should be correct.

[edit: Accidentally uploaded the original patch again -- sorry -- please ignore patch attached to this post]

claar’s picture

FileSize
2.75 KB

Wow -- sorry, I'm new at this. One last try.

Josh Waihi’s picture

Status: Needs review » Reviewed & tested by the community

I've applied and tested patch on PostgreSQL 8.3 - works a treat.
Also, just a note, to use regex on PostgreSQL you can use the syntax SIMILAR TO (see: http://www.postgresql.org/docs/8.3/static/functions-matching.html)

Shiny’s picture

works as advertised -- please can this be committed to CVS?

Shiny’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD.

Status: Fixed » Closed (fixed)

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