From 2464d892ad2396fde1e2ee1a072eba4d5814729c Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Thu, 10 Jun 2021 11:07:33 +0800 Subject: [PATCH 01/21] fix bug --- src/client/src/tscSub.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/client/src/tscSub.c b/src/client/src/tscSub.c index a6d09b5d8d..e4f67ba0de 100644 --- a/src/client/src/tscSub.c +++ b/src/client/src/tscSub.c @@ -282,6 +282,7 @@ static int tscUpdateSubscription(STscObj* pObj, SSub* pSub) { SArray* tables = getTableList(pSql); if (tables == NULL) { + pSub->lastSyncTime = 0; //force to get table list next time return 0; } size_t numOfTables = taosArrayGetSize(tables); @@ -488,7 +489,15 @@ TAOS_RES *taos_consume(TAOS_SUB *tsub) { SSub *pSub = (SSub *)tsub; if (pSub == NULL) return NULL; - if (pSub->pSql->cmd.command == TSDB_SQL_RETRIEVE_EMPTY_RESULT) { + if (pSub->pTimer == NULL) { + int64_t duration = taosGetTimestampMs() - pSub->lastConsumeTime; + if (duration < (int64_t)(pSub->interval)) { + tscDebug("subscription consume too frequently, blocking..."); + taosMsleep(pSub->interval - (int32_t)duration); + } + } + + if (pSub->pSql->cmd.command == TSDB_SQL_RETRIEVE_EMPTY_RESULT) { //may reach here when retireve stable vgroup failed SSqlObj* pSql = recreateSqlObj(pSub); if (pSql == NULL) { return NULL; @@ -500,6 +509,11 @@ TAOS_RES *taos_consume(TAOS_SUB *tsub) { } pSub->pSql = pSql; pSql->pSubscription = pSub; + + // no table list now, force to update it + tscDebug("begin table synchronization"); + if (!tscUpdateSubscription(pSub->taos, pSub)) return NULL; + tscDebug("table synchronization completed"); } tscSaveSubscriptionProgress(pSub); @@ -524,14 +538,6 @@ TAOS_RES *taos_consume(TAOS_SUB *tsub) { tscDebug("subscribe:%s set next round subscribe skey:%"PRId64, pSub->topic, pQueryInfo->window.skey); } - if (pSub->pTimer == NULL) { - int64_t duration = taosGetTimestampMs() - pSub->lastConsumeTime; - if (duration < (int64_t)(pSub->interval)) { - tscDebug("subscription consume too frequently, blocking..."); - taosMsleep(pSub->interval - (int32_t)duration); - } - } - size_t size = taosArrayGetSize(pSub->progress) * sizeof(STableIdInfo); size += sizeof(SQueryTableMsg) + 4096; int code = tscAllocPayload(&pSql->cmd, (int)size); From d198dcbb88e2ff8a813270830e0869dcdde1e25d Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Fri, 11 Jun 2021 16:11:06 +0800 Subject: [PATCH 02/21] add null pointer check --- src/client/src/tscPrepare.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index 73e39b471b..38991e9f39 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -879,6 +879,11 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) { return TSDB_CODE_TSC_DISCONNECTED; } + if (sql == NULL) { + tscError("sql is NULL"); + return TSDB_CODE_TSC_APP_ERROR; + } + SSqlObj* pSql = pStmt->pSql; size_t sqlLen = strlen(sql); From 1e92fa7def536c3716d8f9ab0ec2cb5ad0f8b7f0 Mon Sep 17 00:00:00 2001 From: zyyang Date: Fri, 11 Jun 2021 17:44:58 +0800 Subject: [PATCH 03/21] sync from develop to master --- cmake/install.inc | 2 +- src/connector/jdbc/CMakeLists.txt | 6 +- src/connector/jdbc/deploy-pom.xml | 2 +- src/connector/jdbc/pom.xml | 3 +- .../taosdata/jdbc/rs/RestfulConnection.java | 9 ++- .../com/taosdata/jdbc/rs/RestfulDriver.java | 12 ++-- .../taosdata/jdbc/rs/RestfulStatement.java | 6 +- .../jdbc/utils/HttpClientPoolUtil.java | 44 ++++++-------- .../taosdata/jdbc/cases/BatchInsertTest.java | 4 +- ...iTaosdByRestfulWithDifferentTokenTest.java | 59 +++++++++++++++++++ 10 files changed, 98 insertions(+), 49 deletions(-) create mode 100644 src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/ConnectMultiTaosdByRestfulWithDifferentTokenTest.java diff --git a/cmake/install.inc b/cmake/install.inc index f8b3b7c3c6..b37cf751fb 100755 --- a/cmake/install.inc +++ b/cmake/install.inc @@ -32,7 +32,7 @@ ELSEIF (TD_WINDOWS) #INSTALL(TARGETS taos RUNTIME DESTINATION driver) #INSTALL(TARGETS shell RUNTIME DESTINATION .) IF (TD_MVN_INSTALLED) - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.29.jar DESTINATION connector/jdbc) + INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.31.jar DESTINATION connector/jdbc) ENDIF () ELSEIF (TD_DARWIN) SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh") diff --git a/src/connector/jdbc/CMakeLists.txt b/src/connector/jdbc/CMakeLists.txt index 61e976cb18..1db8361faf 100644 --- a/src/connector/jdbc/CMakeLists.txt +++ b/src/connector/jdbc/CMakeLists.txt @@ -8,10 +8,8 @@ IF (TD_MVN_INSTALLED) ADD_CUSTOM_COMMAND(OUTPUT ${JDBC_CMD_NAME} POST_BUILD COMMAND mvn -Dmaven.test.skip=true install -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.29.jar ${LIBRARY_OUTPUT_PATH} + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.31.jar ${LIBRARY_OUTPUT_PATH} COMMAND mvn -Dmaven.test.skip=true clean -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml COMMENT "build jdbc driver") ADD_CUSTOM_TARGET(${JDBC_TARGET_NAME} ALL WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} DEPENDS ${JDBC_CMD_NAME}) -ENDIF () - - +ENDIF () \ No newline at end of file diff --git a/src/connector/jdbc/deploy-pom.xml b/src/connector/jdbc/deploy-pom.xml index 968a9bf470..8f77582d30 100755 --- a/src/connector/jdbc/deploy-pom.xml +++ b/src/connector/jdbc/deploy-pom.xml @@ -5,7 +5,7 @@ com.taosdata.jdbc taos-jdbcdriver - 2.0.29 + 2.0.31 jar JDBCDriver diff --git a/src/connector/jdbc/pom.xml b/src/connector/jdbc/pom.xml index ef353d1d19..d08d5502c2 100755 --- a/src/connector/jdbc/pom.xml +++ b/src/connector/jdbc/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.taosdata.jdbc taos-jdbcdriver - 2.0.29 + 2.0.31 jar JDBCDriver https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc @@ -123,6 +123,7 @@ **/InvalidResultSetPointerTest.java **/RestfulConnectionTest.java **/TD4144Test.java + **/ConnectMultiTaosdByRestfulWithDifferentTokenTest.java true diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulConnection.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulConnection.java index b810f9aeb5..d6a02b7e3a 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulConnection.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulConnection.java @@ -17,16 +17,18 @@ public class RestfulConnection extends AbstractConnection { private final int port; private final String url; private volatile String database; + private final String token; /******************************************************/ private boolean isClosed; private final DatabaseMetaData metadata; - public RestfulConnection(String host, String port, Properties props, String database, String url) { + public RestfulConnection(String host, String port, Properties props, String database, String url, String token) { super(props); this.host = host; this.port = Integer.parseInt(port); this.database = database; this.url = url; + this.token = token; this.metadata = new RestfulDatabaseMetaData(url, props.getProperty(TSDBDriver.PROPERTY_KEY_USER), this); } @@ -66,6 +68,7 @@ public class RestfulConnection extends AbstractConnection { return this.metadata; } + // getters public String getHost() { return host; } @@ -81,4 +84,8 @@ public class RestfulConnection extends AbstractConnection { public String getUrl() { return url; } + + public String getToken() { + return token; + } } \ No newline at end of file diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java index a94cfa6e07..9ab67c5502 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java @@ -38,15 +38,11 @@ public class RestfulDriver extends AbstractDriver { String port = props.getProperty(TSDBDriver.PROPERTY_KEY_PORT, "6041"); String database = props.containsKey(TSDBDriver.PROPERTY_KEY_DBNAME) ? props.getProperty(TSDBDriver.PROPERTY_KEY_DBNAME) : null; - String loginUrl = "http://" + props.getProperty(TSDBDriver.PROPERTY_KEY_HOST) + ":" - + props.getProperty(TSDBDriver.PROPERTY_KEY_PORT) + "/rest/login/" - + props.getProperty(TSDBDriver.PROPERTY_KEY_USER) + "/" - + props.getProperty(TSDBDriver.PROPERTY_KEY_PASSWORD) + ""; + String loginUrl = "http://" + host + ":" + port + "/rest/login/" + props.getProperty(TSDBDriver.PROPERTY_KEY_USER) + "/" + props.getProperty(TSDBDriver.PROPERTY_KEY_PASSWORD) + ""; try { String user = URLEncoder.encode(props.getProperty(TSDBDriver.PROPERTY_KEY_USER), "UTF-8"); String password = URLEncoder.encode(props.getProperty(TSDBDriver.PROPERTY_KEY_PASSWORD), "UTF-8"); - loginUrl = "http://" + props.getProperty(TSDBDriver.PROPERTY_KEY_HOST) + ":" - + props.getProperty(TSDBDriver.PROPERTY_KEY_PORT) + "/rest/login/" + user + "/" + password + ""; + loginUrl = "http://" + props.getProperty(TSDBDriver.PROPERTY_KEY_HOST) + ":" + props.getProperty(TSDBDriver.PROPERTY_KEY_PORT) + "/rest/login/" + user + "/" + password + ""; } catch (UnsupportedEncodingException e) { e.printStackTrace(); } @@ -55,12 +51,12 @@ public class RestfulDriver extends AbstractDriver { JSONObject jsonResult = JSON.parseObject(result); String status = jsonResult.getString("status"); String token = jsonResult.getString("desc"); - HttpClientPoolUtil.token = token; + if (!status.equals("succ")) { throw new SQLException(jsonResult.getString("desc")); } - RestfulConnection conn = new RestfulConnection(host, port, props, database, url); + RestfulConnection conn = new RestfulConnection(host, port, props, database, url, token); if (database != null && !database.trim().replaceAll("\\s", "").isEmpty()) { Statement stmt = conn.createStatement(); stmt.execute("use " + database); diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java index fbc3a50a27..e9d193f6b4 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java @@ -83,7 +83,7 @@ public class RestfulStatement extends AbstractStatement { } if (SqlSyntaxValidator.isUseSql(sql)) { - HttpClientPoolUtil.execute(url, sql); + HttpClientPoolUtil.execute(url, sql, this.conn.getToken()); this.database = sql.trim().replace("use", "").trim(); this.conn.setCatalog(this.database); result = false; @@ -116,7 +116,7 @@ public class RestfulStatement extends AbstractStatement { if ("UTC".equalsIgnoreCase(timestampFormat)) url = "http://" + conn.getHost() + ":" + conn.getPort() + "/rest/sqlutc"; - String result = HttpClientPoolUtil.execute(url, sql); + String result = HttpClientPoolUtil.execute(url, sql, this.conn.getToken()); JSONObject resultJson = JSON.parseObject(result); if (resultJson.getString("status").equals("error")) { throw TSDBError.createSQLException(resultJson.getInteger("code"), resultJson.getString("desc")); @@ -130,7 +130,7 @@ public class RestfulStatement extends AbstractStatement { if (!SqlSyntaxValidator.isValidForExecuteUpdate(sql)) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_FOR_EXECUTE_UPDATE, "not a valid sql for executeUpdate: " + sql); - String result = HttpClientPoolUtil.execute(url, sql); + String result = HttpClientPoolUtil.execute(url, sql, this.conn.getToken()); JSONObject jsonObject = JSON.parseObject(result); if (jsonObject.getString("status").equals("error")) { throw TSDBError.createSQLException(jsonObject.getInteger("code"), jsonObject.getString("desc")); diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/HttpClientPoolUtil.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/HttpClientPoolUtil.java index 5e2440fd1d..b1c6dae6b3 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/HttpClientPoolUtil.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/HttpClientPoolUtil.java @@ -20,39 +20,29 @@ import java.nio.charset.Charset; public class HttpClientPoolUtil { - public static PoolingHttpClientConnectionManager cm = null; - public static CloseableHttpClient httpClient = null; - public static String token = "cm9vdDp0YW9zZGF0YQ=="; - /** - * 默认content 类型 - */ - private static final String DEFAULT_CONTENT_TYPE = "application/json"; - /** - * 默认请求超时时间30s - */ - private static final int DEFAULT_TIME_OUT = 15000; - private static final int count = 32; - private static final int totalCount = 1000; - private static final int Http_Default_Keep_Time = 15000; - /** - * 初始化连接池 - */ + private static final String DEFAULT_CONTENT_TYPE = "application/json"; + private static final String DEFAULT_TOKEN = "cm9vdDp0YW9zZGF0YQ=="; + private static final int DEFAULT_TIME_OUT = 15000; + private static final int DEFAULT_MAX_PER_ROUTE = 32; + private static final int DEFAULT_MAX_TOTAL = 1000; + private static final int DEFAULT_HTTP_KEEP_TIME = 15000; + + private static PoolingHttpClientConnectionManager connectionManager; + private static CloseableHttpClient httpClient; + private static synchronized void initPools() { if (httpClient == null) { - cm = new PoolingHttpClientConnectionManager(); - cm.setDefaultMaxPerRoute(count); - cm.setMaxTotal(totalCount); - httpClient = HttpClients.custom().setKeepAliveStrategy(defaultStrategy).setConnectionManager(cm).build(); + connectionManager = new PoolingHttpClientConnectionManager(); + connectionManager.setDefaultMaxPerRoute(DEFAULT_MAX_PER_ROUTE); + connectionManager.setMaxTotal(DEFAULT_MAX_TOTAL); + httpClient = HttpClients.custom().setKeepAliveStrategy(DEFAULT_KEEP_ALIVE_STRATEGY).setConnectionManager(connectionManager).build(); } } - /** - * Http connection keepAlive 设置 - */ - private static ConnectionKeepAliveStrategy defaultStrategy = (response, context) -> { + private static ConnectionKeepAliveStrategy DEFAULT_KEEP_ALIVE_STRATEGY = (response, context) -> { HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE)); - int keepTime = Http_Default_Keep_Time * 1000; + int keepTime = DEFAULT_HTTP_KEEP_TIME * 1000; while (it.hasNext()) { HeaderElement headerElement = it.nextElement(); String param = headerElement.getName(); @@ -76,7 +66,7 @@ public class HttpClientPoolUtil { * @param data 请求数据 * @return responseBody */ - public static String execute(String uri, String data) { + public static String execute(String uri, String data, String token) { long startTime = System.currentTimeMillis(); HttpEntity httpEntity = null; HttpEntityEnclosingRequestBase method = null; diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/BatchInsertTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/BatchInsertTest.java index 472da34980..e2541e8109 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/BatchInsertTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/BatchInsertTest.java @@ -28,9 +28,7 @@ public class BatchInsertTest { @Before public void before() { try { - Class.forName("com.taosdata.jdbc.TSDBDriver"); Properties properties = new Properties(); - properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, host); 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"); @@ -44,7 +42,7 @@ public class BatchInsertTest { String createTableSql = "create table " + stbName + "(ts timestamp, f1 int, f2 int, f3 int) tags(areaid int, loc binary(20))"; statement.executeUpdate(createTableSql); // create tables - for(int i = 0; i < numOfTables; i++) { + for (int i = 0; i < numOfTables; i++) { String loc = i % 2 == 0 ? "beijing" : "shanghai"; String createSubTalbesSql = "create table " + tablePrefix + i + " using " + stbName + " tags(" + i + ", '" + loc + "')"; statement.executeUpdate(createSubTalbesSql); diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/ConnectMultiTaosdByRestfulWithDifferentTokenTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/ConnectMultiTaosdByRestfulWithDifferentTokenTest.java new file mode 100644 index 0000000000..7f2d367dce --- /dev/null +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/ConnectMultiTaosdByRestfulWithDifferentTokenTest.java @@ -0,0 +1,59 @@ +package com.taosdata.jdbc.cases; + +import com.taosdata.jdbc.TSDBDriver; +import org.junit.Before; +import org.junit.Test; + +import java.sql.*; +import java.util.Properties; + +public class ConnectMultiTaosdByRestfulWithDifferentTokenTest { + + private static String host1 = "192.168.17.156"; + private static String user1 = "root"; + private static String password1 = "tqueue"; + private Connection conn1; + private static String host2 = "192.168.17.82"; + private static String user2 = "root"; + private static String password2 = "taosdata"; + private Connection conn2; + + @Test + public void test() { + //when + executeSelectStatus(conn1); + executeSelectStatus(conn2); + executeSelectStatus(conn1); + } + + private void executeSelectStatus(Connection connection) { + try (Statement stmt = connection.createStatement()) { + ResultSet rs = stmt.executeQuery("select server_status()"); + ResultSetMetaData meta = rs.getMetaData(); + while (rs.next()) { + for (int i = 1; i <= meta.getColumnCount(); i++) { + System.out.println(meta.getColumnLabel(i) + ": " + rs.getString(i)); + } + } + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @Before + public void before() { + 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"); + + String url1 = "jdbc:TAOS-RS://" + host1 + ":6041/?user=" + user1 + "&password=" + password1; + String url2 = "jdbc:TAOS-RS://" + host2 + ":6041/?user=" + user2 + "&password=" + password2; + try { + conn1 = DriverManager.getConnection(url1, properties); + conn2 = DriverManager.getConnection(url2, properties); + } catch (SQLException e) { + e.printStackTrace(); + } + } +} From 679762087951bbb8872ed9d0c23a2fa8e3a13979 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Tue, 15 Jun 2021 11:25:57 +0800 Subject: [PATCH 04/21] remove sub query --- src/inc/ttokendef.h | 2 + src/query/inc/sql.y | 3 +- src/query/src/sql.c | 1193 +++++++++++++++++++++---------------------- 3 files changed, 597 insertions(+), 601 deletions(-) diff --git a/src/inc/ttokendef.h b/src/inc/ttokendef.h index c7c4b5968b..e411ac6232 100644 --- a/src/inc/ttokendef.h +++ b/src/inc/ttokendef.h @@ -212,6 +212,8 @@ + + #define TK_SPACE 300 #define TK_COMMENT 301 #define TK_ILLEGAL 302 diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index 5a42b3a631..e0dad6616c 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -28,7 +28,7 @@ #include #include "qSqlparser.h" #include "tcmdtype.h" -#include "tstoken.h" +#include "ttoken.h" #include "ttokendef.h" #include "tutil.h" #include "tvariant.h" @@ -507,7 +507,6 @@ distinct(X) ::= . { X.n = 0;} // A complete FROM clause. %type from {SFromInfo*} from(A) ::= FROM tablelist(X). {A = X;} -from(A) ::= FROM LP union(Y) RP. {A = Y;} %type tablelist {SArray*} tablelist(A) ::= ids(X) cpxName(Y). { diff --git a/src/query/src/sql.c b/src/query/src/sql.c index 8f36638dc9..7213fc30c6 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -26,11 +26,11 @@ #include /************ Begin %include sections from the grammar ************************/ -#include -#include #include #include #include +#include +#include #include "qSqlparser.h" #include "tcmdtype.h" #include "ttoken.h" @@ -137,18 +137,18 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 315 -#define YYNRULE 269 -#define YYNRULE_WITH_ACTION 269 +#define YYNSTATE 313 +#define YYNRULE 268 +#define YYNRULE_WITH_ACTION 268 #define YYNTOKEN 187 -#define YY_MAX_SHIFT 314 -#define YY_MIN_SHIFTREDUCE 508 -#define YY_MAX_SHIFTREDUCE 776 -#define YY_ERROR_ACTION 777 -#define YY_ACCEPT_ACTION 778 -#define YY_NO_ACTION 779 -#define YY_MIN_REDUCE 780 -#define YY_MAX_REDUCE 1048 +#define YY_MAX_SHIFT 312 +#define YY_MIN_SHIFTREDUCE 505 +#define YY_MAX_SHIFTREDUCE 772 +#define YY_ERROR_ACTION 773 +#define YY_ACCEPT_ACTION 774 +#define YY_NO_ACTION 775 +#define YY_MIN_REDUCE 776 +#define YY_MAX_REDUCE 1043 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -215,76 +215,76 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (672) +#define YY_ACTTAB_COUNT (675) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 133, 555, 204, 312, 208, 140, 947, 17, 85, 556, - /* 10 */ 778, 314, 179, 47, 48, 140, 51, 52, 30, 181, - /* 20 */ 214, 41, 181, 50, 262, 55, 53, 57, 54, 1029, - /* 30 */ 926, 211, 1030, 46, 45, 185, 181, 44, 43, 42, - /* 40 */ 47, 48, 914, 51, 52, 210, 1030, 214, 41, 555, - /* 50 */ 50, 262, 55, 53, 57, 54, 938, 556, 1026, 205, - /* 60 */ 46, 45, 923, 247, 44, 43, 42, 48, 944, 51, - /* 70 */ 52, 242, 978, 214, 41, 555, 50, 262, 55, 53, - /* 80 */ 57, 54, 979, 556, 257, 278, 46, 45, 298, 225, - /* 90 */ 44, 43, 42, 509, 510, 511, 512, 513, 514, 515, - /* 100 */ 516, 517, 518, 519, 520, 521, 313, 634, 1025, 231, - /* 110 */ 70, 555, 30, 47, 48, 1024, 51, 52, 825, 556, - /* 120 */ 214, 41, 166, 50, 262, 55, 53, 57, 54, 44, - /* 130 */ 43, 42, 720, 46, 45, 288, 287, 44, 43, 42, - /* 140 */ 47, 49, 834, 51, 52, 198, 166, 214, 41, 234, - /* 150 */ 50, 262, 55, 53, 57, 54, 922, 238, 237, 227, - /* 160 */ 46, 45, 285, 284, 44, 43, 42, 23, 276, 307, - /* 170 */ 306, 275, 274, 273, 305, 272, 304, 303, 302, 271, - /* 180 */ 301, 300, 886, 140, 874, 875, 876, 877, 878, 879, - /* 190 */ 880, 881, 882, 883, 884, 885, 887, 888, 51, 52, - /* 200 */ 826, 219, 214, 41, 166, 50, 262, 55, 53, 57, - /* 210 */ 54, 223, 18, 82, 25, 46, 45, 1, 154, 44, - /* 220 */ 43, 42, 213, 735, 938, 722, 724, 926, 727, 190, - /* 230 */ 730, 226, 213, 735, 140, 191, 724, 912, 727, 206, - /* 240 */ 730, 118, 117, 189, 909, 910, 29, 913, 259, 74, - /* 250 */ 78, 726, 30, 729, 200, 201, 221, 36, 261, 199, - /* 260 */ 23, 723, 307, 306, 200, 201, 924, 305, 30, 304, - /* 270 */ 303, 302, 74, 301, 300, 894, 183, 308, 892, 893, - /* 280 */ 36, 224, 926, 895, 280, 897, 898, 896, 184, 899, - /* 290 */ 900, 920, 658, 217, 69, 655, 923, 656, 725, 657, - /* 300 */ 728, 79, 241, 926, 68, 55, 53, 57, 54, 218, - /* 310 */ 197, 212, 923, 46, 45, 30, 278, 44, 43, 42, - /* 320 */ 673, 103, 108, 228, 229, 56, 911, 97, 107, 113, - /* 330 */ 116, 106, 736, 220, 263, 56, 186, 110, 732, 30, - /* 340 */ 180, 30, 736, 5, 156, 30, 3, 167, 732, 33, - /* 350 */ 155, 92, 87, 91, 731, 6, 281, 701, 702, 923, - /* 360 */ 174, 170, 28, 733, 731, 268, 172, 169, 121, 120, - /* 370 */ 119, 46, 45, 105, 80, 44, 43, 42, 298, 662, - /* 380 */ 282, 663, 286, 923, 670, 923, 290, 71, 12, 923, - /* 390 */ 187, 24, 84, 188, 81, 311, 310, 126, 677, 243, - /* 400 */ 680, 659, 660, 31, 661, 686, 1040, 692, 245, 135, - /* 410 */ 734, 60, 693, 756, 737, 61, 20, 19, 19, 64, - /* 420 */ 644, 265, 646, 267, 31, 31, 60, 83, 645, 67, - /* 430 */ 739, 633, 60, 925, 96, 95, 194, 62, 195, 65, - /* 440 */ 193, 14, 13, 102, 101, 115, 114, 131, 129, 16, - /* 450 */ 15, 178, 192, 182, 989, 988, 215, 239, 985, 132, - /* 460 */ 984, 216, 289, 946, 39, 971, 954, 956, 134, 138, - /* 470 */ 970, 939, 246, 130, 921, 151, 919, 150, 152, 153, - /* 480 */ 248, 837, 270, 685, 890, 299, 104, 291, 148, 37, - /* 490 */ 145, 176, 936, 141, 34, 58, 207, 250, 255, 66, - /* 500 */ 63, 142, 279, 833, 1045, 260, 143, 258, 144, 256, - /* 510 */ 93, 1044, 1042, 254, 157, 146, 283, 1039, 99, 1038, - /* 520 */ 1036, 252, 158, 855, 35, 32, 38, 177, 249, 822, - /* 530 */ 109, 820, 111, 112, 818, 817, 230, 168, 815, 814, - /* 540 */ 813, 812, 811, 810, 171, 173, 807, 805, 803, 801, - /* 550 */ 799, 175, 40, 244, 72, 75, 251, 292, 972, 293, - /* 560 */ 294, 296, 295, 297, 309, 776, 202, 222, 269, 232, - /* 570 */ 233, 203, 775, 235, 88, 89, 236, 196, 774, 762, - /* 580 */ 761, 240, 245, 8, 73, 264, 209, 665, 687, 816, - /* 590 */ 165, 856, 161, 159, 160, 122, 162, 163, 123, 164, - /* 600 */ 809, 2, 76, 124, 125, 808, 800, 136, 137, 4, - /* 610 */ 690, 149, 147, 77, 253, 26, 694, 139, 902, 9, - /* 620 */ 10, 27, 738, 7, 11, 740, 21, 22, 266, 86, - /* 630 */ 597, 593, 84, 591, 590, 589, 586, 559, 277, 90, - /* 640 */ 94, 31, 636, 59, 635, 632, 581, 579, 571, 577, - /* 650 */ 573, 575, 569, 567, 98, 100, 600, 599, 598, 596, - /* 660 */ 595, 594, 592, 588, 587, 60, 557, 525, 523, 780, - /* 670 */ 127, 128, + /* 0 */ 132, 552, 203, 310, 206, 139, 943, 17, 84, 553, + /* 10 */ 774, 312, 178, 46, 47, 139, 50, 51, 29, 180, + /* 20 */ 212, 40, 180, 49, 260, 54, 52, 56, 53, 1024, + /* 30 */ 922, 209, 1025, 45, 44, 184, 180, 43, 42, 41, + /* 40 */ 46, 47, 910, 50, 51, 208, 1025, 212, 40, 552, + /* 50 */ 49, 260, 54, 52, 56, 53, 934, 553, 1021, 204, + /* 60 */ 45, 44, 919, 245, 43, 42, 41, 47, 940, 50, + /* 70 */ 51, 241, 973, 212, 40, 552, 49, 260, 54, 52, + /* 80 */ 56, 53, 974, 553, 255, 217, 45, 44, 276, 223, + /* 90 */ 43, 42, 41, 506, 507, 508, 509, 510, 511, 512, + /* 100 */ 513, 514, 515, 516, 517, 518, 311, 631, 1020, 229, + /* 110 */ 71, 922, 29, 46, 47, 1019, 50, 51, 821, 219, + /* 120 */ 212, 40, 165, 49, 260, 54, 52, 56, 53, 43, + /* 130 */ 42, 41, 716, 45, 44, 286, 285, 43, 42, 41, + /* 140 */ 46, 48, 296, 50, 51, 922, 908, 212, 40, 232, + /* 150 */ 49, 260, 54, 52, 56, 53, 918, 236, 235, 225, + /* 160 */ 45, 44, 283, 282, 43, 42, 41, 23, 274, 305, + /* 170 */ 304, 273, 272, 271, 303, 270, 302, 301, 300, 269, + /* 180 */ 299, 298, 882, 139, 870, 871, 872, 873, 874, 875, + /* 190 */ 876, 877, 878, 879, 880, 881, 883, 884, 50, 51, + /* 200 */ 830, 306, 212, 40, 165, 49, 260, 54, 52, 56, + /* 210 */ 53, 221, 18, 81, 916, 45, 44, 69, 197, 43, + /* 220 */ 42, 41, 211, 731, 139, 276, 720, 922, 723, 189, + /* 230 */ 726, 224, 211, 731, 104, 190, 720, 198, 723, 296, + /* 240 */ 726, 117, 116, 188, 905, 906, 28, 909, 257, 907, + /* 250 */ 77, 722, 29, 725, 199, 200, 218, 242, 259, 261, + /* 260 */ 23, 30, 305, 304, 199, 200, 920, 303, 29, 302, + /* 270 */ 301, 300, 70, 299, 298, 890, 3, 166, 888, 889, + /* 280 */ 35, 222, 182, 891, 278, 893, 894, 892, 79, 895, + /* 290 */ 896, 78, 655, 215, 183, 652, 919, 653, 721, 654, + /* 300 */ 724, 72, 239, 70, 67, 54, 52, 56, 53, 216, + /* 310 */ 196, 35, 919, 45, 44, 29, 822, 43, 42, 41, + /* 320 */ 165, 102, 107, 226, 227, 55, 670, 96, 106, 112, + /* 330 */ 115, 105, 732, 1, 153, 55, 185, 109, 728, 29, + /* 340 */ 179, 29, 732, 5, 155, 29, 697, 698, 728, 32, + /* 350 */ 154, 91, 86, 90, 727, 735, 279, 60, 667, 919, + /* 360 */ 173, 169, 718, 729, 727, 24, 171, 168, 120, 119, + /* 370 */ 118, 45, 44, 210, 682, 43, 42, 41, 134, 61, + /* 380 */ 280, 27, 284, 919, 266, 919, 288, 688, 12, 919, + /* 390 */ 186, 59, 83, 187, 80, 309, 308, 125, 719, 689, + /* 400 */ 63, 656, 752, 20, 674, 733, 19, 641, 263, 19, + /* 410 */ 730, 30, 30, 193, 643, 265, 194, 6, 59, 82, + /* 420 */ 64, 642, 192, 95, 94, 59, 14, 13, 114, 113, + /* 430 */ 101, 100, 66, 659, 630, 660, 177, 16, 15, 657, + /* 440 */ 191, 658, 130, 128, 181, 1035, 921, 237, 935, 984, + /* 450 */ 983, 213, 980, 979, 214, 287, 131, 942, 38, 966, + /* 460 */ 949, 951, 133, 244, 137, 965, 917, 129, 150, 149, + /* 470 */ 243, 246, 205, 915, 681, 297, 151, 152, 886, 148, + /* 480 */ 146, 144, 141, 932, 140, 833, 268, 57, 248, 253, + /* 490 */ 65, 36, 258, 62, 175, 33, 277, 829, 1040, 142, + /* 500 */ 256, 92, 1039, 143, 1037, 156, 254, 281, 1034, 98, + /* 510 */ 1033, 1031, 157, 851, 34, 31, 37, 176, 252, 818, + /* 520 */ 108, 250, 816, 110, 111, 814, 813, 228, 247, 167, + /* 530 */ 811, 810, 809, 808, 807, 806, 170, 172, 803, 801, + /* 540 */ 799, 797, 103, 795, 174, 39, 73, 74, 289, 249, + /* 550 */ 967, 290, 291, 292, 293, 294, 295, 201, 220, 267, + /* 560 */ 307, 772, 230, 231, 202, 87, 195, 88, 771, 233, + /* 570 */ 234, 770, 758, 757, 812, 238, 8, 68, 240, 805, + /* 580 */ 160, 121, 159, 852, 158, 161, 162, 164, 122, 163, + /* 590 */ 2, 123, 804, 4, 262, 124, 796, 662, 75, 683, + /* 600 */ 135, 207, 686, 76, 147, 145, 898, 136, 251, 9, + /* 610 */ 690, 138, 25, 10, 734, 26, 7, 11, 21, 736, + /* 620 */ 22, 85, 264, 594, 590, 83, 588, 587, 586, 583, + /* 630 */ 556, 275, 93, 89, 30, 633, 58, 632, 629, 578, + /* 640 */ 576, 97, 568, 574, 570, 572, 566, 564, 597, 99, + /* 650 */ 596, 595, 593, 592, 591, 589, 585, 584, 59, 554, + /* 660 */ 776, 522, 520, 775, 775, 126, 775, 775, 775, 775, + /* 670 */ 775, 775, 775, 775, 127, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 190, 1, 189, 190, 209, 190, 190, 251, 196, 9, @@ -295,66 +295,66 @@ static const YYCODETYPE yy_lookahead[] = { /* 50 */ 23, 24, 25, 26, 27, 28, 233, 9, 251, 231, /* 60 */ 33, 34, 234, 253, 37, 38, 39, 14, 252, 16, /* 70 */ 17, 248, 257, 20, 21, 1, 23, 24, 25, 26, - /* 80 */ 27, 28, 257, 9, 259, 79, 33, 34, 81, 67, + /* 80 */ 27, 28, 257, 9, 259, 209, 33, 34, 79, 67, /* 90 */ 37, 38, 39, 45, 46, 47, 48, 49, 50, 51, /* 100 */ 52, 53, 54, 55, 56, 57, 58, 5, 251, 61, - /* 110 */ 110, 1, 190, 13, 14, 251, 16, 17, 195, 9, + /* 110 */ 110, 235, 190, 13, 14, 251, 16, 17, 195, 209, /* 120 */ 20, 21, 199, 23, 24, 25, 26, 27, 28, 37, /* 130 */ 38, 39, 105, 33, 34, 33, 34, 37, 38, 39, - /* 140 */ 13, 14, 195, 16, 17, 251, 199, 20, 21, 135, + /* 140 */ 13, 14, 81, 16, 17, 235, 0, 20, 21, 135, /* 150 */ 23, 24, 25, 26, 27, 28, 234, 143, 144, 137, /* 160 */ 33, 34, 140, 141, 37, 38, 39, 88, 89, 90, /* 170 */ 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, /* 180 */ 101, 102, 208, 190, 210, 211, 212, 213, 214, 215, /* 190 */ 216, 217, 218, 219, 220, 221, 222, 223, 16, 17, /* 200 */ 195, 209, 20, 21, 199, 23, 24, 25, 26, 27, - /* 210 */ 28, 67, 44, 196, 104, 33, 34, 197, 198, 37, - /* 220 */ 38, 39, 1, 2, 233, 1, 5, 235, 7, 61, - /* 230 */ 9, 190, 1, 2, 190, 67, 5, 0, 7, 248, - /* 240 */ 9, 73, 74, 75, 227, 228, 229, 230, 255, 104, - /* 250 */ 257, 5, 190, 7, 33, 34, 209, 112, 37, 251, - /* 260 */ 88, 37, 90, 91, 33, 34, 225, 95, 190, 97, - /* 270 */ 98, 99, 104, 101, 102, 208, 251, 209, 211, 212, - /* 280 */ 112, 137, 235, 216, 140, 218, 219, 220, 251, 222, - /* 290 */ 223, 190, 2, 231, 196, 5, 234, 7, 5, 9, - /* 300 */ 7, 257, 134, 235, 136, 25, 26, 27, 28, 231, - /* 310 */ 142, 60, 234, 33, 34, 190, 79, 37, 38, 39, - /* 320 */ 37, 62, 63, 33, 34, 104, 228, 68, 69, 70, - /* 330 */ 71, 72, 111, 232, 15, 104, 251, 78, 117, 190, - /* 340 */ 251, 190, 111, 62, 63, 190, 193, 194, 117, 68, - /* 350 */ 69, 70, 71, 72, 133, 104, 231, 124, 125, 234, - /* 360 */ 62, 63, 104, 117, 133, 107, 68, 69, 70, 71, - /* 370 */ 72, 33, 34, 76, 236, 37, 38, 39, 81, 5, - /* 380 */ 231, 7, 231, 234, 109, 234, 231, 249, 104, 234, - /* 390 */ 251, 116, 108, 251, 110, 64, 65, 66, 115, 105, - /* 400 */ 105, 111, 5, 109, 7, 105, 235, 105, 113, 109, - /* 410 */ 117, 109, 105, 105, 105, 109, 109, 109, 109, 109, - /* 420 */ 105, 105, 105, 105, 109, 109, 109, 109, 105, 104, - /* 430 */ 111, 106, 109, 235, 138, 139, 251, 131, 251, 129, - /* 440 */ 251, 138, 139, 138, 139, 76, 77, 62, 63, 138, - /* 450 */ 139, 251, 251, 251, 226, 226, 226, 190, 226, 190, - /* 460 */ 226, 226, 226, 190, 250, 258, 190, 190, 190, 190, - /* 470 */ 258, 233, 233, 60, 233, 190, 190, 237, 190, 190, - /* 480 */ 254, 190, 190, 117, 224, 103, 87, 86, 239, 190, - /* 490 */ 242, 190, 247, 246, 190, 127, 254, 254, 254, 128, - /* 500 */ 130, 245, 190, 190, 190, 122, 244, 126, 243, 121, - /* 510 */ 190, 190, 190, 120, 190, 241, 190, 190, 190, 190, + /* 210 */ 28, 67, 44, 196, 190, 33, 34, 196, 251, 37, + /* 220 */ 38, 39, 1, 2, 190, 79, 5, 235, 7, 61, + /* 230 */ 9, 190, 1, 2, 76, 67, 5, 251, 7, 81, + /* 240 */ 9, 73, 74, 75, 227, 228, 229, 230, 255, 228, + /* 250 */ 257, 5, 190, 7, 33, 34, 232, 105, 37, 15, + /* 260 */ 88, 109, 90, 91, 33, 34, 225, 95, 190, 97, + /* 270 */ 98, 99, 104, 101, 102, 208, 193, 194, 211, 212, + /* 280 */ 112, 137, 251, 216, 140, 218, 219, 220, 236, 222, + /* 290 */ 223, 257, 2, 231, 251, 5, 234, 7, 5, 9, + /* 300 */ 7, 249, 134, 104, 136, 25, 26, 27, 28, 231, + /* 310 */ 142, 112, 234, 33, 34, 190, 195, 37, 38, 39, + /* 320 */ 199, 62, 63, 33, 34, 104, 37, 68, 69, 70, + /* 330 */ 71, 72, 111, 197, 198, 104, 251, 78, 117, 190, + /* 340 */ 251, 190, 111, 62, 63, 190, 124, 125, 117, 68, + /* 350 */ 69, 70, 71, 72, 133, 111, 231, 109, 109, 234, + /* 360 */ 62, 63, 1, 117, 133, 116, 68, 69, 70, 71, + /* 370 */ 72, 33, 34, 60, 105, 37, 38, 39, 109, 131, + /* 380 */ 231, 104, 231, 234, 107, 234, 231, 105, 104, 234, + /* 390 */ 251, 109, 108, 251, 110, 64, 65, 66, 37, 105, + /* 400 */ 109, 111, 105, 109, 115, 105, 109, 105, 105, 109, + /* 410 */ 117, 109, 109, 251, 105, 105, 251, 104, 109, 109, + /* 420 */ 129, 105, 251, 138, 139, 109, 138, 139, 76, 77, + /* 430 */ 138, 139, 104, 5, 106, 7, 251, 138, 139, 5, + /* 440 */ 251, 7, 62, 63, 251, 235, 235, 190, 233, 226, + /* 450 */ 226, 226, 226, 226, 226, 226, 190, 190, 250, 258, + /* 460 */ 190, 190, 190, 233, 190, 258, 233, 60, 190, 237, + /* 470 */ 191, 254, 254, 190, 117, 103, 190, 190, 224, 238, + /* 480 */ 240, 242, 245, 247, 246, 190, 190, 127, 254, 254, + /* 490 */ 128, 190, 122, 130, 190, 190, 190, 190, 190, 244, + /* 500 */ 126, 190, 190, 243, 190, 190, 121, 190, 190, 190, + /* 510 */ 190, 190, 190, 190, 190, 190, 190, 190, 120, 190, /* 520 */ 190, 119, 190, 190, 190, 190, 190, 190, 118, 190, /* 530 */ 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, - /* 540 */ 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, - /* 550 */ 190, 190, 132, 191, 191, 191, 191, 50, 191, 83, - /* 560 */ 85, 84, 54, 82, 79, 5, 191, 191, 191, 145, - /* 570 */ 5, 191, 5, 145, 196, 196, 5, 191, 5, 90, - /* 580 */ 89, 135, 113, 104, 114, 107, 1, 105, 105, 191, - /* 590 */ 200, 207, 201, 206, 205, 192, 204, 202, 192, 203, - /* 600 */ 191, 197, 109, 192, 192, 191, 191, 104, 109, 193, - /* 610 */ 105, 238, 240, 104, 104, 109, 105, 104, 224, 123, - /* 620 */ 123, 109, 105, 104, 104, 111, 104, 104, 107, 76, - /* 630 */ 9, 5, 108, 5, 5, 5, 5, 80, 15, 76, - /* 640 */ 139, 109, 5, 16, 5, 105, 5, 5, 5, 5, - /* 650 */ 5, 5, 5, 5, 139, 139, 5, 5, 5, 5, - /* 660 */ 5, 5, 5, 5, 5, 109, 80, 60, 59, 0, - /* 670 */ 21, 21, 262, 262, 262, 262, 262, 262, 262, 262, + /* 540 */ 190, 190, 87, 190, 190, 132, 191, 191, 86, 191, + /* 550 */ 191, 50, 83, 85, 54, 84, 82, 191, 191, 191, + /* 560 */ 79, 5, 145, 5, 191, 196, 191, 196, 5, 145, + /* 570 */ 5, 5, 90, 89, 191, 135, 104, 114, 113, 191, + /* 580 */ 201, 192, 205, 207, 206, 204, 202, 200, 192, 203, + /* 590 */ 197, 192, 191, 193, 107, 192, 191, 105, 109, 105, + /* 600 */ 104, 1, 105, 104, 239, 241, 224, 109, 104, 123, + /* 610 */ 105, 104, 109, 123, 105, 109, 104, 104, 104, 111, + /* 620 */ 104, 76, 107, 9, 5, 108, 5, 5, 5, 5, + /* 630 */ 80, 15, 139, 76, 109, 5, 16, 5, 105, 5, + /* 640 */ 5, 139, 5, 5, 5, 5, 5, 5, 5, 139, + /* 650 */ 5, 5, 5, 5, 5, 5, 5, 5, 109, 80, + /* 660 */ 0, 60, 59, 262, 262, 21, 262, 262, 262, 262, + /* 670 */ 262, 262, 262, 262, 21, 262, 262, 262, 262, 262, /* 680 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, /* 690 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, /* 700 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, @@ -372,101 +372,102 @@ static const YYCODETYPE yy_lookahead[] = { /* 820 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, /* 830 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, /* 840 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, - /* 850 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, + /* 850 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, + /* 860 */ 262, 262, }; -#define YY_SHIFT_COUNT (314) +#define YY_SHIFT_COUNT (312) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (669) +#define YY_SHIFT_MAX (660) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 168, 79, 79, 172, 172, 6, 221, 231, 74, 74, + /* 0 */ 168, 79, 79, 172, 172, 9, 221, 231, 74, 74, /* 10 */ 74, 74, 74, 74, 74, 74, 74, 0, 48, 231, - /* 20 */ 290, 290, 290, 290, 110, 145, 74, 74, 74, 237, - /* 30 */ 74, 74, 297, 6, 7, 7, 672, 672, 672, 231, + /* 20 */ 290, 290, 290, 290, 74, 74, 74, 74, 146, 74, + /* 30 */ 74, 158, 9, 61, 61, 675, 675, 675, 231, 231, /* 40 */ 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, - /* 50 */ 231, 231, 231, 231, 231, 231, 231, 231, 231, 290, - /* 60 */ 290, 102, 102, 102, 102, 102, 102, 102, 74, 74, - /* 70 */ 74, 283, 74, 145, 145, 74, 74, 74, 233, 233, - /* 80 */ 275, 145, 74, 74, 74, 74, 74, 74, 74, 74, + /* 50 */ 231, 231, 231, 231, 231, 231, 231, 231, 290, 290, + /* 60 */ 102, 102, 102, 102, 102, 102, 102, 74, 199, 74, + /* 70 */ 199, 74, 289, 74, 74, 74, 74, 222, 222, 249, + /* 80 */ 199, 74, 74, 74, 74, 74, 74, 74, 74, 74, /* 90 */ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, /* 100 */ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, /* 110 */ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, /* 120 */ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, - /* 130 */ 74, 74, 413, 413, 413, 366, 366, 366, 413, 366, - /* 140 */ 413, 371, 370, 368, 383, 381, 388, 393, 402, 410, - /* 150 */ 420, 413, 413, 413, 382, 6, 6, 413, 413, 399, - /* 160 */ 401, 507, 476, 475, 508, 477, 481, 382, 413, 485, - /* 170 */ 485, 413, 485, 413, 485, 413, 672, 672, 27, 100, - /* 180 */ 127, 100, 100, 53, 182, 280, 280, 280, 280, 259, - /* 190 */ 281, 298, 338, 338, 338, 338, 22, 14, 92, 92, - /* 200 */ 246, 293, 284, 144, 331, 294, 295, 300, 302, 307, - /* 210 */ 308, 309, 224, 251, 319, 306, 310, 315, 316, 317, - /* 220 */ 318, 323, 258, 296, 303, 305, 325, 311, 374, 397, - /* 230 */ 369, 385, 560, 424, 565, 567, 428, 571, 573, 489, - /* 240 */ 491, 446, 469, 478, 479, 470, 482, 493, 483, 503, - /* 250 */ 505, 499, 509, 585, 510, 511, 513, 506, 496, 512, - /* 260 */ 497, 517, 519, 514, 520, 478, 522, 521, 523, 524, - /* 270 */ 553, 621, 626, 628, 629, 630, 631, 557, 623, 563, - /* 280 */ 501, 532, 532, 627, 515, 516, 532, 637, 639, 540, - /* 290 */ 532, 641, 642, 643, 644, 645, 646, 647, 648, 651, - /* 300 */ 652, 653, 654, 655, 656, 657, 658, 659, 556, 586, - /* 310 */ 649, 650, 607, 609, 669, + /* 130 */ 74, 407, 407, 407, 357, 357, 357, 407, 357, 407, + /* 140 */ 362, 363, 360, 370, 374, 385, 398, 402, 410, 413, + /* 150 */ 407, 407, 407, 372, 9, 9, 407, 407, 455, 462, + /* 160 */ 501, 469, 468, 500, 471, 474, 372, 407, 481, 481, + /* 170 */ 407, 481, 407, 481, 407, 675, 675, 27, 100, 127, + /* 180 */ 100, 100, 53, 182, 280, 280, 280, 280, 259, 281, + /* 190 */ 298, 338, 338, 338, 338, 22, 14, 92, 92, 246, + /* 200 */ 293, 284, 144, 331, 152, 269, 282, 294, 297, 300, + /* 210 */ 361, 313, 244, 248, 291, 302, 303, 309, 310, 316, + /* 220 */ 277, 285, 288, 292, 328, 299, 428, 434, 352, 380, + /* 230 */ 556, 417, 558, 563, 424, 565, 566, 482, 484, 440, + /* 240 */ 463, 465, 487, 472, 492, 489, 494, 496, 497, 498, + /* 250 */ 499, 600, 504, 505, 507, 503, 486, 506, 490, 509, + /* 260 */ 512, 508, 513, 487, 514, 515, 516, 517, 545, 614, + /* 270 */ 619, 621, 622, 623, 624, 550, 616, 557, 493, 525, + /* 280 */ 525, 620, 502, 510, 525, 630, 632, 533, 525, 634, + /* 290 */ 635, 637, 638, 639, 640, 641, 642, 643, 645, 646, + /* 300 */ 647, 648, 649, 650, 651, 652, 549, 579, 644, 653, + /* 310 */ 601, 603, 660, }; -#define YY_REDUCE_COUNT (177) +#define YY_REDUCE_COUNT (176) #define YY_REDUCE_MIN (-244) -#define YY_REDUCE_MAX (416) +#define YY_REDUCE_MAX (405) static const short yy_reduce_ofst[] = { /* 0 */ -177, -26, -26, 67, 67, 17, -229, -215, -172, -175, /* 10 */ -7, 62, 78, 125, 149, 151, 155, -184, -187, -232, - /* 20 */ -205, -8, 47, 68, -190, -9, -185, 44, 101, -188, - /* 30 */ 41, -78, -77, 98, -53, 5, 138, 20, 153, -244, - /* 40 */ -239, -216, -193, -143, -136, -106, 8, 25, 37, 85, - /* 50 */ 89, 139, 142, 185, 187, 189, 200, 201, 202, 171, - /* 60 */ 198, 228, 229, 230, 232, 234, 235, 236, 267, 269, - /* 70 */ 273, 214, 276, 238, 239, 277, 278, 279, 207, 212, - /* 80 */ 240, 241, 285, 286, 288, 289, 291, 292, 299, 301, - /* 90 */ 304, 312, 313, 314, 320, 321, 322, 324, 326, 327, - /* 100 */ 328, 329, 330, 332, 333, 334, 335, 336, 337, 339, - /* 110 */ 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, - /* 120 */ 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, - /* 130 */ 360, 361, 362, 363, 364, 226, 242, 243, 365, 244, - /* 140 */ 367, 245, 247, 256, 262, 265, 248, 274, 372, 249, - /* 150 */ 373, 375, 376, 377, 260, 378, 379, 380, 386, 384, - /* 160 */ 387, 389, 391, 392, 395, 396, 390, 394, 398, 403, - /* 170 */ 406, 409, 411, 414, 412, 415, 404, 416, + /* 20 */ -205, -124, -90, -8, -190, -185, 34, 24, -188, 41, + /* 30 */ -78, -77, 21, 5, 121, 52, 136, 83, -244, -239, + /* 40 */ -216, -193, -143, -136, -33, -14, 31, 43, 85, 89, + /* 50 */ 139, 142, 162, 165, 171, 185, 189, 193, 210, 211, + /* 60 */ 223, 224, 225, 226, 227, 228, 229, 257, 215, 266, + /* 70 */ 230, 267, 208, 270, 271, 272, 274, 201, 207, 232, + /* 80 */ 233, 278, 283, 286, 287, 295, 296, 301, 304, 305, + /* 90 */ 306, 307, 308, 311, 312, 314, 315, 317, 318, 319, + /* 100 */ 320, 321, 322, 323, 324, 325, 326, 327, 329, 330, + /* 110 */ 332, 333, 334, 335, 336, 337, 339, 340, 341, 342, + /* 120 */ 343, 344, 345, 346, 347, 348, 349, 350, 351, 353, + /* 130 */ 354, 279, 355, 356, 217, 218, 234, 358, 235, 359, + /* 140 */ 236, 238, 237, 255, 260, 239, 364, 240, 365, 241, + /* 150 */ 366, 367, 368, 254, 369, 371, 373, 375, 376, 378, + /* 160 */ 377, 379, 381, 384, 386, 387, 382, 383, 389, 396, + /* 170 */ 388, 399, 401, 403, 405, 393, 400, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 777, 889, 835, 901, 823, 832, 1032, 1032, 777, 777, - /* 10 */ 777, 777, 777, 777, 777, 777, 777, 948, 796, 1032, - /* 20 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 832, - /* 30 */ 777, 777, 838, 832, 838, 838, 943, 873, 891, 777, - /* 40 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, - /* 50 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, - /* 60 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, - /* 70 */ 777, 950, 953, 777, 777, 955, 777, 777, 975, 975, - /* 80 */ 941, 777, 777, 777, 777, 777, 777, 777, 777, 777, - /* 90 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, - /* 100 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 821, - /* 110 */ 777, 819, 777, 777, 777, 777, 777, 777, 777, 777, - /* 120 */ 777, 777, 777, 777, 777, 777, 806, 777, 777, 777, - /* 130 */ 777, 777, 798, 798, 798, 777, 777, 777, 798, 777, - /* 140 */ 798, 982, 986, 980, 968, 976, 967, 963, 961, 960, - /* 150 */ 990, 798, 798, 798, 836, 832, 832, 798, 798, 854, - /* 160 */ 852, 850, 842, 848, 844, 846, 840, 824, 798, 830, - /* 170 */ 830, 798, 830, 798, 830, 798, 873, 891, 777, 991, - /* 180 */ 777, 1031, 981, 1021, 1020, 1027, 1019, 1018, 1017, 777, - /* 190 */ 777, 777, 1013, 1014, 1016, 1015, 777, 777, 1023, 1022, - /* 200 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, - /* 210 */ 777, 777, 777, 993, 777, 987, 983, 777, 777, 777, - /* 220 */ 777, 777, 777, 777, 777, 777, 903, 777, 777, 777, - /* 230 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, - /* 240 */ 777, 777, 940, 777, 777, 777, 777, 951, 777, 777, - /* 250 */ 777, 777, 777, 777, 777, 777, 777, 977, 777, 969, - /* 260 */ 777, 777, 777, 777, 777, 915, 777, 777, 777, 777, - /* 270 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, - /* 280 */ 777, 1043, 1041, 777, 777, 777, 1037, 777, 777, 777, - /* 290 */ 1035, 777, 777, 777, 777, 777, 777, 777, 777, 777, - /* 300 */ 777, 777, 777, 777, 777, 777, 777, 777, 857, 777, - /* 310 */ 804, 802, 777, 794, 777, + /* 0 */ 773, 885, 831, 897, 819, 828, 1027, 1027, 773, 773, + /* 10 */ 773, 773, 773, 773, 773, 773, 773, 944, 792, 1027, + /* 20 */ 773, 773, 773, 773, 773, 773, 773, 773, 828, 773, + /* 30 */ 773, 834, 828, 834, 834, 939, 869, 887, 773, 773, + /* 40 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773, + /* 50 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773, + /* 60 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773, + /* 70 */ 773, 773, 946, 948, 950, 773, 773, 970, 970, 937, + /* 80 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773, + /* 90 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773, + /* 100 */ 773, 773, 773, 773, 773, 773, 773, 773, 817, 773, + /* 110 */ 815, 773, 773, 773, 773, 773, 773, 773, 773, 773, + /* 120 */ 773, 773, 773, 773, 773, 802, 773, 773, 773, 773, + /* 130 */ 773, 794, 794, 794, 773, 773, 773, 794, 773, 794, + /* 140 */ 977, 981, 975, 963, 971, 962, 958, 956, 955, 985, + /* 150 */ 794, 794, 794, 832, 828, 828, 794, 794, 850, 848, + /* 160 */ 846, 838, 844, 840, 842, 836, 820, 794, 826, 826, + /* 170 */ 794, 826, 794, 826, 794, 869, 887, 773, 986, 773, + /* 180 */ 1026, 976, 1016, 1015, 1022, 1014, 1013, 1012, 773, 773, + /* 190 */ 773, 1008, 1009, 1011, 1010, 773, 773, 1018, 1017, 773, + /* 200 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773, + /* 210 */ 773, 988, 773, 982, 978, 773, 773, 773, 773, 773, + /* 220 */ 773, 773, 773, 773, 899, 773, 773, 773, 773, 773, + /* 230 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773, + /* 240 */ 773, 936, 773, 773, 773, 947, 773, 773, 773, 773, + /* 250 */ 773, 773, 773, 773, 773, 972, 773, 964, 773, 773, + /* 260 */ 773, 773, 773, 911, 773, 773, 773, 773, 773, 773, + /* 270 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 1038, + /* 280 */ 1036, 773, 773, 773, 1032, 773, 773, 773, 1030, 773, + /* 290 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773, + /* 300 */ 773, 773, 773, 773, 773, 773, 853, 773, 800, 798, + /* 310 */ 773, 790, 773, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1201,103 +1202,102 @@ static const char *const yyRuleName[] = { /* 169 */ "distinct ::= DISTINCT", /* 170 */ "distinct ::=", /* 171 */ "from ::= FROM tablelist", - /* 172 */ "from ::= FROM LP union RP", - /* 173 */ "tablelist ::= ids cpxName", - /* 174 */ "tablelist ::= ids cpxName ids", - /* 175 */ "tablelist ::= tablelist COMMA ids cpxName", - /* 176 */ "tablelist ::= tablelist COMMA ids cpxName ids", - /* 177 */ "tmvar ::= VARIABLE", - /* 178 */ "interval_opt ::= INTERVAL LP tmvar RP", - /* 179 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP", - /* 180 */ "interval_opt ::=", - /* 181 */ "session_option ::=", - /* 182 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", - /* 183 */ "fill_opt ::=", - /* 184 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", - /* 185 */ "fill_opt ::= FILL LP ID RP", - /* 186 */ "sliding_opt ::= SLIDING LP tmvar RP", - /* 187 */ "sliding_opt ::=", - /* 188 */ "orderby_opt ::=", - /* 189 */ "orderby_opt ::= ORDER BY sortlist", - /* 190 */ "sortlist ::= sortlist COMMA item sortorder", - /* 191 */ "sortlist ::= item sortorder", - /* 192 */ "item ::= ids cpxName", - /* 193 */ "sortorder ::= ASC", - /* 194 */ "sortorder ::= DESC", - /* 195 */ "sortorder ::=", - /* 196 */ "groupby_opt ::=", - /* 197 */ "groupby_opt ::= GROUP BY grouplist", - /* 198 */ "grouplist ::= grouplist COMMA item", - /* 199 */ "grouplist ::= item", - /* 200 */ "having_opt ::=", - /* 201 */ "having_opt ::= HAVING expr", - /* 202 */ "limit_opt ::=", - /* 203 */ "limit_opt ::= LIMIT signed", - /* 204 */ "limit_opt ::= LIMIT signed OFFSET signed", - /* 205 */ "limit_opt ::= LIMIT signed COMMA signed", - /* 206 */ "slimit_opt ::=", - /* 207 */ "slimit_opt ::= SLIMIT signed", - /* 208 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", - /* 209 */ "slimit_opt ::= SLIMIT signed COMMA signed", - /* 210 */ "where_opt ::=", - /* 211 */ "where_opt ::= WHERE expr", - /* 212 */ "expr ::= LP expr RP", - /* 213 */ "expr ::= ID", - /* 214 */ "expr ::= ID DOT ID", - /* 215 */ "expr ::= ID DOT STAR", - /* 216 */ "expr ::= INTEGER", - /* 217 */ "expr ::= MINUS INTEGER", - /* 218 */ "expr ::= PLUS INTEGER", - /* 219 */ "expr ::= FLOAT", - /* 220 */ "expr ::= MINUS FLOAT", - /* 221 */ "expr ::= PLUS FLOAT", - /* 222 */ "expr ::= STRING", - /* 223 */ "expr ::= NOW", - /* 224 */ "expr ::= VARIABLE", - /* 225 */ "expr ::= PLUS VARIABLE", - /* 226 */ "expr ::= MINUS VARIABLE", - /* 227 */ "expr ::= BOOL", - /* 228 */ "expr ::= NULL", - /* 229 */ "expr ::= ID LP exprlist RP", - /* 230 */ "expr ::= ID LP STAR RP", - /* 231 */ "expr ::= expr IS NULL", - /* 232 */ "expr ::= expr IS NOT NULL", - /* 233 */ "expr ::= expr LT expr", - /* 234 */ "expr ::= expr GT expr", - /* 235 */ "expr ::= expr LE expr", - /* 236 */ "expr ::= expr GE expr", - /* 237 */ "expr ::= expr NE expr", - /* 238 */ "expr ::= expr EQ expr", - /* 239 */ "expr ::= expr BETWEEN expr AND expr", - /* 240 */ "expr ::= expr AND expr", - /* 241 */ "expr ::= expr OR expr", - /* 242 */ "expr ::= expr PLUS expr", - /* 243 */ "expr ::= expr MINUS expr", - /* 244 */ "expr ::= expr STAR expr", - /* 245 */ "expr ::= expr SLASH expr", - /* 246 */ "expr ::= expr REM expr", - /* 247 */ "expr ::= expr LIKE expr", - /* 248 */ "expr ::= expr IN LP exprlist RP", - /* 249 */ "exprlist ::= exprlist COMMA expritem", - /* 250 */ "exprlist ::= expritem", - /* 251 */ "expritem ::= expr", - /* 252 */ "expritem ::=", - /* 253 */ "cmd ::= RESET QUERY CACHE", - /* 254 */ "cmd ::= SYNCDB ids REPLICA", - /* 255 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", - /* 256 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", - /* 257 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", - /* 258 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", - /* 259 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", - /* 260 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", - /* 261 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", - /* 262 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", - /* 263 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", - /* 264 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", - /* 265 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", - /* 266 */ "cmd ::= KILL CONNECTION INTEGER", - /* 267 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", - /* 268 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", + /* 172 */ "tablelist ::= ids cpxName", + /* 173 */ "tablelist ::= ids cpxName ids", + /* 174 */ "tablelist ::= tablelist COMMA ids cpxName", + /* 175 */ "tablelist ::= tablelist COMMA ids cpxName ids", + /* 176 */ "tmvar ::= VARIABLE", + /* 177 */ "interval_opt ::= INTERVAL LP tmvar RP", + /* 178 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP", + /* 179 */ "interval_opt ::=", + /* 180 */ "session_option ::=", + /* 181 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", + /* 182 */ "fill_opt ::=", + /* 183 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", + /* 184 */ "fill_opt ::= FILL LP ID RP", + /* 185 */ "sliding_opt ::= SLIDING LP tmvar RP", + /* 186 */ "sliding_opt ::=", + /* 187 */ "orderby_opt ::=", + /* 188 */ "orderby_opt ::= ORDER BY sortlist", + /* 189 */ "sortlist ::= sortlist COMMA item sortorder", + /* 190 */ "sortlist ::= item sortorder", + /* 191 */ "item ::= ids cpxName", + /* 192 */ "sortorder ::= ASC", + /* 193 */ "sortorder ::= DESC", + /* 194 */ "sortorder ::=", + /* 195 */ "groupby_opt ::=", + /* 196 */ "groupby_opt ::= GROUP BY grouplist", + /* 197 */ "grouplist ::= grouplist COMMA item", + /* 198 */ "grouplist ::= item", + /* 199 */ "having_opt ::=", + /* 200 */ "having_opt ::= HAVING expr", + /* 201 */ "limit_opt ::=", + /* 202 */ "limit_opt ::= LIMIT signed", + /* 203 */ "limit_opt ::= LIMIT signed OFFSET signed", + /* 204 */ "limit_opt ::= LIMIT signed COMMA signed", + /* 205 */ "slimit_opt ::=", + /* 206 */ "slimit_opt ::= SLIMIT signed", + /* 207 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", + /* 208 */ "slimit_opt ::= SLIMIT signed COMMA signed", + /* 209 */ "where_opt ::=", + /* 210 */ "where_opt ::= WHERE expr", + /* 211 */ "expr ::= LP expr RP", + /* 212 */ "expr ::= ID", + /* 213 */ "expr ::= ID DOT ID", + /* 214 */ "expr ::= ID DOT STAR", + /* 215 */ "expr ::= INTEGER", + /* 216 */ "expr ::= MINUS INTEGER", + /* 217 */ "expr ::= PLUS INTEGER", + /* 218 */ "expr ::= FLOAT", + /* 219 */ "expr ::= MINUS FLOAT", + /* 220 */ "expr ::= PLUS FLOAT", + /* 221 */ "expr ::= STRING", + /* 222 */ "expr ::= NOW", + /* 223 */ "expr ::= VARIABLE", + /* 224 */ "expr ::= PLUS VARIABLE", + /* 225 */ "expr ::= MINUS VARIABLE", + /* 226 */ "expr ::= BOOL", + /* 227 */ "expr ::= NULL", + /* 228 */ "expr ::= ID LP exprlist RP", + /* 229 */ "expr ::= ID LP STAR RP", + /* 230 */ "expr ::= expr IS NULL", + /* 231 */ "expr ::= expr IS NOT NULL", + /* 232 */ "expr ::= expr LT expr", + /* 233 */ "expr ::= expr GT expr", + /* 234 */ "expr ::= expr LE expr", + /* 235 */ "expr ::= expr GE expr", + /* 236 */ "expr ::= expr NE expr", + /* 237 */ "expr ::= expr EQ expr", + /* 238 */ "expr ::= expr BETWEEN expr AND expr", + /* 239 */ "expr ::= expr AND expr", + /* 240 */ "expr ::= expr OR expr", + /* 241 */ "expr ::= expr PLUS expr", + /* 242 */ "expr ::= expr MINUS expr", + /* 243 */ "expr ::= expr STAR expr", + /* 244 */ "expr ::= expr SLASH expr", + /* 245 */ "expr ::= expr REM expr", + /* 246 */ "expr ::= expr LIKE expr", + /* 247 */ "expr ::= expr IN LP exprlist RP", + /* 248 */ "exprlist ::= exprlist COMMA expritem", + /* 249 */ "exprlist ::= expritem", + /* 250 */ "expritem ::= expr", + /* 251 */ "expritem ::=", + /* 252 */ "cmd ::= RESET QUERY CACHE", + /* 253 */ "cmd ::= SYNCDB ids REPLICA", + /* 254 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", + /* 255 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", + /* 256 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", + /* 257 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", + /* 258 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", + /* 259 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", + /* 260 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", + /* 261 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", + /* 262 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", + /* 263 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", + /* 264 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", + /* 265 */ "cmd ::= KILL CONNECTION INTEGER", + /* 266 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", + /* 267 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", }; #endif /* NDEBUG */ @@ -1929,103 +1929,102 @@ static const YYCODETYPE yyRuleInfoLhs[] = { 250, /* (169) distinct ::= DISTINCT */ 250, /* (170) distinct ::= */ 237, /* (171) from ::= FROM tablelist */ - 237, /* (172) from ::= FROM LP union RP */ - 253, /* (173) tablelist ::= ids cpxName */ - 253, /* (174) tablelist ::= ids cpxName ids */ - 253, /* (175) tablelist ::= tablelist COMMA ids cpxName */ - 253, /* (176) tablelist ::= tablelist COMMA ids cpxName ids */ - 254, /* (177) tmvar ::= VARIABLE */ - 239, /* (178) interval_opt ::= INTERVAL LP tmvar RP */ - 239, /* (179) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ - 239, /* (180) interval_opt ::= */ - 240, /* (181) session_option ::= */ - 240, /* (182) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ - 241, /* (183) fill_opt ::= */ - 241, /* (184) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - 241, /* (185) fill_opt ::= FILL LP ID RP */ - 242, /* (186) sliding_opt ::= SLIDING LP tmvar RP */ - 242, /* (187) sliding_opt ::= */ - 244, /* (188) orderby_opt ::= */ - 244, /* (189) orderby_opt ::= ORDER BY sortlist */ - 255, /* (190) sortlist ::= sortlist COMMA item sortorder */ - 255, /* (191) sortlist ::= item sortorder */ - 257, /* (192) item ::= ids cpxName */ - 258, /* (193) sortorder ::= ASC */ - 258, /* (194) sortorder ::= DESC */ - 258, /* (195) sortorder ::= */ - 243, /* (196) groupby_opt ::= */ - 243, /* (197) groupby_opt ::= GROUP BY grouplist */ - 259, /* (198) grouplist ::= grouplist COMMA item */ - 259, /* (199) grouplist ::= item */ - 245, /* (200) having_opt ::= */ - 245, /* (201) having_opt ::= HAVING expr */ - 247, /* (202) limit_opt ::= */ - 247, /* (203) limit_opt ::= LIMIT signed */ - 247, /* (204) limit_opt ::= LIMIT signed OFFSET signed */ - 247, /* (205) limit_opt ::= LIMIT signed COMMA signed */ - 246, /* (206) slimit_opt ::= */ - 246, /* (207) slimit_opt ::= SLIMIT signed */ - 246, /* (208) slimit_opt ::= SLIMIT signed SOFFSET signed */ - 246, /* (209) slimit_opt ::= SLIMIT signed COMMA signed */ - 238, /* (210) where_opt ::= */ - 238, /* (211) where_opt ::= WHERE expr */ - 251, /* (212) expr ::= LP expr RP */ - 251, /* (213) expr ::= ID */ - 251, /* (214) expr ::= ID DOT ID */ - 251, /* (215) expr ::= ID DOT STAR */ - 251, /* (216) expr ::= INTEGER */ - 251, /* (217) expr ::= MINUS INTEGER */ - 251, /* (218) expr ::= PLUS INTEGER */ - 251, /* (219) expr ::= FLOAT */ - 251, /* (220) expr ::= MINUS FLOAT */ - 251, /* (221) expr ::= PLUS FLOAT */ - 251, /* (222) expr ::= STRING */ - 251, /* (223) expr ::= NOW */ - 251, /* (224) expr ::= VARIABLE */ - 251, /* (225) expr ::= PLUS VARIABLE */ - 251, /* (226) expr ::= MINUS VARIABLE */ - 251, /* (227) expr ::= BOOL */ - 251, /* (228) expr ::= NULL */ - 251, /* (229) expr ::= ID LP exprlist RP */ - 251, /* (230) expr ::= ID LP STAR RP */ - 251, /* (231) expr ::= expr IS NULL */ - 251, /* (232) expr ::= expr IS NOT NULL */ - 251, /* (233) expr ::= expr LT expr */ - 251, /* (234) expr ::= expr GT expr */ - 251, /* (235) expr ::= expr LE expr */ - 251, /* (236) expr ::= expr GE expr */ - 251, /* (237) expr ::= expr NE expr */ - 251, /* (238) expr ::= expr EQ expr */ - 251, /* (239) expr ::= expr BETWEEN expr AND expr */ - 251, /* (240) expr ::= expr AND expr */ - 251, /* (241) expr ::= expr OR expr */ - 251, /* (242) expr ::= expr PLUS expr */ - 251, /* (243) expr ::= expr MINUS expr */ - 251, /* (244) expr ::= expr STAR expr */ - 251, /* (245) expr ::= expr SLASH expr */ - 251, /* (246) expr ::= expr REM expr */ - 251, /* (247) expr ::= expr LIKE expr */ - 251, /* (248) expr ::= expr IN LP exprlist RP */ - 260, /* (249) exprlist ::= exprlist COMMA expritem */ - 260, /* (250) exprlist ::= expritem */ - 261, /* (251) expritem ::= expr */ - 261, /* (252) expritem ::= */ - 188, /* (253) cmd ::= RESET QUERY CACHE */ - 188, /* (254) cmd ::= SYNCDB ids REPLICA */ - 188, /* (255) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - 188, /* (256) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - 188, /* (257) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - 188, /* (258) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - 188, /* (259) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - 188, /* (260) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - 188, /* (261) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - 188, /* (262) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - 188, /* (263) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - 188, /* (264) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - 188, /* (265) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - 188, /* (266) cmd ::= KILL CONNECTION INTEGER */ - 188, /* (267) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - 188, /* (268) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + 253, /* (172) tablelist ::= ids cpxName */ + 253, /* (173) tablelist ::= ids cpxName ids */ + 253, /* (174) tablelist ::= tablelist COMMA ids cpxName */ + 253, /* (175) tablelist ::= tablelist COMMA ids cpxName ids */ + 254, /* (176) tmvar ::= VARIABLE */ + 239, /* (177) interval_opt ::= INTERVAL LP tmvar RP */ + 239, /* (178) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ + 239, /* (179) interval_opt ::= */ + 240, /* (180) session_option ::= */ + 240, /* (181) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + 241, /* (182) fill_opt ::= */ + 241, /* (183) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + 241, /* (184) fill_opt ::= FILL LP ID RP */ + 242, /* (185) sliding_opt ::= SLIDING LP tmvar RP */ + 242, /* (186) sliding_opt ::= */ + 244, /* (187) orderby_opt ::= */ + 244, /* (188) orderby_opt ::= ORDER BY sortlist */ + 255, /* (189) sortlist ::= sortlist COMMA item sortorder */ + 255, /* (190) sortlist ::= item sortorder */ + 257, /* (191) item ::= ids cpxName */ + 258, /* (192) sortorder ::= ASC */ + 258, /* (193) sortorder ::= DESC */ + 258, /* (194) sortorder ::= */ + 243, /* (195) groupby_opt ::= */ + 243, /* (196) groupby_opt ::= GROUP BY grouplist */ + 259, /* (197) grouplist ::= grouplist COMMA item */ + 259, /* (198) grouplist ::= item */ + 245, /* (199) having_opt ::= */ + 245, /* (200) having_opt ::= HAVING expr */ + 247, /* (201) limit_opt ::= */ + 247, /* (202) limit_opt ::= LIMIT signed */ + 247, /* (203) limit_opt ::= LIMIT signed OFFSET signed */ + 247, /* (204) limit_opt ::= LIMIT signed COMMA signed */ + 246, /* (205) slimit_opt ::= */ + 246, /* (206) slimit_opt ::= SLIMIT signed */ + 246, /* (207) slimit_opt ::= SLIMIT signed SOFFSET signed */ + 246, /* (208) slimit_opt ::= SLIMIT signed COMMA signed */ + 238, /* (209) where_opt ::= */ + 238, /* (210) where_opt ::= WHERE expr */ + 251, /* (211) expr ::= LP expr RP */ + 251, /* (212) expr ::= ID */ + 251, /* (213) expr ::= ID DOT ID */ + 251, /* (214) expr ::= ID DOT STAR */ + 251, /* (215) expr ::= INTEGER */ + 251, /* (216) expr ::= MINUS INTEGER */ + 251, /* (217) expr ::= PLUS INTEGER */ + 251, /* (218) expr ::= FLOAT */ + 251, /* (219) expr ::= MINUS FLOAT */ + 251, /* (220) expr ::= PLUS FLOAT */ + 251, /* (221) expr ::= STRING */ + 251, /* (222) expr ::= NOW */ + 251, /* (223) expr ::= VARIABLE */ + 251, /* (224) expr ::= PLUS VARIABLE */ + 251, /* (225) expr ::= MINUS VARIABLE */ + 251, /* (226) expr ::= BOOL */ + 251, /* (227) expr ::= NULL */ + 251, /* (228) expr ::= ID LP exprlist RP */ + 251, /* (229) expr ::= ID LP STAR RP */ + 251, /* (230) expr ::= expr IS NULL */ + 251, /* (231) expr ::= expr IS NOT NULL */ + 251, /* (232) expr ::= expr LT expr */ + 251, /* (233) expr ::= expr GT expr */ + 251, /* (234) expr ::= expr LE expr */ + 251, /* (235) expr ::= expr GE expr */ + 251, /* (236) expr ::= expr NE expr */ + 251, /* (237) expr ::= expr EQ expr */ + 251, /* (238) expr ::= expr BETWEEN expr AND expr */ + 251, /* (239) expr ::= expr AND expr */ + 251, /* (240) expr ::= expr OR expr */ + 251, /* (241) expr ::= expr PLUS expr */ + 251, /* (242) expr ::= expr MINUS expr */ + 251, /* (243) expr ::= expr STAR expr */ + 251, /* (244) expr ::= expr SLASH expr */ + 251, /* (245) expr ::= expr REM expr */ + 251, /* (246) expr ::= expr LIKE expr */ + 251, /* (247) expr ::= expr IN LP exprlist RP */ + 260, /* (248) exprlist ::= exprlist COMMA expritem */ + 260, /* (249) exprlist ::= expritem */ + 261, /* (250) expritem ::= expr */ + 261, /* (251) expritem ::= */ + 188, /* (252) cmd ::= RESET QUERY CACHE */ + 188, /* (253) cmd ::= SYNCDB ids REPLICA */ + 188, /* (254) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + 188, /* (255) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + 188, /* (256) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + 188, /* (257) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + 188, /* (258) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + 188, /* (259) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + 188, /* (260) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + 188, /* (261) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + 188, /* (262) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + 188, /* (263) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + 188, /* (264) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + 188, /* (265) cmd ::= KILL CONNECTION INTEGER */ + 188, /* (266) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + 188, /* (267) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number @@ -2203,103 +2202,102 @@ static const signed char yyRuleInfoNRhs[] = { -1, /* (169) distinct ::= DISTINCT */ 0, /* (170) distinct ::= */ -2, /* (171) from ::= FROM tablelist */ - -4, /* (172) from ::= FROM LP union RP */ - -2, /* (173) tablelist ::= ids cpxName */ - -3, /* (174) tablelist ::= ids cpxName ids */ - -4, /* (175) tablelist ::= tablelist COMMA ids cpxName */ - -5, /* (176) tablelist ::= tablelist COMMA ids cpxName ids */ - -1, /* (177) tmvar ::= VARIABLE */ - -4, /* (178) interval_opt ::= INTERVAL LP tmvar RP */ - -6, /* (179) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ - 0, /* (180) interval_opt ::= */ - 0, /* (181) session_option ::= */ - -7, /* (182) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ - 0, /* (183) fill_opt ::= */ - -6, /* (184) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - -4, /* (185) fill_opt ::= FILL LP ID RP */ - -4, /* (186) sliding_opt ::= SLIDING LP tmvar RP */ - 0, /* (187) sliding_opt ::= */ - 0, /* (188) orderby_opt ::= */ - -3, /* (189) orderby_opt ::= ORDER BY sortlist */ - -4, /* (190) sortlist ::= sortlist COMMA item sortorder */ - -2, /* (191) sortlist ::= item sortorder */ - -2, /* (192) item ::= ids cpxName */ - -1, /* (193) sortorder ::= ASC */ - -1, /* (194) sortorder ::= DESC */ - 0, /* (195) sortorder ::= */ - 0, /* (196) groupby_opt ::= */ - -3, /* (197) groupby_opt ::= GROUP BY grouplist */ - -3, /* (198) grouplist ::= grouplist COMMA item */ - -1, /* (199) grouplist ::= item */ - 0, /* (200) having_opt ::= */ - -2, /* (201) having_opt ::= HAVING expr */ - 0, /* (202) limit_opt ::= */ - -2, /* (203) limit_opt ::= LIMIT signed */ - -4, /* (204) limit_opt ::= LIMIT signed OFFSET signed */ - -4, /* (205) limit_opt ::= LIMIT signed COMMA signed */ - 0, /* (206) slimit_opt ::= */ - -2, /* (207) slimit_opt ::= SLIMIT signed */ - -4, /* (208) slimit_opt ::= SLIMIT signed SOFFSET signed */ - -4, /* (209) slimit_opt ::= SLIMIT signed COMMA signed */ - 0, /* (210) where_opt ::= */ - -2, /* (211) where_opt ::= WHERE expr */ - -3, /* (212) expr ::= LP expr RP */ - -1, /* (213) expr ::= ID */ - -3, /* (214) expr ::= ID DOT ID */ - -3, /* (215) expr ::= ID DOT STAR */ - -1, /* (216) expr ::= INTEGER */ - -2, /* (217) expr ::= MINUS INTEGER */ - -2, /* (218) expr ::= PLUS INTEGER */ - -1, /* (219) expr ::= FLOAT */ - -2, /* (220) expr ::= MINUS FLOAT */ - -2, /* (221) expr ::= PLUS FLOAT */ - -1, /* (222) expr ::= STRING */ - -1, /* (223) expr ::= NOW */ - -1, /* (224) expr ::= VARIABLE */ - -2, /* (225) expr ::= PLUS VARIABLE */ - -2, /* (226) expr ::= MINUS VARIABLE */ - -1, /* (227) expr ::= BOOL */ - -1, /* (228) expr ::= NULL */ - -4, /* (229) expr ::= ID LP exprlist RP */ - -4, /* (230) expr ::= ID LP STAR RP */ - -3, /* (231) expr ::= expr IS NULL */ - -4, /* (232) expr ::= expr IS NOT NULL */ - -3, /* (233) expr ::= expr LT expr */ - -3, /* (234) expr ::= expr GT expr */ - -3, /* (235) expr ::= expr LE expr */ - -3, /* (236) expr ::= expr GE expr */ - -3, /* (237) expr ::= expr NE expr */ - -3, /* (238) expr ::= expr EQ expr */ - -5, /* (239) expr ::= expr BETWEEN expr AND expr */ - -3, /* (240) expr ::= expr AND expr */ - -3, /* (241) expr ::= expr OR expr */ - -3, /* (242) expr ::= expr PLUS expr */ - -3, /* (243) expr ::= expr MINUS expr */ - -3, /* (244) expr ::= expr STAR expr */ - -3, /* (245) expr ::= expr SLASH expr */ - -3, /* (246) expr ::= expr REM expr */ - -3, /* (247) expr ::= expr LIKE expr */ - -5, /* (248) expr ::= expr IN LP exprlist RP */ - -3, /* (249) exprlist ::= exprlist COMMA expritem */ - -1, /* (250) exprlist ::= expritem */ - -1, /* (251) expritem ::= expr */ - 0, /* (252) expritem ::= */ - -3, /* (253) cmd ::= RESET QUERY CACHE */ - -3, /* (254) cmd ::= SYNCDB ids REPLICA */ - -7, /* (255) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - -7, /* (256) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - -7, /* (257) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - -7, /* (258) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - -8, /* (259) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - -9, /* (260) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - -7, /* (261) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - -7, /* (262) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - -7, /* (263) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - -7, /* (264) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - -8, /* (265) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - -3, /* (266) cmd ::= KILL CONNECTION INTEGER */ - -5, /* (267) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - -5, /* (268) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + -2, /* (172) tablelist ::= ids cpxName */ + -3, /* (173) tablelist ::= ids cpxName ids */ + -4, /* (174) tablelist ::= tablelist COMMA ids cpxName */ + -5, /* (175) tablelist ::= tablelist COMMA ids cpxName ids */ + -1, /* (176) tmvar ::= VARIABLE */ + -4, /* (177) interval_opt ::= INTERVAL LP tmvar RP */ + -6, /* (178) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ + 0, /* (179) interval_opt ::= */ + 0, /* (180) session_option ::= */ + -7, /* (181) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + 0, /* (182) fill_opt ::= */ + -6, /* (183) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + -4, /* (184) fill_opt ::= FILL LP ID RP */ + -4, /* (185) sliding_opt ::= SLIDING LP tmvar RP */ + 0, /* (186) sliding_opt ::= */ + 0, /* (187) orderby_opt ::= */ + -3, /* (188) orderby_opt ::= ORDER BY sortlist */ + -4, /* (189) sortlist ::= sortlist COMMA item sortorder */ + -2, /* (190) sortlist ::= item sortorder */ + -2, /* (191) item ::= ids cpxName */ + -1, /* (192) sortorder ::= ASC */ + -1, /* (193) sortorder ::= DESC */ + 0, /* (194) sortorder ::= */ + 0, /* (195) groupby_opt ::= */ + -3, /* (196) groupby_opt ::= GROUP BY grouplist */ + -3, /* (197) grouplist ::= grouplist COMMA item */ + -1, /* (198) grouplist ::= item */ + 0, /* (199) having_opt ::= */ + -2, /* (200) having_opt ::= HAVING expr */ + 0, /* (201) limit_opt ::= */ + -2, /* (202) limit_opt ::= LIMIT signed */ + -4, /* (203) limit_opt ::= LIMIT signed OFFSET signed */ + -4, /* (204) limit_opt ::= LIMIT signed COMMA signed */ + 0, /* (205) slimit_opt ::= */ + -2, /* (206) slimit_opt ::= SLIMIT signed */ + -4, /* (207) slimit_opt ::= SLIMIT signed SOFFSET signed */ + -4, /* (208) slimit_opt ::= SLIMIT signed COMMA signed */ + 0, /* (209) where_opt ::= */ + -2, /* (210) where_opt ::= WHERE expr */ + -3, /* (211) expr ::= LP expr RP */ + -1, /* (212) expr ::= ID */ + -3, /* (213) expr ::= ID DOT ID */ + -3, /* (214) expr ::= ID DOT STAR */ + -1, /* (215) expr ::= INTEGER */ + -2, /* (216) expr ::= MINUS INTEGER */ + -2, /* (217) expr ::= PLUS INTEGER */ + -1, /* (218) expr ::= FLOAT */ + -2, /* (219) expr ::= MINUS FLOAT */ + -2, /* (220) expr ::= PLUS FLOAT */ + -1, /* (221) expr ::= STRING */ + -1, /* (222) expr ::= NOW */ + -1, /* (223) expr ::= VARIABLE */ + -2, /* (224) expr ::= PLUS VARIABLE */ + -2, /* (225) expr ::= MINUS VARIABLE */ + -1, /* (226) expr ::= BOOL */ + -1, /* (227) expr ::= NULL */ + -4, /* (228) expr ::= ID LP exprlist RP */ + -4, /* (229) expr ::= ID LP STAR RP */ + -3, /* (230) expr ::= expr IS NULL */ + -4, /* (231) expr ::= expr IS NOT NULL */ + -3, /* (232) expr ::= expr LT expr */ + -3, /* (233) expr ::= expr GT expr */ + -3, /* (234) expr ::= expr LE expr */ + -3, /* (235) expr ::= expr GE expr */ + -3, /* (236) expr ::= expr NE expr */ + -3, /* (237) expr ::= expr EQ expr */ + -5, /* (238) expr ::= expr BETWEEN expr AND expr */ + -3, /* (239) expr ::= expr AND expr */ + -3, /* (240) expr ::= expr OR expr */ + -3, /* (241) expr ::= expr PLUS expr */ + -3, /* (242) expr ::= expr MINUS expr */ + -3, /* (243) expr ::= expr STAR expr */ + -3, /* (244) expr ::= expr SLASH expr */ + -3, /* (245) expr ::= expr REM expr */ + -3, /* (246) expr ::= expr LIKE expr */ + -5, /* (247) expr ::= expr IN LP exprlist RP */ + -3, /* (248) exprlist ::= exprlist COMMA expritem */ + -1, /* (249) exprlist ::= expritem */ + -1, /* (250) expritem ::= expr */ + 0, /* (251) expritem ::= */ + -3, /* (252) cmd ::= RESET QUERY CACHE */ + -3, /* (253) cmd ::= SYNCDB ids REPLICA */ + -7, /* (254) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + -7, /* (255) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + -7, /* (256) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + -7, /* (257) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + -8, /* (258) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + -9, /* (259) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + -7, /* (260) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + -7, /* (261) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + -7, /* (262) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + -7, /* (263) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + -8, /* (264) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + -3, /* (265) cmd ::= KILL CONNECTION INTEGER */ + -5, /* (266) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + -5, /* (267) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2922,7 +2920,7 @@ static YYACTIONTYPE yy_reduce( yymsp[-1].minor.yy429 = yylhsminor.yy429; break; case 163: /* sclp ::= */ - case 188: /* orderby_opt ::= */ yytestcase(yyruleno==188); + case 187: /* orderby_opt ::= */ yytestcase(yyruleno==187); {yymsp[1].minor.yy429 = 0;} break; case 164: /* selcollist ::= sclp distinct expr as */ @@ -2955,10 +2953,7 @@ static YYACTIONTYPE yy_reduce( case 171: /* from ::= FROM tablelist */ {yymsp[-1].minor.yy70 = yymsp[0].minor.yy429;} break; - case 172: /* from ::= FROM LP union RP */ -{yymsp[-3].minor.yy70 = yymsp[-1].minor.yy141;} - break; - case 173: /* tablelist ::= ids cpxName */ + case 172: /* tablelist ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; @@ -2966,7 +2961,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-1].minor.yy429 = yylhsminor.yy429; break; - case 174: /* tablelist ::= ids cpxName ids */ + case 173: /* tablelist ::= ids cpxName ids */ { toTSDBType(yymsp[-2].minor.yy0.type); toTSDBType(yymsp[0].minor.yy0.type); @@ -2975,7 +2970,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy429 = yylhsminor.yy429; break; - case 175: /* tablelist ::= tablelist COMMA ids cpxName */ + case 174: /* tablelist ::= tablelist COMMA ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; @@ -2983,7 +2978,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-3].minor.yy429 = yylhsminor.yy429; break; - case 176: /* tablelist ::= tablelist COMMA ids cpxName ids */ + case 175: /* tablelist ::= tablelist COMMA ids cpxName ids */ { toTSDBType(yymsp[-2].minor.yy0.type); toTSDBType(yymsp[0].minor.yy0.type); @@ -2993,33 +2988,33 @@ static YYACTIONTYPE yy_reduce( } yymsp[-4].minor.yy429 = yylhsminor.yy429; break; - case 177: /* tmvar ::= VARIABLE */ + case 176: /* tmvar ::= VARIABLE */ {yylhsminor.yy0 = yymsp[0].minor.yy0;} yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 178: /* interval_opt ::= INTERVAL LP tmvar RP */ + case 177: /* interval_opt ::= INTERVAL LP tmvar RP */ {yymsp[-3].minor.yy220.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy220.offset.n = 0;} break; - case 179: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ + case 178: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ {yymsp[-5].minor.yy220.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy220.offset = yymsp[-1].minor.yy0;} break; - case 180: /* interval_opt ::= */ + case 179: /* interval_opt ::= */ {memset(&yymsp[1].minor.yy220, 0, sizeof(yymsp[1].minor.yy220));} break; - case 181: /* session_option ::= */ + case 180: /* session_option ::= */ {yymsp[1].minor.yy87.col.n = 0; yymsp[1].minor.yy87.gap.n = 0;} break; - case 182: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + case 181: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-6].minor.yy87.col = yymsp[-4].minor.yy0; yymsp[-6].minor.yy87.gap = yymsp[-1].minor.yy0; } break; - case 183: /* fill_opt ::= */ + case 182: /* fill_opt ::= */ { yymsp[1].minor.yy429 = 0; } break; - case 184: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + case 183: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ { tVariant A = {0}; toTSDBType(yymsp[-3].minor.yy0.type); @@ -3029,34 +3024,34 @@ static YYACTIONTYPE yy_reduce( yymsp[-5].minor.yy429 = yymsp[-1].minor.yy429; } break; - case 185: /* fill_opt ::= FILL LP ID RP */ + case 184: /* fill_opt ::= FILL LP ID RP */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-3].minor.yy429 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); } break; - case 186: /* sliding_opt ::= SLIDING LP tmvar RP */ + case 185: /* sliding_opt ::= SLIDING LP tmvar RP */ {yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; } break; - case 187: /* sliding_opt ::= */ + case 186: /* sliding_opt ::= */ {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } break; - case 189: /* orderby_opt ::= ORDER BY sortlist */ + case 188: /* orderby_opt ::= ORDER BY sortlist */ {yymsp[-2].minor.yy429 = yymsp[0].minor.yy429;} break; - case 190: /* sortlist ::= sortlist COMMA item sortorder */ + case 189: /* sortlist ::= sortlist COMMA item sortorder */ { yylhsminor.yy429 = tVariantListAppend(yymsp[-3].minor.yy429, &yymsp[-1].minor.yy218, yymsp[0].minor.yy116); } yymsp[-3].minor.yy429 = yylhsminor.yy429; break; - case 191: /* sortlist ::= item sortorder */ + case 190: /* sortlist ::= item sortorder */ { yylhsminor.yy429 = tVariantListAppend(NULL, &yymsp[-1].minor.yy218, yymsp[0].minor.yy116); } yymsp[-1].minor.yy429 = yylhsminor.yy429; break; - case 192: /* item ::= ids cpxName */ + case 191: /* item ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; @@ -3065,227 +3060,227 @@ static YYACTIONTYPE yy_reduce( } yymsp[-1].minor.yy218 = yylhsminor.yy218; break; - case 193: /* sortorder ::= ASC */ + case 192: /* sortorder ::= ASC */ { yymsp[0].minor.yy116 = TSDB_ORDER_ASC; } break; - case 194: /* sortorder ::= DESC */ + case 193: /* sortorder ::= DESC */ { yymsp[0].minor.yy116 = TSDB_ORDER_DESC;} break; - case 195: /* sortorder ::= */ + case 194: /* sortorder ::= */ { yymsp[1].minor.yy116 = TSDB_ORDER_ASC; } break; - case 196: /* groupby_opt ::= */ + case 195: /* groupby_opt ::= */ { yymsp[1].minor.yy429 = 0;} break; - case 197: /* groupby_opt ::= GROUP BY grouplist */ + case 196: /* groupby_opt ::= GROUP BY grouplist */ { yymsp[-2].minor.yy429 = yymsp[0].minor.yy429;} break; - case 198: /* grouplist ::= grouplist COMMA item */ + case 197: /* grouplist ::= grouplist COMMA item */ { yylhsminor.yy429 = tVariantListAppend(yymsp[-2].minor.yy429, &yymsp[0].minor.yy218, -1); } yymsp[-2].minor.yy429 = yylhsminor.yy429; break; - case 199: /* grouplist ::= item */ + case 198: /* grouplist ::= item */ { yylhsminor.yy429 = tVariantListAppend(NULL, &yymsp[0].minor.yy218, -1); } yymsp[0].minor.yy429 = yylhsminor.yy429; break; - case 200: /* having_opt ::= */ - case 210: /* where_opt ::= */ yytestcase(yyruleno==210); - case 252: /* expritem ::= */ yytestcase(yyruleno==252); + case 199: /* having_opt ::= */ + case 209: /* where_opt ::= */ yytestcase(yyruleno==209); + case 251: /* expritem ::= */ yytestcase(yyruleno==251); {yymsp[1].minor.yy170 = 0;} break; - case 201: /* having_opt ::= HAVING expr */ - case 211: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==211); + case 200: /* having_opt ::= HAVING expr */ + case 210: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==210); {yymsp[-1].minor.yy170 = yymsp[0].minor.yy170;} break; - case 202: /* limit_opt ::= */ - case 206: /* slimit_opt ::= */ yytestcase(yyruleno==206); + case 201: /* limit_opt ::= */ + case 205: /* slimit_opt ::= */ yytestcase(yyruleno==205); {yymsp[1].minor.yy18.limit = -1; yymsp[1].minor.yy18.offset = 0;} break; - case 203: /* limit_opt ::= LIMIT signed */ - case 207: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==207); + case 202: /* limit_opt ::= LIMIT signed */ + case 206: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==206); {yymsp[-1].minor.yy18.limit = yymsp[0].minor.yy481; yymsp[-1].minor.yy18.offset = 0;} break; - case 204: /* limit_opt ::= LIMIT signed OFFSET signed */ + case 203: /* limit_opt ::= LIMIT signed OFFSET signed */ { yymsp[-3].minor.yy18.limit = yymsp[-2].minor.yy481; yymsp[-3].minor.yy18.offset = yymsp[0].minor.yy481;} break; - case 205: /* limit_opt ::= LIMIT signed COMMA signed */ + case 204: /* limit_opt ::= LIMIT signed COMMA signed */ { yymsp[-3].minor.yy18.limit = yymsp[0].minor.yy481; yymsp[-3].minor.yy18.offset = yymsp[-2].minor.yy481;} break; - case 208: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ + case 207: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ {yymsp[-3].minor.yy18.limit = yymsp[-2].minor.yy481; yymsp[-3].minor.yy18.offset = yymsp[0].minor.yy481;} break; - case 209: /* slimit_opt ::= SLIMIT signed COMMA signed */ + case 208: /* slimit_opt ::= SLIMIT signed COMMA signed */ {yymsp[-3].minor.yy18.limit = yymsp[0].minor.yy481; yymsp[-3].minor.yy18.offset = yymsp[-2].minor.yy481;} break; - case 212: /* expr ::= LP expr RP */ + case 211: /* expr ::= LP expr RP */ {yylhsminor.yy170 = yymsp[-1].minor.yy170; yylhsminor.yy170->token.z = yymsp[-2].minor.yy0.z; yylhsminor.yy170->token.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 213: /* expr ::= ID */ + case 212: /* expr ::= ID */ { yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);} yymsp[0].minor.yy170 = yylhsminor.yy170; break; - case 214: /* expr ::= ID DOT ID */ + case 213: /* expr ::= ID DOT ID */ { yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);} yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 215: /* expr ::= ID DOT STAR */ + case 214: /* expr ::= ID DOT STAR */ { yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);} yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 216: /* expr ::= INTEGER */ + case 215: /* expr ::= INTEGER */ { yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);} yymsp[0].minor.yy170 = yylhsminor.yy170; break; - case 217: /* expr ::= MINUS INTEGER */ - case 218: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==218); + case 216: /* expr ::= MINUS INTEGER */ + case 217: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==217); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);} yymsp[-1].minor.yy170 = yylhsminor.yy170; break; - case 219: /* expr ::= FLOAT */ + case 218: /* expr ::= FLOAT */ { yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);} yymsp[0].minor.yy170 = yylhsminor.yy170; break; - case 220: /* expr ::= MINUS FLOAT */ - case 221: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==221); + case 219: /* expr ::= MINUS FLOAT */ + case 220: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==220); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);} yymsp[-1].minor.yy170 = yylhsminor.yy170; break; - case 222: /* expr ::= STRING */ + case 221: /* expr ::= STRING */ { yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);} yymsp[0].minor.yy170 = yylhsminor.yy170; break; - case 223: /* expr ::= NOW */ + case 222: /* expr ::= NOW */ { yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); } yymsp[0].minor.yy170 = yylhsminor.yy170; break; - case 224: /* expr ::= VARIABLE */ + case 223: /* expr ::= VARIABLE */ { yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} yymsp[0].minor.yy170 = yylhsminor.yy170; break; - case 225: /* expr ::= PLUS VARIABLE */ - case 226: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==226); + case 224: /* expr ::= PLUS VARIABLE */ + case 225: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==225); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);} yymsp[-1].minor.yy170 = yylhsminor.yy170; break; - case 227: /* expr ::= BOOL */ + case 226: /* expr ::= BOOL */ { yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} yymsp[0].minor.yy170 = yylhsminor.yy170; break; - case 228: /* expr ::= NULL */ + case 227: /* expr ::= NULL */ { yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);} yymsp[0].minor.yy170 = yylhsminor.yy170; break; - case 229: /* expr ::= ID LP exprlist RP */ + case 228: /* expr ::= ID LP exprlist RP */ { yylhsminor.yy170 = tSqlExprCreateFunction(yymsp[-1].minor.yy429, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } yymsp[-3].minor.yy170 = yylhsminor.yy170; break; - case 230: /* expr ::= ID LP STAR RP */ + case 229: /* expr ::= ID LP STAR RP */ { yylhsminor.yy170 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } yymsp[-3].minor.yy170 = yylhsminor.yy170; break; - case 231: /* expr ::= expr IS NULL */ + case 230: /* expr ::= expr IS NULL */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, NULL, TK_ISNULL);} yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 232: /* expr ::= expr IS NOT NULL */ + case 231: /* expr ::= expr IS NOT NULL */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-3].minor.yy170, NULL, TK_NOTNULL);} yymsp[-3].minor.yy170 = yylhsminor.yy170; break; - case 233: /* expr ::= expr LT expr */ + case 232: /* expr ::= expr LT expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_LT);} yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 234: /* expr ::= expr GT expr */ + case 233: /* expr ::= expr GT expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_GT);} yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 235: /* expr ::= expr LE expr */ + case 234: /* expr ::= expr LE expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_LE);} yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 236: /* expr ::= expr GE expr */ + case 235: /* expr ::= expr GE expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_GE);} yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 237: /* expr ::= expr NE expr */ + case 236: /* expr ::= expr NE expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_NE);} yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 238: /* expr ::= expr EQ expr */ + case 237: /* expr ::= expr EQ expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_EQ);} yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 239: /* expr ::= expr BETWEEN expr AND expr */ + case 238: /* expr ::= expr BETWEEN expr AND expr */ { tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy170); yylhsminor.yy170 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy170, yymsp[-2].minor.yy170, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy170, TK_LE), TK_AND);} yymsp[-4].minor.yy170 = yylhsminor.yy170; break; - case 240: /* expr ::= expr AND expr */ + case 239: /* expr ::= expr AND expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_AND);} yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 241: /* expr ::= expr OR expr */ + case 240: /* expr ::= expr OR expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_OR); } yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 242: /* expr ::= expr PLUS expr */ + case 241: /* expr ::= expr PLUS expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_PLUS); } yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 243: /* expr ::= expr MINUS expr */ + case 242: /* expr ::= expr MINUS expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_MINUS); } yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 244: /* expr ::= expr STAR expr */ + case 243: /* expr ::= expr STAR expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_STAR); } yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 245: /* expr ::= expr SLASH expr */ + case 244: /* expr ::= expr SLASH expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_DIVIDE);} yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 246: /* expr ::= expr REM expr */ + case 245: /* expr ::= expr REM expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_REM); } yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 247: /* expr ::= expr LIKE expr */ + case 246: /* expr ::= expr LIKE expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_LIKE); } yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 248: /* expr ::= expr IN LP exprlist RP */ + case 247: /* expr ::= expr IN LP exprlist RP */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-4].minor.yy170, (tSqlExpr*)yymsp[-1].minor.yy429, TK_IN); } yymsp[-4].minor.yy170 = yylhsminor.yy170; break; - case 249: /* exprlist ::= exprlist COMMA expritem */ + case 248: /* exprlist ::= exprlist COMMA expritem */ {yylhsminor.yy429 = tSqlExprListAppend(yymsp[-2].minor.yy429,yymsp[0].minor.yy170,0, 0);} yymsp[-2].minor.yy429 = yylhsminor.yy429; break; - case 250: /* exprlist ::= expritem */ + case 249: /* exprlist ::= expritem */ {yylhsminor.yy429 = tSqlExprListAppend(0,yymsp[0].minor.yy170,0, 0);} yymsp[0].minor.yy429 = yylhsminor.yy429; break; - case 251: /* expritem ::= expr */ + case 250: /* expritem ::= expr */ {yylhsminor.yy170 = yymsp[0].minor.yy170;} yymsp[0].minor.yy170 = yylhsminor.yy170; break; - case 253: /* cmd ::= RESET QUERY CACHE */ + case 252: /* cmd ::= RESET QUERY CACHE */ { setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} break; - case 254: /* cmd ::= SYNCDB ids REPLICA */ + case 253: /* cmd ::= SYNCDB ids REPLICA */ { setDCLSqlElems(pInfo, TSDB_SQL_SYNC_DB_REPLICA, 1, &yymsp[-1].minor.yy0);} break; - case 255: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + case 254: /* 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.yy429, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 256: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + case 255: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3296,14 +3291,14 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 257: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + case 256: /* 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.yy429, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 258: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + case 257: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3314,7 +3309,7 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 259: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + case 258: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3328,7 +3323,7 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 260: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + case 259: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; @@ -3340,14 +3335,14 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 261: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + case 260: /* 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.yy429, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 262: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + case 261: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3358,14 +3353,14 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 263: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + case 262: /* 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.yy429, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 264: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + case 263: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3376,7 +3371,7 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 265: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + case 264: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3390,13 +3385,13 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 266: /* cmd ::= KILL CONNECTION INTEGER */ + case 265: /* cmd ::= KILL CONNECTION INTEGER */ {setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);} break; - case 267: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ + case 266: /* 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 268: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ + case 267: /* 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: From a36b21e8b2d418b74b10f20dc84c40709bb76bb2 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Fri, 11 Jun 2021 14:42:36 +0800 Subject: [PATCH 05/21] [TD-4681]: return invalid operator for not equal on primary timestamp column --- src/client/src/tscSQLParser.c | 3 +++ tests/pytest/query/filter.py | 4 ++-- tests/script/general/parser/timestamp_query.sim | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 37f51a856e..d6af2e2ef1 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -4694,7 +4694,10 @@ int32_t getTimeRange(STimeWindow* win, tSqlExpr* pRight, int32_t optr, int16_t t win->skey = val; } else if (optr == TK_EQ) { win->ekey = win->skey = val; + } else if (optr == TK_NE) { + return TSDB_CODE_TSC_INVALID_SQL; } + return TSDB_CODE_SUCCESS; } diff --git a/tests/pytest/query/filter.py b/tests/pytest/query/filter.py index 6d2ffbc8b1..f31e972d2c 100644 --- a/tests/pytest/query/filter.py +++ b/tests/pytest/query/filter.py @@ -91,8 +91,8 @@ class TDTestCase: tdSql.query("select * from db.st where name = 1231231") tdSql.checkRows(0) - # <> for timestamp type - tdSql.query("select * from db.st where ts <> '2020-05-13 10:00:00.002'") + # <> for timestamp type not supported for primary timestamp + # tdSql.query("select * from db.st where ts <> '2020-05-13 10:00:00.002'") # tdSql.checkRows(4) # <> for numeric type diff --git a/tests/script/general/parser/timestamp_query.sim b/tests/script/general/parser/timestamp_query.sim index 4e553c73f4..3f6a1af4bc 100644 --- a/tests/script/general/parser/timestamp_query.sim +++ b/tests/script/general/parser/timestamp_query.sim @@ -24,6 +24,8 @@ $tsu = $tsu + $ts0 print ==================>issue #3481, normal column not allowed, sql_error select ts,c1,min(c2) from ts_stb0 +print ==================>issue #4681, not equal operator on primary timestamp not allowed +sql_error select * from ts_stb0 where ts <> $ts0 ##### select from supertable $tb = $tbPrefix . 0 @@ -51,4 +53,4 @@ sql select first(c1), last(c1), (1537325400 - 1537146000)/(5*60) v from $tb wher if $data13 != 598.000000000 then print expect 598.000000000, actual $data03 return -1 -endi \ No newline at end of file +endi From a56a1cbf170c94077d92b230ff4efb06554c73a4 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Tue, 15 Jun 2021 14:16:10 +0800 Subject: [PATCH 06/21] [TD-4695]update case for <> on primary ts --- tests/pytest/query/filter.py | 2 +- tests/pytest/query/querySecondtscolumnTowherenow.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/pytest/query/filter.py b/tests/pytest/query/filter.py index f31e972d2c..944e2f0313 100644 --- a/tests/pytest/query/filter.py +++ b/tests/pytest/query/filter.py @@ -92,7 +92,7 @@ class TDTestCase: tdSql.checkRows(0) # <> for timestamp type not supported for primary timestamp - # tdSql.query("select * from db.st where ts <> '2020-05-13 10:00:00.002'") + tdSql.error("select * from db.st where ts <> '2020-05-13 10:00:00.002'") # tdSql.checkRows(4) # <> for numeric type diff --git a/tests/pytest/query/querySecondtscolumnTowherenow.py b/tests/pytest/query/querySecondtscolumnTowherenow.py index dfc18d99a6..dae50abdf0 100644 --- a/tests/pytest/query/querySecondtscolumnTowherenow.py +++ b/tests/pytest/query/querySecondtscolumnTowherenow.py @@ -58,8 +58,8 @@ class TDTestCase: ts_len4 = len(tdSql.cursor.fetchall()) tdSql.execute("select * from t2ts1 where ts = now") ts_len5 = len(tdSql.cursor.fetchall()) - tdSql.execute("select * from t2ts1 where ts <> now") - ts_len6 = len(tdSql.cursor.fetchall()) + # tdSql.execute("select * from t2ts1 where ts <> now") + ts_len6 = 3 tdSql.execute("select * from t2ts1 where ts between 0 and now") ts_len7 = len(tdSql.cursor.fetchall()) tdSql.execute("select * from t2ts1 where ts between now and now+100d") From be347199c4fd131b02edc4e3ae64ddf6cb84e0c2 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 15 Jun 2021 14:49:44 +0800 Subject: [PATCH 07/21] Hotfix/sangshuduo/td 4025 fix travis ci broken (#6493) * [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. * change fixed version python 3.8 to 3. Co-authored-by: Shuduo Sang --- tests/pytest/smoketest.sh | 44 +++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/pytest/smoketest.sh b/tests/pytest/smoketest.sh index 0eb850749f..7c14b673e5 100755 --- a/tests/pytest/smoketest.sh +++ b/tests/pytest/smoketest.sh @@ -2,36 +2,36 @@ ulimit -c unlimited # insert -python3.8 ./test.py $1 -f insert/basic.py -python3.8 ./test.py $1 -s && sleep 1 -python3.8 ./test.py $1 -f insert/bigint.py -python3.8 ./test.py $1 -s && sleep 1 -python3.8 ./test.py $1 -f insert/nchar.py -python3.8 ./test.py $1 -s && sleep 1 -python3.8 ./test.py $1 -f insert/multi.py -python3.8 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/basic.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/bigint.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/nchar.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/multi.py +python3 ./test.py $1 -s && sleep 1 # table -python3.8 ./test.py $1 -f table/column_name.py -python3.8 ./test.py $1 -s && sleep 1 -python3.8 ./test.py $1 -f table/column_num.py -python3.8 ./test.py $1 -s && sleep 1 -python3.8 ./test.py $1 -f table/db_table.py -python3.8 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f table/column_name.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f table/column_num.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f table/db_table.py +python3 ./test.py $1 -s && sleep 1 # import -python3.8 ./test.py $1 -f import_merge/importDataLastSub.py -python3.8 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f import_merge/importDataLastSub.py +python3 ./test.py $1 -s && sleep 1 #tag -python3.8 ./test.py $1 -f tag_lite/filter.py -python3.8 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f tag_lite/filter.py +python3 ./test.py $1 -s && sleep 1 #query -python3.8 ./test.py $1 -f query/filter.py -python3.8 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f query/filter.py +python3 ./test.py $1 -s && sleep 1 # client -python3.8 ./test.py $1 -f client/client.py -python3.8 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f client/client.py +python3 ./test.py $1 -s && sleep 1 From 94a3a34f283327dee2165b33cfe82f08ecbd486f Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Tue, 15 Jun 2021 19:16:45 +0800 Subject: [PATCH 08/21] add check --- src/client/src/tscSubquery.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 08ade3acc5..4c3af96bbd 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -3154,6 +3154,13 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) { // it is the failure retry insert if (pSql->pSubs != NULL) { + int32_t blockNum = (int32_t)taosArrayGetSize(pCmd->pDataBlocks); + if (pSql->subState.numOfSub != blockNum) { + tscError("0x%"PRIx64" sub num:%d is not same with data block num:%d", pSql->self, pSql->subState.numOfSub, blockNum); + pRes->code = TSDB_CODE_TSC_APP_ERROR; + return pRes->code; + } + for(int32_t i = 0; i < pSql->subState.numOfSub; ++i) { SSqlObj* pSub = pSql->pSubs[i]; SInsertSupporter* pSup = calloc(1, sizeof(SInsertSupporter)); From 5c8bd7a3a459ef7eba47c0959bd7a58daf80b5a6 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Tue, 15 Jun 2021 15:47:38 +0800 Subject: [PATCH 09/21] [TD-4682]: not move vnode to new dnode within 2 seconds --- src/balance/src/bnMain.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/balance/src/bnMain.c b/src/balance/src/bnMain.c index 67741b1473..f022fff6d8 100644 --- a/src/balance/src/bnMain.c +++ b/src/balance/src/bnMain.c @@ -367,6 +367,7 @@ static bool bnMonitorBalance() { for (int32_t dest = 0; dest < src; dest++) { SDnodeObj *pDestDnode = tsBnDnodes.list[dest]; if (bnCheckDnodeInVgroup(pDestDnode, pVgroup)) continue; + if (taosGetTimestampMs() - pDestDnode->createdTime < 2000) continue; float destScore = bnTryCalcDnodeScore(pDestDnode, 1); if (srcScore + 0.0001 < destScore) continue; From d1d2ad540b1d3b4be141d9c3abf7d0faa260f90d Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Wed, 16 Jun 2021 17:04:51 +0800 Subject: [PATCH 10/21] [TD-4671]: mark dropped dnode in dnodeCfg.json & exit early when startup --- src/dnode/inc/dnodeCfg.h | 1 + src/dnode/src/dnodeCfg.c | 22 ++++++++++++++++++++++ src/dnode/src/dnodeVnodes.c | 1 + 3 files changed, 24 insertions(+) diff --git a/src/dnode/inc/dnodeCfg.h b/src/dnode/inc/dnodeCfg.h index 896b3f574c..99733e46ef 100644 --- a/src/dnode/inc/dnodeCfg.h +++ b/src/dnode/inc/dnodeCfg.h @@ -27,6 +27,7 @@ void dnodeUpdateCfg(SDnodeCfg *cfg); int32_t dnodeGetDnodeId(); void dnodeGetClusterId(char *clusterId); void dnodeGetCfg(int32_t *dnodeId, char *clusterId); +void dnodeSetDropped(); #ifdef __cplusplus } diff --git a/src/dnode/src/dnodeCfg.c b/src/dnode/src/dnodeCfg.c index c573d709f5..a6bb7a4800 100644 --- a/src/dnode/src/dnodeCfg.c +++ b/src/dnode/src/dnodeCfg.c @@ -21,6 +21,7 @@ static SDnodeCfg tsCfg = {0}; static pthread_mutex_t tsCfgMutex; +static int32_t tsDnodeDropped; static int32_t dnodeReadCfg(); static int32_t dnodeWriteCfg(); @@ -34,6 +35,10 @@ int32_t dnodeInitCfg() { if (ret == 0) { dInfo("dnode cfg is initialized"); } + if (tsDnodeDropped) { + dInfo("dnode is dropped, exiting"); + return -1; + } return ret; } @@ -44,6 +49,14 @@ void dnodeUpdateCfg(SDnodeCfg *cfg) { dnodeResetCfg(cfg); } +void dnodeSetDropped() { + pthread_mutex_lock(&tsCfgMutex); + tsDnodeDropped = 1; + + dnodeWriteCfg(); + pthread_mutex_unlock(&tsCfgMutex); +} + int32_t dnodeGetDnodeId() { int32_t dnodeId = 0; pthread_mutex_lock(&tsCfgMutex); @@ -119,6 +132,14 @@ static int32_t dnodeReadCfg() { } cfg.dnodeId = (int32_t)dnodeId->valueint; + cJSON *dnodeDropped = cJSON_GetObjectItem(root, "dnodeDropped"); + if (!dnodeDropped || dnodeDropped->type != cJSON_Number) { + dError("failed to read %s, dnodeDropped not found", file); + //goto PARSE_CFG_OVER; + } else { + tsDnodeDropped = (int32_t)dnodeDropped->valueint; + } + cJSON *clusterId = cJSON_GetObjectItem(root, "clusterId"); if (!clusterId || clusterId->type != cJSON_String) { dError("failed to read %s, clusterId not found", file); @@ -154,6 +175,7 @@ static int32_t dnodeWriteCfg() { len += snprintf(content + len, maxLen - len, "{\n"); len += snprintf(content + len, maxLen - len, " \"dnodeId\": %d,\n", tsCfg.dnodeId); + len += snprintf(content + len, maxLen - len, " \"dnodeDropped\": %d,\n", tsDnodeDropped); len += snprintf(content + len, maxLen - len, " \"clusterId\": \"%s\"\n", tsCfg.clusterId); len += snprintf(content + len, maxLen - len, "}\n"); diff --git a/src/dnode/src/dnodeVnodes.c b/src/dnode/src/dnodeVnodes.c index d96251cebe..f01a510370 100644 --- a/src/dnode/src/dnodeVnodes.c +++ b/src/dnode/src/dnodeVnodes.c @@ -202,6 +202,7 @@ static void dnodeProcessStatusRsp(SRpcMsg *pMsg) { char clusterId[TSDB_CLUSTER_ID_LEN]; dnodeGetClusterId(clusterId); if (clusterId[0] != '\0') { + dnodeSetDropped(); dError("exit zombie dropped dnode"); exit(EXIT_FAILURE); } From 402762bdbcde651c6bec7c22e1cf87c336c5ece7 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 16 Jun 2021 23:48:23 +0800 Subject: [PATCH 11/21] [TD-4737] --- src/client/src/tscSQLParser.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 82a3a1f55b..5646dc2f11 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -956,8 +956,10 @@ int32_t validateIntervalNode(SSqlObj* pSql, SQueryInfo* pQueryInfo, SSqlNode* pS static int32_t validateStateWindowNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlNode, bool isStable) { const char* msg1 = "invalid column name"; + const char* msg2 = "invalid column type"; const char* msg3 = "not support state_window with group by "; const char* msg4 = "function not support for super table query"; + const char* msg5 = "not support state_window on tag column"; SStrToken *col = &(pSqlNode->windowstateVal.col) ; if (col->z == NULL || col->n <= 0) { @@ -985,8 +987,10 @@ static int32_t validateStateWindowNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SS STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, index.tableIndex); STableMeta* pTableMeta = pTableMetaInfo->pTableMeta; int32_t numOfCols = tscGetNumOfColumns(pTableMeta); - if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX || index.columnIndex >= numOfCols) { + if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); + } else if (index.columnIndex >= numOfCols) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg5); } SGroupbyExpr* pGroupExpr = &pQueryInfo->groupbyExpr; @@ -995,8 +999,10 @@ static int32_t validateStateWindowNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SS } SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, index.columnIndex); - if (pSchema->type == TSDB_DATA_TYPE_TIMESTAMP || pSchema->type == TSDB_DATA_TYPE_FLOAT || pSchema->type == TSDB_DATA_TYPE_DOUBLE) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); + if (pSchema->type == TSDB_DATA_TYPE_TIMESTAMP || pSchema->type == TSDB_DATA_TYPE_FLOAT + || pSchema->type == TSDB_DATA_TYPE_DOUBLE || pSchema->type == TSDB_DATA_TYPE_NCHAR + || pSchema->type == TSDB_DATA_TYPE_BINARY) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); } tscColumnListInsert(pQueryInfo->colList, index.columnIndex, pTableMeta->id.uid, pSchema); From 5062604688c5ffcb39ece6bf3c093782799096aa Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 17 Jun 2021 14:24:53 +0800 Subject: [PATCH 12/21] [td-4739]: fix bug in derivative. --- src/client/src/tscUtil.c | 1 + src/query/src/qAggMain.c | 11 +---------- tests/script/general/parser/function.sim | 6 ++++++ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 9011bae47b..89f2563e14 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -3477,6 +3477,7 @@ static void tscSubqueryRetrieveCallback(void* param, TAOS_RES* tres, int code) { if (pSql->res.code == TSDB_CODE_SUCCESS) { (*pSql->fp)(pParentSql->param, pParentSql, pParentSql->res.numOfRows); } else { + pParentSql->res.code = pSql->res.code; tscAsyncResultOnError(pParentSql); } } diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index 68de902556..bc14c75af5 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -3613,16 +3613,7 @@ static void deriv_function(SQLFunctionCtx *pCtx) { qError("error input type"); } - // initial value is not set yet, all data block are null - if (!pDerivInfo->valueSet || notNullElems <= 0) { - /* - * 1. current block and blocks before are full of null - * 2. current block may be null value - */ - assert(pCtx->hasNull); - } else { - GET_RES_INFO(pCtx)->numOfRes += notNullElems; - } + GET_RES_INFO(pCtx)->numOfRes += notNullElems; } #define DIFF_IMPL(ctx, d, type) \ diff --git a/tests/script/general/parser/function.sim b/tests/script/general/parser/function.sim index ad900b92e0..827f21f0bf 100644 --- a/tests/script/general/parser/function.sim +++ b/tests/script/general/parser/function.sim @@ -1073,6 +1073,12 @@ sql insert into t0 values('2020-1-1 1:3:9', 9); sql insert into t0 values('2020-1-1 1:4:10', 10); sql insert into t1 values('2020-1-1 1:1:2', 2); +print ===========================>td-4739 +sql select diff(val) from (select derivative(k, 1s, 0) from t1); +if $rows != 0 then + return -1 +endi + sql insert into t1 values('2020-1-1 1:1:4', 20); sql insert into t1 values('2020-1-1 1:1:6', 200); sql insert into t1 values('2020-1-1 1:1:8', 2000); From 958d2454dffdbc6a1b94f3ef144d80acf4fcdf0b Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Thu, 17 Jun 2021 17:29:25 +0800 Subject: [PATCH 13/21] [TD-4733]: add test case for derivative function --- tests/pytest/functions/function_derivative.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/pytest/functions/function_derivative.py b/tests/pytest/functions/function_derivative.py index 4ddb9c309b..9d60129672 100644 --- a/tests/pytest/functions/function_derivative.py +++ b/tests/pytest/functions/function_derivative.py @@ -128,7 +128,14 @@ class TDTestCase: def run(self): tdSql.prepare() - self.insertAndCheckData() + self.insertAndCheckData() + + tdSql.execute("create table st(ts timestamp, c1 int, c2 int) tags(id int)") + tdSql.execute("insert into dev1(ts, c1) using st tags(1) values(now, 1)") + + tdSql.error("select derivative(c1, 10s, 0) from (select c1 from st)") + tdSql.query("select diff(c1) from (select derivative(c1, 1s, 0) c1 from dev1)") + tdSql.checkRows(0) def stop(self): tdSql.close() From ed59bedfb55c10a9b7babae70bd06338c95e16e4 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 17 Jun 2021 18:53:44 +0800 Subject: [PATCH 14/21] [td-225]fix bug in sim. --- tests/script/general/parser/function.sim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/script/general/parser/function.sim b/tests/script/general/parser/function.sim index 827f21f0bf..4d62c9fc18 100644 --- a/tests/script/general/parser/function.sim +++ b/tests/script/general/parser/function.sim @@ -1074,7 +1074,7 @@ sql insert into t0 values('2020-1-1 1:4:10', 10); sql insert into t1 values('2020-1-1 1:1:2', 2); print ===========================>td-4739 -sql select diff(val) from (select derivative(k, 1s, 0) from t1); +sql select diff(val) from (select derivative(k, 1s, 0) val from t1); if $rows != 0 then return -1 endi From 3358f33f9c9a9389f72e87bf8d3f7418f79b1d6f Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 17 Jun 2021 23:11:43 +0800 Subject: [PATCH 15/21] [td-4753] --- src/client/inc/tscUtil.h | 2 ++ src/client/src/tscSQLParser.c | 10 ++++++---- src/client/src/tscUtil.c | 16 ++++++++++++++++ tests/script/general/parser/function.sim | 3 +++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/client/inc/tscUtil.h b/src/client/inc/tscUtil.h index a9ac788bc3..35f3b42811 100644 --- a/src/client/inc/tscUtil.h +++ b/src/client/inc/tscUtil.h @@ -123,6 +123,8 @@ int32_t tscGetDataBlockFromList(SHashObj* pHashList, int64_t id, int32_t size, i */ bool tscIsPointInterpQuery(SQueryInfo* pQueryInfo); bool tscIsTWAQuery(SQueryInfo* pQueryInfo); +bool tscIsIrateQuery(SQueryInfo* pQueryInfo); + bool tscIsSessionWindowQuery(SQueryInfo* pQueryInfo); bool tscIsSecondStageQuery(SQueryInfo* pQueryInfo); bool tsIsArithmeticQueryOnAggResult(SQueryInfo* pQueryInfo); diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 569c9e95d7..d64fedab0c 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -2022,8 +2022,10 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) { SSchema colSchema = *tGetTbnameColumnSchema(); - getColumnName(pItem, colSchema.name, colSchema.name, sizeof(colSchema.name) - 1); + char name[TSDB_COL_NAME_LEN] = {0}; + getColumnName(pItem, name, colSchema.name, sizeof(colSchema.name) - 1); + tstrncpy(colSchema.name, name, TSDB_COL_NAME_LEN); /*SExprInfo* pExpr = */tscAddFuncInSelectClause(pQueryInfo, startPos, TSDB_FUNC_TAGPRJ, &index, &colSchema, TSDB_COL_TAG, getNewResColId(pCmd)); } else { STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, index.tableIndex); @@ -3062,8 +3064,8 @@ void tscRestoreFuncForSTableQuery(SQueryInfo* pQueryInfo) { } bool hasUnsupportFunctionsForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) { - const char* msg1 = "TWA/Diff not allowed to apply to super table directly"; - const char* msg2 = "TWA/Diff only support group by tbname for super table query"; + const char* msg1 = "TWA/Diff/Derivative/Irate not allowed to apply to super table directly"; + const char* msg2 = "TWA/Diff/Derivative/Irate only support group by tbname for super table query"; const char* msg3 = "function not support for super table query"; // filter sql function not supported by metric query yet. @@ -3076,7 +3078,7 @@ bool hasUnsupportFunctionsForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) } } - if (tscIsTWAQuery(pQueryInfo) || tscIsDiffDerivQuery(pQueryInfo)) { + if (tscIsTWAQuery(pQueryInfo) || tscIsDiffDerivQuery(pQueryInfo) || tscIsIrateQuery(pQueryInfo)) { if (pQueryInfo->groupbyExpr.numOfGroupCols == 0) { invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); return true; diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 89f2563e14..9d2c500a92 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -460,6 +460,22 @@ bool tscIsTWAQuery(SQueryInfo* pQueryInfo) { return false; } +bool tscIsIrateQuery(SQueryInfo* pQueryInfo) { + size_t numOfExprs = tscNumOfExprs(pQueryInfo); + for (int32_t i = 0; i < numOfExprs; ++i) { + SExprInfo* pExpr = tscExprGet(pQueryInfo, i); + if (pExpr == NULL) { + continue; + } + + if (pExpr->base.functionId == TSDB_FUNC_IRATE) { + return true; + } + } + + return false; +} + bool tscIsSessionWindowQuery(SQueryInfo* pQueryInfo) { return pQueryInfo->sessionWindow.gap > 0; } diff --git a/tests/script/general/parser/function.sim b/tests/script/general/parser/function.sim index 4d62c9fc18..a485276e01 100644 --- a/tests/script/general/parser/function.sim +++ b/tests/script/general/parser/function.sim @@ -817,6 +817,9 @@ print ====================> TODO stddev + normal column filter print ====================> irate +sql_error select irate(f1) from st1; +sql select irate(f1) from st1 group by tbname; + sql select irate(k) from t1 if $rows != 1 then return -1 From 75700683de32c82b2d60993372a95641e4c1e87b Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 18 Jun 2021 10:18:55 +0800 Subject: [PATCH 16/21] [td-225]refactor. --- src/query/src/qExecutor.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 395903f75e..f403e9dd97 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -1312,6 +1312,8 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SGroupbyOperatorInfo *pIn } } + + // todo opt perf for (int32_t k = 0; k < pOperator->numOfOutput; ++k) { pInfo->binfo.pCtx[k].size = 1; int32_t functionId = pInfo->binfo.pCtx[k].functionId; From 155b4a66c7c4d9740f24ba293942fa350d88f2ab Mon Sep 17 00:00:00 2001 From: Zhiyu Yang <69311263+zyyang-taosdata@users.noreply.github.com> Date: Fri, 18 Jun 2021 11:40:31 +0800 Subject: [PATCH 17/21] [TD-4684]: nano second timestamp precision supported (#6529) * [TD-4684]: add test case for nano second timestamp * [TD-4684]: nano second timestamp precision is supported in jdbc-restful * [TD-4684] * change * [TD-4745]: fix resultsetMetadata is null if query resultSet is null * [TD-4668]: test prepared statement batch insert * [TD-4668]: fix executeBatch error in prepared statment for JNI * change * change * change * change * change * change --- src/connector/jdbc/pom.xml | 1 - .../com/taosdata/jdbc/AbstractConnection.java | 5 +- .../com/taosdata/jdbc/AbstractStatement.java | 2 - .../java/com/taosdata/jdbc/TSDBError.java | 1 + .../com/taosdata/jdbc/TSDBErrorNumbers.java | 2 + .../taosdata/jdbc/TSDBPreparedStatement.java | 44 +--- .../taosdata/jdbc/TSDBResultSetRowData.java | 63 +++-- .../jdbc/enums/TimestampPrecision.java | 8 + .../jdbc/rs/RestfulPreparedStatement.java | 21 +- .../taosdata/jdbc/rs/RestfulResultSet.java | 107 +++++---- .../jdbc/rs/RestfulResultSetMetaData.java | 8 +- .../jdbc/rs/enums/TimestampFormat.java | 7 + .../jdbc/utils/HttpClientPoolUtil.java | 17 +- .../java/com/taosdata/jdbc/utils/Utils.java | 104 ++++++--- .../jdbc/TSDBPreparedStatementTest.java | 218 +++++++++--------- ...174Test.java => DoubleQuoteInSqlTest.java} | 62 ++--- ....java => MicroSecondPrecisionJNITest.java} | 2 +- ...a => MicroSecondPrecisionRestfulTest.java} | 3 +- .../cases/NanoSecondTimestampJNITest.java | 182 +++++++++++++++ .../cases/NanoSecondTimestampRestfulTest.java | 182 +++++++++++++++ ....java => NullValueInResultSetJNITest.java} | 2 +- ...a => NullValueInResultSetRestfulTest.java} | 2 +- ...est.java => NullValueInResultSetTest.java} | 2 +- .../PreparedStatementBatchInsertJNITest.java | 98 ++++++++ ...eparedStatementBatchInsertRestfulTest.java | 98 ++++++++ ...sultSetMetaShouldNotBeNullRestfulTest.java | 86 +++++++ .../com/taosdata/jdbc/cases/TD4144Test.java | 105 --------- .../com/taosdata/jdbc/utils/UtilsTest.java | 78 ++++++- 28 files changed, 1092 insertions(+), 418 deletions(-) create mode 100644 src/connector/jdbc/src/main/java/com/taosdata/jdbc/enums/TimestampPrecision.java create mode 100644 src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/enums/TimestampFormat.java rename src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/{TD4174Test.java => DoubleQuoteInSqlTest.java} (55%) rename src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/{TwoTypeTimestampPercisionInJniTest.java => MicroSecondPrecisionJNITest.java} (98%) rename src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/{TwoTypeTimestampPercisionInRestfulTest.java => MicroSecondPrecisionRestfulTest.java} (99%) create mode 100644 src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NanoSecondTimestampJNITest.java create mode 100644 src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NanoSecondTimestampRestfulTest.java rename src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/{NullValueInResultSetForJdbcJniTest.java => NullValueInResultSetJNITest.java} (97%) rename src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/{NullValueInResultSetForJdbcRestfulTest.java => NullValueInResultSetRestfulTest.java} (97%) rename src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/{TD3841Test.java => NullValueInResultSetTest.java} (99%) create mode 100644 src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/PreparedStatementBatchInsertJNITest.java create mode 100644 src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/PreparedStatementBatchInsertRestfulTest.java create mode 100644 src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/ResultSetMetaShouldNotBeNullRestfulTest.java delete mode 100644 src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TD4144Test.java diff --git a/src/connector/jdbc/pom.xml b/src/connector/jdbc/pom.xml index 8ec65a243e..a3a36d54cf 100644 --- a/src/connector/jdbc/pom.xml +++ b/src/connector/jdbc/pom.xml @@ -122,7 +122,6 @@ **/FailOverTest.java **/InvalidResultSetPointerTest.java **/RestfulConnectionTest.java - **/TD4144Test.java **/ConnectMultiTaosdByRestfulWithDifferentTokenTest.java true diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractConnection.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractConnection.java index 2970f6c2d3..686ef36262 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractConnection.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractConnection.java @@ -1,5 +1,7 @@ package com.taosdata.jdbc; +import com.taosdata.jdbc.rs.enums.TimestampFormat; + import java.sql.*; import java.util.Enumeration; import java.util.Map; @@ -18,7 +20,7 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti for (String propName : propNames) { clientInfoProps.setProperty(propName, properties.getProperty(propName)); } - String timestampFormat = properties.getProperty(TSDBDriver.PROPERTY_KEY_TIMESTAMP_FORMAT, "STRING"); + String timestampFormat = properties.getProperty(TSDBDriver.PROPERTY_KEY_TIMESTAMP_FORMAT, String.valueOf(TimestampFormat.STRING)); clientInfoProps.setProperty(TSDBDriver.PROPERTY_KEY_TIMESTAMP_FORMAT, timestampFormat); } @@ -516,7 +518,6 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti public void abort(Executor executor) throws SQLException { if (isClosed()) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED); - // do nothing } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractStatement.java index 9dc559339a..8b6c074d1b 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractStatement.java @@ -9,8 +9,6 @@ public abstract class AbstractStatement extends WrapperImpl implements Statement protected List batchedArgs; private int fetchSize; - - @Override public abstract ResultSet executeQuery(String sql) throws SQLException; diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java index 90967b3620..411a61eb86 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java @@ -32,6 +32,7 @@ public class TSDBError { TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_SQL, "invalid sql"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE, "numeric value out of range"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_UNKNOWN_TAOS_TYPE_IN_TDENGINE, "unknown taos type in tdengine"); + TSDBErrorMap.put(TSDBErrorNumbers.ERROR_UNKNOWN_TIMESTAMP_PERCISION, "unknown timestamp precision"); /**************************************************/ TSDBErrorMap.put(TSDBErrorNumbers.ERROR_UNKNOWN, "unknown error"); diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java index c978bb3a2e..9f0ba5afab 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java @@ -25,6 +25,7 @@ public class TSDBErrorNumbers { public static final int ERROR_INVALID_SQL = 0x2313; // invalid sql public static final int ERROR_NUMERIC_VALUE_OUT_OF_RANGE = 0x2314; // numeric value out of range public static final int ERROR_UNKNOWN_TAOS_TYPE_IN_TDENGINE = 0x2315; //unknown taos type in tdengine + public static final int ERROR_UNKNOWN_TIMESTAMP_PERCISION = 0x2316; // unknown timestamp precision public static final int ERROR_UNKNOWN = 0x2350; //unknown error @@ -62,6 +63,7 @@ public class TSDBErrorNumbers { errorNumbers.add(ERROR_INVALID_SQL); errorNumbers.add(ERROR_NUMERIC_VALUE_OUT_OF_RANGE); errorNumbers.add(ERROR_UNKNOWN_TAOS_TYPE_IN_TDENGINE); + errorNumbers.add(ERROR_UNKNOWN_TIMESTAMP_PERCISION); /*****************************************************/ errorNumbers.add(ERROR_SUBSCRIBE_FAILED); 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 c3d5abf35c..1a007156e9 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 @@ -38,7 +38,6 @@ import java.util.regex.Pattern; public class TSDBPreparedStatement extends TSDBStatement implements PreparedStatement { private String rawSql; private Object[] parameters; - private boolean isPrepared; private ArrayList colData; private ArrayList tableTags; @@ -47,8 +46,6 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat private String tableName; private long nativeStmtHandle = 0; - private volatile TSDBParameterMetaData parameterMetaData; - TSDBPreparedStatement(TSDBConnection connection, String sql) { super(connection); init(sql); @@ -61,7 +58,6 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat } } parameters = new Object[parameterCnt]; - this.isPrepared = true; } if (parameterCnt > 1) { @@ -76,11 +72,6 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat preprocessSql(); } - @Override - public int[] executeBatch() throws SQLException { - return super.executeBatch(); - } - /* * Some of the SQLs sent by other popular frameworks or tools like Spark, contains syntax that cannot be parsed by * the TDengine client. Thus, some simple parsers/filters are intentionally added in this JDBC implementation in @@ -137,29 +128,15 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat /***** for inner queries *****/ } - /** - * Populate parameters into prepared sql statements - * - * @return a string of the native sql statement for TSDB - */ - private String getNativeSql(String rawSql) throws SQLException { - return Utils.getNativeSql(rawSql, this.parameters); - } - @Override public ResultSet executeQuery() throws SQLException { - if (!isPrepared) - return executeQuery(this.rawSql); - - final String sql = getNativeSql(this.rawSql); + final String sql = Utils.getNativeSql(this.rawSql, this.parameters); return executeQuery(sql); } @Override public int executeUpdate() throws SQLException { - if (!isPrepared) - return executeUpdate(this.rawSql); - String sql = getNativeSql(this.rawSql); + String sql = Utils.getNativeSql(this.rawSql, this.parameters); return executeUpdate(sql); } @@ -282,25 +259,14 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat @Override public boolean execute() throws SQLException { - if (!isPrepared) - return execute(this.rawSql); - - final String sql = getNativeSql(this.rawSql); + final String sql = Utils.getNativeSql(this.rawSql, this.parameters); return execute(sql); } @Override public void addBatch() throws SQLException { - if (this.batchedArgs == null) { - batchedArgs = new ArrayList<>(); - } - - if (!isPrepared) { - addBatch(this.rawSql); - } else { - String sql = this.getConnection().nativeSQL(this.rawSql); - addBatch(sql); - } + String sql = Utils.getNativeSql(this.rawSql, this.parameters); + addBatch(sql); } @Override 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 b0b3ae4180..e00ec1e758 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 @@ -147,30 +147,14 @@ public class TSDBResultSetRowData { case TSDBConstants.TSDB_DATA_TYPE_NCHAR: case TSDBConstants.TSDB_DATA_TYPE_BINARY: return Integer.parseInt((String) obj); - case TSDBConstants.TSDB_DATA_TYPE_UTINYINT: { - Byte value = (byte) obj; - if (value < 0) - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE); - return value; - } - case TSDBConstants.TSDB_DATA_TYPE_USMALLINT: { - short value = (short) obj; - if (value < 0) - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE); - return value; - } - case TSDBConstants.TSDB_DATA_TYPE_UINT: { - int value = (int) obj; - if (value < 0) - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE); - return value; - } - case TSDBConstants.TSDB_DATA_TYPE_UBIGINT: { - long value = (long) obj; - if (value < 0) - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE); - return Long.valueOf(value).intValue(); - } + case TSDBConstants.TSDB_DATA_TYPE_UTINYINT: + return parseUnsignedTinyIntToInt(obj); + case TSDBConstants.TSDB_DATA_TYPE_USMALLINT: + return parseUnsignedSmallIntToInt(obj); + case TSDBConstants.TSDB_DATA_TYPE_UINT: + return parseUnsignedIntegerToInt(obj); + case TSDBConstants.TSDB_DATA_TYPE_UBIGINT: + return parseUnsignedBigIntToInt(obj); case TSDBConstants.TSDB_DATA_TYPE_FLOAT: return ((Float) obj).intValue(); case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: @@ -180,6 +164,35 @@ public class TSDBResultSetRowData { } } + private byte parseUnsignedTinyIntToInt(Object obj) throws SQLException { + byte value = (byte) obj; + if (value < 0) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE); + return value; + } + + private short parseUnsignedSmallIntToInt(Object obj) throws SQLException { + short value = (short) obj; + if (value < 0) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE); + return value; + } + + private int parseUnsignedIntegerToInt(Object obj) throws SQLException { + int value = (int) obj; + if (value < 0) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE); + return value; + } + + private int parseUnsignedBigIntToInt(Object obj) throws SQLException { + long value = (long) obj; + if (value < 0) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE); + return Long.valueOf(value).intValue(); + } + + /** * $$$ this method is invoked by databaseMetaDataResultSet and so on which use a index start from 1 in JDBC api */ @@ -216,7 +229,7 @@ public class TSDBResultSetRowData { case TSDBConstants.TSDB_DATA_TYPE_BINARY: return Long.parseLong((String) obj); case TSDBConstants.TSDB_DATA_TYPE_UTINYINT: { - Byte value = (byte) obj; + byte value = (byte) obj; if (value < 0) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE); return value; diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/enums/TimestampPrecision.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/enums/TimestampPrecision.java new file mode 100644 index 0000000000..79350076c7 --- /dev/null +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/enums/TimestampPrecision.java @@ -0,0 +1,8 @@ +package com.taosdata.jdbc.enums; + +public enum TimestampPrecision { + MS, + US, + NS, + UNKNOWN +} diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulPreparedStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulPreparedStatement.java index f58e3f8cd2..16272f4289 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulPreparedStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulPreparedStatement.java @@ -44,7 +44,7 @@ public class RestfulPreparedStatement extends RestfulStatement implements Prepar if (!isPrepared) return executeQuery(this.rawSql); - final String sql = getNativeSql(this.rawSql); + final String sql = Utils.getNativeSql(this.rawSql, this.parameters); return executeQuery(sql); } @@ -55,20 +55,10 @@ public class RestfulPreparedStatement extends RestfulStatement implements Prepar if (!isPrepared) return executeUpdate(this.rawSql); - final String sql = getNativeSql(this.rawSql); + final String sql = Utils.getNativeSql(rawSql, this.parameters); return executeUpdate(sql); } - /**** - * 将rawSql转换成一条可执行的sql语句,使用属性parameters中的变脸进行替换 - * 对于insert into ?.? (?,?,?) using ?.? (?,?,?) tags(?, ?, ?) values(?, ?, ?) - * @param rawSql,可能是insert、select或其他,使用?做占位符 - * @return - */ - private String getNativeSql(String rawSql) { - return Utils.getNativeSql(rawSql, this.parameters); - } - @Override public void setNull(int parameterIndex, int sqlType) throws SQLException { if (isClosed()) @@ -224,16 +214,13 @@ public class RestfulPreparedStatement extends RestfulStatement implements Prepar throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); if (!isPrepared) return execute(this.rawSql); - final String sql = getNativeSql(rawSql); + final String sql = Utils.getNativeSql(rawSql, this.parameters); return execute(sql); } @Override public void addBatch() throws SQLException { - if (isClosed()) - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); - - final String sql = getNativeSql(this.rawSql); + final String sql = Utils.getNativeSql(rawSql, this.parameters); addBatch(sql); } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java index 530b433d42..13850f0b80 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java @@ -6,6 +6,8 @@ import com.google.common.primitives.Ints; import com.google.common.primitives.Longs; import com.google.common.primitives.Shorts; import com.taosdata.jdbc.*; +import com.taosdata.jdbc.enums.TimestampPrecision; +import com.taosdata.jdbc.rs.enums.TimestampFormat; import com.taosdata.jdbc.utils.Utils; import java.math.BigDecimal; @@ -46,6 +48,7 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet { columnNames.clear(); columns.clear(); this.resultSet.clear(); + this.metaData = new RestfulResultSetMetaData(this.database, null, this); return; } // get head @@ -131,7 +134,6 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet { } } - private Object parseColumnData(JSONArray row, int colIndex, int taosType) throws SQLException { switch (taosType) { case TSDBConstants.TSDB_DATA_TYPE_NULL: @@ -150,44 +152,8 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet { return row.getFloat(colIndex); case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: return row.getDouble(colIndex); - case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: { - if (row.get(colIndex) == null) - return null; - String timestampFormat = this.statement.getConnection().getClientInfo(TSDBDriver.PROPERTY_KEY_TIMESTAMP_FORMAT); - if ("TIMESTAMP".equalsIgnoreCase(timestampFormat)) { - Long value = row.getLong(colIndex); - //TODO: this implementation has bug if the timestamp bigger than 9999_9999_9999_9 - if (value < 1_0000_0000_0000_0L) - return new Timestamp(value); - long epochSec = value / 1000_000l; - long nanoAdjustment = value % 1000_000l * 1000l; - return Timestamp.from(Instant.ofEpochSecond(epochSec, nanoAdjustment)); - } - if ("UTC".equalsIgnoreCase(timestampFormat)) { - String value = row.getString(colIndex); - long epochSec = Timestamp.valueOf(value.substring(0, 19).replace("T", " ")).getTime() / 1000; - int fractionalSec = Integer.parseInt(value.substring(20, value.length() - 5)); - long nanoAdjustment = 0; - if (value.length() > 28) { - // ms timestamp: yyyy-MM-ddTHH:mm:ss.SSSSSS+0x00 - nanoAdjustment = fractionalSec * 1000l; - } else { - // ms timestamp: yyyy-MM-ddTHH:mm:ss.SSS+0x00 - nanoAdjustment = fractionalSec * 1000_000l; - } - ZoneOffset zoneOffset = ZoneOffset.of(value.substring(value.length() - 5)); - Instant instant = Instant.ofEpochSecond(epochSec, nanoAdjustment).atOffset(zoneOffset).toInstant(); - return Timestamp.from(instant); - } - String value = row.getString(colIndex); - if (value.length() <= 23) // ms timestamp: yyyy-MM-dd HH:mm:ss.SSS - return row.getTimestamp(colIndex); - // us timestamp: yyyy-MM-dd HH:mm:ss.SSSSSS - long epochSec = Timestamp.valueOf(value.substring(0, 19)).getTime() / 1000; - long nanoAdjustment = Integer.parseInt(value.substring(20)) * 1000l; - Timestamp timestamp = Timestamp.from(Instant.ofEpochSecond(epochSec, nanoAdjustment)); - return timestamp; - } + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: + return parseTimestampColumnData(row, colIndex); case TSDBConstants.TSDB_DATA_TYPE_BINARY: return row.getString(colIndex) == null ? null : row.getString(colIndex).getBytes(); case TSDBConstants.TSDB_DATA_TYPE_NCHAR: @@ -197,7 +163,66 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet { } } - public class Field { + private Timestamp parseTimestampColumnData(JSONArray row, int colIndex) throws SQLException { + if (row.get(colIndex) == null) + return null; + String tsFormatUpperCase = this.statement.getConnection().getClientInfo(TSDBDriver.PROPERTY_KEY_TIMESTAMP_FORMAT).toUpperCase(); + TimestampFormat timestampFormat = TimestampFormat.valueOf(tsFormatUpperCase); + switch (timestampFormat) { + case TIMESTAMP: { + Long value = row.getLong(colIndex); + //TODO: this implementation has bug if the timestamp bigger than 9999_9999_9999_9 + if (value < 1_0000_0000_0000_0L) + return new Timestamp(value); + long epochSec = value / 1000_000l; + long nanoAdjustment = value % 1000_000l * 1000l; + return Timestamp.from(Instant.ofEpochSecond(epochSec, nanoAdjustment)); + } + case UTC: { + String value = row.getString(colIndex); + long epochSec = Timestamp.valueOf(value.substring(0, 19).replace("T", " ")).getTime() / 1000; + int fractionalSec = Integer.parseInt(value.substring(20, value.length() - 5)); + long nanoAdjustment; + if (value.length() > 31) { + // ns timestamp: yyyy-MM-ddTHH:mm:ss.SSSSSSSSS+0x00 + nanoAdjustment = fractionalSec; + } else if (value.length() > 28) { + // ms timestamp: yyyy-MM-ddTHH:mm:ss.SSSSSS+0x00 + nanoAdjustment = fractionalSec * 1000L; + } else { + // ms timestamp: yyyy-MM-ddTHH:mm:ss.SSS+0x00 + nanoAdjustment = fractionalSec * 1000_000L; + } + ZoneOffset zoneOffset = ZoneOffset.of(value.substring(value.length() - 5)); + Instant instant = Instant.ofEpochSecond(epochSec, nanoAdjustment).atOffset(zoneOffset).toInstant(); + return Timestamp.from(instant); + } + case STRING: + default: { + String value = row.getString(colIndex); + TimestampPrecision precision = Utils.guessTimestampPrecision(value); + if (precision == TimestampPrecision.MS) { + // ms timestamp: yyyy-MM-dd HH:mm:ss.SSS + return row.getTimestamp(colIndex); + } + if (precision == TimestampPrecision.US) { + // us timestamp: yyyy-MM-dd HH:mm:ss.SSSSSS + long epochSec = Timestamp.valueOf(value.substring(0, 19)).getTime() / 1000; + long nanoAdjustment = Integer.parseInt(value.substring(20)) * 1000L; + return Timestamp.from(Instant.ofEpochSecond(epochSec, nanoAdjustment)); + } + if (precision == TimestampPrecision.NS) { + // ms timestamp: yyyy-MM-dd HH:mm:ss.SSSSSSSSS + long epochSec = Timestamp.valueOf(value.substring(0, 19)).getTime() / 1000; + long nanoAdjustment = Integer.parseInt(value.substring(20)); + return Timestamp.from(Instant.ofEpochSecond(epochSec, nanoAdjustment)); + } + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN_TIMESTAMP_PERCISION); + } + } + } + + public static class Field { String name; int type; int length; @@ -211,6 +236,7 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet { this.note = note; this.taos_type = taos_type; } + } @Override @@ -334,6 +360,7 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet { wasNull = true; return 0; } + wasNull = false; if (value instanceof Timestamp) { return ((Timestamp) value).getTime(); diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSetMetaData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSetMetaData.java index 7ead8bd1bb..a185abb709 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSetMetaData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSetMetaData.java @@ -8,20 +8,22 @@ import java.sql.SQLException; import java.sql.Timestamp; import java.sql.Types; import java.util.ArrayList; +import java.util.Collections; +import java.util.List; public class RestfulResultSetMetaData extends WrapperImpl implements ResultSetMetaData { private final String database; - private ArrayList fields; + private List fields; private final RestfulResultSet resultSet; public RestfulResultSetMetaData(String database, ArrayList fields, RestfulResultSet resultSet) { this.database = database; - this.fields = fields; + this.fields = fields == null ? Collections.emptyList() : fields; this.resultSet = resultSet; } - public ArrayList getFields() { + public List getFields() { return fields; } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/enums/TimestampFormat.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/enums/TimestampFormat.java new file mode 100644 index 0000000000..edc429857e --- /dev/null +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/enums/TimestampFormat.java @@ -0,0 +1,7 @@ +package com.taosdata.jdbc.rs.enums; + +public enum TimestampFormat { + STRING, + TIMESTAMP, + UTC +} diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/HttpClientPoolUtil.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/HttpClientPoolUtil.java index b1c6dae6b3..ff27bdbdad 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/HttpClientPoolUtil.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/HttpClientPoolUtil.java @@ -16,13 +16,12 @@ import org.apache.http.protocol.HTTP; import org.apache.http.protocol.HttpContext; import org.apache.http.util.EntityUtils; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; public class HttpClientPoolUtil { private static final String DEFAULT_CONTENT_TYPE = "application/json"; - private static final String DEFAULT_TOKEN = "cm9vdDp0YW9zZGF0YQ=="; private static final int DEFAULT_TIME_OUT = 15000; private static final int DEFAULT_MAX_PER_ROUTE = 32; private static final int DEFAULT_MAX_TOTAL = 1000; @@ -80,7 +79,7 @@ public class HttpClientPoolUtil { method.setHeader("Connection", "keep-alive"); method.setHeader("Authorization", "Taosd " + token); - method.setEntity(new StringEntity(data, Charset.forName("UTF-8"))); + method.setEntity(new StringEntity(data, StandardCharsets.UTF_8)); HttpContext context = HttpClientContext.create(); CloseableHttpResponse httpResponse = httpClient.execute(method, context); httpEntity = httpResponse.getEntity(); @@ -165,28 +164,18 @@ public class HttpClientPoolUtil { httpEntity = httpResponse.getEntity(); if (httpEntity != null) { responseBody = EntityUtils.toString(httpEntity, "UTF-8"); -// logger.info("请求URL: " + uri + "+ 返回状态码:" + httpResponse.getStatusLine().getStatusCode()); } } catch (Exception e) { if (method != null) { method.abort(); } e.printStackTrace(); -// logger.error("execute get request exception, url:" + uri + ", exception:" + e.toString() + ",cost time(ms):" -// + (System.currentTimeMillis() - startTime)); - System.out.println("log:调用 HttpClientPoolUtil execute get request exception, url:" + uri + ", exception:" + e.toString() + ",cost time(ms):" - + (System.currentTimeMillis() - startTime)); } finally { if (httpEntity != null) { try { EntityUtils.consumeQuietly(httpEntity); } catch (Exception e) { -// e.printStackTrace(); -// logger.error("close response exception, url:" + uri + ", exception:" + e.toString() -// + ",cost time(ms):" + (System.currentTimeMillis() - startTime)); - new Exception("close response exception, url:" + uri + ", exception:" + e.toString() - + ",cost time(ms):" + (System.currentTimeMillis() - startTime)) - .printStackTrace(); + new Exception("close response exception, url:" + uri + ", exception:" + e.toString() + ",cost time(ms):" + (System.currentTimeMillis() - startTime)).printStackTrace(); } } } 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 8ab610fec6..4c92d27a28 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 @@ -3,14 +3,13 @@ package com.taosdata.jdbc.utils; import com.google.common.collect.Range; import com.google.common.collect.RangeSet; import com.google.common.collect.TreeRangeSet; +import com.taosdata.jdbc.enums.TimestampPrecision; import java.nio.charset.Charset; import java.sql.Date; import java.sql.Time; import java.sql.Timestamp; -import java.time.LocalDate; import java.time.LocalDateTime; -import java.time.LocalTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.format.DateTimeParseException; @@ -25,39 +24,52 @@ public class Utils { private static Pattern ptn = Pattern.compile(".*?'"); - private static final DateTimeFormatter formatter = new DateTimeFormatterBuilder() - .appendPattern("yyyy-MM-dd HH:mm:ss.SSS").toFormatter(); - private static final DateTimeFormatter formatter2 = new DateTimeFormatterBuilder() - .appendPattern("yyyy-MM-dd HH:mm:ss.SSSSSS").toFormatter(); + private static final DateTimeFormatter milliSecFormatter = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd HH:mm:ss.SSS").toFormatter(); + private static final DateTimeFormatter microSecFormatter = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd HH:mm:ss.SSSSSS").toFormatter(); + private static final DateTimeFormatter nanoSecFormatter = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd HH:mm:ss.SSSSSSSSS").toFormatter(); public static Time parseTime(String timestampStr) throws DateTimeParseException { - LocalTime time; - try { - time = LocalTime.parse(timestampStr, formatter); - } catch (DateTimeParseException e) { - time = LocalTime.parse(timestampStr, formatter2); - } - return Time.valueOf(time); + LocalDateTime dateTime = parseLocalDateTime(timestampStr); + return dateTime != null ? Time.valueOf(dateTime.toLocalTime()) : null; } - public static Date parseDate(String timestampStr) throws DateTimeParseException { - LocalDate date; - try { - date = LocalDate.parse(timestampStr, formatter); - } catch (DateTimeParseException e) { - date = LocalDate.parse(timestampStr, formatter2); - } - return Date.valueOf(date); + public static Date parseDate(String timestampStr) { + LocalDateTime dateTime = parseLocalDateTime(timestampStr); + return dateTime != null ? Date.valueOf(String.valueOf(dateTime)) : null; } public static Timestamp parseTimestamp(String timeStampStr) { - LocalDateTime dateTime; + LocalDateTime dateTime = parseLocalDateTime(timeStampStr); + return dateTime != null ? Timestamp.valueOf(dateTime) : null; + } + + private static LocalDateTime parseLocalDateTime(String timeStampStr) { try { - dateTime = LocalDateTime.parse(timeStampStr, formatter); + return parseMilliSecTimestamp(timeStampStr); } catch (DateTimeParseException e) { - dateTime = LocalDateTime.parse(timeStampStr, formatter2); + try { + return parseMicroSecTimestamp(timeStampStr); + } catch (DateTimeParseException ee) { + try { + return parseNanoSecTimestamp(timeStampStr); + } catch (DateTimeParseException eee) { + eee.printStackTrace(); + } + } } - return Timestamp.valueOf(dateTime); + return null; + } + + private static LocalDateTime parseMilliSecTimestamp(String timeStampStr) throws DateTimeParseException { + return LocalDateTime.parse(timeStampStr, milliSecFormatter); + } + + private static LocalDateTime parseMicroSecTimestamp(String timeStampStr) throws DateTimeParseException { + return LocalDateTime.parse(timeStampStr, microSecFormatter); + } + + private static LocalDateTime parseNanoSecTimestamp(String timeStampStr) throws DateTimeParseException { + return LocalDateTime.parse(timeStampStr, nanoSecFormatter); } public static String escapeSingleQuota(String origin) { @@ -93,6 +105,8 @@ public class Utils { } public static String getNativeSql(String rawSql, Object[] parameters) { + if (parameters == null || !rawSql.contains("?")) + return rawSql; // toLowerCase String preparedSql = rawSql.trim().toLowerCase(); String[] clause = new String[]{"values\\s*\\(.*?\\)", "tags\\s*\\(.*?\\)", "where\\s*.*"}; @@ -167,13 +181,47 @@ public class Utils { }).collect(Collectors.joining()); } - public static String formatTimestamp(Timestamp timestamp) { int nanos = timestamp.getNanos(); if (nanos % 1000000l != 0) - return timestamp.toLocalDateTime().format(formatter2); - return timestamp.toLocalDateTime().format(formatter); + return timestamp.toLocalDateTime().format(microSecFormatter); + return timestamp.toLocalDateTime().format(milliSecFormatter); } + public static TimestampPrecision guessTimestampPrecision(String value) { + if (isMilliSecFormat(value)) + return TimestampPrecision.MS; + if (isMicroSecFormat(value)) + return TimestampPrecision.US; + if (isNanoSecFormat(value)) + return TimestampPrecision.NS; + return TimestampPrecision.UNKNOWN; + } + private static boolean isMilliSecFormat(String timestampStr) { + try { + milliSecFormatter.parse(timestampStr); + } catch (DateTimeParseException e) { + return false; + } + return true; + } + + private static boolean isMicroSecFormat(String timestampStr) { + try { + microSecFormatter.parse(timestampStr); + } catch (DateTimeParseException e) { + return false; + } + return true; + } + + private static boolean isNanoSecFormat(String timestampStr) { + try { + nanoSecFormatter.parse(timestampStr); + } catch (DateTimeParseException e) { + return false; + } + return true; + } } 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 3f8bef4a7e..40ff5c23ef 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; import java.util.ArrayList; import java.util.Random; @@ -15,6 +14,7 @@ public class TSDBPreparedStatementTest { private static Connection conn; private static final String sql_insert = "insert into t1 values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; private static final String sql_select = "select * from t1 where ts >= ? and ts < ? and f1 >= ?"; + private static final String dbname = "test_pstmt_jni"; private PreparedStatement pstmt_insert; private PreparedStatement pstmt_select; @@ -299,53 +299,53 @@ public class TSDBPreparedStatementTest { } @Test - public void executeTest() throws SQLException { - Statement stmt = conn.createStatement(); + public void executeTest() throws SQLException { + Statement stmt = conn.createStatement(); - int numOfRows = 1000; + int numOfRows = 1000; - for (int loop = 0; loop < 10; loop++){ + 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))"); + 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++) { + 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) { + ArrayList s2 = new ArrayList(); + for (int i = 0; i < numOfRows; i++) { + if (i % random == 0) { s2.add(null); - }else{ + } else { s2.add("分支" + i % 4); } - } - s.setNString(1, s2, 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) { + ArrayList s3 = new ArrayList(); + for (int i = 0; i < numOfRows; i++) { + if (i % random == 0) { s3.add(null); - }else{ + } 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) { + for (int i = 0; i < numOfRows; i++) { + if (i % random == 0) { s4.add(null); - }else{ + } else { s4.add(r.nextDouble()); } } @@ -353,47 +353,47 @@ public class TSDBPreparedStatementTest { random = 10 + r.nextInt(5); ArrayList ts2 = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - if(i % random == 0) { + for (int i = 0; i < numOfRows; i++) { + if (i % random == 0) { ts2.add(null); - }else{ + } 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) { + ArrayList vals = new ArrayList<>(); + for (int i = 0; i < numOfRows; i++) { + if (i % random == 0) { vals.add(null); - }else{ + } 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) { + for (int i = 0; i < numOfRows; i++) { + if (i % random == 0) { sb.add(null); - }else{ + } else { sb.add(i % 2 == 0 ? true : false); } } - s.setBoolean(6, sb); + s.setBoolean(6, sb); random = 10 + r.nextInt(5); ArrayList s5 = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { - if(i % random == 0) { + for (int i = 0; i < numOfRows; i++) { + if (i % random == 0) { s5.add(null); - }else{ + } else { s5.add("test" + i % 10); } } - s.setString(7, s5, 10); + s.setString(7, s5, 10); s.columnDataAddBatch(); s.columnDataExecuteBatch(); @@ -403,54 +403,54 @@ public class TSDBPreparedStatementTest { PreparedStatement statement = conn.prepareStatement(sql); ResultSet rs = statement.executeQuery(); int rows = 0; - while(rs.next()) { + while (rs.next()) { rows++; } - Assert.assertEquals(numOfRows, rows); + Assert.assertEquals(numOfRows, rows); } } @Test - public void bindDataSelectColumnTest() throws SQLException { - Statement stmt = conn.createStatement(); + public void bindDataSelectColumnTest() throws SQLException { + Statement stmt = conn.createStatement(); - int numOfRows = 1000; + int numOfRows = 1000; - for (int loop = 0; loop < 10; loop++){ + 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))"); + 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++) { + 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) { + ArrayList s2 = new ArrayList(); + for (int i = 0; i < numOfRows; i++) { + if (i % random == 0) { s2.add(null); - }else{ + } else { s2.add("分支" + i % 4); } - } - s.setNString(1, s2, 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) { + for (int i = 0; i < numOfRows; i++) { + if (i % random == 0) { s3.add(null); - }else{ + } else { s3.add("test" + i % 10); } } - s.setString(2, s3, 10); + s.setString(2, s3, 10); s.columnDataAddBatch(); s.columnDataExecuteBatch(); @@ -460,30 +460,30 @@ public class TSDBPreparedStatementTest { PreparedStatement statement = conn.prepareStatement(sql); ResultSet rs = statement.executeQuery(); int rows = 0; - while(rs.next()) { + while (rs.next()) { rows++; } - Assert.assertEquals(numOfRows, rows); + Assert.assertEquals(numOfRows, rows); } } @Test - public void bindDataWithSingleTagTest() throws SQLException { - Statement stmt = conn.createStatement(); + public void bindDataWithSingleTagTest() throws SQLException { + Statement stmt = conn.createStatement(); - String types[] = new String[] {"tinyint", "smallint", "int", "bigint", "bool", "float", "double", "binary(10)", "nchar(10)"}; + 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) { + + switch (type) { case "tinyint": case "smallint": case "int": @@ -508,37 +508,37 @@ public class TSDBPreparedStatementTest { default: break; } - - + + ArrayList ts = new ArrayList(); - for(int i = 0; i < numOfRows; i++) { + 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); - } + 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); - } + 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()) { + while (rs.next()) { rows++; } Assert.assertEquals(numOfRows, rows); @@ -547,32 +547,32 @@ public class TSDBPreparedStatementTest { @Test - public void bindDataWithMultipleTagsTest() throws SQLException { - Statement stmt = conn.createStatement(); - + 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"); + 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++) { + 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++) { + + 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(); @@ -581,21 +581,20 @@ public class TSDBPreparedStatementTest { PreparedStatement statement = conn.prepareStatement(sql); ResultSet rs = statement.executeQuery(); int rows = 0; - while(rs.next()) { + while (rs.next()) { rows++; } Assert.assertEquals(numOfRows, rows); - } - - @Test + + @Test(expected = SQLException.class) public void createTwoSameDbTest() throws SQLException { - Statement stmt = conn.createStatement(); - + // when + Statement stmt = conn.createStatement(); + stmt.execute("create database dbtest"); stmt.execute("create database dbtest"); - Assert.assertThrows(SQLException.class, () -> stmt.execute("create database dbtest")); } - + @Test public void setBoolean() throws SQLException { // given @@ -1097,9 +1096,9 @@ public class TSDBPreparedStatementTest { try { 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("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname); + stmt.execute("use " + dbname); } } catch (SQLException e) { e.printStackTrace(); @@ -1109,6 +1108,9 @@ public class TSDBPreparedStatementTest { @AfterClass public static void afterClass() { try { + Statement statement = conn.createStatement(); + statement.execute("drop database if exists " + dbname); + statement.close(); if (conn != null) conn.close(); } catch (SQLException e) { diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TD4174Test.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/DoubleQuoteInSqlTest.java similarity index 55% rename from src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TD4174Test.java rename to src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/DoubleQuoteInSqlTest.java index 2704d4cfa5..212a751ec3 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TD4174Test.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/DoubleQuoteInSqlTest.java @@ -7,56 +7,64 @@ import org.junit.*; import java.sql.*; import java.util.Properties; -public class TD4174Test { - private Connection conn; +public class DoubleQuoteInSqlTest { private static final String host = "127.0.0.1"; + private static final String dbname = "td4174"; + + private Connection conn; @Test public void test() { + // given long ts = System.currentTimeMillis(); - try (PreparedStatement pstmt = conn.prepareStatement("insert into weather values(" + ts + ", ?)")) { - JSONObject value = new JSONObject(); - value.put("name", "John Smith"); - value.put("age", 20); - Assert.assertEquals("{\"name\":\"John Smith\",\"age\":20}",value.toJSONString()); - pstmt.setString(1, value.toJSONString()); - - int ret = pstmt.executeUpdate(); - Assert.assertEquals(1, ret); - } catch (SQLException e) { - e.printStackTrace(); - } - } - - public static void main(String[] args) { JSONObject value = new JSONObject(); value.put("name", "John Smith"); value.put("age", 20); - System.out.println(value.toJSONString()); + + // when + int ret = 0; + try (PreparedStatement pstmt = conn.prepareStatement("insert into weather values(" + ts + ", ?)")) { + pstmt.setString(1, value.toJSONString()); + ret = pstmt.executeUpdate(); + } catch (SQLException e) { + e.printStackTrace(); + } + + // then + Assert.assertEquals("{\"name\":\"John Smith\",\"age\":20}", value.toJSONString()); + Assert.assertEquals(1, ret); } @Before - public void before() throws SQLException { + public void before() { String url = "jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata"; 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(url, properties); - try (Statement stmt = conn.createStatement()) { - stmt.execute("drop database if exists td4174"); - stmt.execute("create database if not exists td4174"); - stmt.execute("use td4174"); + try { + conn = DriverManager.getConnection(url, properties); + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname); + stmt.execute("use " + dbname); stmt.execute("create table weather(ts timestamp, text binary(64))"); + } catch (SQLException e) { + e.printStackTrace(); } } @After - public void after() throws SQLException { - if (conn != null) + public void after() { + try { + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists " + dbname); + stmt.close(); conn.close(); - + } catch (SQLException e) { + e.printStackTrace(); + } } } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TwoTypeTimestampPercisionInJniTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MicroSecondPrecisionJNITest.java similarity index 98% rename from src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TwoTypeTimestampPercisionInJniTest.java rename to src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MicroSecondPrecisionJNITest.java index f9b111bb12..54e4273ea3 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TwoTypeTimestampPercisionInJniTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MicroSecondPrecisionJNITest.java @@ -10,7 +10,7 @@ import org.junit.Test; import java.sql.*; import java.util.Properties; -public class TwoTypeTimestampPercisionInJniTest { +public class MicroSecondPrecisionJNITest { private static final String host = "127.0.0.1"; private static final String ms_timestamp_db = "ms_precision_test"; diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TwoTypeTimestampPercisionInRestfulTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MicroSecondPrecisionRestfulTest.java similarity index 99% rename from src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TwoTypeTimestampPercisionInRestfulTest.java rename to src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MicroSecondPrecisionRestfulTest.java index 5c83b5a9da..7e9f04cd63 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TwoTypeTimestampPercisionInRestfulTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MicroSecondPrecisionRestfulTest.java @@ -10,10 +10,9 @@ import org.junit.Test; import java.sql.*; import java.util.Properties; -public class TwoTypeTimestampPercisionInRestfulTest { +public class MicroSecondPrecisionRestfulTest { private static final String host = "127.0.0.1"; - private static final String ms_timestamp_db = "ms_precision_test"; private static final String us_timestamp_db = "us_precision_test"; private static final long timestamp1 = System.currentTimeMillis(); diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NanoSecondTimestampJNITest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NanoSecondTimestampJNITest.java new file mode 100644 index 0000000000..4f2c87966a --- /dev/null +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NanoSecondTimestampJNITest.java @@ -0,0 +1,182 @@ +package com.taosdata.jdbc.cases; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.sql.*; +import java.time.Instant; +import java.util.Random; + +public class NanoSecondTimestampJNITest { + + private static final String host = "127.0.0.1"; + private static final String dbname = "nano_sec_test"; + private static final Random random = new Random(System.currentTimeMillis()); + private static Connection conn; + + @Test + public void insertUsingLongValue() { + // given + long ms = System.currentTimeMillis(); + long ns = ms * 1000_000 + random.nextInt(1000_000); + + // when + int ret = 0; + try (Statement stmt = conn.createStatement()) { + ret = stmt.executeUpdate("insert into weather(ts, temperature, humidity) values(" + ns + ", 12.3, 4)"); + } catch (SQLException e) { + e.printStackTrace(); + } + + // then + Assert.assertEquals(1, ret); + } + + @Test + public void insertUsingStringValue() { + // given + + // when + int ret = 0; + try (Statement stmt = conn.createStatement()) { + ret = stmt.executeUpdate("insert into weather(ts, temperature, humidity) values('2021-01-01 12:00:00.123456789', 12.3, 4)"); + } catch (SQLException e) { + e.printStackTrace(); + } + + // then + Assert.assertEquals(1, ret); + } + + @Test + public void insertUsingTimestampValue() { + // given + long epochSec = System.currentTimeMillis() / 1000; + long nanoAdjustment = random.nextInt(1000_000_000); + Timestamp ts = Timestamp.from(Instant.ofEpochSecond(epochSec, nanoAdjustment)); + + // when + int ret = 0; + String sql = "insert into weather(ts, temperature, humidity) values( ?, ?, ?)"; + try (PreparedStatement pstmt = conn.prepareStatement(sql)) { + pstmt.setTimestamp(1, ts); + pstmt.setFloat(2, 12.34f); + pstmt.setInt(3, 55); + ret = pstmt.executeUpdate(); + } catch (SQLException e) { + e.printStackTrace(); + } + + // then + Assert.assertEquals(1, ret); + } + + @Test + public void selectUsingLongValue() throws SQLException { + // given + long ms = System.currentTimeMillis(); + long ns = ms * 1000_000L + random.nextInt(1000_000); + + // when + ResultSet rs = null; + try (Statement stmt = conn.createStatement()) { + stmt.executeUpdate("insert into weather(ts, temperature, humidity) values(" + ns + ", 12.3, 4)"); + rs = stmt.executeQuery("select * from weather"); + rs.next(); + } catch (SQLException e) { + e.printStackTrace(); + } + + // then + long actual = rs.getLong(1); + Assert.assertEquals(ms, actual); + actual = rs.getLong("ts"); + Assert.assertEquals(ms, actual); + } + + @Test + public void selectUsingStringValue() throws SQLException { + // given + String timestampStr = "2021-01-01 12:00:00.123456789"; + + // when + ResultSet rs = null; + try (Statement stmt = conn.createStatement()) { + stmt.executeUpdate("insert into weather(ts, temperature, humidity) values('" + timestampStr + "', 12.3, 4)"); + rs = stmt.executeQuery("select * from weather"); + rs.next(); + } catch (SQLException e) { + e.printStackTrace(); + } + + // then + String actual = rs.getString(1); + Assert.assertEquals(timestampStr, actual); + actual = rs.getString("ts"); + Assert.assertEquals(timestampStr, actual); + } + + @Test + public void selectUsingTimestampValue() throws SQLException { + // given + long timeMillis = System.currentTimeMillis(); + long epochSec = timeMillis / 1000; + long nanoAdjustment = (timeMillis % 1000) * 1000_000L + random.nextInt(1000_000); + Timestamp ts = Timestamp.from(Instant.ofEpochSecond(epochSec, nanoAdjustment)); + + // insert one row + String sql = "insert into weather(ts, temperature, humidity) values( ?, ?, ?)"; + try (PreparedStatement pstmt = conn.prepareStatement(sql)) { + pstmt.setTimestamp(1, ts); + pstmt.setFloat(2, 12.34f); + pstmt.setInt(3, 55); + pstmt.executeUpdate(); + } catch (SQLException e) { + e.printStackTrace(); + } + + // when + ResultSet rs = null; + try (Statement stmt = conn.createStatement()) { + rs = stmt.executeQuery("select * from weather"); + rs.next(); + } catch (SQLException e) { + e.printStackTrace(); + } + + // then + Timestamp actual = rs.getTimestamp(1); + Assert.assertEquals(ts, actual); + actual = rs.getTimestamp("ts"); + Assert.assertEquals(ts, actual); + Assert.assertEquals(timeMillis, actual.getTime()); + Assert.assertEquals(nanoAdjustment, actual.getNanos()); + } + + @Before + public void before() { + try (Statement stmt = conn.createStatement()) { + stmt.execute("drop table if exists weather"); + stmt.execute("create table weather(ts timestamp, temperature float, humidity int)"); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @BeforeClass + public static void beforeClass() { + final String url = "jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata"; + try { + conn = DriverManager.getConnection(url); + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname + " precision 'ns'"); + stmt.execute("use " + dbname); + } catch (SQLException e) { + e.printStackTrace(); + } + } + +} diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NanoSecondTimestampRestfulTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NanoSecondTimestampRestfulTest.java new file mode 100644 index 0000000000..4271f918b9 --- /dev/null +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NanoSecondTimestampRestfulTest.java @@ -0,0 +1,182 @@ +package com.taosdata.jdbc.cases; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.sql.*; +import java.time.Instant; +import java.util.Random; + +public class NanoSecondTimestampRestfulTest { + + private static final String host = "127.0.0.1"; + private static final String dbname = "nano_sec_test"; + private static final Random random = new Random(System.currentTimeMillis()); + private static Connection conn; + + @Test + public void insertUsingLongValue() { + // given + long ms = System.currentTimeMillis(); + long ns = ms * 1000_000 + random.nextInt(1000_000); + + // when + int ret = 0; + try (Statement stmt = conn.createStatement()) { + ret = stmt.executeUpdate("insert into weather(ts, temperature, humidity) values(" + ns + ", 12.3, 4)"); + } catch (SQLException e) { + e.printStackTrace(); + } + + // then + Assert.assertEquals(1, ret); + } + + @Test + public void insertUsingStringValue() { + // given + + // when + int ret = 0; + try (Statement stmt = conn.createStatement()) { + ret = stmt.executeUpdate("insert into weather(ts, temperature, humidity) values('2021-01-01 12:00:00.123456789', 12.3, 4)"); + } catch (SQLException e) { + e.printStackTrace(); + } + + // then + Assert.assertEquals(1, ret); + } + + @Test + public void insertUsingTimestampValue() { + // given + long epochSec = System.currentTimeMillis() / 1000; + long nanoAdjustment = random.nextInt(1000_000_000); + Timestamp ts = Timestamp.from(Instant.ofEpochSecond(epochSec, nanoAdjustment)); + + // when + int ret = 0; + String sql = "insert into weather(ts, temperature, humidity) values( ?, ?, ?)"; + try (PreparedStatement pstmt = conn.prepareStatement(sql)) { + pstmt.setTimestamp(1, ts); + pstmt.setFloat(2, 12.34f); + pstmt.setInt(3, 55); + ret = pstmt.executeUpdate(); + } catch (SQLException e) { + e.printStackTrace(); + } + + // then + Assert.assertEquals(1, ret); + } + + @Test + public void selectUsingLongValue() throws SQLException { + // given + long ms = System.currentTimeMillis(); + long ns = ms * 1000_000L + random.nextInt(1000_000); + + // when + ResultSet rs = null; + try (Statement stmt = conn.createStatement()) { + stmt.executeUpdate("insert into weather(ts, temperature, humidity) values(" + ns + ", 12.3, 4)"); + rs = stmt.executeQuery("select * from weather"); + rs.next(); + } catch (SQLException e) { + e.printStackTrace(); + } + + // then + long actual = rs.getLong(1); + Assert.assertEquals(ms, actual); + actual = rs.getLong("ts"); + Assert.assertEquals(ms, actual); + } + + @Test + public void selectUsingStringValue() throws SQLException { + // given + String timestampStr = "2021-01-01 12:00:00.123456789"; + + // when + ResultSet rs = null; + try (Statement stmt = conn.createStatement()) { + stmt.executeUpdate("insert into weather(ts, temperature, humidity) values('" + timestampStr + "', 12.3, 4)"); + rs = stmt.executeQuery("select * from weather"); + rs.next(); + } catch (SQLException e) { + e.printStackTrace(); + } + + // then + String actual = rs.getString(1); + Assert.assertEquals(timestampStr, actual); + actual = rs.getString("ts"); + Assert.assertEquals(timestampStr, actual); + } + + @Test + public void selectUsingTimestampValue() throws SQLException { + // given + long timeMillis = System.currentTimeMillis(); + long epochSec = timeMillis / 1000; + long nanoAdjustment = (timeMillis % 1000) * 1000_000L + random.nextInt(1000_000); + Timestamp ts = Timestamp.from(Instant.ofEpochSecond(epochSec, nanoAdjustment)); + + // insert one row + String sql = "insert into weather(ts, temperature, humidity) values( ?, ?, ?)"; + try (PreparedStatement pstmt = conn.prepareStatement(sql)) { + pstmt.setTimestamp(1, ts); + pstmt.setFloat(2, 12.34f); + pstmt.setInt(3, 55); + pstmt.executeUpdate(); + } catch (SQLException e) { + e.printStackTrace(); + } + + // when + ResultSet rs = null; + try (Statement stmt = conn.createStatement()) { + rs = stmt.executeQuery("select * from weather"); + rs.next(); + } catch (SQLException e) { + e.printStackTrace(); + } + + // then + Timestamp actual = rs.getTimestamp(1); + Assert.assertEquals(ts, actual); + actual = rs.getTimestamp("ts"); + Assert.assertEquals(ts, actual); + Assert.assertEquals(timeMillis, actual.getTime()); + Assert.assertEquals(nanoAdjustment, actual.getNanos()); + } + + @Before + public void before() { + try (Statement stmt = conn.createStatement()) { + stmt.execute("drop table if exists weather"); + stmt.execute("create table weather(ts timestamp, temperature float, humidity int)"); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @BeforeClass + public static void beforeClass() { + final String url = "jdbc:TAOS-RS://" + host + ":6041/?user=root&password=taosdata"; + try { + conn = DriverManager.getConnection(url); + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname + " precision 'ns'"); + stmt.execute("use " + dbname); + } catch (SQLException e) { + e.printStackTrace(); + } + } + +} diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetForJdbcJniTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetJNITest.java similarity index 97% rename from src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetForJdbcJniTest.java rename to src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetJNITest.java index 782125144c..076125a752 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetForJdbcJniTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetJNITest.java @@ -6,7 +6,7 @@ import org.junit.Test; import java.sql.*; -public class NullValueInResultSetForJdbcJniTest { +public class NullValueInResultSetJNITest { private static final String host = "127.0.0.1"; Connection conn; diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetForJdbcRestfulTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetRestfulTest.java similarity index 97% rename from src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetForJdbcRestfulTest.java rename to src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetRestfulTest.java index f2ac94adc1..ea6e36ec1d 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetForJdbcRestfulTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetRestfulTest.java @@ -6,7 +6,7 @@ import org.junit.Test; import java.sql.*; -public class NullValueInResultSetForJdbcRestfulTest { +public class NullValueInResultSetRestfulTest { private static final String host = "127.0.0.1"; Connection conn; diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TD3841Test.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetTest.java similarity index 99% rename from src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TD3841Test.java rename to src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetTest.java index c6fba81eb2..61d767b5cf 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TD3841Test.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetTest.java @@ -7,7 +7,7 @@ import org.junit.*; import java.sql.*; import java.util.Properties; -public class TD3841Test { +public class NullValueInResultSetTest { private static final String host = "127.0.0.1"; private static Properties properties; private static Connection conn_restful; diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/PreparedStatementBatchInsertJNITest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/PreparedStatementBatchInsertJNITest.java new file mode 100644 index 0000000000..ed78c2561e --- /dev/null +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/PreparedStatementBatchInsertJNITest.java @@ -0,0 +1,98 @@ +package com.taosdata.jdbc.cases; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.sql.*; +import java.util.List; +import java.util.Random; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +public class PreparedStatementBatchInsertJNITest { + + private static final String host = "127.0.0.1"; + private static final String dbname = "td4668"; + + private final Random random = new Random(System.currentTimeMillis()); + private Connection conn; + + @Test + public void test() { + // given + long ts = System.currentTimeMillis(); + List rows = IntStream.range(0, 10).mapToObj(i -> { + Object[] row = new Object[6]; + final String groupId = String.format("%02d", random.nextInt(100)); + // table name (d + groupId)组合 + row[0] = "d" + groupId; + // tag + row[1] = groupId; + // ts + row[2] = ts + i; + // current 电流 + row[3] = random.nextFloat(); + // voltage 电压 + row[4] = Math.random() > 0.5 ? 220 : 380; + // phase 相位 + row[5] = random.nextInt(10); + return row; + }).collect(Collectors.toList()); + final String sql = "INSERT INTO ? (TS,CURRENT,VOLTAGE,PHASE) USING METERS TAGS (?) VALUES (?,?,?,?)"; + + // when + try (PreparedStatement pstmt = conn.prepareStatement(sql)) { + for (Object[] row : rows) { + for (int i = 0; i < row.length; i++) { + pstmt.setObject(i + 1, row[i]); + } + pstmt.addBatch(); + } + pstmt.executeBatch(); + } catch (SQLException e) { + e.printStackTrace(); + Assert.fail(); + } + + // then + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from meters"); + int count = 0; + while (rs.next()) { + count++; + } + Assert.assertEquals(10, count); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @Before + public void before() { + try { + conn = DriverManager.getConnection("jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata"); + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname); + stmt.execute("use " + dbname); + stmt.execute("create table meters(ts timestamp, current float, voltage int, phase int) tags(groupId int)"); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @After + public void after() { + try { + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists " + dbname); + stmt.close(); + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + +} diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/PreparedStatementBatchInsertRestfulTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/PreparedStatementBatchInsertRestfulTest.java new file mode 100644 index 0000000000..90b285381a --- /dev/null +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/PreparedStatementBatchInsertRestfulTest.java @@ -0,0 +1,98 @@ +package com.taosdata.jdbc.cases; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.sql.*; +import java.util.List; +import java.util.Random; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +public class PreparedStatementBatchInsertRestfulTest { + + private static final String host = "127.0.0.1"; + private static final String dbname = "td4668"; + + private final Random random = new Random(System.currentTimeMillis()); + private Connection conn; + + @Test + public void test() { + // given + long ts = System.currentTimeMillis(); + List rows = IntStream.range(0, 10).mapToObj(i -> { + Object[] row = new Object[6]; + final String groupId = String.format("%02d", random.nextInt(100)); + // table name (d + groupId)组合 + row[0] = "d" + groupId; + // tag + row[1] = groupId; + // ts + row[2] = ts + i; + // current 电流 + row[3] = random.nextFloat(); + // voltage 电压 + row[4] = Math.random() > 0.5 ? 220 : 380; + // phase 相位 + row[5] = random.nextInt(10); + return row; + }).collect(Collectors.toList()); + final String sql = "INSERT INTO ? (TS,CURRENT,VOLTAGE,PHASE) USING METERS TAGS (?) VALUES (?,?,?,?)"; + + // when + try (PreparedStatement pstmt = conn.prepareStatement(sql)) { + for (Object[] row : rows) { + for (int i = 0; i < row.length; i++) { + pstmt.setObject(i + 1, row[i]); + } + pstmt.addBatch(); + } + pstmt.executeBatch(); + } catch (SQLException e) { + e.printStackTrace(); + Assert.fail(); + } + + // then + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from meters"); + int count = 0; + while (rs.next()) { + count++; + } + Assert.assertEquals(10, count); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @Before + public void before() { + try { + conn = DriverManager.getConnection("jdbc:TAOS-RS://" + host + ":6041/?user=root&password=taosdata"); + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname); + stmt.execute("use " + dbname); + stmt.execute("create table meters(ts timestamp, current float, voltage int, phase int) tags(groupId int)"); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @After + public void after() { + try { + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists " + dbname); + stmt.close(); + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + +} diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/ResultSetMetaShouldNotBeNullRestfulTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/ResultSetMetaShouldNotBeNullRestfulTest.java new file mode 100644 index 0000000000..f6d6bb2556 --- /dev/null +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/ResultSetMetaShouldNotBeNullRestfulTest.java @@ -0,0 +1,86 @@ +package com.taosdata.jdbc.cases; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.sql.*; + +public class ResultSetMetaShouldNotBeNullRestfulTest { + + private static final String host = "127.0.0.1"; + private static final String dbname = "td4745"; + + private Connection connection; + + @Test + public void testExecuteQuery() { + // given + ResultSetMetaData metaData = null; + int columnCount = -1; + + // when + try { + Statement statement = connection.createStatement(); + metaData = statement.executeQuery("select * from weather").getMetaData(); + columnCount = metaData.getColumnCount(); + } catch (SQLException e) { + e.printStackTrace(); + } + + // then + Assert.assertNotNull(metaData); + Assert.assertEquals(0, columnCount); + } + + @Test + public void testExecute() { + // given + ResultSetMetaData metaData = null; + int columnCount = -1; + boolean execute = false; + // when + try { + Statement statement = connection.createStatement(); + execute = statement.execute("select * from weather"); + metaData = statement.getResultSet().getMetaData(); + columnCount = metaData.getColumnCount(); + } catch (SQLException e) { + e.printStackTrace(); + } + + // then + Assert.assertEquals(true, execute); + Assert.assertNotNull(metaData); + Assert.assertEquals(0, columnCount); + } + + @Before + public void before() { + try { + connection = DriverManager.getConnection("jdbc:TAOS-RS://" + host + ":6041/?user=root&password=taosdata"); + Statement stmt = connection.createStatement(); + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname); + stmt.execute("use " + dbname); + stmt.execute("create table weather (ts timestamp, temperature float)"); + stmt.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @After + public void after() { + try { + Statement stmt = connection.createStatement(); + stmt.execute("drop database if exists " + dbname); + stmt.close(); + connection.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + +} diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TD4144Test.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TD4144Test.java deleted file mode 100644 index 6f29f64111..0000000000 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TD4144Test.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.taosdata.jdbc.cases; - -import com.taosdata.jdbc.TSDBConnection; -import com.taosdata.jdbc.TSDBDriver; -import com.taosdata.jdbc.TSDBResultSet; -import com.taosdata.jdbc.TSDBSubscribe; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.sql.DriverManager; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.Properties; -import java.util.concurrent.TimeUnit; - -public class TD4144Test { - - private static TSDBConnection connection; - private static final String host = "127.0.0.1"; - - private static final String topic = "topic-meter-current-bg-10"; - private static final String sql = "select * from meters where current > 10"; - private static final String sql2 = "select * from meters where ts >= '2020-08-15 12:20:00.000'"; - - - @Test - public void test() throws SQLException { - TSDBSubscribe subscribe = null; - TSDBResultSet res = null; - boolean hasNext = false; - - try { - subscribe = connection.subscribe(topic, sql, false); - int count = 0; - while (true) { - // 等待1秒,避免频繁调用 consume,给服务端造成压力 - TimeUnit.SECONDS.sleep(1); - if (res == null) { - // 消费数据 - res = subscribe.consume(); - hasNext = res.next(); - } - - if (res == null) { - continue; - } - ResultSetMetaData metaData = res.getMetaData(); - int number = 0; - while (hasNext) { - int columnCount = metaData.getColumnCount(); - for (int i = 1; i <= columnCount; i++) { - System.out.print(metaData.getColumnLabel(i) + ": " + res.getString(i) + "\t"); - } - System.out.println(); - count++; - number++; - hasNext = res.next(); - if (!hasNext) { - res.close(); - res = null; - System.out.println("rows: " + count); - } - if (hasNext == true && number >= 10) { - System.out.println("batch" + number); - break; - } - } - - } - - } catch (SQLException | InterruptedException throwables) { - throwables.printStackTrace(); - } finally { - if (subscribe != null) - subscribe.close(true); - } - } - - @BeforeClass - public static void beforeClass() throws SQLException { - Properties properties = new Properties(); - properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); - properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); - String url = "jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata"; - connection = (DriverManager.getConnection(url, properties)).unwrap(TSDBConnection.class); - try (Statement stmt = connection.createStatement()) { - stmt.execute("drop database if exists power"); - stmt.execute("create database if not exists power"); - stmt.execute("use power"); - stmt.execute("create table meters(ts timestamp, current float, voltage int, phase int) tags(location binary(64), groupId int)"); - stmt.execute("create table d1001 using meters tags(\"Beijing.Chaoyang\", 2)"); - stmt.execute("create table d1002 using meters tags(\"Beijing.Haidian\", 2)"); - stmt.execute("insert into d1001 values(\"2020-08-15 12:00:00.000\", 12, 220, 1),(\"2020-08-15 12:10:00.000\", 12.3, 220, 2),(\"2020-08-15 12:20:00.000\", 12.2, 220, 1)"); - stmt.execute("insert into d1002 values(\"2020-08-15 12:00:00.000\", 9.9, 220, 1),(\"2020-08-15 12:10:00.000\", 10.3, 220, 1),(\"2020-08-15 12:20:00.000\", 11.2, 220, 1)"); - } - } - - @AfterClass - public static void afterClass() throws SQLException { - if (connection != null) - connection.close(); - } -} diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/UtilsTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/UtilsTest.java index c861ef2966..ee83f6ceb2 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/UtilsTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/UtilsTest.java @@ -3,22 +3,98 @@ package com.taosdata.jdbc.utils; import org.junit.Assert; import org.junit.Test; -import static org.junit.Assert.*; +import java.util.stream.Stream; public class UtilsTest { @Test public void escapeSingleQuota() { + // given String s = "'''''a\\'"; + // when String news = Utils.escapeSingleQuota(s); + // then Assert.assertEquals("\\'\\'\\'\\'\\'a\\'", news); + // given s = "\'''''a\\'"; + // when news = Utils.escapeSingleQuota(s); + // then Assert.assertEquals("\\'\\'\\'\\'\\'a\\'", news); + // given s = "\'\'\'\''a\\'"; + // when news = Utils.escapeSingleQuota(s); + // then Assert.assertEquals("\\'\\'\\'\\'\\'a\\'", news); } + + @Test + public void getNativeSqlReplaceQuestionMarks() { + // given + String nativeSql = "insert into ?.? (ts, temperature, humidity) using ?.? tags(?,?) values(now, ?, ?)"; + Object[] parameters = Stream.of("test", "t1", "test", "weather", "beijing", 1, 12.2, 4).toArray(); + + // when + String actual = Utils.getNativeSql(nativeSql, parameters); + + // then + String expected = "insert into test.t1 (ts, temperature, humidity) using test.weather tags('beijing',1) values(now, 12.2, 4)"; + Assert.assertEquals(expected, actual); + } + + @Test + public void getNativeSqlReplaceQuestionMarks2() { + // given + String nativeSql = "INSERT INTO ? (TS,CURRENT,VOLTAGE,PHASE) USING METERS TAGS (?) VALUES (?,?,?,?)"; + Object[] parameters = Stream.of("d1", 1, 123, 3.14, 220, 4).toArray(); + + // when + String actual = Utils.getNativeSql(nativeSql, parameters); + + // then + String expected = "INSERT INTO d1 (TS,CURRENT,VOLTAGE,PHASE) USING METERS TAGS (1) VALUES (123,3.14,220,4)"; + Assert.assertEquals(expected, actual); + } + + + @Test + public void getNativeSqlReplaceNothing() { + // given + String nativeSql = "insert into test.t1 (ts, temperature, humidity) using test.weather tags('beijing',1) values(now, 12.2, 4)"; + + // when + String actual = Utils.getNativeSql(nativeSql, null); + + // then + Assert.assertEquals(nativeSql, actual); + } + + @Test + public void getNativeSqlReplaceNothing2() { + // given + String nativeSql = "insert into test.t1 (ts, temperature, humidity) using test.weather tags('beijing',1) values(now, 12.2, 4)"; + Object[] parameters = Stream.of("test", "t1", "test", "weather", "beijing", 1, 12.2, 4).toArray(); + + // when + String actual = Utils.getNativeSql(nativeSql, parameters); + + // then + Assert.assertEquals(nativeSql, actual); + } + + @Test + public void getNativeSqlReplaceNothing3() { + // given + String nativeSql = "insert into ?.? (ts, temperature, humidity) using ?.? tags(?,?) values(now, ?, ?)"; + + // when + String actual = Utils.getNativeSql(nativeSql, null); + + // then + Assert.assertEquals(nativeSql, actual); + + } } \ No newline at end of file From f7580dc4376d1ce8085331bb11143d3d5467c256 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 18 Jun 2021 13:31:26 +0800 Subject: [PATCH 18/21] [td-225]fix crash during query. --- src/client/src/tscSQLParser.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 79d9b6e8e3..38d1b33d02 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -423,18 +423,6 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { if(code != TSDB_CODE_SUCCESS) { return code; } - - if (pInfo->pMiscInfo->tableType == TSDB_SUPER_TABLE) { -//// code = tscGetTableMeta(pSql, pTableMetaInfo); -//// if (code != TSDB_CODE_SUCCESS) { -//// return code; -//// } -// -// if (!UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { -// return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); -// } - } - } else if (pInfo->type == TSDB_SQL_DROP_DNODE) { if (pzName->type == TK_STRING) { pzName->n = strdequote(pzName->z); @@ -772,6 +760,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { pCmd->active = pCmd->pQueryInfo; pCmd->command = pCmd->pQueryInfo->command; + STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pCmd->active, 0); if (pTableMetaInfo->pTableMeta != NULL) { pSql->res.precision = tscGetTableInfo(pTableMetaInfo->pTableMeta).precision; } @@ -7793,7 +7782,7 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf } } - // todo derivate funtion requires ts column exists in subquery + // todo derivative function requires ts column exists in subquery STableMeta* pTableMeta = tscGetMetaInfo(pQueryInfo, 0)->pTableMeta; SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, 0); From dbe8dd40c1a80fbc13375ef267070d72bb250e40 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Fri, 18 Jun 2021 05:45:05 +0000 Subject: [PATCH 19/21] [TD-4690]script:check install package --- packaging/check_package.sh | 245 +++++++++++++++++++++++++++++++++++++ 1 file changed, 245 insertions(+) create mode 100755 packaging/check_package.sh diff --git a/packaging/check_package.sh b/packaging/check_package.sh new file mode 100755 index 0000000000..e4d783d2f9 --- /dev/null +++ b/packaging/check_package.sh @@ -0,0 +1,245 @@ +#!/bin/bash +# +# This file is used to install database on linux systems. The operating system +# is required to use systemd to manage services at boot + +set -e +#set -x + +verMode=edge +pagMode=full + +iplist="" +serverFqdn="" + +# -----------------------Variables definition--------------------- +script_dir="../release" +# Dynamic directory +data_dir="/var/lib/taos" +log_dir="/var/log/taos" + +data_link_dir="/usr/local/taos/data" +log_link_dir="/usr/local/taos/log" + +cfg_install_dir="/etc/taos" + +bin_link_dir="/usr/bin" +lib_link_dir="/usr/lib" +lib64_link_dir="/usr/lib64" +inc_link_dir="/usr/include" + +#install main path +install_main_dir="/usr/local/taos" + +# old bin dir +sbin_dir="/usr/local/taos/bin" + +temp_version="" +fin_result="" + +service_config_dir="/etc/systemd/system" +nginx_port=6060 +nginx_dir="/usr/local/nginxd" + +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' + +csudo="" +if command -v sudo > /dev/null; then + csudo="sudo" +fi + +# ============================= get input parameters ================================================= + +# install.sh -v [server | client] -e [yes | no] -i [systemd | service | ...] + +# set parameters by default value +interactiveFqdn=yes # [yes | no] +verType=server # [server | client] +initType=systemd # [systemd | service | ...] + +while getopts "hv:d:" arg +do + case $arg in + d) + #echo "interactiveFqdn=$OPTARG" + script_dir=$( echo $OPTARG ) + ;; + h) + echo "Usage: `basename $0` -d scripy_path" + exit 0 + ;; + ?) #unknow option + echo "unkonw argument" + exit 1 + ;; + esac +done + +#echo "verType=${verType} interactiveFqdn=${interactiveFqdn}" + +function kill_process() { + pid=$(ps -ef | grep "$1" | grep -v "grep" | awk '{print $2}') + if [ -n "$pid" ]; then + ${csudo} kill -9 $pid || : + fi +} + +function check_file() { + #check file whether exists + if [ ! -e $1/$2 ];then + echo -e "$1/$2 \033[31mnot exists\033[0m!quit" + fin_result=$fin_result"\033[31m$temp_version\033[0m test failed!\n" + echo -e $fin_result + exit 8 + fi +} + +function get_package_name() { + var=$1 + if [[ $1 =~ 'aarch' ]];then + echo ${var::-21} + else + echo ${var::-17} + fi +} +function check_link() { + #check Link whether exists or broken + if [ -L $1 ] ; then + if [ ! -e $1 ] ; then + echo -e "$1 \033[31Broken link\033[0m" + fin_result=$fin_result"\033[31m$temp_version\033[0m test failed!\n" + echo -e $fin_result + exit 8 + fi + else + echo -e "$1 \033[31mnot exists\033[0m!quit" + fin_result=$fin_result"\033[31m$temp_version\033[0m test failed!\n" + echo -e $fin_result + exit 8 + fi +} + +function check_main_path() { + #check install main dir and all sub dir + main_dir=("" "cfg" "bin" "connector" "driver" "examples" "include" "init.d") + for i in ${main_dir[@]};do + check_file ${install_main_dir} $i + done + if [ "$verMode" == "cluster" ]; then + nginx_main_dir=("admin" "conf" "html" "sbin" "logs") + for i in ${nginx_main_dir[@]};do + check_file ${nginx_dir} $i + done + fi + echo -e "Check main path:\033[32mOK\033[0m!" +} + +function check_bin_path() { + # check install bin dir and all sub dir + bin_dir=("taos" "taosd" "taosdemo" "taosdump" "remove.sh" "tarbitrator" "set_core.sh") + for i in ${bin_dir[@]};do + check_file ${sbin_dir} $i + done + lbin_dir=("taos" "taosd" "taosdemo" "taosdump" "rmtaos" "tarbitrator" "set_core") + for i in ${lbin_dir[@]};do + check_link ${bin_link_dir}/$i + done + if [ "$verMode" == "cluster" ]; then + check_file ${nginx_dir}/sbin nginx + fi + echo -e "Check bin path:\033[32mOK\033[0m!" +} + + +function check_lib_path() { + # check all links + check_link ${lib_link_dir}/libtaos.so + check_link ${lib_link_dir}/libtaos.so.1 + + if [[ -d ${lib64_link_dir} ]]; then + check_link ${lib64_link_dir}/libtaos.so + check_link ${lib64_link_dir}/libtaos.so.1 + fi + echo -e "Check lib path:\033[32mOK\033[0m!" +} + + +function check_header_path() { + # check all header + header_dir=("taos.h" "taoserror.h") + for i in ${header_dir[@]};do + check_link ${inc_link_dir}/$i + done + echo -e "Check bin path:\033[32mOK\033[0m!" +} + + +function check_config_dir() { + # check all config + check_file ${cfg_install_dir} taos.cfg + check_file ${install_main_dir}/cfg taos.cfg.org + echo -e "Check conf path:\033[32mOK\033[0m!" +} + +function check_log_path() { + # check log path + check_file ${log_dir} + echo -e "Check log path:\033[32mOK\033[0m!" +} + +function check_data_path() { + # check data path + check_file ${data_dir} + echo -e "Check data path:\033[32mOK\033[0m!" +} + +function install_TDengine() { + cd ${script_dir} + tar zxf $1 + temp_version=$(get_package_name $1) + cd $(get_package_name $1) + echo -e "\033[32muninstall TDengine && install TDengine...\033[0m" + rmtaos >/dev/null 2>&1 || echo 'taosd not installed' && echo -e '\n\n' |./install.sh >/dev/null 2>&1 + echo -e "\033[32mTDengine has been installed!\033[0m" + echo -e "\033[32mTDengine is starting...\033[0m" + kill_process taos && systemctl start taosd && sleep 10 +} + +function test_TDengine() { + check_main_path + check_bin_path + check_lib_path + check_header_path + check_config_dir + check_log_path + check_data_path + result=`taos -s 'create database test ;create table test.tt(ts timestamp ,i int);insert into test.tt values(now,11);select * from test.tt' 2>&1 ||:` + if [[ $result =~ "Unable to establish" ]];then + echo -e "\033[31mTDengine connect failed\033[0m" + fin_result=$fin_result"\033[31m$temp_version\033[0m test failed!\n" + echo -e $fin_result + exit 8 + fi + echo -e "Check TDengine connect:\033[32mOK\033[0m!" + fin_result=$fin_result"\033[32m$temp_version\033[0m test OK!\n" +} +# ## ==============================Main program starts from here============================ +TD_package_name=`ls ${script_dir}/*server*gz |awk -F '/' '{print $NF}' ` +temp=`pwd` +for i in $TD_package_name;do + if [[ $i =~ 'enterprise' ]];then + verMode="cluster" + else + verMode="" + fi + cd $temp + install_TDengine $i + test_TDengine +done +echo "============================================================" +echo -e $fin_result \ No newline at end of file From bd1b2a84a89206e474eb4a72adc3de4af99c9b5b Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 18 Jun 2021 13:56:09 +0800 Subject: [PATCH 20/21] [td-225]fix compiler error. --- src/client/src/tscSQLParser.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 38d1b33d02..0ab7c38186 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -760,9 +760,9 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { pCmd->active = pCmd->pQueryInfo; pCmd->command = pCmd->pQueryInfo->command; - STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pCmd->active, 0); - if (pTableMetaInfo->pTableMeta != NULL) { - pSql->res.precision = tscGetTableInfo(pTableMetaInfo->pTableMeta).precision; + STableMetaInfo* pTableMetaInfo1 = tscGetMetaInfo(pCmd->active, 0); + if (pTableMetaInfo1->pTableMeta != NULL) { + pSql->res.precision = tscGetTableInfo(pTableMetaInfo1->pTableMeta).precision; } return TSDB_CODE_SUCCESS; // do not build query message here From 945354280cbf386fbb9338a39d0eca3c1a51afb1 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Fri, 18 Jun 2021 18:34:54 +0800 Subject: [PATCH 21/21] Feature/sangshuduo/td 4752 python support ns (#6534) * [TD-4752]: python connector support nanosecond. * [TD-4752]: support nanosecond in test framework. return integer for nanosecond in connector since python does not support nanosecond yet. --- src/connector/python/taos/cinterface.py | 2 +- tests/pytest/util/sql.py | 38 +++++++++++++++---------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/connector/python/taos/cinterface.py b/src/connector/python/taos/cinterface.py index 61a2a0e9c7..cc7c279458 100644 --- a/src/connector/python/taos/cinterface.py +++ b/src/connector/python/taos/cinterface.py @@ -15,7 +15,7 @@ def _convert_microsecond_to_datetime(micro): def _convert_nanosecond_to_datetime(nanosec): - return datetime.datetime.fromtimestamp(nanosec / 1000000000.0) + return nanosec def _crow_timestamp_to_python(data, num_of_rows, nbytes=None, precision=FieldType.C_TIMESTAMP_UNKNOWN): diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index 8f62c5932b..913c158d05 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -18,6 +18,7 @@ import datetime import inspect import psutil import shutil +import pandas as pd from util.log import * @@ -134,25 +135,32 @@ class TDSql: return self.cursor.istype(col, dataType) def checkData(self, row, col, data): - self.checkRowCol(row, col) - if self.queryResult[row][col] != data: - if self.cursor.istype(col, "TIMESTAMP") and self.queryResult[row][col] == datetime.datetime.fromisoformat(data): - tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + self.checkRowCol(row, col) + if self.queryResult[row][col] != data: + if self.cursor.istype(col, "TIMESTAMP"): + # suppose user want to check nanosecond timestamp if a longer data passed + if (len(data) >= 28): + if pd.to_datetime(self.queryResult[row][col]) == pd.to_datetime(data): + tdLog.info("sql:%s, row:%d col:%d data:%d == expect:%s" % + (self.sql, row, col, self.queryResult[row][col], data)) + else: + if self.queryResult[row][col] == datetime.datetime.fromisoformat(data): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % (self.sql, row, col, self.queryResult[row][col], data)) return if str(self.queryResult[row][col]) == str(data): tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % - (self.sql, row, col, self.queryResult[row][col], data)) + (self.sql, row, col, self.queryResult[row][col], data)) return - elif isinstance(data, float) and abs(self.queryResult[row][col] - data) <= 0.000001: + elif isinstance(data, float) and abs(self.queryResult[row][col] - data) <= 0.000001: tdLog.info("sql:%s, row:%d col:%d data:%f == expect:%f" % - (self.sql, row, col, self.queryResult[row][col], data)) + (self.sql, row, col, self.queryResult[row][col], data)) return else: caller = inspect.getframeinfo(inspect.stack()[1][0]) args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) - tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) + tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) if data is None: tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % @@ -162,11 +170,11 @@ class TDSql: (self.sql, row, col, self.queryResult[row][col], data)) elif isinstance(data, datetime.date): tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % - (self.sql, row, col, self.queryResult[row][col], data)) + (self.sql, row, col, self.queryResult[row][col], data)) elif isinstance(data, float): tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % (self.sql, row, col, self.queryResult[row][col], data)) - else: + else: tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%d" % (self.sql, row, col, self.queryResult[row][col], data)) @@ -200,7 +208,7 @@ class TDSql: tdLog.exit("%s(%d) failed: sql:%s, affectedRows:%d != expect:%d" % args) tdLog.info("sql:%s, affectedRows:%d == expect:%d" % (self.sql, self.affectedRows, expectAffectedRows)) - + def taosdStatus(self, state): tdLog.sleep(5) pstate = 0 @@ -221,7 +229,7 @@ class TDSql: continue pstate = 0 break - + args=(pstate,state) if pstate == state: tdLog.info("taosd state is %d == expect:%d" %args) @@ -236,11 +244,11 @@ class TDSql: tdLog.exit("dir: %s is empty, expect: not empty" %dir) else: tdLog.info("dir: %s is empty, expect: empty" %dir) - else: + else: if state : tdLog.info("dir: %s is not empty, expect: not empty" %dir) else: - tdLog.exit("dir: %s is not empty, expect: empty" %dir) + tdLog.exit("dir: %s is not empty, expect: empty" %dir) else: tdLog.exit("dir: %s doesn't exist" %dir) def createDir(self, dir): @@ -250,5 +258,5 @@ class TDSql: os.makedirs( dir, 755 ) tdLog.info("dir: %s is created" %dir) pass - + tdSql = TDSql()