[development] portability issue with uid=0 being anonymous
Christoph Otto (Volt)
a-chotto at microsoft.com
Thu Nov 1 18:34:01 UTC 2007
I'm porting the Drupal 6 beta to run on the new sqlsrv driver for SQL Server 2005 and am running into some issues around the way uid 0 and 1 are set to anonymous and admin. The current code (modules/system/system.install line 249) inserts placeholders into uid = 1 and 2 then subtracts 1 from each uid via an UPDATE. This works fine for MySQL and PostgreSQL, but isn't portable to SQL Server 2005, which doesn't allow IDENTITY columns to be changed. (The only way I've found to do it is to create a new column and insert the new values, but this is not elegant.)
My approach has been to add an 'initial value' key to the 'fields' array returned by hook_schema. If this value is set for a 'serial' field, the value will be the first in the sequence. Both PostgreSQL and SQL Server 2005 have ways to make an serial or IDENTITY column start at 0, but I haven't found a way that works for MySQL. (Adding AUTO_INCREMENT=0 to the end of the table definition silently fails, even with sqlmode=NO_AUTO_VALUE_ON_ZERO.) The attached patch against CVS works correctly for PostgreSQL but breaks on MySQL.
I'm not attached to any alternative way of making this port work and would appreciate any input.
Thanks,
Christoph Otto (Volt)
a-chotto at microsoft.com
Microsoft Open Source Software Lab
-------------- next part --------------
A non-text attachment was scrubbed...
Name: initial_value.patch
Type: application/octet-stream
Size: 3923 bytes
Desc: initial_value.patch
Url : http://lists.drupal.org/pipermail/development/attachments/20071101/c3d54117/attachment.obj
More information about the development
mailing list