I am trying to use entityform with SQLite, but get an error when enabling entityform. The problem seems to be that SQLite doesn't like the notion of having both a table and an index named entityform_type.

Here is a complete set of steps to reproduce the error.

$ drush --version
drush version 5.8

# This is needed to allow installation with sqlite to proceed
patch -p1 < curl http://drupal.org/files/1266572-20-workaround-in-sqlite-some-update-missed-d7-do-not-test.patch

$ drush site-install --db-url=sqlite://sites/default/files/site.sqlite -y
You are about to create a sites/default/settings.php file and CREATE  the 'sites/default/files/site.sqlite' da
tabase. Do you want to continue? (y/n): y
Starting Drupal installation. This takes a few seconds ...                                         [ok]
Installation complete.  User name: admin  User password: cnUUaLH4MQ                                [ok]

$ drush dl entityform
Project entityform (7.x-1.0) downloaded to                                                         [success]
/home/haxney/Documents/durgood/sites/all/modules/entityform.
Project entityform contains 3 modules: entityform_notifications, entityform_test, entityform.

$ drush en -y entityform
The following projects have unmet dependencies:
entityform requires rules, views, entity
Would you like to download them? (y/n): y
Project rules (7.x-2.2) downloaded to /home/haxney/Documents/durgood/sites/all/modules/rules.      [success]
Project rules contains 4 modules: rules_admin, rules_scheduler, rules_i18n, rules.
Project views (7.x-3.5) downloaded to /home/haxney/Documents/durgood/sites/all/modules/views.      [success]
Project views contains 2 modules: views, views_ui.
Project entity (7.x-1.0) downloaded to /home/haxney/Documents/durgood/sites/all/modules/entity.    [success]
Project entity contains 2 modules: entity, entity_token.
The following projects have unmet dependencies:
entityform requires ctools
Would you like to download them? (y/n): y
Project ctools (7.x-1.2) downloaded to /home/haxney/Documents/durgood/sites/all/modules/ctools.    [success]
Project ctools contains 9 modules: ctools_access_ruleset, views_content, bulk_export, stylizer, ctools_plugin
example, ctools_custom_content, ctools_ajax_sample, page_manager, ctools.
The following extensions will be enabled: entityform, entity_token, rules, ctools, views, entity
Do you really want to continue? (y/n): y
WD php: PDOException: SQLSTATE[HY000]: General error: 1 there is already an index named            [error]
entityform_type: CREATE TABLE {entityform_type} (
id INTEGER PRIMARY KEY AUTOINCREMENT,
type VARCHAR(255) NOT NULL,
label VARCHAR(255) NOT NULL DEFAULT '',
weight INTEGER NOT NULL DEFAULT 0,
data TEXT NULL DEFAULT NULL,
status INTEGER NOT NULL DEFAULT 1,
module VARCHAR(255) NULL DEFAULT NULL
);
; Array
(
)
 in db_create_table() (line 2688 of /home/haxney/Documents/durgood/includes/database/database.inc).
Cannot modify header information - headers already sent by (output started at                      [warning]
/usr/share/drush/includes/output.inc:37) bootstrap.inc:1212
PDOException: SQLSTATE[HY000]: General error: 1 there is already an index named entityform_type: CREATE TABLE{entityform_type} (
id INTEGER PRIMARY KEY AUTOINCREMENT,
type VARCHAR(255) NOT NULL,
label VARCHAR(255) NOT NULL DEFAULT &#039;&#039;,
weight INTEGER NOT NULL DEFAULT 0,
data TEXT NULL DEFAULT NULL,
status INTEGER NOT NULL DEFAULT 1,
module VARCHAR(255) NULL DEFAULT NULL
);
; Array
(
)
 in db_create_table() (line 2688 of /home/haxney/Documents/durgood/includes/database/database.inc).
Drush command terminated abnormally due to an unrecoverable error.                                 [error]

I'm on Drupal 7.18 under Ubuntu 12.10, 64-bit using PHP 5.4.6-1ubuntu1.1

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

haxney’s picture

Aha! I've found a solution. The problem is that Drupal forms index names by concatenating the table name with the index name, so the index named type on the table entityform created an index called entityform_type, which clashes with the table of the same name. Changing the name of $schema['entityform']['indexes']['type'] to $schema['entityform']['indexes']['entity_form_type_index'] (for example) produces an index named entityform_entity_form_type_index, which no longer clashes with the table name.

Incidentally, there is an index called entityform_type_type because of the unique key on the table entityform_type. Not a problem, just FYI.

tedbow’s picture

Status: Active » Postponed (maintainer needs more info)

Ok, thinking about how to fix this.

Can you let me know what version of SQLite you are using?

Thanks

Mentor.37’s picture

Same problem, how can i fix it?

tedbow’s picture

I never heard back from him about my question in #2. Can you let me what version of SQLite you are using?

Mentor.37’s picture

I'm using sqlite 3.

tedbow’s picture

@Mentor, please confirm that you are using

SQLite 3.3.7 or higher

From http://drupal.org/requirements
Before I investigate this problem I want to make sure that this is happening with the recommended version of SQLite

Mentor.37’s picture

Yes, i have SQLite 3.7.7.1.

tedbow’s picture

@Mentor, ok thanks.

I have attached that renames the index by dropping and re-adding it.

Let me know if this works for you.

tedbow’s picture

Status: Postponed (maintainer needs more info) » Needs review

changing to needs review

Status: Needs review » Needs work

The last submitted patch, entityform-rename_type_index-1876872-8.patch, failed testing.

tedbow’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Status: Needs work » Needs review

patch is against dev version

tedbow’s picture

tedbow’s picture

I don't have SQLite installed. I have tested this with my setup that uses mysql but will need someone to test it on SQLite.

Mentor.37’s picture

I'm unable to apply patch. How can i do this?

jweowu’s picture

jeyram’s picture

Well, the patch doesn't work for me. I'm using sqlite ver 3.7.9

jeyram@PCRam:~/drupal/sites/all/modules/entityform$ git apply -v entityform-rename_type_index-1876872-8.patch
Checking patch entityform.install...
Applied patch entityform.install cleanly.

jeyram@PCRam:~/drupal/sites/all/modules/entityform$ drush cc theme-registry
'theme-registry' cache was cleared in /home/jeyram/Documents/quick-drupal-20121003184025/drupal#default                                                                       [success]

jeyram@PCRam:~/drupal/sites/all/modules/entityform$ drush en entityform
The following extensions will be enabled: entityform
Do you really want to continue? (y/n): y
WD php: PDOException: SQLSTATE[HY000]: General error: 1 there is already an index named entityform_type: CREATE TABLE {entityform_type} (                                     [error]
id INTEGER PRIMARY KEY AUTOINCREMENT, 
type VARCHAR(255) NOT NULL, 
label VARCHAR(255) NOT NULL DEFAULT '', 
weight INTEGER NOT NULL DEFAULT 0, 
data TEXT NULL DEFAULT NULL, 
status INTEGER NOT NULL DEFAULT 1, 
module VARCHAR(255) NULL DEFAULT NULL
);
; Array
(
)
 in db_create_table() (line 2717 of /home/jeyram/Documents/quick-drupal-20121003184025/drupal/includes/database/database.inc).
PDOException: SQLSTATE[HY000]: General error: 1 there is already an index named entityform_type: CREATE TABLE {entityform_type} (
id INTEGER PRIMARY KEY AUTOINCREMENT, 
type VARCHAR(255) NOT NULL, 
label VARCHAR(255) NOT NULL DEFAULT &#039;&#039;, 
weight INTEGER NOT NULL DEFAULT 0, 
data TEXT NULL DEFAULT NULL, 
status INTEGER NOT NULL DEFAULT 1, 
module VARCHAR(255) NULL DEFAULT NULL
);
; Array
(
)
 in db_create_table() (line 2717 of /home/jeyram/Documents/quick-drupal-20121003184025/drupal/includes/database/database.inc).
Drush command terminated abnormally due to an unrecoverable error.                                                                                                            [error]


tedbow’s picture

@jeyram does it not work on an existing or new install?

tedbow’s picture

Status: Needs review » Postponed (maintainer needs more info)

more info needed

geek-merlin’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
1.33 KB

I'm suffering from this on sqlite 3.6.20.

first for other sufferers how to cure the WSOD:

drush sqlq "update system set status=0 where name='entityform';"
drush cc all
drush sqlq "drop table entityform;"

(the last line is important because although the module is marked uninstalled there IS an entityform table left.)

the i applied the patch to dev and tested fresh install, but got same exception as above #16.
reviewing the code - no wonder.
fixed the fix and made a happy clean install.
patch flying in.

upupax’s picture

The patch works for me

Xumorist’s picture

czigor’s picture

Patch works for me too. I don't understand what's the problem with the 'type' index though. Is 'type' a reserved word in sqlite?

geek-merlin’s picture

Status: Needs review » Reviewed & tested by the community

rtbc as of #20&#22

tedbow’s picture

tedbow’s picture

Status: Reviewed & tested by the community » Needs review

I am going to re-test to make it sure it still applies.
Thanks,

geek-merlin’s picture

Status: Needs review » Reviewed & tested by the community

OK, testbot is happy.

geek-merlin’s picture

czigor’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
926 bytes

Above patch does not apply any more, rerolling.

Status: Needs review » Needs work

The last submitted patch, 28: entityform-sqlite_error-1876872-28.patch, failed testing.

czigor’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Needs work » Needs review

Wrong branch.

czigor’s picture

Status: Needs review » Reviewed & tested by the community
kenorb’s picture

The same in here, patch works fine.

Reproducible steps:

1. Clone this sandbox.
2. Remove this patch from `contrib-core.yml`.
3. Build sandbox via `make`.

It should fail:

exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1 there is already an index named [error]

joelpittet’s picture

This is a bit strange because core has this in node, field, dblog and feeds also does this. Do you have to patch any of those as well?

  • joelpittet committed 751cd0e on 7.x-2.x authored by czigor
    Issue #1876872 by tedbow, czigor, axel.rutz, Mentor.37, haxney,...
joelpittet’s picture

Status: Reviewed & tested by the community » Fixed

Re-rolled it for entityform_update_7007, and committed to -dev. I see that it's the _type that's likely causing this and none of the other modules tables are named that way.

Status: Fixed » Closed (fixed)

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

nikathone’s picture

This issue fix seems to have introduced another one. The index rename change below is being done under $schema['entityform']

<?php
-      'type' => array('type'),
+      'type_index' => array('type'),
?>

while the function entityform_update_7006(&$sandbox = NULL) is targeting the $schema['entityform_type']

<?php
+  db_drop_index('entityform_type', 'type');
+  db_add_index('entityform_type', 'type_index', array('type'));
?>

Noticed this error when I installed https://www.drupal.org/project/schema

joelpittet’s picture

please open a new issue, I'm not totally following the issue you have.