-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[MDEV-31414] Implement optional lengths for string types #4551
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Osama Nabih <[email protected]>
Signed-off-by: Osama Nabih <[email protected]>
|
Hi,
That is a nice guess! Our documentation claims it's 21,844 characters, though I think it's a bit outdated, since we support 4-byte encodings for some time. So yes, it's got to be UINT16_MAX/4 - header_length, where header_length is something like 3. |
FooBarrior
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We follow the TDD paradigm - every feature should be covered with tests (and every bugfix, if possible). Include both .test and .result files in the commit.
I'm fine with a hard constant of 16383 in scope of this small work, we can always extend it and make a function of charset any time we want, since 16383 is expected to be the minimum of the maximums.
| Support SQL Standard T081: "Optional string types maximum length" | ||
| Allows users to specify VARCHAR fields without a length | ||
| */ | ||
| def->length= 16383; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Declare a constant in the appropriate place, like MAX_VARCHAR_SIZE, or maybe better MAX_VARCHAR_ESTIMATED_SIZE, signifying the imprecise nature.
I tried to look for the existing one and turns out it's pretty widely used in a raw literal form in the sql directory. Let's be the first good guys who'll add it there.
There is a constant in innodb -- we can't refer to it from sql, because this will reverse the dependencies. (innodb depends from sql, not vice-versa)
| Support SQL Standard T081: "Optional string types maximum length" | ||
| Allows users to specify VARCHAR fields without a length | ||
| */ | ||
| def->length= 16383; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty surprised this change would work on its own. Fine by me, if it does, though. Please add the test with a new syntax.
|
You can try to make tha max value variable if you want. Though it may require some research. The problem is that we have (at least) three layers of charset settings:
One overrides another. At some point, Filed would get a deduced value of charset, and perhaps Create_field would get it, too. Though it's hard to say, when exactly. You'd have to test all three cases though:
Again, I'm NOT putting this as a requirement for this submission! |
Jira: https://jira.mariadb.org/browse/MDEV-31414
Adding support for SQL standard 2023's T081:
Optional string types maximum lengthThis PR allows the user to not specify a length for a
VARCHARfield. We default to the maximum possible value,which is65,535(0xFFFF) according to https://mariadb.com/docs/server/reference/data-types/string-data-types/varcharAfter trying
65,535, I got the error that size is too big, maximum is16383Questions:
16383reported as the maximum due to collation choice? I am guessing the max bytes is65,535but maybe due to collation every char requires 4 bytes and that's how we end up with16383? Is there a way to get the current char size for the server?m_has_explicit_lengthproperty inLex_length_and_dec_stin this case be set to true? (default is false here as no value was provided toLexduring parsing of theVARCHARclause.