Closed (fixed)
Project:
Drupal core
Version:
6.x-dev
Component:
documentation
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
7 Nov 2007 at 13:53 UTC
Updated:
22 Nov 2007 at 16:12 UTC
Jump to comment: Most recent file
Column blocks.pages has no default value and therefore must always be specified when inserting a new row. If it is not, MySQL uses an "implicit default value" but PostgreSQL properly fails the query.
The new _block_rehash, from http://drupal.org/node/80963, does not specify a value for pages so the query fails on that db.
Patch attached.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | block-rehash-pages-190128-8.patch | 935 bytes | bjaspan |
| #8 | postgresql_sucks.patch | 557 bytes | chx |
| block-rehash-pages.patch | 694 bytes | bjaspan |
Comments
Comment #4
bjaspan commentedI deleted some previous comments of mine that turned out to be wrong.
The reason blocks.pages has no default value is that mysql does not allow default values on text columns. You can actually specify default '' when creating a column but if you then ask mysql what the column's default value is, it says it does not have one.
Confusion arises because of mysql's (IMHO stupid) "implicit default value" rules which will use '' as the default value for a text column if no other value is provided and the column is NOT NULL. This has allowed a lot of sloppy coding.
If we want to have a single database schema for mysql and pgsql and have schema.module able to verify that the database matches the schema, we cannot allow default values for text columns. Therefore, my patch to block.module is correct; a value for pages must be provided explicitly.
Comment #5
gábor hojtsyMaybe add a short onliner above it like "// Empty value required by PostgreSQL" or something would be good, otherwise it looks puzzling.
Comment #6
gregglesHow would someone test this patch?
Enable a module that provides a block?
Edit the block admin page?
Comment #7
chx commentedYou need to check whether pages is set and only if not then set default -- we want to let people to specify whatever in their hook_block.
Comment #8
chx commentedComment #9
bjaspan commented#5 and #7: Fixed. New patch attached.
#6: To test this patch: Use pgsql. Display admin/build/blocks (or call _block_rehash()), removing any obsolete blocks from the db. Enable a new module that defines a block but does not specify a 'pages' value in the hook_block('list') output. Display admin/build/blocks (or call _block_rehash()) again. Without the patch, a query error results; with the patch, it does not. This could be done manually or via simpletest.
Comment #10
bjaspan commentedI guess chx attached his patch while I was rewriting mine. They are functionally identical so it is fair to say we have reviewed each other's patches, so I'll agree with his RTBC. :-)
BTW, in this case I have to say it is mysql that sucks, not pgsql. mysql's "implicit default values" are a horrible idea that leads to sloppy coding and it is mysql, not pgsql, that cannot handle a default value on text columns.
Comment #11
gábor hojtsyThanks, committed.
Comment #12
gábor hojtsyBTW same problem with the log field here: http://drupal.org/node/188462
Comment #13
bjaspan commentedI need to document this to the Schema API handbook.
Comment #14
gábor hojtsyIn which case it is not fixed, and not critical anymore.
Comment #15
bjaspan commentedDocumented at http://drupal.org/node/190504.
Comment #16
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.