1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

MCOL-641 This commit enables CS to return a warning on non-supported ZEROFILL

keyword.

The change potentially replaces tabs with spaces in the bison's ddl.y file.
This commit is contained in:
Roman Nozdrin
2020-02-18 12:30:30 +00:00
parent 2eb5af1d24
commit 31d597d87e
2 changed files with 138 additions and 115 deletions

View File

@ -63,7 +63,6 @@ char* copy_string(const char *str);
%pure-parser %pure-parser
%lex-param {void * scanner} %lex-param {void * scanner}
%parse-param {struct ddlpackage::pass_to_bison * x} %parse-param {struct ddlpackage::pass_to_bison * x}
%debug
/* Bison uses this to generate a C union definition. This is used to /* Bison uses this to generate a C union definition. This is used to
store the application created values associated with syntactic store the application created values associated with syntactic
@ -1007,7 +1006,7 @@ exact_numeric_type:
$2->fLength = DDLDatatypeLength[DDL_UNSIGNED_NUMERIC]; $2->fLength = DDLDatatypeLength[DDL_UNSIGNED_NUMERIC];
$$ = $2; $$ = $2;
} }
| DECIMAL opt_precision_scale opt_signed opt_zerofill | DECIMAL opt_precision_scale opt_signed
{ {
$2->fType = DDL_DECIMAL; $2->fType = DDL_DECIMAL;
$$ = $2; $$ = $2;
@ -1113,128 +1112,128 @@ opt_signed:
SIGNED {$$ = NULL;} SIGNED {$$ = NULL;}
| {$$ = NULL;} | {$$ = NULL;}
opt_zerofill: opt_zerofill:
ZEROFILL {$$ = NULL;} ZEROFILL {$$ = NULL;}
| {$$ = NULL;} | {$$ = NULL;}
opt_display_width: opt_display_width:
'(' ICONST ')' {$$ = NULL;} '(' ICONST ')' {$$ = NULL;}
| {$$ = NULL;}
;
approximate_numeric_type:
DOUBLE opt_display_precision_scale_null
{
$$ = new ColumnType(DDL_DOUBLE);
$$->fLength = DDLDatatypeLength[DDL_DOUBLE];
}
| DOUBLE opt_display_precision_scale_null UNSIGNED
{
$$ = new ColumnType(DDL_UNSIGNED_DOUBLE);
$$->fLength = DDLDatatypeLength[DDL_DOUBLE];
}
| DOUBLE PRECISION opt_display_precision_scale_null
{
$$ = new ColumnType(DDL_DOUBLE);
$$->fLength = DDLDatatypeLength[DDL_DOUBLE];
}
| DOUBLE PRECISION opt_display_precision_scale_null UNSIGNED
{
$$ = new ColumnType(DDL_UNSIGNED_DOUBLE);
$$->fLength = DDLDatatypeLength[DDL_DOUBLE];
}
| REAL opt_display_precision_scale_null
{
$$ = new ColumnType(DDL_DOUBLE);
$$->fLength = DDLDatatypeLength[DDL_DOUBLE];
}
| REAL opt_display_precision_scale_null UNSIGNED
{
$$ = new ColumnType(DDL_UNSIGNED_DOUBLE);
$$->fLength = DDLDatatypeLength[DDL_DOUBLE];
}
| IDB_FLOAT opt_display_precision_scale_null
{
$$ = new ColumnType(DDL_FLOAT);
$$->fLength = DDLDatatypeLength[DDL_FLOAT];
}
| IDB_FLOAT opt_display_precision_scale_null UNSIGNED
{
$$ = new ColumnType(DDL_UNSIGNED_FLOAT);
$$->fLength = DDLDatatypeLength[DDL_FLOAT];
}
;
opt_display_precision_scale_null:
'(' ICONST ')' {$$ = NULL;}
|
'(' ICONST ',' ICONST ')' {$$ = NULL;}
| {$$ = NULL;} | {$$ = NULL;}
; ;
literal:
ICONST
| string_literal
| FCONST
;
datetime_type: approximate_numeric_type:
DATETIME opt_time_precision DOUBLE opt_display_precision_scale_null
{ {
$$ = new ColumnType(DDL_DATETIME); $$ = new ColumnType(DDL_DOUBLE);
$$->fLength = DDLDatatypeLength[DDL_DATETIME]; $$->fLength = DDLDatatypeLength[DDL_DOUBLE];
$$->fPrecision = $2; }
} | DOUBLE opt_display_precision_scale_null UNSIGNED
| {
DATE $$ = new ColumnType(DDL_UNSIGNED_DOUBLE);
{ $$->fLength = DDLDatatypeLength[DDL_DOUBLE];
$$ = new ColumnType(DDL_DATE); }
$$->fLength = DDLDatatypeLength[DDL_DATE]; | DOUBLE PRECISION opt_display_precision_scale_null
} {
| $$ = new ColumnType(DDL_DOUBLE);
TIME opt_time_precision $$->fLength = DDLDatatypeLength[DDL_DOUBLE];
{ }
$$ = new ColumnType(DDL_TIME); | DOUBLE PRECISION opt_display_precision_scale_null UNSIGNED
$$->fLength = DDLDatatypeLength[DDL_TIME]; {
$$->fPrecision = $2; $$ = new ColumnType(DDL_UNSIGNED_DOUBLE);
} $$->fLength = DDLDatatypeLength[DDL_DOUBLE];
| }
TIMESTAMP opt_time_precision | REAL opt_display_precision_scale_null
{ {
$$ = new ColumnType(DDL_TIMESTAMP); $$ = new ColumnType(DDL_DOUBLE);
$$->fLength = DDLDatatypeLength[DDL_TIMESTAMP]; $$->fLength = DDLDatatypeLength[DDL_DOUBLE];
$$->fPrecision = $2; }
} | REAL opt_display_precision_scale_null UNSIGNED
{
$$ = new ColumnType(DDL_UNSIGNED_DOUBLE);
$$->fLength = DDLDatatypeLength[DDL_DOUBLE];
}
| IDB_FLOAT opt_display_precision_scale_null
{
$$ = new ColumnType(DDL_FLOAT);
$$->fLength = DDLDatatypeLength[DDL_FLOAT];
}
| IDB_FLOAT opt_display_precision_scale_null UNSIGNED
{
$$ = new ColumnType(DDL_UNSIGNED_FLOAT);
$$->fLength = DDLDatatypeLength[DDL_FLOAT];
}
;
opt_time_precision: opt_display_precision_scale_null:
'(' ICONST ')' {$$ = atoi($2);} '(' ICONST ')' {$$ = NULL;}
| {$$ = -1;} |
; '(' ICONST ',' ICONST ')' {$$ = NULL;}
| {$$ = NULL;}
;
literal:
ICONST
| string_literal
| FCONST
;
drop_column_def: datetime_type:
DROP column_name drop_behavior {$$ = new AtaDropColumn($2, $3);} DATETIME opt_time_precision
| DROP COLUMN column_name drop_behavior {$$ = new AtaDropColumn($3, $4);} {
| DROP COLUMN '(' column_name_list ')' {$$ = new AtaDropColumns($4);} $$ = new ColumnType(DDL_DATETIME);
| DROP '(' column_name_list ')' {$$ = new AtaDropColumns($3);} $$->fLength = DDLDatatypeLength[DDL_DATETIME];
| DROP COLUMNS '(' column_name_list ')' {$$ = new AtaDropColumns($4);} $$->fPrecision = $2;
; }
|
DATE
{
$$ = new ColumnType(DDL_DATE);
$$->fLength = DDLDatatypeLength[DDL_DATE];
}
|
TIME opt_time_precision
{
$$ = new ColumnType(DDL_TIME);
$$->fLength = DDLDatatypeLength[DDL_TIME];
$$->fPrecision = $2;
}
|
TIMESTAMP opt_time_precision
{
$$ = new ColumnType(DDL_TIMESTAMP);
$$->fLength = DDLDatatypeLength[DDL_TIMESTAMP];
$$->fPrecision = $2;
}
drop_behavior: opt_time_precision:
CASCADE {$$ = DDL_CASCADE;} '(' ICONST ')' {$$ = atoi($2);}
| RESTRICT {$$ = DDL_RESTRICT;} | {$$ = -1;}
| {$$ = DDL_NO_ACTION;} ;
;
alter_column_def: drop_column_def:
ALTER opt_column column_name SET default_clause {$$ = new AtaSetColumnDefault($3, $5);} DROP column_name drop_behavior {$$ = new AtaDropColumn($2, $3);}
| ALTER opt_column column_name DROP DEFAULT {$$ = new AtaDropColumnDefault($3);} | DROP COLUMN column_name drop_behavior {$$ = new AtaDropColumn($3, $4);}
; | DROP COLUMN '(' column_name_list ')' {$$ = new AtaDropColumns($4);}
| DROP '(' column_name_list ')' {$$ = new AtaDropColumns($3);}
| DROP COLUMNS '(' column_name_list ')' {$$ = new AtaDropColumns($4);}
;
opt_column: drop_behavior:
COLUMN CASCADE {$$ = DDL_CASCADE;}
| | RESTRICT {$$ = DDL_RESTRICT;}
; | {$$ = DDL_NO_ACTION;}
;
%% alter_column_def:
ALTER opt_column column_name SET default_clause {$$ = new AtaSetColumnDefault($3, $5);}
| ALTER opt_column column_name DROP DEFAULT {$$ = new AtaDropColumnDefault($3);}
;
opt_column:
COLUMN
|
;
%%

View File

@ -2299,6 +2299,22 @@ static bool get_field_default_value(THD *thd, Field *field, String *def_value,
return has_default; return has_default;
} }
/*
Utility function search for ZEROFILL
*/
bool hasZerofillDecimal(TABLE *table_arg)
{
for (Field **field= table_arg->field; *field; field++)
{
if (((*field)->flags & ZEROFILL_FLAG)
&& typeid (**field) == typeid(Field_new_decimal))
return true;
}
return false;
}
int ha_mcs_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO* create_info, cal_connection_info& ci) int ha_mcs_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO* create_info, cal_connection_info& ci)
{ {
#ifdef MCS_DEBUG #ifdef MCS_DEBUG
@ -2578,6 +2594,14 @@ int ha_mcs_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO* crea
cout << "ha_mcs_impl_create_: ProcessDDL error, now in state NOT_ALTER" << endl; cout << "ha_mcs_impl_create_: ProcessDDL error, now in state NOT_ALTER" << endl;
#endif #endif
} }
else
{
if (hasZerofillDecimal(table_arg))
{
push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
WARN_OPTION_IGNORED, "ZEROFILL is ignored in ColumnStore");
}
}
return rc; return rc;
} }