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

[jdbc] Reduce the default character limit for VARCHAR columns in MySQL #16680

Merged
merged 1 commit into from
Apr 27, 2024

Conversation

jlaur
Copy link
Contributor

@jlaur jlaur commented Apr 23, 2024

See https://dev.mysql.com/doc/refman/8.3/en/storage-requirements.html and namely:

The effective maximum number of bytes that can be stored in a VARCHAR or VARBINARY column is subject to the maximum row size of 65,535 bytes, which is shared among all columns. For a VARCHAR column that stores multibyte characters, the effective maximum number of characters is less. For example, utf8mb4 characters can require up to four bytes per character, so a VARCHAR column that uses the utf8mb4 character set can be declared to be a maximum of 16,383 characters. See Section 10.4.7, “Limits on Table Column Count and Row Size”.

The old size was based on up to three bytes per character, but utf8mb4 can require up to four bytes per character. On top of that we need space for the time column as well. This is now aligned with MariaDB:

sqlTypes.put("IMAGEITEM", "VARCHAR(16255)");
sqlTypes.put("STRINGITEM", "VARCHAR(16255)"); // MariaDB using utf-8 max = 16383, using 16383-128 = 16255

Resolves #13920
Resolves #16678

@jlaur jlaur added the bug An unexpected problem or unintended behavior of an add-on label Apr 23, 2024
@jlaur jlaur requested a review from a team as a code owner April 23, 2024 20:25
Resolves openhab#13920

Resolves openhab#16678

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
@jlaur jlaur force-pushed the 13920-jdbc-mysql-varchar-utf8mb4 branch from 3014140 to 70cdaf8 Compare April 23, 2024 20:35
Copy link
Contributor

@lsiepel lsiepel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lsiepel lsiepel merged commit e67675b into openhab:main Apr 27, 2024
5 checks passed
@lsiepel lsiepel added this to the 4.2 milestone Apr 27, 2024
@jlaur jlaur deleted the 13920-jdbc-mysql-varchar-utf8mb4 branch April 27, 2024 09:28
lo92fr pushed a commit to lo92fr/openhab-addons that referenced this pull request Apr 30, 2024
…hab#16680)

Resolves openhab#13920

Resolves openhab#16678

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
psmedley pushed a commit to psmedley/openhab-addons that referenced this pull request Jun 15, 2024
…hab#16680)

Resolves openhab#13920

Resolves openhab#16678

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Paul Smedley <paul@smedley.id.au>
pgfeller pushed a commit to pgfeller/openhab-addons that referenced this pull request Sep 29, 2024
…hab#16680)

Resolves openhab#13920

Resolves openhab#16678

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Patrik Gfeller <patrik.gfeller@proton.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
2 participants