? block-sql.patch
Index: modules/block/block.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.admin.inc,v
retrieving revision 1.16
diff -u -p -r1.16 block.admin.inc
--- modules/block/block.admin.inc	16 Apr 2008 11:35:51 -0000	1.16
+++ modules/block/block.admin.inc	30 Apr 2008 00:36:07 -0000
@@ -255,7 +255,7 @@ function block_admin_configure(&$form_st
 
 function block_admin_configure_validate($form, &$form_state) {
   if ($form_state['values']['module'] == 'block') {
-    if (empty($form_state['values']['info']) || db_result(db_query("SELECT COUNT(*) FROM {boxes} WHERE bid != %d AND info = '%s'", $form_state['values']['delta'], $form_state['values']['info']))) {
+    if (empty($form_state['values']['info']) || db_result(db_query("SELECT COUNT(*) FROM {boxes} WHERE bid <> '%s' AND info = '%s'", $form_state['values']['delta'], $form_state['values']['info']))) {
       form_set_error('info', t('Please ensure that each block description is unique.'));
     }
   }
@@ -284,7 +284,8 @@ function block_add_block_form(&$form_sta
 }
 
 function block_add_block_form_validate($form, &$form_state) {
-  if (empty($form_state['values']['info']) || db_result(db_query("SELECT COUNT(*) FROM {boxes} WHERE info = '%s'", $form_state['values']['info']))) {
+  $delta = strtolower(preg_replace('/[^a-z0-9]/i', '-', $form_state['values']['info']));  
+  if (empty($form_state['values']['info']) || db_result(db_query("SELECT COUNT(*) FROM {boxes} WHERE bid = '%s'", $delta))) {
     form_set_error('info', t('Please ensure that each block description is unique.'));
   }
 }
@@ -293,12 +294,12 @@ function block_add_block_form_validate($
  * Save the new custom block.
  */
 function block_add_block_form_submit($form, &$form_state) {
-  db_query("INSERT INTO {boxes} (body, info, format) VALUES ('%s', '%s', %d)", $form_state['values']['body'], $form_state['values']['info'], $form_state['values']['format']);
-  $delta = db_last_insert_id('boxes', 'bid');
+  $delta = strtolower(preg_replace('/[^a-z0-9]/i', '-', $form_state['values']['info']));
+  db_query("INSERT INTO {boxes} (bid, body, info, format) VALUES ('%s', '%s', '%s', %d)", $delta, $form_state['values']['body'], $form_state['values']['info'], $form_state['values']['format']);
 
   foreach (list_themes() as $key => $theme) {
     if ($theme->status) {
-      db_query("INSERT INTO {blocks} (visibility, pages, custom, title, module, theme, status, weight, delta, cache) VALUES(%d, '%s', %d, '%s', '%s', '%s', %d, %d, %d, %d)", $form_state['values']['visibility'], trim($form_state['values']['pages']), $form_state['values']['custom'], $form_state['values']['title'], $form_state['values']['module'], $theme->name, 0, 0, $delta, BLOCK_NO_CACHE);
+      db_query("INSERT INTO {blocks} (visibility, pages, custom, title, module, theme, status, weight, delta, cache) VALUES(%d, '%s', %d, '%s', '%s', '%s', %d, %d, '%s', %d)", $form_state['values']['visibility'], trim($form_state['values']['pages']), $form_state['values']['custom'], $form_state['values']['title'], $form_state['values']['module'], $theme->name, 0, 0, $delta, BLOCK_NO_CACHE);
     }
   }
 
@@ -328,7 +329,7 @@ function block_box_delete(&$form_state, 
  * Deletion of custom blocks.
  */
 function block_box_delete_submit($form, &$form_state) {
-  db_query('DELETE FROM {boxes} WHERE bid = %d', $form_state['values']['bid']);
+  db_query("DELETE FROM {boxes} WHERE bid = '%s'", $form_state['values']['bid']);
   db_query("DELETE FROM {blocks} WHERE module = 'block' AND delta = %d", $form_state['values']['bid']);
   drupal_set_message(t('The block %name has been removed.', array('%name' => $form_state['values']['info'])));
   cache_clear_all();
Index: modules/block/block.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.install,v
retrieving revision 1.10
diff -u -p -r1.10 block.install
--- modules/block/block.install	16 Apr 2008 11:35:51 -0000	1.10
+++ modules/block/block.install	30 Apr 2008 00:36:07 -0000
@@ -22,7 +22,7 @@ function block_schema() {
       ),
       'delta' => array(
         'type' => 'varchar',
-        'length' => 32,
+        'length' => 128,
         'not null' => TRUE,
         'default' => '0',
         'description' => t('Unique ID for block within a module.'),
@@ -130,9 +130,10 @@ function block_schema() {
     'description' => t('Stores contents of custom-made blocks.'),
     'fields' => array(
       'bid' => array(
-        'type' => 'serial',
-        'unsigned' => TRUE,
+        'type' => 'varchar',
+        'length' => 128,
         'not null' => TRUE,
+        'default' => '',
         'description' => t("The block's {blocks}.bid."),
       ),
       'body' => array(
Index: modules/block/block.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.module,v
retrieving revision 1.304
diff -u -p -r1.304 block.module
--- modules/block/block.module	23 Apr 2008 20:01:48 -0000	1.304
+++ modules/block/block.module	30 Apr 2008 00:36:08 -0000
@@ -339,7 +339,7 @@ function block_box_save($edit, $delta) {
     $edit['format'] = FILTER_FORMAT_DEFAULT;
   }
 
-  db_query("UPDATE {boxes} SET body = '%s', info = '%s', format = %d WHERE bid = %d", $edit['body'], $edit['info'], $edit['format'], $delta);
+  db_query("UPDATE {boxes} SET body = '%s', info = '%s', format = %d WHERE bid = '%s'", $edit['body'], $edit['info'], $edit['format'], $delta);
 
   return TRUE;
 }
Index: modules/system/system.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.install,v
retrieving revision 1.250
diff -u -p -r1.250 system.install
--- modules/system/system.install	16 Apr 2008 11:35:52 -0000	1.250
+++ modules/system/system.install	30 Apr 2008 00:36:12 -0000
@@ -2861,6 +2861,28 @@ function system_update_7005() {
 }
 
 /**
+ * Convert boxes.bid from int to varchar.  Also makes blocks.delta the
+ * same length (128) for consistency.
+ */
+function system_update_7006() {
+  $ret = array();
+  // If we drop the primary key first, we get a SQL error because of the auto_increment.
+  db_change_field($ret, 'boxes', 'bid', 'bid',
+    array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''));
+  db_drop_primary_key($ret, 'boxes');
+  db_add_primary_key($ret, 'boxes', array('bid'));
+  db_change_field($ret, 'blocks', 'delta', 'delta',
+    array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => 0));
+  // Loop through existing blocks and set the bid properly.
+  $data = db_query("SELECT * FROM {boxes}");
+  while ($box = db_fetch_array($data)) {
+    $delta = strtolower(preg_replace('/[^a-z0-9]/i', '-', $box['info']));
+    db_query("UPDATE {boxes} SET bid = '%s' WHERE info = '%s'", $delta, $box['info']);
+  }
+  return $ret;
+}
+
+/**
  * @} End of "defgroup updates-6.x-to-7.x"
  * The next series of updates should start at 8000.
  */
