Merge pull request #16154 from taosdata/fix/TD-18437
fix: return error if stable's name duplicate with child table
This commit is contained in:
commit
06b7f5397a
|
@ -181,10 +181,28 @@ int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSche
|
||||||
|
|
||||||
int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
SMetaEntry me = {0};
|
SMetaEntry me = {0};
|
||||||
|
int kLen = 0;
|
||||||
|
int vLen = 0;
|
||||||
|
const void *pKey = NULL;
|
||||||
|
const void *pVal = NULL;
|
||||||
|
void *pBuf = NULL;
|
||||||
|
int32_t szBuf = 0;
|
||||||
|
void *p = NULL;
|
||||||
|
|
||||||
// validate req
|
// validate req
|
||||||
if (tdbTbGet(pMeta->pNameIdx, pReq->name, strlen(pReq->name), NULL, NULL) == 0) {
|
void *pData = NULL;
|
||||||
|
int nData = 0;
|
||||||
|
if (tdbTbGet(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, &pData, &nData) == 0) {
|
||||||
|
tb_uid_t uid = *(tb_uid_t *)pData;
|
||||||
|
tdbFree(pData);
|
||||||
|
SMetaInfo info;
|
||||||
|
metaGetInfo(pMeta, uid, &info);
|
||||||
|
if (info.uid == info.suid) {
|
||||||
return 0;
|
return 0;
|
||||||
|
} else {
|
||||||
|
terrno = TSDB_CODE_TDB_TABLE_ALREADY_EXIST;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set structs
|
// set structs
|
||||||
|
|
|
@ -3,6 +3,21 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
|
print =============== conflict stb
|
||||||
|
sql create database db vgroups 1;
|
||||||
|
sql use db;
|
||||||
|
sql create table stb (ts timestamp, i int) tags (j int);
|
||||||
|
sql_error create table stb using stb tags (1);
|
||||||
|
sql_error create table stb (ts timestamp, i int);
|
||||||
|
|
||||||
|
sql create table ctb (ts timestamp, i int);
|
||||||
|
sql_error create table ctb (ts timestamp, i int) tags (j int);
|
||||||
|
|
||||||
|
sql create table ntb (ts timestamp, i int);
|
||||||
|
sql_error create table ntb (ts timestamp, i int) tags (j int);
|
||||||
|
|
||||||
|
sql drop database db
|
||||||
|
|
||||||
print =============== create database d1
|
print =============== create database d1
|
||||||
sql create database d1
|
sql create database d1
|
||||||
sql use d1
|
sql use d1
|
||||||
|
|
Loading…
Reference in New Issue