Skip to content
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

Core schema changes to accommodate utf8mb4 index length limits #1596

Merged
merged 1 commit into from Jan 16, 2018

Conversation

drbyte
Copy link
Member

@drbyte drbyte commented Jan 14, 2018

Note: the cases where the field length was changed instead of the index are either primary keys or fields whose length can afford to be shorter.

  • field lengths where shorter will suffice
  • lengths on hybrid indexes
  • Session Length: PHP allows for 256

Supporting 256 chars in db requires MySQL 5.0.3 or newer.

@drbyte drbyte force-pushed the utf8mb4_core_schema_changes branch 2 times, most recently from bf9a0d2 to 0798f61 Compare January 16, 2018 18:20
@drbyte drbyte force-pushed the utf8mb4_core_schema_changes branch from 0798f61 to 06a8319 Compare January 16, 2018 18:33
@drbyte drbyte merged commit 9a36fff into zencart:v156 Jan 16, 2018
@drbyte drbyte deleted the utf8mb4_core_schema_changes branch January 16, 2018 19:25
@torvista
Copy link
Member

torvista commented Jan 16, 2018

In phpmyadmin, on the sessions table it will not allow varchar(256) with InnoDB, even with utf8_general_ci (10.1.29-MariaDB).

@drbyte
Copy link
Member Author

drbyte commented Jan 16, 2018

Some reading I've done further suggests it may require MySQL higher than 5.7.7 or MariaDB higher than 10.2.2

What error message/s do you get?

@torvista
Copy link
Member

torvista commented Jan 17, 2018

clipboard01
10.1.29-MariaDB is the latest currently offered by Xampp for php 7.2.
Maybe utf8mb4 is not ready for primetime yet...

@torvista
Copy link
Member

I note the ZC156 installer appears to complete successfully despite having failed to create this table: no error flagged (subsequently the admin login fails with a debug).

@drbyte
Copy link
Member Author

drbyte commented Jan 17, 2018

Did whos_online throw any errors?
From my reading I understand that unique keys need to also support the full length * 4, so would expect the same error to occur when creating the session_id unique index on the whos_online table, too.

I "get" that the sessions table is doing this, because the primary key is an index, actually a unique-index.

It's frustrating that zc_install doesn't seem to be getting flagged about the error. Grrr.

@torvista
Copy link
Member

whos_oline is created ok: has varchar(256) and is still MyISAM.
clipboard01

@drbyte
Copy link
Member Author

drbyte commented Jan 17, 2018

Puzzling

I have mariadb 10.2.12 installed, so my testing results are a bit different.

@torvista
Copy link
Member

I've installed ZC158 many times on Xampp having created the DB with
CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci;
with no problem.
But I've just started to tryout Laragon and the install did not create table products.description: needing both varchars at 250 to create the table (they are set differently at 254/255).
Subsequently when playing with this value in the database admin tool Heidi, it won't accept more than 250. The error is the same as that created in the installer debug.

Clipboard04

This is php 7.4.16, mysql 5.7.24.

@drbyte
Copy link
Member Author

drbyte commented Mar 17, 2021

MySQL has significantly tinier capacity (1000) than MariaDB does (over 3000) on index lengths.

The issue is that if you want to support mb4 on MySQL then you can NEVER have columns longer than 250 characters, because each character requires 4 bytes. 250 * 4 = 1000 which is MySQL's maximum index size.

The problem is compounded many times over when indexing multiple columns.
And even worse when storeowners want to stuff even longer values in those columns.

There are some options:

  • don't use MySQL (use MariaDB instead)
  • use shorter index lengths (see below) on those fields
  • drop (or skip creating) indexes on those longer fields (you'll have to edit the .SQL file before installing)
  • use shorter column lengths (you'll have to edit the .SQL file before installing)

For v158 I've reverted the default install to use a shorter length.

drbyte added a commit that referenced this pull request Mar 17, 2021
Can't use longer than 250 on MySQL due to its limitations.
Using 191 for consistency with other fields.

Ref e97fba0
Ref #1596
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants