On install of payments module I got this error:
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes: CREATE TABLE {paymentreference} ( `bundle` VARCHAR(255) NOT NULL, `entity_type` VARCHAR(255) NOT NULL, `field_name` VARCHAR(255) NOT NULL, `pid` INT NOT NULL DEFAULT 0, PRIMARY KEY (`pid`), INDEX `instance` (`bundle`, `entity_type`, `field_name`) ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8; Array ( ) in db_create_table() (line 2688 of /var/www/vhosts/xxx/httpdocs/includes/database/database.inc).
Is it the module or is it a database setting issue on my side?
Comment | File | Size | Author |
---|---|---|---|
#24 | paymentreference-limit_column_lengths-1924796-24.patch | 1.64 KB | torotil |
#19 | payment_1924796_19.patch | 3.36 KB | Xano |
#18 | payment_1924796_18.patch | 3.57 KB | Xano |
Comments
Comment #1
j.slemmer CreditAttribution: j.slemmer commentedComment #2
XanoThanks for reporting this bug! I'm not familiar with this kind of error, but my search efforts lead me to believe that the combination of the three fields used for the index (bundle, entity_type and field_name) causes the index to be too long. If my calculations are correct, and you are using UTF-8, the index length can be up to (255 + 255 + 255) * 4 bytes = 3060 bytes.
The weird thing is that the tests, which require {paymentreference} to be created, pass both locally and on the testbot.
@j.slemmer: Can you try to run the tests on the machine on which you experience this issue, and try to reproduce the problem on another machine?
Comment #3
j.slemmer CreditAttribution: j.slemmer commentedI tried to reproduce locally, which I could not. Seems to be isolated to our server then.
Not to familiar with running tests. If you want to assist with that, more then willing to give that a try.
Comment #4
XanoThe Getting Started with SimpleTest should do a good job at explaining how to run tests. Let me know if it works for you!
Comment #5
XanoIf anyone can provide steps on how to reproduce this issue, please provide them here and reopen the issue.
Comment #6
Alex Bukach CreditAttribution: Alex Bukach commentedI have the same issue. For my current dev environment there is a single step to reproduce the issue: deploy fresh D7, then execute
drush dl payment
drush en paymentreference
I use MySQL, UTF-8.
Comment #7
XanoCan you give us more details about your environment?
Comment #8
Alex Bukach CreditAttribution: Alex Bukach commentedI'm not sure what details can be useful for you since I suppose this issue is caused by using utf-8 with MySQL only.
I use Drupal 7.21, php 5.2.13, MySQL server version 5.1.41-gm2, protocol version 10, encoding UTF-8. What other info can I give you?
Comment #9
mt3ch CreditAttribution: mt3ch commentedI had this problem so don't have the paymentreference table. Now I've tried to update from 1.5 to 1.6 and just get a white screen each time so I'm wondering if it is related to not having this table.
Do you recommend not applying any updates until this problem is resolved?
Comment #10
XanoNow work on 8.x-2.x has started, we'll have to fix the problem in that branch before we can patch 7.x-1.x. As the database schema is identical, and will be for at least a while, we can probably use the same fix for both branches.
Comment #11
phaer CreditAttribution: phaer commentedI am able to reproduce this bug by using MyISAM as my database engine (payment 7.x-1.7). The same code runs fine on InnoDB which is the default for Drupal but it would be nice to be able to use MyISAM for faster tests during development.
Comment #12
XanoThis depends on #1709960: declare a maximum length for entity and bundle machine names, as there is no standard maximum length for entity type and bundle machine names yet. paymentreference_schema() uses such high values simply to make sure values are never truncated.
Comment #13
XanoComment #14
XanoMoving back to 7.x-1.x, because 8.x-2.x no longer has this table.
Does anyone have more information? I'm still not sure how to solve this.
Comment #15
RemovE CreditAttribution: RemovE commentedI changed paymentreference.install schema length values. And now working.
Comment #16
XanoThat will work most of the time, but Drupal 7 does not set explicit limits on the lengths of those values, so this breaks with entity types that have a name that's longer than 32 characters.
Comment #17
vibrasphere CreditAttribution: vibrasphere commentedHi, I just got this error. 6 months no progress?
Comment #18
XanoLet's try this. It shouldn't break backwards compatibility.
If nobody has any ideas on how to solve this, then no progress can be made ;-)
Comment #19
XanoThe previous patch contained a copy/paste error.
Comment #21
XanoNote that this patch will greatly reduce the chances of running into this error, but it will never be able to fully prevent it, because entity type names, bundles, and field names have no maximum lengths. As long as those three together are no longer than 253 charachters, the patch will work.
Comment #22
torotil CreditAttribution: torotil commentedThat's not entirely true. They are implicitly constrained to the column sizes used in the field-module (one of the reasons to create the notion of entities in the first place). In D7 those limits are:
Sadly those 3 are indeed longer than 253 characters (288 characters).
Comment #23
torotil CreditAttribution: torotil commentedHm, Why don't we simply use field_instance_config.id as a foreign key? (Whatever happened to primary-keys?)
In field_instance_config entity_type is limited to 32 chars. That means there is no fieldable entity with a longer entity_type. That's why in field_instance_config the index on exactly the same columns works without any issues on MyISAM.
Comment #24
torotil CreditAttribution: torotil commentedHere is a patch that limits the columns following
field_config_instance
.Comment #25
XanoOh, cool! I have seen some lengthy discussions about maximum lengths in core and IIRC this could never be solved in D7 because there was no maximum.
Thanks!
Comment #27
XanoI checked and these are the same restrictions as used for the
field_config_instance
table.Comment #28
XanoThanks for all the help!