I'm trying to create a table with 40 fields, six or so indexes, and float, int, and text data. When I hit "create" I get this error message

* Error creating table.
* Error creating table

This is unhelpful, but it's all I got.

CommentFileSizeAuthor
#7 780358-7_fix-change_errors.patch2.91 KBalex_b
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Funkymoses’s picture

FWIW: creating a one-element table and adding additional fields works, but only the most recently added field can be modified or deleted.

alex_b’s picture

Chances are that the schema of the table you're trying to create is not valid. Try to print the exact SQL statement submitted to the DB to the log or the screen, debug from there...

kdebaas’s picture

I can confirm the bug. Apparently there is a problem creating indexes and primary keys. When I do not check the index and primary key checkboxes, the table is succesfully created. However, subsequently trying to assign an index or primary key by editing the schema results in error messages:

* Error changing indexes
* Error changing primary key

vip_sa’s picture

I get the following when trying to create a normal table with one primary key:

* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'number) ) /*!40100 DEFAULT CHARACTER SET UTF8 */' at line 13 query: CREATE TABLE messages ( `title` VARCHAR(255) DEFAULT NULL, `mobile number` VARCHAR(255) DEFAULT NULL, `network` VARCHAR(255) DEFAULT NULL, `direction` VARCHAR(255) DEFAULT NULL, `message` VARCHAR(255) DEFAULT NULL, `local` VARCHAR(255) DEFAULT NULL, `tariff` FLOAT DEFAULT NULL, `service` VARCHAR(255) DEFAULT NULL, `status` VARCHAR(255) DEFAULT NULL, `charge` FLOAT DEFAULT NULL, `profit` FLOAT DEFAULT NULL, PRIMARY KEY (mobile number) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in C:\wamp\www\training\includes\database.inc on line 550.
* Error creating table.
* Error creating table

alex_b’s picture

#4 contains field names with spaces.

alex_b’s picture

I can confirm

BLOB/TEXT column 'a' used in key specification without a key length query: ALTER TABLE Test ADD PRIMARY KEY (a) in /opt/local/apache2/htdocs/feeds/includes/database.mysql-common.inc on line 374.
Error changing primary key

when trying to assign a text field PK

alex_b’s picture

Version: 6.x-1.0-alpha11 » 6.x-1.x-dev
Status: Active » Needs review
FileSize
2.91 KB

This patch should fix some of the reported problems.

The issue lies deeper though: the current UI allows changes to field specs, indexes and PKs at the same time. This leads to a myriad of permutations of potential changes that can't all be validated. We need to split up the UI.

alex_b’s picture

Title: error on creating table » Fix PK and index errors on table changes.
Status: Needs review » Fixed

This is committed now. I am adjusting the title to what has actually been fixed. Larger picture on table manipulation is captured here now: #867680: SQL errors when manipulating tables - split up table UI

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.