enh: error msg for csv file path that is too long
This commit is contained in:
parent
7c002fa0d5
commit
91d19e458d
|
@ -2254,10 +2254,16 @@ static int32_t parseDataFromFileImpl(SInsertParseContext* pCxt, SVnodeModifyOpSt
|
||||||
|
|
||||||
static int32_t parseDataFromFile(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, SToken* pFilePath,
|
static int32_t parseDataFromFile(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, SToken* pFilePath,
|
||||||
SRowsDataContext rowsDataCxt) {
|
SRowsDataContext rowsDataCxt) {
|
||||||
char filePathStr[PATH_MAX] = {0};
|
char filePathStr[PATH_MAX + 16] = {0};
|
||||||
if (TK_NK_STRING == pFilePath->type) {
|
if (TK_NK_STRING == pFilePath->type) {
|
||||||
(void)trimString(pFilePath->z, pFilePath->n, filePathStr, sizeof(filePathStr));
|
(void)trimString(pFilePath->z, pFilePath->n, filePathStr, sizeof(filePathStr));
|
||||||
|
if (strlen(filePathStr) >= PATH_MAX) {
|
||||||
|
return buildSyntaxErrMsg(&pCxt->msg, "file path is too long, max length is 4096", pFilePath->z);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (pFilePath->n >= PATH_MAX) {
|
||||||
|
return buildSyntaxErrMsg(&pCxt->msg, "file path is too long, max length is 4096", pFilePath->z);
|
||||||
|
}
|
||||||
strncpy(filePathStr, pFilePath->z, pFilePath->n);
|
strncpy(filePathStr, pFilePath->z, pFilePath->n);
|
||||||
}
|
}
|
||||||
pStmt->fp = taosOpenFile(filePathStr, TD_FILE_READ | TD_FILE_STREAM);
|
pStmt->fp = taosOpenFile(filePathStr, TD_FILE_READ | TD_FILE_STREAM);
|
||||||
|
|
Loading…
Reference in New Issue