-
-
Notifications
You must be signed in to change notification settings - Fork 239
Fix issues with longish concatenated context aliases #8494
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: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,20 @@ static ValueExprNode* resolveUsingField(DsqlCompilerScratch* dsqlScratch, const | |
|
||
namespace | ||
{ | ||
void appendContextAlias(DsqlCompilerScratch* dsqlScratch, const string& alias) | ||
{ | ||
const auto len = alias.length(); | ||
if (len <= MAX_UCHAR) | ||
dsqlScratch->appendMetaString(alias.c_str()); | ||
else | ||
{ | ||
string truncatedAlias(alias); | ||
truncatedAlias.resize(MAX_UCHAR - 3); | ||
truncatedAlias += "..."; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 |
||
dsqlScratch->appendMetaString(truncatedAlias.c_str()); | ||
} | ||
} | ||
|
||
// Search through the list of ANDed booleans to find comparisons | ||
// referring streams of parent select expressions. | ||
// Extract those booleans and return them to the caller. | ||
|
@@ -687,7 +701,7 @@ void LocalTableSourceNode::genBlr(DsqlCompilerScratch* dsqlScratch) | |
{ | ||
dsqlScratch->appendUChar(blr_local_table_id); | ||
dsqlScratch->appendUShort(tableNumber); | ||
dsqlScratch->appendMetaString(alias.c_str()); // dsqlContext->ctx_alias? | ||
appendContextAlias(dsqlScratch, alias); // dsqlContext->ctx_alias? | ||
|
||
GEN_stuff_context(dsqlScratch, dsqlContext); | ||
} | ||
|
@@ -885,7 +899,7 @@ void RelationSourceNode::genBlr(DsqlCompilerScratch* dsqlScratch) | |
} | ||
|
||
if (dsqlContext->ctx_alias.hasData()) | ||
dsqlScratch->appendMetaString(dsqlContext->ctx_alias.c_str()); | ||
appendContextAlias(dsqlScratch, dsqlContext->ctx_alias); | ||
|
||
GEN_stuff_context(dsqlScratch, dsqlContext); | ||
} | ||
|
@@ -1507,7 +1521,7 @@ void ProcedureSourceNode::genBlr(DsqlCompilerScratch* dsqlScratch) | |
if (dsqlContext->ctx_alias.hasData()) | ||
{ | ||
dsqlScratch->appendUChar(blr_invsel_procedure_alias); | ||
dsqlScratch->appendMetaString(dsqlContext->ctx_alias.c_str()); | ||
appendContextAlias(dsqlScratch, dsqlContext->ctx_alias); | ||
} | ||
|
||
dsqlScratch->appendUChar(blr_end); | ||
|
@@ -1519,7 +1533,7 @@ void ProcedureSourceNode::genBlr(DsqlCompilerScratch* dsqlScratch) | |
{ | ||
dsqlScratch->appendUChar(blr_subproc); | ||
dsqlScratch->appendMetaString(dsqlProcedure->prc_name.identifier.c_str()); | ||
dsqlScratch->appendMetaString(dsqlContext->ctx_alias.c_str()); | ||
appendContextAlias(dsqlScratch, dsqlContext->ctx_alias); | ||
} | ||
else | ||
{ | ||
|
@@ -1546,7 +1560,7 @@ void ProcedureSourceNode::genBlr(DsqlCompilerScratch* dsqlScratch) | |
} | ||
|
||
if (dsqlContext->ctx_alias.hasData()) | ||
dsqlScratch->appendMetaString(dsqlContext->ctx_alias.c_str()); | ||
appendContextAlias(dsqlScratch, dsqlContext->ctx_alias); | ||
} | ||
|
||
GEN_stuff_context(dsqlScratch, dsqlContext); | ||
|
@@ -4079,7 +4093,7 @@ void TableValueFunctionSourceNode::genBlr(DsqlCompilerScratch* dsqlScratch) | |
|
||
GEN_stuff_context(dsqlScratch, dsqlContext); | ||
|
||
dsqlScratch->appendMetaString(dsqlContext->ctx_alias.c_str()); | ||
appendContextAlias(dsqlScratch, dsqlContext->ctx_alias); | ||
|
||
dsqlScratch->appendUShort(dsqlContext->ctx_proc_inputs->items.getCount()); | ||
for (auto& arg : dsqlContext->ctx_proc_inputs->items) | ||
|
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?
Uh oh!
There was an error while loading. Please reload this page.
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.
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.