-
-
Notifications
You must be signed in to change notification settings - Fork 232
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
Fix issues with longish concatenated context aliases #8494
base: master
Are you sure you want to change the base?
Conversation
Test case is available upon request. |
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.
The adaptation of plans to the schemas PR was really trick.
Maybe you can do the master changes based on it or in the same branch?
{ | ||
string truncatedAlias(alias); | ||
truncatedAlias.resize(MAX_UCHAR - 3); | ||
truncatedAlias += "..."; |
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.
How this change of a name overflow to ellipsis will resolve problems?
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.
It avoids an assertion (debug build) or weird alias truncation (release build) inside BlrWriter::appendString
when called from genBlr()
. Of course, we could just truncate the string at the 255 bytes boundary, but IMHO ellipsis look better as clearly shows the fact of truncation. Now BLR is generated (and later parsed) properly and ellipsis is shown inside the very long plan's alias, AFAIS without any additional side effects.
No problem. Once approved, I will commit to v5 and delay the master PR until schemas are merged. |
void appendContextAlias(DsqlCompilerScratch* dsqlScratch, const string& alias) | ||
{ | ||
const auto len = alias.length(); | ||
if (len <= MAX_UCHAR) |
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.
Could it be more advantageous to use MAX_SQL_IDENTIFIER_LEN rather than MAX_UCHAR, considering the possibility of MetaName length expanding in the future?
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.
- Alias is a MetaName inside the query, but it's a string for the optimizer (because it's concatenated from the whole aliases stack for nested contexts like derived tables).
- String length inside BLR is limited by 1 byte, hence the check for MAX_UCHAR. It would be a PITA to extend it (without introducing new BLR version).
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.
Got it, thanks for the clarification.
Currently nested contexts (e.g. derived tables) have context aliases concatenated through the whole stack, so the final string is not limited to the maximum metadata name length.
planEntry.alias
a string rather thanMetaName
All these issues now assert: (1) and (2) for aliases longer than 252 bytes and (3) for aliases longer than 255 bytes.