diff --git a/docs-cn/12-taos-sql/05-insert.md b/docs-cn/12-taos-sql/05-insert.md index 04118303f3f6517d65d8ecbbe9fdeb774a3177b7..047ff8e9c48cb9c211f2e615eea452e8c8a6c39a 100644 --- a/docs-cn/12-taos-sql/05-insert.md +++ b/docs-cn/12-taos-sql/05-insert.md @@ -111,13 +111,6 @@ INSERT INTO d1001 FILE '/tmp/csvfile.csv'; INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) FILE '/tmp/csvfile.csv'; ``` -也可以在一条语句中向多个表以自动建表的方式插入记录。例如: - -``` -INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) FILE '/tmp/csvfile_21001.csv' - d21002 USING meters (groupId) TAGS (2) FILE '/tmp/csvfile_21002.csv'; -``` - ## 历史记录写入 可使用 IMPORT 或者 INSERT 命令,IMPORT 的语法,功能与 INSERT 完全一样。 diff --git a/docs-en/12-taos-sql/05-insert.md b/docs-en/12-taos-sql/05-insert.md index 1336cd7238a19190583ea9d268a64df242ffd3c9..36640db9cfb418a7dfb7d4d4468afd959ebe1d6c 100644 --- a/docs-en/12-taos-sql/05-insert.md +++ b/docs-en/12-taos-sql/05-insert.md @@ -113,13 +113,6 @@ From version 2.1.5.0, tables can be automatically created using a super table as INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) FILE '/tmp/csvfile.csv'; ``` -Multiple tables can be automatically created and inserted in a single SQL statement, like below: - -```sql -INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) FILE '/tmp/csvfile_21001.csv' - d21002 USING meters (groupId) TAGS (2) FILE '/tmp/csvfile_21002.csv'; -``` - ## More About Insert For SQL statement like `insert`, a stream parsing strategy is applied. That means before an error is found and the execution is aborted, the part prior to the error point has already been executed. Below is an experiment to help understand the behavior. diff --git a/documentation20/cn/12.taos-sql/docs.md b/documentation20/cn/12.taos-sql/docs.md index 2fd86b1c9e55230f5497534ee909d587afd52626..a5044c6b7af9d5f46aced67d44a182058f5e9124 100755 --- a/documentation20/cn/12.taos-sql/docs.md +++ b/documentation20/cn/12.taos-sql/docs.md @@ -456,11 +456,6 @@ INSERT INTO ```mysql INSERT INTO d21001 USING meters TAGS ('Beijing.Chaoyang', 2) FILE '/tmp/csvfile.csv'; ``` - 也可以在一条语句中向多个表以自动建表的方式插入记录。例如: - ```mysql - INSERT INTO d21001 USING meters TAGS ('Beijing.Chaoyang', 2) FILE '/tmp/csvfile_21001.csv' - d21002 USING meters (groupId) TAGS (2) FILE '/tmp/csvfile_21002.csv'; - ``` **历史记录写入**:可使用IMPORT或者INSERT命令,IMPORT的语法,功能与INSERT完全一样。 diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 3f65c64aed6b7fd4f9c0fb14336785934820246f..c353c4af5d25388266e7afd702ff0a3f6658707b 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -257,6 +257,8 @@ typedef struct SInsertStatementParam { int32_t batchSize; // for parameter ('?') binding and batch processing int32_t numOfParams; + int32_t numOfFiles; + char msg[512]; // error message uint32_t insertType; // insert data from [file|sql statement| bound statement] uint64_t objectId; // sql object id diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 979408b19d8e36315c9c37a73d2ae3f8c559f721..ad209839bb24b7a34fc761a4111997db4076b4de 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -1501,6 +1501,11 @@ int tsParseInsertSql(SSqlObj *pSql) { tscInvalidOperationMsg(pInsertParam->msg, "invalid filename", sToken.z); goto _clean; } + + if (++pInsertParam->numOfFiles > 1) { + code = tscInvalidOperationMsg(pInsertParam->msg, "data from multi files is not supported", NULL); + goto _clean; + } } else { if (bindedColumns == NULL) { STableMeta *pTableMeta = pTableMetaInfo->pTableMeta; diff --git a/tests/pytest/insert/insertFromCSV.py b/tests/pytest/insert/insertFromCSV.py index c5d36485699dd2b798b353b614008be7234edfd4..ed21072dcad3cb91898273c5368567c839b54049 100644 --- a/tests/pytest/insert/insertFromCSV.py +++ b/tests/pytest/insert/insertFromCSV.py @@ -30,7 +30,7 @@ class TDTestCase: self.ts = 1500074556514 self.csvfile = "/tmp/csvfile.csv" - self.rows = 100000 + self.rows = 10000 def writeCSV(self): with open(self.csvfile, 'w', encoding='utf-8', newline='') as csvFile: @@ -64,6 +64,8 @@ class TDTestCase: tdSql.query("select * from stb") tdSql.checkRows(self.rows * 2) + tdSql.error("insert into t4 using stb tags(2, 'test2') file '%s' t5 using stb(t1) tags(5) file '%s'" % (self.csvfile, self.csvfile)) + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__)