enh: remove column list

This commit is contained in:
dapan1121 2023-09-22 11:36:53 +08:00
parent a67b0c99fc
commit a61d90f672
15 changed files with 731 additions and 768 deletions

View File

@ -360,6 +360,7 @@
#define TK_NK_SPACE 600
#define TK_NK_COMMENT 601
#define TK_NK_ILLEGAL 602

View File

@ -498,7 +498,6 @@ typedef struct SCreateViewStmt {
char viewName[TSDB_VIEW_NAME_LEN];
char* pQuerySql;
bool orReplace;
SNodeList* pCols;
SNode* pQuery;
SCMCreateViewReq createReq;
} SCreateViewStmt;

View File

@ -33,7 +33,7 @@ typedef struct SStmtCallback {
int32_t (*getExecInfoFn)(TAOS_STMT*, SHashObj**, SHashObj**);
} SStmtCallback;
typedef int32_t (*validateSqlFn)(void* param, SQuery* pQuery, const char* sql, SCMCreateViewReq* pRes);
typedef int32_t (*validateSqlFn)(void* param, const char* sql, SCMCreateViewReq* pRes);
typedef struct SParseCsvCxt {
TdFilePtr fp; // last parsed file

View File

@ -726,6 +726,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_INVALID_VARBINARY TAOS_DEF_ERROR_CODE(0, 0x266A)
#define TSDB_CODE_PAR_INVALID_IP_RANGE TAOS_DEF_ERROR_CODE(0, 0x266B)
#define TSDB_CODE_PAR_INVALID_VIEW_QUERY TAOS_DEF_ERROR_CODE(0, 0x266C)
#define TSDB_CODE_PAR_COL_QUERY_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x266D)
#define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF)
//planner

View File

@ -1,5 +1,9 @@
aux_source_directory(src CLIENT_SRC)
IF (TD_ENTERPRISE)
LIST(APPEND CLIENT_SRC ${TD_ENTERPRISE_DIR}/src/plugins/view/src/clientView.c)
ENDIF ()
if(TD_WINDOWS)
add_library(taos SHARED ${CLIENT_SRC} ${CMAKE_CURRENT_SOURCE_DIR}/src/taos.rc.in)
else()

View File

@ -300,7 +300,8 @@ void taosAsyncQueryImpl(uint64_t connId, const char* sql, __taos_async_fn_t fp,
void taosAsyncQueryImplWithReqid(uint64_t connId, const char* sql, __taos_async_fn_t fp, void* param, bool validateOnly,
int64_t reqid);
void taosAsyncFetchImpl(SRequestObj *pRequest, __taos_async_fn_t fp, void *param);
int32_t clientValidateSql(void* param, SQuery* pQuery, const char* sql, SCMCreateViewReq* pReq);
int32_t clientValidateSql(void* param, const char* sql, SCMCreateViewReq* pReq);
void syncQueryFn(void* param, void* res, int32_t code);
int32_t getVersion1BlockMetaSize(const char* p, int32_t numOfCols);
@ -411,6 +412,11 @@ int32_t buildPreviousRequest(SRequestObj *pRequest, const char* sql, SRequestObj
int32_t prepareAndParseSqlSyntax(SSqlCallbackWrapper **ppWrapper, SRequestObj *pRequest, bool updateMetaForce);
void returnToUser(SRequestObj* pRequest);
void stopAllQueries(SRequestObj *pRequest);
void freeQueryParam(SSyncQueryParam* param);
#ifdef TD_ENTERPRISE
int32_t clientValidateSqlImpl(void* param, const char* sql, SCMCreateViewReq* pReq);
#endif
#ifdef __cplusplus
}

View File

@ -2592,58 +2592,12 @@ void taosAsyncFetchImpl(SRequestObj* pRequest, __taos_async_fn_t fp, void* param
schedulerFetchRows(pRequest->body.queryJob, &req);
}
int32_t asyncValidateSql(void* param) {
doAsyncQuery((SRequestObj*)param, false);
int32_t clientValidateSql(void* param, const char* sql, SCMCreateViewReq* pReq) {
#ifndef TD_ENTERPRISE
return TSDB_CODE_SUCCESS;
#else
return clientValidateSqlImpl(param, sql, pReq);
#endif
}
int32_t clientValidateSql(void* param, SQuery* pQuery, const char* sql, SCMCreateViewReq* pReq) {
SSqlCallbackWrapper *pWrapper = (SSqlCallbackWrapper *)param;
SSyncQueryParam* syncParam = taosMemoryCalloc(1, sizeof(SSyncQueryParam));
tsem_init(&syncParam->sem, 0, 0);
SRequestObj* pRequest = pWrapper->pRequest;
SRequestObj* pNewRequest = NULL;
int32_t code = buildRequest(pRequest->pTscObj->id, sql, strlen(sql), syncParam, true, &pNewRequest, 0);
if (code != TSDB_CODE_SUCCESS) {
terrno = code;
return code;
}
//pNewRequest->pQuery = pQuery;
pNewRequest->body.queryFp = syncQueryFn;
code = taosAsyncExec(asyncValidateSql, pNewRequest, NULL);
if (TSDB_CODE_SUCCESS != code) {
tscError("failed to sched async validate sql");
return code;
}
tsem_wait(&syncParam->sem);
code = pNewRequest->code;
pRequest->code = code;
if (TSDB_CODE_SUCCESS == code) {
pReq->numOfCols = pQuery->numOfResCols;
pReq->precision = pQuery->precision;
pReq->pSchema = taosMemoryMalloc(pQuery->numOfResCols * sizeof(SSchema));
if (NULL == pReq->pSchema) {
code = terrno = TSDB_CODE_OUT_OF_MEMORY;
} else {
memcpy(pReq->pSchema, pQuery->pResSchema, pQuery->numOfResCols * sizeof(SSchema));
}
} else if (0 != pNewRequest->msgBuf[0]) {
strncpy(pRequest->msgBuf, pNewRequest->msgBuf, pRequest->msgBufLen - 1);
pRequest->msgBuf[pRequest->msgBufLen - 1] = 0;
}
freeQueryParam(syncParam);
destroyRequest(pNewRequest);
return code;
}

View File

@ -8489,9 +8489,9 @@ void tFreeSCMCreateViewReq(SCMCreateViewReq* pReq) {
return;
}
taosMemoryFree(pReq->querySql);
taosMemoryFree(pReq->sql);
taosMemoryFree(pReq->pSchema);
taosMemoryFreeClear(pReq->querySql);
taosMemoryFreeClear(pReq->sql);
taosMemoryFreeClear(pReq->pSchema);
}
int32_t tSerializeSCMDropViewReq(void* buf, int32_t bufLen, const SCMDropViewReq* pReq) {

View File

@ -1130,6 +1130,8 @@ void nodesDestroyNode(SNode* pNode) {
break;
case QUERY_NODE_CREATE_VIEW_STMT: {
SCreateViewStmt* pStmt = (SCreateViewStmt*)pNode;
taosMemoryFree(pStmt->pQuerySql);
tFreeSCMCreateViewReq(&pStmt->createReq);
nodesDestroyNode(pStmt->pQuery);
break;
}

View File

@ -248,7 +248,7 @@ SNode* createRevokeStmt(SAstCreateContext* pCxt, int64_t privileges, STokenPair*
SNode* pTagCond);
SNode* createDeleteStmt(SAstCreateContext* pCxt, SNode* pTable, SNode* pWhere);
SNode* createInsertStmt(SAstCreateContext* pCxt, SNode* pTable, SNodeList* pCols, SNode* pQuery);
SNode* createCreateViewStmt(SAstCreateContext* pCxt, bool orReplace, SNode* pView, SNodeList* pCols, const SToken* pAs, SNode* pQuery);
SNode* createCreateViewStmt(SAstCreateContext* pCxt, bool orReplace, SNode* pView, const SToken* pAs, SNode* pQuery);
SNode* createDropViewStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pView);
#ifdef __cplusplus

View File

@ -623,8 +623,8 @@ or_replace_opt(A) ::= .
or_replace_opt(A) ::= OR REPLACE. { A = true; }
/************************************************ create/drop view **************************************************/
cmd ::= CREATE or_replace_opt(A) VIEW full_view_name(B) col_list_opt(C) AS(D) query_or_subquery(E).
{ pCxt->pRootNode = createCreateViewStmt(pCxt, A, B, C, &D, E); }
cmd ::= CREATE or_replace_opt(A) VIEW full_view_name(B) AS(C) query_or_subquery(D).
{ pCxt->pRootNode = createCreateViewStmt(pCxt, A, B, &C, D); }
cmd ::= DROP VIEW exists_opt(A) full_view_name(B). { pCxt->pRootNode = createDropViewStmt(pCxt, A, B); }
full_view_name(A) ::= view_name(B). { A = createViewNode(pCxt, NULL, &B); }

View File

@ -2162,7 +2162,7 @@ SNode* createDropFunctionStmt(SAstCreateContext* pCxt, bool ignoreNotExists, con
return (SNode*)pStmt;
}
SNode* createCreateViewStmt(SAstCreateContext* pCxt, bool orReplace, SNode* pView, SNodeList* pCols, const SToken* pAs, SNode* pQuery) {
SNode* createCreateViewStmt(SAstCreateContext* pCxt, bool orReplace, SNode* pView, const SToken* pAs, SNode* pQuery) {
CHECK_PARSER_STATUS(pCxt);
SCreateViewStmt* pStmt = (SCreateViewStmt*)nodesMakeNode(QUERY_NODE_CREATE_VIEW_STMT);
CHECK_OUT_OF_MEM(pStmt);
@ -2173,7 +2173,6 @@ SNode* createCreateViewStmt(SAstCreateContext* pCxt, bool orReplace, SNode* pVie
nodesDestroyNode(pView);
pStmt->orReplace = orReplace;
pStmt->pQuery = pQuery;
pStmt->pCols = pCols;
return (SNode*)pStmt;
}

View File

@ -7273,11 +7273,7 @@ static int32_t validateCreateView(STranslateContext* pCxt, SCreateViewStmt* pStm
static int32_t translateCreateView(STranslateContext* pCxt, SCreateViewStmt* pStmt) {
int32_t code = validateCreateView(pCxt, pStmt);
if (TSDB_CODE_SUCCESS == code) {
SQuery* pQuery = NULL;
code = buildQueryAfterParse(&pQuery, pStmt->pQuery, 0, NULL);
if (TSDB_CODE_SUCCESS == code) {
code = (*pCxt->pParseCxt->validateSqlFp)(pCxt->pParseCxt->validateSqlParam, pQuery, pStmt->pQuerySql, &pStmt->createReq);
}
code = (*pCxt->pParseCxt->validateSqlFp)(pCxt->pParseCxt->validateSqlParam, pStmt->pQuerySql, &pStmt->createReq);
}
if (TSDB_CODE_SUCCESS == code) {
strncpy(pStmt->createReq.name, pStmt->viewName, sizeof(pStmt->createReq.name) - 1);

File diff suppressed because it is too large Load Diff

View File

@ -587,6 +587,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_IP_RANGE, "Invalid IPV4 addres
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INTERNAL_ERROR, "Parser internal error")
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Invalid stream query")
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_VIEW_QUERY, "Invalid view query type")
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_COL_QUERY_MISMATCH, "Columns number mismatch with query result")
//planner
TAOS_DEFINE_ERROR(TSDB_CODE_PLAN_INTERNAL_ERROR, "Planner internal error")