[validate table name when insert]
This commit is contained in:
parent
95dc6b4119
commit
c304b17977
|
@ -724,6 +724,19 @@ static int32_t tscParseSqlForCreateTableOnDemand(char** sqlstr, SSqlObj* pSql) {
|
|||
return code;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int validateTableName(char* tblName, int len)
|
||||
{
|
||||
char buf[TSDB_METER_ID_LEN] = {0};
|
||||
memcpy(buf, tblName, len);
|
||||
|
||||
SSQLToken token = {len, TK_ID, buf};
|
||||
tSQLGetToken(buf, &token.type);
|
||||
|
||||
return tscValidateName(&token);
|
||||
}
|
||||
|
||||
/**
|
||||
* usage: insert into table1 values() () table2 values()()
|
||||
*
|
||||
|
@ -774,6 +787,16 @@ int tsParseInsertStatement(SSqlCmd* pCmd, char* str, char* acct, char* db, SSqlO
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check the validity of the table name
|
||||
*
|
||||
*/
|
||||
if (validateTableName(id, idlen) != TSDB_CODE_SUCCESS) {
|
||||
code = TSDB_CODE_INVALID_SQL;
|
||||
sprintf(pCmd->payload, "table name is invalid");
|
||||
goto _error_clean;
|
||||
}
|
||||
|
||||
SSQLToken token = {idlen, TK_ID, id};
|
||||
if ((code = setMeterID(pSql, &token)) != TSDB_CODE_SUCCESS) {
|
||||
goto _error_clean;
|
||||
|
|
Loading…
Reference in New Issue