From 5bb0a3d04b1ee594f0e4b647fa0859ed5d99a171 Mon Sep 17 00:00:00 2001 From: bryanchang0603 Date: Sat, 5 Jun 2021 17:17:13 +0800 Subject: [PATCH 01/72] [TD-4473] initial git --- tests/pytest/alter/alter_keep.py | 63 ++++++++++++----- .../manualTest/manual_chang_time_1_1.py | 67 +++++++++++++++++++ .../manual_change_time_1_1_A.json | 60 +++++++++++++++++ .../manual_change_time_1_1_B.json | 60 +++++++++++++++++ 4 files changed, 235 insertions(+), 15 deletions(-) create mode 100644 tests/pytest/manualTest/manual_chang_time_1_1.py create mode 100644 tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_A.json create mode 100644 tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_B.json diff --git a/tests/pytest/alter/alter_keep.py b/tests/pytest/alter/alter_keep.py index cb630963a7..f9c71ed4ff 100644 --- a/tests/pytest/alter/alter_keep.py +++ b/tests/pytest/alter/alter_keep.py @@ -116,25 +116,58 @@ class TDTestCase: ##TODO: need to wait for TD-4445 to implement the following ## tests - # tdSql.prepare() - # tdSql.execute('create table tb (ts timestamp, speed int)') - # tdSql.execute('alter database db keep 10,10,10') - # tdSql.execute('insert into tb values (now, 10)') - # tdSql.execute('insert into tb values (now + 10m, 10)') - # tdSql.query('select * from tb') - # tdSql.checkRows(2) - # tdSql.execute('alter database db keep 40,40,40') - # tdSql.query('show databases') - # tdSql.checkData(0,7,'40,40,40') - # tdSql.error('insert into tb values (now-60d, 10)') - # tdSql.execute('insert into tb values (now-30d, 10)') - # tdSql.query('select * from tb') - # tdSql.checkRows(3) + + ## preset the keep + tdSql.prepare() + tdSql.execute('create table tb (ts timestamp, speed int)') + tdSql.execute('alter database db keep 10,10,10') + tdSql.execute('insert into tb values (now, 10)') + tdSql.execute('insert into tb values (now + 10m, 10)') + tdSql.query('select * from tb') + tdSql.checkRows(2) + + + #after alter from small to large, check if the alter if functioning + #test if change through test.py is consistent with change from taos client + #test case for TD-4459 and TD-4445 + tdSql.execute('alter database db keep 40,40,40') + tdSql.query('show databases') + tdSql.checkData(0,7,'40,40,40') + tdSql.error('insert into tb values (now-60d, 10)') + tdSql.execute('insert into tb values (now-30d, 10)') + tdSql.query('select * from tb') + tdSql.checkRows(3) + + rowNum = 3 + for i in range(30): + rowNum += 1 + tdSql.execute('alter database db keep 20,20,20') + tdSql.execute('alter database db keep 40,40,40') + tdSql.query('show databases') + tdSql.checkData(0,7,'40,40,40') + tdSql.error('insert into tb values (now-60d, 10)') + tdSql.execute('insert into tb values (now-30d, 10)') + tdSql.query('select * from tb') + tdSql.checkRows(rowNum) + + tdSql.execute('alter database db keep 10,10,10') + tdSql.query('show databases') + tdSql.checkData(0,7,'10,10,10') + tdSql.execute('alter database db keep 15,15,15') + tdSql.query('show databases') + tdSql.checkData(0,7,'15,15,15') + tdSql.execute('insert into tb values (now-30d, 10)') + tdSql.query('select * from tb') + tdSql.checkRows(rowNum + 1) + # tdSql.execute('alter database db keep 20,20,20') # tdSql.query('show databases') # tdSql.checkData(0,7,'20,20,20') + # tdSql.error('insert into tb values (now-30d, 10)') + # tdSql.query('show databases') + # tdSql.checkData(0,7,'20,20,20') # tdSql.query('select * from tb') - # tdSql.checkRows(2) + # tdSql.checkRows(rowNum) def stop(self): diff --git a/tests/pytest/manualTest/manual_chang_time_1_1.py b/tests/pytest/manualTest/manual_chang_time_1_1.py new file mode 100644 index 0000000000..0d82f7c871 --- /dev/null +++ b/tests/pytest/manualTest/manual_chang_time_1_1.py @@ -0,0 +1,67 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import tdDnodes + +##TODO: auto test version is currently unsupported, need to come up with +# an auto test version in the future +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + ## change system time to 2020/10/20 + os.system ('timedatectl set-ntp off') + os.system ('timedatectl set-time 2020-10-20') + + #run taosdemo to insert data. one row per second from 2020/10/11 to 2020/10/20 + # + os.system("%staosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_A.json" % binPath) + input("please check memory usage for taosd. After checking, press enter") + + def stop(self): + tdSql.close() + tdLog.debug("%s alter block manual check finish" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_A.json b/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_A.json new file mode 100644 index 0000000000..7b8abd6d4e --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_A.json @@ -0,0 +1,60 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 32766, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 1, + "cache": 4, + "blocks": 3, + "precision": "ms", + "keep": 10, + "minRows": 1000, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 864000, + "childtable_limit": 1, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1000, + "start_timestamp": "2020-10-11 00:00:00.000", + "sample_format": "csv", + "sample_file": "./tools/taosdemoAllTest/sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 5120, "count":1}], + "tags": [{"type": "TINYINT", "count":2}] + }] + }] +} \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_B.json b/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_B.json new file mode 100644 index 0000000000..846730acfb --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_B.json @@ -0,0 +1,60 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 32766, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "no", + "replica": 1, + "days": 1, + "cache": 4, + "blocks": 3, + "precision": "ms", + "keep": 10, + "minRows": 1000, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"yes", + "childtable_count": 1, + "childtable_prefix": "stb_", + "auto_create_table": "yes", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 86400, + "childtable_limit": 1, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1000, + "start_timestamp": "2020-10-17 00:00:00.000", + "sample_format": "csv", + "sample_file": "./tools/taosdemoAllTest/sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 5120, "count":1}], + "tags": [{"type": "TINYINT", "count":1}] + }] + }] +} \ No newline at end of file From ed50bd47c2cdc92507dc0df68fdff880e07ef1c2 Mon Sep 17 00:00:00 2001 From: bryanchang0603 Date: Mon, 7 Jun 2021 09:32:23 +0800 Subject: [PATCH 02/72] [TD-4473] updating test cases --- .../manualTest/manual_chang_time_1_1.py | 28 +++++- .../manualTest/manual_chang_time_1_2.py | 86 +++++++++++++++++++ .../manual_chang_time_1_auto_test.py | 77 +++++++++++++++++ .../manual_change_time_1_1_B.json | 4 +- 4 files changed, 191 insertions(+), 4 deletions(-) create mode 100644 tests/pytest/manualTest/manual_chang_time_1_2.py create mode 100644 tests/pytest/manualTest/manual_chang_time_1_auto_test.py diff --git a/tests/pytest/manualTest/manual_chang_time_1_1.py b/tests/pytest/manualTest/manual_chang_time_1_1.py index 0d82f7c871..69ea6f349b 100644 --- a/tests/pytest/manualTest/manual_chang_time_1_1.py +++ b/tests/pytest/manualTest/manual_chang_time_1_1.py @@ -16,6 +16,8 @@ from util.log import * from util.cases import * from util.sql import * from util.dnodes import tdDnodes +from datetime import datetime +import subprocess ##TODO: auto test version is currently unsupported, need to come up with # an auto test version in the future @@ -54,9 +56,31 @@ class TDTestCase: os.system ('timedatectl set-time 2020-10-20') #run taosdemo to insert data. one row per second from 2020/10/11 to 2020/10/20 - # + #11 data files should be generated + #vnode at TDinternal/community/sim/dnode1/data/vnode os.system("%staosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_A.json" % binPath) - input("please check memory usage for taosd. After checking, press enter") + input("please the data file. After checking, press enter") + + tdSql.query('select first(ts) from stb_0') + tdSql.checkData(0,0,datetime(2020,10,11,0,0,0,0)) + tdSql.query('select last(ts) from stb_0') + tdSql.checkData(0,0,datetime(2020,10,20,23,59,59,0)) + + os.system ('timedatectl set-time 2020-10-25') + + #run taosdemo to insert data. one row per second from 2020/10/16 to 2020/10/20 + #4 oldest data file should be removed from tsdb/data + #vnode at TDinternal/community/sim/dnode1/data/vnode + #7 data file should be found + os.system("%staosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_B.json" % binPath) + input("please the data file. After checking, press enter") + + tdSql.query('select first(ts) from stb_0') + tdSql.checkData(0,0,datetime(2020,10,14,8,0,0,0)) + + ##test results + #2021/06/05 first check: 11 data files second check: 7 data files + # confirm with the assumption Baosheng Chang def stop(self): tdSql.close() diff --git a/tests/pytest/manualTest/manual_chang_time_1_2.py b/tests/pytest/manualTest/manual_chang_time_1_2.py new file mode 100644 index 0000000000..26661f7314 --- /dev/null +++ b/tests/pytest/manualTest/manual_chang_time_1_2.py @@ -0,0 +1,86 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import tdDnodes +from datetime import datetime + +##TODO: auto test version is currently unsupported, need to come up with +# an auto test version in the future +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + ## change system time to 2020/10/20 + os.system ('timedatectl set-ntp off') + os.system ('timedatectl set-time 2020-10-20') + + #run taosdemo to insert data. one row per second from 2020/10/11 to 2020/10/20 + #11 data files should be generated + #vnode at TDinternal/community/sim/dnode1/data/vnode + os.system("%staosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_A.json" % binPath) + input("please the data file. After checking, press enter") + + tdSql.query('select first(ts) from stb_0') #check the last data in the database + tdSql.checkData(0,0,datetime(2020,10,11,0,0,0,0)) + + os.system ('timedatectl set-time 2020-10-25') + + #restart taosd + #4 oldest data file should be removed from tsdb/data + #vnode at TDinternal/community/sim/dnode1/data/vnode + #7 data file should be found + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query('select first(ts) from stb_0') + tdSql.checkData(0,0,datetime(2020,10,14,8,0,0,0)) #check the last data in the database + input("please the data file. After checking, press enter") + + + + def stop(self): + tdSql.close() + tdLog.debug("%s alter block manual check finish" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/manualTest/manual_chang_time_1_auto_test.py b/tests/pytest/manualTest/manual_chang_time_1_auto_test.py new file mode 100644 index 0000000000..86bc77404b --- /dev/null +++ b/tests/pytest/manualTest/manual_chang_time_1_auto_test.py @@ -0,0 +1,77 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import tdDnodes +from datetime import datetime +import subprocess + +##TODO: auto test version is currently unsupported, need to come up with +# an auto test version in the future +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + #tdSql.prepare() + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + ## change system time to 2020/10/20 + os.system ('timedatectl set-ntp off') + os.system ('timedatectl set-time 2020-10-20') + + #run taosdemo to insert data. one row per second from 2020/10/11 to 2020/10/20 + #11 data files should be generated + #vnode at TDinternal/community/sim/dnode1/data/vnode + #os.system("%staosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_A.json" % binPath) + #input("please the data file. After checking, press enter") + commandArray = ['ls', '-l', f'{binPath}sim/dnode1/data/vnode/vnode2/tsdb/data', '|grep', '\'data\'', '|wc', '-l'] + result = subprocess.run(commandArray, stdout=subprocess.PIPE).stdout.decode('utf-8') + print(result) + # tdSql.query('select first(ts) from stb_0') + # tdSql.checkData(0,0,datetime(2020,10,11,0,0,0,0)) + # tdSql.query('select last(ts) from stb_0') + # tdSql.checkData(0,0,datetime(2020,10,20,23,59,59,0)) + + def stop(self): + tdSql.close() + tdLog.debug("%s alter block manual check finish" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_B.json b/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_B.json index 846730acfb..aeee6322e5 100644 --- a/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_B.json +++ b/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_B.json @@ -40,7 +40,7 @@ "batch_create_tbl_num": 20, "data_source": "rand", "insert_mode": "taosc", - "insert_rows": 86400, + "insert_rows": 432000, "childtable_limit": 1, "childtable_offset":0, "interlace_rows": 0, @@ -49,7 +49,7 @@ "disorder_ratio": 0, "disorder_range": 1000, "timestamp_step": 1000, - "start_timestamp": "2020-10-17 00:00:00.000", + "start_timestamp": "2020-10-16 00:00:00.500", "sample_format": "csv", "sample_file": "./tools/taosdemoAllTest/sample.csv", "tags_file": "", From 5f5313b23451b594de751ec5d01d0498a41e34fc Mon Sep 17 00:00:00 2001 From: bryanchang0603 Date: Mon, 7 Jun 2021 11:25:46 +0800 Subject: [PATCH 03/72] [TD-4366] modifying test case --- .../manualTest/manual_chang_time_1_2.py | 42 +++++++++++++-- .../manual_chang_time_1_auto_test.py | 54 +++++++++++++++---- .../pytest/manualTest/manual_chang_time_2.py | 46 ++++++++++++++++ 3 files changed, 129 insertions(+), 13 deletions(-) create mode 100644 tests/pytest/manualTest/manual_chang_time_2.py diff --git a/tests/pytest/manualTest/manual_chang_time_1_2.py b/tests/pytest/manualTest/manual_chang_time_1_2.py index 26661f7314..f0f11d3e72 100644 --- a/tests/pytest/manualTest/manual_chang_time_1_2.py +++ b/tests/pytest/manualTest/manual_chang_time_1_2.py @@ -17,6 +17,7 @@ from util.cases import * from util.sql import * from util.dnodes import tdDnodes from datetime import datetime +import subprocess ##TODO: auto test version is currently unsupported, need to come up with # an auto test version in the future @@ -40,7 +41,24 @@ class TDTestCase: buildPath = root[:len(root)-len("/build/bin")] break return buildPath - + + def getTDenginePath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + print(projPath) + for root, dirs, files in os.walk(projPath): + if ("sim" in dirs): + print(root) + rootRealPath = os.path.realpath(root) + # if ("packaging" not in rootRealPath): + # buildPath = root[:len(root)-len("/build/bin")] + # break + return rootRealPath + def run(self): tdSql.prepare() buildPath = self.getBuildPath() @@ -49,6 +67,12 @@ class TDTestCase: else: tdLog.info("taosd found in %s" % buildPath) binPath = buildPath+ "/build/bin/" + TDenginePath = self.getTDenginePath() + print('TD '+ TDenginePath) + if (TDenginePath == ""): + tdLog.exit("TDengine not found!") + else: + tdLog.info("TDengine found in %s" % TDenginePath) ## change system time to 2020/10/20 os.system ('timedatectl set-ntp off') @@ -58,7 +82,13 @@ class TDTestCase: #11 data files should be generated #vnode at TDinternal/community/sim/dnode1/data/vnode os.system("%staosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_A.json" % binPath) - input("please the data file. After checking, press enter") + commandArray = ['ls', '-l', f'{TDenginePath}/sim/dnode1/data/vnode/vnode2/tsdb/data'] + result = subprocess.run(commandArray, stdout=subprocess.PIPE).stdout.decode('utf-8') + print(result.count('data')) + if result.count('data') != 11: + tdLog.exit('wrong number of files') + else: + tdLog.info("data file number correct") tdSql.query('select first(ts) from stb_0') #check the last data in the database tdSql.checkData(0,0,datetime(2020,10,11,0,0,0,0)) @@ -73,7 +103,13 @@ class TDTestCase: tdDnodes.start(1) tdSql.query('select first(ts) from stb_0') tdSql.checkData(0,0,datetime(2020,10,14,8,0,0,0)) #check the last data in the database - input("please the data file. After checking, press enter") + commandArray = ['ls', '-l', f'{TDenginePath}/sim/dnode1/data/vnode/vnode2/tsdb/data'] + result = subprocess.run(commandArray, stdout=subprocess.PIPE).stdout.decode('utf-8') + print(result.count('data')) + if result.count('data') != 7: + tdLog.exit('wrong number of files') + else: + tdLog.info("data file number correct") diff --git a/tests/pytest/manualTest/manual_chang_time_1_auto_test.py b/tests/pytest/manualTest/manual_chang_time_1_auto_test.py index 86bc77404b..a9e8935df4 100644 --- a/tests/pytest/manualTest/manual_chang_time_1_auto_test.py +++ b/tests/pytest/manualTest/manual_chang_time_1_auto_test.py @@ -26,6 +26,23 @@ class TDTestCase: tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) + def getTDenginePath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + print(projPath) + for root, dirs, files in os.walk(projPath): + if ("sim" in dirs): + print(root) + rootRealPath = os.path.realpath(root) + # if ("packaging" not in rootRealPath): + # buildPath = root[:len(root)-len("/build/bin")] + # break + return rootRealPath + def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -41,15 +58,21 @@ class TDTestCase: buildPath = root[:len(root)-len("/build/bin")] break return buildPath - + def run(self): - #tdSql.prepare() + tdSql.prepare() buildPath = self.getBuildPath() if (buildPath == ""): tdLog.exit("taosd not found!") else: tdLog.info("taosd found in %s" % buildPath) binPath = buildPath+ "/build/bin/" + TDenginePath = self.getTDenginePath() + print('TD '+ TDenginePath) + if (TDenginePath == ""): + tdLog.exit("TDengine not found!") + else: + tdLog.info("TDengine found in %s" % TDenginePath) ## change system time to 2020/10/20 os.system ('timedatectl set-ntp off') @@ -58,15 +81,26 @@ class TDTestCase: #run taosdemo to insert data. one row per second from 2020/10/11 to 2020/10/20 #11 data files should be generated #vnode at TDinternal/community/sim/dnode1/data/vnode - #os.system("%staosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_A.json" % binPath) - #input("please the data file. After checking, press enter") - commandArray = ['ls', '-l', f'{binPath}sim/dnode1/data/vnode/vnode2/tsdb/data', '|grep', '\'data\'', '|wc', '-l'] + os.system("%staosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_A.json" % binPath) + commandArray = ['ls', '-l', f'{TDenginePath}/sim/dnode1/data/vnode/vnode2/tsdb/data'] result = subprocess.run(commandArray, stdout=subprocess.PIPE).stdout.decode('utf-8') - print(result) - # tdSql.query('select first(ts) from stb_0') - # tdSql.checkData(0,0,datetime(2020,10,11,0,0,0,0)) - # tdSql.query('select last(ts) from stb_0') - # tdSql.checkData(0,0,datetime(2020,10,20,23,59,59,0)) + print(result.count('data')) + if result.count('data') != 11: + tdLog.exit('wrong number of files') + else: + tdLog.info("data file number correct") + + os.system ('timedatectl set-time 2020-10-25') + os.system("%staosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_B.json" % binPath) + commandArray = ['ls', '-l', f'{TDenginePath}/sim/dnode1/data/vnode/vnode2/tsdb/data'] + result = subprocess.run(commandArray, stdout=subprocess.PIPE).stdout.decode('utf-8') + print(result.count('data')) + if result.count('data') != 7: + tdLog.exit('wrong number of files') + else: + tdLog.info("data file number correct") + tdSql.query('select first(ts) from stb_0') + tdSql.checkData(0,0,datetime(2020,10,14,8,0,0,0)) def stop(self): tdSql.close() diff --git a/tests/pytest/manualTest/manual_chang_time_2.py b/tests/pytest/manualTest/manual_chang_time_2.py new file mode 100644 index 0000000000..5d60d557c0 --- /dev/null +++ b/tests/pytest/manualTest/manual_chang_time_2.py @@ -0,0 +1,46 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +from fabric import Connection +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import tdDnodes +from datetime import datetime +import subprocess + +# class VMPnode + +# ##TODO: auto test version is currently unsupported, need to come up with +# # an auto test version in the future +# class TDTestCase: +# def init(self, conn, logSql): +# tdLog.debug("start to execute %s" % __file__) +# tdSql.init(conn.cursor(), logSql) + +# def run(self): +# return + + + +# def stop(self): +# tdSql.close() +# tdLog.debug("%s alter block manual check finish" % __file__) + + +# tdCases.addWindows(__file__, TDTestCase()) +# tdCases.addLinux(__file__, TDTestCase()) + +conn = conn = Connection("{}@{}".format('ubuntu', "lyq-q-1"), connect_kwargs={"password": "{}".format('tbase125!')}) +conn.run('sudo timedatectl set-ntp off') +conn.run('sudo timedatectl set-time 2020-10-20') \ No newline at end of file From 60502d9b021519123b70f815ec920ad88cafeb79 Mon Sep 17 00:00:00 2001 From: bryanchang0603 Date: Mon, 7 Jun 2021 11:27:36 +0800 Subject: [PATCH 04/72] [TD-4773] modifying test case --- tests/pytest/alter/alter_keep.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/pytest/alter/alter_keep.py b/tests/pytest/alter/alter_keep.py index f9c71ed4ff..dd9fd08ba6 100644 --- a/tests/pytest/alter/alter_keep.py +++ b/tests/pytest/alter/alter_keep.py @@ -153,10 +153,10 @@ class TDTestCase: tdSql.execute('alter database db keep 10,10,10') tdSql.query('show databases') tdSql.checkData(0,7,'10,10,10') - tdSql.execute('alter database db keep 15,15,15') - tdSql.query('show databases') - tdSql.checkData(0,7,'15,15,15') - tdSql.execute('insert into tb values (now-30d, 10)') + # tdSql.execute('alter database db keep 15,15,15') + # tdSql.query('show databases') + # tdSql.checkData(0,7,'15,15,15') + tdSql.execute('insert into tb values (now-15d, 10)') tdSql.query('select * from tb') tdSql.checkRows(rowNum + 1) From ed65cfc6789ace9e0add36f2146a57eca9852101 Mon Sep 17 00:00:00 2001 From: bryanchang0603 Date: Sun, 25 Oct 2020 00:05:29 +0800 Subject: [PATCH 05/72] [TD-4366] updating the automatic version of test cases. Not sure if they can go through jenkins --- .../pytest/manualTest/manual_chang_time_2.py | 46 --------- ..._time_1_1.py => manual_change_time_1_1.py} | 73 +++++++++----- ..._time_1_2.py => manual_change_time_1_2.py} | 8 +- .../pytest/manualTest/manual_change_time_2.py | 97 +++++++++++++++++++ .../pytest/manualTest/manual_change_time_3.py | 97 +++++++++++++++++++ 5 files changed, 245 insertions(+), 76 deletions(-) delete mode 100644 tests/pytest/manualTest/manual_chang_time_2.py rename tests/pytest/manualTest/{manual_chang_time_1_1.py => manual_change_time_1_1.py} (54%) rename tests/pytest/manualTest/{manual_chang_time_1_2.py => manual_change_time_1_2.py} (96%) create mode 100644 tests/pytest/manualTest/manual_change_time_2.py create mode 100644 tests/pytest/manualTest/manual_change_time_3.py diff --git a/tests/pytest/manualTest/manual_chang_time_2.py b/tests/pytest/manualTest/manual_chang_time_2.py deleted file mode 100644 index 5d60d557c0..0000000000 --- a/tests/pytest/manualTest/manual_chang_time_2.py +++ /dev/null @@ -1,46 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- -from fabric import Connection -import sys -from util.log import * -from util.cases import * -from util.sql import * -from util.dnodes import tdDnodes -from datetime import datetime -import subprocess - -# class VMPnode - -# ##TODO: auto test version is currently unsupported, need to come up with -# # an auto test version in the future -# class TDTestCase: -# def init(self, conn, logSql): -# tdLog.debug("start to execute %s" % __file__) -# tdSql.init(conn.cursor(), logSql) - -# def run(self): -# return - - - -# def stop(self): -# tdSql.close() -# tdLog.debug("%s alter block manual check finish" % __file__) - - -# tdCases.addWindows(__file__, TDTestCase()) -# tdCases.addLinux(__file__, TDTestCase()) - -conn = conn = Connection("{}@{}".format('ubuntu', "lyq-q-1"), connect_kwargs={"password": "{}".format('tbase125!')}) -conn.run('sudo timedatectl set-ntp off') -conn.run('sudo timedatectl set-time 2020-10-20') \ No newline at end of file diff --git a/tests/pytest/manualTest/manual_chang_time_1_1.py b/tests/pytest/manualTest/manual_change_time_1_1.py similarity index 54% rename from tests/pytest/manualTest/manual_chang_time_1_1.py rename to tests/pytest/manualTest/manual_change_time_1_1.py index 69ea6f349b..8b444eeb6a 100644 --- a/tests/pytest/manualTest/manual_chang_time_1_1.py +++ b/tests/pytest/manualTest/manual_change_time_1_1.py @@ -19,13 +19,29 @@ from util.dnodes import tdDnodes from datetime import datetime import subprocess -##TODO: auto test version is currently unsupported, need to come up with -# an auto test version in the future +##TODO: this is now automatic, but not sure if this will run through jenkins class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) + def getTDenginePath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + print(projPath) + for root, dirs, files in os.walk(projPath): + if ("sim" in dirs): + print(root) + rootRealPath = os.path.realpath(root) + # if ("packaging" not in rootRealPath): + # buildPath = root[:len(root)-len("/build/bin")] + # break + return rootRealPath + def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -41,7 +57,7 @@ class TDTestCase: buildPath = root[:len(root)-len("/build/bin")] break return buildPath - + def run(self): tdSql.prepare() buildPath = self.getBuildPath() @@ -50,37 +66,42 @@ class TDTestCase: else: tdLog.info("taosd found in %s" % buildPath) binPath = buildPath+ "/build/bin/" + TDenginePath = self.getTDenginePath() + print('TD '+ TDenginePath) + if (TDenginePath == ""): + tdLog.exit("TDengine not found!") + else: + tdLog.info("TDengine found in %s" % TDenginePath) ## change system time to 2020/10/20 - os.system ('timedatectl set-ntp off') - os.system ('timedatectl set-time 2020-10-20') + os.system('sudo timedatectl set-ntp off') + os.system('sudo timedatectl set-time 2020-10-20') #run taosdemo to insert data. one row per second from 2020/10/11 to 2020/10/20 #11 data files should be generated #vnode at TDinternal/community/sim/dnode1/data/vnode os.system("%staosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_A.json" % binPath) - input("please the data file. After checking, press enter") - - tdSql.query('select first(ts) from stb_0') - tdSql.checkData(0,0,datetime(2020,10,11,0,0,0,0)) - tdSql.query('select last(ts) from stb_0') - tdSql.checkData(0,0,datetime(2020,10,20,23,59,59,0)) - - os.system ('timedatectl set-time 2020-10-25') - - #run taosdemo to insert data. one row per second from 2020/10/16 to 2020/10/20 - #4 oldest data file should be removed from tsdb/data - #vnode at TDinternal/community/sim/dnode1/data/vnode - #7 data file should be found - os.system("%staosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_B.json" % binPath) - input("please the data file. After checking, press enter") - - tdSql.query('select first(ts) from stb_0') - tdSql.checkData(0,0,datetime(2020,10,14,8,0,0,0)) + commandArray = ['ls', '-l', f'{TDenginePath}/sim/dnode1/data/vnode/vnode2/tsdb/data'] + result = subprocess.run(commandArray, stdout=subprocess.PIPE).stdout.decode('utf-8') + print(result.count('data')) + if result.count('data') != 11: + tdLog.exit('wrong number of files') + else: + tdLog.info("data file number correct") - ##test results - #2021/06/05 first check: 11 data files second check: 7 data files - # confirm with the assumption Baosheng Chang + #move 5 days ahead to 2020/10/25. 4 oldest files should be removed during the new write + #leaving 7 data files. + os.system ('timedatectl set-time 2020-10-25') + os.system("%staosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_B.json" % binPath) + commandArray = ['ls', '-l', f'{TDenginePath}/sim/dnode1/data/vnode/vnode2/tsdb/data'] + result = subprocess.run(commandArray, stdout=subprocess.PIPE).stdout.decode('utf-8') + print(result.count('data')) + if result.count('data') != 7: + tdLog.exit('wrong number of files') + else: + tdLog.info("data file number correct") + tdSql.query('select first(ts) from stb_0') + tdSql.checkData(0,0,datetime(2020,10,14,8,0,0,0)) #check the last data in the database def stop(self): tdSql.close() diff --git a/tests/pytest/manualTest/manual_chang_time_1_2.py b/tests/pytest/manualTest/manual_change_time_1_2.py similarity index 96% rename from tests/pytest/manualTest/manual_chang_time_1_2.py rename to tests/pytest/manualTest/manual_change_time_1_2.py index f0f11d3e72..076099edae 100644 --- a/tests/pytest/manualTest/manual_chang_time_1_2.py +++ b/tests/pytest/manualTest/manual_change_time_1_2.py @@ -19,8 +19,7 @@ from util.dnodes import tdDnodes from datetime import datetime import subprocess -##TODO: auto test version is currently unsupported, need to come up with -# an auto test version in the future +##TODO: this is now automatic, but not sure if this will run through jenkins class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) @@ -95,10 +94,11 @@ class TDTestCase: os.system ('timedatectl set-time 2020-10-25') - #restart taosd + #moves 5 days ahead to 2020/10/25 and restart taosd #4 oldest data file should be removed from tsdb/data - #vnode at TDinternal/community/sim/dnode1/data/vnode #7 data file should be found + #vnode at TDinternal/community/sim/dnode1/data/vnode + os.system ('timedatectl set-time 2020-10-25') tdDnodes.stop(1) tdDnodes.start(1) tdSql.query('select first(ts) from stb_0') diff --git a/tests/pytest/manualTest/manual_change_time_2.py b/tests/pytest/manualTest/manual_change_time_2.py new file mode 100644 index 0000000000..4aeacb9f63 --- /dev/null +++ b/tests/pytest/manualTest/manual_change_time_2.py @@ -0,0 +1,97 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +from fabric import Connection +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import tdDnodes +from datetime import datetime +import subprocess +import time +import taos +##TODO: this is now automatic, but not sure if this will run through jenkins + +#the initial time used for this test is 2020/10/20 + +#setting local machine's time for later connecting to the server +os.system('sudo timedatectl set-ntp off') +os.system('sudo timedatectl set-time 2020-10-25') + +#connect to VM lyq-1, and initalize the environment at lyq-1 +conn1 = Connection("{}@{}".format('ubuntu', "192.168.1.125"), connect_kwargs={"password": "{}".format('tbase125!')}) +conn1.run("sudo systemctl stop taosd") +conn1.run('ls -l') +conn1.run('sudo timedatectl set-ntp off') +conn1.run('sudo timedatectl set-time 2020-10-20') + +with conn1.cd('/data/taos/log'): + conn1.run('sudo rm -rf *') + +with conn1.cd('/data/taos/data'): + conn1.run('sudo rm -rf *') + +#lanuch taosd and start taosdemo +conn1.run("sudo systemctl start taosd") +time.sleep(5) +with conn1.cd('~/bschang_test'): + conn1.run('taosdemo -f manual_change_time_1_1_A.json') + +#force everything onto disk +conn1.run("sudo systemctl restart taosd") +time.sleep(10) + +#change lyq-1 to 2020/10/25 for testing if the server +#will send data that is out of time range +conn1.run('sudo timedatectl set-time 2020-10-25') + +#connect to VM lyq-2, initalize the environment at lyq-2, and run taosd +#on that +conn2 = Connection("{}@{}".format('ubuntu', "192.168.1.126"), connect_kwargs={"password": "{}".format('tbase125!')}) +conn2.run('sudo timedatectl set-ntp off') +conn2.run('sudo timedatectl set-time 2020-10-20') +conn2.run("sudo systemctl stop taosd") +with conn2.cd('/data/taos/log'): + conn2.run('sudo rm -rf *') +with conn2.cd('/data/taos/data'): + conn2.run('sudo rm -rf *') +conn2.run("sudo systemctl start taosd") + +#set replica to 2 +connTaos = taos.connect(host = '192.168.1.125', user = 'root', password = 'taosdata', cnfig = '/etc/taos') +c1 = connTaos.cursor() +c1.execute('create dnode \'lyq-2:6030\'') +c1.execute('alter database db replica 2') +c1.close() +connTaos.close() +time.sleep(5) + +#force everything onto the disk for lyq-2 +#stopping taosd on lyq-1 for future testing +conn2.run("sudo systemctl stop taosd") +conn1.run("sudo systemctl stop taosd") + +#reset the time +conn1.run('sudo timedatectl set-ntp on') +conn2.run('sudo timedatectl set-ntp on') +os.system('sudo timedatectl set-ntp on') + +#check if the number of file received is 7 +#the 4 oldest data files should be dropped +#4 files because of moving 5 days ahead +with conn2.cd('/data/taos/data/vnode/vnode3/tsdb/data'): + result = conn2.run('ls -l |grep \'data\' |wc -l') + if result.stdout.strip() != '7': + tdLog.exit('the file number is wrong') + else: + tdLog.success('the file number is the same. test pass') diff --git a/tests/pytest/manualTest/manual_change_time_3.py b/tests/pytest/manualTest/manual_change_time_3.py new file mode 100644 index 0000000000..a288147b56 --- /dev/null +++ b/tests/pytest/manualTest/manual_change_time_3.py @@ -0,0 +1,97 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +from fabric import Connection +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import tdDnodes +from datetime import datetime +import subprocess +import time +import taos + +##TODO: this is now automatic, but not sure if this will run through jenkins + +#the initial time used for this test is 2020/10/20 + +#setting local machine's time for later connecting to the server +os.system('sudo timedatectl set-ntp off') +os.system('sudo timedatectl set-time 2020-10-20') + +#connect to VM lyq-1, and initalize the environment at lyq-1 +conn1 = Connection("{}@{}".format('ubuntu', "192.168.1.125"), connect_kwargs={"password": "{}".format('tbase125!')}) +conn1.run("sudo systemctl stop taosd") +conn1.run('sudo timedatectl set-ntp off') +conn1.run('sudo timedatectl set-time 2020-10-20') +with conn1.cd('/data/taos/log'): + conn1.run('sudo rm -rf *') + +with conn1.cd('/data/taos/data'): + conn1.run('sudo rm -rf *') + +#lanuch taosd and start taosdemo +conn1.run("sudo systemctl start taosd") +time.sleep(5) +with conn1.cd('~/bschang_test'): + conn1.run('taosdemo -f manual_change_time_1_1_A.json') #the json file is placed in lyq-1 already + +#force everything onto disk +conn1.run("sudo systemctl restart taosd") +time.sleep(10) + +#connect to VM lyq-2, and initalize the environment at lyq-2 +conn2 = Connection("{}@{}".format('ubuntu', "192.168.1.126"), connect_kwargs={"password": "{}".format('tbase125!')}) +conn2.run('sudo timedatectl set-ntp off') +conn2.run('sudo timedatectl set-time 2020-10-20') +conn2.run("sudo systemctl stop taosd") +with conn2.cd('/data/taos/log'): + conn2.run('sudo rm -rf *') +with conn2.cd('/data/taos/data'): + conn2.run('sudo rm -rf *') + +#the date of lyq-2 is going to be set to 2020/10/25 +#for testing if other pnode will accpet file out of local time range +conn2.run("sudo systemctl start taosd") +conn2.run('sudo timedatectl set-time 2020-10-25') + +#set the replica to 2 +connTaos = taos.connect(host = '192.168.1.125', user = 'root', password = 'taosdata', cnfig = '/etc/taos') +c1 = connTaos.cursor() +c1.execute('create dnode \'lyq-2:6030\'') +c1.execute('alter database db replica 2') +time.sleep(5) + +#force everything onto the disk for lyq-2 +#stopping taosd on lyq-1 for future testing +conn2.run("sudo systemctl stop taosd") +conn1.run("sudo systemctl stop taosd") + +#reset the time +conn1.run('sudo timedatectl set-ntp on') +conn2.run('sudo timedatectl set-ntp on') +os.system('sudo timedatectl set-ntp on') + +#check if the number of file received is 7 +#the 4 oldest data files should be dropped +#4 files because of moving 5 days ahead +with conn2.cd('/data/taos/data/vnode/vnode3/tsdb/data'): + result = conn2.run('ls -l |grep \'data\' |wc -l') + if result.stdout.strip() != '7': + tdLog.exit('the file number is wrong') + else: + tdLog.success('the file number is the same. test pass') + +c1.close() +connTaos.close() + From ba6b1a7022a4da9ffd0b7c386065115592126438 Mon Sep 17 00:00:00 2001 From: tickduan <417921451@qq.com> Date: Thu, 3 Jun 2021 16:39:52 +0800 Subject: [PATCH 06/72] check primary cloumn must timestamp type on project query --- src/client/src/tscSQLParser.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index f8aa444d9e..4c94123a03 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -6664,6 +6664,8 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { const char* msg5 = "sql too long"; // todo ADD support const char* msg6 = "from missing in subclause"; const char* msg7 = "time interval is required"; + const char* msg8 = "query column is required"; + const char* msg9 = "the first column should be primary timestamp column"; SSqlCmd* pCmd = &pSql->cmd; SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); @@ -6721,8 +6723,26 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); } - if (!tscIsProjectionQuery(pQueryInfo) && pQueryInfo->interval.interval == 0) { - return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg7); + // project query primary column must be timestamp type + if (tscIsProjectionQuery(pQueryInfo)) { + size_t size = tscSqlExprNumOfExprs(pQueryInfo); + // check zero + if(size == 0) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg8); + } + + // check primary column is timestamp + SSqlExpr* pSqlExpr = tscSqlExprGet(pQueryInfo, 0); + if(pSqlExpr == NULL) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg8); + } + if( pSqlExpr->colInfo.colId != PRIMARYKEY_TIMESTAMP_COL_INDEX) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg9); + } + } else { + if (pQueryInfo->interval.interval == 0) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg7); + } } // set the created table[stream] name From 6bfbe73623b1637499e3201ff9f5b3fa348ccf23 Mon Sep 17 00:00:00 2001 From: tickduan <417921451@qq.com> Date: Thu, 3 Jun 2021 17:50:08 +0800 Subject: [PATCH 07/72] modify tips text --- src/client/src/tscSQLParser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 4c94123a03..fea966d94e 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -6665,7 +6665,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { const char* msg6 = "from missing in subclause"; const char* msg7 = "time interval is required"; const char* msg8 = "query column is required"; - const char* msg9 = "the first column should be primary timestamp column"; + const char* msg9 = "the first column must be timestamp type"; SSqlCmd* pCmd = &pSql->cmd; SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); From 0b33fdbec1c10b7380a46f7c88123cd9cb06e6e8 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Thu, 3 Jun 2021 18:15:36 +0800 Subject: [PATCH 08/72] [TD-4412]: add new configuration parameter for db option cachelast --- src/common/src/tglobal.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index ed91695569..786c612d61 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -887,6 +887,16 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + cfg.option = "cachelast"; + cfg.ptr = &tsCacheLastRow; + cfg.valType = TAOS_CFG_VTYPE_INT8; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; + cfg.minValue = TSDB_MIN_DB_CACHE_LAST_ROW; + cfg.maxValue = TSDB_MAX_DB_CACHE_LAST_ROW; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + cfg.option = "mqttHostName"; cfg.ptr = tsMqttHostName; cfg.valType = TAOS_CFG_VTYPE_STRING; From e4c10a3e2465704fc438725487820f152097b62d Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Fri, 4 Jun 2021 10:24:56 +0800 Subject: [PATCH 09/72] test/offlineThreshold: fix index in show variables; --- tests/pytest/functions/showOfflineThresholdIs864000.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/pytest/functions/showOfflineThresholdIs864000.py b/tests/pytest/functions/showOfflineThresholdIs864000.py index 6cce869bf2..6734df1fac 100644 --- a/tests/pytest/functions/showOfflineThresholdIs864000.py +++ b/tests/pytest/functions/showOfflineThresholdIs864000.py @@ -25,7 +25,7 @@ class TDTestCase: def run(self): tdSql.query("show variables") - tdSql.checkData(51, 1, 864000) + tdSql.checkData(52, 1, 864000) def stop(self): tdSql.close() @@ -33,4 +33,4 @@ class TDTestCase: tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file +tdCases.addLinux(__file__, TDTestCase()) From 0a86ce884ee50e981a5e80a9ea12a8c144a23290 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Fri, 4 Jun 2021 13:19:29 +0800 Subject: [PATCH 10/72] [TD-4412]: add new configuration parameter for db option precision --- src/common/src/tglobal.c | 10 ++++++++++ tests/pytest/functions/showOfflineThresholdIs864000.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 786c612d61..381d2804c1 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -817,6 +817,16 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + cfg.option = "precision"; + cfg.ptr = &tsTimePrecision; + cfg.valType = TAOS_CFG_VTYPE_INT8; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; + cfg.minValue = TSDB_MIN_PRECISION; + cfg.maxValue = TSDB_MAX_PRECISION; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + cfg.option = "comp"; cfg.ptr = &tsCompression; cfg.valType = TAOS_CFG_VTYPE_INT8; diff --git a/tests/pytest/functions/showOfflineThresholdIs864000.py b/tests/pytest/functions/showOfflineThresholdIs864000.py index 6734df1fac..a7a1c2bf3f 100644 --- a/tests/pytest/functions/showOfflineThresholdIs864000.py +++ b/tests/pytest/functions/showOfflineThresholdIs864000.py @@ -25,7 +25,7 @@ class TDTestCase: def run(self): tdSql.query("show variables") - tdSql.checkData(52, 1, 864000) + tdSql.checkData(53, 1, 864000) def stop(self): tdSql.close() From b721486890dfb2614329ab55333d3ef146eb15ee Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Fri, 4 Jun 2021 16:21:25 +0800 Subject: [PATCH 11/72] fix tag string quote issue --- src/common/src/tvariant.c | 2 +- src/util/inc/tutil.h | 1 + src/util/src/tutil.c | 27 +++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/common/src/tvariant.c b/src/common/src/tvariant.c index 9988450c30..33dab51633 100644 --- a/src/common/src/tvariant.c +++ b/src/common/src/tvariant.c @@ -74,7 +74,7 @@ void tVariantCreate(tVariant *pVar, SStrToken *token) { case TSDB_DATA_TYPE_BINARY: { pVar->pz = strndup(token->z, token->n); - pVar->nLen = strdequote(pVar->pz); + pVar->nLen = strRmquote(pVar->pz, token->n); break; } diff --git a/src/util/inc/tutil.h b/src/util/inc/tutil.h index fe5c038c51..7c8fd2ed83 100644 --- a/src/util/inc/tutil.h +++ b/src/util/inc/tutil.h @@ -26,6 +26,7 @@ extern "C" { #include "taosdef.h" int32_t strdequote(char *src); +int32_t strRmquote(char *z, int32_t len); size_t strtrim(char *src); char * strnchr(char *haystack, char needle, int32_t len, bool skipquote); char ** strsplit(char *src, const char *delim, int32_t *num); diff --git a/src/util/src/tutil.c b/src/util/src/tutil.c index 451976f563..70285eb3cc 100644 --- a/src/util/src/tutil.c +++ b/src/util/src/tutil.c @@ -52,6 +52,33 @@ int32_t strdequote(char *z) { return j + 1; // only one quote, do nothing } + +int32_t strRmquote(char *z, int32_t len){ + // delete escape character: \\, \', \" + char delim = z[0]; + + int32_t cnt = 0; + int32_t j = 0; + for (uint32_t k = 1; k < len - 1; ++k) { + if (z[k] == '\\' || (z[k] == delim && z[k + 1] == delim)) { + z[j] = z[k + 1]; + + cnt++; + j++; + k++; + continue; + } + + z[j] = z[k]; + j++; + } + + z[j] = 0; + + return len - 2 - cnt; +} + + size_t strtrim(char *z) { int32_t i = 0; int32_t j = 0; From 408425e88bdb398178cf8262c5e781c67073501f Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Fri, 4 Jun 2021 17:49:30 +0800 Subject: [PATCH 12/72] Hotfix/sangshuduo/td 4025 fix travis ci broken (#6375) * [TD-4025]: travis ci broken due to valgrind dependency missed. * [TD-4025]: travis ci broken due to valgrind dependency missed. change focal to bionic. * [TD-4025]: travis ci broken due to valgrind dependency missed. install python3.8 * [TD-4025]: travis ci broken due to valgrind dependency missed. install python3.8 and pip, setuptools * [TD-4025]: travis ci broken due to valgrind dependency missed. install python3.8, and install pip and setuptools * [TD-4025]: travis ci broken due to valgrind dependency missed. modify smoketest.sh to python3.8 * fix timezone build error with clang/linux. Co-authored-by: Shuduo Sang --- src/os/src/detail/osTime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/os/src/detail/osTime.c b/src/os/src/detail/osTime.c index 67e0c2642e..2956dd29ad 100644 --- a/src/os/src/detail/osTime.c +++ b/src/os/src/detail/osTime.c @@ -43,7 +43,7 @@ */ int64_t user_mktime64(const unsigned int year0, const unsigned int mon0, const unsigned int day, const unsigned int hour, - const unsigned int min, const unsigned int sec, int64_t timezone) + const unsigned int min, const unsigned int sec, int64_t time_zone) { unsigned int mon = mon0, year = year0; @@ -61,7 +61,7 @@ int64_t user_mktime64(const unsigned int year0, const unsigned int mon0, res = res*24; res = ((res + hour) * 60 + min) * 60 + sec; - return (res + timezone); + return (res + time_zone); } // ==== mktime() kernel code =================// From 87331b48e31dec23c7670b98831a5488c4b1bf18 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Thu, 3 Jun 2021 16:19:14 +0800 Subject: [PATCH 13/72] [TD-3126]support nanoseconds time precision --- src/client/src/tscParseInsert.c | 6 +- src/client/src/tscSQLParser.c | 109 +++++++++------------------- src/client/src/tscStream.c | 34 +++------ src/kit/shell/src/shellEngine.c | 17 ++++- src/kit/taosdemo/taosdemo.c | 14 +++- src/mnode/src/mnodeDb.c | 9 ++- src/os/inc/osTime.h | 16 +++- src/os/src/detail/osTime.c | 72 ++++++++++++------ src/plugins/http/inc/httpJson.h | 4 +- src/plugins/http/src/httpJson.c | 94 ++++++++++++++++++------ src/plugins/http/src/httpRestJson.c | 6 +- src/query/inc/qSqlparser.h | 2 +- src/query/src/qExecutor.c | 16 ++-- src/query/src/qSqlParser.c | 11 +-- src/util/src/ttokenizer.c | 4 +- 15 files changed, 231 insertions(+), 183 deletions(-) diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index cd9853df03..1611d3dbf9 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -107,14 +107,10 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1 return tscInvalidOperationMsg(error, "value expected in timestamp", sToken.z); } - if (parseAbsoluteDuration(valueToken.z, valueToken.n, &interval) != TSDB_CODE_SUCCESS) { + if (parseAbsoluteDuration(valueToken.z, valueToken.n, &interval, timePrec) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_OPERATION; } - if (timePrec == TSDB_TIME_PRECISION_MILLI) { - interval /= 1000; - } - if (sToken.type == TK_PLUS) { useconds += interval; } else { diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index baa1538297..20a85a17b7 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -832,18 +832,15 @@ int32_t validateIntervalNode(SSqlObj* pSql, SQueryInfo* pQueryInfo, SSqlNode* pS // interval is not null SStrToken *t = &pSqlNode->interval.interval; - if (parseNatualDuration(t->z, t->n, &pQueryInfo->interval.interval, &pQueryInfo->interval.intervalUnit) != TSDB_CODE_SUCCESS) { + if (parseNatualDuration(t->z, t->n, &pQueryInfo->interval.interval, + &pQueryInfo->interval.intervalUnit, tinfo.precision) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_OPERATION; } if (pQueryInfo->interval.intervalUnit != 'n' && pQueryInfo->interval.intervalUnit != 'y') { - // if the unit of time window value is millisecond, change the value from microsecond - if (tinfo.precision == TSDB_TIME_PRECISION_MILLI) { - pQueryInfo->interval.interval = pQueryInfo->interval.interval / 1000; - } // interval cannot be less than 10 milliseconds - if (pQueryInfo->interval.interval < tsMinIntervalTime) { + if (convertTimePrecision(pQueryInfo->interval.interval, tinfo.precision, TSDB_TIME_PRECISION_MILLI) < tsMinIntervalTime) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); } } @@ -919,6 +916,8 @@ int32_t validateSessionNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode * pS const char* msg3 = "invalid column name"; const char* msg4 = "invalid time window"; + STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); + STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta); // no session window if (!TPARSER_HAS_TOKEN(pSqlNode->sessionVal.gap)) { return TSDB_CODE_SUCCESS; @@ -928,7 +927,7 @@ int32_t validateSessionNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode * pS SStrToken* gap = &pSqlNode->sessionVal.gap; char timeUnit = 0; - if (parseNatualDuration(gap->z, gap->n, &pQueryInfo->sessionWindow.gap, &timeUnit) != TSDB_CODE_SUCCESS) { + if (parseNatualDuration(gap->z, gap->n, &pQueryInfo->sessionWindow.gap, &timeUnit, tinfo.precision) != TSDB_CODE_SUCCESS) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); } @@ -936,13 +935,6 @@ int32_t validateSessionNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode * pS return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } - // if the unit of time window value is millisecond, change the value from microsecond - STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta); - if (tinfo.precision == TSDB_TIME_PRECISION_MILLI) { - pQueryInfo->sessionWindow.gap = pQueryInfo->sessionWindow.gap / 1000; - } - if (pQueryInfo->sessionWindow.gap != 0 && pQueryInfo->interval.interval != 0) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); } @@ -979,7 +971,8 @@ int32_t parseIntervalOffset(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SStrToken* of return TSDB_CODE_SUCCESS; } - if (parseNatualDuration(t->z, t->n, &pQueryInfo->interval.offset, &pQueryInfo->interval.offsetUnit) != TSDB_CODE_SUCCESS) { + if (parseNatualDuration(t->z, t->n, &pQueryInfo->interval.offset, + &pQueryInfo->interval.offsetUnit, tinfo.precision) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_OPERATION; } @@ -988,10 +981,6 @@ int32_t parseIntervalOffset(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SStrToken* of } if (pQueryInfo->interval.offsetUnit != 'n' && pQueryInfo->interval.offsetUnit != 'y') { - // if the unit of time window value is millisecond, change the value from microsecond - if (tinfo.precision == TSDB_TIME_PRECISION_MILLI) { - pQueryInfo->interval.offset = pQueryInfo->interval.offset / 1000; - } if (pQueryInfo->interval.intervalUnit != 'n' && pQueryInfo->interval.intervalUnit != 'y') { if (pQueryInfo->interval.offset >= pQueryInfo->interval.interval) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); @@ -1036,12 +1025,10 @@ int32_t parseSlidingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SStrToken* pSl return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); } - parseAbsoluteDuration(pSliding->z, pSliding->n, &pQueryInfo->interval.sliding); - if (tinfo.precision == TSDB_TIME_PRECISION_MILLI) { - pQueryInfo->interval.sliding /= 1000; - } + parseAbsoluteDuration(pSliding->z, pSliding->n, &pQueryInfo->interval.sliding, tinfo.precision); - if (pQueryInfo->interval.sliding < tsMinSlidingTime) { + if (pQueryInfo->interval.sliding < + convertTimePrecision(tsMinSlidingTime, TSDB_TIME_PRECISION_MILLI, tinfo.precision)) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg0); } @@ -3189,8 +3176,9 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, return retVal; } } else if ((colType == TSDB_DATA_TYPE_TIMESTAMP) && (TSDB_DATA_TYPE_BIGINT == pRight->value.nType)) { - if ((timePrecision == TSDB_TIME_PRECISION_MILLI) && (pRight->flags & (1 << EXPR_FLAG_US_TIMESTAMP))) { - pRight->value.i64 /= 1000; + if (pRight->flags & (1 << EXPR_FLAG_NS_TIMESTAMP)) { + pRight->value.i64 = + convertTimePrecision(pRight->value.i64, TSDB_TIME_PRECISION_NANO, timePrecision); } } @@ -4707,7 +4695,7 @@ int32_t getTimeRange(STimeWindow* win, tSqlExpr* pRight, int32_t optr, int16_t t char* seg = strnchr(pRight->value.pz, '-', pRight->value.nLen, false); if (seg != NULL) { - if (taosParseTime(pRight->value.pz, &val, pRight->value.nLen, TSDB_TIME_PRECISION_MICRO, tsDaylight) == TSDB_CODE_SUCCESS) { + if (taosParseTime(pRight->value.pz, &val, pRight->value.nLen, timePrecision, tsDaylight) == TSDB_CODE_SUCCESS) { parsed = true; } else { return TSDB_CODE_TSC_INVALID_OPERATION; @@ -4720,18 +4708,6 @@ int32_t getTimeRange(STimeWindow* win, tSqlExpr* pRight, int32_t optr, int16_t t return TSDB_CODE_TSC_INVALID_OPERATION; } } - } else if (pRight->tokenId == TK_INTEGER && timePrecision == TSDB_TIME_PRECISION_MILLI) { - /* - * if the pRight->tokenId == TK_INTEGER/TK_FLOAT, the value is adaptive, we - * need the time precision in metermeta to transfer the value in MICROSECOND - * - * Additional check to avoid data overflow - */ - if (pRight->value.i64 <= INT64_MAX / 1000) { - pRight->value.i64 *= 1000; - } - } else if (pRight->tokenId == TK_FLOAT && timePrecision == TSDB_TIME_PRECISION_MILLI) { - pRight->value.dKey *= 1000; } if (!parsed) { @@ -4739,33 +4715,19 @@ int32_t getTimeRange(STimeWindow* win, tSqlExpr* pRight, int32_t optr, int16_t t * failed to parse timestamp in regular formation, try next * it may be a epoch time in string format */ - tVariantDump(&pRight->value, (char*)&val, TSDB_DATA_TYPE_BIGINT, true); - - /* - * transfer it into MICROSECOND format if it is a string, since for - * TK_INTEGER/TK_FLOAT the value has been transferred - * - * additional check to avoid data overflow - */ - if (pRight->tokenId == TK_STRING && timePrecision == TSDB_TIME_PRECISION_MILLI) { - if (val <= INT64_MAX / 1000) { - val *= 1000; - } + if (pRight->flags & (1 << EXPR_FLAG_NS_TIMESTAMP)) { + pRight->value.i64 = convertTimePrecision(pRight->value.i64, TSDB_TIME_PRECISION_NANO, timePrecision); } - } - - int32_t delta = 1; - /* for millisecond, delta is 1ms=1000us */ - if (timePrecision == TSDB_TIME_PRECISION_MILLI) { - delta *= 1000; + + tVariantDump(&pRight->value, (char*)&val, TSDB_DATA_TYPE_BIGINT, true); } if (optr == TK_LE) { win->ekey = val; } else if (optr == TK_LT) { - win->ekey = val - delta; + win->ekey = val - 1; } else if (optr == TK_GT) { - win->skey = val + delta; + win->skey = val + 1; } else if (optr == TK_GE) { win->skey = val; } else if (optr == TK_EQ) { @@ -5488,8 +5450,10 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { int32_t validateSqlFunctionInStreamSql(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) { const char* msg0 = "sample interval can not be less than 10ms."; const char* msg1 = "functions not allowed in select clause"; - - if (pQueryInfo->interval.interval != 0 && pQueryInfo->interval.interval < 10 && + STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); + STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta); + if (pQueryInfo->interval.interval != 0 && + convertTimePrecision(pQueryInfo->interval.interval, tinfo.precision, TSDB_TIME_PRECISION_MILLI)< 10 && pQueryInfo->interval.intervalUnit != 'n' && pQueryInfo->interval.intervalUnit != 'y') { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg0); @@ -5882,11 +5846,15 @@ static int32_t setTimePrecision(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDbInfo } else if (strncmp(pToken->z, TSDB_TIME_PRECISION_MICRO_STR, pToken->n) == 0 && strlen(TSDB_TIME_PRECISION_MICRO_STR) == pToken->n) { pMsg->precision = TSDB_TIME_PRECISION_MICRO; + } else if (strncmp(pToken->z, TSDB_TIME_PRECISION_NANO_STR, pToken->n) == 0 && + strlen(TSDB_TIME_PRECISION_NANO_STR) == pToken->n) { + pMsg->precision = TSDB_TIME_PRECISION_NANO; } else { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg); } } + return TSDB_CODE_SUCCESS; } @@ -6514,9 +6482,10 @@ int32_t tscCheckCreateDbParams(SSqlCmd* pCmd, SCreateDbMsg* pCreate) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg); } - if (pCreate->precision != TSDB_TIME_PRECISION_MILLI && pCreate->precision != TSDB_TIME_PRECISION_MICRO) { - snprintf(msg, tListLen(msg), "invalid db option timePrecision: %d valid value: [%d, %d]", pCreate->precision, - TSDB_TIME_PRECISION_MILLI, TSDB_TIME_PRECISION_MICRO); + if (pCreate->precision != TSDB_TIME_PRECISION_MILLI && pCreate->precision != TSDB_TIME_PRECISION_MICRO && + pCreate->precision != TSDB_TIME_PRECISION_NANO) { + snprintf(msg, tListLen(msg), "invalid db option timePrecision: %d valid value: [%d, %d, %d]", pCreate->precision, + TSDB_TIME_PRECISION_MILLI, TSDB_TIME_PRECISION_MICRO, TSDB_TIME_PRECISION_NANO); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg); } @@ -7640,12 +7609,6 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf if (validateWhereNode(pQueryInfo, &pSqlNode->pWhere, pSql) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_OPERATION; } - - STableMeta* pTableMeta = tscGetMetaInfo(pQueryInfo, 0)->pTableMeta; - if (pTableMeta->tableInfo.precision == TSDB_TIME_PRECISION_MILLI) { - pQueryInfo->window.skey = pQueryInfo->window.skey / 1000; - pQueryInfo->window.ekey = pQueryInfo->window.ekey / 1000; - } } // validate the interval info @@ -7696,18 +7659,12 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf } // set where info - STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta); - if (pSqlNode->pWhere != NULL) { if (validateWhereNode(pQueryInfo, &pSqlNode->pWhere, pSql) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_OPERATION; } pSqlNode->pWhere = NULL; - if (tinfo.precision == TSDB_TIME_PRECISION_MILLI) { - pQueryInfo->window.skey = pQueryInfo->window.skey / 1000; - pQueryInfo->window.ekey = pQueryInfo->window.ekey / 1000; - } } else { if (taosArrayGetSize(pSqlNode->from->list) > 1) { // Cross join not allowed yet return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), "cross join not supported yet"); diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index 9b13cd2140..d51a277ffe 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -53,9 +53,7 @@ static int64_t tscGetRetryDelayTime(SSqlStream* pStream, int64_t slidingTime, in if (pStream->interval.intervalUnit != 'n' && pStream->interval.intervalUnit != 'y') { // change to ms - if (prec == TSDB_TIME_PRECISION_MICRO) { - slidingTime = slidingTime / 1000; - } + slidingTime = convertTimePrecision(slidingTime, pStream->precision, TSDB_TIME_PRECISION_MILLI); if (slidingTime < retryDelta) { return slidingTime; @@ -157,11 +155,7 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) { pQueryInfo->window.skey = pStream->stime; int64_t etime = taosGetTimestamp(pStream->precision); // delay to wait all data in last time window - if (pStream->precision == TSDB_TIME_PRECISION_MICRO) { - etime -= tsMaxStreamComputDelay * 1000l; - } else { - etime -= tsMaxStreamComputDelay; - } + etime -= convertTimePrecision(tsMaxStreamComputDelay, TSDB_TIME_PRECISION_MILLI, pStream->precision); if (etime > pStream->etime) { etime = pStream->etime; } else if (pStream->interval.intervalUnit != 'y' && pStream->interval.intervalUnit != 'n') { @@ -178,8 +172,8 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) { int64_t timer = pStream->interval.sliding; if (pStream->interval.intervalUnit == 'y' || pStream->interval.intervalUnit == 'n') { timer = 86400 * 1000l; - } else if (pStream->precision == TSDB_TIME_PRECISION_MICRO) { - timer /= 1000l; + } else { + timer = convertTimePrecision(timer, pStream->precision, TSDB_TIME_PRECISION_MILLI); } tscSetRetryTimer(pStream, pSql, timer); return; @@ -369,9 +363,8 @@ static void tscSetRetryTimer(SSqlStream *pStream, SSqlObj *pSql, int64_t timer) } static int64_t getLaunchTimeDelay(const SSqlStream* pStream) { - int64_t maxDelay = - (pStream->precision == TSDB_TIME_PRECISION_MICRO) ? tsMaxStreamComputDelay * 1000L : tsMaxStreamComputDelay; - + int64_t maxDelay = convertTimePrecision(tsMaxStreamComputDelay, TSDB_TIME_PRECISION_MILLI, pStream->precision); + int64_t delayDelta = maxDelay; if (pStream->interval.intervalUnit != 'n' && pStream->interval.intervalUnit != 'y') { delayDelta = (int64_t)(pStream->interval.sliding * tsStreamComputDelayRatio); @@ -438,16 +431,14 @@ static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql) { timer += getLaunchTimeDelay(pStream); - if (pStream->precision == TSDB_TIME_PRECISION_MICRO) { - timer = timer / 1000L; - } + timer = convertTimePrecision(timer, pStream->precision, TSDB_TIME_PRECISION_MILLI); tscSetRetryTimer(pStream, pSql, timer); } static int32_t tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) { int64_t minIntervalTime = - (pStream->precision == TSDB_TIME_PRECISION_MICRO) ? tsMinIntervalTime * 1000L : tsMinIntervalTime; + convertTimePrecision(tsMinIntervalTime, TSDB_TIME_PRECISION_MILLI, pStream->precision); SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd); @@ -471,7 +462,7 @@ static int32_t tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) { } int64_t minSlidingTime = - (pStream->precision == TSDB_TIME_PRECISION_MICRO) ? tsMinSlidingTime * 1000L : tsMinSlidingTime; + convertTimePrecision(tsMinSlidingTime, TSDB_TIME_PRECISION_MILLI, pStream->precision); if (pQueryInfo->interval.intervalUnit != 'n' && pQueryInfo->interval.intervalUnit!= 'y' && pQueryInfo->interval.sliding < minSlidingTime) { tscWarn("0x%"PRIx64" stream:%p, original sliding value:%" PRId64 " too small, reset to:%" PRId64, pSql->self, pStream, @@ -539,13 +530,12 @@ static int64_t tscGetLaunchTimestamp(const SSqlStream *pStream) { timer = pStream->stime - now; } - int64_t startDelay = - (pStream->precision == TSDB_TIME_PRECISION_MICRO) ? tsStreamCompStartDelay * 1000L : tsStreamCompStartDelay; - + int64_t startDelay = convertTimePrecision(tsStreamCompStartDelay, TSDB_TIME_PRECISION_MILLI, pStream->precision); + timer += getLaunchTimeDelay(pStream); timer += startDelay; - return (pStream->precision == TSDB_TIME_PRECISION_MICRO) ? timer / 1000L : timer; + return convertTimePrecision(timer, pStream->precision, TSDB_TIME_PRECISION_MILLI); } static void tscCreateStream(void *param, TAOS_RES *res, int code) { diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index d4176fca91..d5fa0a9e09 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -398,7 +398,10 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) { time_t tt; int32_t ms = 0; - if (precision == TSDB_TIME_PRECISION_MICRO) { + if (precision == TSDB_TIME_PRECISION_NANO) { + tt = (time_t)(val / 1000000000); + ms = val % 1000000000; + } else if (precision == TSDB_TIME_PRECISION_MICRO) { tt = (time_t)(val / 1000000); ms = val % 1000000; } else { @@ -419,7 +422,9 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) { #endif if (tt <= 0 && ms < 0) { tt--; - if (precision == TSDB_TIME_PRECISION_MICRO) { + if (precision == TSDB_TIME_PRECISION_NANO) { + ms += 1000000000; + } else if (precision == TSDB_TIME_PRECISION_MICRO) { ms += 1000000; } else { ms += 1000; @@ -427,9 +432,11 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) { } struct tm* ptm = localtime(&tt); - size_t pos = strftime(buf, 32, "%Y-%m-%d %H:%M:%S", ptm); + size_t pos = strftime(buf, 35, "%Y-%m-%d %H:%M:%S", ptm); - if (precision == TSDB_TIME_PRECISION_MICRO) { + if (precision == TSDB_TIME_PRECISION_NANO) { + sprintf(buf + pos, ".%09d", ms); + } else if (precision == TSDB_TIME_PRECISION_MICRO) { sprintf(buf + pos, ".%06d", ms); } else { sprintf(buf + pos, ".%03d", ms); @@ -778,6 +785,8 @@ static int calcColWidth(TAOS_FIELD* field, int precision) { case TSDB_DATA_TYPE_TIMESTAMP: if (args.is_raw_time) { return MAX(14, width); + } if (precision == TSDB_TIME_PRECISION_NANO) { + return MAX(29, width); } else if (precision == TSDB_TIME_PRECISION_MICRO) { return MAX(26, width); // '2020-01-01 00:00:00.000000' } else { diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 6f5d407a73..c52f41ef86 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -1848,7 +1848,9 @@ static void printfQueryMeta() { static char* formatTimestamp(char* buf, int64_t val, int precision) { time_t tt; - if (precision == TSDB_TIME_PRECISION_MICRO) { + if (precision == TSDB_TIME_PRECISION_NANO) { + tt = (time_t)(val / 1000000000); + } else if (precision == TSDB_TIME_PRECISION_MICRO) { tt = (time_t)(val / 1000000); } else { tt = (time_t)(val / 1000); @@ -1869,7 +1871,9 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) { struct tm* ptm = localtime(&tt); size_t pos = strftime(buf, 32, "%Y-%m-%d %H:%M:%S", ptm); - if (precision == TSDB_TIME_PRECISION_MICRO) { + if (precision == TSDB_TIME_PRECISION_NANO) { + sprintf(buf + pos, ".%09d", (int)(val % 1000000000)); + } else if (precision == TSDB_TIME_PRECISION_MICRO) { sprintf(buf + pos, ".%06d", (int)(val % 1000000)); } else { sprintf(buf + pos, ".%03d", (int)(val % 1000)); @@ -6249,9 +6253,11 @@ static void startMultiThreadInsertData(int threads, char* db_name, if (0 != precision[0]) { if (0 == strncasecmp(precision, "ms", 2)) { timePrec = TSDB_TIME_PRECISION_MILLI; - } else if (0 == strncasecmp(precision, "us", 2)) { + } else if (0 == strncasecmp(precision, "us", 2)) { timePrec = TSDB_TIME_PRECISION_MICRO; - } else { + } else if (0 == strncasecmp(precision, "ns", 2)) { + timePrec = TSDB_TIME_PRECISION_NANO; + } else { errorPrint("Not support precision: %s\n", precision); exit(-1); } diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c index b0ac1192bb..ff36256b18 100644 --- a/src/mnode/src/mnodeDb.c +++ b/src/mnode/src/mnodeDb.c @@ -820,8 +820,13 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void #endif pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - char *prec = (pDb->cfg.precision == TSDB_TIME_PRECISION_MILLI) ? TSDB_TIME_PRECISION_MILLI_STR - : TSDB_TIME_PRECISION_MICRO_STR; + char *prec = NULL; + switch (pDb->cfg.precision) { + case TSDB_TIME_PRECISION_MILLI: prec = TSDB_TIME_PRECISION_MILLI_STR; break; + case TSDB_TIME_PRECISION_MICRO: prec = TSDB_TIME_PRECISION_MICRO_STR; break; + case TSDB_TIME_PRECISION_NANO: prec = TSDB_TIME_PRECISION_NANO_STR; break; + default: assert(false); break; + } STR_WITH_SIZE_TO_VARSTR(pWrite, prec, 2); cols++; diff --git a/src/os/inc/osTime.h b/src/os/inc/osTime.h index 4743a8c160..f013a2f7d1 100644 --- a/src/os/inc/osTime.h +++ b/src/os/inc/osTime.h @@ -55,6 +55,13 @@ static FORCE_INLINE int64_t taosGetTimestampUs() { return (int64_t)systemTime.tv_sec * 1000000L + (int64_t)systemTime.tv_usec; } +//@return timestamp in nanosecond +static FORCE_INLINE int64_t taosGetTimestampNs() { + struct timespec systemTime = {0}; + clock_gettime(CLOCK_REALTIME, &systemTime); + return (int64_t)systemTime.tv_sec * 1000000000L + (int64_t)systemTime.tv_nsec; +} + /* * @return timestamp decided by global conf variable, tsTimePrecision * if precision == TSDB_TIME_PRECISION_MICRO, it returns timestamp in microsecond. @@ -63,7 +70,9 @@ static FORCE_INLINE int64_t taosGetTimestampUs() { static FORCE_INLINE int64_t taosGetTimestamp(int32_t precision) { if (precision == TSDB_TIME_PRECISION_MICRO) { return taosGetTimestampUs(); - } else { + } else if (precision == TSDB_TIME_PRECISION_NANO) { + return taosGetTimestampNs(); + }else { return taosGetTimestampMs(); } } @@ -88,12 +97,13 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision); int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precision); int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char unit, int32_t precision); -int32_t parseAbsoluteDuration(char* token, int32_t tokenlen, int64_t* ts); -int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* duration, char* unit); +int32_t parseAbsoluteDuration(char* token, int32_t tokenlen, int64_t* ts, int32_t timePrecision); +int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* duration, char* unit, int32_t timePrecision); int32_t taosParseTime(char* timestr, int64_t* time, int32_t len, int32_t timePrec, int8_t dayligth); void deltaToUtcInitOnce(); +int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision); #ifdef __cplusplus } #endif diff --git a/src/os/src/detail/osTime.c b/src/os/src/detail/osTime.c index 67e0c2642e..73122dc666 100644 --- a/src/os/src/detail/osTime.c +++ b/src/os/src/detail/osTime.c @@ -14,7 +14,13 @@ */ #define _BSD_SOURCE + +#ifdef DARWIN #define _XOPEN_SOURCE +#else +#define _XOPEN_SOURCE 500 +#endif + #define _DEFAULT_SOURCE #include "os.h" @@ -119,8 +125,9 @@ int64_t parseFraction(char* str, char** end, int32_t timePrec) { const int32_t MILLI_SEC_FRACTION_LEN = 3; const int32_t MICRO_SEC_FRACTION_LEN = 6; + const int32_t NANO_SEC_FRACTION_LEN = 9; - int32_t factor[6] = {1, 10, 100, 1000, 10000, 100000}; + int32_t factor[9] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000}; int32_t times = 1; while (str[i] >= '0' && str[i] <= '9') { @@ -140,12 +147,17 @@ int64_t parseFraction(char* str, char** end, int32_t timePrec) { } times = MILLI_SEC_FRACTION_LEN - i; - } else { - assert(timePrec == TSDB_TIME_PRECISION_MICRO); + } else if (timePrec == TSDB_TIME_PRECISION_MICRO) { if (i >= MICRO_SEC_FRACTION_LEN) { i = MICRO_SEC_FRACTION_LEN; } times = MICRO_SEC_FRACTION_LEN - i; + } else { + assert(timePrec == TSDB_TIME_PRECISION_NANO); + if (i >= NANO_SEC_FRACTION_LEN) { + i = NANO_SEC_FRACTION_LEN; + } + times = NANO_SEC_FRACTION_LEN - i; } fraction = strnatoi(str, i) * factor[times]; @@ -202,7 +214,9 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) { * 2013-04-12T15:52:01.123+0800 */ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec) { - int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : 1000000; + + int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : + (timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000); int64_t tzOffset = 0; struct tm tm = {0}; @@ -287,7 +301,8 @@ int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec) { } } - int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : 1000000; + int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : + (timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000); *time = factor * seconds + fraction; return 0; @@ -315,37 +330,50 @@ int32_t parseLocaltimeWithDst(char* timestr, int64_t* time, int32_t timePrec) { } } - int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : 1000000; + int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : + (timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000); *time = factor * seconds + fraction; return 0; } - -static int32_t getDurationInUs(int64_t val, char unit, int64_t* result) { - *result = val; - - int64_t factor = 1000L; +int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision) { + assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || + fromPrecision == TSDB_TIME_PRECISION_MICRO || + fromPrecision == TSDB_TIME_PRECISION_NANO); + assert(toPrecision == TSDB_TIME_PRECISION_MILLI || + toPrecision == TSDB_TIME_PRECISION_MICRO || + toPrecision == TSDB_TIME_PRECISION_NANO); + static double factors[3][3] = { {1., 1000., 1000000.}, + {1.0 / 1000, 1., 1000.}, + {1.0 / 1000000, 1.0 / 1000, 1.} }; + return (int64_t)((double)time * factors[fromPrecision][toPrecision]); +} +static int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision) { switch (unit) { case 's': - (*result) *= MILLISECOND_PER_SECOND*factor; + (*result) = convertTimePrecision(val * MILLISECOND_PER_SECOND, TSDB_TIME_PRECISION_MILLI, timePrecision); break; case 'm': - (*result) *= MILLISECOND_PER_MINUTE*factor; + (*result) = convertTimePrecision(val * MILLISECOND_PER_MINUTE, TSDB_TIME_PRECISION_MILLI, timePrecision); break; case 'h': - (*result) *= MILLISECOND_PER_HOUR*factor; + (*result) = convertTimePrecision(val * MILLISECOND_PER_HOUR, TSDB_TIME_PRECISION_MILLI, timePrecision); break; case 'd': - (*result) *= MILLISECOND_PER_DAY*factor; + (*result) = convertTimePrecision(val * MILLISECOND_PER_DAY, TSDB_TIME_PRECISION_MILLI, timePrecision); break; case 'w': - (*result) *= MILLISECOND_PER_WEEK*factor; + (*result) = convertTimePrecision(val * MILLISECOND_PER_WEEK, TSDB_TIME_PRECISION_MILLI, timePrecision); break; case 'a': - (*result) *= factor; + (*result) = convertTimePrecision(val, TSDB_TIME_PRECISION_MILLI, timePrecision); break; case 'u': + (*result) = convertTimePrecision(val, TSDB_TIME_PRECISION_MICRO, timePrecision); + break; + case 'b': + (*result) = convertTimePrecision(val, TSDB_TIME_PRECISION_NANO, timePrecision); break; default: { return -1; @@ -357,6 +385,8 @@ static int32_t getDurationInUs(int64_t val, char unit, int64_t* result) { } /* + * b - nanoseconds; + * u - microseconds; * a - Millionseconds * s - Seconds * m - Minutes @@ -366,7 +396,7 @@ static int32_t getDurationInUs(int64_t val, char unit, int64_t* result) { * n - Months (30 days) * y - Years (365 days) */ -int32_t parseAbsoluteDuration(char* token, int32_t tokenlen, int64_t* duration) { +int32_t parseAbsoluteDuration(char* token, int32_t tokenlen, int64_t* duration, int32_t timePrecision) { errno = 0; char* endPtr = NULL; @@ -382,10 +412,10 @@ int32_t parseAbsoluteDuration(char* token, int32_t tokenlen, int64_t* duration) return -1; } - return getDurationInUs(timestamp, unit, duration); + return getDuration(timestamp, unit, duration, timePrecision); } -int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* duration, char* unit) { +int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* duration, char* unit, int32_t timePrecision) { errno = 0; /* get the basic numeric value */ @@ -399,7 +429,7 @@ int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* durati return 0; } - return getDurationInUs(*duration, *unit, duration); + return getDuration(*duration, *unit, duration, timePrecision); } int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) { diff --git a/src/plugins/http/inc/httpJson.h b/src/plugins/http/inc/httpJson.h index 4d182d0132..3595ad926f 100644 --- a/src/plugins/http/inc/httpJson.h +++ b/src/plugins/http/inc/httpJson.h @@ -64,8 +64,8 @@ void httpJsonOriginString(JsonBuf* buf, char* sVal, int32_t len); void httpJsonStringForTransMean(JsonBuf* buf, char* SVal, int32_t maxLen); void httpJsonInt64(JsonBuf* buf, int64_t num); void httpJsonUInt64(JsonBuf* buf, uint64_t num); -void httpJsonTimestamp(JsonBuf* buf, int64_t t, bool us); -void httpJsonUtcTimestamp(JsonBuf* buf, int64_t t, bool us); +void httpJsonTimestamp(JsonBuf* buf, int64_t t, int32_t timePrecision); +void httpJsonUtcTimestamp(JsonBuf* buf, int64_t t, int32_t timePrecision); void httpJsonInt(JsonBuf* buf, int32_t num); void httpJsonUInt(JsonBuf* buf, uint32_t num); void httpJsonFloat(JsonBuf* buf, float num); diff --git a/src/plugins/http/src/httpJson.c b/src/plugins/http/src/httpJson.c index 19166e720f..df4c4fbc63 100644 --- a/src/plugins/http/src/httpJson.c +++ b/src/plugins/http/src/httpJson.c @@ -262,42 +262,92 @@ void httpJsonUInt64(JsonBuf* buf, uint64_t num) { buf->lst += snprintf(buf->lst, MAX_NUM_STR_SZ, "%" PRIu64, num); } -void httpJsonTimestamp(JsonBuf* buf, int64_t t, bool us) { +void httpJsonTimestamp(JsonBuf* buf, int64_t t, int32_t timePrecision) { char ts[35] = {0}; struct tm* ptm; - int32_t precision = 1000; - if (us) { - precision = 1000000; + + int32_t fractionLen; + char* format = NULL; + time_t quot = 0; + long mod = 0; + + switch (timePrecision) { + case TSDB_TIME_PRECISION_MILLI: { + quot = t / 1000; + fractionLen = 5; + format = ".%03" PRId64; + mod = t % 1000; + break; + } + + case TSDB_TIME_PRECISION_MICRO: { + quot = t / 1000000; + fractionLen = 8; + format = ".%06" PRId64; + mod = t % 1000000; + break; + } + + case TSDB_TIME_PRECISION_NANO: { + quot = t / 1000000000; + fractionLen = 11; + format = ".%09" PRId64; + mod = t % 1000000000; + break; + } + + default: + assert(false); } - time_t tt = t / precision; - ptm = localtime(&tt); + ptm = localtime("); int32_t length = (int32_t)strftime(ts, 35, "%Y-%m-%d %H:%M:%S", ptm); - if (us) { - length += snprintf(ts + length, 8, ".%06" PRId64, t % precision); - } else { - length += snprintf(ts + length, 5, ".%03" PRId64, t % precision); - } + length += snprintf(ts + length, fractionLen, format, mod); httpJsonString(buf, ts, length); } -void httpJsonUtcTimestamp(JsonBuf* buf, int64_t t, bool us) { +void httpJsonUtcTimestamp(JsonBuf* buf, int64_t t, int32_t timePrecision) { char ts[40] = {0}; struct tm* ptm; - int32_t precision = 1000; - if (us) { - precision = 1000000; + + int32_t fractionLen; + char* format = NULL; + time_t quot = 0; + long mod = 0; + + switch (timePrecision) { + case TSDB_TIME_PRECISION_MILLI: { + quot = t / 1000; + fractionLen = 5; + format = ".%03" PRId64; + mod = t % 1000; + break; + } + + case TSDB_TIME_PRECISION_MICRO: { + quot = t / 1000000; + fractionLen = 8; + format = ".%06" PRId64; + mod = t % 1000000; + break; + } + + case TSDB_TIME_PRECISION_NANO: { + quot = t / 1000000000; + fractionLen = 11; + format = ".%09" PRId64; + mod = t % 1000000000; + break; + } + + default: + assert(false); } - time_t tt = t / precision; - ptm = localtime(&tt); + ptm = localtime("); int32_t length = (int32_t)strftime(ts, 40, "%Y-%m-%dT%H:%M:%S", ptm); - if (us) { - length += snprintf(ts + length, 8, ".%06" PRId64, t % precision); - } else { - length += snprintf(ts + length, 5, ".%03" PRId64, t % precision); - } + length += snprintf(ts + length, fractionLen, format, mod); length += (int32_t)strftime(ts + length, 40 - length, "%z", ptm); httpJsonString(buf, ts, length); diff --git a/src/plugins/http/src/httpRestJson.c b/src/plugins/http/src/httpRestJson.c index 60c23e603e..47f2d4ff5b 100644 --- a/src/plugins/http/src/httpRestJson.c +++ b/src/plugins/http/src/httpRestJson.c @@ -186,13 +186,11 @@ bool restBuildSqlJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, break; case TSDB_DATA_TYPE_TIMESTAMP: if (timestampFormat == REST_TIMESTAMP_FMT_LOCAL_STRING) { - httpJsonTimestamp(jsonBuf, *((int64_t *)row[i]), - taos_result_precision(result) == TSDB_TIME_PRECISION_MICRO); + httpJsonTimestamp(jsonBuf, *((int64_t *)row[i]), taos_result_precision(result)); } else if (timestampFormat == REST_TIMESTAMP_FMT_TIMESTAMP) { httpJsonInt64(jsonBuf, *((int64_t *)row[i])); } else { - httpJsonUtcTimestamp(jsonBuf, *((int64_t *)row[i]), - taos_result_precision(result) == TSDB_TIME_PRECISION_MICRO); + httpJsonUtcTimestamp(jsonBuf, *((int64_t *)row[i]), taos_result_precision(result)); } break; default: diff --git a/src/query/inc/qSqlparser.h b/src/query/inc/qSqlparser.h index 652191bf0f..c2a4e99b63 100644 --- a/src/query/inc/qSqlparser.h +++ b/src/query/inc/qSqlparser.h @@ -46,7 +46,7 @@ enum SQL_NODE_FROM_TYPE { enum SQL_EXPR_FLAG { EXPR_FLAG_TS_ERROR = 1, - EXPR_FLAG_US_TIMESTAMP = 2, + EXPR_FLAG_NS_TIMESTAMP = 2, EXPR_FLAG_TIMESTAMP_VAR = 3, }; diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 5ac19bba82..d15fd08100 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -130,10 +130,10 @@ static void getNextTimeWindow(SQueryAttr* pQueryAttr, STimeWindow* tw) { return; } - int64_t key = tw->skey / 1000, interval = pQueryAttr->interval.interval; - if (pQueryAttr->precision == TSDB_TIME_PRECISION_MICRO) { - key /= 1000; - } + int64_t key = tw->skey, interval = pQueryAttr->interval.interval; + //convert key to second + key = convertTimePrecision(key, pQueryAttr->precision, TSDB_TIME_PRECISION_MILLI) / 1000; + if (pQueryAttr->interval.intervalUnit == 'y') { interval *= 12; } @@ -145,17 +145,13 @@ static void getNextTimeWindow(SQueryAttr* pQueryAttr, STimeWindow* tw) { int mon = (int)(tm.tm_year * 12 + tm.tm_mon + interval * factor); tm.tm_year = mon / 12; tm.tm_mon = mon % 12; - tw->skey = mktime(&tm) * 1000L; + tw->skey = convertTimePrecision(mktime(&tm) * 1000L, TSDB_TIME_PRECISION_MILLI, pQueryAttr->precision); mon = (int)(mon + interval); tm.tm_year = mon / 12; tm.tm_mon = mon % 12; - tw->ekey = mktime(&tm) * 1000L; + tw->ekey = convertTimePrecision(mktime(&tm) * 1000L, TSDB_TIME_PRECISION_MILLI, pQueryAttr->precision); - if (pQueryAttr->precision == TSDB_TIME_PRECISION_MICRO) { - tw->skey *= 1000L; - tw->ekey *= 1000L; - } tw->ekey -= 1; } diff --git a/src/query/src/qSqlParser.c b/src/query/src/qSqlParser.c index 2cf3463d60..f725c7da2f 100644 --- a/src/query/src/qSqlParser.c +++ b/src/query/src/qSqlParser.c @@ -139,19 +139,20 @@ tSqlExpr *tSqlExprCreateIdValue(SStrToken *pToken, int32_t optrType) { pSqlExpr->tokenId = optrType; pSqlExpr->type = SQL_NODE_VALUE; } else if (optrType == TK_NOW) { - // use microsecond by default - pSqlExpr->value.i64 = taosGetTimestamp(TSDB_TIME_PRECISION_MICRO); + // use nanosecond by default TODO set value after getting database precision + pSqlExpr->value.i64 = taosGetTimestamp(TSDB_TIME_PRECISION_NANO); pSqlExpr->value.nType = TSDB_DATA_TYPE_BIGINT; pSqlExpr->tokenId = TK_TIMESTAMP; // TK_TIMESTAMP used to denote the time value is in microsecond pSqlExpr->type = SQL_NODE_VALUE; - pSqlExpr->flags |= 1 << EXPR_FLAG_US_TIMESTAMP; + pSqlExpr->flags |= 1 << EXPR_FLAG_NS_TIMESTAMP; } else if (optrType == TK_VARIABLE) { - int32_t ret = parseAbsoluteDuration(pToken->z, pToken->n, &pSqlExpr->value.i64); + // use nanosecond by default TODO set value after getting database precision + int32_t ret = parseAbsoluteDuration(pToken->z, pToken->n, &pSqlExpr->value.i64, TSDB_TIME_PRECISION_NANO); if (ret != TSDB_CODE_SUCCESS) { terrno = TSDB_CODE_TSC_SQL_SYNTAX_ERROR; } - pSqlExpr->flags |= 1 << EXPR_FLAG_US_TIMESTAMP; + pSqlExpr->flags |= 1 << EXPR_FLAG_NS_TIMESTAMP; pSqlExpr->flags |= 1 << EXPR_FLAG_TIMESTAMP_VAR; pSqlExpr->value.nType = TSDB_DATA_TYPE_BIGINT; pSqlExpr->tokenId = TK_TIMESTAMP; diff --git a/src/util/src/ttokenizer.c b/src/util/src/ttokenizer.c index 7026fcda0f..3ab2aca67f 100644 --- a/src/util/src/ttokenizer.c +++ b/src/util/src/ttokenizer.c @@ -494,9 +494,9 @@ uint32_t tGetToken(char* z, uint32_t* tokenId) { } /* here is the 1u/1a/2s/3m/9y */ - if ((z[i] == 'u' || z[i] == 'a' || z[i] == 's' || z[i] == 'm' || z[i] == 'h' || z[i] == 'd' || z[i] == 'n' || + if ((z[i] == 'b' || z[i] == 'u' || z[i] == 'a' || z[i] == 's' || z[i] == 'm' || z[i] == 'h' || z[i] == 'd' || z[i] == 'n' || z[i] == 'y' || z[i] == 'w' || - z[i] == 'U' || z[i] == 'A' || z[i] == 'S' || z[i] == 'M' || z[i] == 'H' || z[i] == 'D' || z[i] == 'N' || + z[i] == 'B' || z[i] == 'U' || z[i] == 'A' || z[i] == 'S' || z[i] == 'M' || z[i] == 'H' || z[i] == 'D' || z[i] == 'N' || z[i] == 'Y' || z[i] == 'W') && (isIdChar[(uint8_t)z[i + 1]] == 0)) { *tokenId = TK_VARIABLE; From 54c58e85c790969f8c509603f4294b5587f8eb33 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Fri, 4 Jun 2021 18:39:05 +0800 Subject: [PATCH 14/72] fix bug --- src/util/src/tutil.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/src/tutil.c b/src/util/src/tutil.c index 70285eb3cc..bda52936f9 100644 --- a/src/util/src/tutil.c +++ b/src/util/src/tutil.c @@ -56,6 +56,9 @@ int32_t strdequote(char *z) { int32_t strRmquote(char *z, int32_t len){ // delete escape character: \\, \', \" char delim = z[0]; + if (delim != '\'' && delim != '\"') { + return len; + } int32_t cnt = 0; int32_t j = 0; From 9596883fd1c4cd454c1a0832272ac7b6b07a70a5 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Sat, 5 Jun 2021 01:37:39 +0000 Subject: [PATCH 15/72] fix install py connector in jenkins --- tests/mas/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mas/Jenkinsfile b/tests/mas/Jenkinsfile index 0e6e94a037..ae2286298f 100644 --- a/tests/mas/Jenkinsfile +++ b/tests/mas/Jenkinsfile @@ -21,7 +21,7 @@ def pre_test(){ cmake .. > /dev/null make > /dev/null make install > /dev/null - pip3 install ${WKC}/src/connector/python/linux/python3/ + pip3 install ${WKC}/src/connector/python/ || echo 0 ''' return 1 } From 70298585549442cda0dd9cd53278fe5408736021 Mon Sep 17 00:00:00 2001 From: tickduan <417921451@qq.com> Date: Sat, 5 Jun 2021 10:40:46 +0800 Subject: [PATCH 16/72] fix kill connection with _root user cause taosd crash --- src/client/src/tscProfile.c | 13 ++++--------- src/client/src/tscStream.c | 4 ++++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/client/src/tscProfile.c b/src/client/src/tscProfile.c index ea2a3d8228..7870ca7976 100644 --- a/src/client/src/tscProfile.c +++ b/src/client/src/tscProfile.c @@ -295,23 +295,18 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) { } void tscKillConnection(STscObj *pObj) { + // get stream header by locked pthread_mutex_lock(&pObj->mutex); - - SSqlObj *pSql = pObj->sqlList; - while (pSql) { - pSql = pSql->next; - } - - SSqlStream *pStream = pObj->streamList; + pthread_mutex_unlock(&pObj->mutex); + while (pStream) { SSqlStream *tmp = pStream->next; + // taos_close_stream function call pObj->mutet lock , careful death-lock taos_close_stream(pStream); pStream = tmp; } - pthread_mutex_unlock(&pObj->mutex); - tscDebug("connection:%p is killed", pObj); taos_close(pObj); } diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index b60824b2fa..3fd727a745 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -141,6 +141,10 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) { pStream->numOfRes = 0; // reset the numOfRes. SSqlObj *pSql = pStream->pSql; + // pSql == NULL maybe killStream already called + if(pSql == NULL) { + return ; + } SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); tscDebug("0x%"PRIx64" add into timer", pSql->self); From e66d12967af0f85fcc361f9aa0f1b96b7c76c064 Mon Sep 17 00:00:00 2001 From: xywang Date: Sat, 5 Jun 2021 14:39:50 +0800 Subject: [PATCH 17/72] [TD-3304]: added detailed info for invalid blocks option --- src/client/src/tscSQLParser.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index baa1538297..2c767d82b9 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -6486,6 +6486,13 @@ int32_t tscCheckCreateDbParams(SSqlCmd* pCmd, SCreateDbMsg* pCreate) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg); } + int32_t blocks = ntohl(pCreate->totalBlocks); + if (blocks != -1 && (blocks < TSDB_MIN_TOTAL_BLOCKS || blocks > TSDB_MAX_TOTAL_BLOCKS)) { + snprintf(msg, tListLen(msg), "invalid db option totalBlocks: %d valid range: [%d, %d]", blocks, + TSDB_MIN_TOTAL_BLOCKS, TSDB_MAX_TOTAL_BLOCKS); + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg); + } + if (pCreate->quorum != -1 && (pCreate->quorum < TSDB_MIN_DB_QUORUM_OPTION || pCreate->quorum > TSDB_MAX_DB_QUORUM_OPTION)) { snprintf(msg, tListLen(msg), "invalid db option quorum: %d valid range: [%d, %d]", pCreate->quorum, From 51ecfc0486ccde553cf16791c63cee18aa853e18 Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Sat, 5 Jun 2021 14:24:56 +0800 Subject: [PATCH 18/72] [TD-3938]: add test case --- tests/pytest/cluster/clusterSetup.py | 70 +++++++++++++++++++++------- 1 file changed, 53 insertions(+), 17 deletions(-) diff --git a/tests/pytest/cluster/clusterSetup.py b/tests/pytest/cluster/clusterSetup.py index 8a26427021..692a8b237e 100644 --- a/tests/pytest/cluster/clusterSetup.py +++ b/tests/pytest/cluster/clusterSetup.py @@ -15,6 +15,7 @@ from fabric import Connection import random import time import logging +import os class Node: def __init__(self, index, username, hostIP, hostName, password, homeDir): @@ -23,7 +24,8 @@ class Node: self.hostIP = hostIP self.hostName = hostName self.homeDir = homeDir - self.conn = Connection("{}@{}".format(username, hostName), connect_kwargs={"password": "{}".format(password)}) + self.corePath = '/coredump' + self.conn = Connection("{}@{}".format(username, hostName), connect_kwargs={"password": "{}".format(password)}) def buildTaosd(self): try: @@ -126,21 +128,37 @@ class Node: except Exception as e: print("remove taosd error for node %d " % self.index) logging.exception(e) + + + def detectCoredumpFile(self): + try: + result = self.conn.run("find /coredump -name 'core_*' ", hide=True) + output = result.stdout + print("output: %s" % output) + return output + except Exception as e: + print("find coredump file error on node %d " % self.index) + logging.exception(e) + class Nodes: def __init__(self): self.tdnodes = [] - self.tdnodes.append(Node(0, 'root', '52.143.103.7', 'node1', 'a', '/root/')) - self.tdnodes.append(Node(1, 'root', '52.250.48.222', 'node2', 'a', '/root/')) - self.tdnodes.append(Node(2, 'root', '51.141.167.23', 'node3', 'a', '/root/')) - self.tdnodes.append(Node(3, 'root', '52.247.207.173', 'node4', 'a', '/root/')) - self.tdnodes.append(Node(4, 'root', '51.141.166.100', 'node5', 'a', '/root/')) + self.tdnodes.append(Node(0, 'root', '192.168.17.194', 'taosdata', 'r', '/root/')) + # self.tdnodes.append(Node(1, 'root', '52.250.48.222', 'node2', 'a', '/root/')) + # self.tdnodes.append(Node(2, 'root', '51.141.167.23', 'node3', 'a', '/root/')) + # self.tdnodes.append(Node(3, 'root', '52.247.207.173', 'node4', 'a', '/root/')) + # self.tdnodes.append(Node(4, 'root', '51.141.166.100', 'node5', 'a', '/root/')) def stopOneNode(self, index): + self.tdnodes[index].stopTaosd() self.tdnodes[index].forceStopOneTaosd() def startOneNode(self, index): self.tdnodes[index].startOneTaosd() + + def detectCoredumpFile(self, index): + return self.tdnodes[index].detectCoredumpFile() def stopAllTaosd(self): for i in range(len(self.tdnodes)): @@ -166,14 +184,32 @@ class Nodes: for i in range(len(self.tdnodes)): self.tdnodes[i].removeData() -# kill taosd randomly every 10 mins -nodes = Nodes() -loop = 0 -while True: - loop = loop + 1 - index = random.randint(0, 4) - print("loop: %d, kill taosd on node%d" %(loop, index)) - nodes.stopOneNode(index) - time.sleep(60) - nodes.startOneNode(index) - time.sleep(600) \ No newline at end of file +class Test: + def __init__(self): + self.nodes = Nodes() + + # kill taosd randomly every 10 mins + def randomlyKillDnode(self): + loop = 0 + while True: + index = random.randint(0, 4) + print("loop: %d, kill taosd on node%d" %(loop, index)) + self.nodes.stopOneNode(index) + time.sleep(60) + self.nodes.startOneNode(index) + time.sleep(600) + loop = loop + 1 + + def detectCoredump(self): + loop = 0 + while True: + for i in range(len(self.nodes.tdnodes)): + result = self.nodes.detectCoredumpFile(i) + print("core file path is %s" % result) + if result and not result.isspace(): + self.nodes.stopAllTaosd() + print("sleep for 10 mins") + time.sleep(600) + +test = Test() +test.detectCoredump() \ No newline at end of file From d2c1841410410ee7d6d508793a50e3ac48afc783 Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Sat, 5 Jun 2021 15:43:05 +0800 Subject: [PATCH 19/72] [TD-3938]: add script to detect coredump file --- tests/pytest/cluster/clusterSetup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/pytest/cluster/clusterSetup.py b/tests/pytest/cluster/clusterSetup.py index 692a8b237e..87414303f8 100644 --- a/tests/pytest/cluster/clusterSetup.py +++ b/tests/pytest/cluster/clusterSetup.py @@ -15,7 +15,6 @@ from fabric import Connection import random import time import logging -import os class Node: def __init__(self, index, username, hostIP, hostName, password, homeDir): From 91e2d73361545b9287714a833ebb33c4ac520a45 Mon Sep 17 00:00:00 2001 From: xywang Date: Sat, 5 Jun 2021 16:58:36 +0800 Subject: [PATCH 20/72] [TD-3304]: fixed a test case bug --- tests/script/general/db/alter_option.sim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/script/general/db/alter_option.sim b/tests/script/general/db/alter_option.sim index c3bb23855f..bd68ddd859 100644 --- a/tests/script/general/db/alter_option.sim +++ b/tests/script/general/db/alter_option.sim @@ -177,7 +177,7 @@ sql alter database db blocks 20 sql alter database db blocks 10 sql_error alter database db blocks 2 sql_error alter database db blocks 1 -sql alter database db blocks 0 +sql_error alter database db blocks 0 sql_error alter database db blocks -1 sql_error alter database db blocks 10001 From 354564dbc98e69a55852860f1512f4d13518d135 Mon Sep 17 00:00:00 2001 From: xywang Date: Sat, 5 Jun 2021 17:58:28 +0800 Subject: [PATCH 21/72] [TD-3304]: fixed a test case bug in topic1.sim --- tests/script/general/db/topic1.sim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/script/general/db/topic1.sim b/tests/script/general/db/topic1.sim index 2b4cce5e64..63cae8dffd 100644 --- a/tests/script/general/db/topic1.sim +++ b/tests/script/general/db/topic1.sim @@ -455,7 +455,7 @@ sql alter database db blocks 20 sql alter database db blocks 10 sql_error alter database db blocks 2 sql_error alter database db blocks 1 -sql alter database db blocks 0 +sql_error alter database db blocks 0 sql_error alter database db blocks -1 sql_error alter database db blocks 10001 From 6052797c56f67d4e55363f8c897cdc3a4587b9e3 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Mon, 7 Jun 2021 08:54:07 +0800 Subject: [PATCH 22/72] fix bug --- src/client/src/tscSQLParser.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 363bb41085..4a9b0ac815 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -314,7 +314,9 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { } } else if (pInfo->type == TSDB_SQL_DROP_DNODE) { - pzName->n = strdequote(pzName->z); + if (pzName->type == TK_STRING) { + pzName->n = strdequote(pzName->z); + } strncpy(pCmd->payload, pzName->z, pzName->n); } else { // drop user/account if (pzName->n >= TSDB_USER_LEN) { @@ -392,7 +394,9 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { } SStrToken* id = taosArrayGet(pInfo->pMiscInfo->a, 0); - id->n = strdequote(id->z); + if (id->type == TK_STRING) { + id->n = strdequote(id->z); + } break; } From 47f85222d4c4ab01bfe1a37c84ea2c51eb62892b Mon Sep 17 00:00:00 2001 From: tickduan <417921451@qq.com> Date: Mon, 7 Jun 2021 09:28:14 +0800 Subject: [PATCH 23/72] after kill client connection in taosd can not create stream normally --- src/client/inc/tsclient.h | 1 + src/client/src/tscProfile.c | 16 ++++++++++++++++ src/client/src/tscStream.c | 5 +++-- src/cq/src/cqMain.c | 20 +++----------------- src/inc/tcq.h | 17 +++++++++++++++++ 5 files changed, 40 insertions(+), 19 deletions(-) diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 0e63fa3551..6e273df38f 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -405,6 +405,7 @@ typedef struct SSqlObj { typedef struct SSqlStream { SSqlObj *pSql; + void * cqhandle; // stream belong to SCQContext handle const char* dstTable; uint32_t streamId; char listed; diff --git a/src/client/src/tscProfile.c b/src/client/src/tscProfile.c index 7870ca7976..5b2198be62 100644 --- a/src/client/src/tscProfile.c +++ b/src/client/src/tscProfile.c @@ -19,6 +19,7 @@ #include "ttimer.h" #include "tutil.h" #include "taosmsg.h" +#include "tcq.h" #include "taos.h" @@ -294,6 +295,18 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) { return msgLen; } +// cqContext->dbconn is killed then call this callback +void cqConnKilledNotify(void* handle, void* conn) { + if (handle == NULL || conn == NULL){ + return ; + } + + SCqContext* pContext = (SCqContext*) handle; + if (pContext->dbConn == conn){ + atomic_store_ptr(&(pContext->dbConn), NULL); + } +} + void tscKillConnection(STscObj *pObj) { // get stream header by locked pthread_mutex_lock(&pObj->mutex); @@ -302,6 +315,8 @@ void tscKillConnection(STscObj *pObj) { while (pStream) { SSqlStream *tmp = pStream->next; + // set associate variant to NULL + cqConnKilledNotify(pStream->cqhandle, pObj); // taos_close_stream function call pObj->mutet lock , careful death-lock taos_close_stream(pStream); pStream = tmp; @@ -310,3 +325,4 @@ void tscKillConnection(STscObj *pObj) { tscDebug("connection:%p is killed", pObj); taos_close(pObj); } + diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index 3fd727a745..ed024e21ba 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -666,7 +666,7 @@ void cbParseSql(void* param, TAOS_RES* res, int code) { } TAOS_STREAM *taos_open_stream_withname(TAOS *taos, const char* dstTable, const char *sqlstr, void (*fp)(void *param, TAOS_RES *, TAOS_ROW row), - int64_t stime, void *param, void (*callback)(void *)) { + int64_t stime, void *param, void (*callback)(void *), void* cqhandle) { STscObj *pObj = (STscObj *)taos; if (pObj == NULL || pObj->signature != pObj) return NULL; @@ -699,6 +699,7 @@ TAOS_STREAM *taos_open_stream_withname(TAOS *taos, const char* dstTable, const c pStream->callback = callback; pStream->param = param; pStream->pSql = pSql; + pStream->cqhandle = cqhandle; pSql->pStream = pStream; pSql->param = pStream; pSql->maxRetry = TSDB_MAX_REPLICA; @@ -739,7 +740,7 @@ TAOS_STREAM *taos_open_stream_withname(TAOS *taos, const char* dstTable, const c TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *param, TAOS_RES *, TAOS_ROW row), int64_t stime, void *param, void (*callback)(void *)) { - return taos_open_stream_withname(taos, "", sqlstr, fp, stime, param, callback); + return taos_open_stream_withname(taos, "", sqlstr, fp, stime, param, callback, NULL); } void taos_close_stream(TAOS_STREAM *handle) { diff --git a/src/cq/src/cqMain.c b/src/cq/src/cqMain.c index ee4be02b90..f539e77253 100644 --- a/src/cq/src/cqMain.c +++ b/src/cq/src/cqMain.c @@ -38,21 +38,6 @@ #define cDebug(...) { if (cqDebugFlag & DEBUG_DEBUG) { taosPrintLog("CQ ", cqDebugFlag, __VA_ARGS__); }} #define cTrace(...) { if (cqDebugFlag & DEBUG_TRACE) { taosPrintLog("CQ ", cqDebugFlag, __VA_ARGS__); }} -typedef struct { - int32_t vgId; - int32_t master; - int32_t num; // number of continuous streams - char user[TSDB_USER_LEN]; - char pass[TSDB_KEY_LEN]; - char db[TSDB_DB_NAME_LEN]; - FCqWrite cqWrite; - struct SCqObj *pHead; - void *dbConn; - void *tmrCtrl; - pthread_mutex_t mutex; - int32_t delete; - int32_t cqObjNum; -} SCqContext; typedef struct SCqObj { tmr_h tmrId; @@ -439,7 +424,7 @@ static void cqProcessCreateTimer(void *param, void *tmrId) { // inner implement in tscStream.c TAOS_STREAM *taos_open_stream_withname(TAOS *taos, const char* desName, const char *sqlstr, void (*fp)(void *param, TAOS_RES *, TAOS_ROW row), - int64_t stime, void *param, void (*callback)(void *)); + int64_t stime, void *param, void (*callback)(void *), void* cqhandle); static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) { pObj->pContext = pContext; @@ -453,7 +438,8 @@ static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) { pObj->tmrId = 0; if (pObj->pStream == NULL) { - pObj->pStream = taos_open_stream_withname(pContext->dbConn, pObj->dstTable, pObj->sqlStr, cqProcessStreamRes, INT64_MIN, (void *)pObj->rid, NULL); + pObj->pStream = taos_open_stream_withname(pContext->dbConn, pObj->dstTable, pObj->sqlStr, cqProcessStreamRes, \ + INT64_MIN, (void *)pObj->rid, NULL, pContext); // TODO the pObj->pStream may be released if error happens if (pObj->pStream) { diff --git a/src/inc/tcq.h b/src/inc/tcq.h index 552a40665a..7549c3d498 100644 --- a/src/inc/tcq.h +++ b/src/inc/tcq.h @@ -31,6 +31,23 @@ typedef struct { FCqWrite cqWrite; } SCqCfg; +// SCqContext +typedef struct { + int32_t vgId; + int32_t master; + int32_t num; // number of continuous streams + char user[TSDB_USER_LEN]; + char pass[TSDB_KEY_LEN]; + char db[TSDB_DB_NAME_LEN]; + FCqWrite cqWrite; + struct SCqObj *pHead; + void *dbConn; + void *tmrCtrl; + pthread_mutex_t mutex; + int32_t delete; + int32_t cqObjNum; +} SCqContext; + // the following API shall be called by vnode void *cqOpen(void *ahandle, const SCqCfg *pCfg); void cqClose(void *handle); From d7f32149ef4fceee9fbb0278b65beb1f603224d4 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Mon, 7 Jun 2021 09:47:26 +0800 Subject: [PATCH 24/72] [TD-3126]:add nano second precision testcase and modify tsim to support time precision --- tests/script/fullGeneralSuite.sim | 1 + tests/script/general/parser/precision_ns.sim | 113 +++++++++++++++++++ tests/script/general/parser/testSuite.sim | 1 + tests/script/regressionSuite.sim | 1 + tests/tsim/src/simExe.c | 20 +++- 5 files changed, 133 insertions(+), 3 deletions(-) create mode 100644 tests/script/general/parser/precision_ns.sim diff --git a/tests/script/fullGeneralSuite.sim b/tests/script/fullGeneralSuite.sim index 2cd2236200..9372657533 100644 --- a/tests/script/fullGeneralSuite.sim +++ b/tests/script/fullGeneralSuite.sim @@ -135,6 +135,7 @@ run general/parser/tags_dynamically_specifiy.sim run general/parser/set_tag_vals.sim #unsupport run general/parser/repeatAlter.sim #unsupport run general/parser/slimit_alter_tags.sim +run general/parser/precision_ns.sim run general/stable/disk.sim run general/stable/dnode3.sim run general/stable/metrics.sim diff --git a/tests/script/general/parser/precision_ns.sim b/tests/script/general/parser/precision_ns.sim new file mode 100644 index 0000000000..3e9a2dd3ff --- /dev/null +++ b/tests/script/general/parser/precision_ns.sim @@ -0,0 +1,113 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 1000 +sql connect + +$dbPrefix = m_di_db_ns +$tbPrefix = m_di_tb +$mtPrefix = m_di_mt +$ntPrefix = m_di_nt +$tbNum = 2 +$rowNum = 200 +$futureTs = 300000000000 + +print =============== step1: create database and tables and insert data +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$nt = $ntPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db precision 'ns' +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $futureTs + $x * 100 + 43 + $ns = $cc . b + sql insert into $tb values (now + $ns , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql create table $nt (ts timestamp, tbcol int) +$x = 0 +while $x < $rowNum + $cc = $futureTs + $x * 100 + 43 + $ns = $cc . b + sql insert into $nt values (now + $ns , $x ) + $x = $x + 1 +endw + +sleep 100 + +print =============== step2: select count(*) from tables +$i = 0 +$tb = $tbPrefix . $i + +sql select count(*) from $tb + +if $data00 != $rowNum then + print expect $rowNum, actual:$data00 + return -1 +endi + +$i = 0 +$mt = $mtPrefix . $i +sql select count(*) from $mt + +$mtRowNum = $tbNum * $rowNum +if $data00 != $mtRowNum then + print expect $mtRowNum, actual:$data00 + return -1 +endi + +$i = 0 +$nt = $ntPrefix . $i + +sql select count(*) from $nt + +if $data00 != $rowNum then + print expect $rowNum, actual:$data00 + return -1 +endi + +print =============== step3: check nano second timestamp +$i = 0 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql insert into $tb values (now-43b , $x ) +sql select count(*) from $tb where ts Date: Mon, 7 Jun 2021 10:55:35 +0800 Subject: [PATCH 25/72] [TD-4556]add compact flag in STsdbRepo --- src/tsdb/inc/tsdbint.h | 1 + src/tsdb/src/tsdbMain.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/tsdb/inc/tsdbint.h b/src/tsdb/inc/tsdbint.h index 7cf8882631..dd43e39310 100644 --- a/src/tsdb/inc/tsdbint.h +++ b/src/tsdb/inc/tsdbint.h @@ -92,6 +92,7 @@ struct STsdbRepo { pthread_mutex_t mutex; bool repoLocked; int32_t code; // Commit code + bool inCompact; // is in compact process? }; #define REPO_ID(r) (r)->config.tsdbId diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index bb02e01283..85ed0821ac 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -533,6 +533,7 @@ static STsdbRepo *tsdbNewRepo(STsdbCfg *pCfg, STsdbAppH *pAppH) { pRepo->state = TSDB_STATE_OK; pRepo->code = TSDB_CODE_SUCCESS; + pRepo->inCompact = false; pRepo->config = *pCfg; if (pAppH) { pRepo->appH = *pAppH; From ae9c4a48838db6dbc356e5d1d022e8739042f933 Mon Sep 17 00:00:00 2001 From: tickduan <417921451@qq.com> Date: Mon, 7 Jun 2021 13:39:12 +0800 Subject: [PATCH 26/72] fix delay 24 hours bugs --- src/client/src/tscStream.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index ed024e21ba..de2f0087ce 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -340,8 +340,12 @@ static void tscSetRetryTimer(SSqlStream *pStream, SSqlObj *pSql, int64_t timer) if (pStream->isProject) { int64_t now = taosGetTimestamp(pStream->precision); int64_t etime = now > pStream->etime ? pStream->etime : now; - - if (pStream->etime < now && now - pStream->etime > tsMaxRetentWindow) { + int64_t maxRetent = tsMaxRetentWindow * 1000; + if(pStream->precision == TSDB_TIME_PRECISION_MICRO) { + maxRetent *= 1000; + } + + if (pStream->etime < now && now - pStream->etime > maxRetent) { /* * current time window will be closed, since it too early to exceed the maxRetentWindow value */ From d9e1bb8439e6bdd739f735c37bcd87d11fa45c9d Mon Sep 17 00:00:00 2001 From: zyyang Date: Mon, 7 Jun 2021 13:55:35 +0800 Subject: [PATCH 27/72] change --- .../com/taosdata/jdbc/AbstractResultSet.java | 7 +- .../com/taosdata/jdbc/TSDBConnection.java | 14 +- .../com/taosdata/jdbc/TSDBJNIConnector.java | 97 +++- .../taosdata/jdbc/TSDBPreparedStatement.java | 526 +++++++++++++++++- .../taosdata/jdbc/TSDBResultSetBlockData.java | 60 +- .../taosdata/jdbc/TSDBResultSetRowData.java | 5 +- .../java/com/taosdata/jdbc/TSDBStatement.java | 66 +-- .../com/taosdata/jdbc/utils/NullType.java | 91 +++ .../java/com/taosdata/jdbc/utils/Utils.java | 1 + .../jdbc/TSDBPreparedStatementTest.java | 292 ++++++++++ .../com/taosdata/jdbc/TSDBResultSetTest.java | 10 +- .../cases/InsertSpecialCharacterJniTest.java | 1 + 12 files changed, 1035 insertions(+), 135 deletions(-) create mode 100755 src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/NullType.java diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java index 4b5b88d93b..f8ea9af423 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java @@ -84,10 +84,12 @@ public abstract class AbstractResultSet extends WrapperImpl implements ResultSet } @Override + @Deprecated public InputStream getUnicodeStream(int columnIndex) throws SQLException { - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED); - + } + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); } @@ -171,6 +173,7 @@ public abstract class AbstractResultSet extends WrapperImpl implements ResultSet } @Override + @Deprecated public InputStream getUnicodeStream(String columnLabel) throws SQLException { return getUnicodeStream(findColumn(columnLabel)); } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java index c8ab9fb15a..02fee74eb5 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java @@ -49,7 +49,7 @@ public class TSDBConnection extends AbstractConnection { this.databaseMetaData.setConnection(this); } - public TSDBJNIConnector getConnection() { + public TSDBJNIConnector getConnector() { return this.connector; } @@ -58,7 +58,7 @@ public class TSDBConnection extends AbstractConnection { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED); } - return new TSDBStatement(this, this.connector); + return new TSDBStatement(this); } public TSDBSubscribe subscribe(String topic, String sql, boolean restart) throws SQLException { @@ -74,14 +74,18 @@ public class TSDBConnection extends AbstractConnection { } public PreparedStatement prepareStatement(String sql) throws SQLException { - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED); - return new TSDBPreparedStatement(this, this.connector, sql); + } + + return new TSDBPreparedStatement(this, sql); } public void close() throws SQLException { - if (isClosed) + if (isClosed) { return; + } + this.connector.closeConnection(); this.isClosed = true; } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java index 7f0cf7de8d..256e735285 100755 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java @@ -16,12 +16,13 @@ */ package com.taosdata.jdbc; -import com.taosdata.jdbc.utils.TaosInfo; - +import java.nio.ByteBuffer; import java.sql.SQLException; import java.sql.SQLWarning; import java.util.List; +import com.taosdata.jdbc.utils.TaosInfo; + /** * JNI connector */ @@ -29,10 +30,13 @@ public class TSDBJNIConnector { private static volatile Boolean isInitialized = false; private TaosInfo taosInfo = TaosInfo.getInstance(); + // Connection pointer used in C private long taos = TSDBConstants.JNI_NULL_POINTER; + // result set status in current connection private boolean isResultsetClosed; + private int affectedRows = -1; static { @@ -75,7 +79,6 @@ public class TSDBJNIConnector { public boolean connect(String host, int port, String dbName, String user, String password) throws SQLException { if (this.taos != TSDBConstants.JNI_NULL_POINTER) { -// this.closeConnectionImp(this.taos); closeConnection(); this.taos = TSDBConstants.JNI_NULL_POINTER; } @@ -97,12 +100,6 @@ public class TSDBJNIConnector { * @throws SQLException */ public long executeQuery(String sql) throws SQLException { - // close previous result set if the user forgets to invoke the - // free method to close previous result set. -// if (!this.isResultsetClosed) { -// freeResultSet(taosResultSetPointer); -// } - Long pSql = 0l; try { pSql = this.executeQueryImp(sql.getBytes(TaosGlobalConfig.getCharset()), this.taos); @@ -170,7 +167,7 @@ public class TSDBJNIConnector { private native long isUpdateQueryImp(long connection, long pSql); /** - * Free resultset operation from C to release resultset pointer by JNI + * Free result set operation from C to release result set pointer by JNI */ public int freeResultSet(long pSql) { int res = this.freeResultSetImp(this.taos, pSql); @@ -178,19 +175,6 @@ public class TSDBJNIConnector { return res; } - /** - * Close the open result set which is associated to the current connection. If the result set is already - * closed, return 0 for success. - */ -// public int freeResultSet() { -// int resCode = TSDBConstants.JNI_SUCCESS; -// if (!isResultsetClosed) { -// resCode = this.freeResultSetImp(this.taos, this.taosResultSetPointer); -// taosResultSetPointer = TSDBConstants.JNI_NULL_POINTER; -// isResultsetClosed = true; -// } -// return resCode; -// } private native int freeResultSetImp(long connection, long result); /** @@ -237,6 +221,7 @@ public class TSDBJNIConnector { */ public void closeConnection() throws SQLException { int code = this.closeConnectionImp(this.taos); + if (code < 0) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); } else if (code == 0) { @@ -244,6 +229,7 @@ public class TSDBJNIConnector { } else { throw new SQLException("Undefined error code returned by TDengine when closing a connection"); } + // invoke closeConnectionImpl only here taosInfo.connect_close_increment(); } @@ -280,7 +266,7 @@ public class TSDBJNIConnector { private native void unsubscribeImp(long subscription, boolean isKeep); /** - * Validate if a create table sql statement is correct without actually creating that table + * Validate if a create table SQL statement is correct without actually creating that table */ public boolean validateCreateTableSql(String sql) { int res = validateCreateTableSqlImp(taos, sql.getBytes()); @@ -288,4 +274,67 @@ public class TSDBJNIConnector { } private native int validateCreateTableSqlImp(long connection, byte[] sqlBytes); + + public long prepareStmt(String sql) throws SQLException { + Long stmt = prepareStmtImp(sql.getBytes(), this.taos); + if (stmt == TSDBConstants.JNI_TDENGINE_ERROR) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_SQL); + } else if (stmt == TSDBConstants.JNI_CONNECTION_NULL) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); + } else if (stmt == TSDBConstants.JNI_SQL_NULL) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_SQL_NULL); + } else if (stmt == TSDBConstants.JNI_OUT_OF_MEMORY) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_OUT_OF_MEMORY); + } + + return stmt; + } + + private native long prepareStmtImp(byte[] sql, long con); + + public void setBindTableName(long stmt, String tableName) throws SQLException { + int code = setBindTableNameImp(stmt, tableName, this.taos); + if (code != TSDBConstants.JNI_SUCCESS) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "failed to set table name"); + } + } + + private native int setBindTableNameImp(long stmt, String name, long conn); + + public void setBindTableNameAndTags(long stmt, String tableName, int numOfTags, ByteBuffer tags, ByteBuffer typeList, ByteBuffer lengthList, ByteBuffer nullList) throws SQLException { + int code = setTableNameTagsImp(stmt, tableName, numOfTags, tags.array(), typeList.array(), lengthList.array(), + nullList.array(), this.taos); + if (code != TSDBConstants.JNI_SUCCESS) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "failed to bind table name and corresponding tags"); + } + } + + private native int setTableNameTagsImp(long stmt, String name, int numOfTags, byte[] tags, byte[] typeList, byte[] lengthList, byte[] nullList, long conn); + + public void bindColumnDataArray(long stmt, ByteBuffer colDataList, ByteBuffer lengthList, ByteBuffer isNullList, int type, int bytes, int numOfRows,int columnIndex) throws SQLException { + int code = bindColDataImp(stmt, colDataList.array(), lengthList.array(), isNullList.array(), type, bytes, numOfRows, columnIndex, this.taos); + if (code != TSDBConstants.JNI_SUCCESS) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "failed to bind column data"); + } + } + + private native int bindColDataImp(long stmt, byte[] colDataList, byte[] lengthList, byte[] isNullList, int type, int bytes, int numOfRows, int columnIndex, long conn); + + public void executeBatch(long stmt) throws SQLException { + int code = executeBatchImp(stmt, this.taos); + if (code != TSDBConstants.JNI_SUCCESS) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "failed to execute batch bind"); + } + } + + private native int executeBatchImp(long stmt, long con); + + public void closeBatch(long stmt) throws SQLException { + int code = closeStmt(stmt, this.taos); + if (code != TSDBConstants.JNI_SUCCESS) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "failed to close batch bind"); + } + } + + private native int closeStmt(long stmt, long con); } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java index 56f971a35e..f6810237c0 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java @@ -18,33 +18,43 @@ import com.taosdata.jdbc.utils.Utils; import java.io.InputStream; import java.io.Reader; +import java.io.UnsupportedEncodingException; import java.math.BigDecimal; import java.net.URL; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; import java.sql.*; import java.util.ArrayList; import java.util.Calendar; +import java.util.Collections; import java.util.regex.Matcher; import java.util.regex.Pattern; /* - * TDengine only supports a subset of the standard SQL, thus this implemetation of the + * TDengine only supports a subset of the standard SQL, thus this implementation of the * standard JDBC API contains more or less some adjustments customized for certain * compatibility needs. */ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStatement { - private String rawSql; private Object[] parameters; private boolean isPrepared; - + + private ArrayList colData; + private ArrayList tableTags; + private int tagValueLength; + + private String tableName; + private long nativeStmtHandle = 0; + private volatile TSDBParameterMetaData parameterMetaData; - TSDBPreparedStatement(TSDBConnection connection, TSDBJNIConnector connecter, String sql) { - super(connection, connecter); + TSDBPreparedStatement(TSDBConnection connection, String sql) { + super(connection); init(sql); + int parameterCnt = 0; if (sql.contains("?")) { - int parameterCnt = 0; for (int i = 0; i < sql.length(); i++) { if ('?' == sql.charAt(i)) { parameterCnt++; @@ -53,6 +63,12 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat parameters = new Object[parameterCnt]; this.isPrepared = true; } + + if (parameterCnt > 1) { + // the table name is also a parameter, so ignore it. + this.colData = new ArrayList(); + this.tableTags = new ArrayList(); + } } private void init(String sql) { @@ -260,10 +276,14 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat @Override public void setObject(int parameterIndex, Object x) throws SQLException { - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); - if (parameterIndex < 1 && parameterIndex >= parameters.length) + } + + if (parameterIndex < 1 && parameterIndex >= parameters.length) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE); + } + parameters[parameterIndex - 1] = x; } @@ -300,9 +320,10 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat @Override public void setRef(int parameterIndex, Ref x) throws SQLException { - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); - + } + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); } @@ -515,4 +536,489 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); } + + /////////////////////////////////////////////////////////////////////// + // NOTE: the following APIs are not JDBC compatible + // set the bind table name + private static class ColumnInfo { + @SuppressWarnings("rawtypes") + private ArrayList data; + private int type; + private int bytes; + private boolean typeIsSet; + + public ColumnInfo() { + this.typeIsSet = false; + } + + public void setType(int type) throws SQLException { + if (this.isTypeSet()) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "column data type has been set"); + } + + this.typeIsSet = true; + this.type = type; + } + + public boolean isTypeSet() { + return this.typeIsSet; + } + }; + + private static class TableTagInfo { + private boolean isNull; + private Object value; + private int type; + public TableTagInfo(Object value, int type) { + this.value = value; + this.type = type; + } + + public static TableTagInfo createNullTag(int type) { + TableTagInfo info = new TableTagInfo(null, type); + info.isNull = true; + return info; + } + }; + + public void setTableName(String name) { + this.tableName = name; + } + + private void ensureTagCapacity(int index) { + if (this.tableTags.size() < index + 1) { + int delta = index + 1 - this.tableTags.size(); + this.tableTags.addAll(Collections.nCopies(delta, null)); + } + } + + public void setTagNull(int index, int type) { + ensureTagCapacity(index); + this.tableTags.set(index, TableTagInfo.createNullTag(type)); + } + + public void setTagBoolean(int index, boolean value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_BOOL)); + this.tagValueLength += Byte.BYTES; + } + + public void setTagInt(int index, int value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_INT)); + this.tagValueLength += Integer.BYTES; + } + + public void setTagByte(int index, byte value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_TINYINT)); + this.tagValueLength += Byte.BYTES; + } + + public void setTagShort(int index, short value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_SMALLINT)); + this.tagValueLength += Short.BYTES; + } + + public void setTagLong(int index, long value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_BIGINT)); + this.tagValueLength += Long.BYTES; + } + + public void setTagTimestamp(int index, long value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP)); + this.tagValueLength += Long.BYTES; + } + + public void setTagFloat(int index, float value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_FLOAT)); + this.tagValueLength += Float.BYTES; + } + + public void setTagDouble(int index, double value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_DOUBLE)); + this.tagValueLength += Double.BYTES; + } + + public void setTagString(int index, String value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_BINARY)); + this.tagValueLength += value.getBytes().length; + } + + public void setTagNString(int index, String value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_NCHAR)); + + String charset = TaosGlobalConfig.getCharset(); + try { + this.tagValueLength += value.getBytes(charset).length; + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + + public void setValueImpl(int columnIndex, ArrayList list, int type, int bytes) throws SQLException { + if (this.colData.size() == 0) { + this.colData.addAll(Collections.nCopies(this.parameters.length - 1 - this.tableTags.size(), null)); + + } + ColumnInfo col = (ColumnInfo) this.colData.get(columnIndex); + if (col == null) { + ColumnInfo p = new ColumnInfo(); + p.setType(type); + p.bytes = bytes; + p.data = (ArrayList) list.clone(); + this.colData.set(columnIndex, p); + } else { + if (col.type != type) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "column data type mismatch"); + } + col.data.addAll(list); + } + } + + public void setInt(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_INT, Integer.BYTES); + } + + public void setFloat(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_FLOAT, Float.BYTES); + } + + public void setTimestamp(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP, Long.BYTES); + } + + public void setLong(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_BIGINT, Long.BYTES); + } + + public void setDouble(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_DOUBLE, Double.BYTES); + } + + public void setBoolean(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_BOOL, Byte.BYTES); + } + + public void setByte(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_TINYINT, Byte.BYTES); + } + + public void setShort(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_SMALLINT, Short.BYTES); + } + + public void setString(int columnIndex, ArrayList list, int size) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_BINARY, size); + } + + // note: expand the required space for each NChar character + public void setNString(int columnIndex, ArrayList list, int size) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_NCHAR, size * Integer.BYTES); + } + + public void columnDataAddBatch() throws SQLException { + // pass the data block to native code + if (rawSql == null) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "sql statement not set yet"); + } + + // table name is not set yet, abort + if (this.tableName == null) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "table name not set yet"); + } + + int numOfCols = this.colData.size(); + if (numOfCols == 0) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "column data not bind"); + } + + TSDBJNIConnector connector = ((TSDBConnection) this.getConnection()).getConnector(); + this.nativeStmtHandle = connector.prepareStmt(rawSql); + + if (this.tableTags == null) { + connector.setBindTableName(this.nativeStmtHandle, this.tableName); + } else { + int num = this.tableTags.size(); + ByteBuffer tagDataList = ByteBuffer.allocate(this.tagValueLength); + tagDataList.order(ByteOrder.LITTLE_ENDIAN); + + ByteBuffer typeList = ByteBuffer.allocate(num); + typeList.order(ByteOrder.LITTLE_ENDIAN); + + ByteBuffer lengthList = ByteBuffer.allocate(num * Long.BYTES); + lengthList.order(ByteOrder.LITTLE_ENDIAN); + + ByteBuffer isNullList = ByteBuffer.allocate(num * Integer.BYTES); + isNullList.order(ByteOrder.LITTLE_ENDIAN); + + for (int i = 0; i < num; ++i) { + TableTagInfo tag = this.tableTags.get(i); + if (tag.isNull) { + typeList.put((byte) tag.type); + isNullList.putInt(1); + lengthList.putLong(0); + continue; + } + + switch (tag.type) { + case TSDBConstants.TSDB_DATA_TYPE_INT: { + Integer val = (Integer) tag.value; + tagDataList.putInt(val); + lengthList.putLong(Integer.BYTES); + break; + } + case TSDBConstants.TSDB_DATA_TYPE_TINYINT: { + Byte val = (Byte) tag.value; + tagDataList.put(val); + lengthList.putLong(Byte.BYTES); + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_BOOL: { + Boolean val = (Boolean) tag.value; + tagDataList.put((byte) (val ? 1 : 0)); + lengthList.putLong(Byte.BYTES); + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: { + Short val = (Short) tag.value; + tagDataList.putShort(val); + lengthList.putLong(Short.BYTES); + + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: + case TSDBConstants.TSDB_DATA_TYPE_BIGINT: { + Long val = (Long) tag.value; + tagDataList.putLong(val == null ? 0 : val); + lengthList.putLong(Long.BYTES); + + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: { + Float val = (Float) tag.value; + tagDataList.putFloat(val == null ? 0 : val); + lengthList.putLong(Float.BYTES); + + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: { + Double val = (Double) tag.value; + tagDataList.putDouble(val == null ? 0 : val); + lengthList.putLong(Double.BYTES); + + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_NCHAR: + case TSDBConstants.TSDB_DATA_TYPE_BINARY: { + String charset = TaosGlobalConfig.getCharset(); + String val = (String) tag.value; + + byte[] b = null; + try { + if (tag.type == TSDBConstants.TSDB_DATA_TYPE_BINARY) { + b = val.getBytes(); + } else { + b = val.getBytes(charset); + } + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + tagDataList.put(b); + lengthList.putLong(b.length); + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_UTINYINT: + case TSDBConstants.TSDB_DATA_TYPE_USMALLINT: + case TSDBConstants.TSDB_DATA_TYPE_UINT: + case TSDBConstants.TSDB_DATA_TYPE_UBIGINT: { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "not support data types"); + } + } + + typeList.put((byte) tag.type); + isNullList.putInt(tag.isNull? 1 : 0); + } + + connector.setBindTableNameAndTags(this.nativeStmtHandle, this.tableName, this.tableTags.size(), tagDataList, + typeList, lengthList, isNullList); + } + + ColumnInfo colInfo = (ColumnInfo) this.colData.get(0); + if (colInfo == null) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "column data not bind"); + } + + int rows = colInfo.data.size(); + for (int i = 0; i < numOfCols; ++i) { + ColumnInfo col1 = this.colData.get(i); + if (col1 == null || !col1.isTypeSet()) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "column data not bind"); + } + + if (rows != col1.data.size()) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "the rows in column data not identical"); + } + + ByteBuffer colDataList = ByteBuffer.allocate(rows * col1.bytes); + colDataList.order(ByteOrder.LITTLE_ENDIAN); + + ByteBuffer lengthList = ByteBuffer.allocate(rows * Integer.BYTES); + lengthList.order(ByteOrder.LITTLE_ENDIAN); + + ByteBuffer isNullList = ByteBuffer.allocate(rows * Byte.BYTES); + isNullList.order(ByteOrder.LITTLE_ENDIAN); + + switch (col1.type) { + case TSDBConstants.TSDB_DATA_TYPE_INT: { + for (int j = 0; j < rows; ++j) { + Integer val = (Integer) col1.data.get(j); + colDataList.putInt(val == null? Integer.MIN_VALUE:val); + isNullList.put((byte) (val == null? 1:0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_TINYINT: { + for (int j = 0; j < rows; ++j) { + Byte val = (Byte) col1.data.get(j); + colDataList.put(val == null? 0:val); + isNullList.put((byte) (val == null? 1:0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_BOOL: { + for (int j = 0; j < rows; ++j) { + Boolean val = (Boolean) col1.data.get(j); + if (val == null) { + colDataList.put((byte) 0); + } else { + colDataList.put((byte) (val? 1:0)); + } + + isNullList.put((byte) (val == null? 1:0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: { + for (int j = 0; j < rows; ++j) { + Short val = (Short) col1.data.get(j); + colDataList.putShort(val == null? 0:val); + isNullList.put((byte) (val == null? 1:0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: + case TSDBConstants.TSDB_DATA_TYPE_BIGINT: { + for (int j = 0; j < rows; ++j) { + Long val = (Long) col1.data.get(j); + colDataList.putLong(val == null? 0:val); + isNullList.put((byte) (val == null? 1:0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: { + for (int j = 0; j < rows; ++j) { + Float val = (Float) col1.data.get(j); + colDataList.putFloat(val == null? 0:val); + isNullList.put((byte) (val == null? 1:0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: { + for (int j = 0; j < rows; ++j) { + Double val = (Double) col1.data.get(j); + colDataList.putDouble(val == null? 0:val); + isNullList.put((byte) (val == null? 1:0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_NCHAR: + case TSDBConstants.TSDB_DATA_TYPE_BINARY: { + String charset = TaosGlobalConfig.getCharset(); + for (int j = 0; j < rows; ++j) { + String val = (String) col1.data.get(j); + + colDataList.position(j * col1.bytes); // seek to the correct position + if (val != null) { + byte[] b = null; + try { + if (col1.type == TSDBConstants.TSDB_DATA_TYPE_BINARY) { + b = val.getBytes(); + } else { + b = val.getBytes(charset); + } + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + if (val.length() > col1.bytes) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "string data too long"); + } + + colDataList.put(b); + lengthList.putInt(b.length); + isNullList.put((byte) 0); + } else { + lengthList.putInt(0); + isNullList.put((byte) 1); + } + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_UTINYINT: + case TSDBConstants.TSDB_DATA_TYPE_USMALLINT: + case TSDBConstants.TSDB_DATA_TYPE_UINT: + case TSDBConstants.TSDB_DATA_TYPE_UBIGINT: { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "not support data types"); + } + }; + + connector.bindColumnDataArray(this.nativeStmtHandle, colDataList, lengthList, isNullList, col1.type, col1.bytes, rows, i); + } + } + + public void columnDataExecuteBatch() throws SQLException { + TSDBJNIConnector connector = ((TSDBConnection) this.getConnection()).getConnector(); + connector.executeBatch(this.nativeStmtHandle); + this.columnDataClearBatch(); + } + + public void columnDataClearBatch() { + int size = this.colData.size(); + this.colData.clear(); + + this.colData.addAll(Collections.nCopies(size, null)); + this.tableName = null; // clear the table name + } + + public void columnDataCloseBatch() throws SQLException { + TSDBJNIConnector connector = ((TSDBConnection) this.getConnection()).getConnector(); + connector.closeBatch(this.nativeStmtHandle); + + this.nativeStmtHandle = 0L; + this.tableName = null; + } } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java index ce5290de66..7b3be5d263 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java @@ -29,6 +29,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import com.taosdata.jdbc.utils.NullType; + public class TSDBResultSetBlockData { private int numOfRows = 0; private int rowIndex = 0; @@ -164,59 +166,7 @@ public class TSDBResultSetBlockData { } } - private static class NullType { - private static final byte NULL_BOOL_VAL = 0x2; - private static final String NULL_STR = "null"; - - public String toString() { - return NullType.NULL_STR; - } - - public static boolean isBooleanNull(byte val) { - return val == NullType.NULL_BOOL_VAL; - } - - private static boolean isTinyIntNull(byte val) { - return val == Byte.MIN_VALUE; - } - - private static boolean isSmallIntNull(short val) { - return val == Short.MIN_VALUE; - } - - private static boolean isIntNull(int val) { - return val == Integer.MIN_VALUE; - } - - private static boolean isBigIntNull(long val) { - return val == Long.MIN_VALUE; - } - - private static boolean isFloatNull(float val) { - return Float.isNaN(val); - } - - private static boolean isDoubleNull(double val) { - return Double.isNaN(val); - } - - private static boolean isBinaryNull(byte[] val, int length) { - if (length != Byte.BYTES) { - return false; - } - - return val[0] == 0xFF; - } - - private static boolean isNcharNull(byte[] val, int length) { - if (length != Integer.BYTES) { - return false; - } - - return (val[0] & val[1] & val[2] & val[3]) == 0xFF; - } - - } + /** * The original type may not be a string type, but will be converted to by @@ -488,8 +438,8 @@ public class TSDBResultSetBlockData { } try { - String ss = TaosGlobalConfig.getCharset(); - return new String(dest, ss); + String charset = TaosGlobalConfig.getCharset(); + return new String(dest, charset); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java index 34470fbc4e..618e896a6d 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java @@ -84,7 +84,8 @@ public class TSDBResultSetRowData { data.set(col, value); } - public int getInt(int col, int srcType) throws SQLException { + @SuppressWarnings("deprecation") + public int getInt(int col, int srcType) throws SQLException { Object obj = data.get(col); switch (srcType) { @@ -128,7 +129,7 @@ public class TSDBResultSetRowData { long value = (long) obj; if (value < 0) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE); - return new Long(value).intValue(); + return Long.valueOf(value).intValue(); } } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java index fb20a621b0..d8ba67576d 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java @@ -19,8 +19,6 @@ import java.sql.ResultSet; import java.sql.SQLException; public class TSDBStatement extends AbstractStatement { - - private TSDBJNIConnector connector; /** * Status of current statement */ @@ -29,29 +27,26 @@ public class TSDBStatement extends AbstractStatement { private TSDBConnection connection; private TSDBResultSet resultSet; - public void setConnection(TSDBConnection connection) { + TSDBStatement(TSDBConnection connection) { this.connection = connection; } - TSDBStatement(TSDBConnection connection, TSDBJNIConnector connector) { - this.connection = connection; - this.connector = connector; - } - public ResultSet executeQuery(String sql) throws SQLException { // check if closed - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); + } + //TODO: 如果在executeQuery方法中执行insert语句,那么先执行了SQL,再通过pSql来检查是否为一个insert语句,但这个insert SQL已经执行成功了 // execute query - long pSql = this.connector.executeQuery(sql); + long pSql = this.connection.getConnector().executeQuery(sql); // if pSql is create/insert/update/delete/alter SQL - if (this.connector.isUpdateQuery(pSql)) { - this.connector.freeResultSet(pSql); + if (this.connection.getConnector().isUpdateQuery(pSql)) { + this.connection.getConnector().freeResultSet(pSql); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_WITH_EXECUTEQUERY); } - TSDBResultSet res = new TSDBResultSet(this, this.connector, pSql); + TSDBResultSet res = new TSDBResultSet(this, this.connection.getConnector(), pSql); res.setBatchFetch(this.connection.getBatchFetch()); return res; } @@ -60,14 +55,14 @@ public class TSDBStatement extends AbstractStatement { if (isClosed()) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); - long pSql = this.connector.executeQuery(sql); + long pSql = this.connection.getConnector().executeQuery(sql); // if pSql is create/insert/update/delete/alter SQL - if (!this.connector.isUpdateQuery(pSql)) { - this.connector.freeResultSet(pSql); + if (!this.connection.getConnector().isUpdateQuery(pSql)) { + this.connection.getConnector().freeResultSet(pSql); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_WITH_EXECUTEUPDATE); } - int affectedRows = this.connector.getAffectedRows(pSql); - this.connector.freeResultSet(pSql); + int affectedRows = this.connection.getConnector().getAffectedRows(pSql); + this.connection.getConnector().freeResultSet(pSql); return affectedRows; } @@ -81,30 +76,29 @@ public class TSDBStatement extends AbstractStatement { public boolean execute(String sql) throws SQLException { // check if closed - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); + } + // execute query - long pSql = this.connector.executeQuery(sql); + long pSql = this.connection.getConnector().executeQuery(sql); // if pSql is create/insert/update/delete/alter SQL - if (this.connector.isUpdateQuery(pSql)) { - this.affectedRows = this.connector.getAffectedRows(pSql); - this.connector.freeResultSet(pSql); + if (this.connection.getConnector().isUpdateQuery(pSql)) { + this.affectedRows = this.connection.getConnector().getAffectedRows(pSql); + this.connection.getConnector().freeResultSet(pSql); return false; } - this.resultSet = new TSDBResultSet(this, this.connector, pSql); + this.resultSet = new TSDBResultSet(this, this.connection.getConnector(), pSql); this.resultSet.setBatchFetch(this.connection.getBatchFetch()); return true; } public ResultSet getResultSet() throws SQLException { - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); -// long resultSetPointer = connector.getResultSet(); -// TSDBResultSet resSet = null; -// if (resultSetPointer != TSDBConstants.JNI_NULL_POINTER) { -// resSet = new TSDBResultSet(connector, resultSetPointer); -// } + } + return this.resultSet; } @@ -115,12 +109,20 @@ public class TSDBStatement extends AbstractStatement { } public Connection getConnection() throws SQLException { - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); - if (this.connector == null) + } + + if (this.connection.getConnector() == null) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); + } + return this.connection; } + + public void setConnection(TSDBConnection connection) { + this.connection = connection; + } public boolean isClosed() throws SQLException { return isClosed; diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/NullType.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/NullType.java new file mode 100755 index 0000000000..0e05aeeee7 --- /dev/null +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/NullType.java @@ -0,0 +1,91 @@ +package com.taosdata.jdbc.utils; + +public class NullType { + private static final byte NULL_BOOL_VAL = 0x2; + private static final String NULL_STR = "null"; + + public String toString() { + return NullType.NULL_STR; + } + + public static boolean isBooleanNull(byte val) { + return val == NullType.NULL_BOOL_VAL; + } + + public static boolean isTinyIntNull(byte val) { + return val == Byte.MIN_VALUE; + } + + public static boolean isSmallIntNull(short val) { + return val == Short.MIN_VALUE; + } + + public static boolean isIntNull(int val) { + return val == Integer.MIN_VALUE; + } + + public static boolean isBigIntNull(long val) { + return val == Long.MIN_VALUE; + } + + public static boolean isFloatNull(float val) { + return Float.isNaN(val); + } + + public static boolean isDoubleNull(double val) { + return Double.isNaN(val); + } + + public static boolean isBinaryNull(byte[] val, int length) { + if (length != Byte.BYTES) { + return false; + } + + return val[0] == 0xFF; + } + + public static boolean isNcharNull(byte[] val, int length) { + if (length != Integer.BYTES) { + return false; + } + + return (val[0] & val[1] & val[2] & val[3]) == 0xFF; + } + + public static byte getBooleanNull() { + return NullType.NULL_BOOL_VAL; + } + + public static byte getTinyintNull() { + return Byte.MIN_VALUE; + } + + public static int getIntNull() { + return Integer.MIN_VALUE; + } + + public static short getSmallIntNull() { + return Short.MIN_VALUE; + } + + public static long getBigIntNull() { + return Long.MIN_VALUE; + } + + public static int getFloatNull() { + return 0x7FF00000; + } + + public static long getDoubleNull() { + return 0x7FFFFF0000000000L; + } + + public static byte getBinaryNull() { + return (byte) 0xFF; + } + + public static byte[] getNcharNull() { + return new byte[] {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}; + } + +} diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/Utils.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/Utils.java index 082cec1e24..eeb936a1d0 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/Utils.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/Utils.java @@ -146,6 +146,7 @@ public class Utils { */ private static String transformSql(String rawSql, Object[] paramArr, Map placeholderPosition, RangeSet clauseRangeSet) { String[] sqlArr = rawSql.split("\\?"); + return IntStream.range(0, sqlArr.length).mapToObj(index -> { if (index == paramArr.length) return sqlArr[index]; diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java index dc6fd4c501..277ca447f5 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java @@ -8,6 +8,8 @@ import org.junit.Test; import java.io.IOException; import java.io.Serializable; import java.sql.*; +import java.util.ArrayList; +import java.util.Random; public class TSDBPreparedStatementTest { private static final String host = "127.0.0.1"; @@ -97,6 +99,296 @@ public class TSDBPreparedStatementTest { Assert.assertEquals(1, result); } + @Test + public void executeTest() throws SQLException { + Statement stmt = conn.createStatement(); + + int numOfRows = 1000; + + for (int loop = 0; loop < 10; loop++){ + stmt.execute("drop table if exists weather_test"); + stmt.execute("create table weather_test(ts timestamp, f1 nchar(4), f2 float, f3 double, f4 timestamp, f5 int, f6 bool, f7 binary(10))"); + + TSDBPreparedStatement s = (TSDBPreparedStatement) conn.prepareStatement("insert into ? values(?, ?, ?, ?, ?, ?, ?, ?)"); + Random r = new Random(); + s.setTableName("weather_test"); + + ArrayList ts = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + ts.add(System.currentTimeMillis() + i); + } + s.setTimestamp(0, ts); + + int random = 10 + r.nextInt(5); + ArrayList s2 = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + if(i % random == 0) { + s2.add(null); + }else{ + s2.add("分支" + i % 4); + } + } + s.setNString(1, s2, 4); + + random = 10 + r.nextInt(5); + ArrayList s3 = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + if(i % random == 0) { + s3.add(null); + }else{ + s3.add(r.nextFloat()); + } + } + s.setFloat(2, s3); + + random = 10 + r.nextInt(5); + ArrayList s4 = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + if(i % random == 0) { + s4.add(null); + }else{ + s4.add(r.nextDouble()); + } + } + s.setDouble(3, s4); + + random = 10 + r.nextInt(5); + ArrayList ts2 = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + if(i % random == 0) { + ts2.add(null); + }else{ + ts2.add(System.currentTimeMillis() + i); + } + } + s.setTimestamp(4, ts2); + + random = 10 + r.nextInt(5); + ArrayList vals = new ArrayList<>(); + for(int i = 0; i < numOfRows; i++) { + if(i % random == 0) { + vals.add(null); + }else{ + vals.add(r.nextInt()); + } + } + s.setInt(5, vals); + + random = 10 + r.nextInt(5); + ArrayList sb = new ArrayList<>(); + for(int i = 0; i < numOfRows; i++) { + if(i % random == 0) { + sb.add(null); + }else{ + sb.add(i % 2 == 0 ? true : false); + } + } + s.setBoolean(6, sb); + + random = 10 + r.nextInt(5); + ArrayList s5 = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + if(i % random == 0) { + s5.add(null); + }else{ + s5.add("test" + i % 10); + } + } + s.setString(7, s5, 10); + + s.columnDataAddBatch(); + s.columnDataExecuteBatch(); + s.columnDataCloseBatch(); + + String sql = "select * from weather_test"; + PreparedStatement statement = conn.prepareStatement(sql); + ResultSet rs = statement.executeQuery(); + int rows = 0; + while(rs.next()) { + rows++; + } + Assert.assertEquals(numOfRows, rows); + } + } + + @Test + public void bindDataSelectColumnTest() throws SQLException { + Statement stmt = conn.createStatement(); + + int numOfRows = 1000; + + for (int loop = 0; loop < 10; loop++){ + stmt.execute("drop table if exists weather_test"); + stmt.execute("create table weather_test(ts timestamp, f1 nchar(4), f2 float, f3 double, f4 timestamp, f5 int, f6 bool, f7 binary(10))"); + + TSDBPreparedStatement s = (TSDBPreparedStatement) conn.prepareStatement("insert into ? (ts, f1, f7) values(?, ?, ?)"); + Random r = new Random(); + s.setTableName("weather_test"); + + ArrayList ts = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + ts.add(System.currentTimeMillis() + i); + } + s.setTimestamp(0, ts); + + int random = 10 + r.nextInt(5); + ArrayList s2 = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + if(i % random == 0) { + s2.add(null); + }else{ + s2.add("分支" + i % 4); + } + } + s.setNString(1, s2, 4); + + random = 10 + r.nextInt(5); + ArrayList s3 = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + if(i % random == 0) { + s3.add(null); + }else{ + s3.add("test" + i % 10); + } + } + s.setString(2, s3, 10); + + s.columnDataAddBatch(); + s.columnDataExecuteBatch(); + s.columnDataCloseBatch(); + + String sql = "select * from weather_test"; + PreparedStatement statement = conn.prepareStatement(sql); + ResultSet rs = statement.executeQuery(); + int rows = 0; + while(rs.next()) { + rows++; + } + Assert.assertEquals(numOfRows, rows); + } + } + + @Test + public void bindDataWithSingleTagTest() throws SQLException { + Statement stmt = conn.createStatement(); + + String types[] = new String[] {"tinyint", "smallint", "int", "bigint", "bool", "float", "double", "binary(10)", "nchar(10)"}; + + for (String type : types) { + stmt.execute("drop table if exists weather_test"); + stmt.execute("create table weather_test(ts timestamp, f1 nchar(10), f2 binary(10)) tags (t " + type + ")"); + + int numOfRows = 1; + + TSDBPreparedStatement s = (TSDBPreparedStatement) conn.prepareStatement("insert into ? using weather_test tags(?) values(?, ?, ?)"); + Random r = new Random(); + s.setTableName("w1"); + + switch(type) { + case "tinyint": + case "smallint": + case "int": + case "bigint": + s.setTagInt(0, 1); + break; + case "float": + s.setTagFloat(0, 1.23f); + break; + case "double": + s.setTagDouble(0, 3.14159265); + break; + case "bool": + s.setTagBoolean(0, true); + break; + case "binary(10)": + s.setTagString(0, "test"); + break; + case "nchar(10)": + s.setTagNString(0, "test"); + break; + default: + break; + } + + + ArrayList ts = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + ts.add(System.currentTimeMillis() + i); + } + s.setTimestamp(0, ts); + + int random = 10 + r.nextInt(5); + ArrayList s2 = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + s2.add("分支" + i % 4); + } + s.setNString(1, s2, 10); + + random = 10 + r.nextInt(5); + ArrayList s3 = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + s3.add("test" + i % 4); + } + s.setString(2, s3, 10); + + s.columnDataAddBatch(); + s.columnDataExecuteBatch(); + s.columnDataCloseBatch(); + + String sql = "select * from weather_test"; + PreparedStatement statement = conn.prepareStatement(sql); + ResultSet rs = statement.executeQuery(); + int rows = 0; + while(rs.next()) { + rows++; + } + Assert.assertEquals(numOfRows, rows); + } + } + + + @Test + public void bindDataWithMultipleTagsTest() throws SQLException { + Statement stmt = conn.createStatement(); + + stmt.execute("drop table if exists weather_test"); + stmt.execute("create table weather_test(ts timestamp, f1 nchar(10), f2 binary(10)) tags (t1 int, t2 binary(10))"); + + int numOfRows = 1; + + TSDBPreparedStatement s = (TSDBPreparedStatement) conn.prepareStatement("insert into ? using weather_test tags(?,?) (ts, f2) values(?, ?)"); + s.setTableName("w2"); + s.setTagInt(0, 1); + s.setTagString(1, "test"); + + + ArrayList ts = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + ts.add(System.currentTimeMillis() + i); + } + s.setTimestamp(0, ts); + + ArrayList s2 = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + s2.add("test" + i % 4); + } + s.setString(1, s2, 10); + + s.columnDataAddBatch(); + s.columnDataExecuteBatch(); + s.columnDataCloseBatch(); + + String sql = "select * from weather_test"; + PreparedStatement statement = conn.prepareStatement(sql); + ResultSet rs = statement.executeQuery(); + int rows = 0; + while(rs.next()) { + rows++; + } + Assert.assertEquals(numOfRows, rows); + + } + @Test public void setBoolean() throws SQLException { pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java index c5c6f7bca5..f304fd6874 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java @@ -3,7 +3,6 @@ package com.taosdata.jdbc; import com.google.common.primitives.Ints; import com.google.common.primitives.Longs; import com.google.common.primitives.Shorts; -import com.taosdata.jdbc.rs.RestfulResultSet; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -177,7 +176,8 @@ public class TSDBResultSetTest { rs.getAsciiStream("f1"); } - @Test(expected = SQLFeatureNotSupportedException.class) + @SuppressWarnings("deprecation") + @Test(expected = SQLFeatureNotSupportedException.class) public void getUnicodeStream() throws SQLException { rs.getUnicodeStream("f1"); } @@ -326,7 +326,7 @@ public class TSDBResultSetTest { @Test(expected = SQLFeatureNotSupportedException.class) public void getRow() throws SQLException { - int row = rs.getRow(); + rs.getRow(); } @Test(expected = SQLFeatureNotSupportedException.class) @@ -405,12 +405,12 @@ public class TSDBResultSetTest { @Test(expected = SQLFeatureNotSupportedException.class) public void updateByte() throws SQLException { - rs.updateByte(1, new Byte("0")); + rs.updateByte(1, (byte) 0); } @Test(expected = SQLFeatureNotSupportedException.class) public void updateShort() throws SQLException { - rs.updateShort(1, new Short("0")); + rs.updateShort(1, (short) 0); } @Test(expected = SQLFeatureNotSupportedException.class) diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterJniTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterJniTest.java index a3c46dc232..4b4e83719f 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterJniTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterJniTest.java @@ -345,6 +345,7 @@ public class InsertSpecialCharacterJniTest { } } + @Test public void testCase12() throws SQLException { final long now = System.currentTimeMillis(); From f8c13734d6bd9438a78bc677e717d14170e79418 Mon Sep 17 00:00:00 2001 From: tickduan <417921451@qq.com> Date: Mon, 7 Jun 2021 15:18:13 +0800 Subject: [PATCH 28/72] fix merge to develop conflict --- src/client/src/tscSQLParser.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 363bb41085..a5b1675170 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -6674,9 +6674,8 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { const char* msg5 = "sql too long"; // todo ADD support const char* msg6 = "from missing in subclause"; const char* msg7 = "time interval is required"; - const char* msg8 = "query column is required"; - const char* msg9 = "the first column must be timestamp type"; - + const char* msg8 = "the first column should be primary timestamp column"; + SSqlCmd* pCmd = &pSql->cmd; SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); assert(pQueryInfo->numOfTables == 1); @@ -6733,26 +6732,15 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); } - // project query primary column must be timestamp type if (tscIsProjectionQuery(pQueryInfo)) { - size_t size = tscSqlExprNumOfExprs(pQueryInfo); - // check zero - if(size == 0) { + SExprInfo* pExpr = tscExprGet(pQueryInfo, 0); + if (pExpr->base.colInfo.colId != PRIMARYKEY_TIMESTAMP_COL_INDEX) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg8); } - - // check primary column is timestamp - SSqlExpr* pSqlExpr = tscSqlExprGet(pQueryInfo, 0); - if(pSqlExpr == NULL) { - return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg8); - } - if( pSqlExpr->colInfo.colId != PRIMARYKEY_TIMESTAMP_COL_INDEX) { - return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg9); - } } else { if (pQueryInfo->interval.interval == 0) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg7); - } + } } // set the created table[stream] name From d3861c455154fb4ffeb57d9a30a9b59525413d10 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Sat, 5 Jun 2021 15:06:06 +0800 Subject: [PATCH 29/72] [TD-4535]:_block_dist() function improvement --- src/query/src/qAggMain.c | 19 ++++++++++++++++--- src/tsdb/src/tsdbRead.c | 25 ++++++++++++------------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index ba6efcabb2..5244f087a8 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -4834,6 +4834,19 @@ void generateBlockDistResult(STableBlockDist *pTableBlockDist, char* result) { min = totalBlocks > 0 ? pTableBlockDist->minRows : 0; max = totalBlocks > 0 ? pTableBlockDist->maxRows : 0; + double stdDev = 0; + if (totalBlocks > 0) { + double variance = 0; + for (int32_t i = 0; i < numSteps; i++) { + SFileBlockInfo *blockInfo = taosArrayGet(blockInfos, i); + int64_t blocks = blockInfo->numBlocksOfStep; + int32_t rows = (i * TSDB_BLOCK_DIST_STEP_ROWS + TSDB_BLOCK_DIST_STEP_ROWS / 2); + variance += blocks * (rows - avg) * (rows - avg); + } + variance = variance / totalBlocks; + stdDev = sqrt(variance); + } + double percents[] = {0.05, 0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 0.95, 0.99}; int32_t percentiles[] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; assert(sizeof(percents)/sizeof(double) == sizeof(percentiles)/sizeof(int32_t)); @@ -4848,12 +4861,12 @@ void generateBlockDistResult(STableBlockDist *pTableBlockDist, char* result) { "60th=[%d], 70th=[%d], 80th=[%d], 90th=[%d], 95th=[%d], 99th=[%d]\n\t " "Min=[%"PRId64"(Rows)] Max=[%"PRId64"(Rows)] Avg=[%"PRId64"(Rows)] Stddev=[%.2f] \n\t " "Rows=[%"PRIu64"], Blocks=[%"PRId64"], Size=[%.3f(Kb)] Comp=[%.2f]\n\t " - "RowsInMem=[%d] \n\t SeekHeaderTime=[%d(us)]", + "RowsInMem=[%d] \n\t", percentiles[0], percentiles[1], percentiles[2], percentiles[3], percentiles[4], percentiles[5], percentiles[6], percentiles[7], percentiles[8], percentiles[9], percentiles[10], percentiles[11], - min, max, avg, 0.0, + min, max, avg, stdDev, totalRows, totalBlocks, totalLen/1024.0, compRatio, - pTableBlockDist->numOfRowsInMemTable, pTableBlockDist->firstSeekTimeUs); + pTableBlockDist->numOfRowsInMemTable); varDataSetLen(result, sz); UNUSED(sz); } diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index c333294179..8feb727c50 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -218,11 +218,6 @@ static void tsdbMayUnTakeMemSnapshot(STsdbQueryHandle* pQueryHandle) { int64_t tsdbGetNumOfRowsInMemTable(TsdbQueryHandleT* pHandle) { STsdbQueryHandle* pQueryHandle = (STsdbQueryHandle*) pHandle; - size_t size = taosArrayGetSize(pQueryHandle->pTableCheckInfo); - assert(pQueryHandle->activeIndex < size && pQueryHandle->activeIndex >= 0 && size >= 1); - STableCheckInfo* pCheckInfo = taosArrayGet(pQueryHandle->pTableCheckInfo, pQueryHandle->activeIndex); - - int64_t rows = 0; SMemRef* pMemRef = pQueryHandle->pMemRef; if (pMemRef == NULL) { return rows; } @@ -233,15 +228,19 @@ int64_t tsdbGetNumOfRowsInMemTable(TsdbQueryHandleT* pHandle) { SMemTable* pMemT = pMemRef->snapshot.mem; SMemTable* pIMemT = pMemRef->snapshot.imem; - if (pMemT && pCheckInfo->tableId.tid < pMemT->maxTables) { - pMem = pMemT->tData[pCheckInfo->tableId.tid]; - rows += (pMem && pMem->uid == pCheckInfo->tableId.uid) ? pMem->numOfRows: 0; + size_t size = taosArrayGetSize(pQueryHandle->pTableCheckInfo); + for (int32_t i = 0; i < size; ++i) { + STableCheckInfo* pCheckInfo = taosArrayGet(pQueryHandle->pTableCheckInfo, i); + + if (pMemT && pCheckInfo->tableId.tid < pMemT->maxTables) { + pMem = pMemT->tData[pCheckInfo->tableId.tid]; + rows += (pMem && pMem->uid == pCheckInfo->tableId.uid) ? pMem->numOfRows : 0; + } + if (pIMemT && pCheckInfo->tableId.tid < pIMemT->maxTables) { + pIMem = pIMemT->tData[pCheckInfo->tableId.tid]; + rows += (pIMem && pIMem->uid == pCheckInfo->tableId.uid) ? pIMem->numOfRows : 0; + } } - if (pIMemT && pCheckInfo->tableId.tid < pIMemT->maxTables) { - pIMem = pIMemT->tData[pCheckInfo->tableId.tid]; - rows += (pIMem && pIMem->uid == pCheckInfo->tableId.uid) ? pIMem->numOfRows: 0; - } - return rows; } From c7ad63e06df6e14cc96418c0ae1f50c53e576741 Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Mon, 7 Jun 2021 16:14:47 +0800 Subject: [PATCH 30/72] remove test cases not available for master branch --- .../jdbc/TSDBPreparedStatementTest.java | 290 ------------------ 1 file changed, 290 deletions(-) diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java index 277ca447f5..121392c83e 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java @@ -98,297 +98,7 @@ public class TSDBPreparedStatementTest { result = pstmt_insert.executeUpdate(); Assert.assertEquals(1, result); } - - @Test - public void executeTest() throws SQLException { - Statement stmt = conn.createStatement(); - - int numOfRows = 1000; - - for (int loop = 0; loop < 10; loop++){ - stmt.execute("drop table if exists weather_test"); - stmt.execute("create table weather_test(ts timestamp, f1 nchar(4), f2 float, f3 double, f4 timestamp, f5 int, f6 bool, f7 binary(10))"); - - TSDBPreparedStatement s = (TSDBPreparedStatement) conn.prepareStatement("insert into ? values(?, ?, ?, ?, ?, ?, ?, ?)"); - Random r = new Random(); - s.setTableName("weather_test"); - - ArrayList ts = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - ts.add(System.currentTimeMillis() + i); - } - s.setTimestamp(0, ts); - - int random = 10 + r.nextInt(5); - ArrayList s2 = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - if(i % random == 0) { - s2.add(null); - }else{ - s2.add("分支" + i % 4); - } - } - s.setNString(1, s2, 4); - - random = 10 + r.nextInt(5); - ArrayList s3 = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - if(i % random == 0) { - s3.add(null); - }else{ - s3.add(r.nextFloat()); - } - } - s.setFloat(2, s3); - - random = 10 + r.nextInt(5); - ArrayList s4 = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - if(i % random == 0) { - s4.add(null); - }else{ - s4.add(r.nextDouble()); - } - } - s.setDouble(3, s4); - - random = 10 + r.nextInt(5); - ArrayList ts2 = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - if(i % random == 0) { - ts2.add(null); - }else{ - ts2.add(System.currentTimeMillis() + i); - } - } - s.setTimestamp(4, ts2); - - random = 10 + r.nextInt(5); - ArrayList vals = new ArrayList<>(); - for(int i = 0; i < numOfRows; i++) { - if(i % random == 0) { - vals.add(null); - }else{ - vals.add(r.nextInt()); - } - } - s.setInt(5, vals); - - random = 10 + r.nextInt(5); - ArrayList sb = new ArrayList<>(); - for(int i = 0; i < numOfRows; i++) { - if(i % random == 0) { - sb.add(null); - }else{ - sb.add(i % 2 == 0 ? true : false); - } - } - s.setBoolean(6, sb); - - random = 10 + r.nextInt(5); - ArrayList s5 = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - if(i % random == 0) { - s5.add(null); - }else{ - s5.add("test" + i % 10); - } - } - s.setString(7, s5, 10); - - s.columnDataAddBatch(); - s.columnDataExecuteBatch(); - s.columnDataCloseBatch(); - - String sql = "select * from weather_test"; - PreparedStatement statement = conn.prepareStatement(sql); - ResultSet rs = statement.executeQuery(); - int rows = 0; - while(rs.next()) { - rows++; - } - Assert.assertEquals(numOfRows, rows); - } - } - - @Test - public void bindDataSelectColumnTest() throws SQLException { - Statement stmt = conn.createStatement(); - - int numOfRows = 1000; - - for (int loop = 0; loop < 10; loop++){ - stmt.execute("drop table if exists weather_test"); - stmt.execute("create table weather_test(ts timestamp, f1 nchar(4), f2 float, f3 double, f4 timestamp, f5 int, f6 bool, f7 binary(10))"); - - TSDBPreparedStatement s = (TSDBPreparedStatement) conn.prepareStatement("insert into ? (ts, f1, f7) values(?, ?, ?)"); - Random r = new Random(); - s.setTableName("weather_test"); - - ArrayList ts = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - ts.add(System.currentTimeMillis() + i); - } - s.setTimestamp(0, ts); - - int random = 10 + r.nextInt(5); - ArrayList s2 = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - if(i % random == 0) { - s2.add(null); - }else{ - s2.add("分支" + i % 4); - } - } - s.setNString(1, s2, 4); - - random = 10 + r.nextInt(5); - ArrayList s3 = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - if(i % random == 0) { - s3.add(null); - }else{ - s3.add("test" + i % 10); - } - } - s.setString(2, s3, 10); - - s.columnDataAddBatch(); - s.columnDataExecuteBatch(); - s.columnDataCloseBatch(); - - String sql = "select * from weather_test"; - PreparedStatement statement = conn.prepareStatement(sql); - ResultSet rs = statement.executeQuery(); - int rows = 0; - while(rs.next()) { - rows++; - } - Assert.assertEquals(numOfRows, rows); - } - } - - @Test - public void bindDataWithSingleTagTest() throws SQLException { - Statement stmt = conn.createStatement(); - - String types[] = new String[] {"tinyint", "smallint", "int", "bigint", "bool", "float", "double", "binary(10)", "nchar(10)"}; - - for (String type : types) { - stmt.execute("drop table if exists weather_test"); - stmt.execute("create table weather_test(ts timestamp, f1 nchar(10), f2 binary(10)) tags (t " + type + ")"); - - int numOfRows = 1; - TSDBPreparedStatement s = (TSDBPreparedStatement) conn.prepareStatement("insert into ? using weather_test tags(?) values(?, ?, ?)"); - Random r = new Random(); - s.setTableName("w1"); - - switch(type) { - case "tinyint": - case "smallint": - case "int": - case "bigint": - s.setTagInt(0, 1); - break; - case "float": - s.setTagFloat(0, 1.23f); - break; - case "double": - s.setTagDouble(0, 3.14159265); - break; - case "bool": - s.setTagBoolean(0, true); - break; - case "binary(10)": - s.setTagString(0, "test"); - break; - case "nchar(10)": - s.setTagNString(0, "test"); - break; - default: - break; - } - - - ArrayList ts = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - ts.add(System.currentTimeMillis() + i); - } - s.setTimestamp(0, ts); - - int random = 10 + r.nextInt(5); - ArrayList s2 = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - s2.add("分支" + i % 4); - } - s.setNString(1, s2, 10); - - random = 10 + r.nextInt(5); - ArrayList s3 = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - s3.add("test" + i % 4); - } - s.setString(2, s3, 10); - - s.columnDataAddBatch(); - s.columnDataExecuteBatch(); - s.columnDataCloseBatch(); - - String sql = "select * from weather_test"; - PreparedStatement statement = conn.prepareStatement(sql); - ResultSet rs = statement.executeQuery(); - int rows = 0; - while(rs.next()) { - rows++; - } - Assert.assertEquals(numOfRows, rows); - } - } - - - @Test - public void bindDataWithMultipleTagsTest() throws SQLException { - Statement stmt = conn.createStatement(); - - stmt.execute("drop table if exists weather_test"); - stmt.execute("create table weather_test(ts timestamp, f1 nchar(10), f2 binary(10)) tags (t1 int, t2 binary(10))"); - - int numOfRows = 1; - - TSDBPreparedStatement s = (TSDBPreparedStatement) conn.prepareStatement("insert into ? using weather_test tags(?,?) (ts, f2) values(?, ?)"); - s.setTableName("w2"); - s.setTagInt(0, 1); - s.setTagString(1, "test"); - - - ArrayList ts = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - ts.add(System.currentTimeMillis() + i); - } - s.setTimestamp(0, ts); - - ArrayList s2 = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - s2.add("test" + i % 4); - } - s.setString(1, s2, 10); - - s.columnDataAddBatch(); - s.columnDataExecuteBatch(); - s.columnDataCloseBatch(); - - String sql = "select * from weather_test"; - PreparedStatement statement = conn.prepareStatement(sql); - ResultSet rs = statement.executeQuery(); - int rows = 0; - while(rs.next()) { - rows++; - } - Assert.assertEquals(numOfRows, rows); - - } - @Test public void setBoolean() throws SQLException { pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); From 0491aa9756815e3a829cd7c43e39ae8c2cddb8c5 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Mon, 7 Jun 2021 16:35:00 +0800 Subject: [PATCH 31/72] modify keep --- src/client/src/tscSQLParser.c | 68 +- src/inc/taosmsg.h | 2 +- src/inc/ttokendef.h | 45 +- src/mnode/inc/mnodeDef.h | 2 +- src/mnode/src/mnodeDb.c | 43 +- src/mnode/src/mnodeVgroup.c | 6 +- src/query/inc/sql.y | 11 +- src/query/src/sql.c | 2919 +++++++++++++++++---------------- src/util/src/terror.c | 2 +- 9 files changed, 1563 insertions(+), 1535 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index baa1538297..50b610d908 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -5819,9 +5819,11 @@ int32_t validateLimitNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlN } static int32_t setKeepOption(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDbInfo* pCreateDb) { - const char* msg = "invalid number of options"; + const char* msg1 = "invalid number of keep options"; + const char* msg2 = "invalid keep value"; + const char* msg3 = "invalid keep value, should be keep0 <= keep1 <= keep2"; - pMsg->daysToKeep = htonl(-1); + pMsg->daysToKeep0 = htonl(-1); pMsg->daysToKeep1 = htonl(-1); pMsg->daysToKeep2 = htonl(-1); @@ -5829,38 +5831,38 @@ static int32_t setKeepOption(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDbInfo* p if (pKeep != NULL) { size_t s = taosArrayGetSize(pKeep); tVariantListItem* p0 = taosArrayGet(pKeep, 0); - switch (s) { - case 1: { - if ((int32_t)p0->pVar.i64 <= 0) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg); - } - pMsg->daysToKeep = htonl((int32_t)p0->pVar.i64); - } - break; - case 2: { - tVariantListItem* p1 = taosArrayGet(pKeep, 1); - if ((int32_t)p0->pVar.i64 <= 0 || (int32_t)p1->pVar.i64 <= 0) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg); - } - pMsg->daysToKeep = htonl((int32_t)p0->pVar.i64); - pMsg->daysToKeep1 = htonl((int32_t)p1->pVar.i64); - break; - } - case 3: { - tVariantListItem* p1 = taosArrayGet(pKeep, 1); - tVariantListItem* p2 = taosArrayGet(pKeep, 2); - - if ((int32_t)p0->pVar.i64 <= 0 || (int32_t)p1->pVar.i64 <= 0 || (int32_t)p2->pVar.i64 <= 0) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg); - } - - pMsg->daysToKeep = htonl((int32_t)p0->pVar.i64); - pMsg->daysToKeep1 = htonl((int32_t)p1->pVar.i64); - pMsg->daysToKeep2 = htonl((int32_t)p2->pVar.i64); - break; - } - default: { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg); } + size_t expectNum = 1; +#ifdef _STORAGE + expectNum = 3; +#endif + if (s != expectNum) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } + + if ((int32_t)p0->pVar.i64 <= 0) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); + } + pMsg->daysToKeep0 = htonl((int32_t)p0->pVar.i64); + +#ifdef _STORAGE + tVariantListItem* p1 = taosArrayGet(pKeep, 1); + tVariantListItem* p2 = taosArrayGet(pKeep, 2); + + if ((int32_t)p1->pVar.i64 <= 0 || (int32_t)p2->pVar.i64 <= 0) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); + } + + if (!(((int32_t)p0->pVar.i64 <= (int32_t)p1->pVar.i64) && ((int32_t)p1->pVar.i64 <= (int32_t)p2->pVar.i64))) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); + } + + pMsg->daysToKeep1 = htonl((int32_t)p1->pVar.i64); + pMsg->daysToKeep2 = htonl((int32_t)p2->pVar.i64); +#else + UNUSED(msg3); + pMsg->daysToKeep1 = pMsg->daysToKeep0; + pMsg->daysToKeep2 = pMsg->daysToKeep0; +#endif } return TSDB_CODE_SUCCESS; diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index 15b1da1dd3..c7fe649748 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -548,7 +548,7 @@ typedef struct { int32_t totalBlocks; int32_t maxTables; int32_t daysPerFile; - int32_t daysToKeep; + int32_t daysToKeep0; int32_t daysToKeep1; int32_t daysToKeep2; int32_t minRowsPerFileBlock; diff --git a/src/inc/ttokendef.h b/src/inc/ttokendef.h index c7d630891b..ac453472fe 100644 --- a/src/inc/ttokendef.h +++ b/src/inc/ttokendef.h @@ -104,28 +104,28 @@ #define TK_QTIME 85 #define TK_CONNS 86 #define TK_STATE 87 -#define TK_KEEP 88 -#define TK_CACHE 89 -#define TK_REPLICA 90 -#define TK_QUORUM 91 -#define TK_DAYS 92 -#define TK_MINROWS 93 -#define TK_MAXROWS 94 -#define TK_BLOCKS 95 -#define TK_CTIME 96 -#define TK_WAL 97 -#define TK_FSYNC 98 -#define TK_COMP 99 -#define TK_PRECISION 100 -#define TK_UPDATE 101 -#define TK_CACHELAST 102 -#define TK_PARTITIONS 103 -#define TK_LP 104 -#define TK_RP 105 -#define TK_UNSIGNED 106 -#define TK_TAGS 107 -#define TK_USING 108 -#define TK_COMMA 109 +#define TK_COMMA 88 +#define TK_KEEP 89 +#define TK_CACHE 90 +#define TK_REPLICA 91 +#define TK_QUORUM 92 +#define TK_DAYS 93 +#define TK_MINROWS 94 +#define TK_MAXROWS 95 +#define TK_BLOCKS 96 +#define TK_CTIME 97 +#define TK_WAL 98 +#define TK_FSYNC 99 +#define TK_COMP 100 +#define TK_PRECISION 101 +#define TK_UPDATE 102 +#define TK_CACHELAST 103 +#define TK_PARTITIONS 104 +#define TK_LP 105 +#define TK_RP 106 +#define TK_UNSIGNED 107 +#define TK_TAGS 108 +#define TK_USING 109 #define TK_AS 110 #define TK_NULL 111 #define TK_SELECT 112 @@ -213,6 +213,7 @@ + #define TK_SPACE 300 #define TK_COMMENT 301 #define TK_ILLEGAL 302 diff --git a/src/mnode/inc/mnodeDef.h b/src/mnode/inc/mnodeDef.h index e052f34a33..45061dfabd 100644 --- a/src/mnode/inc/mnodeDef.h +++ b/src/mnode/inc/mnodeDef.h @@ -161,7 +161,7 @@ typedef struct { int32_t totalBlocks; int32_t maxTables; int32_t daysPerFile; - int32_t daysToKeep; + int32_t daysToKeep0; int32_t daysToKeep1; int32_t daysToKeep2; int32_t minRowsPerFileBlock; diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c index b0ac1192bb..4b5d05ebc7 100644 --- a/src/mnode/src/mnodeDb.c +++ b/src/mnode/src/mnodeDb.c @@ -261,26 +261,27 @@ static int32_t mnodeCheckDbCfg(SDbCfg *pCfg) { return TSDB_CODE_MND_INVALID_DB_OPTION_DAYS; } - if (pCfg->daysToKeep < TSDB_MIN_KEEP || pCfg->daysToKeep > TSDB_MAX_KEEP) { - mError("invalid db option daysToKeep:%d valid range: [%d, %d]", pCfg->daysToKeep, TSDB_MIN_KEEP, TSDB_MAX_KEEP); + if (pCfg->daysToKeep0 < TSDB_MIN_KEEP || pCfg->daysToKeep0 > TSDB_MAX_KEEP) { + mError("invalid db option daysToKeep:%d valid range: [%d, %d]", pCfg->daysToKeep0, TSDB_MIN_KEEP, TSDB_MAX_KEEP); return TSDB_CODE_MND_INVALID_DB_OPTION_KEEP; } - if (pCfg->daysToKeep < pCfg->daysPerFile) { - mError("invalid db option daysToKeep:%d should larger than daysPerFile:%d", pCfg->daysToKeep, pCfg->daysPerFile); + if (pCfg->daysToKeep0 < pCfg->daysPerFile) { + mError("invalid db option daysToKeep:%d should larger than daysPerFile:%d", pCfg->daysToKeep0, pCfg->daysPerFile); return TSDB_CODE_MND_INVALID_DB_OPTION_KEEP; } - if (pCfg->daysToKeep2 < TSDB_MIN_KEEP || pCfg->daysToKeep2 > pCfg->daysToKeep) { - mError("invalid db option daysToKeep2:%d valid range: [%d, %d]", pCfg->daysToKeep2, TSDB_MIN_KEEP, pCfg->daysToKeep); + if (pCfg->daysToKeep1 < pCfg->daysToKeep0 || pCfg->daysToKeep1 > TSDB_MAX_KEEP) { + mError("invalid db option daysToKeep1:%d valid range: [%d, %d]", pCfg->daysToKeep1, pCfg->daysToKeep0, TSDB_MAX_KEEP); return TSDB_CODE_MND_INVALID_DB_OPTION_KEEP; } - if (pCfg->daysToKeep1 < TSDB_MIN_KEEP || pCfg->daysToKeep1 > pCfg->daysToKeep2) { - mError("invalid db option daysToKeep1:%d valid range: [%d, %d]", pCfg->daysToKeep1, TSDB_MIN_KEEP, pCfg->daysToKeep2); + if (pCfg->daysToKeep2 < pCfg->daysToKeep1 || pCfg->daysToKeep2 > TSDB_MAX_KEEP) { + mError("invalid db option daysToKeep2:%d valid range: [%d, %d]", pCfg->daysToKeep2, pCfg->daysToKeep1, TSDB_MAX_KEEP); return TSDB_CODE_MND_INVALID_DB_OPTION_KEEP; } + if (pCfg->maxRowsPerFileBlock < TSDB_MIN_MAX_ROW_FBLOCK || pCfg->maxRowsPerFileBlock > TSDB_MAX_MAX_ROW_FBLOCK) { mError("invalid db option maxRowsPerFileBlock:%d valid range: [%d, %d]", pCfg->maxRowsPerFileBlock, TSDB_MIN_MAX_ROW_FBLOCK, TSDB_MAX_MAX_ROW_FBLOCK); @@ -378,9 +379,9 @@ static void mnodeSetDefaultDbCfg(SDbCfg *pCfg) { if (pCfg->totalBlocks < 0) pCfg->totalBlocks = tsBlocksPerVnode; if (pCfg->maxTables < 0) pCfg->maxTables = tsMaxTablePerVnode; if (pCfg->daysPerFile < 0) pCfg->daysPerFile = tsDaysPerFile; - if (pCfg->daysToKeep < 0) pCfg->daysToKeep = tsDaysToKeep; - if (pCfg->daysToKeep1 < 0) pCfg->daysToKeep1 = pCfg->daysToKeep; - if (pCfg->daysToKeep2 < 0) pCfg->daysToKeep2 = pCfg->daysToKeep; + if (pCfg->daysToKeep2 < 0) pCfg->daysToKeep2 = tsDaysToKeep; + if (pCfg->daysToKeep1 < 0) pCfg->daysToKeep1 = pCfg->daysToKeep2; + if (pCfg->daysToKeep0 < 0) pCfg->daysToKeep0 = pCfg->daysToKeep1; if (pCfg->minRowsPerFileBlock < 0) pCfg->minRowsPerFileBlock = tsMinRowsInFileBlock; if (pCfg->maxRowsPerFileBlock < 0) pCfg->maxRowsPerFileBlock = tsMaxRowsInFileBlock; if (pCfg->fsyncPeriod <0) pCfg->fsyncPeriod = tsFsyncPeriod; @@ -435,7 +436,7 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg * .totalBlocks = pCreate->totalBlocks, .maxTables = pCreate->maxTables, .daysPerFile = pCreate->daysPerFile, - .daysToKeep = pCreate->daysToKeep, + .daysToKeep0 = pCreate->daysToKeep0, .daysToKeep1 = pCreate->daysToKeep1, .daysToKeep2 = pCreate->daysToKeep2, .minRowsPerFileBlock = pCreate->minRowsPerFileBlock, @@ -777,7 +778,7 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; char tmp[128] = {0}; - sprintf(tmp, "%d,%d,%d", pDb->cfg.daysToKeep1, pDb->cfg.daysToKeep2, pDb->cfg.daysToKeep); + sprintf(tmp, "%d,%d,%d", pDb->cfg.daysToKeep0, pDb->cfg.daysToKeep1, pDb->cfg.daysToKeep2); STR_WITH_SIZE_TO_VARSTR(pWrite, tmp, strlen(tmp)); cols++; @@ -890,7 +891,7 @@ static int32_t mnodeProcessCreateDbMsg(SMnodeMsg *pMsg) { pCreate->cacheBlockSize = htonl(pCreate->cacheBlockSize); pCreate->totalBlocks = htonl(pCreate->totalBlocks); pCreate->daysPerFile = htonl(pCreate->daysPerFile); - pCreate->daysToKeep = htonl(pCreate->daysToKeep); + pCreate->daysToKeep0 = htonl(pCreate->daysToKeep0); pCreate->daysToKeep1 = htonl(pCreate->daysToKeep1); pCreate->daysToKeep2 = htonl(pCreate->daysToKeep2); pCreate->commitTime = htonl(pCreate->commitTime); @@ -917,7 +918,7 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) { int32_t cacheBlockSize = htonl(pAlter->cacheBlockSize); int32_t totalBlocks = htonl(pAlter->totalBlocks); int32_t daysPerFile = htonl(pAlter->daysPerFile); - int32_t daysToKeep = htonl(pAlter->daysToKeep); + int32_t daysToKeep0 = htonl(pAlter->daysToKeep0); int32_t daysToKeep1 = htonl(pAlter->daysToKeep1); int32_t daysToKeep2 = htonl(pAlter->daysToKeep2); int32_t minRows = htonl(pAlter->minRowsPerFileBlock); @@ -960,9 +961,9 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) { terrno = TSDB_CODE_MND_INVALID_DB_OPTION; } - if (daysToKeep > 0 && daysToKeep != pDb->cfg.daysToKeep) { - mDebug("db:%s, daysToKeep:%d change to %d", pDb->name, pDb->cfg.daysToKeep, daysToKeep); - newCfg.daysToKeep = daysToKeep; + if (daysToKeep0 > 0 && daysToKeep0 != pDb->cfg.daysToKeep0) { + mDebug("db:%s, daysToKeep:%d change to %d", pDb->name, pDb->cfg.daysToKeep0, daysToKeep0); + newCfg.daysToKeep0 = daysToKeep0; } if (daysToKeep1 > 0 && daysToKeep1 != pDb->cfg.daysToKeep1) { @@ -1063,8 +1064,8 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) { // community version can only change daysToKeep // but enterprise version can change all daysToKeep options #ifndef _STORAGE - newCfg.daysToKeep1 = newCfg.daysToKeep; - newCfg.daysToKeep2 = newCfg.daysToKeep; + newCfg.daysToKeep1 = newCfg.daysToKeep0; + newCfg.daysToKeep2 = newCfg.daysToKeep0; #endif return newCfg; @@ -1304,4 +1305,4 @@ int32_t mnodeCompactDbs() { mInfo("end to compact dbs table..."); return 0; -} \ No newline at end of file +} diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index a64d256484..2e138ab890 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -894,9 +894,9 @@ static SCreateVnodeMsg *mnodeBuildVnodeMsg(SVgObj *pVgroup) { pCfg->totalBlocks = htonl(pDb->cfg.totalBlocks); pCfg->maxTables = htonl(maxTables + 1); pCfg->daysPerFile = htonl(pDb->cfg.daysPerFile); - pCfg->daysToKeep = htonl(pDb->cfg.daysToKeep); - pCfg->daysToKeep1 = htonl(pDb->cfg.daysToKeep1); - pCfg->daysToKeep2 = htonl(pDb->cfg.daysToKeep2); + pCfg->daysToKeep = htonl(pDb->cfg.daysToKeep2); //FROM DB TO VNODE MAP + pCfg->daysToKeep1 = htonl(pDb->cfg.daysToKeep0); + pCfg->daysToKeep2 = htonl(pDb->cfg.daysToKeep1); pCfg->minRowsPerFileBlock = htonl(pDb->cfg.minRowsPerFileBlock); pCfg->maxRowsPerFileBlock = htonl(pDb->cfg.maxRowsPerFileBlock); pCfg->fsyncPeriod = htonl(pDb->cfg.fsyncPeriod); diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index 01eaf3bbb6..117a2bd27f 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -238,9 +238,18 @@ acct_optr(Y) ::= pps(C) tseries(D) storage(P) streams(F) qtime(Q) dbs(E) users(K Y.stat = M; } +%type intitemlist {SArray*} +%destructor intitemlist {taosArrayDestroy($$);} + +%type intitem {tVariant} +intitemlist(A) ::= intitemlist(X) COMMA intitem(Y). { A = tVariantListAppend(X, &Y, -1); } +intitemlist(A) ::= intitem(X). { A = tVariantListAppend(NULL, &X, -1); } + +intitem(A) ::= INTEGER(X). { toTSDBType(X.type); tVariantCreate(&A, &X); } + %type keep {SArray*} %destructor keep {taosArrayDestroy($$);} -keep(Y) ::= KEEP tagitemlist(X). { Y = X; } +keep(Y) ::= KEEP intitemlist(X). { Y = X; } cache(Y) ::= CACHE INTEGER(X). { Y = X; } replica(Y) ::= REPLICA INTEGER(X). { Y = X; } diff --git a/src/query/src/sql.c b/src/query/src/sql.c index 0d11153e8e..44428d1517 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -100,28 +100,28 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 266 +#define YYNOCODE 268 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SStrToken typedef union { int yyinit; ParseTOKENTYPE yy0; - TAOS_FIELD yy27; - SWindowStateVal yy76; - SCreateDbInfo yy114; - SSqlNode* yy124; - SCreateAcctInfo yy183; - SCreatedTableInfo yy192; - SArray* yy193; - SCreateTableSql* yy270; - int yy312; - SRelationInfo* yy332; - SIntervalVal yy392; + SCreateDbInfo yy22; + TAOS_FIELD yy47; + SRelationInfo* yy52; + SCreateAcctInfo yy83; + SSessionWindowVal yy84; + tSqlExpr* yy162; + SWindowStateVal yy176; + int yy196; + SLimitVal yy230; + SArray* yy325; + SIntervalVal yy328; + int64_t yy373; + SCreateTableSql* yy422; tVariant yy442; - SSessionWindowVal yy447; - tSqlExpr* yy454; - int64_t yy473; - SLimitVal yy482; + SCreatedTableInfo yy504; + SSqlNode* yy536; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -137,18 +137,18 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 341 -#define YYNRULE 280 -#define YYNRULE_WITH_ACTION 280 +#define YYNSTATE 342 +#define YYNRULE 283 +#define YYNRULE_WITH_ACTION 283 #define YYNTOKEN 189 -#define YY_MAX_SHIFT 340 -#define YY_MIN_SHIFTREDUCE 538 -#define YY_MAX_SHIFTREDUCE 817 -#define YY_ERROR_ACTION 818 -#define YY_ACCEPT_ACTION 819 -#define YY_NO_ACTION 820 -#define YY_MIN_REDUCE 821 -#define YY_MAX_REDUCE 1100 +#define YY_MAX_SHIFT 341 +#define YY_MIN_SHIFTREDUCE 542 +#define YY_MAX_SHIFTREDUCE 824 +#define YY_ERROR_ACTION 825 +#define YY_ACCEPT_ACTION 826 +#define YY_NO_ACTION 827 +#define YY_MIN_REDUCE 828 +#define YY_MAX_REDUCE 1110 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -215,277 +215,277 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (722) +#define YY_ACTTAB_COUNT (724) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 989, 586, 217, 338, 954, 22, 223, 192, 194, 587, - /* 10 */ 819, 340, 198, 52, 53, 151, 56, 57, 226, 1077, - /* 20 */ 229, 46, 283, 55, 282, 60, 58, 62, 59, 1073, - /* 30 */ 665, 194, 968, 51, 50, 194, 234, 49, 48, 47, - /* 40 */ 52, 53, 1076, 56, 57, 225, 1077, 229, 46, 586, - /* 50 */ 55, 282, 60, 58, 62, 59, 980, 587, 314, 313, - /* 60 */ 51, 50, 968, 986, 49, 48, 47, 53, 35, 56, - /* 70 */ 57, 144, 258, 229, 46, 75, 55, 282, 60, 58, - /* 80 */ 62, 59, 279, 298, 87, 867, 51, 50, 94, 178, - /* 90 */ 49, 48, 47, 539, 540, 541, 542, 543, 544, 545, - /* 100 */ 546, 547, 548, 549, 550, 551, 339, 953, 298, 218, - /* 110 */ 76, 586, 964, 52, 53, 35, 56, 57, 775, 587, - /* 120 */ 229, 46, 956, 55, 282, 60, 58, 62, 59, 49, - /* 130 */ 48, 47, 756, 51, 50, 265, 264, 49, 48, 47, - /* 140 */ 52, 54, 980, 56, 57, 324, 980, 229, 46, 586, - /* 150 */ 55, 282, 60, 58, 62, 59, 219, 587, 220, 965, - /* 160 */ 51, 50, 221, 1072, 49, 48, 47, 28, 296, 333, - /* 170 */ 332, 295, 294, 293, 331, 292, 330, 329, 328, 291, - /* 180 */ 327, 326, 928, 35, 916, 917, 918, 919, 920, 921, - /* 190 */ 922, 923, 924, 925, 926, 927, 929, 930, 56, 57, - /* 200 */ 876, 1071, 229, 46, 178, 55, 282, 60, 58, 62, - /* 210 */ 59, 962, 23, 91, 29, 51, 50, 1, 166, 49, - /* 220 */ 48, 47, 228, 771, 232, 79, 760, 965, 763, 203, - /* 230 */ 766, 228, 771, 261, 13, 760, 204, 763, 93, 766, - /* 240 */ 90, 128, 127, 202, 951, 952, 34, 955, 60, 58, - /* 250 */ 62, 59, 89, 235, 214, 215, 51, 50, 281, 151, - /* 260 */ 49, 48, 47, 214, 215, 762, 77, 765, 28, 1096, - /* 270 */ 333, 332, 82, 35, 35, 331, 701, 330, 329, 328, - /* 280 */ 41, 327, 326, 8, 936, 51, 50, 934, 935, 49, - /* 290 */ 48, 47, 937, 868, 939, 940, 938, 178, 941, 942, - /* 300 */ 113, 107, 118, 257, 239, 74, 704, 117, 123, 126, - /* 310 */ 116, 242, 211, 35, 233, 303, 120, 965, 965, 689, - /* 320 */ 212, 761, 686, 764, 687, 61, 688, 213, 1026, 35, - /* 330 */ 277, 35, 772, 1036, 61, 5, 38, 168, 768, 151, - /* 340 */ 196, 772, 167, 101, 96, 100, 35, 768, 35, 151, - /* 350 */ 245, 246, 35, 35, 304, 767, 236, 965, 186, 184, - /* 360 */ 182, 142, 140, 139, 767, 181, 131, 130, 129, 334, - /* 370 */ 305, 243, 306, 965, 240, 965, 238, 769, 302, 301, - /* 380 */ 82, 244, 968, 241, 708, 309, 308, 310, 41, 311, - /* 390 */ 965, 250, 965, 312, 316, 968, 965, 965, 3, 179, - /* 400 */ 254, 253, 337, 336, 136, 115, 966, 80, 1025, 259, - /* 410 */ 324, 737, 738, 36, 758, 261, 720, 728, 88, 729, - /* 420 */ 146, 66, 227, 25, 67, 792, 197, 773, 690, 24, - /* 430 */ 675, 24, 70, 770, 36, 285, 677, 287, 676, 36, - /* 440 */ 66, 92, 66, 33, 125, 124, 288, 68, 199, 15, - /* 450 */ 759, 14, 106, 71, 105, 193, 200, 17, 19, 16, - /* 460 */ 18, 201, 73, 112, 664, 111, 6, 207, 693, 691, - /* 470 */ 694, 692, 208, 206, 21, 1035, 20, 1088, 191, 205, - /* 480 */ 195, 967, 230, 255, 1032, 1031, 231, 315, 44, 143, - /* 490 */ 988, 1018, 999, 996, 1017, 997, 981, 262, 1001, 145, - /* 500 */ 149, 271, 162, 963, 141, 114, 266, 222, 719, 268, - /* 510 */ 158, 275, 154, 163, 978, 152, 155, 276, 961, 164, - /* 520 */ 165, 280, 153, 72, 156, 63, 879, 69, 290, 278, - /* 530 */ 42, 274, 189, 39, 299, 875, 300, 1095, 103, 1094, - /* 540 */ 1091, 169, 307, 1087, 109, 1086, 1083, 170, 897, 40, - /* 550 */ 272, 37, 43, 190, 270, 864, 119, 862, 121, 122, - /* 560 */ 267, 860, 859, 247, 180, 857, 856, 855, 854, 853, - /* 570 */ 852, 183, 185, 849, 847, 845, 843, 187, 840, 188, - /* 580 */ 45, 260, 78, 83, 325, 269, 1019, 317, 318, 319, - /* 590 */ 320, 321, 322, 323, 335, 817, 248, 216, 237, 289, - /* 600 */ 249, 816, 251, 252, 209, 210, 97, 98, 815, 798, - /* 610 */ 797, 256, 261, 263, 858, 696, 284, 9, 132, 851, - /* 620 */ 173, 133, 172, 898, 171, 174, 175, 177, 176, 4, - /* 630 */ 134, 850, 842, 932, 135, 30, 841, 81, 84, 721, - /* 640 */ 2, 161, 159, 157, 160, 147, 944, 724, 148, 85, - /* 650 */ 224, 726, 86, 273, 10, 730, 150, 11, 776, 774, - /* 660 */ 31, 7, 32, 12, 26, 286, 27, 95, 628, 93, - /* 670 */ 624, 622, 621, 620, 617, 297, 99, 590, 64, 36, - /* 680 */ 65, 102, 667, 666, 104, 108, 663, 612, 610, 602, - /* 690 */ 608, 604, 606, 600, 598, 631, 110, 630, 629, 627, - /* 700 */ 626, 625, 623, 619, 618, 588, 555, 553, 66, 821, - /* 710 */ 820, 820, 137, 820, 820, 820, 820, 820, 820, 820, - /* 720 */ 820, 138, + /* 0 */ 22, 590, 193, 999, 195, 144, 218, 339, 195, 591, + /* 10 */ 622, 826, 341, 52, 53, 1086, 56, 57, 227, 1087, + /* 20 */ 230, 46, 590, 55, 283, 60, 58, 62, 59, 964, + /* 30 */ 591, 199, 224, 51, 50, 195, 978, 49, 48, 47, + /* 40 */ 52, 53, 34, 56, 57, 226, 1087, 230, 46, 590, + /* 50 */ 55, 283, 60, 58, 62, 59, 151, 591, 235, 990, + /* 60 */ 51, 50, 978, 151, 49, 48, 47, 53, 996, 56, + /* 70 */ 57, 266, 265, 230, 46, 259, 55, 283, 60, 58, + /* 80 */ 62, 59, 1083, 75, 220, 151, 51, 50, 975, 151, + /* 90 */ 49, 48, 47, 543, 544, 545, 546, 547, 548, 549, + /* 100 */ 550, 551, 552, 553, 554, 555, 340, 246, 299, 219, + /* 110 */ 76, 52, 53, 237, 56, 57, 963, 978, 230, 46, + /* 120 */ 94, 55, 283, 60, 58, 62, 59, 1036, 990, 278, + /* 130 */ 299, 51, 50, 763, 1035, 49, 48, 47, 52, 54, + /* 140 */ 82, 56, 57, 976, 221, 230, 46, 41, 55, 283, + /* 150 */ 60, 58, 62, 59, 280, 966, 87, 874, 51, 50, + /* 160 */ 88, 178, 49, 48, 47, 325, 40, 297, 334, 333, + /* 170 */ 296, 295, 294, 332, 293, 331, 330, 329, 292, 328, + /* 180 */ 327, 938, 926, 927, 928, 929, 930, 931, 932, 933, + /* 190 */ 934, 935, 936, 937, 939, 940, 56, 57, 34, 990, + /* 200 */ 230, 46, 972, 55, 283, 60, 58, 62, 59, 49, + /* 210 */ 48, 47, 23, 51, 50, 222, 977, 49, 48, 47, + /* 220 */ 229, 778, 1082, 34, 767, 769, 770, 772, 773, 204, + /* 230 */ 34, 229, 778, 335, 907, 767, 205, 770, 672, 773, + /* 240 */ 233, 128, 127, 203, 975, 1081, 236, 34, 40, 115, + /* 250 */ 334, 333, 215, 216, 325, 332, 282, 331, 330, 329, + /* 260 */ 89, 328, 327, 215, 216, 213, 315, 314, 946, 974, + /* 270 */ 944, 945, 234, 82, 77, 947, 975, 949, 950, 948, + /* 280 */ 41, 951, 952, 60, 58, 62, 59, 711, 768, 304, + /* 290 */ 771, 51, 50, 975, 590, 49, 48, 47, 34, 113, + /* 300 */ 107, 118, 591, 258, 1106, 74, 117, 123, 126, 116, + /* 310 */ 240, 696, 212, 251, 693, 120, 694, 245, 695, 5, + /* 320 */ 37, 168, 255, 254, 61, 214, 167, 101, 96, 100, + /* 330 */ 779, 34, 1, 166, 91, 61, 775, 776, 3, 179, + /* 340 */ 305, 779, 242, 243, 975, 197, 284, 775, 187, 185, + /* 350 */ 183, 744, 745, 774, 1098, 182, 131, 130, 129, 34, + /* 360 */ 708, 34, 34, 765, 774, 715, 961, 962, 33, 965, + /* 370 */ 51, 50, 198, 306, 49, 48, 47, 975, 35, 34, + /* 380 */ 241, 34, 239, 200, 303, 302, 67, 247, 8, 244, + /* 390 */ 13, 310, 309, 883, 93, 90, 260, 178, 28, 766, + /* 400 */ 777, 307, 875, 311, 312, 975, 178, 975, 975, 338, + /* 410 */ 337, 136, 142, 140, 139, 146, 64, 79, 25, 80, + /* 420 */ 697, 313, 24, 317, 262, 975, 262, 975, 24, 228, + /* 430 */ 68, 70, 194, 727, 735, 35, 736, 35, 201, 64, + /* 440 */ 799, 92, 782, 15, 64, 14, 780, 32, 202, 106, + /* 450 */ 289, 105, 44, 682, 17, 286, 16, 684, 19, 288, + /* 460 */ 18, 700, 683, 701, 112, 698, 111, 699, 73, 208, + /* 470 */ 671, 125, 124, 71, 6, 21, 1046, 20, 209, 207, + /* 480 */ 192, 206, 1045, 196, 231, 1042, 256, 143, 1041, 232, + /* 490 */ 316, 998, 1009, 1006, 1007, 1011, 1028, 145, 149, 991, + /* 500 */ 263, 141, 1027, 973, 272, 162, 163, 942, 971, 164, + /* 510 */ 165, 726, 886, 291, 42, 190, 38, 988, 300, 281, + /* 520 */ 153, 882, 152, 156, 301, 1105, 72, 103, 267, 223, + /* 530 */ 1104, 1101, 69, 169, 269, 276, 63, 308, 1097, 279, + /* 540 */ 109, 154, 277, 275, 1096, 155, 1093, 170, 273, 904, + /* 550 */ 39, 36, 43, 191, 157, 271, 871, 119, 869, 121, + /* 560 */ 122, 268, 867, 866, 248, 181, 864, 863, 862, 861, + /* 570 */ 860, 859, 184, 186, 856, 854, 852, 850, 188, 847, + /* 580 */ 189, 45, 261, 78, 83, 270, 1029, 326, 114, 318, + /* 590 */ 319, 320, 321, 322, 323, 217, 324, 238, 290, 336, + /* 600 */ 824, 249, 210, 211, 97, 98, 250, 823, 252, 253, + /* 610 */ 822, 257, 805, 804, 285, 262, 9, 173, 177, 865, + /* 620 */ 905, 171, 172, 174, 176, 175, 132, 133, 858, 906, + /* 630 */ 2, 134, 857, 4, 135, 849, 81, 848, 703, 29, + /* 640 */ 264, 84, 160, 158, 159, 161, 148, 728, 147, 85, + /* 650 */ 954, 731, 733, 86, 225, 274, 30, 737, 31, 150, + /* 660 */ 10, 11, 781, 95, 7, 12, 783, 26, 27, 287, + /* 670 */ 635, 631, 629, 93, 628, 627, 624, 594, 298, 99, + /* 680 */ 65, 35, 674, 102, 66, 673, 670, 616, 104, 614, + /* 690 */ 108, 606, 612, 608, 610, 604, 602, 638, 110, 637, + /* 700 */ 636, 634, 633, 632, 630, 626, 625, 180, 592, 559, + /* 710 */ 557, 828, 827, 827, 137, 827, 827, 827, 827, 827, + /* 720 */ 827, 827, 827, 138, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 192, 1, 191, 192, 0, 254, 211, 254, 254, 9, - /* 10 */ 189, 190, 254, 13, 14, 192, 16, 17, 264, 265, - /* 20 */ 20, 21, 15, 23, 24, 25, 26, 27, 28, 254, - /* 30 */ 5, 254, 237, 33, 34, 254, 211, 37, 38, 39, - /* 40 */ 13, 14, 265, 16, 17, 264, 265, 20, 21, 1, - /* 50 */ 23, 24, 25, 26, 27, 28, 235, 9, 33, 34, - /* 60 */ 33, 34, 237, 255, 37, 38, 39, 14, 192, 16, - /* 70 */ 17, 192, 251, 20, 21, 198, 23, 24, 25, 26, - /* 80 */ 27, 28, 259, 79, 261, 197, 33, 34, 198, 201, + /* 0 */ 256, 1, 256, 192, 256, 192, 191, 192, 256, 9, + /* 10 */ 5, 189, 190, 13, 14, 267, 16, 17, 266, 267, + /* 20 */ 20, 21, 1, 23, 24, 25, 26, 27, 28, 0, + /* 30 */ 9, 256, 235, 33, 34, 256, 239, 37, 38, 39, + /* 40 */ 13, 14, 192, 16, 17, 266, 267, 20, 21, 1, + /* 50 */ 23, 24, 25, 26, 27, 28, 192, 9, 235, 237, + /* 60 */ 33, 34, 239, 192, 37, 38, 39, 14, 257, 16, + /* 70 */ 17, 258, 259, 20, 21, 253, 23, 24, 25, 26, + /* 80 */ 27, 28, 256, 198, 234, 192, 33, 34, 238, 192, /* 90 */ 37, 38, 39, 45, 46, 47, 48, 49, 50, 51, - /* 100 */ 52, 53, 54, 55, 56, 57, 58, 230, 79, 61, - /* 110 */ 110, 1, 236, 13, 14, 192, 16, 17, 111, 9, - /* 120 */ 20, 21, 232, 23, 24, 25, 26, 27, 28, 37, - /* 130 */ 38, 39, 105, 33, 34, 256, 257, 37, 38, 39, - /* 140 */ 13, 14, 235, 16, 17, 81, 235, 20, 21, 1, - /* 150 */ 23, 24, 25, 26, 27, 28, 233, 9, 251, 236, - /* 160 */ 33, 34, 251, 254, 37, 38, 39, 88, 89, 90, - /* 170 */ 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, - /* 180 */ 101, 102, 210, 192, 212, 213, 214, 215, 216, 217, - /* 190 */ 218, 219, 220, 221, 222, 223, 224, 225, 16, 17, - /* 200 */ 197, 254, 20, 21, 201, 23, 24, 25, 26, 27, - /* 210 */ 28, 192, 44, 198, 104, 33, 34, 199, 200, 37, - /* 220 */ 38, 39, 1, 2, 233, 105, 5, 236, 7, 61, - /* 230 */ 9, 1, 2, 113, 104, 5, 68, 7, 108, 9, - /* 240 */ 110, 73, 74, 75, 229, 230, 231, 232, 25, 26, - /* 250 */ 27, 28, 238, 234, 33, 34, 33, 34, 37, 192, - /* 260 */ 37, 38, 39, 33, 34, 5, 252, 7, 88, 237, - /* 270 */ 90, 91, 104, 192, 192, 95, 109, 97, 98, 99, - /* 280 */ 112, 101, 102, 116, 210, 33, 34, 213, 214, 37, - /* 290 */ 38, 39, 218, 197, 220, 221, 222, 201, 224, 225, - /* 300 */ 62, 63, 64, 135, 68, 137, 37, 69, 70, 71, - /* 310 */ 72, 68, 144, 192, 233, 233, 78, 236, 236, 2, - /* 320 */ 254, 5, 5, 7, 7, 104, 9, 254, 261, 192, - /* 330 */ 263, 192, 111, 228, 104, 62, 63, 64, 117, 192, - /* 340 */ 254, 111, 69, 70, 71, 72, 192, 117, 192, 192, - /* 350 */ 33, 34, 192, 192, 233, 134, 211, 236, 62, 63, - /* 360 */ 64, 62, 63, 64, 134, 69, 70, 71, 72, 211, - /* 370 */ 233, 192, 233, 236, 138, 236, 140, 117, 142, 143, - /* 380 */ 104, 138, 237, 140, 115, 142, 143, 233, 112, 233, - /* 390 */ 236, 136, 236, 233, 233, 237, 236, 236, 195, 196, - /* 400 */ 145, 146, 65, 66, 67, 76, 227, 105, 261, 105, - /* 410 */ 81, 125, 126, 109, 1, 113, 105, 105, 261, 105, - /* 420 */ 109, 109, 60, 109, 109, 105, 254, 105, 111, 109, - /* 430 */ 105, 109, 109, 117, 109, 105, 105, 105, 105, 109, - /* 440 */ 109, 109, 109, 104, 76, 77, 107, 132, 254, 139, - /* 450 */ 37, 141, 139, 130, 141, 254, 254, 139, 139, 141, - /* 460 */ 141, 254, 104, 139, 106, 141, 104, 254, 5, 5, - /* 470 */ 7, 7, 254, 254, 139, 228, 141, 237, 254, 254, - /* 480 */ 254, 237, 228, 192, 228, 228, 228, 228, 253, 192, - /* 490 */ 192, 262, 192, 192, 262, 192, 235, 235, 192, 192, - /* 500 */ 192, 192, 239, 235, 60, 87, 258, 258, 117, 258, - /* 510 */ 243, 258, 247, 192, 250, 249, 246, 122, 192, 192, - /* 520 */ 192, 123, 248, 129, 245, 128, 192, 131, 192, 127, - /* 530 */ 192, 121, 192, 192, 192, 192, 192, 192, 192, 192, - /* 540 */ 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - /* 550 */ 120, 192, 192, 192, 119, 192, 192, 192, 192, 192, - /* 560 */ 118, 192, 192, 192, 192, 192, 192, 192, 192, 192, + /* 100 */ 52, 53, 54, 55, 56, 57, 58, 192, 79, 61, + /* 110 */ 110, 13, 14, 235, 16, 17, 231, 239, 20, 21, + /* 120 */ 198, 23, 24, 25, 26, 27, 28, 263, 237, 265, + /* 130 */ 79, 33, 34, 106, 263, 37, 38, 39, 13, 14, + /* 140 */ 105, 16, 17, 228, 253, 20, 21, 112, 23, 24, + /* 150 */ 25, 26, 27, 28, 261, 233, 263, 197, 33, 34, + /* 160 */ 263, 201, 37, 38, 39, 81, 89, 90, 91, 92, + /* 170 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, + /* 180 */ 103, 212, 213, 214, 215, 216, 217, 218, 219, 220, + /* 190 */ 221, 222, 223, 224, 225, 226, 16, 17, 192, 237, + /* 200 */ 20, 21, 192, 23, 24, 25, 26, 27, 28, 37, + /* 210 */ 38, 39, 44, 33, 34, 253, 239, 37, 38, 39, + /* 220 */ 1, 2, 256, 192, 5, 5, 7, 7, 9, 61, + /* 230 */ 192, 1, 2, 210, 211, 5, 68, 7, 5, 9, + /* 240 */ 234, 73, 74, 75, 238, 256, 236, 192, 89, 76, + /* 250 */ 91, 92, 33, 34, 81, 96, 37, 98, 99, 100, + /* 260 */ 240, 102, 103, 33, 34, 256, 33, 34, 212, 238, + /* 270 */ 214, 215, 234, 105, 254, 219, 238, 221, 222, 223, + /* 280 */ 112, 225, 226, 25, 26, 27, 28, 37, 5, 234, + /* 290 */ 7, 33, 34, 238, 1, 37, 38, 39, 192, 62, + /* 300 */ 63, 64, 9, 135, 239, 137, 69, 70, 71, 72, + /* 310 */ 68, 2, 144, 136, 5, 78, 7, 68, 9, 62, + /* 320 */ 63, 64, 145, 146, 105, 256, 69, 70, 71, 72, + /* 330 */ 111, 192, 199, 200, 198, 105, 117, 117, 195, 196, + /* 340 */ 234, 111, 33, 34, 238, 256, 15, 117, 62, 63, + /* 350 */ 64, 125, 126, 134, 239, 69, 70, 71, 72, 192, + /* 360 */ 88, 192, 192, 1, 134, 115, 230, 231, 232, 233, + /* 370 */ 33, 34, 256, 234, 37, 38, 39, 238, 88, 192, + /* 380 */ 138, 192, 140, 256, 142, 143, 88, 138, 116, 140, + /* 390 */ 105, 142, 143, 197, 109, 110, 106, 201, 105, 37, + /* 400 */ 117, 234, 197, 234, 234, 238, 201, 238, 238, 65, + /* 410 */ 66, 67, 62, 63, 64, 88, 88, 106, 88, 106, + /* 420 */ 111, 234, 88, 234, 113, 238, 113, 238, 88, 60, + /* 430 */ 132, 88, 256, 106, 106, 88, 106, 88, 256, 88, + /* 440 */ 106, 88, 111, 139, 88, 141, 106, 105, 256, 139, + /* 450 */ 108, 141, 255, 106, 139, 106, 141, 106, 139, 106, + /* 460 */ 141, 5, 106, 7, 139, 5, 141, 7, 105, 256, + /* 470 */ 107, 76, 77, 130, 105, 139, 229, 141, 256, 256, + /* 480 */ 256, 256, 229, 256, 229, 229, 192, 192, 229, 229, + /* 490 */ 229, 192, 192, 192, 192, 192, 264, 192, 192, 237, + /* 500 */ 237, 60, 264, 237, 192, 241, 192, 227, 192, 192, + /* 510 */ 192, 117, 192, 192, 192, 192, 192, 252, 192, 123, + /* 520 */ 250, 192, 251, 247, 192, 192, 129, 192, 260, 260, + /* 530 */ 192, 192, 131, 192, 260, 260, 128, 192, 192, 127, + /* 540 */ 192, 249, 122, 121, 192, 248, 192, 192, 120, 192, + /* 550 */ 192, 192, 192, 192, 246, 119, 192, 192, 192, 192, + /* 560 */ 192, 118, 192, 192, 192, 192, 192, 192, 192, 192, /* 570 */ 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - /* 580 */ 133, 193, 193, 193, 103, 193, 193, 86, 50, 83, - /* 590 */ 85, 54, 84, 82, 79, 5, 147, 193, 193, 193, - /* 600 */ 5, 5, 147, 5, 193, 193, 198, 198, 5, 90, - /* 610 */ 89, 136, 113, 109, 193, 105, 107, 104, 194, 193, - /* 620 */ 203, 194, 207, 209, 208, 206, 204, 202, 205, 195, - /* 630 */ 194, 193, 193, 226, 194, 104, 193, 114, 109, 105, - /* 640 */ 199, 240, 242, 244, 241, 104, 226, 105, 109, 104, - /* 650 */ 1, 105, 104, 104, 124, 105, 104, 124, 111, 105, - /* 660 */ 109, 104, 109, 104, 104, 107, 104, 76, 9, 108, - /* 670 */ 5, 5, 5, 5, 5, 15, 76, 80, 16, 109, - /* 680 */ 16, 141, 5, 5, 141, 141, 105, 5, 5, 5, - /* 690 */ 5, 5, 5, 5, 5, 5, 141, 5, 5, 5, - /* 700 */ 5, 5, 5, 5, 5, 80, 60, 59, 109, 0, - /* 710 */ 266, 266, 21, 266, 266, 266, 266, 266, 266, 266, - /* 720 */ 266, 21, 266, 266, 266, 266, 266, 266, 266, 266, - /* 730 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 740 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 750 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 760 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 770 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 780 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 790 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 800 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 810 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 820 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 830 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 840 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 850 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 860 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 870 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 880 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 890 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 900 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 910 */ 266, + /* 580 */ 192, 133, 193, 193, 193, 193, 193, 104, 87, 86, + /* 590 */ 50, 83, 85, 54, 84, 193, 82, 193, 193, 79, + /* 600 */ 5, 147, 193, 193, 198, 198, 5, 5, 147, 5, + /* 610 */ 5, 136, 91, 90, 108, 113, 105, 203, 202, 193, + /* 620 */ 209, 208, 207, 206, 205, 204, 194, 194, 193, 211, + /* 630 */ 199, 194, 193, 195, 194, 193, 114, 193, 106, 105, + /* 640 */ 88, 88, 243, 245, 244, 242, 88, 106, 105, 105, + /* 650 */ 227, 106, 106, 105, 1, 105, 88, 106, 88, 105, + /* 660 */ 124, 124, 106, 76, 105, 105, 111, 105, 105, 108, + /* 670 */ 9, 5, 5, 109, 5, 5, 5, 80, 15, 76, + /* 680 */ 16, 88, 5, 141, 16, 5, 106, 5, 141, 5, + /* 690 */ 141, 5, 5, 5, 5, 5, 5, 5, 141, 5, + /* 700 */ 5, 5, 5, 5, 5, 5, 5, 88, 80, 60, + /* 710 */ 59, 0, 268, 268, 21, 268, 268, 268, 268, 268, + /* 720 */ 268, 268, 268, 21, 268, 268, 268, 268, 268, 268, + /* 730 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 740 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 750 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 760 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 770 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 780 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 790 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 800 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 810 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 820 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 830 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 840 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 850 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 860 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 870 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 880 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 890 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 900 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 910 */ 268, 268, 268, }; -#define YY_SHIFT_COUNT (340) +#define YY_SHIFT_COUNT (341) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (709) +#define YY_SHIFT_MAX (711) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 168, 79, 79, 180, 180, 29, 221, 230, 110, 148, - /* 10 */ 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, - /* 20 */ 148, 148, 0, 48, 230, 317, 317, 317, 317, 276, - /* 30 */ 276, 148, 148, 148, 4, 148, 148, 329, 29, 64, - /* 40 */ 64, 722, 722, 722, 230, 230, 230, 230, 230, 230, + /* 0 */ 168, 77, 77, 159, 159, 51, 219, 230, 293, 21, + /* 10 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + /* 20 */ 21, 21, 0, 48, 230, 309, 309, 309, 35, 35, + /* 30 */ 21, 21, 21, 29, 21, 21, 173, 51, 84, 84, + /* 40 */ 5, 724, 724, 724, 230, 230, 230, 230, 230, 230, /* 50 */ 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, - /* 60 */ 230, 230, 230, 230, 317, 317, 317, 25, 25, 25, - /* 70 */ 25, 25, 25, 25, 148, 148, 148, 269, 148, 148, - /* 80 */ 148, 276, 276, 148, 148, 148, 148, 286, 286, 167, - /* 90 */ 276, 148, 148, 148, 148, 148, 148, 148, 148, 148, - /* 100 */ 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, - /* 110 */ 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, - /* 120 */ 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, - /* 130 */ 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, - /* 140 */ 148, 148, 148, 444, 444, 444, 391, 391, 391, 444, - /* 150 */ 391, 444, 394, 396, 397, 398, 402, 395, 410, 430, - /* 160 */ 435, 442, 447, 444, 444, 444, 481, 29, 29, 444, - /* 170 */ 444, 418, 501, 538, 506, 505, 537, 508, 511, 481, - /* 180 */ 444, 515, 515, 444, 515, 444, 515, 444, 444, 722, - /* 190 */ 722, 27, 100, 127, 100, 100, 53, 182, 223, 223, - /* 200 */ 223, 223, 238, 273, 296, 252, 252, 252, 252, 236, - /* 210 */ 243, 255, 92, 92, 260, 316, 130, 337, 299, 304, - /* 220 */ 120, 302, 311, 312, 314, 320, 322, 413, 362, 7, - /* 230 */ 315, 323, 325, 330, 331, 332, 333, 339, 310, 313, - /* 240 */ 318, 319, 324, 358, 335, 463, 464, 368, 590, 449, - /* 250 */ 595, 596, 455, 598, 603, 519, 521, 475, 499, 509, - /* 260 */ 513, 523, 510, 531, 504, 529, 534, 541, 542, 539, - /* 270 */ 545, 546, 548, 649, 549, 550, 552, 551, 530, 553, - /* 280 */ 533, 554, 557, 547, 559, 509, 560, 558, 562, 561, - /* 290 */ 591, 659, 665, 666, 667, 668, 669, 597, 660, 600, - /* 300 */ 662, 540, 543, 570, 570, 570, 570, 664, 544, 555, - /* 310 */ 570, 570, 570, 677, 678, 581, 570, 682, 683, 684, - /* 320 */ 685, 686, 687, 688, 689, 690, 692, 693, 694, 695, - /* 330 */ 696, 697, 698, 699, 599, 625, 691, 700, 646, 648, - /* 340 */ 709, + /* 60 */ 230, 230, 230, 230, 309, 309, 309, 233, 233, 233, + /* 70 */ 233, 233, 233, 233, 21, 21, 21, 250, 21, 21, + /* 80 */ 21, 35, 35, 21, 21, 21, 21, 226, 226, 272, + /* 90 */ 35, 21, 21, 21, 21, 21, 21, 21, 21, 21, + /* 100 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + /* 110 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + /* 120 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + /* 130 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + /* 140 */ 21, 21, 21, 441, 441, 441, 394, 394, 394, 441, + /* 150 */ 394, 441, 397, 401, 408, 396, 412, 420, 422, 428, + /* 160 */ 436, 443, 448, 441, 441, 441, 483, 51, 51, 441, + /* 170 */ 441, 501, 503, 540, 508, 507, 539, 510, 514, 483, + /* 180 */ 5, 441, 520, 520, 441, 520, 441, 520, 441, 441, + /* 190 */ 724, 724, 27, 98, 125, 98, 98, 53, 180, 258, + /* 200 */ 258, 258, 258, 237, 257, 286, 337, 337, 337, 337, + /* 210 */ 242, 249, 177, 172, 172, 220, 283, 285, 344, 350, + /* 220 */ 290, 311, 313, 327, 328, 330, 334, 340, 362, 369, + /* 230 */ 331, 298, 343, 347, 349, 351, 353, 356, 342, 304, + /* 240 */ 310, 315, 456, 460, 319, 325, 363, 336, 395, 595, + /* 250 */ 454, 601, 602, 461, 604, 605, 521, 523, 475, 502, + /* 260 */ 506, 511, 522, 532, 534, 552, 553, 541, 543, 545, + /* 270 */ 558, 544, 546, 548, 653, 550, 551, 554, 568, 536, + /* 280 */ 570, 537, 556, 559, 555, 560, 506, 562, 561, 563, + /* 290 */ 564, 587, 661, 666, 667, 669, 670, 671, 597, 663, + /* 300 */ 603, 664, 542, 547, 593, 593, 593, 593, 668, 549, + /* 310 */ 557, 593, 593, 593, 677, 680, 580, 593, 682, 684, + /* 320 */ 686, 687, 688, 689, 690, 691, 692, 694, 695, 696, + /* 330 */ 697, 698, 699, 700, 701, 619, 628, 693, 702, 649, + /* 340 */ 651, 711, }; -#define YY_REDUCE_COUNT (190) -#define YY_REDUCE_MIN (-249) -#define YY_REDUCE_MAX (443) +#define YY_REDUCE_COUNT (191) +#define YY_REDUCE_MIN (-256) +#define YY_REDUCE_MAX (444) static const short yy_reduce_ofst[] = { - /* 0 */ -179, -28, -28, 74, 74, 15, -246, -219, -121, -77, - /* 10 */ 67, -177, -9, 81, 82, 121, 137, 139, 154, 156, - /* 20 */ 160, 161, -192, -189, -223, -205, -175, 145, 158, -93, - /* 30 */ -89, 147, 157, 19, -110, 179, -124, -112, -123, 3, - /* 40 */ 96, 14, 18, 203, -249, -247, -242, -225, -91, -53, - /* 50 */ 66, 73, 86, 172, 194, 201, 202, 207, 213, 218, - /* 60 */ 219, 224, 225, 226, 32, 240, 244, 105, 247, 254, - /* 70 */ 256, 257, 258, 259, 291, 297, 298, 235, 300, 301, - /* 80 */ 303, 261, 262, 306, 307, 308, 309, 229, 232, 263, - /* 90 */ 268, 321, 326, 327, 328, 334, 336, 338, 340, 341, - /* 100 */ 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, - /* 110 */ 352, 353, 354, 355, 356, 357, 359, 360, 361, 363, - /* 120 */ 364, 365, 366, 367, 369, 370, 371, 372, 373, 374, - /* 130 */ 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, - /* 140 */ 385, 386, 387, 388, 389, 390, 248, 249, 251, 392, - /* 150 */ 253, 393, 264, 266, 274, 265, 270, 279, 399, 267, - /* 160 */ 400, 403, 401, 404, 405, 406, 407, 408, 409, 411, - /* 170 */ 412, 414, 416, 415, 417, 419, 422, 423, 425, 420, - /* 180 */ 421, 424, 427, 426, 436, 438, 440, 439, 443, 441, - /* 190 */ 434, + /* 0 */ -178, -31, -31, 56, 56, 136, -248, -221, -187, -150, + /* 10 */ -136, -107, 6, 38, 55, 106, 139, 167, 169, 170, + /* 20 */ 187, 189, -189, -185, -252, -203, -177, -122, -109, -38, + /* 30 */ -129, -103, 10, -78, -85, 31, -40, -115, 196, 205, + /* 40 */ 23, 20, 133, 143, -256, -254, -225, -174, -34, -11, + /* 50 */ 9, 69, 89, 116, 127, 176, 182, 192, 213, 222, + /* 60 */ 223, 224, 225, 227, -23, 65, 115, 247, 253, 255, + /* 70 */ 256, 259, 260, 261, 294, 295, 299, 197, 300, 301, + /* 80 */ 302, 262, 263, 303, 305, 306, 312, 232, 238, 264, + /* 90 */ 266, 314, 316, 317, 318, 320, 321, 322, 323, 324, + /* 100 */ 326, 329, 332, 333, 335, 338, 339, 341, 345, 346, + /* 110 */ 348, 352, 354, 355, 357, 358, 359, 360, 361, 364, + /* 120 */ 365, 366, 367, 368, 370, 371, 372, 373, 374, 375, + /* 130 */ 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, + /* 140 */ 386, 387, 388, 389, 390, 391, 268, 269, 274, 392, + /* 150 */ 275, 393, 265, 271, 270, 292, 297, 276, 308, 398, + /* 160 */ 400, 399, 403, 402, 404, 405, 280, 406, 407, 409, + /* 170 */ 410, 411, 413, 415, 414, 417, 421, 419, 416, 423, + /* 180 */ 418, 426, 432, 433, 435, 437, 439, 440, 442, 444, + /* 190 */ 431, 438, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 818, 931, 877, 943, 865, 874, 1079, 1079, 818, 818, - /* 10 */ 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, - /* 20 */ 818, 818, 990, 837, 1079, 818, 818, 818, 818, 818, - /* 30 */ 818, 818, 818, 818, 874, 818, 818, 880, 874, 880, - /* 40 */ 880, 985, 915, 933, 818, 818, 818, 818, 818, 818, - /* 50 */ 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, - /* 60 */ 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, - /* 70 */ 818, 818, 818, 818, 818, 818, 818, 992, 998, 995, - /* 80 */ 818, 818, 818, 1000, 818, 818, 818, 1022, 1022, 983, - /* 90 */ 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, - /* 100 */ 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, - /* 110 */ 818, 818, 818, 818, 818, 818, 818, 818, 818, 863, - /* 120 */ 818, 861, 818, 818, 818, 818, 818, 818, 818, 818, - /* 130 */ 818, 818, 818, 818, 818, 818, 848, 818, 818, 818, - /* 140 */ 818, 818, 818, 839, 839, 839, 818, 818, 818, 839, - /* 150 */ 818, 839, 1029, 1033, 1027, 1015, 1023, 1014, 1010, 1008, - /* 160 */ 1006, 1005, 1037, 839, 839, 839, 878, 874, 874, 839, - /* 170 */ 839, 896, 894, 892, 884, 890, 886, 888, 882, 866, - /* 180 */ 839, 872, 872, 839, 872, 839, 872, 839, 839, 915, - /* 190 */ 933, 818, 1038, 818, 1078, 1028, 1068, 1067, 1074, 1066, - /* 200 */ 1065, 1064, 818, 818, 818, 1060, 1061, 1063, 1062, 818, - /* 210 */ 818, 818, 1070, 1069, 818, 818, 818, 818, 818, 818, - /* 220 */ 818, 818, 818, 818, 818, 818, 818, 818, 1040, 818, - /* 230 */ 1034, 1030, 818, 818, 818, 818, 818, 818, 818, 818, - /* 240 */ 818, 818, 818, 945, 818, 818, 818, 818, 818, 818, - /* 250 */ 818, 818, 818, 818, 818, 818, 818, 818, 982, 818, - /* 260 */ 818, 818, 818, 818, 994, 993, 818, 818, 818, 818, - /* 270 */ 818, 818, 818, 818, 818, 818, 818, 1024, 818, 1016, - /* 280 */ 818, 818, 818, 818, 818, 957, 818, 818, 818, 818, - /* 290 */ 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, - /* 300 */ 818, 818, 818, 1097, 1092, 1093, 1090, 818, 818, 818, - /* 310 */ 1089, 1084, 1085, 818, 818, 818, 1082, 818, 818, 818, - /* 320 */ 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, - /* 330 */ 818, 818, 818, 818, 899, 818, 846, 844, 818, 835, - /* 340 */ 818, + /* 0 */ 825, 941, 884, 953, 872, 881, 1089, 1089, 825, 825, + /* 10 */ 825, 825, 825, 825, 825, 825, 825, 825, 825, 825, + /* 20 */ 825, 825, 1000, 844, 1089, 825, 825, 825, 825, 825, + /* 30 */ 825, 825, 825, 881, 825, 825, 887, 881, 887, 887, + /* 40 */ 825, 995, 925, 943, 825, 825, 825, 825, 825, 825, + /* 50 */ 825, 825, 825, 825, 825, 825, 825, 825, 825, 825, + /* 60 */ 825, 825, 825, 825, 825, 825, 825, 825, 825, 825, + /* 70 */ 825, 825, 825, 825, 825, 825, 825, 1002, 1008, 1005, + /* 80 */ 825, 825, 825, 1010, 825, 825, 825, 1032, 1032, 993, + /* 90 */ 825, 825, 825, 825, 825, 825, 825, 825, 825, 825, + /* 100 */ 825, 825, 825, 825, 825, 825, 825, 825, 825, 825, + /* 110 */ 825, 825, 825, 825, 825, 825, 825, 825, 825, 870, + /* 120 */ 825, 868, 825, 825, 825, 825, 825, 825, 825, 825, + /* 130 */ 825, 825, 825, 825, 825, 825, 855, 825, 825, 825, + /* 140 */ 825, 825, 825, 846, 846, 846, 825, 825, 825, 846, + /* 150 */ 825, 846, 1039, 1043, 1037, 1025, 1033, 1024, 1020, 1018, + /* 160 */ 1016, 1015, 1047, 846, 846, 846, 885, 881, 881, 846, + /* 170 */ 846, 903, 901, 899, 891, 897, 893, 895, 889, 873, + /* 180 */ 825, 846, 879, 879, 846, 879, 846, 879, 846, 846, + /* 190 */ 925, 943, 825, 1048, 825, 1088, 1038, 1078, 1077, 1084, + /* 200 */ 1076, 1075, 1074, 825, 825, 825, 1070, 1071, 1073, 1072, + /* 210 */ 825, 825, 825, 1080, 1079, 825, 825, 825, 825, 825, + /* 220 */ 825, 825, 825, 825, 825, 825, 825, 825, 825, 1050, + /* 230 */ 825, 1044, 1040, 825, 825, 825, 825, 825, 825, 825, + /* 240 */ 825, 825, 825, 825, 825, 825, 955, 825, 825, 825, + /* 250 */ 825, 825, 825, 825, 825, 825, 825, 825, 825, 992, + /* 260 */ 825, 825, 825, 825, 825, 1004, 1003, 825, 825, 825, + /* 270 */ 825, 825, 825, 825, 825, 825, 825, 825, 1034, 825, + /* 280 */ 1026, 825, 825, 825, 825, 825, 967, 825, 825, 825, + /* 290 */ 825, 825, 825, 825, 825, 825, 825, 825, 825, 825, + /* 300 */ 825, 825, 825, 825, 1107, 1102, 1103, 1100, 825, 825, + /* 310 */ 825, 1099, 1094, 1095, 825, 825, 825, 1092, 825, 825, + /* 320 */ 825, 825, 825, 825, 825, 825, 825, 825, 825, 825, + /* 330 */ 825, 825, 825, 825, 825, 909, 825, 853, 851, 825, + /* 340 */ 842, 825, }; /********** End of lemon-generated parsing tables *****************************/ @@ -593,6 +593,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* QTIME => nothing */ 0, /* CONNS => nothing */ 0, /* STATE => nothing */ + 0, /* COMMA => nothing */ 0, /* KEEP => nothing */ 0, /* CACHE => nothing */ 0, /* REPLICA => nothing */ @@ -614,7 +615,6 @@ static const YYCODETYPE yyFallback[] = { 0, /* UNSIGNED => nothing */ 0, /* TAGS => nothing */ 0, /* USING => nothing */ - 0, /* COMMA => nothing */ 0, /* AS => nothing */ 1, /* NULL => ID */ 0, /* SELECT => nothing */ @@ -869,28 +869,28 @@ static const char *const yyTokenName[] = { /* 85 */ "QTIME", /* 86 */ "CONNS", /* 87 */ "STATE", - /* 88 */ "KEEP", - /* 89 */ "CACHE", - /* 90 */ "REPLICA", - /* 91 */ "QUORUM", - /* 92 */ "DAYS", - /* 93 */ "MINROWS", - /* 94 */ "MAXROWS", - /* 95 */ "BLOCKS", - /* 96 */ "CTIME", - /* 97 */ "WAL", - /* 98 */ "FSYNC", - /* 99 */ "COMP", - /* 100 */ "PRECISION", - /* 101 */ "UPDATE", - /* 102 */ "CACHELAST", - /* 103 */ "PARTITIONS", - /* 104 */ "LP", - /* 105 */ "RP", - /* 106 */ "UNSIGNED", - /* 107 */ "TAGS", - /* 108 */ "USING", - /* 109 */ "COMMA", + /* 88 */ "COMMA", + /* 89 */ "KEEP", + /* 90 */ "CACHE", + /* 91 */ "REPLICA", + /* 92 */ "QUORUM", + /* 93 */ "DAYS", + /* 94 */ "MINROWS", + /* 95 */ "MAXROWS", + /* 96 */ "BLOCKS", + /* 97 */ "CTIME", + /* 98 */ "WAL", + /* 99 */ "FSYNC", + /* 100 */ "COMP", + /* 101 */ "PRECISION", + /* 102 */ "UPDATE", + /* 103 */ "CACHELAST", + /* 104 */ "PARTITIONS", + /* 105 */ "LP", + /* 106 */ "RP", + /* 107 */ "UNSIGNED", + /* 108 */ "TAGS", + /* 109 */ "USING", /* 110 */ "AS", /* 111 */ "NULL", /* 112 */ "SELECT", @@ -991,62 +991,64 @@ static const char *const yyTokenName[] = { /* 207 */ "users", /* 208 */ "conns", /* 209 */ "state", - /* 210 */ "keep", - /* 211 */ "tagitemlist", - /* 212 */ "cache", - /* 213 */ "replica", - /* 214 */ "quorum", - /* 215 */ "days", - /* 216 */ "minrows", - /* 217 */ "maxrows", - /* 218 */ "blocks", - /* 219 */ "ctime", - /* 220 */ "wal", - /* 221 */ "fsync", - /* 222 */ "comp", - /* 223 */ "prec", - /* 224 */ "update", - /* 225 */ "cachelast", - /* 226 */ "partitions", - /* 227 */ "typename", - /* 228 */ "signed", - /* 229 */ "create_table_args", - /* 230 */ "create_stable_args", - /* 231 */ "create_table_list", - /* 232 */ "create_from_stable", - /* 233 */ "columnlist", - /* 234 */ "tagNamelist", - /* 235 */ "select", - /* 236 */ "column", - /* 237 */ "tagitem", - /* 238 */ "selcollist", - /* 239 */ "from", - /* 240 */ "where_opt", - /* 241 */ "interval_opt", - /* 242 */ "session_option", - /* 243 */ "windowstate_option", - /* 244 */ "fill_opt", - /* 245 */ "sliding_opt", - /* 246 */ "groupby_opt", - /* 247 */ "orderby_opt", - /* 248 */ "having_opt", - /* 249 */ "slimit_opt", - /* 250 */ "limit_opt", - /* 251 */ "union", - /* 252 */ "sclp", - /* 253 */ "distinct", - /* 254 */ "expr", - /* 255 */ "as", - /* 256 */ "tablelist", - /* 257 */ "sub", - /* 258 */ "tmvar", - /* 259 */ "sortlist", - /* 260 */ "sortitem", - /* 261 */ "item", - /* 262 */ "sortorder", - /* 263 */ "grouplist", - /* 264 */ "exprlist", - /* 265 */ "expritem", + /* 210 */ "intitemlist", + /* 211 */ "intitem", + /* 212 */ "keep", + /* 213 */ "cache", + /* 214 */ "replica", + /* 215 */ "quorum", + /* 216 */ "days", + /* 217 */ "minrows", + /* 218 */ "maxrows", + /* 219 */ "blocks", + /* 220 */ "ctime", + /* 221 */ "wal", + /* 222 */ "fsync", + /* 223 */ "comp", + /* 224 */ "prec", + /* 225 */ "update", + /* 226 */ "cachelast", + /* 227 */ "partitions", + /* 228 */ "typename", + /* 229 */ "signed", + /* 230 */ "create_table_args", + /* 231 */ "create_stable_args", + /* 232 */ "create_table_list", + /* 233 */ "create_from_stable", + /* 234 */ "columnlist", + /* 235 */ "tagitemlist", + /* 236 */ "tagNamelist", + /* 237 */ "select", + /* 238 */ "column", + /* 239 */ "tagitem", + /* 240 */ "selcollist", + /* 241 */ "from", + /* 242 */ "where_opt", + /* 243 */ "interval_opt", + /* 244 */ "session_option", + /* 245 */ "windowstate_option", + /* 246 */ "fill_opt", + /* 247 */ "sliding_opt", + /* 248 */ "groupby_opt", + /* 249 */ "orderby_opt", + /* 250 */ "having_opt", + /* 251 */ "slimit_opt", + /* 252 */ "limit_opt", + /* 253 */ "union", + /* 254 */ "sclp", + /* 255 */ "distinct", + /* 256 */ "expr", + /* 257 */ "as", + /* 258 */ "tablelist", + /* 259 */ "sub", + /* 260 */ "tmvar", + /* 261 */ "sortlist", + /* 262 */ "sortitem", + /* 263 */ "item", + /* 264 */ "sortorder", + /* 265 */ "grouplist", + /* 266 */ "exprlist", + /* 267 */ "expritem", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1132,208 +1134,211 @@ static const char *const yyRuleName[] = { /* 75 */ "state ::=", /* 76 */ "state ::= STATE ids", /* 77 */ "acct_optr ::= pps tseries storage streams qtime dbs users conns state", - /* 78 */ "keep ::= KEEP tagitemlist", - /* 79 */ "cache ::= CACHE INTEGER", - /* 80 */ "replica ::= REPLICA INTEGER", - /* 81 */ "quorum ::= QUORUM INTEGER", - /* 82 */ "days ::= DAYS INTEGER", - /* 83 */ "minrows ::= MINROWS INTEGER", - /* 84 */ "maxrows ::= MAXROWS INTEGER", - /* 85 */ "blocks ::= BLOCKS INTEGER", - /* 86 */ "ctime ::= CTIME INTEGER", - /* 87 */ "wal ::= WAL INTEGER", - /* 88 */ "fsync ::= FSYNC INTEGER", - /* 89 */ "comp ::= COMP INTEGER", - /* 90 */ "prec ::= PRECISION STRING", - /* 91 */ "update ::= UPDATE INTEGER", - /* 92 */ "cachelast ::= CACHELAST INTEGER", - /* 93 */ "partitions ::= PARTITIONS INTEGER", - /* 94 */ "db_optr ::=", - /* 95 */ "db_optr ::= db_optr cache", - /* 96 */ "db_optr ::= db_optr replica", - /* 97 */ "db_optr ::= db_optr quorum", - /* 98 */ "db_optr ::= db_optr days", - /* 99 */ "db_optr ::= db_optr minrows", - /* 100 */ "db_optr ::= db_optr maxrows", - /* 101 */ "db_optr ::= db_optr blocks", - /* 102 */ "db_optr ::= db_optr ctime", - /* 103 */ "db_optr ::= db_optr wal", - /* 104 */ "db_optr ::= db_optr fsync", - /* 105 */ "db_optr ::= db_optr comp", - /* 106 */ "db_optr ::= db_optr prec", - /* 107 */ "db_optr ::= db_optr keep", - /* 108 */ "db_optr ::= db_optr update", - /* 109 */ "db_optr ::= db_optr cachelast", - /* 110 */ "topic_optr ::= db_optr", - /* 111 */ "topic_optr ::= topic_optr partitions", - /* 112 */ "alter_db_optr ::=", - /* 113 */ "alter_db_optr ::= alter_db_optr replica", - /* 114 */ "alter_db_optr ::= alter_db_optr quorum", - /* 115 */ "alter_db_optr ::= alter_db_optr keep", - /* 116 */ "alter_db_optr ::= alter_db_optr blocks", - /* 117 */ "alter_db_optr ::= alter_db_optr comp", - /* 118 */ "alter_db_optr ::= alter_db_optr wal", - /* 119 */ "alter_db_optr ::= alter_db_optr fsync", - /* 120 */ "alter_db_optr ::= alter_db_optr update", - /* 121 */ "alter_db_optr ::= alter_db_optr cachelast", - /* 122 */ "alter_topic_optr ::= alter_db_optr", - /* 123 */ "alter_topic_optr ::= alter_topic_optr partitions", - /* 124 */ "typename ::= ids", - /* 125 */ "typename ::= ids LP signed RP", - /* 126 */ "typename ::= ids UNSIGNED", - /* 127 */ "signed ::= INTEGER", - /* 128 */ "signed ::= PLUS INTEGER", - /* 129 */ "signed ::= MINUS INTEGER", - /* 130 */ "cmd ::= CREATE TABLE create_table_args", - /* 131 */ "cmd ::= CREATE TABLE create_stable_args", - /* 132 */ "cmd ::= CREATE STABLE create_stable_args", - /* 133 */ "cmd ::= CREATE TABLE create_table_list", - /* 134 */ "create_table_list ::= create_from_stable", - /* 135 */ "create_table_list ::= create_table_list create_from_stable", - /* 136 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP", - /* 137 */ "create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP", - /* 138 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP", - /* 139 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP", - /* 140 */ "tagNamelist ::= tagNamelist COMMA ids", - /* 141 */ "tagNamelist ::= ids", - /* 142 */ "create_table_args ::= ifnotexists ids cpxName AS select", - /* 143 */ "columnlist ::= columnlist COMMA column", - /* 144 */ "columnlist ::= column", - /* 145 */ "column ::= ids typename", - /* 146 */ "tagitemlist ::= tagitemlist COMMA tagitem", - /* 147 */ "tagitemlist ::= tagitem", - /* 148 */ "tagitem ::= INTEGER", - /* 149 */ "tagitem ::= FLOAT", - /* 150 */ "tagitem ::= STRING", - /* 151 */ "tagitem ::= BOOL", - /* 152 */ "tagitem ::= NULL", - /* 153 */ "tagitem ::= MINUS INTEGER", - /* 154 */ "tagitem ::= MINUS FLOAT", - /* 155 */ "tagitem ::= PLUS INTEGER", - /* 156 */ "tagitem ::= PLUS FLOAT", - /* 157 */ "select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt", - /* 158 */ "select ::= LP select RP", - /* 159 */ "union ::= select", - /* 160 */ "union ::= union UNION ALL select", - /* 161 */ "cmd ::= union", - /* 162 */ "select ::= SELECT selcollist", - /* 163 */ "sclp ::= selcollist COMMA", - /* 164 */ "sclp ::=", - /* 165 */ "selcollist ::= sclp distinct expr as", - /* 166 */ "selcollist ::= sclp STAR", - /* 167 */ "as ::= AS ids", - /* 168 */ "as ::= ids", - /* 169 */ "as ::=", - /* 170 */ "distinct ::= DISTINCT", - /* 171 */ "distinct ::=", - /* 172 */ "from ::= FROM tablelist", - /* 173 */ "from ::= FROM sub", - /* 174 */ "sub ::= LP union RP", - /* 175 */ "sub ::= LP union RP ids", - /* 176 */ "sub ::= sub COMMA LP union RP ids", - /* 177 */ "tablelist ::= ids cpxName", - /* 178 */ "tablelist ::= ids cpxName ids", - /* 179 */ "tablelist ::= tablelist COMMA ids cpxName", - /* 180 */ "tablelist ::= tablelist COMMA ids cpxName ids", - /* 181 */ "tmvar ::= VARIABLE", - /* 182 */ "interval_opt ::= INTERVAL LP tmvar RP", - /* 183 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP", - /* 184 */ "interval_opt ::=", - /* 185 */ "session_option ::=", - /* 186 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", - /* 187 */ "windowstate_option ::=", - /* 188 */ "windowstate_option ::= STATE_WINDOW LP ids RP", - /* 189 */ "fill_opt ::=", - /* 190 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", - /* 191 */ "fill_opt ::= FILL LP ID RP", - /* 192 */ "sliding_opt ::= SLIDING LP tmvar RP", - /* 193 */ "sliding_opt ::=", - /* 194 */ "orderby_opt ::=", - /* 195 */ "orderby_opt ::= ORDER BY sortlist", - /* 196 */ "sortlist ::= sortlist COMMA item sortorder", - /* 197 */ "sortlist ::= item sortorder", - /* 198 */ "item ::= ids cpxName", - /* 199 */ "sortorder ::= ASC", - /* 200 */ "sortorder ::= DESC", - /* 201 */ "sortorder ::=", - /* 202 */ "groupby_opt ::=", - /* 203 */ "groupby_opt ::= GROUP BY grouplist", - /* 204 */ "grouplist ::= grouplist COMMA item", - /* 205 */ "grouplist ::= item", - /* 206 */ "having_opt ::=", - /* 207 */ "having_opt ::= HAVING expr", - /* 208 */ "limit_opt ::=", - /* 209 */ "limit_opt ::= LIMIT signed", - /* 210 */ "limit_opt ::= LIMIT signed OFFSET signed", - /* 211 */ "limit_opt ::= LIMIT signed COMMA signed", - /* 212 */ "slimit_opt ::=", - /* 213 */ "slimit_opt ::= SLIMIT signed", - /* 214 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", - /* 215 */ "slimit_opt ::= SLIMIT signed COMMA signed", - /* 216 */ "where_opt ::=", - /* 217 */ "where_opt ::= WHERE expr", - /* 218 */ "expr ::= LP expr RP", - /* 219 */ "expr ::= ID", - /* 220 */ "expr ::= ID DOT ID", - /* 221 */ "expr ::= ID DOT STAR", - /* 222 */ "expr ::= INTEGER", - /* 223 */ "expr ::= MINUS INTEGER", - /* 224 */ "expr ::= PLUS INTEGER", - /* 225 */ "expr ::= FLOAT", - /* 226 */ "expr ::= MINUS FLOAT", - /* 227 */ "expr ::= PLUS FLOAT", - /* 228 */ "expr ::= STRING", - /* 229 */ "expr ::= NOW", - /* 230 */ "expr ::= VARIABLE", - /* 231 */ "expr ::= PLUS VARIABLE", - /* 232 */ "expr ::= MINUS VARIABLE", - /* 233 */ "expr ::= BOOL", - /* 234 */ "expr ::= NULL", - /* 235 */ "expr ::= ID LP exprlist RP", - /* 236 */ "expr ::= ID LP STAR RP", - /* 237 */ "expr ::= expr IS NULL", - /* 238 */ "expr ::= expr IS NOT NULL", - /* 239 */ "expr ::= expr LT expr", - /* 240 */ "expr ::= expr GT expr", - /* 241 */ "expr ::= expr LE expr", - /* 242 */ "expr ::= expr GE expr", - /* 243 */ "expr ::= expr NE expr", - /* 244 */ "expr ::= expr EQ expr", - /* 245 */ "expr ::= expr BETWEEN expr AND expr", - /* 246 */ "expr ::= expr AND expr", - /* 247 */ "expr ::= expr OR expr", - /* 248 */ "expr ::= expr PLUS expr", - /* 249 */ "expr ::= expr MINUS expr", - /* 250 */ "expr ::= expr STAR expr", - /* 251 */ "expr ::= expr SLASH expr", - /* 252 */ "expr ::= expr REM expr", - /* 253 */ "expr ::= expr LIKE expr", - /* 254 */ "expr ::= expr IN LP exprlist RP", - /* 255 */ "exprlist ::= exprlist COMMA expritem", - /* 256 */ "exprlist ::= expritem", - /* 257 */ "expritem ::= expr", - /* 258 */ "expritem ::=", - /* 259 */ "cmd ::= RESET QUERY CACHE", - /* 260 */ "cmd ::= SYNCDB ids REPLICA", - /* 261 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", - /* 262 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", - /* 263 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", - /* 264 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", - /* 265 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", - /* 266 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", - /* 267 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", - /* 268 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", - /* 269 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", - /* 270 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", - /* 271 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", - /* 272 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", - /* 273 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", - /* 274 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", - /* 275 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", - /* 276 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", - /* 277 */ "cmd ::= KILL CONNECTION INTEGER", - /* 278 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", - /* 279 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", + /* 78 */ "intitemlist ::= intitemlist COMMA intitem", + /* 79 */ "intitemlist ::= intitem", + /* 80 */ "intitem ::= INTEGER", + /* 81 */ "keep ::= KEEP intitemlist", + /* 82 */ "cache ::= CACHE INTEGER", + /* 83 */ "replica ::= REPLICA INTEGER", + /* 84 */ "quorum ::= QUORUM INTEGER", + /* 85 */ "days ::= DAYS INTEGER", + /* 86 */ "minrows ::= MINROWS INTEGER", + /* 87 */ "maxrows ::= MAXROWS INTEGER", + /* 88 */ "blocks ::= BLOCKS INTEGER", + /* 89 */ "ctime ::= CTIME INTEGER", + /* 90 */ "wal ::= WAL INTEGER", + /* 91 */ "fsync ::= FSYNC INTEGER", + /* 92 */ "comp ::= COMP INTEGER", + /* 93 */ "prec ::= PRECISION STRING", + /* 94 */ "update ::= UPDATE INTEGER", + /* 95 */ "cachelast ::= CACHELAST INTEGER", + /* 96 */ "partitions ::= PARTITIONS INTEGER", + /* 97 */ "db_optr ::=", + /* 98 */ "db_optr ::= db_optr cache", + /* 99 */ "db_optr ::= db_optr replica", + /* 100 */ "db_optr ::= db_optr quorum", + /* 101 */ "db_optr ::= db_optr days", + /* 102 */ "db_optr ::= db_optr minrows", + /* 103 */ "db_optr ::= db_optr maxrows", + /* 104 */ "db_optr ::= db_optr blocks", + /* 105 */ "db_optr ::= db_optr ctime", + /* 106 */ "db_optr ::= db_optr wal", + /* 107 */ "db_optr ::= db_optr fsync", + /* 108 */ "db_optr ::= db_optr comp", + /* 109 */ "db_optr ::= db_optr prec", + /* 110 */ "db_optr ::= db_optr keep", + /* 111 */ "db_optr ::= db_optr update", + /* 112 */ "db_optr ::= db_optr cachelast", + /* 113 */ "topic_optr ::= db_optr", + /* 114 */ "topic_optr ::= topic_optr partitions", + /* 115 */ "alter_db_optr ::=", + /* 116 */ "alter_db_optr ::= alter_db_optr replica", + /* 117 */ "alter_db_optr ::= alter_db_optr quorum", + /* 118 */ "alter_db_optr ::= alter_db_optr keep", + /* 119 */ "alter_db_optr ::= alter_db_optr blocks", + /* 120 */ "alter_db_optr ::= alter_db_optr comp", + /* 121 */ "alter_db_optr ::= alter_db_optr wal", + /* 122 */ "alter_db_optr ::= alter_db_optr fsync", + /* 123 */ "alter_db_optr ::= alter_db_optr update", + /* 124 */ "alter_db_optr ::= alter_db_optr cachelast", + /* 125 */ "alter_topic_optr ::= alter_db_optr", + /* 126 */ "alter_topic_optr ::= alter_topic_optr partitions", + /* 127 */ "typename ::= ids", + /* 128 */ "typename ::= ids LP signed RP", + /* 129 */ "typename ::= ids UNSIGNED", + /* 130 */ "signed ::= INTEGER", + /* 131 */ "signed ::= PLUS INTEGER", + /* 132 */ "signed ::= MINUS INTEGER", + /* 133 */ "cmd ::= CREATE TABLE create_table_args", + /* 134 */ "cmd ::= CREATE TABLE create_stable_args", + /* 135 */ "cmd ::= CREATE STABLE create_stable_args", + /* 136 */ "cmd ::= CREATE TABLE create_table_list", + /* 137 */ "create_table_list ::= create_from_stable", + /* 138 */ "create_table_list ::= create_table_list create_from_stable", + /* 139 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP", + /* 140 */ "create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP", + /* 141 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP", + /* 142 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP", + /* 143 */ "tagNamelist ::= tagNamelist COMMA ids", + /* 144 */ "tagNamelist ::= ids", + /* 145 */ "create_table_args ::= ifnotexists ids cpxName AS select", + /* 146 */ "columnlist ::= columnlist COMMA column", + /* 147 */ "columnlist ::= column", + /* 148 */ "column ::= ids typename", + /* 149 */ "tagitemlist ::= tagitemlist COMMA tagitem", + /* 150 */ "tagitemlist ::= tagitem", + /* 151 */ "tagitem ::= INTEGER", + /* 152 */ "tagitem ::= FLOAT", + /* 153 */ "tagitem ::= STRING", + /* 154 */ "tagitem ::= BOOL", + /* 155 */ "tagitem ::= NULL", + /* 156 */ "tagitem ::= MINUS INTEGER", + /* 157 */ "tagitem ::= MINUS FLOAT", + /* 158 */ "tagitem ::= PLUS INTEGER", + /* 159 */ "tagitem ::= PLUS FLOAT", + /* 160 */ "select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt", + /* 161 */ "select ::= LP select RP", + /* 162 */ "union ::= select", + /* 163 */ "union ::= union UNION ALL select", + /* 164 */ "cmd ::= union", + /* 165 */ "select ::= SELECT selcollist", + /* 166 */ "sclp ::= selcollist COMMA", + /* 167 */ "sclp ::=", + /* 168 */ "selcollist ::= sclp distinct expr as", + /* 169 */ "selcollist ::= sclp STAR", + /* 170 */ "as ::= AS ids", + /* 171 */ "as ::= ids", + /* 172 */ "as ::=", + /* 173 */ "distinct ::= DISTINCT", + /* 174 */ "distinct ::=", + /* 175 */ "from ::= FROM tablelist", + /* 176 */ "from ::= FROM sub", + /* 177 */ "sub ::= LP union RP", + /* 178 */ "sub ::= LP union RP ids", + /* 179 */ "sub ::= sub COMMA LP union RP ids", + /* 180 */ "tablelist ::= ids cpxName", + /* 181 */ "tablelist ::= ids cpxName ids", + /* 182 */ "tablelist ::= tablelist COMMA ids cpxName", + /* 183 */ "tablelist ::= tablelist COMMA ids cpxName ids", + /* 184 */ "tmvar ::= VARIABLE", + /* 185 */ "interval_opt ::= INTERVAL LP tmvar RP", + /* 186 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP", + /* 187 */ "interval_opt ::=", + /* 188 */ "session_option ::=", + /* 189 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", + /* 190 */ "windowstate_option ::=", + /* 191 */ "windowstate_option ::= STATE_WINDOW LP ids RP", + /* 192 */ "fill_opt ::=", + /* 193 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", + /* 194 */ "fill_opt ::= FILL LP ID RP", + /* 195 */ "sliding_opt ::= SLIDING LP tmvar RP", + /* 196 */ "sliding_opt ::=", + /* 197 */ "orderby_opt ::=", + /* 198 */ "orderby_opt ::= ORDER BY sortlist", + /* 199 */ "sortlist ::= sortlist COMMA item sortorder", + /* 200 */ "sortlist ::= item sortorder", + /* 201 */ "item ::= ids cpxName", + /* 202 */ "sortorder ::= ASC", + /* 203 */ "sortorder ::= DESC", + /* 204 */ "sortorder ::=", + /* 205 */ "groupby_opt ::=", + /* 206 */ "groupby_opt ::= GROUP BY grouplist", + /* 207 */ "grouplist ::= grouplist COMMA item", + /* 208 */ "grouplist ::= item", + /* 209 */ "having_opt ::=", + /* 210 */ "having_opt ::= HAVING expr", + /* 211 */ "limit_opt ::=", + /* 212 */ "limit_opt ::= LIMIT signed", + /* 213 */ "limit_opt ::= LIMIT signed OFFSET signed", + /* 214 */ "limit_opt ::= LIMIT signed COMMA signed", + /* 215 */ "slimit_opt ::=", + /* 216 */ "slimit_opt ::= SLIMIT signed", + /* 217 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", + /* 218 */ "slimit_opt ::= SLIMIT signed COMMA signed", + /* 219 */ "where_opt ::=", + /* 220 */ "where_opt ::= WHERE expr", + /* 221 */ "expr ::= LP expr RP", + /* 222 */ "expr ::= ID", + /* 223 */ "expr ::= ID DOT ID", + /* 224 */ "expr ::= ID DOT STAR", + /* 225 */ "expr ::= INTEGER", + /* 226 */ "expr ::= MINUS INTEGER", + /* 227 */ "expr ::= PLUS INTEGER", + /* 228 */ "expr ::= FLOAT", + /* 229 */ "expr ::= MINUS FLOAT", + /* 230 */ "expr ::= PLUS FLOAT", + /* 231 */ "expr ::= STRING", + /* 232 */ "expr ::= NOW", + /* 233 */ "expr ::= VARIABLE", + /* 234 */ "expr ::= PLUS VARIABLE", + /* 235 */ "expr ::= MINUS VARIABLE", + /* 236 */ "expr ::= BOOL", + /* 237 */ "expr ::= NULL", + /* 238 */ "expr ::= ID LP exprlist RP", + /* 239 */ "expr ::= ID LP STAR RP", + /* 240 */ "expr ::= expr IS NULL", + /* 241 */ "expr ::= expr IS NOT NULL", + /* 242 */ "expr ::= expr LT expr", + /* 243 */ "expr ::= expr GT expr", + /* 244 */ "expr ::= expr LE expr", + /* 245 */ "expr ::= expr GE expr", + /* 246 */ "expr ::= expr NE expr", + /* 247 */ "expr ::= expr EQ expr", + /* 248 */ "expr ::= expr BETWEEN expr AND expr", + /* 249 */ "expr ::= expr AND expr", + /* 250 */ "expr ::= expr OR expr", + /* 251 */ "expr ::= expr PLUS expr", + /* 252 */ "expr ::= expr MINUS expr", + /* 253 */ "expr ::= expr STAR expr", + /* 254 */ "expr ::= expr SLASH expr", + /* 255 */ "expr ::= expr REM expr", + /* 256 */ "expr ::= expr LIKE expr", + /* 257 */ "expr ::= expr IN LP exprlist RP", + /* 258 */ "exprlist ::= exprlist COMMA expritem", + /* 259 */ "exprlist ::= expritem", + /* 260 */ "expritem ::= expr", + /* 261 */ "expritem ::=", + /* 262 */ "cmd ::= RESET QUERY CACHE", + /* 263 */ "cmd ::= SYNCDB ids REPLICA", + /* 264 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", + /* 265 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", + /* 266 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", + /* 267 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", + /* 268 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", + /* 269 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", + /* 270 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", + /* 271 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", + /* 272 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", + /* 273 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", + /* 274 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", + /* 275 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", + /* 276 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", + /* 277 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", + /* 278 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", + /* 279 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", + /* 280 */ "cmd ::= KILL CONNECTION INTEGER", + /* 281 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", + /* 282 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", }; #endif /* NDEBUG */ @@ -1459,57 +1464,58 @@ static void yy_destructor( ** inside the C code. */ /********* Begin destructor definitions ***************************************/ - case 210: /* keep */ - case 211: /* tagitemlist */ - case 233: /* columnlist */ - case 234: /* tagNamelist */ - case 244: /* fill_opt */ - case 246: /* groupby_opt */ - case 247: /* orderby_opt */ - case 259: /* sortlist */ - case 263: /* grouplist */ + case 210: /* intitemlist */ + case 212: /* keep */ + case 234: /* columnlist */ + case 235: /* tagitemlist */ + case 236: /* tagNamelist */ + case 246: /* fill_opt */ + case 248: /* groupby_opt */ + case 249: /* orderby_opt */ + case 261: /* sortlist */ + case 265: /* grouplist */ { -taosArrayDestroy((yypminor->yy193)); +taosArrayDestroy((yypminor->yy325)); } break; - case 231: /* create_table_list */ + case 232: /* create_table_list */ { -destroyCreateTableSql((yypminor->yy270)); +destroyCreateTableSql((yypminor->yy422)); } break; - case 235: /* select */ + case 237: /* select */ { -destroySqlNode((yypminor->yy124)); +destroySqlNode((yypminor->yy536)); } break; - case 238: /* selcollist */ - case 252: /* sclp */ - case 264: /* exprlist */ + case 240: /* selcollist */ + case 254: /* sclp */ + case 266: /* exprlist */ { -tSqlExprListDestroy((yypminor->yy193)); +tSqlExprListDestroy((yypminor->yy325)); } break; - case 239: /* from */ - case 256: /* tablelist */ - case 257: /* sub */ + case 241: /* from */ + case 258: /* tablelist */ + case 259: /* sub */ { -destroyRelationInfo((yypminor->yy332)); +destroyRelationInfo((yypminor->yy52)); } break; - case 240: /* where_opt */ - case 248: /* having_opt */ - case 254: /* expr */ - case 265: /* expritem */ + case 242: /* where_opt */ + case 250: /* having_opt */ + case 256: /* expr */ + case 267: /* expritem */ { -tSqlExprDestroy((yypminor->yy454)); +tSqlExprDestroy((yypminor->yy162)); } break; - case 251: /* union */ + case 253: /* union */ { -destroyAllSqlNode((yypminor->yy193)); +destroyAllSqlNode((yypminor->yy325)); } break; - case 260: /* sortitem */ + case 262: /* sortitem */ { tVariantDestroy(&(yypminor->yy442)); } @@ -1878,208 +1884,211 @@ static const YYCODETYPE yyRuleInfoLhs[] = { 209, /* (75) state ::= */ 209, /* (76) state ::= STATE ids */ 197, /* (77) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ - 210, /* (78) keep ::= KEEP tagitemlist */ - 212, /* (79) cache ::= CACHE INTEGER */ - 213, /* (80) replica ::= REPLICA INTEGER */ - 214, /* (81) quorum ::= QUORUM INTEGER */ - 215, /* (82) days ::= DAYS INTEGER */ - 216, /* (83) minrows ::= MINROWS INTEGER */ - 217, /* (84) maxrows ::= MAXROWS INTEGER */ - 218, /* (85) blocks ::= BLOCKS INTEGER */ - 219, /* (86) ctime ::= CTIME INTEGER */ - 220, /* (87) wal ::= WAL INTEGER */ - 221, /* (88) fsync ::= FSYNC INTEGER */ - 222, /* (89) comp ::= COMP INTEGER */ - 223, /* (90) prec ::= PRECISION STRING */ - 224, /* (91) update ::= UPDATE INTEGER */ - 225, /* (92) cachelast ::= CACHELAST INTEGER */ - 226, /* (93) partitions ::= PARTITIONS INTEGER */ - 199, /* (94) db_optr ::= */ - 199, /* (95) db_optr ::= db_optr cache */ - 199, /* (96) db_optr ::= db_optr replica */ - 199, /* (97) db_optr ::= db_optr quorum */ - 199, /* (98) db_optr ::= db_optr days */ - 199, /* (99) db_optr ::= db_optr minrows */ - 199, /* (100) db_optr ::= db_optr maxrows */ - 199, /* (101) db_optr ::= db_optr blocks */ - 199, /* (102) db_optr ::= db_optr ctime */ - 199, /* (103) db_optr ::= db_optr wal */ - 199, /* (104) db_optr ::= db_optr fsync */ - 199, /* (105) db_optr ::= db_optr comp */ - 199, /* (106) db_optr ::= db_optr prec */ - 199, /* (107) db_optr ::= db_optr keep */ - 199, /* (108) db_optr ::= db_optr update */ - 199, /* (109) db_optr ::= db_optr cachelast */ - 200, /* (110) topic_optr ::= db_optr */ - 200, /* (111) topic_optr ::= topic_optr partitions */ - 195, /* (112) alter_db_optr ::= */ - 195, /* (113) alter_db_optr ::= alter_db_optr replica */ - 195, /* (114) alter_db_optr ::= alter_db_optr quorum */ - 195, /* (115) alter_db_optr ::= alter_db_optr keep */ - 195, /* (116) alter_db_optr ::= alter_db_optr blocks */ - 195, /* (117) alter_db_optr ::= alter_db_optr comp */ - 195, /* (118) alter_db_optr ::= alter_db_optr wal */ - 195, /* (119) alter_db_optr ::= alter_db_optr fsync */ - 195, /* (120) alter_db_optr ::= alter_db_optr update */ - 195, /* (121) alter_db_optr ::= alter_db_optr cachelast */ - 196, /* (122) alter_topic_optr ::= alter_db_optr */ - 196, /* (123) alter_topic_optr ::= alter_topic_optr partitions */ - 227, /* (124) typename ::= ids */ - 227, /* (125) typename ::= ids LP signed RP */ - 227, /* (126) typename ::= ids UNSIGNED */ - 228, /* (127) signed ::= INTEGER */ - 228, /* (128) signed ::= PLUS INTEGER */ - 228, /* (129) signed ::= MINUS INTEGER */ - 190, /* (130) cmd ::= CREATE TABLE create_table_args */ - 190, /* (131) cmd ::= CREATE TABLE create_stable_args */ - 190, /* (132) cmd ::= CREATE STABLE create_stable_args */ - 190, /* (133) cmd ::= CREATE TABLE create_table_list */ - 231, /* (134) create_table_list ::= create_from_stable */ - 231, /* (135) create_table_list ::= create_table_list create_from_stable */ - 229, /* (136) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ - 230, /* (137) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ - 232, /* (138) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ - 232, /* (139) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ - 234, /* (140) tagNamelist ::= tagNamelist COMMA ids */ - 234, /* (141) tagNamelist ::= ids */ - 229, /* (142) create_table_args ::= ifnotexists ids cpxName AS select */ - 233, /* (143) columnlist ::= columnlist COMMA column */ - 233, /* (144) columnlist ::= column */ - 236, /* (145) column ::= ids typename */ - 211, /* (146) tagitemlist ::= tagitemlist COMMA tagitem */ - 211, /* (147) tagitemlist ::= tagitem */ - 237, /* (148) tagitem ::= INTEGER */ - 237, /* (149) tagitem ::= FLOAT */ - 237, /* (150) tagitem ::= STRING */ - 237, /* (151) tagitem ::= BOOL */ - 237, /* (152) tagitem ::= NULL */ - 237, /* (153) tagitem ::= MINUS INTEGER */ - 237, /* (154) tagitem ::= MINUS FLOAT */ - 237, /* (155) tagitem ::= PLUS INTEGER */ - 237, /* (156) tagitem ::= PLUS FLOAT */ - 235, /* (157) select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ - 235, /* (158) select ::= LP select RP */ - 251, /* (159) union ::= select */ - 251, /* (160) union ::= union UNION ALL select */ - 190, /* (161) cmd ::= union */ - 235, /* (162) select ::= SELECT selcollist */ - 252, /* (163) sclp ::= selcollist COMMA */ - 252, /* (164) sclp ::= */ - 238, /* (165) selcollist ::= sclp distinct expr as */ - 238, /* (166) selcollist ::= sclp STAR */ - 255, /* (167) as ::= AS ids */ - 255, /* (168) as ::= ids */ - 255, /* (169) as ::= */ - 253, /* (170) distinct ::= DISTINCT */ - 253, /* (171) distinct ::= */ - 239, /* (172) from ::= FROM tablelist */ - 239, /* (173) from ::= FROM sub */ - 257, /* (174) sub ::= LP union RP */ - 257, /* (175) sub ::= LP union RP ids */ - 257, /* (176) sub ::= sub COMMA LP union RP ids */ - 256, /* (177) tablelist ::= ids cpxName */ - 256, /* (178) tablelist ::= ids cpxName ids */ - 256, /* (179) tablelist ::= tablelist COMMA ids cpxName */ - 256, /* (180) tablelist ::= tablelist COMMA ids cpxName ids */ - 258, /* (181) tmvar ::= VARIABLE */ - 241, /* (182) interval_opt ::= INTERVAL LP tmvar RP */ - 241, /* (183) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ - 241, /* (184) interval_opt ::= */ - 242, /* (185) session_option ::= */ - 242, /* (186) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ - 243, /* (187) windowstate_option ::= */ - 243, /* (188) windowstate_option ::= STATE_WINDOW LP ids RP */ - 244, /* (189) fill_opt ::= */ - 244, /* (190) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - 244, /* (191) fill_opt ::= FILL LP ID RP */ - 245, /* (192) sliding_opt ::= SLIDING LP tmvar RP */ - 245, /* (193) sliding_opt ::= */ - 247, /* (194) orderby_opt ::= */ - 247, /* (195) orderby_opt ::= ORDER BY sortlist */ - 259, /* (196) sortlist ::= sortlist COMMA item sortorder */ - 259, /* (197) sortlist ::= item sortorder */ - 261, /* (198) item ::= ids cpxName */ - 262, /* (199) sortorder ::= ASC */ - 262, /* (200) sortorder ::= DESC */ - 262, /* (201) sortorder ::= */ - 246, /* (202) groupby_opt ::= */ - 246, /* (203) groupby_opt ::= GROUP BY grouplist */ - 263, /* (204) grouplist ::= grouplist COMMA item */ - 263, /* (205) grouplist ::= item */ - 248, /* (206) having_opt ::= */ - 248, /* (207) having_opt ::= HAVING expr */ - 250, /* (208) limit_opt ::= */ - 250, /* (209) limit_opt ::= LIMIT signed */ - 250, /* (210) limit_opt ::= LIMIT signed OFFSET signed */ - 250, /* (211) limit_opt ::= LIMIT signed COMMA signed */ - 249, /* (212) slimit_opt ::= */ - 249, /* (213) slimit_opt ::= SLIMIT signed */ - 249, /* (214) slimit_opt ::= SLIMIT signed SOFFSET signed */ - 249, /* (215) slimit_opt ::= SLIMIT signed COMMA signed */ - 240, /* (216) where_opt ::= */ - 240, /* (217) where_opt ::= WHERE expr */ - 254, /* (218) expr ::= LP expr RP */ - 254, /* (219) expr ::= ID */ - 254, /* (220) expr ::= ID DOT ID */ - 254, /* (221) expr ::= ID DOT STAR */ - 254, /* (222) expr ::= INTEGER */ - 254, /* (223) expr ::= MINUS INTEGER */ - 254, /* (224) expr ::= PLUS INTEGER */ - 254, /* (225) expr ::= FLOAT */ - 254, /* (226) expr ::= MINUS FLOAT */ - 254, /* (227) expr ::= PLUS FLOAT */ - 254, /* (228) expr ::= STRING */ - 254, /* (229) expr ::= NOW */ - 254, /* (230) expr ::= VARIABLE */ - 254, /* (231) expr ::= PLUS VARIABLE */ - 254, /* (232) expr ::= MINUS VARIABLE */ - 254, /* (233) expr ::= BOOL */ - 254, /* (234) expr ::= NULL */ - 254, /* (235) expr ::= ID LP exprlist RP */ - 254, /* (236) expr ::= ID LP STAR RP */ - 254, /* (237) expr ::= expr IS NULL */ - 254, /* (238) expr ::= expr IS NOT NULL */ - 254, /* (239) expr ::= expr LT expr */ - 254, /* (240) expr ::= expr GT expr */ - 254, /* (241) expr ::= expr LE expr */ - 254, /* (242) expr ::= expr GE expr */ - 254, /* (243) expr ::= expr NE expr */ - 254, /* (244) expr ::= expr EQ expr */ - 254, /* (245) expr ::= expr BETWEEN expr AND expr */ - 254, /* (246) expr ::= expr AND expr */ - 254, /* (247) expr ::= expr OR expr */ - 254, /* (248) expr ::= expr PLUS expr */ - 254, /* (249) expr ::= expr MINUS expr */ - 254, /* (250) expr ::= expr STAR expr */ - 254, /* (251) expr ::= expr SLASH expr */ - 254, /* (252) expr ::= expr REM expr */ - 254, /* (253) expr ::= expr LIKE expr */ - 254, /* (254) expr ::= expr IN LP exprlist RP */ - 264, /* (255) exprlist ::= exprlist COMMA expritem */ - 264, /* (256) exprlist ::= expritem */ - 265, /* (257) expritem ::= expr */ - 265, /* (258) expritem ::= */ - 190, /* (259) cmd ::= RESET QUERY CACHE */ - 190, /* (260) cmd ::= SYNCDB ids REPLICA */ - 190, /* (261) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - 190, /* (262) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - 190, /* (263) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ - 190, /* (264) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - 190, /* (265) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - 190, /* (266) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - 190, /* (267) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - 190, /* (268) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ - 190, /* (269) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - 190, /* (270) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - 190, /* (271) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ - 190, /* (272) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - 190, /* (273) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - 190, /* (274) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - 190, /* (275) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ - 190, /* (276) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ - 190, /* (277) cmd ::= KILL CONNECTION INTEGER */ - 190, /* (278) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - 190, /* (279) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + 210, /* (78) intitemlist ::= intitemlist COMMA intitem */ + 210, /* (79) intitemlist ::= intitem */ + 211, /* (80) intitem ::= INTEGER */ + 212, /* (81) keep ::= KEEP intitemlist */ + 213, /* (82) cache ::= CACHE INTEGER */ + 214, /* (83) replica ::= REPLICA INTEGER */ + 215, /* (84) quorum ::= QUORUM INTEGER */ + 216, /* (85) days ::= DAYS INTEGER */ + 217, /* (86) minrows ::= MINROWS INTEGER */ + 218, /* (87) maxrows ::= MAXROWS INTEGER */ + 219, /* (88) blocks ::= BLOCKS INTEGER */ + 220, /* (89) ctime ::= CTIME INTEGER */ + 221, /* (90) wal ::= WAL INTEGER */ + 222, /* (91) fsync ::= FSYNC INTEGER */ + 223, /* (92) comp ::= COMP INTEGER */ + 224, /* (93) prec ::= PRECISION STRING */ + 225, /* (94) update ::= UPDATE INTEGER */ + 226, /* (95) cachelast ::= CACHELAST INTEGER */ + 227, /* (96) partitions ::= PARTITIONS INTEGER */ + 199, /* (97) db_optr ::= */ + 199, /* (98) db_optr ::= db_optr cache */ + 199, /* (99) db_optr ::= db_optr replica */ + 199, /* (100) db_optr ::= db_optr quorum */ + 199, /* (101) db_optr ::= db_optr days */ + 199, /* (102) db_optr ::= db_optr minrows */ + 199, /* (103) db_optr ::= db_optr maxrows */ + 199, /* (104) db_optr ::= db_optr blocks */ + 199, /* (105) db_optr ::= db_optr ctime */ + 199, /* (106) db_optr ::= db_optr wal */ + 199, /* (107) db_optr ::= db_optr fsync */ + 199, /* (108) db_optr ::= db_optr comp */ + 199, /* (109) db_optr ::= db_optr prec */ + 199, /* (110) db_optr ::= db_optr keep */ + 199, /* (111) db_optr ::= db_optr update */ + 199, /* (112) db_optr ::= db_optr cachelast */ + 200, /* (113) topic_optr ::= db_optr */ + 200, /* (114) topic_optr ::= topic_optr partitions */ + 195, /* (115) alter_db_optr ::= */ + 195, /* (116) alter_db_optr ::= alter_db_optr replica */ + 195, /* (117) alter_db_optr ::= alter_db_optr quorum */ + 195, /* (118) alter_db_optr ::= alter_db_optr keep */ + 195, /* (119) alter_db_optr ::= alter_db_optr blocks */ + 195, /* (120) alter_db_optr ::= alter_db_optr comp */ + 195, /* (121) alter_db_optr ::= alter_db_optr wal */ + 195, /* (122) alter_db_optr ::= alter_db_optr fsync */ + 195, /* (123) alter_db_optr ::= alter_db_optr update */ + 195, /* (124) alter_db_optr ::= alter_db_optr cachelast */ + 196, /* (125) alter_topic_optr ::= alter_db_optr */ + 196, /* (126) alter_topic_optr ::= alter_topic_optr partitions */ + 228, /* (127) typename ::= ids */ + 228, /* (128) typename ::= ids LP signed RP */ + 228, /* (129) typename ::= ids UNSIGNED */ + 229, /* (130) signed ::= INTEGER */ + 229, /* (131) signed ::= PLUS INTEGER */ + 229, /* (132) signed ::= MINUS INTEGER */ + 190, /* (133) cmd ::= CREATE TABLE create_table_args */ + 190, /* (134) cmd ::= CREATE TABLE create_stable_args */ + 190, /* (135) cmd ::= CREATE STABLE create_stable_args */ + 190, /* (136) cmd ::= CREATE TABLE create_table_list */ + 232, /* (137) create_table_list ::= create_from_stable */ + 232, /* (138) create_table_list ::= create_table_list create_from_stable */ + 230, /* (139) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + 231, /* (140) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + 233, /* (141) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ + 233, /* (142) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ + 236, /* (143) tagNamelist ::= tagNamelist COMMA ids */ + 236, /* (144) tagNamelist ::= ids */ + 230, /* (145) create_table_args ::= ifnotexists ids cpxName AS select */ + 234, /* (146) columnlist ::= columnlist COMMA column */ + 234, /* (147) columnlist ::= column */ + 238, /* (148) column ::= ids typename */ + 235, /* (149) tagitemlist ::= tagitemlist COMMA tagitem */ + 235, /* (150) tagitemlist ::= tagitem */ + 239, /* (151) tagitem ::= INTEGER */ + 239, /* (152) tagitem ::= FLOAT */ + 239, /* (153) tagitem ::= STRING */ + 239, /* (154) tagitem ::= BOOL */ + 239, /* (155) tagitem ::= NULL */ + 239, /* (156) tagitem ::= MINUS INTEGER */ + 239, /* (157) tagitem ::= MINUS FLOAT */ + 239, /* (158) tagitem ::= PLUS INTEGER */ + 239, /* (159) tagitem ::= PLUS FLOAT */ + 237, /* (160) select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ + 237, /* (161) select ::= LP select RP */ + 253, /* (162) union ::= select */ + 253, /* (163) union ::= union UNION ALL select */ + 190, /* (164) cmd ::= union */ + 237, /* (165) select ::= SELECT selcollist */ + 254, /* (166) sclp ::= selcollist COMMA */ + 254, /* (167) sclp ::= */ + 240, /* (168) selcollist ::= sclp distinct expr as */ + 240, /* (169) selcollist ::= sclp STAR */ + 257, /* (170) as ::= AS ids */ + 257, /* (171) as ::= ids */ + 257, /* (172) as ::= */ + 255, /* (173) distinct ::= DISTINCT */ + 255, /* (174) distinct ::= */ + 241, /* (175) from ::= FROM tablelist */ + 241, /* (176) from ::= FROM sub */ + 259, /* (177) sub ::= LP union RP */ + 259, /* (178) sub ::= LP union RP ids */ + 259, /* (179) sub ::= sub COMMA LP union RP ids */ + 258, /* (180) tablelist ::= ids cpxName */ + 258, /* (181) tablelist ::= ids cpxName ids */ + 258, /* (182) tablelist ::= tablelist COMMA ids cpxName */ + 258, /* (183) tablelist ::= tablelist COMMA ids cpxName ids */ + 260, /* (184) tmvar ::= VARIABLE */ + 243, /* (185) interval_opt ::= INTERVAL LP tmvar RP */ + 243, /* (186) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ + 243, /* (187) interval_opt ::= */ + 244, /* (188) session_option ::= */ + 244, /* (189) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + 245, /* (190) windowstate_option ::= */ + 245, /* (191) windowstate_option ::= STATE_WINDOW LP ids RP */ + 246, /* (192) fill_opt ::= */ + 246, /* (193) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + 246, /* (194) fill_opt ::= FILL LP ID RP */ + 247, /* (195) sliding_opt ::= SLIDING LP tmvar RP */ + 247, /* (196) sliding_opt ::= */ + 249, /* (197) orderby_opt ::= */ + 249, /* (198) orderby_opt ::= ORDER BY sortlist */ + 261, /* (199) sortlist ::= sortlist COMMA item sortorder */ + 261, /* (200) sortlist ::= item sortorder */ + 263, /* (201) item ::= ids cpxName */ + 264, /* (202) sortorder ::= ASC */ + 264, /* (203) sortorder ::= DESC */ + 264, /* (204) sortorder ::= */ + 248, /* (205) groupby_opt ::= */ + 248, /* (206) groupby_opt ::= GROUP BY grouplist */ + 265, /* (207) grouplist ::= grouplist COMMA item */ + 265, /* (208) grouplist ::= item */ + 250, /* (209) having_opt ::= */ + 250, /* (210) having_opt ::= HAVING expr */ + 252, /* (211) limit_opt ::= */ + 252, /* (212) limit_opt ::= LIMIT signed */ + 252, /* (213) limit_opt ::= LIMIT signed OFFSET signed */ + 252, /* (214) limit_opt ::= LIMIT signed COMMA signed */ + 251, /* (215) slimit_opt ::= */ + 251, /* (216) slimit_opt ::= SLIMIT signed */ + 251, /* (217) slimit_opt ::= SLIMIT signed SOFFSET signed */ + 251, /* (218) slimit_opt ::= SLIMIT signed COMMA signed */ + 242, /* (219) where_opt ::= */ + 242, /* (220) where_opt ::= WHERE expr */ + 256, /* (221) expr ::= LP expr RP */ + 256, /* (222) expr ::= ID */ + 256, /* (223) expr ::= ID DOT ID */ + 256, /* (224) expr ::= ID DOT STAR */ + 256, /* (225) expr ::= INTEGER */ + 256, /* (226) expr ::= MINUS INTEGER */ + 256, /* (227) expr ::= PLUS INTEGER */ + 256, /* (228) expr ::= FLOAT */ + 256, /* (229) expr ::= MINUS FLOAT */ + 256, /* (230) expr ::= PLUS FLOAT */ + 256, /* (231) expr ::= STRING */ + 256, /* (232) expr ::= NOW */ + 256, /* (233) expr ::= VARIABLE */ + 256, /* (234) expr ::= PLUS VARIABLE */ + 256, /* (235) expr ::= MINUS VARIABLE */ + 256, /* (236) expr ::= BOOL */ + 256, /* (237) expr ::= NULL */ + 256, /* (238) expr ::= ID LP exprlist RP */ + 256, /* (239) expr ::= ID LP STAR RP */ + 256, /* (240) expr ::= expr IS NULL */ + 256, /* (241) expr ::= expr IS NOT NULL */ + 256, /* (242) expr ::= expr LT expr */ + 256, /* (243) expr ::= expr GT expr */ + 256, /* (244) expr ::= expr LE expr */ + 256, /* (245) expr ::= expr GE expr */ + 256, /* (246) expr ::= expr NE expr */ + 256, /* (247) expr ::= expr EQ expr */ + 256, /* (248) expr ::= expr BETWEEN expr AND expr */ + 256, /* (249) expr ::= expr AND expr */ + 256, /* (250) expr ::= expr OR expr */ + 256, /* (251) expr ::= expr PLUS expr */ + 256, /* (252) expr ::= expr MINUS expr */ + 256, /* (253) expr ::= expr STAR expr */ + 256, /* (254) expr ::= expr SLASH expr */ + 256, /* (255) expr ::= expr REM expr */ + 256, /* (256) expr ::= expr LIKE expr */ + 256, /* (257) expr ::= expr IN LP exprlist RP */ + 266, /* (258) exprlist ::= exprlist COMMA expritem */ + 266, /* (259) exprlist ::= expritem */ + 267, /* (260) expritem ::= expr */ + 267, /* (261) expritem ::= */ + 190, /* (262) cmd ::= RESET QUERY CACHE */ + 190, /* (263) cmd ::= SYNCDB ids REPLICA */ + 190, /* (264) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + 190, /* (265) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + 190, /* (266) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + 190, /* (267) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + 190, /* (268) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + 190, /* (269) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + 190, /* (270) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + 190, /* (271) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + 190, /* (272) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + 190, /* (273) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + 190, /* (274) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + 190, /* (275) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + 190, /* (276) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + 190, /* (277) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + 190, /* (278) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + 190, /* (279) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + 190, /* (280) cmd ::= KILL CONNECTION INTEGER */ + 190, /* (281) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + 190, /* (282) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number @@ -2163,208 +2172,211 @@ static const signed char yyRuleInfoNRhs[] = { 0, /* (75) state ::= */ -2, /* (76) state ::= STATE ids */ -9, /* (77) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ - -2, /* (78) keep ::= KEEP tagitemlist */ - -2, /* (79) cache ::= CACHE INTEGER */ - -2, /* (80) replica ::= REPLICA INTEGER */ - -2, /* (81) quorum ::= QUORUM INTEGER */ - -2, /* (82) days ::= DAYS INTEGER */ - -2, /* (83) minrows ::= MINROWS INTEGER */ - -2, /* (84) maxrows ::= MAXROWS INTEGER */ - -2, /* (85) blocks ::= BLOCKS INTEGER */ - -2, /* (86) ctime ::= CTIME INTEGER */ - -2, /* (87) wal ::= WAL INTEGER */ - -2, /* (88) fsync ::= FSYNC INTEGER */ - -2, /* (89) comp ::= COMP INTEGER */ - -2, /* (90) prec ::= PRECISION STRING */ - -2, /* (91) update ::= UPDATE INTEGER */ - -2, /* (92) cachelast ::= CACHELAST INTEGER */ - -2, /* (93) partitions ::= PARTITIONS INTEGER */ - 0, /* (94) db_optr ::= */ - -2, /* (95) db_optr ::= db_optr cache */ - -2, /* (96) db_optr ::= db_optr replica */ - -2, /* (97) db_optr ::= db_optr quorum */ - -2, /* (98) db_optr ::= db_optr days */ - -2, /* (99) db_optr ::= db_optr minrows */ - -2, /* (100) db_optr ::= db_optr maxrows */ - -2, /* (101) db_optr ::= db_optr blocks */ - -2, /* (102) db_optr ::= db_optr ctime */ - -2, /* (103) db_optr ::= db_optr wal */ - -2, /* (104) db_optr ::= db_optr fsync */ - -2, /* (105) db_optr ::= db_optr comp */ - -2, /* (106) db_optr ::= db_optr prec */ - -2, /* (107) db_optr ::= db_optr keep */ - -2, /* (108) db_optr ::= db_optr update */ - -2, /* (109) db_optr ::= db_optr cachelast */ - -1, /* (110) topic_optr ::= db_optr */ - -2, /* (111) topic_optr ::= topic_optr partitions */ - 0, /* (112) alter_db_optr ::= */ - -2, /* (113) alter_db_optr ::= alter_db_optr replica */ - -2, /* (114) alter_db_optr ::= alter_db_optr quorum */ - -2, /* (115) alter_db_optr ::= alter_db_optr keep */ - -2, /* (116) alter_db_optr ::= alter_db_optr blocks */ - -2, /* (117) alter_db_optr ::= alter_db_optr comp */ - -2, /* (118) alter_db_optr ::= alter_db_optr wal */ - -2, /* (119) alter_db_optr ::= alter_db_optr fsync */ - -2, /* (120) alter_db_optr ::= alter_db_optr update */ - -2, /* (121) alter_db_optr ::= alter_db_optr cachelast */ - -1, /* (122) alter_topic_optr ::= alter_db_optr */ - -2, /* (123) alter_topic_optr ::= alter_topic_optr partitions */ - -1, /* (124) typename ::= ids */ - -4, /* (125) typename ::= ids LP signed RP */ - -2, /* (126) typename ::= ids UNSIGNED */ - -1, /* (127) signed ::= INTEGER */ - -2, /* (128) signed ::= PLUS INTEGER */ - -2, /* (129) signed ::= MINUS INTEGER */ - -3, /* (130) cmd ::= CREATE TABLE create_table_args */ - -3, /* (131) cmd ::= CREATE TABLE create_stable_args */ - -3, /* (132) cmd ::= CREATE STABLE create_stable_args */ - -3, /* (133) cmd ::= CREATE TABLE create_table_list */ - -1, /* (134) create_table_list ::= create_from_stable */ - -2, /* (135) create_table_list ::= create_table_list create_from_stable */ - -6, /* (136) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ - -10, /* (137) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ - -10, /* (138) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ - -13, /* (139) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ - -3, /* (140) tagNamelist ::= tagNamelist COMMA ids */ - -1, /* (141) tagNamelist ::= ids */ - -5, /* (142) create_table_args ::= ifnotexists ids cpxName AS select */ - -3, /* (143) columnlist ::= columnlist COMMA column */ - -1, /* (144) columnlist ::= column */ - -2, /* (145) column ::= ids typename */ - -3, /* (146) tagitemlist ::= tagitemlist COMMA tagitem */ - -1, /* (147) tagitemlist ::= tagitem */ - -1, /* (148) tagitem ::= INTEGER */ - -1, /* (149) tagitem ::= FLOAT */ - -1, /* (150) tagitem ::= STRING */ - -1, /* (151) tagitem ::= BOOL */ - -1, /* (152) tagitem ::= NULL */ - -2, /* (153) tagitem ::= MINUS INTEGER */ - -2, /* (154) tagitem ::= MINUS FLOAT */ - -2, /* (155) tagitem ::= PLUS INTEGER */ - -2, /* (156) tagitem ::= PLUS FLOAT */ - -14, /* (157) select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ - -3, /* (158) select ::= LP select RP */ - -1, /* (159) union ::= select */ - -4, /* (160) union ::= union UNION ALL select */ - -1, /* (161) cmd ::= union */ - -2, /* (162) select ::= SELECT selcollist */ - -2, /* (163) sclp ::= selcollist COMMA */ - 0, /* (164) sclp ::= */ - -4, /* (165) selcollist ::= sclp distinct expr as */ - -2, /* (166) selcollist ::= sclp STAR */ - -2, /* (167) as ::= AS ids */ - -1, /* (168) as ::= ids */ - 0, /* (169) as ::= */ - -1, /* (170) distinct ::= DISTINCT */ - 0, /* (171) distinct ::= */ - -2, /* (172) from ::= FROM tablelist */ - -2, /* (173) from ::= FROM sub */ - -3, /* (174) sub ::= LP union RP */ - -4, /* (175) sub ::= LP union RP ids */ - -6, /* (176) sub ::= sub COMMA LP union RP ids */ - -2, /* (177) tablelist ::= ids cpxName */ - -3, /* (178) tablelist ::= ids cpxName ids */ - -4, /* (179) tablelist ::= tablelist COMMA ids cpxName */ - -5, /* (180) tablelist ::= tablelist COMMA ids cpxName ids */ - -1, /* (181) tmvar ::= VARIABLE */ - -4, /* (182) interval_opt ::= INTERVAL LP tmvar RP */ - -6, /* (183) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ - 0, /* (184) interval_opt ::= */ - 0, /* (185) session_option ::= */ - -7, /* (186) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ - 0, /* (187) windowstate_option ::= */ - -4, /* (188) windowstate_option ::= STATE_WINDOW LP ids RP */ - 0, /* (189) fill_opt ::= */ - -6, /* (190) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - -4, /* (191) fill_opt ::= FILL LP ID RP */ - -4, /* (192) sliding_opt ::= SLIDING LP tmvar RP */ - 0, /* (193) sliding_opt ::= */ - 0, /* (194) orderby_opt ::= */ - -3, /* (195) orderby_opt ::= ORDER BY sortlist */ - -4, /* (196) sortlist ::= sortlist COMMA item sortorder */ - -2, /* (197) sortlist ::= item sortorder */ - -2, /* (198) item ::= ids cpxName */ - -1, /* (199) sortorder ::= ASC */ - -1, /* (200) sortorder ::= DESC */ - 0, /* (201) sortorder ::= */ - 0, /* (202) groupby_opt ::= */ - -3, /* (203) groupby_opt ::= GROUP BY grouplist */ - -3, /* (204) grouplist ::= grouplist COMMA item */ - -1, /* (205) grouplist ::= item */ - 0, /* (206) having_opt ::= */ - -2, /* (207) having_opt ::= HAVING expr */ - 0, /* (208) limit_opt ::= */ - -2, /* (209) limit_opt ::= LIMIT signed */ - -4, /* (210) limit_opt ::= LIMIT signed OFFSET signed */ - -4, /* (211) limit_opt ::= LIMIT signed COMMA signed */ - 0, /* (212) slimit_opt ::= */ - -2, /* (213) slimit_opt ::= SLIMIT signed */ - -4, /* (214) slimit_opt ::= SLIMIT signed SOFFSET signed */ - -4, /* (215) slimit_opt ::= SLIMIT signed COMMA signed */ - 0, /* (216) where_opt ::= */ - -2, /* (217) where_opt ::= WHERE expr */ - -3, /* (218) expr ::= LP expr RP */ - -1, /* (219) expr ::= ID */ - -3, /* (220) expr ::= ID DOT ID */ - -3, /* (221) expr ::= ID DOT STAR */ - -1, /* (222) expr ::= INTEGER */ - -2, /* (223) expr ::= MINUS INTEGER */ - -2, /* (224) expr ::= PLUS INTEGER */ - -1, /* (225) expr ::= FLOAT */ - -2, /* (226) expr ::= MINUS FLOAT */ - -2, /* (227) expr ::= PLUS FLOAT */ - -1, /* (228) expr ::= STRING */ - -1, /* (229) expr ::= NOW */ - -1, /* (230) expr ::= VARIABLE */ - -2, /* (231) expr ::= PLUS VARIABLE */ - -2, /* (232) expr ::= MINUS VARIABLE */ - -1, /* (233) expr ::= BOOL */ - -1, /* (234) expr ::= NULL */ - -4, /* (235) expr ::= ID LP exprlist RP */ - -4, /* (236) expr ::= ID LP STAR RP */ - -3, /* (237) expr ::= expr IS NULL */ - -4, /* (238) expr ::= expr IS NOT NULL */ - -3, /* (239) expr ::= expr LT expr */ - -3, /* (240) expr ::= expr GT expr */ - -3, /* (241) expr ::= expr LE expr */ - -3, /* (242) expr ::= expr GE expr */ - -3, /* (243) expr ::= expr NE expr */ - -3, /* (244) expr ::= expr EQ expr */ - -5, /* (245) expr ::= expr BETWEEN expr AND expr */ - -3, /* (246) expr ::= expr AND expr */ - -3, /* (247) expr ::= expr OR expr */ - -3, /* (248) expr ::= expr PLUS expr */ - -3, /* (249) expr ::= expr MINUS expr */ - -3, /* (250) expr ::= expr STAR expr */ - -3, /* (251) expr ::= expr SLASH expr */ - -3, /* (252) expr ::= expr REM expr */ - -3, /* (253) expr ::= expr LIKE expr */ - -5, /* (254) expr ::= expr IN LP exprlist RP */ - -3, /* (255) exprlist ::= exprlist COMMA expritem */ - -1, /* (256) exprlist ::= expritem */ - -1, /* (257) expritem ::= expr */ - 0, /* (258) expritem ::= */ - -3, /* (259) cmd ::= RESET QUERY CACHE */ - -3, /* (260) cmd ::= SYNCDB ids REPLICA */ - -7, /* (261) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - -7, /* (262) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - -7, /* (263) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ - -7, /* (264) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - -7, /* (265) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - -8, /* (266) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - -9, /* (267) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - -7, /* (268) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ - -7, /* (269) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - -7, /* (270) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - -7, /* (271) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ - -7, /* (272) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - -7, /* (273) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - -8, /* (274) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - -9, /* (275) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ - -7, /* (276) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ - -3, /* (277) cmd ::= KILL CONNECTION INTEGER */ - -5, /* (278) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - -5, /* (279) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + -3, /* (78) intitemlist ::= intitemlist COMMA intitem */ + -1, /* (79) intitemlist ::= intitem */ + -1, /* (80) intitem ::= INTEGER */ + -2, /* (81) keep ::= KEEP intitemlist */ + -2, /* (82) cache ::= CACHE INTEGER */ + -2, /* (83) replica ::= REPLICA INTEGER */ + -2, /* (84) quorum ::= QUORUM INTEGER */ + -2, /* (85) days ::= DAYS INTEGER */ + -2, /* (86) minrows ::= MINROWS INTEGER */ + -2, /* (87) maxrows ::= MAXROWS INTEGER */ + -2, /* (88) blocks ::= BLOCKS INTEGER */ + -2, /* (89) ctime ::= CTIME INTEGER */ + -2, /* (90) wal ::= WAL INTEGER */ + -2, /* (91) fsync ::= FSYNC INTEGER */ + -2, /* (92) comp ::= COMP INTEGER */ + -2, /* (93) prec ::= PRECISION STRING */ + -2, /* (94) update ::= UPDATE INTEGER */ + -2, /* (95) cachelast ::= CACHELAST INTEGER */ + -2, /* (96) partitions ::= PARTITIONS INTEGER */ + 0, /* (97) db_optr ::= */ + -2, /* (98) db_optr ::= db_optr cache */ + -2, /* (99) db_optr ::= db_optr replica */ + -2, /* (100) db_optr ::= db_optr quorum */ + -2, /* (101) db_optr ::= db_optr days */ + -2, /* (102) db_optr ::= db_optr minrows */ + -2, /* (103) db_optr ::= db_optr maxrows */ + -2, /* (104) db_optr ::= db_optr blocks */ + -2, /* (105) db_optr ::= db_optr ctime */ + -2, /* (106) db_optr ::= db_optr wal */ + -2, /* (107) db_optr ::= db_optr fsync */ + -2, /* (108) db_optr ::= db_optr comp */ + -2, /* (109) db_optr ::= db_optr prec */ + -2, /* (110) db_optr ::= db_optr keep */ + -2, /* (111) db_optr ::= db_optr update */ + -2, /* (112) db_optr ::= db_optr cachelast */ + -1, /* (113) topic_optr ::= db_optr */ + -2, /* (114) topic_optr ::= topic_optr partitions */ + 0, /* (115) alter_db_optr ::= */ + -2, /* (116) alter_db_optr ::= alter_db_optr replica */ + -2, /* (117) alter_db_optr ::= alter_db_optr quorum */ + -2, /* (118) alter_db_optr ::= alter_db_optr keep */ + -2, /* (119) alter_db_optr ::= alter_db_optr blocks */ + -2, /* (120) alter_db_optr ::= alter_db_optr comp */ + -2, /* (121) alter_db_optr ::= alter_db_optr wal */ + -2, /* (122) alter_db_optr ::= alter_db_optr fsync */ + -2, /* (123) alter_db_optr ::= alter_db_optr update */ + -2, /* (124) alter_db_optr ::= alter_db_optr cachelast */ + -1, /* (125) alter_topic_optr ::= alter_db_optr */ + -2, /* (126) alter_topic_optr ::= alter_topic_optr partitions */ + -1, /* (127) typename ::= ids */ + -4, /* (128) typename ::= ids LP signed RP */ + -2, /* (129) typename ::= ids UNSIGNED */ + -1, /* (130) signed ::= INTEGER */ + -2, /* (131) signed ::= PLUS INTEGER */ + -2, /* (132) signed ::= MINUS INTEGER */ + -3, /* (133) cmd ::= CREATE TABLE create_table_args */ + -3, /* (134) cmd ::= CREATE TABLE create_stable_args */ + -3, /* (135) cmd ::= CREATE STABLE create_stable_args */ + -3, /* (136) cmd ::= CREATE TABLE create_table_list */ + -1, /* (137) create_table_list ::= create_from_stable */ + -2, /* (138) create_table_list ::= create_table_list create_from_stable */ + -6, /* (139) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + -10, /* (140) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + -10, /* (141) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ + -13, /* (142) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ + -3, /* (143) tagNamelist ::= tagNamelist COMMA ids */ + -1, /* (144) tagNamelist ::= ids */ + -5, /* (145) create_table_args ::= ifnotexists ids cpxName AS select */ + -3, /* (146) columnlist ::= columnlist COMMA column */ + -1, /* (147) columnlist ::= column */ + -2, /* (148) column ::= ids typename */ + -3, /* (149) tagitemlist ::= tagitemlist COMMA tagitem */ + -1, /* (150) tagitemlist ::= tagitem */ + -1, /* (151) tagitem ::= INTEGER */ + -1, /* (152) tagitem ::= FLOAT */ + -1, /* (153) tagitem ::= STRING */ + -1, /* (154) tagitem ::= BOOL */ + -1, /* (155) tagitem ::= NULL */ + -2, /* (156) tagitem ::= MINUS INTEGER */ + -2, /* (157) tagitem ::= MINUS FLOAT */ + -2, /* (158) tagitem ::= PLUS INTEGER */ + -2, /* (159) tagitem ::= PLUS FLOAT */ + -14, /* (160) select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ + -3, /* (161) select ::= LP select RP */ + -1, /* (162) union ::= select */ + -4, /* (163) union ::= union UNION ALL select */ + -1, /* (164) cmd ::= union */ + -2, /* (165) select ::= SELECT selcollist */ + -2, /* (166) sclp ::= selcollist COMMA */ + 0, /* (167) sclp ::= */ + -4, /* (168) selcollist ::= sclp distinct expr as */ + -2, /* (169) selcollist ::= sclp STAR */ + -2, /* (170) as ::= AS ids */ + -1, /* (171) as ::= ids */ + 0, /* (172) as ::= */ + -1, /* (173) distinct ::= DISTINCT */ + 0, /* (174) distinct ::= */ + -2, /* (175) from ::= FROM tablelist */ + -2, /* (176) from ::= FROM sub */ + -3, /* (177) sub ::= LP union RP */ + -4, /* (178) sub ::= LP union RP ids */ + -6, /* (179) sub ::= sub COMMA LP union RP ids */ + -2, /* (180) tablelist ::= ids cpxName */ + -3, /* (181) tablelist ::= ids cpxName ids */ + -4, /* (182) tablelist ::= tablelist COMMA ids cpxName */ + -5, /* (183) tablelist ::= tablelist COMMA ids cpxName ids */ + -1, /* (184) tmvar ::= VARIABLE */ + -4, /* (185) interval_opt ::= INTERVAL LP tmvar RP */ + -6, /* (186) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ + 0, /* (187) interval_opt ::= */ + 0, /* (188) session_option ::= */ + -7, /* (189) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + 0, /* (190) windowstate_option ::= */ + -4, /* (191) windowstate_option ::= STATE_WINDOW LP ids RP */ + 0, /* (192) fill_opt ::= */ + -6, /* (193) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + -4, /* (194) fill_opt ::= FILL LP ID RP */ + -4, /* (195) sliding_opt ::= SLIDING LP tmvar RP */ + 0, /* (196) sliding_opt ::= */ + 0, /* (197) orderby_opt ::= */ + -3, /* (198) orderby_opt ::= ORDER BY sortlist */ + -4, /* (199) sortlist ::= sortlist COMMA item sortorder */ + -2, /* (200) sortlist ::= item sortorder */ + -2, /* (201) item ::= ids cpxName */ + -1, /* (202) sortorder ::= ASC */ + -1, /* (203) sortorder ::= DESC */ + 0, /* (204) sortorder ::= */ + 0, /* (205) groupby_opt ::= */ + -3, /* (206) groupby_opt ::= GROUP BY grouplist */ + -3, /* (207) grouplist ::= grouplist COMMA item */ + -1, /* (208) grouplist ::= item */ + 0, /* (209) having_opt ::= */ + -2, /* (210) having_opt ::= HAVING expr */ + 0, /* (211) limit_opt ::= */ + -2, /* (212) limit_opt ::= LIMIT signed */ + -4, /* (213) limit_opt ::= LIMIT signed OFFSET signed */ + -4, /* (214) limit_opt ::= LIMIT signed COMMA signed */ + 0, /* (215) slimit_opt ::= */ + -2, /* (216) slimit_opt ::= SLIMIT signed */ + -4, /* (217) slimit_opt ::= SLIMIT signed SOFFSET signed */ + -4, /* (218) slimit_opt ::= SLIMIT signed COMMA signed */ + 0, /* (219) where_opt ::= */ + -2, /* (220) where_opt ::= WHERE expr */ + -3, /* (221) expr ::= LP expr RP */ + -1, /* (222) expr ::= ID */ + -3, /* (223) expr ::= ID DOT ID */ + -3, /* (224) expr ::= ID DOT STAR */ + -1, /* (225) expr ::= INTEGER */ + -2, /* (226) expr ::= MINUS INTEGER */ + -2, /* (227) expr ::= PLUS INTEGER */ + -1, /* (228) expr ::= FLOAT */ + -2, /* (229) expr ::= MINUS FLOAT */ + -2, /* (230) expr ::= PLUS FLOAT */ + -1, /* (231) expr ::= STRING */ + -1, /* (232) expr ::= NOW */ + -1, /* (233) expr ::= VARIABLE */ + -2, /* (234) expr ::= PLUS VARIABLE */ + -2, /* (235) expr ::= MINUS VARIABLE */ + -1, /* (236) expr ::= BOOL */ + -1, /* (237) expr ::= NULL */ + -4, /* (238) expr ::= ID LP exprlist RP */ + -4, /* (239) expr ::= ID LP STAR RP */ + -3, /* (240) expr ::= expr IS NULL */ + -4, /* (241) expr ::= expr IS NOT NULL */ + -3, /* (242) expr ::= expr LT expr */ + -3, /* (243) expr ::= expr GT expr */ + -3, /* (244) expr ::= expr LE expr */ + -3, /* (245) expr ::= expr GE expr */ + -3, /* (246) expr ::= expr NE expr */ + -3, /* (247) expr ::= expr EQ expr */ + -5, /* (248) expr ::= expr BETWEEN expr AND expr */ + -3, /* (249) expr ::= expr AND expr */ + -3, /* (250) expr ::= expr OR expr */ + -3, /* (251) expr ::= expr PLUS expr */ + -3, /* (252) expr ::= expr MINUS expr */ + -3, /* (253) expr ::= expr STAR expr */ + -3, /* (254) expr ::= expr SLASH expr */ + -3, /* (255) expr ::= expr REM expr */ + -3, /* (256) expr ::= expr LIKE expr */ + -5, /* (257) expr ::= expr IN LP exprlist RP */ + -3, /* (258) exprlist ::= exprlist COMMA expritem */ + -1, /* (259) exprlist ::= expritem */ + -1, /* (260) expritem ::= expr */ + 0, /* (261) expritem ::= */ + -3, /* (262) cmd ::= RESET QUERY CACHE */ + -3, /* (263) cmd ::= SYNCDB ids REPLICA */ + -7, /* (264) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + -7, /* (265) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + -7, /* (266) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + -7, /* (267) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + -7, /* (268) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + -8, /* (269) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + -9, /* (270) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + -7, /* (271) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + -7, /* (272) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + -7, /* (273) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + -7, /* (274) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + -7, /* (275) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + -7, /* (276) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + -8, /* (277) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + -9, /* (278) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + -7, /* (279) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + -3, /* (280) cmd ::= KILL CONNECTION INTEGER */ + -5, /* (281) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + -5, /* (282) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2455,9 +2467,9 @@ static YYACTIONTYPE yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* program ::= cmd */ - case 130: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==130); - case 131: /* cmd ::= CREATE TABLE create_stable_args */ yytestcase(yyruleno==131); - case 132: /* cmd ::= CREATE STABLE create_stable_args */ yytestcase(yyruleno==132); + case 133: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==133); + case 134: /* cmd ::= CREATE TABLE create_stable_args */ yytestcase(yyruleno==134); + case 135: /* cmd ::= CREATE STABLE create_stable_args */ yytestcase(yyruleno==135); {} break; case 1: /* cmd ::= SHOW DATABASES */ @@ -2627,13 +2639,13 @@ static YYACTIONTYPE yy_reduce( break; case 44: /* cmd ::= ALTER DATABASE ids alter_db_optr */ case 45: /* cmd ::= ALTER TOPIC ids alter_topic_optr */ yytestcase(yyruleno==45); -{ SStrToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy114, &t);} +{ SStrToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy22, &t);} break; case 46: /* cmd ::= ALTER ACCOUNT ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy183);} +{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy83);} break; case 47: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy183);} +{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy83);} break; case 48: /* ids ::= ID */ case 49: /* ids ::= STRING */ yytestcase(yyruleno==49); @@ -2645,7 +2657,7 @@ static YYACTIONTYPE yy_reduce( break; case 51: /* ifexists ::= */ case 53: /* ifnotexists ::= */ yytestcase(yyruleno==53); - case 171: /* distinct ::= */ yytestcase(yyruleno==171); + case 174: /* distinct ::= */ yytestcase(yyruleno==174); { yymsp[1].minor.yy0.n = 0;} break; case 52: /* ifnotexists ::= IF NOT EXISTS */ @@ -2655,11 +2667,11 @@ static YYACTIONTYPE yy_reduce( { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 1, &yymsp[0].minor.yy0);} break; case 55: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy183);} +{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy83);} break; case 56: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ case 57: /* cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ yytestcase(yyruleno==57); -{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy114, &yymsp[-2].minor.yy0);} +{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy22, &yymsp[-2].minor.yy0);} break; case 58: /* cmd ::= CREATE USER ids PASS ids */ { setCreateUserSql(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);} @@ -2688,272 +2700,275 @@ static YYACTIONTYPE yy_reduce( break; case 77: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ { - yylhsminor.yy183.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; - yylhsminor.yy183.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; - yylhsminor.yy183.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; - yylhsminor.yy183.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; - yylhsminor.yy183.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; - yylhsminor.yy183.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy183.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy183.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; - yylhsminor.yy183.stat = yymsp[0].minor.yy0; + yylhsminor.yy83.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; + yylhsminor.yy83.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; + yylhsminor.yy83.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; + yylhsminor.yy83.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; + yylhsminor.yy83.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; + yylhsminor.yy83.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy83.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy83.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; + yylhsminor.yy83.stat = yymsp[0].minor.yy0; } - yymsp[-8].minor.yy183 = yylhsminor.yy183; + yymsp[-8].minor.yy83 = yylhsminor.yy83; break; - case 78: /* keep ::= KEEP tagitemlist */ -{ yymsp[-1].minor.yy193 = yymsp[0].minor.yy193; } + case 78: /* intitemlist ::= intitemlist COMMA intitem */ + case 149: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==149); +{ yylhsminor.yy325 = tVariantListAppend(yymsp[-2].minor.yy325, &yymsp[0].minor.yy442, -1); } + yymsp[-2].minor.yy325 = yylhsminor.yy325; break; - case 79: /* cache ::= CACHE INTEGER */ - case 80: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==80); - case 81: /* quorum ::= QUORUM INTEGER */ yytestcase(yyruleno==81); - case 82: /* days ::= DAYS INTEGER */ yytestcase(yyruleno==82); - case 83: /* minrows ::= MINROWS INTEGER */ yytestcase(yyruleno==83); - case 84: /* maxrows ::= MAXROWS INTEGER */ yytestcase(yyruleno==84); - case 85: /* blocks ::= BLOCKS INTEGER */ yytestcase(yyruleno==85); - case 86: /* ctime ::= CTIME INTEGER */ yytestcase(yyruleno==86); - case 87: /* wal ::= WAL INTEGER */ yytestcase(yyruleno==87); - case 88: /* fsync ::= FSYNC INTEGER */ yytestcase(yyruleno==88); - case 89: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==89); - case 90: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==90); - case 91: /* update ::= UPDATE INTEGER */ yytestcase(yyruleno==91); - case 92: /* cachelast ::= CACHELAST INTEGER */ yytestcase(yyruleno==92); - case 93: /* partitions ::= PARTITIONS INTEGER */ yytestcase(yyruleno==93); + case 79: /* intitemlist ::= intitem */ + case 150: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==150); +{ yylhsminor.yy325 = tVariantListAppend(NULL, &yymsp[0].minor.yy442, -1); } + yymsp[0].minor.yy325 = yylhsminor.yy325; + break; + case 80: /* intitem ::= INTEGER */ + case 151: /* tagitem ::= INTEGER */ yytestcase(yyruleno==151); + case 152: /* tagitem ::= FLOAT */ yytestcase(yyruleno==152); + case 153: /* tagitem ::= STRING */ yytestcase(yyruleno==153); + case 154: /* tagitem ::= BOOL */ yytestcase(yyruleno==154); +{ toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy442, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy442 = yylhsminor.yy442; + break; + case 81: /* keep ::= KEEP intitemlist */ +{ yymsp[-1].minor.yy325 = yymsp[0].minor.yy325; } + break; + case 82: /* cache ::= CACHE INTEGER */ + case 83: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==83); + case 84: /* quorum ::= QUORUM INTEGER */ yytestcase(yyruleno==84); + case 85: /* days ::= DAYS INTEGER */ yytestcase(yyruleno==85); + case 86: /* minrows ::= MINROWS INTEGER */ yytestcase(yyruleno==86); + case 87: /* maxrows ::= MAXROWS INTEGER */ yytestcase(yyruleno==87); + case 88: /* blocks ::= BLOCKS INTEGER */ yytestcase(yyruleno==88); + case 89: /* ctime ::= CTIME INTEGER */ yytestcase(yyruleno==89); + case 90: /* wal ::= WAL INTEGER */ yytestcase(yyruleno==90); + case 91: /* fsync ::= FSYNC INTEGER */ yytestcase(yyruleno==91); + case 92: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==92); + case 93: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==93); + case 94: /* update ::= UPDATE INTEGER */ yytestcase(yyruleno==94); + case 95: /* cachelast ::= CACHELAST INTEGER */ yytestcase(yyruleno==95); + case 96: /* partitions ::= PARTITIONS INTEGER */ yytestcase(yyruleno==96); { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 94: /* db_optr ::= */ -{setDefaultCreateDbOption(&yymsp[1].minor.yy114); yymsp[1].minor.yy114.dbType = TSDB_DB_TYPE_DEFAULT;} + case 97: /* db_optr ::= */ +{setDefaultCreateDbOption(&yymsp[1].minor.yy22); yymsp[1].minor.yy22.dbType = TSDB_DB_TYPE_DEFAULT;} break; - case 95: /* db_optr ::= db_optr cache */ -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; + case 98: /* db_optr ::= db_optr cache */ +{ yylhsminor.yy22 = yymsp[-1].minor.yy22; yylhsminor.yy22.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy22 = yylhsminor.yy22; break; - case 96: /* db_optr ::= db_optr replica */ - case 113: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==113); -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; + case 99: /* db_optr ::= db_optr replica */ + case 116: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==116); +{ yylhsminor.yy22 = yymsp[-1].minor.yy22; yylhsminor.yy22.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy22 = yylhsminor.yy22; break; - case 97: /* db_optr ::= db_optr quorum */ - case 114: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==114); -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; + case 100: /* db_optr ::= db_optr quorum */ + case 117: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==117); +{ yylhsminor.yy22 = yymsp[-1].minor.yy22; yylhsminor.yy22.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy22 = yylhsminor.yy22; break; - case 98: /* db_optr ::= db_optr days */ -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; + case 101: /* db_optr ::= db_optr days */ +{ yylhsminor.yy22 = yymsp[-1].minor.yy22; yylhsminor.yy22.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy22 = yylhsminor.yy22; break; - case 99: /* db_optr ::= db_optr minrows */ -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; + case 102: /* db_optr ::= db_optr minrows */ +{ yylhsminor.yy22 = yymsp[-1].minor.yy22; yylhsminor.yy22.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy22 = yylhsminor.yy22; break; - case 100: /* db_optr ::= db_optr maxrows */ -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; + case 103: /* db_optr ::= db_optr maxrows */ +{ yylhsminor.yy22 = yymsp[-1].minor.yy22; yylhsminor.yy22.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy22 = yylhsminor.yy22; break; - case 101: /* db_optr ::= db_optr blocks */ - case 116: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==116); -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; + case 104: /* db_optr ::= db_optr blocks */ + case 119: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==119); +{ yylhsminor.yy22 = yymsp[-1].minor.yy22; yylhsminor.yy22.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy22 = yylhsminor.yy22; break; - case 102: /* db_optr ::= db_optr ctime */ -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; + case 105: /* db_optr ::= db_optr ctime */ +{ yylhsminor.yy22 = yymsp[-1].minor.yy22; yylhsminor.yy22.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy22 = yylhsminor.yy22; break; - case 103: /* db_optr ::= db_optr wal */ - case 118: /* alter_db_optr ::= alter_db_optr wal */ yytestcase(yyruleno==118); -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; + case 106: /* db_optr ::= db_optr wal */ + case 121: /* alter_db_optr ::= alter_db_optr wal */ yytestcase(yyruleno==121); +{ yylhsminor.yy22 = yymsp[-1].minor.yy22; yylhsminor.yy22.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy22 = yylhsminor.yy22; break; - case 104: /* db_optr ::= db_optr fsync */ - case 119: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==119); -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; + case 107: /* db_optr ::= db_optr fsync */ + case 122: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==122); +{ yylhsminor.yy22 = yymsp[-1].minor.yy22; yylhsminor.yy22.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy22 = yylhsminor.yy22; break; - case 105: /* db_optr ::= db_optr comp */ - case 117: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==117); -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; + case 108: /* db_optr ::= db_optr comp */ + case 120: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==120); +{ yylhsminor.yy22 = yymsp[-1].minor.yy22; yylhsminor.yy22.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy22 = yylhsminor.yy22; break; - case 106: /* db_optr ::= db_optr prec */ -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.precision = yymsp[0].minor.yy0; } - yymsp[-1].minor.yy114 = yylhsminor.yy114; + case 109: /* db_optr ::= db_optr prec */ +{ yylhsminor.yy22 = yymsp[-1].minor.yy22; yylhsminor.yy22.precision = yymsp[0].minor.yy0; } + yymsp[-1].minor.yy22 = yylhsminor.yy22; break; - case 107: /* db_optr ::= db_optr keep */ - case 115: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==115); -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.keep = yymsp[0].minor.yy193; } - yymsp[-1].minor.yy114 = yylhsminor.yy114; + case 110: /* db_optr ::= db_optr keep */ + case 118: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==118); +{ yylhsminor.yy22 = yymsp[-1].minor.yy22; yylhsminor.yy22.keep = yymsp[0].minor.yy325; } + yymsp[-1].minor.yy22 = yylhsminor.yy22; break; - case 108: /* db_optr ::= db_optr update */ - case 120: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==120); -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; + case 111: /* db_optr ::= db_optr update */ + case 123: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==123); +{ yylhsminor.yy22 = yymsp[-1].minor.yy22; yylhsminor.yy22.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy22 = yylhsminor.yy22; break; - case 109: /* db_optr ::= db_optr cachelast */ - case 121: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==121); -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; + case 112: /* db_optr ::= db_optr cachelast */ + case 124: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==124); +{ yylhsminor.yy22 = yymsp[-1].minor.yy22; yylhsminor.yy22.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy22 = yylhsminor.yy22; break; - case 110: /* topic_optr ::= db_optr */ - case 122: /* alter_topic_optr ::= alter_db_optr */ yytestcase(yyruleno==122); -{ yylhsminor.yy114 = yymsp[0].minor.yy114; yylhsminor.yy114.dbType = TSDB_DB_TYPE_TOPIC; } - yymsp[0].minor.yy114 = yylhsminor.yy114; + case 113: /* topic_optr ::= db_optr */ + case 125: /* alter_topic_optr ::= alter_db_optr */ yytestcase(yyruleno==125); +{ yylhsminor.yy22 = yymsp[0].minor.yy22; yylhsminor.yy22.dbType = TSDB_DB_TYPE_TOPIC; } + yymsp[0].minor.yy22 = yylhsminor.yy22; break; - case 111: /* topic_optr ::= topic_optr partitions */ - case 123: /* alter_topic_optr ::= alter_topic_optr partitions */ yytestcase(yyruleno==123); -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; + case 114: /* topic_optr ::= topic_optr partitions */ + case 126: /* alter_topic_optr ::= alter_topic_optr partitions */ yytestcase(yyruleno==126); +{ yylhsminor.yy22 = yymsp[-1].minor.yy22; yylhsminor.yy22.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy22 = yylhsminor.yy22; break; - case 112: /* alter_db_optr ::= */ -{ setDefaultCreateDbOption(&yymsp[1].minor.yy114); yymsp[1].minor.yy114.dbType = TSDB_DB_TYPE_DEFAULT;} + case 115: /* alter_db_optr ::= */ +{ setDefaultCreateDbOption(&yymsp[1].minor.yy22); yymsp[1].minor.yy22.dbType = TSDB_DB_TYPE_DEFAULT;} break; - case 124: /* typename ::= ids */ + case 127: /* typename ::= ids */ { yymsp[0].minor.yy0.type = 0; - tSetColumnType (&yylhsminor.yy27, &yymsp[0].minor.yy0); + tSetColumnType (&yylhsminor.yy47, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy27 = yylhsminor.yy27; + yymsp[0].minor.yy47 = yylhsminor.yy47; break; - case 125: /* typename ::= ids LP signed RP */ + case 128: /* typename ::= ids LP signed RP */ { - if (yymsp[-1].minor.yy473 <= 0) { + if (yymsp[-1].minor.yy373 <= 0) { yymsp[-3].minor.yy0.type = 0; - tSetColumnType(&yylhsminor.yy27, &yymsp[-3].minor.yy0); + tSetColumnType(&yylhsminor.yy47, &yymsp[-3].minor.yy0); } else { - yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy473; // negative value of name length - tSetColumnType(&yylhsminor.yy27, &yymsp[-3].minor.yy0); + yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy373; // negative value of name length + tSetColumnType(&yylhsminor.yy47, &yymsp[-3].minor.yy0); } } - yymsp[-3].minor.yy27 = yylhsminor.yy27; + yymsp[-3].minor.yy47 = yylhsminor.yy47; break; - case 126: /* typename ::= ids UNSIGNED */ + case 129: /* typename ::= ids UNSIGNED */ { yymsp[-1].minor.yy0.type = 0; yymsp[-1].minor.yy0.n = ((yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z); - tSetColumnType (&yylhsminor.yy27, &yymsp[-1].minor.yy0); + tSetColumnType (&yylhsminor.yy47, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy27 = yylhsminor.yy27; + yymsp[-1].minor.yy47 = yylhsminor.yy47; break; - case 127: /* signed ::= INTEGER */ -{ yylhsminor.yy473 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[0].minor.yy473 = yylhsminor.yy473; + case 130: /* signed ::= INTEGER */ +{ yylhsminor.yy373 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[0].minor.yy373 = yylhsminor.yy373; break; - case 128: /* signed ::= PLUS INTEGER */ -{ yymsp[-1].minor.yy473 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + case 131: /* signed ::= PLUS INTEGER */ +{ yymsp[-1].minor.yy373 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 129: /* signed ::= MINUS INTEGER */ -{ yymsp[-1].minor.yy473 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} + case 132: /* signed ::= MINUS INTEGER */ +{ yymsp[-1].minor.yy373 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} break; - case 133: /* cmd ::= CREATE TABLE create_table_list */ -{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy270;} + case 136: /* cmd ::= CREATE TABLE create_table_list */ +{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy422;} break; - case 134: /* create_table_list ::= create_from_stable */ + case 137: /* create_table_list ::= create_from_stable */ { SCreateTableSql* pCreateTable = calloc(1, sizeof(SCreateTableSql)); pCreateTable->childTableInfo = taosArrayInit(4, sizeof(SCreatedTableInfo)); - taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy192); + taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy504); pCreateTable->type = TSQL_CREATE_TABLE_FROM_STABLE; - yylhsminor.yy270 = pCreateTable; + yylhsminor.yy422 = pCreateTable; } - yymsp[0].minor.yy270 = yylhsminor.yy270; + yymsp[0].minor.yy422 = yylhsminor.yy422; break; - case 135: /* create_table_list ::= create_table_list create_from_stable */ + case 138: /* create_table_list ::= create_table_list create_from_stable */ { - taosArrayPush(yymsp[-1].minor.yy270->childTableInfo, &yymsp[0].minor.yy192); - yylhsminor.yy270 = yymsp[-1].minor.yy270; + taosArrayPush(yymsp[-1].minor.yy422->childTableInfo, &yymsp[0].minor.yy504); + yylhsminor.yy422 = yymsp[-1].minor.yy422; } - yymsp[-1].minor.yy270 = yylhsminor.yy270; + yymsp[-1].minor.yy422 = yylhsminor.yy422; break; - case 136: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + case 139: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ { - yylhsminor.yy270 = tSetCreateTableInfo(yymsp[-1].minor.yy193, NULL, NULL, TSQL_CREATE_TABLE); - setSqlInfo(pInfo, yylhsminor.yy270, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy422 = tSetCreateTableInfo(yymsp[-1].minor.yy325, NULL, NULL, TSQL_CREATE_TABLE); + setSqlInfo(pInfo, yylhsminor.yy422, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-4].minor.yy0, &yymsp[-5].minor.yy0); } - yymsp[-5].minor.yy270 = yylhsminor.yy270; + yymsp[-5].minor.yy422 = yylhsminor.yy422; break; - case 137: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + case 140: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ { - yylhsminor.yy270 = tSetCreateTableInfo(yymsp[-5].minor.yy193, yymsp[-1].minor.yy193, NULL, TSQL_CREATE_STABLE); - setSqlInfo(pInfo, yylhsminor.yy270, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy422 = tSetCreateTableInfo(yymsp[-5].minor.yy325, yymsp[-1].minor.yy325, NULL, TSQL_CREATE_STABLE); + setSqlInfo(pInfo, yylhsminor.yy422, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); } - yymsp[-9].minor.yy270 = yylhsminor.yy270; + yymsp[-9].minor.yy422 = yylhsminor.yy422; break; - case 138: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ + case 141: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; - yylhsminor.yy192 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy193, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); + yylhsminor.yy504 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy325, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); } - yymsp[-9].minor.yy192 = yylhsminor.yy192; + yymsp[-9].minor.yy504 = yylhsminor.yy504; break; - case 139: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ + case 142: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ { yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; yymsp[-11].minor.yy0.n += yymsp[-10].minor.yy0.n; - yylhsminor.yy192 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy193, yymsp[-1].minor.yy193, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0); + yylhsminor.yy504 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy325, yymsp[-1].minor.yy325, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0); } - yymsp[-12].minor.yy192 = yylhsminor.yy192; + yymsp[-12].minor.yy504 = yylhsminor.yy504; break; - case 140: /* tagNamelist ::= tagNamelist COMMA ids */ -{taosArrayPush(yymsp[-2].minor.yy193, &yymsp[0].minor.yy0); yylhsminor.yy193 = yymsp[-2].minor.yy193; } - yymsp[-2].minor.yy193 = yylhsminor.yy193; + case 143: /* tagNamelist ::= tagNamelist COMMA ids */ +{taosArrayPush(yymsp[-2].minor.yy325, &yymsp[0].minor.yy0); yylhsminor.yy325 = yymsp[-2].minor.yy325; } + yymsp[-2].minor.yy325 = yylhsminor.yy325; break; - case 141: /* tagNamelist ::= ids */ -{yylhsminor.yy193 = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(yylhsminor.yy193, &yymsp[0].minor.yy0);} - yymsp[0].minor.yy193 = yylhsminor.yy193; + case 144: /* tagNamelist ::= ids */ +{yylhsminor.yy325 = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(yylhsminor.yy325, &yymsp[0].minor.yy0);} + yymsp[0].minor.yy325 = yylhsminor.yy325; break; - case 142: /* create_table_args ::= ifnotexists ids cpxName AS select */ + case 145: /* create_table_args ::= ifnotexists ids cpxName AS select */ { - yylhsminor.yy270 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy124, TSQL_CREATE_STREAM); - setSqlInfo(pInfo, yylhsminor.yy270, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy422 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy536, TSQL_CREATE_STREAM); + setSqlInfo(pInfo, yylhsminor.yy422, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-3].minor.yy0.n += yymsp[-2].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-3].minor.yy0, &yymsp[-4].minor.yy0); } - yymsp[-4].minor.yy270 = yylhsminor.yy270; + yymsp[-4].minor.yy422 = yylhsminor.yy422; break; - case 143: /* columnlist ::= columnlist COMMA column */ -{taosArrayPush(yymsp[-2].minor.yy193, &yymsp[0].minor.yy27); yylhsminor.yy193 = yymsp[-2].minor.yy193; } - yymsp[-2].minor.yy193 = yylhsminor.yy193; + case 146: /* columnlist ::= columnlist COMMA column */ +{taosArrayPush(yymsp[-2].minor.yy325, &yymsp[0].minor.yy47); yylhsminor.yy325 = yymsp[-2].minor.yy325; } + yymsp[-2].minor.yy325 = yylhsminor.yy325; break; - case 144: /* columnlist ::= column */ -{yylhsminor.yy193 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy193, &yymsp[0].minor.yy27);} - yymsp[0].minor.yy193 = yylhsminor.yy193; + case 147: /* columnlist ::= column */ +{yylhsminor.yy325 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy325, &yymsp[0].minor.yy47);} + yymsp[0].minor.yy325 = yylhsminor.yy325; break; - case 145: /* column ::= ids typename */ + case 148: /* column ::= ids typename */ { - tSetColumnInfo(&yylhsminor.yy27, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy27); + tSetColumnInfo(&yylhsminor.yy47, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy47); } - yymsp[-1].minor.yy27 = yylhsminor.yy27; + yymsp[-1].minor.yy47 = yylhsminor.yy47; break; - case 146: /* tagitemlist ::= tagitemlist COMMA tagitem */ -{ yylhsminor.yy193 = tVariantListAppend(yymsp[-2].minor.yy193, &yymsp[0].minor.yy442, -1); } - yymsp[-2].minor.yy193 = yylhsminor.yy193; - break; - case 147: /* tagitemlist ::= tagitem */ -{ yylhsminor.yy193 = tVariantListAppend(NULL, &yymsp[0].minor.yy442, -1); } - yymsp[0].minor.yy193 = yylhsminor.yy193; - break; - case 148: /* tagitem ::= INTEGER */ - case 149: /* tagitem ::= FLOAT */ yytestcase(yyruleno==149); - case 150: /* tagitem ::= STRING */ yytestcase(yyruleno==150); - case 151: /* tagitem ::= BOOL */ yytestcase(yyruleno==151); -{ toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy442, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy442 = yylhsminor.yy442; - break; - case 152: /* tagitem ::= NULL */ + case 155: /* tagitem ::= NULL */ { yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy442, &yymsp[0].minor.yy0); } yymsp[0].minor.yy442 = yylhsminor.yy442; break; - case 153: /* tagitem ::= MINUS INTEGER */ - case 154: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==154); - case 155: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==155); - case 156: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==156); + case 156: /* tagitem ::= MINUS INTEGER */ + case 157: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==157); + case 158: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==158); + case 159: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==159); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type; @@ -2962,181 +2977,181 @@ static YYACTIONTYPE yy_reduce( } yymsp[-1].minor.yy442 = yylhsminor.yy442; break; - case 157: /* select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ + case 160: /* select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ { - yylhsminor.yy124 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy193, yymsp[-11].minor.yy332, yymsp[-10].minor.yy454, yymsp[-4].minor.yy193, yymsp[-3].minor.yy193, &yymsp[-9].minor.yy392, &yymsp[-8].minor.yy447, &yymsp[-7].minor.yy76, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy193, &yymsp[0].minor.yy482, &yymsp[-1].minor.yy482, yymsp[-2].minor.yy454); + yylhsminor.yy536 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy325, yymsp[-11].minor.yy52, yymsp[-10].minor.yy162, yymsp[-4].minor.yy325, yymsp[-3].minor.yy325, &yymsp[-9].minor.yy328, &yymsp[-8].minor.yy84, &yymsp[-7].minor.yy176, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy325, &yymsp[0].minor.yy230, &yymsp[-1].minor.yy230, yymsp[-2].minor.yy162); } - yymsp[-13].minor.yy124 = yylhsminor.yy124; + yymsp[-13].minor.yy536 = yylhsminor.yy536; break; - case 158: /* select ::= LP select RP */ -{yymsp[-2].minor.yy124 = yymsp[-1].minor.yy124;} + case 161: /* select ::= LP select RP */ +{yymsp[-2].minor.yy536 = yymsp[-1].minor.yy536;} break; - case 159: /* union ::= select */ -{ yylhsminor.yy193 = setSubclause(NULL, yymsp[0].minor.yy124); } - yymsp[0].minor.yy193 = yylhsminor.yy193; + case 162: /* union ::= select */ +{ yylhsminor.yy325 = setSubclause(NULL, yymsp[0].minor.yy536); } + yymsp[0].minor.yy325 = yylhsminor.yy325; break; - case 160: /* union ::= union UNION ALL select */ -{ yylhsminor.yy193 = appendSelectClause(yymsp[-3].minor.yy193, yymsp[0].minor.yy124); } - yymsp[-3].minor.yy193 = yylhsminor.yy193; + case 163: /* union ::= union UNION ALL select */ +{ yylhsminor.yy325 = appendSelectClause(yymsp[-3].minor.yy325, yymsp[0].minor.yy536); } + yymsp[-3].minor.yy325 = yylhsminor.yy325; break; - case 161: /* cmd ::= union */ -{ setSqlInfo(pInfo, yymsp[0].minor.yy193, NULL, TSDB_SQL_SELECT); } + case 164: /* cmd ::= union */ +{ setSqlInfo(pInfo, yymsp[0].minor.yy325, NULL, TSDB_SQL_SELECT); } break; - case 162: /* select ::= SELECT selcollist */ + case 165: /* select ::= SELECT selcollist */ { - yylhsminor.yy124 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy193, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + yylhsminor.yy536 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy325, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } - yymsp[-1].minor.yy124 = yylhsminor.yy124; + yymsp[-1].minor.yy536 = yylhsminor.yy536; break; - case 163: /* sclp ::= selcollist COMMA */ -{yylhsminor.yy193 = yymsp[-1].minor.yy193;} - yymsp[-1].minor.yy193 = yylhsminor.yy193; + case 166: /* sclp ::= selcollist COMMA */ +{yylhsminor.yy325 = yymsp[-1].minor.yy325;} + yymsp[-1].minor.yy325 = yylhsminor.yy325; break; - case 164: /* sclp ::= */ - case 194: /* orderby_opt ::= */ yytestcase(yyruleno==194); -{yymsp[1].minor.yy193 = 0;} + case 167: /* sclp ::= */ + case 197: /* orderby_opt ::= */ yytestcase(yyruleno==197); +{yymsp[1].minor.yy325 = 0;} break; - case 165: /* selcollist ::= sclp distinct expr as */ + case 168: /* selcollist ::= sclp distinct expr as */ { - yylhsminor.yy193 = tSqlExprListAppend(yymsp[-3].minor.yy193, yymsp[-1].minor.yy454, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); + yylhsminor.yy325 = tSqlExprListAppend(yymsp[-3].minor.yy325, yymsp[-1].minor.yy162, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); } - yymsp[-3].minor.yy193 = yylhsminor.yy193; + yymsp[-3].minor.yy325 = yylhsminor.yy325; break; - case 166: /* selcollist ::= sclp STAR */ + case 169: /* selcollist ::= sclp STAR */ { tSqlExpr *pNode = tSqlExprCreateIdValue(NULL, TK_ALL); - yylhsminor.yy193 = tSqlExprListAppend(yymsp[-1].minor.yy193, pNode, 0, 0); + yylhsminor.yy325 = tSqlExprListAppend(yymsp[-1].minor.yy325, pNode, 0, 0); } - yymsp[-1].minor.yy193 = yylhsminor.yy193; + yymsp[-1].minor.yy325 = yylhsminor.yy325; break; - case 167: /* as ::= AS ids */ + case 170: /* as ::= AS ids */ { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 168: /* as ::= ids */ + case 171: /* as ::= ids */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 169: /* as ::= */ + case 172: /* as ::= */ { yymsp[1].minor.yy0.n = 0; } break; - case 170: /* distinct ::= DISTINCT */ + case 173: /* distinct ::= DISTINCT */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 172: /* from ::= FROM tablelist */ - case 173: /* from ::= FROM sub */ yytestcase(yyruleno==173); -{yymsp[-1].minor.yy332 = yymsp[0].minor.yy332;} + case 175: /* from ::= FROM tablelist */ + case 176: /* from ::= FROM sub */ yytestcase(yyruleno==176); +{yymsp[-1].minor.yy52 = yymsp[0].minor.yy52;} break; - case 174: /* sub ::= LP union RP */ -{yymsp[-2].minor.yy332 = addSubqueryElem(NULL, yymsp[-1].minor.yy193, NULL);} + case 177: /* sub ::= LP union RP */ +{yymsp[-2].minor.yy52 = addSubqueryElem(NULL, yymsp[-1].minor.yy325, NULL);} break; - case 175: /* sub ::= LP union RP ids */ -{yymsp[-3].minor.yy332 = addSubqueryElem(NULL, yymsp[-2].minor.yy193, &yymsp[0].minor.yy0);} + case 178: /* sub ::= LP union RP ids */ +{yymsp[-3].minor.yy52 = addSubqueryElem(NULL, yymsp[-2].minor.yy325, &yymsp[0].minor.yy0);} break; - case 176: /* sub ::= sub COMMA LP union RP ids */ -{yylhsminor.yy332 = addSubqueryElem(yymsp[-5].minor.yy332, yymsp[-2].minor.yy193, &yymsp[0].minor.yy0);} - yymsp[-5].minor.yy332 = yylhsminor.yy332; + case 179: /* sub ::= sub COMMA LP union RP ids */ +{yylhsminor.yy52 = addSubqueryElem(yymsp[-5].minor.yy52, yymsp[-2].minor.yy325, &yymsp[0].minor.yy0);} + yymsp[-5].minor.yy52 = yylhsminor.yy52; break; - case 177: /* tablelist ::= ids cpxName */ + case 180: /* tablelist ::= ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy332 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); + yylhsminor.yy52 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); } - yymsp[-1].minor.yy332 = yylhsminor.yy332; + yymsp[-1].minor.yy52 = yylhsminor.yy52; break; - case 178: /* tablelist ::= ids cpxName ids */ + case 181: /* tablelist ::= ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy332 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); + yylhsminor.yy52 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy332 = yylhsminor.yy332; + yymsp[-2].minor.yy52 = yylhsminor.yy52; break; - case 179: /* tablelist ::= tablelist COMMA ids cpxName */ + case 182: /* tablelist ::= tablelist COMMA ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy332 = setTableNameList(yymsp[-3].minor.yy332, &yymsp[-1].minor.yy0, NULL); + yylhsminor.yy52 = setTableNameList(yymsp[-3].minor.yy52, &yymsp[-1].minor.yy0, NULL); } - yymsp[-3].minor.yy332 = yylhsminor.yy332; + yymsp[-3].minor.yy52 = yylhsminor.yy52; break; - case 180: /* tablelist ::= tablelist COMMA ids cpxName ids */ + case 183: /* tablelist ::= tablelist COMMA ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy332 = setTableNameList(yymsp[-4].minor.yy332, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); + yylhsminor.yy52 = setTableNameList(yymsp[-4].minor.yy52, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } - yymsp[-4].minor.yy332 = yylhsminor.yy332; + yymsp[-4].minor.yy52 = yylhsminor.yy52; break; - case 181: /* tmvar ::= VARIABLE */ + case 184: /* tmvar ::= VARIABLE */ {yylhsminor.yy0 = yymsp[0].minor.yy0;} yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 182: /* interval_opt ::= INTERVAL LP tmvar RP */ -{yymsp[-3].minor.yy392.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy392.offset.n = 0;} + case 185: /* interval_opt ::= INTERVAL LP tmvar RP */ +{yymsp[-3].minor.yy328.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy328.offset.n = 0;} break; - case 183: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ -{yymsp[-5].minor.yy392.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy392.offset = yymsp[-1].minor.yy0;} + case 186: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ +{yymsp[-5].minor.yy328.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy328.offset = yymsp[-1].minor.yy0;} break; - case 184: /* interval_opt ::= */ -{memset(&yymsp[1].minor.yy392, 0, sizeof(yymsp[1].minor.yy392));} + case 187: /* interval_opt ::= */ +{memset(&yymsp[1].minor.yy328, 0, sizeof(yymsp[1].minor.yy328));} break; - case 185: /* session_option ::= */ -{yymsp[1].minor.yy447.col.n = 0; yymsp[1].minor.yy447.gap.n = 0;} + case 188: /* session_option ::= */ +{yymsp[1].minor.yy84.col.n = 0; yymsp[1].minor.yy84.gap.n = 0;} break; - case 186: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + case 189: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - yymsp[-6].minor.yy447.col = yymsp[-4].minor.yy0; - yymsp[-6].minor.yy447.gap = yymsp[-1].minor.yy0; + yymsp[-6].minor.yy84.col = yymsp[-4].minor.yy0; + yymsp[-6].minor.yy84.gap = yymsp[-1].minor.yy0; } break; - case 187: /* windowstate_option ::= */ -{yymsp[1].minor.yy76.col.n = 0;} + case 190: /* windowstate_option ::= */ +{yymsp[1].minor.yy176.col.n = 0;} break; - case 188: /* windowstate_option ::= STATE_WINDOW LP ids RP */ + case 191: /* windowstate_option ::= STATE_WINDOW LP ids RP */ { - yymsp[-3].minor.yy76.col = yymsp[-1].minor.yy0; + yymsp[-3].minor.yy176.col = yymsp[-1].minor.yy0; } break; - case 189: /* fill_opt ::= */ -{ yymsp[1].minor.yy193 = 0; } + case 192: /* fill_opt ::= */ +{ yymsp[1].minor.yy325 = 0; } break; - case 190: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + case 193: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ { tVariant A = {0}; toTSDBType(yymsp[-3].minor.yy0.type); tVariantCreate(&A, &yymsp[-3].minor.yy0); - tVariantListInsert(yymsp[-1].minor.yy193, &A, -1, 0); - yymsp[-5].minor.yy193 = yymsp[-1].minor.yy193; + tVariantListInsert(yymsp[-1].minor.yy325, &A, -1, 0); + yymsp[-5].minor.yy325 = yymsp[-1].minor.yy325; } break; - case 191: /* fill_opt ::= FILL LP ID RP */ + case 194: /* fill_opt ::= FILL LP ID RP */ { toTSDBType(yymsp[-1].minor.yy0.type); - yymsp[-3].minor.yy193 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); + yymsp[-3].minor.yy325 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); } break; - case 192: /* sliding_opt ::= SLIDING LP tmvar RP */ + case 195: /* sliding_opt ::= SLIDING LP tmvar RP */ {yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; } break; - case 193: /* sliding_opt ::= */ + case 196: /* sliding_opt ::= */ {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } break; - case 195: /* orderby_opt ::= ORDER BY sortlist */ -{yymsp[-2].minor.yy193 = yymsp[0].minor.yy193;} + case 198: /* orderby_opt ::= ORDER BY sortlist */ +{yymsp[-2].minor.yy325 = yymsp[0].minor.yy325;} break; - case 196: /* sortlist ::= sortlist COMMA item sortorder */ + case 199: /* sortlist ::= sortlist COMMA item sortorder */ { - yylhsminor.yy193 = tVariantListAppend(yymsp[-3].minor.yy193, &yymsp[-1].minor.yy442, yymsp[0].minor.yy312); + yylhsminor.yy325 = tVariantListAppend(yymsp[-3].minor.yy325, &yymsp[-1].minor.yy442, yymsp[0].minor.yy196); } - yymsp[-3].minor.yy193 = yylhsminor.yy193; + yymsp[-3].minor.yy325 = yylhsminor.yy325; break; - case 197: /* sortlist ::= item sortorder */ + case 200: /* sortlist ::= item sortorder */ { - yylhsminor.yy193 = tVariantListAppend(NULL, &yymsp[-1].minor.yy442, yymsp[0].minor.yy312); + yylhsminor.yy325 = tVariantListAppend(NULL, &yymsp[-1].minor.yy442, yymsp[0].minor.yy196); } - yymsp[-1].minor.yy193 = yylhsminor.yy193; + yymsp[-1].minor.yy325 = yylhsminor.yy325; break; - case 198: /* item ::= ids cpxName */ + case 201: /* item ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; @@ -3145,227 +3160,227 @@ static YYACTIONTYPE yy_reduce( } yymsp[-1].minor.yy442 = yylhsminor.yy442; break; - case 199: /* sortorder ::= ASC */ -{ yymsp[0].minor.yy312 = TSDB_ORDER_ASC; } + case 202: /* sortorder ::= ASC */ +{ yymsp[0].minor.yy196 = TSDB_ORDER_ASC; } break; - case 200: /* sortorder ::= DESC */ -{ yymsp[0].minor.yy312 = TSDB_ORDER_DESC;} + case 203: /* sortorder ::= DESC */ +{ yymsp[0].minor.yy196 = TSDB_ORDER_DESC;} break; - case 201: /* sortorder ::= */ -{ yymsp[1].minor.yy312 = TSDB_ORDER_ASC; } + case 204: /* sortorder ::= */ +{ yymsp[1].minor.yy196 = TSDB_ORDER_ASC; } break; - case 202: /* groupby_opt ::= */ -{ yymsp[1].minor.yy193 = 0;} + case 205: /* groupby_opt ::= */ +{ yymsp[1].minor.yy325 = 0;} break; - case 203: /* groupby_opt ::= GROUP BY grouplist */ -{ yymsp[-2].minor.yy193 = yymsp[0].minor.yy193;} + case 206: /* groupby_opt ::= GROUP BY grouplist */ +{ yymsp[-2].minor.yy325 = yymsp[0].minor.yy325;} break; - case 204: /* grouplist ::= grouplist COMMA item */ + case 207: /* grouplist ::= grouplist COMMA item */ { - yylhsminor.yy193 = tVariantListAppend(yymsp[-2].minor.yy193, &yymsp[0].minor.yy442, -1); + yylhsminor.yy325 = tVariantListAppend(yymsp[-2].minor.yy325, &yymsp[0].minor.yy442, -1); } - yymsp[-2].minor.yy193 = yylhsminor.yy193; + yymsp[-2].minor.yy325 = yylhsminor.yy325; break; - case 205: /* grouplist ::= item */ + case 208: /* grouplist ::= item */ { - yylhsminor.yy193 = tVariantListAppend(NULL, &yymsp[0].minor.yy442, -1); + yylhsminor.yy325 = tVariantListAppend(NULL, &yymsp[0].minor.yy442, -1); } - yymsp[0].minor.yy193 = yylhsminor.yy193; + yymsp[0].minor.yy325 = yylhsminor.yy325; break; - case 206: /* having_opt ::= */ - case 216: /* where_opt ::= */ yytestcase(yyruleno==216); - case 258: /* expritem ::= */ yytestcase(yyruleno==258); -{yymsp[1].minor.yy454 = 0;} + case 209: /* having_opt ::= */ + case 219: /* where_opt ::= */ yytestcase(yyruleno==219); + case 261: /* expritem ::= */ yytestcase(yyruleno==261); +{yymsp[1].minor.yy162 = 0;} break; - case 207: /* having_opt ::= HAVING expr */ - case 217: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==217); -{yymsp[-1].minor.yy454 = yymsp[0].minor.yy454;} + case 210: /* having_opt ::= HAVING expr */ + case 220: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==220); +{yymsp[-1].minor.yy162 = yymsp[0].minor.yy162;} break; - case 208: /* limit_opt ::= */ - case 212: /* slimit_opt ::= */ yytestcase(yyruleno==212); -{yymsp[1].minor.yy482.limit = -1; yymsp[1].minor.yy482.offset = 0;} + case 211: /* limit_opt ::= */ + case 215: /* slimit_opt ::= */ yytestcase(yyruleno==215); +{yymsp[1].minor.yy230.limit = -1; yymsp[1].minor.yy230.offset = 0;} break; - case 209: /* limit_opt ::= LIMIT signed */ - case 213: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==213); -{yymsp[-1].minor.yy482.limit = yymsp[0].minor.yy473; yymsp[-1].minor.yy482.offset = 0;} + case 212: /* limit_opt ::= LIMIT signed */ + case 216: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==216); +{yymsp[-1].minor.yy230.limit = yymsp[0].minor.yy373; yymsp[-1].minor.yy230.offset = 0;} break; - case 210: /* limit_opt ::= LIMIT signed OFFSET signed */ -{ yymsp[-3].minor.yy482.limit = yymsp[-2].minor.yy473; yymsp[-3].minor.yy482.offset = yymsp[0].minor.yy473;} + case 213: /* limit_opt ::= LIMIT signed OFFSET signed */ +{ yymsp[-3].minor.yy230.limit = yymsp[-2].minor.yy373; yymsp[-3].minor.yy230.offset = yymsp[0].minor.yy373;} break; - case 211: /* limit_opt ::= LIMIT signed COMMA signed */ -{ yymsp[-3].minor.yy482.limit = yymsp[0].minor.yy473; yymsp[-3].minor.yy482.offset = yymsp[-2].minor.yy473;} + case 214: /* limit_opt ::= LIMIT signed COMMA signed */ +{ yymsp[-3].minor.yy230.limit = yymsp[0].minor.yy373; yymsp[-3].minor.yy230.offset = yymsp[-2].minor.yy373;} break; - case 214: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ -{yymsp[-3].minor.yy482.limit = yymsp[-2].minor.yy473; yymsp[-3].minor.yy482.offset = yymsp[0].minor.yy473;} + case 217: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ +{yymsp[-3].minor.yy230.limit = yymsp[-2].minor.yy373; yymsp[-3].minor.yy230.offset = yymsp[0].minor.yy373;} break; - case 215: /* slimit_opt ::= SLIMIT signed COMMA signed */ -{yymsp[-3].minor.yy482.limit = yymsp[0].minor.yy473; yymsp[-3].minor.yy482.offset = yymsp[-2].minor.yy473;} + case 218: /* slimit_opt ::= SLIMIT signed COMMA signed */ +{yymsp[-3].minor.yy230.limit = yymsp[0].minor.yy373; yymsp[-3].minor.yy230.offset = yymsp[-2].minor.yy373;} break; - case 218: /* expr ::= LP expr RP */ -{yylhsminor.yy454 = yymsp[-1].minor.yy454; yylhsminor.yy454->token.z = yymsp[-2].minor.yy0.z; yylhsminor.yy454->token.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; + case 221: /* expr ::= LP expr RP */ +{yylhsminor.yy162 = yymsp[-1].minor.yy162; yylhsminor.yy162->token.z = yymsp[-2].minor.yy0.z; yylhsminor.yy162->token.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} + yymsp[-2].minor.yy162 = yylhsminor.yy162; break; - case 219: /* expr ::= ID */ -{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);} - yymsp[0].minor.yy454 = yylhsminor.yy454; + case 222: /* expr ::= ID */ +{ yylhsminor.yy162 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);} + yymsp[0].minor.yy162 = yylhsminor.yy162; break; - case 220: /* expr ::= ID DOT ID */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; + case 223: /* expr ::= ID DOT ID */ +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy162 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);} + yymsp[-2].minor.yy162 = yylhsminor.yy162; break; - case 221: /* expr ::= ID DOT STAR */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; + case 224: /* expr ::= ID DOT STAR */ +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy162 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);} + yymsp[-2].minor.yy162 = yylhsminor.yy162; break; - case 222: /* expr ::= INTEGER */ -{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);} - yymsp[0].minor.yy454 = yylhsminor.yy454; + case 225: /* expr ::= INTEGER */ +{ yylhsminor.yy162 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);} + yymsp[0].minor.yy162 = yylhsminor.yy162; break; - case 223: /* expr ::= MINUS INTEGER */ - case 224: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==224); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);} - yymsp[-1].minor.yy454 = yylhsminor.yy454; + case 226: /* expr ::= MINUS INTEGER */ + case 227: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==227); +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy162 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);} + yymsp[-1].minor.yy162 = yylhsminor.yy162; break; - case 225: /* expr ::= FLOAT */ -{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);} - yymsp[0].minor.yy454 = yylhsminor.yy454; + case 228: /* expr ::= FLOAT */ +{ yylhsminor.yy162 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);} + yymsp[0].minor.yy162 = yylhsminor.yy162; break; - case 226: /* expr ::= MINUS FLOAT */ - case 227: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==227); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);} - yymsp[-1].minor.yy454 = yylhsminor.yy454; + case 229: /* expr ::= MINUS FLOAT */ + case 230: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==230); +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy162 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);} + yymsp[-1].minor.yy162 = yylhsminor.yy162; break; - case 228: /* expr ::= STRING */ -{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);} - yymsp[0].minor.yy454 = yylhsminor.yy454; + case 231: /* expr ::= STRING */ +{ yylhsminor.yy162 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);} + yymsp[0].minor.yy162 = yylhsminor.yy162; break; - case 229: /* expr ::= NOW */ -{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); } - yymsp[0].minor.yy454 = yylhsminor.yy454; + case 232: /* expr ::= NOW */ +{ yylhsminor.yy162 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); } + yymsp[0].minor.yy162 = yylhsminor.yy162; break; - case 230: /* expr ::= VARIABLE */ -{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} - yymsp[0].minor.yy454 = yylhsminor.yy454; + case 233: /* expr ::= VARIABLE */ +{ yylhsminor.yy162 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} + yymsp[0].minor.yy162 = yylhsminor.yy162; break; - case 231: /* expr ::= PLUS VARIABLE */ - case 232: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==232); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);} - yymsp[-1].minor.yy454 = yylhsminor.yy454; + case 234: /* expr ::= PLUS VARIABLE */ + case 235: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==235); +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy162 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);} + yymsp[-1].minor.yy162 = yylhsminor.yy162; break; - case 233: /* expr ::= BOOL */ -{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} - yymsp[0].minor.yy454 = yylhsminor.yy454; + case 236: /* expr ::= BOOL */ +{ yylhsminor.yy162 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} + yymsp[0].minor.yy162 = yylhsminor.yy162; break; - case 234: /* expr ::= NULL */ -{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);} - yymsp[0].minor.yy454 = yylhsminor.yy454; + case 237: /* expr ::= NULL */ +{ yylhsminor.yy162 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);} + yymsp[0].minor.yy162 = yylhsminor.yy162; break; - case 235: /* expr ::= ID LP exprlist RP */ -{ yylhsminor.yy454 = tSqlExprCreateFunction(yymsp[-1].minor.yy193, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy454 = yylhsminor.yy454; + case 238: /* expr ::= ID LP exprlist RP */ +{ yylhsminor.yy162 = tSqlExprCreateFunction(yymsp[-1].minor.yy325, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy162 = yylhsminor.yy162; break; - case 236: /* expr ::= ID LP STAR RP */ -{ yylhsminor.yy454 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy454 = yylhsminor.yy454; + case 239: /* expr ::= ID LP STAR RP */ +{ yylhsminor.yy162 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy162 = yylhsminor.yy162; break; - case 237: /* expr ::= expr IS NULL */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, NULL, TK_ISNULL);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; + case 240: /* expr ::= expr IS NULL */ +{yylhsminor.yy162 = tSqlExprCreate(yymsp[-2].minor.yy162, NULL, TK_ISNULL);} + yymsp[-2].minor.yy162 = yylhsminor.yy162; break; - case 238: /* expr ::= expr IS NOT NULL */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-3].minor.yy454, NULL, TK_NOTNULL);} - yymsp[-3].minor.yy454 = yylhsminor.yy454; + case 241: /* expr ::= expr IS NOT NULL */ +{yylhsminor.yy162 = tSqlExprCreate(yymsp[-3].minor.yy162, NULL, TK_NOTNULL);} + yymsp[-3].minor.yy162 = yylhsminor.yy162; break; - case 239: /* expr ::= expr LT expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_LT);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; + case 242: /* expr ::= expr LT expr */ +{yylhsminor.yy162 = tSqlExprCreate(yymsp[-2].minor.yy162, yymsp[0].minor.yy162, TK_LT);} + yymsp[-2].minor.yy162 = yylhsminor.yy162; break; - case 240: /* expr ::= expr GT expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_GT);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; + case 243: /* expr ::= expr GT expr */ +{yylhsminor.yy162 = tSqlExprCreate(yymsp[-2].minor.yy162, yymsp[0].minor.yy162, TK_GT);} + yymsp[-2].minor.yy162 = yylhsminor.yy162; break; - case 241: /* expr ::= expr LE expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_LE);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; + case 244: /* expr ::= expr LE expr */ +{yylhsminor.yy162 = tSqlExprCreate(yymsp[-2].minor.yy162, yymsp[0].minor.yy162, TK_LE);} + yymsp[-2].minor.yy162 = yylhsminor.yy162; break; - case 242: /* expr ::= expr GE expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_GE);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; + case 245: /* expr ::= expr GE expr */ +{yylhsminor.yy162 = tSqlExprCreate(yymsp[-2].minor.yy162, yymsp[0].minor.yy162, TK_GE);} + yymsp[-2].minor.yy162 = yylhsminor.yy162; break; - case 243: /* expr ::= expr NE expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_NE);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; + case 246: /* expr ::= expr NE expr */ +{yylhsminor.yy162 = tSqlExprCreate(yymsp[-2].minor.yy162, yymsp[0].minor.yy162, TK_NE);} + yymsp[-2].minor.yy162 = yylhsminor.yy162; break; - case 244: /* expr ::= expr EQ expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_EQ);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; + case 247: /* expr ::= expr EQ expr */ +{yylhsminor.yy162 = tSqlExprCreate(yymsp[-2].minor.yy162, yymsp[0].minor.yy162, TK_EQ);} + yymsp[-2].minor.yy162 = yylhsminor.yy162; break; - case 245: /* expr ::= expr BETWEEN expr AND expr */ -{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy454); yylhsminor.yy454 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy454, yymsp[-2].minor.yy454, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy454, TK_LE), TK_AND);} - yymsp[-4].minor.yy454 = yylhsminor.yy454; + case 248: /* expr ::= expr BETWEEN expr AND expr */ +{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy162); yylhsminor.yy162 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy162, yymsp[-2].minor.yy162, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy162, TK_LE), TK_AND);} + yymsp[-4].minor.yy162 = yylhsminor.yy162; break; - case 246: /* expr ::= expr AND expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_AND);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; + case 249: /* expr ::= expr AND expr */ +{yylhsminor.yy162 = tSqlExprCreate(yymsp[-2].minor.yy162, yymsp[0].minor.yy162, TK_AND);} + yymsp[-2].minor.yy162 = yylhsminor.yy162; break; - case 247: /* expr ::= expr OR expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_OR); } - yymsp[-2].minor.yy454 = yylhsminor.yy454; + case 250: /* expr ::= expr OR expr */ +{yylhsminor.yy162 = tSqlExprCreate(yymsp[-2].minor.yy162, yymsp[0].minor.yy162, TK_OR); } + yymsp[-2].minor.yy162 = yylhsminor.yy162; break; - case 248: /* expr ::= expr PLUS expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_PLUS); } - yymsp[-2].minor.yy454 = yylhsminor.yy454; + case 251: /* expr ::= expr PLUS expr */ +{yylhsminor.yy162 = tSqlExprCreate(yymsp[-2].minor.yy162, yymsp[0].minor.yy162, TK_PLUS); } + yymsp[-2].minor.yy162 = yylhsminor.yy162; break; - case 249: /* expr ::= expr MINUS expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_MINUS); } - yymsp[-2].minor.yy454 = yylhsminor.yy454; + case 252: /* expr ::= expr MINUS expr */ +{yylhsminor.yy162 = tSqlExprCreate(yymsp[-2].minor.yy162, yymsp[0].minor.yy162, TK_MINUS); } + yymsp[-2].minor.yy162 = yylhsminor.yy162; break; - case 250: /* expr ::= expr STAR expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_STAR); } - yymsp[-2].minor.yy454 = yylhsminor.yy454; + case 253: /* expr ::= expr STAR expr */ +{yylhsminor.yy162 = tSqlExprCreate(yymsp[-2].minor.yy162, yymsp[0].minor.yy162, TK_STAR); } + yymsp[-2].minor.yy162 = yylhsminor.yy162; break; - case 251: /* expr ::= expr SLASH expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_DIVIDE);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; + case 254: /* expr ::= expr SLASH expr */ +{yylhsminor.yy162 = tSqlExprCreate(yymsp[-2].minor.yy162, yymsp[0].minor.yy162, TK_DIVIDE);} + yymsp[-2].minor.yy162 = yylhsminor.yy162; break; - case 252: /* expr ::= expr REM expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_REM); } - yymsp[-2].minor.yy454 = yylhsminor.yy454; + case 255: /* expr ::= expr REM expr */ +{yylhsminor.yy162 = tSqlExprCreate(yymsp[-2].minor.yy162, yymsp[0].minor.yy162, TK_REM); } + yymsp[-2].minor.yy162 = yylhsminor.yy162; break; - case 253: /* expr ::= expr LIKE expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_LIKE); } - yymsp[-2].minor.yy454 = yylhsminor.yy454; + case 256: /* expr ::= expr LIKE expr */ +{yylhsminor.yy162 = tSqlExprCreate(yymsp[-2].minor.yy162, yymsp[0].minor.yy162, TK_LIKE); } + yymsp[-2].minor.yy162 = yylhsminor.yy162; break; - case 254: /* expr ::= expr IN LP exprlist RP */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-4].minor.yy454, (tSqlExpr*)yymsp[-1].minor.yy193, TK_IN); } - yymsp[-4].minor.yy454 = yylhsminor.yy454; + case 257: /* expr ::= expr IN LP exprlist RP */ +{yylhsminor.yy162 = tSqlExprCreate(yymsp[-4].minor.yy162, (tSqlExpr*)yymsp[-1].minor.yy325, TK_IN); } + yymsp[-4].minor.yy162 = yylhsminor.yy162; break; - case 255: /* exprlist ::= exprlist COMMA expritem */ -{yylhsminor.yy193 = tSqlExprListAppend(yymsp[-2].minor.yy193,yymsp[0].minor.yy454,0, 0);} - yymsp[-2].minor.yy193 = yylhsminor.yy193; + case 258: /* exprlist ::= exprlist COMMA expritem */ +{yylhsminor.yy325 = tSqlExprListAppend(yymsp[-2].minor.yy325,yymsp[0].minor.yy162,0, 0);} + yymsp[-2].minor.yy325 = yylhsminor.yy325; break; - case 256: /* exprlist ::= expritem */ -{yylhsminor.yy193 = tSqlExprListAppend(0,yymsp[0].minor.yy454,0, 0);} - yymsp[0].minor.yy193 = yylhsminor.yy193; + case 259: /* exprlist ::= expritem */ +{yylhsminor.yy325 = tSqlExprListAppend(0,yymsp[0].minor.yy162,0, 0);} + yymsp[0].minor.yy325 = yylhsminor.yy325; break; - case 257: /* expritem ::= expr */ -{yylhsminor.yy454 = yymsp[0].minor.yy454;} - yymsp[0].minor.yy454 = yylhsminor.yy454; + case 260: /* expritem ::= expr */ +{yylhsminor.yy162 = yymsp[0].minor.yy162;} + yymsp[0].minor.yy162 = yylhsminor.yy162; break; - case 259: /* cmd ::= RESET QUERY CACHE */ + case 262: /* cmd ::= RESET QUERY CACHE */ { setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} break; - case 260: /* cmd ::= SYNCDB ids REPLICA */ + case 263: /* cmd ::= SYNCDB ids REPLICA */ { setDCLSqlElems(pInfo, TSDB_SQL_SYNC_DB_REPLICA, 1, &yymsp[-1].minor.yy0);} break; - case 261: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + case 264: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy193, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy325, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 262: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + case 265: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3376,21 +3391,21 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 263: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + case 266: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy193, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy325, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 264: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + case 267: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy193, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy325, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 265: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + case 268: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3401,7 +3416,7 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 266: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + case 269: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3415,7 +3430,7 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 267: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + case 270: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; @@ -3427,21 +3442,21 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 268: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + case 271: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy193, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy325, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 269: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + case 272: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy193, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy325, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 270: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + case 273: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3452,21 +3467,21 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 271: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + case 274: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy193, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy325, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 272: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + case 275: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy193, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy325, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 273: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + case 276: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3477,7 +3492,7 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 274: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + case 277: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3491,7 +3506,7 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 275: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + case 278: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; @@ -3503,20 +3518,20 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 276: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + case 279: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy193, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy325, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 277: /* cmd ::= KILL CONNECTION INTEGER */ + case 280: /* cmd ::= KILL CONNECTION INTEGER */ {setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);} break; - case 278: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ + case 281: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_STREAM, &yymsp[-2].minor.yy0);} break; - case 279: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ + case 282: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_QUERY, &yymsp[-2].minor.yy0);} break; default: diff --git a/src/util/src/terror.c b/src/util/src/terror.c index 382f872486..1d37a6e9a4 100644 --- a/src/util/src/terror.c +++ b/src/util/src/terror.c @@ -193,7 +193,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_IN_DROPPING, "Database not availabl TAOS_DEFINE_ERROR(TSDB_CODE_MND_VGROUP_NOT_READY, "Database unsynced") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_DB_OPTION_DAYS, "Invalid database option: days out of range") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_DB_OPTION_KEEP, "Invalid database option: keep >= keep1 >= keep0 >= days") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_DB_OPTION_KEEP, "Invalid database option: keep2 >= keep1 >= keep0 >= days") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_TOPIC, "Invalid topic name") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_TOPIC_OPTION, "Invalid topic option") From b80f22633969a4f2397038eb7728600ccbc33318 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 7 Jun 2021 17:03:35 +0800 Subject: [PATCH 32/72] [td-225] update log. --- src/query/src/qExecutor.c | 2 +- src/query/src/queryMain.c | 4 ++-- src/tsdb/src/tsdbRead.c | 16 +++++++++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 338861144e..b301221104 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -7208,7 +7208,7 @@ SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SGroupbyExpr* pGroupbyExpr, S // todo refactor pQInfo->query.queryBlockDist = (numOfOutput == 1 && pExprs[0].base.functionId == TSDB_FUNC_BLKINFO); - qDebug("qmsg:%p QInfo:0x%" PRIx64 "-%p created", pQueryMsg, pQInfo->qId, pQInfo); + qDebug("qmsg:%p vgId:%d, QInfo:0x%" PRIx64 "-%p created", pQueryMsg, pQInfo->query.vgId, pQInfo->qId, pQInfo); return pQInfo; _cleanup_qinfo: diff --git a/src/query/src/queryMain.c b/src/query/src/queryMain.c index fa2eac6619..38ef81e793 100644 --- a/src/query/src/queryMain.c +++ b/src/query/src/queryMain.c @@ -132,7 +132,7 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, qi numOfGroupByCols = 0; } - qDebug("qmsg:%p query stable, uid:%"PRId64", tid:%d", pQueryMsg, id->uid, id->tid); + qDebug("qmsg:%p query stable, uid:%"PRIu64", tid:%d", pQueryMsg, id->uid, id->tid); code = tsdbQuerySTableByTagCond(tsdb, id->uid, pQueryMsg->window.skey, param.tagCond, pQueryMsg->tagCondLen, pQueryMsg->tagNameRelType, param.tbnameCond, &tableGroupInfo, param.pGroupColIndex, numOfGroupByCols); @@ -162,7 +162,7 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, qi assert(pQueryMsg->stableQuery == isSTableQuery); (*pQInfo) = createQInfoImpl(pQueryMsg, param.pGroupbyExpr, param.pExprs, param.pSecExprs, &tableGroupInfo, - param.pTagColumnInfo, vgId, param.sql, qId); + param.pTagColumnInfo, vgId, param.sql, qId); param.sql = NULL; param.pExprs = NULL; diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 1545d44395..b66c9db95d 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -1088,7 +1088,11 @@ static int32_t handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SBlock* p assert(cur->pos >= 0 && cur->pos <= binfo.rows); TSKEY key = (row != NULL)? dataRowKey(row):TSKEY_INITIAL_VAL; - tsdbDebug("%p key in mem:%"PRId64", 0x%"PRIx64, pQueryHandle, key, pQueryHandle->qId); + if (key != TSKEY_INITIAL_VAL) { + tsdbDebug("%p key in mem:%"PRId64", 0x%"PRIx64, pQueryHandle, key, pQueryHandle->qId); + } else { + tsdbDebug("%p no data in mem, 0x%"PRIx64, pQueryHandle, pQueryHandle->qId); + } if ((ASCENDING_TRAVERSE(pQueryHandle->order) && (key != TSKEY_INITIAL_VAL && key <= binfo.window.ekey)) || (!ASCENDING_TRAVERSE(pQueryHandle->order) && (key != TSKEY_INITIAL_VAL && key >= binfo.window.skey))) { @@ -1152,8 +1156,14 @@ static int32_t handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SBlock* p } assert(cur->blockCompleted); - tsdbDebug("create data block from remain file block, brange:%"PRId64"-%"PRId64", rows:%d, lastKey:%"PRId64", %p", - cur->win.skey, cur->win.ekey, cur->rows, cur->lastKey, pQueryHandle); + if (cur->rows == binfo.rows) { + tsdbDebug("%p whole file block qualified, brange:%"PRId64"-%"PRId64", rows:%d, lastKey:%"PRId64", %"PRIx64, + pQueryHandle, cur->win.skey, cur->win.ekey, cur->rows, cur->lastKey, pQueryHandle->qId); + } else { + tsdbDebug("%p create data block from remain file block, brange:%"PRId64"-%"PRId64", rows:%d, total:%d, lastKey:%"PRId64", %"PRIx64, + pQueryHandle, cur->win.skey, cur->win.ekey, cur->rows, binfo.rows, cur->lastKey, pQueryHandle->qId); + } + } return code; From c9adad624d14ba6421eeccde323e4f8fee3b9452 Mon Sep 17 00:00:00 2001 From: tickduan <417921451@qq.com> Date: Mon, 7 Jun 2021 17:04:22 +0800 Subject: [PATCH 33/72] restore, fix build error --- src/client/src/tscSQLParser.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index a5b1675170..a04bfa0482 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -6675,7 +6675,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { const char* msg6 = "from missing in subclause"; const char* msg7 = "time interval is required"; const char* msg8 = "the first column should be primary timestamp column"; - + SSqlCmd* pCmd = &pSql->cmd; SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); assert(pQueryInfo->numOfTables == 1); @@ -6732,15 +6732,26 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); } + // project query primary column must be timestamp type if (tscIsProjectionQuery(pQueryInfo)) { - SExprInfo* pExpr = tscExprGet(pQueryInfo, 0); - if (pExpr->base.colInfo.colId != PRIMARYKEY_TIMESTAMP_COL_INDEX) { + size_t size = tscSqlExprNumOfExprs(pQueryInfo); + // check zero + if(size == 0) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg8); + } + + // check primary column is timestamp + SSqlExpr* pSqlExpr = tscSqlExprGet(pQueryInfo, 0); + if(pSqlExpr == NULL) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg8); + } + if( pSqlExpr->colInfo.colId != PRIMARYKEY_TIMESTAMP_COL_INDEX) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg8); } } else { if (pQueryInfo->interval.interval == 0) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg7); - } + } } // set the created table[stream] name From a9597ccbe73e009d7252240025ca052a11a4b831 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Mon, 7 Jun 2021 18:34:44 +0800 Subject: [PATCH 34/72] support upgrade from low version --- src/mnode/src/mnodeDb.c | 13 ++++++++++++- src/mnode/src/mnodeVgroup.c | 6 +++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c index 4b5d05ebc7..3fa33dc4b7 100644 --- a/src/mnode/src/mnodeDb.c +++ b/src/mnode/src/mnodeDb.c @@ -778,7 +778,11 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; char tmp[128] = {0}; - sprintf(tmp, "%d,%d,%d", pDb->cfg.daysToKeep0, pDb->cfg.daysToKeep1, pDb->cfg.daysToKeep2); + if (pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep1 || pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep2) { + sprintf(tmp, "%d,%d,%d", pDb->cfg.daysToKeep1, pDb->cfg.daysToKeep2, pDb->cfg.daysToKeep0); + } else { + sprintf(tmp, "%d,%d,%d", pDb->cfg.daysToKeep0, pDb->cfg.daysToKeep1, pDb->cfg.daysToKeep2); + } STR_WITH_SIZE_TO_VARSTR(pWrite, tmp, strlen(tmp)); cols++; @@ -937,6 +941,13 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) { terrno = TSDB_CODE_SUCCESS; + if (pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep1 || pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep2) { + int32_t t = pDb->cfg.daysToKeep0; + newCfg.daysToKeep0 = pDb->cfg.daysToKeep1; + newCfg.daysToKeep1 = pDb->cfg.daysToKeep2; + newCfg.daysToKeep2 = t; + } + if (cacheBlockSize > 0 && cacheBlockSize != pDb->cfg.cacheBlockSize) { mError("db:%s, can't alter cache option", pDb->name); terrno = TSDB_CODE_MND_INVALID_DB_OPTION; diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index 2e138ab890..2a781b9202 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -894,9 +894,9 @@ static SCreateVnodeMsg *mnodeBuildVnodeMsg(SVgObj *pVgroup) { pCfg->totalBlocks = htonl(pDb->cfg.totalBlocks); pCfg->maxTables = htonl(maxTables + 1); pCfg->daysPerFile = htonl(pDb->cfg.daysPerFile); - pCfg->daysToKeep = htonl(pDb->cfg.daysToKeep2); //FROM DB TO VNODE MAP - pCfg->daysToKeep1 = htonl(pDb->cfg.daysToKeep0); - pCfg->daysToKeep2 = htonl(pDb->cfg.daysToKeep1); + pCfg->daysToKeep = htonl(pDb->cfg.daysToKeep2); //FROM DB TO VNODE MAP: + pCfg->daysToKeep1 = htonl(pDb->cfg.daysToKeep0); //keep0,keep1,keep2 in SQL is mapped to keep1,keep2,keep in vnode + pCfg->daysToKeep2 = htonl(pDb->cfg.daysToKeep1); //user,client,mnode use keep0,keep1,keep2; vnode use keep1,keep2,keep pCfg->minRowsPerFileBlock = htonl(pDb->cfg.minRowsPerFileBlock); pCfg->maxRowsPerFileBlock = htonl(pDb->cfg.maxRowsPerFileBlock); pCfg->fsyncPeriod = htonl(pDb->cfg.fsyncPeriod); From 7608dab8ad8e67d8ea7f0c637d9a03f155dab54a Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Mon, 7 Jun 2021 19:35:59 +0800 Subject: [PATCH 35/72] [TD-4605]: early version visual studio compile. (#6399) --- src/kit/taosdemo/taosdemo.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index dcfed8bc2a..4202a833ea 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -625,6 +625,10 @@ static int64_t g_totalChildTables = 0; static SQueryMetaInfo g_queryInfo; static FILE * g_fpOfInsertResult = NULL; +#if _MSC_VER <= 1900 +#define __func__ __FUNCTION__ +#endif + #define debugPrint(fmt, ...) \ do { if (g_args.debug_print || g_args.verbose_print) \ fprintf(stderr, "DEBG: "fmt, __VA_ARGS__); } while(0) From 881b267d2fb3b008d5b582f353471bcf8b33420d Mon Sep 17 00:00:00 2001 From: bryanchang0603 Date: Tue, 8 Jun 2021 09:13:25 +0800 Subject: [PATCH 36/72] [TD-4473] revertalterkeep.py to older version --- tests/pytest/alter/alter_keep.py | 61 ++++++++------------------------ 1 file changed, 14 insertions(+), 47 deletions(-) diff --git a/tests/pytest/alter/alter_keep.py b/tests/pytest/alter/alter_keep.py index dd9fd08ba6..cb630963a7 100644 --- a/tests/pytest/alter/alter_keep.py +++ b/tests/pytest/alter/alter_keep.py @@ -116,58 +116,25 @@ class TDTestCase: ##TODO: need to wait for TD-4445 to implement the following ## tests - - ## preset the keep - tdSql.prepare() - tdSql.execute('create table tb (ts timestamp, speed int)') - tdSql.execute('alter database db keep 10,10,10') - tdSql.execute('insert into tb values (now, 10)') - tdSql.execute('insert into tb values (now + 10m, 10)') - tdSql.query('select * from tb') - tdSql.checkRows(2) - - - #after alter from small to large, check if the alter if functioning - #test if change through test.py is consistent with change from taos client - #test case for TD-4459 and TD-4445 - tdSql.execute('alter database db keep 40,40,40') - tdSql.query('show databases') - tdSql.checkData(0,7,'40,40,40') - tdSql.error('insert into tb values (now-60d, 10)') - tdSql.execute('insert into tb values (now-30d, 10)') - tdSql.query('select * from tb') - tdSql.checkRows(3) - - rowNum = 3 - for i in range(30): - rowNum += 1 - tdSql.execute('alter database db keep 20,20,20') - tdSql.execute('alter database db keep 40,40,40') - tdSql.query('show databases') - tdSql.checkData(0,7,'40,40,40') - tdSql.error('insert into tb values (now-60d, 10)') - tdSql.execute('insert into tb values (now-30d, 10)') - tdSql.query('select * from tb') - tdSql.checkRows(rowNum) - - tdSql.execute('alter database db keep 10,10,10') - tdSql.query('show databases') - tdSql.checkData(0,7,'10,10,10') - # tdSql.execute('alter database db keep 15,15,15') + # tdSql.prepare() + # tdSql.execute('create table tb (ts timestamp, speed int)') + # tdSql.execute('alter database db keep 10,10,10') + # tdSql.execute('insert into tb values (now, 10)') + # tdSql.execute('insert into tb values (now + 10m, 10)') + # tdSql.query('select * from tb') + # tdSql.checkRows(2) + # tdSql.execute('alter database db keep 40,40,40') # tdSql.query('show databases') - # tdSql.checkData(0,7,'15,15,15') - tdSql.execute('insert into tb values (now-15d, 10)') - tdSql.query('select * from tb') - tdSql.checkRows(rowNum + 1) - + # tdSql.checkData(0,7,'40,40,40') + # tdSql.error('insert into tb values (now-60d, 10)') + # tdSql.execute('insert into tb values (now-30d, 10)') + # tdSql.query('select * from tb') + # tdSql.checkRows(3) # tdSql.execute('alter database db keep 20,20,20') # tdSql.query('show databases') # tdSql.checkData(0,7,'20,20,20') - # tdSql.error('insert into tb values (now-30d, 10)') - # tdSql.query('show databases') - # tdSql.checkData(0,7,'20,20,20') # tdSql.query('select * from tb') - # tdSql.checkRows(rowNum) + # tdSql.checkRows(2) def stop(self): From b7c0995f8744d5c5a8badd1551276cb82cfeae45 Mon Sep 17 00:00:00 2001 From: bryanchang0603 Date: Tue, 8 Jun 2021 09:15:10 +0800 Subject: [PATCH 37/72] [TD-4473] remove old file --- .../manual_chang_time_1_auto_test.py | 111 ------------------ 1 file changed, 111 deletions(-) delete mode 100644 tests/pytest/manualTest/manual_chang_time_1_auto_test.py diff --git a/tests/pytest/manualTest/manual_chang_time_1_auto_test.py b/tests/pytest/manualTest/manual_chang_time_1_auto_test.py deleted file mode 100644 index a9e8935df4..0000000000 --- a/tests/pytest/manualTest/manual_chang_time_1_auto_test.py +++ /dev/null @@ -1,111 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -from util.log import * -from util.cases import * -from util.sql import * -from util.dnodes import tdDnodes -from datetime import datetime -import subprocess - -##TODO: auto test version is currently unsupported, need to come up with -# an auto test version in the future -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def getTDenginePath(self): - selfPath = os.path.dirname(os.path.realpath(__file__)) - - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] - else: - projPath = selfPath[:selfPath.find("tests")] - print(projPath) - for root, dirs, files in os.walk(projPath): - if ("sim" in dirs): - print(root) - rootRealPath = os.path.realpath(root) - # if ("packaging" not in rootRealPath): - # buildPath = root[:len(root)-len("/build/bin")] - # break - return rootRealPath - - def getBuildPath(self): - selfPath = os.path.dirname(os.path.realpath(__file__)) - - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] - else: - projPath = selfPath[:selfPath.find("tests")] - - for root, dirs, files in os.walk(projPath): - if ("taosd" in files): - rootRealPath = os.path.dirname(os.path.realpath(root)) - if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] - break - return buildPath - - def run(self): - tdSql.prepare() - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") - else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" - TDenginePath = self.getTDenginePath() - print('TD '+ TDenginePath) - if (TDenginePath == ""): - tdLog.exit("TDengine not found!") - else: - tdLog.info("TDengine found in %s" % TDenginePath) - - ## change system time to 2020/10/20 - os.system ('timedatectl set-ntp off') - os.system ('timedatectl set-time 2020-10-20') - - #run taosdemo to insert data. one row per second from 2020/10/11 to 2020/10/20 - #11 data files should be generated - #vnode at TDinternal/community/sim/dnode1/data/vnode - os.system("%staosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_A.json" % binPath) - commandArray = ['ls', '-l', f'{TDenginePath}/sim/dnode1/data/vnode/vnode2/tsdb/data'] - result = subprocess.run(commandArray, stdout=subprocess.PIPE).stdout.decode('utf-8') - print(result.count('data')) - if result.count('data') != 11: - tdLog.exit('wrong number of files') - else: - tdLog.info("data file number correct") - - os.system ('timedatectl set-time 2020-10-25') - os.system("%staosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_B.json" % binPath) - commandArray = ['ls', '-l', f'{TDenginePath}/sim/dnode1/data/vnode/vnode2/tsdb/data'] - result = subprocess.run(commandArray, stdout=subprocess.PIPE).stdout.decode('utf-8') - print(result.count('data')) - if result.count('data') != 7: - tdLog.exit('wrong number of files') - else: - tdLog.info("data file number correct") - tdSql.query('select first(ts) from stb_0') - tdSql.checkData(0,0,datetime(2020,10,14,8,0,0,0)) - - def stop(self): - tdSql.close() - tdLog.debug("%s alter block manual check finish" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) From 2aaa8c33c817851dd479366c82f862eb86db768d Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 8 Jun 2021 10:00:31 +0800 Subject: [PATCH 38/72] [td-225]fix bug in derivative --- src/client/src/tscSQLParser.c | 32 ++++-- src/query/src/qAggMain.c | 19 ++-- tests/script/general/parser/function.sim | 122 +++++++++++++++++++++++ 3 files changed, 152 insertions(+), 21 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index e7a821ddf4..5f0551b109 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -2157,7 +2157,8 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col const char* msg6 = "function applied to tags not allowed"; const char* msg7 = "normal table can not apply this function"; const char* msg8 = "multi-columns selection does not support alias column name"; - const char* msg9 = "diff can no be applied to unsigned numeric type"; + const char* msg9 = "diff/derivative can no be applied to unsigned numeric type"; + const char* msg10 = "derivative duration should be greater than 1 Second"; switch (functionId) { case TSDB_FUNC_COUNT: { @@ -2340,12 +2341,23 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col tickPerSec /= 1000; } + if (tickPerSec <= 0 || tickPerSec < TSDB_TICK_PER_SECOND(info.precision)) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg10); + } + tscExprAddParams(&pExpr->base, (char*) &tickPerSec, TSDB_DATA_TYPE_BIGINT, LONG_BYTES); memset(val, 0, tListLen(val)); + if (tVariantDump(&pParamElem[2].pNode->value, val, TSDB_DATA_TYPE_BIGINT, true) < 0) { return TSDB_CODE_TSC_INVALID_OPERATION; } + int64_t v = *(int64_t*) val; + if (v != 0 && v != 1) { + const char* msg10 = "third parameter in derivative should be 0 or 1"; + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg10); + } + tscExprAddParams(&pExpr->base, val, TSDB_DATA_TYPE_BIGINT, LONG_BYTES); } @@ -5645,7 +5657,7 @@ int32_t validateSqlFunctionInStreamSql(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) { int32_t validateFunctionsInIntervalOrGroupbyQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) { bool isProjectionFunction = false; - const char* msg1 = "column projection is not compatible with interval"; + const char* msg1 = "functions not compatible with interval"; // multi-output set/ todo refactor size_t size = taosArrayGetSize(pQueryInfo->exprList); @@ -5669,8 +5681,8 @@ int32_t validateFunctionsInIntervalOrGroupbyQuery(SSqlCmd* pCmd, SQueryInfo* pQu } } - if ((pExpr->base.functionId == TSDB_FUNC_PRJ && pExpr->base.numOfParams == 0) || pExpr->base.functionId == TSDB_FUNC_DIFF || - pExpr->base.functionId == TSDB_FUNC_ARITHM) { + int32_t f = pExpr->base.functionId; + if ((f == TSDB_FUNC_PRJ && pExpr->base.numOfParams == 0) || f == TSDB_FUNC_DIFF || f == TSDB_FUNC_ARITHM || f == TSDB_FUNC_DERIVATIVE) { isProjectionFunction = true; } } @@ -7789,7 +7801,7 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf if (validateIntervalNode(pSql, pQueryInfo, pSqlNode) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_OPERATION; } else { - if (isTimeWindowQuery(pQueryInfo)) { + if (isTimeWindowQuery(pQueryInfo) || pQueryInfo->sessionWindow.gap > 0) { // check if the first column of the nest query result is timestamp column SColumn* pCol = taosArrayGetP(pQueryInfo->colList, 0); if (pCol->info.type != TSDB_DATA_TYPE_TIMESTAMP) { @@ -7872,11 +7884,6 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf // set interval value if (validateIntervalNode(pSql, pQueryInfo, pSqlNode) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_OPERATION; - } else { - if (isTimeWindowQuery(pQueryInfo) && - (validateFunctionsInIntervalOrGroupbyQuery(pCmd, pQueryInfo) != TSDB_CODE_SUCCESS)) { - return TSDB_CODE_TSC_INVALID_OPERATION; - } } if (tscQueryTags(pQueryInfo)) { @@ -7907,6 +7914,11 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf return TSDB_CODE_TSC_INVALID_OPERATION; } + if ((isTimeWindowQuery(pQueryInfo) || pQueryInfo->sessionWindow.gap > 0) && + (validateFunctionsInIntervalOrGroupbyQuery(pCmd, pQueryInfo) != TSDB_CODE_SUCCESS)) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + if (isSTable) { tscTansformFuncForSTableQuery(pQueryInfo); if (hasUnsupportFunctionsForSTableQuery(pCmd, pQueryInfo)) { diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index 62be49c3df..96eaeb48cf 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -3428,7 +3428,7 @@ static bool deriv_function_setup(SQLFunctionCtx *pCtx) { SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); SDerivInfo* pDerivInfo = GET_ROWCELL_INTERBUF(pResInfo); - pDerivInfo->ignoreNegative = pCtx->param[2].i64; + pDerivInfo->ignoreNegative = pCtx->param[1].i64; pDerivInfo->prevTs = -1; pDerivInfo->tsWindow = pCtx->param[0].i64; pDerivInfo->valueSet = false; @@ -3440,10 +3440,8 @@ static void deriv_function(SQLFunctionCtx *pCtx) { SDerivInfo* pDerivInfo = GET_ROWCELL_INTERBUF(pResInfo); void *data = GET_INPUT_DATA_LIST(pCtx); - bool isFirstBlock = (pDerivInfo->valueSet == false); int32_t notNullElems = 0; - int32_t step = GET_FORWARD_DIRECTION_FACTOR(pCtx->order); int32_t i = (pCtx->order == TSDB_ORDER_ASC) ? 0 : pCtx->size - 1; @@ -3469,12 +3467,12 @@ static void deriv_function(SQLFunctionCtx *pCtx) { *pTimestamp = tsList[i]; pOutput += 1; pTimestamp += 1; + notNullElems++; } } pDerivInfo->prevValue = pData[i]; pDerivInfo->prevTs = tsList[i]; - notNullElems++; } break; @@ -3496,12 +3494,12 @@ static void deriv_function(SQLFunctionCtx *pCtx) { *pTimestamp = tsList[i]; pOutput += 1; pTimestamp += 1; + notNullElems++; } } pDerivInfo->prevValue = (double) pData[i]; pDerivInfo->prevTs = tsList[i]; - notNullElems++; } break; } @@ -3522,12 +3520,12 @@ static void deriv_function(SQLFunctionCtx *pCtx) { *pTimestamp = tsList[i]; pOutput += 1; pTimestamp += 1; + notNullElems++; } } pDerivInfo->prevValue = pData[i]; pDerivInfo->prevTs = tsList[i]; - notNullElems++; } break; } @@ -3549,12 +3547,12 @@ static void deriv_function(SQLFunctionCtx *pCtx) { *pTimestamp = tsList[i]; pOutput += 1; pTimestamp += 1; + notNullElems++; } } pDerivInfo->prevValue = pData[i]; pDerivInfo->prevTs = tsList[i]; - notNullElems++; } break; } @@ -3575,12 +3573,12 @@ static void deriv_function(SQLFunctionCtx *pCtx) { *pTimestamp = tsList[i]; pOutput += 1; pTimestamp += 1; + notNullElems++; } } pDerivInfo->prevValue = pData[i]; pDerivInfo->prevTs = tsList[i]; - notNullElems++; } break; } @@ -3602,12 +3600,12 @@ static void deriv_function(SQLFunctionCtx *pCtx) { pOutput += 1; pTimestamp += 1; + notNullElems++; } } pDerivInfo->prevValue = pData[i]; pDerivInfo->prevTs = tsList[i]; - notNullElems++; } break; } @@ -3623,8 +3621,7 @@ static void deriv_function(SQLFunctionCtx *pCtx) { */ assert(pCtx->hasNull); } else { - int32_t forwardStep = (isFirstBlock) ? notNullElems - 1 : notNullElems; - GET_RES_INFO(pCtx)->numOfRes += forwardStep; + GET_RES_INFO(pCtx)->numOfRes += notNullElems; } } diff --git a/tests/script/general/parser/function.sim b/tests/script/general/parser/function.sim index 591d5d1535..bec4267b8b 100644 --- a/tests/script/general/parser/function.sim +++ b/tests/script/general/parser/function.sim @@ -932,3 +932,125 @@ if $data32 != 0.000144445 then return -1 endi +print ===========================> derivative +sql drop table t1 +sql drop table tx; +sql drop table m1; +sql drop table if exists tm0; +sql drop table if exists tm1; +sql create table tm0(ts timestamp, k double) +sql insert into tm0 values('2015-08-18T00:00:00Z', 2.064) ('2015-08-18T00:06:00Z', 2.116) ('2015-08-18T00:12:00Z', 2.028) +sql insert into tm0 values('2015-08-18T00:18:00Z', 2.126) ('2015-08-18T00:24:00Z', 2.041) ('2015-08-18T00:30:00Z', 2.051) + +sql_error select derivative(ts) from tm0; +sql_error select derivative(k) from tm0; +sql_error select derivative(k, 0, 0) from tm0; +sql_error select derivative(k, 1, 911) from tm0; +sql_error select derivative(kx, 1s, 1) from tm0; +sql_error select derivative(k, -20s, 1) from tm0; +sql_error select derivative(k, 20a, 0) from tm0; +sql_error select derivative(k, 200a, 0) from tm0; +sql_error select derivative(k, 999a, 0) from tm0; +sql_error select derivative(k, 20s, -12) from tm0; + +sql select derivative(k, 1s, 0) from tm0 +if $rows != 5 then + return -1 +endi + +if $data00 != @15-08-18 08:06:00.000@ then + return -1 +endi + +if $data01 != 0.000144444 then + print expect 0.000144444, actual: $data01 + return -1 +endi + +if $data10 != @15-08-18 08:12:00.000@ then + return -1 +endi + +if $data11 != -0.000244444 then + return -1 +endi + +if $data20 != @15-08-18 08:18:00.000@ then + return -1 +endi + +if $data21 != 0.000272222 then + print expect 0.000272222, actual: $data21 + return -1 +endi + +if $data30 != @15-08-18 08:24:00.000@ then + return -1 +endi + +if $data31 != -0.000236111 then + print expect 0.000236111, actual: $data31 + return -1 +endi + +sql select derivative(k, 6m, 0) from tm0; +if $rows != 5 then + return -1 +endi + +if $data00 != @15-08-18 08:06:00.000@ then + return -1 +endi + +if $data01 != 0.052000000 then + print expect 0.052000000, actual: $data01 + return -1 +endi + +if $data10 != @15-08-18 08:12:00.000@ then + return -1 +endi + +if $data11 != -0.088000000 then + return -1 +endi + +if $data20 != @15-08-18 08:18:00.000@ then + return -1 +endi + +if $data21 != 0.098000000 then + return -1 +endi + +if $data30 != @15-08-18 08:24:00.000@ then + return -1 +endi + +if $data31 != -0.085000000 then + return -1 +endi + +sql select derivative(k, 12m, 0) from tm0; +if $rows != 5 then + return -1 +endi + +if $data00 != @15-08-18 08:06:00.000@ then + return -1 +endi + +if $data01 != 0.104000000 then + print expect 0.104000000, actual: $data01 + return -1 +endi + +sql select derivative(k, 6m, 1) from tm0; +if $rows != 3 then + return -1 +endi + +sql_error select derivative(k, 6m, 1) from tm0 interval(1s); +sql_error select derivative(k, 6m, 1) from tm0 session(ts, 1s); +sql_error select derivative(k, 6m, 1) from tm0 group by k; +sql_error select derivative(k, 6m, 1) from \ No newline at end of file From c99a639c79d1190b519ccae8abeaf13aaea4a582 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 8 Jun 2021 11:06:36 +0800 Subject: [PATCH 39/72] [TD-4605]: early version visual studio compile. (#6406) From fd155d4245691b878ee1c72036066206dc6f3ca2 Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Tue, 8 Jun 2021 11:15:12 +0800 Subject: [PATCH 40/72] update test case --- tests/pytest/query/last_row_cache.py | 22 +++++++++++--- tests/pytest/query/subqueryFilter.py | 44 ++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 4 deletions(-) diff --git a/tests/pytest/query/last_row_cache.py b/tests/pytest/query/last_row_cache.py index 4aae4ce487..8315384149 100644 --- a/tests/pytest/query/last_row_cache.py +++ b/tests/pytest/query/last_row_cache.py @@ -141,7 +141,7 @@ class TDTestCase: def run(self): tdSql.prepare() - print("============== last_row_cache_0.sim") + print("============== Step1: last_row_cache_0.sim") tdSql.execute("create database test1 cachelast 0") tdSql.execute("use test1") self.insertData() @@ -149,43 +149,48 @@ class TDTestCase: self.insertData2() self.executeQueries2() - print("============== alter last cache") + print("============== Step2: alter database test1 cachelast 1") tdSql.execute("alter database test1 cachelast 1") self.executeQueries2() + print("============== Step3: alter database test1 cachelast 2") tdSql.execute("alter database test1 cachelast 2") self.executeQueries2() + print("============== Step4: alter database test1 cachelast 3") tdSql.execute("alter database test1 cachelast 3") self.executeQueries2() - print("============== alter last cache") + print("============== Step5: alter database test1 cachelast 0 and restart taosd") tdSql.execute("alter database test1 cachelast 0") self.executeQueries2() tdDnodes.stop(1) tdDnodes.start(1) self.executeQueries2() + print("============== Step6: alter database test1 cachelast 1 and restart taosd") tdSql.execute("alter database test1 cachelast 1") self.executeQueries2() tdDnodes.stop(1) tdDnodes.start(1) self.executeQueries2() + print("============== Step7: alter database test1 cachelast 2 and restart taosd") tdSql.execute("alter database test1 cachelast 2") self.executeQueries2() tdDnodes.stop(1) tdDnodes.start(1) self.executeQueries2() + print("============== Step8: alter database test1 cachelast 3 and restart taosd") tdSql.execute("alter database test1 cachelast 3") self.executeQueries2() tdDnodes.stop(1) tdDnodes.start(1) self.executeQueries2() - print("============== last_row_cache_1.sim") + print("============== Step9: create database test2 cachelast 1") tdSql.execute("create database test2 cachelast 1") tdSql.execute("use test2") self.insertData() @@ -196,42 +201,51 @@ class TDTestCase: tdDnodes.start(1) self.executeQueries2() + print("============== Step8: alter database test2 cachelast 0") tdSql.execute("alter database test2 cachelast 0") self.executeQueries2() + print("============== Step9: alter database test2 cachelast 1") tdSql.execute("alter database test2 cachelast 1") self.executeQueries2() + print("============== Step10: alter database test2 cachelast 2") tdSql.execute("alter database test2 cachelast 2") self.executeQueries2() + print("============== Step11: alter database test2 cachelast 3") tdSql.execute("alter database test2 cachelast 3") self.executeQueries2() + print("============== Step12: alter database test2 cachelast 0 and restart taosd") tdSql.execute("alter database test2 cachelast 0") self.executeQueries2() tdDnodes.stop(1) tdDnodes.start(1) self.executeQueries2() + print("============== Step13: alter database test2 cachelast 1 and restart taosd") tdSql.execute("alter database test2 cachelast 1") self.executeQueries2() tdDnodes.stop(1) tdDnodes.start(1) self.executeQueries2() + print("============== Step14: alter database test2 cachelast 2 and restart taosd") tdSql.execute("alter database test2 cachelast 2") self.executeQueries2() tdDnodes.stop(1) tdDnodes.start(1) self.executeQueries2() + print("============== Step15: alter database test2 cachelast 3 and restart taosd") tdSql.execute("alter database test2 cachelast 3") self.executeQueries2() tdDnodes.stop(1) tdDnodes.start(1) self.executeQueries2() + print("============== Step16: select last_row(*) from st group by tbname") tdSql.query("select last_row(*) from st group by tbname") tdSql.checkRows(10) diff --git a/tests/pytest/query/subqueryFilter.py b/tests/pytest/query/subqueryFilter.py index 1e111360e2..ca0c748408 100644 --- a/tests/pytest/query/subqueryFilter.py +++ b/tests/pytest/query/subqueryFilter.py @@ -67,6 +67,50 @@ class TDTestCase: tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val > 20") tdSql.checkRows(1) tdSql.checkData(0, 0, 1) + + tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val >= 20") + tdSql.checkRows(2) + + tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val < 20") + tdSql.checkRows(63) + + tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val <= 20") + tdSql.checkRows(64) + + tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val = 20") + tdSql.checkRows(1) + + tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val > 20") + tdSql.checkData(0, 0, 1) + + tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val >= 20") + tdSql.checkData(0, 0, 2) + + tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val < 20") + tdSql.checkData(0, 0, 63) + + tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val <= 20") + tdSql.checkData(0, 0, 64) + + tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val = 20") + tdSql.checkData(0, 0, 1) + + tdSql.query("select count(*) from (select last(tagtype) val from st interval(30s)) a where a.val > 20") + tdSql.checkData(0, 0, 3) + + tdSql.query("select count(*) from (select last(tagtype) val from st interval(30s)) a where a.val >= 20") + tdSql.checkData(0, 0, 5) + + tdSql.query("select count(*) from (select last(tagtype) val from st interval(30s)) a where a.val < 20") + tdSql.checkData(0, 0, 60) + + tdSql.query("select count(*) from (select last(tagtype) val from st interval(30s)) a where a.val <= 20") + tdSql.checkData(0, 0, 62) + + tdSql.query("select count(*) from (select last(tagtype) val from st interval(30s)) a where a.val = 20") + tdSql.checkData(0, 0, 2) + + From b3c74da37aa2715ab962d6f1326dbf58f380cd5b Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Tue, 8 Jun 2021 11:16:27 +0800 Subject: [PATCH 41/72] add test case --- src/mnode/src/mnodeDb.c | 18 +- tests/script/general/parser/alter.sim | 60 +++- .../parser/alter__for_community_version.sim | 316 ++++++++++++++++++ tests/script/general/parser/create_db.sim | 49 ++- .../create_db__for_community_version.sim | 238 +++++++++++++ .../general/parser/dbtbnameValidate.sim | 2 +- tests/script/general/parser/first_last.sim | 4 +- tests/script/general/parser/function.sim | 2 +- tests/script/general/parser/groupby.sim | 2 +- tests/script/general/parser/join.sim | 2 +- .../script/general/parser/join_manyblocks.sim | 2 +- .../script/general/parser/join_multivnode.sim | 4 +- .../parser/projection_limit_offset.sim | 2 +- .../general/parser/select_with_tags.sim | 4 +- tests/script/general/parser/sliding.sim | 2 +- tests/script/general/parser/subInfrom.sim | 2 +- tests/script/general/parser/topbot.sim | 8 +- tests/script/jenkins/basic.txt | 4 + 18 files changed, 697 insertions(+), 24 deletions(-) create mode 100644 tests/script/general/parser/alter__for_community_version.sim create mode 100644 tests/script/general/parser/create_db__for_community_version.sim diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c index 3fa33dc4b7..9faf08c2ec 100644 --- a/src/mnode/src/mnodeDb.c +++ b/src/mnode/src/mnodeDb.c @@ -612,7 +612,12 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn pShow->bytes[cols] = 24 + VARSTR_HEADER_SIZE; pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "keep0,keep1,keep(D)"); + +#ifdef _STORAGE + strcpy(pSchema[cols].name, "keep0,keep1,keep2"); +#else + strcpy(pSchema[cols].name, "keep"); +#endif pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; @@ -778,11 +783,15 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; char tmp[128] = {0}; +#ifdef _STORAGE if (pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep1 || pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep2) { sprintf(tmp, "%d,%d,%d", pDb->cfg.daysToKeep1, pDb->cfg.daysToKeep2, pDb->cfg.daysToKeep0); } else { sprintf(tmp, "%d,%d,%d", pDb->cfg.daysToKeep0, pDb->cfg.daysToKeep1, pDb->cfg.daysToKeep2); } +#else + sprintf(tmp, "%d", pDb->cfg.daysToKeep0); +#endif STR_WITH_SIZE_TO_VARSTR(pWrite, tmp, strlen(tmp)); cols++; @@ -941,6 +950,7 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) { terrno = TSDB_CODE_SUCCESS; + //UPGRATE FROM LOW VERSION, reorder it if (pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep1 || pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep2) { int32_t t = pDb->cfg.daysToKeep0; newCfg.daysToKeep0 = pDb->cfg.daysToKeep1; @@ -972,17 +982,17 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) { terrno = TSDB_CODE_MND_INVALID_DB_OPTION; } - if (daysToKeep0 > 0 && daysToKeep0 != pDb->cfg.daysToKeep0) { + if (daysToKeep0 > 0 && (daysToKeep0 != pDb->cfg.daysToKeep0 || newCfg.daysToKeep0 != pDb->cfg.daysToKeep0)) { mDebug("db:%s, daysToKeep:%d change to %d", pDb->name, pDb->cfg.daysToKeep0, daysToKeep0); newCfg.daysToKeep0 = daysToKeep0; } - if (daysToKeep1 > 0 && daysToKeep1 != pDb->cfg.daysToKeep1) { + if (daysToKeep1 > 0 && (daysToKeep1 != pDb->cfg.daysToKeep1 || newCfg.daysToKeep1 != pDb->cfg.daysToKeep1)) { mDebug("db:%s, daysToKeep1:%d change to %d", pDb->name, pDb->cfg.daysToKeep1, daysToKeep1); newCfg.daysToKeep1 = daysToKeep1; } - if (daysToKeep2 > 0 && daysToKeep2 != pDb->cfg.daysToKeep2) { + if (daysToKeep2 > 0 && (daysToKeep2 != pDb->cfg.daysToKeep2 || newCfg.daysToKeep2 != pDb->cfg.daysToKeep2)) { mDebug("db:%s, daysToKeep2:%d change to %d", pDb->name, pDb->cfg.daysToKeep2, daysToKeep2); newCfg.daysToKeep2 = daysToKeep2; } diff --git a/tests/script/general/parser/alter.sim b/tests/script/general/parser/alter.sim index 6c88497396..5c22f67a0b 100644 --- a/tests/script/general/parser/alter.sim +++ b/tests/script/general/parser/alter.sim @@ -20,8 +20,66 @@ $db = $dbPrefix . $i $mt = $mtPrefix . $i sql drop database if exists $db -sql create database $db +sql create database $db days 10 keep 20,20,20 sql use $db + +sql_error alter database $db keep "20" +sql_error alter database $db keep "20","20","20" +sql_error alter database $db keep 20 +sql_error alter database $db keep 20.0 +sql_error alter database $db keep 20.0,20.0,20.0 +sql_error alter database $db keep 0,0,0 +sql_error alter database $db keep -1,-1,-1 +sql_error alter database $db keep 20,20 +sql_error alter database $db keep 9,9,9 +sql_error alter database $db keep 20,20,19 +sql_error alter database $db keep 20,19,20 +sql_error alter database $db keep 20,19,19 +sql_error alter database $db keep 20,19,18 +sql_error alter database $db keep 20,20,20,20 +sql_error alter database $db keep 365001,365001,365001 +sql alter database $db keep 20,20,20 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 20,20,20 then + return -1 +endi +sql alter database $db keep 10,10,10 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 10,10,10 then + return -1 +endi +sql alter database $db keep 10,10,11 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 10,10,11 then + return -1 +endi +sql alter database $db keep 11,12,13 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 11,12,13 then + return -1 +endi +sql alter database $db keep 365000,365000,365000 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 365000,365000,365000 then + return -1 +endi + + ##### alter table test, simeplest case sql create table tb (ts timestamp, c1 int, c2 int, c3 int) sql insert into tb values (now, 1, 1, 1) diff --git a/tests/script/general/parser/alter__for_community_version.sim b/tests/script/general/parser/alter__for_community_version.sim new file mode 100644 index 0000000000..f55fb812a7 --- /dev/null +++ b/tests/script/general/parser/alter__for_community_version.sim @@ -0,0 +1,316 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = m_alt_db +$tbPrefix = m_alt_tb +$mtPrefix = m_alt_mt +$tbNum = 10 +$rowNum = 5 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== alter.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database if exists $db +sql create database $db days 10 keep 20 +sql use $db +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 20 then + return -1 +endi + +sql_error alter database $db keep "20" +sql_error alter database $db keep "20","20","20" +sql_error alter database $db keep 0 +sql_error alter database $db keep 20.0 +sql_error alter database $db keep 20.0,20.0,20.0 +sql_error alter database $db keep 0,0,0 +sql_error alter database $db keep 3 +sql_error alter database $db keep -1,-1,-1 +sql_error alter database $db keep 20,20 +sql_error alter database $db keep 9,9,9 +sql_error alter database $db keep 20,20,19 +sql_error alter database $db keep 20,19,20 +sql_error alter database $db keep 20,19,19 +sql_error alter database $db keep 20,19,18 +sql_error alter database $db keep 20,20,20,20 +sql_error alter database $db keep 365001,365001,365001 +sql_error alter database $db keep 365001 +sql alter database $db keep 20 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 20 then + return -1 +endi +sql alter database $db keep 10 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 10 then + return -1 +endi +sql alter database $db keep 11 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 11 then + return -1 +endi +sql alter database $db keep 13 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 13 then + return -1 +endi +sql alter database $db keep 365000 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 365000 then + return -1 +endi + + +##### alter table test, simeplest case +sql create table tb (ts timestamp, c1 int, c2 int, c3 int) +sql insert into tb values (now, 1, 1, 1) +sql select * from tb order by ts desc +if $rows != 1 then + return -1 +endi +sql alter table tb drop column c3 +sql select * from tb order by ts desc +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi +sql alter table tb add column c3 nchar(4) +sql select * from tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data03 != NULL then + return -1 +endi +sql insert into tb values (now, 2, 2, 'taos') +sql select * from tb order by ts desc +if $rows != 2 then + return -1 +endi +print data03 = $data03 +if $data03 != taos then + print expect taos, actual: $data03 + return -1 +endi +sql drop table tb + +##### alter metric test, simplest case +sql create table mt (ts timestamp, c1 int, c2 int, c3 int) tags (t1 int) +sql create table tb using mt tags(1) +sql insert into tb values (now, 1, 1, 1) +sql alter table mt drop column c3 +sql select * from tb order by ts desc +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi + +sql alter table mt add column c3 nchar(4) +sql select * from tb order by ts desc +if $data03 != NULL then + return -1 +endi +sql insert into tb values (now, 2, 2, 'taos') +sql select * from tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data03 != taos then + return -1 +endi +if $data13 != NULL then + return -1 +endi +sql drop table tb +sql drop table mt + +## [TBASE272] +sql create table tb (ts timestamp, c1 int, c2 int, c3 int) +sql insert into tb values (now, 1, 1, 1) +sql alter table tb drop column c3 +sql alter table tb add column c3 nchar(5) +sql insert into tb values(now, 2, 2, 'taos') +sql drop table tb +sql create table mt (ts timestamp, c1 int, c2 int, c3 int) tags (t1 int) +sql create table tb using mt tags(1) +sql insert into tb values (now, 1, 1, 1) +sql alter table mt drop column c3 +sql select * from tb order by ts desc +if $rows != 1 then + return -1 +endi +sql drop table tb +sql drop table mt + +sleep 100 +### ALTER TABLE WHILE STREAMING [TBASE271] +#sql create table tb1 (ts timestamp, c1 int, c2 nchar(5), c3 int) +#sql create table strm as select count(*), avg(c1), first(c2), sum(c3) from tb1 interval(2s) +#sql select * from strm +#if $rows != 0 then +# return -1 +#endi +##sleep 12000 +#sql insert into tb1 values (now, 1, 'taos', 1) +#sleep 20000 +#sql select * from strm +#print rows = $rows +#if $rows != 1 then +# return -1 +#endi +#if $data04 != 1 then +# return -1 +#endi +#sql alter table tb1 drop column c3 +#sleep 500 +#sql insert into tb1 values (now, 2, 'taos') +#sleep 30000 +#sql select * from strm +#if $rows != 2 then +# return -1 +#endi +#if $data04 != 1 then +# return -1 +#endi +#sql alter table tb1 add column c3 int +#sleep 500 +#sql insert into tb1 values (now, 3, 'taos', 3); +#sleep 100 +#sql select * from strm +#if $rows != 3 then +# return -1 +#endi +#if $data04 != 1 then +# return -1 +#endi + +## ALTER TABLE AND INSERT BY COLUMNS +sql create table mt (ts timestamp, c1 int, c2 int) tags(t1 int) +sql create table tb using mt tags(0) +sql insert into tb values (now-1m, 1, 1) +sql alter table mt drop column c2 +sql_error insert into tb (ts, c1, c2) values (now, 2, 2) +sql insert into tb (ts, c1) values (now, 2) +sql select * from tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != null then + return -1 +endi +sql alter table mt add column c2 int +sql insert into tb (ts, c2) values (now, 3) +sql select * from tb order by ts desc +if $data02 != 3 then + return -1 +endi + +## ALTER TABLE AND IMPORT +sql drop database $db +sql create database $db +sql use $db +sql create table mt (ts timestamp, c1 int, c2 nchar(7), c3 int) tags (t1 int) +sql create table tb using mt tags(1) +sleep 100 +sql insert into tb values ('2018-11-01 16:30:00.000', 1, 'insert', 1) +sql alter table mt drop column c3 + +sql insert into tb values ('2018-11-01 16:29:59.000', 1, 'insert') +sql import into tb values ('2018-11-01 16:29:59.000', 1, 'import') +sql select * from tb order by ts desc +if $data01 != 1 then + return -1 +endi +if $data02 != insert then + return -1 +endi +sql alter table mt add column c3 nchar(4) +sql select * from tb order by ts desc +if $data03 != NULL then + return -1 +endi + +print ============================>TD-3366 TD-3486 +sql insert into td_3366(ts, c3, c1) using mt(t1) tags(911) values('2018-1-1 11:11:11', 'new1', 12); +sql insert into td_3486(ts, c3, c1) using mt(t1) tags(-12) values('2018-1-1 11:11:11', 'new1', 12); +sql insert into ttxu(ts, c3, c1) using mt(t1) tags('-121') values('2018-1-1 11:11:11', 'new1', 12); + +sql insert into tb(ts, c1, c3) using mt(t1) tags(123) values('2018-11-01 16:29:58.000', 2, 'port') + +sql insert into tb values ('2018-11-01 16:29:58.000', 2, 'import', 3) +sql import into tb values ('2018-11-01 16:29:58.000', 2, 'import', 3) +sql import into tb values ('2018-11-01 16:39:58.000', 2, 'import', 3) +sql select * from tb order by ts desc +if $rows != 4 then + return -1 +endi + +if $data03 != 3 then + return -1 +endi + +##### ILLEGAL OPERATIONS + +# try dropping columns that are defined in metric +sql_error alter table tb drop column c1; + +# try dropping primary key +sql_error alter table mt drop column ts; + +# try modifying two columns in a single statement +sql_error alter table mt add column c5 nchar(3) c6 nchar(4) + +# duplicate columns +sql_error alter table mt add column c1 int + +# drop non-existing columns +sql_error alter table mt drop column c9 + +#sql drop database $db +#sql show databases +#if $rows != 0 then +# return -1 +#endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/create_db.sim b/tests/script/general/parser/create_db.sim index 9ca84af136..d3b74b697f 100644 --- a/tests/script/general/parser/create_db.sim +++ b/tests/script/general/parser/create_db.sim @@ -102,7 +102,7 @@ print create_db.sim case5: db_meta_data test # cfg params $replica = 1 # max=3 $days = 10 -$keep = 365 +$keep = 365,365,365 $rows_db = 1000 $cache = 16 # 16MB $ablocks = 100 @@ -150,6 +150,53 @@ sql_error create database $db day 3651 # keep [1, infinity] sql_error create database $db keep 0 +sql_error create database $db keep 0,0,0 +sql_error create database $db keep 3,3,3 +sql_error create database $db keep 11.0 +sql_error create database $db keep 11.0,11.0,11.0 +sql_error create database $db keep "11","11","11" +sql_error create database $db keep "11" +sql_error create database $db keep 13,12,11 +sql_error create database $db keep 11,12,11 +sql_error create database $db keep 12,11,12 +sql_error create database $db keep 11,11 +sql_error create database $db keep 365001,365001,365001 +sql create database dbk1 keep 11,11,11 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 11,11,11 then + return -1 +endi +sql drop database dbk1 +sql create database dbk2 keep 11,12,13 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 11,12,13 then + return -1 +endi +sql drop database dbk2 +sql create database dbk3 keep 11,11,13 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 11,11,13 then + return -1 +endi +sql drop database dbk3 +sql create database dbk4 keep 11,13,13 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 11,13,13 then + return -1 +endi +sql drop database dbk4 #sql_error create database $db keep 3651 # rows [200, 10000] diff --git a/tests/script/general/parser/create_db__for_community_version.sim b/tests/script/general/parser/create_db__for_community_version.sim new file mode 100644 index 0000000000..406e69b0e6 --- /dev/null +++ b/tests/script/general/parser/create_db__for_community_version.sim @@ -0,0 +1,238 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_in_db +$tbPrefix = fi_in_tb +$mtPrefix = fi_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print excuting test script create_db.sim +print =============== set up +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql_error createdatabase $db +sql create database $db +sql use $db +sql show databases + +if $rows != 1 then + return -1 +endi +if $data00 != $db then + return -1 +endi +sql drop database $db + +# case1: case_insensitivity test +print =========== create_db.sim case1: case insensitivity test +sql_error CREATEDATABASE $db +sql CREATE DATABASE $db +sql use $db +sql show databases + +if $rows != 1 then + return -1 +endi +if $data00 != $db then + return -1 +endi +sql drop database $db +print case_insensitivity test passed + +# case2: illegal_db_name test +print =========== create_db.sim case2: illegal_db_name test +$illegal_db1 = 1db +$illegal_db2 = d@b + +sql_error create database $illegal_db1 +sql_error create database $illegal_db2 +print illegal_db_name test passed + +# case3: chinese_char_in_db_name test +print ========== create_db.sim case3: chinese_char_in_db_name test +$CN_db1 = 数据库 +$CN_db2 = 数据库1 +$CN_db3 = db数据库1 +sql_error create database $CN_db1 +sql_error create database $CN_db2 +sql_error create database $CN_db3 +#sql show databases +#if $rows != 3 then +# return -1 +#endi +#if $data00 != $CN_db1 then +# return -1 +#endi +#if $data10 != $CN_db2 then +# return -1 +#endi +#if $data20 != $CN_db3 then +# return -1 +#endi +#sql drop database $CN_db1 +#sql drop database $CN_db2 +#sql drop database $CN_db3 +print case_chinese_char_in_db_name test passed + +# case4: db_already_exists +print create_db.sim case4: db_already_exists +sql create database db0 +sql create database db0 +sql show databases +if $rows != 1 then + return -1 +endi +sql drop database db0 +print db_already_exists test passed + +# case5: db_meta_data +print create_db.sim case5: db_meta_data test +# cfg params +$replica = 1 # max=3 +$days = 10 +$keep = 365 +$rows_db = 1000 +$cache = 16 # 16MB +$ablocks = 100 +$tblocks = 32 # max=512, automatically trimmed when exceeding +$ctime = 36000 # 10 hours +$wal = 1 # valid value is 1, 2 +$comp = 1 # max=32, automatically trimmed when exceeding + +sql create database $db replica $replica days $days keep $keep maxrows $rows_db cache $cache blocks 4 ctime $ctime wal $wal comp $comp +sql show databases +if $rows != 1 then + return -1 +endi +if $data00 != $db then + return -1 +endi +if $data04 != $replica then + return -1 +endi +if $data06 != $days then + return -1 +endi +if $data07 != 365 then + return -1 +endi +print data08 = $data07 +if $data08 != $cache then + print expect $cache, actual:$data08 + return -1 +endi +if $data09 != 4 then + return -1 +endi + +sql drop database $db + +## param range tests +# replica [1,3] +#sql_error create database $db replica 0 +sql_error create database $db replica 4 + +# day [1, 3650] +sql_error create database $db day 0 +sql_error create database $db day 3651 + +# keep [1, infinity] +sql_error create database $db keep 0 +sql_error create database $db keep 0,0,0 +sql_error create database $db keep 3,3,3 +sql_error create database $db keep 3 +sql_error create database $db keep 11.0 +sql_error create database $db keep 11.0,11.0,11.0 +sql_error create database $db keep "11","11","11" +sql_error create database $db keep "11" +sql_error create database $db keep 13,12,11 +sql_error create database $db keep 11,12,11 +sql_error create database $db keep 12,11,12 +sql_error create database $db keep 11,12,13 +sql_error create database $db keep 11,12,13,14 +sql_error create database $db keep 11,11 +sql_error create database $db keep 365001,365001,365001 +sql_error create database $db keep 365001 +sql create database dbk1 keep 11 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 11 then + return -1 +endi +sql drop database dbk1 +sql create database dbk2 keep 12 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 12 then + return -1 +endi +sql drop database dbk2 +sql create database dbk3 keep 11 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 11 then + return -1 +endi +sql drop database dbk3 +sql create database dbk4 keep 13 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 13 then + return -1 +endi +sql drop database dbk4 +#sql_error create database $db keep 3651 + +# rows [200, 10000] +sql_error create database $db maxrows 199 +#sql_error create database $db maxrows 10001 + +# cache [100, 10485760] +sql_error create database $db cache 0 +#sql_error create database $db cache 10485761 + + +# blocks [32, 4096 overwriten by 4096 if exceeds, Note added:2018-10-24] +#sql_error create database $db tblocks 31 +#sql_error create database $db tblocks 4097 + +# ctime [30, 40960] +sql_error create database $db ctime 29 +sql_error create database $db ctime 40961 + +# wal {0, 2} +#sql_error create database $db wal 0 +sql_error create database $db wal -1 +sql_error create database $db wal 3 + +# comp {0, 1, 2} +sql_error create database $db comp -1 +sql_error create database $db comp 3 + +sql_error drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/dbtbnameValidate.sim b/tests/script/general/parser/dbtbnameValidate.sim index bc3bfefafb..caa5f3aa6d 100644 --- a/tests/script/general/parser/dbtbnameValidate.sim +++ b/tests/script/general/parser/dbtbnameValidate.sim @@ -7,7 +7,7 @@ sleep 100 sql connect print ========== db name and table name check in create and drop, describe -sql create database abc keep 36500 +sql create database abc keep 36500,36500,36500 sql create database 'abc123' sql create database '_ab1234' sql create database 'ABC123' diff --git a/tests/script/general/parser/first_last.sim b/tests/script/general/parser/first_last.sim index f47f67ddc6..70c3e8a5f6 100644 --- a/tests/script/general/parser/first_last.sim +++ b/tests/script/general/parser/first_last.sim @@ -86,7 +86,7 @@ sleep 100 run general/parser/first_last_query.sim print =================> insert data regression test -sql create database test keep 36500 +sql create database test keep 36500,36500,36500 sql use test sql create table tm0 (ts timestamp, k int) @@ -124,4 +124,4 @@ if $rows != 10000 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/function.sim b/tests/script/general/parser/function.sim index 591d5d1535..11eb3fb2bd 100644 --- a/tests/script/general/parser/function.sim +++ b/tests/script/general/parser/function.sim @@ -21,7 +21,7 @@ $db = $dbPrefix . $i $mt = $mtPrefix . $i sql drop database if exists $db -sql create database $db keep 36500 +sql create database $db keep 36500,36500,36500 sql use $db print =====================================> td-4481 diff --git a/tests/script/general/parser/groupby.sim b/tests/script/general/parser/groupby.sim index 124e76e85c..8ded859669 100644 --- a/tests/script/general/parser/groupby.sim +++ b/tests/script/general/parser/groupby.sim @@ -29,7 +29,7 @@ $tstart = 100000 sql drop database if exists $db -x step1 step1: -sql create database if not exists $db keep 36500 +sql create database if not exists $db keep 36500,36500,36500 sql use $db sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) diff --git a/tests/script/general/parser/join.sim b/tests/script/general/parser/join.sim index 2c14a86c3a..6142277e50 100644 --- a/tests/script/general/parser/join.sim +++ b/tests/script/general/parser/join.sim @@ -26,7 +26,7 @@ $tstart = 100000 sql drop database if exists $db -x step1 step1: -sql create database if not exists $db keep 36500 +sql create database if not exists $db keep 36500,36500,36500 sql use $db sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) diff --git a/tests/script/general/parser/join_manyblocks.sim b/tests/script/general/parser/join_manyblocks.sim index fddd59c0a1..43936ee645 100644 --- a/tests/script/general/parser/join_manyblocks.sim +++ b/tests/script/general/parser/join_manyblocks.sim @@ -24,7 +24,7 @@ $tstart = 100000 sql drop database if exists $db -x step1 step1: -sql create database if not exists $db keep 36500 +sql create database if not exists $db keep 36500,36500,36500 sql use $db sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) diff --git a/tests/script/general/parser/join_multivnode.sim b/tests/script/general/parser/join_multivnode.sim index c72b2c5b3e..4bafc0d0e9 100644 --- a/tests/script/general/parser/join_multivnode.sim +++ b/tests/script/general/parser/join_multivnode.sim @@ -24,7 +24,7 @@ $tstart = 100000 sql drop database if exists $db -x step1 step1: -sql create database if not exists $db keep 36500 +sql create database if not exists $db keep 36500,36500,36500 sql use $db sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) @@ -367,4 +367,4 @@ if $data35 != 5 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/projection_limit_offset.sim b/tests/script/general/parser/projection_limit_offset.sim index ffbcb28ffd..2a93a179a2 100644 --- a/tests/script/general/parser/projection_limit_offset.sim +++ b/tests/script/general/parser/projection_limit_offset.sim @@ -23,7 +23,7 @@ $tstart = 100000 sql drop database if exists $db -x step1 step1: -sql create database if not exists $db keep 36500 +sql create database if not exists $db keep 36500,36500,36500 sql use $db sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) diff --git a/tests/script/general/parser/select_with_tags.sim b/tests/script/general/parser/select_with_tags.sim index 9d5214bfaa..45507bf1e7 100644 --- a/tests/script/general/parser/select_with_tags.sim +++ b/tests/script/general/parser/select_with_tags.sim @@ -24,7 +24,7 @@ $tstart = 100000 sql drop database if exists $db -x step1 step1: -sql create database if not exists $db keep 36500 +sql create database if not exists $db keep 36500,36500,36500 sql use $db sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12), t3 int) @@ -902,4 +902,4 @@ sql_error select first(c1), count(*), t2, t1, tbname from select_tags_mt0 group #sql select count(c1) from select_tags_mt0 where c1=99 group by tbname; #sql select count(*),tbname from select_tags_mt0 group by tbname -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/sliding.sim b/tests/script/general/parser/sliding.sim index b2695ff95f..cbdcb2162a 100644 --- a/tests/script/general/parser/sliding.sim +++ b/tests/script/general/parser/sliding.sim @@ -29,7 +29,7 @@ $mt = $mtPrefix . $i sql drop database if exists $db -x step1 step1: -sql create database if not exists $db keep 36500 +sql create database if not exists $db keep 36500,36500,36500 sql use $db sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) diff --git a/tests/script/general/parser/subInfrom.sim b/tests/script/general/parser/subInfrom.sim index e47831ee87..09ba4381ba 100644 --- a/tests/script/general/parser/subInfrom.sim +++ b/tests/script/general/parser/subInfrom.sim @@ -26,7 +26,7 @@ $stb = $stbPrefix . $i sql drop database $db -x step1 step1: -sql create database $db cache 16 maxrows 4096 keep 36500 +sql create database $db cache 16 maxrows 4096 keep 36500,36500,36500 print ====== create tables sql use $db sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) diff --git a/tests/script/general/parser/topbot.sim b/tests/script/general/parser/topbot.sim index 5c61acb2ba..8a10fa2b41 100644 --- a/tests/script/general/parser/topbot.sim +++ b/tests/script/general/parser/topbot.sim @@ -25,7 +25,7 @@ $stb = $stbPrefix . $i sql drop database $db -x step1 step1: -sql create database $db cache 16 maxrows 4096 keep 36500 +sql create database $db cache 16 maxrows 4096 keep 36500,36500,36500 print ====== create tables sql use $db sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) @@ -175,7 +175,7 @@ if $data21 != 2.10000 then endi print =====================td-1302 case -sql create database t1 keep 36500; +sql create database t1 keep 36500,36500,36500; sql use t1; sql create table test(ts timestamp, k int); sql insert into test values(29999, 1)(70000, 2)(80000, 3) @@ -194,7 +194,7 @@ if $rows != 3 then endi print ==============>td-1308 -sql create database db keep 36500; +sql create database db keep 36500,36500,36500; sql use db; sql create table stb (ts timestamp, c1 int, c2 binary(10)) tags(t1 binary(10)); @@ -377,4 +377,4 @@ sql_error select * from ttm2 where k<>null sql_error select * from ttm2 where k like null sql_error select * from ttm2 where k Date: Tue, 8 Jun 2021 11:16:28 +0800 Subject: [PATCH 42/72] [TD-4473] modifying two cases to auto test with minor modification --- .../change_time_1_1.py} | 60 +++----------- .../change_time_1_2.py} | 58 ++----------- tests/pytest/fulltest.sh | 2 + tests/pytest/util/pathFinding.py | 83 +++++++++++++++++++ 4 files changed, 104 insertions(+), 99 deletions(-) rename tests/pytest/{manualTest/manual_change_time_1_1.py => client/change_time_1_1.py} (53%) rename tests/pytest/{manualTest/manual_change_time_1_2.py => client/change_time_1_2.py} (58%) create mode 100644 tests/pytest/util/pathFinding.py diff --git a/tests/pytest/manualTest/manual_change_time_1_1.py b/tests/pytest/client/change_time_1_1.py similarity index 53% rename from tests/pytest/manualTest/manual_change_time_1_1.py rename to tests/pytest/client/change_time_1_1.py index 8b444eeb6a..24e0195a9c 100644 --- a/tests/pytest/manualTest/manual_change_time_1_1.py +++ b/tests/pytest/client/change_time_1_1.py @@ -15,6 +15,7 @@ import sys from util.log import * from util.cases import * from util.sql import * +from util.pathFinding import * from util.dnodes import tdDnodes from datetime import datetime import subprocess @@ -24,54 +25,12 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - - def getTDenginePath(self): - selfPath = os.path.dirname(os.path.realpath(__file__)) - - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] - else: - projPath = selfPath[:selfPath.find("tests")] - print(projPath) - for root, dirs, files in os.walk(projPath): - if ("sim" in dirs): - print(root) - rootRealPath = os.path.realpath(root) - # if ("packaging" not in rootRealPath): - # buildPath = root[:len(root)-len("/build/bin")] - # break - return rootRealPath - - def getBuildPath(self): - selfPath = os.path.dirname(os.path.realpath(__file__)) - - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] - else: - projPath = selfPath[:selfPath.find("tests")] - - for root, dirs, files in os.walk(projPath): - if ("taosd" in files): - rootRealPath = os.path.dirname(os.path.realpath(root)) - if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] - break - return buildPath + tdFindPath.init(__file__) def run(self): tdSql.prepare() - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") - else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" - TDenginePath = self.getTDenginePath() - print('TD '+ TDenginePath) - if (TDenginePath == ""): - tdLog.exit("TDengine not found!") - else: - tdLog.info("TDengine found in %s" % TDenginePath) + binPath = tdFindPath.getTaosdemoPath() + TDenginePath = tdFindPath.getTDenginePath() ## change system time to 2020/10/20 os.system('sudo timedatectl set-ntp off') @@ -80,32 +39,33 @@ class TDTestCase: #run taosdemo to insert data. one row per second from 2020/10/11 to 2020/10/20 #11 data files should be generated #vnode at TDinternal/community/sim/dnode1/data/vnode - os.system("%staosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_A.json" % binPath) + os.system(f"{binPath}taosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_A.json") commandArray = ['ls', '-l', f'{TDenginePath}/sim/dnode1/data/vnode/vnode2/tsdb/data'] result = subprocess.run(commandArray, stdout=subprocess.PIPE).stdout.decode('utf-8') print(result.count('data')) if result.count('data') != 11: tdLog.exit('wrong number of files') else: - tdLog.info("data file number correct") + tdLog.debug("data file number correct") #move 5 days ahead to 2020/10/25. 4 oldest files should be removed during the new write #leaving 7 data files. os.system ('timedatectl set-time 2020-10-25') - os.system("%staosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_B.json" % binPath) + os.system(f"{binPath}taosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_B.json") commandArray = ['ls', '-l', f'{TDenginePath}/sim/dnode1/data/vnode/vnode2/tsdb/data'] result = subprocess.run(commandArray, stdout=subprocess.PIPE).stdout.decode('utf-8') print(result.count('data')) if result.count('data') != 7: tdLog.exit('wrong number of files') else: - tdLog.info("data file number correct") + tdLog.debug("data file number correct") tdSql.query('select first(ts) from stb_0') tdSql.checkData(0,0,datetime(2020,10,14,8,0,0,0)) #check the last data in the database def stop(self): + os.system('sudo timedatectl set-ntp on') tdSql.close() - tdLog.debug("%s alter block manual check finish" % __file__) + tdLog.success("alter block manual check finish") tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/pytest/manualTest/manual_change_time_1_2.py b/tests/pytest/client/change_time_1_2.py similarity index 58% rename from tests/pytest/manualTest/manual_change_time_1_2.py rename to tests/pytest/client/change_time_1_2.py index 076099edae..cd1a17926d 100644 --- a/tests/pytest/manualTest/manual_change_time_1_2.py +++ b/tests/pytest/client/change_time_1_2.py @@ -16,6 +16,7 @@ from util.log import * from util.cases import * from util.sql import * from util.dnodes import tdDnodes +from util.pathFinding import * from datetime import datetime import subprocess @@ -24,54 +25,12 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - - def getBuildPath(self): - selfPath = os.path.dirname(os.path.realpath(__file__)) - - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] - else: - projPath = selfPath[:selfPath.find("tests")] - - for root, dirs, files in os.walk(projPath): - if ("taosd" in files): - rootRealPath = os.path.dirname(os.path.realpath(root)) - if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] - break - return buildPath - - def getTDenginePath(self): - selfPath = os.path.dirname(os.path.realpath(__file__)) - - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] - else: - projPath = selfPath[:selfPath.find("tests")] - print(projPath) - for root, dirs, files in os.walk(projPath): - if ("sim" in dirs): - print(root) - rootRealPath = os.path.realpath(root) - # if ("packaging" not in rootRealPath): - # buildPath = root[:len(root)-len("/build/bin")] - # break - return rootRealPath + tdFindPath.init(__file__) def run(self): tdSql.prepare() - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") - else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" - TDenginePath = self.getTDenginePath() - print('TD '+ TDenginePath) - if (TDenginePath == ""): - tdLog.exit("TDengine not found!") - else: - tdLog.info("TDengine found in %s" % TDenginePath) + binPath = tdFindPath.getTaosdemoPath() + TDenginePath = tdFindPath.getTDenginePath() ## change system time to 2020/10/20 os.system ('timedatectl set-ntp off') @@ -80,14 +39,14 @@ class TDTestCase: #run taosdemo to insert data. one row per second from 2020/10/11 to 2020/10/20 #11 data files should be generated #vnode at TDinternal/community/sim/dnode1/data/vnode - os.system("%staosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_A.json" % binPath) + os.system(f"{binPath}taosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_A.json") commandArray = ['ls', '-l', f'{TDenginePath}/sim/dnode1/data/vnode/vnode2/tsdb/data'] result = subprocess.run(commandArray, stdout=subprocess.PIPE).stdout.decode('utf-8') print(result.count('data')) if result.count('data') != 11: tdLog.exit('wrong number of files') else: - tdLog.info("data file number correct") + tdLog.debug("data file number correct") tdSql.query('select first(ts) from stb_0') #check the last data in the database tdSql.checkData(0,0,datetime(2020,10,11,0,0,0,0)) @@ -109,13 +68,14 @@ class TDTestCase: if result.count('data') != 7: tdLog.exit('wrong number of files') else: - tdLog.info("data file number correct") + tdLog.debug("data file number correct") def stop(self): + os.system('sudo timedatectl set-ntp on') tdSql.close() - tdLog.debug("%s alter block manual check finish" % __file__) + tdLog.success("alter block manual check finish") tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index 8fed9aa81c..6a09a41b93 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -256,6 +256,8 @@ python3 ./test.py -f client/client.py python3 ./test.py -f client/version.py python3 ./test.py -f client/alterDatabase.py python3 ./test.py -f client/noConnectionErrorTest.py +python3 test.py -f client/change_time_1_1.py +python3 test.py -f client/change_time_1_2.py # Misc python3 testCompress.py diff --git a/tests/pytest/util/pathFinding.py b/tests/pytest/util/pathFinding.py new file mode 100644 index 0000000000..9dee5142ce --- /dev/null +++ b/tests/pytest/util/pathFinding.py @@ -0,0 +1,83 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + + +import os +from util.log import * + + + +class TDFindPath: + """This class is for finding path within TDengine + """ + def __init__(self): + self.file = "" + + + def init(self, file): + """[summary] + + Args: + file (str): the file location you want to start the query. Generally using __file__ + """ + self.file = file + + def getTaosdemoPath(self): + """for finding the path of directory containing taosdemo + + Returns: + str: the path to directory containing taosdemo + """ + selfPath = os.path.dirname(os.path.realpath(self.file)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info(f"taosd found in {buildPath}") + return buildPath + "/build/bin/" + + def getTDenginePath(self): + """for finding the root path of TDengine + + Returns: + str: the root path of TDengine + """ + selfPath = os.path.dirname(os.path.realpath(self.file)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + print(projPath) + for root, dirs, files in os.walk(projPath): + if ("sim" in dirs): + print(root) + rootRealPath = os.path.realpath(root) + if (rootRealPath == ""): + tdLog.exit("TDengine not found!") + else: + tdLog.info(f"TDengine found in {rootRealPath}") + return rootRealPath + +tdFindPath = TDFindPath() \ No newline at end of file From 3bf8a5dd7e3663331880586ac3badd02e8e6ac5b Mon Sep 17 00:00:00 2001 From: zyyang <69311263+zyyang-taosdata@users.noreply.github.com> Date: Tue, 8 Jun 2021 11:38:51 +0800 Subject: [PATCH 43/72] sync jdbc from develop to master (#6394) * change * remove test cases not available for master branch Co-authored-by: Ping Xiao --- .../com/taosdata/jdbc/AbstractResultSet.java | 7 +- .../com/taosdata/jdbc/TSDBConnection.java | 14 +- .../com/taosdata/jdbc/TSDBJNIConnector.java | 97 +++- .../taosdata/jdbc/TSDBPreparedStatement.java | 526 +++++++++++++++++- .../taosdata/jdbc/TSDBResultSetBlockData.java | 60 +- .../taosdata/jdbc/TSDBResultSetRowData.java | 5 +- .../java/com/taosdata/jdbc/TSDBStatement.java | 66 +-- .../com/taosdata/jdbc/utils/NullType.java | 91 +++ .../java/com/taosdata/jdbc/utils/Utils.java | 1 + .../jdbc/TSDBPreparedStatementTest.java | 4 +- .../com/taosdata/jdbc/TSDBResultSetTest.java | 10 +- .../cases/InsertSpecialCharacterJniTest.java | 1 + 12 files changed, 746 insertions(+), 136 deletions(-) create mode 100755 src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/NullType.java diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java index 4b5b88d93b..f8ea9af423 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java @@ -84,10 +84,12 @@ public abstract class AbstractResultSet extends WrapperImpl implements ResultSet } @Override + @Deprecated public InputStream getUnicodeStream(int columnIndex) throws SQLException { - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED); - + } + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); } @@ -171,6 +173,7 @@ public abstract class AbstractResultSet extends WrapperImpl implements ResultSet } @Override + @Deprecated public InputStream getUnicodeStream(String columnLabel) throws SQLException { return getUnicodeStream(findColumn(columnLabel)); } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java index c8ab9fb15a..02fee74eb5 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java @@ -49,7 +49,7 @@ public class TSDBConnection extends AbstractConnection { this.databaseMetaData.setConnection(this); } - public TSDBJNIConnector getConnection() { + public TSDBJNIConnector getConnector() { return this.connector; } @@ -58,7 +58,7 @@ public class TSDBConnection extends AbstractConnection { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED); } - return new TSDBStatement(this, this.connector); + return new TSDBStatement(this); } public TSDBSubscribe subscribe(String topic, String sql, boolean restart) throws SQLException { @@ -74,14 +74,18 @@ public class TSDBConnection extends AbstractConnection { } public PreparedStatement prepareStatement(String sql) throws SQLException { - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED); - return new TSDBPreparedStatement(this, this.connector, sql); + } + + return new TSDBPreparedStatement(this, sql); } public void close() throws SQLException { - if (isClosed) + if (isClosed) { return; + } + this.connector.closeConnection(); this.isClosed = true; } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java index 7f0cf7de8d..256e735285 100755 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java @@ -16,12 +16,13 @@ */ package com.taosdata.jdbc; -import com.taosdata.jdbc.utils.TaosInfo; - +import java.nio.ByteBuffer; import java.sql.SQLException; import java.sql.SQLWarning; import java.util.List; +import com.taosdata.jdbc.utils.TaosInfo; + /** * JNI connector */ @@ -29,10 +30,13 @@ public class TSDBJNIConnector { private static volatile Boolean isInitialized = false; private TaosInfo taosInfo = TaosInfo.getInstance(); + // Connection pointer used in C private long taos = TSDBConstants.JNI_NULL_POINTER; + // result set status in current connection private boolean isResultsetClosed; + private int affectedRows = -1; static { @@ -75,7 +79,6 @@ public class TSDBJNIConnector { public boolean connect(String host, int port, String dbName, String user, String password) throws SQLException { if (this.taos != TSDBConstants.JNI_NULL_POINTER) { -// this.closeConnectionImp(this.taos); closeConnection(); this.taos = TSDBConstants.JNI_NULL_POINTER; } @@ -97,12 +100,6 @@ public class TSDBJNIConnector { * @throws SQLException */ public long executeQuery(String sql) throws SQLException { - // close previous result set if the user forgets to invoke the - // free method to close previous result set. -// if (!this.isResultsetClosed) { -// freeResultSet(taosResultSetPointer); -// } - Long pSql = 0l; try { pSql = this.executeQueryImp(sql.getBytes(TaosGlobalConfig.getCharset()), this.taos); @@ -170,7 +167,7 @@ public class TSDBJNIConnector { private native long isUpdateQueryImp(long connection, long pSql); /** - * Free resultset operation from C to release resultset pointer by JNI + * Free result set operation from C to release result set pointer by JNI */ public int freeResultSet(long pSql) { int res = this.freeResultSetImp(this.taos, pSql); @@ -178,19 +175,6 @@ public class TSDBJNIConnector { return res; } - /** - * Close the open result set which is associated to the current connection. If the result set is already - * closed, return 0 for success. - */ -// public int freeResultSet() { -// int resCode = TSDBConstants.JNI_SUCCESS; -// if (!isResultsetClosed) { -// resCode = this.freeResultSetImp(this.taos, this.taosResultSetPointer); -// taosResultSetPointer = TSDBConstants.JNI_NULL_POINTER; -// isResultsetClosed = true; -// } -// return resCode; -// } private native int freeResultSetImp(long connection, long result); /** @@ -237,6 +221,7 @@ public class TSDBJNIConnector { */ public void closeConnection() throws SQLException { int code = this.closeConnectionImp(this.taos); + if (code < 0) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); } else if (code == 0) { @@ -244,6 +229,7 @@ public class TSDBJNIConnector { } else { throw new SQLException("Undefined error code returned by TDengine when closing a connection"); } + // invoke closeConnectionImpl only here taosInfo.connect_close_increment(); } @@ -280,7 +266,7 @@ public class TSDBJNIConnector { private native void unsubscribeImp(long subscription, boolean isKeep); /** - * Validate if a create table sql statement is correct without actually creating that table + * Validate if a create table SQL statement is correct without actually creating that table */ public boolean validateCreateTableSql(String sql) { int res = validateCreateTableSqlImp(taos, sql.getBytes()); @@ -288,4 +274,67 @@ public class TSDBJNIConnector { } private native int validateCreateTableSqlImp(long connection, byte[] sqlBytes); + + public long prepareStmt(String sql) throws SQLException { + Long stmt = prepareStmtImp(sql.getBytes(), this.taos); + if (stmt == TSDBConstants.JNI_TDENGINE_ERROR) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_SQL); + } else if (stmt == TSDBConstants.JNI_CONNECTION_NULL) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); + } else if (stmt == TSDBConstants.JNI_SQL_NULL) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_SQL_NULL); + } else if (stmt == TSDBConstants.JNI_OUT_OF_MEMORY) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_OUT_OF_MEMORY); + } + + return stmt; + } + + private native long prepareStmtImp(byte[] sql, long con); + + public void setBindTableName(long stmt, String tableName) throws SQLException { + int code = setBindTableNameImp(stmt, tableName, this.taos); + if (code != TSDBConstants.JNI_SUCCESS) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "failed to set table name"); + } + } + + private native int setBindTableNameImp(long stmt, String name, long conn); + + public void setBindTableNameAndTags(long stmt, String tableName, int numOfTags, ByteBuffer tags, ByteBuffer typeList, ByteBuffer lengthList, ByteBuffer nullList) throws SQLException { + int code = setTableNameTagsImp(stmt, tableName, numOfTags, tags.array(), typeList.array(), lengthList.array(), + nullList.array(), this.taos); + if (code != TSDBConstants.JNI_SUCCESS) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "failed to bind table name and corresponding tags"); + } + } + + private native int setTableNameTagsImp(long stmt, String name, int numOfTags, byte[] tags, byte[] typeList, byte[] lengthList, byte[] nullList, long conn); + + public void bindColumnDataArray(long stmt, ByteBuffer colDataList, ByteBuffer lengthList, ByteBuffer isNullList, int type, int bytes, int numOfRows,int columnIndex) throws SQLException { + int code = bindColDataImp(stmt, colDataList.array(), lengthList.array(), isNullList.array(), type, bytes, numOfRows, columnIndex, this.taos); + if (code != TSDBConstants.JNI_SUCCESS) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "failed to bind column data"); + } + } + + private native int bindColDataImp(long stmt, byte[] colDataList, byte[] lengthList, byte[] isNullList, int type, int bytes, int numOfRows, int columnIndex, long conn); + + public void executeBatch(long stmt) throws SQLException { + int code = executeBatchImp(stmt, this.taos); + if (code != TSDBConstants.JNI_SUCCESS) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "failed to execute batch bind"); + } + } + + private native int executeBatchImp(long stmt, long con); + + public void closeBatch(long stmt) throws SQLException { + int code = closeStmt(stmt, this.taos); + if (code != TSDBConstants.JNI_SUCCESS) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "failed to close batch bind"); + } + } + + private native int closeStmt(long stmt, long con); } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java index 56f971a35e..f6810237c0 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java @@ -18,33 +18,43 @@ import com.taosdata.jdbc.utils.Utils; import java.io.InputStream; import java.io.Reader; +import java.io.UnsupportedEncodingException; import java.math.BigDecimal; import java.net.URL; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; import java.sql.*; import java.util.ArrayList; import java.util.Calendar; +import java.util.Collections; import java.util.regex.Matcher; import java.util.regex.Pattern; /* - * TDengine only supports a subset of the standard SQL, thus this implemetation of the + * TDengine only supports a subset of the standard SQL, thus this implementation of the * standard JDBC API contains more or less some adjustments customized for certain * compatibility needs. */ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStatement { - private String rawSql; private Object[] parameters; private boolean isPrepared; - + + private ArrayList colData; + private ArrayList tableTags; + private int tagValueLength; + + private String tableName; + private long nativeStmtHandle = 0; + private volatile TSDBParameterMetaData parameterMetaData; - TSDBPreparedStatement(TSDBConnection connection, TSDBJNIConnector connecter, String sql) { - super(connection, connecter); + TSDBPreparedStatement(TSDBConnection connection, String sql) { + super(connection); init(sql); + int parameterCnt = 0; if (sql.contains("?")) { - int parameterCnt = 0; for (int i = 0; i < sql.length(); i++) { if ('?' == sql.charAt(i)) { parameterCnt++; @@ -53,6 +63,12 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat parameters = new Object[parameterCnt]; this.isPrepared = true; } + + if (parameterCnt > 1) { + // the table name is also a parameter, so ignore it. + this.colData = new ArrayList(); + this.tableTags = new ArrayList(); + } } private void init(String sql) { @@ -260,10 +276,14 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat @Override public void setObject(int parameterIndex, Object x) throws SQLException { - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); - if (parameterIndex < 1 && parameterIndex >= parameters.length) + } + + if (parameterIndex < 1 && parameterIndex >= parameters.length) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE); + } + parameters[parameterIndex - 1] = x; } @@ -300,9 +320,10 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat @Override public void setRef(int parameterIndex, Ref x) throws SQLException { - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); - + } + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); } @@ -515,4 +536,489 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); } + + /////////////////////////////////////////////////////////////////////// + // NOTE: the following APIs are not JDBC compatible + // set the bind table name + private static class ColumnInfo { + @SuppressWarnings("rawtypes") + private ArrayList data; + private int type; + private int bytes; + private boolean typeIsSet; + + public ColumnInfo() { + this.typeIsSet = false; + } + + public void setType(int type) throws SQLException { + if (this.isTypeSet()) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "column data type has been set"); + } + + this.typeIsSet = true; + this.type = type; + } + + public boolean isTypeSet() { + return this.typeIsSet; + } + }; + + private static class TableTagInfo { + private boolean isNull; + private Object value; + private int type; + public TableTagInfo(Object value, int type) { + this.value = value; + this.type = type; + } + + public static TableTagInfo createNullTag(int type) { + TableTagInfo info = new TableTagInfo(null, type); + info.isNull = true; + return info; + } + }; + + public void setTableName(String name) { + this.tableName = name; + } + + private void ensureTagCapacity(int index) { + if (this.tableTags.size() < index + 1) { + int delta = index + 1 - this.tableTags.size(); + this.tableTags.addAll(Collections.nCopies(delta, null)); + } + } + + public void setTagNull(int index, int type) { + ensureTagCapacity(index); + this.tableTags.set(index, TableTagInfo.createNullTag(type)); + } + + public void setTagBoolean(int index, boolean value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_BOOL)); + this.tagValueLength += Byte.BYTES; + } + + public void setTagInt(int index, int value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_INT)); + this.tagValueLength += Integer.BYTES; + } + + public void setTagByte(int index, byte value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_TINYINT)); + this.tagValueLength += Byte.BYTES; + } + + public void setTagShort(int index, short value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_SMALLINT)); + this.tagValueLength += Short.BYTES; + } + + public void setTagLong(int index, long value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_BIGINT)); + this.tagValueLength += Long.BYTES; + } + + public void setTagTimestamp(int index, long value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP)); + this.tagValueLength += Long.BYTES; + } + + public void setTagFloat(int index, float value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_FLOAT)); + this.tagValueLength += Float.BYTES; + } + + public void setTagDouble(int index, double value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_DOUBLE)); + this.tagValueLength += Double.BYTES; + } + + public void setTagString(int index, String value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_BINARY)); + this.tagValueLength += value.getBytes().length; + } + + public void setTagNString(int index, String value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_NCHAR)); + + String charset = TaosGlobalConfig.getCharset(); + try { + this.tagValueLength += value.getBytes(charset).length; + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + + public void setValueImpl(int columnIndex, ArrayList list, int type, int bytes) throws SQLException { + if (this.colData.size() == 0) { + this.colData.addAll(Collections.nCopies(this.parameters.length - 1 - this.tableTags.size(), null)); + + } + ColumnInfo col = (ColumnInfo) this.colData.get(columnIndex); + if (col == null) { + ColumnInfo p = new ColumnInfo(); + p.setType(type); + p.bytes = bytes; + p.data = (ArrayList) list.clone(); + this.colData.set(columnIndex, p); + } else { + if (col.type != type) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "column data type mismatch"); + } + col.data.addAll(list); + } + } + + public void setInt(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_INT, Integer.BYTES); + } + + public void setFloat(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_FLOAT, Float.BYTES); + } + + public void setTimestamp(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP, Long.BYTES); + } + + public void setLong(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_BIGINT, Long.BYTES); + } + + public void setDouble(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_DOUBLE, Double.BYTES); + } + + public void setBoolean(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_BOOL, Byte.BYTES); + } + + public void setByte(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_TINYINT, Byte.BYTES); + } + + public void setShort(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_SMALLINT, Short.BYTES); + } + + public void setString(int columnIndex, ArrayList list, int size) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_BINARY, size); + } + + // note: expand the required space for each NChar character + public void setNString(int columnIndex, ArrayList list, int size) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_NCHAR, size * Integer.BYTES); + } + + public void columnDataAddBatch() throws SQLException { + // pass the data block to native code + if (rawSql == null) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "sql statement not set yet"); + } + + // table name is not set yet, abort + if (this.tableName == null) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "table name not set yet"); + } + + int numOfCols = this.colData.size(); + if (numOfCols == 0) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "column data not bind"); + } + + TSDBJNIConnector connector = ((TSDBConnection) this.getConnection()).getConnector(); + this.nativeStmtHandle = connector.prepareStmt(rawSql); + + if (this.tableTags == null) { + connector.setBindTableName(this.nativeStmtHandle, this.tableName); + } else { + int num = this.tableTags.size(); + ByteBuffer tagDataList = ByteBuffer.allocate(this.tagValueLength); + tagDataList.order(ByteOrder.LITTLE_ENDIAN); + + ByteBuffer typeList = ByteBuffer.allocate(num); + typeList.order(ByteOrder.LITTLE_ENDIAN); + + ByteBuffer lengthList = ByteBuffer.allocate(num * Long.BYTES); + lengthList.order(ByteOrder.LITTLE_ENDIAN); + + ByteBuffer isNullList = ByteBuffer.allocate(num * Integer.BYTES); + isNullList.order(ByteOrder.LITTLE_ENDIAN); + + for (int i = 0; i < num; ++i) { + TableTagInfo tag = this.tableTags.get(i); + if (tag.isNull) { + typeList.put((byte) tag.type); + isNullList.putInt(1); + lengthList.putLong(0); + continue; + } + + switch (tag.type) { + case TSDBConstants.TSDB_DATA_TYPE_INT: { + Integer val = (Integer) tag.value; + tagDataList.putInt(val); + lengthList.putLong(Integer.BYTES); + break; + } + case TSDBConstants.TSDB_DATA_TYPE_TINYINT: { + Byte val = (Byte) tag.value; + tagDataList.put(val); + lengthList.putLong(Byte.BYTES); + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_BOOL: { + Boolean val = (Boolean) tag.value; + tagDataList.put((byte) (val ? 1 : 0)); + lengthList.putLong(Byte.BYTES); + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: { + Short val = (Short) tag.value; + tagDataList.putShort(val); + lengthList.putLong(Short.BYTES); + + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: + case TSDBConstants.TSDB_DATA_TYPE_BIGINT: { + Long val = (Long) tag.value; + tagDataList.putLong(val == null ? 0 : val); + lengthList.putLong(Long.BYTES); + + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: { + Float val = (Float) tag.value; + tagDataList.putFloat(val == null ? 0 : val); + lengthList.putLong(Float.BYTES); + + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: { + Double val = (Double) tag.value; + tagDataList.putDouble(val == null ? 0 : val); + lengthList.putLong(Double.BYTES); + + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_NCHAR: + case TSDBConstants.TSDB_DATA_TYPE_BINARY: { + String charset = TaosGlobalConfig.getCharset(); + String val = (String) tag.value; + + byte[] b = null; + try { + if (tag.type == TSDBConstants.TSDB_DATA_TYPE_BINARY) { + b = val.getBytes(); + } else { + b = val.getBytes(charset); + } + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + tagDataList.put(b); + lengthList.putLong(b.length); + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_UTINYINT: + case TSDBConstants.TSDB_DATA_TYPE_USMALLINT: + case TSDBConstants.TSDB_DATA_TYPE_UINT: + case TSDBConstants.TSDB_DATA_TYPE_UBIGINT: { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "not support data types"); + } + } + + typeList.put((byte) tag.type); + isNullList.putInt(tag.isNull? 1 : 0); + } + + connector.setBindTableNameAndTags(this.nativeStmtHandle, this.tableName, this.tableTags.size(), tagDataList, + typeList, lengthList, isNullList); + } + + ColumnInfo colInfo = (ColumnInfo) this.colData.get(0); + if (colInfo == null) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "column data not bind"); + } + + int rows = colInfo.data.size(); + for (int i = 0; i < numOfCols; ++i) { + ColumnInfo col1 = this.colData.get(i); + if (col1 == null || !col1.isTypeSet()) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "column data not bind"); + } + + if (rows != col1.data.size()) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "the rows in column data not identical"); + } + + ByteBuffer colDataList = ByteBuffer.allocate(rows * col1.bytes); + colDataList.order(ByteOrder.LITTLE_ENDIAN); + + ByteBuffer lengthList = ByteBuffer.allocate(rows * Integer.BYTES); + lengthList.order(ByteOrder.LITTLE_ENDIAN); + + ByteBuffer isNullList = ByteBuffer.allocate(rows * Byte.BYTES); + isNullList.order(ByteOrder.LITTLE_ENDIAN); + + switch (col1.type) { + case TSDBConstants.TSDB_DATA_TYPE_INT: { + for (int j = 0; j < rows; ++j) { + Integer val = (Integer) col1.data.get(j); + colDataList.putInt(val == null? Integer.MIN_VALUE:val); + isNullList.put((byte) (val == null? 1:0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_TINYINT: { + for (int j = 0; j < rows; ++j) { + Byte val = (Byte) col1.data.get(j); + colDataList.put(val == null? 0:val); + isNullList.put((byte) (val == null? 1:0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_BOOL: { + for (int j = 0; j < rows; ++j) { + Boolean val = (Boolean) col1.data.get(j); + if (val == null) { + colDataList.put((byte) 0); + } else { + colDataList.put((byte) (val? 1:0)); + } + + isNullList.put((byte) (val == null? 1:0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: { + for (int j = 0; j < rows; ++j) { + Short val = (Short) col1.data.get(j); + colDataList.putShort(val == null? 0:val); + isNullList.put((byte) (val == null? 1:0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: + case TSDBConstants.TSDB_DATA_TYPE_BIGINT: { + for (int j = 0; j < rows; ++j) { + Long val = (Long) col1.data.get(j); + colDataList.putLong(val == null? 0:val); + isNullList.put((byte) (val == null? 1:0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: { + for (int j = 0; j < rows; ++j) { + Float val = (Float) col1.data.get(j); + colDataList.putFloat(val == null? 0:val); + isNullList.put((byte) (val == null? 1:0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: { + for (int j = 0; j < rows; ++j) { + Double val = (Double) col1.data.get(j); + colDataList.putDouble(val == null? 0:val); + isNullList.put((byte) (val == null? 1:0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_NCHAR: + case TSDBConstants.TSDB_DATA_TYPE_BINARY: { + String charset = TaosGlobalConfig.getCharset(); + for (int j = 0; j < rows; ++j) { + String val = (String) col1.data.get(j); + + colDataList.position(j * col1.bytes); // seek to the correct position + if (val != null) { + byte[] b = null; + try { + if (col1.type == TSDBConstants.TSDB_DATA_TYPE_BINARY) { + b = val.getBytes(); + } else { + b = val.getBytes(charset); + } + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + if (val.length() > col1.bytes) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "string data too long"); + } + + colDataList.put(b); + lengthList.putInt(b.length); + isNullList.put((byte) 0); + } else { + lengthList.putInt(0); + isNullList.put((byte) 1); + } + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_UTINYINT: + case TSDBConstants.TSDB_DATA_TYPE_USMALLINT: + case TSDBConstants.TSDB_DATA_TYPE_UINT: + case TSDBConstants.TSDB_DATA_TYPE_UBIGINT: { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "not support data types"); + } + }; + + connector.bindColumnDataArray(this.nativeStmtHandle, colDataList, lengthList, isNullList, col1.type, col1.bytes, rows, i); + } + } + + public void columnDataExecuteBatch() throws SQLException { + TSDBJNIConnector connector = ((TSDBConnection) this.getConnection()).getConnector(); + connector.executeBatch(this.nativeStmtHandle); + this.columnDataClearBatch(); + } + + public void columnDataClearBatch() { + int size = this.colData.size(); + this.colData.clear(); + + this.colData.addAll(Collections.nCopies(size, null)); + this.tableName = null; // clear the table name + } + + public void columnDataCloseBatch() throws SQLException { + TSDBJNIConnector connector = ((TSDBConnection) this.getConnection()).getConnector(); + connector.closeBatch(this.nativeStmtHandle); + + this.nativeStmtHandle = 0L; + this.tableName = null; + } } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java index ce5290de66..7b3be5d263 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java @@ -29,6 +29,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import com.taosdata.jdbc.utils.NullType; + public class TSDBResultSetBlockData { private int numOfRows = 0; private int rowIndex = 0; @@ -164,59 +166,7 @@ public class TSDBResultSetBlockData { } } - private static class NullType { - private static final byte NULL_BOOL_VAL = 0x2; - private static final String NULL_STR = "null"; - - public String toString() { - return NullType.NULL_STR; - } - - public static boolean isBooleanNull(byte val) { - return val == NullType.NULL_BOOL_VAL; - } - - private static boolean isTinyIntNull(byte val) { - return val == Byte.MIN_VALUE; - } - - private static boolean isSmallIntNull(short val) { - return val == Short.MIN_VALUE; - } - - private static boolean isIntNull(int val) { - return val == Integer.MIN_VALUE; - } - - private static boolean isBigIntNull(long val) { - return val == Long.MIN_VALUE; - } - - private static boolean isFloatNull(float val) { - return Float.isNaN(val); - } - - private static boolean isDoubleNull(double val) { - return Double.isNaN(val); - } - - private static boolean isBinaryNull(byte[] val, int length) { - if (length != Byte.BYTES) { - return false; - } - - return val[0] == 0xFF; - } - - private static boolean isNcharNull(byte[] val, int length) { - if (length != Integer.BYTES) { - return false; - } - - return (val[0] & val[1] & val[2] & val[3]) == 0xFF; - } - - } + /** * The original type may not be a string type, but will be converted to by @@ -488,8 +438,8 @@ public class TSDBResultSetBlockData { } try { - String ss = TaosGlobalConfig.getCharset(); - return new String(dest, ss); + String charset = TaosGlobalConfig.getCharset(); + return new String(dest, charset); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java index 34470fbc4e..618e896a6d 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java @@ -84,7 +84,8 @@ public class TSDBResultSetRowData { data.set(col, value); } - public int getInt(int col, int srcType) throws SQLException { + @SuppressWarnings("deprecation") + public int getInt(int col, int srcType) throws SQLException { Object obj = data.get(col); switch (srcType) { @@ -128,7 +129,7 @@ public class TSDBResultSetRowData { long value = (long) obj; if (value < 0) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE); - return new Long(value).intValue(); + return Long.valueOf(value).intValue(); } } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java index fb20a621b0..d8ba67576d 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java @@ -19,8 +19,6 @@ import java.sql.ResultSet; import java.sql.SQLException; public class TSDBStatement extends AbstractStatement { - - private TSDBJNIConnector connector; /** * Status of current statement */ @@ -29,29 +27,26 @@ public class TSDBStatement extends AbstractStatement { private TSDBConnection connection; private TSDBResultSet resultSet; - public void setConnection(TSDBConnection connection) { + TSDBStatement(TSDBConnection connection) { this.connection = connection; } - TSDBStatement(TSDBConnection connection, TSDBJNIConnector connector) { - this.connection = connection; - this.connector = connector; - } - public ResultSet executeQuery(String sql) throws SQLException { // check if closed - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); + } + //TODO: 如果在executeQuery方法中执行insert语句,那么先执行了SQL,再通过pSql来检查是否为一个insert语句,但这个insert SQL已经执行成功了 // execute query - long pSql = this.connector.executeQuery(sql); + long pSql = this.connection.getConnector().executeQuery(sql); // if pSql is create/insert/update/delete/alter SQL - if (this.connector.isUpdateQuery(pSql)) { - this.connector.freeResultSet(pSql); + if (this.connection.getConnector().isUpdateQuery(pSql)) { + this.connection.getConnector().freeResultSet(pSql); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_WITH_EXECUTEQUERY); } - TSDBResultSet res = new TSDBResultSet(this, this.connector, pSql); + TSDBResultSet res = new TSDBResultSet(this, this.connection.getConnector(), pSql); res.setBatchFetch(this.connection.getBatchFetch()); return res; } @@ -60,14 +55,14 @@ public class TSDBStatement extends AbstractStatement { if (isClosed()) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); - long pSql = this.connector.executeQuery(sql); + long pSql = this.connection.getConnector().executeQuery(sql); // if pSql is create/insert/update/delete/alter SQL - if (!this.connector.isUpdateQuery(pSql)) { - this.connector.freeResultSet(pSql); + if (!this.connection.getConnector().isUpdateQuery(pSql)) { + this.connection.getConnector().freeResultSet(pSql); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_WITH_EXECUTEUPDATE); } - int affectedRows = this.connector.getAffectedRows(pSql); - this.connector.freeResultSet(pSql); + int affectedRows = this.connection.getConnector().getAffectedRows(pSql); + this.connection.getConnector().freeResultSet(pSql); return affectedRows; } @@ -81,30 +76,29 @@ public class TSDBStatement extends AbstractStatement { public boolean execute(String sql) throws SQLException { // check if closed - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); + } + // execute query - long pSql = this.connector.executeQuery(sql); + long pSql = this.connection.getConnector().executeQuery(sql); // if pSql is create/insert/update/delete/alter SQL - if (this.connector.isUpdateQuery(pSql)) { - this.affectedRows = this.connector.getAffectedRows(pSql); - this.connector.freeResultSet(pSql); + if (this.connection.getConnector().isUpdateQuery(pSql)) { + this.affectedRows = this.connection.getConnector().getAffectedRows(pSql); + this.connection.getConnector().freeResultSet(pSql); return false; } - this.resultSet = new TSDBResultSet(this, this.connector, pSql); + this.resultSet = new TSDBResultSet(this, this.connection.getConnector(), pSql); this.resultSet.setBatchFetch(this.connection.getBatchFetch()); return true; } public ResultSet getResultSet() throws SQLException { - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); -// long resultSetPointer = connector.getResultSet(); -// TSDBResultSet resSet = null; -// if (resultSetPointer != TSDBConstants.JNI_NULL_POINTER) { -// resSet = new TSDBResultSet(connector, resultSetPointer); -// } + } + return this.resultSet; } @@ -115,12 +109,20 @@ public class TSDBStatement extends AbstractStatement { } public Connection getConnection() throws SQLException { - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); - if (this.connector == null) + } + + if (this.connection.getConnector() == null) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); + } + return this.connection; } + + public void setConnection(TSDBConnection connection) { + this.connection = connection; + } public boolean isClosed() throws SQLException { return isClosed; diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/NullType.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/NullType.java new file mode 100755 index 0000000000..0e05aeeee7 --- /dev/null +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/NullType.java @@ -0,0 +1,91 @@ +package com.taosdata.jdbc.utils; + +public class NullType { + private static final byte NULL_BOOL_VAL = 0x2; + private static final String NULL_STR = "null"; + + public String toString() { + return NullType.NULL_STR; + } + + public static boolean isBooleanNull(byte val) { + return val == NullType.NULL_BOOL_VAL; + } + + public static boolean isTinyIntNull(byte val) { + return val == Byte.MIN_VALUE; + } + + public static boolean isSmallIntNull(short val) { + return val == Short.MIN_VALUE; + } + + public static boolean isIntNull(int val) { + return val == Integer.MIN_VALUE; + } + + public static boolean isBigIntNull(long val) { + return val == Long.MIN_VALUE; + } + + public static boolean isFloatNull(float val) { + return Float.isNaN(val); + } + + public static boolean isDoubleNull(double val) { + return Double.isNaN(val); + } + + public static boolean isBinaryNull(byte[] val, int length) { + if (length != Byte.BYTES) { + return false; + } + + return val[0] == 0xFF; + } + + public static boolean isNcharNull(byte[] val, int length) { + if (length != Integer.BYTES) { + return false; + } + + return (val[0] & val[1] & val[2] & val[3]) == 0xFF; + } + + public static byte getBooleanNull() { + return NullType.NULL_BOOL_VAL; + } + + public static byte getTinyintNull() { + return Byte.MIN_VALUE; + } + + public static int getIntNull() { + return Integer.MIN_VALUE; + } + + public static short getSmallIntNull() { + return Short.MIN_VALUE; + } + + public static long getBigIntNull() { + return Long.MIN_VALUE; + } + + public static int getFloatNull() { + return 0x7FF00000; + } + + public static long getDoubleNull() { + return 0x7FFFFF0000000000L; + } + + public static byte getBinaryNull() { + return (byte) 0xFF; + } + + public static byte[] getNcharNull() { + return new byte[] {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}; + } + +} diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/Utils.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/Utils.java index 082cec1e24..eeb936a1d0 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/Utils.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/Utils.java @@ -146,6 +146,7 @@ public class Utils { */ private static String transformSql(String rawSql, Object[] paramArr, Map placeholderPosition, RangeSet clauseRangeSet) { String[] sqlArr = rawSql.split("\\?"); + return IntStream.range(0, sqlArr.length).mapToObj(index -> { if (index == paramArr.length) return sqlArr[index]; diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java index dc6fd4c501..121392c83e 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java @@ -8,6 +8,8 @@ import org.junit.Test; import java.io.IOException; import java.io.Serializable; import java.sql.*; +import java.util.ArrayList; +import java.util.Random; public class TSDBPreparedStatementTest { private static final String host = "127.0.0.1"; @@ -96,7 +98,7 @@ public class TSDBPreparedStatementTest { result = pstmt_insert.executeUpdate(); Assert.assertEquals(1, result); } - + @Test public void setBoolean() throws SQLException { pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java index c5c6f7bca5..f304fd6874 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java @@ -3,7 +3,6 @@ package com.taosdata.jdbc; import com.google.common.primitives.Ints; import com.google.common.primitives.Longs; import com.google.common.primitives.Shorts; -import com.taosdata.jdbc.rs.RestfulResultSet; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -177,7 +176,8 @@ public class TSDBResultSetTest { rs.getAsciiStream("f1"); } - @Test(expected = SQLFeatureNotSupportedException.class) + @SuppressWarnings("deprecation") + @Test(expected = SQLFeatureNotSupportedException.class) public void getUnicodeStream() throws SQLException { rs.getUnicodeStream("f1"); } @@ -326,7 +326,7 @@ public class TSDBResultSetTest { @Test(expected = SQLFeatureNotSupportedException.class) public void getRow() throws SQLException { - int row = rs.getRow(); + rs.getRow(); } @Test(expected = SQLFeatureNotSupportedException.class) @@ -405,12 +405,12 @@ public class TSDBResultSetTest { @Test(expected = SQLFeatureNotSupportedException.class) public void updateByte() throws SQLException { - rs.updateByte(1, new Byte("0")); + rs.updateByte(1, (byte) 0); } @Test(expected = SQLFeatureNotSupportedException.class) public void updateShort() throws SQLException { - rs.updateShort(1, new Short("0")); + rs.updateShort(1, (short) 0); } @Test(expected = SQLFeatureNotSupportedException.class) diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterJniTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterJniTest.java index a3c46dc232..4b4e83719f 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterJniTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterJniTest.java @@ -345,6 +345,7 @@ public class InsertSpecialCharacterJniTest { } } + @Test public void testCase12() throws SQLException { final long now = System.currentTimeMillis(); From 60068b12176ab95c7ffa3b82a4dc49d62d46b771 Mon Sep 17 00:00:00 2001 From: lichuang Date: Tue, 8 Jun 2021 11:43:34 +0800 Subject: [PATCH 44/72] [TD-4556]merge tsdb compact algo from enterprise version --- src/inc/tsdb.h | 2 +- src/tsdb/src/tsdbCompact.c | 511 ++++++++++++++++++++++++++++++++++++- src/tsdb/src/tsdbMain.c | 2 + 3 files changed, 511 insertions(+), 4 deletions(-) diff --git a/src/inc/tsdb.h b/src/inc/tsdb.h index 05d29daad5..79d9029dbc 100644 --- a/src/inc/tsdb.h +++ b/src/inc/tsdb.h @@ -94,7 +94,7 @@ STsdbRepo *tsdbOpenRepo(STsdbCfg *pCfg, STsdbAppH *pAppH); int tsdbCloseRepo(STsdbRepo *repo, int toCommit); int32_t tsdbConfigRepo(STsdbRepo *repo, STsdbCfg *pCfg); int tsdbGetState(STsdbRepo *repo); - +bool tsdbInCompact(STsdbRepo *repo); // --------- TSDB TABLE DEFINITION typedef struct { uint64_t uid; // the unique table ID diff --git a/src/tsdb/src/tsdbCompact.c b/src/tsdb/src/tsdbCompact.c index 635bba388a..2e8e81b65e 100644 --- a/src/tsdb/src/tsdbCompact.c +++ b/src/tsdb/src/tsdbCompact.c @@ -12,11 +12,516 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#include "tsdb.h" +#include "tsdbint.h" #ifndef _TSDB_PLUGINS -int tsdbCompact(STsdbRepo *pRepo) { return 0; } -void *tsdbCompactImpl(STsdbRepo *pRepo) { return NULL; } +typedef struct { + STable * pTable; + SBlockIdx * pBlkIdx; + SBlockIdx bindex; + SBlockInfo *pInfo; +} STableCompactH; + +typedef struct { + SRtn rtn; + SFSIter fsIter; + SArray * tbArray; // table array to cache table obj and block indexes + SReadH readh; + SDFileSet wSet; + SArray * aBlkIdx; + SArray * aSupBlk; + SDataCols *pDataCols; +} SCompactH; + +#define TSDB_COMPACT_WSET(pComph) (&((pComph)->wSet)) +#define TSDB_COMPACT_REPO(pComph) TSDB_READ_REPO(&((pComph)->readh)) +#define TSDB_COMPACT_HEAD_FILE(pComph) TSDB_DFILE_IN_SET(TSDB_COMPACT_WSET(pComph), TSDB_FILE_HEAD) +#define TSDB_COMPACT_DATA_FILE(pComph) TSDB_DFILE_IN_SET(TSDB_COMPACT_WSET(pComph), TSDB_FILE_DATA) +#define TSDB_COMPACT_LAST_FILE(pComph) TSDB_DFILE_IN_SET(TSDB_COMPACT_WSET(pComph), TSDB_FILE_LAST) +#define TSDB_COMPACT_BUF(pComph) TSDB_READ_BUF(&((pComph)->readh)) +#define TSDB_COMPACT_COMP_BUF(pComph) TSDB_READ_COMP_BUF(&((pComph)->readh)) + +static int tsdbAsyncCompact(STsdbRepo *pRepo); +static void tsdbStartCompact(STsdbRepo *pRepo); +static void tsdbEndCompact(STsdbRepo *pRepo, int eno); +static int tsdbCompactMeta(STsdbRepo *pRepo); +static int tsdbCompactTSData(STsdbRepo *pRepo); +static int tsdbCompactFSet(SCompactH *pComph, SDFileSet *pSet); +static bool tsdbShouldCompact(SCompactH *pComph); +static int tsdbInitCompactH(SCompactH *pComph, STsdbRepo *pRepo); +static void tsdbDestroyCompactH(SCompactH *pComph); +static int tsdbInitCompTbArray(SCompactH *pComph); +static void tsdbDestroyCompTbArray(SCompactH *pComph); +static int tsdbCacheFSetIndex(SCompactH *pComph); +static int tsdbCompactFSetInit(SCompactH *pComph, SDFileSet *pSet); +static void tsdbCompactFSetEnd(SCompactH *pComph); +static int tsdbCompactFSetImpl(SCompactH *pComph); +static int tsdbWriteBlockToRightFile(SCompactH *pComph, STable *pTable, SDataCols *pDataCols, void **ppBuf, + void **ppCBuf); + +int tsdbCompact(STsdbRepo *pRepo) { return tsdbAsyncCompact(pRepo); } + +void *tsdbCompactImpl(STsdbRepo *pRepo) { + // Check if there are files in TSDB FS to compact + if (REPO_FS(pRepo)->cstatus->pmf == NULL) { + tsdbInfo("vgId:%d no file to compact in FS", REPO_ID(pRepo)); + return NULL; + } + + tsdbStartCompact(pRepo); + + if (tsdbCompactMeta(pRepo) < 0) { + tsdbError("vgId:%d failed to compact META data since %s", REPO_ID(pRepo), tstrerror(terrno)); + goto _err; + } + + if (tsdbCompactTSData(pRepo) < 0) { + tsdbError("vgId:%d failed to compact TS data since %s", REPO_ID(pRepo), tstrerror(terrno)); + goto _err; + } + + tsdbEndCompact(pRepo, TSDB_CODE_SUCCESS); + return NULL; + +_err: + pRepo->code = terrno; + tsdbEndCompact(pRepo, terrno); + return NULL; +} + +static int tsdbAsyncCompact(STsdbRepo *pRepo) { + tsem_wait(&(pRepo->readyToCommit)); + return tsdbScheduleCommit(pRepo, COMPACT_REQ); +} + +static void tsdbStartCompact(STsdbRepo *pRepo) { + ASSERT(!pRepo->inCompact); + tsdbInfo("vgId:%d start to compact!", REPO_ID(pRepo)); + tsdbStartFSTxn(pRepo, 0, 0); + pRepo->code = TSDB_CODE_SUCCESS; + pRepo->inCompact = true; +} + +static void tsdbEndCompact(STsdbRepo *pRepo, int eno) { + if (eno != TSDB_CODE_SUCCESS) { + tsdbEndFSTxnWithError(REPO_FS(pRepo)); + } else { + tsdbEndFSTxn(pRepo); + } + pRepo->inCompact = false; + tsdbInfo("vgId:%d compact over, %s", REPO_ID(pRepo), (eno == TSDB_CODE_SUCCESS) ? "succeed" : "failed"); + tsem_post(&(pRepo->readyToCommit)); +} + +static int tsdbCompactMeta(STsdbRepo *pRepo) { + STsdbFS *pfs = REPO_FS(pRepo); + tsdbUpdateMFile(pfs, pfs->cstatus->pmf); + return 0; +} + +static int tsdbCompactTSData(STsdbRepo *pRepo) { + SCompactH compactH; + SDFileSet *pSet = NULL; + + tsdbDebug("vgId:%d start to compact TS data", REPO_ID(pRepo)); + + // If no file, just return 0; + if (taosArrayGetSize(REPO_FS(pRepo)->cstatus->df) <= 0) { + tsdbDebug("vgId:%d no TS data file to compact, compact over", REPO_ID(pRepo)); + return 0; + } + + if (tsdbInitCompactH(&compactH, pRepo) < 0) { + return -1; + } + + while ((pSet = tsdbFSIterNext(&(compactH.fsIter)))) { + // Remove those expired files + if (pSet->fid < compactH.rtn.minFid) { + tsdbInfo("vgId:%d FSET %d on level %d disk id %d expires, remove it", REPO_ID(pRepo), pSet->fid, + TSDB_FSET_LEVEL(pSet), TSDB_FSET_ID(pSet)); + continue; + } + + if (TSDB_FSET_LEVEL(pSet) == TFS_MAX_LEVEL) { + tsdbDebug("vgId:%d FSET %d on level %d, should not compact", REPO_ID(pRepo), pSet->fid, TFS_MAX_LEVEL); + tsdbUpdateDFileSet(REPO_FS(pRepo), pSet); + continue; + } + + if (tsdbCompactFSet(&compactH, pSet) < 0) { + tsdbDestroyCompactH(&compactH); + tsdbError("vgId:%d failed to compact FSET %d since %s", REPO_ID(pRepo), pSet->fid, tstrerror(terrno)); + return -1; + } + } + + tsdbDestroyCompactH(&compactH); + tsdbDebug("vgId:%d compact TS data over", REPO_ID(pRepo)); + return 0; +} + +static int tsdbCompactFSet(SCompactH *pComph, SDFileSet *pSet) { + STsdbRepo *pRepo = TSDB_COMPACT_REPO(pComph); + SDiskID did; + + tsdbDebug("vgId:%d start to compact FSET %d on level %d id %d", REPO_ID(pRepo), pSet->fid, TSDB_FSET_LEVEL(pSet), + TSDB_FSET_ID(pSet)); + + if (tsdbCompactFSetInit(pComph, pSet) < 0) { + return -1; + } + + if (!tsdbShouldCompact(pComph)) { + tsdbDebug("vgId:%d no need to compact FSET %d", REPO_ID(pRepo), pSet->fid); + if (tsdbApplyRtnOnFSet(TSDB_COMPACT_REPO(pComph), pSet, &(pComph->rtn)) < 0) { + tsdbCompactFSetEnd(pComph); + return -1; + } + } else { + // Create new fset as compacted fset + tfsAllocDisk(tsdbGetFidLevel(pSet->fid, &(pComph->rtn)), &(did.level), &(did.id)); + if (did.level == TFS_UNDECIDED_LEVEL) { + terrno = TSDB_CODE_TDB_NO_AVAIL_DISK; + tsdbError("vgId:%d failed to compact FSET %d since %s", REPO_ID(pRepo), pSet->fid, tstrerror(terrno)); + tsdbCompactFSetEnd(pComph); + return -1; + } + + tsdbInitDFileSet(TSDB_COMPACT_WSET(pComph), did, REPO_ID(pRepo), TSDB_FSET_FID(pSet), + FS_TXN_VERSION(REPO_FS(pRepo))); + if (tsdbCreateDFileSet(TSDB_COMPACT_WSET(pComph), true) < 0) { + tsdbError("vgId:%d failed to compact FSET %d since %s", REPO_ID(pRepo), pSet->fid, tstrerror(terrno)); + tsdbCompactFSetEnd(pComph); + return -1; + } + + if (tsdbCompactFSetImpl(pComph) < 0) { + tsdbCloseDFileSet(TSDB_COMPACT_WSET(pComph)); + tsdbRemoveDFileSet(TSDB_COMPACT_WSET(pComph)); + tsdbCompactFSetEnd(pComph); + return -1; + } + + tsdbCloseDFileSet(TSDB_COMPACT_WSET(pComph)); + tsdbUpdateDFileSet(REPO_FS(pRepo), TSDB_COMPACT_WSET(pComph)); + tsdbDebug("vgId:%d FSET %d compact over", REPO_ID(pRepo), pSet->fid); + } + + tsdbCompactFSetEnd(pComph); + return 0; +} + +static bool tsdbShouldCompact(SCompactH *pComph) { + STsdbRepo * pRepo = TSDB_COMPACT_REPO(pComph); + STsdbCfg * pCfg = REPO_CFG(pRepo); + SReadH * pReadh = &(pComph->readh); + STableCompactH *pTh; + SBlock * pBlock; + int defaultRows = TSDB_DEFAULT_BLOCK_ROWS(pCfg->maxRowsPerFileBlock); + SDFile * pDataF = TSDB_READ_DATA_FILE(pReadh); + SDFile * pLastF = TSDB_READ_LAST_FILE(pReadh); + + int tblocks = 0; // total blocks + int nSubBlocks = 0; // # of blocks with sub-blocks + int nSmallBlocks = 0; // # of blocks with rows < defaultRows + int64_t tsize = 0; + + for (size_t i = 0; i < taosArrayGetSize(pComph->tbArray); i++) { + pTh = (STableCompactH *)taosArrayGet(pComph->tbArray, i); + + if (pTh->pTable == NULL || pTh->pBlkIdx == NULL) continue; + + for (size_t bidx = 0; bidx < pTh->pBlkIdx->numOfBlocks; bidx++) { + tblocks++; + pBlock = pTh->pInfo->blocks + bidx; + + if (pBlock->numOfRows < defaultRows) { + nSmallBlocks++; + } + + if (pBlock->numOfSubBlocks > 1) { + nSubBlocks++; + for (int k = 0; k < pBlock->numOfSubBlocks; k++) { + SBlock *iBlock = ((SBlock *)POINTER_SHIFT(pTh->pInfo, pBlock->offset)) + k; + tsize = tsize + iBlock->len; + } + } else if (pBlock->numOfSubBlocks == 1) { + tsize += pBlock->len; + } else { + ASSERT(0); + } + } + } + + return (((nSubBlocks * 1.0 / tblocks) > 0.33) || ((nSmallBlocks * 1.0 / tblocks) > 0.33) || + (tsize * 1.0 / (pDataF->info.size + pLastF->info.size - 2 * TSDB_FILE_HEAD_SIZE) < 0.85)); +} + +static int tsdbInitCompactH(SCompactH *pComph, STsdbRepo *pRepo) { + STsdbCfg *pCfg = REPO_CFG(pRepo); + + memset(pComph, 0, sizeof(*pComph)); + + TSDB_FSET_SET_CLOSED(TSDB_COMPACT_WSET(pComph)); + + tsdbGetRtnSnap(pRepo, &(pComph->rtn)); + tsdbFSIterInit(&(pComph->fsIter), REPO_FS(pRepo), TSDB_FS_ITER_FORWARD); + + if (tsdbInitReadH(&(pComph->readh), pRepo) < 0) { + return -1; + } + + if (tsdbInitCompTbArray(pComph) < 0) { + tsdbDestroyCompactH(pComph); + return -1; + } + + pComph->aBlkIdx = taosArrayInit(1024, sizeof(SBlockIdx)); + if (pComph->aBlkIdx == NULL) { + terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + tsdbDestroyCompactH(pComph); + return -1; + } + + pComph->aSupBlk = taosArrayInit(1024, sizeof(SBlock)); + if (pComph->aSupBlk == NULL) { + terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + tsdbDestroyCompactH(pComph); + return -1; + } + + pComph->pDataCols = tdNewDataCols(0, 0, pCfg->maxRowsPerFileBlock); + if (pComph->pDataCols == NULL) { + terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + tsdbDestroyCompactH(pComph); + return -1; + } + + return 0; +} + +static void tsdbDestroyCompactH(SCompactH *pComph) { + pComph->pDataCols = tdFreeDataCols(pComph->pDataCols); + pComph->aSupBlk = taosArrayDestroy(pComph->aSupBlk); + pComph->aBlkIdx = taosArrayDestroy(pComph->aBlkIdx); + tsdbDestroyCompTbArray(pComph); + tsdbDestroyReadH(&(pComph->readh)); + tsdbCloseDFileSet(TSDB_COMPACT_WSET(pComph)); +} + +static int tsdbInitCompTbArray(SCompactH *pComph) { // Init pComp->tbArray + STsdbRepo *pRepo = TSDB_COMPACT_REPO(pComph); + STsdbMeta *pMeta = pRepo->tsdbMeta; + + if (tsdbRLockRepoMeta(pRepo) < 0) return -1; + + pComph->tbArray = taosArrayInit(pMeta->maxTables, sizeof(STableCompactH)); + if (pComph->tbArray == NULL) { + terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + tsdbUnlockRepoMeta(pRepo); + return -1; + } + + // Note here must start from 0 + for (int i = 0; i < pMeta->maxTables; i++) { + STableCompactH ch = {0}; + if (pMeta->tables[i] != NULL) { + tsdbRefTable(pMeta->tables[i]); + ch.pTable = pMeta->tables[i]; + } + + if (taosArrayPush(pComph->tbArray, &ch) == NULL) { + terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + tsdbUnlockRepoMeta(pRepo); + return -1; + } + } + + if (tsdbUnlockRepoMeta(pRepo) < 0) return -1; + return 0; +} + +static void tsdbDestroyCompTbArray(SCompactH *pComph) { + STableCompactH *pTh; + + if (pComph->tbArray == NULL) return; + + for (size_t i = 0; i < taosArrayGetSize(pComph->tbArray); i++) { + pTh = (STableCompactH *)taosArrayGet(pComph->tbArray, i); + if (pTh->pTable) { + tsdbUnRefTable(pTh->pTable); + } + + pTh->pInfo = taosTZfree(pTh->pInfo); + } + + pComph->tbArray = taosArrayDestroy(pComph->tbArray); +} + +static int tsdbCacheFSetIndex(SCompactH *pComph) { + SReadH *pReadH = &(pComph->readh); + + if (tsdbLoadBlockIdx(pReadH) < 0) { + return -1; + } + + for (int tid = 1; tid < taosArrayGetSize(pComph->tbArray); tid++) { + STableCompactH *pTh = (STableCompactH *)taosArrayGet(pComph->tbArray, tid); + pTh->pBlkIdx = NULL; + + if (pTh->pTable == NULL) continue; + if (tsdbSetReadTable(pReadH, pTh->pTable) < 0) { + return -1; + } + + if (pReadH->pBlkIdx == NULL) continue; + pTh->bindex = *(pReadH->pBlkIdx); + pTh->pBlkIdx = &(pTh->bindex); + + if (tsdbMakeRoom((void **)(&(pTh->pInfo)), pTh->pBlkIdx->len) < 0) { + return -1; + } + + if (tsdbLoadBlockInfo(pReadH, (void *)(pTh->pInfo)) < 0) { + return -1; + } + } + + return 0; +} + +static int tsdbCompactFSetInit(SCompactH *pComph, SDFileSet *pSet) { + taosArrayClear(pComph->aBlkIdx); + taosArrayClear(pComph->aSupBlk); + + if (tsdbSetAndOpenReadFSet(&(pComph->readh), pSet) < 0) { + return -1; + } + + if (tsdbCacheFSetIndex(pComph) < 0) { + tsdbCloseAndUnsetFSet(&(pComph->readh)); + return -1; + } + + return 0; +} + +static void tsdbCompactFSetEnd(SCompactH *pComph) { tsdbCloseAndUnsetFSet(&(pComph->readh)); } + +static int tsdbCompactFSetImpl(SCompactH *pComph) { + STsdbRepo *pRepo = TSDB_COMPACT_REPO(pComph); + STsdbCfg * pCfg = REPO_CFG(pRepo); + SReadH * pReadh = &(pComph->readh); + SBlockIdx blkIdx; + void ** ppBuf = &(TSDB_COMPACT_BUF(pComph)); + void ** ppCBuf = &(TSDB_COMPACT_COMP_BUF(pComph)); + int defaultRows = TSDB_DEFAULT_BLOCK_ROWS(pCfg->maxRowsPerFileBlock); + + taosArrayClear(pComph->aBlkIdx); + + for (int tid = 1; tid < taosArrayGetSize(pComph->tbArray); tid++) { + STableCompactH *pTh = (STableCompactH *)taosArrayGet(pComph->tbArray, tid); + STSchema * pSchema; + + if (pTh->pTable == NULL || pTh->pBlkIdx == NULL) continue; + + pSchema = tsdbGetTableSchemaImpl(pTh->pTable, true, true, -1); + taosArrayClear(pComph->aSupBlk); + if ((tdInitDataCols(pComph->pDataCols, pSchema) < 0) || (tdInitDataCols(pReadh->pDCols[0], pSchema) < 0) || + (tdInitDataCols(pReadh->pDCols[1], pSchema) < 0)) { + terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + return -1; + } + tdFreeSchema(pSchema); + + // Loop to compact each block data + for (int i = 0; i < pTh->pBlkIdx->numOfBlocks; i++) { + SBlock *pBlock = pTh->pInfo->blocks + i; + + // Load the block data + if (tsdbLoadBlockData(pReadh, pBlock, pTh->pInfo) < 0) { + return -1; + } + + // Merge pComph->pDataCols and pReadh->pDCols[0] and write data to file + if (pComph->pDataCols->numOfRows == 0 && pBlock->numOfRows >= defaultRows) { + if (tsdbWriteBlockToRightFile(pComph, pTh->pTable, pReadh->pDCols[0], ppBuf, ppCBuf) < 0) { + return -1; + } + } else { + int ridx = 0; + + while (true) { + if (pReadh->pDCols[0]->numOfRows - ridx == 0) break; + int rowsToMerge = MIN(pReadh->pDCols[0]->numOfRows - ridx, defaultRows - pComph->pDataCols->numOfRows); + + tdMergeDataCols(pComph->pDataCols, pReadh->pDCols[0], rowsToMerge, &ridx); + + if (pComph->pDataCols->numOfRows < defaultRows) { + break; + } + + if (tsdbWriteBlockToRightFile(pComph, pTh->pTable, pComph->pDataCols, ppBuf, ppCBuf) < 0) { + return -1; + } + tdResetDataCols(pComph->pDataCols); + } + } + } + + if (pComph->pDataCols->numOfRows > 0 && + tsdbWriteBlockToRightFile(pComph, pTh->pTable, pComph->pDataCols, ppBuf, ppCBuf) < 0) { + return -1; + } + + if (tsdbWriteBlockInfoImpl(TSDB_COMPACT_HEAD_FILE(pComph), pTh->pTable, pComph->aSupBlk, NULL, ppBuf, &blkIdx) < + 0) { + return -1; + } + + if ((blkIdx.numOfBlocks > 0) && (taosArrayPush(pComph->aBlkIdx, (void *)(&blkIdx)) == NULL)) { + terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + return -1; + } + } + + if (tsdbWriteBlockIdx(TSDB_COMPACT_HEAD_FILE(pComph), pComph->aBlkIdx, ppBuf) < 0) { + return -1; + } + + return 0; +} + +static int tsdbWriteBlockToRightFile(SCompactH *pComph, STable *pTable, SDataCols *pDataCols, void **ppBuf, + void **ppCBuf) { + STsdbRepo *pRepo = TSDB_COMPACT_REPO(pComph); + STsdbCfg * pCfg = REPO_CFG(pRepo); + SDFile * pDFile; + bool isLast; + SBlock block; + + ASSERT(pDataCols->numOfRows > 0); + + if (pDataCols->numOfRows < pCfg->minRowsPerFileBlock) { + pDFile = TSDB_COMPACT_LAST_FILE(pComph); + isLast = true; + } else { + pDFile = TSDB_COMPACT_DATA_FILE(pComph); + isLast = false; + } + + if (tsdbWriteBlockImpl(pRepo, pTable, pDFile, pDataCols, &block, isLast, true, ppBuf, ppCBuf) < 0) { + return -1; + } + + if (taosArrayPush(pComph->aSupBlk, (void *)(&block)) == NULL) { + terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + return -1; + } + + return 0; +} #endif \ No newline at end of file diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index 85ed0821ac..0cbabb8909 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -195,6 +195,8 @@ STsdbRepoInfo *tsdbGetStatus(STsdbRepo *pRepo) { return NULL; } int tsdbGetState(STsdbRepo *repo) { return repo->state; } +bool tsdbInCompact(STsdbRepo *repo) { return repo->inCompact; } + void tsdbReportStat(void *repo, int64_t *totalPoints, int64_t *totalStorage, int64_t *compStorage) { ASSERT(repo != NULL); STsdbRepo *pRepo = repo; From 496f646aff50b642d53519c170b8df23bc9ede26 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Tue, 8 Jun 2021 13:06:46 +0800 Subject: [PATCH 45/72] fix bug --- src/client/src/tscParseInsert.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index f1dd8975dc..bba9db86c5 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -466,6 +466,10 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, SSqlCmd *pCmd, int1 int32_t cnt = 0; int32_t j = 0; + if (sToken.n >= TSDB_MAX_BYTES_PER_ROW) { + return tscSQLSyntaxErrMsg(pCmd->payload, "too long string", sToken.z); + } + for (uint32_t k = 1; k < sToken.n - 1; ++k) { if (sToken.z[k] == '\\' || (sToken.z[k] == delim && sToken.z[k + 1] == delim)) { tmpTokenBuf[j] = sToken.z[k + 1]; @@ -705,7 +709,7 @@ static int32_t doParseInsertStatement(SSqlCmd* pCmd, char **str, STableDataBlock } code = TSDB_CODE_TSC_INVALID_SQL; - char tmpTokenBuf[16*1024] = {0}; // used for deleting Escape character: \\, \', \" + char tmpTokenBuf[TSDB_MAX_BYTES_PER_ROW] = {0}; // used for deleting Escape character: \\, \', \" int32_t numOfRows = 0; code = tsParseValues(str, dataBuf, maxNumOfRows, pCmd, &numOfRows, tmpTokenBuf); From c43a02a6f0e6e4383e3cf90d4ca98e971aa86c71 Mon Sep 17 00:00:00 2001 From: Elias Soong Date: Tue, 8 Jun 2021 13:19:38 +0800 Subject: [PATCH 46/72] [TD-4500] : limit the length of FQDN parameter. --- documentation20/cn/03.architecture/docs.md | 2 +- documentation20/cn/11.administrator/docs.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation20/cn/03.architecture/docs.md b/documentation20/cn/03.architecture/docs.md index 2668967102..d22855198a 100644 --- a/documentation20/cn/03.architecture/docs.md +++ b/documentation20/cn/03.architecture/docs.md @@ -176,7 +176,7 @@ TDengine 分布式架构的逻辑结构图如下: **通讯方式:**TDengine系统的各个数据节点之间,以及应用驱动与各数据节点之间的通讯是通过TCP/UDP进行的。因为考虑到物联网场景,数据写入的包一般不大,因此TDengine 除采用TCP做传输之外,还采用UDP方式,因为UDP 更加高效,而且不受连接数的限制。TDengine实现了自己的超时、重传、确认等机制,以确保UDP的可靠传输。对于数据量不到15K的数据包,采取UDP的方式进行传输,超过15K的,或者是查询类的操作,自动采取TCP的方式进行传输。同时,TDengine根据配置和数据包,会自动对数据进行压缩/解压缩,数字签名/认证等处理。对于数据节点之间的数据复制,只采用TCP方式进行数据传输。 -**FQDN配置**:一个数据节点有一个或多个FQDN,可以在系统配置文件taos.cfg通过参数“fqdn"进行指定,如果没有指定,系统将自动获取计算机的hostname作为其FQDN。如果节点没有配置FQDN,可以直接将该节点的配置参数fqdn设置为它的IP地址。但不建议使用IP,因为IP地址可变,一旦变化,将让集群无法正常工作。一个数据节点的EP(End Point)由FQDN + Port组成。采用FQDN,需要保证DNS服务正常工作,或者在节点以及应用所在的节点配置好hosts文件。 +**FQDN配置**:一个数据节点有一个或多个FQDN,可以在系统配置文件taos.cfg通过参数“fqdn"进行指定,如果没有指定,系统将自动获取计算机的hostname作为其FQDN。如果节点没有配置FQDN,可以直接将该节点的配置参数fqdn设置为它的IP地址。但不建议使用IP,因为IP地址可变,一旦变化,将让集群无法正常工作。一个数据节点的EP(End Point)由FQDN + Port组成。采用FQDN,需要保证DNS服务正常工作,或者在节点以及应用所在的节点配置好hosts文件。另外,这个参数值的长度需要控制在 96 个字符以内。 **端口配置:**一个数据节点对外的端口由TDengine的系统配置参数serverPort决定,对集群内部通讯的端口是serverPort+5。集群内数据节点之间的数据复制操作还占有一个TCP端口,是serverPort+10. 为支持多线程高效的处理UDP数据,每个对内和对外的UDP连接,都需要占用5个连续的端口。因此一个数据节点总的端口范围为serverPort到serverPort + 10,总共11个TCP/UDP端口。(另外还可能有 RESTful、Arbitrator 所使用的端口,那样的话就一共是 13 个。)使用时,需要确保防火墙将这些端口打开,以备使用。每个数据节点可以配置不同的serverPort。(详细的端口情况请参见 [TDengine 2.0 端口说明](https://www.taosdata.com/cn/documentation/faq#port)) diff --git a/documentation20/cn/11.administrator/docs.md b/documentation20/cn/11.administrator/docs.md index bfa0456c7d..f7a5bffe0c 100644 --- a/documentation20/cn/11.administrator/docs.md +++ b/documentation20/cn/11.administrator/docs.md @@ -99,7 +99,7 @@ taosd -C 下面仅仅列出一些重要的配置参数,更多的参数请看配置文件里的说明。各个参数的详细介绍及作用请看前述章节,而且这些参数的缺省配置都是工作的,一般无需设置。**注意:配置修改后,需要重启*taosd*服务才能生效。** - firstEp: taosd启动时,主动连接的集群中首个dnode的end point, 默认值为localhost:6030。 -- fqdn:数据节点的FQDN,缺省为操作系统配置的第一个hostname。如果习惯IP地址访问,可设置为该节点的IP地址。 +- fqdn:数据节点的FQDN,缺省为操作系统配置的第一个hostname。如果习惯IP地址访问,可设置为该节点的IP地址。这个参数值的长度需要控制在 96 个字符以内。 - serverPort:taosd启动后,对外服务的端口号,默认值为6030。(RESTful服务使用的端口号是在此基础上+11,即默认值为6041。) - dataDir: 数据文件目录,所有的数据文件都将写入该目录。默认值:/var/lib/taos。 - logDir:日志文件目录,客户端和服务器的运行日志文件将写入该目录。默认值:/var/log/taos。 From 5ff935c509671a8f33245b8c43332ba9a441855f Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Tue, 8 Jun 2021 14:31:09 +0800 Subject: [PATCH 47/72] Fix test failure --- tests/pytest/query/subqueryFilter.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/pytest/query/subqueryFilter.py b/tests/pytest/query/subqueryFilter.py index ca0c748408..5dca08b458 100644 --- a/tests/pytest/query/subqueryFilter.py +++ b/tests/pytest/query/subqueryFilter.py @@ -69,16 +69,16 @@ class TDTestCase: tdSql.checkData(0, 0, 1) tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val >= 20") - tdSql.checkRows(2) + tdSql.checkData(0, 0, 2) tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val < 20") - tdSql.checkRows(63) + tdSql.checkData(0, 0, 63) tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val <= 20") - tdSql.checkRows(64) + tdSql.checkData(0, 0, 64) tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val = 20") - tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val > 20") tdSql.checkData(0, 0, 1) From 99c9ebb99becc47b4417dc728da517847a8c8a7c Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Tue, 8 Jun 2021 14:46:25 +0800 Subject: [PATCH 48/72] fix bug --- src/plugins/monitor/src/monMain.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/monitor/src/monMain.c b/src/plugins/monitor/src/monMain.c index d9f7d81ebd..2c4a0c1a4c 100644 --- a/src/plugins/monitor/src/monMain.c +++ b/src/plugins/monitor/src/monMain.c @@ -184,11 +184,17 @@ static void *monThreadFunc(void *param) { static void monBuildMonitorSql(char *sql, int32_t cmd) { memset(sql, 0, SQL_LENGTH); +#ifdef _STORAGE + char *keepValue = "30,30,30"; +#else + char *keepValue = "30"; +#endif + if (cmd == MON_CMD_CREATE_DB) { snprintf(sql, SQL_LENGTH, - "create database if not exists %s replica 1 days 10 keep 30 cache %d " + "create database if not exists %s replica 1 days 10 keep %s cache %d " "blocks %d precision 'us'", - tsMonitorDbName, TSDB_MIN_CACHE_BLOCK_SIZE, TSDB_MIN_TOTAL_BLOCKS); + tsMonitorDbName, keepValue, TSDB_MIN_CACHE_BLOCK_SIZE, TSDB_MIN_TOTAL_BLOCKS); } else if (cmd == MON_CMD_CREATE_MT_DN) { snprintf(sql, SQL_LENGTH, "create table if not exists %s.dn(ts timestamp" From a87f83bff081b964d0cb89a88dca9e0f95b727ac Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Tue, 8 Jun 2021 15:34:36 +0800 Subject: [PATCH 49/72] [TD-4521] --- src/os/src/detail/osString.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/os/src/detail/osString.c b/src/os/src/detail/osString.c index 2c49797d83..fdc70b667e 100644 --- a/src/os/src/detail/osString.c +++ b/src/os/src/detail/osString.c @@ -59,6 +59,9 @@ bool taosMbsToUcs4(char *mbs, size_t mbsLength, char *ucs4, int32_t ucs4_max_len iconv_close(cd); if (len != NULL) { *len = (int32_t)(ucs4_max_len - outLeft); + if (*len < 0) { + return false; + } } return true; From 041b1e187f17b5ba94986e89bf474670e0de4c46 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Tue, 8 Jun 2021 15:40:19 +0800 Subject: [PATCH 50/72] modify error msg --- src/client/src/tscSQLParser.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index c26d16c9e2..37f51a856e 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -1991,6 +1991,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col const char* msg7 = "normal table can not apply this function"; const char* msg8 = "multi-columns selection does not support alias column name"; const char* msg9 = "diff can no be applied to unsigned numeric type"; + const char* msg10 = "parameter is out of range [1, 100]"; switch (functionId) { case TSDB_FUNC_COUNT: { @@ -2378,7 +2379,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col int64_t nTop = GET_INT32_VAL(val); if (nTop <= 0 || nTop > 100) { // todo use macro - return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg5); + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg10); } // todo REFACTOR From 7fd970d7e43533664280fc8b4c22b75dacb2c1e8 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 8 Jun 2021 15:48:12 +0800 Subject: [PATCH 51/72] [td-4612]: check invalid query in outer query. [td-4611]: fix bug during aggregate in outer query. [td-255]fix memory leaks and suppress warning by valgrind. --- src/client/src/tscSQLParser.c | 46 +- src/client/src/tscServer.c | 2 +- src/client/src/tscUtil.c | 10 +- src/query/inc/sql.y | 6 +- src/query/src/qExecutor.c | 13 +- src/query/src/sql.c | 2226 ++++++++++++++------------------- 6 files changed, 989 insertions(+), 1314 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 5f0551b109..75741e8820 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -122,7 +122,7 @@ static int32_t getColumnIndexByName(SSqlCmd* pCmd, const SStrToken* pToken, SQue static int32_t getTableIndexByName(SStrToken* pToken, SQueryInfo* pQueryInfo, SColumnIndex* pIndex); static int32_t getTableIndexImpl(SStrToken* pTableToken, SQueryInfo* pQueryInfo, SColumnIndex* pIndex); -static int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo); +static int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, char* msg); static int32_t doLocalQueryProcess(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlNode); static int32_t tscCheckCreateDbParams(SSqlCmd* pCmd, SCreateDbMsg* pCreate); @@ -2159,6 +2159,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col const char* msg8 = "multi-columns selection does not support alias column name"; const char* msg9 = "diff/derivative can no be applied to unsigned numeric type"; const char* msg10 = "derivative duration should be greater than 1 Second"; + const char* msg11 = "third parameter in derivative should be 0 or 1"; switch (functionId) { case TSDB_FUNC_COUNT: { @@ -2310,7 +2311,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6); } - SExprInfo* pExpr = tscExprAppend(pQueryInfo, functionId, &index, resultType, resultSize, getNewResColId(pCmd), resultSize, false); + SExprInfo* pExpr = tscExprAppend(pQueryInfo, functionId, &index, resultType, resultSize, getNewResColId(pCmd), intermediateResSize, false); if (functionId == TSDB_FUNC_LEASTSQR) { // set the leastsquares parameters char val[8] = {0}; @@ -2354,8 +2355,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col int64_t v = *(int64_t*) val; if (v != 0 && v != 1) { - const char* msg10 = "third parameter in derivative should be 0 or 1"; - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg10); + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg11); } tscExprAddParams(&pExpr->base, val, TSDB_DATA_TYPE_BIGINT, LONG_BYTES); @@ -6278,7 +6278,7 @@ static void updateTagPrjFunction(SQueryInfo* pQueryInfo) { * 2. if selectivity function and tagprj function both exist, there should be only * one selectivity function exists. */ -static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, SSqlCmd* pCmd) { +static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, char* msg) { const char* msg1 = "only one selectivity function allowed in presence of tags function"; const char* msg3 = "aggregation function should not be mixed up with projection"; @@ -6316,7 +6316,7 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, SSqlCmd* pCmd) // When the tag projection function on tag column that is not in the group by clause, aggregation function and // selectivity function exist in select clause is not allowed. if (numOfAggregation > 0) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); + return invalidOperationMsg(msg, msg1); } /* @@ -6345,7 +6345,7 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, SSqlCmd* pCmd) (functionId == TSDB_FUNC_LAST_DST && (pExpr->base.colInfo.flag & TSDB_COL_NULL) != 0)) { // do nothing } else { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); + return invalidOperationMsg(msg, msg1); } } @@ -6358,7 +6358,7 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, SSqlCmd* pCmd) } else { if ((pQueryInfo->type & TSDB_QUERY_TYPE_PROJECTION_QUERY) != 0) { if (numOfAggregation > 0 && pQueryInfo->groupbyExpr.numOfGroupCols == 0) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); + return invalidOperationMsg(msg, msg3); } if (numOfAggregation > 0 || numOfSelectivity > 0) { @@ -6468,7 +6468,7 @@ static int32_t doTagFunctionCheck(SQueryInfo* pQueryInfo) { return (tableCounting && tagProjection)? -1:0; } -int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) { +int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, char* msg) { const char* msg1 = "functions/columns not allowed in group by query"; const char* msg2 = "projection query on columns not allowed"; const char* msg3 = "group by/session/state_window not allowed on projection query"; @@ -6478,17 +6478,17 @@ int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) { // only retrieve tags, group by is not supportted if (tscQueryTags(pQueryInfo)) { if (doTagFunctionCheck(pQueryInfo) != TSDB_CODE_SUCCESS) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg5); + return invalidOperationMsg(msg, msg5); } if (pQueryInfo->groupbyExpr.numOfGroupCols > 0 || isTimeWindowQuery(pQueryInfo)) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); + return invalidOperationMsg(msg, msg4); } else { return TSDB_CODE_SUCCESS; } } if (tscIsProjectionQuery(pQueryInfo) && tscIsSessionWindowQuery(pQueryInfo)) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); + return invalidOperationMsg(msg, msg3); } if (pQueryInfo->groupbyExpr.numOfGroupCols > 0) { @@ -6496,6 +6496,7 @@ int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) { if (onlyTagPrjFunction(pQueryInfo) && allTagPrjInGroupby(pQueryInfo)) { // It is a groupby aggregate query, the tag project function is not suitable for this case. updateTagPrjFunction(pQueryInfo); + return doAddGroupbyColumnsOnDemand(pCmd, pQueryInfo); } @@ -6520,21 +6521,21 @@ int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) { } if (!qualified) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); + return invalidOperationMsg(msg, msg2); } } if (IS_MULTIOUTPUT(aAggs[functId].status) && functId != TSDB_FUNC_TOP && functId != TSDB_FUNC_BOTTOM && functId != TSDB_FUNC_DIFF && functId != TSDB_FUNC_TAGPRJ && functId != TSDB_FUNC_PRJ) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); + return invalidOperationMsg(msg, msg1); } if (functId == TSDB_FUNC_COUNT && pExpr->base.colInfo.colIndex == TSDB_TBNAME_COLUMN_INDEX) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); + return invalidOperationMsg(msg, msg1); } } - if (checkUpdateTagPrjFunctions(pQueryInfo, pCmd) != TSDB_CODE_SUCCESS) { + if (checkUpdateTagPrjFunctions(pQueryInfo, msg) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_OPERATION; } @@ -6544,12 +6545,12 @@ int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) { // projection query on super table does not compatible with "group by" syntax if (tscIsProjectionQuery(pQueryInfo)) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); + return invalidOperationMsg(msg, msg3); } return TSDB_CODE_SUCCESS; } else { - return checkUpdateTagPrjFunctions(pQueryInfo, pCmd); + return checkUpdateTagPrjFunctions(pQueryInfo, msg); } } int32_t doLocalQueryProcess(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlNode) { @@ -7816,10 +7817,13 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf // set order by info STableMeta* pTableMeta = tscGetMetaInfo(pQueryInfo, 0)->pTableMeta; - if (validateOrderbyNode(pCmd, pQueryInfo, pSqlNode, tscGetTableSchema(pTableMeta)) != - TSDB_CODE_SUCCESS) { + if (validateOrderbyNode(pCmd, pQueryInfo, pSqlNode, tscGetTableSchema(pTableMeta)) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_OPERATION; } + + if ((code = doFunctionsCompatibleCheck(pCmd, pQueryInfo, tscGetErrorMsgPayload(pCmd))) != TSDB_CODE_SUCCESS) { + return code; + } } else { pQueryInfo->command = TSDB_SQL_SELECT; @@ -7948,7 +7952,7 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf return code; } - if ((code = doFunctionsCompatibleCheck(pCmd, pQueryInfo)) != TSDB_CODE_SUCCESS) { + if ((code = doFunctionsCompatibleCheck(pCmd, pQueryInfo,tscGetErrorMsgPayload(pCmd))) != TSDB_CODE_SUCCESS) { return code; } diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 880c58aa1c..b4c7a64fd0 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -912,7 +912,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { } SGroupbyExpr *pGroupbyExpr = query.pGroupbyExpr; - if (pGroupbyExpr->numOfGroupCols > 0) { + if (pGroupbyExpr != NULL && pGroupbyExpr->numOfGroupCols > 0) { pQueryMsg->orderByIdx = htons(pGroupbyExpr->orderIndex); pQueryMsg->orderType = htons(pGroupbyExpr->orderType); diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 280d2aa630..60919c98b5 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -962,6 +962,9 @@ static void destroyDummyInputOperator(void* param, int32_t numOfOutput) { pInfo->block = destroyOutputBuf(pInfo->block); pInfo->pSql = NULL; + + cleanupResultRowInfo(&pInfo->pTableQueryInfo->resInfo); + tfree(pInfo->pTableQueryInfo); } // todo this operator servers as the adapter for Operator tree and SqlRes result, remove it later @@ -4263,10 +4266,9 @@ int32_t tscCreateQueryFromQueryInfo(SQueryInfo* pQueryInfo, SQueryAttr* pQueryAt STableMetaInfo* pTableMetaInfo = pQueryInfo->pTableMetaInfo[0]; - pQueryAttr->pGroupbyExpr = calloc(1, sizeof(SGroupbyExpr)); - *(pQueryAttr->pGroupbyExpr) = pQueryInfo->groupbyExpr; - if (pQueryInfo->groupbyExpr.numOfGroupCols > 0) { + pQueryAttr->pGroupbyExpr = calloc(1, sizeof(SGroupbyExpr)); + *(pQueryAttr->pGroupbyExpr) = pQueryInfo->groupbyExpr; pQueryAttr->pGroupbyExpr->columnInfo = taosArrayDup(pQueryInfo->groupbyExpr.columnInfo); } else { assert(pQueryInfo->groupbyExpr.columnInfo == NULL); @@ -4345,7 +4347,7 @@ int32_t tscCreateQueryFromQueryInfo(SQueryInfo* pQueryInfo, SQueryAttr* pQueryAt return TSDB_CODE_TSC_INVALID_OPERATION; } - if (pQueryAttr->pGroupbyExpr->numOfGroupCols < 0) { + if (pQueryAttr->pGroupbyExpr != NULL && pQueryAttr->pGroupbyExpr->numOfGroupCols < 0) { tscError("%p illegal value of numOfGroupCols in query msg: %d", addr, pQueryInfo->groupbyExpr.numOfGroupCols); return TSDB_CODE_TSC_INVALID_OPERATION; } diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index 01eaf3bbb6..c7be2f3c4f 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -559,10 +559,8 @@ session_option(X) ::= SESSION LP ids(V) cpxName(Z) COMMA tmvar(Y) RP. { X.gap = Y; } %type windowstate_option {SWindowStateVal} -windowstate_option(X) ::= . {X.col.n = 0;} -windowstate_option(X) ::= STATE_WINDOW LP ids(V) RP. { - X.col = V; -} +windowstate_option(X) ::= . { X.col.n = 0; X.col.z = NULL;} +windowstate_option(X) ::= STATE_WINDOW LP ids(V) RP. { X.col = V; } %type fill_opt {SArray*} %destructor fill_opt {taosArrayDestroy($$);} diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index fca328d8f9..5a0eecb549 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -735,6 +735,7 @@ static void doApplyFunctions(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx if (pCtx[k].preAggVals.isSet && forwardStep < numOfTotal) { pCtx[k].preAggVals.isSet = false; } + if (functionNeedToExecute(pRuntimeEnv, &pCtx[k], functionId)) { aAggs[functionId].xFunction(&pCtx[k]); } @@ -918,7 +919,7 @@ void setInputDataBlock(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx, SSDataBlo doSetInputDataBlockInfo(pOperator, pCtx, pBlock, order); } } else { - if (pCtx[0].pInput == NULL && pBlock->pDataBlock != NULL) { + if (/*pCtx[0].pInput == NULL && */pBlock->pDataBlock != NULL) { doSetInputDataBlock(pOperator, pCtx, pBlock, order); } else { doSetInputDataBlockInfo(pOperator, pCtx, pBlock, order); @@ -1169,7 +1170,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul SQueryRuntimeEnv* pRuntimeEnv = pOperatorInfo->pRuntimeEnv; int32_t numOfOutput = pOperatorInfo->numOfOutput; - SQueryAttr* pQueryAttr = pRuntimeEnv->pQueryAttr; + SQueryAttr* pQueryAttr = pRuntimeEnv->pQueryAttr; int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQueryAttr->order.order); bool ascQuery = QUERY_IS_ASC_QUERY(pQueryAttr); @@ -3094,7 +3095,7 @@ int32_t initResultRow(SResultRow *pResultRow) { * +------------+-----------------result column 1-----------+-----------------result column 2-----------+ * + SResultRow | SResultRowCellInfo | intermediate buffer1 | SResultRowCellInfo | intermediate buffer 2| * +------------+-------------------------------------------+-------------------------------------------+ - * offset[0] offset[1] + * offset[0] offset[1] offset[2] */ void setDefaultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SOptrBasicInfo *pInfo, int64_t uid, int32_t stage) { SQLFunctionCtx* pCtx = pInfo->pCtx; @@ -3323,7 +3324,7 @@ void setResultRowOutputBufInitCtx(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pRe offset += pCtx[i].outputBytes; int32_t functionId = pCtx[i].functionId; - if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM || functionId == TSDB_FUNC_DIFF) { + if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM || functionId == TSDB_FUNC_DIFF || functionId == TSDB_FUNC_DERIVATIVE) { pCtx[i].ptsOutputBuf = pCtx[0].pOutput; } @@ -3381,7 +3382,7 @@ void setResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pResult, SQLF offset += pCtx[i].outputBytes; int32_t functionId = pCtx[i].functionId; - if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM || functionId == TSDB_FUNC_DIFF) { + if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM || functionId == TSDB_FUNC_DIFF || functionId == TSDB_FUNC_DERIVATIVE) { pCtx[i].ptsOutputBuf = pCtx[0].pOutput; } @@ -3589,6 +3590,8 @@ static int32_t doCopyToSDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SGroupResInfo* int32_t step = -1; qDebug("QInfo:0x%"PRIx64" start to copy data from windowResInfo to output buf", GET_QID(pRuntimeEnv)); + assert(orderType == TSDB_ORDER_ASC || orderType == TSDB_ORDER_DESC); + if (orderType == TSDB_ORDER_ASC) { start = pGroupResInfo->index; step = 1; diff --git a/src/query/src/sql.c b/src/query/src/sql.c index 0d11153e8e..ac6508e45c 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -23,7 +23,6 @@ ** input grammar file: */ #include -#include /************ Begin %include sections from the grammar ************************/ #include @@ -77,10 +76,8 @@ ** zero the stack is dynamically sized using realloc() ** ParseARG_SDECL A static variable declaration for the %extra_argument ** ParseARG_PDECL A parameter declaration for the %extra_argument -** ParseARG_PARAM Code to pass %extra_argument as a subroutine parameter ** ParseARG_STORE Code to store %extra_argument into yypParser ** ParseARG_FETCH Code to extract %extra_argument from yypParser -** ParseCTX_* As ParseARG_ except for %extra_context ** YYERRORSYMBOL is the code number of the error symbol. If not ** defined, then do no error processing. ** YYNSTATE the combined number of states. @@ -100,46 +97,39 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 266 +#define YYNOCODE 268 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SStrToken typedef union { int yyinit; ParseTOKENTYPE yy0; - TAOS_FIELD yy27; - SWindowStateVal yy76; - SCreateDbInfo yy114; - SSqlNode* yy124; - SCreateAcctInfo yy183; - SCreatedTableInfo yy192; - SArray* yy193; - SCreateTableSql* yy270; - int yy312; - SRelationInfo* yy332; - SIntervalVal yy392; - tVariant yy442; - SSessionWindowVal yy447; - tSqlExpr* yy454; - int64_t yy473; - SLimitVal yy482; + SArray* yy15; + SWindowStateVal yy96; + SSqlNode* yy134; + SLimitVal yy150; + SSessionWindowVal yy151; + SRelationInfo* yy160; + int yy250; + tSqlExpr* yy328; + tVariant yy380; + SCreatedTableInfo yy390; + SCreateAcctInfo yy397; + SCreateDbInfo yy454; + SCreateTableSql* yy482; + int64_t yy489; + SIntervalVal yy496; + TAOS_FIELD yy505; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 #endif #define ParseARG_SDECL SSqlInfo* pInfo; #define ParseARG_PDECL ,SSqlInfo* pInfo -#define ParseARG_PARAM ,pInfo -#define ParseARG_FETCH SSqlInfo* pInfo=yypParser->pInfo; -#define ParseARG_STORE yypParser->pInfo=pInfo; -#define ParseCTX_SDECL -#define ParseCTX_PDECL -#define ParseCTX_PARAM -#define ParseCTX_FETCH -#define ParseCTX_STORE +#define ParseARG_FETCH SSqlInfo* pInfo = yypParser->pInfo +#define ParseARG_STORE yypParser->pInfo = pInfo #define YYFALLBACK 1 #define YYNSTATE 341 #define YYNRULE 280 -#define YYNRULE_WITH_ACTION 280 #define YYNTOKEN 189 #define YY_MAX_SHIFT 340 #define YY_MIN_SHIFTREDUCE 538 @@ -150,7 +140,6 @@ typedef union { #define YY_MIN_REDUCE 821 #define YY_MAX_REDUCE 1100 /************* End control #defines *******************************************/ -#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) /* Define the yytestcase() macro to be a no-op if is not already defined ** otherwise. @@ -215,11 +204,11 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (722) +#define YY_ACTTAB_COUNT (721) static const YYACTIONTYPE yy_action[] = { /* 0 */ 989, 586, 217, 338, 954, 22, 223, 192, 194, 587, /* 10 */ 819, 340, 198, 52, 53, 151, 56, 57, 226, 1077, - /* 20 */ 229, 46, 283, 55, 282, 60, 58, 62, 59, 1073, + /* 20 */ 229, 46, 1073, 55, 282, 60, 58, 62, 59, 1072, /* 30 */ 665, 194, 968, 51, 50, 194, 234, 49, 48, 47, /* 40 */ 52, 53, 1076, 56, 57, 225, 1077, 229, 46, 586, /* 50 */ 55, 282, 60, 58, 62, 59, 980, 587, 314, 313, @@ -228,162 +217,161 @@ static const YYACTIONTYPE yy_action[] = { /* 80 */ 62, 59, 279, 298, 87, 867, 51, 50, 94, 178, /* 90 */ 49, 48, 47, 539, 540, 541, 542, 543, 544, 545, /* 100 */ 546, 547, 548, 549, 550, 551, 339, 953, 298, 218, - /* 110 */ 76, 586, 964, 52, 53, 35, 56, 57, 775, 587, + /* 110 */ 76, 586, 964, 52, 53, 35, 56, 57, 324, 587, /* 120 */ 229, 46, 956, 55, 282, 60, 58, 62, 59, 49, /* 130 */ 48, 47, 756, 51, 50, 265, 264, 49, 48, 47, - /* 140 */ 52, 54, 980, 56, 57, 324, 980, 229, 46, 586, + /* 140 */ 52, 54, 980, 56, 57, 1071, 980, 229, 46, 586, /* 150 */ 55, 282, 60, 58, 62, 59, 219, 587, 220, 965, - /* 160 */ 51, 50, 221, 1072, 49, 48, 47, 28, 296, 333, + /* 160 */ 51, 50, 221, 212, 49, 48, 47, 28, 296, 333, /* 170 */ 332, 295, 294, 293, 331, 292, 330, 329, 328, 291, /* 180 */ 327, 326, 928, 35, 916, 917, 918, 919, 920, 921, /* 190 */ 922, 923, 924, 925, 926, 927, 929, 930, 56, 57, - /* 200 */ 876, 1071, 229, 46, 178, 55, 282, 60, 58, 62, - /* 210 */ 59, 962, 23, 91, 29, 51, 50, 1, 166, 49, - /* 220 */ 48, 47, 228, 771, 232, 79, 760, 965, 763, 203, - /* 230 */ 766, 228, 771, 261, 13, 760, 204, 763, 93, 766, + /* 200 */ 151, 213, 229, 46, 151, 55, 282, 60, 58, 62, + /* 210 */ 59, 962, 23, 91, 29, 51, 50, 243, 196, 49, + /* 220 */ 48, 47, 228, 771, 232, 197, 760, 965, 763, 203, + /* 230 */ 766, 228, 771, 151, 13, 760, 204, 763, 93, 766, /* 240 */ 90, 128, 127, 202, 951, 952, 34, 955, 60, 58, - /* 250 */ 62, 59, 89, 235, 214, 215, 51, 50, 281, 151, - /* 260 */ 49, 48, 47, 214, 215, 762, 77, 765, 28, 1096, - /* 270 */ 333, 332, 82, 35, 35, 331, 701, 330, 329, 328, - /* 280 */ 41, 327, 326, 8, 936, 51, 50, 934, 935, 49, - /* 290 */ 48, 47, 937, 868, 939, 940, 938, 178, 941, 942, - /* 300 */ 113, 107, 118, 257, 239, 74, 704, 117, 123, 126, - /* 310 */ 116, 242, 211, 35, 233, 303, 120, 965, 965, 689, - /* 320 */ 212, 761, 686, 764, 687, 61, 688, 213, 1026, 35, - /* 330 */ 277, 35, 772, 1036, 61, 5, 38, 168, 768, 151, - /* 340 */ 196, 772, 167, 101, 96, 100, 35, 768, 35, 151, - /* 350 */ 245, 246, 35, 35, 304, 767, 236, 965, 186, 184, - /* 360 */ 182, 142, 140, 139, 767, 181, 131, 130, 129, 334, - /* 370 */ 305, 243, 306, 965, 240, 965, 238, 769, 302, 301, - /* 380 */ 82, 244, 968, 241, 708, 309, 308, 310, 41, 311, - /* 390 */ 965, 250, 965, 312, 316, 968, 965, 965, 3, 179, - /* 400 */ 254, 253, 337, 336, 136, 115, 966, 80, 1025, 259, - /* 410 */ 324, 737, 738, 36, 758, 261, 720, 728, 88, 729, - /* 420 */ 146, 66, 227, 25, 67, 792, 197, 773, 690, 24, - /* 430 */ 675, 24, 70, 770, 36, 285, 677, 287, 676, 36, - /* 440 */ 66, 92, 66, 33, 125, 124, 288, 68, 199, 15, - /* 450 */ 759, 14, 106, 71, 105, 193, 200, 17, 19, 16, - /* 460 */ 18, 201, 73, 112, 664, 111, 6, 207, 693, 691, - /* 470 */ 694, 692, 208, 206, 21, 1035, 20, 1088, 191, 205, - /* 480 */ 195, 967, 230, 255, 1032, 1031, 231, 315, 44, 143, - /* 490 */ 988, 1018, 999, 996, 1017, 997, 981, 262, 1001, 145, - /* 500 */ 149, 271, 162, 963, 141, 114, 266, 222, 719, 268, - /* 510 */ 158, 275, 154, 163, 978, 152, 155, 276, 961, 164, - /* 520 */ 165, 280, 153, 72, 156, 63, 879, 69, 290, 278, - /* 530 */ 42, 274, 189, 39, 299, 875, 300, 1095, 103, 1094, - /* 540 */ 1091, 169, 307, 1087, 109, 1086, 1083, 170, 897, 40, - /* 550 */ 272, 37, 43, 190, 270, 864, 119, 862, 121, 122, - /* 560 */ 267, 860, 859, 247, 180, 857, 856, 855, 854, 853, - /* 570 */ 852, 183, 185, 849, 847, 845, 843, 187, 840, 188, - /* 580 */ 45, 260, 78, 83, 325, 269, 1019, 317, 318, 319, - /* 590 */ 320, 321, 322, 323, 335, 817, 248, 216, 237, 289, - /* 600 */ 249, 816, 251, 252, 209, 210, 97, 98, 815, 798, - /* 610 */ 797, 256, 261, 263, 858, 696, 284, 9, 132, 851, - /* 620 */ 173, 133, 172, 898, 171, 174, 175, 177, 176, 4, - /* 630 */ 134, 850, 842, 932, 135, 30, 841, 81, 84, 721, - /* 640 */ 2, 161, 159, 157, 160, 147, 944, 724, 148, 85, - /* 650 */ 224, 726, 86, 273, 10, 730, 150, 11, 776, 774, - /* 660 */ 31, 7, 32, 12, 26, 286, 27, 95, 628, 93, - /* 670 */ 624, 622, 621, 620, 617, 297, 99, 590, 64, 36, - /* 680 */ 65, 102, 667, 666, 104, 108, 663, 612, 610, 602, - /* 690 */ 608, 604, 606, 600, 598, 631, 110, 630, 629, 627, - /* 700 */ 626, 625, 623, 619, 618, 588, 555, 553, 66, 821, - /* 710 */ 820, 820, 137, 820, 820, 820, 820, 820, 820, 820, - /* 720 */ 820, 138, + /* 250 */ 62, 59, 966, 235, 214, 215, 51, 50, 281, 1096, + /* 260 */ 49, 48, 47, 214, 215, 337, 336, 136, 28, 1025, + /* 270 */ 333, 332, 82, 88, 250, 331, 704, 330, 329, 328, + /* 280 */ 41, 327, 326, 254, 253, 936, 35, 199, 934, 935, + /* 290 */ 142, 140, 139, 937, 876, 939, 940, 938, 178, 941, + /* 300 */ 942, 82, 1026, 257, 277, 74, 113, 107, 118, 41, + /* 310 */ 236, 334, 211, 117, 123, 126, 116, 239, 762, 193, + /* 320 */ 765, 35, 120, 242, 761, 61, 764, 233, 689, 1088, + /* 330 */ 965, 686, 772, 687, 61, 688, 968, 968, 768, 200, + /* 340 */ 115, 772, 5, 38, 168, 324, 283, 768, 79, 167, + /* 350 */ 101, 96, 100, 868, 708, 767, 261, 178, 35, 245, + /* 360 */ 246, 201, 303, 35, 767, 965, 186, 184, 182, 35, + /* 370 */ 35, 35, 89, 181, 131, 130, 129, 51, 50, 35, + /* 380 */ 35, 49, 48, 47, 1, 166, 77, 240, 967, 238, + /* 390 */ 259, 302, 301, 244, 36, 241, 701, 309, 308, 304, + /* 400 */ 3, 179, 965, 8, 305, 758, 227, 965, 737, 738, + /* 410 */ 306, 310, 311, 965, 965, 965, 67, 80, 207, 70, + /* 420 */ 312, 316, 720, 965, 965, 261, 146, 728, 729, 792, + /* 430 */ 769, 66, 25, 24, 773, 1036, 770, 690, 24, 68, + /* 440 */ 71, 759, 775, 675, 285, 208, 33, 36, 36, 288, + /* 450 */ 6, 206, 677, 287, 676, 255, 66, 92, 66, 73, + /* 460 */ 15, 664, 14, 693, 106, 694, 105, 17, 691, 16, + /* 470 */ 692, 19, 112, 18, 111, 21, 1035, 20, 125, 124, + /* 480 */ 191, 205, 195, 230, 143, 1032, 1031, 231, 315, 988, + /* 490 */ 44, 999, 996, 997, 1001, 145, 981, 262, 149, 271, + /* 500 */ 1018, 1017, 963, 162, 163, 141, 932, 961, 164, 165, + /* 510 */ 719, 879, 266, 290, 325, 160, 158, 276, 153, 978, + /* 520 */ 42, 152, 63, 189, 222, 72, 268, 39, 299, 275, + /* 530 */ 875, 69, 280, 300, 1095, 278, 103, 154, 1094, 155, + /* 540 */ 156, 274, 157, 1091, 169, 307, 1087, 109, 272, 1086, + /* 550 */ 1083, 170, 897, 40, 37, 43, 190, 864, 119, 862, + /* 560 */ 121, 122, 860, 859, 247, 180, 857, 856, 855, 854, + /* 570 */ 853, 852, 183, 185, 849, 847, 845, 843, 187, 840, + /* 580 */ 188, 270, 260, 78, 83, 269, 1019, 267, 45, 114, + /* 590 */ 317, 318, 319, 216, 321, 237, 320, 289, 322, 323, + /* 600 */ 335, 209, 817, 248, 97, 98, 210, 249, 816, 252, + /* 610 */ 815, 251, 798, 797, 256, 858, 261, 132, 173, 133, + /* 620 */ 898, 175, 171, 172, 174, 176, 177, 851, 4, 134, + /* 630 */ 850, 2, 135, 842, 841, 284, 9, 81, 696, 161, + /* 640 */ 159, 30, 147, 263, 84, 944, 224, 721, 724, 85, + /* 650 */ 10, 726, 86, 148, 273, 11, 730, 150, 31, 774, + /* 660 */ 7, 32, 12, 26, 286, 27, 776, 95, 93, 628, + /* 670 */ 624, 622, 621, 620, 617, 590, 297, 99, 64, 36, + /* 680 */ 102, 667, 666, 663, 612, 610, 65, 602, 104, 608, + /* 690 */ 604, 606, 600, 598, 631, 630, 629, 627, 626, 625, + /* 700 */ 623, 619, 618, 108, 110, 66, 588, 555, 553, 821, + /* 710 */ 820, 820, 820, 820, 820, 820, 820, 820, 820, 137, + /* 720 */ 138, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 192, 1, 191, 192, 0, 254, 211, 254, 254, 9, - /* 10 */ 189, 190, 254, 13, 14, 192, 16, 17, 264, 265, - /* 20 */ 20, 21, 15, 23, 24, 25, 26, 27, 28, 254, - /* 30 */ 5, 254, 237, 33, 34, 254, 211, 37, 38, 39, - /* 40 */ 13, 14, 265, 16, 17, 264, 265, 20, 21, 1, - /* 50 */ 23, 24, 25, 26, 27, 28, 235, 9, 33, 34, - /* 60 */ 33, 34, 237, 255, 37, 38, 39, 14, 192, 16, - /* 70 */ 17, 192, 251, 20, 21, 198, 23, 24, 25, 26, - /* 80 */ 27, 28, 259, 79, 261, 197, 33, 34, 198, 201, + /* 0 */ 193, 1, 192, 193, 0, 255, 212, 255, 255, 9, + /* 10 */ 190, 191, 255, 13, 14, 193, 16, 17, 265, 266, + /* 20 */ 20, 21, 255, 23, 24, 25, 26, 27, 28, 255, + /* 30 */ 5, 255, 238, 33, 34, 255, 212, 37, 38, 39, + /* 40 */ 13, 14, 266, 16, 17, 265, 266, 20, 21, 1, + /* 50 */ 23, 24, 25, 26, 27, 28, 236, 9, 33, 34, + /* 60 */ 33, 34, 238, 256, 37, 38, 39, 14, 193, 16, + /* 70 */ 17, 193, 252, 20, 21, 199, 23, 24, 25, 26, + /* 80 */ 27, 28, 260, 79, 262, 198, 33, 34, 199, 202, /* 90 */ 37, 38, 39, 45, 46, 47, 48, 49, 50, 51, - /* 100 */ 52, 53, 54, 55, 56, 57, 58, 230, 79, 61, - /* 110 */ 110, 1, 236, 13, 14, 192, 16, 17, 111, 9, - /* 120 */ 20, 21, 232, 23, 24, 25, 26, 27, 28, 37, - /* 130 */ 38, 39, 105, 33, 34, 256, 257, 37, 38, 39, - /* 140 */ 13, 14, 235, 16, 17, 81, 235, 20, 21, 1, - /* 150 */ 23, 24, 25, 26, 27, 28, 233, 9, 251, 236, - /* 160 */ 33, 34, 251, 254, 37, 38, 39, 88, 89, 90, + /* 100 */ 52, 53, 54, 55, 56, 57, 58, 231, 79, 61, + /* 110 */ 110, 1, 237, 13, 14, 193, 16, 17, 81, 9, + /* 120 */ 20, 21, 233, 23, 24, 25, 26, 27, 28, 37, + /* 130 */ 38, 39, 105, 33, 34, 257, 258, 37, 38, 39, + /* 140 */ 13, 14, 236, 16, 17, 255, 236, 20, 21, 1, + /* 150 */ 23, 24, 25, 26, 27, 28, 234, 9, 252, 237, + /* 160 */ 33, 34, 252, 255, 37, 38, 39, 88, 89, 90, /* 170 */ 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, - /* 180 */ 101, 102, 210, 192, 212, 213, 214, 215, 216, 217, - /* 190 */ 218, 219, 220, 221, 222, 223, 224, 225, 16, 17, - /* 200 */ 197, 254, 20, 21, 201, 23, 24, 25, 26, 27, - /* 210 */ 28, 192, 44, 198, 104, 33, 34, 199, 200, 37, - /* 220 */ 38, 39, 1, 2, 233, 105, 5, 236, 7, 61, - /* 230 */ 9, 1, 2, 113, 104, 5, 68, 7, 108, 9, - /* 240 */ 110, 73, 74, 75, 229, 230, 231, 232, 25, 26, - /* 250 */ 27, 28, 238, 234, 33, 34, 33, 34, 37, 192, - /* 260 */ 37, 38, 39, 33, 34, 5, 252, 7, 88, 237, - /* 270 */ 90, 91, 104, 192, 192, 95, 109, 97, 98, 99, - /* 280 */ 112, 101, 102, 116, 210, 33, 34, 213, 214, 37, - /* 290 */ 38, 39, 218, 197, 220, 221, 222, 201, 224, 225, - /* 300 */ 62, 63, 64, 135, 68, 137, 37, 69, 70, 71, - /* 310 */ 72, 68, 144, 192, 233, 233, 78, 236, 236, 2, - /* 320 */ 254, 5, 5, 7, 7, 104, 9, 254, 261, 192, - /* 330 */ 263, 192, 111, 228, 104, 62, 63, 64, 117, 192, - /* 340 */ 254, 111, 69, 70, 71, 72, 192, 117, 192, 192, - /* 350 */ 33, 34, 192, 192, 233, 134, 211, 236, 62, 63, - /* 360 */ 64, 62, 63, 64, 134, 69, 70, 71, 72, 211, - /* 370 */ 233, 192, 233, 236, 138, 236, 140, 117, 142, 143, - /* 380 */ 104, 138, 237, 140, 115, 142, 143, 233, 112, 233, - /* 390 */ 236, 136, 236, 233, 233, 237, 236, 236, 195, 196, - /* 400 */ 145, 146, 65, 66, 67, 76, 227, 105, 261, 105, - /* 410 */ 81, 125, 126, 109, 1, 113, 105, 105, 261, 105, - /* 420 */ 109, 109, 60, 109, 109, 105, 254, 105, 111, 109, - /* 430 */ 105, 109, 109, 117, 109, 105, 105, 105, 105, 109, - /* 440 */ 109, 109, 109, 104, 76, 77, 107, 132, 254, 139, - /* 450 */ 37, 141, 139, 130, 141, 254, 254, 139, 139, 141, - /* 460 */ 141, 254, 104, 139, 106, 141, 104, 254, 5, 5, - /* 470 */ 7, 7, 254, 254, 139, 228, 141, 237, 254, 254, - /* 480 */ 254, 237, 228, 192, 228, 228, 228, 228, 253, 192, - /* 490 */ 192, 262, 192, 192, 262, 192, 235, 235, 192, 192, - /* 500 */ 192, 192, 239, 235, 60, 87, 258, 258, 117, 258, - /* 510 */ 243, 258, 247, 192, 250, 249, 246, 122, 192, 192, - /* 520 */ 192, 123, 248, 129, 245, 128, 192, 131, 192, 127, - /* 530 */ 192, 121, 192, 192, 192, 192, 192, 192, 192, 192, - /* 540 */ 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - /* 550 */ 120, 192, 192, 192, 119, 192, 192, 192, 192, 192, - /* 560 */ 118, 192, 192, 192, 192, 192, 192, 192, 192, 192, - /* 570 */ 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - /* 580 */ 133, 193, 193, 193, 103, 193, 193, 86, 50, 83, - /* 590 */ 85, 54, 84, 82, 79, 5, 147, 193, 193, 193, - /* 600 */ 5, 5, 147, 5, 193, 193, 198, 198, 5, 90, - /* 610 */ 89, 136, 113, 109, 193, 105, 107, 104, 194, 193, - /* 620 */ 203, 194, 207, 209, 208, 206, 204, 202, 205, 195, - /* 630 */ 194, 193, 193, 226, 194, 104, 193, 114, 109, 105, - /* 640 */ 199, 240, 242, 244, 241, 104, 226, 105, 109, 104, - /* 650 */ 1, 105, 104, 104, 124, 105, 104, 124, 111, 105, - /* 660 */ 109, 104, 109, 104, 104, 107, 104, 76, 9, 108, - /* 670 */ 5, 5, 5, 5, 5, 15, 76, 80, 16, 109, - /* 680 */ 16, 141, 5, 5, 141, 141, 105, 5, 5, 5, - /* 690 */ 5, 5, 5, 5, 5, 5, 141, 5, 5, 5, - /* 700 */ 5, 5, 5, 5, 5, 80, 60, 59, 109, 0, - /* 710 */ 266, 266, 21, 266, 266, 266, 266, 266, 266, 266, - /* 720 */ 266, 21, 266, 266, 266, 266, 266, 266, 266, 266, - /* 730 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 740 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 750 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 760 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 770 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 780 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 790 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 800 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 810 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 820 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 830 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 840 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 850 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 860 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 870 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 880 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 890 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 900 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - /* 910 */ 266, + /* 180 */ 101, 102, 211, 193, 213, 214, 215, 216, 217, 218, + /* 190 */ 219, 220, 221, 222, 223, 224, 225, 226, 16, 17, + /* 200 */ 193, 255, 20, 21, 193, 23, 24, 25, 26, 27, + /* 210 */ 28, 193, 44, 199, 104, 33, 34, 193, 255, 37, + /* 220 */ 38, 39, 1, 2, 234, 255, 5, 237, 7, 61, + /* 230 */ 9, 1, 2, 193, 104, 5, 68, 7, 108, 9, + /* 240 */ 110, 73, 74, 75, 230, 231, 232, 233, 25, 26, + /* 250 */ 27, 28, 228, 235, 33, 34, 33, 34, 37, 238, + /* 260 */ 37, 38, 39, 33, 34, 65, 66, 67, 88, 262, + /* 270 */ 90, 91, 104, 262, 136, 95, 37, 97, 98, 99, + /* 280 */ 112, 101, 102, 145, 146, 211, 193, 255, 214, 215, + /* 290 */ 62, 63, 64, 219, 198, 221, 222, 223, 202, 225, + /* 300 */ 226, 104, 262, 135, 264, 137, 62, 63, 64, 112, + /* 310 */ 212, 212, 144, 69, 70, 71, 72, 68, 5, 255, + /* 320 */ 7, 193, 78, 68, 5, 104, 7, 234, 2, 238, + /* 330 */ 237, 5, 111, 7, 104, 9, 238, 238, 117, 255, + /* 340 */ 76, 111, 62, 63, 64, 81, 15, 117, 105, 69, + /* 350 */ 70, 71, 72, 198, 115, 134, 113, 202, 193, 33, + /* 360 */ 34, 255, 234, 193, 134, 237, 62, 63, 64, 193, + /* 370 */ 193, 193, 239, 69, 70, 71, 72, 33, 34, 193, + /* 380 */ 193, 37, 38, 39, 200, 201, 253, 138, 238, 140, + /* 390 */ 105, 142, 143, 138, 109, 140, 109, 142, 143, 234, + /* 400 */ 196, 197, 237, 116, 234, 1, 60, 237, 125, 126, + /* 410 */ 234, 234, 234, 237, 237, 237, 109, 105, 255, 109, + /* 420 */ 234, 234, 105, 237, 237, 113, 109, 105, 105, 105, + /* 430 */ 117, 109, 109, 109, 105, 229, 117, 111, 109, 132, + /* 440 */ 130, 37, 111, 105, 105, 255, 104, 109, 109, 107, + /* 450 */ 104, 255, 105, 105, 105, 193, 109, 109, 109, 104, + /* 460 */ 139, 106, 141, 5, 139, 7, 141, 139, 5, 141, + /* 470 */ 7, 139, 139, 141, 141, 139, 229, 141, 76, 77, + /* 480 */ 255, 255, 255, 229, 193, 229, 229, 229, 229, 193, + /* 490 */ 254, 193, 193, 193, 193, 193, 236, 236, 193, 193, + /* 500 */ 263, 263, 236, 240, 193, 60, 227, 193, 193, 193, + /* 510 */ 117, 193, 259, 193, 103, 242, 244, 122, 249, 251, + /* 520 */ 193, 250, 128, 193, 259, 129, 259, 193, 193, 259, + /* 530 */ 193, 131, 123, 193, 193, 127, 193, 248, 193, 247, + /* 540 */ 246, 121, 245, 193, 193, 193, 193, 193, 120, 193, + /* 550 */ 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, + /* 560 */ 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, + /* 570 */ 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, + /* 580 */ 193, 119, 194, 194, 194, 194, 194, 118, 133, 87, + /* 590 */ 86, 50, 83, 194, 54, 194, 85, 194, 84, 82, + /* 600 */ 79, 194, 5, 147, 199, 199, 194, 5, 5, 5, + /* 610 */ 5, 147, 90, 89, 136, 194, 113, 195, 204, 195, + /* 620 */ 210, 205, 209, 208, 207, 206, 203, 194, 196, 195, + /* 630 */ 194, 200, 195, 194, 194, 107, 104, 114, 105, 241, + /* 640 */ 243, 104, 104, 109, 109, 227, 1, 105, 105, 104, + /* 650 */ 124, 105, 104, 109, 104, 124, 105, 104, 109, 105, + /* 660 */ 104, 109, 104, 104, 107, 104, 111, 76, 108, 9, + /* 670 */ 5, 5, 5, 5, 5, 80, 15, 76, 16, 109, + /* 680 */ 141, 5, 5, 105, 5, 5, 16, 5, 141, 5, + /* 690 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + /* 700 */ 5, 5, 5, 141, 141, 109, 80, 60, 59, 0, + /* 710 */ 267, 267, 267, 267, 267, 267, 267, 267, 267, 21, + /* 720 */ 21, 267, 267, 267, 267, 267, 267, 267, 267, 267, + /* 730 */ 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + /* 740 */ 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + /* 750 */ 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + /* 760 */ 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + /* 770 */ 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + /* 780 */ 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + /* 790 */ 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + /* 800 */ 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + /* 810 */ 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + /* 820 */ 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + /* 830 */ 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + /* 840 */ 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + /* 850 */ 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + /* 860 */ 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + /* 870 */ 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + /* 880 */ 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + /* 890 */ 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + /* 900 */ 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, }; #define YY_SHIFT_COUNT (340) #define YY_SHIFT_MIN (0) @@ -391,64 +379,64 @@ static const YYCODETYPE yy_lookahead[] = { static const unsigned short int yy_shift_ofst[] = { /* 0 */ 168, 79, 79, 180, 180, 29, 221, 230, 110, 148, /* 10 */ 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, - /* 20 */ 148, 148, 0, 48, 230, 317, 317, 317, 317, 276, - /* 30 */ 276, 148, 148, 148, 4, 148, 148, 329, 29, 64, - /* 40 */ 64, 722, 722, 722, 230, 230, 230, 230, 230, 230, + /* 20 */ 148, 148, 0, 48, 230, 326, 326, 326, 326, 197, + /* 30 */ 197, 148, 148, 148, 4, 148, 148, 264, 29, 37, + /* 40 */ 37, 721, 721, 721, 230, 230, 230, 230, 230, 230, /* 50 */ 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, - /* 60 */ 230, 230, 230, 230, 317, 317, 317, 25, 25, 25, - /* 70 */ 25, 25, 25, 25, 148, 148, 148, 269, 148, 148, - /* 80 */ 148, 276, 276, 148, 148, 148, 148, 286, 286, 167, - /* 90 */ 276, 148, 148, 148, 148, 148, 148, 148, 148, 148, + /* 60 */ 230, 230, 230, 230, 326, 326, 326, 25, 25, 25, + /* 70 */ 25, 25, 25, 25, 148, 148, 148, 239, 148, 148, + /* 80 */ 148, 197, 197, 148, 148, 148, 148, 283, 283, 287, + /* 90 */ 197, 148, 148, 148, 148, 148, 148, 148, 148, 148, /* 100 */ 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, /* 110 */ 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, /* 120 */ 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, /* 130 */ 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, - /* 140 */ 148, 148, 148, 444, 444, 444, 391, 391, 391, 444, - /* 150 */ 391, 444, 394, 396, 397, 398, 402, 395, 410, 430, - /* 160 */ 435, 442, 447, 444, 444, 444, 481, 29, 29, 444, - /* 170 */ 444, 418, 501, 538, 506, 505, 537, 508, 511, 481, - /* 180 */ 444, 515, 515, 444, 515, 444, 515, 444, 444, 722, - /* 190 */ 722, 27, 100, 127, 100, 100, 53, 182, 223, 223, - /* 200 */ 223, 223, 238, 273, 296, 252, 252, 252, 252, 236, - /* 210 */ 243, 255, 92, 92, 260, 316, 130, 337, 299, 304, - /* 220 */ 120, 302, 311, 312, 314, 320, 322, 413, 362, 7, - /* 230 */ 315, 323, 325, 330, 331, 332, 333, 339, 310, 313, - /* 240 */ 318, 319, 324, 358, 335, 463, 464, 368, 590, 449, - /* 250 */ 595, 596, 455, 598, 603, 519, 521, 475, 499, 509, - /* 260 */ 513, 523, 510, 531, 504, 529, 534, 541, 542, 539, - /* 270 */ 545, 546, 548, 649, 549, 550, 552, 551, 530, 553, - /* 280 */ 533, 554, 557, 547, 559, 509, 560, 558, 562, 561, - /* 290 */ 591, 659, 665, 666, 667, 668, 669, 597, 660, 600, - /* 300 */ 662, 540, 543, 570, 570, 570, 570, 664, 544, 555, - /* 310 */ 570, 570, 570, 677, 678, 581, 570, 682, 683, 684, - /* 320 */ 685, 686, 687, 688, 689, 690, 692, 693, 694, 695, - /* 330 */ 696, 697, 698, 699, 599, 625, 691, 700, 646, 648, + /* 140 */ 148, 148, 148, 445, 445, 445, 393, 393, 393, 445, + /* 150 */ 393, 445, 396, 400, 394, 409, 408, 395, 420, 428, + /* 160 */ 462, 469, 455, 445, 445, 445, 411, 29, 29, 445, + /* 170 */ 445, 502, 504, 541, 509, 511, 540, 514, 517, 411, + /* 180 */ 445, 521, 521, 445, 521, 445, 521, 445, 445, 721, + /* 190 */ 721, 27, 100, 127, 100, 100, 53, 182, 223, 223, + /* 200 */ 223, 223, 244, 280, 304, 344, 344, 344, 344, 249, + /* 210 */ 255, 138, 92, 92, 313, 319, 130, 200, 228, 285, + /* 220 */ 243, 312, 317, 322, 323, 324, 329, 404, 346, 331, + /* 230 */ 307, 310, 338, 339, 347, 348, 349, 342, 321, 325, + /* 240 */ 328, 332, 333, 355, 336, 458, 463, 402, 597, 456, + /* 250 */ 602, 603, 464, 604, 605, 522, 524, 478, 503, 528, + /* 260 */ 532, 523, 533, 537, 534, 535, 542, 538, 543, 544, + /* 270 */ 545, 546, 548, 645, 550, 551, 553, 549, 526, 552, + /* 280 */ 531, 554, 556, 555, 558, 528, 559, 557, 561, 560, + /* 290 */ 591, 660, 665, 666, 667, 668, 669, 595, 661, 601, + /* 300 */ 662, 539, 547, 570, 570, 570, 570, 670, 562, 563, + /* 310 */ 570, 570, 570, 676, 677, 578, 570, 679, 680, 682, + /* 320 */ 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, + /* 330 */ 694, 695, 696, 697, 596, 626, 698, 699, 647, 649, /* 340 */ 709, }; #define YY_REDUCE_COUNT (190) -#define YY_REDUCE_MIN (-249) -#define YY_REDUCE_MAX (443) +#define YY_REDUCE_MIN (-250) +#define YY_REDUCE_MAX (440) static const short yy_reduce_ofst[] = { - /* 0 */ -179, -28, -28, 74, 74, 15, -246, -219, -121, -77, - /* 10 */ 67, -177, -9, 81, 82, 121, 137, 139, 154, 156, - /* 20 */ 160, 161, -192, -189, -223, -205, -175, 145, 158, -93, - /* 30 */ -89, 147, 157, 19, -110, 179, -124, -112, -123, 3, - /* 40 */ 96, 14, 18, 203, -249, -247, -242, -225, -91, -53, - /* 50 */ 66, 73, 86, 172, 194, 201, 202, 207, 213, 218, - /* 60 */ 219, 224, 225, 226, 32, 240, 244, 105, 247, 254, - /* 70 */ 256, 257, 258, 259, 291, 297, 298, 235, 300, 301, - /* 80 */ 303, 261, 262, 306, 307, 308, 309, 229, 232, 263, - /* 90 */ 268, 321, 326, 327, 328, 334, 336, 338, 340, 341, - /* 100 */ 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, - /* 110 */ 352, 353, 354, 355, 356, 357, 359, 360, 361, 363, - /* 120 */ 364, 365, 366, 367, 369, 370, 371, 372, 373, 374, + /* 0 */ -180, -29, -29, 74, 74, 14, -247, -220, -122, -78, + /* 10 */ 40, -178, -10, 93, 128, 165, 170, 176, 177, 178, + /* 20 */ 186, 187, -193, -190, -224, -206, -176, 98, 99, -94, + /* 30 */ -90, 7, 11, 18, -111, 24, -125, -113, -124, 96, + /* 40 */ 155, 133, 184, 204, -250, -248, -243, -233, -226, -110, + /* 50 */ -92, -54, -37, -30, 32, 64, 84, 106, 163, 190, + /* 60 */ 196, 225, 226, 227, 21, 91, 150, 206, 247, 254, + /* 70 */ 256, 257, 258, 259, 262, 291, 296, 236, 298, 299, + /* 80 */ 300, 260, 261, 301, 302, 305, 306, 237, 238, 263, + /* 90 */ 266, 311, 314, 315, 316, 318, 320, 327, 330, 334, + /* 100 */ 335, 337, 340, 341, 343, 345, 350, 351, 352, 353, + /* 110 */ 354, 356, 357, 358, 359, 360, 361, 362, 363, 364, + /* 120 */ 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, /* 130 */ 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, - /* 140 */ 385, 386, 387, 388, 389, 390, 248, 249, 251, 392, - /* 150 */ 253, 393, 264, 266, 274, 265, 270, 279, 399, 267, - /* 160 */ 400, 403, 401, 404, 405, 406, 407, 408, 409, 411, - /* 170 */ 412, 414, 416, 415, 417, 419, 422, 423, 425, 420, - /* 180 */ 421, 424, 427, 426, 436, 438, 440, 439, 443, 441, - /* 190 */ 434, + /* 140 */ 385, 386, 387, 388, 389, 390, 253, 265, 267, 391, + /* 150 */ 270, 392, 268, 271, 269, 289, 292, 294, 297, 272, + /* 160 */ 397, 273, 398, 399, 401, 403, 279, 405, 406, 407, + /* 170 */ 412, 410, 413, 415, 414, 417, 416, 419, 423, 418, + /* 180 */ 421, 422, 424, 433, 434, 436, 437, 439, 440, 431, + /* 190 */ 432, }; static const YYACTIONTYPE yy_default[] = { /* 0 */ 818, 931, 877, 943, 865, 874, 1079, 1079, 818, 818, @@ -733,7 +721,6 @@ struct yyParser { int yyerrcnt; /* Shifts left before out of the error */ #endif ParseARG_SDECL /* A place to hold %extra_argument */ - ParseCTX_SDECL /* A place to hold %extra_context */ #if YYSTACKDEPTH<=0 int yystksz; /* Current side of the stack */ yyStackEntry *yystack; /* The parser's stack */ @@ -970,83 +957,84 @@ static const char *const yyTokenName[] = { /* 186 */ "INSERT", /* 187 */ "INTO", /* 188 */ "VALUES", - /* 189 */ "program", - /* 190 */ "cmd", - /* 191 */ "dbPrefix", - /* 192 */ "ids", - /* 193 */ "cpxName", - /* 194 */ "ifexists", - /* 195 */ "alter_db_optr", - /* 196 */ "alter_topic_optr", - /* 197 */ "acct_optr", - /* 198 */ "ifnotexists", - /* 199 */ "db_optr", - /* 200 */ "topic_optr", - /* 201 */ "pps", - /* 202 */ "tseries", - /* 203 */ "dbs", - /* 204 */ "streams", - /* 205 */ "storage", - /* 206 */ "qtime", - /* 207 */ "users", - /* 208 */ "conns", - /* 209 */ "state", - /* 210 */ "keep", - /* 211 */ "tagitemlist", - /* 212 */ "cache", - /* 213 */ "replica", - /* 214 */ "quorum", - /* 215 */ "days", - /* 216 */ "minrows", - /* 217 */ "maxrows", - /* 218 */ "blocks", - /* 219 */ "ctime", - /* 220 */ "wal", - /* 221 */ "fsync", - /* 222 */ "comp", - /* 223 */ "prec", - /* 224 */ "update", - /* 225 */ "cachelast", - /* 226 */ "partitions", - /* 227 */ "typename", - /* 228 */ "signed", - /* 229 */ "create_table_args", - /* 230 */ "create_stable_args", - /* 231 */ "create_table_list", - /* 232 */ "create_from_stable", - /* 233 */ "columnlist", - /* 234 */ "tagNamelist", - /* 235 */ "select", - /* 236 */ "column", - /* 237 */ "tagitem", - /* 238 */ "selcollist", - /* 239 */ "from", - /* 240 */ "where_opt", - /* 241 */ "interval_opt", - /* 242 */ "session_option", - /* 243 */ "windowstate_option", - /* 244 */ "fill_opt", - /* 245 */ "sliding_opt", - /* 246 */ "groupby_opt", - /* 247 */ "orderby_opt", - /* 248 */ "having_opt", - /* 249 */ "slimit_opt", - /* 250 */ "limit_opt", - /* 251 */ "union", - /* 252 */ "sclp", - /* 253 */ "distinct", - /* 254 */ "expr", - /* 255 */ "as", - /* 256 */ "tablelist", - /* 257 */ "sub", - /* 258 */ "tmvar", - /* 259 */ "sortlist", - /* 260 */ "sortitem", - /* 261 */ "item", - /* 262 */ "sortorder", - /* 263 */ "grouplist", - /* 264 */ "exprlist", - /* 265 */ "expritem", + /* 189 */ "error", + /* 190 */ "program", + /* 191 */ "cmd", + /* 192 */ "dbPrefix", + /* 193 */ "ids", + /* 194 */ "cpxName", + /* 195 */ "ifexists", + /* 196 */ "alter_db_optr", + /* 197 */ "alter_topic_optr", + /* 198 */ "acct_optr", + /* 199 */ "ifnotexists", + /* 200 */ "db_optr", + /* 201 */ "topic_optr", + /* 202 */ "pps", + /* 203 */ "tseries", + /* 204 */ "dbs", + /* 205 */ "streams", + /* 206 */ "storage", + /* 207 */ "qtime", + /* 208 */ "users", + /* 209 */ "conns", + /* 210 */ "state", + /* 211 */ "keep", + /* 212 */ "tagitemlist", + /* 213 */ "cache", + /* 214 */ "replica", + /* 215 */ "quorum", + /* 216 */ "days", + /* 217 */ "minrows", + /* 218 */ "maxrows", + /* 219 */ "blocks", + /* 220 */ "ctime", + /* 221 */ "wal", + /* 222 */ "fsync", + /* 223 */ "comp", + /* 224 */ "prec", + /* 225 */ "update", + /* 226 */ "cachelast", + /* 227 */ "partitions", + /* 228 */ "typename", + /* 229 */ "signed", + /* 230 */ "create_table_args", + /* 231 */ "create_stable_args", + /* 232 */ "create_table_list", + /* 233 */ "create_from_stable", + /* 234 */ "columnlist", + /* 235 */ "tagNamelist", + /* 236 */ "select", + /* 237 */ "column", + /* 238 */ "tagitem", + /* 239 */ "selcollist", + /* 240 */ "from", + /* 241 */ "where_opt", + /* 242 */ "interval_opt", + /* 243 */ "session_option", + /* 244 */ "windowstate_option", + /* 245 */ "fill_opt", + /* 246 */ "sliding_opt", + /* 247 */ "groupby_opt", + /* 248 */ "orderby_opt", + /* 249 */ "having_opt", + /* 250 */ "slimit_opt", + /* 251 */ "limit_opt", + /* 252 */ "union", + /* 253 */ "sclp", + /* 254 */ "distinct", + /* 255 */ "expr", + /* 256 */ "as", + /* 257 */ "tablelist", + /* 258 */ "sub", + /* 259 */ "tmvar", + /* 260 */ "sortlist", + /* 261 */ "sortitem", + /* 262 */ "item", + /* 263 */ "sortorder", + /* 264 */ "grouplist", + /* 265 */ "exprlist", + /* 266 */ "expritem", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1382,29 +1370,28 @@ static int yyGrowStack(yyParser *p){ /* Initialize a new parser that has already been allocated. */ -void ParseInit(void *yypRawParser ParseCTX_PDECL){ - yyParser *yypParser = (yyParser*)yypRawParser; - ParseCTX_STORE +void ParseInit(void *yypParser){ + yyParser *pParser = (yyParser*)yypParser; #ifdef YYTRACKMAXSTACKDEPTH - yypParser->yyhwm = 0; + pParser->yyhwm = 0; #endif #if YYSTACKDEPTH<=0 - yypParser->yytos = NULL; - yypParser->yystack = NULL; - yypParser->yystksz = 0; - if( yyGrowStack(yypParser) ){ - yypParser->yystack = &yypParser->yystk0; - yypParser->yystksz = 1; + pParser->yytos = NULL; + pParser->yystack = NULL; + pParser->yystksz = 0; + if( yyGrowStack(pParser) ){ + pParser->yystack = &pParser->yystk0; + pParser->yystksz = 1; } #endif #ifndef YYNOERRORRECOVERY - yypParser->yyerrcnt = -1; + pParser->yyerrcnt = -1; #endif - yypParser->yytos = yypParser->yystack; - yypParser->yystack[0].stateno = 0; - yypParser->yystack[0].major = 0; + pParser->yytos = pParser->yystack; + pParser->yystack[0].stateno = 0; + pParser->yystack[0].major = 0; #if YYSTACKDEPTH>0 - yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1]; + pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1]; #endif } @@ -1421,14 +1408,11 @@ void ParseInit(void *yypRawParser ParseCTX_PDECL){ ** A pointer to a parser. This pointer is used in subsequent calls ** to Parse and ParseFree. */ -void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) ParseCTX_PDECL){ - yyParser *yypParser; - yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); - if( yypParser ){ - ParseCTX_STORE - ParseInit(yypParser ParseCTX_PARAM); - } - return (void*)yypParser; +void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){ + yyParser *pParser; + pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); + if( pParser ) ParseInit(pParser); + return pParser; } #endif /* Parse_ENGINEALWAYSONSTACK */ @@ -1445,8 +1429,7 @@ static void yy_destructor( YYCODETYPE yymajor, /* Type code for object to destroy */ YYMINORTYPE *yypminor /* The object to be destroyed */ ){ - ParseARG_FETCH - ParseCTX_FETCH + ParseARG_FETCH; switch( yymajor ){ /* Here is inserted the actions which take place when a ** terminal or non-terminal is destroyed. This can happen @@ -1459,59 +1442,59 @@ static void yy_destructor( ** inside the C code. */ /********* Begin destructor definitions ***************************************/ - case 210: /* keep */ - case 211: /* tagitemlist */ - case 233: /* columnlist */ - case 234: /* tagNamelist */ - case 244: /* fill_opt */ - case 246: /* groupby_opt */ - case 247: /* orderby_opt */ - case 259: /* sortlist */ - case 263: /* grouplist */ + case 211: /* keep */ + case 212: /* tagitemlist */ + case 234: /* columnlist */ + case 235: /* tagNamelist */ + case 245: /* fill_opt */ + case 247: /* groupby_opt */ + case 248: /* orderby_opt */ + case 260: /* sortlist */ + case 264: /* grouplist */ { -taosArrayDestroy((yypminor->yy193)); +taosArrayDestroy((yypminor->yy15)); } break; - case 231: /* create_table_list */ + case 232: /* create_table_list */ { -destroyCreateTableSql((yypminor->yy270)); +destroyCreateTableSql((yypminor->yy482)); } break; - case 235: /* select */ + case 236: /* select */ { -destroySqlNode((yypminor->yy124)); +destroySqlNode((yypminor->yy134)); } break; - case 238: /* selcollist */ - case 252: /* sclp */ - case 264: /* exprlist */ + case 239: /* selcollist */ + case 253: /* sclp */ + case 265: /* exprlist */ { -tSqlExprListDestroy((yypminor->yy193)); +tSqlExprListDestroy((yypminor->yy15)); } break; - case 239: /* from */ - case 256: /* tablelist */ - case 257: /* sub */ + case 240: /* from */ + case 257: /* tablelist */ + case 258: /* sub */ { -destroyRelationInfo((yypminor->yy332)); +destroyRelationInfo((yypminor->yy160)); } break; - case 240: /* where_opt */ - case 248: /* having_opt */ - case 254: /* expr */ - case 265: /* expritem */ + case 241: /* where_opt */ + case 249: /* having_opt */ + case 255: /* expr */ + case 266: /* expritem */ { -tSqlExprDestroy((yypminor->yy454)); +tSqlExprDestroy((yypminor->yy328)); } break; - case 251: /* union */ + case 252: /* union */ { -destroyAllSqlNode((yypminor->yy193)); +destroyAllSqlNode((yypminor->yy15)); } break; - case 260: /* sortitem */ + case 261: /* sortitem */ { -tVariantDestroy(&(yypminor->yy442)); +tVariantDestroy(&(yypminor->yy380)); } break; /********* End destructor definitions *****************************************/ @@ -1623,12 +1606,13 @@ int ParseCoverage(FILE *out){ ** Find the appropriate action for a parser given the terminal ** look-ahead token iLookAhead. */ -static YYACTIONTYPE yy_find_shift_action( - YYCODETYPE iLookAhead, /* The look-ahead token */ - YYACTIONTYPE stateno /* Current state number */ +static unsigned int yy_find_shift_action( + yyParser *pParser, /* The parser */ + YYCODETYPE iLookAhead /* The look-ahead token */ ){ int i; - + int stateno = pParser->yytos->stateno; + if( stateno>YY_MAX_SHIFT ) return stateno; assert( stateno <= YY_SHIFT_COUNT ); #if defined(YYCOVERAGE) @@ -1636,19 +1620,15 @@ static YYACTIONTYPE yy_find_shift_action( #endif do{ i = yy_shift_ofst[stateno]; - assert( i>=0 ); - assert( i<=YY_ACTTAB_COUNT ); - assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); + assert( i>=0 && i+YYNTOKEN<=sizeof(yy_lookahead)/sizeof(yy_lookahead[0]) ); assert( iLookAhead!=YYNOCODE ); assert( iLookAhead < YYNTOKEN ); i += iLookAhead; - assert( i<(int)YY_NLOOKAHEAD ); if( yy_lookahead[i]!=iLookAhead ){ #ifdef YYFALLBACK YYCODETYPE iFallback; /* Fallback token */ - assert( iLookAhead %s\n", @@ -1663,8 +1643,15 @@ static YYACTIONTYPE yy_find_shift_action( #ifdef YYWILDCARD { int j = i - iLookAhead + YYWILDCARD; - assert( j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) ); - if( yy_lookahead[j]==YYWILDCARD && iLookAhead>0 ){ + if( +#if YY_SHIFT_MIN+YYWILDCARD<0 + j>=0 && +#endif +#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT + j0 + ){ #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", @@ -1678,7 +1665,6 @@ static YYACTIONTYPE yy_find_shift_action( #endif /* YYWILDCARD */ return yy_default[stateno]; }else{ - assert( i>=0 && iyytos; - yytos->stateno = yyNewState; - yytos->major = yyMajor; + yytos->stateno = (YYACTIONTYPE)yyNewState; + yytos->major = (YYCODETYPE)yyMajor; yytos->minor.yy0 = yyMinor; yyTraceShift(yypParser, yyNewState, "Shift"); } -/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side -** of that rule */ -static const YYCODETYPE yyRuleInfoLhs[] = { - 189, /* (0) program ::= cmd */ - 190, /* (1) cmd ::= SHOW DATABASES */ - 190, /* (2) cmd ::= SHOW TOPICS */ - 190, /* (3) cmd ::= SHOW MNODES */ - 190, /* (4) cmd ::= SHOW DNODES */ - 190, /* (5) cmd ::= SHOW ACCOUNTS */ - 190, /* (6) cmd ::= SHOW USERS */ - 190, /* (7) cmd ::= SHOW MODULES */ - 190, /* (8) cmd ::= SHOW QUERIES */ - 190, /* (9) cmd ::= SHOW CONNECTIONS */ - 190, /* (10) cmd ::= SHOW STREAMS */ - 190, /* (11) cmd ::= SHOW VARIABLES */ - 190, /* (12) cmd ::= SHOW SCORES */ - 190, /* (13) cmd ::= SHOW GRANTS */ - 190, /* (14) cmd ::= SHOW VNODES */ - 190, /* (15) cmd ::= SHOW VNODES IPTOKEN */ - 191, /* (16) dbPrefix ::= */ - 191, /* (17) dbPrefix ::= ids DOT */ - 193, /* (18) cpxName ::= */ - 193, /* (19) cpxName ::= DOT ids */ - 190, /* (20) cmd ::= SHOW CREATE TABLE ids cpxName */ - 190, /* (21) cmd ::= SHOW CREATE STABLE ids cpxName */ - 190, /* (22) cmd ::= SHOW CREATE DATABASE ids */ - 190, /* (23) cmd ::= SHOW dbPrefix TABLES */ - 190, /* (24) cmd ::= SHOW dbPrefix TABLES LIKE ids */ - 190, /* (25) cmd ::= SHOW dbPrefix STABLES */ - 190, /* (26) cmd ::= SHOW dbPrefix STABLES LIKE ids */ - 190, /* (27) cmd ::= SHOW dbPrefix VGROUPS */ - 190, /* (28) cmd ::= SHOW dbPrefix VGROUPS ids */ - 190, /* (29) cmd ::= DROP TABLE ifexists ids cpxName */ - 190, /* (30) cmd ::= DROP STABLE ifexists ids cpxName */ - 190, /* (31) cmd ::= DROP DATABASE ifexists ids */ - 190, /* (32) cmd ::= DROP TOPIC ifexists ids */ - 190, /* (33) cmd ::= DROP DNODE ids */ - 190, /* (34) cmd ::= DROP USER ids */ - 190, /* (35) cmd ::= DROP ACCOUNT ids */ - 190, /* (36) cmd ::= USE ids */ - 190, /* (37) cmd ::= DESCRIBE ids cpxName */ - 190, /* (38) cmd ::= ALTER USER ids PASS ids */ - 190, /* (39) cmd ::= ALTER USER ids PRIVILEGE ids */ - 190, /* (40) cmd ::= ALTER DNODE ids ids */ - 190, /* (41) cmd ::= ALTER DNODE ids ids ids */ - 190, /* (42) cmd ::= ALTER LOCAL ids */ - 190, /* (43) cmd ::= ALTER LOCAL ids ids */ - 190, /* (44) cmd ::= ALTER DATABASE ids alter_db_optr */ - 190, /* (45) cmd ::= ALTER TOPIC ids alter_topic_optr */ - 190, /* (46) cmd ::= ALTER ACCOUNT ids acct_optr */ - 190, /* (47) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ - 192, /* (48) ids ::= ID */ - 192, /* (49) ids ::= STRING */ - 194, /* (50) ifexists ::= IF EXISTS */ - 194, /* (51) ifexists ::= */ - 198, /* (52) ifnotexists ::= IF NOT EXISTS */ - 198, /* (53) ifnotexists ::= */ - 190, /* (54) cmd ::= CREATE DNODE ids */ - 190, /* (55) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ - 190, /* (56) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ - 190, /* (57) cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ - 190, /* (58) cmd ::= CREATE USER ids PASS ids */ - 201, /* (59) pps ::= */ - 201, /* (60) pps ::= PPS INTEGER */ - 202, /* (61) tseries ::= */ - 202, /* (62) tseries ::= TSERIES INTEGER */ - 203, /* (63) dbs ::= */ - 203, /* (64) dbs ::= DBS INTEGER */ - 204, /* (65) streams ::= */ - 204, /* (66) streams ::= STREAMS INTEGER */ - 205, /* (67) storage ::= */ - 205, /* (68) storage ::= STORAGE INTEGER */ - 206, /* (69) qtime ::= */ - 206, /* (70) qtime ::= QTIME INTEGER */ - 207, /* (71) users ::= */ - 207, /* (72) users ::= USERS INTEGER */ - 208, /* (73) conns ::= */ - 208, /* (74) conns ::= CONNS INTEGER */ - 209, /* (75) state ::= */ - 209, /* (76) state ::= STATE ids */ - 197, /* (77) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ - 210, /* (78) keep ::= KEEP tagitemlist */ - 212, /* (79) cache ::= CACHE INTEGER */ - 213, /* (80) replica ::= REPLICA INTEGER */ - 214, /* (81) quorum ::= QUORUM INTEGER */ - 215, /* (82) days ::= DAYS INTEGER */ - 216, /* (83) minrows ::= MINROWS INTEGER */ - 217, /* (84) maxrows ::= MAXROWS INTEGER */ - 218, /* (85) blocks ::= BLOCKS INTEGER */ - 219, /* (86) ctime ::= CTIME INTEGER */ - 220, /* (87) wal ::= WAL INTEGER */ - 221, /* (88) fsync ::= FSYNC INTEGER */ - 222, /* (89) comp ::= COMP INTEGER */ - 223, /* (90) prec ::= PRECISION STRING */ - 224, /* (91) update ::= UPDATE INTEGER */ - 225, /* (92) cachelast ::= CACHELAST INTEGER */ - 226, /* (93) partitions ::= PARTITIONS INTEGER */ - 199, /* (94) db_optr ::= */ - 199, /* (95) db_optr ::= db_optr cache */ - 199, /* (96) db_optr ::= db_optr replica */ - 199, /* (97) db_optr ::= db_optr quorum */ - 199, /* (98) db_optr ::= db_optr days */ - 199, /* (99) db_optr ::= db_optr minrows */ - 199, /* (100) db_optr ::= db_optr maxrows */ - 199, /* (101) db_optr ::= db_optr blocks */ - 199, /* (102) db_optr ::= db_optr ctime */ - 199, /* (103) db_optr ::= db_optr wal */ - 199, /* (104) db_optr ::= db_optr fsync */ - 199, /* (105) db_optr ::= db_optr comp */ - 199, /* (106) db_optr ::= db_optr prec */ - 199, /* (107) db_optr ::= db_optr keep */ - 199, /* (108) db_optr ::= db_optr update */ - 199, /* (109) db_optr ::= db_optr cachelast */ - 200, /* (110) topic_optr ::= db_optr */ - 200, /* (111) topic_optr ::= topic_optr partitions */ - 195, /* (112) alter_db_optr ::= */ - 195, /* (113) alter_db_optr ::= alter_db_optr replica */ - 195, /* (114) alter_db_optr ::= alter_db_optr quorum */ - 195, /* (115) alter_db_optr ::= alter_db_optr keep */ - 195, /* (116) alter_db_optr ::= alter_db_optr blocks */ - 195, /* (117) alter_db_optr ::= alter_db_optr comp */ - 195, /* (118) alter_db_optr ::= alter_db_optr wal */ - 195, /* (119) alter_db_optr ::= alter_db_optr fsync */ - 195, /* (120) alter_db_optr ::= alter_db_optr update */ - 195, /* (121) alter_db_optr ::= alter_db_optr cachelast */ - 196, /* (122) alter_topic_optr ::= alter_db_optr */ - 196, /* (123) alter_topic_optr ::= alter_topic_optr partitions */ - 227, /* (124) typename ::= ids */ - 227, /* (125) typename ::= ids LP signed RP */ - 227, /* (126) typename ::= ids UNSIGNED */ - 228, /* (127) signed ::= INTEGER */ - 228, /* (128) signed ::= PLUS INTEGER */ - 228, /* (129) signed ::= MINUS INTEGER */ - 190, /* (130) cmd ::= CREATE TABLE create_table_args */ - 190, /* (131) cmd ::= CREATE TABLE create_stable_args */ - 190, /* (132) cmd ::= CREATE STABLE create_stable_args */ - 190, /* (133) cmd ::= CREATE TABLE create_table_list */ - 231, /* (134) create_table_list ::= create_from_stable */ - 231, /* (135) create_table_list ::= create_table_list create_from_stable */ - 229, /* (136) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ - 230, /* (137) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ - 232, /* (138) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ - 232, /* (139) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ - 234, /* (140) tagNamelist ::= tagNamelist COMMA ids */ - 234, /* (141) tagNamelist ::= ids */ - 229, /* (142) create_table_args ::= ifnotexists ids cpxName AS select */ - 233, /* (143) columnlist ::= columnlist COMMA column */ - 233, /* (144) columnlist ::= column */ - 236, /* (145) column ::= ids typename */ - 211, /* (146) tagitemlist ::= tagitemlist COMMA tagitem */ - 211, /* (147) tagitemlist ::= tagitem */ - 237, /* (148) tagitem ::= INTEGER */ - 237, /* (149) tagitem ::= FLOAT */ - 237, /* (150) tagitem ::= STRING */ - 237, /* (151) tagitem ::= BOOL */ - 237, /* (152) tagitem ::= NULL */ - 237, /* (153) tagitem ::= MINUS INTEGER */ - 237, /* (154) tagitem ::= MINUS FLOAT */ - 237, /* (155) tagitem ::= PLUS INTEGER */ - 237, /* (156) tagitem ::= PLUS FLOAT */ - 235, /* (157) select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ - 235, /* (158) select ::= LP select RP */ - 251, /* (159) union ::= select */ - 251, /* (160) union ::= union UNION ALL select */ - 190, /* (161) cmd ::= union */ - 235, /* (162) select ::= SELECT selcollist */ - 252, /* (163) sclp ::= selcollist COMMA */ - 252, /* (164) sclp ::= */ - 238, /* (165) selcollist ::= sclp distinct expr as */ - 238, /* (166) selcollist ::= sclp STAR */ - 255, /* (167) as ::= AS ids */ - 255, /* (168) as ::= ids */ - 255, /* (169) as ::= */ - 253, /* (170) distinct ::= DISTINCT */ - 253, /* (171) distinct ::= */ - 239, /* (172) from ::= FROM tablelist */ - 239, /* (173) from ::= FROM sub */ - 257, /* (174) sub ::= LP union RP */ - 257, /* (175) sub ::= LP union RP ids */ - 257, /* (176) sub ::= sub COMMA LP union RP ids */ - 256, /* (177) tablelist ::= ids cpxName */ - 256, /* (178) tablelist ::= ids cpxName ids */ - 256, /* (179) tablelist ::= tablelist COMMA ids cpxName */ - 256, /* (180) tablelist ::= tablelist COMMA ids cpxName ids */ - 258, /* (181) tmvar ::= VARIABLE */ - 241, /* (182) interval_opt ::= INTERVAL LP tmvar RP */ - 241, /* (183) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ - 241, /* (184) interval_opt ::= */ - 242, /* (185) session_option ::= */ - 242, /* (186) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ - 243, /* (187) windowstate_option ::= */ - 243, /* (188) windowstate_option ::= STATE_WINDOW LP ids RP */ - 244, /* (189) fill_opt ::= */ - 244, /* (190) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - 244, /* (191) fill_opt ::= FILL LP ID RP */ - 245, /* (192) sliding_opt ::= SLIDING LP tmvar RP */ - 245, /* (193) sliding_opt ::= */ - 247, /* (194) orderby_opt ::= */ - 247, /* (195) orderby_opt ::= ORDER BY sortlist */ - 259, /* (196) sortlist ::= sortlist COMMA item sortorder */ - 259, /* (197) sortlist ::= item sortorder */ - 261, /* (198) item ::= ids cpxName */ - 262, /* (199) sortorder ::= ASC */ - 262, /* (200) sortorder ::= DESC */ - 262, /* (201) sortorder ::= */ - 246, /* (202) groupby_opt ::= */ - 246, /* (203) groupby_opt ::= GROUP BY grouplist */ - 263, /* (204) grouplist ::= grouplist COMMA item */ - 263, /* (205) grouplist ::= item */ - 248, /* (206) having_opt ::= */ - 248, /* (207) having_opt ::= HAVING expr */ - 250, /* (208) limit_opt ::= */ - 250, /* (209) limit_opt ::= LIMIT signed */ - 250, /* (210) limit_opt ::= LIMIT signed OFFSET signed */ - 250, /* (211) limit_opt ::= LIMIT signed COMMA signed */ - 249, /* (212) slimit_opt ::= */ - 249, /* (213) slimit_opt ::= SLIMIT signed */ - 249, /* (214) slimit_opt ::= SLIMIT signed SOFFSET signed */ - 249, /* (215) slimit_opt ::= SLIMIT signed COMMA signed */ - 240, /* (216) where_opt ::= */ - 240, /* (217) where_opt ::= WHERE expr */ - 254, /* (218) expr ::= LP expr RP */ - 254, /* (219) expr ::= ID */ - 254, /* (220) expr ::= ID DOT ID */ - 254, /* (221) expr ::= ID DOT STAR */ - 254, /* (222) expr ::= INTEGER */ - 254, /* (223) expr ::= MINUS INTEGER */ - 254, /* (224) expr ::= PLUS INTEGER */ - 254, /* (225) expr ::= FLOAT */ - 254, /* (226) expr ::= MINUS FLOAT */ - 254, /* (227) expr ::= PLUS FLOAT */ - 254, /* (228) expr ::= STRING */ - 254, /* (229) expr ::= NOW */ - 254, /* (230) expr ::= VARIABLE */ - 254, /* (231) expr ::= PLUS VARIABLE */ - 254, /* (232) expr ::= MINUS VARIABLE */ - 254, /* (233) expr ::= BOOL */ - 254, /* (234) expr ::= NULL */ - 254, /* (235) expr ::= ID LP exprlist RP */ - 254, /* (236) expr ::= ID LP STAR RP */ - 254, /* (237) expr ::= expr IS NULL */ - 254, /* (238) expr ::= expr IS NOT NULL */ - 254, /* (239) expr ::= expr LT expr */ - 254, /* (240) expr ::= expr GT expr */ - 254, /* (241) expr ::= expr LE expr */ - 254, /* (242) expr ::= expr GE expr */ - 254, /* (243) expr ::= expr NE expr */ - 254, /* (244) expr ::= expr EQ expr */ - 254, /* (245) expr ::= expr BETWEEN expr AND expr */ - 254, /* (246) expr ::= expr AND expr */ - 254, /* (247) expr ::= expr OR expr */ - 254, /* (248) expr ::= expr PLUS expr */ - 254, /* (249) expr ::= expr MINUS expr */ - 254, /* (250) expr ::= expr STAR expr */ - 254, /* (251) expr ::= expr SLASH expr */ - 254, /* (252) expr ::= expr REM expr */ - 254, /* (253) expr ::= expr LIKE expr */ - 254, /* (254) expr ::= expr IN LP exprlist RP */ - 264, /* (255) exprlist ::= exprlist COMMA expritem */ - 264, /* (256) exprlist ::= expritem */ - 265, /* (257) expritem ::= expr */ - 265, /* (258) expritem ::= */ - 190, /* (259) cmd ::= RESET QUERY CACHE */ - 190, /* (260) cmd ::= SYNCDB ids REPLICA */ - 190, /* (261) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - 190, /* (262) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - 190, /* (263) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ - 190, /* (264) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - 190, /* (265) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - 190, /* (266) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - 190, /* (267) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - 190, /* (268) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ - 190, /* (269) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - 190, /* (270) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - 190, /* (271) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ - 190, /* (272) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - 190, /* (273) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - 190, /* (274) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - 190, /* (275) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ - 190, /* (276) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ - 190, /* (277) cmd ::= KILL CONNECTION INTEGER */ - 190, /* (278) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - 190, /* (279) cmd ::= KILL QUERY INTEGER COLON INTEGER */ -}; - -/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number -** of symbols on the right-hand side of that rule. */ -static const signed char yyRuleInfoNRhs[] = { - -1, /* (0) program ::= cmd */ - -2, /* (1) cmd ::= SHOW DATABASES */ - -2, /* (2) cmd ::= SHOW TOPICS */ - -2, /* (3) cmd ::= SHOW MNODES */ - -2, /* (4) cmd ::= SHOW DNODES */ - -2, /* (5) cmd ::= SHOW ACCOUNTS */ - -2, /* (6) cmd ::= SHOW USERS */ - -2, /* (7) cmd ::= SHOW MODULES */ - -2, /* (8) cmd ::= SHOW QUERIES */ - -2, /* (9) cmd ::= SHOW CONNECTIONS */ - -2, /* (10) cmd ::= SHOW STREAMS */ - -2, /* (11) cmd ::= SHOW VARIABLES */ - -2, /* (12) cmd ::= SHOW SCORES */ - -2, /* (13) cmd ::= SHOW GRANTS */ - -2, /* (14) cmd ::= SHOW VNODES */ - -3, /* (15) cmd ::= SHOW VNODES IPTOKEN */ - 0, /* (16) dbPrefix ::= */ - -2, /* (17) dbPrefix ::= ids DOT */ - 0, /* (18) cpxName ::= */ - -2, /* (19) cpxName ::= DOT ids */ - -5, /* (20) cmd ::= SHOW CREATE TABLE ids cpxName */ - -5, /* (21) cmd ::= SHOW CREATE STABLE ids cpxName */ - -4, /* (22) cmd ::= SHOW CREATE DATABASE ids */ - -3, /* (23) cmd ::= SHOW dbPrefix TABLES */ - -5, /* (24) cmd ::= SHOW dbPrefix TABLES LIKE ids */ - -3, /* (25) cmd ::= SHOW dbPrefix STABLES */ - -5, /* (26) cmd ::= SHOW dbPrefix STABLES LIKE ids */ - -3, /* (27) cmd ::= SHOW dbPrefix VGROUPS */ - -4, /* (28) cmd ::= SHOW dbPrefix VGROUPS ids */ - -5, /* (29) cmd ::= DROP TABLE ifexists ids cpxName */ - -5, /* (30) cmd ::= DROP STABLE ifexists ids cpxName */ - -4, /* (31) cmd ::= DROP DATABASE ifexists ids */ - -4, /* (32) cmd ::= DROP TOPIC ifexists ids */ - -3, /* (33) cmd ::= DROP DNODE ids */ - -3, /* (34) cmd ::= DROP USER ids */ - -3, /* (35) cmd ::= DROP ACCOUNT ids */ - -2, /* (36) cmd ::= USE ids */ - -3, /* (37) cmd ::= DESCRIBE ids cpxName */ - -5, /* (38) cmd ::= ALTER USER ids PASS ids */ - -5, /* (39) cmd ::= ALTER USER ids PRIVILEGE ids */ - -4, /* (40) cmd ::= ALTER DNODE ids ids */ - -5, /* (41) cmd ::= ALTER DNODE ids ids ids */ - -3, /* (42) cmd ::= ALTER LOCAL ids */ - -4, /* (43) cmd ::= ALTER LOCAL ids ids */ - -4, /* (44) cmd ::= ALTER DATABASE ids alter_db_optr */ - -4, /* (45) cmd ::= ALTER TOPIC ids alter_topic_optr */ - -4, /* (46) cmd ::= ALTER ACCOUNT ids acct_optr */ - -6, /* (47) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ - -1, /* (48) ids ::= ID */ - -1, /* (49) ids ::= STRING */ - -2, /* (50) ifexists ::= IF EXISTS */ - 0, /* (51) ifexists ::= */ - -3, /* (52) ifnotexists ::= IF NOT EXISTS */ - 0, /* (53) ifnotexists ::= */ - -3, /* (54) cmd ::= CREATE DNODE ids */ - -6, /* (55) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ - -5, /* (56) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ - -5, /* (57) cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ - -5, /* (58) cmd ::= CREATE USER ids PASS ids */ - 0, /* (59) pps ::= */ - -2, /* (60) pps ::= PPS INTEGER */ - 0, /* (61) tseries ::= */ - -2, /* (62) tseries ::= TSERIES INTEGER */ - 0, /* (63) dbs ::= */ - -2, /* (64) dbs ::= DBS INTEGER */ - 0, /* (65) streams ::= */ - -2, /* (66) streams ::= STREAMS INTEGER */ - 0, /* (67) storage ::= */ - -2, /* (68) storage ::= STORAGE INTEGER */ - 0, /* (69) qtime ::= */ - -2, /* (70) qtime ::= QTIME INTEGER */ - 0, /* (71) users ::= */ - -2, /* (72) users ::= USERS INTEGER */ - 0, /* (73) conns ::= */ - -2, /* (74) conns ::= CONNS INTEGER */ - 0, /* (75) state ::= */ - -2, /* (76) state ::= STATE ids */ - -9, /* (77) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ - -2, /* (78) keep ::= KEEP tagitemlist */ - -2, /* (79) cache ::= CACHE INTEGER */ - -2, /* (80) replica ::= REPLICA INTEGER */ - -2, /* (81) quorum ::= QUORUM INTEGER */ - -2, /* (82) days ::= DAYS INTEGER */ - -2, /* (83) minrows ::= MINROWS INTEGER */ - -2, /* (84) maxrows ::= MAXROWS INTEGER */ - -2, /* (85) blocks ::= BLOCKS INTEGER */ - -2, /* (86) ctime ::= CTIME INTEGER */ - -2, /* (87) wal ::= WAL INTEGER */ - -2, /* (88) fsync ::= FSYNC INTEGER */ - -2, /* (89) comp ::= COMP INTEGER */ - -2, /* (90) prec ::= PRECISION STRING */ - -2, /* (91) update ::= UPDATE INTEGER */ - -2, /* (92) cachelast ::= CACHELAST INTEGER */ - -2, /* (93) partitions ::= PARTITIONS INTEGER */ - 0, /* (94) db_optr ::= */ - -2, /* (95) db_optr ::= db_optr cache */ - -2, /* (96) db_optr ::= db_optr replica */ - -2, /* (97) db_optr ::= db_optr quorum */ - -2, /* (98) db_optr ::= db_optr days */ - -2, /* (99) db_optr ::= db_optr minrows */ - -2, /* (100) db_optr ::= db_optr maxrows */ - -2, /* (101) db_optr ::= db_optr blocks */ - -2, /* (102) db_optr ::= db_optr ctime */ - -2, /* (103) db_optr ::= db_optr wal */ - -2, /* (104) db_optr ::= db_optr fsync */ - -2, /* (105) db_optr ::= db_optr comp */ - -2, /* (106) db_optr ::= db_optr prec */ - -2, /* (107) db_optr ::= db_optr keep */ - -2, /* (108) db_optr ::= db_optr update */ - -2, /* (109) db_optr ::= db_optr cachelast */ - -1, /* (110) topic_optr ::= db_optr */ - -2, /* (111) topic_optr ::= topic_optr partitions */ - 0, /* (112) alter_db_optr ::= */ - -2, /* (113) alter_db_optr ::= alter_db_optr replica */ - -2, /* (114) alter_db_optr ::= alter_db_optr quorum */ - -2, /* (115) alter_db_optr ::= alter_db_optr keep */ - -2, /* (116) alter_db_optr ::= alter_db_optr blocks */ - -2, /* (117) alter_db_optr ::= alter_db_optr comp */ - -2, /* (118) alter_db_optr ::= alter_db_optr wal */ - -2, /* (119) alter_db_optr ::= alter_db_optr fsync */ - -2, /* (120) alter_db_optr ::= alter_db_optr update */ - -2, /* (121) alter_db_optr ::= alter_db_optr cachelast */ - -1, /* (122) alter_topic_optr ::= alter_db_optr */ - -2, /* (123) alter_topic_optr ::= alter_topic_optr partitions */ - -1, /* (124) typename ::= ids */ - -4, /* (125) typename ::= ids LP signed RP */ - -2, /* (126) typename ::= ids UNSIGNED */ - -1, /* (127) signed ::= INTEGER */ - -2, /* (128) signed ::= PLUS INTEGER */ - -2, /* (129) signed ::= MINUS INTEGER */ - -3, /* (130) cmd ::= CREATE TABLE create_table_args */ - -3, /* (131) cmd ::= CREATE TABLE create_stable_args */ - -3, /* (132) cmd ::= CREATE STABLE create_stable_args */ - -3, /* (133) cmd ::= CREATE TABLE create_table_list */ - -1, /* (134) create_table_list ::= create_from_stable */ - -2, /* (135) create_table_list ::= create_table_list create_from_stable */ - -6, /* (136) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ - -10, /* (137) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ - -10, /* (138) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ - -13, /* (139) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ - -3, /* (140) tagNamelist ::= tagNamelist COMMA ids */ - -1, /* (141) tagNamelist ::= ids */ - -5, /* (142) create_table_args ::= ifnotexists ids cpxName AS select */ - -3, /* (143) columnlist ::= columnlist COMMA column */ - -1, /* (144) columnlist ::= column */ - -2, /* (145) column ::= ids typename */ - -3, /* (146) tagitemlist ::= tagitemlist COMMA tagitem */ - -1, /* (147) tagitemlist ::= tagitem */ - -1, /* (148) tagitem ::= INTEGER */ - -1, /* (149) tagitem ::= FLOAT */ - -1, /* (150) tagitem ::= STRING */ - -1, /* (151) tagitem ::= BOOL */ - -1, /* (152) tagitem ::= NULL */ - -2, /* (153) tagitem ::= MINUS INTEGER */ - -2, /* (154) tagitem ::= MINUS FLOAT */ - -2, /* (155) tagitem ::= PLUS INTEGER */ - -2, /* (156) tagitem ::= PLUS FLOAT */ - -14, /* (157) select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ - -3, /* (158) select ::= LP select RP */ - -1, /* (159) union ::= select */ - -4, /* (160) union ::= union UNION ALL select */ - -1, /* (161) cmd ::= union */ - -2, /* (162) select ::= SELECT selcollist */ - -2, /* (163) sclp ::= selcollist COMMA */ - 0, /* (164) sclp ::= */ - -4, /* (165) selcollist ::= sclp distinct expr as */ - -2, /* (166) selcollist ::= sclp STAR */ - -2, /* (167) as ::= AS ids */ - -1, /* (168) as ::= ids */ - 0, /* (169) as ::= */ - -1, /* (170) distinct ::= DISTINCT */ - 0, /* (171) distinct ::= */ - -2, /* (172) from ::= FROM tablelist */ - -2, /* (173) from ::= FROM sub */ - -3, /* (174) sub ::= LP union RP */ - -4, /* (175) sub ::= LP union RP ids */ - -6, /* (176) sub ::= sub COMMA LP union RP ids */ - -2, /* (177) tablelist ::= ids cpxName */ - -3, /* (178) tablelist ::= ids cpxName ids */ - -4, /* (179) tablelist ::= tablelist COMMA ids cpxName */ - -5, /* (180) tablelist ::= tablelist COMMA ids cpxName ids */ - -1, /* (181) tmvar ::= VARIABLE */ - -4, /* (182) interval_opt ::= INTERVAL LP tmvar RP */ - -6, /* (183) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ - 0, /* (184) interval_opt ::= */ - 0, /* (185) session_option ::= */ - -7, /* (186) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ - 0, /* (187) windowstate_option ::= */ - -4, /* (188) windowstate_option ::= STATE_WINDOW LP ids RP */ - 0, /* (189) fill_opt ::= */ - -6, /* (190) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - -4, /* (191) fill_opt ::= FILL LP ID RP */ - -4, /* (192) sliding_opt ::= SLIDING LP tmvar RP */ - 0, /* (193) sliding_opt ::= */ - 0, /* (194) orderby_opt ::= */ - -3, /* (195) orderby_opt ::= ORDER BY sortlist */ - -4, /* (196) sortlist ::= sortlist COMMA item sortorder */ - -2, /* (197) sortlist ::= item sortorder */ - -2, /* (198) item ::= ids cpxName */ - -1, /* (199) sortorder ::= ASC */ - -1, /* (200) sortorder ::= DESC */ - 0, /* (201) sortorder ::= */ - 0, /* (202) groupby_opt ::= */ - -3, /* (203) groupby_opt ::= GROUP BY grouplist */ - -3, /* (204) grouplist ::= grouplist COMMA item */ - -1, /* (205) grouplist ::= item */ - 0, /* (206) having_opt ::= */ - -2, /* (207) having_opt ::= HAVING expr */ - 0, /* (208) limit_opt ::= */ - -2, /* (209) limit_opt ::= LIMIT signed */ - -4, /* (210) limit_opt ::= LIMIT signed OFFSET signed */ - -4, /* (211) limit_opt ::= LIMIT signed COMMA signed */ - 0, /* (212) slimit_opt ::= */ - -2, /* (213) slimit_opt ::= SLIMIT signed */ - -4, /* (214) slimit_opt ::= SLIMIT signed SOFFSET signed */ - -4, /* (215) slimit_opt ::= SLIMIT signed COMMA signed */ - 0, /* (216) where_opt ::= */ - -2, /* (217) where_opt ::= WHERE expr */ - -3, /* (218) expr ::= LP expr RP */ - -1, /* (219) expr ::= ID */ - -3, /* (220) expr ::= ID DOT ID */ - -3, /* (221) expr ::= ID DOT STAR */ - -1, /* (222) expr ::= INTEGER */ - -2, /* (223) expr ::= MINUS INTEGER */ - -2, /* (224) expr ::= PLUS INTEGER */ - -1, /* (225) expr ::= FLOAT */ - -2, /* (226) expr ::= MINUS FLOAT */ - -2, /* (227) expr ::= PLUS FLOAT */ - -1, /* (228) expr ::= STRING */ - -1, /* (229) expr ::= NOW */ - -1, /* (230) expr ::= VARIABLE */ - -2, /* (231) expr ::= PLUS VARIABLE */ - -2, /* (232) expr ::= MINUS VARIABLE */ - -1, /* (233) expr ::= BOOL */ - -1, /* (234) expr ::= NULL */ - -4, /* (235) expr ::= ID LP exprlist RP */ - -4, /* (236) expr ::= ID LP STAR RP */ - -3, /* (237) expr ::= expr IS NULL */ - -4, /* (238) expr ::= expr IS NOT NULL */ - -3, /* (239) expr ::= expr LT expr */ - -3, /* (240) expr ::= expr GT expr */ - -3, /* (241) expr ::= expr LE expr */ - -3, /* (242) expr ::= expr GE expr */ - -3, /* (243) expr ::= expr NE expr */ - -3, /* (244) expr ::= expr EQ expr */ - -5, /* (245) expr ::= expr BETWEEN expr AND expr */ - -3, /* (246) expr ::= expr AND expr */ - -3, /* (247) expr ::= expr OR expr */ - -3, /* (248) expr ::= expr PLUS expr */ - -3, /* (249) expr ::= expr MINUS expr */ - -3, /* (250) expr ::= expr STAR expr */ - -3, /* (251) expr ::= expr SLASH expr */ - -3, /* (252) expr ::= expr REM expr */ - -3, /* (253) expr ::= expr LIKE expr */ - -5, /* (254) expr ::= expr IN LP exprlist RP */ - -3, /* (255) exprlist ::= exprlist COMMA expritem */ - -1, /* (256) exprlist ::= expritem */ - -1, /* (257) expritem ::= expr */ - 0, /* (258) expritem ::= */ - -3, /* (259) cmd ::= RESET QUERY CACHE */ - -3, /* (260) cmd ::= SYNCDB ids REPLICA */ - -7, /* (261) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - -7, /* (262) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - -7, /* (263) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ - -7, /* (264) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - -7, /* (265) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - -8, /* (266) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - -9, /* (267) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - -7, /* (268) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ - -7, /* (269) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - -7, /* (270) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - -7, /* (271) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ - -7, /* (272) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - -7, /* (273) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - -8, /* (274) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - -9, /* (275) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ - -7, /* (276) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ - -3, /* (277) cmd ::= KILL CONNECTION INTEGER */ - -5, /* (278) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - -5, /* (279) cmd ::= KILL QUERY INTEGER COLON INTEGER */ +/* The following table contains information about every rule that +** is used during the reduce. +*/ +static const struct { + YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ + signed char nrhs; /* Negative of the number of RHS symbols in the rule */ +} yyRuleInfo[] = { + { 190, -1 }, /* (0) program ::= cmd */ + { 191, -2 }, /* (1) cmd ::= SHOW DATABASES */ + { 191, -2 }, /* (2) cmd ::= SHOW TOPICS */ + { 191, -2 }, /* (3) cmd ::= SHOW MNODES */ + { 191, -2 }, /* (4) cmd ::= SHOW DNODES */ + { 191, -2 }, /* (5) cmd ::= SHOW ACCOUNTS */ + { 191, -2 }, /* (6) cmd ::= SHOW USERS */ + { 191, -2 }, /* (7) cmd ::= SHOW MODULES */ + { 191, -2 }, /* (8) cmd ::= SHOW QUERIES */ + { 191, -2 }, /* (9) cmd ::= SHOW CONNECTIONS */ + { 191, -2 }, /* (10) cmd ::= SHOW STREAMS */ + { 191, -2 }, /* (11) cmd ::= SHOW VARIABLES */ + { 191, -2 }, /* (12) cmd ::= SHOW SCORES */ + { 191, -2 }, /* (13) cmd ::= SHOW GRANTS */ + { 191, -2 }, /* (14) cmd ::= SHOW VNODES */ + { 191, -3 }, /* (15) cmd ::= SHOW VNODES IPTOKEN */ + { 192, 0 }, /* (16) dbPrefix ::= */ + { 192, -2 }, /* (17) dbPrefix ::= ids DOT */ + { 194, 0 }, /* (18) cpxName ::= */ + { 194, -2 }, /* (19) cpxName ::= DOT ids */ + { 191, -5 }, /* (20) cmd ::= SHOW CREATE TABLE ids cpxName */ + { 191, -5 }, /* (21) cmd ::= SHOW CREATE STABLE ids cpxName */ + { 191, -4 }, /* (22) cmd ::= SHOW CREATE DATABASE ids */ + { 191, -3 }, /* (23) cmd ::= SHOW dbPrefix TABLES */ + { 191, -5 }, /* (24) cmd ::= SHOW dbPrefix TABLES LIKE ids */ + { 191, -3 }, /* (25) cmd ::= SHOW dbPrefix STABLES */ + { 191, -5 }, /* (26) cmd ::= SHOW dbPrefix STABLES LIKE ids */ + { 191, -3 }, /* (27) cmd ::= SHOW dbPrefix VGROUPS */ + { 191, -4 }, /* (28) cmd ::= SHOW dbPrefix VGROUPS ids */ + { 191, -5 }, /* (29) cmd ::= DROP TABLE ifexists ids cpxName */ + { 191, -5 }, /* (30) cmd ::= DROP STABLE ifexists ids cpxName */ + { 191, -4 }, /* (31) cmd ::= DROP DATABASE ifexists ids */ + { 191, -4 }, /* (32) cmd ::= DROP TOPIC ifexists ids */ + { 191, -3 }, /* (33) cmd ::= DROP DNODE ids */ + { 191, -3 }, /* (34) cmd ::= DROP USER ids */ + { 191, -3 }, /* (35) cmd ::= DROP ACCOUNT ids */ + { 191, -2 }, /* (36) cmd ::= USE ids */ + { 191, -3 }, /* (37) cmd ::= DESCRIBE ids cpxName */ + { 191, -5 }, /* (38) cmd ::= ALTER USER ids PASS ids */ + { 191, -5 }, /* (39) cmd ::= ALTER USER ids PRIVILEGE ids */ + { 191, -4 }, /* (40) cmd ::= ALTER DNODE ids ids */ + { 191, -5 }, /* (41) cmd ::= ALTER DNODE ids ids ids */ + { 191, -3 }, /* (42) cmd ::= ALTER LOCAL ids */ + { 191, -4 }, /* (43) cmd ::= ALTER LOCAL ids ids */ + { 191, -4 }, /* (44) cmd ::= ALTER DATABASE ids alter_db_optr */ + { 191, -4 }, /* (45) cmd ::= ALTER TOPIC ids alter_topic_optr */ + { 191, -4 }, /* (46) cmd ::= ALTER ACCOUNT ids acct_optr */ + { 191, -6 }, /* (47) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ + { 193, -1 }, /* (48) ids ::= ID */ + { 193, -1 }, /* (49) ids ::= STRING */ + { 195, -2 }, /* (50) ifexists ::= IF EXISTS */ + { 195, 0 }, /* (51) ifexists ::= */ + { 199, -3 }, /* (52) ifnotexists ::= IF NOT EXISTS */ + { 199, 0 }, /* (53) ifnotexists ::= */ + { 191, -3 }, /* (54) cmd ::= CREATE DNODE ids */ + { 191, -6 }, /* (55) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ + { 191, -5 }, /* (56) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ + { 191, -5 }, /* (57) cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ + { 191, -5 }, /* (58) cmd ::= CREATE USER ids PASS ids */ + { 202, 0 }, /* (59) pps ::= */ + { 202, -2 }, /* (60) pps ::= PPS INTEGER */ + { 203, 0 }, /* (61) tseries ::= */ + { 203, -2 }, /* (62) tseries ::= TSERIES INTEGER */ + { 204, 0 }, /* (63) dbs ::= */ + { 204, -2 }, /* (64) dbs ::= DBS INTEGER */ + { 205, 0 }, /* (65) streams ::= */ + { 205, -2 }, /* (66) streams ::= STREAMS INTEGER */ + { 206, 0 }, /* (67) storage ::= */ + { 206, -2 }, /* (68) storage ::= STORAGE INTEGER */ + { 207, 0 }, /* (69) qtime ::= */ + { 207, -2 }, /* (70) qtime ::= QTIME INTEGER */ + { 208, 0 }, /* (71) users ::= */ + { 208, -2 }, /* (72) users ::= USERS INTEGER */ + { 209, 0 }, /* (73) conns ::= */ + { 209, -2 }, /* (74) conns ::= CONNS INTEGER */ + { 210, 0 }, /* (75) state ::= */ + { 210, -2 }, /* (76) state ::= STATE ids */ + { 198, -9 }, /* (77) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ + { 211, -2 }, /* (78) keep ::= KEEP tagitemlist */ + { 213, -2 }, /* (79) cache ::= CACHE INTEGER */ + { 214, -2 }, /* (80) replica ::= REPLICA INTEGER */ + { 215, -2 }, /* (81) quorum ::= QUORUM INTEGER */ + { 216, -2 }, /* (82) days ::= DAYS INTEGER */ + { 217, -2 }, /* (83) minrows ::= MINROWS INTEGER */ + { 218, -2 }, /* (84) maxrows ::= MAXROWS INTEGER */ + { 219, -2 }, /* (85) blocks ::= BLOCKS INTEGER */ + { 220, -2 }, /* (86) ctime ::= CTIME INTEGER */ + { 221, -2 }, /* (87) wal ::= WAL INTEGER */ + { 222, -2 }, /* (88) fsync ::= FSYNC INTEGER */ + { 223, -2 }, /* (89) comp ::= COMP INTEGER */ + { 224, -2 }, /* (90) prec ::= PRECISION STRING */ + { 225, -2 }, /* (91) update ::= UPDATE INTEGER */ + { 226, -2 }, /* (92) cachelast ::= CACHELAST INTEGER */ + { 227, -2 }, /* (93) partitions ::= PARTITIONS INTEGER */ + { 200, 0 }, /* (94) db_optr ::= */ + { 200, -2 }, /* (95) db_optr ::= db_optr cache */ + { 200, -2 }, /* (96) db_optr ::= db_optr replica */ + { 200, -2 }, /* (97) db_optr ::= db_optr quorum */ + { 200, -2 }, /* (98) db_optr ::= db_optr days */ + { 200, -2 }, /* (99) db_optr ::= db_optr minrows */ + { 200, -2 }, /* (100) db_optr ::= db_optr maxrows */ + { 200, -2 }, /* (101) db_optr ::= db_optr blocks */ + { 200, -2 }, /* (102) db_optr ::= db_optr ctime */ + { 200, -2 }, /* (103) db_optr ::= db_optr wal */ + { 200, -2 }, /* (104) db_optr ::= db_optr fsync */ + { 200, -2 }, /* (105) db_optr ::= db_optr comp */ + { 200, -2 }, /* (106) db_optr ::= db_optr prec */ + { 200, -2 }, /* (107) db_optr ::= db_optr keep */ + { 200, -2 }, /* (108) db_optr ::= db_optr update */ + { 200, -2 }, /* (109) db_optr ::= db_optr cachelast */ + { 201, -1 }, /* (110) topic_optr ::= db_optr */ + { 201, -2 }, /* (111) topic_optr ::= topic_optr partitions */ + { 196, 0 }, /* (112) alter_db_optr ::= */ + { 196, -2 }, /* (113) alter_db_optr ::= alter_db_optr replica */ + { 196, -2 }, /* (114) alter_db_optr ::= alter_db_optr quorum */ + { 196, -2 }, /* (115) alter_db_optr ::= alter_db_optr keep */ + { 196, -2 }, /* (116) alter_db_optr ::= alter_db_optr blocks */ + { 196, -2 }, /* (117) alter_db_optr ::= alter_db_optr comp */ + { 196, -2 }, /* (118) alter_db_optr ::= alter_db_optr wal */ + { 196, -2 }, /* (119) alter_db_optr ::= alter_db_optr fsync */ + { 196, -2 }, /* (120) alter_db_optr ::= alter_db_optr update */ + { 196, -2 }, /* (121) alter_db_optr ::= alter_db_optr cachelast */ + { 197, -1 }, /* (122) alter_topic_optr ::= alter_db_optr */ + { 197, -2 }, /* (123) alter_topic_optr ::= alter_topic_optr partitions */ + { 228, -1 }, /* (124) typename ::= ids */ + { 228, -4 }, /* (125) typename ::= ids LP signed RP */ + { 228, -2 }, /* (126) typename ::= ids UNSIGNED */ + { 229, -1 }, /* (127) signed ::= INTEGER */ + { 229, -2 }, /* (128) signed ::= PLUS INTEGER */ + { 229, -2 }, /* (129) signed ::= MINUS INTEGER */ + { 191, -3 }, /* (130) cmd ::= CREATE TABLE create_table_args */ + { 191, -3 }, /* (131) cmd ::= CREATE TABLE create_stable_args */ + { 191, -3 }, /* (132) cmd ::= CREATE STABLE create_stable_args */ + { 191, -3 }, /* (133) cmd ::= CREATE TABLE create_table_list */ + { 232, -1 }, /* (134) create_table_list ::= create_from_stable */ + { 232, -2 }, /* (135) create_table_list ::= create_table_list create_from_stable */ + { 230, -6 }, /* (136) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + { 231, -10 }, /* (137) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + { 233, -10 }, /* (138) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ + { 233, -13 }, /* (139) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ + { 235, -3 }, /* (140) tagNamelist ::= tagNamelist COMMA ids */ + { 235, -1 }, /* (141) tagNamelist ::= ids */ + { 230, -5 }, /* (142) create_table_args ::= ifnotexists ids cpxName AS select */ + { 234, -3 }, /* (143) columnlist ::= columnlist COMMA column */ + { 234, -1 }, /* (144) columnlist ::= column */ + { 237, -2 }, /* (145) column ::= ids typename */ + { 212, -3 }, /* (146) tagitemlist ::= tagitemlist COMMA tagitem */ + { 212, -1 }, /* (147) tagitemlist ::= tagitem */ + { 238, -1 }, /* (148) tagitem ::= INTEGER */ + { 238, -1 }, /* (149) tagitem ::= FLOAT */ + { 238, -1 }, /* (150) tagitem ::= STRING */ + { 238, -1 }, /* (151) tagitem ::= BOOL */ + { 238, -1 }, /* (152) tagitem ::= NULL */ + { 238, -2 }, /* (153) tagitem ::= MINUS INTEGER */ + { 238, -2 }, /* (154) tagitem ::= MINUS FLOAT */ + { 238, -2 }, /* (155) tagitem ::= PLUS INTEGER */ + { 238, -2 }, /* (156) tagitem ::= PLUS FLOAT */ + { 236, -14 }, /* (157) select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ + { 236, -3 }, /* (158) select ::= LP select RP */ + { 252, -1 }, /* (159) union ::= select */ + { 252, -4 }, /* (160) union ::= union UNION ALL select */ + { 191, -1 }, /* (161) cmd ::= union */ + { 236, -2 }, /* (162) select ::= SELECT selcollist */ + { 253, -2 }, /* (163) sclp ::= selcollist COMMA */ + { 253, 0 }, /* (164) sclp ::= */ + { 239, -4 }, /* (165) selcollist ::= sclp distinct expr as */ + { 239, -2 }, /* (166) selcollist ::= sclp STAR */ + { 256, -2 }, /* (167) as ::= AS ids */ + { 256, -1 }, /* (168) as ::= ids */ + { 256, 0 }, /* (169) as ::= */ + { 254, -1 }, /* (170) distinct ::= DISTINCT */ + { 254, 0 }, /* (171) distinct ::= */ + { 240, -2 }, /* (172) from ::= FROM tablelist */ + { 240, -2 }, /* (173) from ::= FROM sub */ + { 258, -3 }, /* (174) sub ::= LP union RP */ + { 258, -4 }, /* (175) sub ::= LP union RP ids */ + { 258, -6 }, /* (176) sub ::= sub COMMA LP union RP ids */ + { 257, -2 }, /* (177) tablelist ::= ids cpxName */ + { 257, -3 }, /* (178) tablelist ::= ids cpxName ids */ + { 257, -4 }, /* (179) tablelist ::= tablelist COMMA ids cpxName */ + { 257, -5 }, /* (180) tablelist ::= tablelist COMMA ids cpxName ids */ + { 259, -1 }, /* (181) tmvar ::= VARIABLE */ + { 242, -4 }, /* (182) interval_opt ::= INTERVAL LP tmvar RP */ + { 242, -6 }, /* (183) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ + { 242, 0 }, /* (184) interval_opt ::= */ + { 243, 0 }, /* (185) session_option ::= */ + { 243, -7 }, /* (186) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + { 244, 0 }, /* (187) windowstate_option ::= */ + { 244, -4 }, /* (188) windowstate_option ::= STATE_WINDOW LP ids RP */ + { 245, 0 }, /* (189) fill_opt ::= */ + { 245, -6 }, /* (190) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + { 245, -4 }, /* (191) fill_opt ::= FILL LP ID RP */ + { 246, -4 }, /* (192) sliding_opt ::= SLIDING LP tmvar RP */ + { 246, 0 }, /* (193) sliding_opt ::= */ + { 248, 0 }, /* (194) orderby_opt ::= */ + { 248, -3 }, /* (195) orderby_opt ::= ORDER BY sortlist */ + { 260, -4 }, /* (196) sortlist ::= sortlist COMMA item sortorder */ + { 260, -2 }, /* (197) sortlist ::= item sortorder */ + { 262, -2 }, /* (198) item ::= ids cpxName */ + { 263, -1 }, /* (199) sortorder ::= ASC */ + { 263, -1 }, /* (200) sortorder ::= DESC */ + { 263, 0 }, /* (201) sortorder ::= */ + { 247, 0 }, /* (202) groupby_opt ::= */ + { 247, -3 }, /* (203) groupby_opt ::= GROUP BY grouplist */ + { 264, -3 }, /* (204) grouplist ::= grouplist COMMA item */ + { 264, -1 }, /* (205) grouplist ::= item */ + { 249, 0 }, /* (206) having_opt ::= */ + { 249, -2 }, /* (207) having_opt ::= HAVING expr */ + { 251, 0 }, /* (208) limit_opt ::= */ + { 251, -2 }, /* (209) limit_opt ::= LIMIT signed */ + { 251, -4 }, /* (210) limit_opt ::= LIMIT signed OFFSET signed */ + { 251, -4 }, /* (211) limit_opt ::= LIMIT signed COMMA signed */ + { 250, 0 }, /* (212) slimit_opt ::= */ + { 250, -2 }, /* (213) slimit_opt ::= SLIMIT signed */ + { 250, -4 }, /* (214) slimit_opt ::= SLIMIT signed SOFFSET signed */ + { 250, -4 }, /* (215) slimit_opt ::= SLIMIT signed COMMA signed */ + { 241, 0 }, /* (216) where_opt ::= */ + { 241, -2 }, /* (217) where_opt ::= WHERE expr */ + { 255, -3 }, /* (218) expr ::= LP expr RP */ + { 255, -1 }, /* (219) expr ::= ID */ + { 255, -3 }, /* (220) expr ::= ID DOT ID */ + { 255, -3 }, /* (221) expr ::= ID DOT STAR */ + { 255, -1 }, /* (222) expr ::= INTEGER */ + { 255, -2 }, /* (223) expr ::= MINUS INTEGER */ + { 255, -2 }, /* (224) expr ::= PLUS INTEGER */ + { 255, -1 }, /* (225) expr ::= FLOAT */ + { 255, -2 }, /* (226) expr ::= MINUS FLOAT */ + { 255, -2 }, /* (227) expr ::= PLUS FLOAT */ + { 255, -1 }, /* (228) expr ::= STRING */ + { 255, -1 }, /* (229) expr ::= NOW */ + { 255, -1 }, /* (230) expr ::= VARIABLE */ + { 255, -2 }, /* (231) expr ::= PLUS VARIABLE */ + { 255, -2 }, /* (232) expr ::= MINUS VARIABLE */ + { 255, -1 }, /* (233) expr ::= BOOL */ + { 255, -1 }, /* (234) expr ::= NULL */ + { 255, -4 }, /* (235) expr ::= ID LP exprlist RP */ + { 255, -4 }, /* (236) expr ::= ID LP STAR RP */ + { 255, -3 }, /* (237) expr ::= expr IS NULL */ + { 255, -4 }, /* (238) expr ::= expr IS NOT NULL */ + { 255, -3 }, /* (239) expr ::= expr LT expr */ + { 255, -3 }, /* (240) expr ::= expr GT expr */ + { 255, -3 }, /* (241) expr ::= expr LE expr */ + { 255, -3 }, /* (242) expr ::= expr GE expr */ + { 255, -3 }, /* (243) expr ::= expr NE expr */ + { 255, -3 }, /* (244) expr ::= expr EQ expr */ + { 255, -5 }, /* (245) expr ::= expr BETWEEN expr AND expr */ + { 255, -3 }, /* (246) expr ::= expr AND expr */ + { 255, -3 }, /* (247) expr ::= expr OR expr */ + { 255, -3 }, /* (248) expr ::= expr PLUS expr */ + { 255, -3 }, /* (249) expr ::= expr MINUS expr */ + { 255, -3 }, /* (250) expr ::= expr STAR expr */ + { 255, -3 }, /* (251) expr ::= expr SLASH expr */ + { 255, -3 }, /* (252) expr ::= expr REM expr */ + { 255, -3 }, /* (253) expr ::= expr LIKE expr */ + { 255, -5 }, /* (254) expr ::= expr IN LP exprlist RP */ + { 265, -3 }, /* (255) exprlist ::= exprlist COMMA expritem */ + { 265, -1 }, /* (256) exprlist ::= expritem */ + { 266, -1 }, /* (257) expritem ::= expr */ + { 266, 0 }, /* (258) expritem ::= */ + { 191, -3 }, /* (259) cmd ::= RESET QUERY CACHE */ + { 191, -3 }, /* (260) cmd ::= SYNCDB ids REPLICA */ + { 191, -7 }, /* (261) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + { 191, -7 }, /* (262) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + { 191, -7 }, /* (263) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + { 191, -7 }, /* (264) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + { 191, -7 }, /* (265) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + { 191, -8 }, /* (266) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + { 191, -9 }, /* (267) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + { 191, -7 }, /* (268) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + { 191, -7 }, /* (269) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + { 191, -7 }, /* (270) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + { 191, -7 }, /* (271) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + { 191, -7 }, /* (272) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + { 191, -7 }, /* (273) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + { 191, -8 }, /* (274) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + { 191, -9 }, /* (275) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + { 191, -7 }, /* (276) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + { 191, -3 }, /* (277) cmd ::= KILL CONNECTION INTEGER */ + { 191, -5 }, /* (278) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + { 191, -5 }, /* (279) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2379,34 +2082,30 @@ static void yy_accept(yyParser*); /* Forward Declaration */ ** only called from one place, optimizing compilers will in-line it, which ** means that the extra parameters have no performance impact. */ -static YYACTIONTYPE yy_reduce( +static void yy_reduce( yyParser *yypParser, /* The parser */ unsigned int yyruleno, /* Number of the rule by which to reduce */ int yyLookahead, /* Lookahead token, or YYNOCODE if none */ ParseTOKENTYPE yyLookaheadToken /* Value of the lookahead token */ - ParseCTX_PDECL /* %extra_context */ ){ int yygoto; /* The next state */ - YYACTIONTYPE yyact; /* The next action */ + int yyact; /* The next action */ yyStackEntry *yymsp; /* The top of the parser's stack */ int yysize; /* Amount to pop the stack */ - ParseARG_FETCH + ParseARG_FETCH; (void)yyLookahead; (void)yyLookaheadToken; yymsp = yypParser->yytos; #ifndef NDEBUG if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ - yysize = yyRuleInfoNRhs[yyruleno]; + yysize = yyRuleInfo[yyruleno].nrhs; if( yysize ){ - fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", + fprintf(yyTraceFILE, "%sReduce %d [%s], go to state %d.\n", yyTracePrompt, - yyruleno, yyRuleName[yyruleno], - yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ yypParser->yyhwm++; @@ -2424,19 +2123,13 @@ static YYACTIONTYPE yy_reduce( #if YYSTACKDEPTH>0 if( yypParser->yytos>=yypParser->yystackEnd ){ yyStackOverflow(yypParser); - /* The call to yyStackOverflow() above pops the stack until it is - ** empty, causing the main parser loop to exit. So the return value - ** is never used and does not matter. */ - return 0; + return; } #else if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ if( yyGrowStack(yypParser) ){ yyStackOverflow(yypParser); - /* The call to yyStackOverflow() above pops the stack until it is - ** empty, causing the main parser loop to exit. So the return value - ** is never used and does not matter. */ - return 0; + return; } yymsp = yypParser->yytos; } @@ -2627,13 +2320,13 @@ static YYACTIONTYPE yy_reduce( break; case 44: /* cmd ::= ALTER DATABASE ids alter_db_optr */ case 45: /* cmd ::= ALTER TOPIC ids alter_topic_optr */ yytestcase(yyruleno==45); -{ SStrToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy114, &t);} +{ SStrToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy454, &t);} break; case 46: /* cmd ::= ALTER ACCOUNT ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy183);} +{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy397);} break; case 47: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy183);} +{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy397);} break; case 48: /* ids ::= ID */ case 49: /* ids ::= STRING */ yytestcase(yyruleno==49); @@ -2655,11 +2348,11 @@ static YYACTIONTYPE yy_reduce( { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 1, &yymsp[0].minor.yy0);} break; case 55: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy183);} +{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy397);} break; case 56: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ case 57: /* cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ yytestcase(yyruleno==57); -{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy114, &yymsp[-2].minor.yy0);} +{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy454, &yymsp[-2].minor.yy0);} break; case 58: /* cmd ::= CREATE USER ids PASS ids */ { setCreateUserSql(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);} @@ -2688,20 +2381,20 @@ static YYACTIONTYPE yy_reduce( break; case 77: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ { - yylhsminor.yy183.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; - yylhsminor.yy183.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; - yylhsminor.yy183.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; - yylhsminor.yy183.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; - yylhsminor.yy183.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; - yylhsminor.yy183.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy183.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy183.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; - yylhsminor.yy183.stat = yymsp[0].minor.yy0; + yylhsminor.yy397.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; + yylhsminor.yy397.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; + yylhsminor.yy397.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; + yylhsminor.yy397.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; + yylhsminor.yy397.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; + yylhsminor.yy397.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy397.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy397.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; + yylhsminor.yy397.stat = yymsp[0].minor.yy0; } - yymsp[-8].minor.yy183 = yylhsminor.yy183; + yymsp[-8].minor.yy397 = yylhsminor.yy397; break; case 78: /* keep ::= KEEP tagitemlist */ -{ yymsp[-1].minor.yy193 = yymsp[0].minor.yy193; } +{ yymsp[-1].minor.yy15 = yymsp[0].minor.yy15; } break; case 79: /* cache ::= CACHE INTEGER */ case 80: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==80); @@ -2721,234 +2414,234 @@ static YYACTIONTYPE yy_reduce( { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; case 94: /* db_optr ::= */ -{setDefaultCreateDbOption(&yymsp[1].minor.yy114); yymsp[1].minor.yy114.dbType = TSDB_DB_TYPE_DEFAULT;} +{setDefaultCreateDbOption(&yymsp[1].minor.yy454); yymsp[1].minor.yy454.dbType = TSDB_DB_TYPE_DEFAULT;} break; case 95: /* db_optr ::= db_optr cache */ -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; +{ yylhsminor.yy454 = yymsp[-1].minor.yy454; yylhsminor.yy454.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy454 = yylhsminor.yy454; break; case 96: /* db_optr ::= db_optr replica */ case 113: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==113); -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; +{ yylhsminor.yy454 = yymsp[-1].minor.yy454; yylhsminor.yy454.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy454 = yylhsminor.yy454; break; case 97: /* db_optr ::= db_optr quorum */ case 114: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==114); -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; +{ yylhsminor.yy454 = yymsp[-1].minor.yy454; yylhsminor.yy454.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy454 = yylhsminor.yy454; break; case 98: /* db_optr ::= db_optr days */ -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; +{ yylhsminor.yy454 = yymsp[-1].minor.yy454; yylhsminor.yy454.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy454 = yylhsminor.yy454; break; case 99: /* db_optr ::= db_optr minrows */ -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; +{ yylhsminor.yy454 = yymsp[-1].minor.yy454; yylhsminor.yy454.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy454 = yylhsminor.yy454; break; case 100: /* db_optr ::= db_optr maxrows */ -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; +{ yylhsminor.yy454 = yymsp[-1].minor.yy454; yylhsminor.yy454.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy454 = yylhsminor.yy454; break; case 101: /* db_optr ::= db_optr blocks */ case 116: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==116); -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; +{ yylhsminor.yy454 = yymsp[-1].minor.yy454; yylhsminor.yy454.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy454 = yylhsminor.yy454; break; case 102: /* db_optr ::= db_optr ctime */ -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; +{ yylhsminor.yy454 = yymsp[-1].minor.yy454; yylhsminor.yy454.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy454 = yylhsminor.yy454; break; case 103: /* db_optr ::= db_optr wal */ case 118: /* alter_db_optr ::= alter_db_optr wal */ yytestcase(yyruleno==118); -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; +{ yylhsminor.yy454 = yymsp[-1].minor.yy454; yylhsminor.yy454.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy454 = yylhsminor.yy454; break; case 104: /* db_optr ::= db_optr fsync */ case 119: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==119); -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; +{ yylhsminor.yy454 = yymsp[-1].minor.yy454; yylhsminor.yy454.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy454 = yylhsminor.yy454; break; case 105: /* db_optr ::= db_optr comp */ case 117: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==117); -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; +{ yylhsminor.yy454 = yymsp[-1].minor.yy454; yylhsminor.yy454.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy454 = yylhsminor.yy454; break; case 106: /* db_optr ::= db_optr prec */ -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.precision = yymsp[0].minor.yy0; } - yymsp[-1].minor.yy114 = yylhsminor.yy114; +{ yylhsminor.yy454 = yymsp[-1].minor.yy454; yylhsminor.yy454.precision = yymsp[0].minor.yy0; } + yymsp[-1].minor.yy454 = yylhsminor.yy454; break; case 107: /* db_optr ::= db_optr keep */ case 115: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==115); -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.keep = yymsp[0].minor.yy193; } - yymsp[-1].minor.yy114 = yylhsminor.yy114; +{ yylhsminor.yy454 = yymsp[-1].minor.yy454; yylhsminor.yy454.keep = yymsp[0].minor.yy15; } + yymsp[-1].minor.yy454 = yylhsminor.yy454; break; case 108: /* db_optr ::= db_optr update */ case 120: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==120); -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; +{ yylhsminor.yy454 = yymsp[-1].minor.yy454; yylhsminor.yy454.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy454 = yylhsminor.yy454; break; case 109: /* db_optr ::= db_optr cachelast */ case 121: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==121); -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; +{ yylhsminor.yy454 = yymsp[-1].minor.yy454; yylhsminor.yy454.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy454 = yylhsminor.yy454; break; case 110: /* topic_optr ::= db_optr */ case 122: /* alter_topic_optr ::= alter_db_optr */ yytestcase(yyruleno==122); -{ yylhsminor.yy114 = yymsp[0].minor.yy114; yylhsminor.yy114.dbType = TSDB_DB_TYPE_TOPIC; } - yymsp[0].minor.yy114 = yylhsminor.yy114; +{ yylhsminor.yy454 = yymsp[0].minor.yy454; yylhsminor.yy454.dbType = TSDB_DB_TYPE_TOPIC; } + yymsp[0].minor.yy454 = yylhsminor.yy454; break; case 111: /* topic_optr ::= topic_optr partitions */ case 123: /* alter_topic_optr ::= alter_topic_optr partitions */ yytestcase(yyruleno==123); -{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy114 = yylhsminor.yy114; +{ yylhsminor.yy454 = yymsp[-1].minor.yy454; yylhsminor.yy454.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy454 = yylhsminor.yy454; break; case 112: /* alter_db_optr ::= */ -{ setDefaultCreateDbOption(&yymsp[1].minor.yy114); yymsp[1].minor.yy114.dbType = TSDB_DB_TYPE_DEFAULT;} +{ setDefaultCreateDbOption(&yymsp[1].minor.yy454); yymsp[1].minor.yy454.dbType = TSDB_DB_TYPE_DEFAULT;} break; case 124: /* typename ::= ids */ { yymsp[0].minor.yy0.type = 0; - tSetColumnType (&yylhsminor.yy27, &yymsp[0].minor.yy0); + tSetColumnType (&yylhsminor.yy505, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy27 = yylhsminor.yy27; + yymsp[0].minor.yy505 = yylhsminor.yy505; break; case 125: /* typename ::= ids LP signed RP */ { - if (yymsp[-1].minor.yy473 <= 0) { + if (yymsp[-1].minor.yy489 <= 0) { yymsp[-3].minor.yy0.type = 0; - tSetColumnType(&yylhsminor.yy27, &yymsp[-3].minor.yy0); + tSetColumnType(&yylhsminor.yy505, &yymsp[-3].minor.yy0); } else { - yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy473; // negative value of name length - tSetColumnType(&yylhsminor.yy27, &yymsp[-3].minor.yy0); + yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy489; // negative value of name length + tSetColumnType(&yylhsminor.yy505, &yymsp[-3].minor.yy0); } } - yymsp[-3].minor.yy27 = yylhsminor.yy27; + yymsp[-3].minor.yy505 = yylhsminor.yy505; break; case 126: /* typename ::= ids UNSIGNED */ { yymsp[-1].minor.yy0.type = 0; yymsp[-1].minor.yy0.n = ((yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z); - tSetColumnType (&yylhsminor.yy27, &yymsp[-1].minor.yy0); + tSetColumnType (&yylhsminor.yy505, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy27 = yylhsminor.yy27; + yymsp[-1].minor.yy505 = yylhsminor.yy505; break; case 127: /* signed ::= INTEGER */ -{ yylhsminor.yy473 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[0].minor.yy473 = yylhsminor.yy473; +{ yylhsminor.yy489 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[0].minor.yy489 = yylhsminor.yy489; break; case 128: /* signed ::= PLUS INTEGER */ -{ yymsp[-1].minor.yy473 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy489 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } break; case 129: /* signed ::= MINUS INTEGER */ -{ yymsp[-1].minor.yy473 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} +{ yymsp[-1].minor.yy489 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} break; case 133: /* cmd ::= CREATE TABLE create_table_list */ -{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy270;} +{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy482;} break; case 134: /* create_table_list ::= create_from_stable */ { SCreateTableSql* pCreateTable = calloc(1, sizeof(SCreateTableSql)); pCreateTable->childTableInfo = taosArrayInit(4, sizeof(SCreatedTableInfo)); - taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy192); + taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy390); pCreateTable->type = TSQL_CREATE_TABLE_FROM_STABLE; - yylhsminor.yy270 = pCreateTable; + yylhsminor.yy482 = pCreateTable; } - yymsp[0].minor.yy270 = yylhsminor.yy270; + yymsp[0].minor.yy482 = yylhsminor.yy482; break; case 135: /* create_table_list ::= create_table_list create_from_stable */ { - taosArrayPush(yymsp[-1].minor.yy270->childTableInfo, &yymsp[0].minor.yy192); - yylhsminor.yy270 = yymsp[-1].minor.yy270; + taosArrayPush(yymsp[-1].minor.yy482->childTableInfo, &yymsp[0].minor.yy390); + yylhsminor.yy482 = yymsp[-1].minor.yy482; } - yymsp[-1].minor.yy270 = yylhsminor.yy270; + yymsp[-1].minor.yy482 = yylhsminor.yy482; break; case 136: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ { - yylhsminor.yy270 = tSetCreateTableInfo(yymsp[-1].minor.yy193, NULL, NULL, TSQL_CREATE_TABLE); - setSqlInfo(pInfo, yylhsminor.yy270, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy482 = tSetCreateTableInfo(yymsp[-1].minor.yy15, NULL, NULL, TSQL_CREATE_TABLE); + setSqlInfo(pInfo, yylhsminor.yy482, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-4].minor.yy0, &yymsp[-5].minor.yy0); } - yymsp[-5].minor.yy270 = yylhsminor.yy270; + yymsp[-5].minor.yy482 = yylhsminor.yy482; break; case 137: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ { - yylhsminor.yy270 = tSetCreateTableInfo(yymsp[-5].minor.yy193, yymsp[-1].minor.yy193, NULL, TSQL_CREATE_STABLE); - setSqlInfo(pInfo, yylhsminor.yy270, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy482 = tSetCreateTableInfo(yymsp[-5].minor.yy15, yymsp[-1].minor.yy15, NULL, TSQL_CREATE_STABLE); + setSqlInfo(pInfo, yylhsminor.yy482, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); } - yymsp[-9].minor.yy270 = yylhsminor.yy270; + yymsp[-9].minor.yy482 = yylhsminor.yy482; break; case 138: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; - yylhsminor.yy192 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy193, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); + yylhsminor.yy390 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy15, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); } - yymsp[-9].minor.yy192 = yylhsminor.yy192; + yymsp[-9].minor.yy390 = yylhsminor.yy390; break; case 139: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ { yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; yymsp[-11].minor.yy0.n += yymsp[-10].minor.yy0.n; - yylhsminor.yy192 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy193, yymsp[-1].minor.yy193, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0); + yylhsminor.yy390 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy15, yymsp[-1].minor.yy15, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0); } - yymsp[-12].minor.yy192 = yylhsminor.yy192; + yymsp[-12].minor.yy390 = yylhsminor.yy390; break; case 140: /* tagNamelist ::= tagNamelist COMMA ids */ -{taosArrayPush(yymsp[-2].minor.yy193, &yymsp[0].minor.yy0); yylhsminor.yy193 = yymsp[-2].minor.yy193; } - yymsp[-2].minor.yy193 = yylhsminor.yy193; +{taosArrayPush(yymsp[-2].minor.yy15, &yymsp[0].minor.yy0); yylhsminor.yy15 = yymsp[-2].minor.yy15; } + yymsp[-2].minor.yy15 = yylhsminor.yy15; break; case 141: /* tagNamelist ::= ids */ -{yylhsminor.yy193 = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(yylhsminor.yy193, &yymsp[0].minor.yy0);} - yymsp[0].minor.yy193 = yylhsminor.yy193; +{yylhsminor.yy15 = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(yylhsminor.yy15, &yymsp[0].minor.yy0);} + yymsp[0].minor.yy15 = yylhsminor.yy15; break; case 142: /* create_table_args ::= ifnotexists ids cpxName AS select */ { - yylhsminor.yy270 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy124, TSQL_CREATE_STREAM); - setSqlInfo(pInfo, yylhsminor.yy270, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy482 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy134, TSQL_CREATE_STREAM); + setSqlInfo(pInfo, yylhsminor.yy482, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-3].minor.yy0.n += yymsp[-2].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-3].minor.yy0, &yymsp[-4].minor.yy0); } - yymsp[-4].minor.yy270 = yylhsminor.yy270; + yymsp[-4].minor.yy482 = yylhsminor.yy482; break; case 143: /* columnlist ::= columnlist COMMA column */ -{taosArrayPush(yymsp[-2].minor.yy193, &yymsp[0].minor.yy27); yylhsminor.yy193 = yymsp[-2].minor.yy193; } - yymsp[-2].minor.yy193 = yylhsminor.yy193; +{taosArrayPush(yymsp[-2].minor.yy15, &yymsp[0].minor.yy505); yylhsminor.yy15 = yymsp[-2].minor.yy15; } + yymsp[-2].minor.yy15 = yylhsminor.yy15; break; case 144: /* columnlist ::= column */ -{yylhsminor.yy193 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy193, &yymsp[0].minor.yy27);} - yymsp[0].minor.yy193 = yylhsminor.yy193; +{yylhsminor.yy15 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy15, &yymsp[0].minor.yy505);} + yymsp[0].minor.yy15 = yylhsminor.yy15; break; case 145: /* column ::= ids typename */ { - tSetColumnInfo(&yylhsminor.yy27, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy27); + tSetColumnInfo(&yylhsminor.yy505, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy505); } - yymsp[-1].minor.yy27 = yylhsminor.yy27; + yymsp[-1].minor.yy505 = yylhsminor.yy505; break; case 146: /* tagitemlist ::= tagitemlist COMMA tagitem */ -{ yylhsminor.yy193 = tVariantListAppend(yymsp[-2].minor.yy193, &yymsp[0].minor.yy442, -1); } - yymsp[-2].minor.yy193 = yylhsminor.yy193; +{ yylhsminor.yy15 = tVariantListAppend(yymsp[-2].minor.yy15, &yymsp[0].minor.yy380, -1); } + yymsp[-2].minor.yy15 = yylhsminor.yy15; break; case 147: /* tagitemlist ::= tagitem */ -{ yylhsminor.yy193 = tVariantListAppend(NULL, &yymsp[0].minor.yy442, -1); } - yymsp[0].minor.yy193 = yylhsminor.yy193; +{ yylhsminor.yy15 = tVariantListAppend(NULL, &yymsp[0].minor.yy380, -1); } + yymsp[0].minor.yy15 = yylhsminor.yy15; break; case 148: /* tagitem ::= INTEGER */ case 149: /* tagitem ::= FLOAT */ yytestcase(yyruleno==149); case 150: /* tagitem ::= STRING */ yytestcase(yyruleno==150); case 151: /* tagitem ::= BOOL */ yytestcase(yyruleno==151); -{ toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy442, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy442 = yylhsminor.yy442; +{ toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy380, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy380 = yylhsminor.yy380; break; case 152: /* tagitem ::= NULL */ -{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy442, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy442 = yylhsminor.yy442; +{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy380, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy380 = yylhsminor.yy380; break; case 153: /* tagitem ::= MINUS INTEGER */ case 154: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==154); @@ -2958,56 +2651,56 @@ static YYACTIONTYPE yy_reduce( yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type; toTSDBType(yymsp[-1].minor.yy0.type); - tVariantCreate(&yylhsminor.yy442, &yymsp[-1].minor.yy0); + tVariantCreate(&yylhsminor.yy380, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; + yymsp[-1].minor.yy380 = yylhsminor.yy380; break; case 157: /* select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ { - yylhsminor.yy124 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy193, yymsp[-11].minor.yy332, yymsp[-10].minor.yy454, yymsp[-4].minor.yy193, yymsp[-3].minor.yy193, &yymsp[-9].minor.yy392, &yymsp[-8].minor.yy447, &yymsp[-7].minor.yy76, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy193, &yymsp[0].minor.yy482, &yymsp[-1].minor.yy482, yymsp[-2].minor.yy454); + yylhsminor.yy134 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy15, yymsp[-11].minor.yy160, yymsp[-10].minor.yy328, yymsp[-4].minor.yy15, yymsp[-3].minor.yy15, &yymsp[-9].minor.yy496, &yymsp[-8].minor.yy151, &yymsp[-7].minor.yy96, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy15, &yymsp[0].minor.yy150, &yymsp[-1].minor.yy150, yymsp[-2].minor.yy328); } - yymsp[-13].minor.yy124 = yylhsminor.yy124; + yymsp[-13].minor.yy134 = yylhsminor.yy134; break; case 158: /* select ::= LP select RP */ -{yymsp[-2].minor.yy124 = yymsp[-1].minor.yy124;} +{yymsp[-2].minor.yy134 = yymsp[-1].minor.yy134;} break; case 159: /* union ::= select */ -{ yylhsminor.yy193 = setSubclause(NULL, yymsp[0].minor.yy124); } - yymsp[0].minor.yy193 = yylhsminor.yy193; +{ yylhsminor.yy15 = setSubclause(NULL, yymsp[0].minor.yy134); } + yymsp[0].minor.yy15 = yylhsminor.yy15; break; case 160: /* union ::= union UNION ALL select */ -{ yylhsminor.yy193 = appendSelectClause(yymsp[-3].minor.yy193, yymsp[0].minor.yy124); } - yymsp[-3].minor.yy193 = yylhsminor.yy193; +{ yylhsminor.yy15 = appendSelectClause(yymsp[-3].minor.yy15, yymsp[0].minor.yy134); } + yymsp[-3].minor.yy15 = yylhsminor.yy15; break; case 161: /* cmd ::= union */ -{ setSqlInfo(pInfo, yymsp[0].minor.yy193, NULL, TSDB_SQL_SELECT); } +{ setSqlInfo(pInfo, yymsp[0].minor.yy15, NULL, TSDB_SQL_SELECT); } break; case 162: /* select ::= SELECT selcollist */ { - yylhsminor.yy124 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy193, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + yylhsminor.yy134 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy15, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } - yymsp[-1].minor.yy124 = yylhsminor.yy124; + yymsp[-1].minor.yy134 = yylhsminor.yy134; break; case 163: /* sclp ::= selcollist COMMA */ -{yylhsminor.yy193 = yymsp[-1].minor.yy193;} - yymsp[-1].minor.yy193 = yylhsminor.yy193; +{yylhsminor.yy15 = yymsp[-1].minor.yy15;} + yymsp[-1].minor.yy15 = yylhsminor.yy15; break; case 164: /* sclp ::= */ case 194: /* orderby_opt ::= */ yytestcase(yyruleno==194); -{yymsp[1].minor.yy193 = 0;} +{yymsp[1].minor.yy15 = 0;} break; case 165: /* selcollist ::= sclp distinct expr as */ { - yylhsminor.yy193 = tSqlExprListAppend(yymsp[-3].minor.yy193, yymsp[-1].minor.yy454, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); + yylhsminor.yy15 = tSqlExprListAppend(yymsp[-3].minor.yy15, yymsp[-1].minor.yy328, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); } - yymsp[-3].minor.yy193 = yylhsminor.yy193; + yymsp[-3].minor.yy15 = yylhsminor.yy15; break; case 166: /* selcollist ::= sclp STAR */ { tSqlExpr *pNode = tSqlExprCreateIdValue(NULL, TK_ALL); - yylhsminor.yy193 = tSqlExprListAppend(yymsp[-1].minor.yy193, pNode, 0, 0); + yylhsminor.yy15 = tSqlExprListAppend(yymsp[-1].minor.yy15, pNode, 0, 0); } - yymsp[-1].minor.yy193 = yylhsminor.yy193; + yymsp[-1].minor.yy15 = yylhsminor.yy15; break; case 167: /* as ::= AS ids */ { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } @@ -3025,79 +2718,77 @@ static YYACTIONTYPE yy_reduce( break; case 172: /* from ::= FROM tablelist */ case 173: /* from ::= FROM sub */ yytestcase(yyruleno==173); -{yymsp[-1].minor.yy332 = yymsp[0].minor.yy332;} +{yymsp[-1].minor.yy160 = yymsp[0].minor.yy160;} break; case 174: /* sub ::= LP union RP */ -{yymsp[-2].minor.yy332 = addSubqueryElem(NULL, yymsp[-1].minor.yy193, NULL);} +{yymsp[-2].minor.yy160 = addSubqueryElem(NULL, yymsp[-1].minor.yy15, NULL);} break; case 175: /* sub ::= LP union RP ids */ -{yymsp[-3].minor.yy332 = addSubqueryElem(NULL, yymsp[-2].minor.yy193, &yymsp[0].minor.yy0);} +{yymsp[-3].minor.yy160 = addSubqueryElem(NULL, yymsp[-2].minor.yy15, &yymsp[0].minor.yy0);} break; case 176: /* sub ::= sub COMMA LP union RP ids */ -{yylhsminor.yy332 = addSubqueryElem(yymsp[-5].minor.yy332, yymsp[-2].minor.yy193, &yymsp[0].minor.yy0);} - yymsp[-5].minor.yy332 = yylhsminor.yy332; +{yylhsminor.yy160 = addSubqueryElem(yymsp[-5].minor.yy160, yymsp[-2].minor.yy15, &yymsp[0].minor.yy0);} + yymsp[-5].minor.yy160 = yylhsminor.yy160; break; case 177: /* tablelist ::= ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy332 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); + yylhsminor.yy160 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); } - yymsp[-1].minor.yy332 = yylhsminor.yy332; + yymsp[-1].minor.yy160 = yylhsminor.yy160; break; case 178: /* tablelist ::= ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy332 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); + yylhsminor.yy160 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy332 = yylhsminor.yy332; + yymsp[-2].minor.yy160 = yylhsminor.yy160; break; case 179: /* tablelist ::= tablelist COMMA ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy332 = setTableNameList(yymsp[-3].minor.yy332, &yymsp[-1].minor.yy0, NULL); + yylhsminor.yy160 = setTableNameList(yymsp[-3].minor.yy160, &yymsp[-1].minor.yy0, NULL); } - yymsp[-3].minor.yy332 = yylhsminor.yy332; + yymsp[-3].minor.yy160 = yylhsminor.yy160; break; case 180: /* tablelist ::= tablelist COMMA ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy332 = setTableNameList(yymsp[-4].minor.yy332, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); + yylhsminor.yy160 = setTableNameList(yymsp[-4].minor.yy160, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } - yymsp[-4].minor.yy332 = yylhsminor.yy332; + yymsp[-4].minor.yy160 = yylhsminor.yy160; break; case 181: /* tmvar ::= VARIABLE */ {yylhsminor.yy0 = yymsp[0].minor.yy0;} yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 182: /* interval_opt ::= INTERVAL LP tmvar RP */ -{yymsp[-3].minor.yy392.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy392.offset.n = 0;} +{yymsp[-3].minor.yy496.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy496.offset.n = 0;} break; case 183: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ -{yymsp[-5].minor.yy392.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy392.offset = yymsp[-1].minor.yy0;} +{yymsp[-5].minor.yy496.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy496.offset = yymsp[-1].minor.yy0;} break; case 184: /* interval_opt ::= */ -{memset(&yymsp[1].minor.yy392, 0, sizeof(yymsp[1].minor.yy392));} +{memset(&yymsp[1].minor.yy496, 0, sizeof(yymsp[1].minor.yy496));} break; case 185: /* session_option ::= */ -{yymsp[1].minor.yy447.col.n = 0; yymsp[1].minor.yy447.gap.n = 0;} +{yymsp[1].minor.yy151.col.n = 0; yymsp[1].minor.yy151.gap.n = 0;} break; case 186: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - yymsp[-6].minor.yy447.col = yymsp[-4].minor.yy0; - yymsp[-6].minor.yy447.gap = yymsp[-1].minor.yy0; + yymsp[-6].minor.yy151.col = yymsp[-4].minor.yy0; + yymsp[-6].minor.yy151.gap = yymsp[-1].minor.yy0; } break; case 187: /* windowstate_option ::= */ -{yymsp[1].minor.yy76.col.n = 0;} +{ yymsp[1].minor.yy96.col.n = 0; yymsp[1].minor.yy96.col.z = NULL;} break; case 188: /* windowstate_option ::= STATE_WINDOW LP ids RP */ -{ - yymsp[-3].minor.yy76.col = yymsp[-1].minor.yy0; -} +{ yymsp[-3].minor.yy96.col = yymsp[-1].minor.yy0; } break; case 189: /* fill_opt ::= */ -{ yymsp[1].minor.yy193 = 0; } +{ yymsp[1].minor.yy15 = 0; } break; case 190: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ { @@ -3105,14 +2796,14 @@ static YYACTIONTYPE yy_reduce( toTSDBType(yymsp[-3].minor.yy0.type); tVariantCreate(&A, &yymsp[-3].minor.yy0); - tVariantListInsert(yymsp[-1].minor.yy193, &A, -1, 0); - yymsp[-5].minor.yy193 = yymsp[-1].minor.yy193; + tVariantListInsert(yymsp[-1].minor.yy15, &A, -1, 0); + yymsp[-5].minor.yy15 = yymsp[-1].minor.yy15; } break; case 191: /* fill_opt ::= FILL LP ID RP */ { toTSDBType(yymsp[-1].minor.yy0.type); - yymsp[-3].minor.yy193 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); + yymsp[-3].minor.yy15 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); } break; case 192: /* sliding_opt ::= SLIDING LP tmvar RP */ @@ -3122,235 +2813,235 @@ static YYACTIONTYPE yy_reduce( {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } break; case 195: /* orderby_opt ::= ORDER BY sortlist */ -{yymsp[-2].minor.yy193 = yymsp[0].minor.yy193;} +{yymsp[-2].minor.yy15 = yymsp[0].minor.yy15;} break; case 196: /* sortlist ::= sortlist COMMA item sortorder */ { - yylhsminor.yy193 = tVariantListAppend(yymsp[-3].minor.yy193, &yymsp[-1].minor.yy442, yymsp[0].minor.yy312); + yylhsminor.yy15 = tVariantListAppend(yymsp[-3].minor.yy15, &yymsp[-1].minor.yy380, yymsp[0].minor.yy250); } - yymsp[-3].minor.yy193 = yylhsminor.yy193; + yymsp[-3].minor.yy15 = yylhsminor.yy15; break; case 197: /* sortlist ::= item sortorder */ { - yylhsminor.yy193 = tVariantListAppend(NULL, &yymsp[-1].minor.yy442, yymsp[0].minor.yy312); + yylhsminor.yy15 = tVariantListAppend(NULL, &yymsp[-1].minor.yy380, yymsp[0].minor.yy250); } - yymsp[-1].minor.yy193 = yylhsminor.yy193; + yymsp[-1].minor.yy15 = yylhsminor.yy15; break; case 198: /* item ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - tVariantCreate(&yylhsminor.yy442, &yymsp[-1].minor.yy0); + tVariantCreate(&yylhsminor.yy380, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; + yymsp[-1].minor.yy380 = yylhsminor.yy380; break; case 199: /* sortorder ::= ASC */ -{ yymsp[0].minor.yy312 = TSDB_ORDER_ASC; } +{ yymsp[0].minor.yy250 = TSDB_ORDER_ASC; } break; case 200: /* sortorder ::= DESC */ -{ yymsp[0].minor.yy312 = TSDB_ORDER_DESC;} +{ yymsp[0].minor.yy250 = TSDB_ORDER_DESC;} break; case 201: /* sortorder ::= */ -{ yymsp[1].minor.yy312 = TSDB_ORDER_ASC; } +{ yymsp[1].minor.yy250 = TSDB_ORDER_ASC; } break; case 202: /* groupby_opt ::= */ -{ yymsp[1].minor.yy193 = 0;} +{ yymsp[1].minor.yy15 = 0;} break; case 203: /* groupby_opt ::= GROUP BY grouplist */ -{ yymsp[-2].minor.yy193 = yymsp[0].minor.yy193;} +{ yymsp[-2].minor.yy15 = yymsp[0].minor.yy15;} break; case 204: /* grouplist ::= grouplist COMMA item */ { - yylhsminor.yy193 = tVariantListAppend(yymsp[-2].minor.yy193, &yymsp[0].minor.yy442, -1); + yylhsminor.yy15 = tVariantListAppend(yymsp[-2].minor.yy15, &yymsp[0].minor.yy380, -1); } - yymsp[-2].minor.yy193 = yylhsminor.yy193; + yymsp[-2].minor.yy15 = yylhsminor.yy15; break; case 205: /* grouplist ::= item */ { - yylhsminor.yy193 = tVariantListAppend(NULL, &yymsp[0].minor.yy442, -1); + yylhsminor.yy15 = tVariantListAppend(NULL, &yymsp[0].minor.yy380, -1); } - yymsp[0].minor.yy193 = yylhsminor.yy193; + yymsp[0].minor.yy15 = yylhsminor.yy15; break; case 206: /* having_opt ::= */ case 216: /* where_opt ::= */ yytestcase(yyruleno==216); case 258: /* expritem ::= */ yytestcase(yyruleno==258); -{yymsp[1].minor.yy454 = 0;} +{yymsp[1].minor.yy328 = 0;} break; case 207: /* having_opt ::= HAVING expr */ case 217: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==217); -{yymsp[-1].minor.yy454 = yymsp[0].minor.yy454;} +{yymsp[-1].minor.yy328 = yymsp[0].minor.yy328;} break; case 208: /* limit_opt ::= */ case 212: /* slimit_opt ::= */ yytestcase(yyruleno==212); -{yymsp[1].minor.yy482.limit = -1; yymsp[1].minor.yy482.offset = 0;} +{yymsp[1].minor.yy150.limit = -1; yymsp[1].minor.yy150.offset = 0;} break; case 209: /* limit_opt ::= LIMIT signed */ case 213: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==213); -{yymsp[-1].minor.yy482.limit = yymsp[0].minor.yy473; yymsp[-1].minor.yy482.offset = 0;} +{yymsp[-1].minor.yy150.limit = yymsp[0].minor.yy489; yymsp[-1].minor.yy150.offset = 0;} break; case 210: /* limit_opt ::= LIMIT signed OFFSET signed */ -{ yymsp[-3].minor.yy482.limit = yymsp[-2].minor.yy473; yymsp[-3].minor.yy482.offset = yymsp[0].minor.yy473;} +{ yymsp[-3].minor.yy150.limit = yymsp[-2].minor.yy489; yymsp[-3].minor.yy150.offset = yymsp[0].minor.yy489;} break; case 211: /* limit_opt ::= LIMIT signed COMMA signed */ -{ yymsp[-3].minor.yy482.limit = yymsp[0].minor.yy473; yymsp[-3].minor.yy482.offset = yymsp[-2].minor.yy473;} +{ yymsp[-3].minor.yy150.limit = yymsp[0].minor.yy489; yymsp[-3].minor.yy150.offset = yymsp[-2].minor.yy489;} break; case 214: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ -{yymsp[-3].minor.yy482.limit = yymsp[-2].minor.yy473; yymsp[-3].minor.yy482.offset = yymsp[0].minor.yy473;} +{yymsp[-3].minor.yy150.limit = yymsp[-2].minor.yy489; yymsp[-3].minor.yy150.offset = yymsp[0].minor.yy489;} break; case 215: /* slimit_opt ::= SLIMIT signed COMMA signed */ -{yymsp[-3].minor.yy482.limit = yymsp[0].minor.yy473; yymsp[-3].minor.yy482.offset = yymsp[-2].minor.yy473;} +{yymsp[-3].minor.yy150.limit = yymsp[0].minor.yy489; yymsp[-3].minor.yy150.offset = yymsp[-2].minor.yy489;} break; case 218: /* expr ::= LP expr RP */ -{yylhsminor.yy454 = yymsp[-1].minor.yy454; yylhsminor.yy454->token.z = yymsp[-2].minor.yy0.z; yylhsminor.yy454->token.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; +{yylhsminor.yy328 = yymsp[-1].minor.yy328; yylhsminor.yy328->token.z = yymsp[-2].minor.yy0.z; yylhsminor.yy328->token.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} + yymsp[-2].minor.yy328 = yylhsminor.yy328; break; case 219: /* expr ::= ID */ -{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);} - yymsp[0].minor.yy454 = yylhsminor.yy454; +{ yylhsminor.yy328 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);} + yymsp[0].minor.yy328 = yylhsminor.yy328; break; case 220: /* expr ::= ID DOT ID */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy328 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);} + yymsp[-2].minor.yy328 = yylhsminor.yy328; break; case 221: /* expr ::= ID DOT STAR */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy328 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);} + yymsp[-2].minor.yy328 = yylhsminor.yy328; break; case 222: /* expr ::= INTEGER */ -{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);} - yymsp[0].minor.yy454 = yylhsminor.yy454; +{ yylhsminor.yy328 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);} + yymsp[0].minor.yy328 = yylhsminor.yy328; break; case 223: /* expr ::= MINUS INTEGER */ case 224: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==224); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);} - yymsp[-1].minor.yy454 = yylhsminor.yy454; +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy328 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);} + yymsp[-1].minor.yy328 = yylhsminor.yy328; break; case 225: /* expr ::= FLOAT */ -{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);} - yymsp[0].minor.yy454 = yylhsminor.yy454; +{ yylhsminor.yy328 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);} + yymsp[0].minor.yy328 = yylhsminor.yy328; break; case 226: /* expr ::= MINUS FLOAT */ case 227: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==227); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);} - yymsp[-1].minor.yy454 = yylhsminor.yy454; +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy328 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);} + yymsp[-1].minor.yy328 = yylhsminor.yy328; break; case 228: /* expr ::= STRING */ -{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);} - yymsp[0].minor.yy454 = yylhsminor.yy454; +{ yylhsminor.yy328 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);} + yymsp[0].minor.yy328 = yylhsminor.yy328; break; case 229: /* expr ::= NOW */ -{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); } - yymsp[0].minor.yy454 = yylhsminor.yy454; +{ yylhsminor.yy328 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); } + yymsp[0].minor.yy328 = yylhsminor.yy328; break; case 230: /* expr ::= VARIABLE */ -{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} - yymsp[0].minor.yy454 = yylhsminor.yy454; +{ yylhsminor.yy328 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} + yymsp[0].minor.yy328 = yylhsminor.yy328; break; case 231: /* expr ::= PLUS VARIABLE */ case 232: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==232); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);} - yymsp[-1].minor.yy454 = yylhsminor.yy454; +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy328 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);} + yymsp[-1].minor.yy328 = yylhsminor.yy328; break; case 233: /* expr ::= BOOL */ -{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} - yymsp[0].minor.yy454 = yylhsminor.yy454; +{ yylhsminor.yy328 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} + yymsp[0].minor.yy328 = yylhsminor.yy328; break; case 234: /* expr ::= NULL */ -{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);} - yymsp[0].minor.yy454 = yylhsminor.yy454; +{ yylhsminor.yy328 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);} + yymsp[0].minor.yy328 = yylhsminor.yy328; break; case 235: /* expr ::= ID LP exprlist RP */ -{ yylhsminor.yy454 = tSqlExprCreateFunction(yymsp[-1].minor.yy193, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy454 = yylhsminor.yy454; +{ yylhsminor.yy328 = tSqlExprCreateFunction(yymsp[-1].minor.yy15, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy328 = yylhsminor.yy328; break; case 236: /* expr ::= ID LP STAR RP */ -{ yylhsminor.yy454 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy454 = yylhsminor.yy454; +{ yylhsminor.yy328 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy328 = yylhsminor.yy328; break; case 237: /* expr ::= expr IS NULL */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, NULL, TK_ISNULL);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; +{yylhsminor.yy328 = tSqlExprCreate(yymsp[-2].minor.yy328, NULL, TK_ISNULL);} + yymsp[-2].minor.yy328 = yylhsminor.yy328; break; case 238: /* expr ::= expr IS NOT NULL */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-3].minor.yy454, NULL, TK_NOTNULL);} - yymsp[-3].minor.yy454 = yylhsminor.yy454; +{yylhsminor.yy328 = tSqlExprCreate(yymsp[-3].minor.yy328, NULL, TK_NOTNULL);} + yymsp[-3].minor.yy328 = yylhsminor.yy328; break; case 239: /* expr ::= expr LT expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_LT);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; +{yylhsminor.yy328 = tSqlExprCreate(yymsp[-2].minor.yy328, yymsp[0].minor.yy328, TK_LT);} + yymsp[-2].minor.yy328 = yylhsminor.yy328; break; case 240: /* expr ::= expr GT expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_GT);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; +{yylhsminor.yy328 = tSqlExprCreate(yymsp[-2].minor.yy328, yymsp[0].minor.yy328, TK_GT);} + yymsp[-2].minor.yy328 = yylhsminor.yy328; break; case 241: /* expr ::= expr LE expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_LE);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; +{yylhsminor.yy328 = tSqlExprCreate(yymsp[-2].minor.yy328, yymsp[0].minor.yy328, TK_LE);} + yymsp[-2].minor.yy328 = yylhsminor.yy328; break; case 242: /* expr ::= expr GE expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_GE);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; +{yylhsminor.yy328 = tSqlExprCreate(yymsp[-2].minor.yy328, yymsp[0].minor.yy328, TK_GE);} + yymsp[-2].minor.yy328 = yylhsminor.yy328; break; case 243: /* expr ::= expr NE expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_NE);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; +{yylhsminor.yy328 = tSqlExprCreate(yymsp[-2].minor.yy328, yymsp[0].minor.yy328, TK_NE);} + yymsp[-2].minor.yy328 = yylhsminor.yy328; break; case 244: /* expr ::= expr EQ expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_EQ);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; +{yylhsminor.yy328 = tSqlExprCreate(yymsp[-2].minor.yy328, yymsp[0].minor.yy328, TK_EQ);} + yymsp[-2].minor.yy328 = yylhsminor.yy328; break; case 245: /* expr ::= expr BETWEEN expr AND expr */ -{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy454); yylhsminor.yy454 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy454, yymsp[-2].minor.yy454, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy454, TK_LE), TK_AND);} - yymsp[-4].minor.yy454 = yylhsminor.yy454; +{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy328); yylhsminor.yy328 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy328, yymsp[-2].minor.yy328, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy328, TK_LE), TK_AND);} + yymsp[-4].minor.yy328 = yylhsminor.yy328; break; case 246: /* expr ::= expr AND expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_AND);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; +{yylhsminor.yy328 = tSqlExprCreate(yymsp[-2].minor.yy328, yymsp[0].minor.yy328, TK_AND);} + yymsp[-2].minor.yy328 = yylhsminor.yy328; break; case 247: /* expr ::= expr OR expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_OR); } - yymsp[-2].minor.yy454 = yylhsminor.yy454; +{yylhsminor.yy328 = tSqlExprCreate(yymsp[-2].minor.yy328, yymsp[0].minor.yy328, TK_OR); } + yymsp[-2].minor.yy328 = yylhsminor.yy328; break; case 248: /* expr ::= expr PLUS expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_PLUS); } - yymsp[-2].minor.yy454 = yylhsminor.yy454; +{yylhsminor.yy328 = tSqlExprCreate(yymsp[-2].minor.yy328, yymsp[0].minor.yy328, TK_PLUS); } + yymsp[-2].minor.yy328 = yylhsminor.yy328; break; case 249: /* expr ::= expr MINUS expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_MINUS); } - yymsp[-2].minor.yy454 = yylhsminor.yy454; +{yylhsminor.yy328 = tSqlExprCreate(yymsp[-2].minor.yy328, yymsp[0].minor.yy328, TK_MINUS); } + yymsp[-2].minor.yy328 = yylhsminor.yy328; break; case 250: /* expr ::= expr STAR expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_STAR); } - yymsp[-2].minor.yy454 = yylhsminor.yy454; +{yylhsminor.yy328 = tSqlExprCreate(yymsp[-2].minor.yy328, yymsp[0].minor.yy328, TK_STAR); } + yymsp[-2].minor.yy328 = yylhsminor.yy328; break; case 251: /* expr ::= expr SLASH expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_DIVIDE);} - yymsp[-2].minor.yy454 = yylhsminor.yy454; +{yylhsminor.yy328 = tSqlExprCreate(yymsp[-2].minor.yy328, yymsp[0].minor.yy328, TK_DIVIDE);} + yymsp[-2].minor.yy328 = yylhsminor.yy328; break; case 252: /* expr ::= expr REM expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_REM); } - yymsp[-2].minor.yy454 = yylhsminor.yy454; +{yylhsminor.yy328 = tSqlExprCreate(yymsp[-2].minor.yy328, yymsp[0].minor.yy328, TK_REM); } + yymsp[-2].minor.yy328 = yylhsminor.yy328; break; case 253: /* expr ::= expr LIKE expr */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_LIKE); } - yymsp[-2].minor.yy454 = yylhsminor.yy454; +{yylhsminor.yy328 = tSqlExprCreate(yymsp[-2].minor.yy328, yymsp[0].minor.yy328, TK_LIKE); } + yymsp[-2].minor.yy328 = yylhsminor.yy328; break; case 254: /* expr ::= expr IN LP exprlist RP */ -{yylhsminor.yy454 = tSqlExprCreate(yymsp[-4].minor.yy454, (tSqlExpr*)yymsp[-1].minor.yy193, TK_IN); } - yymsp[-4].minor.yy454 = yylhsminor.yy454; +{yylhsminor.yy328 = tSqlExprCreate(yymsp[-4].minor.yy328, (tSqlExpr*)yymsp[-1].minor.yy15, TK_IN); } + yymsp[-4].minor.yy328 = yylhsminor.yy328; break; case 255: /* exprlist ::= exprlist COMMA expritem */ -{yylhsminor.yy193 = tSqlExprListAppend(yymsp[-2].minor.yy193,yymsp[0].minor.yy454,0, 0);} - yymsp[-2].minor.yy193 = yylhsminor.yy193; +{yylhsminor.yy15 = tSqlExprListAppend(yymsp[-2].minor.yy15,yymsp[0].minor.yy328,0, 0);} + yymsp[-2].minor.yy15 = yylhsminor.yy15; break; case 256: /* exprlist ::= expritem */ -{yylhsminor.yy193 = tSqlExprListAppend(0,yymsp[0].minor.yy454,0, 0);} - yymsp[0].minor.yy193 = yylhsminor.yy193; +{yylhsminor.yy15 = tSqlExprListAppend(0,yymsp[0].minor.yy328,0, 0);} + yymsp[0].minor.yy15 = yylhsminor.yy15; break; case 257: /* expritem ::= expr */ -{yylhsminor.yy454 = yymsp[0].minor.yy454;} - yymsp[0].minor.yy454 = yylhsminor.yy454; +{yylhsminor.yy328 = yymsp[0].minor.yy328;} + yymsp[0].minor.yy328 = yylhsminor.yy328; break; case 259: /* cmd ::= RESET QUERY CACHE */ { setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} @@ -3361,7 +3052,7 @@ static YYACTIONTYPE yy_reduce( case 261: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy193, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy15, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; @@ -3379,14 +3070,14 @@ static YYACTIONTYPE yy_reduce( case 263: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy193, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy15, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; case 264: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy193, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy15, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; @@ -3421,7 +3112,7 @@ static YYACTIONTYPE yy_reduce( toTSDBType(yymsp[-2].minor.yy0.type); SArray* A = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1); - A = tVariantListAppend(A, &yymsp[0].minor.yy442, -1); + A = tVariantListAppend(A, &yymsp[0].minor.yy380, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); @@ -3430,14 +3121,14 @@ static YYACTIONTYPE yy_reduce( case 268: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy193, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy15, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; case 269: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy193, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy15, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; @@ -3455,14 +3146,14 @@ static YYACTIONTYPE yy_reduce( case 271: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy193, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy15, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; case 272: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy193, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy15, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; @@ -3497,7 +3188,7 @@ static YYACTIONTYPE yy_reduce( toTSDBType(yymsp[-2].minor.yy0.type); SArray* A = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1); - A = tVariantListAppend(A, &yymsp[0].minor.yy442, -1); + A = tVariantListAppend(A, &yymsp[0].minor.yy380, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); @@ -3506,7 +3197,7 @@ static YYACTIONTYPE yy_reduce( case 276: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy193, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy15, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; @@ -3523,9 +3214,9 @@ static YYACTIONTYPE yy_reduce( break; /********** End reduce actions ************************************************/ }; - assert( yyrulenostateno = (YYACTIONTYPE)yyact; yymsp->major = (YYCODETYPE)yygoto; yyTraceShift(yypParser, yyact, "... then shift"); - return yyact; } /* @@ -3550,8 +3240,7 @@ static YYACTIONTYPE yy_reduce( static void yy_parse_failed( yyParser *yypParser /* The parser */ ){ - ParseARG_FETCH - ParseCTX_FETCH + ParseARG_FETCH; #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); @@ -3562,8 +3251,7 @@ static void yy_parse_failed( ** parser fails */ /************ Begin %parse_failure code ***************************************/ /************ End %parse_failure code *****************************************/ - ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ - ParseCTX_STORE + ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } #endif /* YYNOERRORRECOVERY */ @@ -3575,8 +3263,7 @@ static void yy_syntax_error( int yymajor, /* The major type of the error token */ ParseTOKENTYPE yyminor /* The minor type of the error token */ ){ - ParseARG_FETCH - ParseCTX_FETCH + ParseARG_FETCH; #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ @@ -3602,8 +3289,7 @@ static void yy_syntax_error( assert(len <= outputBufLen); /************ End %syntax_error code ******************************************/ - ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ - ParseCTX_STORE + ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } /* @@ -3612,8 +3298,7 @@ static void yy_syntax_error( static void yy_accept( yyParser *yypParser /* The parser */ ){ - ParseARG_FETCH - ParseCTX_FETCH + ParseARG_FETCH; #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); @@ -3628,8 +3313,7 @@ static void yy_accept( /*********** Begin %parse_accept code *****************************************/ /*********** End %parse_accept code *******************************************/ - ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ - ParseCTX_STORE + ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } /* The main parser program. @@ -3658,47 +3342,45 @@ void Parse( ParseARG_PDECL /* Optional %extra_argument parameter */ ){ YYMINORTYPE yyminorunion; - YYACTIONTYPE yyact; /* The parser action. */ + unsigned int yyact; /* The parser action. */ #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) int yyendofinput; /* True if we are at the end of input */ #endif #ifdef YYERRORSYMBOL int yyerrorhit = 0; /* True if yymajor has invoked an error */ #endif - yyParser *yypParser = (yyParser*)yyp; /* The parser */ - ParseCTX_FETCH - ParseARG_STORE + yyParser *yypParser; /* The parser */ + yypParser = (yyParser*)yyp; assert( yypParser->yytos!=0 ); #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) yyendofinput = (yymajor==0); #endif + ParseARG_STORE; - yyact = yypParser->yytos->stateno; #ifndef NDEBUG if( yyTraceFILE ){ - if( yyact < YY_MIN_REDUCE ){ + int stateno = yypParser->yytos->stateno; + if( stateno < YY_MIN_REDUCE ){ fprintf(yyTraceFILE,"%sInput '%s' in state %d\n", - yyTracePrompt,yyTokenName[yymajor],yyact); + yyTracePrompt,yyTokenName[yymajor],stateno); }else{ fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n", - yyTracePrompt,yyTokenName[yymajor],yyact-YY_MIN_REDUCE); + yyTracePrompt,yyTokenName[yymajor],stateno-YY_MIN_REDUCE); } } #endif do{ - assert( yyact==yypParser->yytos->stateno ); - yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact); + yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); if( yyact >= YY_MIN_REDUCE ){ - yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor, - yyminor ParseCTX_PARAM); + yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,yyminor); }else if( yyact <= YY_MAX_SHIFTREDUCE ){ - yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor); + yy_shift(yypParser,yyact,yymajor,yyminor); #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt--; #endif - break; + yymajor = YYNOCODE; }else if( yyact==YY_ACCEPT_ACTION ){ yypParser->yytos--; yy_accept(yypParser); @@ -3749,9 +3431,10 @@ void Parse( yymajor = YYNOCODE; }else{ while( yypParser->yytos >= yypParser->yystack + && yymx != YYERRORSYMBOL && (yyact = yy_find_reduce_action( yypParser->yytos->stateno, - YYERRORSYMBOL)) > YY_MAX_SHIFTREDUCE + YYERRORSYMBOL)) >= YY_MIN_REDUCE ){ yy_pop_parser_stack(yypParser); } @@ -3768,8 +3451,6 @@ void Parse( } yypParser->yyerrcnt = 3; yyerrorhit = 1; - if( yymajor==YYNOCODE ) break; - yyact = yypParser->yytos->stateno; #elif defined(YYNOERRORRECOVERY) /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to ** do any kind of error recovery. Instead, simply invoke the syntax @@ -3780,7 +3461,8 @@ void Parse( */ yy_syntax_error(yypParser,yymajor, yyminor); yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); - break; + yymajor = YYNOCODE; + #else /* YYERRORSYMBOL is not defined */ /* This is what we do if the grammar does not define ERROR: ** @@ -3802,10 +3484,10 @@ void Parse( yypParser->yyerrcnt = -1; #endif } - break; + yymajor = YYNOCODE; #endif } - }while( yypParser->yytos>yypParser->yystack ); + }while( yymajor!=YYNOCODE && yypParser->yytos>yypParser->yystack ); #ifndef NDEBUG if( yyTraceFILE ){ yyStackEntry *i; @@ -3820,17 +3502,3 @@ void Parse( #endif return; } - -/* -** Return the fallback token corresponding to canonical token iToken, or -** 0 if iToken has no fallback. -*/ -int ParseFallback(int iToken){ -#ifdef YYFALLBACK - assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ); - return yyFallback[iToken]; -#else - (void)iToken; - return 0; -#endif -} From 7bbf7c5930bc4de0c46d42060977a8b526be9f51 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 8 Jun 2021 16:08:48 +0800 Subject: [PATCH 52/72] [td-255] fix bugs found by regression test. --- src/query/src/qAggMain.c | 2 +- src/query/src/qExecutor.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index 96eaeb48cf..472f3f8fe1 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -5287,7 +5287,7 @@ SAggFunctionInfo aAggs[] = {{ }, { // 17 - "ts_dummy", + "ts", TSDB_FUNC_TS_DUMMY, TSDB_FUNC_TS_DUMMY, TSDB_BASE_FUNC_SO | TSDB_FUNCSTATE_NEED_TS, diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 5a0eecb549..8cc25f1fe6 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -4573,7 +4573,7 @@ SOperatorInfo* createDataBlocksOptScanInfo(void* pTsdbQueryHandle, SQueryRuntime } SArray* getOrderCheckColumns(SQueryAttr* pQuery) { - int32_t numOfCols = pQuery->pGroupbyExpr->numOfGroupCols; + int32_t numOfCols = pQuery->pGroupbyExpr == NULL? 0: pQuery->pGroupbyExpr->numOfGroupCols; SArray* pOrderColumns = NULL; if (numOfCols > 0) { @@ -4612,7 +4612,7 @@ SArray* getOrderCheckColumns(SQueryAttr* pQuery) { } SArray* getResultGroupCheckColumns(SQueryAttr* pQuery) { - int32_t numOfCols = pQuery->pGroupbyExpr->numOfGroupCols; + int32_t numOfCols = pQuery->pGroupbyExpr == NULL? 0 : pQuery->pGroupbyExpr->numOfGroupCols; SArray* pOrderColumns = NULL; if (numOfCols > 0) { From cc53777cc31b42ca37d9acc8bcbd7d6a6e7af7b0 Mon Sep 17 00:00:00 2001 From: jiaoqiyuan Date: Tue, 8 Jun 2021 16:22:25 +0800 Subject: [PATCH 53/72] init array before use it. --- src/kit/taosdemo/taosdemo.c | 2 +- tests/examples/c/apitest.c | 9 ++++----- tests/examples/c/demo.c | 2 +- tests/examples/c/prepare.c | 2 +- tests/examples/c/subscribe.c | 3 +-- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 6f5d407a73..4d27805685 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -1209,7 +1209,6 @@ static void fetchResult(TAOS_RES *res, threadInfo* pThreadInfo) { } int totalLen = 0; - char temp[16000]; // fetch the records row by row while((row = taos_fetch_row(res))) { @@ -1220,6 +1219,7 @@ static void fetchResult(TAOS_RES *res, threadInfo* pThreadInfo) { memset(databuf, 0, 100*1024*1024); } num_rows++; + char temp[16000] = {0}; int len = taos_print_row(temp, row, fields, num_fields); len += sprintf(temp + len, "\n"); //printf("query result:%s\n", temp); diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index 2961750efc..a482e2902e 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -86,7 +86,7 @@ static int print_result(TAOS_RES* res, int blockFetch) { } } else { while ((row = taos_fetch_row(res))) { - char temp[256]; + char temp[256] = {0}; taos_print_row(temp, row, fields, num_fields); puts(temp); nRows++; @@ -389,10 +389,10 @@ void verify_prepare(TAOS* taos) { int rows = 0; int num_fields = taos_num_fields(result); TAOS_FIELD *fields = taos_fetch_fields(result); - char temp[256]; // fetch the records row by row while ((row = taos_fetch_row(result))) { + char temp[256] = {0}; rows++; taos_print_row(temp, row, fields, num_fields); printf("%s\n", temp); @@ -606,10 +606,10 @@ void verify_prepare2(TAOS* taos) { int rows = 0; int num_fields = taos_num_fields(result); TAOS_FIELD *fields = taos_fetch_fields(result); - char temp[256]; // fetch the records row by row while ((row = taos_fetch_row(result))) { + char temp[256] = {0}; rows++; taos_print_row(temp, row, fields, num_fields); printf("%s\n", temp); @@ -856,8 +856,7 @@ void verify_prepare3(TAOS* taos) { // fetch the records row by row while ((row = taos_fetch_row(result))) { - memset(temp, 0, sizeof(temp)/sizeof(temp[0])); - + char temp[256] = {0}; rows++; taos_print_row(temp, row, fields, num_fields); printf("%s\n", temp); diff --git a/tests/examples/c/demo.c b/tests/examples/c/demo.c index 0b1cd7b5d2..f8c69d0043 100644 --- a/tests/examples/c/demo.c +++ b/tests/examples/c/demo.c @@ -116,12 +116,12 @@ void Test(TAOS *taos, char *qstr, int index) { int rows = 0; int num_fields = taos_field_count(result); TAOS_FIELD *fields = taos_fetch_fields(result); - char temp[1024]; printf("num_fields = %d\n", num_fields); printf("select * from table, result:\n"); // fetch the records row by row while ((row = taos_fetch_row(result))) { + char temp[1024] = {0}; rows++; taos_print_row(temp, row, fields, num_fields); printf("%s\n", temp); diff --git a/tests/examples/c/prepare.c b/tests/examples/c/prepare.c index 13d71beea6..723b340a92 100644 --- a/tests/examples/c/prepare.c +++ b/tests/examples/c/prepare.c @@ -184,10 +184,10 @@ int main(int argc, char *argv[]) int rows = 0; int num_fields = taos_num_fields(result); TAOS_FIELD *fields = taos_fetch_fields(result); - char temp[256]; // fetch the records row by row while ((row = taos_fetch_row(result))) { + char temp[256] = {0}; rows++; taos_print_row(temp, row, fields, num_fields); printf("%s\n", temp); diff --git a/tests/examples/c/subscribe.c b/tests/examples/c/subscribe.c index 1d3533fa5e..ad12f0e7a5 100644 --- a/tests/examples/c/subscribe.c +++ b/tests/examples/c/subscribe.c @@ -14,8 +14,6 @@ void print_result(TAOS_RES* res, int blockFetch) { int num_fields = taos_num_fields(res); TAOS_FIELD* fields = taos_fetch_fields(res); int nRows = 0; - char buf[4096]; - if (blockFetch) { nRows = taos_fetch_block(res, &row); @@ -25,6 +23,7 @@ void print_result(TAOS_RES* res, int blockFetch) { //} } else { while ((row = taos_fetch_row(res))) { + char buf[4096] = {0}; taos_print_row(buf, row, fields, num_fields); puts(buf); nRows++; From bbe9e3a093c2bbbba5bd0964b92e320474130fa6 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Tue, 8 Jun 2021 17:11:02 +0800 Subject: [PATCH 54/72] support one keep for storage --- src/client/src/tscSQLParser.c | 30 ++++++++--------------- tests/script/general/parser/alter.sim | 20 +++++++++++++-- tests/script/general/parser/create_db.sim | 22 ++++++++++++++++- 3 files changed, 49 insertions(+), 23 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 50b610d908..35c737d5e4 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -5830,39 +5830,29 @@ static int32_t setKeepOption(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDbInfo* p SArray* pKeep = pCreateDb->keep; if (pKeep != NULL) { size_t s = taosArrayGetSize(pKeep); - tVariantListItem* p0 = taosArrayGet(pKeep, 0); - size_t expectNum = 1; #ifdef _STORAGE - expectNum = 3; + if (s >= 4 ||s <= 0) { +#else + if (s != 1) { #endif - if (s != expectNum) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } - if ((int32_t)p0->pVar.i64 <= 0) { + tVariantListItem* p0 = taosArrayGet(pKeep, 0); + tVariantListItem* p1 = (s > 1) ? taosArrayGet(pKeep, 1) : p0; + tVariantListItem* p2 = (s > 2) ? taosArrayGet(pKeep, 2) : p1; + + if ((int32_t)p0->pVar.i64 <= 0 || (int32_t)p1->pVar.i64 <= 0 || (int32_t)p2->pVar.i64 <= 0) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); } - pMsg->daysToKeep0 = htonl((int32_t)p0->pVar.i64); - -#ifdef _STORAGE - tVariantListItem* p1 = taosArrayGet(pKeep, 1); - tVariantListItem* p2 = taosArrayGet(pKeep, 2); - - if ((int32_t)p1->pVar.i64 <= 0 || (int32_t)p2->pVar.i64 <= 0) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); - } - if (!(((int32_t)p0->pVar.i64 <= (int32_t)p1->pVar.i64) && ((int32_t)p1->pVar.i64 <= (int32_t)p2->pVar.i64))) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); } + pMsg->daysToKeep0 = htonl((int32_t)p0->pVar.i64); pMsg->daysToKeep1 = htonl((int32_t)p1->pVar.i64); pMsg->daysToKeep2 = htonl((int32_t)p2->pVar.i64); -#else - UNUSED(msg3); - pMsg->daysToKeep1 = pMsg->daysToKeep0; - pMsg->daysToKeep2 = pMsg->daysToKeep0; -#endif + } return TSDB_CODE_SUCCESS; diff --git a/tests/script/general/parser/alter.sim b/tests/script/general/parser/alter.sim index 5c22f67a0b..d1a4702a69 100644 --- a/tests/script/general/parser/alter.sim +++ b/tests/script/general/parser/alter.sim @@ -25,12 +25,12 @@ sql use $db sql_error alter database $db keep "20" sql_error alter database $db keep "20","20","20" -sql_error alter database $db keep 20 +sql_error alter database $db keep 20,19 sql_error alter database $db keep 20.0 sql_error alter database $db keep 20.0,20.0,20.0 sql_error alter database $db keep 0,0,0 sql_error alter database $db keep -1,-1,-1 -sql_error alter database $db keep 20,20 +sql_error alter database $db keep 9,20 sql_error alter database $db keep 9,9,9 sql_error alter database $db keep 20,20,19 sql_error alter database $db keep 20,19,20 @@ -38,6 +38,22 @@ sql_error alter database $db keep 20,19,19 sql_error alter database $db keep 20,19,18 sql_error alter database $db keep 20,20,20,20 sql_error alter database $db keep 365001,365001,365001 +sql alter database $db keep 21 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 21,21,21 then + return -1 +endi +sql alter database $db keep 11,12 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 11,12,12 then + return -1 +endi sql alter database $db keep 20,20,20 sql show databases if $rows != 1 then diff --git a/tests/script/general/parser/create_db.sim b/tests/script/general/parser/create_db.sim index d3b74b697f..7881060ad1 100644 --- a/tests/script/general/parser/create_db.sim +++ b/tests/script/general/parser/create_db.sim @@ -159,8 +159,28 @@ sql_error create database $db keep "11" sql_error create database $db keep 13,12,11 sql_error create database $db keep 11,12,11 sql_error create database $db keep 12,11,12 -sql_error create database $db keep 11,11 +sql_error create database $db keep 8 +sql_error create database $db keep 12,11 sql_error create database $db keep 365001,365001,365001 +sql create database dbk0 keep 19 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 19,19,19 then + return -1 +endi +sql drop database dbk0 +sql create database dbka keep 19,20 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 19,20,20 then + return -1 +endi +sql drop database dbka + sql create database dbk1 keep 11,11,11 sql show databases if $rows != 1 then From 80e64a5ad5dc34f6f4ee615b0c3c35d551dbdbe0 Mon Sep 17 00:00:00 2001 From: zyyang Date: Tue, 8 Jun 2021 17:17:59 +0800 Subject: [PATCH 55/72] sync jdbc driver from develop to master --- .../jdbc/AbstractDatabaseMetaData.java | 948 +++++++------- .../jdbc/AbstractParameterMetaData.java | 23 + .../com/taosdata/jdbc/AbstractResultSet.java | 10 +- .../jdbc/DatabaseMetaDataResultSet.java | 922 +------------- .../java/com/taosdata/jdbc/TSDBConstants.java | 65 +- .../com/taosdata/jdbc/TSDBJNIConnector.java | 107 +- .../taosdata/jdbc/TSDBPreparedStatement.java | 894 +++++++------ .../java/com/taosdata/jdbc/TSDBResultSet.java | 109 +- .../taosdata/jdbc/TSDBResultSetMetaData.java | 1 + .../taosdata/jdbc/TSDBResultSetRowData.java | 270 ++-- .../java/com/taosdata/jdbc/TSDBStatement.java | 11 +- .../java/com/taosdata/jdbc/utils/Utils.java | 11 +- .../com/taosdata/jdbc/TSDBConnectionTest.java | 30 +- .../jdbc/TSDBDatabaseMetaDataTest.java | 243 +++- .../taosdata/jdbc/TSDBJNIConnectorTest.java | 6 +- .../jdbc/TSDBParameterMetaDataTest.java | 44 +- .../jdbc/TSDBPreparedStatementTest.java | 1111 +++++++++-------- .../com/taosdata/jdbc/TSDBResultSetTest.java | 10 +- .../com/taosdata/jdbc/TSDBStatementTest.java | 3 - .../jdbc/rs/RestfulDatabaseMetaDataTest.java | 235 +++- .../jdbc/rs/RestfulParameterMetaDataTest.java | 27 +- 21 files changed, 2433 insertions(+), 2647 deletions(-) diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java index 5dcaa77ebd..48811d30a6 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java @@ -12,6 +12,9 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da private final static int DRIVER_MAJAR_VERSION = 2; private final static int DRIVER_MINOR_VERSION = 0; + private String precision = "ms"; + private String database; + public boolean allProceduresAreCallable() throws SQLException { return false; } @@ -493,102 +496,105 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da public abstract ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException; + private List buildGetTablesColumnMetaDataList() { + List columnMetaDataList = new ArrayList<>(); + columnMetaDataList.add(buildTableCatalogMeta(1)); // 1. TABLE_CAT + columnMetaDataList.add(buildTableSchemaMeta(2)); // 2. TABLE_SCHEM + columnMetaDataList.add(buildTableNameMeta(3)); // 3. TABLE_NAME + columnMetaDataList.add(buildTableTypeMeta(4)); // 4. TABLE_TYPE + columnMetaDataList.add(buildRemarksMeta(5)); // 5. remarks + columnMetaDataList.add(buildTypeCatMeta(6)); // 6. TYPE_CAT + columnMetaDataList.add(buildTypeSchemaMeta(7)); // 7. TYPE_SCHEM + columnMetaDataList.add(buildTypeNameMeta(8)); // 8. TYPE_NAME + columnMetaDataList.add(buildSelfReferencingColName(9)); // 9. SELF_REFERENCING_COL_NAME + columnMetaDataList.add(buildRefGenerationMeta(10)); // 10. REF_GENERATION + return columnMetaDataList; + } + + private ColumnMetaData buildTypeCatMeta(int colIndex) { + ColumnMetaData col6 = new ColumnMetaData(); + col6.setColIndex(colIndex); + col6.setColName("TYPE_CAT"); + col6.setColType(Types.NCHAR); + return col6; + } + + private ColumnMetaData buildTypeSchemaMeta(int colIndex) { + ColumnMetaData col7 = new ColumnMetaData(); + col7.setColIndex(colIndex); + col7.setColName("TYPE_SCHEM"); + col7.setColType(Types.NCHAR); + return col7; + } + + private ColumnMetaData buildTypeNameMeta(int colIndex) { + ColumnMetaData col8 = new ColumnMetaData(); + col8.setColIndex(colIndex); + col8.setColName("TYPE_NAME"); + col8.setColType(Types.NCHAR); + return col8; + } + + private ColumnMetaData buildSelfReferencingColName(int colIndex) { + ColumnMetaData col9 = new ColumnMetaData(); + col9.setColIndex(colIndex); + col9.setColName("SELF_REFERENCING_COL_NAME"); + col9.setColType(Types.NCHAR); + return col9; + } + + private ColumnMetaData buildRefGenerationMeta(int colIndex) { + ColumnMetaData col10 = new ColumnMetaData(); + col10.setColIndex(colIndex); + col10.setColName("REF_GENERATION"); + col10.setColType(Types.NCHAR); + return col10; + } + protected ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types, Connection connection) throws SQLException { + if (catalog == null || catalog.isEmpty()) + return null; + if (!isAvailableCatalog(connection, catalog)) + return new EmptyResultSet(); + + DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); + // set column metadata list + resultSet.setColumnMetaDataList(buildGetTablesColumnMetaDataList()); + // set row data + List rowDataList = new ArrayList<>(); try (Statement stmt = connection.createStatement()) { - if (catalog == null || catalog.isEmpty()) - return null; - - ResultSet databases = stmt.executeQuery("show databases"); - String dbname = null; - while (databases.next()) { - dbname = databases.getString("name"); - if (dbname.equalsIgnoreCase(catalog)) - break; - } - databases.close(); - if (dbname == null) - return null; - - stmt.execute("use " + dbname); - DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); - List columnMetaDataList = new ArrayList<>(); - ColumnMetaData col1 = new ColumnMetaData(); - col1.setColIndex(1); - col1.setColName("TABLE_CAT"); - col1.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col1); - ColumnMetaData col2 = new ColumnMetaData(); - col2.setColIndex(2); - col2.setColName("TABLE_SCHEM"); - col2.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col2); - ColumnMetaData col3 = new ColumnMetaData(); - col3.setColIndex(3); - col3.setColName("TABLE_NAME"); - col3.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col3); - ColumnMetaData col4 = new ColumnMetaData(); - col4.setColIndex(4); - col4.setColName("TABLE_TYPE"); - col4.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col4); - ColumnMetaData col5 = new ColumnMetaData(); - col5.setColIndex(5); - col5.setColName("REMARKS"); - col5.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col5); - ColumnMetaData col6 = new ColumnMetaData(); - col6.setColIndex(6); - col6.setColName("TYPE_CAT"); - col6.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col6); - ColumnMetaData col7 = new ColumnMetaData(); - col7.setColIndex(7); - col7.setColName("TYPE_SCHEM"); - col7.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col7); - ColumnMetaData col8 = new ColumnMetaData(); - col8.setColIndex(8); - col8.setColName("TYPE_NAME"); - col8.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col8); - ColumnMetaData col9 = new ColumnMetaData(); - col9.setColIndex(9); - col9.setColName("SELF_REFERENCING_COL_NAME"); - col9.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col9); - ColumnMetaData col10 = new ColumnMetaData(); - col10.setColIndex(10); - col10.setColName("REF_GENERATION"); - col10.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col10); - resultSet.setColumnMetaDataList(columnMetaDataList); - - List rowDataList = new ArrayList<>(); + stmt.execute("use " + catalog); ResultSet tables = stmt.executeQuery("show tables"); while (tables.next()) { TSDBResultSetRowData rowData = new TSDBResultSetRowData(10); - rowData.setString(0, dbname); //table_cat - rowData.setString(1, null); //TABLE_SCHEM - rowData.setString(2, tables.getString("table_name")); //TABLE_NAME - rowData.setString(3, "TABLE"); //TABLE_TYPE - rowData.setString(4, ""); //REMARKS + rowData.setStringValue(1, catalog); //TABLE_CAT + rowData.setStringValue(2, null); //TABLE_SCHEM + rowData.setStringValue(3, tables.getString("table_name")); //TABLE_NAME + rowData.setStringValue(4, "TABLE"); //TABLE_TYPE + rowData.setStringValue(5, ""); //REMARKS rowDataList.add(rowData); } - ResultSet stables = stmt.executeQuery("show stables"); while (stables.next()) { TSDBResultSetRowData rowData = new TSDBResultSetRowData(10); - rowData.setString(0, dbname); //TABLE_CAT - rowData.setString(1, null); //TABLE_SCHEM - rowData.setString(2, stables.getString("name")); //TABLE_NAME - rowData.setString(3, "TABLE"); //TABLE_TYPE - rowData.setString(4, "STABLE"); //REMARKS + rowData.setStringValue(1, catalog); //TABLE_CAT + rowData.setStringValue(2, null); //TABLE_SCHEM + rowData.setStringValue(3, stables.getString("name")); //TABLE_NAME + rowData.setStringValue(4, "TABLE"); //TABLE_TYPE + rowData.setStringValue(5, "STABLE"); //REMARKS rowDataList.add(rowData); } resultSet.setRowDataList(rowDataList); - return resultSet; } + return resultSet; + } + + private ColumnMetaData buildTableTypeMeta(int colIndex) { + ColumnMetaData col4 = new ColumnMetaData(); + col4.setColIndex(colIndex); + col4.setColName("TABLE_TYPE"); + col4.setColType(Types.NCHAR); + return col4; } public ResultSet getSchemas() throws SQLException { @@ -597,25 +603,24 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da public abstract ResultSet getCatalogs() throws SQLException; + private List buildTableTypesColumnMetadataList() { + List columnMetaDataList = new ArrayList<>(); + columnMetaDataList.add(buildTableTypeMeta(1)); + return columnMetaDataList; + } + public ResultSet getTableTypes() throws SQLException { DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); // set up ColumnMetaDataList - List columnMetaDataList = new ArrayList<>(); - ColumnMetaData colMetaData = new ColumnMetaData(); - colMetaData.setColIndex(0); - colMetaData.setColName("TABLE_TYPE"); - colMetaData.setColSize(10); - colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(colMetaData); - resultSet.setColumnMetaDataList(columnMetaDataList); + resultSet.setColumnMetaDataList(buildTableTypesColumnMetadataList()); // set up rowDataList List rowDataList = new ArrayList<>(); TSDBResultSetRowData rowData = new TSDBResultSetRowData(1); - rowData.setString(0, "TABLE"); + rowData.setStringValue(1, "TABLE"); rowDataList.add(rowData); rowData = new TSDBResultSetRowData(1); - rowData.setString(0, "STABLE"); + rowData.setStringValue(1, "STABLE"); rowDataList.add(rowData); resultSet.setRowDataList(rowDataList); @@ -625,278 +630,330 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da public abstract ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException; protected ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern, Connection conn) { + if (catalog == null || catalog.isEmpty()) + return null; + if (!isAvailableCatalog(conn, catalog)) + return new EmptyResultSet(); + + DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); + // set up ColumnMetaDataList + resultSet.setColumnMetaDataList(buildGetColumnsColumnMetaDataList()); + // set up rowDataList + List rowDataList = new ArrayList<>(); try (Statement stmt = conn.createStatement()) { - if (catalog == null || catalog.isEmpty()) - return null; - - ResultSet databases = stmt.executeQuery("show databases"); - String dbname = null; - while (databases.next()) { - dbname = databases.getString("name"); - if (dbname.equalsIgnoreCase(catalog)) - break; - } - databases.close(); - if (dbname == null) - return null; - - stmt.execute("use " + dbname); - DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); - // set up ColumnMetaDataList - - List columnMetaDataList = new ArrayList<>(); - // TABLE_CAT - ColumnMetaData col1 = new ColumnMetaData(); - col1.setColIndex(1); - col1.setColName("TABLE_CAT"); - col1.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col1); - // TABLE_SCHEM - ColumnMetaData col2 = new ColumnMetaData(); - col2.setColIndex(2); - col2.setColName("TABLE_SCHEM"); - col2.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col2); - // TABLE_NAME - ColumnMetaData col3 = new ColumnMetaData(); - col3.setColIndex(3); - col3.setColName("TABLE_NAME"); - col3.setColSize(193); - col3.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col3); - // COLUMN_NAME - ColumnMetaData col4 = new ColumnMetaData(); - col4.setColIndex(4); - col4.setColName("COLUMN_NAME"); - col4.setColSize(65); - col4.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col4); - // DATA_TYPE - ColumnMetaData col5 = new ColumnMetaData(); - col5.setColIndex(5); - col5.setColName("DATA_TYPE"); - col5.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); - columnMetaDataList.add(col5); - // TYPE_NAME - ColumnMetaData col6 = new ColumnMetaData(); - col6.setColIndex(6); - col6.setColName("TYPE_NAME"); - col6.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col6); - // COLUMN_SIZE - ColumnMetaData col7 = new ColumnMetaData(); - col7.setColIndex(7); - col7.setColName("COLUMN_SIZE"); - col7.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); - columnMetaDataList.add(col7); - // BUFFER_LENGTH, not used - ColumnMetaData col8 = new ColumnMetaData(); - col8.setColIndex(8); - col8.setColName("BUFFER_LENGTH"); - columnMetaDataList.add(col8); - // DECIMAL_DIGITS - ColumnMetaData col9 = new ColumnMetaData(); - col9.setColIndex(9); - col9.setColName("DECIMAL_DIGITS"); - col9.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); - columnMetaDataList.add(col9); - // add NUM_PREC_RADIX - ColumnMetaData col10 = new ColumnMetaData(); - col10.setColIndex(10); - col10.setColName("NUM_PREC_RADIX"); - col10.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); - columnMetaDataList.add(col10); - // NULLABLE - ColumnMetaData col11 = new ColumnMetaData(); - col11.setColIndex(11); - col11.setColName("NULLABLE"); - col11.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); - columnMetaDataList.add(col11); - // REMARKS - ColumnMetaData col12 = new ColumnMetaData(); - col12.setColIndex(12); - col12.setColName("REMARKS"); - col12.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col12); - // COLUMN_DEF - ColumnMetaData col13 = new ColumnMetaData(); - col13.setColIndex(13); - col13.setColName("COLUMN_DEF"); - col13.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col13); - //SQL_DATA_TYPE - ColumnMetaData col14 = new ColumnMetaData(); - col14.setColIndex(14); - col14.setColName("SQL_DATA_TYPE"); - col14.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); - columnMetaDataList.add(col14); - //SQL_DATETIME_SUB - ColumnMetaData col15 = new ColumnMetaData(); - col15.setColIndex(15); - col15.setColName("SQL_DATETIME_SUB"); - col15.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); - columnMetaDataList.add(col15); - //CHAR_OCTET_LENGTH - ColumnMetaData col16 = new ColumnMetaData(); - col16.setColIndex(16); - col16.setColName("CHAR_OCTET_LENGTH"); - col16.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); - columnMetaDataList.add(col16); - //ORDINAL_POSITION - ColumnMetaData col17 = new ColumnMetaData(); - col17.setColIndex(17); - col17.setColName("ORDINAL_POSITION"); - col17.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); - columnMetaDataList.add(col17); - // IS_NULLABLE - ColumnMetaData col18 = new ColumnMetaData(); - col18.setColIndex(18); - col18.setColName("IS_NULLABLE"); - col18.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col18); - //SCOPE_CATALOG - ColumnMetaData col19 = new ColumnMetaData(); - col19.setColIndex(19); - col19.setColName("SCOPE_CATALOG"); - col19.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col19); - //SCOPE_SCHEMA - ColumnMetaData col20 = new ColumnMetaData(); - col20.setColIndex(20); - col20.setColName("SCOPE_SCHEMA"); - col20.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col20); - //SCOPE_TABLE - ColumnMetaData col21 = new ColumnMetaData(); - col21.setColIndex(21); - col21.setColName("SCOPE_TABLE"); - col21.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col21); - //SOURCE_DATA_TYPE - ColumnMetaData col22 = new ColumnMetaData(); - col22.setColIndex(22); - col22.setColName("SOURCE_DATA_TYPE"); - col22.setColType(TSDBConstants.TSDB_DATA_TYPE_SMALLINT); - columnMetaDataList.add(col22); - //IS_AUTOINCREMENT - ColumnMetaData col23 = new ColumnMetaData(); - col23.setColIndex(23); - col23.setColName("IS_AUTOINCREMENT"); - col23.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col23); - //IS_GENERATEDCOLUMN - ColumnMetaData col24 = new ColumnMetaData(); - col24.setColIndex(24); - col24.setColName("IS_GENERATEDCOLUMN"); - col24.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col24); - - resultSet.setColumnMetaDataList(columnMetaDataList); - // set up rowDataList - ResultSet rs = stmt.executeQuery("describe " + dbname + "." + tableNamePattern); - List rowDataList = new ArrayList<>(); - int index = 0; + ResultSet rs = stmt.executeQuery("describe " + catalog + "." + tableNamePattern); + int rowIndex = 0; while (rs.next()) { TSDBResultSetRowData rowData = new TSDBResultSetRowData(24); // set TABLE_CAT - rowData.setString(0, dbname); + rowData.setStringValue(1, catalog); + // set TABLE_SCHEM + rowData.setStringValue(2, null); // set TABLE_NAME - rowData.setString(2, tableNamePattern); + rowData.setStringValue(3, tableNamePattern); // set COLUMN_NAME - rowData.setString(3, rs.getString("Field")); + rowData.setStringValue(4, rs.getString("Field")); // set DATA_TYPE String typeName = rs.getString("Type"); - rowData.setInt(4, getDataType(typeName)); + rowData.setIntValue(5, TSDBConstants.typeName2JdbcType(typeName)); // set TYPE_NAME - rowData.setString(5, typeName); + rowData.setStringValue(6, typeName); // set COLUMN_SIZE int length = rs.getInt("Length"); - rowData.setInt(6, getColumnSize(typeName, length)); + rowData.setIntValue(7, calculateColumnSize(typeName, precision, length)); + // set BUFFER LENGTH + rowData.setStringValue(8, null); // set DECIMAL_DIGITS - rowData.setInt(8, getDecimalDigits(typeName)); + Integer decimalDigits = calculateDecimalDigits(typeName); + if (decimalDigits != null) { + rowData.setIntValue(9, decimalDigits); + } else { + rowData.setStringValue(9, null); + } // set NUM_PREC_RADIX - rowData.setInt(9, 10); + rowData.setIntValue(10, 10); // set NULLABLE - rowData.setInt(10, getNullable(index, typeName)); + rowData.setIntValue(11, isNullable(rowIndex, typeName)); // set REMARKS - rowData.setString(11, rs.getString("Note")); + String note = rs.getString("Note"); + rowData.setStringValue(12, note.trim().isEmpty() ? null : note); rowDataList.add(rowData); - index++; + rowIndex++; } resultSet.setRowDataList(rowDataList); - return resultSet; - } catch (SQLException e) { e.printStackTrace(); } - return null; + return resultSet; } - protected int getNullable(int index, String typeName) { + private int isNullable(int index, String typeName) { if (index == 0 && "TIMESTAMP".equals(typeName)) return DatabaseMetaData.columnNoNulls; return DatabaseMetaData.columnNullable; } - protected int getColumnSize(String typeName, int length) { + private Integer calculateColumnSize(String typeName, String precisionType, int length) { switch (typeName) { case "TIMESTAMP": - return 23; - default: - return 0; - } - } - - protected int getDecimalDigits(String typeName) { - switch (typeName) { - case "FLOAT": - return 5; - case "DOUBLE": - return 9; - default: - return 0; - } - } - - protected int getDataType(String typeName) { - switch (typeName) { - case "TIMESTAMP": - return Types.TIMESTAMP; - case "INT": - return Types.INTEGER; - case "BIGINT": - return Types.BIGINT; - case "FLOAT": - return Types.FLOAT; - case "DOUBLE": - return Types.DOUBLE; - case "BINARY": - return Types.BINARY; - case "SMALLINT": - return Types.SMALLINT; - case "TINYINT": - return Types.TINYINT; + return precisionType.equals("ms") ? TSDBConstants.TIMESTAMP_MS_PRECISION : TSDBConstants.TIMESTAMP_US_PRECISION; case "BOOL": - return Types.BOOLEAN; + return TSDBConstants.BOOLEAN_PRECISION; + case "TINYINT": + return TSDBConstants.TINYINT_PRECISION; + case "SMALLINT": + return TSDBConstants.SMALLINT_PRECISION; + case "INT": + return TSDBConstants.INT_PRECISION; + case "BIGINT": + return TSDBConstants.BIGINT_PRECISION; + case "FLOAT": + return TSDBConstants.FLOAT_PRECISION; + case "DOUBLE": + return TSDBConstants.DOUBLE_PRECISION; case "NCHAR": - return Types.NCHAR; + case "BINARY": + return length; default: - return Types.NULL; + return null; } } - public ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern) - throws SQLException { + private Integer calculateDecimalDigits(String typeName) { + switch (typeName) { + case "TINYINT": + case "SMALLINT": + case "INT": + case "BIGINT": + return 0; + default: + return null; + } + } + + private ColumnMetaData buildTableCatalogMeta(int colIndex) { + ColumnMetaData col1 = new ColumnMetaData(); + col1.setColIndex(colIndex); + col1.setColName("TABLE_CAT"); + col1.setColType(Types.NCHAR); + return col1; + } + + private ColumnMetaData buildTableSchemaMeta(int colIndex) { + ColumnMetaData col2 = new ColumnMetaData(); + col2.setColIndex(colIndex); + col2.setColName("TABLE_SCHEM"); + col2.setColType(Types.NCHAR); + return col2; + } + + private ColumnMetaData buildTableNameMeta(int colIndex) { + ColumnMetaData col3 = new ColumnMetaData(); + col3.setColIndex(colIndex); + col3.setColName("TABLE_NAME"); + col3.setColSize(193); + col3.setColType(Types.NCHAR); + return col3; + } + + private ColumnMetaData buildColumnNameMeta(int colIndex) { + ColumnMetaData col4 = new ColumnMetaData(); + col4.setColIndex(colIndex); + col4.setColName("COLUMN_NAME"); + col4.setColSize(65); + col4.setColType(Types.NCHAR); + return col4; + } + + private ColumnMetaData buildDataTypeMeta(int colIndex) { + ColumnMetaData col5 = new ColumnMetaData(); + col5.setColIndex(colIndex); + col5.setColName("DATA_TYPE"); + col5.setColType(Types.INTEGER); + return col5; + } + + private ColumnMetaData buildColumnSizeMeta() { + ColumnMetaData col7 = new ColumnMetaData(); + col7.setColIndex(7); + col7.setColName("COLUMN_SIZE"); + col7.setColType(Types.INTEGER); + return col7; + } + + private ColumnMetaData buildBufferLengthMeta() { + ColumnMetaData col8 = new ColumnMetaData(); + col8.setColIndex(8); + col8.setColName("BUFFER_LENGTH"); + return col8; + } + + private ColumnMetaData buildDecimalDigitsMeta() { + ColumnMetaData col9 = new ColumnMetaData(); + col9.setColIndex(9); + col9.setColName("DECIMAL_DIGITS"); + col9.setColType(Types.INTEGER); + return col9; + } + + private ColumnMetaData buildNumPrecRadixMeta() { + ColumnMetaData col10 = new ColumnMetaData(); + col10.setColIndex(10); + col10.setColName("NUM_PREC_RADIX"); + col10.setColType(Types.INTEGER); + return col10; + } + + private ColumnMetaData buildNullableMeta() { + ColumnMetaData col11 = new ColumnMetaData(); + col11.setColIndex(11); + col11.setColName("NULLABLE"); + col11.setColType(Types.INTEGER); + return col11; + } + + private ColumnMetaData buildRemarksMeta(int colIndex) { + ColumnMetaData col12 = new ColumnMetaData(); + col12.setColIndex(colIndex); + col12.setColName("REMARKS"); + col12.setColType(Types.NCHAR); + return col12; + } + + private ColumnMetaData buildColumnDefMeta() { + ColumnMetaData col13 = new ColumnMetaData(); + col13.setColIndex(13); + col13.setColName("COLUMN_DEF"); + col13.setColType(Types.NCHAR); + return col13; + } + + private ColumnMetaData buildSqlDataTypeMeta() { + ColumnMetaData col14 = new ColumnMetaData(); + col14.setColIndex(14); + col14.setColName("SQL_DATA_TYPE"); + col14.setColType(Types.INTEGER); + return col14; + } + + private ColumnMetaData buildSqlDatetimeSubMeta() { + ColumnMetaData col15 = new ColumnMetaData(); + col15.setColIndex(15); + col15.setColName("SQL_DATETIME_SUB"); + col15.setColType(Types.INTEGER); + return col15; + } + + private ColumnMetaData buildCharOctetLengthMeta() { + ColumnMetaData col16 = new ColumnMetaData(); + col16.setColIndex(16); + col16.setColName("CHAR_OCTET_LENGTH"); + col16.setColType(Types.INTEGER); + return col16; + } + + private ColumnMetaData buildOrdinalPositionMeta() { + ColumnMetaData col17 = new ColumnMetaData(); + col17.setColIndex(17); + col17.setColName("ORDINAL_POSITION"); + col17.setColType(Types.INTEGER); + return col17; + } + + private ColumnMetaData buildIsNullableMeta() { + ColumnMetaData col18 = new ColumnMetaData(); + col18.setColIndex(18); + col18.setColName("IS_NULLABLE"); + col18.setColType(Types.NCHAR); + return col18; + } + + private ColumnMetaData buildScopeCatalogMeta() { + ColumnMetaData col19 = new ColumnMetaData(); + col19.setColIndex(19); + col19.setColName("SCOPE_CATALOG"); + col19.setColType(Types.NCHAR); + return col19; + } + + private ColumnMetaData buildScopeSchemaMeta() { + ColumnMetaData col20 = new ColumnMetaData(); + col20.setColIndex(20); + col20.setColName("SCOPE_SCHEMA"); + col20.setColType(Types.NCHAR); + return col20; + } + + private ColumnMetaData buildScopeTableMeta() { + ColumnMetaData col21 = new ColumnMetaData(); + col21.setColIndex(21); + col21.setColName("SCOPE_TABLE"); + col21.setColType(Types.NCHAR); + return col21; + } + + private ColumnMetaData buildSourceDataTypeMeta() { + ColumnMetaData col22 = new ColumnMetaData(); + col22.setColIndex(22); + col22.setColName("SOURCE_DATA_TYPE"); + col22.setColType(TSDBConstants.TSDB_DATA_TYPE_SMALLINT); + return col22; + } + + private ColumnMetaData buildIsAutoIncrementMeta() { + ColumnMetaData col23 = new ColumnMetaData(); + col23.setColIndex(23); + col23.setColName("IS_AUTOINCREMENT"); + col23.setColType(Types.NCHAR); + return col23; + } + + private ColumnMetaData buildIsGeneratedColumnMeta() { + ColumnMetaData col24 = new ColumnMetaData(); + col24.setColIndex(24); + col24.setColName("IS_GENERATEDCOLUMN"); + col24.setColType(Types.NCHAR); + return col24; + } + + private List buildGetColumnsColumnMetaDataList() { + List columnMetaDataList = new ArrayList<>(); + columnMetaDataList.add(buildTableCatalogMeta(1)); //1. TABLE_CAT + columnMetaDataList.add(buildTableSchemaMeta(2)); //2. TABLE_SCHEMA + columnMetaDataList.add(buildTableNameMeta(3)); //3. TABLE_NAME + columnMetaDataList.add(buildColumnNameMeta(4)); //4. COLUMN_NAME + columnMetaDataList.add(buildDataTypeMeta(5)); //5. DATA_TYPE + columnMetaDataList.add(buildTypeNameMeta(6)); //6. TYPE_NAME + columnMetaDataList.add(buildColumnSizeMeta()); //7. COLUMN_SIZE + columnMetaDataList.add(buildBufferLengthMeta()); //8. BUFFER_LENGTH, not used + columnMetaDataList.add(buildDecimalDigitsMeta()); //9. DECIMAL_DIGITS + columnMetaDataList.add(buildNumPrecRadixMeta()); //10. NUM_PREC_RADIX + columnMetaDataList.add(buildNullableMeta()); //11. NULLABLE + columnMetaDataList.add(buildRemarksMeta(12)); //12. REMARKS + columnMetaDataList.add(buildColumnDefMeta()); //13. COLUMN_DEF + columnMetaDataList.add(buildSqlDataTypeMeta()); //14. SQL_DATA_TYPE + columnMetaDataList.add(buildSqlDatetimeSubMeta()); //15. SQL_DATETIME_SUB + columnMetaDataList.add(buildCharOctetLengthMeta()); //16. CHAR_OCTET_LENGTH + columnMetaDataList.add(buildOrdinalPositionMeta()); //17. ORDINAL_POSITION + columnMetaDataList.add(buildIsNullableMeta()); //18. IS_NULLABLE + columnMetaDataList.add(buildScopeCatalogMeta()); //19. SCOPE_CATALOG + columnMetaDataList.add(buildScopeSchemaMeta()); //20. SCOPE_SCHEMA + columnMetaDataList.add(buildScopeTableMeta()); //21. SCOPE_TABLE + columnMetaDataList.add(buildSourceDataTypeMeta()); //22. SOURCE_DATA_TYPE + columnMetaDataList.add(buildIsAutoIncrementMeta()); //23. IS_AUTOINCREMENT + columnMetaDataList.add(buildIsGeneratedColumnMeta()); //24. IS_GENERATEDCOLUMN + return columnMetaDataList; + } + + public ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern) throws SQLException { return getEmptyResultSet(); } - public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) - throws SQLException { + public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) throws SQLException { return getEmptyResultSet(); } - public ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable) - throws SQLException { + public ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable) throws SQLException { return getEmptyResultSet(); } @@ -914,8 +971,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da return getEmptyResultSet(); } - public ResultSet getCrossReference(String parentCatalog, String parentSchema, String parentTable, - String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException { + public ResultSet getCrossReference(String parentCatalog, String parentSchema, String parentTable, String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException { return getEmptyResultSet(); } @@ -923,8 +979,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da return getEmptyResultSet(); } - public ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) - throws SQLException { + public ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) throws SQLException { return getEmptyResultSet(); } @@ -976,8 +1031,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da return false; } - public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) - throws SQLException { + public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) throws SQLException { return getEmptyResultSet(); } @@ -1005,8 +1059,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da public abstract ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException; - public ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern, - String attributeNamePattern) throws SQLException { + public ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern, String attributeNamePattern) throws SQLException { return getEmptyResultSet(); } @@ -1069,18 +1122,15 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da return getEmptyResultSet(); } - public ResultSet getFunctions(String catalog, String schemaPattern, String functionNamePattern) - throws SQLException { + public ResultSet getFunctions(String catalog, String schemaPattern, String functionNamePattern) throws SQLException { return getEmptyResultSet(); } - public ResultSet getFunctionColumns(String catalog, String schemaPattern, String functionNamePattern, - String columnNamePattern) throws SQLException { + public ResultSet getFunctionColumns(String catalog, String schemaPattern, String functionNamePattern, String columnNamePattern) throws SQLException { return getEmptyResultSet(); } - public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern, - String columnNamePattern) throws SQLException { + public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException { return getEmptyResultSet(); } @@ -1093,164 +1143,142 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da } protected ResultSet getCatalogs(Connection conn) throws SQLException { + DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); + // set up ColumnMetaDataList + List columnMetaDataList = new ArrayList<>(); + columnMetaDataList.add(buildTableCatalogMeta(1)); // 1. TABLE_CAT + resultSet.setColumnMetaDataList(columnMetaDataList); + try (Statement stmt = conn.createStatement()) { - DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); - // set up ColumnMetaDataList - List columnMetaDataList = new ArrayList<>(); - // TABLE_CAT - ColumnMetaData col1 = new ColumnMetaData(); - col1.setColIndex(1); - col1.setColName("TABLE_CAT"); - col1.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col1); - - resultSet.setColumnMetaDataList(columnMetaDataList); - List rowDataList = new ArrayList<>(); ResultSet rs = stmt.executeQuery("show databases"); while (rs.next()) { TSDBResultSetRowData rowData = new TSDBResultSetRowData(1); - rowData.setString(0, rs.getString("name")); + rowData.setStringValue(1, rs.getString("name")); rowDataList.add(rowData); } resultSet.setRowDataList(rowDataList); - return resultSet; } + return resultSet; } protected ResultSet getPrimaryKeys(String catalog, String schema, String table, Connection conn) throws SQLException { + if (catalog == null || catalog.isEmpty()) + return null; + if (!isAvailableCatalog(conn, catalog)) + return new EmptyResultSet(); + + DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); try (Statement stmt = conn.createStatement()) { - if (catalog == null || catalog.isEmpty()) - return null; - - ResultSet databases = stmt.executeQuery("show databases"); - String dbname = null; - while (databases.next()) { - dbname = databases.getString("name"); - if (dbname.equalsIgnoreCase(catalog)) - break; - } - databases.close(); - if (dbname == null) - return null; - - stmt.execute("use " + dbname); - DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); // set up ColumnMetaDataList - List columnMetaDataList = new ArrayList<>(); - // TABLE_CAT - ColumnMetaData col1 = new ColumnMetaData(); - col1.setColIndex(0); - col1.setColName("TABLE_CAT"); - col1.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col1); - // TABLE_SCHEM - ColumnMetaData col2 = new ColumnMetaData(); - col2.setColIndex(1); - col2.setColName("TABLE_SCHEM"); - col2.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col2); - // TABLE_NAME - ColumnMetaData col3 = new ColumnMetaData(); - col3.setColIndex(2); - col3.setColName("TABLE_NAME"); - col3.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col3); - // COLUMN_NAME - ColumnMetaData col4 = new ColumnMetaData(); - col4.setColIndex(3); - col4.setColName("COLUMN_NAME"); - col4.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col4); - // KEY_SEQ - ColumnMetaData col5 = new ColumnMetaData(); - col5.setColIndex(4); - col5.setColName("KEY_SEQ"); - col5.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); - columnMetaDataList.add(col5); - // PK_NAME - ColumnMetaData col6 = new ColumnMetaData(); - col6.setColIndex(5); - col6.setColName("PK_NAME"); - col6.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col6); - resultSet.setColumnMetaDataList(columnMetaDataList); - + resultSet.setColumnMetaDataList(buildGetPrimaryKeysMetadataList()); // set rowData List rowDataList = new ArrayList<>(); - ResultSet rs = stmt.executeQuery("describe " + dbname + "." + table); + ResultSet rs = stmt.executeQuery("describe " + catalog + "." + table); rs.next(); TSDBResultSetRowData rowData = new TSDBResultSetRowData(6); - rowData.setString(0, null); - rowData.setString(1, null); - rowData.setString(2, table); - String pkName = rs.getString(1); - rowData.setString(3, pkName); - rowData.setInt(4, 1); - rowData.setString(5, pkName); + rowData.setStringValue(1, catalog); + rowData.setStringValue(2, null); + rowData.setStringValue(3, table); + String primaryKey = rs.getString("Field"); + rowData.setStringValue(4, primaryKey); + rowData.setShortValue(5, (short) 1); + rowData.setStringValue(6, primaryKey); rowDataList.add(rowData); resultSet.setRowDataList(rowDataList); - return resultSet; } + return resultSet; + } + + private List buildGetPrimaryKeysMetadataList() { + List columnMetaDataList = new ArrayList<>(); + columnMetaDataList.add(buildTableCatalogMeta(1)); // 1. TABLE_CAT + columnMetaDataList.add(buildTableSchemaMeta(2)); // 2. TABLE_SCHEM + columnMetaDataList.add(buildTableNameMeta(3)); // 3. TABLE_NAME + columnMetaDataList.add(buildColumnNameMeta(4)); // 4. COLUMN_NAME + columnMetaDataList.add(buildKeySeqMeta(5)); // 5. KEY_SEQ + columnMetaDataList.add(buildPrimaryKeyNameMeta(6)); // 6. PK_NAME + return columnMetaDataList; + } + + private ColumnMetaData buildKeySeqMeta(int colIndex) { + ColumnMetaData col5 = new ColumnMetaData(); + col5.setColIndex(colIndex); + col5.setColName("KEY_SEQ"); + col5.setColType(Types.SMALLINT); + return col5; + } + + private ColumnMetaData buildPrimaryKeyNameMeta(int colIndex) { + ColumnMetaData col6 = new ColumnMetaData(); + col6.setColIndex(colIndex); + col6.setColName("PK_NAME"); + col6.setColType(Types.NCHAR); + return col6; + } + + private boolean isAvailableCatalog(Connection connection, String catalog) { + try (Statement stmt = connection.createStatement()) { + ResultSet databases = stmt.executeQuery("show databases"); + while (databases.next()) { + String dbname = databases.getString("name"); + this.database = dbname; + this.precision = databases.getString("precision"); + if (dbname.equalsIgnoreCase(catalog)) + return true; + } + databases.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + return false; } protected ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern, Connection conn) throws SQLException { + if (catalog == null || catalog.isEmpty()) + return null; + + if (!isAvailableCatalog(conn, catalog)) { + return new EmptyResultSet(); + } + + DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); try (Statement stmt = conn.createStatement()) { - if (catalog == null || catalog.isEmpty()) - return null; - - ResultSet databases = stmt.executeQuery("show databases"); - String dbname = null; - while (databases.next()) { - dbname = databases.getString("name"); - if (dbname.equalsIgnoreCase(catalog)) - break; - } - databases.close(); - if (dbname == null) - return null; - - stmt.execute("use " + dbname); - DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); // set up ColumnMetaDataList - List columnMetaDataList = new ArrayList<>(); - // TABLE_CAT - ColumnMetaData col1 = new ColumnMetaData(); - col1.setColIndex(0); - col1.setColName("TABLE_CAT"); - col1.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col1); - // TABLE_SCHEM - ColumnMetaData col2 = new ColumnMetaData(); - col2.setColIndex(1); - col2.setColName("TABLE_SCHEM"); - col2.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col2); - // TABLE_NAME - ColumnMetaData col3 = new ColumnMetaData(); - col3.setColIndex(2); - col3.setColName("TABLE_NAME"); - col3.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col3); - // SUPERTABLE_NAME - ColumnMetaData col4 = new ColumnMetaData(); - col4.setColIndex(3); - col4.setColName("SUPERTABLE_NAME"); - col4.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); - columnMetaDataList.add(col4); - resultSet.setColumnMetaDataList(columnMetaDataList); - + resultSet.setColumnMetaDataList(buildGetSuperTablesColumnMetaDataList()); + // set result set row data + stmt.execute("use " + catalog); ResultSet rs = stmt.executeQuery("show tables like '" + tableNamePattern + "'"); List rowDataList = new ArrayList<>(); while (rs.next()) { TSDBResultSetRowData rowData = new TSDBResultSetRowData(4); - rowData.setString(2, rs.getString(1)); - rowData.setString(3, rs.getString(4)); + rowData.setStringValue(1, catalog); + rowData.setStringValue(2, null); + rowData.setStringValue(3, rs.getString("table_name")); + rowData.setStringValue(4, rs.getString("stable_name")); rowDataList.add(rowData); } resultSet.setRowDataList(rowDataList); - return resultSet; } + return resultSet; } + + private List buildGetSuperTablesColumnMetaDataList() { + List columnMetaDataList = new ArrayList<>(); + columnMetaDataList.add(buildTableCatalogMeta(1)); // 1. TABLE_CAT + columnMetaDataList.add(buildTableSchemaMeta(2)); // 2. TABLE_SCHEM + columnMetaDataList.add(buildTableNameMeta(3)); // 3. TABLE_NAME + columnMetaDataList.add(buildSuperTableNameMeta(4)); // 4. SUPERTABLE_NAME + return columnMetaDataList; + } + + private ColumnMetaData buildSuperTableNameMeta(int colIndex) { + ColumnMetaData col4 = new ColumnMetaData(); + col4.setColIndex(colIndex); + col4.setColName("SUPERTABLE_NAME"); + col4.setColType(Types.NCHAR); + return col4; + } + } \ No newline at end of file diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractParameterMetaData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractParameterMetaData.java index 7df7252ae2..cb6c7d40ad 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractParameterMetaData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractParameterMetaData.java @@ -1,5 +1,7 @@ package com.taosdata.jdbc; +import com.sun.org.apache.xpath.internal.operations.Bool; + import java.sql.ParameterMetaData; import java.sql.SQLException; import java.sql.Timestamp; @@ -49,6 +51,22 @@ public abstract class AbstractParameterMetaData extends WrapperImpl implements P if (param < 1 && param >= parameters.length) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE); + if (parameters[param - 1] instanceof Boolean) + return TSDBConstants.BOOLEAN_PRECISION; + if (parameters[param - 1] instanceof Byte) + return TSDBConstants.TINYINT_PRECISION; + if (parameters[param - 1] instanceof Short) + return TSDBConstants.SMALLINT_PRECISION; + if (parameters[param - 1] instanceof Integer) + return TSDBConstants.INT_PRECISION; + if (parameters[param - 1] instanceof Long) + return TSDBConstants.BIGINT_PRECISION; + if (parameters[param - 1] instanceof Timestamp) + return TSDBConstants.TIMESTAMP_MS_PRECISION; + if (parameters[param - 1] instanceof Float) + return TSDBConstants.FLOAT_PRECISION; + if (parameters[param - 1] instanceof Double) + return TSDBConstants.DOUBLE_PRECISION; if (parameters[param - 1] instanceof String) return ((String) parameters[param - 1]).length(); if (parameters[param - 1] instanceof byte[]) @@ -60,6 +78,11 @@ public abstract class AbstractParameterMetaData extends WrapperImpl implements P public int getScale(int param) throws SQLException { if (param < 1 && param >= parameters.length) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE); + + if (parameters[param - 1] instanceof Float) + return TSDBConstants.FLOAT_SCALE; + if (parameters[param - 1] instanceof Double) + return TSDBConstants.DOUBLE_SCALE; return 0; } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java index f8ea9af423..e17548055c 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java @@ -66,10 +66,16 @@ public abstract class AbstractResultSet extends WrapperImpl implements ResultSet public abstract byte[] getBytes(int columnIndex) throws SQLException; @Override - public abstract Date getDate(int columnIndex) throws SQLException; + public Date getDate(int columnIndex) throws SQLException { + Timestamp timestamp = getTimestamp(columnIndex); + return timestamp == null ? null : new Date(timestamp.getTime()); + } @Override - public abstract Time getTime(int columnIndex) throws SQLException; + public Time getTime(int columnIndex) throws SQLException { + Timestamp timestamp = getTimestamp(columnIndex); + return timestamp == null ? null : new Time(timestamp.getTime()); + } @Override public abstract Timestamp getTimestamp(int columnIndex) throws SQLException; diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/DatabaseMetaDataResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/DatabaseMetaDataResultSet.java index f6a0fcca31..cd266529f3 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/DatabaseMetaDataResultSet.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/DatabaseMetaDataResultSet.java @@ -14,76 +14,42 @@ *****************************************************************************/ package com.taosdata.jdbc; -import java.io.InputStream; -import java.io.Reader; import java.math.BigDecimal; -import java.net.URL; -import java.sql.Date; import java.sql.*; -import java.util.*; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Iterator; +import java.util.List; /* - * TDengine only supports a subset of the standard SQL, thus this implemetation of the + * TDengine only supports a subset of the standard SQL, thus this implementation of the * standard JDBC API contains more or less some adjustments customized for certain * compatibility needs. */ -public class DatabaseMetaDataResultSet implements ResultSet { +public class DatabaseMetaDataResultSet extends AbstractResultSet { - private List columnMetaDataList; - private List rowDataList; + private List columnMetaDataList = new ArrayList<>(); + private List rowDataList = new ArrayList<>(); private TSDBResultSetRowData rowCursor; // position of cursor, starts from 0 as beforeFirst, increases as next() is called private int cursorRowNumber = 0; - public DatabaseMetaDataResultSet() { - rowDataList = new ArrayList(); - columnMetaDataList = new ArrayList(); - } - - public List getRowDataList() { - return rowDataList; - } - public void setRowDataList(List rowDataList) { this.rowDataList = rowDataList; } - public List getColumnMetaDataList() { - return columnMetaDataList; - } - public void setColumnMetaDataList(List columnMetaDataList) { this.columnMetaDataList = columnMetaDataList; } - public TSDBResultSetRowData getRowCursor() { - return rowCursor; - } - - public void setRowCursor(TSDBResultSetRowData rowCursor) { - this.rowCursor = rowCursor; - } - @Override public boolean next() throws SQLException { -// boolean ret = false; -// if (rowDataList.size() > 0) { -// ret = rowDataList.iterator().hasNext(); -// if (ret) { -// rowCursor = rowDataList.iterator().next(); -// cursorRowNumber++; -// } -// } -// return ret; - - /**** add by zyyang 2020-09-29 ****************/ boolean ret = false; if (!rowDataList.isEmpty() && cursorRowNumber < rowDataList.size()) { rowCursor = rowDataList.get(cursorRowNumber++); ret = true; } - return ret; } @@ -99,189 +65,72 @@ public class DatabaseMetaDataResultSet implements ResultSet { @Override public String getString(int columnIndex) throws SQLException { - columnIndex--; - int colType = columnMetaDataList.get(columnIndex).getColType(); - return rowCursor.getString(columnIndex, colType); + int colType = columnMetaDataList.get(columnIndex - 1).getColType(); + int nativeType = TSDBConstants.jdbcType2TaosType(colType); + return rowCursor.getString(columnIndex, nativeType); } @Override public boolean getBoolean(int columnIndex) throws SQLException { - columnIndex--; - return rowCursor.getBoolean(columnIndex, columnMetaDataList.get(columnIndex).getColType()); + int colType = columnMetaDataList.get(columnIndex - 1).getColType(); + int nativeType = TSDBConstants.jdbcType2TaosType(colType); + return rowCursor.getBoolean(columnIndex, nativeType); } @Override public byte getByte(int columnIndex) throws SQLException { - columnIndex--; - return (byte) rowCursor.getInt(columnIndex, columnMetaDataList.get(columnIndex).getColType()); + int colType = columnMetaDataList.get(columnIndex - 1).getColType(); + int nativeType = TSDBConstants.jdbcType2TaosType(colType); + return (byte) rowCursor.getInt(columnIndex, nativeType); } @Override public short getShort(int columnIndex) throws SQLException { - columnIndex--; - return (short) rowCursor.getInt(columnIndex, columnMetaDataList.get(columnIndex).getColType()); + int colType = columnMetaDataList.get(columnIndex - 1).getColType(); + int nativeType = TSDBConstants.jdbcType2TaosType(colType); + return (short) rowCursor.getInt(columnIndex, nativeType); } @Override public int getInt(int columnIndex) throws SQLException { - columnIndex--; - return rowCursor.getInt(columnIndex, columnMetaDataList.get(columnIndex).getColType()); + int colType = columnMetaDataList.get(columnIndex - 1).getColType(); + int nativeType = TSDBConstants.jdbcType2TaosType(colType); + return rowCursor.getInt(columnIndex, nativeType); } @Override public long getLong(int columnIndex) throws SQLException { - columnIndex--; - return rowCursor.getLong(columnIndex, columnMetaDataList.get(columnIndex).getColType()); + int colType = columnMetaDataList.get(columnIndex - 1).getColType(); + int nativeType = TSDBConstants.jdbcType2TaosType(colType); + return rowCursor.getLong(columnIndex, nativeType); } @Override public float getFloat(int columnIndex) throws SQLException { - columnIndex--; - return rowCursor.getFloat(columnIndex, columnMetaDataList.get(columnIndex).getColType()); + int colType = columnMetaDataList.get(columnIndex - 1).getColType(); + int nativeType = TSDBConstants.jdbcType2TaosType(colType); + return rowCursor.getFloat(columnIndex, nativeType); } @Override public double getDouble(int columnIndex) throws SQLException { - columnIndex--; - return rowCursor.getDouble(columnIndex, columnMetaDataList.get(columnIndex).getColType()); - } - - @Override - public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { - columnIndex--; - return new BigDecimal(rowCursor.getDouble(columnIndex, columnMetaDataList.get(columnIndex).getColType())); + int colType = columnMetaDataList.get(columnIndex - 1).getColType(); + int nativeType = TSDBConstants.jdbcType2TaosType(colType); + return rowCursor.getDouble(columnIndex, nativeType); } @Override public byte[] getBytes(int columnIndex) throws SQLException { - columnIndex--; - return (rowCursor.getString(columnIndex, columnMetaDataList.get(columnIndex).getColType())).getBytes(); - } - - @Override - public Date getDate(int columnIndex) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public Time getTime(int columnIndex) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); + int colType = columnMetaDataList.get(columnIndex - 1).getColType(); + int nativeType = TSDBConstants.jdbcType2TaosType(colType); + return (rowCursor.getString(columnIndex, nativeType)).getBytes(); } @Override public Timestamp getTimestamp(int columnIndex) throws SQLException { - columnIndex--; - return rowCursor.getTimestamp(columnIndex); - } - - @Override - public InputStream getAsciiStream(int columnIndex) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public InputStream getUnicodeStream(int columnIndex) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public InputStream getBinaryStream(int columnIndex) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public String getString(String columnLabel) throws SQLException { - return getString(findColumn(columnLabel)); - } - - @Override - public boolean getBoolean(String columnLabel) throws SQLException { - return getBoolean(findColumn(columnLabel)); - } - - @Override - public byte getByte(String columnLabel) throws SQLException { - return getByte(findColumn(columnLabel)); - } - - @Override - public short getShort(String columnLabel) throws SQLException { - return getShort(findColumn(columnLabel)); - } - - @Override - public int getInt(String columnLabel) throws SQLException { - return getInt(findColumn(columnLabel)); - } - - @Override - public long getLong(String columnLabel) throws SQLException { - return getLong(findColumn(columnLabel)); - } - - @Override - public float getFloat(String columnLabel) throws SQLException { - return getFloat(findColumn(columnLabel)); - } - - @Override - public double getDouble(String columnLabel) throws SQLException { - return getDouble(findColumn(columnLabel)); - } - - @Override - public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException { - return getBigDecimal(findColumn(columnLabel)); - } - - @Override - public byte[] getBytes(String columnLabel) throws SQLException { - return getBytes(findColumn(columnLabel)); - } - - @Override - public Date getDate(String columnLabel) throws SQLException { - return getDate(findColumn(columnLabel)); - } - - @Override - public Time getTime(String columnLabel) throws SQLException { - return getTime(findColumn(columnLabel)); - } - - @Override - public Timestamp getTimestamp(String columnLabel) throws SQLException { - return getTimestamp(findColumn(columnLabel)); - } - - @Override - public InputStream getAsciiStream(String columnLabel) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public InputStream getUnicodeStream(String columnLabel) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public InputStream getBinaryStream(String columnLabel) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public SQLWarning getWarnings() throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void clearWarnings() throws SQLException { - - } - - @Override - public String getCursorName() throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); + int colType = columnMetaDataList.get(columnIndex - 1).getColType(); + int nativeType = TSDBConstants.jdbcType2TaosType(colType); + return rowCursor.getTimestamp(columnIndex,nativeType); } @Override @@ -291,12 +140,7 @@ public class DatabaseMetaDataResultSet implements ResultSet { @Override public Object getObject(int columnIndex) throws SQLException { - return rowCursor.get(columnIndex); - } - - @Override - public Object getObject(String columnLabel) throws SQLException { - return rowCursor.get(findColumn(columnLabel)); + return rowCursor.getObject(columnIndex); } @Override @@ -304,31 +148,19 @@ public class DatabaseMetaDataResultSet implements ResultSet { Iterator colMetaDataIt = this.columnMetaDataList.iterator(); while (colMetaDataIt.hasNext()) { ColumnMetaData colMetaData = colMetaDataIt.next(); - if (colMetaData.getColName() != null && colMetaData.getColName().equalsIgnoreCase(columnLabel)) { - return colMetaData.getColIndex() + 1; + if (colMetaData.getColName() != null && colMetaData.getColName().equals(columnLabel)) { + return colMetaData.getColIndex(); } } throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE); } - @Override - public Reader getCharacterStream(int columnIndex) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public Reader getCharacterStream(String columnLabel) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - @Override public BigDecimal getBigDecimal(int columnIndex) throws SQLException { - return new BigDecimal(rowCursor.getDouble(columnIndex, columnMetaDataList.get(columnIndex).getColType())); - } - - @Override - public BigDecimal getBigDecimal(String columnLabel) throws SQLException { - return getBigDecimal(findColumn(columnLabel)); + int colType = columnMetaDataList.get(columnIndex - 1).getColType(); + int nativeType = TSDBConstants.jdbcType2TaosType(colType); + double value = rowCursor.getDouble(columnIndex, nativeType); + return new BigDecimal(value); } @Override @@ -378,7 +210,6 @@ public class DatabaseMetaDataResultSet implements ResultSet { } else { return 0; } - } @Override @@ -396,434 +227,14 @@ public class DatabaseMetaDataResultSet implements ResultSet { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); } - @Override - public void setFetchDirection(int direction) throws SQLException { - - } - - @Override - public int getFetchDirection() throws SQLException { - return ResultSet.FETCH_FORWARD; - } - - @Override - public void setFetchSize(int rows) throws SQLException { - - } - - @Override - public int getFetchSize() throws SQLException { - return 0; - } - - @Override - public int getType() throws SQLException { - return ResultSet.TYPE_FORWARD_ONLY; - } - - @Override - public int getConcurrency() throws SQLException { - return ResultSet.CONCUR_READ_ONLY; - } - - @Override - public boolean rowUpdated() throws SQLException { - return false; - } - - @Override - public boolean rowInserted() throws SQLException { - return false; - } - - @Override - public boolean rowDeleted() throws SQLException { - return false; - } - - @Override - public void updateNull(int columnIndex) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateBoolean(int columnIndex, boolean x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateByte(int columnIndex, byte x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateShort(int columnIndex, short x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateInt(int columnIndex, int x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateLong(int columnIndex, long x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateFloat(int columnIndex, float x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateDouble(int columnIndex, double x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateString(int columnIndex, String x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateBytes(int columnIndex, byte[] x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateDate(int columnIndex, Date x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateTime(int columnIndex, Time x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateObject(int columnIndex, Object x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateNull(String columnLabel) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateBoolean(String columnLabel, boolean x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateByte(String columnLabel, byte x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateShort(String columnLabel, short x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateInt(String columnLabel, int x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateLong(String columnLabel, long x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateFloat(String columnLabel, float x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateDouble(String columnLabel, double x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateString(String columnLabel, String x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateBytes(String columnLabel, byte[] x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateDate(String columnLabel, Date x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateTime(String columnLabel, Time x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateObject(String columnLabel, Object x) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void insertRow() throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void updateRow() throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void deleteRow() throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void refreshRow() throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void cancelRowUpdates() throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void moveToInsertRow() throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public void moveToCurrentRow() throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - @Override public Statement getStatement() throws SQLException { return null; } - @Override - public Object getObject(int columnIndex, Map> map) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public Ref getRef(int columnIndex) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public Blob getBlob(int columnIndex) throws SQLException { - return null; - } - - @Override - public Clob getClob(int columnIndex) throws SQLException { - return null; - } - - @Override - public Array getArray(int columnIndex) throws SQLException { - return null; - } - - @Override - public Object getObject(String columnLabel, Map> map) throws SQLException { - return null; - } - - @Override - public Ref getRef(String columnLabel) throws SQLException { - return null; - } - - @Override - public Blob getBlob(String columnLabel) throws SQLException { - return null; - } - - @Override - public Clob getClob(String columnLabel) throws SQLException { - return null; - } - - @Override - public Array getArray(String columnLabel) throws SQLException { - return null; - } - - @Override - public Date getDate(int columnIndex, Calendar cal) throws SQLException { - return null; - } - - @Override - public Date getDate(String columnLabel, Calendar cal) throws SQLException { - return null; - } - - @Override - public Time getTime(int columnIndex, Calendar cal) throws SQLException { - return null; - } - - @Override - public Time getTime(String columnLabel, Calendar cal) throws SQLException { - return null; - } - - @Override public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { - return null; - } - - @Override - public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException { - return null; - } - - @Override - public URL getURL(int columnIndex) throws SQLException { - return null; - } - - @Override - public URL getURL(String columnLabel) throws SQLException { - return null; - } - - @Override - public void updateRef(int columnIndex, Ref x) throws SQLException { - - } - - @Override - public void updateRef(String columnLabel, Ref x) throws SQLException { - - } - - @Override - public void updateBlob(int columnIndex, Blob x) throws SQLException { - - } - - @Override - public void updateBlob(String columnLabel, Blob x) throws SQLException { - - } - - @Override - public void updateClob(int columnIndex, Clob x) throws SQLException { - - } - - @Override - public void updateClob(String columnLabel, Clob x) throws SQLException { - - } - - @Override - public void updateArray(int columnIndex, Array x) throws SQLException { - - } - - @Override - public void updateArray(String columnLabel, Array x) throws SQLException { - - } - - @Override - public RowId getRowId(int columnIndex) throws SQLException { - return null; - } - - @Override - public RowId getRowId(String columnLabel) throws SQLException { - return null; - } - - @Override - public void updateRowId(int columnIndex, RowId x) throws SQLException { - - } - - @Override - public void updateRowId(String columnLabel, RowId x) throws SQLException { - - } - - @Override - public int getHoldability() throws SQLException { - return 0; + //TODO: calendar is not used + return getTimestamp(columnIndex); } @Override @@ -831,246 +242,9 @@ public class DatabaseMetaDataResultSet implements ResultSet { return false; } - @Override - public void updateNString(int columnIndex, String nString) throws SQLException { - - } - - @Override - public void updateNString(String columnLabel, String nString) throws SQLException { - - } - - @Override - public void updateNClob(int columnIndex, NClob nClob) throws SQLException { - - } - - @Override - public void updateNClob(String columnLabel, NClob nClob) throws SQLException { - - } - - @Override - public NClob getNClob(int columnIndex) throws SQLException { - return null; - } - - @Override - public NClob getNClob(String columnLabel) throws SQLException { - return null; - } - - @Override - public SQLXML getSQLXML(int columnIndex) throws SQLException { - return null; - } - - @Override - public SQLXML getSQLXML(String columnLabel) throws SQLException { - return null; - } - - @Override - public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException { - - } - - @Override - public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException { - - } - @Override public String getNString(int columnIndex) throws SQLException { - return null; + return getString(columnIndex); } - @Override - public String getNString(String columnLabel) throws SQLException { - return null; - } - - @Override - public Reader getNCharacterStream(int columnIndex) throws SQLException { - return null; - } - - @Override - public Reader getNCharacterStream(String columnLabel) throws SQLException { - return null; - } - - @Override - public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException { - - } - - @Override - public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { - - } - - @Override - public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException { - - } - - @Override - public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException { - - } - - @Override - public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException { - - } - - @Override - public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException { - - } - - @Override - public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException { - - } - - @Override - public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { - - } - - @Override - public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException { - - } - - @Override - public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException { - - } - - @Override - public void updateClob(int columnIndex, Reader reader, long length) throws SQLException { - - } - - @Override - public void updateClob(String columnLabel, Reader reader, long length) throws SQLException { - - } - - @Override - public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException { - - } - - @Override - public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException { - - } - - @Override - public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException { - - } - - @Override - public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException { - - } - - @Override - public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException { - - } - - @Override - public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException { - - } - - @Override - public void updateCharacterStream(int columnIndex, Reader x) throws SQLException { - - } - - @Override - public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException { - - } - - @Override - public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException { - - } - - @Override - public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException { - - } - - @Override - public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException { - - } - - @Override - public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException { - - } - - @Override - public void updateClob(int columnIndex, Reader reader) throws SQLException { - - } - - @Override - public void updateClob(String columnLabel, Reader reader) throws SQLException { - - } - - @Override - public void updateNClob(int columnIndex, Reader reader) throws SQLException { - - } - - @Override - public void updateNClob(String columnLabel, Reader reader) throws SQLException { - - } - - @Override - public T getObject(int columnIndex, Class type) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public T getObject(String columnLabel, Class type) throws SQLException { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } - - @Override - public T unwrap(Class iface) throws SQLException { - return null; - } - - @Override - public boolean isWrapperFor(Class iface) throws SQLException { - return false; - } - - private int getTrueColumnIndex(int columnIndex) throws SQLException { - if (columnIndex < 1) { - throw new SQLException("Column Index out of range, " + columnIndex + " < " + 1); - } - - int numOfCols = this.columnMetaDataList.size(); - if (columnIndex > numOfCols) { - throw new SQLException("Column Index out of range, " + columnIndex + " > " + numOfCols); - } - - return columnIndex - 1; - } } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConstants.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConstants.java index f38555ce8a..e6406d2c6d 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConstants.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConstants.java @@ -41,15 +41,15 @@ public abstract class TSDBConstants { public static final int TSDB_DATA_TYPE_BINARY = 8; public static final int TSDB_DATA_TYPE_TIMESTAMP = 9; public static final int TSDB_DATA_TYPE_NCHAR = 10; - /* - 系统增加新的无符号数据类型,分别是: - unsigned tinyint, 数值范围:0-254, NULL 为255 - unsigned smallint,数值范围: 0-65534, NULL 为65535 - unsigned int,数值范围:0-4294967294,NULL 为4294967295u - unsigned bigint,数值范围:0-18446744073709551614u,NULL 为18446744073709551615u。 - example: - create table tb(ts timestamp, a tinyint unsigned, b smallint unsigned, c int unsigned, d bigint unsigned); - */ + /** + * 系统增加新的无符号数据类型,分别是: + * unsigned tinyint, 数值范围:0-254, NULL 为255 + * unsigned smallint,数值范围: 0-65534, NULL 为65535 + * unsigned int,数值范围:0-4294967294,NULL 为4294967295u + * unsigned bigint,数值范围:0-18446744073709551614u,NULL 为18446744073709551615u。 + * example: + * create table tb(ts timestamp, a tinyint unsigned, b smallint unsigned, c int unsigned, d bigint unsigned); + */ public static final int TSDB_DATA_TYPE_UTINYINT = 11; //unsigned tinyint public static final int TSDB_DATA_TYPE_USMALLINT = 12; //unsigned smallint public static final int TSDB_DATA_TYPE_UINT = 13; //unsigned int @@ -57,6 +57,47 @@ public abstract class TSDBConstants { // nchar column max length public static final int maxFieldSize = 16 * 1024; + // precision for data types + public static final int BOOLEAN_PRECISION = 1; + public static final int TINYINT_PRECISION = 4; + public static final int SMALLINT_PRECISION = 6; + public static final int INT_PRECISION = 11; + public static final int BIGINT_PRECISION = 20; + public static final int FLOAT_PRECISION = 12; + public static final int DOUBLE_PRECISION = 22; + public static final int TIMESTAMP_MS_PRECISION = 23; + public static final int TIMESTAMP_US_PRECISION = 26; + // scale for data types + public static final int FLOAT_SCALE = 31; + public static final int DOUBLE_SCALE = 31; + + public static int typeName2JdbcType(String type) { + switch (type.toUpperCase()) { + case "TIMESTAMP": + return Types.TIMESTAMP; + case "INT": + return Types.INTEGER; + case "BIGINT": + return Types.BIGINT; + case "FLOAT": + return Types.FLOAT; + case "DOUBLE": + return Types.DOUBLE; + case "BINARY": + return Types.BINARY; + case "SMALLINT": + return Types.SMALLINT; + case "TINYINT": + return Types.TINYINT; + case "BOOL": + return Types.BOOLEAN; + case "NCHAR": + return Types.NCHAR; + default: + return Types.NULL; + } + } + public static int taosType2JdbcType(int taosType) throws SQLException { switch (taosType) { case TSDBConstants.TSDB_DATA_TYPE_BOOL: @@ -88,7 +129,7 @@ public abstract class TSDBConstants { } public static String taosType2JdbcTypeName(int taosType) throws SQLException { - switch (taosType){ + switch (taosType) { case TSDBConstants.TSDB_DATA_TYPE_BOOL: return "BOOL"; case TSDBConstants.TSDB_DATA_TYPE_UTINYINT: @@ -119,7 +160,7 @@ public abstract class TSDBConstants { } public static int jdbcType2TaosType(int jdbcType) throws SQLException { - switch (jdbcType){ + switch (jdbcType) { case Types.BOOLEAN: return TSDBConstants.TSDB_DATA_TYPE_BOOL; case Types.TINYINT: @@ -145,7 +186,7 @@ public abstract class TSDBConstants { } public static String jdbcType2TaosTypeName(int jdbcType) throws SQLException { - switch (jdbcType){ + switch (jdbcType) { case Types.BOOLEAN: return "BOOL"; case Types.TINYINT: diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java index 256e735285..92792d9751 100755 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java @@ -16,13 +16,13 @@ */ package com.taosdata.jdbc; +import com.taosdata.jdbc.utils.TaosInfo; + import java.nio.ByteBuffer; import java.sql.SQLException; import java.sql.SQLWarning; import java.util.List; -import com.taosdata.jdbc.utils.TaosInfo; - /** * JNI connector */ @@ -30,10 +30,10 @@ public class TSDBJNIConnector { private static volatile Boolean isInitialized = false; private TaosInfo taosInfo = TaosInfo.getInstance(); - + // Connection pointer used in C private long taos = TSDBConstants.JNI_NULL_POINTER; - + // result set status in current connection private boolean isResultsetClosed; @@ -194,7 +194,9 @@ public class TSDBJNIConnector { * Get schema metadata */ public int getSchemaMetaData(long resultSet, List columnMetaData) { - return this.getSchemaMetaDataImp(this.taos, resultSet, columnMetaData); + int ret = this.getSchemaMetaDataImp(this.taos, resultSet, columnMetaData); + columnMetaData.stream().forEach(column -> column.setColIndex(column.getColIndex() + 1)); + return ret; } private native int getSchemaMetaDataImp(long connection, long resultSet, List columnMetaData); @@ -221,7 +223,7 @@ public class TSDBJNIConnector { */ public void closeConnection() throws SQLException { int code = this.closeConnectionImp(this.taos); - + if (code < 0) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); } else if (code == 0) { @@ -229,7 +231,7 @@ public class TSDBJNIConnector { } else { throw new SQLException("Undefined error code returned by TDengine when closing a connection"); } - + // invoke closeConnectionImpl only here taosInfo.connect_close_increment(); } @@ -274,67 +276,76 @@ public class TSDBJNIConnector { } private native int validateCreateTableSqlImp(long connection, byte[] sqlBytes); - - public long prepareStmt(String sql) throws SQLException { - Long stmt = prepareStmtImp(sql.getBytes(), this.taos); - if (stmt == TSDBConstants.JNI_TDENGINE_ERROR) { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_SQL); - } else if (stmt == TSDBConstants.JNI_CONNECTION_NULL) { + + public long prepareStmt(String sql) throws SQLException { + Long stmt; + try { + stmt = prepareStmtImp(sql.getBytes(), this.taos); + } catch (Exception e) { + e.printStackTrace(); + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_ENCODING); + } + + if (stmt == TSDBConstants.JNI_CONNECTION_NULL) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); - } else if (stmt == TSDBConstants.JNI_SQL_NULL) { + } + + if (stmt == TSDBConstants.JNI_SQL_NULL) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_SQL_NULL); - } else if (stmt == TSDBConstants.JNI_OUT_OF_MEMORY) { + } + + if (stmt == TSDBConstants.JNI_OUT_OF_MEMORY) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_OUT_OF_MEMORY); } - - return stmt; + + return stmt; } - + private native long prepareStmtImp(byte[] sql, long con); - + public void setBindTableName(long stmt, String tableName) throws SQLException { - int code = setBindTableNameImp(stmt, tableName, this.taos); - if (code != TSDBConstants.JNI_SUCCESS) { + int code = setBindTableNameImp(stmt, tableName, this.taos); + if (code != TSDBConstants.JNI_SUCCESS) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "failed to set table name"); - } - } - + } + } + private native int setBindTableNameImp(long stmt, String name, long conn); - + public void setBindTableNameAndTags(long stmt, String tableName, int numOfTags, ByteBuffer tags, ByteBuffer typeList, ByteBuffer lengthList, ByteBuffer nullList) throws SQLException { - int code = setTableNameTagsImp(stmt, tableName, numOfTags, tags.array(), typeList.array(), lengthList.array(), - nullList.array(), this.taos); - if (code != TSDBConstants.JNI_SUCCESS) { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "failed to bind table name and corresponding tags"); - } + int code = setTableNameTagsImp(stmt, tableName, numOfTags, tags.array(), typeList.array(), lengthList.array(), + nullList.array(), this.taos); + if (code != TSDBConstants.JNI_SUCCESS) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "failed to bind table name and corresponding tags"); + } } - + private native int setTableNameTagsImp(long stmt, String name, int numOfTags, byte[] tags, byte[] typeList, byte[] lengthList, byte[] nullList, long conn); - - public void bindColumnDataArray(long stmt, ByteBuffer colDataList, ByteBuffer lengthList, ByteBuffer isNullList, int type, int bytes, int numOfRows,int columnIndex) throws SQLException { - int code = bindColDataImp(stmt, colDataList.array(), lengthList.array(), isNullList.array(), type, bytes, numOfRows, columnIndex, this.taos); - if (code != TSDBConstants.JNI_SUCCESS) { + + public void bindColumnDataArray(long stmt, ByteBuffer colDataList, ByteBuffer lengthList, ByteBuffer isNullList, int type, int bytes, int numOfRows, int columnIndex) throws SQLException { + int code = bindColDataImp(stmt, colDataList.array(), lengthList.array(), isNullList.array(), type, bytes, numOfRows, columnIndex, this.taos); + if (code != TSDBConstants.JNI_SUCCESS) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "failed to bind column data"); - } - } - + } + } + private native int bindColDataImp(long stmt, byte[] colDataList, byte[] lengthList, byte[] isNullList, int type, int bytes, int numOfRows, int columnIndex, long conn); - + public void executeBatch(long stmt) throws SQLException { - int code = executeBatchImp(stmt, this.taos); - if (code != TSDBConstants.JNI_SUCCESS) { + int code = executeBatchImp(stmt, this.taos); + if (code != TSDBConstants.JNI_SUCCESS) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "failed to execute batch bind"); - } + } } - + private native int executeBatchImp(long stmt, long con); - + public void closeBatch(long stmt) throws SQLException { - int code = closeStmt(stmt, this.taos); - if (code != TSDBConstants.JNI_SUCCESS) { + int code = closeStmt(stmt, this.taos); + if (code != TSDBConstants.JNI_SUCCESS) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "failed to close batch bind"); - } + } } - + private native int closeStmt(long stmt, long con); } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java index f6810237c0..c3d5abf35c 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java @@ -39,18 +39,18 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat private String rawSql; private Object[] parameters; private boolean isPrepared; - + private ArrayList colData; private ArrayList tableTags; private int tagValueLength; - + private String tableName; private long nativeStmtHandle = 0; - + private volatile TSDBParameterMetaData parameterMetaData; TSDBPreparedStatement(TSDBConnection connection, String sql) { - super(connection); + super(connection); init(sql); int parameterCnt = 0; @@ -64,11 +64,11 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat this.isPrepared = true; } - if (parameterCnt > 1) { - // the table name is also a parameter, so ignore it. - this.colData = new ArrayList(); - this.tableTags = new ArrayList(); - } + if (parameterCnt > 1) { + // the table name is also a parameter, so ignore it. + this.colData = new ArrayList(); + this.tableTags = new ArrayList(); + } } private void init(String sql) { @@ -205,9 +205,7 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat @Override public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException { - if (isClosed()) - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); + setObject(parameterIndex, x.doubleValue()); } @Override @@ -222,16 +220,12 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat @Override public void setDate(int parameterIndex, Date x) throws SQLException { - if (isClosed()) - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); + setObject(parameterIndex, new Timestamp(x.getTime())); } @Override public void setTime(int parameterIndex, Time x) throws SQLException { - if (isClosed()) - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); + setObject(parameterIndex, new Timestamp(x.getTime())); } @Override @@ -279,11 +273,10 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); } - + if (parameterIndex < 1 && parameterIndex >= parameters.length) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE); } - parameters[parameterIndex - 1] = x; } @@ -323,7 +316,7 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); } - + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); } @@ -350,9 +343,9 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat @Override public ResultSetMetaData getMetaData() throws SQLException { - if (isClosed()) - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); + if (this.getResultSet() == null) + return null; + return getResultSet().getMetaData(); } @Override @@ -396,10 +389,7 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat if (isClosed()) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); - if (parameterMetaData == null) { - this.parameterMetaData = new TSDBParameterMetaData(parameters); - } - return this.parameterMetaData; + return new TSDBParameterMetaData(parameters); } @Override @@ -411,9 +401,7 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat @Override public void setNString(int parameterIndex, String value) throws SQLException { - if (isClosed()) - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); + setString(parameterIndex, value); } @Override @@ -536,489 +524,495 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); } - + /////////////////////////////////////////////////////////////////////// // NOTE: the following APIs are not JDBC compatible // set the bind table name private static class ColumnInfo { - @SuppressWarnings("rawtypes") - private ArrayList data; - private int type; - private int bytes; - private boolean typeIsSet; - - public ColumnInfo() { - this.typeIsSet = false; - } - - public void setType(int type) throws SQLException { - if (this.isTypeSet()) { + @SuppressWarnings("rawtypes") + private ArrayList data; + private int type; + private int bytes; + private boolean typeIsSet; + + public ColumnInfo() { + this.typeIsSet = false; + } + + public void setType(int type) throws SQLException { + if (this.isTypeSet()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "column data type has been set"); - } + } + + this.typeIsSet = true; + this.type = type; + } + + public boolean isTypeSet() { + return this.typeIsSet; + } + } + + ; - this.typeIsSet = true; - this.type = type; - } - - public boolean isTypeSet() { - return this.typeIsSet; - } - }; - private static class TableTagInfo { - private boolean isNull; - private Object value; - private int type; - public TableTagInfo(Object value, int type) { - this.value = value; - this.type = type; - } - - public static TableTagInfo createNullTag(int type) { - TableTagInfo info = new TableTagInfo(null, type); - info.isNull = true; - return info; - } - }; - - public void setTableName(String name) { - this.tableName = name; - } - - private void ensureTagCapacity(int index) { - if (this.tableTags.size() < index + 1) { - int delta = index + 1 - this.tableTags.size(); - this.tableTags.addAll(Collections.nCopies(delta, null)); - } - } - - public void setTagNull(int index, int type) { - ensureTagCapacity(index); - this.tableTags.set(index, TableTagInfo.createNullTag(type)); - } - - public void setTagBoolean(int index, boolean value) { - ensureTagCapacity(index); - this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_BOOL)); - this.tagValueLength += Byte.BYTES; - } - - public void setTagInt(int index, int value) { - ensureTagCapacity(index); - this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_INT)); - this.tagValueLength += Integer.BYTES; - } - - public void setTagByte(int index, byte value) { - ensureTagCapacity(index); - this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_TINYINT)); - this.tagValueLength += Byte.BYTES; - } - - public void setTagShort(int index, short value) { - ensureTagCapacity(index); - this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_SMALLINT)); - this.tagValueLength += Short.BYTES; - } - - public void setTagLong(int index, long value) { - ensureTagCapacity(index); - this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_BIGINT)); - this.tagValueLength += Long.BYTES; - } - - public void setTagTimestamp(int index, long value) { - ensureTagCapacity(index); - this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP)); - this.tagValueLength += Long.BYTES; - } - - public void setTagFloat(int index, float value) { - ensureTagCapacity(index); - this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_FLOAT)); - this.tagValueLength += Float.BYTES; - } - - public void setTagDouble(int index, double value) { - ensureTagCapacity(index); - this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_DOUBLE)); - this.tagValueLength += Double.BYTES; - } - - public void setTagString(int index, String value) { - ensureTagCapacity(index); - this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_BINARY)); - this.tagValueLength += value.getBytes().length; - } - - public void setTagNString(int index, String value) { - ensureTagCapacity(index); - this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_NCHAR)); - - String charset = TaosGlobalConfig.getCharset(); - try { - this.tagValueLength += value.getBytes(charset).length; - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - } - - public void setValueImpl(int columnIndex, ArrayList list, int type, int bytes) throws SQLException { - if (this.colData.size() == 0) { - this.colData.addAll(Collections.nCopies(this.parameters.length - 1 - this.tableTags.size(), null)); + private boolean isNull; + private Object value; + private int type; - } - ColumnInfo col = (ColumnInfo) this.colData.get(columnIndex); - if (col == null) { - ColumnInfo p = new ColumnInfo(); - p.setType(type); - p.bytes = bytes; - p.data = (ArrayList) list.clone(); - this.colData.set(columnIndex, p); - } else { - if (col.type != type) { + public TableTagInfo(Object value, int type) { + this.value = value; + this.type = type; + } + + public static TableTagInfo createNullTag(int type) { + TableTagInfo info = new TableTagInfo(null, type); + info.isNull = true; + return info; + } + } + + ; + + public void setTableName(String name) { + this.tableName = name; + } + + private void ensureTagCapacity(int index) { + if (this.tableTags.size() < index + 1) { + int delta = index + 1 - this.tableTags.size(); + this.tableTags.addAll(Collections.nCopies(delta, null)); + } + } + + public void setTagNull(int index, int type) { + ensureTagCapacity(index); + this.tableTags.set(index, TableTagInfo.createNullTag(type)); + } + + public void setTagBoolean(int index, boolean value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_BOOL)); + this.tagValueLength += Byte.BYTES; + } + + public void setTagInt(int index, int value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_INT)); + this.tagValueLength += Integer.BYTES; + } + + public void setTagByte(int index, byte value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_TINYINT)); + this.tagValueLength += Byte.BYTES; + } + + public void setTagShort(int index, short value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_SMALLINT)); + this.tagValueLength += Short.BYTES; + } + + public void setTagLong(int index, long value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_BIGINT)); + this.tagValueLength += Long.BYTES; + } + + public void setTagTimestamp(int index, long value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP)); + this.tagValueLength += Long.BYTES; + } + + public void setTagFloat(int index, float value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_FLOAT)); + this.tagValueLength += Float.BYTES; + } + + public void setTagDouble(int index, double value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_DOUBLE)); + this.tagValueLength += Double.BYTES; + } + + public void setTagString(int index, String value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_BINARY)); + this.tagValueLength += value.getBytes().length; + } + + public void setTagNString(int index, String value) { + ensureTagCapacity(index); + this.tableTags.set(index, new TableTagInfo(value, TSDBConstants.TSDB_DATA_TYPE_NCHAR)); + + String charset = TaosGlobalConfig.getCharset(); + try { + this.tagValueLength += value.getBytes(charset).length; + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + + public void setValueImpl(int columnIndex, ArrayList list, int type, int bytes) throws SQLException { + if (this.colData.size() == 0) { + this.colData.addAll(Collections.nCopies(this.parameters.length - 1 - this.tableTags.size(), null)); + } + + ColumnInfo col = (ColumnInfo) this.colData.get(columnIndex); + if (col == null) { + ColumnInfo p = new ColumnInfo(); + p.setType(type); + p.bytes = bytes; + p.data = (ArrayList) list.clone(); + this.colData.set(columnIndex, p); + } else { + if (col.type != type) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "column data type mismatch"); - } - col.data.addAll(list); - } + } + col.data.addAll(list); + } } - + public void setInt(int columnIndex, ArrayList list) throws SQLException { - setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_INT, Integer.BYTES); + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_INT, Integer.BYTES); } - + public void setFloat(int columnIndex, ArrayList list) throws SQLException { - setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_FLOAT, Float.BYTES); + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_FLOAT, Float.BYTES); } - + public void setTimestamp(int columnIndex, ArrayList list) throws SQLException { - setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP, Long.BYTES); + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP, Long.BYTES); } - + public void setLong(int columnIndex, ArrayList list) throws SQLException { - setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_BIGINT, Long.BYTES); + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_BIGINT, Long.BYTES); } - + public void setDouble(int columnIndex, ArrayList list) throws SQLException { - setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_DOUBLE, Double.BYTES); + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_DOUBLE, Double.BYTES); } - + public void setBoolean(int columnIndex, ArrayList list) throws SQLException { - setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_BOOL, Byte.BYTES); + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_BOOL, Byte.BYTES); } - + public void setByte(int columnIndex, ArrayList list) throws SQLException { - setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_TINYINT, Byte.BYTES); + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_TINYINT, Byte.BYTES); } - + public void setShort(int columnIndex, ArrayList list) throws SQLException { - setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_SMALLINT, Short.BYTES); + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_SMALLINT, Short.BYTES); } - + public void setString(int columnIndex, ArrayList list, int size) throws SQLException { - setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_BINARY, size); + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_BINARY, size); } - + // note: expand the required space for each NChar character public void setNString(int columnIndex, ArrayList list, int size) throws SQLException { - setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_NCHAR, size * Integer.BYTES); + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_NCHAR, size * Integer.BYTES); } - + public void columnDataAddBatch() throws SQLException { - // pass the data block to native code - if (rawSql == null) { + // pass the data block to native code + if (rawSql == null) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "sql statement not set yet"); - } - - // table name is not set yet, abort - if (this.tableName == null) { + } + + // table name is not set yet, abort + if (this.tableName == null) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "table name not set yet"); - } - - int numOfCols = this.colData.size(); - if (numOfCols == 0) { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "column data not bind"); - } - - TSDBJNIConnector connector = ((TSDBConnection) this.getConnection()).getConnector(); - this.nativeStmtHandle = connector.prepareStmt(rawSql); - - if (this.tableTags == null) { - connector.setBindTableName(this.nativeStmtHandle, this.tableName); - } else { - int num = this.tableTags.size(); - ByteBuffer tagDataList = ByteBuffer.allocate(this.tagValueLength); - tagDataList.order(ByteOrder.LITTLE_ENDIAN); + } - ByteBuffer typeList = ByteBuffer.allocate(num); - typeList.order(ByteOrder.LITTLE_ENDIAN); + int numOfCols = this.colData.size(); + if (numOfCols == 0) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "column data not bind"); + } - ByteBuffer lengthList = ByteBuffer.allocate(num * Long.BYTES); - lengthList.order(ByteOrder.LITTLE_ENDIAN); + TSDBJNIConnector connector = ((TSDBConnection) this.getConnection()).getConnector(); + this.nativeStmtHandle = connector.prepareStmt(rawSql); - ByteBuffer isNullList = ByteBuffer.allocate(num * Integer.BYTES); - isNullList.order(ByteOrder.LITTLE_ENDIAN); + if (this.tableTags == null) { + connector.setBindTableName(this.nativeStmtHandle, this.tableName); + } else { + int num = this.tableTags.size(); + ByteBuffer tagDataList = ByteBuffer.allocate(this.tagValueLength); + tagDataList.order(ByteOrder.LITTLE_ENDIAN); - for (int i = 0; i < num; ++i) { - TableTagInfo tag = this.tableTags.get(i); - if (tag.isNull) { - typeList.put((byte) tag.type); - isNullList.putInt(1); - lengthList.putLong(0); - continue; - } - - switch (tag.type) { - case TSDBConstants.TSDB_DATA_TYPE_INT: { - Integer val = (Integer) tag.value; - tagDataList.putInt(val); - lengthList.putLong(Integer.BYTES); - break; - } - case TSDBConstants.TSDB_DATA_TYPE_TINYINT: { - Byte val = (Byte) tag.value; - tagDataList.put(val); - lengthList.putLong(Byte.BYTES); - break; - } + ByteBuffer typeList = ByteBuffer.allocate(num); + typeList.order(ByteOrder.LITTLE_ENDIAN); - case TSDBConstants.TSDB_DATA_TYPE_BOOL: { - Boolean val = (Boolean) tag.value; - tagDataList.put((byte) (val ? 1 : 0)); - lengthList.putLong(Byte.BYTES); - break; - } + ByteBuffer lengthList = ByteBuffer.allocate(num * Long.BYTES); + lengthList.order(ByteOrder.LITTLE_ENDIAN); - case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: { - Short val = (Short) tag.value; - tagDataList.putShort(val); - lengthList.putLong(Short.BYTES); + ByteBuffer isNullList = ByteBuffer.allocate(num * Integer.BYTES); + isNullList.order(ByteOrder.LITTLE_ENDIAN); - break; - } + for (int i = 0; i < num; ++i) { + TableTagInfo tag = this.tableTags.get(i); + if (tag.isNull) { + typeList.put((byte) tag.type); + isNullList.putInt(1); + lengthList.putLong(0); + continue; + } - case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: - case TSDBConstants.TSDB_DATA_TYPE_BIGINT: { - Long val = (Long) tag.value; - tagDataList.putLong(val == null ? 0 : val); - lengthList.putLong(Long.BYTES); + switch (tag.type) { + case TSDBConstants.TSDB_DATA_TYPE_INT: { + Integer val = (Integer) tag.value; + tagDataList.putInt(val); + lengthList.putLong(Integer.BYTES); + break; + } + case TSDBConstants.TSDB_DATA_TYPE_TINYINT: { + Byte val = (Byte) tag.value; + tagDataList.put(val); + lengthList.putLong(Byte.BYTES); + break; + } - break; - } + case TSDBConstants.TSDB_DATA_TYPE_BOOL: { + Boolean val = (Boolean) tag.value; + tagDataList.put((byte) (val ? 1 : 0)); + lengthList.putLong(Byte.BYTES); + break; + } - case TSDBConstants.TSDB_DATA_TYPE_FLOAT: { - Float val = (Float) tag.value; - tagDataList.putFloat(val == null ? 0 : val); - lengthList.putLong(Float.BYTES); + case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: { + Short val = (Short) tag.value; + tagDataList.putShort(val); + lengthList.putLong(Short.BYTES); - break; - } + break; + } - case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: { - Double val = (Double) tag.value; - tagDataList.putDouble(val == null ? 0 : val); - lengthList.putLong(Double.BYTES); + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: + case TSDBConstants.TSDB_DATA_TYPE_BIGINT: { + Long val = (Long) tag.value; + tagDataList.putLong(val == null ? 0 : val); + lengthList.putLong(Long.BYTES); - break; - } + break; + } - case TSDBConstants.TSDB_DATA_TYPE_NCHAR: - case TSDBConstants.TSDB_DATA_TYPE_BINARY: { - String charset = TaosGlobalConfig.getCharset(); - String val = (String) tag.value; + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: { + Float val = (Float) tag.value; + tagDataList.putFloat(val == null ? 0 : val); + lengthList.putLong(Float.BYTES); - byte[] b = null; - try { - if (tag.type == TSDBConstants.TSDB_DATA_TYPE_BINARY) { - b = val.getBytes(); - } else { - b = val.getBytes(charset); - } - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } + break; + } - tagDataList.put(b); - lengthList.putLong(b.length); - break; - } + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: { + Double val = (Double) tag.value; + tagDataList.putDouble(val == null ? 0 : val); + lengthList.putLong(Double.BYTES); - case TSDBConstants.TSDB_DATA_TYPE_UTINYINT: - case TSDBConstants.TSDB_DATA_TYPE_USMALLINT: - case TSDBConstants.TSDB_DATA_TYPE_UINT: - case TSDBConstants.TSDB_DATA_TYPE_UBIGINT: { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "not support data types"); - } - } - - typeList.put((byte) tag.type); - isNullList.putInt(tag.isNull? 1 : 0); - } + break; + } - connector.setBindTableNameAndTags(this.nativeStmtHandle, this.tableName, this.tableTags.size(), tagDataList, - typeList, lengthList, isNullList); - } - - ColumnInfo colInfo = (ColumnInfo) this.colData.get(0); - if (colInfo == null) { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "column data not bind"); - } - - int rows = colInfo.data.size(); - for (int i = 0; i < numOfCols; ++i) { - ColumnInfo col1 = this.colData.get(i); - if (col1 == null || !col1.isTypeSet()) { + case TSDBConstants.TSDB_DATA_TYPE_NCHAR: + case TSDBConstants.TSDB_DATA_TYPE_BINARY: { + String charset = TaosGlobalConfig.getCharset(); + String val = (String) tag.value; + + byte[] b = null; + try { + if (tag.type == TSDBConstants.TSDB_DATA_TYPE_BINARY) { + b = val.getBytes(); + } else { + b = val.getBytes(charset); + } + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + tagDataList.put(b); + lengthList.putLong(b.length); + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_UTINYINT: + case TSDBConstants.TSDB_DATA_TYPE_USMALLINT: + case TSDBConstants.TSDB_DATA_TYPE_UINT: + case TSDBConstants.TSDB_DATA_TYPE_UBIGINT: { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "not support data types"); + } + } + + typeList.put((byte) tag.type); + isNullList.putInt(tag.isNull ? 1 : 0); + } + + connector.setBindTableNameAndTags(this.nativeStmtHandle, this.tableName, this.tableTags.size(), tagDataList, + typeList, lengthList, isNullList); + } + + ColumnInfo colInfo = (ColumnInfo) this.colData.get(0); + if (colInfo == null) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "column data not bind"); + } + + int rows = colInfo.data.size(); + for (int i = 0; i < numOfCols; ++i) { + ColumnInfo col1 = this.colData.get(i); + if (col1 == null || !col1.isTypeSet()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "column data not bind"); - } - - if (rows != col1.data.size()) { + } + + if (rows != col1.data.size()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "the rows in column data not identical"); - } - - ByteBuffer colDataList = ByteBuffer.allocate(rows * col1.bytes); - colDataList.order(ByteOrder.LITTLE_ENDIAN); - + } + + ByteBuffer colDataList = ByteBuffer.allocate(rows * col1.bytes); + colDataList.order(ByteOrder.LITTLE_ENDIAN); + ByteBuffer lengthList = ByteBuffer.allocate(rows * Integer.BYTES); lengthList.order(ByteOrder.LITTLE_ENDIAN); - + ByteBuffer isNullList = ByteBuffer.allocate(rows * Byte.BYTES); isNullList.order(ByteOrder.LITTLE_ENDIAN); - - switch (col1.type) { - case TSDBConstants.TSDB_DATA_TYPE_INT: { - for (int j = 0; j < rows; ++j) { - Integer val = (Integer) col1.data.get(j); - colDataList.putInt(val == null? Integer.MIN_VALUE:val); - isNullList.put((byte) (val == null? 1:0)); - } - break; - } - - case TSDBConstants.TSDB_DATA_TYPE_TINYINT: { - for (int j = 0; j < rows; ++j) { - Byte val = (Byte) col1.data.get(j); - colDataList.put(val == null? 0:val); - isNullList.put((byte) (val == null? 1:0)); - } - break; - } - - case TSDBConstants.TSDB_DATA_TYPE_BOOL: { - for (int j = 0; j < rows; ++j) { - Boolean val = (Boolean) col1.data.get(j); - if (val == null) { - colDataList.put((byte) 0); - } else { - colDataList.put((byte) (val? 1:0)); - } - - isNullList.put((byte) (val == null? 1:0)); - } - break; - } - - case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: { - for (int j = 0; j < rows; ++j) { - Short val = (Short) col1.data.get(j); - colDataList.putShort(val == null? 0:val); - isNullList.put((byte) (val == null? 1:0)); - } - break; - } - - case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: - case TSDBConstants.TSDB_DATA_TYPE_BIGINT: { - for (int j = 0; j < rows; ++j) { - Long val = (Long) col1.data.get(j); - colDataList.putLong(val == null? 0:val); - isNullList.put((byte) (val == null? 1:0)); - } - break; - } - - case TSDBConstants.TSDB_DATA_TYPE_FLOAT: { - for (int j = 0; j < rows; ++j) { - Float val = (Float) col1.data.get(j); - colDataList.putFloat(val == null? 0:val); - isNullList.put((byte) (val == null? 1:0)); - } - break; - } - - case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: { - for (int j = 0; j < rows; ++j) { - Double val = (Double) col1.data.get(j); - colDataList.putDouble(val == null? 0:val); - isNullList.put((byte) (val == null? 1:0)); - } - break; - } - - case TSDBConstants.TSDB_DATA_TYPE_NCHAR: - case TSDBConstants.TSDB_DATA_TYPE_BINARY: { - String charset = TaosGlobalConfig.getCharset(); - for (int j = 0; j < rows; ++j) { - String val = (String) col1.data.get(j); - colDataList.position(j * col1.bytes); // seek to the correct position - if (val != null) { - byte[] b = null; - try { - if (col1.type == TSDBConstants.TSDB_DATA_TYPE_BINARY) { - b = val.getBytes(); - } else { - b = val.getBytes(charset); - } - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - - if (val.length() > col1.bytes) { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "string data too long"); - } - - colDataList.put(b); - lengthList.putInt(b.length); - isNullList.put((byte) 0); - } else { - lengthList.putInt(0); - isNullList.put((byte) 1); - } - } - break; - } - - case TSDBConstants.TSDB_DATA_TYPE_UTINYINT: - case TSDBConstants.TSDB_DATA_TYPE_USMALLINT: - case TSDBConstants.TSDB_DATA_TYPE_UINT: - case TSDBConstants.TSDB_DATA_TYPE_UBIGINT: { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "not support data types"); - } - }; - - connector.bindColumnDataArray(this.nativeStmtHandle, colDataList, lengthList, isNullList, col1.type, col1.bytes, rows, i); - } + switch (col1.type) { + case TSDBConstants.TSDB_DATA_TYPE_INT: { + for (int j = 0; j < rows; ++j) { + Integer val = (Integer) col1.data.get(j); + colDataList.putInt(val == null ? Integer.MIN_VALUE : val); + isNullList.put((byte) (val == null ? 1 : 0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_TINYINT: { + for (int j = 0; j < rows; ++j) { + Byte val = (Byte) col1.data.get(j); + colDataList.put(val == null ? 0 : val); + isNullList.put((byte) (val == null ? 1 : 0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_BOOL: { + for (int j = 0; j < rows; ++j) { + Boolean val = (Boolean) col1.data.get(j); + if (val == null) { + colDataList.put((byte) 0); + } else { + colDataList.put((byte) (val ? 1 : 0)); + } + + isNullList.put((byte) (val == null ? 1 : 0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: { + for (int j = 0; j < rows; ++j) { + Short val = (Short) col1.data.get(j); + colDataList.putShort(val == null ? 0 : val); + isNullList.put((byte) (val == null ? 1 : 0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: + case TSDBConstants.TSDB_DATA_TYPE_BIGINT: { + for (int j = 0; j < rows; ++j) { + Long val = (Long) col1.data.get(j); + colDataList.putLong(val == null ? 0 : val); + isNullList.put((byte) (val == null ? 1 : 0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: { + for (int j = 0; j < rows; ++j) { + Float val = (Float) col1.data.get(j); + colDataList.putFloat(val == null ? 0 : val); + isNullList.put((byte) (val == null ? 1 : 0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: { + for (int j = 0; j < rows; ++j) { + Double val = (Double) col1.data.get(j); + colDataList.putDouble(val == null ? 0 : val); + isNullList.put((byte) (val == null ? 1 : 0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_NCHAR: + case TSDBConstants.TSDB_DATA_TYPE_BINARY: { + String charset = TaosGlobalConfig.getCharset(); + for (int j = 0; j < rows; ++j) { + String val = (String) col1.data.get(j); + + colDataList.position(j * col1.bytes); // seek to the correct position + if (val != null) { + byte[] b = null; + try { + if (col1.type == TSDBConstants.TSDB_DATA_TYPE_BINARY) { + b = val.getBytes(); + } else { + b = val.getBytes(charset); + } + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + if (val.length() > col1.bytes) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "string data too long"); + } + + colDataList.put(b); + lengthList.putInt(b.length); + isNullList.put((byte) 0); + } else { + lengthList.putInt(0); + isNullList.put((byte) 1); + } + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_UTINYINT: + case TSDBConstants.TSDB_DATA_TYPE_USMALLINT: + case TSDBConstants.TSDB_DATA_TYPE_UINT: + case TSDBConstants.TSDB_DATA_TYPE_UBIGINT: { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "not support data types"); + } + } + ; + + connector.bindColumnDataArray(this.nativeStmtHandle, colDataList, lengthList, isNullList, col1.type, col1.bytes, rows, i); + } } - - public void columnDataExecuteBatch() throws SQLException { - TSDBJNIConnector connector = ((TSDBConnection) this.getConnection()).getConnector(); - connector.executeBatch(this.nativeStmtHandle); - this.columnDataClearBatch(); - } - + + public void columnDataExecuteBatch() throws SQLException { + TSDBJNIConnector connector = ((TSDBConnection) this.getConnection()).getConnector(); + connector.executeBatch(this.nativeStmtHandle); + this.columnDataClearBatch(); + } + public void columnDataClearBatch() { - int size = this.colData.size(); - this.colData.clear(); - + int size = this.colData.size(); + this.colData.clear(); + this.colData.addAll(Collections.nCopies(size, null)); this.tableName = null; // clear the table name } - + public void columnDataCloseBatch() throws SQLException { - TSDBJNIConnector connector = ((TSDBConnection) this.getConnection()).getConnector(); - connector.closeBatch(this.nativeStmtHandle); - - this.nativeStmtHandle = 0L; - this.tableName = null; + TSDBJNIConnector connector = ((TSDBConnection) this.getConnection()).getConnector(); + connector.closeBatch(this.nativeStmtHandle); + + this.nativeStmtHandle = 0L; + this.tableName = null; } } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java index aba29d602b..59a64ad520 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java @@ -133,9 +133,10 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet { if (this.getBatchFetch()) return this.blockData.getString(columnIndex - 1); - this.lastWasNull = this.rowData.wasNull(columnIndex - 1); + this.lastWasNull = this.rowData.wasNull(columnIndex); if (!lastWasNull) { - res = this.rowData.getString(columnIndex - 1, this.columnMetaDataList.get(columnIndex - 1).getColType()); + int nativeType = this.columnMetaDataList.get(columnIndex - 1).getColType(); + res = this.rowData.getString(columnIndex, nativeType); } return res; } @@ -147,9 +148,10 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet { if (this.getBatchFetch()) return this.blockData.getBoolean(columnIndex - 1); - this.lastWasNull = this.rowData.wasNull(columnIndex - 1); + this.lastWasNull = this.rowData.wasNull(columnIndex); if (!lastWasNull) { - res = this.rowData.getBoolean(columnIndex - 1, this.columnMetaDataList.get(columnIndex - 1).getColType()); + int nativeType = this.columnMetaDataList.get(columnIndex - 1).getColType(); + res = this.rowData.getBoolean(columnIndex, nativeType); } return res; } @@ -161,9 +163,10 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet { if (this.getBatchFetch()) return (byte) this.blockData.getInt(columnIndex - 1); - this.lastWasNull = this.rowData.wasNull(columnIndex - 1); + this.lastWasNull = this.rowData.wasNull(columnIndex); if (!lastWasNull) { - res = (byte) this.rowData.getInt(columnIndex - 1, this.columnMetaDataList.get(columnIndex - 1).getColType()); + int nativeType = this.columnMetaDataList.get(columnIndex - 1).getColType(); + res = (byte) this.rowData.getInt(columnIndex, nativeType); } return res; } @@ -175,9 +178,10 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet { if (this.getBatchFetch()) return (short) this.blockData.getInt(columnIndex - 1); - this.lastWasNull = this.rowData.wasNull(columnIndex - 1); + this.lastWasNull = this.rowData.wasNull(columnIndex); if (!lastWasNull) { - res = (short) this.rowData.getInt(columnIndex - 1, this.columnMetaDataList.get(columnIndex - 1).getColType()); + int nativeType = this.columnMetaDataList.get(columnIndex - 1).getColType(); + res = (short) this.rowData.getInt(columnIndex, nativeType); } return res; } @@ -189,9 +193,11 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet { if (this.getBatchFetch()) return this.blockData.getInt(columnIndex - 1); - this.lastWasNull = this.rowData.wasNull(columnIndex - 1); + + this.lastWasNull = this.rowData.wasNull(columnIndex); if (!lastWasNull) { - res = this.rowData.getInt(columnIndex - 1, this.columnMetaDataList.get(columnIndex - 1).getColType()); + int nativeType = this.columnMetaDataList.get(columnIndex - 1).getColType(); + res = this.rowData.getInt(columnIndex, nativeType); } return res; } @@ -203,13 +209,15 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet { if (this.getBatchFetch()) return this.blockData.getLong(columnIndex - 1); - this.lastWasNull = this.rowData.wasNull(columnIndex - 1); + this.lastWasNull = this.rowData.wasNull(columnIndex); if (!lastWasNull) { - Object value = this.rowData.get(columnIndex - 1); - if (value instanceof Timestamp) + Object value = this.rowData.getObject(columnIndex); + if (value instanceof Timestamp) { res = ((Timestamp) value).getTime(); - else - res = this.rowData.getLong(columnIndex - 1, this.columnMetaDataList.get(columnIndex - 1).getColType()); + } else { + int nativeType = this.columnMetaDataList.get(columnIndex - 1).getColType(); + res = this.rowData.getLong(columnIndex, nativeType); + } } return res; } @@ -221,9 +229,11 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet { if (this.getBatchFetch()) return (float) this.blockData.getDouble(columnIndex - 1); - this.lastWasNull = this.rowData.wasNull(columnIndex - 1); - if (!lastWasNull) - res = this.rowData.getFloat(columnIndex - 1, this.columnMetaDataList.get(columnIndex - 1).getColType()); + this.lastWasNull = this.rowData.wasNull(columnIndex); + if (!lastWasNull) { + int nativeType = this.columnMetaDataList.get(columnIndex - 1).getColType(); + res = this.rowData.getFloat(columnIndex, nativeType); + } return res; } @@ -235,9 +245,10 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet { if (this.getBatchFetch()) return this.blockData.getDouble(columnIndex - 1); - this.lastWasNull = this.rowData.wasNull(columnIndex - 1); + this.lastWasNull = this.rowData.wasNull(columnIndex); if (!lastWasNull) { - res = this.rowData.getDouble(columnIndex - 1, this.columnMetaDataList.get(columnIndex - 1).getColType()); + int nativeType = this.columnMetaDataList.get(columnIndex - 1).getColType(); + res = this.rowData.getDouble(columnIndex, nativeType); } return res; } @@ -245,34 +256,27 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet { public byte[] getBytes(int columnIndex) throws SQLException { checkAvailability(columnIndex, this.columnMetaDataList.size()); - Object value = this.rowData.get(columnIndex - 1); + Object value = this.rowData.getObject(columnIndex); if (value == null) return null; - int colType = this.columnMetaDataList.get(columnIndex - 1).getColType(); - switch (colType) { + int nativeType = this.columnMetaDataList.get(columnIndex - 1).getColType(); + switch (nativeType) { case TSDBConstants.TSDB_DATA_TYPE_BIGINT: - return Longs.toByteArray((Long) value); + return Longs.toByteArray((long) value); case TSDBConstants.TSDB_DATA_TYPE_INT: return Ints.toByteArray((int) value); case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: - return Shorts.toByteArray((Short) value); + return Shorts.toByteArray((short) value); case TSDBConstants.TSDB_DATA_TYPE_TINYINT: return new byte[]{(byte) value}; + case TSDBConstants.TSDB_DATA_TYPE_BINARY: + return (byte[]) value; + case TSDBConstants.TSDB_DATA_TYPE_BOOL: + case TSDBConstants.TSDB_DATA_TYPE_NCHAR: + default: + return value.toString().getBytes(); } - return value.toString().getBytes(); - } - - @Override - public Date getDate(int columnIndex) throws SQLException { - Timestamp timestamp = getTimestamp(columnIndex); - return timestamp == null ? null : new Date(timestamp.getTime()); - } - - @Override - public Time getTime(int columnIndex) throws SQLException { - Timestamp timestamp = getTimestamp(columnIndex); - return timestamp == null ? null : new Time(timestamp.getTime()); } public Timestamp getTimestamp(int columnIndex) throws SQLException { @@ -282,9 +286,10 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet { if (this.getBatchFetch()) return this.blockData.getTimestamp(columnIndex - 1); - this.lastWasNull = this.rowData.wasNull(columnIndex - 1); + this.lastWasNull = this.rowData.wasNull(columnIndex); if (!lastWasNull) { - res = this.rowData.getTimestamp(columnIndex - 1); + int nativeType = this.columnMetaDataList.get(columnIndex - 1).getColType(); + res = this.rowData.getTimestamp(columnIndex, nativeType); } return res; } @@ -304,13 +309,9 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet { if (this.getBatchFetch()) return this.blockData.get(columnIndex - 1); - this.lastWasNull = this.rowData.wasNull(columnIndex - 1); + this.lastWasNull = this.rowData.wasNull(columnIndex); if (!lastWasNull) { - int colType = this.columnMetaDataList.get(columnIndex - 1).getColType(); - if (colType == TSDBConstants.TSDB_DATA_TYPE_BINARY) - res = ((String) this.rowData.get(columnIndex - 1)).getBytes(); - else - res = this.rowData.get(columnIndex - 1); + res = this.rowData.getObject(columnIndex); } return res; } @@ -318,7 +319,7 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet { public int findColumn(String columnLabel) throws SQLException { for (ColumnMetaData colMetaData : this.columnMetaDataList) { if (colMetaData.getColName() != null && colMetaData.getColName().equalsIgnoreCase(columnLabel)) { - return colMetaData.getColIndex() + 1; + return colMetaData.getColIndex(); } } throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE); @@ -329,25 +330,25 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet { if (this.getBatchFetch()) return new BigDecimal(this.blockData.getLong(columnIndex - 1)); - this.lastWasNull = this.rowData.wasNull(columnIndex - 1); + this.lastWasNull = this.rowData.wasNull(columnIndex); BigDecimal res = null; if (!lastWasNull) { - int colType = this.columnMetaDataList.get(columnIndex - 1).getColType(); - switch (colType) { + int nativeType = this.columnMetaDataList.get(columnIndex - 1).getColType(); + switch (nativeType) { case TSDBConstants.TSDB_DATA_TYPE_TINYINT: case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: case TSDBConstants.TSDB_DATA_TYPE_INT: case TSDBConstants.TSDB_DATA_TYPE_BIGINT: - res = new BigDecimal(Long.valueOf(this.rowData.get(columnIndex - 1).toString())); + res = new BigDecimal(Long.valueOf(this.rowData.getObject(columnIndex).toString())); break; case TSDBConstants.TSDB_DATA_TYPE_FLOAT: case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: - res = new BigDecimal(Double.valueOf(this.rowData.get(columnIndex - 1).toString())); + res = new BigDecimal(Double.valueOf(this.rowData.getObject(columnIndex).toString())); break; case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: - return new BigDecimal(((Timestamp) this.rowData.get(columnIndex - 1)).getTime()); + return new BigDecimal(((Timestamp) this.rowData.getObject(columnIndex)).getTime()); default: - res = new BigDecimal(this.rowData.get(columnIndex - 1).toString()); + res = new BigDecimal(this.rowData.getObject(columnIndex).toString()); } } return res; diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetMetaData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetMetaData.java index e4ac5303d0..48d4247392 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetMetaData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetMetaData.java @@ -113,6 +113,7 @@ public class TSDBResultSetMetaData extends WrapperImpl implements ResultSetMetaD ColumnMetaData columnMetaData = this.colMetaDataList.get(column - 1); switch (columnMetaData.getColType()) { + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: return 5; case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java index 618e896a6d..01104440ab 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java @@ -14,6 +14,8 @@ *****************************************************************************/ package com.taosdata.jdbc; +import com.taosdata.jdbc.utils.NullType; + import java.math.BigDecimal; import java.sql.SQLException; import java.sql.Timestamp; @@ -22,11 +24,13 @@ import java.util.ArrayList; import java.util.Collections; public class TSDBResultSetRowData { + private ArrayList data; - private int colSize = 0; + private int colSize; public TSDBResultSetRowData(int colSize) { - this.setColSize(colSize); + this.colSize = colSize; + this.clear(); } public void clear() { @@ -41,68 +45,104 @@ public class TSDBResultSetRowData { } public boolean wasNull(int col) { - return data.get(col) == null; + return data.get(col - 1) == null; } + /** + * $$$ this method is invoked by databaseMetaDataResultSet and so on which use a index start from 1 in JDBC api + */ + public void setBooleanValue(int col, boolean value) { + setBoolean(col - 1, value); + } + + /** + * !!! this method is invoked by JNI method and the index start from 0 in C implementations + */ public void setBoolean(int col, boolean value) { data.set(col, value); } - public boolean getBoolean(int col, int srcType) throws SQLException { - Object obj = data.get(col); + public boolean getBoolean(int col, int nativeType) throws SQLException { + Object obj = data.get(col - 1); - switch (srcType) { + switch (nativeType) { case TSDBConstants.TSDB_DATA_TYPE_BOOL: return (Boolean) obj; - case TSDBConstants.TSDB_DATA_TYPE_FLOAT: - return ((Float) obj) == 1.0 ? Boolean.TRUE : Boolean.FALSE; - case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: - return ((Double) obj) == 1.0 ? Boolean.TRUE : Boolean.FALSE; case TSDBConstants.TSDB_DATA_TYPE_TINYINT: return ((Byte) obj) == 1 ? Boolean.TRUE : Boolean.FALSE; case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: return ((Short) obj) == 1 ? Boolean.TRUE : Boolean.FALSE; case TSDBConstants.TSDB_DATA_TYPE_INT: return ((Integer) obj) == 1 ? Boolean.TRUE : Boolean.FALSE; - case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: case TSDBConstants.TSDB_DATA_TYPE_BIGINT: return ((Long) obj) == 1L ? Boolean.TRUE : Boolean.FALSE; + case TSDBConstants.TSDB_DATA_TYPE_BINARY: + case TSDBConstants.TSDB_DATA_TYPE_NCHAR: { + return obj.toString().contains("1"); + } default: return false; } } + /** + * $$$ this method is invoked by databaseMetaDataResultSet and so on which use a index start from 1 in JDBC api + */ + public void setByteValue(int colIndex, byte value) { + setByte(colIndex - 1, value); + } + + /** + * !!! this method is invoked by JNI method and the index start from 0 in C implementations + */ public void setByte(int col, byte value) { data.set(col, value); } + /** + * $$$ this method is invoked by databaseMetaDataResultSet and so on which use a index start from 1 in JDBC api + */ + public void setShortValue(int colIndex, short value) { + setShort(colIndex - 1, value); + } + + /** + * !!! this method is invoked by JNI method and the index start from 0 in C implementations + */ public void setShort(int col, short value) { data.set(col, value); } + /** + * $$$ this method is invoked by databaseMetaDataResultSet and so on which use a index start from 1 in JDBC api + */ + public void setIntValue(int colIndex, int value) { + setInt(colIndex - 1, value); + } + + /** + * !!! this method is invoked by JNI method and the index start from 0 in C implementations + */ public void setInt(int col, int value) { data.set(col, value); } - @SuppressWarnings("deprecation") - public int getInt(int col, int srcType) throws SQLException { - Object obj = data.get(col); + public int getInt(int col, int nativeType) throws SQLException { + Object obj = data.get(col - 1); + if (obj == null) + return NullType.getIntNull(); - switch (srcType) { + switch (nativeType) { case TSDBConstants.TSDB_DATA_TYPE_BOOL: return Boolean.TRUE.equals(obj) ? 1 : 0; - case TSDBConstants.TSDB_DATA_TYPE_FLOAT: - return ((Float) obj).intValue(); - case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: - return ((Double) obj).intValue(); case TSDBConstants.TSDB_DATA_TYPE_TINYINT: return (Byte) obj; case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: return (Short) obj; case TSDBConstants.TSDB_DATA_TYPE_INT: return (Integer) obj; - case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: case TSDBConstants.TSDB_DATA_TYPE_BIGINT: + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: return ((Long) obj).intValue(); case TSDBConstants.TSDB_DATA_TYPE_NCHAR: case TSDBConstants.TSDB_DATA_TYPE_BINARY: @@ -131,33 +171,46 @@ public class TSDBResultSetRowData { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE); return Long.valueOf(value).intValue(); } + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: + return ((Float) obj).intValue(); + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: + return ((Double) obj).intValue(); + default: + return 0; } - - return 0; } + /** + * $$$ this method is invoked by databaseMetaDataResultSet and so on which use a index start from 1 in JDBC api + */ + public void setLongValue(int colIndex, long value) { + setLong(colIndex - 1, value); + } + + /** + * !!! this method is invoked by JNI method and the index start from 0 in C implementations + */ public void setLong(int col, long value) { data.set(col, value); } - public long getLong(int col, int srcType) throws SQLException { - Object obj = data.get(col); + public long getLong(int col, int nativeType) throws SQLException { + Object obj = data.get(col - 1); + if (obj == null) { + return NullType.getBigIntNull(); + } - switch (srcType) { + switch (nativeType) { case TSDBConstants.TSDB_DATA_TYPE_BOOL: return Boolean.TRUE.equals(obj) ? 1 : 0; - case TSDBConstants.TSDB_DATA_TYPE_FLOAT: - return ((Float) obj).longValue(); - case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: - return ((Double) obj).longValue(); case TSDBConstants.TSDB_DATA_TYPE_TINYINT: return (Byte) obj; case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: return (Short) obj; case TSDBConstants.TSDB_DATA_TYPE_INT: return (Integer) obj; - case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: case TSDBConstants.TSDB_DATA_TYPE_BIGINT: + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: return (Long) obj; case TSDBConstants.TSDB_DATA_TYPE_NCHAR: case TSDBConstants.TSDB_DATA_TYPE_BINARY: @@ -186,19 +239,35 @@ public class TSDBResultSetRowData { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE); return value; } + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: + return ((Float) obj).longValue(); + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: + return ((Double) obj).longValue(); + default: + return 0; } - - return 0; } + /** + * $$$ this method is invoked by databaseMetaDataResultSet and so on which use a index start from 1 in JDBC api + */ + public void setFloatValue(int colIndex, float value) { + setFloat(colIndex - 1, value); + } + + /** + * !!! this method is invoked by JNI method and the index start from 0 in C implementations + */ public void setFloat(int col, float value) { data.set(col, value); } - public float getFloat(int col, int srcType) { - Object obj = data.get(col); + public float getFloat(int col, int nativeType) { + Object obj = data.get(col - 1); + if (obj == null) + return NullType.getFloatNull(); - switch (srcType) { + switch (nativeType) { case TSDBConstants.TSDB_DATA_TYPE_BOOL: return Boolean.TRUE.equals(obj) ? 1 : 0; case TSDBConstants.TSDB_DATA_TYPE_FLOAT: @@ -214,19 +283,31 @@ public class TSDBResultSetRowData { case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: case TSDBConstants.TSDB_DATA_TYPE_BIGINT: return (Long) obj; + default: + return NullType.getFloatNull(); } - - return 0; } + /** + * $$$ this method is invoked by databaseMetaDataResultSet and so on which use a index start from 1 in JDBC api + */ + public void setDoubleValue(int colIndex, double value) { + setDouble(colIndex - 1, value); + } + + /** + * !!! this method is invoked by JNI method and the index start from 0 in C implementations + */ public void setDouble(int col, double value) { data.set(col, value); } - public double getDouble(int col, int srcType) { - Object obj = data.get(col); + public double getDouble(int col, int nativeType) { + Object obj = data.get(col - 1); + if (obj == null) + return NullType.getDoubleNull(); - switch (srcType) { + switch (nativeType) { case TSDBConstants.TSDB_DATA_TYPE_BOOL: return Boolean.TRUE.equals(obj) ? 1 : 0; case TSDBConstants.TSDB_DATA_TYPE_FLOAT: @@ -242,16 +323,46 @@ public class TSDBResultSetRowData { case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: case TSDBConstants.TSDB_DATA_TYPE_BIGINT: return (Long) obj; + default: + return NullType.getDoubleNull(); } - - return 0; } + /** + * $$$ this method is invoked by databaseMetaDataResultSet and so on which use a index start from 1 in JDBC api + */ + public void setStringValue(int colIndex, String value) { + data.set(colIndex - 1, value); + } + + /** + * !!! this method is invoked by JNI method and the index start from 0 in C implementations + */ public void setString(int col, String value) { - data.set(col, value); + // TODO: + // !!!NOTE!!! + // this is very confusing problem which related to JNI-method implementation, + // the JNI method return a String(encoded in UTF) for BINARY value, which means the JNI method will invoke + // this setString(int, String) to handle BINARY value, we need to build a byte[] with default charsetEncoding + data.set(col, value == null ? null : value.getBytes()); } + /** + * $$$ this method is invoked by databaseMetaDataResultSet and so on which use a index start from 1 in JDBC api + */ + public void setByteArrayValue(int colIndex, byte[] value) { + setByteArray(colIndex - 1, value); + } + + /** + * !!! this method is invoked by JNI method and the index start from 0 in C implementations + */ public void setByteArray(int col, byte[] value) { + // TODO: + // !!!NOTE!!! + // this is very confusing problem which related to JNI-method implementation, + // the JNI method return a byte[] for NCHAR value, which means the JNI method will invoke + // this setByteArr(int, byte[]) to handle NCHAR value, we need to build a String with charsetEncoding by TaosGlobalConfig try { data.set(col, new String(value, TaosGlobalConfig.getCharset())); } catch (Exception e) { @@ -259,47 +370,56 @@ public class TSDBResultSetRowData { } } - /** - * The original type may not be a string type, but will be converted to by calling this method - * - * @param col column index - * @return - */ - public String getString(int col, int srcType) { - switch (srcType) { - case TSDBConstants.TSDB_DATA_TYPE_BINARY: - case TSDBConstants.TSDB_DATA_TYPE_NCHAR: - return (String) data.get(col); + public String getString(int col, int nativeType) { + Object obj = data.get(col - 1); + if (obj == null) + return null; + + switch (nativeType) { case TSDBConstants.TSDB_DATA_TYPE_UTINYINT: { - Byte value = new Byte(String.valueOf(data.get(col))); + Byte value = new Byte(String.valueOf(obj)); if (value >= 0) return value.toString(); return Integer.toString(value & 0xff); } case TSDBConstants.TSDB_DATA_TYPE_USMALLINT: { - Short value = new Short(String.valueOf(data.get(col))); + Short value = new Short(String.valueOf(obj)); if (value >= 0) return value.toString(); return Integer.toString(value & 0xffff); } case TSDBConstants.TSDB_DATA_TYPE_UINT: { - Integer value = new Integer(String.valueOf(data.get(col))); + Integer value = new Integer(String.valueOf(obj)); if (value >= 0) return value.toString(); return Long.toString(value & 0xffffffffl); } case TSDBConstants.TSDB_DATA_TYPE_UBIGINT: { - Long value = new Long(String.valueOf(data.get(col))); + Long value = new Long(String.valueOf(obj)); if (value >= 0) return value.toString(); long lowValue = value & 0x7fffffffffffffffL; return BigDecimal.valueOf(lowValue).add(BigDecimal.valueOf(Long.MAX_VALUE)).add(BigDecimal.valueOf(1)).toString(); } + case TSDBConstants.TSDB_DATA_TYPE_BINARY: + return new String((byte[]) obj); + case TSDBConstants.TSDB_DATA_TYPE_NCHAR: + return (String) obj; default: - return String.valueOf(data.get(col)); + return String.valueOf(obj); } } + /** + * $$$ this method is invoked by databaseMetaDataResultSet and so on which use a index start from 1 in JDBC api + */ + public void setTimestampValue(int colIndex, long value) { + setTimestamp(colIndex - 1, value); + } + + /** + * !!! this method is invoked by JNI method and the index start from 0 in C implementations + */ public void setTimestamp(int col, long ts) { //TODO: this implementation contains logical error // when precision is us the (long ts) is 16 digital number @@ -316,28 +436,20 @@ public class TSDBResultSetRowData { } } - public Timestamp getTimestamp(int col) { - return (Timestamp) data.get(col); + public Timestamp getTimestamp(int col, int nativeType) { + Object obj = data.get(col - 1); + if (obj == null) + return null; + switch (nativeType) { + case TSDBConstants.TSDB_DATA_TYPE_BIGINT: + return new Timestamp((Long) obj); + default: + return (Timestamp) obj; + } } - public Object get(int col) { - return data.get(col); + public Object getObject(int col) { + return data.get(col - 1); } - public int getColSize() { - return colSize; - } - - private void setColSize(int colSize) { - this.colSize = colSize; - this.clear(); - } - - public ArrayList getData() { - return data; - } - - public void setData(ArrayList data) { - this.data = (ArrayList) data.clone(); - } } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java index d8ba67576d..e1ebc4ab3c 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java @@ -32,14 +32,15 @@ public class TSDBStatement extends AbstractStatement { } public ResultSet executeQuery(String sql) throws SQLException { - // check if closed if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); } - - //TODO: 如果在executeQuery方法中执行insert语句,那么先执行了SQL,再通过pSql来检查是否为一个insert语句,但这个insert SQL已经执行成功了 - - // execute query + //TODO: + // this is an unreasonable implementation, if the paratemer is a insert statement, + // the JNI connector will execute the sql at first and return a pointer: pSql, + // we use this pSql and invoke the isUpdateQuery(long pSql) method to decide . + // but the insert sql is already executed in database. + //execute query long pSql = this.connection.getConnector().executeQuery(sql); // if pSql is create/insert/update/delete/alter SQL if (this.connection.getConnector().isUpdateQuery(pSql)) { diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/Utils.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/Utils.java index eeb936a1d0..8ab610fec6 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/Utils.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/Utils.java @@ -95,16 +95,7 @@ public class Utils { public static String getNativeSql(String rawSql, Object[] parameters) { // toLowerCase String preparedSql = rawSql.trim().toLowerCase(); - - String[] clause = new String[0]; - if (SqlSyntaxValidator.isInsertSql(preparedSql)) { - // insert or import - clause = new String[]{"values\\s*\\(.*?\\)", "tags\\s*\\(.*?\\)"}; - } - if (SqlSyntaxValidator.isSelectSql(preparedSql)) { - // select - clause = new String[]{"where\\s*.*"}; - } + String[] clause = new String[]{"values\\s*\\(.*?\\)", "tags\\s*\\(.*?\\)", "where\\s*.*"}; Map placeholderPositions = new HashMap<>(); RangeSet clauseRangeSet = TreeRangeSet.create(); findPlaceholderPosition(preparedSql, placeholderPositions); diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBConnectionTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBConnectionTest.java index ca7251bb0e..dc6d0d322a 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBConnectionTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBConnectionTest.java @@ -32,20 +32,34 @@ public class TSDBConnectionTest { } @Test - public void subscribe() { + public void runSubscribe() { try { + // given TSDBConnection unwrap = conn.unwrap(TSDBConnection.class); TSDBSubscribe subscribe = unwrap.subscribe("topic1", "select * from log.log", false); + // when TSDBResultSet rs = subscribe.consume(); ResultSetMetaData metaData = rs.getMetaData(); - for (int count = 0; count < 10 && rs.next(); count++) { - for (int i = 1; i <= metaData.getColumnCount(); i++) { - String value = rs.getString(i); - System.out.print(metaData.getColumnLabel(i) + ":" + value + "\t"); - } - System.out.println(); - } + + // then Assert.assertNotNull(rs); + Assert.assertEquals(4, metaData.getColumnCount()); + Assert.assertEquals("ts", metaData.getColumnLabel(1)); + Assert.assertEquals("level", metaData.getColumnLabel(2)); + Assert.assertEquals("content", metaData.getColumnLabel(3)); + Assert.assertEquals("ipaddr", metaData.getColumnLabel(4)); + rs.next(); + // row 1 + { + Assert.assertNotNull(rs.getTimestamp(1)); + Assert.assertNotNull(rs.getTimestamp("ts")); + Assert.assertNotNull(rs.getByte(2)); + Assert.assertNotNull(rs.getByte("level")); + Assert.assertNotNull(rs.getString(3)); + Assert.assertNotNull(rs.getString("content")); + Assert.assertNotNull(rs.getString(4)); + Assert.assertNotNull(rs.getString("ipaddr")); + } subscribe.close(false); } catch (SQLException e) { e.printStackTrace(); diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java index a7657fa3e5..cb6133015c 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java @@ -7,9 +7,11 @@ import java.util.Properties; public class TSDBDatabaseMetaDataTest { private static final String host = "127.0.0.1"; + private static final String url = "jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata"; private static Connection connection; private static TSDBDatabaseMetaData metaData; + @Test public void unwrap() throws SQLException { TSDBDatabaseMetaData unwrap = metaData.unwrap(TSDBDatabaseMetaData.class); @@ -33,7 +35,7 @@ public class TSDBDatabaseMetaDataTest { @Test public void getURL() throws SQLException { - Assert.assertEquals("jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata", metaData.getURL()); + Assert.assertEquals(url, metaData.getURL()); } @Test @@ -627,17 +629,32 @@ public class TSDBDatabaseMetaDataTest { @Test public void getTables() throws SQLException { - System.out.println("****************************************************"); - ResultSet tables = metaData.getTables("log", "", null, null); - ResultSetMetaData metaData = tables.getMetaData(); - while (tables.next()) { - System.out.print(metaData.getColumnLabel(1) + ":" + tables.getString(1) + "\t"); - System.out.print(metaData.getColumnLabel(3) + ":" + tables.getString(3) + "\t"); - System.out.print(metaData.getColumnLabel(4) + ":" + tables.getString(4) + "\t"); - System.out.print(metaData.getColumnLabel(5) + ":" + tables.getString(5) + "\n"); + ResultSet rs = metaData.getTables("log", "", null, null); + ResultSetMetaData meta = rs.getMetaData(); + Assert.assertNotNull(rs); + rs.next(); + { + // TABLE_CAT + Assert.assertEquals("TABLE_CAT", meta.getColumnLabel(1)); + Assert.assertEquals("log", rs.getString(1)); + Assert.assertEquals("log", rs.getString("TABLE_CAT")); + // TABLE_SCHEM + Assert.assertEquals("TABLE_SCHEM", meta.getColumnLabel(2)); + Assert.assertEquals(null, rs.getString(2)); + Assert.assertEquals(null, rs.getString("TABLE_SCHEM")); + // TABLE_NAME + Assert.assertEquals("TABLE_NAME", meta.getColumnLabel(3)); + Assert.assertNotNull(rs.getString(3)); + Assert.assertNotNull(rs.getString("TABLE_NAME")); + // TABLE_TYPE + Assert.assertEquals("TABLE_TYPE", meta.getColumnLabel(4)); + Assert.assertEquals("TABLE", rs.getString(4)); + Assert.assertEquals("TABLE", rs.getString("TABLE_TYPE")); + // REMARKS + Assert.assertEquals("REMARKS", meta.getColumnLabel(5)); + Assert.assertEquals("", rs.getString(5)); + Assert.assertEquals("", rs.getString("REMARKS")); } - System.out.println(); - Assert.assertNotNull(tables); } @Test @@ -647,46 +664,130 @@ public class TSDBDatabaseMetaDataTest { @Test public void getCatalogs() throws SQLException { - System.out.println("****************************************************"); - - ResultSet catalogs = metaData.getCatalogs(); - ResultSetMetaData meta = catalogs.getMetaData(); - while (catalogs.next()) { - for (int i = 1; i <= meta.getColumnCount(); i++) { - System.out.print(meta.getColumnLabel(i) + ": " + catalogs.getString(i)); - } - System.out.println(); + ResultSet rs = metaData.getCatalogs(); + ResultSetMetaData meta = rs.getMetaData(); + rs.next(); + { + // TABLE_CAT + Assert.assertEquals("TABLE_CAT", meta.getColumnLabel(1)); + Assert.assertNotNull(rs.getString(1)); + Assert.assertNotNull(rs.getString("TABLE_CAT")); } } @Test public void getTableTypes() throws SQLException { - System.out.println("****************************************************"); - ResultSet tableTypes = metaData.getTableTypes(); - while (tableTypes.next()) { - System.out.println(tableTypes.getString("TABLE_TYPE")); + tableTypes.next(); + // tableTypes: table + { + Assert.assertEquals("TABLE", tableTypes.getString(1)); + Assert.assertEquals("TABLE", tableTypes.getString("TABLE_TYPE")); + } + tableTypes.next(); + // tableTypes: stable + { + Assert.assertEquals("STABLE", tableTypes.getString(1)); + Assert.assertEquals("STABLE", tableTypes.getString("TABLE_TYPE")); } - Assert.assertNotNull(metaData.getTableTypes()); } @Test public void getColumns() throws SQLException { - System.out.println("****************************************************"); - + // when ResultSet columns = metaData.getColumns("log", "", "dn", ""); + // then ResultSetMetaData meta = columns.getMetaData(); - while (columns.next()) { - System.out.print(meta.getColumnLabel(1) + ": " + columns.getString(1) + "\t"); - System.out.print(meta.getColumnLabel(3) + ": " + columns.getString(3) + "\t"); - System.out.print(meta.getColumnLabel(4) + ": " + columns.getString(4) + "\t"); - System.out.print(meta.getColumnLabel(5) + ": " + columns.getString(5) + "\t"); - System.out.print(meta.getColumnLabel(6) + ": " + columns.getString(6) + "\t"); - System.out.print(meta.getColumnLabel(7) + ": " + columns.getString(7) + "\t"); - System.out.print(meta.getColumnLabel(9) + ": " + columns.getString(9) + "\t"); - System.out.print(meta.getColumnLabel(10) + ": " + columns.getString(10) + "\t"); - System.out.print(meta.getColumnLabel(11) + ": " + columns.getString(11) + "\n"); - System.out.print(meta.getColumnLabel(12) + ": " + columns.getString(12) + "\n"); + columns.next(); + // column: 1 + { + // TABLE_CAT + Assert.assertEquals("TABLE_CAT", meta.getColumnLabel(1)); + Assert.assertEquals("log", columns.getString(1)); + Assert.assertEquals("log", columns.getString("TABLE_CAT")); + // TABLE_NAME + Assert.assertEquals("TABLE_NAME", meta.getColumnLabel(3)); + Assert.assertEquals("dn", columns.getString(3)); + Assert.assertEquals("dn", columns.getString("TABLE_NAME")); + // COLUMN_NAME + Assert.assertEquals("COLUMN_NAME", meta.getColumnLabel(4)); + Assert.assertEquals("ts", columns.getString(4)); + Assert.assertEquals("ts", columns.getString("COLUMN_NAME")); + // DATA_TYPE + Assert.assertEquals("DATA_TYPE", meta.getColumnLabel(5)); + Assert.assertEquals(Types.TIMESTAMP, columns.getInt(5)); + Assert.assertEquals(Types.TIMESTAMP, columns.getInt("DATA_TYPE")); + // TYPE_NAME + Assert.assertEquals("TYPE_NAME", meta.getColumnLabel(6)); + Assert.assertEquals("TIMESTAMP", columns.getString(6)); + Assert.assertEquals("TIMESTAMP", columns.getString("TYPE_NAME")); + // COLUMN_SIZE + Assert.assertEquals("COLUMN_SIZE", meta.getColumnLabel(7)); + Assert.assertEquals(26, columns.getInt(7)); + Assert.assertEquals(26, columns.getInt("COLUMN_SIZE")); + // DECIMAL_DIGITS + Assert.assertEquals("DECIMAL_DIGITS", meta.getColumnLabel(9)); + Assert.assertEquals(Integer.MIN_VALUE, columns.getInt(9)); + Assert.assertEquals(Integer.MIN_VALUE, columns.getInt("DECIMAL_DIGITS")); + Assert.assertEquals(null, columns.getString(9)); + Assert.assertEquals(null, columns.getString("DECIMAL_DIGITS")); + // NUM_PREC_RADIX + Assert.assertEquals("NUM_PREC_RADIX", meta.getColumnLabel(10)); + Assert.assertEquals(10, columns.getInt(10)); + Assert.assertEquals(10, columns.getInt("NUM_PREC_RADIX")); + // NULLABLE + Assert.assertEquals("NULLABLE", meta.getColumnLabel(11)); + Assert.assertEquals(DatabaseMetaData.columnNoNulls, columns.getInt(11)); + Assert.assertEquals(DatabaseMetaData.columnNoNulls, columns.getInt("NULLABLE")); + // REMARKS + Assert.assertEquals("REMARKS", meta.getColumnLabel(12)); + Assert.assertEquals(null, columns.getString(12)); + Assert.assertEquals(null, columns.getString("REMARKS")); + } + columns.next(); + // column: 2 + { + // TABLE_CAT + Assert.assertEquals("TABLE_CAT", meta.getColumnLabel(1)); + Assert.assertEquals("log", columns.getString(1)); + Assert.assertEquals("log", columns.getString("TABLE_CAT")); + // TABLE_NAME + Assert.assertEquals("TABLE_NAME", meta.getColumnLabel(3)); + Assert.assertEquals("dn", columns.getString(3)); + Assert.assertEquals("dn", columns.getString("TABLE_NAME")); + // COLUMN_NAME + Assert.assertEquals("COLUMN_NAME", meta.getColumnLabel(4)); + Assert.assertEquals("cpu_taosd", columns.getString(4)); + Assert.assertEquals("cpu_taosd", columns.getString("COLUMN_NAME")); + // DATA_TYPE + Assert.assertEquals("DATA_TYPE", meta.getColumnLabel(5)); + Assert.assertEquals(Types.FLOAT, columns.getInt(5)); + Assert.assertEquals(Types.FLOAT, columns.getInt("DATA_TYPE")); + // TYPE_NAME + Assert.assertEquals("TYPE_NAME", meta.getColumnLabel(6)); + Assert.assertEquals("FLOAT", columns.getString(6)); + Assert.assertEquals("FLOAT", columns.getString("TYPE_NAME")); + // COLUMN_SIZE + Assert.assertEquals("COLUMN_SIZE", meta.getColumnLabel(7)); + Assert.assertEquals(12, columns.getInt(7)); + Assert.assertEquals(12, columns.getInt("COLUMN_SIZE")); + // DECIMAL_DIGITS + Assert.assertEquals("DECIMAL_DIGITS", meta.getColumnLabel(9)); + Assert.assertEquals(Integer.MIN_VALUE, columns.getInt(9)); + Assert.assertEquals(Integer.MIN_VALUE, columns.getInt("DECIMAL_DIGITS")); + Assert.assertEquals(null, columns.getString(9)); + Assert.assertEquals(null, columns.getString("DECIMAL_DIGITS")); + // NUM_PREC_RADIX + Assert.assertEquals("NUM_PREC_RADIX", meta.getColumnLabel(10)); + Assert.assertEquals(10, columns.getInt(10)); + Assert.assertEquals(10, columns.getInt("NUM_PREC_RADIX")); + // NULLABLE + Assert.assertEquals("NULLABLE", meta.getColumnLabel(11)); + Assert.assertEquals(DatabaseMetaData.columnNullable, columns.getInt(11)); + Assert.assertEquals(DatabaseMetaData.columnNullable, columns.getInt("NULLABLE")); + // REMARKS + Assert.assertEquals("REMARKS", meta.getColumnLabel(12)); + Assert.assertEquals(null, columns.getString(12)); } } @@ -712,17 +813,35 @@ public class TSDBDatabaseMetaDataTest { @Test public void getPrimaryKeys() throws SQLException { - System.out.println("****************************************************"); - ResultSet rs = metaData.getPrimaryKeys("log", "", "dn1"); - while (rs.next()) { - System.out.println("TABLE_NAME: " + rs.getString("TABLE_NAME")); - System.out.println("COLUMN_NAME: " + rs.getString("COLUMN_NAME")); - System.out.println("KEY_SEQ: " + rs.getString("KEY_SEQ")); - System.out.println("PK_NAME: " + rs.getString("PK_NAME")); + ResultSetMetaData meta = rs.getMetaData(); + rs.next(); + { + // TABLE_CAT + Assert.assertEquals("TABLE_CAT", meta.getColumnLabel(1)); + Assert.assertEquals("log", rs.getString(1)); + Assert.assertEquals("log", rs.getString("TABLE_CAT")); + // TABLE_SCHEM + Assert.assertEquals("TABLE_SCHEM", meta.getColumnLabel(2)); + Assert.assertEquals(null, rs.getString(2)); + Assert.assertEquals(null, rs.getString("TABLE_SCHEM")); + // TABLE_NAME + Assert.assertEquals("TABLE_NAME", meta.getColumnLabel(3)); + Assert.assertEquals("dn1", rs.getString(3)); + Assert.assertEquals("dn1", rs.getString("TABLE_NAME")); + // COLUMN_NAME + Assert.assertEquals("COLUMN_NAME", meta.getColumnLabel(4)); + Assert.assertEquals("ts", rs.getString(4)); + Assert.assertEquals("ts", rs.getString("COLUMN_NAME")); + // KEY_SEQ + Assert.assertEquals("KEY_SEQ", meta.getColumnLabel(5)); + Assert.assertEquals(1, rs.getShort(5)); + Assert.assertEquals(1, rs.getShort("KEY_SEQ")); + // DATA_TYPE + Assert.assertEquals("PK_NAME", meta.getColumnLabel(6)); + Assert.assertEquals("ts", rs.getString(6)); + Assert.assertEquals("ts", rs.getString("PK_NAME")); } - - Assert.assertNotNull(rs); } @Test @@ -847,14 +966,27 @@ public class TSDBDatabaseMetaDataTest { @Test public void getSuperTables() throws SQLException { - System.out.println("****************************************************"); - ResultSet rs = metaData.getSuperTables("log", "", "dn1"); - while (rs.next()) { - System.out.println("TABLE_NAME: " + rs.getString("TABLE_NAME")); - System.out.println("SUPERTABLE_NAME: " + rs.getString("SUPERTABLE_NAME")); + ResultSetMetaData meta = rs.getMetaData(); + rs.next(); + { + // TABLE_CAT + Assert.assertEquals("TABLE_CAT", meta.getColumnLabel(1)); + Assert.assertEquals("log", rs.getString(1)); + Assert.assertEquals("log", rs.getString("TABLE_CAT")); + // TABLE_CAT + Assert.assertEquals("TABLE_SCHEM", meta.getColumnLabel(2)); + Assert.assertEquals(null, rs.getString(2)); + Assert.assertEquals(null, rs.getString("TABLE_SCHEM")); + // TABLE_CAT + Assert.assertEquals("TABLE_NAME", meta.getColumnLabel(3)); + Assert.assertEquals("dn1", rs.getString(3)); + Assert.assertEquals("dn1", rs.getString("TABLE_NAME")); + // TABLE_CAT + Assert.assertEquals("SUPERTABLE_NAME", meta.getColumnLabel(4)); + Assert.assertEquals("dn", rs.getString(4)); + Assert.assertEquals("dn", rs.getString("SUPERTABLE_NAME")); } - Assert.assertNotNull(rs); } @Test @@ -951,15 +1083,12 @@ public class TSDBDatabaseMetaDataTest { @BeforeClass public static void beforeClass() { try { - Class.forName("com.taosdata.jdbc.TSDBDriver"); Properties properties = new Properties(); properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); - connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata", properties); + connection = DriverManager.getConnection(url, properties); metaData = connection.getMetaData().unwrap(TSDBDatabaseMetaData.class); - } catch (ClassNotFoundException e) { - e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java index 161539962d..66078ef503 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java @@ -45,9 +45,9 @@ public class TSDBJNIConnectorTest { rowData = new TSDBResultSetRowData(columnSize); // iterate resultSet for (int i = 0; next(connector, pSql); i++) { - System.out.println("col[" + i + "] size: " + rowData.getColSize()); - rowData.getData().stream().forEach(col -> System.out.print(col + "\t")); - System.out.println(); +// System.out.println("col[" + i + "] size: " + rowData.getColSize()); +// rowData.getData().stream().forEach(col -> System.out.print(col + "\t")); +// System.out.println(); } // close resultSet code = connector.freeResultSet(pSql); diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBParameterMetaDataTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBParameterMetaDataTest.java index 12bcc43917..83caf1bebb 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBParameterMetaDataTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBParameterMetaDataTest.java @@ -54,16 +54,17 @@ public class TSDBParameterMetaDataTest { @Test public void getPrecision() throws SQLException { - Assert.assertEquals(0, parameterMetaData_insert.getPrecision(1)); - Assert.assertEquals(0, parameterMetaData_insert.getPrecision(2)); - Assert.assertEquals(0, parameterMetaData_insert.getPrecision(3)); - Assert.assertEquals(0, parameterMetaData_insert.getPrecision(4)); - Assert.assertEquals(0, parameterMetaData_insert.getPrecision(5)); - Assert.assertEquals(0, parameterMetaData_insert.getPrecision(6)); - Assert.assertEquals(0, parameterMetaData_insert.getPrecision(7)); - Assert.assertEquals(0, parameterMetaData_insert.getPrecision(8)); - Assert.assertEquals(5, parameterMetaData_insert.getPrecision(9)); - Assert.assertEquals(5, parameterMetaData_insert.getPrecision(10)); + //create table weather(ts timestamp, f1 int, f2 bigint, f3 float, f4 double, f5 smallint, f6 tinyint, f7 bool, f8 binary(64), f9 nchar(64)) + Assert.assertEquals(TSDBConstants.TIMESTAMP_MS_PRECISION, parameterMetaData_insert.getPrecision(1)); + Assert.assertEquals(TSDBConstants.INT_PRECISION, parameterMetaData_insert.getPrecision(2)); + Assert.assertEquals(TSDBConstants.BIGINT_PRECISION, parameterMetaData_insert.getPrecision(3)); + Assert.assertEquals(TSDBConstants.FLOAT_PRECISION, parameterMetaData_insert.getPrecision(4)); + Assert.assertEquals(TSDBConstants.DOUBLE_PRECISION, parameterMetaData_insert.getPrecision(5)); + Assert.assertEquals(TSDBConstants.SMALLINT_PRECISION, parameterMetaData_insert.getPrecision(6)); + Assert.assertEquals(TSDBConstants.TINYINT_PRECISION, parameterMetaData_insert.getPrecision(7)); + Assert.assertEquals(TSDBConstants.BOOLEAN_PRECISION, parameterMetaData_insert.getPrecision(8)); + Assert.assertEquals("hello".getBytes().length, parameterMetaData_insert.getPrecision(9)); + Assert.assertEquals("涛思数据".length(), parameterMetaData_insert.getPrecision(10)); } @Test @@ -71,8 +72,8 @@ public class TSDBParameterMetaDataTest { Assert.assertEquals(0, parameterMetaData_insert.getScale(1)); Assert.assertEquals(0, parameterMetaData_insert.getScale(2)); Assert.assertEquals(0, parameterMetaData_insert.getScale(3)); - Assert.assertEquals(0, parameterMetaData_insert.getScale(4)); - Assert.assertEquals(0, parameterMetaData_insert.getScale(5)); + Assert.assertEquals(31, parameterMetaData_insert.getScale(4)); + Assert.assertEquals(31, parameterMetaData_insert.getScale(5)); Assert.assertEquals(0, parameterMetaData_insert.getScale(6)); Assert.assertEquals(0, parameterMetaData_insert.getScale(7)); Assert.assertEquals(0, parameterMetaData_insert.getScale(8)); @@ -124,10 +125,16 @@ public class TSDBParameterMetaDataTest { @Test public void getParameterMode() throws SQLException { - for (int i = 1; i <= parameterMetaData_insert.getParameterCount(); i++) { - int parameterMode = parameterMetaData_insert.getParameterMode(i); - Assert.assertEquals(ParameterMetaData.parameterModeUnknown, parameterMode); - } + Assert.assertEquals(ParameterMetaData.parameterModeUnknown, parameterMetaData_insert.getParameterMode(1)); + Assert.assertEquals(ParameterMetaData.parameterModeUnknown, parameterMetaData_insert.getParameterMode(2)); + Assert.assertEquals(ParameterMetaData.parameterModeUnknown, parameterMetaData_insert.getParameterMode(3)); + Assert.assertEquals(ParameterMetaData.parameterModeUnknown, parameterMetaData_insert.getParameterMode(4)); + Assert.assertEquals(ParameterMetaData.parameterModeUnknown, parameterMetaData_insert.getParameterMode(5)); + Assert.assertEquals(ParameterMetaData.parameterModeUnknown, parameterMetaData_insert.getParameterMode(6)); + Assert.assertEquals(ParameterMetaData.parameterModeUnknown, parameterMetaData_insert.getParameterMode(7)); + Assert.assertEquals(ParameterMetaData.parameterModeUnknown, parameterMetaData_insert.getParameterMode(8)); + Assert.assertEquals(ParameterMetaData.parameterModeUnknown, parameterMetaData_insert.getParameterMode(9)); + Assert.assertEquals(ParameterMetaData.parameterModeUnknown, parameterMetaData_insert.getParameterMode(10)); } @Test @@ -144,7 +151,6 @@ public class TSDBParameterMetaDataTest { @BeforeClass public static void beforeClass() { try { - Class.forName("com.taosdata.jdbc.TSDBDriver"); conn = DriverManager.getConnection("jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata"); try (Statement stmt = conn.createStatement()) { stmt.execute("drop database if exists test_pstmt"); @@ -164,7 +170,7 @@ public class TSDBParameterMetaDataTest { pstmt_insert.setObject(7, Byte.MAX_VALUE); pstmt_insert.setObject(8, true); pstmt_insert.setObject(9, "hello".getBytes()); - pstmt_insert.setObject(10, "Hello"); + pstmt_insert.setObject(10, "涛思数据"); parameterMetaData_insert = pstmt_insert.getParameterMetaData(); pstmt_select = conn.prepareStatement(sql_select); @@ -173,7 +179,7 @@ public class TSDBParameterMetaDataTest { pstmt_select.setInt(3, 0); parameterMetaData_select = pstmt_select.getParameterMetaData(); - } catch (ClassNotFoundException | SQLException e) { + } catch (SQLException e) { e.printStackTrace(); } } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java index 277ca447f5..3ad51479d6 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java @@ -1,523 +1,652 @@ package com.taosdata.jdbc; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.*; import java.io.IOException; -import java.io.Serializable; +import java.math.BigDecimal; import java.sql.*; -import java.util.ArrayList; -import java.util.Random; +import java.time.LocalTime; public class TSDBPreparedStatementTest { + private static final String host = "127.0.0.1"; private static Connection conn; private static final String sql_insert = "insert into t1 values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; - private static PreparedStatement pstmt_insert; - private static final String sql_select = "select * from t1 where ts > ? and ts <= ? and f1 >= ?"; - private static PreparedStatement pstmt_select; + private static final String sql_select = "select * from t1 where ts >= ? and ts < ? and f1 >= ?"; + + private PreparedStatement pstmt_insert; + private PreparedStatement pstmt_select; + //create table weather(ts timestamp, f1 int, f2 bigint, f3 float, f4 double, f5 smallint, f6 tinyint, f7 bool, f8 binary(64), f9 nchar(64)) tags(loc nchar(64)) @Test public void executeQuery() throws SQLException { - long end = System.currentTimeMillis(); - long start = end - 1000 * 60 * 60; + // given + long ts = System.currentTimeMillis(); + pstmt_insert.setTimestamp(1, new Timestamp(ts)); + pstmt_insert.setInt(2, 2); + pstmt_insert.setLong(3, 3l); + pstmt_insert.setFloat(4, 3.14f); + pstmt_insert.setDouble(5, 3.1415); + pstmt_insert.setShort(6, (short) 6); + pstmt_insert.setByte(7, (byte) 7); + pstmt_insert.setBoolean(8, true); + pstmt_insert.setBytes(9, "abc".getBytes()); + pstmt_insert.setString(10, "涛思数据"); + pstmt_insert.executeUpdate(); + long start = ts - 1000 * 60 * 60; + long end = ts + 1000 * 60 * 60; pstmt_select.setTimestamp(1, new Timestamp(start)); pstmt_select.setTimestamp(2, new Timestamp(end)); pstmt_select.setInt(3, 0); + // when ResultSet rs = pstmt_select.executeQuery(); - Assert.assertNotNull(rs); ResultSetMetaData meta = rs.getMetaData(); - while (rs.next()) { - for (int i = 1; i <= meta.getColumnCount(); i++) { - System.out.print(meta.getColumnLabel(i) + ": " + rs.getString(i) + "\t"); - } - System.out.println(); + rs.next(); + + // then + assertMetaData(meta); + { + Assert.assertNotNull(rs); + Assert.assertEquals(ts, rs.getTimestamp(1).getTime()); + Assert.assertEquals(2, rs.getInt(2)); + Assert.assertEquals(2, rs.getInt("f1")); + Assert.assertEquals(3l, rs.getLong(3)); + Assert.assertEquals(3l, rs.getLong("f2")); + Assert.assertEquals(3.14f, rs.getFloat(4), 0.0); + Assert.assertEquals(3.14f, rs.getFloat("f3"), 0.0); + Assert.assertEquals(3.1415, rs.getDouble(5), 0.0); + Assert.assertEquals(3.1415, rs.getDouble("f4"), 0.0); + Assert.assertEquals((short) 6, rs.getShort(6)); + Assert.assertEquals((short) 6, rs.getShort("f5")); + Assert.assertEquals((byte) 7, rs.getByte(7)); + Assert.assertEquals((byte) 7, rs.getByte("f6")); + Assert.assertTrue(rs.getBoolean(8)); + Assert.assertTrue(rs.getBoolean("f7")); + Assert.assertArrayEquals("abc".getBytes(), rs.getBytes(9)); + Assert.assertArrayEquals("abc".getBytes(), rs.getBytes("f8")); + Assert.assertEquals("涛思数据", rs.getString(10)); + Assert.assertEquals("涛思数据", rs.getString("f9")); } } - @Test - public void executeUpdate() throws SQLException { - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); - pstmt_insert.setFloat(4, 3.14f); - int result = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, result); + private void assertMetaData(ResultSetMetaData meta) throws SQLException { + Assert.assertEquals(10, meta.getColumnCount()); + Assert.assertEquals("ts", meta.getColumnLabel(1)); + Assert.assertEquals("f1", meta.getColumnLabel(2)); + Assert.assertEquals("f2", meta.getColumnLabel(3)); + Assert.assertEquals("f3", meta.getColumnLabel(4)); + Assert.assertEquals("f4", meta.getColumnLabel(5)); + Assert.assertEquals("f5", meta.getColumnLabel(6)); + Assert.assertEquals("f6", meta.getColumnLabel(7)); + Assert.assertEquals("f7", meta.getColumnLabel(8)); + Assert.assertEquals("f8", meta.getColumnLabel(9)); + Assert.assertEquals("f9", meta.getColumnLabel(10)); } @Test - public void setNull() throws SQLException { - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); + public void setNullForTimestamp() throws SQLException { + // given + long ts = System.currentTimeMillis(); + + // when + pstmt_insert.setTimestamp(1, new Timestamp(ts)); pstmt_insert.setNull(2, Types.INTEGER); int result = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, result); - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); + // then + Assert.assertEquals(1, result); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from t1"); + ResultSetMetaData meta = rs.getMetaData(); + assertMetaData(meta); + rs.next(); + assertAllNullExceptTimestamp(rs, ts); + } + } + + private void assertAllNullExceptTimestamp(ResultSet rs, long ts) throws SQLException { + Assert.assertNotNull(rs); + Assert.assertEquals(ts, rs.getTimestamp(1).getTime()); + Assert.assertEquals(0, rs.getInt(2)); + Assert.assertEquals(0, rs.getInt("f1")); + Assert.assertEquals(0, rs.getLong(3)); + Assert.assertEquals(0, rs.getLong("f2")); + Assert.assertEquals(0, rs.getFloat(4), 0.0); + Assert.assertEquals(0, rs.getFloat("f3"), 0.0); + Assert.assertEquals(0, rs.getDouble(5), 0.0); + Assert.assertEquals(0, rs.getDouble("f4"), 0.0); + Assert.assertEquals(0, rs.getShort(6)); + Assert.assertEquals(0, rs.getShort("f5")); + Assert.assertEquals(0, rs.getByte(7)); + Assert.assertEquals(0, rs.getByte("f6")); + Assert.assertFalse(rs.getBoolean(8)); + Assert.assertFalse(rs.getBoolean("f7")); + Assert.assertNull(rs.getBytes(9)); + Assert.assertNull(rs.getBytes("f8")); + Assert.assertNull(rs.getString(10)); + Assert.assertNull(rs.getString("f9")); + } + + @Test + public void setNullForInteger() throws SQLException { + // given + long ts = System.currentTimeMillis(); + + // when + pstmt_insert.setTimestamp(1, new Timestamp(ts)); pstmt_insert.setNull(3, Types.BIGINT); - result = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, result); + int result = pstmt_insert.executeUpdate(); - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); + // then + Assert.assertEquals(1, result); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from t1"); + ResultSetMetaData meta = rs.getMetaData(); + assertMetaData(meta); + rs.next(); + assertAllNullExceptTimestamp(rs, ts); + } + } + + @Test + public void setNullForFloat() throws SQLException { + // given + long ts = System.currentTimeMillis(); + + // when + pstmt_insert.setTimestamp(1, new Timestamp(ts)); pstmt_insert.setNull(4, Types.FLOAT); - result = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, result); + int result = pstmt_insert.executeUpdate(); - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); + // then + Assert.assertEquals(1, result); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from t1"); + ResultSetMetaData meta = rs.getMetaData(); + assertMetaData(meta); + rs.next(); + assertAllNullExceptTimestamp(rs, ts); + } + } + + @Test + public void setNullForDouble() throws SQLException { + // given + long ts = System.currentTimeMillis(); + + // when + pstmt_insert.setTimestamp(1, new Timestamp(ts)); pstmt_insert.setNull(5, Types.DOUBLE); - result = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, result); + int result = pstmt_insert.executeUpdate(); - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); + // then + Assert.assertEquals(1, result); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from t1"); + ResultSetMetaData meta = rs.getMetaData(); + assertMetaData(meta); + rs.next(); + assertAllNullExceptTimestamp(rs, ts); + } + } + + @Test + public void setNullForSmallInt() throws SQLException { + // given + long ts = System.currentTimeMillis(); + + // when + pstmt_insert.setTimestamp(1, new Timestamp(ts)); pstmt_insert.setNull(6, Types.SMALLINT); - result = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, result); + int result = pstmt_insert.executeUpdate(); - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); + // then + Assert.assertEquals(1, result); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from t1"); + ResultSetMetaData meta = rs.getMetaData(); + assertMetaData(meta); + rs.next(); + assertAllNullExceptTimestamp(rs, ts); + } + } + + @Test + public void setNullForTinyInt() throws SQLException { + // given + long ts = System.currentTimeMillis(); + + // when + pstmt_insert.setTimestamp(1, new Timestamp(ts)); pstmt_insert.setNull(7, Types.TINYINT); - result = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, result); + int result = pstmt_insert.executeUpdate(); - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); + // then + Assert.assertEquals(1, result); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from t1"); + ResultSetMetaData meta = rs.getMetaData(); + assertMetaData(meta); + rs.next(); + assertAllNullExceptTimestamp(rs, ts); + } + } + + @Test + public void setNullForBoolean() throws SQLException { + // given + long ts = System.currentTimeMillis(); + + // when + pstmt_insert.setTimestamp(1, new Timestamp(ts)); pstmt_insert.setNull(8, Types.BOOLEAN); - result = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, result); + int result = pstmt_insert.executeUpdate(); - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); + // then + Assert.assertEquals(1, result); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from t1"); + ResultSetMetaData meta = rs.getMetaData(); + assertMetaData(meta); + rs.next(); + assertAllNullExceptTimestamp(rs, ts); + } + } + + @Test + public void setNullForBinary() throws SQLException { + // given + long ts = System.currentTimeMillis(); + + // when + pstmt_insert.setTimestamp(1, new Timestamp(ts)); pstmt_insert.setNull(9, Types.BINARY); - result = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, result); + int result = pstmt_insert.executeUpdate(); - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); + // then + Assert.assertEquals(1, result); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from t1"); + ResultSetMetaData meta = rs.getMetaData(); + assertMetaData(meta); + rs.next(); + assertAllNullExceptTimestamp(rs, ts); + } + } + + @Test + public void setNullForNchar() throws SQLException { + // given + long ts = System.currentTimeMillis(); + + // when + pstmt_insert.setTimestamp(1, new Timestamp(ts)); pstmt_insert.setNull(10, Types.NCHAR); - result = pstmt_insert.executeUpdate(); + int result = pstmt_insert.executeUpdate(); + + // then Assert.assertEquals(1, result); - - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); - pstmt_insert.setNull(10, Types.OTHER); - result = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, result); - } - - @Test - public void executeTest() throws SQLException { - Statement stmt = conn.createStatement(); - - int numOfRows = 1000; - - for (int loop = 0; loop < 10; loop++){ - stmt.execute("drop table if exists weather_test"); - stmt.execute("create table weather_test(ts timestamp, f1 nchar(4), f2 float, f3 double, f4 timestamp, f5 int, f6 bool, f7 binary(10))"); - - TSDBPreparedStatement s = (TSDBPreparedStatement) conn.prepareStatement("insert into ? values(?, ?, ?, ?, ?, ?, ?, ?)"); - Random r = new Random(); - s.setTableName("weather_test"); - - ArrayList ts = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - ts.add(System.currentTimeMillis() + i); - } - s.setTimestamp(0, ts); - - int random = 10 + r.nextInt(5); - ArrayList s2 = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - if(i % random == 0) { - s2.add(null); - }else{ - s2.add("分支" + i % 4); - } - } - s.setNString(1, s2, 4); - - random = 10 + r.nextInt(5); - ArrayList s3 = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - if(i % random == 0) { - s3.add(null); - }else{ - s3.add(r.nextFloat()); - } - } - s.setFloat(2, s3); - - random = 10 + r.nextInt(5); - ArrayList s4 = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - if(i % random == 0) { - s4.add(null); - }else{ - s4.add(r.nextDouble()); - } - } - s.setDouble(3, s4); - - random = 10 + r.nextInt(5); - ArrayList ts2 = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - if(i % random == 0) { - ts2.add(null); - }else{ - ts2.add(System.currentTimeMillis() + i); - } - } - s.setTimestamp(4, ts2); - - random = 10 + r.nextInt(5); - ArrayList vals = new ArrayList<>(); - for(int i = 0; i < numOfRows; i++) { - if(i % random == 0) { - vals.add(null); - }else{ - vals.add(r.nextInt()); - } - } - s.setInt(5, vals); - - random = 10 + r.nextInt(5); - ArrayList sb = new ArrayList<>(); - for(int i = 0; i < numOfRows; i++) { - if(i % random == 0) { - sb.add(null); - }else{ - sb.add(i % 2 == 0 ? true : false); - } - } - s.setBoolean(6, sb); - - random = 10 + r.nextInt(5); - ArrayList s5 = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - if(i % random == 0) { - s5.add(null); - }else{ - s5.add("test" + i % 10); - } - } - s.setString(7, s5, 10); - - s.columnDataAddBatch(); - s.columnDataExecuteBatch(); - s.columnDataCloseBatch(); - - String sql = "select * from weather_test"; - PreparedStatement statement = conn.prepareStatement(sql); - ResultSet rs = statement.executeQuery(); - int rows = 0; - while(rs.next()) { - rows++; - } - Assert.assertEquals(numOfRows, rows); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from t1"); + ResultSetMetaData meta = rs.getMetaData(); + assertMetaData(meta); + rs.next(); + assertAllNullExceptTimestamp(rs, ts); } } - + @Test - public void bindDataSelectColumnTest() throws SQLException { - Statement stmt = conn.createStatement(); - - int numOfRows = 1000; - - for (int loop = 0; loop < 10; loop++){ - stmt.execute("drop table if exists weather_test"); - stmt.execute("create table weather_test(ts timestamp, f1 nchar(4), f2 float, f3 double, f4 timestamp, f5 int, f6 bool, f7 binary(10))"); - - TSDBPreparedStatement s = (TSDBPreparedStatement) conn.prepareStatement("insert into ? (ts, f1, f7) values(?, ?, ?)"); - Random r = new Random(); - s.setTableName("weather_test"); - - ArrayList ts = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - ts.add(System.currentTimeMillis() + i); - } - s.setTimestamp(0, ts); - - int random = 10 + r.nextInt(5); - ArrayList s2 = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - if(i % random == 0) { - s2.add(null); - }else{ - s2.add("分支" + i % 4); - } - } - s.setNString(1, s2, 4); - - random = 10 + r.nextInt(5); - ArrayList s3 = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - if(i % random == 0) { - s3.add(null); - }else{ - s3.add("test" + i % 10); - } - } - s.setString(2, s3, 10); - - s.columnDataAddBatch(); - s.columnDataExecuteBatch(); - s.columnDataCloseBatch(); - - String sql = "select * from weather_test"; - PreparedStatement statement = conn.prepareStatement(sql); - ResultSet rs = statement.executeQuery(); - int rows = 0; - while(rs.next()) { - rows++; - } - Assert.assertEquals(numOfRows, rows); - } - } - - @Test - public void bindDataWithSingleTagTest() throws SQLException { + public void createTwoSameDbTest() throws SQLException { Statement stmt = conn.createStatement(); - - String types[] = new String[] {"tinyint", "smallint", "int", "bigint", "bool", "float", "double", "binary(10)", "nchar(10)"}; - - for (String type : types) { - stmt.execute("drop table if exists weather_test"); - stmt.execute("create table weather_test(ts timestamp, f1 nchar(10), f2 binary(10)) tags (t " + type + ")"); - - int numOfRows = 1; - - TSDBPreparedStatement s = (TSDBPreparedStatement) conn.prepareStatement("insert into ? using weather_test tags(?) values(?, ?, ?)"); - Random r = new Random(); - s.setTableName("w1"); - - switch(type) { - case "tinyint": - case "smallint": - case "int": - case "bigint": - s.setTagInt(0, 1); - break; - case "float": - s.setTagFloat(0, 1.23f); - break; - case "double": - s.setTagDouble(0, 3.14159265); - break; - case "bool": - s.setTagBoolean(0, true); - break; - case "binary(10)": - s.setTagString(0, "test"); - break; - case "nchar(10)": - s.setTagNString(0, "test"); - break; - default: - break; - } - - - ArrayList ts = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - ts.add(System.currentTimeMillis() + i); - } - s.setTimestamp(0, ts); - - int random = 10 + r.nextInt(5); - ArrayList s2 = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - s2.add("分支" + i % 4); - } - s.setNString(1, s2, 10); - - random = 10 + r.nextInt(5); - ArrayList s3 = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - s3.add("test" + i % 4); - } - s.setString(2, s3, 10); - - s.columnDataAddBatch(); - s.columnDataExecuteBatch(); - s.columnDataCloseBatch(); - - String sql = "select * from weather_test"; - PreparedStatement statement = conn.prepareStatement(sql); - ResultSet rs = statement.executeQuery(); - int rows = 0; - while(rs.next()) { - rows++; - } - Assert.assertEquals(numOfRows, rows); - } - } - - - @Test - public void bindDataWithMultipleTagsTest() throws SQLException { - Statement stmt = conn.createStatement(); - - stmt.execute("drop table if exists weather_test"); - stmt.execute("create table weather_test(ts timestamp, f1 nchar(10), f2 binary(10)) tags (t1 int, t2 binary(10))"); - - int numOfRows = 1; - - TSDBPreparedStatement s = (TSDBPreparedStatement) conn.prepareStatement("insert into ? using weather_test tags(?,?) (ts, f2) values(?, ?)"); - s.setTableName("w2"); - s.setTagInt(0, 1); - s.setTagString(1, "test"); - - - ArrayList ts = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - ts.add(System.currentTimeMillis() + i); - } - s.setTimestamp(0, ts); - - ArrayList s2 = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - s2.add("test" + i % 4); - } - s.setString(1, s2, 10); - - s.columnDataAddBatch(); - s.columnDataExecuteBatch(); - s.columnDataCloseBatch(); - - String sql = "select * from weather_test"; - PreparedStatement statement = conn.prepareStatement(sql); - ResultSet rs = statement.executeQuery(); - int rows = 0; - while(rs.next()) { - rows++; - } - Assert.assertEquals(numOfRows, rows); - + + stmt.execute("create database dbtest"); + Assert.assertThrows(SQLException.class, () -> stmt.execute("create database dbtest")); } @Test public void setBoolean() throws SQLException { - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); + // given + long ts = System.currentTimeMillis(); + + // when + pstmt_insert.setTimestamp(1, new Timestamp(ts)); pstmt_insert.setBoolean(8, true); - int ret = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, ret); + int result = pstmt_insert.executeUpdate(); + + // then + Assert.assertEquals(1, result); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from t1"); + ResultSetMetaData meta = rs.getMetaData(); + assertMetaData(meta); + rs.next(); + { + Assert.assertNotNull(rs); + Assert.assertEquals(ts, rs.getTimestamp(1).getTime()); + Assert.assertEquals(ts, rs.getTimestamp("ts").getTime()); + Assert.assertTrue(rs.getBoolean(8)); + Assert.assertTrue(rs.getBoolean("f7")); + } + } } @Test public void setByte() throws SQLException { - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); + // given + long ts = System.currentTimeMillis(); + + // when + pstmt_insert.setTimestamp(1, new Timestamp(ts)); pstmt_insert.setByte(7, (byte) 0x001); - int ret = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, ret); + int result = pstmt_insert.executeUpdate(); + + // then + Assert.assertEquals(1, result); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from t1"); + ResultSetMetaData meta = rs.getMetaData(); + assertMetaData(meta); + rs.next(); + { + Assert.assertNotNull(rs); + Assert.assertEquals(ts, rs.getTimestamp(1).getTime()); + Assert.assertEquals(ts, rs.getTimestamp("ts").getTime()); + Assert.assertEquals((byte) 0x001, rs.getByte(7)); + Assert.assertEquals((byte) 0x001, rs.getByte("f6")); + } + } } @Test public void setShort() throws SQLException { - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); + // given + long ts = System.currentTimeMillis(); + + // when + pstmt_insert.setTimestamp(1, new Timestamp(ts)); pstmt_insert.setShort(6, (short) 2); - int ret = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, ret); + int result = pstmt_insert.executeUpdate(); + + // then + Assert.assertEquals(1, result); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from t1"); + ResultSetMetaData meta = rs.getMetaData(); + assertMetaData(meta); + rs.next(); + { + Assert.assertNotNull(rs); + Assert.assertEquals(ts, rs.getTimestamp(1).getTime()); + Assert.assertEquals(ts, rs.getTimestamp("ts").getTime()); + Assert.assertEquals((short) 2, rs.getByte(6)); + Assert.assertEquals((short) 2, rs.getByte("f5")); + } + } } @Test public void setInt() throws SQLException { - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); + // given + long ts = System.currentTimeMillis(); + + // when + pstmt_insert.setTimestamp(1, new Timestamp(ts)); pstmt_insert.setInt(2, 10086); - int ret = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, ret); + int result = pstmt_insert.executeUpdate(); + + // then + Assert.assertEquals(1, result); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from t1"); + ResultSetMetaData meta = rs.getMetaData(); + assertMetaData(meta); + rs.next(); + { + Assert.assertNotNull(rs); + Assert.assertEquals(ts, rs.getTimestamp(1).getTime()); + Assert.assertEquals(ts, rs.getTimestamp("ts").getTime()); + Assert.assertEquals(10086, rs.getInt(2)); + Assert.assertEquals(10086, rs.getInt("f1")); + } + } } @Test public void setLong() throws SQLException { - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); + // given + long ts = System.currentTimeMillis(); + + // when + pstmt_insert.setTimestamp(1, new Timestamp(ts)); pstmt_insert.setLong(3, Long.MAX_VALUE); - int ret = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, ret); + int result = pstmt_insert.executeUpdate(); + + // then + Assert.assertEquals(1, result); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from t1"); + ResultSetMetaData meta = rs.getMetaData(); + assertMetaData(meta); + rs.next(); + { + Assert.assertNotNull(rs); + Assert.assertEquals(ts, rs.getTimestamp(1).getTime()); + Assert.assertEquals(ts, rs.getTimestamp("ts").getTime()); + Assert.assertEquals(Long.MAX_VALUE, rs.getLong(3)); + Assert.assertEquals(Long.MAX_VALUE, rs.getLong("f2")); + } + } } @Test public void setFloat() throws SQLException { - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); + // given + long ts = System.currentTimeMillis(); + + // when + pstmt_insert.setTimestamp(1, new Timestamp(ts)); pstmt_insert.setFloat(4, 3.14f); - int ret = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, ret); + int result = pstmt_insert.executeUpdate(); + + // then + Assert.assertEquals(1, result); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from t1"); + ResultSetMetaData meta = rs.getMetaData(); + assertMetaData(meta); + rs.next(); + { + Assert.assertNotNull(rs); + Assert.assertEquals(ts, rs.getTimestamp(1).getTime()); + Assert.assertEquals(ts, rs.getTimestamp("ts").getTime()); + Assert.assertEquals(3.14f, rs.getFloat(4), 0.0f); + Assert.assertEquals(3.14f, rs.getFloat("f3"), 0.0f); + } + } } @Test public void setDouble() throws SQLException { - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); + // given + long ts = System.currentTimeMillis(); + + // when + pstmt_insert.setTimestamp(1, new Timestamp(ts)); pstmt_insert.setDouble(5, 3.14444); - int ret = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, ret); + int result = pstmt_insert.executeUpdate(); + + // then + Assert.assertEquals(1, result); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from t1"); + ResultSetMetaData meta = rs.getMetaData(); + assertMetaData(meta); + rs.next(); + { + Assert.assertNotNull(rs); + Assert.assertEquals(ts, rs.getTimestamp(1).getTime()); + Assert.assertEquals(ts, rs.getTimestamp("ts").getTime()); + Assert.assertEquals(3.14444, rs.getDouble(5), 0.0); + Assert.assertEquals(3.14444, rs.getDouble("f4"), 0.0); + } + } } - @Test(expected = SQLFeatureNotSupportedException.class) + @Test public void setBigDecimal() throws SQLException { - pstmt_insert.setBigDecimal(1, null); + // given + long ts = System.currentTimeMillis(); + BigDecimal bigDecimal = new BigDecimal(3.14444); + + // when + pstmt_insert.setTimestamp(1, new Timestamp(ts)); + pstmt_insert.setBigDecimal(5, bigDecimal); + int result = pstmt_insert.executeUpdate(); + + // then + Assert.assertEquals(1, result); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from t1"); + ResultSetMetaData meta = rs.getMetaData(); + assertMetaData(meta); + rs.next(); + { + Assert.assertNotNull(rs); + Assert.assertEquals(ts, rs.getTimestamp(1).getTime()); + Assert.assertEquals(ts, rs.getTimestamp("ts").getTime()); + Assert.assertEquals(3.14444, rs.getDouble(5), 0.0); + Assert.assertEquals(3.14444, rs.getDouble("f4"), 0.0); + } + } } @Test public void setString() throws SQLException { - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); - pstmt_insert.setString(10, "aaaa"); - boolean execute = pstmt_insert.execute(); - Assert.assertFalse(execute); + // given + long ts = System.currentTimeMillis(); + String f9 = "{\"name\": \"john\", \"age\": 10, \"address\": \"192.168.1.100\"}"; - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); - pstmt_insert.setString(10, new Person("john", 33, true).toString()); - Assert.assertFalse(pstmt_insert.execute()); + // when + pstmt_insert.setTimestamp(1, new Timestamp(ts)); + pstmt_insert.setString(10, f9); + int result = pstmt_insert.executeUpdate(); - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); - pstmt_insert.setString(10, new Person("john", 33, true).toString().replaceAll("'", "\"")); - Assert.assertFalse(pstmt_insert.execute()); - } - - class Person { - String name; - int age; - boolean sex; - - public Person(String name, int age, boolean sex) { - this.name = name; - this.age = age; - this.sex = sex; - } - - @Override - public String toString() { - return "Person{" + - "name='" + name + '\'' + - ", age=" + age + - ", sex=" + sex + - '}'; + // then + Assert.assertEquals(1, result); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from t1"); + ResultSetMetaData meta = rs.getMetaData(); + assertMetaData(meta); + rs.next(); + { + Assert.assertNotNull(rs); + Assert.assertEquals(ts, rs.getTimestamp(1).getTime()); + Assert.assertEquals(ts, rs.getTimestamp("ts").getTime()); + Assert.assertEquals(f9, rs.getString(10)); + Assert.assertEquals(f9, rs.getString("f9")); + } } } @Test public void setBytes() throws SQLException, IOException { + // given + long ts = System.currentTimeMillis(); + byte[] f8 = "{\"name\": \"john\", \"age\": 10, \"address\": \"192.168.1.100\"}".getBytes(); + + // when pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); + pstmt_insert.setBytes(9, f8); + int result = pstmt_insert.executeUpdate(); -// ByteArrayOutputStream baos = new ByteArrayOutputStream(); -// ObjectOutputStream oos = new ObjectOutputStream(baos); -// oos.writeObject(new Person("john", 33, true)); -// oos.flush(); -// byte[] bytes = baos.toByteArray(); -// pstmt_insert.setBytes(9, bytes); - - pstmt_insert.setBytes(9, new Person("john", 33, true).toString().getBytes()); - int ret = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, ret); + // then + Assert.assertEquals(1, result); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from t1"); + ResultSetMetaData meta = rs.getMetaData(); + assertMetaData(meta); + rs.next(); + { + Assert.assertNotNull(rs); + Assert.assertEquals(ts, rs.getTimestamp(1).getTime()); + Assert.assertEquals(ts, rs.getTimestamp("ts").getTime()); + Assert.assertArrayEquals(f8, rs.getBytes(9)); + Assert.assertArrayEquals(f8, rs.getBytes("f8")); + } + } } - @Test(expected = SQLFeatureNotSupportedException.class) + @Test public void setDate() throws SQLException { - pstmt_insert.setDate(1, new Date(System.currentTimeMillis())); + // given + long ts = new java.util.Date().getTime(); + + // when + pstmt_insert.setDate(1, new Date(ts)); + int result = pstmt_insert.executeUpdate(); + + // then + Assert.assertEquals(1, result); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from t1"); + ResultSetMetaData meta = rs.getMetaData(); + assertMetaData(meta); + rs.next(); + { + Assert.assertNotNull(rs); + Assert.assertEquals(ts, rs.getTimestamp(1).getTime()); + Assert.assertEquals(ts, rs.getTimestamp("ts").getTime()); + } + } } - @Test(expected = SQLFeatureNotSupportedException.class) + @Test public void setTime() throws SQLException { - pstmt_insert.setTime(1, new Time(System.currentTimeMillis())); + // given + long ts = System.currentTimeMillis(); + + // when + pstmt_insert.setTime(1, new Time(ts)); + int result = pstmt_insert.executeUpdate(); + + // then + Assert.assertEquals(1, result); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from t1"); + ResultSetMetaData meta = rs.getMetaData(); + assertMetaData(meta); + rs.next(); + { + Assert.assertNotNull(rs); + Assert.assertEquals(ts, rs.getTimestamp(1).getTime()); + Assert.assertEquals(ts, rs.getTimestamp("ts").getTime()); + } + } } @Test public void setTimestamp() throws SQLException { - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); - int ret = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, ret); + // given + long ts = System.currentTimeMillis(); + + // when + pstmt_insert.setTimestamp(1, new Timestamp(ts)); + int result = pstmt_insert.executeUpdate(); + + // then + Assert.assertEquals(1, result); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from t1"); + ResultSetMetaData meta = rs.getMetaData(); + assertMetaData(meta); + rs.next(); + { + Assert.assertNotNull(rs); + Assert.assertEquals(ts, rs.getTimestamp(1).getTime()); + Assert.assertEquals(ts, rs.getTimestamp("ts").getTime()); + } + } } @Test(expected = SQLFeatureNotSupportedException.class) @@ -530,72 +659,6 @@ public class TSDBPreparedStatementTest { pstmt_insert.setBinaryStream(1, null); } - @Test - public void clearParameters() throws SQLException { - pstmt_insert.clearParameters(); - } - - @Test - public void setObject() throws SQLException { - pstmt_insert.setObject(1, new Timestamp(System.currentTimeMillis())); - int ret = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, ret); - - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); - pstmt_insert.setObject(2, 111); - ret = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, ret); - - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); - pstmt_insert.setObject(3, Long.MAX_VALUE); - ret = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, ret); - - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); - pstmt_insert.setObject(4, 3.14159265354f); - ret = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, ret); - - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); - pstmt_insert.setObject(5, Double.MAX_VALUE); - ret = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, ret); - - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); - pstmt_insert.setObject(6, Short.MAX_VALUE); - ret = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, ret); - - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); - pstmt_insert.setObject(7, Byte.MAX_VALUE); - ret = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, ret); - - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); - pstmt_insert.setObject(8, true); - ret = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, ret); - - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); - pstmt_insert.setObject(9, "hello".getBytes()); - ret = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, ret); - - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); - pstmt_insert.setObject(10, "Hello"); - ret = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, ret); - } - - @Test - public void execute() throws SQLException { - pstmt_insert.setTimestamp(1, new Timestamp(System.currentTimeMillis())); - int ret = pstmt_insert.executeUpdate(); - Assert.assertEquals(1, ret); - - executeQuery(); - } - @Test(expected = SQLFeatureNotSupportedException.class) public void setCharacterStream() throws SQLException { pstmt_insert.setCharacterStream(1, null); @@ -621,9 +684,17 @@ public class TSDBPreparedStatementTest { pstmt_insert.setArray(1, null); } - @Test(expected = SQLFeatureNotSupportedException.class) + @Test public void getMetaData() throws SQLException { - pstmt_insert.getMetaData(); + // given + long ts = System.currentTimeMillis(); + + // when + pstmt_insert.setTimestamp(1, new Timestamp(ts)); + ResultSetMetaData metaData = pstmt_insert.getMetaData(); + + // then + Assert.assertNull(metaData); } @Test(expected = SQLFeatureNotSupportedException.class) @@ -633,9 +704,46 @@ public class TSDBPreparedStatementTest { @Test public void getParameterMetaData() throws SQLException { + // given + long ts = System.currentTimeMillis(); + pstmt_insert.setTimestamp(1, new Timestamp(ts)); + pstmt_insert.setInt(2, 2); + pstmt_insert.setLong(3, 3l); + pstmt_insert.setFloat(4, 3.14f); + pstmt_insert.setDouble(5, 3.1415); + pstmt_insert.setShort(6, (short) 6); + pstmt_insert.setByte(7, (byte) 7); + pstmt_insert.setBoolean(8, true); + pstmt_insert.setBytes(9, "abc".getBytes()); + pstmt_insert.setString(10, "涛思数据"); + + // when ParameterMetaData parameterMetaData = pstmt_insert.getParameterMetaData(); + + // then Assert.assertNotNull(parameterMetaData); - //TODO: modify the test case + Assert.assertEquals(10, parameterMetaData.getParameterCount()); + Assert.assertEquals(Types.TIMESTAMP, parameterMetaData.getParameterType(1)); + Assert.assertEquals(Types.INTEGER, parameterMetaData.getParameterType(2)); + Assert.assertEquals(Types.BIGINT, parameterMetaData.getParameterType(3)); + Assert.assertEquals(Types.FLOAT, parameterMetaData.getParameterType(4)); + Assert.assertEquals(Types.DOUBLE, parameterMetaData.getParameterType(5)); + Assert.assertEquals(Types.SMALLINT, parameterMetaData.getParameterType(6)); + Assert.assertEquals(Types.TINYINT, parameterMetaData.getParameterType(7)); + Assert.assertEquals(Types.BOOLEAN, parameterMetaData.getParameterType(8)); + Assert.assertEquals(Types.BINARY, parameterMetaData.getParameterType(9)); + Assert.assertEquals(Types.NCHAR, parameterMetaData.getParameterType(10)); + + Assert.assertEquals("TIMESTAMP", parameterMetaData.getParameterTypeName(1)); + Assert.assertEquals("INT", parameterMetaData.getParameterTypeName(2)); + Assert.assertEquals("BIGINT", parameterMetaData.getParameterTypeName(3)); + Assert.assertEquals("FLOAT", parameterMetaData.getParameterTypeName(4)); + Assert.assertEquals("DOUBLE", parameterMetaData.getParameterTypeName(5)); + Assert.assertEquals("SMALLINT", parameterMetaData.getParameterTypeName(6)); + Assert.assertEquals("TINYINT", parameterMetaData.getParameterTypeName(7)); + Assert.assertEquals("BOOL", parameterMetaData.getParameterTypeName(8)); + Assert.assertEquals("BINARY", parameterMetaData.getParameterTypeName(9)); + Assert.assertEquals("NCHAR", parameterMetaData.getParameterTypeName(10)); } @Test(expected = SQLFeatureNotSupportedException.class) @@ -643,9 +751,9 @@ public class TSDBPreparedStatementTest { pstmt_insert.setRowId(1, null); } - @Test(expected = SQLFeatureNotSupportedException.class) + @Test public void setNString() throws SQLException { - pstmt_insert.setNString(1, null); + setString(); } @Test(expected = SQLFeatureNotSupportedException.class) @@ -663,22 +771,45 @@ public class TSDBPreparedStatementTest { pstmt_insert.setSQLXML(1, null); } + @Before + public void before() { + try { + Statement stmt = conn.createStatement(); + stmt.execute("drop table if exists weather"); + stmt.execute("create table if not exists weather(ts timestamp, f1 int, f2 bigint, f3 float, f4 double, f5 smallint, f6 tinyint, f7 bool, f8 binary(64), f9 nchar(64)) tags(loc nchar(64))"); + stmt.execute("create table if not exists t1 using weather tags('beijing')"); + stmt.close(); + + pstmt_insert = conn.prepareStatement(sql_insert); + pstmt_select = conn.prepareStatement(sql_select); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @After + public void after() { + try { + if (pstmt_insert != null) + pstmt_insert.close(); + if (pstmt_select != null) + pstmt_select.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + + } @BeforeClass public static void beforeClass() { try { - Class.forName("com.taosdata.jdbc.TSDBDriver"); conn = DriverManager.getConnection("jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata"); try (Statement stmt = conn.createStatement()) { stmt.execute("drop database if exists test_pstmt_jni"); stmt.execute("create database if not exists test_pstmt_jni"); stmt.execute("use test_pstmt_jni"); - stmt.execute("create table weather(ts timestamp, f1 int, f2 bigint, f3 float, f4 double, f5 smallint, f6 tinyint, f7 bool, f8 binary(64), f9 nchar(64)) tags(loc nchar(64))"); - stmt.execute("create table t1 using weather tags('beijing')"); } - pstmt_insert = conn.prepareStatement(sql_insert); - pstmt_select = conn.prepareStatement(sql_select); - } catch (ClassNotFoundException | SQLException e) { + } catch (SQLException e) { e.printStackTrace(); } } @@ -686,10 +817,6 @@ public class TSDBPreparedStatementTest { @AfterClass public static void afterClass() { try { - if (pstmt_insert != null) - pstmt_insert.close(); - if (pstmt_select != null) - pstmt_select.close(); if (conn != null) conn.close(); } catch (SQLException e) { diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java index f304fd6874..31ee35899c 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java @@ -14,6 +14,7 @@ import java.math.BigDecimal; import java.sql.*; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.Arrays; public class TSDBResultSetTest { @@ -133,7 +134,7 @@ public class TSDBResultSetTest { Assert.assertEquals(3.1415926, Double.valueOf(new String(f5)), 0.000000f); byte[] f6 = rs.getBytes("f6"); - Assert.assertEquals("abc", new String(f6)); + Assert.assertTrue(Arrays.equals("abc".getBytes(), f6)); byte[] f7 = rs.getBytes("f7"); Assert.assertEquals((short) 10, Shorts.fromByteArray(f7)); @@ -176,8 +177,7 @@ public class TSDBResultSetTest { rs.getAsciiStream("f1"); } - @SuppressWarnings("deprecation") - @Test(expected = SQLFeatureNotSupportedException.class) + @Test(expected = SQLFeatureNotSupportedException.class) public void getUnicodeStream() throws SQLException { rs.getUnicodeStream("f1"); } @@ -646,7 +646,6 @@ public class TSDBResultSetTest { @BeforeClass public static void beforeClass() { try { - Class.forName("com.taosdata.jdbc.TSDBDriver"); conn = DriverManager.getConnection("jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata"); stmt = conn.createStatement(); stmt.execute("create database if not exists restful_test"); @@ -656,10 +655,9 @@ public class TSDBResultSetTest { stmt.execute("insert into restful_test.weather values('2021-01-01 00:00:00.000', 1, 100, 3.1415, 3.1415926, 'abc', 10, 10, true, '涛思数据')"); rs = stmt.executeQuery("select * from restful_test.weather"); rs.next(); - } catch (ClassNotFoundException | SQLException e) { + } catch (SQLException e) { e.printStackTrace(); } - } @AfterClass diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBStatementTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBStatementTest.java index 671551c426..51535bc886 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBStatementTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBStatementTest.java @@ -387,15 +387,12 @@ public class TSDBStatementTest { @BeforeClass public static void beforeClass() { try { - Class.forName("com.taosdata.jdbc.TSDBDriver"); Properties properties = new Properties(); properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); conn = DriverManager.getConnection("jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata", properties); stmt = conn.createStatement(); - } catch (ClassNotFoundException e) { - e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulDatabaseMetaDataTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulDatabaseMetaDataTest.java index a052fbbdcb..85007db0e5 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulDatabaseMetaDataTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulDatabaseMetaDataTest.java @@ -10,6 +10,7 @@ import java.sql.*; import java.util.Properties; public class RestfulDatabaseMetaDataTest { + private static final String host = "127.0.0.1"; private static final String url = "jdbc:TAOS-RS://" + host + ":6041/?user=root&password=taosdata"; private static Connection connection; @@ -632,17 +633,32 @@ public class RestfulDatabaseMetaDataTest { @Test public void getTables() throws SQLException { - System.out.println("****************************************************"); - ResultSet tables = metaData.getTables("log", "", null, null); - ResultSetMetaData metaData = tables.getMetaData(); - while (tables.next()) { - System.out.print(metaData.getColumnLabel(1) + ":" + tables.getString(1) + "\t"); - System.out.print(metaData.getColumnLabel(3) + ":" + tables.getString(3) + "\t"); - System.out.print(metaData.getColumnLabel(4) + ":" + tables.getString(4) + "\t"); - System.out.print(metaData.getColumnLabel(5) + ":" + tables.getString(5) + "\n"); + ResultSet rs = metaData.getTables("log", "", null, null); + ResultSetMetaData meta = rs.getMetaData(); + Assert.assertNotNull(rs); + rs.next(); + { + // TABLE_CAT + Assert.assertEquals("TABLE_CAT", meta.getColumnLabel(1)); + Assert.assertEquals("log", rs.getString(1)); + Assert.assertEquals("log", rs.getString("TABLE_CAT")); + // TABLE_SCHEM + Assert.assertEquals("TABLE_SCHEM", meta.getColumnLabel(2)); + Assert.assertEquals(null, rs.getString(2)); + Assert.assertEquals(null, rs.getString("TABLE_SCHEM")); + // TABLE_NAME + Assert.assertEquals("TABLE_NAME", meta.getColumnLabel(3)); + Assert.assertNotNull(rs.getString(3)); + Assert.assertNotNull(rs.getString("TABLE_NAME")); + // TABLE_TYPE + Assert.assertEquals("TABLE_TYPE", meta.getColumnLabel(4)); + Assert.assertEquals("TABLE", rs.getString(4)); + Assert.assertEquals("TABLE", rs.getString("TABLE_TYPE")); + // REMARKS + Assert.assertEquals("REMARKS", meta.getColumnLabel(5)); + Assert.assertEquals("", rs.getString(5)); + Assert.assertEquals("", rs.getString("REMARKS")); } - System.out.println(); - Assert.assertNotNull(tables); } @Test @@ -652,46 +668,130 @@ public class RestfulDatabaseMetaDataTest { @Test public void getCatalogs() throws SQLException { - System.out.println("****************************************************"); - - ResultSet catalogs = metaData.getCatalogs(); - ResultSetMetaData meta = catalogs.getMetaData(); - while (catalogs.next()) { - for (int i = 1; i <= meta.getColumnCount(); i++) { - System.out.print(meta.getColumnLabel(i) + ": " + catalogs.getString(i)); - } - System.out.println(); + ResultSet rs = metaData.getCatalogs(); + ResultSetMetaData meta = rs.getMetaData(); + rs.next(); + { + // TABLE_CAT + Assert.assertEquals("TABLE_CAT", meta.getColumnLabel(1)); + Assert.assertNotNull(rs.getString(1)); + Assert.assertNotNull(rs.getString("TABLE_CAT")); } } @Test public void getTableTypes() throws SQLException { - System.out.println("****************************************************"); - ResultSet tableTypes = metaData.getTableTypes(); - while (tableTypes.next()) { - System.out.println(tableTypes.getString("TABLE_TYPE")); + tableTypes.next(); + // tableTypes: table + { + Assert.assertEquals("TABLE", tableTypes.getString(1)); + Assert.assertEquals("TABLE", tableTypes.getString("TABLE_TYPE")); + } + tableTypes.next(); + // tableTypes: stable + { + Assert.assertEquals("STABLE", tableTypes.getString(1)); + Assert.assertEquals("STABLE", tableTypes.getString("TABLE_TYPE")); } - Assert.assertNotNull(metaData.getTableTypes()); } @Test public void getColumns() throws SQLException { - System.out.println("****************************************************"); - + // when ResultSet columns = metaData.getColumns("log", "", "dn", ""); + // then ResultSetMetaData meta = columns.getMetaData(); - while (columns.next()) { - System.out.print(meta.getColumnLabel(1) + ": " + columns.getString(1) + "\t"); - System.out.print(meta.getColumnLabel(3) + ": " + columns.getString(3) + "\t"); - System.out.print(meta.getColumnLabel(4) + ": " + columns.getString(4) + "\t"); - System.out.print(meta.getColumnLabel(5) + ": " + columns.getString(5) + "\t"); - System.out.print(meta.getColumnLabel(6) + ": " + columns.getString(6) + "\t"); - System.out.print(meta.getColumnLabel(7) + ": " + columns.getString(7) + "\t"); - System.out.print(meta.getColumnLabel(9) + ": " + columns.getString(9) + "\t"); - System.out.print(meta.getColumnLabel(10) + ": " + columns.getString(10) + "\t"); - System.out.print(meta.getColumnLabel(11) + ": " + columns.getString(11) + "\n"); - System.out.print(meta.getColumnLabel(12) + ": " + columns.getString(12) + "\n"); + columns.next(); + // column: 1 + { + // TABLE_CAT + Assert.assertEquals("TABLE_CAT", meta.getColumnLabel(1)); + Assert.assertEquals("log", columns.getString(1)); + Assert.assertEquals("log", columns.getString("TABLE_CAT")); + // TABLE_NAME + Assert.assertEquals("TABLE_NAME", meta.getColumnLabel(3)); + Assert.assertEquals("dn", columns.getString(3)); + Assert.assertEquals("dn", columns.getString("TABLE_NAME")); + // COLUMN_NAME + Assert.assertEquals("COLUMN_NAME", meta.getColumnLabel(4)); + Assert.assertEquals("ts", columns.getString(4)); + Assert.assertEquals("ts", columns.getString("COLUMN_NAME")); + // DATA_TYPE + Assert.assertEquals("DATA_TYPE", meta.getColumnLabel(5)); + Assert.assertEquals(Types.TIMESTAMP, columns.getInt(5)); + Assert.assertEquals(Types.TIMESTAMP, columns.getInt("DATA_TYPE")); + // TYPE_NAME + Assert.assertEquals("TYPE_NAME", meta.getColumnLabel(6)); + Assert.assertEquals("TIMESTAMP", columns.getString(6)); + Assert.assertEquals("TIMESTAMP", columns.getString("TYPE_NAME")); + // COLUMN_SIZE + Assert.assertEquals("COLUMN_SIZE", meta.getColumnLabel(7)); + Assert.assertEquals(26, columns.getInt(7)); + Assert.assertEquals(26, columns.getInt("COLUMN_SIZE")); + // DECIMAL_DIGITS + Assert.assertEquals("DECIMAL_DIGITS", meta.getColumnLabel(9)); + Assert.assertEquals(Integer.MIN_VALUE, columns.getInt(9)); + Assert.assertEquals(Integer.MIN_VALUE, columns.getInt("DECIMAL_DIGITS")); + Assert.assertEquals(null, columns.getString(9)); + Assert.assertEquals(null, columns.getString("DECIMAL_DIGITS")); + // NUM_PREC_RADIX + Assert.assertEquals("NUM_PREC_RADIX", meta.getColumnLabel(10)); + Assert.assertEquals(10, columns.getInt(10)); + Assert.assertEquals(10, columns.getInt("NUM_PREC_RADIX")); + // NULLABLE + Assert.assertEquals("NULLABLE", meta.getColumnLabel(11)); + Assert.assertEquals(DatabaseMetaData.columnNoNulls, columns.getInt(11)); + Assert.assertEquals(DatabaseMetaData.columnNoNulls, columns.getInt("NULLABLE")); + // REMARKS + Assert.assertEquals("REMARKS", meta.getColumnLabel(12)); + Assert.assertEquals(null, columns.getString(12)); + Assert.assertEquals(null, columns.getString("REMARKS")); + } + columns.next(); + // column: 2 + { + // TABLE_CAT + Assert.assertEquals("TABLE_CAT", meta.getColumnLabel(1)); + Assert.assertEquals("log", columns.getString(1)); + Assert.assertEquals("log", columns.getString("TABLE_CAT")); + // TABLE_NAME + Assert.assertEquals("TABLE_NAME", meta.getColumnLabel(3)); + Assert.assertEquals("dn", columns.getString(3)); + Assert.assertEquals("dn", columns.getString("TABLE_NAME")); + // COLUMN_NAME + Assert.assertEquals("COLUMN_NAME", meta.getColumnLabel(4)); + Assert.assertEquals("cpu_taosd", columns.getString(4)); + Assert.assertEquals("cpu_taosd", columns.getString("COLUMN_NAME")); + // DATA_TYPE + Assert.assertEquals("DATA_TYPE", meta.getColumnLabel(5)); + Assert.assertEquals(Types.FLOAT, columns.getInt(5)); + Assert.assertEquals(Types.FLOAT, columns.getInt("DATA_TYPE")); + // TYPE_NAME + Assert.assertEquals("TYPE_NAME", meta.getColumnLabel(6)); + Assert.assertEquals("FLOAT", columns.getString(6)); + Assert.assertEquals("FLOAT", columns.getString("TYPE_NAME")); + // COLUMN_SIZE + Assert.assertEquals("COLUMN_SIZE", meta.getColumnLabel(7)); + Assert.assertEquals(12, columns.getInt(7)); + Assert.assertEquals(12, columns.getInt("COLUMN_SIZE")); + // DECIMAL_DIGITS + Assert.assertEquals("DECIMAL_DIGITS", meta.getColumnLabel(9)); + Assert.assertEquals(Integer.MIN_VALUE, columns.getInt(9)); + Assert.assertEquals(Integer.MIN_VALUE, columns.getInt("DECIMAL_DIGITS")); + Assert.assertEquals(null, columns.getString(9)); + Assert.assertEquals(null, columns.getString("DECIMAL_DIGITS")); + // NUM_PREC_RADIX + Assert.assertEquals("NUM_PREC_RADIX", meta.getColumnLabel(10)); + Assert.assertEquals(10, columns.getInt(10)); + Assert.assertEquals(10, columns.getInt("NUM_PREC_RADIX")); + // NULLABLE + Assert.assertEquals("NULLABLE", meta.getColumnLabel(11)); + Assert.assertEquals(DatabaseMetaData.columnNullable, columns.getInt(11)); + Assert.assertEquals(DatabaseMetaData.columnNullable, columns.getInt("NULLABLE")); + // REMARKS + Assert.assertEquals("REMARKS", meta.getColumnLabel(12)); + Assert.assertEquals(null, columns.getString(12)); } } @@ -717,17 +817,35 @@ public class RestfulDatabaseMetaDataTest { @Test public void getPrimaryKeys() throws SQLException { - System.out.println("****************************************************"); - ResultSet rs = metaData.getPrimaryKeys("log", "", "dn1"); - while (rs.next()) { - System.out.println("TABLE_NAME: " + rs.getString("TABLE_NAME")); - System.out.println("COLUMN_NAME: " + rs.getString("COLUMN_NAME")); - System.out.println("KEY_SEQ: " + rs.getString("KEY_SEQ")); - System.out.println("PK_NAME: " + rs.getString("PK_NAME")); + ResultSetMetaData meta = rs.getMetaData(); + rs.next(); + { + // TABLE_CAT + Assert.assertEquals("TABLE_CAT", meta.getColumnLabel(1)); + Assert.assertEquals("log", rs.getString(1)); + Assert.assertEquals("log", rs.getString("TABLE_CAT")); + // TABLE_SCHEM + Assert.assertEquals("TABLE_SCHEM", meta.getColumnLabel(2)); + Assert.assertEquals(null, rs.getString(2)); + Assert.assertEquals(null, rs.getString("TABLE_SCHEM")); + // TABLE_NAME + Assert.assertEquals("TABLE_NAME", meta.getColumnLabel(3)); + Assert.assertEquals("dn1", rs.getString(3)); + Assert.assertEquals("dn1", rs.getString("TABLE_NAME")); + // COLUMN_NAME + Assert.assertEquals("COLUMN_NAME", meta.getColumnLabel(4)); + Assert.assertEquals("ts", rs.getString(4)); + Assert.assertEquals("ts", rs.getString("COLUMN_NAME")); + // KEY_SEQ + Assert.assertEquals("KEY_SEQ", meta.getColumnLabel(5)); + Assert.assertEquals(1, rs.getShort(5)); + Assert.assertEquals(1, rs.getShort("KEY_SEQ")); + // DATA_TYPE + Assert.assertEquals("PK_NAME", meta.getColumnLabel(6)); + Assert.assertEquals("ts", rs.getString(6)); + Assert.assertEquals("ts", rs.getString("PK_NAME")); } - - Assert.assertNotNull(rs); } @Test @@ -852,14 +970,27 @@ public class RestfulDatabaseMetaDataTest { @Test public void getSuperTables() throws SQLException { - System.out.println("****************************************************"); - ResultSet rs = metaData.getSuperTables("log", "", "dn1"); - while (rs.next()) { - System.out.println("TABLE_NAME: " + rs.getString("TABLE_NAME")); - System.out.println("SUPERTABLE_NAME: " + rs.getString("SUPERTABLE_NAME")); + ResultSetMetaData meta = rs.getMetaData(); + rs.next(); + { + // TABLE_CAT + Assert.assertEquals("TABLE_CAT", meta.getColumnLabel(1)); + Assert.assertEquals("log", rs.getString(1)); + Assert.assertEquals("log", rs.getString("TABLE_CAT")); + // TABLE_CAT + Assert.assertEquals("TABLE_SCHEM", meta.getColumnLabel(2)); + Assert.assertEquals(null, rs.getString(2)); + Assert.assertEquals(null, rs.getString("TABLE_SCHEM")); + // TABLE_CAT + Assert.assertEquals("TABLE_NAME", meta.getColumnLabel(3)); + Assert.assertEquals("dn1", rs.getString(3)); + Assert.assertEquals("dn1", rs.getString("TABLE_NAME")); + // TABLE_CAT + Assert.assertEquals("SUPERTABLE_NAME", meta.getColumnLabel(4)); + Assert.assertEquals("dn", rs.getString(4)); + Assert.assertEquals("dn", rs.getString("SUPERTABLE_NAME")); } - Assert.assertNotNull(rs); } @Test diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulParameterMetaDataTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulParameterMetaDataTest.java index 8bb2532ce8..81d7f5b56c 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulParameterMetaDataTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulParameterMetaDataTest.java @@ -54,16 +54,17 @@ public class RestfulParameterMetaDataTest { @Test public void getPrecision() throws SQLException { - Assert.assertEquals(0, parameterMetaData_insert.getPrecision(1)); - Assert.assertEquals(0, parameterMetaData_insert.getPrecision(2)); - Assert.assertEquals(0, parameterMetaData_insert.getPrecision(3)); - Assert.assertEquals(0, parameterMetaData_insert.getPrecision(4)); - Assert.assertEquals(0, parameterMetaData_insert.getPrecision(5)); - Assert.assertEquals(0, parameterMetaData_insert.getPrecision(6)); - Assert.assertEquals(0, parameterMetaData_insert.getPrecision(7)); - Assert.assertEquals(0, parameterMetaData_insert.getPrecision(8)); - Assert.assertEquals(5, parameterMetaData_insert.getPrecision(9)); - Assert.assertEquals(5, parameterMetaData_insert.getPrecision(10)); + //create table weather(ts timestamp, f1 int, f2 bigint, f3 float, f4 double, f5 smallint, f6 tinyint, f7 bool, f8 binary(64), f9 nchar(64)) + Assert.assertEquals(TSDBConstants.TIMESTAMP_MS_PRECISION, parameterMetaData_insert.getPrecision(1)); + Assert.assertEquals(TSDBConstants.INT_PRECISION, parameterMetaData_insert.getPrecision(2)); + Assert.assertEquals(TSDBConstants.BIGINT_PRECISION, parameterMetaData_insert.getPrecision(3)); + Assert.assertEquals(TSDBConstants.FLOAT_PRECISION, parameterMetaData_insert.getPrecision(4)); + Assert.assertEquals(TSDBConstants.DOUBLE_PRECISION, parameterMetaData_insert.getPrecision(5)); + Assert.assertEquals(TSDBConstants.SMALLINT_PRECISION, parameterMetaData_insert.getPrecision(6)); + Assert.assertEquals(TSDBConstants.TINYINT_PRECISION, parameterMetaData_insert.getPrecision(7)); + Assert.assertEquals(TSDBConstants.BOOLEAN_PRECISION, parameterMetaData_insert.getPrecision(8)); + Assert.assertEquals("hello".getBytes().length, parameterMetaData_insert.getPrecision(9)); + Assert.assertEquals("涛思数据".length(), parameterMetaData_insert.getPrecision(10)); } @Test @@ -71,8 +72,8 @@ public class RestfulParameterMetaDataTest { Assert.assertEquals(0, parameterMetaData_insert.getScale(1)); Assert.assertEquals(0, parameterMetaData_insert.getScale(2)); Assert.assertEquals(0, parameterMetaData_insert.getScale(3)); - Assert.assertEquals(0, parameterMetaData_insert.getScale(4)); - Assert.assertEquals(0, parameterMetaData_insert.getScale(5)); + Assert.assertEquals(31, parameterMetaData_insert.getScale(4)); + Assert.assertEquals(31, parameterMetaData_insert.getScale(5)); Assert.assertEquals(0, parameterMetaData_insert.getScale(6)); Assert.assertEquals(0, parameterMetaData_insert.getScale(7)); Assert.assertEquals(0, parameterMetaData_insert.getScale(8)); @@ -164,7 +165,7 @@ public class RestfulParameterMetaDataTest { pstmt_insert.setObject(7, Byte.MAX_VALUE); pstmt_insert.setObject(8, true); pstmt_insert.setObject(9, "hello".getBytes()); - pstmt_insert.setObject(10, "Hello"); + pstmt_insert.setObject(10, "涛思数据"); parameterMetaData_insert = pstmt_insert.getParameterMetaData(); pstmt_select = conn.prepareStatement(sql_select); From 1b53460b8cdf4b4b3c4512bd2fc8a7bf19506fcd Mon Sep 17 00:00:00 2001 From: zyyang Date: Tue, 8 Jun 2021 17:25:00 +0800 Subject: [PATCH 56/72] change --- .../test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java index 3ad51479d6..a09dea745d 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java @@ -5,7 +5,6 @@ import org.junit.*; import java.io.IOException; import java.math.BigDecimal; import java.sql.*; -import java.time.LocalTime; public class TSDBPreparedStatementTest { From 57c298b4390408fd8bd95caf7ba0e5ef227980eb Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Tue, 8 Jun 2021 17:26:00 +0800 Subject: [PATCH 57/72] fix bug --- src/mnode/src/mnodeDb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c index 9faf08c2ec..fd04f3380d 100644 --- a/src/mnode/src/mnodeDb.c +++ b/src/mnode/src/mnodeDb.c @@ -790,7 +790,7 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void sprintf(tmp, "%d,%d,%d", pDb->cfg.daysToKeep0, pDb->cfg.daysToKeep1, pDb->cfg.daysToKeep2); } #else - sprintf(tmp, "%d", pDb->cfg.daysToKeep0); + sprintf(tmp, "%d", pDb->cfg.daysToKeep2); #endif STR_WITH_SIZE_TO_VARSTR(pWrite, tmp, strlen(tmp)); cols++; From 63ccb3fa6f007db5844b597c27f3c2d6c1cc7146 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Tue, 8 Jun 2021 17:41:52 +0800 Subject: [PATCH 58/72] restore case --- tests/script/general/parser/dbtbnameValidate.sim | 2 +- tests/script/general/parser/first_last.sim | 2 +- tests/script/general/parser/function.sim | 2 +- tests/script/general/parser/groupby.sim | 2 +- tests/script/general/parser/join.sim | 2 +- tests/script/general/parser/join_manyblocks.sim | 2 +- tests/script/general/parser/join_multivnode.sim | 2 +- tests/script/general/parser/projection_limit_offset.sim | 2 +- tests/script/general/parser/select_with_tags.sim | 2 +- tests/script/general/parser/sliding.sim | 2 +- tests/script/general/parser/subInfrom.sim | 2 +- tests/script/general/parser/topbot.sim | 6 +++--- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/script/general/parser/dbtbnameValidate.sim b/tests/script/general/parser/dbtbnameValidate.sim index caa5f3aa6d..bc3bfefafb 100644 --- a/tests/script/general/parser/dbtbnameValidate.sim +++ b/tests/script/general/parser/dbtbnameValidate.sim @@ -7,7 +7,7 @@ sleep 100 sql connect print ========== db name and table name check in create and drop, describe -sql create database abc keep 36500,36500,36500 +sql create database abc keep 36500 sql create database 'abc123' sql create database '_ab1234' sql create database 'ABC123' diff --git a/tests/script/general/parser/first_last.sim b/tests/script/general/parser/first_last.sim index 70c3e8a5f6..09047b4528 100644 --- a/tests/script/general/parser/first_last.sim +++ b/tests/script/general/parser/first_last.sim @@ -86,7 +86,7 @@ sleep 100 run general/parser/first_last_query.sim print =================> insert data regression test -sql create database test keep 36500,36500,36500 +sql create database test keep 36500 sql use test sql create table tm0 (ts timestamp, k int) diff --git a/tests/script/general/parser/function.sim b/tests/script/general/parser/function.sim index 11eb3fb2bd..591d5d1535 100644 --- a/tests/script/general/parser/function.sim +++ b/tests/script/general/parser/function.sim @@ -21,7 +21,7 @@ $db = $dbPrefix . $i $mt = $mtPrefix . $i sql drop database if exists $db -sql create database $db keep 36500,36500,36500 +sql create database $db keep 36500 sql use $db print =====================================> td-4481 diff --git a/tests/script/general/parser/groupby.sim b/tests/script/general/parser/groupby.sim index 8ded859669..124e76e85c 100644 --- a/tests/script/general/parser/groupby.sim +++ b/tests/script/general/parser/groupby.sim @@ -29,7 +29,7 @@ $tstart = 100000 sql drop database if exists $db -x step1 step1: -sql create database if not exists $db keep 36500,36500,36500 +sql create database if not exists $db keep 36500 sql use $db sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) diff --git a/tests/script/general/parser/join.sim b/tests/script/general/parser/join.sim index 6142277e50..2c14a86c3a 100644 --- a/tests/script/general/parser/join.sim +++ b/tests/script/general/parser/join.sim @@ -26,7 +26,7 @@ $tstart = 100000 sql drop database if exists $db -x step1 step1: -sql create database if not exists $db keep 36500,36500,36500 +sql create database if not exists $db keep 36500 sql use $db sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) diff --git a/tests/script/general/parser/join_manyblocks.sim b/tests/script/general/parser/join_manyblocks.sim index 43936ee645..fddd59c0a1 100644 --- a/tests/script/general/parser/join_manyblocks.sim +++ b/tests/script/general/parser/join_manyblocks.sim @@ -24,7 +24,7 @@ $tstart = 100000 sql drop database if exists $db -x step1 step1: -sql create database if not exists $db keep 36500,36500,36500 +sql create database if not exists $db keep 36500 sql use $db sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) diff --git a/tests/script/general/parser/join_multivnode.sim b/tests/script/general/parser/join_multivnode.sim index 4bafc0d0e9..61438241b0 100644 --- a/tests/script/general/parser/join_multivnode.sim +++ b/tests/script/general/parser/join_multivnode.sim @@ -24,7 +24,7 @@ $tstart = 100000 sql drop database if exists $db -x step1 step1: -sql create database if not exists $db keep 36500,36500,36500 +sql create database if not exists $db keep 36500 sql use $db sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) diff --git a/tests/script/general/parser/projection_limit_offset.sim b/tests/script/general/parser/projection_limit_offset.sim index 2a93a179a2..ffbcb28ffd 100644 --- a/tests/script/general/parser/projection_limit_offset.sim +++ b/tests/script/general/parser/projection_limit_offset.sim @@ -23,7 +23,7 @@ $tstart = 100000 sql drop database if exists $db -x step1 step1: -sql create database if not exists $db keep 36500,36500,36500 +sql create database if not exists $db keep 36500 sql use $db sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) diff --git a/tests/script/general/parser/select_with_tags.sim b/tests/script/general/parser/select_with_tags.sim index 45507bf1e7..45f6f5c49f 100644 --- a/tests/script/general/parser/select_with_tags.sim +++ b/tests/script/general/parser/select_with_tags.sim @@ -24,7 +24,7 @@ $tstart = 100000 sql drop database if exists $db -x step1 step1: -sql create database if not exists $db keep 36500,36500,36500 +sql create database if not exists $db keep 36500 sql use $db sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12), t3 int) diff --git a/tests/script/general/parser/sliding.sim b/tests/script/general/parser/sliding.sim index cbdcb2162a..b2695ff95f 100644 --- a/tests/script/general/parser/sliding.sim +++ b/tests/script/general/parser/sliding.sim @@ -29,7 +29,7 @@ $mt = $mtPrefix . $i sql drop database if exists $db -x step1 step1: -sql create database if not exists $db keep 36500,36500,36500 +sql create database if not exists $db keep 36500 sql use $db sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) diff --git a/tests/script/general/parser/subInfrom.sim b/tests/script/general/parser/subInfrom.sim index 09ba4381ba..e47831ee87 100644 --- a/tests/script/general/parser/subInfrom.sim +++ b/tests/script/general/parser/subInfrom.sim @@ -26,7 +26,7 @@ $stb = $stbPrefix . $i sql drop database $db -x step1 step1: -sql create database $db cache 16 maxrows 4096 keep 36500,36500,36500 +sql create database $db cache 16 maxrows 4096 keep 36500 print ====== create tables sql use $db sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) diff --git a/tests/script/general/parser/topbot.sim b/tests/script/general/parser/topbot.sim index 8a10fa2b41..ddab1b3f83 100644 --- a/tests/script/general/parser/topbot.sim +++ b/tests/script/general/parser/topbot.sim @@ -25,7 +25,7 @@ $stb = $stbPrefix . $i sql drop database $db -x step1 step1: -sql create database $db cache 16 maxrows 4096 keep 36500,36500,36500 +sql create database $db cache 16 maxrows 4096 keep 36500 print ====== create tables sql use $db sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) @@ -175,7 +175,7 @@ if $data21 != 2.10000 then endi print =====================td-1302 case -sql create database t1 keep 36500,36500,36500; +sql create database t1 keep 36500 sql use t1; sql create table test(ts timestamp, k int); sql insert into test values(29999, 1)(70000, 2)(80000, 3) @@ -194,7 +194,7 @@ if $rows != 3 then endi print ==============>td-1308 -sql create database db keep 36500,36500,36500; +sql create database db keep 36500 sql use db; sql create table stb (ts timestamp, c1 int, c2 binary(10)) tags(t1 binary(10)); From e42a8bc633a43f1fc4e8fec660e576c6886a3c22 Mon Sep 17 00:00:00 2001 From: Qiyuan Jiao Date: Tue, 8 Jun 2021 17:45:32 +0800 Subject: [PATCH 59/72] Update apitest.c remove unneeded define --- tests/examples/c/apitest.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index a482e2902e..f881b5b20c 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -852,7 +852,6 @@ void verify_prepare3(TAOS* taos) { int rows = 0; int num_fields = taos_num_fields(result); TAOS_FIELD *fields = taos_fetch_fields(result); - char temp[256] = {0}; // fetch the records row by row while ((row = taos_fetch_row(result))) { From a76457b42adda64905477536af4f26b1b98cdb15 Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Tue, 8 Jun 2021 17:45:46 +0800 Subject: [PATCH 60/72] Add jdbc data binding cases back --- .../jdbc/TSDBPreparedStatementTest.java | 292 ++++++++++++++++++ 1 file changed, 292 insertions(+) diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java index 3ad51479d6..6d4176d606 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java @@ -6,6 +6,8 @@ import java.io.IOException; import java.math.BigDecimal; import java.sql.*; import java.time.LocalTime; +import java.util.ArrayList; +import java.util.Random; public class TSDBPreparedStatementTest { @@ -295,6 +297,296 @@ public class TSDBPreparedStatementTest { assertAllNullExceptTimestamp(rs, ts); } } + + @Test + public void executeTest() throws SQLException { + Statement stmt = conn.createStatement(); + + int numOfRows = 1000; + + for (int loop = 0; loop < 10; loop++){ + stmt.execute("drop table if exists weather_test"); + stmt.execute("create table weather_test(ts timestamp, f1 nchar(4), f2 float, f3 double, f4 timestamp, f5 int, f6 bool, f7 binary(10))"); + + TSDBPreparedStatement s = (TSDBPreparedStatement) conn.prepareStatement("insert into ? values(?, ?, ?, ?, ?, ?, ?, ?)"); + Random r = new Random(); + s.setTableName("weather_test"); + + ArrayList ts = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + ts.add(System.currentTimeMillis() + i); + } + s.setTimestamp(0, ts); + + int random = 10 + r.nextInt(5); + ArrayList s2 = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + if(i % random == 0) { + s2.add(null); + }else{ + s2.add("分支" + i % 4); + } + } + s.setNString(1, s2, 4); + + random = 10 + r.nextInt(5); + ArrayList s3 = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + if(i % random == 0) { + s3.add(null); + }else{ + s3.add(r.nextFloat()); + } + } + s.setFloat(2, s3); + + random = 10 + r.nextInt(5); + ArrayList s4 = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + if(i % random == 0) { + s4.add(null); + }else{ + s4.add(r.nextDouble()); + } + } + s.setDouble(3, s4); + + random = 10 + r.nextInt(5); + ArrayList ts2 = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + if(i % random == 0) { + ts2.add(null); + }else{ + ts2.add(System.currentTimeMillis() + i); + } + } + s.setTimestamp(4, ts2); + + random = 10 + r.nextInt(5); + ArrayList vals = new ArrayList<>(); + for(int i = 0; i < numOfRows; i++) { + if(i % random == 0) { + vals.add(null); + }else{ + vals.add(r.nextInt()); + } + } + s.setInt(5, vals); + + random = 10 + r.nextInt(5); + ArrayList sb = new ArrayList<>(); + for(int i = 0; i < numOfRows; i++) { + if(i % random == 0) { + sb.add(null); + }else{ + sb.add(i % 2 == 0 ? true : false); + } + } + s.setBoolean(6, sb); + + random = 10 + r.nextInt(5); + ArrayList s5 = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + if(i % random == 0) { + s5.add(null); + }else{ + s5.add("test" + i % 10); + } + } + s.setString(7, s5, 10); + + s.columnDataAddBatch(); + s.columnDataExecuteBatch(); + s.columnDataCloseBatch(); + + String sql = "select * from weather_test"; + PreparedStatement statement = conn.prepareStatement(sql); + ResultSet rs = statement.executeQuery(); + int rows = 0; + while(rs.next()) { + rows++; + } + Assert.assertEquals(numOfRows, rows); + } + } + + @Test + public void bindDataSelectColumnTest() throws SQLException { + Statement stmt = conn.createStatement(); + + int numOfRows = 1000; + + for (int loop = 0; loop < 10; loop++){ + stmt.execute("drop table if exists weather_test"); + stmt.execute("create table weather_test(ts timestamp, f1 nchar(4), f2 float, f3 double, f4 timestamp, f5 int, f6 bool, f7 binary(10))"); + + TSDBPreparedStatement s = (TSDBPreparedStatement) conn.prepareStatement("insert into ? (ts, f1, f7) values(?, ?, ?)"); + Random r = new Random(); + s.setTableName("weather_test"); + + ArrayList ts = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + ts.add(System.currentTimeMillis() + i); + } + s.setTimestamp(0, ts); + + int random = 10 + r.nextInt(5); + ArrayList s2 = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + if(i % random == 0) { + s2.add(null); + }else{ + s2.add("分支" + i % 4); + } + } + s.setNString(1, s2, 4); + + random = 10 + r.nextInt(5); + ArrayList s3 = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + if(i % random == 0) { + s3.add(null); + }else{ + s3.add("test" + i % 10); + } + } + s.setString(2, s3, 10); + + s.columnDataAddBatch(); + s.columnDataExecuteBatch(); + s.columnDataCloseBatch(); + + String sql = "select * from weather_test"; + PreparedStatement statement = conn.prepareStatement(sql); + ResultSet rs = statement.executeQuery(); + int rows = 0; + while(rs.next()) { + rows++; + } + Assert.assertEquals(numOfRows, rows); + } + } + + @Test + public void bindDataWithSingleTagTest() throws SQLException { + Statement stmt = conn.createStatement(); + + String types[] = new String[] {"tinyint", "smallint", "int", "bigint", "bool", "float", "double", "binary(10)", "nchar(10)"}; + + for (String type : types) { + stmt.execute("drop table if exists weather_test"); + stmt.execute("create table weather_test(ts timestamp, f1 nchar(10), f2 binary(10)) tags (t " + type + ")"); + + int numOfRows = 1; + + TSDBPreparedStatement s = (TSDBPreparedStatement) conn.prepareStatement("insert into ? using weather_test tags(?) values(?, ?, ?)"); + Random r = new Random(); + s.setTableName("w1"); + + switch(type) { + case "tinyint": + case "smallint": + case "int": + case "bigint": + s.setTagInt(0, 1); + break; + case "float": + s.setTagFloat(0, 1.23f); + break; + case "double": + s.setTagDouble(0, 3.14159265); + break; + case "bool": + s.setTagBoolean(0, true); + break; + case "binary(10)": + s.setTagString(0, "test"); + break; + case "nchar(10)": + s.setTagNString(0, "test"); + break; + default: + break; + } + + + ArrayList ts = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + ts.add(System.currentTimeMillis() + i); + } + s.setTimestamp(0, ts); + + int random = 10 + r.nextInt(5); + ArrayList s2 = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + s2.add("分支" + i % 4); + } + s.setNString(1, s2, 10); + + random = 10 + r.nextInt(5); + ArrayList s3 = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + s3.add("test" + i % 4); + } + s.setString(2, s3, 10); + + s.columnDataAddBatch(); + s.columnDataExecuteBatch(); + s.columnDataCloseBatch(); + + String sql = "select * from weather_test"; + PreparedStatement statement = conn.prepareStatement(sql); + ResultSet rs = statement.executeQuery(); + int rows = 0; + while(rs.next()) { + rows++; + } + Assert.assertEquals(numOfRows, rows); + } + } + + + @Test + public void bindDataWithMultipleTagsTest() throws SQLException { + Statement stmt = conn.createStatement(); + + stmt.execute("drop table if exists weather_test"); + stmt.execute("create table weather_test(ts timestamp, f1 nchar(10), f2 binary(10)) tags (t1 int, t2 binary(10))"); + + int numOfRows = 1; + + TSDBPreparedStatement s = (TSDBPreparedStatement) conn.prepareStatement("insert into ? using weather_test tags(?,?) (ts, f2) values(?, ?)"); + s.setTableName("w2"); + s.setTagInt(0, 1); + s.setTagString(1, "test"); + + + ArrayList ts = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + ts.add(System.currentTimeMillis() + i); + } + s.setTimestamp(0, ts); + + ArrayList s2 = new ArrayList(); + for(int i = 0; i < numOfRows; i++) { + s2.add("test" + i % 4); + } + s.setString(1, s2, 10); + + s.columnDataAddBatch(); + s.columnDataExecuteBatch(); + s.columnDataCloseBatch(); + + String sql = "select * from weather_test"; + PreparedStatement statement = conn.prepareStatement(sql); + ResultSet rs = statement.executeQuery(); + int rows = 0; + while(rs.next()) { + rows++; + } + Assert.assertEquals(numOfRows, rows); + + } @Test public void createTwoSameDbTest() throws SQLException { From 93566238ec7fdc4834fc504e752e2e1a82af1bc7 Mon Sep 17 00:00:00 2001 From: Elias Soong Date: Tue, 8 Jun 2021 18:28:57 +0800 Subject: [PATCH 61/72] [TD-4533] : correct details of Prepare Statement api for Java. --- documentation20/cn/08.connector/01.java/docs.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/documentation20/cn/08.connector/01.java/docs.md b/documentation20/cn/08.connector/01.java/docs.md index ffea252c86..e6d214c74d 100644 --- a/documentation20/cn/08.connector/01.java/docs.md +++ b/documentation20/cn/08.connector/01.java/docs.md @@ -325,10 +325,12 @@ for (int i = 0; i < numOfRows; i++){ } s.setString(2, s2, 10); -// AddBatch 之后,可以再设定新的表名、TAGS、VALUES 取值,这样就能实现一次执行向多个数据表写入: +// AddBatch 之后,缓存并未清空。为避免混乱,并不推荐在 ExecuteBatch 之前再次绑定新一批的数据: s.columnDataAddBatch(); -// 执行语句: +// 执行绑定数据后的语句: s.columnDataExecuteBatch(); +// 执行语句后清空缓存。在清空之后,可以复用当前的对象,绑定新的一批数据(可以是新表名、新 TAGS 值、新 VALUES 值): +s.columnDataClearBatch(); // 执行完毕,释放资源: s.columnDataCloseBatch(); ``` From 1beac7b6381e407e235b7c00dbd106776bc6c5f9 Mon Sep 17 00:00:00 2001 From: zyyang Date: Tue, 8 Jun 2021 18:48:37 +0800 Subject: [PATCH 62/72] change --- .../java/com/taosdata/jdbc/TSDBPreparedStatementTest.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java index 4865303bfc..0daf6c00bc 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java @@ -297,14 +297,6 @@ public class TSDBPreparedStatementTest { } } - @Test - public void createTwoSameDbTest() throws SQLException { - Statement stmt = conn.createStatement(); - - stmt.execute("create database dbtest"); - Assert.assertThrows(SQLException.class, () -> stmt.execute("create database dbtest")); - } - @Test public void setBoolean() throws SQLException { // given From a40c92722564aa5dba240fbf4132e09b151c4c6f Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 8 Jun 2021 18:56:33 +0800 Subject: [PATCH 63/72] [TD-225] --- src/client/src/tscSQLParser.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 75741e8820..887a255ddf 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -6305,6 +6305,7 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, char* msg) { continue; } + if ((aAggs[functionId].status & TSDB_FUNCSTATE_SELECTIVITY) != 0) { numOfSelectivity++; } else { From 934265ffac5b03a4a8116115e2ad8d10364d8864 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Tue, 8 Jun 2021 21:52:16 +0800 Subject: [PATCH 64/72] [TD-4597] fix stddev and percentile func mixed with session and state_window --- src/query/inc/qExecutor.h | 3 ++- src/query/src/qExecutor.c | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/query/inc/qExecutor.h b/src/query/inc/qExecutor.h index 24547c1e0b..955dd734cf 100644 --- a/src/query/inc/qExecutor.h +++ b/src/query/inc/qExecutor.h @@ -464,6 +464,7 @@ typedef struct SSWindowOperatorInfo { TSKEY prevTs; // previous timestamp int32_t numOfRows; // number of rows int32_t start; // start row index + bool reptScan; // next round scan } SSWindowOperatorInfo; typedef struct SStateWindowOperatorInfo { @@ -473,7 +474,7 @@ typedef struct SStateWindowOperatorInfo { int32_t colIndex; // start row index int32_t start; char* prevData; // previous data - + bool reptScan; } SStateWindowOperatorInfo ; typedef struct SDistinctOperatorInfo { diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 3c999fca0b..7bf5f9bba7 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -30,6 +30,7 @@ #define IS_MASTER_SCAN(runtime) ((runtime)->scanFlag == MASTER_SCAN) #define IS_REVERSE_SCAN(runtime) ((runtime)->scanFlag == REVERSE_SCAN) +#define IS_REPEAT_SCAN(runtime) ((runtime)->scanFlag == REPEAT_SCAN) #define SET_MASTER_SCAN_FLAG(runtime) ((runtime)->scanFlag = MASTER_SCAN) #define SET_REVERSE_SCAN_FLAG(runtime) ((runtime)->scanFlag = REVERSE_SCAN) @@ -1336,6 +1337,10 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInf int64_t gap = pOperator->pRuntimeEnv->pQueryAttr->sw.gap; pInfo->numOfRows = 0; + if (IS_REPEAT_SCAN(pRuntimeEnv) && !pInfo->reptScan) { + pInfo->reptScan = true; + pInfo->prevTs = INT64_MIN; + } TSKEY* tsList = (TSKEY*)pColInfoData->pData; for (int32_t j = 0; j < pSDataBlock->info.rows; ++j) { @@ -1345,7 +1350,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInf pInfo->prevTs = tsList[j]; pInfo->numOfRows = 1; pInfo->start = j; - } else if (tsList[j] - pInfo->prevTs <= gap) { + } else if (tsList[j] - pInfo->prevTs <= gap && (tsList[j] - pInfo->prevTs) >= 0) { pInfo->curWindow.ekey = tsList[j]; pInfo->prevTs = tsList[j]; pInfo->numOfRows += 1; @@ -5175,6 +5180,10 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI SColumnInfoData* pTsColInfoData = taosArrayGet(pSDataBlock->pDataBlock, 0); TSKEY* tsList = (TSKEY*)pTsColInfoData->pData; + if (IS_REPEAT_SCAN(pRuntimeEnv) && !pInfo->reptScan) { + pInfo->reptScan = true; + tfree(pInfo->prevData); + } pInfo->numOfRows = 0; for (int32_t j = 0; j < pSDataBlock->info.rows; ++j) { @@ -5761,6 +5770,7 @@ SOperatorInfo* createTimeIntervalOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOp SOperatorInfo* createStatewindowOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput) { SStateWindowOperatorInfo* pInfo = calloc(1, sizeof(SStateWindowOperatorInfo)); pInfo->colIndex = -1; + pInfo->reptScan = false; pInfo->binfo.pCtx = createSQLFunctionCtx(pRuntimeEnv, pExpr, numOfOutput, &pInfo->binfo.rowCellInfoOffset); pInfo->binfo.pRes = createOutputBuf(pExpr, numOfOutput, pRuntimeEnv->resultInfo.capacity); initResultRowInfo(&pInfo->binfo.resultRowInfo, 8, TSDB_DATA_TYPE_INT); @@ -5788,7 +5798,8 @@ SOperatorInfo* createSWindowOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperato pInfo->binfo.pRes = createOutputBuf(pExpr, numOfOutput, pRuntimeEnv->resultInfo.capacity); initResultRowInfo(&pInfo->binfo.resultRowInfo, 8, TSDB_DATA_TYPE_INT); - pInfo->prevTs = INT64_MIN; + pInfo->prevTs = INT64_MIN; + pInfo->reptScan = false; SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); pOperator->name = "SessionWindowAggOperator"; From db251e8e416b7743a27cc541ac4f7d4494598c5a Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Wed, 9 Jun 2021 06:51:14 +0800 Subject: [PATCH 65/72] Feature/sangshuduo/td 4198 support address sanitizer for develop (#6414) * [TD-4198]: support AddressSanitizer on windows. * fix compile flag. * fix compile warning for early version visual c++. * disable memory sanitizer by default. * fix variable name * add static lib link. --- cmake/define.inc | 27 +++++++++++++++++++++------ cmake/input.inc | 5 +++++ src/query/src/qAggMain.c | 4 ++-- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/cmake/define.inc b/cmake/define.inc index cc8bd0fc35..441bf19997 100755 --- a/cmake/define.inc +++ b/cmake/define.inc @@ -122,10 +122,14 @@ IF (TD_LINUX) ADD_DEFINITIONS(-D_TD_NINGSI_60) MESSAGE(STATUS "set ningsi macro to true") ENDIF () - - SET(DEBUG_FLAGS "-O0 -g3 -DDEBUG") + + IF (TD_MEMORY_SANITIZER) + SET(DEBUG_FLAGS "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -O0 -g3 -DDEBUG") + ELSE () + SET(DEBUG_FLAGS "-O0 -g3 -DDEBUG") + ENDIF () SET(RELEASE_FLAGS "-O3 -Wno-error") - + IF (${COVER} MATCHES "true") MESSAGE(STATUS "Test coverage mode, add extra flags") SET(GCC_COVERAGE_COMPILE_FLAGS "-fprofile-arcs -ftest-coverage") @@ -144,7 +148,11 @@ IF (TD_DARWIN_64) ADD_DEFINITIONS(-DUSE_LIBICONV) MESSAGE(STATUS "darwin64 is defined") SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -Wno-missing-braces -fPIC -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") - SET(DEBUG_FLAGS "-O0 -g3 -DDEBUG") + IF (TD_MEMORY_SANITIZER) + SET(DEBUG_FLAGS "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -O0 -g3 -DDEBUG") + ELSE () + SET(DEBUG_FLAGS "-O0 -g3 -DDEBUG") + ENDIF () SET(RELEASE_FLAGS "-Og") INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/cJson/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/lz4/inc) @@ -162,7 +170,14 @@ IF (TD_WINDOWS) IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900)) SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18") ENDIF () - SET(DEBUG_FLAGS "/fsanitize=thread /fsanitize=leak /fsanitize=memory /fsanitize=undefined /fsanitize=hwaddress /Zi /W3 /GL") + + IF (TD_MEMORY_SANITIZER) +MESSAGE("memory sanitizer detected as true") + SET(DEBUG_FLAGS "/fsanitize=address /Zi /W3 /GL") + ELSE () +MESSAGE("memory sanitizer detected as false") + SET(DEBUG_FLAGS "/Zi /W3 /GL") + ENDIF () SET(RELEASE_FLAGS "/W0 /O3 /GL") ENDIF () @@ -171,7 +186,7 @@ IF (TD_WINDOWS) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/regex) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/wepoll/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/MsvcLibX/include) -ENDIF () +ENDIF () IF (TD_WINDOWS_64) ADD_DEFINITIONS(-D_M_X64) diff --git a/cmake/input.inc b/cmake/input.inc index 9b72a35d94..c073bbbc03 100755 --- a/cmake/input.inc +++ b/cmake/input.inc @@ -83,3 +83,8 @@ SET(TD_BUILD_JDBC TRUE) IF (${BUILD_JDBC} MATCHES "false") SET(TD_BUILD_JDBC FALSE) ENDIF () + +SET(TD_MEMORY_SANITIZER FALSE) +IF (${MEMORY_SANITIZER} MATCHES "true") + SET(TD_MEMORY_SANITIZER TRUE) +ENDIF () diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index ca7b44e3a4..77185342c2 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -4687,8 +4687,8 @@ static bool rate_function_setup(SQLFunctionCtx *pCtx) { pInfo->correctionValue = 0; pInfo->firstKey = INT64_MIN; pInfo->lastKey = INT64_MIN; - pInfo->firstValue = INT64_MIN; - pInfo->lastValue = INT64_MIN; + pInfo->firstValue = (double) INT64_MIN; + pInfo->lastValue = (double) INT64_MIN; pInfo->hasResult = 0; pInfo->isIRate = (pCtx->functionId == TSDB_FUNC_IRATE); From dc3de5dae074a3ef58ba1919299b3ebddddf40e3 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Wed, 9 Jun 2021 06:51:29 +0800 Subject: [PATCH 66/72] Feature/sangshuduo/td 4198 support address sanitizer (#6419) * cherry pick from develop branch. * cherry pick from develop branch. * add static lib link. --- cmake/define.inc | 24 ++++++++++++++++++------ cmake/input.inc | 5 +++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/cmake/define.inc b/cmake/define.inc index e825dce024..da80baabbb 100755 --- a/cmake/define.inc +++ b/cmake/define.inc @@ -117,10 +117,14 @@ IF (TD_LINUX) ADD_DEFINITIONS(-D_TD_NINGSI_60) MESSAGE(STATUS "set ningsi macro to true") ENDIF () - - SET(DEBUG_FLAGS "-O0 -g3 -DDEBUG") + + IF (TD_MEMORY_SANITIZER) + SET(DEBUG_FLAGS "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -O0 -g3 -DDEBUG") + ELSE () + SET(DEBUG_FLAGS "-O0 -g3 -DDEBUG") + ENDIF () SET(RELEASE_FLAGS "-O3 -Wno-error") - + IF (${COVER} MATCHES "true") MESSAGE(STATUS "Test coverage mode, add extra flags") SET(GCC_COVERAGE_COMPILE_FLAGS "-fprofile-arcs -ftest-coverage") @@ -139,7 +143,11 @@ IF (TD_DARWIN_64) ADD_DEFINITIONS(-DUSE_LIBICONV) MESSAGE(STATUS "darwin64 is defined") SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -Wno-missing-braces -fPIC -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") - SET(DEBUG_FLAGS "-O0 -g3 -DDEBUG") + IF (TD_MEMORY_SANITIZER) + SET(DEBUG_FLAGS "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -O0 -g3 -DDEBUG") + ELSE () + SET(DEBUG_FLAGS "-O0 -g3 -DDEBUG") + ENDIF () SET(RELEASE_FLAGS "-Og") INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/cJson/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/lz4/inc) @@ -157,7 +165,11 @@ IF (TD_WINDOWS) IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900)) SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18") ENDIF () - SET(DEBUG_FLAGS "/Zi /W3 /GL") + IF (TD_MEMORY_SANITIZER) + SET(DEBUG_FLAGS "/fsanitize=address /Zi /W3 /GL") + ELSE () + SET(DEBUG_FLAGS "/Zi /W3 /GL") + ENDIF () SET(RELEASE_FLAGS "/W0 /O3 /GL") ENDIF () @@ -166,7 +178,7 @@ IF (TD_WINDOWS) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/regex) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/wepoll/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/MsvcLibX/include) -ENDIF () +ENDIF () IF (TD_WINDOWS_64) ADD_DEFINITIONS(-D_M_X64) diff --git a/cmake/input.inc b/cmake/input.inc index 5841a46567..ca1a27ec44 100755 --- a/cmake/input.inc +++ b/cmake/input.inc @@ -78,3 +78,8 @@ SET(TD_BUILD_JDBC TRUE) IF (${BUILD_JDBC} MATCHES "false") SET(TD_BUILD_JDBC FALSE) ENDIF () + +SET(TD_MEMORY_SANITIZER FALSE) +IF (${MEMORY_SANITIZER} MATCHES "true") + SET(TD_MEMORY_SANITIZER TRUE) +ENDIF () From 56a7b6378ce46d899456f694b78b84eab32cbef5 Mon Sep 17 00:00:00 2001 From: Jun Li Date: Tue, 8 Jun 2021 20:06:54 -0700 Subject: [PATCH 67/72] Fix typo for taos lib on macos (#6428) --- src/connector/python/taos/cinterface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connector/python/taos/cinterface.py b/src/connector/python/taos/cinterface.py index b8824327b0..0f690aeb27 100644 --- a/src/connector/python/taos/cinterface.py +++ b/src/connector/python/taos/cinterface.py @@ -242,7 +242,7 @@ def _load_taos_linux(): def _load_taos_darwin(): - return ctypes.cDLL('libtaos.dylib') + return ctypes.CDLL('libtaos.dylib') def _load_taos_windows(): From 9a2d8533cbeb34f990b30fa41f7c09ce5099b878 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 9 Jun 2021 13:27:08 +0800 Subject: [PATCH 68/72] [td-4625]: fix bug in diff query with group by. --- src/client/inc/tscUtil.h | 1 + src/client/src/tscSQLParser.c | 27 ++++++++++--- src/client/src/tscUtil.c | 28 +++++++++++-- src/query/src/qAggMain.c | 4 +- src/query/src/qExecutor.c | 3 +- tests/script/general/parser/nestquery.sim | 49 +++++++++++++++++++++++ 6 files changed, 99 insertions(+), 13 deletions(-) diff --git a/src/client/inc/tscUtil.h b/src/client/inc/tscUtil.h index 427431d3c0..2c4d711520 100644 --- a/src/client/inc/tscUtil.h +++ b/src/client/inc/tscUtil.h @@ -138,6 +138,7 @@ bool isSimpleAggregateRv(SQueryInfo* pQueryInfo); bool tscNonOrderedProjectionQueryOnSTable(SQueryInfo *pQueryInfo, int32_t tableIndex); bool tscOrderedProjectionQueryOnSTable(SQueryInfo* pQueryInfo, int32_t tableIndex); +bool tscIsDiffDerivQuery(SQueryInfo* pQueryInfo); bool tscIsProjectionQueryOnSTable(SQueryInfo* pQueryInfo, int32_t tableIndex); bool tscIsProjectionQuery(SQueryInfo* pQueryInfo); diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 887a255ddf..3328ef63a4 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -6301,7 +6301,7 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, char* msg) { int16_t functionId = pExpr->base.functionId; if (functionId == TSDB_FUNC_TAGPRJ || functionId == TSDB_FUNC_PRJ || functionId == TSDB_FUNC_TS || - functionId == TSDB_FUNC_ARITHM) { + functionId == TSDB_FUNC_ARITHM || functionId == TSDB_FUNC_TS_DUMMY) { continue; } @@ -6407,9 +6407,14 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo size_t size = tscNumOfExprs(pQueryInfo); if (TSDB_COL_IS_TAG(pColIndex->flag)) { + + int32_t f = TSDB_FUNC_TAG; + if (tscIsDiffDerivQuery(pQueryInfo)) { + f = TSDB_FUNC_TAGPRJ; + } + SColumnIndex index = {.tableIndex = pQueryInfo->groupbyExpr.tableIndex, .columnIndex = colIndex}; - SExprInfo* pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TAG, &index, s->type, s->bytes, - getNewResColId(pCmd), s->bytes, true); + SExprInfo* pExpr = tscExprAppend(pQueryInfo, f, &index, s->type, s->bytes, getNewResColId(pCmd), s->bytes, true); memset(pExpr->base.aliasName, 0, sizeof(pExpr->base.aliasName)); tstrncpy(pExpr->base.aliasName, s->name, sizeof(pExpr->base.aliasName)); @@ -6545,7 +6550,7 @@ int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, char* } // projection query on super table does not compatible with "group by" syntax - if (tscIsProjectionQuery(pQueryInfo)) { + if (tscIsProjectionQuery(pQueryInfo) && !(tscIsDiffDerivQuery(pQueryInfo))) { return invalidOperationMsg(msg, msg3); } @@ -7745,7 +7750,8 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf const char* msg2 = "too many tables in from clause"; const char* msg3 = "start(end) time of query range required or time range too large"; const char* msg4 = "interval query not supported, since the result of sub query not include valid timestamp column"; - const char* msg9 = "only tag query not compatible with normal column filter"; + const char* msg5 = "only tag query not compatible with normal column filter"; + const char* msg6 = "not support stddev/percentile in outer query yet"; int32_t code = TSDB_CODE_SUCCESS; @@ -7786,6 +7792,15 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf return TSDB_CODE_TSC_INVALID_OPERATION; } + // todo NOT support yet + for(int32_t i = 0; i < tscNumOfExprs(pQueryInfo); ++i) { + SExprInfo* pExpr = tscExprGet(pQueryInfo, i); + int32_t f = pExpr->base.functionId; + if (f == TSDB_FUNC_STDDEV || f == TSDB_FUNC_PERCT) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6); + } + } + // validate the query filter condition info if (pSqlNode->pWhere != NULL) { if (validateWhereNode(pQueryInfo, &pSqlNode->pWhere, pSql) != TSDB_CODE_SUCCESS) { @@ -7899,7 +7914,7 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf for (int32_t i = 0; i < numOfCols; ++i) { SColumn* pCols = taosArrayGetP(pQueryInfo->colList, i); if (pCols->info.flist.numOfFilters > 0) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg9); + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg5); } } } diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 60919c98b5..c17cd21c42 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -255,10 +255,14 @@ bool tscIsProjectionQuery(SQueryInfo* pQueryInfo) { size_t size = tscNumOfExprs(pQueryInfo); for (int32_t i = 0; i < size; ++i) { - int32_t functionId = tscExprGet(pQueryInfo, i)->base.functionId; + int32_t f = tscExprGet(pQueryInfo, i)->base.functionId; + if (f == TSDB_FUNC_TS_DUMMY) { + continue; + } - if (functionId != TSDB_FUNC_PRJ && functionId != TSDB_FUNC_TAGPRJ && functionId != TSDB_FUNC_TAG && - functionId != TSDB_FUNC_TS && functionId != TSDB_FUNC_ARITHM) { + if (f != TSDB_FUNC_PRJ && f != TSDB_FUNC_TAGPRJ && f != TSDB_FUNC_TAG && + f != TSDB_FUNC_TS && f != TSDB_FUNC_ARITHM && f != TSDB_FUNC_DIFF && + f != TSDB_FUNC_DERIVATIVE) { return false; } } @@ -266,6 +270,24 @@ bool tscIsProjectionQuery(SQueryInfo* pQueryInfo) { return true; } +bool tscIsDiffDerivQuery(SQueryInfo* pQueryInfo) { + size_t size = tscNumOfExprs(pQueryInfo); + + for (int32_t i = 0; i < size; ++i) { + int32_t f = tscExprGet(pQueryInfo, i)->base.functionId; + if (f == TSDB_FUNC_TS_DUMMY) { + continue; + } + + if (f == TSDB_FUNC_DIFF || f == TSDB_FUNC_DERIVATIVE) { + return true; + } + } + + return false; +} + + bool tscHasColumnFilter(SQueryInfo* pQueryInfo) { // filter on primary timestamp column if (pQueryInfo->window.skey != INT64_MIN || pQueryInfo->window.ekey != INT64_MAX) { diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index 472f3f8fe1..e225439d99 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -5381,7 +5381,7 @@ SAggFunctionInfo aAggs[] = {{ "diff", TSDB_FUNC_DIFF, TSDB_FUNC_INVALID_ID, - TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_NEED_TS, + TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_NEED_TS | TSDB_FUNCSTATE_SELECTIVITY, diff_function_setup, diff_function, diff_function_f, @@ -5485,7 +5485,7 @@ SAggFunctionInfo aAggs[] = {{ "derivative", // return table id and the corresponding tags for join match and subscribe TSDB_FUNC_DERIVATIVE, TSDB_FUNC_INVALID_ID, - TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_NEED_TS, + TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_NEED_TS | TSDB_FUNCSTATE_SELECTIVITY, deriv_function_setup, deriv_function, noop2, diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 8cc25f1fe6..7c79a4c81e 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -1682,8 +1682,6 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf SQueryAttr *pQueryAttr = pRuntimeEnv->pQueryAttr; pRuntimeEnv->prevGroupId = INT32_MIN; - pRuntimeEnv->enableGroupData = false; - pRuntimeEnv->pQueryAttr = pQueryAttr; pRuntimeEnv->pResultRowHashTable = taosHashInit(numOfTables, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); @@ -4118,6 +4116,7 @@ int32_t doInitQInfo(SQInfo* pQInfo, STSBuf* pTsBuf, void* tsdb, void* sourceOptr pQueryAttr->interBufSize = getOutputInterResultBufSize(pQueryAttr); pRuntimeEnv->groupResInfo.totalGroup = (int32_t) (pQueryAttr->stableQuery? GET_NUM_OF_TABLEGROUP(pRuntimeEnv):0); + pRuntimeEnv->enableGroupData = false; pRuntimeEnv->pQueryAttr = pQueryAttr; pRuntimeEnv->pTsBuf = pTsBuf; diff --git a/tests/script/general/parser/nestquery.sim b/tests/script/general/parser/nestquery.sim index 16d190d3fe..98c0918c0f 100644 --- a/tests/script/general/parser/nestquery.sim +++ b/tests/script/general/parser/nestquery.sim @@ -147,8 +147,57 @@ if $data02 != @nest_tb0@ then endi print ===================> nest query interval +sql_error select ts, avg(c1) from (select ts, c1 from nest_tb0); +sql select avg(c1) from (select * from nest_tb0) interval(3d) +if $rows != 3 then + return -1 +endi +if $data00 != @20-09-14 00:00:00.000@ then + return -1 +endi + +if $data01 != 49.222222222 then + return -1 +endi + +if $data10 != @20-09-17 00:00:00.000@ then + print expect 20-09-17 00:00:00.000, actual: $data10 + return -1 +endi + +if $data11 != 49.685185185 then + return -1 +endi + +if $data20 != @20-09-20 00:00:00.000@ then + return -1 +endi + +if $data21 != 49.500000000 then + return -1 +endi + +#define TSDB_FUNC_APERCT 7 +#define TSDB_FUNC_LAST_ROW 10 +#define TSDB_FUNC_TWA 14 +#define TSDB_FUNC_LEASTSQR 15 +#define TSDB_FUNC_ARITHM 23 +#define TSDB_FUNC_DIFF 24 +#define TSDB_FUNC_INTERP 28 +#define TSDB_FUNC_RATE 29 +#define TSDB_FUNC_IRATE 30 +#define TSDB_FUNC_DERIVATIVE 32 + +sql_error select stddev(c1) from (select c1 from nest_tb0); +sql_error select percentile(c1, 20) from (select * from nest_tb0); + +sql select avg(c1),sum(c2), max(c3), min(c4), count(*), first(c7), last(c7),spread(c6) from (select * from nest_tb0) interval(1d); + +sql select top(x, 20) from (select c1 x from nest_tb0); + +sql select bottom(x, 20) from (select c1 x from nest_tb0) print ===================> complex query From 922736fed53b69a7a449db33f09229feadf9211e Mon Sep 17 00:00:00 2001 From: dapan <89396746@qq.com> Date: Wed, 9 Jun 2021 15:29:10 +0800 Subject: [PATCH 69/72] fix case issue --- tests/pytest/alter/alter_keep.py | 12 ++++++------ tests/script/general/db/alter_option.sim | 10 +++++----- tests/script/general/http/restful_full.sim | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/pytest/alter/alter_keep.py b/tests/pytest/alter/alter_keep.py index cb630963a7..f73b8ce460 100644 --- a/tests/pytest/alter/alter_keep.py +++ b/tests/pytest/alter/alter_keep.py @@ -72,9 +72,9 @@ class TDTestCase: tdSql.query('show databases') tdSql.checkData(0,7,'3650,3650,3650') - tdSql.error('alter database db keep 10') + tdSql.execute('alter database db keep 10') tdSql.query('show databases') - tdSql.checkData(0,7,'3650,3650,3650') + tdSql.checkData(0,7,'10,10,10') ## the order for altering keep is keep(D), keep0, keep1. ## if the order is changed, please modify the following test @@ -84,17 +84,17 @@ class TDTestCase: tdSql.query('show databases') tdSql.checkData(0,7,'10,10,10') - tdSql.execute('alter database db keep 100, 98 ,99') + tdSql.error('alter database db keep 100, 98 ,99') tdSql.query('show databases') - tdSql.checkData(0,7,'98,99,100') + tdSql.checkData(0,7,'10,10,10') tdSql.execute('alter database db keep 200, 200 ,200') tdSql.query('show databases') tdSql.checkData(0,7,'200,200,200') - tdSql.error('alter database db keep 198, 199 ,200') + tdSql.execute('alter database db keep 198, 199 ,200') tdSql.query('show databases') - tdSql.checkData(0,7,'200,200,200') + tdSql.checkData(0,7,'198,199,200') # tdSql.execute('alter database db keep 3650,3650,3650') # tdSql.error('alter database db keep 4000,3640') diff --git a/tests/script/general/db/alter_option.sim b/tests/script/general/db/alter_option.sim index bd68ddd859..c20a96fd1b 100644 --- a/tests/script/general/db/alter_option.sim +++ b/tests/script/general/db/alter_option.sim @@ -112,21 +112,21 @@ endi sql alter database db keep 30 sql show databases print keep $data7_db -if $data7_db != 20,20,30 then +if $data7_db != 30,30,30 then return -1 endi sql alter database db keep 40 sql show databases print keep $data7_db -if $data7_db != 20,20,40 then +if $data7_db != 40,40,40 then return -1 endi -sql alter database db keep 40 -sql alter database db keep 30 +sql alter database db keep 40,50 +sql alter database db keep 30,31 sql alter database db keep 20 -sql_error alter database db keep 10 +sql_error alter database db keep 10.0 sql_error alter database db keep 9 sql_error alter database db keep 1 sql_error alter database db keep 0 diff --git a/tests/script/general/http/restful_full.sim b/tests/script/general/http/restful_full.sim index 8094a943f5..a5d3ac2b86 100644 --- a/tests/script/general/http/restful_full.sim +++ b/tests/script/general/http/restful_full.sim @@ -88,7 +88,7 @@ print =============== step2 - no db #11 system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 127.0.0.1:7111/rest/sql print 11-> $system_content -if $system_content != @{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep0,keep1,keep(D)","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","cachelast","precision","update","status"],"column_meta":[["name",8,32],["created_time",9,8],["ntables",4,4],["vgroups",4,4],["replica",3,2],["quorum",3,2],["days",3,2],["keep0,keep1,keep(D)",8,24],["cache(MB)",4,4],["blocks",4,4],["minrows",4,4],["maxrows",4,4],["wallevel",2,1],["fsync",4,4],["comp",2,1],["cachelast",2,1],["precision",8,3],["update",2,1],["status",8,10]],"data":[],"rows":0}@ then +if $system_content != @{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep0,keep1,keep2","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","cachelast","precision","update","status"],"column_meta":[["name",8,32],["created_time",9,8],["ntables",4,4],["vgroups",4,4],["replica",3,2],["quorum",3,2],["days",3,2],["keep0,keep1,keep2",8,24],["cache(MB)",4,4],["blocks",4,4],["minrows",4,4],["maxrows",4,4],["wallevel",2,1],["fsync",4,4],["comp",2,1],["cachelast",2,1],["precision",8,3],["update",2,1],["status",8,10]],"data":[],"rows":0}@ then return -1 endi From 3caf8e43ef94b0389ec364c82ce85e79027f6b90 Mon Sep 17 00:00:00 2001 From: dapan <89396746@qq.com> Date: Wed, 9 Jun 2021 16:51:07 +0800 Subject: [PATCH 70/72] fix case issuei --- tests/script/general/db/topic1.sim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/script/general/db/topic1.sim b/tests/script/general/db/topic1.sim index 63cae8dffd..4939e5a0e2 100644 --- a/tests/script/general/db/topic1.sim +++ b/tests/script/general/db/topic1.sim @@ -367,7 +367,7 @@ sql_error topic db keep 30 sql alter database db keep 30 sql show databases print keep $data7_db -if $data7_db != 20,20,30 then +if $data7_db != 30,30,30 then return -1 endi @@ -375,14 +375,14 @@ sql_error alter topic db keep 40 sql alter database db keep 40 sql show databases print keep $data7_db -if $data7_db != 20,20,40 then +if $data7_db != 40,40,40 then return -1 endi sql alter database db keep 40 sql alter database db keep 30 sql alter database db keep 20 -sql_error alter database db keep 10 +sql_error alter database db keep 10.0 sql_error alter database db keep 9 sql_error alter database db keep 1 sql_error alter database db keep 0 From 38deb7687219ba70fc8b7aa3dd90f92fa3f7aa9d Mon Sep 17 00:00:00 2001 From: Elias Soong Date: Wed, 9 Jun 2021 17:01:11 +0800 Subject: [PATCH 71/72] [TD-3229] : add doc about deploy on Kubenetes environment. --- documentation20/cn/00.index/docs.md | 1 + 1 file changed, 1 insertion(+) diff --git a/documentation20/cn/00.index/docs.md b/documentation20/cn/00.index/docs.md index 50b31a55d3..04de20fd62 100644 --- a/documentation20/cn/00.index/docs.md +++ b/documentation20/cn/00.index/docs.md @@ -15,6 +15,7 @@ TDengine是一个高效的存储、查询、分析时序大数据的平台,专 * [命令行程序TAOS](/getting-started#console):访问TDengine的简便方式 * [极速体验](/getting-started#demo):运行示例程序,快速体验高效的数据插入、查询 * [支持平台列表](/getting-started#platforms):TDengine服务器和客户端支持的平台列表 +* [Kubenetes部署](https://taosdata.github.io/TDengine-Operator/zh/index.html):TDengine在Kubenetes环境进行部署的详细说明 ## [整体架构](/architecture) From c4ac06dac4fe82e8029831f874447206b0bbdac9 Mon Sep 17 00:00:00 2001 From: dapan <89396746@qq.com> Date: Wed, 9 Jun 2021 17:43:25 +0800 Subject: [PATCH 72/72] fix bug --- src/client/src/tscSQLParser.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index ee3f8e2fb9..298bd8dacc 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -2331,8 +2331,10 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col } if (info.precision == TSDB_TIME_PRECISION_MILLI) { + tickPerSec /= 1000000; + } else if (info.precision == TSDB_TIME_PRECISION_MICRO) { tickPerSec /= 1000; - } + } if (tickPerSec <= 0 || tickPerSec < TSDB_TICK_PER_SECOND(info.precision)) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg10);