Merge pull request #1423 from taosdata/liaohj_2
[TD-32] fix error in retrieve data from table created according to st…
This commit is contained in:
commit
df32eea8e7
|
@ -32,7 +32,7 @@ extern "C" {
|
||||||
#define UTIL_TABLE_IS_SUPERTABLE(metaInfo) \
|
#define UTIL_TABLE_IS_SUPERTABLE(metaInfo) \
|
||||||
(((metaInfo)->pTableMeta != NULL) && ((metaInfo)->pTableMeta->tableType == TSDB_SUPER_TABLE))
|
(((metaInfo)->pTableMeta != NULL) && ((metaInfo)->pTableMeta->tableType == TSDB_SUPER_TABLE))
|
||||||
#define UTIL_TABLE_IS_NOMRAL_TABLE(metaInfo) (!(UTIL_TABLE_IS_SUPERTABLE(metaInfo)))
|
#define UTIL_TABLE_IS_NOMRAL_TABLE(metaInfo) (!(UTIL_TABLE_IS_SUPERTABLE(metaInfo)))
|
||||||
#define UTIL_TABLE_CREATE_FROM_STABLE(metaInfo) \
|
#define UTIL_TABLE_IS_CHILD_TABLE(metaInfo) \
|
||||||
(((metaInfo)->pTableMeta != NULL) && ((metaInfo)->pTableMeta->tableType == TSDB_CHILD_TABLE))
|
(((metaInfo)->pTableMeta != NULL) && ((metaInfo)->pTableMeta->tableType == TSDB_CHILD_TABLE))
|
||||||
|
|
||||||
#define TSDB_COL_IS_TAG(f) (((f)&TSDB_COL_TAG) != 0)
|
#define TSDB_COL_IS_TAG(f) (((f)&TSDB_COL_TAG) != 0)
|
||||||
|
|
|
@ -406,11 +406,6 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
SSqlRes *pRes = &pSql->res;
|
SSqlRes *pRes = &pSql->res;
|
||||||
|
|
||||||
if (pSql->fp == NULL) {
|
|
||||||
tscError("%p callBack is NULL!!!", pSql);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pSql->fp == (void *)1) {
|
if (pSql->fp == (void *)1) {
|
||||||
pSql->fp = NULL;
|
pSql->fp = NULL;
|
||||||
|
|
||||||
|
|
|
@ -4240,7 +4240,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
} else if ((pAlterSQL->type == TSDB_ALTER_TABLE_UPDATE_TAG_VAL) && (UTIL_TABLE_IS_SUPERTABLE(pTableMetaInfo))) {
|
} else if ((pAlterSQL->type == TSDB_ALTER_TABLE_UPDATE_TAG_VAL) && (UTIL_TABLE_IS_SUPERTABLE(pTableMetaInfo))) {
|
||||||
return invalidSqlErrMsg(pQueryInfo->msg, msg4);
|
return invalidSqlErrMsg(pQueryInfo->msg, msg4);
|
||||||
} else if ((pAlterSQL->type == TSDB_ALTER_TABLE_ADD_COLUMN || pAlterSQL->type == TSDB_ALTER_TABLE_DROP_COLUMN) &&
|
} else if ((pAlterSQL->type == TSDB_ALTER_TABLE_ADD_COLUMN || pAlterSQL->type == TSDB_ALTER_TABLE_DROP_COLUMN) &&
|
||||||
UTIL_TABLE_CREATE_FROM_STABLE(pTableMetaInfo)) {
|
UTIL_TABLE_IS_CHILD_TABLE(pTableMetaInfo)) {
|
||||||
return invalidSqlErrMsg(pQueryInfo->msg, msg6);
|
return invalidSqlErrMsg(pQueryInfo->msg, msg6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,12 +51,12 @@ int32_t tscGetNumOfColumns(const STableMeta* pTableMeta) {
|
||||||
SSchema *tscGetTableSchema(const STableMeta *pTableMeta) {
|
SSchema *tscGetTableSchema(const STableMeta *pTableMeta) {
|
||||||
assert(pTableMeta != NULL);
|
assert(pTableMeta != NULL);
|
||||||
|
|
||||||
if (pTableMeta->tableType == TSDB_CHILD_TABLE) {
|
// if (pTableMeta->tableType == TSDB_CHILD_TABLE) {
|
||||||
STableMeta* pSTableMeta = pTableMeta->pSTable;
|
// STableMeta* pSTableMeta = pTableMeta->pSTable;
|
||||||
assert (pSTableMeta != NULL);
|
// assert (pSTableMeta != NULL);
|
||||||
|
//
|
||||||
return pSTableMeta->schema;
|
// return pSTableMeta->schema;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return (SSchema*) pTableMeta->schema;
|
return (SSchema*) pTableMeta->schema;
|
||||||
}
|
}
|
||||||
|
@ -72,12 +72,14 @@ SSchema* tscGetTableTagSchema(const STableMeta* pTableMeta) {
|
||||||
|
|
||||||
STableComInfo tscGetTableInfo(const STableMeta* pTableMeta) {
|
STableComInfo tscGetTableInfo(const STableMeta* pTableMeta) {
|
||||||
assert(pTableMeta != NULL);
|
assert(pTableMeta != NULL);
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (pTableMeta->tableType == TSDB_CHILD_TABLE) {
|
if (pTableMeta->tableType == TSDB_CHILD_TABLE) {
|
||||||
assert (pTableMeta->pSTable != NULL);
|
assert (pTableMeta->pSTable != NULL);
|
||||||
return pTableMeta->pSTable->tableInfo;
|
return pTableMeta->pSTable->tableInfo;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return pTableMeta->tableInfo;
|
return pTableMeta->tableInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,12 +132,13 @@ SSchema* tscGetTableColumnSchema(const STableMeta* pTableMeta, int32_t startCol)
|
||||||
assert(pTableMeta != NULL);
|
assert(pTableMeta != NULL);
|
||||||
|
|
||||||
SSchema* pSchema = pTableMeta->schema;
|
SSchema* pSchema = pTableMeta->schema;
|
||||||
|
#if 0
|
||||||
if (pTableMeta->tableType == TSDB_CHILD_TABLE) {
|
if (pTableMeta->tableType == TSDB_CHILD_TABLE) {
|
||||||
assert (pTableMeta->pSTable != NULL);
|
assert (pTableMeta->pSTable != NULL);
|
||||||
pSchema = pTableMeta->pSTable->schema;
|
pSchema = pTableMeta->pSTable->schema;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return &pSchema[startCol];
|
return &pSchema[startCol];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -325,8 +325,9 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg) {
|
||||||
rpcMsg->code = (*tscProcessMsgRsp[pCmd->command])(pSql);
|
rpcMsg->code = (*tscProcessMsgRsp[pCmd->command])(pSql);
|
||||||
|
|
||||||
if (rpcMsg->code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
if (rpcMsg->code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
int command = pCmd->command;
|
void *taosres = tscKeepConn[pCmd->command] ? pSql : NULL;
|
||||||
void *taosres = tscKeepConn[command] ? pSql : NULL;
|
rpcMsg->code = pRes->code ? -pRes->code : pRes->numOfRows;
|
||||||
|
|
||||||
tscTrace("%p Async SQL result:%s res:%p", pSql, tstrerror(pRes->code), taosres);
|
tscTrace("%p Async SQL result:%s res:%p", pSql, tstrerror(pRes->code), taosres);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1817,14 +1818,13 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
|
||||||
pMetaMsg->vgId = htonl(pMetaMsg->vgId);
|
pMetaMsg->vgId = htonl(pMetaMsg->vgId);
|
||||||
pMetaMsg->uid = htobe64(pMetaMsg->uid);
|
pMetaMsg->uid = htobe64(pMetaMsg->uid);
|
||||||
pMetaMsg->contLen = htons(pMetaMsg->contLen);
|
pMetaMsg->contLen = htons(pMetaMsg->contLen);
|
||||||
|
pMetaMsg->numOfColumns = htons(pMetaMsg->numOfColumns);
|
||||||
|
|
||||||
if (pMetaMsg->sid < 0 || pMetaMsg->vgId < 0) {
|
if (pMetaMsg->sid < 0 || pMetaMsg->vgId < 0) {
|
||||||
tscError("invalid meter vgId:%d, sid%d", pMetaMsg->vgId, pMetaMsg->sid);
|
tscError("invalid meter vgId:%d, sid%d", pMetaMsg->vgId, pMetaMsg->sid);
|
||||||
return TSDB_CODE_INVALID_VALUE;
|
return TSDB_CODE_INVALID_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
pMetaMsg->numOfColumns = htons(pMetaMsg->numOfColumns);
|
|
||||||
|
|
||||||
if (pMetaMsg->numOfTags > TSDB_MAX_TAGS || pMetaMsg->numOfTags < 0) {
|
if (pMetaMsg->numOfTags > TSDB_MAX_TAGS || pMetaMsg->numOfTags < 0) {
|
||||||
tscError("invalid numOfTags:%d", pMetaMsg->numOfTags);
|
tscError("invalid numOfTags:%d", pMetaMsg->numOfTags);
|
||||||
return TSDB_CODE_INVALID_VALUE;
|
return TSDB_CODE_INVALID_VALUE;
|
||||||
|
@ -1848,23 +1848,20 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
|
||||||
pSchema++;
|
pSchema++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// rsp += numOfTotalCols * sizeof(SSchema);
|
|
||||||
//
|
|
||||||
// int32_t tagLen = 0;
|
|
||||||
// SSchema *pTagsSchema = tscGetTableTagSchema(pMetaMsg);
|
|
||||||
//
|
|
||||||
// if (pMetaMsg->tableType == TSDB_CHILD_TABLE) {
|
|
||||||
// for (int32_t i = 0; i < pMetaMsg->numOfTags; ++i) {
|
|
||||||
// tagLen += pTagsSchema[i].bytes;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// rsp += tagLen;
|
|
||||||
// int32_t size = (int32_t)(rsp - (char *)pMetaMsg);
|
|
||||||
|
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
STableMeta* pTableMeta = tscCreateTableMetaFromMsg(pMetaMsg, &size);
|
STableMeta* pTableMeta = tscCreateTableMetaFromMsg(pMetaMsg, &size);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// if current table is created according to super table, get the table meta of super table
|
||||||
|
if (pTableMeta->tableType == TSDB_CHILD_TABLE) {
|
||||||
|
char id[TSDB_TABLE_ID_LEN + 1] = {0};
|
||||||
|
strncpy(id, pMetaMsg->stableId, TSDB_TABLE_ID_LEN);
|
||||||
|
|
||||||
|
// NOTE: if the table meta of super table is not cached at client side yet, the pSTable is NULL
|
||||||
|
pTableMeta->pSTable = taosCacheAcquireByName(tscCacheHandle, id);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// todo add one more function: taosAddDataIfNotExists();
|
// todo add one more function: taosAddDataIfNotExists();
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0);
|
||||||
assert(pTableMetaInfo->pTableMeta == NULL);
|
assert(pTableMetaInfo->pTableMeta == NULL);
|
||||||
|
@ -1878,6 +1875,7 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
|
||||||
}
|
}
|
||||||
|
|
||||||
free(pTableMeta);
|
free(pTableMeta);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2343,7 +2341,7 @@ int tscProcessRetrieveRspFromLocal(SSqlObj *pSql) {
|
||||||
|
|
||||||
void tscTableMetaCallBack(void *param, TAOS_RES *res, int code);
|
void tscTableMetaCallBack(void *param, TAOS_RES *res, int code);
|
||||||
|
|
||||||
static int32_t doGetMeterMetaFromServer(SSqlObj *pSql, STableMetaInfo *pTableMetaInfo) {
|
static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInfo) {
|
||||||
SSqlObj *pNew = calloc(1, sizeof(SSqlObj));
|
SSqlObj *pNew = calloc(1, sizeof(SSqlObj));
|
||||||
if (NULL == pNew) {
|
if (NULL == pNew) {
|
||||||
tscError("%p malloc failed for new sqlobj to get meter meta", pSql);
|
tscError("%p malloc failed for new sqlobj to get meter meta", pSql);
|
||||||
|
@ -2370,7 +2368,7 @@ static int32_t doGetMeterMetaFromServer(SSqlObj *pSql, STableMetaInfo *pTableMet
|
||||||
STableMetaInfo *pNewMeterMetaInfo = tscAddEmptyMetaInfo(pNewQueryInfo);
|
STableMetaInfo *pNewMeterMetaInfo = tscAddEmptyMetaInfo(pNewQueryInfo);
|
||||||
assert(pNew->cmd.numOfClause == 1 && pNewQueryInfo->numOfTables == 1);
|
assert(pNew->cmd.numOfClause == 1 && pNewQueryInfo->numOfTables == 1);
|
||||||
|
|
||||||
strcpy(pNewMeterMetaInfo->name, pTableMetaInfo->name);
|
strncpy(pNewMeterMetaInfo->name, pTableMetaInfo->name, tListLen(pNewMeterMetaInfo->name));
|
||||||
memcpy(pNew->cmd.payload, pSql->cmd.payload, TSDB_DEFAULT_PAYLOAD_SIZE); // tag information if table does not exists.
|
memcpy(pNew->cmd.payload, pSql->cmd.payload, TSDB_DEFAULT_PAYLOAD_SIZE); // tag information if table does not exists.
|
||||||
tscTrace("%p new pSqlObj:%p to get tableMeta", pSql, pNew);
|
tscTrace("%p new pSqlObj:%p to get tableMeta", pSql, pNew);
|
||||||
|
|
||||||
|
@ -2388,7 +2386,7 @@ static int32_t doGetMeterMetaFromServer(SSqlObj *pSql, STableMetaInfo *pTableMet
|
||||||
int32_t tscGetTableMeta(SSqlObj *pSql, STableMetaInfo *pTableMetaInfo) {
|
int32_t tscGetTableMeta(SSqlObj *pSql, STableMetaInfo *pTableMetaInfo) {
|
||||||
assert(strlen(pTableMetaInfo->name) != 0);
|
assert(strlen(pTableMetaInfo->name) != 0);
|
||||||
|
|
||||||
// If this STableMetaInfo owns a metermeta, release it first
|
// If this STableMetaInfo owns a table meta, release it first
|
||||||
if (pTableMetaInfo->pTableMeta != NULL) {
|
if (pTableMetaInfo->pTableMeta != NULL) {
|
||||||
taosCacheRelease(tscCacheHandle, (void **)&(pTableMetaInfo->pTableMeta), false);
|
taosCacheRelease(tscCacheHandle, (void **)&(pTableMetaInfo->pTableMeta), false);
|
||||||
}
|
}
|
||||||
|
@ -2401,12 +2399,8 @@ int32_t tscGetTableMeta(SSqlObj *pSql, STableMetaInfo *pTableMetaInfo) {
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
return getTableMetaFromMgmt(pSql, pTableMetaInfo);
|
||||||
* for async insert operation, release data block buffer before issue new object to get metermeta
|
|
||||||
* because in table meta callback function, the tscParse function will generate the submit data blocks
|
|
||||||
*/
|
|
||||||
return doGetMeterMetaFromServer(pSql, pTableMetaInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int tscGetMeterMetaEx(SSqlObj *pSql, STableMetaInfo *pTableMetaInfo, bool createIfNotExists) {
|
int tscGetMeterMetaEx(SSqlObj *pSql, STableMetaInfo *pTableMetaInfo, bool createIfNotExists) {
|
||||||
|
@ -2455,7 +2449,7 @@ int tscRenewMeterMeta(SSqlObj *pSql, char *tableId) {
|
||||||
tscWaitingForCreateTable(pCmd);
|
tscWaitingForCreateTable(pCmd);
|
||||||
taosCacheRelease(tscCacheHandle, (void **)&(pTableMetaInfo->pTableMeta), true);
|
taosCacheRelease(tscCacheHandle, (void **)&(pTableMetaInfo->pTableMeta), true);
|
||||||
|
|
||||||
code = doGetMeterMetaFromServer(pSql, pTableMetaInfo); // todo ??
|
code = getTableMetaFromMgmt(pSql, pTableMetaInfo); // todo ??
|
||||||
} else {
|
} else {
|
||||||
tscTrace("%p metric query not update metric meta, numOfTags:%d, numOfCols:%d, uid:%" PRId64 ", addr:%p", pSql,
|
tscTrace("%p metric query not update metric meta, numOfTags:%d, numOfCols:%d, uid:%" PRId64 ", addr:%p", pSql,
|
||||||
tscGetNumOfTags(pTableMetaInfo->pTableMeta), pCmd->numOfCols, pTableMetaInfo->pTableMeta->uid,
|
tscGetNumOfTags(pTableMetaInfo->pTableMeta), pCmd->numOfCols, pTableMetaInfo->pTableMeta->uid,
|
||||||
|
|
|
@ -651,8 +651,7 @@ static void **tscBuildResFromSubqueries(SSqlObj *pSql) {
|
||||||
|
|
||||||
static void asyncFetchCallback(void *param, TAOS_RES *tres, int numOfRows) {
|
static void asyncFetchCallback(void *param, TAOS_RES *tres, int numOfRows) {
|
||||||
SSqlObj* pSql = (SSqlObj*) tres;
|
SSqlObj* pSql = (SSqlObj*) tres;
|
||||||
if (numOfRows < 0) {
|
if (numOfRows < 0) { // set the error code
|
||||||
// set the error code
|
|
||||||
pSql->res.code = -numOfRows;
|
pSql->res.code = -numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -206,14 +206,6 @@ typedef struct SMsgHead {
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
} SMsgHead;
|
} SMsgHead;
|
||||||
|
|
||||||
// typedef struct {
|
|
||||||
// SMsgDesc desc;
|
|
||||||
// SMsgHead header;
|
|
||||||
// int16_t import;
|
|
||||||
// int32_t numOfTables; // total number of sid
|
|
||||||
// char blks[]; // number of data blocks, each table has at least one data block
|
|
||||||
//} SShellSubmitMsg;
|
|
||||||
|
|
||||||
// Submit message for one table
|
// Submit message for one table
|
||||||
typedef struct SSubmitBlk {
|
typedef struct SSubmitBlk {
|
||||||
int64_t uid; // table unique id
|
int64_t uid; // table unique id
|
||||||
|
@ -683,14 +675,15 @@ typedef struct {
|
||||||
} SSuperTableMeta;
|
} SSuperTableMeta;
|
||||||
|
|
||||||
typedef struct STableMetaMsg {
|
typedef struct STableMetaMsg {
|
||||||
char tableId[TSDB_TABLE_ID_LEN]; // note: This field must be at the front
|
int32_t contLen;
|
||||||
int32_t contLen;
|
|
||||||
uint8_t numOfTags;
|
char tableId[TSDB_TABLE_ID_LEN]; // table id
|
||||||
uint8_t precision;
|
char stableId[TSDB_TABLE_ID_LEN]; // stable name if it is created according to super table
|
||||||
uint8_t tableType;
|
uint8_t numOfTags;
|
||||||
int16_t numOfColumns;
|
uint8_t precision;
|
||||||
int16_t sversion;
|
uint8_t tableType;
|
||||||
|
int16_t numOfColumns;
|
||||||
|
int16_t sversion;
|
||||||
int8_t numOfVpeers;
|
int8_t numOfVpeers;
|
||||||
SVnodeDesc vpeerDesc[TSDB_VNODES_SUPPORT];
|
SVnodeDesc vpeerDesc[TSDB_VNODES_SUPPORT];
|
||||||
int32_t sid;
|
int32_t sid;
|
||||||
|
|
|
@ -728,6 +728,7 @@ static int32_t mgmtDoGetChildTableMeta(SDbObj *pDb, SChildTableObj *pTable, STab
|
||||||
pMeta->numOfTags = 0;
|
pMeta->numOfTags = 0;
|
||||||
pMeta->numOfColumns = htons((int16_t)pTable->superTable->numOfColumns);
|
pMeta->numOfColumns = htons((int16_t)pTable->superTable->numOfColumns);
|
||||||
pMeta->contLen = sizeof(STableMetaMsg) + mgmtSetSchemaFromSuperTable(pMeta->schema, pTable->superTable);
|
pMeta->contLen = sizeof(STableMetaMsg) + mgmtSetSchemaFromSuperTable(pMeta->schema, pTable->superTable);
|
||||||
|
strncpy(pMeta->stableId, pTable->superTable->info.tableId, tListLen(pMeta->stableId));
|
||||||
} else {
|
} else {
|
||||||
pMeta->sversion = htons(pTable->sversion);
|
pMeta->sversion = htons(pTable->sversion);
|
||||||
pMeta->numOfTags = 0;
|
pMeta->numOfTags = 0;
|
||||||
|
|
Loading…
Reference in New Issue