diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c index a7882ffa6186224e30cbbdfb84ff5300131e479e..6b55780af93554446f7f0599fe267e42e258ae81 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -326,6 +326,7 @@ TAOS_ROW tscFetchRow(void *param) { pCmd->command == TSDB_SQL_FETCH || pCmd->command == TSDB_SQL_SHOW || pCmd->command == TSDB_SQL_SHOW_CREATE_TABLE || + pCmd->command == TSDB_SQL_SHOW_CREATE_STABLE || pCmd->command == TSDB_SQL_SHOW_CREATE_DATABASE || pCmd->command == TSDB_SQL_SELECT || pCmd->command == TSDB_SQL_DESCRIBE_TABLE || @@ -679,6 +680,9 @@ static int32_t tscProcessShowCreateTable(SSqlObj *pSql) { assert(pTableMetaInfo->pTableMeta != NULL); const char* tableName = tNameGetTableName(&pTableMetaInfo->name); + if (pSql->cmd.command == TSDB_SQL_SHOW_CREATE_STABLE && !UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { + return TSDB_CODE_TSC_INVALID_VALUE; + } char *result = (char *)calloc(1, TSDB_MAX_BINARY_LEN); int32_t code = TSDB_CODE_SUCCESS; @@ -907,7 +911,7 @@ int tscProcessLocalCmd(SSqlObj *pSql) { */ pRes->qId = 0x1; pRes->numOfRows = 0; - } else if (pCmd->command == TSDB_SQL_SHOW_CREATE_TABLE) { + } else if (pCmd->command == TSDB_SQL_SHOW_CREATE_TABLE || pCmd->command == TSDB_SQL_SHOW_CREATE_STABLE) { pRes->code = tscProcessShowCreateTable(pSql); } else if (pCmd->command == TSDB_SQL_SHOW_CREATE_DATABASE) { pRes->code = tscProcessShowCreateDatabase(pSql); diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 87b4669a04f98b3e1938f98684233b2285f429f8..931189e603e7aabc27c59bafc0ed13b4b9752e60 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -446,6 +446,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { return tscGetTableMeta(pSql, pTableMetaInfo); } + case TSDB_SQL_SHOW_CREATE_STABLE: case TSDB_SQL_SHOW_CREATE_TABLE: { const char* msg1 = "invalid table name"; const char* msg2 = "table name is too long"; diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 9528a553b24dc4eb6211bbef71a96013dc86b2a0..d2bf458e58e211471b31ba09e790f5c8c3735298 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -2641,6 +2641,7 @@ void tscInitMsgsFp() { tscProcessMsgRsp[TSDB_SQL_ALTER_DB] = tscProcessAlterDbMsgRsp; tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_TABLE] = tscProcessShowCreateRsp; + tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_STABLE] = tscProcessShowCreateRsp; tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_DATABASE] = tscProcessShowCreateRsp; tscKeepConn[TSDB_SQL_SHOW] = 1; diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 8dbb1c0a52b67d6067fe379423db5dc9b0610d00..364af4e8b152b0c5be6027659a643dfd0c4aeb94 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -457,6 +457,7 @@ static bool needToFetchNewBlock(SSqlObj* pSql) { pCmd->command == TSDB_SQL_FETCH || pCmd->command == TSDB_SQL_SHOW || pCmd->command == TSDB_SQL_SHOW_CREATE_TABLE || + pCmd->command == TSDB_SQL_SHOW_CREATE_STABLE || pCmd->command == TSDB_SQL_SHOW_CREATE_DATABASE || pCmd->command == TSDB_SQL_SELECT || pCmd->command == TSDB_SQL_DESCRIBE_TABLE || diff --git a/src/common/inc/tcmdtype.h b/src/common/inc/tcmdtype.h index be16e80124358012a079ada5f7cd689afa0f7b75..adf210cfebb15ddc0adcfce2aa85e606f79c44a5 100644 --- a/src/common/inc/tcmdtype.h +++ b/src/common/inc/tcmdtype.h @@ -80,6 +80,7 @@ enum { TSDB_DEFINE_SQL_TYPE( TSDB_SQL_TABLE_JOIN_RETRIEVE, "join-retrieve" ) TSDB_DEFINE_SQL_TYPE( TSDB_SQL_SHOW_CREATE_TABLE, "show-create-table") + TSDB_DEFINE_SQL_TYPE( TSDB_SQL_SHOW_CREATE_STABLE, "show-create-stable") TSDB_DEFINE_SQL_TYPE( TSDB_SQL_SHOW_CREATE_DATABASE, "show-create-database") /* diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index fd922240c2d452f125ce07c77a7faef84f2a31be..8ef8ef0e2b3080ce334686f7fdbb7105596356e5 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -94,6 +94,10 @@ cmd ::= SHOW CREATE TABLE ids(X) cpxName(Y). { X.n += Y.n; setDCLSqlElems(pInfo, TSDB_SQL_SHOW_CREATE_TABLE, 1, &X); } +cmd ::= SHOW CREATE STABLE ids(X) cpxName(Y). { + X.n += Y.n; + setDCLSqlElems(pInfo, TSDB_SQL_SHOW_CREATE_STABLE, 1, &X); +} cmd ::= SHOW CREATE DATABASE ids(X). { setDCLSqlElems(pInfo, TSDB_SQL_SHOW_CREATE_DATABASE, 1, &X);