Reopen: registerVarcharTypes in MySQL5Dialect creates varchar for up to a length of 65535

Description

The problem was already described in which was closed in 2012 because of some in-progress rewrites. Now (2014) the problem still exists:

MySQL defines "effective" maximum lengths of text columns. "Effective" in the case means the length in bytes, not in characters. If the database charset is utf-8 (which nowadays is default in almost all cases), mysql allows the creation of columns of 1/3 of the defined length.

The correct lengths for varchar fields are:

0...21845 -> Varchar(length)
21846...5592405 -> mediumtext
more -> longtext

So the correct implementation of registerVarcharTypes is:

This fix is independent of any rewrite of the length-logic! It is nessecary to make hibernate's mysql(5) dialect work correctly.

The workaround in ("Until then, please explicitly define column lengths on your varchars or use a custom dialect that extends/overrides MySQL5Dialect.") is invalid since it breaks database compatibility.

Environment

MySQL >5.1

Activity

Show:
Michael Wyraz
July 17, 2014, 2:57 PM

The behaviour of mysql is described in http://dev.mysql.com/doc/refman/5.6/en/column-count-limit.html
According to this it really would make sense to use varchar only up to 255 (or less) characters because the maximum row size is 65535 - where varchar counts but text not. So an improvement of the above would be:

Steve Ebersole
October 27, 2015, 7:15 PM

This bug report does not indicate that the reported issue affects version 5.x. Versions prior to 5.x are no longer maintained. It would be a great help to the Hibernate team and community for someone to verify that the reported issue still affects version 5.x. If so, please add the 5.x version that you verified with to the list of affected-versions and attach the (preferably SSCCE) test case you used to do the verification to the report; from there the issues will be looked at during our triage meetings.

For details, see http://in.relation.to/2015/10/27/great-jira-cleanup-2015/

Steve Ebersole
October 28, 2015, 3:25 AM

As part of verifying that this issue affects 5.0, please just set the "Affects version". Leave the "verify-affects-5.0" label and leave the issue in "Awaiting Response" status; these are critical for us to be able to track these verifications and triage them. Thanks.

Assignee

Unassigned

Reporter

Michael Wyraz

Fix versions

None

backPortable

None

Suitable for new contributors

Yes, likely

Requires Release Note

Affirmative

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure