-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error after installation at update database #1
Comments
Which MySQL/MariaDB version are you using? |
mysql 5.7.34 |
Make sure the following settings are enabled in your MySQL sever: https://docs.contao.org/manual/en/installation/system-requirements/#mysql-configuration |
I'm the database guy in this issue. Problem is, mysql restricts the size of a key to 3072 bytes (not chars!). In utf8mb4 each char counts as 4 bytes, so a 2 possibilities:
Otherwise it won't work. |
@webstoney did you make sure you are using theses settings? https://docs.contao.org/manual/en/installation/system-requirements/#mysql-configuration |
Yes, I did |
Hm, I cannot reproduce the problem in MariaDB or MySQL. In theory it should work as long as you use |
|
May be the limit is actually higher on 64-bit systems? Are you on 32-bit? In any case you could adjust your setup this way for example: // contao/dca/tl_address.php
$GLOBALS['TL_DCA']['tl_address']['fields']['number']['sql']['length'] = 32;
$GLOBALS['TL_DCA']['tl_address']['fields']['number']['eval']['maxlength'] = 32;
$GLOBALS['TL_DCA']['tl_address']['fields']['postal']['sql']['length'] = 32;
$GLOBALS['TL_DCA']['tl_address']['fields']['postal']['eval']['maxlength'] = 32;
$GLOBALS['TL_DCA']['tl_address']['fields']['city']['sql']['length'] = 128;
$GLOBALS['TL_DCA']['tl_address']['fields']['city']['eval']['maxlength'] = 128;
$GLOBALS['TL_DCA']['tl_address']['fields']['apartment']['sql']['length'] = 32;
$GLOBALS['TL_DCA']['tl_address']['fields']['apartment']['eval']['maxlength'] = 32; That would bring the index down to under 3072 bytes. |
It's 64-bit (but the 3k limit is at both). I could do that easily, just wanted to get you informed about it. |
What's the
in your case? |
from 0 to 128kB, depends whether additional indexes besides PK are in |
Hm, do you know of any way to figure out the max key length of a platform? |
With the settings of contao it should be 3072 bytes. As it depends on the Table format, there is no way to get it beforehand. If it is below the 3k, people have set the
If it's 8k, then 1536 bytes |
But the index can be created in my local environment as well as all our customer's environments, where this extension is used, so something must be different (apart from the MySQL version). |
Was the key created with utf8mb4? Might be the charset. Use
What mysql versions are in use there? Was InnoDB used? If you don't need the Index for fast retrieving it might be applicable to just use a hash (stored function and unique on the column). But not worth the hassle I think. |
Yes, I am using the default, which is
I am using MariaDB
Yes, I am using the default, which is |
Zust my 2ct: The DDL info seems awkward. InnoDB doesn't support hash indexes neither on mariaDB nor on mySQL. Was the table converted from Aria? Just try your create table statement with another table name and look if it works. |
No, that's just what MariaDB generates and reports.
Yes, but for which table and field? |
for tl_address and street for example |
From a stock mariadb-installation:
|
The result is
Not sure what to tell you, works for me ;) |
For you, not for the customers though. cc. |
I mean for me and our customers. |
apparently not. |
at least in the stock version. |
I am not sure what you mean. As I said, it works for us and our customers. It would be interesting to figure out why it works in our environments (that we have access to), but not in yours. In any case, it should be no trouble to reduce the |
As I come from a bit larger deployments, here my short views regarding indexes:
I'd suggest checking, if the UNIQUE key really works (also with long strings). Might get some unexpected results there. |
The unique index is just there to prevent duplicate addresses on a database level. It is however not technically necessary.
This is something that Contao/Doctrine defines and is out of my control (from the extension's perspective). However, you might want to report this either to Contao or Doctrine. |
The hash-index was only used on mariadb (no using hash in above query). Some more info: Unlimited size of |
After installing the extension I have to log in the contao backend and should make the db-update - starting i get this error in my Logfile:
[2021-11-16 09:18:57] request.INFO: Matched route "contao_install". {"route":"contao_install","route_parameters":{"_route":"contao_install","_scope":"backend","_token_check":true,"_controller":"Contao\InstallationBundle\Controller\InstallationController::installAction"},"request_uri":"https://domain/contao/install","method":"POST"} []
[2021-11-16 09:18:58] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\DriverException: "An exception occurred while executing 'CREATE TABLE tl_address (id INT UNSIGNED AUTO_INCREMENT NOT NULL, pid INT UNSIGNED DEFAULT 0 NOT NULL, tstamp INT UNSIGNED DEFAULT 0 NOT NULL, street VARCHAR(255) DEFAULT '' NOT NULL, number VARCHAR(255) DEFAULT '' NOT NULL, apartment VARCHAR(255) DEFAULT '' NOT NULL, postal VARCHAR(255) DEFAULT '' NOT NULL, city VARCHAR(255) DEFAULT '' NOT NULL, country VARCHAR(2) DEFAULT '' NOT NULL, UNIQUE INDEX pid_street_number_apartment_postal_city_country (pid, street, number, apartment, postal, city, country), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE
utf8mb4_unicode_ci
ENGINE = InnoDB ROW_FORMAT = DYNAMIC': SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 3072 bytes" at /home/domain/public_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 128 {"exception":"[object] (Doctrine\DBAL\Exception\DriverException(code: 0): An exception occurred while executing 'CREATE TABLE tl_address (id INT UNSIGNED AUTO_INCREMENT NOT NULL, pid INT UNSIGNED DEFAULT 0 NOT NULL, tstamp INT UNSIGNED DEFAULT 0 NOT NULL, street VARCHAR(255) DEFAULT '' NOT NULL, number VARCHAR(255) DEFAULT '' NOT NULL, apartment VARCHAR(255) DEFAULT '' NOT NULL, postal VARCHAR(255) DEFAULT '' NOT NULL, city VARCHAR(255) DEFAULT '' NOT NULL, country VARCHAR(2) DEFAULT '' NOT NULL, UNIQUE INDEX pid_street_number_apartment_postal_city_country (pid, street, number, apartment, postal, city, country), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATEutf8mb4_unicode_ci
ENGINE = InnoDB ROW_FORMAT = DYNAMIC':\n\nSQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 3072 bytes at /home/domain/public_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:128, Doctrine\DBAL\Driver\PDO\Exception(code: 42000): SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 3072 bytes at /home/domain/public_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18, PDOException(code: 42000): SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 3072 bytes at /home/domain/public_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:141)"} []Contao 4.9.16 / PHP 7.4.21
The text was updated successfully, but these errors were encountered: