提交 0bb4e921 编写于 作者: D dapan1121

support stable

上级 45b86131
...@@ -5335,7 +5335,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -5335,7 +5335,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f); tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
} else if (pAlterSQL->type == TSDB_ALTER_TABLE_CHANGE_COLUMN) { } else if (pAlterSQL->type == TSDB_ALTER_TABLE_CHANGE_COLUMN) {
if (taosArrayGetSize(pAlterSQL->pAddColumns) != 2) { if (taosArrayGetSize(pAlterSQL->pAddColumns) != 2) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), NULL); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), NULL);
} }
tVariantListItem* pItem = taosArrayGet(pAlterSQL->pAddColumns, 0); tVariantListItem* pItem = taosArrayGet(pAlterSQL->pAddColumns, 0);
...@@ -5343,20 +5343,20 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -5343,20 +5343,20 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
SColumnIndex columnIndex = COLUMN_INDEX_INITIALIZER; SColumnIndex columnIndex = COLUMN_INDEX_INITIALIZER;
SStrToken name = {.type = TK_STRING, .z = pItem->pVar.pz, .n = pItem->pVar.nLen}; SStrToken name = {.type = TK_STRING, .z = pItem->pVar.pz, .n = pItem->pVar.nLen};
if (getColumnIndexByName(pCmd, &name, pQueryInfo, &columnIndex) != TSDB_CODE_SUCCESS) { if (getColumnIndexByName(pCmd, &name, pQueryInfo, &columnIndex) != TSDB_CODE_SUCCESS) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg17); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg17);
} }
SSchema* pColSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, columnIndex.columnIndex); SSchema* pColSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, columnIndex.columnIndex);
if (pColSchema->type != TSDB_DATA_TYPE_BINARY && pColSchema->type != TSDB_DATA_TYPE_NCHAR) { if (pColSchema->type != TSDB_DATA_TYPE_BINARY && pColSchema->type != TSDB_DATA_TYPE_NCHAR) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg21); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg21);
} }
pItem = taosArrayGet(pAlterSQL->pAddColumns, 1); pItem = taosArrayGet(pAlterSQL->pAddColumns, 1);
int64_t nlen = 0; int64_t nlen = 0;
if (tVariantDump(&pItem->pVar, (char *)&nlen, TSDB_DATA_TYPE_BIGINT, false) < 0 || nlen <= 0) { if (tVariantDump(&pItem->pVar, (char *)&nlen, TSDB_DATA_TYPE_BIGINT, false) < 0 || nlen <= 0) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg22); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg22);
} }
TAOS_FIELD f = tscCreateField(pColSchema->type, name.z, nlen); TAOS_FIELD f = tscCreateField(pColSchema->type, name.z, nlen);
......
...@@ -210,6 +210,7 @@ ...@@ -210,6 +210,7 @@
#define TK_SPACE 300 #define TK_SPACE 300
#define TK_COMMENT 301 #define TK_COMMENT 301
#define TK_ILLEGAL 302 #define TK_ILLEGAL 302
......
...@@ -824,6 +824,18 @@ cmd ::= ALTER STABLE ids(X) cpxName(F) DROP COLUMN ids(A). { ...@@ -824,6 +824,18 @@ cmd ::= ALTER STABLE ids(X) cpxName(F) DROP COLUMN ids(A). {
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
cmd ::= ALTER STABLE ids(X) cpxName(F) ALTER COLUMN LENGTH ids(A) INTEGER(Z). {
X.n += F.n;
toTSDBType(A.type);
SArray* K = tVariantListAppendToken(NULL, &A, -1);
toTSDBType(Z.type);
K = tVariantListAppendToken(K, &Z, -1);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, K, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
//////////////////////////////////ALTER TAGS statement///////////////////////////////////// //////////////////////////////////ALTER TAGS statement/////////////////////////////////////
cmd ::= ALTER STABLE ids(X) cpxName(Y) ADD TAG columnlist(A). { cmd ::= ALTER STABLE ids(X) cpxName(Y) ADD TAG columnlist(A). {
X.n += Y.n; X.n += Y.n;
......
此差异已折叠。
...@@ -38,7 +38,7 @@ endi ...@@ -38,7 +38,7 @@ endi
sql create stable stb (ts timestamp, c1 int, c2 binary(10), c3 nchar(10)) tags(id int) sql create stable stb (ts timestamp, c1 int, c2 binary(10), c3 nchar(10)) tags(id int)
sql create table tb1 using stb tags(1) sql create table tb1 using stb tags(1)
sql insert into tb1 values (now, 1, "1", "1") sql insert into tb1 values (now, 1, "1", "1")
sql alter table stb alter column length c2 20; sql alter stable stb alter column length c2 20;
if $rows != 0 then if $rows != 0 then
return -1 return -1
endi endi
...@@ -47,7 +47,9 @@ endi ...@@ -47,7 +47,9 @@ endi
# try dropping columns that are defined in metric # try dropping columns that are defined in metric
sql_error alter table tb alter column length c1 10; sql_error alter table tb alter column length c1 10;
sql_error alter stable tb alter column length c2 10;
sql_error alter table tb1 alter column length c2 10; sql_error alter table tb1 alter column length c2 10;
sql_error alter stable tb1 alter column length c2 10;
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册