-
-
Notifications
You must be signed in to change notification settings - Fork 223
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
Allow collation to be a part of data type #7748
Changes from 8 commits
0d2ad6d
3c8b5e0
24e8732
1df21d2
daa01f5
6f175cd
83916a3
7fab551
9b66e2b
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 |
---|---|---|
@@ -1 +1 @@ | ||
69 shift/reduce conflicts, 21 reduce/reduce conflicts. | ||
71 shift/reduce conflicts, 21 reduce/reduce conflicts. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1449,7 +1449,7 @@ arg_desc_list($parameters) | |
arg_desc($parameters) | ||
: udf_data_type param_mechanism | ||
{ | ||
$parameters->add(newNode<ParameterClause>($1, MetaName())); | ||
$parameters->add(newNode<ParameterClause>($1)); | ||
$parameters->back()->udfMechanism = $2; | ||
} | ||
; | ||
|
@@ -1472,7 +1472,7 @@ return_value1($function) | |
return_value($function) | ||
: udf_data_type return_mechanism | ||
{ | ||
$function->returnType = newNode<ParameterClause>($1, MetaName()); | ||
$function->returnType = newNode<ParameterClause>($1); | ||
$function->returnType->udfMechanism = $2; | ||
} | ||
| PARAMETER pos_short_integer | ||
|
@@ -1740,13 +1740,12 @@ domain_clause | |
{ | ||
$3->fld_name = *$1; | ||
$<createDomainNode>$ = newNode<CreateDomainNode>( | ||
newNode<ParameterClause>($3, MetaName(), $4)); | ||
newNode<ParameterClause>($3, $4)); | ||
} | ||
domain_constraints_opt($5) collate_clause | ||
{ | ||
$$ = $5; | ||
if ($7) | ||
$$->nameType->type->collate = *$7; | ||
setCollate($3, $7); | ||
} | ||
; | ||
|
||
|
@@ -2346,8 +2345,7 @@ column_def($relationNode) | |
} | ||
column_constraint_clause(NOTRIAL($<addColumnClause>4)) collate_clause | ||
{ | ||
if ($6) | ||
$<addColumnClause>4->collate = *$6; | ||
setCollate($2, $6); | ||
} | ||
| symbol_column_name data_type_or_domain identity_clause | ||
{ | ||
|
@@ -2360,8 +2358,7 @@ column_def($relationNode) | |
} | ||
column_constraint_clause(NOTRIAL($<addColumnClause>4)) collate_clause | ||
{ | ||
if ($6) | ||
$<addColumnClause>4->collate = *$6; | ||
setCollate($2, $6); | ||
} | ||
| symbol_column_name non_array_type def_computed | ||
{ | ||
|
@@ -2797,7 +2794,10 @@ input_proc_parameters($parameters) | |
%type input_proc_parameter(<parametersClause>) | ||
input_proc_parameter($parameters) | ||
: column_domain_or_non_array_type collate_clause default_par_opt | ||
{ $parameters->add(newNode<ParameterClause>($1, optName($2), $3)); } | ||
{ | ||
setCollate($1, $2); | ||
$parameters->add(newNode<ParameterClause>($1, $3)); | ||
} | ||
; | ||
|
||
%type output_proc_parameters(<parametersClause>) | ||
|
@@ -2809,7 +2809,10 @@ output_proc_parameters($parameters) | |
%type output_proc_parameter(<parametersClause>) | ||
output_proc_parameter($parameters) | ||
: column_domain_or_non_array_type collate_clause | ||
{ $parameters->add(newNode<ParameterClause>($1, optName($2))); } | ||
{ | ||
setCollate($1, $2); | ||
$parameters->add(newNode<ParameterClause>($1)); | ||
} | ||
; | ||
|
||
%type <legacyField> column_domain_or_non_array_type | ||
|
@@ -2881,7 +2884,8 @@ function_clause_start | |
RETURNS domain_or_non_array_type collate_clause deterministic_clause_opt | ||
{ | ||
$$ = $2; | ||
$$->returnType = newNode<ParameterClause>($5, optName($6)); | ||
$$->returnType = newNode<ParameterClause>($5); | ||
setCollate($5, $6); | ||
$$->deterministic = $7; | ||
} | ||
; | ||
|
@@ -3220,7 +3224,8 @@ local_declaration_subfunc_start | |
RETURNS domain_or_non_array_type collate_clause deterministic_clause_opt | ||
{ | ||
$$ = $4; | ||
$$->dsqlBlock->returns.add(newNode<ParameterClause>($<legacyField>7, optName($8))); | ||
setCollate($7, $8); | ||
$$->dsqlBlock->returns.add(newNode<ParameterClause>($<legacyField>7)); | ||
$$->dsqlDeterministic = $9; | ||
} | ||
; | ||
|
@@ -3235,8 +3240,10 @@ local_declaration_item | |
var_declaration_item | ||
: column_domain_or_non_array_type collate_clause var_declaration_initializer | ||
{ | ||
// Set collate before node allocation to prevent memory leak on throw | ||
setCollate($1, $2); | ||
DeclareVariableNode* node = newNode<DeclareVariableNode>(); | ||
node->dsqlDef = newNode<ParameterClause>($1, optName($2), $3); | ||
node->dsqlDef = newNode<ParameterClause>($1, $3); | ||
$$ = node; | ||
} | ||
; | ||
|
@@ -3916,7 +3923,10 @@ block_parameters($parameters) | |
%type block_parameter(<parametersClause>) | ||
block_parameter($parameters) | ||
: column_domain_or_non_array_type collate_clause '=' parameter | ||
{ $parameters->add(newNode<ParameterClause>($1, optName($2), (ValueSourceClause*) NULL, $4)); } | ||
{ | ||
setCollate($1, $2); | ||
$parameters->add(newNode<ParameterClause>($1, (ValueSourceClause*) NULL, $4)); | ||
} | ||
; | ||
|
||
// CREATE VIEW | ||
|
@@ -4899,20 +4909,27 @@ array_range | |
%type <legacyField> simple_type | ||
simple_type | ||
: non_charset_simple_type | ||
| character_type charset_clause | ||
| character_type charset_clause collate_clause | ||
{ | ||
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. I'm not sure whether it works in our codebase, but accordingly to the SQL specification 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. Yes, but Firebird has no standard character blobs (CLOB or CHARACTER LARGE OBJECT), only binary blobs so this part is not for this PR. |
||
$$ = $1; | ||
if ($2) | ||
{ | ||
$$->charSet = *$2; | ||
$$->flags |= FLD_has_chset; | ||
} | ||
if ($3) | ||
$$->collate = *$3; | ||
} | ||
; | ||
|
||
%type <legacyField> non_charset_simple_type | ||
non_charset_simple_type | ||
: national_character_type | ||
: national_character_type collate_clause | ||
{ | ||
$$ = $1; | ||
if ($2) | ||
$$->collate = *$2; | ||
} | ||
| binary_character_type | ||
| numeric_type | ||
| float_type | ||
|
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.
This does not correspond to changes below. For parameters you seem to allow both and use the latest one. What about local variables?
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.
This PR is intended for table fields only, I'm not sure if parameters and variables are covered. Should they?
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.
You have added the code to
ParameterClause::ctor
with a comment:// Explicit collation has precedence over data type collation
This does not match the text about error being raised.
And parameters/variables are declared using:
column_domain_or_non_array_type collate_clause ...
where
column_domain_or_non_array_type
now includes acollate_clause
itself after your changes...domain_or_non_array_type -> domain_or_non_array_type_name -> non_array_type -> simple_type
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.
This comment applies to cases when data type is derived from domain or column including collation. Old code silently reset collation to default if no explicit COLLATE was provided so I've added the condition and the 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.
Indeed, I'll fix that but it is not really related to the 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.
Local variables seems to be ok:
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.
IMHO, they (along with
setClauseFlag
/checkDuplicateClause
/isDuplicateClause
) should bestatic
, as they don't access the parser state. @asfernandes , do you agree?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 would question the need in
collate_clause
afterdomain_or_non_array_type
andcolumn_domain_or_non_array_type
, as now it's also included inside these parser rules. The only regression would be thatNOT NULL
must be written afterCOLLATE
, not before as now. Is it an acceptable breakage, given the low probability that both co-exist in input/output parameters / return values in real-world scripts? And there will be no need to check for duplicated definitions then.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.
If nodes are going to call
Parser::setClause
, I don't agree. It's layer violation.In this case I would move them to
Node
class.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.
Collation can be removed from ParameterClause constructor parameters and assigned later. Is it ok?