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 have two servers, one runs PostgreSQL 8.2.7 and the Update 6009 failed on it with the following two errors:
- warning: pg_query() [function.pg-query]: Query failed: ERROR: cannot cast type bytea to text LINE 1: ...play SET display_options = CAST(display_options_old AS text) ^ in /usr/clients/www/drupal/includes/database.pgsql.inc on line 185.
- user warning: query: UPDATE views_display SET display_options = CAST(display_options_old AS text) in /usr/clients/www/drupal/includes/database.pgsql.inc on line 960.
The CAST() fails... and the data is lost. (no worries, I had a backup, but some other people might not...)
I have no clue how you could do that translation but by hand (i.e. with a while() loop reading the old data and inserting it in the new table.)
Thank you.
Alexis
Comment | File | Size | Author |
---|---|---|---|
#8 | 765352-pgsql-data-loss.patch | 3.03 KB | merlinofchaos |
Comments
Comment #1
AlexisWilke CreditAttribution: AlexisWilke commentedP.S. my other server has PostgreSQL 8.3.9, that's the one that works properly and accepts the CAST() as is.
Comment #2
dawehnerhttp://drupal.org/node/765236
Is this so hard to find?
Comment #3
dawehnerSorry, for my behavior.
I'm not sure, whether its the same problem for pgsql and for mysql.
Comment #4
javiarauz CreditAttribution: javiarauz commentedSame two errors on pgsql 8.2.16
Greetings,
Javier
Comment #5
dawehnerlets mark this as duplicate of the other issue.
I think its the same.
Comment #6
AlexisWilke CreditAttribution: AlexisWilke commentedThe following works a lot better for my old PostgreSQL server:
Thank you.
Alexis
Comment #7
dawehnerIt should be just be done with non-sql stuff.
Comment #8
merlinofchaos CreditAttribution: merlinofchaos commentedOk, this integrates #6 into a patch that checks for pgsql and uses that code instead. Needs urgent testing.
Comment #9
Dave ReidIs this someplace we should use http://api.drupal.org/api/function/db_change_column/6 instead of db_change_field() since it has extras for PostgreSQL?
Comment #10
merlinofchaos CreditAttribution: merlinofchaos commentedNot according to comments by the pgsql maintainer on http://api.drupal.org/api/function/db_change_field/head
Comment #11
Dave ReidIt has usefulness in a Pgsql-only context for exactly this purpose it seems. Otherwise yes, db_dchange_field() should always be used.
Comment #12
merlinofchaos CreditAttribution: merlinofchaos commentedWell. I would need someone with pgsql to help with this. As soon as possible. We have to get this fix out before more pgsql users get their data destroyed.
Comment #13
merlinofchaos CreditAttribution: merlinofchaos commentedCommitted and hoping for the best.
Comment #14
AlexisWilke CreditAttribution: AlexisWilke commenteddereine,
I'm seeing your answers now... 8-) I don't think that it was the same as that other issue. The other issue talked about the PRIMARY KEY, whereas this one is the CAST that creates a problem. (P.S. I had not even noticed that you marked the issue as a duplicate until now!)
I tried the equivalent of db_change_column() in one of my database and it does not work.
ERROR: column "display_options" is of type text but expression is of type bytea
Thank you for the quick fix Merlin. I hope my fix helped you well. 8-)
I wasn't sure whether you'd want to use a condition or use that code for MySQL as well. It would work for both, although a little slower, it's just for the views definitions so it is relatively limited!
Thank you.
Alexis
Comment #15
gmh04 CreditAttribution: gmh04 commentedHi
I use postgres 8.1 and had the problem upgrading to 6.x-2.9. I restored the display_options table from backup (not the whole site as the backup it was 10 hours old) and installed the 6.x-2.10. The update went well but when I went into the modules page I got the following error:
* warning: Invalid argument supplied for foreach() in /disk/mirror-0/homes/aqmen/distributions/aqmen/modules/views/includes/view.inc on line 1747.
* warning: Invalid argument supplied for foreach() in /disk/mirror-0/homes/aqmen/distributions/aqmen/modules/views/includes/view.inc on line 1747.
* warning: Invalid argument supplied for foreach() in /disk/mirror-0/homes/aqmen/distributions/aqmen/modules/views/includes/view.inc on line 1747.
* warning: Invalid argument supplied for foreach() in /disk/mirror-0/homes/aqmen/distributions/aqmen/modules/views/includes/view.inc on line 1747.
* warning: Invalid argument supplied for foreach() in /disk/mirror-0/homes/aqmen/distributions/aqmen/modules/views/includes/view.inc on line 1747.
* warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error at or near ")" at character 43 in /disk/mirror-0/homes/aqmen/distributions/drupal-6.16/includes/database.pgsql.inc on line 139.
* user warning: query: SELECT * FROM views_display WHERE vid IN () ORDER BY vid, position in /disk/mirror-0/homes/aqmen/distributions/aqmen/modules/views/includes/view.inc on line 1369.
I re-enabled the view module and my views were restored and everything seems to be fine. This error nagging me however.
Thanks for the quick patch!
George
Comment #16
merlinofchaos CreditAttribution: merlinofchaos commentedI've seen that error, it usually means bad cached schema. Try flushing cache?
Comment #17
almalino CreditAttribution: almalino commentedFor you information. I have similar issue as in comment #15 for MySQL database. I created a separate bug report for it since it is different from original bug in this thread.
http://drupal.org/node/769780
Clearing cache didn't help.
Comment #18
AlexisWilke CreditAttribution: AlexisWilke commentedMerlin,
I just noticed that you switched this issue from 3.x to 2.x... I have 3.x and it failed in 3.x (and probably it would do so in 2.x too.)
I just hope that you'll also fix 3.x! 8-)
Thank you.
Alexis
Comment #19
merlinofchaos CreditAttribution: merlinofchaos commentedAny fixes in 2.x will always go forward into 3.x and beyond. I committed this in both branches.