Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
postgresql database
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
7 Oct 2010 at 22:24 UTC
Updated:
29 Jul 2014 at 19:05 UTC
Jump to comment: Most recent file
Comments
Comment #1
sun1) With "upgrade", do you mean upgrading from D6 or merely an earlier version of D7?
2) On which database is this? Doesn't look like MySQL?
It's possible that you found a Drupal core bug -- in which case this issue should be moved into the core queue.
Comment #2
miklThis was from the alpha/beta2 (don’t remember, those releases have been removed since then) release of Mollom for Drupal 7 on a fresh install.
The database is indeed not MySQL, but PostgreSQL.
Comment #3
sunThe module update tries to perform the following (which works as intended on MySQL):
The db_change_field() leads to the error message:
Looking through the postgres driver, I see that code in DatabaseSchema_pgsql::changeField():
But based on the error message, it looks like neither ::createFieldSql() nor ::fieldSetNoDefault() is invoked from ::changeField().
In other words:
1) A previously specified 'default' is not removed or changed prior to changing the column type.
2) Somehow, the passed in $spec and ::createFieldSql() is not invoked or used, so I wonder how more subtle column differences are actually applied on PostgreSQL? E.g., nothing seems to happen when varchar(64) is changed to varchar(255)...?
Comment #4
Stevel commenteddoh! Subscribing this so I can come back to this when I have some more time.
Comment #5
Stevel commentedHow is this for changing defaults?
The second remark from sun was fixed in #951116: db_change_field() fails to convert int to varchar on PostgreSQL I believe.
Comment #6
Stevel commentedNew patch to account for 0, false and other 'empty' variables as default values.
Comment #8
Stevel commented#6: 935258-change-default-nulls.patch queued for re-testing.
Well, how's that... A change in the DatabaseSchema for Postgresql causes test failures on mysql...
Comment #9
Stevel commentedChanging title to reflect the actual bug. Also raising to major there are contrib modules (e.g. mollom) for which the upgrade path fails because of this.
Comment #10
Crell commentedThat's not the right syntax for array_key_exists(). See:
http://www.php.net/array_key_exists
I think
array_key_exists('default', $spec)should be sufficient.Powered by Dreditor.
Comment #11
Stevel commentedUpdated the patch. The isset || array_key_exists seems to be a common pattern in drupal core for efficienty reasons (as far as I understood it).
Comment #12
sunMissing trailing period.
Actually, I don't think that NULL is a valid value for 'default', as that would translate into 'not null' => FALSE instead. Therefore, the isset() should be sufficient.
Powered by Dreditor.
Comment #13
Stevel commentedYes, you are right. NULL is the default default (twice, yes), so we don't have to set a default explicitly if it is NULL. Updated patch again.
Comment #14
sunUnless @Crell disagrees, this looks ready to fly for me.
Comment #15
webchickWe need someone to test the pgsql upgrade path.
Comment #16
josh waihi commentedI get as far as visting update.php and get the following error:
Update:
DatabaseSchemaObjectDoesNotExistException: Cannot set default value of field actions.description: field doesn't exist. in DatabaseSchema_pgsql->fieldSetDefault() (line 397 of /home/josh/drupal/935258/includes/database/pgsql/schema.inc).
Comment #17
Stevel commentedAre you sure you don't get the error without the patch applied?
How are indexes related to default values? This belongs in it's own issue I think (is this the same bug as #935570: Cannot add "system list" because "system" already exists?)
Comment #18
josh waihi commentedsorry, that was the wrong error (is was after I refreshed). Its actually:
DatabaseSchemaObjectDoesNotExistException: Cannot set default value of field actions.description: field doesn't exist. in DatabaseSchema_pgsql->fieldSetDefault() (line 397 of /home/josh/drupal/935258/includes/database/pgsql/schema.inc).
Comment #19
josh waihi commentedWas a php variable error. $field was being used after $field had been renamed to $new_field.
Comment #20
Stevel commenteddoh, of course :) If you don't have any further comments, I guess this is RTBC then.
Comment #21
Stevel commentedComment #22
catchComment #23
dries commentedI don't have PostgreSQL to test on, but decided to commit this to 8.x and 7.x. Thanks.
Comment #24
josh waihi commentedThanks Dries :)