Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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%';
Comment | File | Size | Author |
---|---|---|---|
#8 | postgresfix.patch | 2.75 KB | claar |
#9 | postgresfix.patch | 2.75 KB | claar |
#6 | postgresfix.patch | 2.75 KB | claar |
Comments
Comment #1
starbow CreditAttribution: starbow commentedBummer. 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.
Comment #2
lifepillar CreditAttribution: lifepillar commentedThe 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
Comment #3
starbow CreditAttribution: starbow commentedWill this use of LIKE work in both mysql and postgres?
Comment #4
lifepillar CreditAttribution: lifepillar commentedAs 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
Comment #5
starbow CreditAttribution: starbow commentedComment #6
claar CreditAttribution: claar commentedI 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!
Comment #7
claar CreditAttribution: claar commentedComment #8
claar CreditAttribution: claar commentedThanks 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]
Comment #9
claar CreditAttribution: claar commentedWow -- sorry, I'm new at this. One last try.
Comment #10
Josh Waihi CreditAttribution: Josh Waihi commentedI'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)Comment #11
Shiny CreditAttribution: Shiny commentedworks as advertised -- please can this be committed to CVS?
Comment #12
Shiny CreditAttribution: Shiny commentedCommitted to HEAD.