[development] portability issue with uid=0 being anonymous

David Strauss david at fourkitchens.com
Thu Nov 1 18:43:22 UTC 2007


Christoph Otto (Volt) wrote:
> 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.

I'm pushing for anonymous users to be NULL in Drupal 7. SQL Server isn't
the only RDBMS with issues setting an identity/autoincrement column to
zero. There are some nasty fixes in place for even MySQL.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 186 bytes
Desc: OpenPGP digital signature
Url : http://lists.drupal.org/pipermail/development/attachments/20071101/e9bd5815/attachment.pgp 


More information about the development mailing list