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

Parsing support for ENUM with columnstore engine

This commit is contained in:
Nedeljko Stefanovic
2025-06-19 14:33:29 +00:00
parent 2e2b4b3f82
commit b96e5e6618
5 changed files with 33 additions and 2 deletions

View File

@@ -117,6 +117,7 @@ CREATE {return CREATE;}
CURRENT_USER {return CURRENT_USER;} CURRENT_USER {return CURRENT_USER;}
DATE {ddlget_lval(yyscanner)->str = scanner_copy("date", yyscanner); return DATE;} DATE {ddlget_lval(yyscanner)->str = scanner_copy("date", yyscanner); return DATE;}
DATETIME {return DATETIME;} DATETIME {return DATETIME;}
ENUM {return ENUM;}
TIME {ddlget_lval(yyscanner)->str = scanner_copy("time", yyscanner); return TIME;} TIME {ddlget_lval(yyscanner)->str = scanner_copy("time", yyscanner); return TIME;}
TIMESTAMP {return TIMESTAMP;} TIMESTAMP {return TIMESTAMP;}
DECIMAL {return DECIMAL;} DECIMAL {return DECIMAL;}

View File

@@ -122,6 +122,7 @@ void fix_column_length_and_charset(SchemaObject* elem, const CHARSET_INFO* def_c
ddlpackage::AlterTableActionList *ataList; ddlpackage::AlterTableActionList *ataList;
ddlpackage::DDL_CONSTRAINT_ATTRIBUTES cattr; ddlpackage::DDL_CONSTRAINT_ATTRIBUTES cattr;
std::pair<std::string, std::string> *tableOption; std::pair<std::string, std::string> *tableOption;
std::vector<std::string> *strList;
const char *columnOption; const char *columnOption;
ddlpackage::ColumnConstraintDef *columnConstraintDef; ddlpackage::ColumnConstraintDef *columnConstraintDef;
ddlpackage::ColumnNameList *columnNameList; ddlpackage::ColumnNameList *columnNameList;
@@ -154,7 +155,7 @@ void fix_column_length_and_charset(SchemaObject* elem, const CHARSET_INFO* def_c
CHARACTER CHECK CLOB COLUMN CHARACTER CHECK CLOB COLUMN
BOOL BOOLEAN BOOL BOOLEAN
COLUMNS COMMENT CONSTRAINT CONSTRAINTS CREATE CURRENT_USER DATETIME DEC COLUMNS COMMENT CONSTRAINT CONSTRAINTS CREATE CURRENT_USER DATETIME DEC
DECIMAL DEFAULT DEFERRABLE DEFERRED IDB_DELETE DROP ENGINE DECIMAL DEFAULT DEFERRABLE DEFERRED IDB_DELETE DROP ENGINE ENUM
FOREIGN FULL IMMEDIATE INDEX INITIALLY IDB_INT INTEGER KEY LONGBLOB LONGTEXT FOREIGN FULL IMMEDIATE INDEX INITIALLY IDB_INT INTEGER KEY LONGBLOB LONGTEXT
MATCH MAX_ROWS MEDIUMBLOB MEDIUMTEXT MEDIUMINT MATCH MAX_ROWS MEDIUMBLOB MEDIUMTEXT MEDIUMINT
MIN_ROWS MODIFY NO NOT NULL_TOK NUMBER NUMERIC ON PARTIAL PRECISION PRIMARY MIN_ROWS MODIFY NO NOT NULL_TOK NUMBER NUMERIC ON PARTIAL PRECISION PRIMARY
@@ -207,6 +208,7 @@ ZEROFILL
%type <refActionCode> opt_delete_rule %type <refActionCode> opt_delete_rule
%type <columnType> exact_numeric_type %type <columnType> exact_numeric_type
%type <str> literal %type <str> literal
%type <strList> nonemptyLiteralList
%type <matchType> opt_match_type %type <matchType> opt_match_type
%type <matchType> match_type %type <matchType> match_type
%type <ata> alter_table_comment %type <ata> alter_table_comment
@@ -261,7 +263,7 @@ ZEROFILL
// for objects allocated during parse:. // for objects allocated during parse:.
%destructor { delete $$; } qualified_name ident table_element column_def exact_numeric_type %destructor { delete $$; } qualified_name ident table_element column_def exact_numeric_type
%destructor { delete $$; } table_options opt_table_options table_name %destructor { delete $$; } table_options opt_table_options table_name
%destructor { delete $$; } column_name_list data_type column_constraint %destructor { delete $$; } column_name_list data_type column_constraint nonemptyLiteralList
%destructor { delete $$; } column_constraint_def column_qualifier_list %destructor { delete $$; } column_constraint_def column_qualifier_list
%destructor { delete $$; } opt_referential_triggered_action referential_triggered_action %destructor { delete $$; } opt_referential_triggered_action referential_triggered_action
%destructor { delete $$; } table_option character_string_type binary_string_type blob_type %destructor { delete $$; } table_option character_string_type binary_string_type blob_type
@@ -845,6 +847,7 @@ data_type:
$1->fCollate = $3; $1->fCollate = $3;
$$ = $1; $$ = $1;
} }
| ENUM '(' nonemptyLiteralList ')' { $$ = new ColumnType(DDL_ENUM); $$->fEnumValues = std::move(*$3); }
| IDB_BLOB | IDB_BLOB
{ {
$$ = new ColumnType(DDL_BLOB); $$ = new ColumnType(DDL_BLOB);
@@ -855,7 +858,11 @@ data_type:
$$ = new ColumnType(DDL_CLOB); $$ = new ColumnType(DDL_CLOB);
$$->fLength = DDLDatatypeLength[DDL_CLOB]; $$->fLength = DDLDatatypeLength[DDL_CLOB];
} }
;
nonemptyLiteralList:
literal { $$ = new std::vector<std::string>(); $$->push_back($1); }
| nonemptyLiteralList ',' literal { $$ = $1; $1 = nullptr; $$->push_back($3); }
; ;
column_qualifier_list: column_qualifier_list:

View File

@@ -186,6 +186,7 @@ enum DDL_DATATYPES
DDL_MEDINT, DDL_MEDINT,
DDL_INT, DDL_INT,
DDL_FLOAT, DDL_FLOAT,
DDL_ENUM,
DDL_DATE, DDL_DATE,
DDL_BIGINT, DDL_BIGINT,
DDL_DOUBLE, DDL_DOUBLE,
@@ -941,6 +942,9 @@ struct ColumnType
/** @brief SQL "with timezone" specifier */ /** @brief SQL "with timezone" specifier */
bool fWithTimezone; bool fWithTimezone;
/** @brief enum values for the SQL with enum type */
std::vector<std::string> fEnumValues;
int fCompressiontype; int fCompressiontype;
std::string fAutoincrement; std::string fAutoincrement;

View File

@@ -1125,6 +1125,7 @@ int ColumnType::unserialize(ByteStream& bytestream)
std::string autoincrement; std::string autoincrement;
messageqcpp::ByteStream::octbyte nextVal; messageqcpp::ByteStream::octbyte nextVal;
messageqcpp::ByteStream::quadbyte charsetNum; messageqcpp::ByteStream::quadbyte charsetNum;
messageqcpp::ByteStream::octbyte enumValuesNum = fEnumValues.size();
// read column types // read column types
bytestream >> ftype; bytestream >> ftype;
@@ -1136,6 +1137,14 @@ int ColumnType::unserialize(ByteStream& bytestream)
bytestream >> autoincrement; bytestream >> autoincrement;
bytestream >> nextVal; bytestream >> nextVal;
bytestream >> charsetNum; bytestream >> charsetNum;
bytestream >> enumValuesNum;
for (size_t i = 0; i<fEnumValues.size(); ++i) {
std::string value;
bytestream >> value;
fEnumValues.push_back(value);
}
fType = ftype; fType = ftype;
fLength = length; fLength = length;
@@ -1166,6 +1175,7 @@ int ColumnType::serialize(ByteStream& bytestream)
std::string autoincrement = fAutoincrement; std::string autoincrement = fAutoincrement;
messageqcpp::ByteStream::octbyte nextVal = fNextvalue; messageqcpp::ByteStream::octbyte nextVal = fNextvalue;
messageqcpp::ByteStream::quadbyte charsetNum = fCharsetNum; messageqcpp::ByteStream::quadbyte charsetNum = fCharsetNum;
messageqcpp::ByteStream::octbyte enumValuesNum = fEnumValues.size();
// write column types // write column types
bytestream << ftype; bytestream << ftype;
@@ -1177,6 +1187,11 @@ int ColumnType::serialize(ByteStream& bytestream)
bytestream << autoincrement; bytestream << autoincrement;
bytestream << nextVal; bytestream << nextVal;
bytestream << charsetNum; bytestream << charsetNum;
bytestream << enumValuesNum;
for (size_t i = 0; i<fEnumValues.size(); ++i) {
bytestream << fEnumValues[i];
}
// cout << "BS length = " << bytestream.length() << endl; // cout << "BS length = " << bytestream.length() << endl;

View File

@@ -840,6 +840,10 @@ int ProcessDDLStatement(string& ddlStatement, string& schema, const string& /*ta
} }
} }
if (createTable->fTableDef->fColumns[i]->fType->fType == ddlpackage::DDL_ENUM) {
// TO DO
}
// check varbinary data type // check varbinary data type
if ((createTable->fTableDef->fColumns[i]->fType->fType == ddlpackage::DDL_VARBINARY) && if ((createTable->fTableDef->fColumns[i]->fType->fType == ddlpackage::DDL_VARBINARY) &&
!isVarbinaryAllowed) !isVarbinaryAllowed)