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.
I get this error :
Warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error on or near "cache" at character 13 in /var/www/drupal/includes/database.pgsql.inc on line 45
Fatal error: ERROR: syntax error on or near "cache" at character 13 query: LOCK TABLES cache WRITE in /var/www/drupal/includes/database.pgsql.inc on line 62
Someone could solve this problem ?
Thanks
kinaï
Comment | File | Size | Author |
---|---|---|---|
#13 | drupal-head-lock_0.diff | 2.82 KB | Cvbge |
#11 | drupal-head-lock.diff | 2.82 KB | Cvbge |
#7 | locks_1.diff | 2.81 KB | Cvbge |
#5 | locks_0.diff | 2.8 KB | Cvbge |
#4 | locks.diff | 2.91 KB | Cvbge |
Comments
Comment #1
kinai CreditAttribution: kinai commentedThe SQL Command : LOCK TABLES like used in bootstrap.inc is only specified for MySQL, not for PostgreSQL.
The UNLOCK TABLES SQL command is not implemented in PostgreSQL.
Someone could solve this problem ?
Thanks,
Kinaï
Comment #2
intel352 CreditAttribution: intel352 commentedthis issue still exists, i've verified it on a fresh cvs install w/ pgsql 8
Comment #3
intel352 CreditAttribution: intel352 commentedi fixed the problem in my installation, by changing the syntax to:
LOCK TABLE {cache}
it's table, not tables. and i dropped the 'write' bit.
furthermore, pgsql does not support the UNLOCK command, so i had to comment the unlock tables command. unless there are more lock/unlock commands elsewhere in the code, this works fine for me.
according to pgsql docs, UNLOCK is automatically performed at transaction end, which is why there is no such command.
Comment #4
Cvbge CreditAttribution: Cvbge commentedThe patch adds two functions to lock and unlock tables.
Comment #5
Cvbge CreditAttribution: Cvbge commentedUpdated, without unnecessary changes.
Comment #6
chx CreditAttribution: chx commentedCvbge says he tested pgsql, I applied to a mysql one, saved system settings and looks OK.
Comment #7
Cvbge CreditAttribution: Cvbge commentedWorked, yet not worked ...
This version does not use
db_query("{$table}" )
syntax. I promise I won't do that again!Comment #8
Dries CreditAttribution: Dries commentedMySQL is happy with the singular 'LOCK TABLE' (rather than 'LOCK TABLES') which should work with both MySQL and PostgreSQL. Committed that changes to CVS.
Comment #9
Dries CreditAttribution: Dries commentedComment #10
Cvbge CreditAttribution: Cvbge commentedPlease rollback your patch and either
a) use syntax
LOCK TABLE name
(dropping S and WRITE, if you say that mysql support "LOCK")b) apply my patch.
Postgres does not support WRITE part (as well as S part).
Also locking won't work without starting transaction.
You can do
LOCK TABLE name
only, but this lock is too excessive and won't allow even SELECTs on locked table.Comment #11
Cvbge CreditAttribution: Cvbge commentedAttached updated patch for current head.
Comment #12
Thomas Ilsche CreditAttribution: Thomas Ilsche commented+1
tested the patch on pgsql, runs as expected.
Comment #13
Cvbge CreditAttribution: Cvbge commentedTable names are now escaped
Comment #14
Dries CreditAttribution: Dries commentedCommitted to HEAD.
Comment #15
Cvbge CreditAttribution: Cvbge commentedA sidenote about escaping table names:
db_escape_string() uses pg__escape_string(), from it's php docs:
. It assumes that it will be in ''. For example it does not esape ";"mysql's version does addslashes, but it does not escape ";" either.
For postgresql correct way might be to use "" and escape ", but I'd have to check it. Is it worth it?
Comment #16
(not verified) CreditAttribution: commentedComment #17
(not verified) CreditAttribution: commented