mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 16:03:03 +01:00
Allow collation to be a part of data type (#7748)
This commit is contained in:
parent
a263a19a49
commit
e23f0306b4
@ -624,3 +624,8 @@ ALTER PACKAGE <name> SQL SECURITY {DEFINER | INVOKER} | DROP SQL SECURITY
|
|||||||
|
|
||||||
<db_initial_option> list is expanded by "OWNER username" clause which allows to set an owner user name for the created database.
|
<db_initial_option> list is expanded by "OWNER username" clause which allows to set an owner user name for the created database.
|
||||||
Only users with administrator rights can use this option.
|
Only users with administrator rights can use this option.
|
||||||
|
|
||||||
|
28) COLLATE clause can be used as a part of character data type as per SQL standard.
|
||||||
|
(Dmitry Sibiryakov)
|
||||||
|
|
||||||
|
If is used twice, an error is returned.
|
||||||
|
@ -1119,14 +1119,13 @@ void DdlNode::storeGlobalField(thread_db* tdbb, jrd_tra* transaction, MetaName&
|
|||||||
//----------------------
|
//----------------------
|
||||||
|
|
||||||
|
|
||||||
ParameterClause::ParameterClause(MemoryPool& pool, dsql_fld* field, const MetaName& aCollate,
|
ParameterClause::ParameterClause(MemoryPool& pool, dsql_fld* field,
|
||||||
ValueSourceClause* aDefaultClause, ValueExprNode* aParameterExpr)
|
ValueSourceClause* aDefaultClause, ValueExprNode* aParameterExpr)
|
||||||
: name(pool, field ? field->fld_name : ""),
|
: name(pool, field ? field->fld_name : ""),
|
||||||
type(field),
|
type(field),
|
||||||
defaultClause(aDefaultClause),
|
defaultClause(aDefaultClause),
|
||||||
parameterExpr(aParameterExpr)
|
parameterExpr(aParameterExpr)
|
||||||
{
|
{
|
||||||
type->collate = aCollate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string ParameterClause::internalPrint(NodePrinter& printer) const
|
string ParameterClause::internalPrint(NodePrinter& printer) const
|
||||||
@ -6454,13 +6453,18 @@ void RelationNode::defineField(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch
|
|||||||
computedSource, computedValue);
|
computedSource, computedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
field->collate = clause->collate;
|
|
||||||
field->resolve(dsqlScratch);
|
field->resolve(dsqlScratch);
|
||||||
|
|
||||||
// Generate a domain.
|
// Generate a domain.
|
||||||
storeGlobalField(tdbb, transaction, fieldDefinition.fieldSource, field,
|
storeGlobalField(tdbb, transaction, fieldDefinition.fieldSource, field,
|
||||||
computedSource, computedValue);
|
computedSource, computedValue);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Resolve possible additional collation for domains. For plain types it is already resolved above.
|
||||||
|
if (field->collate.hasData())
|
||||||
|
DDL_resolve_intl_type(dsqlScratch, field, field->collate);
|
||||||
|
}
|
||||||
|
|
||||||
if ((relation->rel_flags & REL_external) &&
|
if ((relation->rel_flags & REL_external) &&
|
||||||
(field->dtype == dtype_blob || field->dtype == dtype_array || field->dimensions))
|
(field->dtype == dtype_blob || field->dtype == dtype_array || field->dimensions))
|
||||||
@ -6473,9 +6477,6 @@ void RelationNode::defineField(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch
|
|||||||
Arg::Gds(isc_dsql_type_not_supp_ext_tab) << typeName << name << field->fld_name);
|
Arg::Gds(isc_dsql_type_not_supp_ext_tab) << typeName << name << field->fld_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clause->collate.hasData())
|
|
||||||
DDL_resolve_intl_type(dsqlScratch, field, clause->collate);
|
|
||||||
|
|
||||||
if (clause->identityOptions)
|
if (clause->identityOptions)
|
||||||
{
|
{
|
||||||
if (clause->identityOptions->increment.value_or(1) == 0)
|
if (clause->identityOptions->increment.value_or(1) == 0)
|
||||||
@ -6519,10 +6520,7 @@ void RelationNode::defineField(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch
|
|||||||
}
|
}
|
||||||
|
|
||||||
fieldDefinition.defaultValue = defaultValue;
|
fieldDefinition.defaultValue = defaultValue;
|
||||||
|
fieldDefinition.collationId = field->collationId;
|
||||||
if (clause->collate.hasData())
|
|
||||||
fieldDefinition.collationId = field->collationId;
|
|
||||||
|
|
||||||
fieldDefinition.store(tdbb, transaction);
|
fieldDefinition.store(tdbb, transaction);
|
||||||
|
|
||||||
// Define the field constraints.
|
// Define the field constraints.
|
||||||
|
@ -171,7 +171,7 @@ public:
|
|||||||
class ParameterClause : public Printable
|
class ParameterClause : public Printable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ParameterClause(MemoryPool& pool, dsql_fld* field, const MetaName& aCollate,
|
ParameterClause(MemoryPool& pool, dsql_fld* field,
|
||||||
ValueSourceClause* aDefaultClause = NULL, ValueExprNode* aParameterExpr = NULL);
|
ValueSourceClause* aDefaultClause = NULL, ValueExprNode* aParameterExpr = NULL);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -340,6 +340,11 @@ private:
|
|||||||
return clause.hasData();
|
return clause.hasData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setCollate(TypeClause* fld, MetaName* name)
|
||||||
|
{
|
||||||
|
if (name)
|
||||||
|
setClause(fld->collate, "COLLATE", *name);
|
||||||
|
}
|
||||||
void checkTimeDialect();
|
void checkTimeDialect();
|
||||||
|
|
||||||
// start - defined in btyacc_fb.ske
|
// start - defined in btyacc_fb.ske
|
||||||
|
@ -1 +1 @@
|
|||||||
69 shift/reduce conflicts, 22 reduce/reduce conflicts.
|
71 shift/reduce conflicts, 22 reduce/reduce conflicts.
|
||||||
|
@ -1457,7 +1457,7 @@ arg_desc_list($parameters)
|
|||||||
arg_desc($parameters)
|
arg_desc($parameters)
|
||||||
: udf_data_type param_mechanism
|
: udf_data_type param_mechanism
|
||||||
{
|
{
|
||||||
$parameters->add(newNode<ParameterClause>($1, MetaName()));
|
$parameters->add(newNode<ParameterClause>($1));
|
||||||
$parameters->back()->udfMechanism = $2;
|
$parameters->back()->udfMechanism = $2;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -1480,7 +1480,7 @@ return_value1($function)
|
|||||||
return_value($function)
|
return_value($function)
|
||||||
: udf_data_type return_mechanism
|
: udf_data_type return_mechanism
|
||||||
{
|
{
|
||||||
$function->returnType = newNode<ParameterClause>($1, MetaName());
|
$function->returnType = newNode<ParameterClause>($1);
|
||||||
$function->returnType->udfMechanism = $2;
|
$function->returnType->udfMechanism = $2;
|
||||||
}
|
}
|
||||||
| PARAMETER pos_short_integer
|
| PARAMETER pos_short_integer
|
||||||
@ -1748,13 +1748,12 @@ domain_clause
|
|||||||
{
|
{
|
||||||
$3->fld_name = *$1;
|
$3->fld_name = *$1;
|
||||||
$<createDomainNode>$ = newNode<CreateDomainNode>(
|
$<createDomainNode>$ = newNode<CreateDomainNode>(
|
||||||
newNode<ParameterClause>($3, MetaName(), $4));
|
newNode<ParameterClause>($3, $4));
|
||||||
}
|
}
|
||||||
domain_constraints_opt($5) collate_clause
|
domain_constraints_opt($5) collate_clause
|
||||||
{
|
{
|
||||||
$$ = $5;
|
$$ = $5;
|
||||||
if ($7)
|
setCollate($3, $7);
|
||||||
$$->nameType->type->collate = *$7;
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -2356,8 +2355,7 @@ column_def($relationNode)
|
|||||||
}
|
}
|
||||||
column_constraint_clause(NOTRIAL($<addColumnClause>4)) collate_clause
|
column_constraint_clause(NOTRIAL($<addColumnClause>4)) collate_clause
|
||||||
{
|
{
|
||||||
if ($6)
|
setCollate($2, $6);
|
||||||
$<addColumnClause>4->collate = *$6;
|
|
||||||
}
|
}
|
||||||
| symbol_column_name data_type_or_domain identity_clause
|
| symbol_column_name data_type_or_domain identity_clause
|
||||||
{
|
{
|
||||||
@ -2370,8 +2368,7 @@ column_def($relationNode)
|
|||||||
}
|
}
|
||||||
column_constraint_clause(NOTRIAL($<addColumnClause>4)) collate_clause
|
column_constraint_clause(NOTRIAL($<addColumnClause>4)) collate_clause
|
||||||
{
|
{
|
||||||
if ($6)
|
setCollate($2, $6);
|
||||||
$<addColumnClause>4->collate = *$6;
|
|
||||||
}
|
}
|
||||||
| symbol_column_name non_array_type def_computed
|
| symbol_column_name non_array_type def_computed
|
||||||
{
|
{
|
||||||
@ -2807,7 +2804,10 @@ input_proc_parameters($parameters)
|
|||||||
%type input_proc_parameter(<parametersClause>)
|
%type input_proc_parameter(<parametersClause>)
|
||||||
input_proc_parameter($parameters)
|
input_proc_parameter($parameters)
|
||||||
: column_domain_or_non_array_type collate_clause default_par_opt
|
: 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>)
|
%type output_proc_parameters(<parametersClause>)
|
||||||
@ -2819,7 +2819,10 @@ output_proc_parameters($parameters)
|
|||||||
%type output_proc_parameter(<parametersClause>)
|
%type output_proc_parameter(<parametersClause>)
|
||||||
output_proc_parameter($parameters)
|
output_proc_parameter($parameters)
|
||||||
: column_domain_or_non_array_type collate_clause
|
: 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
|
%type <legacyField> column_domain_or_non_array_type
|
||||||
@ -2891,7 +2894,8 @@ function_clause_start
|
|||||||
RETURNS domain_or_non_array_type collate_clause deterministic_clause_opt
|
RETURNS domain_or_non_array_type collate_clause deterministic_clause_opt
|
||||||
{
|
{
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
$$->returnType = newNode<ParameterClause>($5, optName($6));
|
$$->returnType = newNode<ParameterClause>($5);
|
||||||
|
setCollate($5, $6);
|
||||||
$$->deterministic = $7;
|
$$->deterministic = $7;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -3230,7 +3234,8 @@ local_declaration_subfunc_start
|
|||||||
RETURNS domain_or_non_array_type collate_clause deterministic_clause_opt
|
RETURNS domain_or_non_array_type collate_clause deterministic_clause_opt
|
||||||
{
|
{
|
||||||
$$ = $4;
|
$$ = $4;
|
||||||
$$->dsqlBlock->returns.add(newNode<ParameterClause>($<legacyField>7, optName($8)));
|
setCollate($7, $8);
|
||||||
|
$$->dsqlBlock->returns.add(newNode<ParameterClause>($<legacyField>7));
|
||||||
$$->dsqlDeterministic = $9;
|
$$->dsqlDeterministic = $9;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -3245,8 +3250,10 @@ local_declaration_item
|
|||||||
var_declaration_item
|
var_declaration_item
|
||||||
: column_domain_or_non_array_type collate_clause var_declaration_initializer
|
: 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>();
|
DeclareVariableNode* node = newNode<DeclareVariableNode>();
|
||||||
node->dsqlDef = newNode<ParameterClause>($1, optName($2), $3);
|
node->dsqlDef = newNode<ParameterClause>($1, $3);
|
||||||
$$ = node;
|
$$ = node;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -3926,7 +3933,10 @@ block_parameters($parameters)
|
|||||||
%type block_parameter(<parametersClause>)
|
%type block_parameter(<parametersClause>)
|
||||||
block_parameter($parameters)
|
block_parameter($parameters)
|
||||||
: column_domain_or_non_array_type collate_clause '=' parameter
|
: 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
|
// CREATE VIEW
|
||||||
@ -4909,7 +4919,7 @@ array_range
|
|||||||
%type <legacyField> simple_type
|
%type <legacyField> simple_type
|
||||||
simple_type
|
simple_type
|
||||||
: non_charset_simple_type
|
: non_charset_simple_type
|
||||||
| character_type charset_clause
|
| character_type charset_clause collate_clause
|
||||||
{
|
{
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
if ($2)
|
if ($2)
|
||||||
@ -4917,12 +4927,19 @@ simple_type
|
|||||||
$$->charSet = *$2;
|
$$->charSet = *$2;
|
||||||
$$->flags |= FLD_has_chset;
|
$$->flags |= FLD_has_chset;
|
||||||
}
|
}
|
||||||
|
if ($3)
|
||||||
|
$$->collate = *$3;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
%type <legacyField> non_charset_simple_type
|
%type <legacyField> non_charset_simple_type
|
||||||
non_charset_simple_type
|
non_charset_simple_type
|
||||||
: national_character_type
|
: national_character_type collate_clause
|
||||||
|
{
|
||||||
|
$$ = $1;
|
||||||
|
if ($2)
|
||||||
|
$$->collate = *$2;
|
||||||
|
}
|
||||||
| binary_character_type
|
| binary_character_type
|
||||||
| numeric_type
|
| numeric_type
|
||||||
| float_type
|
| float_type
|
||||||
|
Loading…
Reference in New Issue
Block a user