diff --git a/contrib/dolphin/expected/m_testcase_fix.out b/contrib/dolphin/expected/m_testcase_fix.out index e5dd4cd755daebe161e965eb32824ce8e0a6c6b2..c40282d3546507353a893f4a32c9fc815e2e23e4 100644 --- a/contrib/dolphin/expected/m_testcase_fix.out +++ b/contrib/dolphin/expected/m_testcase_fix.out @@ -276,5 +276,42 @@ SELECT SUM(a) OVER(ORDER BY a ROWS BETWEEN 9223372036854775807 FOLLOWING AND 922 (4 rows) drop table t; +-- storage +create table t1(c int storage disk); +WARNING: storage disk for TABLE is not supported for current version. skipped +create table t2(c int storage memory); +WARNING: storage memory for TABLE is not supported for current version. skipped +create table t3(c int storage default); +WARNING: storage default for TABLE is not supported for current version. skipped +ALTER TABLE t1 MODIFY COLUMN c INT STORAGE MEMORY; +WARNING: storage memory for TABLE is not supported for current version. skipped +ALTER TABLE t2 MODIFY COLUMN c INT STORAGE default; +WARNING: storage default for TABLE is not supported for current version. skipped +ALTER TABLE t3 MODIFY COLUMN c INT STORAGE disk; +WARNING: storage disk for TABLE is not supported for current version. skipped +insert into t1 values (1); +insert into t2 values (2); +insert into t3 values (3); +select * from t1; + c +--- + 1 +(1 row) + +select * from t2; + c +--- + 2 +(1 row) + +select * from t3; + c +--- + 3 +(1 row) + +drop table t1; +drop table t2; +drop table t3; drop schema m_testcase_fix cascade; reset current_schema; diff --git a/contrib/dolphin/plugin_parser/gram.y b/contrib/dolphin/plugin_parser/gram.y index 30ba6a7fa8190c8c8b98dd9772a9f546a7ebdfcb..e5d9e182de916d017fe215f65bf66882cffe9511 100644 --- a/contrib/dolphin/plugin_parser/gram.y +++ b/contrib/dolphin/plugin_parser/gram.y @@ -287,6 +287,13 @@ typedef enum { OPT_TABLESPACE_STORAGE } TableOptionType; +typedef enum { + WITHOUT_TABLE_STORAGE_DISK_OPT, + TABLE_STORAGE_DISK_OPT, + TABLE_STORAGE_MEMORY_OPT, + TABLE_STORAGE_DEFAULT_OPT +} TableStorageTypeOpt; + typedef struct SingleTableOption { TableOptionType option_type; union { @@ -1114,6 +1121,9 @@ static List* PreHandleTymod(List* origin); %type opt_columns %type opt_row_movement_clause + +%type column_storage_option + /* PGXC_BEGIN */ %type opt_barrier_id OptDistributeType SliceReferenceClause %type OptDistributeBy OptDistributeBy_without_empty OptDistributeByInternal distribute_by_range_clause @@ -1399,7 +1409,7 @@ static List* PreHandleTymod(List* origin); FALSE_ON_ERROR TRUE_ON_ERROR ERROR_ON_ERROR LOCK_TABLES LABEL_LOOP LABEL_REPEAT LABEL_WHILE WITH_PARSER - STORAGE_DISK STORAGE_MEMORY + STORAGE_DISK STORAGE_MEMORY STORAGE_DEFAULT FULL_OUTER /* Precedence: lowest to highest */ @@ -4909,10 +4919,10 @@ modify_column_cmds: | modify_column_cmds ',' modify_column_cmd { $$ = lappend($$, $3); } ; modify_column_cmd: - DolphinColColId Typename opt_charset ColQualList add_column_first_after + DolphinColColId Typename opt_charset column_storage_option ColQualList add_column_first_after { - AlterTableCmd *n = (AlterTableCmd *)$5; - if ($4 == NULL && n->is_first == false && n->after_name == NULL && !ENABLE_MODIFY_COLUMN) { + AlterTableCmd *n = (AlterTableCmd *)$6; + if ($5 == NULL && n->is_first == false && n->after_name == NULL && !ENABLE_MODIFY_COLUMN) { ColumnDef *def = makeNode(ColumnDef); n->subtype = AT_AlterColumnType; n->name = $1; @@ -4960,7 +4970,7 @@ modify_column_cmd: def->collOid = InvalidOid; def->fdwoptions = NULL; def->update_default = NULL; - SplitColQualList($4, &def->constraints, &def->collClause, &def->clientLogicColumnRef, &def->columnOptions, yyscanner); + SplitColQualList($5, &def->constraints, &def->collClause, &def->clientLogicColumnRef, &def->columnOptions, yyscanner); if ($3->binary) { def->columnOptions = lappend(def->columnOptions, makeString("binary")); } @@ -5925,7 +5935,7 @@ alter_table_cmd: { $$ = $2; } - | MODIFY_P COLUMN DolphinColColId Typename opt_charset ColQualList add_column_first_after + | MODIFY_P COLUMN DolphinColColId Typename opt_charset column_storage_option ColQualList add_column_first_after { #ifdef ENABLE_MULTIPLE_NODES const char* message = "Un-support feature"; @@ -5958,11 +5968,11 @@ alter_table_cmd: def->cooked_default = NULL; def->collOid = InvalidOid; def->fdwoptions = NULL; - SplitColQualList($6, &def->constraints, &def->collClause, &def->clientLogicColumnRef, &def->columnOptions, yyscanner); + SplitColQualList($7, &def->constraints, &def->collClause, &def->clientLogicColumnRef, &def->columnOptions, yyscanner); if ($5->binary) { def->columnOptions = lappend(def->columnOptions, makeString("binary")); } - AlterTableCmd *n = (AlterTableCmd *)$7; + AlterTableCmd *n = (AlterTableCmd *)$8; n->subtype = AT_ModifyColumn; n->name = $3; n->def = (Node *)def; @@ -8879,6 +8889,25 @@ tablespace_storage_option: | /*EMPTY*/ {} ; +column_storage_option: + STORAGE_DISK + { + ereport(WARNING, (errmsg("storage disk for TABLE is not supported for current version. skipped"))); + $$ = TABLE_STORAGE_DISK_OPT; + } + | STORAGE_MEMORY + { + ereport(WARNING, (errmsg("storage memory for TABLE is not supported for current version. skipped"))); + $$ = TABLE_STORAGE_MEMORY_OPT; + } + | STORAGE_DEFAULT + { + ereport(WARNING, (errmsg("storage default for TABLE is not supported for current version. skipped"))); + $$ = TABLE_STORAGE_DEFAULT_OPT; + } + | /*EMPTY*/ { $$ = WITHOUT_TABLE_STORAGE_DISK_OPT; } + ; + charset_with_opt_equal: CHARSET opt_equal any_name_or_sconst {} | CHARACTER SET opt_equal any_name_or_sconst {} @@ -10378,29 +10407,29 @@ ColIdForTableElement: DOLPHINIDENT { $$ = $1->str; } | PROXY { $$ = pstrdup($1); } ; -columnDefForTableElement: ColIdForTableElement Typename opt_charset KVType ColCmprsMode create_generic_options ColQualList +columnDefForTableElement: ColIdForTableElement Typename opt_charset column_storage_option KVType ColCmprsMode create_generic_options ColQualList { ColumnDef *n = makeNode(ColumnDef); n->colname = $1; n->typname = $2; n->typname->charset = $3->charset; - n->kvtype = $4; + n->kvtype = $5; n->inhcount = 0; n->is_local = true; n->is_not_null = false; n->is_from_type = false; n->storage = 0; - n->cmprs_mode = $5; + n->cmprs_mode = $6; n->raw_default = NULL; n->update_default = NULL; n->cooked_default = NULL; n->collOid = InvalidOid; - n->fdwoptions = $6; + n->fdwoptions = $7; if ($4 == ATT_KV_UNDEFINED) { - SplitColQualList($7, &n->constraints, &n->collClause, &n->clientLogicColumnRef, &n->columnOptions, + SplitColQualList($8, &n->constraints, &n->collClause, &n->clientLogicColumnRef, &n->columnOptions, yyscanner); } else { - SplitColQualList($7, &n->constraints, &n->collClause, &n->columnOptions, + SplitColQualList($8, &n->constraints, &n->collClause, &n->columnOptions, yyscanner); } if ($3->binary) { @@ -10410,29 +10439,29 @@ columnDefForTableElement: ColIdForTableElement Typename opt_charset KVType ColCm } ; -columnDef: DolphinColColId Typename opt_charset KVType ColCmprsMode create_generic_options ColQualList +columnDef: DolphinColColId Typename opt_charset column_storage_option KVType ColCmprsMode create_generic_options ColQualList { ColumnDef *n = makeNode(ColumnDef); n->colname = $1; n->typname = $2; n->typname->charset = $3->charset; - n->kvtype = $4; + n->kvtype = $5; n->inhcount = 0; n->is_local = true; n->is_not_null = false; n->is_from_type = false; n->storage = 0; - n->cmprs_mode = $5; + n->cmprs_mode = $6; n->raw_default = NULL; n->update_default = NULL; n->cooked_default = NULL; n->collOid = InvalidOid; - n->fdwoptions = $6; - if ($4 == ATT_KV_UNDEFINED) { - SplitColQualList($7, &n->constraints, &n->collClause, &n->clientLogicColumnRef, &n->columnOptions, + n->fdwoptions = $7; + if ($5 == ATT_KV_UNDEFINED) { + SplitColQualList($8, &n->constraints, &n->collClause, &n->clientLogicColumnRef, &n->columnOptions, yyscanner); } else { - SplitColQualList($7, &n->constraints, &n->collClause, &n->columnOptions, + SplitColQualList($8, &n->constraints, &n->collClause, &n->columnOptions, yyscanner); } if ($3->binary) { diff --git a/contrib/dolphin/plugin_parser/parser.cpp b/contrib/dolphin/plugin_parser/parser.cpp index 9f21393a91fefef4426f9b7b7f012729c6e41b25..28c8a1d5656c73495cb4294cb2dd937f67c8c2d9 100644 --- a/contrib/dolphin/plugin_parser/parser.cpp +++ b/contrib/dolphin/plugin_parser/parser.cpp @@ -1424,6 +1424,9 @@ int base_yylex(YYSTYPE* lvalp, YYLTYPE* llocp, core_yyscan_t yyscanner) case MEMORY: cur_token = STORAGE_MEMORY; break; + case DEFAULT: + cur_token = STORAGE_DEFAULT; + break; default: /* save the lookahead token for next time */ SET_LOOKAHEAD_TOKEN(); diff --git a/contrib/dolphin/sql/m_testcase_fix.sql b/contrib/dolphin/sql/m_testcase_fix.sql index 72e4f99025475393638873a817e932745e5d84af..640bd29392370328c86703efe3b94a7fe60cc0c3 100644 --- a/contrib/dolphin/sql/m_testcase_fix.sql +++ b/contrib/dolphin/sql/m_testcase_fix.sql @@ -142,5 +142,26 @@ INSERT INTO t VALUES (1),(2),(3),(4); SELECT SUM(a) OVER(ORDER BY a ROWS BETWEEN 9223372036854775807 FOLLOWING AND 9223372036854775807 FOLLOWING) as sum FROM t; drop table t; +-- storage +create table t1(c int storage disk); +create table t2(c int storage memory); +create table t3(c int storage default); + +ALTER TABLE t1 MODIFY COLUMN c INT STORAGE MEMORY; +ALTER TABLE t2 MODIFY COLUMN c INT STORAGE default; +ALTER TABLE t3 MODIFY COLUMN c INT STORAGE disk; + +insert into t1 values (1); +insert into t2 values (2); +insert into t3 values (3); + +select * from t1; +select * from t2; +select * from t3; + +drop table t1; +drop table t2; +drop table t3; + drop schema m_testcase_fix cascade; reset current_schema; \ No newline at end of file