TD-14043 show tables split
This commit is contained in:
parent
8adeccbfbc
commit
861445c33a
|
@ -125,6 +125,7 @@ typedef struct SRealTableNode {
|
||||||
STableNode table; // QUERY_NODE_REAL_TABLE
|
STableNode table; // QUERY_NODE_REAL_TABLE
|
||||||
struct STableMeta* pMeta;
|
struct STableMeta* pMeta;
|
||||||
SVgroupsInfo* pVgroupList;
|
SVgroupsInfo* pVgroupList;
|
||||||
|
char useDbName[TSDB_DB_NAME_LEN];
|
||||||
} SRealTableNode;
|
} SRealTableNode;
|
||||||
|
|
||||||
typedef struct STempTableNode {
|
typedef struct STempTableNode {
|
||||||
|
|
|
@ -321,103 +321,109 @@ void initAstCreateContext(SParseContext* pParseCxt, SAstCreateContext* pCxt) {
|
||||||
|
|
||||||
static bool checkUserName(SAstCreateContext* pCxt, const SToken* pUserName) {
|
static bool checkUserName(SAstCreateContext* pCxt, const SToken* pUserName) {
|
||||||
if (NULL == pUserName) {
|
if (NULL == pUserName) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (pUserName->n >= TSDB_USER_LEN) {
|
|
||||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
|
||||||
pCxt->valid = false;
|
pCxt->valid = false;
|
||||||
|
} else {
|
||||||
|
if (pUserName->n >= TSDB_USER_LEN) {
|
||||||
|
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
||||||
|
pCxt->valid = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return pCxt->valid;
|
return pCxt->valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool checkPassword(SAstCreateContext* pCxt, const SToken* pPasswordToken, char* pPassword) {
|
static bool checkPassword(SAstCreateContext* pCxt, const SToken* pPasswordToken, char* pPassword) {
|
||||||
if (NULL == pPasswordToken) {
|
if (NULL == pPasswordToken) {
|
||||||
return false;
|
pCxt->valid = false;
|
||||||
}
|
} else if (pPasswordToken->n >= (TSDB_USET_PASSWORD_LEN - 2)) {
|
||||||
if (pPasswordToken->n >= (TSDB_USET_PASSWORD_LEN - 2)) {
|
|
||||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
||||||
pCxt->valid = false;
|
pCxt->valid = false;
|
||||||
return false;
|
} else {
|
||||||
}
|
strncpy(pPassword, pPasswordToken->z, pPasswordToken->n);
|
||||||
strncpy(pPassword, pPasswordToken->z, pPasswordToken->n);
|
strdequote(pPassword);
|
||||||
strdequote(pPassword);
|
if (strtrim(pPassword) <= 0) {
|
||||||
if (strtrim(pPassword) <= 0) {
|
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_PASSWD_EMPTY);
|
||||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_PASSWD_EMPTY);
|
pCxt->valid = false;
|
||||||
pCxt->valid = false;
|
}
|
||||||
}
|
}
|
||||||
return pCxt->valid;
|
return pCxt->valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool checkAndSplitEndpoint(SAstCreateContext* pCxt, const SToken* pEp, char* pFqdn, int32_t* pPort) {
|
static bool checkAndSplitEndpoint(SAstCreateContext* pCxt, const SToken* pEp, char* pFqdn, int32_t* pPort) {
|
||||||
if (NULL == pEp) {
|
if (NULL == pEp) {
|
||||||
return false;
|
pCxt->valid = false;
|
||||||
}
|
} else if (pEp->n >= TSDB_FQDN_LEN + 2 + 6) { // format 'fqdn:port'
|
||||||
if (pEp->n >= TSDB_FQDN_LEN + 2 + 6) { // format 'fqdn:port'
|
|
||||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
||||||
pCxt->valid = false;
|
pCxt->valid = false;
|
||||||
}
|
} else {
|
||||||
char ep[TSDB_FQDN_LEN + 2 + 6];
|
char ep[TSDB_FQDN_LEN + 2 + 6];
|
||||||
strncpy(ep, pEp->z, pEp->n);
|
strncpy(ep, pEp->z, pEp->n);
|
||||||
strdequote(ep);
|
strdequote(ep);
|
||||||
strtrim(ep);
|
strtrim(ep);
|
||||||
char* pColon = strchr(ep, ':');
|
char* pColon = strchr(ep, ':');
|
||||||
if (NULL == pColon) {
|
if (NULL == pColon) {
|
||||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ENDPOINT);
|
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ENDPOINT);
|
||||||
pCxt->valid = false;
|
pCxt->valid = false;
|
||||||
}
|
} else {
|
||||||
strncpy(pFqdn, ep, pColon - ep);
|
strncpy(pFqdn, ep, pColon - ep);
|
||||||
*pPort = strtol(pColon + 1, NULL, 10);
|
*pPort = strtol(pColon + 1, NULL, 10);
|
||||||
if (*pPort >= UINT16_MAX || *pPort <= 0) {
|
if (*pPort >= UINT16_MAX || *pPort <= 0) {
|
||||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_PORT);
|
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_PORT);
|
||||||
pCxt->valid = false;
|
pCxt->valid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return pCxt->valid;
|
return pCxt->valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool checkFqdn(SAstCreateContext* pCxt, const SToken* pFqdn) {
|
static bool checkFqdn(SAstCreateContext* pCxt, const SToken* pFqdn) {
|
||||||
if (NULL == pFqdn) {
|
if (NULL == pFqdn) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (pFqdn->n >= TSDB_FQDN_LEN) {
|
|
||||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
|
||||||
pCxt->valid = false;
|
pCxt->valid = false;
|
||||||
|
} else {
|
||||||
|
if (pFqdn->n >= TSDB_FQDN_LEN) {
|
||||||
|
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
||||||
|
pCxt->valid = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return pCxt->valid;
|
return pCxt->valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool checkPort(SAstCreateContext* pCxt, const SToken* pPortToken, int32_t* pPort) {
|
static bool checkPort(SAstCreateContext* pCxt, const SToken* pPortToken, int32_t* pPort) {
|
||||||
if (NULL == pPortToken) {
|
if (NULL == pPortToken) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
*pPort = strtol(pPortToken->z, NULL, 10);
|
|
||||||
if (*pPort >= UINT16_MAX || *pPort <= 0) {
|
|
||||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_PORT);
|
|
||||||
pCxt->valid = false;
|
pCxt->valid = false;
|
||||||
|
} else {
|
||||||
|
*pPort = strtol(pPortToken->z, NULL, 10);
|
||||||
|
if (*pPort >= UINT16_MAX || *pPort <= 0) {
|
||||||
|
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_PORT);
|
||||||
|
pCxt->valid = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return pCxt->valid;
|
return pCxt->valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool checkDbName(SAstCreateContext* pCxt, const SToken* pDbName, bool query) {
|
static bool checkDbName(SAstCreateContext* pCxt, const SToken* pDbName, bool query) {
|
||||||
if (NULL == pDbName) {
|
if (NULL == pDbName) {
|
||||||
return (query ? NULL != pCxt->pQueryCxt->db : true);
|
pCxt->valid = (query ? NULL != pCxt->pQueryCxt->db : true);
|
||||||
|
} else {
|
||||||
|
pCxt->valid = pDbName->n < TSDB_DB_NAME_LEN ? true : false;
|
||||||
}
|
}
|
||||||
pCxt->valid = pDbName->n < TSDB_DB_NAME_LEN ? true : false;
|
|
||||||
return pCxt->valid;
|
return pCxt->valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool checkTableName(SAstCreateContext* pCxt, const SToken* pTableName) {
|
static bool checkTableName(SAstCreateContext* pCxt, const SToken* pTableName) {
|
||||||
if (NULL == pTableName) {
|
if (NULL == pTableName) {
|
||||||
return true;
|
pCxt->valid = true;
|
||||||
|
} else {
|
||||||
|
pCxt->valid = pTableName->n < TSDB_TABLE_NAME_LEN ? true : false;
|
||||||
}
|
}
|
||||||
pCxt->valid = pTableName->n < TSDB_TABLE_NAME_LEN ? true : false;
|
|
||||||
return pCxt->valid;
|
return pCxt->valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool checkColumnName(SAstCreateContext* pCxt, const SToken* pColumnName) {
|
static bool checkColumnName(SAstCreateContext* pCxt, const SToken* pColumnName) {
|
||||||
if (NULL == pColumnName) {
|
if (NULL == pColumnName) {
|
||||||
return true;
|
pCxt->valid = true;
|
||||||
|
} else {
|
||||||
|
pCxt->valid = pColumnName->n < TSDB_COL_NAME_LEN ? true : false;
|
||||||
}
|
}
|
||||||
pCxt->valid = pColumnName->n < TSDB_COL_NAME_LEN ? true : false;
|
|
||||||
return pCxt->valid;
|
return pCxt->valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,6 +523,10 @@ SNode* createDurationValueNode(SAstCreateContext* pCxt, const SToken* pLiteral)
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createDefaultDatabaseCondValue(SAstCreateContext* pCxt) {
|
SNode* createDefaultDatabaseCondValue(SAstCreateContext* pCxt) {
|
||||||
|
if (NULL == pCxt->pQueryCxt->db) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
SValueNode* val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
SValueNode* val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||||
CHECK_OUT_OF_MEM(val);
|
CHECK_OUT_OF_MEM(val);
|
||||||
val->literal = strdup(pCxt->pQueryCxt->db);
|
val->literal = strdup(pCxt->pQueryCxt->db);
|
||||||
|
@ -590,6 +600,7 @@ SNode* createRealTableNode(SAstCreateContext* pCxt, const SToken* pDbName, const
|
||||||
strncpy(realTable->table.tableAlias, pTableName->z, pTableName->n);
|
strncpy(realTable->table.tableAlias, pTableName->z, pTableName->n);
|
||||||
}
|
}
|
||||||
strncpy(realTable->table.tableName, pTableName->z, pTableName->n);
|
strncpy(realTable->table.tableName, pTableName->z, pTableName->n);
|
||||||
|
strcpy(realTable->useDbName, pCxt->pQueryCxt->db);
|
||||||
return (SNode*)realTable;
|
return (SNode*)realTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -920,7 +931,16 @@ SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName) {
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool needDbShowStmt(ENodeType type) {
|
||||||
|
return QUERY_NODE_SHOW_TABLES_STMT == type || QUERY_NODE_SHOW_STABLES_STMT == type || QUERY_NODE_SHOW_VGROUPS_STMT == type;
|
||||||
|
}
|
||||||
|
|
||||||
SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbNamePattern) {
|
SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbNamePattern) {
|
||||||
|
if (needDbShowStmt(type) && NULL == pDbName && NULL == pCxt->pQueryCxt->db) {
|
||||||
|
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "db not specified");
|
||||||
|
pCxt->valid = false;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
SShowStmt* pStmt = nodesMakeNode(type);;
|
SShowStmt* pStmt = nodesMakeNode(type);;
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->pDbName = pDbName;
|
pStmt->pDbName = pDbName;
|
||||||
|
|
|
@ -560,6 +560,33 @@ static int32_t toVgroupsInfo(SArray* pVgs, SVgroupsInfo** pVgsInfo) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t setSysTableVgroupList(SParseContext* pCxt, SName* pName, SRealTableNode* pRealTable) {
|
||||||
|
// todo release
|
||||||
|
// if (0 != strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_USER_TABLES)) {
|
||||||
|
// return TSDB_CODE_SUCCESS;
|
||||||
|
// }
|
||||||
|
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
SArray* vgroupList = NULL;
|
||||||
|
if ('\0' != pRealTable->useDbName[0]) {
|
||||||
|
code = getDBVgInfo(pCxt, pRealTable->useDbName, &vgroupList);
|
||||||
|
} else {
|
||||||
|
code = getDBVgInfoImpl(pCxt, pName, &vgroupList);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
// todo remove
|
||||||
|
if (NULL != vgroupList && taosArrayGetSize(vgroupList) > 0 && 0 != strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_USER_TABLES)) {
|
||||||
|
taosArrayPopTailBatch(vgroupList, taosArrayGetSize(vgroupList) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
code = toVgroupsInfo(vgroupList, &pRealTable->pVgroupList);
|
||||||
|
}
|
||||||
|
taosArrayDestroy(vgroupList);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t setTableVgroupList(SParseContext* pCxt, SName* pName, SRealTableNode* pRealTable) {
|
static int32_t setTableVgroupList(SParseContext* pCxt, SName* pName, SRealTableNode* pRealTable) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if (TSDB_SUPER_TABLE == pRealTable->pMeta->tableType) {
|
if (TSDB_SUPER_TABLE == pRealTable->pMeta->tableType) {
|
||||||
|
@ -570,12 +597,7 @@ static int32_t setTableVgroupList(SParseContext* pCxt, SName* pName, SRealTableN
|
||||||
}
|
}
|
||||||
taosArrayDestroy(vgroupList);
|
taosArrayDestroy(vgroupList);
|
||||||
} else if (TSDB_SYSTEM_TABLE == pRealTable->pMeta->tableType) {
|
} else if (TSDB_SYSTEM_TABLE == pRealTable->pMeta->tableType) {
|
||||||
SArray* vgroupList = NULL;
|
code = setSysTableVgroupList(pCxt, pName, pRealTable);
|
||||||
code = getDBVgInfoImpl(pCxt, pName, &vgroupList);
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = toVgroupsInfo(vgroupList, &pRealTable->pVgroupList);
|
|
||||||
}
|
|
||||||
taosArrayDestroy(vgroupList);
|
|
||||||
} else {
|
} else {
|
||||||
pRealTable->pVgroupList = calloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo));
|
pRealTable->pVgroupList = calloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo));
|
||||||
if (NULL == pRealTable->pVgroupList) {
|
if (NULL == pRealTable->pVgroupList) {
|
||||||
|
@ -1159,9 +1181,6 @@ static int32_t translateShow(STranslateContext* pCxt, SShowStmt* pStmt) {
|
||||||
|
|
||||||
static int32_t translateShowTables(STranslateContext* pCxt) {
|
static int32_t translateShowTables(STranslateContext* pCxt) {
|
||||||
SVShowTablesReq* pShowReq = calloc(1, sizeof(SVShowTablesReq));
|
SVShowTablesReq* pShowReq = calloc(1, sizeof(SVShowTablesReq));
|
||||||
if (pCxt->pParseCxt->db == NULL || strlen(pCxt->pParseCxt->db) == 0) {
|
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_TSC_INVALID_OPERATION, "db not specified");
|
|
||||||
}
|
|
||||||
|
|
||||||
SArray* array = NULL;
|
SArray* array = NULL;
|
||||||
int32_t code = getDBVgInfo(pCxt->pParseCxt, pCxt->pParseCxt->db, &array);
|
int32_t code = getDBVgInfo(pCxt->pParseCxt, pCxt->pParseCxt->db, &array);
|
||||||
|
@ -1407,6 +1426,10 @@ static int32_t createShowCondition(const SShowStmt* pShow, SSelectStmt* pSelect)
|
||||||
pSelect->pWhere = (NULL == pDbCond ? pTbCond : pDbCond);
|
pSelect->pWhere = (NULL == pDbCond ? pTbCond : pDbCond);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (NULL != pShow->pDbName) {
|
||||||
|
strcpy(((SRealTableNode*)pSelect->pFromTable)->useDbName, ((SValueNode*)pShow->pDbName)->literal);
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,58 +28,58 @@ namespace {
|
||||||
|
|
||||||
void generateInformationSchema(MockCatalogService* mcs) {
|
void generateInformationSchema(MockCatalogService* mcs) {
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "dnodes", TSDB_NORMAL_TABLE, 1).addColumn("id", TSDB_DATA_TYPE_INT);
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "dnodes", TSDB_SYSTEM_TABLE, 1).addColumn("id", TSDB_DATA_TYPE_INT);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "mnodes", TSDB_NORMAL_TABLE, 1).addColumn("id", TSDB_DATA_TYPE_INT);
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "mnodes", TSDB_SYSTEM_TABLE, 1).addColumn("id", TSDB_DATA_TYPE_INT);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "modules", TSDB_NORMAL_TABLE, 1).addColumn("id", TSDB_DATA_TYPE_INT);
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "modules", TSDB_SYSTEM_TABLE, 1).addColumn("id", TSDB_DATA_TYPE_INT);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "qnodes", TSDB_NORMAL_TABLE, 1).addColumn("id", TSDB_DATA_TYPE_INT);
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "qnodes", TSDB_SYSTEM_TABLE, 1).addColumn("id", TSDB_DATA_TYPE_INT);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_databases", TSDB_NORMAL_TABLE, 1).addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_databases", TSDB_SYSTEM_TABLE, 1).addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_functions", TSDB_NORMAL_TABLE, 1).addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_FUNC_NAME_LEN);
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_functions", TSDB_SYSTEM_TABLE, 1).addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_FUNC_NAME_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_indexes", TSDB_NORMAL_TABLE, 2)
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_indexes", TSDB_SYSTEM_TABLE, 2)
|
||||||
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN).addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN).addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_stables", TSDB_NORMAL_TABLE, 2)
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_stables", TSDB_SYSTEM_TABLE, 2)
|
||||||
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN).addColumn("stable_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN).addColumn("stable_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_streams", TSDB_NORMAL_TABLE, 1).addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_streams", TSDB_SYSTEM_TABLE, 1).addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_tables", TSDB_NORMAL_TABLE, 2)
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_tables", TSDB_SYSTEM_TABLE, 2)
|
||||||
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN).addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN).addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_table_distributed", TSDB_NORMAL_TABLE, 1).addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_table_distributed", TSDB_SYSTEM_TABLE, 1).addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_users", TSDB_NORMAL_TABLE, 1).addColumn("user_name", TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN);
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_users", TSDB_SYSTEM_TABLE, 1).addColumn("user_name", TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "vgroups", TSDB_NORMAL_TABLE, 1).addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "vgroups", TSDB_SYSTEM_TABLE, 1).addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,6 +124,10 @@ int32_t __catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* ve
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t __catalogGetDBVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* dbFName, SArray** vgroupList) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void initMetaDataEnv() {
|
void initMetaDataEnv() {
|
||||||
mockCatalogService.reset(new MockCatalogService());
|
mockCatalogService.reset(new MockCatalogService());
|
||||||
|
|
||||||
|
@ -133,6 +137,7 @@ void initMetaDataEnv() {
|
||||||
stub.set(catalogGetTableHashVgroup, __catalogGetTableHashVgroup);
|
stub.set(catalogGetTableHashVgroup, __catalogGetTableHashVgroup);
|
||||||
stub.set(catalogGetTableDistVgInfo, __catalogGetTableDistVgInfo);
|
stub.set(catalogGetTableDistVgInfo, __catalogGetTableDistVgInfo);
|
||||||
stub.set(catalogGetDBVgVersion, __catalogGetDBVgVersion);
|
stub.set(catalogGetDBVgVersion, __catalogGetDBVgVersion);
|
||||||
|
stub.set(catalogGetDBVgInfo, __catalogGetDBVgInfo);
|
||||||
// {
|
// {
|
||||||
// AddrAny any("libcatalog.so");
|
// AddrAny any("libcatalog.so");
|
||||||
// std::map<std::string,void*> result;
|
// std::map<std::string,void*> result;
|
||||||
|
|
|
@ -266,14 +266,19 @@ static SPhysiNode* createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* p
|
||||||
return (SPhysiNode*)pTableScan;
|
return (SPhysiNode*)pTableScan;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SPhysiNode* createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SScanLogicNode* pScanLogicNode) {
|
static SPhysiNode* createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode) {
|
||||||
SSystemTableScanPhysiNode* pScan = (SSystemTableScanPhysiNode*)makePhysiNode(pCxt, QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN);
|
SSystemTableScanPhysiNode* pScan = (SSystemTableScanPhysiNode*)makePhysiNode(pCxt, QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN);
|
||||||
CHECK_ALLOC(pScan, NULL);
|
CHECK_ALLOC(pScan, NULL);
|
||||||
CHECK_CODE(initScanPhysiNode(pCxt, pScanLogicNode, (SScanPhysiNode*)pScan), (SPhysiNode*)pScan);
|
CHECK_CODE(initScanPhysiNode(pCxt, pScanLogicNode, (SScanPhysiNode*)pScan), (SPhysiNode*)pScan);
|
||||||
for (int32_t i = 0; i < pScanLogicNode->pVgroupList->numOfVgroups; ++i) {
|
if (0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_USER_TABLES)) {
|
||||||
SQueryNodeAddr addr;
|
vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode);
|
||||||
vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups + i, &addr);
|
taosArrayPush(pCxt->pExecNodeList, &pSubplan->execNode);
|
||||||
taosArrayPush(pCxt->pExecNodeList, &addr);
|
} else {
|
||||||
|
for (int32_t i = 0; i < pScanLogicNode->pVgroupList->numOfVgroups; ++i) {
|
||||||
|
SQueryNodeAddr addr;
|
||||||
|
vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups + i, &addr);
|
||||||
|
taosArrayPush(pCxt->pExecNodeList, &addr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pScan->mgmtEpSet = pCxt->pPlanCxt->mgmtEpSet;
|
pScan->mgmtEpSet = pCxt->pPlanCxt->mgmtEpSet;
|
||||||
return (SPhysiNode*)pScan;
|
return (SPhysiNode*)pScan;
|
||||||
|
@ -286,7 +291,7 @@ static SPhysiNode* createScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubpl
|
||||||
case SCAN_TYPE_TABLE:
|
case SCAN_TYPE_TABLE:
|
||||||
return createTableScanPhysiNode(pCxt, pSubplan, pScanLogicNode);
|
return createTableScanPhysiNode(pCxt, pSubplan, pScanLogicNode);
|
||||||
case SCAN_TYPE_SYSTEM_TABLE:
|
case SCAN_TYPE_SYSTEM_TABLE:
|
||||||
return createSystemTableScanPhysiNode(pCxt, pScanLogicNode);
|
return createSystemTableScanPhysiNode(pCxt, pSubplan, pScanLogicNode);
|
||||||
case SCAN_TYPE_STREAM:
|
case SCAN_TYPE_STREAM:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -44,7 +44,8 @@ typedef struct SStsInfo {
|
||||||
} SStsInfo;
|
} SStsInfo;
|
||||||
|
|
||||||
static SLogicNode* stsMatchByNode(SLogicNode* pNode) {
|
static SLogicNode* stsMatchByNode(SLogicNode* pNode) {
|
||||||
if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode) && TSDB_SUPER_TABLE == ((SScanLogicNode*)pNode)->pMeta->tableType) {
|
if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode) &&
|
||||||
|
NULL != ((SScanLogicNode*)pNode)->pVgroupList && ((SScanLogicNode*)pNode)->pVgroupList->numOfVgroups > 1) {
|
||||||
return pNode;
|
return pNode;
|
||||||
}
|
}
|
||||||
SNode* pChild;
|
SNode* pChild;
|
||||||
|
|
|
@ -166,3 +166,10 @@ TEST_F(PlannerTest, subquery) {
|
||||||
bind("SELECT count(*) FROM (SELECT c1 + c3 a, c1 + count(*) b FROM t1 where c2 = 'abc' GROUP BY c1, c3) where a > 100 group by b");
|
bind("SELECT count(*) FROM (SELECT c1 + c3 a, c1 + count(*) b FROM t1 where c2 = 'abc' GROUP BY c1, c3) where a > 100 group by b");
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(PlannerTest, showTables) {
|
||||||
|
setDatabase("root", "test");
|
||||||
|
|
||||||
|
bind("show tables");
|
||||||
|
ASSERT_TRUE(run());
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue