From cfe442258070cc29161ae2dd556a07946d88f9e2 Mon Sep 17 00:00:00 2001 From: zyyang Date: Mon, 11 Jan 2021 18:12:30 +0800 Subject: [PATCH 01/21] [TD-2695]: change jdbc unit test cases --- .../com/taosdata/taosdemo/TaosDemoApplication.java | 8 +++----- .../com/taosdata/taosdemo/dao/DatabaseMapperImpl.java | 8 ++++---- .../com/taosdata/taosdemo/dao/SubTableMapperImpl.java | 10 +++++----- .../taosdata/taosdemo/dao/SuperTableMapperImpl.java | 4 ++-- .../com/taosdata/taosdemo/dao/TableMapperImpl.java | 8 +++++++- .../JDBC/taosdemo/src/main/resources/log4j.properties | 2 +- 6 files changed, 22 insertions(+), 18 deletions(-) diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/TaosDemoApplication.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/TaosDemoApplication.java index b9a22a1ef7..4dc49fd37b 100644 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/TaosDemoApplication.java +++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/TaosDemoApplication.java @@ -19,14 +19,13 @@ import java.util.Map; public class TaosDemoApplication { - private static Logger logger = Logger.getLogger(TaosDemoApplication.class); + private static final Logger logger = Logger.getLogger(TaosDemoApplication.class); public static void main(String[] args) throws IOException { // 读配置参数 JdbcTaosdemoConfig config = new JdbcTaosdemoConfig(args); boolean isHelp = Arrays.asList(args).contains("--help"); if (isHelp || config.host == null || config.host.isEmpty()) { -// if (isHelp) { JdbcTaosdemoConfig.printHelp(); System.exit(0); } @@ -75,7 +74,7 @@ public class TaosDemoApplication { } } end = System.currentTimeMillis(); - logger.error(">>> create table time cost : " + (end - start) + " ms."); + logger.info(">>> create table time cost : " + (end - start) + " ms."); /**********************************************************************************/ // 插入 long tableSize = config.numOfTables; @@ -90,7 +89,7 @@ public class TaosDemoApplication { // multi threads to insert int affectedRows = subTableService.insertMultiThreads(superTableMeta, threadSize, tableSize, startTime, gap, config); end = System.currentTimeMillis(); - logger.error("insert " + affectedRows + " rows, time cost: " + (end - start) + " ms"); + logger.info("insert " + affectedRows + " rows, time cost: " + (end - start) + " ms"); /**********************************************************************************/ // 删除表 if (config.dropTable) { @@ -108,5 +107,4 @@ public class TaosDemoApplication { return startTime; } - } diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/DatabaseMapperImpl.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/DatabaseMapperImpl.java index 69bae160f6..421a2dea1f 100644 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/DatabaseMapperImpl.java +++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/DatabaseMapperImpl.java @@ -21,27 +21,27 @@ public class DatabaseMapperImpl implements DatabaseMapper { public void createDatabase(String dbname) { String sql = "create database if not exists " + dbname; jdbcTemplate.execute(sql); - logger.info("SQL >>> " + sql); + logger.debug("SQL >>> " + sql); } @Override public void dropDatabase(String dbname) { String sql = "drop database if exists " + dbname; jdbcTemplate.update(sql); - logger.info("SQL >>> " + sql); + logger.debug("SQL >>> " + sql); } @Override public void createDatabaseWithParameters(Map map) { String sql = SqlSpeller.createDatabase(map); jdbcTemplate.execute(sql); - logger.info("SQL >>> " + sql); + logger.debug("SQL >>> " + sql); } @Override public void useDatabase(String dbname) { String sql = "use " + dbname; jdbcTemplate.execute(sql); - logger.info("SQL >>> " + sql); + logger.debug("SQL >>> " + sql); } } diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SubTableMapperImpl.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SubTableMapperImpl.java index e3a6691430..90b0990a2b 100644 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SubTableMapperImpl.java +++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SubTableMapperImpl.java @@ -21,14 +21,14 @@ public class SubTableMapperImpl implements SubTableMapper { @Override public void createUsingSuperTable(SubTableMeta subTableMeta) { String sql = SqlSpeller.createTableUsingSuperTable(subTableMeta); - logger.info("SQL >>> " + sql); + logger.debug("SQL >>> " + sql); jdbcTemplate.execute(sql); } @Override public int insertOneTableMultiValues(SubTableValue subTableValue) { String sql = SqlSpeller.insertOneTableMultiValues(subTableValue); - logger.info("SQL >>> " + sql); + logger.debug("SQL >>> " + sql); int affectRows = 0; try { @@ -42,7 +42,7 @@ public class SubTableMapperImpl implements SubTableMapper { @Override public int insertOneTableMultiValuesUsingSuperTable(SubTableValue subTableValue) { String sql = SqlSpeller.insertOneTableMultiValuesUsingSuperTable(subTableValue); - logger.info("SQL >>> " + sql); + logger.debug("SQL >>> " + sql); int affectRows = 0; try { @@ -56,7 +56,7 @@ public class SubTableMapperImpl implements SubTableMapper { @Override public int insertMultiTableMultiValues(List tables) { String sql = SqlSpeller.insertMultiSubTableMultiValues(tables); - logger.info("SQL >>> " + sql); + logger.debug("SQL >>> " + sql); int affectRows = 0; try { affectRows = jdbcTemplate.update(sql); @@ -69,7 +69,7 @@ public class SubTableMapperImpl implements SubTableMapper { @Override public int insertMultiTableMultiValuesUsingSuperTable(List tables) { String sql = SqlSpeller.insertMultiTableMultiValuesUsingSuperTable(tables); - logger.info("SQL >>> " + sql); + logger.debug("SQL >>> " + sql); int affectRows = 0; try { affectRows = jdbcTemplate.update(sql); diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SuperTableMapperImpl.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SuperTableMapperImpl.java index a293de5100..efa9a1f39e 100644 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SuperTableMapperImpl.java +++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SuperTableMapperImpl.java @@ -18,14 +18,14 @@ public class SuperTableMapperImpl implements SuperTableMapper { @Override public void createSuperTable(SuperTableMeta tableMetadata) { String sql = SqlSpeller.createSuperTable(tableMetadata); - logger.info("SQL >>> " + sql); + logger.debug("SQL >>> " + sql); jdbcTemplate.execute(sql); } @Override public void dropSuperTable(String database, String name) { String sql = "drop table if exists " + database + "." + name; - logger.info("SQL >>> " + sql); + logger.debug("SQL >>> " + sql); jdbcTemplate.execute(sql); } } diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/TableMapperImpl.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/TableMapperImpl.java index 77415619f0..b049fbe197 100644 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/TableMapperImpl.java +++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/TableMapperImpl.java @@ -1,43 +1,49 @@ package com.taosdata.taosdemo.dao; -import com.taosdata.taosdemo.dao.TableMapper; import com.taosdata.taosdemo.domain.TableMeta; import com.taosdata.taosdemo.domain.TableValue; import com.taosdata.taosdemo.utils.SqlSpeller; +import org.apache.log4j.Logger; import org.springframework.jdbc.core.JdbcTemplate; import java.util.List; public class TableMapperImpl implements TableMapper { + private static final Logger logger = Logger.getLogger(TableMapperImpl.class); private JdbcTemplate template; @Override public void create(TableMeta tableMeta) { String sql = SqlSpeller.createTable(tableMeta); + logger.debug("SQL >>> " + sql); template.execute(sql); } @Override public int insertOneTableMultiValues(TableValue values) { String sql = SqlSpeller.insertOneTableMultiValues(values); + logger.debug("SQL >>> " + sql); return template.update(sql); } @Override public int insertOneTableMultiValuesWithColumns(TableValue values) { String sql = SqlSpeller.insertOneTableMultiValuesWithColumns(values); + logger.debug("SQL >>> " + sql); return template.update(sql); } @Override public int insertMultiTableMultiValues(List tables) { String sql = SqlSpeller.insertMultiTableMultiValues(tables); + logger.debug("SQL >>> " + sql); return template.update(sql); } @Override public int insertMultiTableMultiValuesWithColumns(List tables) { String sql = SqlSpeller.insertMultiTableMultiValuesWithColumns(tables); + logger.debug("SQL >>> " + sql); return template.update(sql); } } diff --git a/tests/examples/JDBC/taosdemo/src/main/resources/log4j.properties b/tests/examples/JDBC/taosdemo/src/main/resources/log4j.properties index b2a9586ea7..352545854d 100644 --- a/tests/examples/JDBC/taosdemo/src/main/resources/log4j.properties +++ b/tests/examples/JDBC/taosdemo/src/main/resources/log4j.properties @@ -1,5 +1,5 @@ ### 设置### -log4j.rootLogger=error,stdout +log4j.rootLogger=info,stdout ### 输出信息到控制抬 ### log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out From ebf3b3a61e6439bd70535be27bb731457a9e3647 Mon Sep 17 00:00:00 2001 From: zyyang Date: Tue, 12 Jan 2021 11:31:51 +0800 Subject: [PATCH 02/21] change --- cmake/install.inc | 2 +- src/connector/jdbc/.classpath | 32 ------------------- src/connector/jdbc/.project | 23 ------------- src/connector/jdbc/CMakeLists.txt | 2 +- src/connector/jdbc/deploy-pom.xml | 2 +- src/connector/jdbc/pom.xml | 15 ++------- .../taosdata/jdbc/TSDBDatabaseMetaData.java | 16 +++++++--- 7 files changed, 16 insertions(+), 76 deletions(-) delete mode 100644 src/connector/jdbc/.classpath delete mode 100644 src/connector/jdbc/.project diff --git a/cmake/install.inc b/cmake/install.inc index 55b3fa188f..b0e5c71022 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.15-dist.jar DESTINATION connector/jdbc) + INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.16-dist.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/.classpath b/src/connector/jdbc/.classpath deleted file mode 100644 index a5d95095cc..0000000000 --- a/src/connector/jdbc/.classpath +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/connector/jdbc/.project b/src/connector/jdbc/.project deleted file mode 100644 index 656ab58d20..0000000000 --- a/src/connector/jdbc/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - taos-jdbcdriver - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - - diff --git a/src/connector/jdbc/CMakeLists.txt b/src/connector/jdbc/CMakeLists.txt index e289f1ae1b..fda0289a2a 100644 --- a/src/connector/jdbc/CMakeLists.txt +++ b/src/connector/jdbc/CMakeLists.txt @@ -8,7 +8,7 @@ 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.15-dist.jar ${LIBRARY_OUTPUT_PATH} + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.16-dist.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}) diff --git a/src/connector/jdbc/deploy-pom.xml b/src/connector/jdbc/deploy-pom.xml index 1a86bc57dc..5aa60c0df9 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.15 + 2.0.16 jar JDBCDriver diff --git a/src/connector/jdbc/pom.xml b/src/connector/jdbc/pom.xml index 9865fc7127..d18d86258a 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.15 + 2.0.16 jar JDBCDriver https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc @@ -49,6 +49,7 @@ + junit junit @@ -56,12 +57,6 @@ test - - mysql - mysql-connector-java - 5.1.47 - - org.apache.httpcomponents @@ -79,12 +74,6 @@ 1.2.58 - - mysql - mysql-connector-java - 5.1.49 - - diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java index f4dee67adf..7b404c3844 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java @@ -35,12 +35,18 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { this.conn = conn; } + + @Override public T unwrap(Class iface) throws SQLException { - return null; + try { + return iface.cast(this); + } catch (ClassCastException cce) { + throw new SQLException("Unable to unwrap to " + iface.toString()); + } } public boolean isWrapperFor(Class iface) throws SQLException { - return false; + return iface.isInstance(this); } public boolean allProceduresAreCallable() throws SQLException { @@ -80,11 +86,11 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { } public String getDatabaseProductName() throws SQLException { - return this.dbProductName; + return "TDengine"; } public String getDatabaseProductVersion() throws SQLException { - return "1.5.1"; + return "2.0.x.x"; } public String getDriverName() throws SQLException { @@ -92,7 +98,7 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { } public String getDriverVersion() throws SQLException { - return "1.0.0"; + return "2.0.x"; } public int getDriverMajorVersion() { From 53fd2f9ab8191f54b6e08a3b7fa28b3edbe06904 Mon Sep 17 00:00:00 2001 From: zyyang Date: Tue, 12 Jan 2021 13:28:56 +0800 Subject: [PATCH 03/21] change --- .../src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java | 1 - .../src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java index 7b404c3844..c069fccf00 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java @@ -35,7 +35,6 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { this.conn = conn; } - @Override public T unwrap(Class iface) throws SQLException { try { diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java index 19dabe0746..27263073ff 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java @@ -231,9 +231,9 @@ public class DatabaseMetaDataTest { databaseMetaData.getFunctionColumns("", "", "", ""); databaseMetaData.getPseudoColumns("", "", "", ""); databaseMetaData.generatedKeyAlwaysReturned(); - } + @AfterClass public static void close() throws Exception { statement.executeUpdate("drop database " + dbName); From abe156f65beb0f959caac6e7037a25af98c0b7b5 Mon Sep 17 00:00:00 2001 From: zyyang Date: Tue, 12 Jan 2021 13:35:11 +0800 Subject: [PATCH 04/21] change --- .../jdbc/TSDBDatabaseMetaDataTest.java | 737 ++++++++++++++++++ 1 file changed, 737 insertions(+) create mode 100644 src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java new file mode 100644 index 0000000000..e9b01ef728 --- /dev/null +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java @@ -0,0 +1,737 @@ +package com.taosdata.jdbc; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.sql.DatabaseMetaData; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.Properties; + +import static org.junit.Assert.*; + +public class TSDBDatabaseMetaDataTest { + private TSDBDatabaseMetaData metaData; + private static final String host = "localhost"; + + @Before + public void before() throws ClassNotFoundException, SQLException { + 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"); + metaData = (TSDBDatabaseMetaData) DriverManager.getConnection("jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata", properties).getMetaData(); + } + + @Test + public void unwrap() throws SQLException { + TSDBDatabaseMetaData unwrap = metaData.unwrap(TSDBDatabaseMetaData.class); + Assert.assertNotNull(unwrap); + } + + @Test + public void isWrapperFor() throws SQLException { + Assert.assertTrue(metaData.isWrapperFor(TSDBDatabaseMetaData.class)); + } + + @Test + public void allProceduresAreCallable() throws SQLException { + Assert.assertFalse(metaData.allProceduresAreCallable()); + } + + @Test + public void allTablesAreSelectable() { + } + + @Test + public void getURL() { + } + + @Test + public void getUserName() { + } + + @Test + public void isReadOnly() { + } + + @Test + public void nullsAreSortedHigh() { + } + + @Test + public void nullsAreSortedLow() { + } + + @Test + public void nullsAreSortedAtStart() { + } + + @Test + public void nullsAreSortedAtEnd() { + } + + @Test + public void getDatabaseProductName() { + } + + @Test + public void getDatabaseProductVersion() { + } + + @Test + public void getDriverName() { + } + + @Test + public void getDriverVersion() { + } + + @Test + public void getDriverMajorVersion() { + } + + @Test + public void getDriverMinorVersion() { + } + + @Test + public void usesLocalFiles() { + } + + @Test + public void usesLocalFilePerTable() { + } + + @Test + public void supportsMixedCaseIdentifiers() { + } + + @Test + public void storesUpperCaseIdentifiers() { + } + + @Test + public void storesLowerCaseIdentifiers() { + } + + @Test + public void storesMixedCaseIdentifiers() { + } + + @Test + public void supportsMixedCaseQuotedIdentifiers() { + } + + @Test + public void storesUpperCaseQuotedIdentifiers() { + } + + @Test + public void storesLowerCaseQuotedIdentifiers() { + } + + @Test + public void storesMixedCaseQuotedIdentifiers() { + } + + @Test + public void getIdentifierQuoteString() { + } + + @Test + public void getSQLKeywords() { + } + + @Test + public void getNumericFunctions() { + } + + @Test + public void getStringFunctions() { + } + + @Test + public void getSystemFunctions() { + } + + @Test + public void getTimeDateFunctions() { + } + + @Test + public void getSearchStringEscape() { + } + + @Test + public void getExtraNameCharacters() { + } + + @Test + public void supportsAlterTableWithAddColumn() { + } + + @Test + public void supportsAlterTableWithDropColumn() { + } + + @Test + public void supportsColumnAliasing() { + } + + @Test + public void nullPlusNonNullIsNull() { + } + + @Test + public void supportsConvert() { + } + + @Test + public void testSupportsConvert() { + } + + @Test + public void supportsTableCorrelationNames() { + } + + @Test + public void supportsDifferentTableCorrelationNames() { + } + + @Test + public void supportsExpressionsInOrderBy() { + } + + @Test + public void supportsOrderByUnrelated() { + } + + @Test + public void supportsGroupBy() { + } + + @Test + public void supportsGroupByUnrelated() { + } + + @Test + public void supportsGroupByBeyondSelect() { + } + + @Test + public void supportsLikeEscapeClause() { + } + + @Test + public void supportsMultipleResultSets() { + } + + @Test + public void supportsMultipleTransactions() { + } + + @Test + public void supportsNonNullableColumns() { + } + + @Test + public void supportsMinimumSQLGrammar() { + } + + @Test + public void supportsCoreSQLGrammar() { + } + + @Test + public void supportsExtendedSQLGrammar() { + } + + @Test + public void supportsANSI92EntryLevelSQL() { + } + + @Test + public void supportsANSI92IntermediateSQL() { + } + + @Test + public void supportsANSI92FullSQL() { + } + + @Test + public void supportsIntegrityEnhancementFacility() { + } + + @Test + public void supportsOuterJoins() { + } + + @Test + public void supportsFullOuterJoins() { + } + + @Test + public void supportsLimitedOuterJoins() { + } + + @Test + public void getSchemaTerm() { + } + + @Test + public void getProcedureTerm() { + } + + @Test + public void getCatalogTerm() { + } + + @Test + public void isCatalogAtStart() { + } + + @Test + public void getCatalogSeparator() { + } + + @Test + public void supportsSchemasInDataManipulation() { + } + + @Test + public void supportsSchemasInProcedureCalls() { + } + + @Test + public void supportsSchemasInTableDefinitions() { + } + + @Test + public void supportsSchemasInIndexDefinitions() { + } + + @Test + public void supportsSchemasInPrivilegeDefinitions() { + } + + @Test + public void supportsCatalogsInDataManipulation() { + } + + @Test + public void supportsCatalogsInProcedureCalls() { + } + + @Test + public void supportsCatalogsInTableDefinitions() { + } + + @Test + public void supportsCatalogsInIndexDefinitions() { + } + + @Test + public void supportsCatalogsInPrivilegeDefinitions() { + } + + @Test + public void supportsPositionedDelete() { + } + + @Test + public void supportsPositionedUpdate() { + } + + @Test + public void supportsSelectForUpdate() { + } + + @Test + public void supportsStoredProcedures() { + } + + @Test + public void supportsSubqueriesInComparisons() { + } + + @Test + public void supportsSubqueriesInExists() { + } + + @Test + public void supportsSubqueriesInIns() { + } + + @Test + public void supportsSubqueriesInQuantifieds() { + } + + @Test + public void supportsCorrelatedSubqueries() { + } + + @Test + public void supportsUnion() { + } + + @Test + public void supportsUnionAll() { + } + + @Test + public void supportsOpenCursorsAcrossCommit() { + } + + @Test + public void supportsOpenCursorsAcrossRollback() { + } + + @Test + public void supportsOpenStatementsAcrossCommit() { + } + + @Test + public void supportsOpenStatementsAcrossRollback() { + } + + @Test + public void getMaxBinaryLiteralLength() { + } + + @Test + public void getMaxCharLiteralLength() { + } + + @Test + public void getMaxColumnNameLength() { + } + + @Test + public void getMaxColumnsInGroupBy() { + } + + @Test + public void getMaxColumnsInIndex() { + } + + @Test + public void getMaxColumnsInOrderBy() { + } + + @Test + public void getMaxColumnsInSelect() { + } + + @Test + public void getMaxColumnsInTable() { + } + + @Test + public void getMaxConnections() { + } + + @Test + public void getMaxCursorNameLength() { + } + + @Test + public void getMaxIndexLength() { + } + + @Test + public void getMaxSchemaNameLength() { + } + + @Test + public void getMaxProcedureNameLength() { + } + + @Test + public void getMaxCatalogNameLength() { + } + + @Test + public void getMaxRowSize() { + } + + @Test + public void doesMaxRowSizeIncludeBlobs() { + } + + @Test + public void getMaxStatementLength() { + } + + @Test + public void getMaxStatements() { + } + + @Test + public void getMaxTableNameLength() { + } + + @Test + public void getMaxTablesInSelect() { + } + + @Test + public void getMaxUserNameLength() { + } + + @Test + public void getDefaultTransactionIsolation() { + } + + @Test + public void supportsTransactions() { + } + + @Test + public void supportsTransactionIsolationLevel() { + } + + @Test + public void supportsDataDefinitionAndDataManipulationTransactions() { + } + + @Test + public void supportsDataManipulationTransactionsOnly() { + } + + @Test + public void dataDefinitionCausesTransactionCommit() { + } + + @Test + public void dataDefinitionIgnoredInTransactions() { + } + + @Test + public void getProcedures() { + } + + @Test + public void getProcedureColumns() { + } + + @Test + public void getTables() { + } + + @Test + public void getSchemas() { + } + + @Test + public void getCatalogs() { + } + + @Test + public void getTableTypes() { + } + + @Test + public void getColumns() { + } + + @Test + public void getColumnPrivileges() { + } + + @Test + public void getTablePrivileges() { + } + + @Test + public void getBestRowIdentifier() { + } + + @Test + public void getVersionColumns() { + } + + @Test + public void getPrimaryKeys() { + } + + @Test + public void getImportedKeys() { + } + + @Test + public void getExportedKeys() { + } + + @Test + public void getCrossReference() { + } + + @Test + public void getTypeInfo() { + } + + @Test + public void getIndexInfo() { + } + + @Test + public void supportsResultSetType() { + } + + @Test + public void supportsResultSetConcurrency() { + } + + @Test + public void ownUpdatesAreVisible() { + } + + @Test + public void ownDeletesAreVisible() { + } + + @Test + public void ownInsertsAreVisible() { + } + + @Test + public void othersUpdatesAreVisible() { + } + + @Test + public void othersDeletesAreVisible() { + } + + @Test + public void othersInsertsAreVisible() { + } + + @Test + public void updatesAreDetected() { + } + + @Test + public void deletesAreDetected() { + } + + @Test + public void insertsAreDetected() { + } + + @Test + public void supportsBatchUpdates() { + } + + @Test + public void getUDTs() { + } + + @Test + public void getConnection() { + } + + @Test + public void supportsSavepoints() { + } + + @Test + public void supportsNamedParameters() { + } + + @Test + public void supportsMultipleOpenResults() { + } + + @Test + public void supportsGetGeneratedKeys() { + } + + @Test + public void getSuperTypes() { + } + + @Test + public void getSuperTables() { + } + + @Test + public void getAttributes() { + } + + @Test + public void supportsResultSetHoldability() { + } + + @Test + public void getResultSetHoldability() { + } + + @Test + public void getDatabaseMajorVersion() { + } + + @Test + public void getDatabaseMinorVersion() { + } + + @Test + public void getJDBCMajorVersion() { + } + + @Test + public void getJDBCMinorVersion() { + } + + @Test + public void getSQLStateType() { + } + + @Test + public void locatorsUpdateCopy() { + } + + @Test + public void supportsStatementPooling() { + } + + @Test + public void getRowIdLifetime() { + } + + @Test + public void testGetSchemas() { + } + + @Test + public void supportsStoredFunctionsUsingCallSyntax() { + } + + @Test + public void autoCommitFailureClosesAllResultSets() { + } + + @Test + public void getClientInfoProperties() { + } + + @Test + public void getFunctions() { + } + + @Test + public void getFunctionColumns() { + } + + @Test + public void getPseudoColumns() { + } + + @Test + public void generatedKeyAlwaysReturned() { + } +} \ No newline at end of file From 5806683eb7200703c8c77417f2f44c220b605942 Mon Sep 17 00:00:00 2001 From: zyyang Date: Tue, 12 Jan 2021 14:03:44 +0800 Subject: [PATCH 05/21] change --- .../java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java | 3 ++- tests/examples/JDBC/taosdemo/readme.md | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java index e9b01ef728..cb13e63017 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java @@ -44,7 +44,8 @@ public class TSDBDatabaseMetaDataTest { } @Test - public void allTablesAreSelectable() { + public void allTablesAreSelectable() throws SQLException { + Assert.assertFalse(metaData.allTablesAreSelectable()); } @Test diff --git a/tests/examples/JDBC/taosdemo/readme.md b/tests/examples/JDBC/taosdemo/readme.md index a4b6e29769..123affc71a 100644 --- a/tests/examples/JDBC/taosdemo/readme.md +++ b/tests/examples/JDBC/taosdemo/readme.md @@ -1,3 +1,6 @@ + + 需求: 1. 可以读lowa的配置文件 -2. 支持对JNI方式和Restful方式的taos-driver \ No newline at end of file +2. 支持JDBC-JNI和JDBC-restful +3. 读取配置文件,持续执行查询 \ No newline at end of file From 20cd227e765c21cb72e4177316c481b53540295a Mon Sep 17 00:00:00 2001 From: zyyang Date: Tue, 12 Jan 2021 14:07:45 +0800 Subject: [PATCH 06/21] change --- .../test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java index cb13e63017..2fe72cc391 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java @@ -49,7 +49,9 @@ public class TSDBDatabaseMetaDataTest { } @Test - public void getURL() { + public void getURL() throws SQLException { + String url = metaData.getURL(); + System.out.println(url); } @Test From b2afe151f3f72e67f5f00d0cfd2cba002e22587b Mon Sep 17 00:00:00 2001 From: zyyang Date: Tue, 12 Jan 2021 14:17:41 +0800 Subject: [PATCH 07/21] change --- .../taosdata/jdbc/TSDBDatabaseMetaDataTest.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java index 2fe72cc391..a4b64d6b25 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java @@ -50,24 +50,27 @@ public class TSDBDatabaseMetaDataTest { @Test public void getURL() throws SQLException { - String url = metaData.getURL(); - System.out.println(url); + Assert.assertEquals("jdbc:TAOS://localhost:6030/?user=root&password=taosdata", metaData.getURL()); } @Test - public void getUserName() { + public void getUserName() throws SQLException { + Assert.assertEquals("root", metaData.getUserName()); } @Test - public void isReadOnly() { + public void isReadOnly() throws SQLException { + Assert.assertFalse(metaData.isReadOnly()); } @Test - public void nullsAreSortedHigh() { + public void nullsAreSortedHigh() throws SQLException { + Assert.assertFalse(metaData.nullsAreSortedHigh()); } @Test - public void nullsAreSortedLow() { + public void nullsAreSortedLow() throws SQLException { + Assert.assertTrue(metaData.nullsAreSortedLow()); } @Test From 7303c5d0314f152104fae9ecf6157eb637c6d583 Mon Sep 17 00:00:00 2001 From: zyyang Date: Wed, 13 Jan 2021 15:52:50 +0800 Subject: [PATCH 08/21] change --- .../jdbc/AbstractDatabaseMetaData.java | 4 +- .../taosdata/jdbc/TSDBDatabaseMetaData.java | 75 +-- .../java/com/taosdata/jdbc/TSDBDriver.java | 2 +- .../jdbc/rs/RestfulDatabaseMetaData.java | 1 - .../taosdata/jdbc/DatabaseMetaDataTest.java | 2 + .../jdbc/TSDBDatabaseMetaDataTest.java | 458 ++++++++++++------ .../MultiThreadsWithSameStatmentTest.java | 79 +++ 7 files changed, 429 insertions(+), 192 deletions(-) create mode 100644 src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java index 1445be1865..8ab0e4429a 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java @@ -497,12 +497,12 @@ public abstract class AbstractDatabaseMetaData implements DatabaseMetaData { public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException { - throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); + return null; } public ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) throws SQLException { - throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); + return null; } public abstract ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java index c069fccf00..96ecd5a2bc 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java @@ -20,13 +20,11 @@ import java.util.List; public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { - private String dbProductName = null; - private String url = null; - private String userName = null; - private Connection conn = null; + private String url; + private String userName; + private Connection conn; - public TSDBDatabaseMetaData(String dbProductName, String url, String userName) { - this.dbProductName = dbProductName; + public TSDBDatabaseMetaData(String url, String userName) { this.url = url; this.userName = userName; } @@ -116,7 +114,9 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { return false; } + public boolean supportsMixedCaseIdentifiers() throws SQLException { + //像database、table这些对象的标识符,在存储时是否采用大小写混合的模式 return false; } @@ -125,7 +125,7 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { } public boolean storesLowerCaseIdentifiers() throws SQLException { - return false; + return true; } public boolean storesMixedCaseIdentifiers() throws SQLException { @@ -133,6 +133,7 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { } public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException { + //像database、table这些对象的标识符,在存储时是否采用大小写混合、并带引号的模式 return false; } @@ -193,10 +194,12 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { } public boolean nullPlusNonNullIsNull() throws SQLException { + // null + non-null != null return false; } public boolean supportsConvert() throws SQLException { + // 是否支持转换函数convert return false; } @@ -221,7 +224,7 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { } public boolean supportsGroupBy() throws SQLException { - return false; + return true; } public boolean supportsGroupByUnrelated() throws SQLException { @@ -493,7 +496,7 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { } public int getDefaultTransactionIsolation() throws SQLException { - return 0; + return Connection.TRANSACTION_NONE; } public boolean supportsTransactions() throws SQLException { @@ -501,6 +504,8 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { } public boolean supportsTransactionIsolationLevel(int level) throws SQLException { + if (level == Connection.TRANSACTION_NONE) + return true; return false; } @@ -522,28 +527,27 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException { - throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); + return null; } public ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) throws SQLException { - throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); + return null; } - public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) - throws SQLException { - Statement stmt = null; - if (null != conn && !conn.isClosed()) { - stmt = conn.createStatement(); - if (catalog == null || catalog.length() < 1) { - catalog = conn.getCatalog(); - } + public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException { + if (conn == null || conn.isClosed()) { + throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); + } + + try (Statement stmt = conn.createStatement()) { + if (catalog == null || catalog.isEmpty()) + return null; + stmt.executeUpdate("use " + catalog); ResultSet resultSet0 = stmt.executeQuery("show tables"); GetTablesResultSet getTablesResultSet = new GetTablesResultSet(resultSet0, catalog, schemaPattern, tableNamePattern, types); return getTablesResultSet; - } else { - throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); } } @@ -552,14 +556,12 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { } public ResultSet getCatalogs() throws SQLException { + if (conn == null || conn.isClosed()) + throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); - if (conn != null && !conn.isClosed()) { - Statement stmt = conn.createStatement(); - ResultSet resultSet0 = stmt.executeQuery("show databases"); - CatalogResultSet resultSet = new CatalogResultSet(resultSet0); - return resultSet; - } else { - return getEmptyResultSet(); + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("show databases"); + return new CatalogResultSet(rs); } } @@ -567,7 +569,7 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); // set up ColumnMetaDataList - List columnMetaDataList = new ArrayList(1); + List columnMetaDataList = new ArrayList<>(1); ColumnMetaData colMetaData = new ColumnMetaData(); colMetaData.setColIndex(0); colMetaData.setColName("TABLE_TYPE"); @@ -576,7 +578,7 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { columnMetaDataList.add(colMetaData); // set up rowDataList - List rowDataList = new ArrayList(2); + List rowDataList = new ArrayList<>(2); TSDBResultSetRowData rowData = new TSDBResultSetRowData(); rowData.setString(0, "TABLE"); rowDataList.add(rowData); @@ -596,11 +598,10 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { Statement stmt = null; if (null != conn && !conn.isClosed()) { stmt = conn.createStatement(); - if (catalog == null || catalog.length() < 1) { - catalog = conn.getCatalog(); - } - stmt.executeUpdate("use " + catalog); + if (catalog == null || catalog.isEmpty()) + return null; + stmt.executeUpdate("use " + catalog); DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); // set up ColumnMetaDataList List columnMetaDataList = new ArrayList<>(24); @@ -856,7 +857,7 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { } public Connection getConnection() throws SQLException { - return null; + return this.conn; } public boolean supportsSavepoints() throws SQLException { @@ -889,11 +890,13 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { } public boolean supportsResultSetHoldability(int holdability) throws SQLException { + if (holdability == ResultSet.HOLD_CURSORS_OVER_COMMIT) + return true; return false; } public int getResultSetHoldability() throws SQLException { - return 0; + return ResultSet.HOLD_CURSORS_OVER_COMMIT; } public int getDatabaseMajorVersion() throws SQLException { diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java index 06f88cebfa..c171ca2a36 100755 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java @@ -214,7 +214,7 @@ public class TSDBDriver extends AbstractTaosDriver { urlProps.setProperty(TSDBDriver.PROPERTY_KEY_HOST, url); } - this.dbMetaData = new TSDBDatabaseMetaData(dbProductName, urlForMeta, urlProps.getProperty(TSDBDriver.PROPERTY_KEY_USER)); + this.dbMetaData = new TSDBDatabaseMetaData(urlForMeta, urlProps.getProperty(TSDBDriver.PROPERTY_KEY_USER)); return urlProps; } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDatabaseMetaData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDatabaseMetaData.java index 21d2c6402f..3c372cc503 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDatabaseMetaData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDatabaseMetaData.java @@ -8,7 +8,6 @@ import java.util.List; public class RestfulDatabaseMetaData extends AbstractDatabaseMetaData { - private final String url; private final String userName; private final Connection connection; diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java index 27263073ff..49b8de4495 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java @@ -168,6 +168,7 @@ public class DatabaseMetaDataTest { try { databaseMetaData.getProcedures("", "", ""); } catch (Exception e) { + } try { databaseMetaData.getProcedureColumns("", "", "", ""); @@ -176,6 +177,7 @@ public class DatabaseMetaDataTest { try { databaseMetaData.getTables("", "", "", new String[]{""}); } catch (Exception e) { + } databaseMetaData.getSchemas(); databaseMetaData.getCatalogs(); diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java index a4b64d6b25..42f8cff9cc 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java @@ -2,16 +2,14 @@ package com.taosdata.jdbc; import org.junit.Assert; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; -import java.sql.DatabaseMetaData; +import java.sql.Connection; import java.sql.DriverManager; +import java.sql.ResultSet; import java.sql.SQLException; import java.util.Properties; -import static org.junit.Assert.*; - public class TSDBDatabaseMetaDataTest { private TSDBDatabaseMetaData metaData; private static final String host = "localhost"; @@ -74,607 +72,763 @@ public class TSDBDatabaseMetaDataTest { } @Test - public void nullsAreSortedAtStart() { + public void nullsAreSortedAtStart() throws SQLException { + Assert.assertTrue(metaData.nullsAreSortedAtStart()); } @Test - public void nullsAreSortedAtEnd() { + public void nullsAreSortedAtEnd() throws SQLException { + Assert.assertFalse(metaData.nullsAreSortedAtEnd()); } @Test - public void getDatabaseProductName() { + public void getDatabaseProductName() throws SQLException { + Assert.assertEquals("TDengine", metaData.getDatabaseProductName()); } @Test - public void getDatabaseProductVersion() { + public void getDatabaseProductVersion() throws SQLException { + Assert.assertEquals("2.0.x.x", metaData.getDatabaseProductVersion()); } @Test - public void getDriverName() { + public void getDriverName() throws SQLException { + Assert.assertEquals("com.taosdata.jdbc.TSDBDriver", metaData.getDriverName()); } @Test - public void getDriverVersion() { + public void getDriverVersion() throws SQLException { + Assert.assertEquals("2.0.x", metaData.getDriverVersion()); } @Test public void getDriverMajorVersion() { + Assert.assertEquals(2, metaData.getDriverMajorVersion()); } @Test public void getDriverMinorVersion() { + Assert.assertEquals(0, metaData.getDriverMinorVersion()); } @Test - public void usesLocalFiles() { + public void usesLocalFiles() throws SQLException { + Assert.assertFalse(metaData.usesLocalFiles()); } @Test - public void usesLocalFilePerTable() { + public void usesLocalFilePerTable() throws SQLException { + Assert.assertFalse(metaData.usesLocalFilePerTable()); } @Test - public void supportsMixedCaseIdentifiers() { + public void supportsMixedCaseIdentifiers() throws SQLException { + Assert.assertFalse(metaData.supportsMixedCaseIdentifiers()); } @Test - public void storesUpperCaseIdentifiers() { + public void storesUpperCaseIdentifiers() throws SQLException { + Assert.assertFalse(metaData.storesUpperCaseIdentifiers()); } @Test - public void storesLowerCaseIdentifiers() { + public void storesLowerCaseIdentifiers() throws SQLException { + Assert.assertTrue(metaData.storesLowerCaseIdentifiers()); } @Test - public void storesMixedCaseIdentifiers() { + public void storesMixedCaseIdentifiers() throws SQLException { + Assert.assertFalse(metaData.storesMixedCaseIdentifiers()); } @Test - public void supportsMixedCaseQuotedIdentifiers() { + public void supportsMixedCaseQuotedIdentifiers() throws SQLException { + Assert.assertFalse(metaData.supportsMixedCaseQuotedIdentifiers()); } @Test - public void storesUpperCaseQuotedIdentifiers() { + public void storesUpperCaseQuotedIdentifiers() throws SQLException { + Assert.assertFalse(metaData.storesUpperCaseQuotedIdentifiers()); } @Test - public void storesLowerCaseQuotedIdentifiers() { + public void storesLowerCaseQuotedIdentifiers() throws SQLException { + Assert.assertFalse(metaData.storesLowerCaseQuotedIdentifiers()); } @Test - public void storesMixedCaseQuotedIdentifiers() { + public void storesMixedCaseQuotedIdentifiers() throws SQLException { + Assert.assertFalse(metaData.storesMixedCaseQuotedIdentifiers()); } @Test - public void getIdentifierQuoteString() { + public void getIdentifierQuoteString() throws SQLException { + Assert.assertEquals(" ", metaData.getIdentifierQuoteString()); } @Test - public void getSQLKeywords() { + public void getSQLKeywords() throws SQLException { + Assert.assertEquals(null, metaData.getSQLKeywords()); } @Test - public void getNumericFunctions() { + public void getNumericFunctions() throws SQLException { + Assert.assertEquals(null, metaData.getNumericFunctions()); } @Test - public void getStringFunctions() { + public void getStringFunctions() throws SQLException { + Assert.assertEquals(null, metaData.getStringFunctions()); } @Test - public void getSystemFunctions() { + public void getSystemFunctions() throws SQLException { + Assert.assertEquals(null, metaData.getSystemFunctions()); } @Test - public void getTimeDateFunctions() { + public void getTimeDateFunctions() throws SQLException { + Assert.assertEquals(null, metaData.getTimeDateFunctions()); } @Test - public void getSearchStringEscape() { + public void getSearchStringEscape() throws SQLException { + Assert.assertEquals(null, metaData.getSearchStringEscape()); } @Test - public void getExtraNameCharacters() { + public void getExtraNameCharacters() throws SQLException { + Assert.assertEquals(null, metaData.getExtraNameCharacters()); } @Test - public void supportsAlterTableWithAddColumn() { + public void supportsAlterTableWithAddColumn() throws SQLException { + Assert.assertTrue(metaData.supportsAlterTableWithAddColumn()); } @Test - public void supportsAlterTableWithDropColumn() { + public void supportsAlterTableWithDropColumn() throws SQLException { + Assert.assertTrue(metaData.supportsAlterTableWithDropColumn()); } @Test - public void supportsColumnAliasing() { + public void supportsColumnAliasing() throws SQLException { + Assert.assertTrue(metaData.supportsColumnAliasing()); } @Test - public void nullPlusNonNullIsNull() { + public void nullPlusNonNullIsNull() throws SQLException { + Assert.assertFalse(metaData.nullPlusNonNullIsNull()); } @Test - public void supportsConvert() { + public void supportsConvert() throws SQLException { + Assert.assertFalse(metaData.supportsConvert()); } @Test - public void testSupportsConvert() { + public void testSupportsConvert() throws SQLException { + Assert.assertFalse(metaData.supportsConvert(1, 1)); } @Test - public void supportsTableCorrelationNames() { + public void supportsTableCorrelationNames() throws SQLException { + Assert.assertFalse(metaData.supportsTableCorrelationNames()); } @Test - public void supportsDifferentTableCorrelationNames() { + public void supportsDifferentTableCorrelationNames() throws SQLException { + Assert.assertFalse(metaData.supportsDifferentTableCorrelationNames()); } @Test - public void supportsExpressionsInOrderBy() { + public void supportsExpressionsInOrderBy() throws SQLException { + Assert.assertFalse(metaData.supportsExpressionsInOrderBy()); } @Test - public void supportsOrderByUnrelated() { + public void supportsOrderByUnrelated() throws SQLException { + Assert.assertFalse(metaData.supportsOrderByUnrelated()); } @Test - public void supportsGroupBy() { + public void supportsGroupBy() throws SQLException { + Assert.assertTrue(metaData.supportsGroupBy()); } @Test - public void supportsGroupByUnrelated() { + public void supportsGroupByUnrelated() throws SQLException { + Assert.assertFalse(metaData.supportsGroupByUnrelated()); } @Test - public void supportsGroupByBeyondSelect() { + public void supportsGroupByBeyondSelect() throws SQLException { + Assert.assertFalse(metaData.supportsGroupByBeyondSelect()); } @Test - public void supportsLikeEscapeClause() { + public void supportsLikeEscapeClause() throws SQLException { + Assert.assertFalse(metaData.supportsLikeEscapeClause()); } @Test - public void supportsMultipleResultSets() { + public void supportsMultipleResultSets() throws SQLException { + Assert.assertFalse(metaData.supportsMultipleResultSets()); } @Test - public void supportsMultipleTransactions() { + public void supportsMultipleTransactions() throws SQLException { + Assert.assertFalse(metaData.supportsMultipleTransactions()); } @Test - public void supportsNonNullableColumns() { + public void supportsNonNullableColumns() throws SQLException { + Assert.assertFalse(metaData.supportsNonNullableColumns()); } @Test - public void supportsMinimumSQLGrammar() { + public void supportsMinimumSQLGrammar() throws SQLException { + Assert.assertFalse(metaData.supportsMinimumSQLGrammar()); } @Test - public void supportsCoreSQLGrammar() { + public void supportsCoreSQLGrammar() throws SQLException { + Assert.assertFalse(metaData.supportsCoreSQLGrammar()); } @Test - public void supportsExtendedSQLGrammar() { + public void supportsExtendedSQLGrammar() throws SQLException { + Assert.assertFalse(metaData.supportsExtendedSQLGrammar()); } @Test - public void supportsANSI92EntryLevelSQL() { + public void supportsANSI92EntryLevelSQL() throws SQLException { + Assert.assertFalse(metaData.supportsANSI92EntryLevelSQL()); } @Test - public void supportsANSI92IntermediateSQL() { + public void supportsANSI92IntermediateSQL() throws SQLException { + Assert.assertFalse(metaData.supportsANSI92IntermediateSQL()); } @Test - public void supportsANSI92FullSQL() { + public void supportsANSI92FullSQL() throws SQLException { + Assert.assertFalse(metaData.supportsANSI92FullSQL()); } @Test - public void supportsIntegrityEnhancementFacility() { + public void supportsIntegrityEnhancementFacility() throws SQLException { + Assert.assertFalse(metaData.supportsIntegrityEnhancementFacility()); } @Test - public void supportsOuterJoins() { + public void supportsOuterJoins() throws SQLException { + Assert.assertFalse(metaData.supportsOuterJoins()); } @Test - public void supportsFullOuterJoins() { + public void supportsFullOuterJoins() throws SQLException { + Assert.assertFalse(metaData.supportsFullOuterJoins()); } @Test - public void supportsLimitedOuterJoins() { + public void supportsLimitedOuterJoins() throws SQLException { + Assert.assertFalse(metaData.supportsLimitedOuterJoins()); } @Test - public void getSchemaTerm() { + public void getSchemaTerm() throws SQLException { + Assert.assertNull(metaData.getSchemaTerm()); } @Test - public void getProcedureTerm() { + public void getProcedureTerm() throws SQLException { + Assert.assertNull(metaData.getProcedureTerm()); } @Test - public void getCatalogTerm() { + public void getCatalogTerm() throws SQLException { + Assert.assertEquals("database", metaData.getCatalogTerm()); } @Test - public void isCatalogAtStart() { + public void isCatalogAtStart() throws SQLException { + Assert.assertTrue(metaData.isCatalogAtStart()); } @Test - public void getCatalogSeparator() { + public void getCatalogSeparator() throws SQLException { + Assert.assertEquals(".", metaData.getCatalogSeparator()); } @Test - public void supportsSchemasInDataManipulation() { + public void supportsSchemasInDataManipulation() throws SQLException { + Assert.assertFalse(metaData.supportsSchemasInDataManipulation()); } @Test - public void supportsSchemasInProcedureCalls() { + public void supportsSchemasInProcedureCalls() throws SQLException { + Assert.assertFalse(metaData.supportsSchemasInProcedureCalls()); } @Test - public void supportsSchemasInTableDefinitions() { + public void supportsSchemasInTableDefinitions() throws SQLException { + Assert.assertFalse(metaData.supportsSchemasInTableDefinitions()); } @Test - public void supportsSchemasInIndexDefinitions() { + public void supportsSchemasInIndexDefinitions() throws SQLException { + Assert.assertFalse(metaData.supportsSchemasInIndexDefinitions()); } @Test - public void supportsSchemasInPrivilegeDefinitions() { + public void supportsSchemasInPrivilegeDefinitions() throws SQLException { + Assert.assertFalse(metaData.supportsSchemasInPrivilegeDefinitions()); } @Test - public void supportsCatalogsInDataManipulation() { + public void supportsCatalogsInDataManipulation() throws SQLException { + Assert.assertTrue(metaData.supportsCatalogsInDataManipulation()); } @Test - public void supportsCatalogsInProcedureCalls() { + public void supportsCatalogsInProcedureCalls() throws SQLException { + Assert.assertFalse(metaData.supportsCatalogsInProcedureCalls()); } @Test - public void supportsCatalogsInTableDefinitions() { + public void supportsCatalogsInTableDefinitions() throws SQLException { + Assert.assertFalse(metaData.supportsCatalogsInTableDefinitions()); } @Test - public void supportsCatalogsInIndexDefinitions() { + public void supportsCatalogsInIndexDefinitions() throws SQLException { + Assert.assertFalse(metaData.supportsCatalogsInIndexDefinitions()); } @Test - public void supportsCatalogsInPrivilegeDefinitions() { + public void supportsCatalogsInPrivilegeDefinitions() throws SQLException { + Assert.assertFalse(metaData.supportsCatalogsInPrivilegeDefinitions()); } @Test - public void supportsPositionedDelete() { + public void supportsPositionedDelete() throws SQLException { + Assert.assertFalse(metaData.supportsPositionedDelete()); } @Test - public void supportsPositionedUpdate() { + public void supportsPositionedUpdate() throws SQLException { + Assert.assertFalse(metaData.supportsPositionedUpdate()); } @Test - public void supportsSelectForUpdate() { + public void supportsSelectForUpdate() throws SQLException { + Assert.assertFalse(metaData.supportsSelectForUpdate()); } @Test - public void supportsStoredProcedures() { + public void supportsStoredProcedures() throws SQLException { + Assert.assertFalse(metaData.supportsStoredProcedures()); } @Test - public void supportsSubqueriesInComparisons() { + public void supportsSubqueriesInComparisons() throws SQLException { + Assert.assertFalse(metaData.supportsSubqueriesInComparisons()); } @Test - public void supportsSubqueriesInExists() { + public void supportsSubqueriesInExists() throws SQLException { + Assert.assertFalse(metaData.supportsSubqueriesInExists()); } @Test - public void supportsSubqueriesInIns() { + public void supportsSubqueriesInIns() throws SQLException { + Assert.assertFalse(metaData.supportsSubqueriesInIns()); } @Test - public void supportsSubqueriesInQuantifieds() { + public void supportsSubqueriesInQuantifieds() throws SQLException { + Assert.assertFalse(metaData.supportsSubqueriesInQuantifieds()); } @Test - public void supportsCorrelatedSubqueries() { + public void supportsCorrelatedSubqueries() throws SQLException { + Assert.assertFalse(metaData.supportsCorrelatedSubqueries()); } @Test - public void supportsUnion() { + public void supportsUnion() throws SQLException { + Assert.assertFalse(metaData.supportsUnion()); } @Test - public void supportsUnionAll() { + public void supportsUnionAll() throws SQLException { + Assert.assertFalse(metaData.supportsUnionAll()); } @Test - public void supportsOpenCursorsAcrossCommit() { + public void supportsOpenCursorsAcrossCommit() throws SQLException { + Assert.assertFalse(metaData.supportsOpenCursorsAcrossCommit()); } @Test - public void supportsOpenCursorsAcrossRollback() { + public void supportsOpenCursorsAcrossRollback() throws SQLException { + Assert.assertFalse(metaData.supportsOpenCursorsAcrossRollback()); } @Test - public void supportsOpenStatementsAcrossCommit() { + public void supportsOpenStatementsAcrossCommit() throws SQLException { + Assert.assertFalse(metaData.supportsOpenStatementsAcrossCommit()); } @Test - public void supportsOpenStatementsAcrossRollback() { + public void supportsOpenStatementsAcrossRollback() throws SQLException { + Assert.assertFalse(metaData.supportsOpenStatementsAcrossRollback()); } @Test - public void getMaxBinaryLiteralLength() { + public void getMaxBinaryLiteralLength() throws SQLException { + Assert.assertEquals(0, metaData.getMaxBinaryLiteralLength()); } @Test - public void getMaxCharLiteralLength() { + public void getMaxCharLiteralLength() throws SQLException { + Assert.assertEquals(0, metaData.getMaxCharLiteralLength()); } @Test - public void getMaxColumnNameLength() { + public void getMaxColumnNameLength() throws SQLException { + Assert.assertEquals(0, metaData.getMaxColumnNameLength()); } @Test - public void getMaxColumnsInGroupBy() { + public void getMaxColumnsInGroupBy() throws SQLException { + Assert.assertEquals(0, metaData.getMaxColumnsInGroupBy()); } @Test - public void getMaxColumnsInIndex() { + public void getMaxColumnsInIndex() throws SQLException { + Assert.assertEquals(0, metaData.getMaxColumnsInIndex()); } @Test - public void getMaxColumnsInOrderBy() { + public void getMaxColumnsInOrderBy() throws SQLException { + Assert.assertEquals(0, metaData.getMaxColumnsInOrderBy()); } @Test - public void getMaxColumnsInSelect() { + public void getMaxColumnsInSelect() throws SQLException { + Assert.assertEquals(0, metaData.getMaxColumnsInSelect()); } @Test - public void getMaxColumnsInTable() { + public void getMaxColumnsInTable() throws SQLException { + Assert.assertEquals(0, metaData.getMaxColumnsInTable()); } @Test - public void getMaxConnections() { + public void getMaxConnections() throws SQLException { + Assert.assertEquals(0, metaData.getMaxConnections()); } @Test - public void getMaxCursorNameLength() { + public void getMaxCursorNameLength() throws SQLException { + Assert.assertEquals(0, metaData.getMaxCursorNameLength()); } @Test - public void getMaxIndexLength() { + public void getMaxIndexLength() throws SQLException { + Assert.assertEquals(0, metaData.getMaxIndexLength()); } @Test - public void getMaxSchemaNameLength() { + public void getMaxSchemaNameLength() throws SQLException { + Assert.assertEquals(0, metaData.getMaxSchemaNameLength()); } @Test - public void getMaxProcedureNameLength() { + public void getMaxProcedureNameLength() throws SQLException { + Assert.assertEquals(0, metaData.getMaxProcedureNameLength()); } @Test - public void getMaxCatalogNameLength() { + public void getMaxCatalogNameLength() throws SQLException { + Assert.assertEquals(0, metaData.getMaxCatalogNameLength()); } @Test - public void getMaxRowSize() { + public void getMaxRowSize() throws SQLException { + Assert.assertEquals(0, metaData.getMaxRowSize()); } @Test - public void doesMaxRowSizeIncludeBlobs() { + public void doesMaxRowSizeIncludeBlobs() throws SQLException { + Assert.assertFalse(metaData.doesMaxRowSizeIncludeBlobs()); } @Test - public void getMaxStatementLength() { + public void getMaxStatementLength() throws SQLException { + Assert.assertEquals(0, metaData.getMaxStatementLength()); } @Test - public void getMaxStatements() { + public void getMaxStatements() throws SQLException { + Assert.assertEquals(0, metaData.getMaxStatements()); } @Test - public void getMaxTableNameLength() { + public void getMaxTableNameLength() throws SQLException { + Assert.assertEquals(0, metaData.getMaxTableNameLength()); } @Test - public void getMaxTablesInSelect() { + public void getMaxTablesInSelect() throws SQLException { + Assert.assertEquals(0, metaData.getMaxTablesInSelect()); } @Test - public void getMaxUserNameLength() { + public void getMaxUserNameLength() throws SQLException { + Assert.assertEquals(0, metaData.getMaxUserNameLength()); } @Test - public void getDefaultTransactionIsolation() { + public void getDefaultTransactionIsolation() throws SQLException { + Assert.assertEquals(Connection.TRANSACTION_NONE, metaData.getDefaultTransactionIsolation()); } @Test - public void supportsTransactions() { + public void supportsTransactions() throws SQLException { + Assert.assertFalse(metaData.supportsTransactions()); } @Test - public void supportsTransactionIsolationLevel() { + public void supportsTransactionIsolationLevel() throws SQLException { + Assert.assertTrue(metaData.supportsTransactionIsolationLevel(Connection.TRANSACTION_NONE)); + Assert.assertFalse(metaData.supportsTransactionIsolationLevel(Connection.TRANSACTION_READ_COMMITTED)); + Assert.assertFalse(metaData.supportsTransactionIsolationLevel(Connection.TRANSACTION_READ_UNCOMMITTED)); + Assert.assertFalse(metaData.supportsTransactionIsolationLevel(Connection.TRANSACTION_REPEATABLE_READ)); + Assert.assertFalse(metaData.supportsTransactionIsolationLevel(Connection.TRANSACTION_SERIALIZABLE)); } @Test - public void supportsDataDefinitionAndDataManipulationTransactions() { + public void supportsDataDefinitionAndDataManipulationTransactions() throws SQLException { + Assert.assertFalse(metaData.supportsDataDefinitionAndDataManipulationTransactions()); } @Test - public void supportsDataManipulationTransactionsOnly() { + public void supportsDataManipulationTransactionsOnly() throws SQLException { + Assert.assertFalse(metaData.supportsDataManipulationTransactionsOnly()); } @Test - public void dataDefinitionCausesTransactionCommit() { + public void dataDefinitionCausesTransactionCommit() throws SQLException { + Assert.assertFalse(metaData.dataDefinitionCausesTransactionCommit()); } @Test - public void dataDefinitionIgnoredInTransactions() { + public void dataDefinitionIgnoredInTransactions() throws SQLException { + Assert.assertFalse(metaData.dataDefinitionIgnoredInTransactions()); } @Test - public void getProcedures() { + public void getProcedures() throws SQLException { + Assert.assertNull(metaData.getProcedures("*", "*", "*")); } @Test - public void getProcedureColumns() { + public void getProcedureColumns() throws SQLException { + Assert.assertNull(metaData.getProcedureColumns("*", "*", "*", "*")); } @Test - public void getTables() { + public void getTables() throws SQLException { + Assert.assertNull(metaData.getTables("", "", "*", null)); } @Test - public void getSchemas() { + public void getSchemas() throws SQLException { + Assert.assertNotNull(metaData.getSchemas()); } @Test - public void getCatalogs() { + public void getCatalogs() throws SQLException { + Assert.assertNotNull(metaData.getCatalogs()); } @Test - public void getTableTypes() { + public void getTableTypes() throws SQLException { + Assert.assertNotNull(metaData.getTableTypes()); } @Test - public void getColumns() { + public void getColumns() throws SQLException { + Assert.assertNotNull(metaData.getColumns("", "", "", "")); } @Test - public void getColumnPrivileges() { + public void getColumnPrivileges() throws SQLException { + Assert.assertNotNull(metaData.getColumnPrivileges("", "", "", "")); } @Test - public void getTablePrivileges() { + public void getTablePrivileges() throws SQLException { + Assert.assertNotNull(metaData.getTablePrivileges("", "", "")); } @Test - public void getBestRowIdentifier() { + public void getBestRowIdentifier() throws SQLException { + Assert.assertNotNull(metaData.getBestRowIdentifier("", "", "", 0, false)); } @Test - public void getVersionColumns() { + public void getVersionColumns() throws SQLException { + Assert.assertNotNull(metaData.getVersionColumns("", "", "")); } @Test - public void getPrimaryKeys() { + public void getPrimaryKeys() throws SQLException { + Assert.assertNotNull(metaData.getPrimaryKeys("", "", "")); } @Test - public void getImportedKeys() { + public void getImportedKeys() throws SQLException { + Assert.assertNotNull(metaData.getImportedKeys("", "", "")); } @Test - public void getExportedKeys() { + public void getExportedKeys() throws SQLException { + Assert.assertNotNull(metaData.getExportedKeys("", "", "")); } @Test - public void getCrossReference() { + public void getCrossReference() throws SQLException { + Assert.assertNotNull(metaData.getCrossReference("", "", "", "", "", "")); } @Test - public void getTypeInfo() { + public void getTypeInfo() throws SQLException { + Assert.assertNotNull(metaData.getTypeInfo()); } @Test - public void getIndexInfo() { + public void getIndexInfo() throws SQLException { + Assert.assertNotNull(metaData.getIndexInfo("", "", "", false, false)); } @Test - public void supportsResultSetType() { + public void supportsResultSetType() throws SQLException { + Assert.assertFalse(metaData.supportsResultSetType(0)); } @Test - public void supportsResultSetConcurrency() { + public void supportsResultSetConcurrency() throws SQLException { + Assert.assertFalse(metaData.supportsResultSetConcurrency(0, 0)); } @Test - public void ownUpdatesAreVisible() { + public void ownUpdatesAreVisible() throws SQLException { + Assert.assertFalse(metaData.ownUpdatesAreVisible(0)); } @Test - public void ownDeletesAreVisible() { + public void ownDeletesAreVisible() throws SQLException { + Assert.assertFalse(metaData.ownDeletesAreVisible(0)); } @Test - public void ownInsertsAreVisible() { + public void ownInsertsAreVisible() throws SQLException { + Assert.assertFalse(metaData.ownInsertsAreVisible(0)); } @Test - public void othersUpdatesAreVisible() { + public void othersUpdatesAreVisible() throws SQLException { + Assert.assertFalse(metaData.othersUpdatesAreVisible(0)); } @Test - public void othersDeletesAreVisible() { + public void othersDeletesAreVisible() throws SQLException { + Assert.assertFalse(metaData.othersDeletesAreVisible(0)); } @Test - public void othersInsertsAreVisible() { + public void othersInsertsAreVisible() throws SQLException { + Assert.assertFalse(metaData.othersInsertsAreVisible(0)); } @Test - public void updatesAreDetected() { + public void updatesAreDetected() throws SQLException { + Assert.assertFalse(metaData.updatesAreDetected(0)); } @Test - public void deletesAreDetected() { + public void deletesAreDetected() throws SQLException { + Assert.assertFalse(metaData.deletesAreDetected(0)); } @Test - public void insertsAreDetected() { + public void insertsAreDetected() throws SQLException { + Assert.assertFalse(metaData.insertsAreDetected(0)); } @Test - public void supportsBatchUpdates() { + public void supportsBatchUpdates() throws SQLException { + Assert.assertFalse(metaData.supportsBatchUpdates()); } @Test - public void getUDTs() { + public void getUDTs() throws SQLException { + Assert.assertNotNull(metaData.getUDTs("", "", "", null)); } @Test - public void getConnection() { + public void getConnection() throws SQLException { + Assert.assertNotNull(metaData.getConnection()); } @Test - public void supportsSavepoints() { + public void supportsSavepoints() throws SQLException { + Assert.assertFalse(metaData.supportsSavepoints()); } @Test - public void supportsNamedParameters() { + public void supportsNamedParameters() throws SQLException { + Assert.assertFalse(metaData.supportsNamedParameters()); } @Test - public void supportsMultipleOpenResults() { + public void supportsMultipleOpenResults() throws SQLException { + Assert.assertFalse(metaData.supportsMultipleOpenResults()); } @Test - public void supportsGetGeneratedKeys() { + public void supportsGetGeneratedKeys() throws SQLException { + Assert.assertFalse(metaData.supportsGetGeneratedKeys()); } @Test - public void getSuperTypes() { + public void getSuperTypes() throws SQLException { + Assert.assertNotNull(metaData.getSuperTypes("", "", "")); } @Test - public void getSuperTables() { + public void getSuperTables() throws SQLException { + Assert.assertNotNull(metaData.getSuperTables("", "", "")); } @Test - public void getAttributes() { + public void getAttributes() throws SQLException { + Assert.assertNotNull(metaData.getAttributes("", "", "", "")); } @Test - public void supportsResultSetHoldability() { + public void supportsResultSetHoldability() throws SQLException { + Assert.assertTrue(metaData.supportsResultSetHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT)); + Assert.assertFalse(metaData.supportsResultSetHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT)); } @Test public void getResultSetHoldability() { + } @Test diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java new file mode 100644 index 0000000000..60ef341729 --- /dev/null +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java @@ -0,0 +1,79 @@ +package com.taosdata.jdbc.cases; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Test; + +import java.sql.*; +import java.util.concurrent.TimeUnit; +import java.util.stream.IntStream; + +public class MultiThreadsWithSameStatmentTest { + private Connection conn; + private Statement stmt; + + @Before + public void before() { + try { + Class.forName("com.taosdata.jdbc.TSDBDriver"); + conn = DriverManager.getConnection("jdbc:TAOS://localhost:6030/?user=root&password=taosdata"); + stmt = conn.createStatement(); + stmt.execute("create database if not exists jdbctest"); + stmt.executeUpdate("create table jdbctest.weather (ts timestamp, f1 int)"); + + } catch (ClassNotFoundException | SQLException e) { + e.printStackTrace(); + } + } + + @Test + public void test() { + Thread t1 = new Thread(() -> { + try { + ResultSet resultSet = stmt.executeQuery("select * from log."); + sleep(5000); + while (resultSet.next()) { + ResultSetMetaData metaData = resultSet.getMetaData(); + for (int i = 1; i <= metaData.getColumnCount(); i++) { + System.out.print(metaData.getColumnLabel(i) + ": " + resultSet.getString(i)); + } + System.out.println(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + }); + + Thread t2 = new Thread(() -> { + try { + stmt.executeUpdate("insert into jdbctest.weather values(now,1)"); + } catch (SQLException e) { + e.printStackTrace(); + } + }); + t1.start(); + sleep(1000); + t2.start(); + } + + private void sleep(long mills) { + try { + TimeUnit.MILLISECONDS.sleep(mills); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + @After + public void after() { + try { + if (stmt != null) + stmt.close(); + if (conn != null) + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } +} From 412da1d04d6702d2fa6ec5965e75efc47017799b Mon Sep 17 00:00:00 2001 From: zyyang Date: Wed, 13 Jan 2021 16:22:18 +0800 Subject: [PATCH 09/21] change --- .../taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java index 60ef341729..528347a04a 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java @@ -20,8 +20,7 @@ public class MultiThreadsWithSameStatmentTest { conn = DriverManager.getConnection("jdbc:TAOS://localhost:6030/?user=root&password=taosdata"); stmt = conn.createStatement(); stmt.execute("create database if not exists jdbctest"); - stmt.executeUpdate("create table jdbctest.weather (ts timestamp, f1 int)"); - + stmt.executeUpdate("create table if not exists jdbctest.weather (ts timestamp, f1 int)"); } catch (ClassNotFoundException | SQLException e) { e.printStackTrace(); } From c967956212854e12bbc0df3cb1c61c83f7fef88f Mon Sep 17 00:00:00 2001 From: zyyang Date: Wed, 13 Jan 2021 16:24:12 +0800 Subject: [PATCH 10/21] change --- .../taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java index 528347a04a..9427c67f80 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java @@ -30,7 +30,7 @@ public class MultiThreadsWithSameStatmentTest { public void test() { Thread t1 = new Thread(() -> { try { - ResultSet resultSet = stmt.executeQuery("select * from log."); + ResultSet resultSet = stmt.executeQuery("select * from jdbctest.weather"); sleep(5000); while (resultSet.next()) { ResultSetMetaData metaData = resultSet.getMetaData(); From 6538d19603ef1d792d2cec57a1a3ad755d2eab7d Mon Sep 17 00:00:00 2001 From: zyyang Date: Wed, 13 Jan 2021 16:33:14 +0800 Subject: [PATCH 11/21] change --- .../src/main/java/com/taosdata/jdbc/TSDBStatement.java | 7 +++++++ .../jdbc/cases/MultiThreadsWithSameStatmentTest.java | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java index cd2a768a38..1afd1a3cba 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java @@ -17,6 +17,7 @@ package com.taosdata.jdbc; import java.sql.*; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.TimeUnit; public class TSDBStatement implements Statement { private TSDBJNIConnector connector = null; @@ -67,6 +68,12 @@ public class TSDBStatement implements Statement { // TODO make sure it is not a update query pSql = this.connector.executeQuery(sql); + try { + TimeUnit.SECONDS.sleep(10); + } catch (InterruptedException e) { + e.printStackTrace(); + } + long resultSetPointer = this.connector.getResultSet(); if (resultSetPointer == TSDBConstants.JNI_CONNECTION_NULL) { diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java index 9427c67f80..90f41dade3 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java @@ -31,7 +31,6 @@ public class MultiThreadsWithSameStatmentTest { Thread t1 = new Thread(() -> { try { ResultSet resultSet = stmt.executeQuery("select * from jdbctest.weather"); - sleep(5000); while (resultSet.next()) { ResultSetMetaData metaData = resultSet.getMetaData(); for (int i = 1; i <= metaData.getColumnCount(); i++) { From d02acc8c159f73e92b0cb9517cc49f95bd8875d7 Mon Sep 17 00:00:00 2001 From: zyyang Date: Wed, 13 Jan 2021 16:40:30 +0800 Subject: [PATCH 12/21] change --- .../taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java index 90f41dade3..29716e081e 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java @@ -38,6 +38,9 @@ public class MultiThreadsWithSameStatmentTest { } System.out.println(); } + + resultSet.close(); + } catch (SQLException e) { e.printStackTrace(); } From a000e6d3068fc662b1abcf9b8d15b09377516477 Mon Sep 17 00:00:00 2001 From: zyyang Date: Wed, 13 Jan 2021 16:57:33 +0800 Subject: [PATCH 13/21] change --- .../java/com/taosdata/jdbc/TSDBStatement.java | 1 - .../MultiThreadsWithSameStatmentTest.java | 36 +++++++++++-------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java index 1afd1a3cba..56e6d73a01 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java @@ -75,7 +75,6 @@ public class TSDBStatement implements Statement { } long resultSetPointer = this.connector.getResultSet(); - if (resultSetPointer == TSDBConstants.JNI_CONNECTION_NULL) { this.connector.freeResultSet(pSql); throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java index 29716e081e..9ed6961a36 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java @@ -10,27 +10,35 @@ import java.util.concurrent.TimeUnit; import java.util.stream.IntStream; public class MultiThreadsWithSameStatmentTest { - private Connection conn; - private Statement stmt; + + + private class Service { + public Connection conn; + public Statement stmt; + + public Service() { + try { + Class.forName("com.taosdata.jdbc.TSDBDriver"); + conn = DriverManager.getConnection("jdbc:TAOS://localhost:6030/?user=root&password=taosdata"); + stmt = conn.createStatement(); + stmt.execute("create database if not exists jdbctest"); + stmt.executeUpdate("create table if not exists jdbctest.weather (ts timestamp, f1 int)"); + } catch (ClassNotFoundException | SQLException e) { + e.printStackTrace(); + } + } + } @Before public void before() { - try { - Class.forName("com.taosdata.jdbc.TSDBDriver"); - conn = DriverManager.getConnection("jdbc:TAOS://localhost:6030/?user=root&password=taosdata"); - stmt = conn.createStatement(); - stmt.execute("create database if not exists jdbctest"); - stmt.executeUpdate("create table if not exists jdbctest.weather (ts timestamp, f1 int)"); - } catch (ClassNotFoundException | SQLException e) { - e.printStackTrace(); - } } @Test public void test() { Thread t1 = new Thread(() -> { try { - ResultSet resultSet = stmt.executeQuery("select * from jdbctest.weather"); + Service service = new Service(); + ResultSet resultSet = service.stmt.executeQuery("select * from jdbctest.weather"); while (resultSet.next()) { ResultSetMetaData metaData = resultSet.getMetaData(); for (int i = 1; i <= metaData.getColumnCount(); i++) { @@ -40,7 +48,6 @@ public class MultiThreadsWithSameStatmentTest { } resultSet.close(); - } catch (SQLException e) { e.printStackTrace(); } @@ -48,7 +55,8 @@ public class MultiThreadsWithSameStatmentTest { Thread t2 = new Thread(() -> { try { - stmt.executeUpdate("insert into jdbctest.weather values(now,1)"); + Service service = new Service(); + service.stmt.executeUpdate("insert into jdbctest.weather values(now,1)"); } catch (SQLException e) { e.printStackTrace(); } From bee49162ffa84ba992f0787680db2f31c661aa6e Mon Sep 17 00:00:00 2001 From: zyyang Date: Wed, 13 Jan 2021 17:00:09 +0800 Subject: [PATCH 14/21] change --- .../MultiThreadsWithSameStatmentTest.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java index 9ed6961a36..3dc2f9680c 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java @@ -27,6 +27,15 @@ public class MultiThreadsWithSameStatmentTest { e.printStackTrace(); } } + + public void release(){ + try { + stmt.close(); + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } } @Before @@ -46,8 +55,8 @@ public class MultiThreadsWithSameStatmentTest { } System.out.println(); } - resultSet.close(); + service.release(); } catch (SQLException e) { e.printStackTrace(); } @@ -57,6 +66,7 @@ public class MultiThreadsWithSameStatmentTest { try { Service service = new Service(); service.stmt.executeUpdate("insert into jdbctest.weather values(now,1)"); + service.release(); } catch (SQLException e) { e.printStackTrace(); } @@ -76,13 +86,5 @@ public class MultiThreadsWithSameStatmentTest { @After public void after() { - try { - if (stmt != null) - stmt.close(); - if (conn != null) - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } } } From 6c3e1629e6b52fe7a3341ba5ff7a6f7cce9c5a53 Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Fri, 15 Jan 2021 17:39:36 +0800 Subject: [PATCH 15/21] change version --- cmake/version.inc | 2 +- snap/snapcraft.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/version.inc b/cmake/version.inc index 49f01d00bc..0509a5ce1b 100644 --- a/cmake/version.inc +++ b/cmake/version.inc @@ -4,7 +4,7 @@ PROJECT(TDengine) IF (DEFINED VERNUMBER) SET(TD_VER_NUMBER ${VERNUMBER}) ELSE () - SET(TD_VER_NUMBER "2.0.13.0") + SET(TD_VER_NUMBER "2.0.14.0") ENDIF () IF (DEFINED VERCOMPATIBLE) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index c4b2039737..102fea6b9e 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,6 +1,6 @@ name: tdengine base: core18 -version: '2.0.13.0' +version: '2.0.14.0' icon: snap/gui/t-dengine.svg summary: an open-source big data platform designed and optimized for IoT. description: | @@ -72,7 +72,7 @@ parts: - usr/bin/taosd - usr/bin/taos - usr/bin/taosdemo - - usr/lib/libtaos.so.2.0.13.0 + - usr/lib/libtaos.so.2.0.14.0 - usr/lib/libtaos.so.1 - usr/lib/libtaos.so From 456f2a82f216e1821ec35ebfd526c86c0200d9b2 Mon Sep 17 00:00:00 2001 From: zyyang Date: Fri, 15 Jan 2021 17:56:54 +0800 Subject: [PATCH 16/21] change --- .../java/com/taosdata/jdbc/TSDBResultSet.java | 2 +- .../java/com/taosdata/jdbc/TSDBStatement.java | 6 ------ .../MultiThreadsWithSameStatmentTest.java | 19 ++++++++++--------- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java index 84a3f58f46..a8a8b3ca87 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java @@ -39,7 +39,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -@SuppressWarnings("unused") public class TSDBResultSet implements ResultSet { private TSDBJNIConnector jniConnector = null; @@ -104,6 +103,7 @@ public class TSDBResultSet implements ResultSet { } public TSDBResultSet() { + } public TSDBResultSet(TSDBJNIConnector connector, long resultSetPointer) throws SQLException { diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java index 56e6d73a01..381f1d3622 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java @@ -68,12 +68,6 @@ public class TSDBStatement implements Statement { // TODO make sure it is not a update query pSql = this.connector.executeQuery(sql); - try { - TimeUnit.SECONDS.sleep(10); - } catch (InterruptedException e) { - e.printStackTrace(); - } - long resultSetPointer = this.connector.getResultSet(); if (resultSetPointer == TSDBConstants.JNI_CONNECTION_NULL) { this.connector.freeResultSet(pSql); diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java index 3dc2f9680c..5cb76cc0cb 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java @@ -1,13 +1,11 @@ package com.taosdata.jdbc.cases; import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; import java.sql.*; import java.util.concurrent.TimeUnit; -import java.util.stream.IntStream; public class MultiThreadsWithSameStatmentTest { @@ -28,7 +26,7 @@ public class MultiThreadsWithSameStatmentTest { } } - public void release(){ + public void release() { try { stmt.close(); conn.close(); @@ -63,13 +61,16 @@ public class MultiThreadsWithSameStatmentTest { }); Thread t2 = new Thread(() -> { - try { - Service service = new Service(); - service.stmt.executeUpdate("insert into jdbctest.weather values(now,1)"); - service.release(); - } catch (SQLException e) { - e.printStackTrace(); + while (true) { + try { + Service service = new Service(); + service.stmt.executeUpdate("insert into jdbctest.weather values(now,1)"); + service.release(); + } catch (SQLException e) { + e.printStackTrace(); + } } + }); t1.start(); sleep(1000); From d3f97ba0009d6baedb4f20545d71becd171926ef Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Fri, 15 Jan 2021 18:03:00 +0800 Subject: [PATCH 17/21] [TD-2768]feature:4x py fetch performance increase --- src/connector/python/linux/python2/setup.py | 2 +- src/connector/python/linux/python2/taos/cursor.py | 4 ++-- src/connector/python/linux/python3/setup.py | 2 +- src/connector/python/linux/python3/taos/cursor.py | 4 ++-- src/connector/python/windows/python2/setup.py | 2 +- src/connector/python/windows/python2/taos/cursor.py | 4 ++-- src/connector/python/windows/python3/setup.py | 2 +- src/connector/python/windows/python3/taos/cursor.py | 4 ++-- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/connector/python/linux/python2/setup.py b/src/connector/python/linux/python2/setup.py index 92a931b504..2cad664307 100644 --- a/src/connector/python/linux/python2/setup.py +++ b/src/connector/python/linux/python2/setup.py @@ -5,7 +5,7 @@ with open("README.md", "r") as fh: setuptools.setup( name="taos", - version="2.0.3", + version="2.0.4", author="Taosdata Inc.", author_email="support@taosdata.com", description="TDengine python client package", diff --git a/src/connector/python/linux/python2/taos/cursor.py b/src/connector/python/linux/python2/taos/cursor.py index 82a01be671..ada83d72c5 100644 --- a/src/connector/python/linux/python2/taos/cursor.py +++ b/src/connector/python/linux/python2/taos/cursor.py @@ -184,7 +184,7 @@ class TDengineCursor(object): return False - def fetchall(self): + def fetchall_row(self): """Fetch all (remaining) rows of a query result, returning them as a sequence of sequences (e.g. a list of tuples). Note that the cursor's arraysize attribute can affect the performance of this operation. """ if self._result is None or self._fields is None: @@ -203,7 +203,7 @@ class TDengineCursor(object): for i in range(len(self._fields)): buffer[i].extend(block[i]) return list(map(tuple, zip(*buffer))) - def fetchall_block(self): + def fetchall(self): if self._result is None or self._fields is None: raise OperationalError("Invalid use of fetchall") diff --git a/src/connector/python/linux/python3/setup.py b/src/connector/python/linux/python3/setup.py index 655a12ad13..e238372cd3 100644 --- a/src/connector/python/linux/python3/setup.py +++ b/src/connector/python/linux/python3/setup.py @@ -5,7 +5,7 @@ with open("README.md", "r") as fh: setuptools.setup( name="taos", - version="2.0.3", + version="2.0.4", author="Taosdata Inc.", author_email="support@taosdata.com", description="TDengine python client package", diff --git a/src/connector/python/linux/python3/taos/cursor.py b/src/connector/python/linux/python3/taos/cursor.py index 0ce20f0eda..f972d2ff07 100644 --- a/src/connector/python/linux/python3/taos/cursor.py +++ b/src/connector/python/linux/python3/taos/cursor.py @@ -192,7 +192,7 @@ class TDengineCursor(object): return False - def fetchall(self): + def fetchall_row(self): """Fetch all (remaining) rows of a query result, returning them as a sequence of sequences (e.g. a list of tuples). Note that the cursor's arraysize attribute can affect the performance of this operation. """ if self._result is None or self._fields is None: @@ -212,7 +212,7 @@ class TDengineCursor(object): buffer[i].extend(block[i]) return list(map(tuple, zip(*buffer))) - def fetchall_block(self): + def fetchall(self): if self._result is None or self._fields is None: raise OperationalError("Invalid use of fetchall") diff --git a/src/connector/python/windows/python2/setup.py b/src/connector/python/windows/python2/setup.py index 5ddbe83011..333f5bedad 100644 --- a/src/connector/python/windows/python2/setup.py +++ b/src/connector/python/windows/python2/setup.py @@ -5,7 +5,7 @@ with open("README.md", "r") as fh: setuptools.setup( name="taos", - version="2.0.3", + version="2.0.4", author="Taosdata Inc.", author_email="support@taosdata.com", description="TDengine python client package", diff --git a/src/connector/python/windows/python2/taos/cursor.py b/src/connector/python/windows/python2/taos/cursor.py index f6fde2619b..958466985e 100644 --- a/src/connector/python/windows/python2/taos/cursor.py +++ b/src/connector/python/windows/python2/taos/cursor.py @@ -138,7 +138,7 @@ class TDengineCursor(object): def fetchmany(self): pass - def fetchall(self): + def fetchall_row(self): """Fetch all (remaining) rows of a query result, returning them as a sequence of sequences (e.g. a list of tuples). Note that the cursor's arraysize attribute can affect the performance of this operation. """ if self._result is None or self._fields is None: @@ -158,7 +158,7 @@ class TDengineCursor(object): buffer[i].extend(block[i]) return list(map(tuple, zip(*buffer))) - def fetchall_block(self): + def fetchall(self): if self._result is None or self._fields is None: raise OperationalError("Invalid use of fetchall") diff --git a/src/connector/python/windows/python3/setup.py b/src/connector/python/windows/python3/setup.py index ffed304c85..f29fec121b 100644 --- a/src/connector/python/windows/python3/setup.py +++ b/src/connector/python/windows/python3/setup.py @@ -5,7 +5,7 @@ with open("README.md", "r") as fh: setuptools.setup( name="taos", - version="2.0.3", + version="2.0.4", author="Taosdata Inc.", author_email="support@taosdata.com", description="TDengine python client package", diff --git a/src/connector/python/windows/python3/taos/cursor.py b/src/connector/python/windows/python3/taos/cursor.py index db66b99d3b..bbac1b1dd5 100644 --- a/src/connector/python/windows/python3/taos/cursor.py +++ b/src/connector/python/windows/python3/taos/cursor.py @@ -139,7 +139,7 @@ class TDengineCursor(object): def fetchmany(self): pass - def fetchall(self): + def fetchall_row(self): """Fetch all (remaining) rows of a query result, returning them as a sequence of sequences (e.g. a list of tuples). Note that the cursor's arraysize attribute can affect the performance of this operation. """ if self._result is None or self._fields is None: @@ -159,7 +159,7 @@ class TDengineCursor(object): buffer[i].extend(block[i]) return list(map(tuple, zip(*buffer))) - def fetchall_block(self): + def fetchall(self): if self._result is None or self._fields is None: raise OperationalError("Invalid use of fetchall") From bbd9fdc654ac7cc910450be091a6d9cdf9a7e526 Mon Sep 17 00:00:00 2001 From: zyyang Date: Fri, 15 Jan 2021 18:31:49 +0800 Subject: [PATCH 18/21] change --- .../taosdata/jdbc/TSDBDatabaseMetaData.java | 4 +- .../jdbc/TSDBDatabaseMetaDataTest.java | 52 ++++++++++++------- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java index 96ecd5a2bc..4ea0fc7950 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java @@ -900,7 +900,7 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { } public int getDatabaseMajorVersion() throws SQLException { - return 0; + return 2; } public int getDatabaseMinorVersion() throws SQLException { @@ -908,7 +908,7 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { } public int getJDBCMajorVersion() throws SQLException { - return 0; + return 2; } public int getJDBCMinorVersion() throws SQLException { diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java index 42f8cff9cc..448b513d0e 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java @@ -827,71 +827,87 @@ public class TSDBDatabaseMetaDataTest { } @Test - public void getResultSetHoldability() { - + public void getResultSetHoldability() throws SQLException { + Assert.assertEquals(1, metaData.getResultSetHoldability()); } @Test - public void getDatabaseMajorVersion() { + public void getDatabaseMajorVersion() throws SQLException { + Assert.assertEquals(2, metaData.getDatabaseMajorVersion()); } @Test - public void getDatabaseMinorVersion() { + public void getDatabaseMinorVersion() throws SQLException { + Assert.assertEquals(0, metaData.getDatabaseMinorVersion()); } @Test - public void getJDBCMajorVersion() { + public void getJDBCMajorVersion() throws SQLException { + Assert.assertEquals(2, metaData.getJDBCMajorVersion()); } @Test - public void getJDBCMinorVersion() { + public void getJDBCMinorVersion() throws SQLException { + Assert.assertEquals(0, metaData.getJDBCMinorVersion()); } @Test - public void getSQLStateType() { + public void getSQLStateType() throws SQLException { + Assert.assertEquals(0, metaData.getSQLStateType()); } @Test - public void locatorsUpdateCopy() { + public void locatorsUpdateCopy() throws SQLException { + Assert.assertFalse(metaData.locatorsUpdateCopy()); } @Test - public void supportsStatementPooling() { + public void supportsStatementPooling() throws SQLException { + Assert.assertFalse(metaData.supportsStatementPooling()); } @Test - public void getRowIdLifetime() { + public void getRowIdLifetime() throws SQLException { + Assert.assertNull(metaData.getRowIdLifetime()); } @Test - public void testGetSchemas() { + public void testGetSchemas() throws SQLException { + Assert.assertNull(metaData.getSchemas()); } @Test - public void supportsStoredFunctionsUsingCallSyntax() { + public void supportsStoredFunctionsUsingCallSyntax() throws SQLException { + Assert.assertFalse(metaData.supportsStoredFunctionsUsingCallSyntax()); } @Test - public void autoCommitFailureClosesAllResultSets() { + public void autoCommitFailureClosesAllResultSets() throws SQLException { + Assert.assertFalse(metaData.autoCommitFailureClosesAllResultSets()); } @Test - public void getClientInfoProperties() { + public void getClientInfoProperties() throws SQLException { + Assert.assertNotNull(metaData.getClientInfoProperties()); } @Test - public void getFunctions() { + public void getFunctions() throws SQLException { + Assert.assertNotNull(metaData.getFunctions("", "", "")); } @Test - public void getFunctionColumns() { + public void getFunctionColumns() throws SQLException { + Assert.assertNotNull(metaData.getFunctionColumns("", "", "", "")); } @Test - public void getPseudoColumns() { + public void getPseudoColumns() throws SQLException { + Assert.assertNotNull(metaData.getPseudoColumns("", "", "", "")); } @Test - public void generatedKeyAlwaysReturned() { + public void generatedKeyAlwaysReturned() throws SQLException { + Assert.assertFalse(metaData.generatedKeyAlwaysReturned()); } } \ No newline at end of file From 00bc36171e4f67c227c8a6d980ddbbd6aa122f17 Mon Sep 17 00:00:00 2001 From: zyyang Date: Sat, 16 Jan 2021 11:49:38 +0800 Subject: [PATCH 19/21] change --- .../taosdata/jdbc/DatabaseMetaDataTest.java | 247 ------------------ 1 file changed, 247 deletions(-) delete mode 100644 src/connector/jdbc/src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java deleted file mode 100644 index 49b8de4495..0000000000 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java +++ /dev/null @@ -1,247 +0,0 @@ -package com.taosdata.jdbc; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.sql.*; -import java.util.Properties; - -public class DatabaseMetaDataTest { - static Connection connection = null; - static PreparedStatement statement = null; - static String dbName = "test"; - static String tName = "t0"; - static String host = "localhost"; - - @BeforeClass - public static void createConnection() throws SQLException { - try { - Class.forName("com.taosdata.jdbc.TSDBDriver"); - } catch (ClassNotFoundException e) { - return; - } - Properties properties = new Properties(); - properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, host); - properties.setProperty(TSDBDriver.PROPERTY_KEY_USER, "root"); - properties.setProperty(TSDBDriver.PROPERTY_KEY_PASSWORD, "taosdata"); - properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); - properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); - properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); - connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties); - - String sql = "drop database if exists " + dbName; - statement = connection.prepareStatement(sql); - statement.executeUpdate("create database if not exists " + dbName); - statement.executeUpdate("create table if not exists " + dbName + "." + tName + " (ts timestamp, k int, v int)"); - } - - @Test - public void testMetaDataTest() throws SQLException { - DatabaseMetaData databaseMetaData = connection.getMetaData(); - ResultSet resultSet = databaseMetaData.getTables(dbName, "t*", "t*", new String[]{"t"}); - while (resultSet.next()) { - for (int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) { - System.out.printf("%d: %s\n", i, resultSet.getString(i)); - } - } - resultSet.close(); - databaseMetaData.isWrapperFor(null); - databaseMetaData.allProceduresAreCallable(); - databaseMetaData.allTablesAreSelectable(); - databaseMetaData.getURL(); - databaseMetaData.getUserName(); - databaseMetaData.isReadOnly(); - databaseMetaData.nullsAreSortedHigh(); - databaseMetaData.nullsAreSortedLow(); - databaseMetaData.nullsAreSortedAtStart(); - databaseMetaData.nullsAreSortedAtEnd(); - databaseMetaData.getDatabaseProductName(); - databaseMetaData.getDatabaseProductVersion(); - databaseMetaData.getDriverName(); - databaseMetaData.getDriverVersion(); - databaseMetaData.getDriverMajorVersion(); - databaseMetaData.getDriverMinorVersion(); - databaseMetaData.usesLocalFiles(); - databaseMetaData.usesLocalFilePerTable(); - databaseMetaData.supportsMixedCaseIdentifiers(); - databaseMetaData.storesUpperCaseIdentifiers(); - databaseMetaData.storesLowerCaseIdentifiers(); - databaseMetaData.storesMixedCaseIdentifiers(); - databaseMetaData.supportsMixedCaseQuotedIdentifiers(); - databaseMetaData.storesUpperCaseQuotedIdentifiers(); - databaseMetaData.storesLowerCaseQuotedIdentifiers(); - databaseMetaData.storesMixedCaseQuotedIdentifiers(); - databaseMetaData.getIdentifierQuoteString(); - databaseMetaData.getSQLKeywords(); - databaseMetaData.getNumericFunctions(); - databaseMetaData.getStringFunctions(); - databaseMetaData.getSystemFunctions(); - databaseMetaData.getTimeDateFunctions(); - databaseMetaData.getSearchStringEscape(); - databaseMetaData.getExtraNameCharacters(); - databaseMetaData.supportsAlterTableWithAddColumn(); - databaseMetaData.supportsAlterTableWithDropColumn(); - databaseMetaData.supportsColumnAliasing(); - databaseMetaData.nullPlusNonNullIsNull(); - databaseMetaData.supportsConvert(); - databaseMetaData.supportsConvert(0, 0); - databaseMetaData.supportsTableCorrelationNames(); - databaseMetaData.supportsDifferentTableCorrelationNames(); - databaseMetaData.supportsExpressionsInOrderBy(); - databaseMetaData.supportsOrderByUnrelated(); - databaseMetaData.supportsGroupBy(); - databaseMetaData.supportsGroupByUnrelated(); - databaseMetaData.supportsGroupByBeyondSelect(); - databaseMetaData.supportsLikeEscapeClause(); - databaseMetaData.supportsMultipleResultSets(); - databaseMetaData.supportsMultipleTransactions(); - databaseMetaData.supportsNonNullableColumns(); - databaseMetaData.supportsMinimumSQLGrammar(); - databaseMetaData.supportsCoreSQLGrammar(); - databaseMetaData.supportsExtendedSQLGrammar(); - databaseMetaData.supportsANSI92EntryLevelSQL(); - databaseMetaData.supportsANSI92IntermediateSQL(); - databaseMetaData.supportsANSI92FullSQL(); - databaseMetaData.supportsIntegrityEnhancementFacility(); - databaseMetaData.supportsOuterJoins(); - databaseMetaData.supportsFullOuterJoins(); - databaseMetaData.supportsLimitedOuterJoins(); - databaseMetaData.getSchemaTerm(); - databaseMetaData.getProcedureTerm(); - databaseMetaData.getCatalogTerm(); - databaseMetaData.isCatalogAtStart(); - databaseMetaData.getCatalogSeparator(); - databaseMetaData.supportsSchemasInDataManipulation(); - databaseMetaData.supportsSchemasInProcedureCalls(); - databaseMetaData.supportsSchemasInTableDefinitions(); - databaseMetaData.supportsSchemasInIndexDefinitions(); - databaseMetaData.supportsSchemasInPrivilegeDefinitions(); - databaseMetaData.supportsCatalogsInDataManipulation(); - databaseMetaData.supportsCatalogsInProcedureCalls(); - databaseMetaData.supportsCatalogsInTableDefinitions(); - databaseMetaData.supportsCatalogsInIndexDefinitions(); - databaseMetaData.supportsCatalogsInPrivilegeDefinitions(); - databaseMetaData.supportsPositionedDelete(); - databaseMetaData.supportsPositionedUpdate(); - databaseMetaData.supportsSelectForUpdate(); - databaseMetaData.supportsStoredProcedures(); - databaseMetaData.supportsSubqueriesInComparisons(); - databaseMetaData.supportsSubqueriesInExists(); - databaseMetaData.supportsSubqueriesInIns(); - databaseMetaData.supportsSubqueriesInQuantifieds(); - databaseMetaData.supportsCorrelatedSubqueries(); - databaseMetaData.supportsUnion(); - databaseMetaData.supportsUnionAll(); - databaseMetaData.supportsOpenCursorsAcrossCommit(); - databaseMetaData.supportsOpenCursorsAcrossRollback(); - databaseMetaData.supportsOpenStatementsAcrossCommit(); - databaseMetaData.supportsOpenStatementsAcrossRollback(); - databaseMetaData.getMaxBinaryLiteralLength(); - databaseMetaData.getMaxCharLiteralLength(); - databaseMetaData.getMaxColumnNameLength(); - databaseMetaData.getMaxColumnsInGroupBy(); - databaseMetaData.getMaxColumnsInIndex(); - databaseMetaData.getMaxColumnsInOrderBy(); - databaseMetaData.getMaxColumnsInSelect(); - databaseMetaData.getMaxColumnsInTable(); - databaseMetaData.getMaxConnections(); - databaseMetaData.getMaxCursorNameLength(); - databaseMetaData.getMaxIndexLength(); - databaseMetaData.getMaxSchemaNameLength(); - databaseMetaData.getMaxProcedureNameLength(); - databaseMetaData.getMaxCatalogNameLength(); - databaseMetaData.getMaxRowSize(); - databaseMetaData.doesMaxRowSizeIncludeBlobs(); - databaseMetaData.getMaxStatementLength(); - databaseMetaData.getMaxStatements(); - databaseMetaData.getMaxTableNameLength(); - databaseMetaData.getMaxTablesInSelect(); - databaseMetaData.getMaxUserNameLength(); - databaseMetaData.getDefaultTransactionIsolation(); - databaseMetaData.supportsTransactions(); - databaseMetaData.supportsTransactionIsolationLevel(0); - databaseMetaData.supportsDataDefinitionAndDataManipulationTransactions(); - databaseMetaData.supportsDataManipulationTransactionsOnly(); - databaseMetaData.dataDefinitionCausesTransactionCommit(); - databaseMetaData.dataDefinitionIgnoredInTransactions(); - try { - databaseMetaData.getProcedures("", "", ""); - } catch (Exception e) { - - } - try { - databaseMetaData.getProcedureColumns("", "", "", ""); - } catch (Exception e) { - } - try { - databaseMetaData.getTables("", "", "", new String[]{""}); - } catch (Exception e) { - - } - databaseMetaData.getSchemas(); - databaseMetaData.getCatalogs(); -// databaseMetaData.getTableTypes(); - - databaseMetaData.getColumns(dbName, "", tName, ""); - databaseMetaData.getColumnPrivileges("", "", "", ""); - databaseMetaData.getTablePrivileges("", "", ""); - databaseMetaData.getBestRowIdentifier("", "", "", 0, false); - databaseMetaData.getVersionColumns("", "", ""); - databaseMetaData.getPrimaryKeys("", "", ""); - databaseMetaData.getImportedKeys("", "", ""); - databaseMetaData.getExportedKeys("", "", ""); - databaseMetaData.getCrossReference("", "", "", "", "", ""); - databaseMetaData.getTypeInfo(); - databaseMetaData.getIndexInfo("", "", "", false, false); - databaseMetaData.supportsResultSetType(0); - databaseMetaData.supportsResultSetConcurrency(0, 0); - databaseMetaData.ownUpdatesAreVisible(0); - databaseMetaData.ownDeletesAreVisible(0); - databaseMetaData.ownInsertsAreVisible(0); - databaseMetaData.othersUpdatesAreVisible(0); - databaseMetaData.othersDeletesAreVisible(0); - databaseMetaData.othersInsertsAreVisible(0); - databaseMetaData.updatesAreDetected(0); - databaseMetaData.deletesAreDetected(0); - databaseMetaData.insertsAreDetected(0); - databaseMetaData.supportsBatchUpdates(); - databaseMetaData.getUDTs("", "", "", new int[]{0}); - databaseMetaData.getConnection(); - databaseMetaData.supportsSavepoints(); - databaseMetaData.supportsNamedParameters(); - databaseMetaData.supportsMultipleOpenResults(); - databaseMetaData.supportsGetGeneratedKeys(); - databaseMetaData.getSuperTypes("", "", ""); - databaseMetaData.getSuperTables("", "", ""); - databaseMetaData.getAttributes("", "", "", ""); - databaseMetaData.supportsResultSetHoldability(0); - databaseMetaData.getResultSetHoldability(); - databaseMetaData.getDatabaseMajorVersion(); - databaseMetaData.getDatabaseMinorVersion(); - databaseMetaData.getJDBCMajorVersion(); - databaseMetaData.getJDBCMinorVersion(); - databaseMetaData.getSQLStateType(); - databaseMetaData.locatorsUpdateCopy(); - databaseMetaData.supportsStatementPooling(); - databaseMetaData.getRowIdLifetime(); - databaseMetaData.getSchemas("", ""); - databaseMetaData.supportsStoredFunctionsUsingCallSyntax(); - databaseMetaData.autoCommitFailureClosesAllResultSets(); - databaseMetaData.getClientInfoProperties(); - databaseMetaData.getFunctions("", "", ""); - databaseMetaData.getFunctionColumns("", "", "", ""); - databaseMetaData.getPseudoColumns("", "", "", ""); - databaseMetaData.generatedKeyAlwaysReturned(); - } - - - @AfterClass - public static void close() throws Exception { - statement.executeUpdate("drop database " + dbName); - statement.close(); - connection.close(); - Thread.sleep(10); - - } -} From 2b7a6aa050b142b31048eead99103ee4f113b91c Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Sat, 16 Jan 2021 18:15:51 +0800 Subject: [PATCH 20/21] [TD-2775] : add update to faq. --- .../webdocs/markdowndocs/faq-ch.md | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/documentation20/webdocs/markdowndocs/faq-ch.md b/documentation20/webdocs/markdowndocs/faq-ch.md index a085e6159a..79139078c1 100644 --- a/documentation20/webdocs/markdowndocs/faq-ch.md +++ b/documentation20/webdocs/markdowndocs/faq-ch.md @@ -1,5 +1,19 @@ # 常见问题 +## 0. 怎么报告问题? + +如果 FAQ 中的信息不能够帮到您,需要 TDengine 技术团队的技术支持与协助,请将以下两个目录中内容打包: +1. /var/log/taos (如果没有修改过默认路径) +2. /etc/taos + +附上必要的问题描述,包括使用的 TDengine 版本信息、平台环境信息、发生该问题的执行操作、出现问题的表征及大概的时间,在 GitHub提交Issue。 + +为了保证有足够的debug信息,如果问题能够重复,请修改/etc/taos/taos.cfg文件,最后面添加一行“debugFlag 135"(不带引号本身),然后重启taosd, 重复问题,然后再递交。也可以通过如下SQL语句,临时设置taosd的日志级别。 +``` + alter dnode debugFlag 135; +``` +但系统正常运行时,请一定将debugFlag设置为131,否则会产生大量的日志信息,降低系统效率。 + ## 1. TDengine2.0之前的版本升级到2.0及以上的版本应该注意什么?☆☆☆ 2.0版本在之前版本的基础上,进行了完全的重构,配置文件和数据文件是不兼容的。在升级之前务必进行如下操作: @@ -118,16 +132,8 @@ TDengine是根据hostname唯一标志一台机器的,在数据文件从机器A - 2.0.7.0 及以后的版本,到/var/lib/taos/dnode下,修复dnodeEps.json的dnodeId对应的FQDN,重启。确保机器内所有机器的此文件是完全相同的。 - 1.x 和 2.x 版本的存储结构不兼容,需要使用迁移工具或者自己开发应用导出导入数据。 -## 17. 怎么报告问题? +## 17. TDengine 是否支持删除或更新已经写入的数据? -如果 FAQ 中的信息不能够帮到您,需要 TDengine 技术团队的技术支持与协助,请将以下两个目录中内容打包: -1. /var/log/taos -2. /etc/taos +TDengine 目前尚不支持删除功能,未来根据用户需求可能会支持。 -附上必要的问题描述,以及发生该问题的执行操作,出现问题的表征及大概的时间,在 GitHub提交Issue。 - -为了保证有足够的debug信息,如果问题能够重复,请修改/etc/taos/taos.cfg文件,最后面添加一行“debugFlag 135"(不带引号本身),然后重启taosd, 重复问题,然后再递交。也可以通过如下SQL语句,临时设置taosd的日志级别。 -``` - alter dnode debugFlag 135; -``` -但系统正常运行时,请一定将debugFlag设置为131,否则会产生大量的日志信息,降低系统效率。 +从 2.0.8.0 开始,TDengine 支持更新已经写入数据的功能。使用更新功能需要在创建数据库时使用 UPDATE 1 参数,之后可以使用 INSERT INTO 命令更新已经写入的相同时间戳数据。UPDATE 参数不支持 ALTER DATABASE 命令修改。没有使用 UPDATE 1 参数创建的数据库,写入相同时间戳的数据不会修改之前的数据,也不会报错。 \ No newline at end of file From 28a4bd3e003b6882ec25528bed189b883067401c Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Sat, 16 Jan 2021 19:20:45 +0800 Subject: [PATCH 21/21] [TD-2775] : add update to faq, fix minor typo. --- documentation20/webdocs/markdowndocs/cluster-ch.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation20/webdocs/markdowndocs/cluster-ch.md b/documentation20/webdocs/markdowndocs/cluster-ch.md index 89f6a64f19..3d53f3a86b 100644 --- a/documentation20/webdocs/markdowndocs/cluster-ch.md +++ b/documentation20/webdocs/markdowndocs/cluster-ch.md @@ -218,7 +218,7 @@ SHOW MNODES; 如果一个数据节点离线,TDengine集群将自动检测到。有如下两种情况: -- 该数据节点离线超过一定时间(taos.cfg里配置参数offlineThreshold控制时长),系统将自动把该数据节点删除,产生系统报警信息,触发负载均衡流程。如果该被删除的数据节点重现上线时,它将无法加入集群,需要系统管理员重新将其添加进集群才会开始工作。 +- 该数据节点离线超过一定时间(taos.cfg里配置参数offlineThreshold控制时长),系统将自动把该数据节点删除,产生系统报警信息,触发负载均衡流程。如果该被删除的数据节点重新上线时,它将无法加入集群,需要系统管理员重新将其添加进集群才会开始工作。 - 离线后,在offlineThreshold的时长内重新上线,系统将自动启动数据恢复流程,等数据完全恢复后,该节点将开始正常工作。 **注意:**如果一个虚拟节点组(包括mnode组)里所归属的每个数据节点都处于离线或unsynced状态,必须等该虚拟节点组里的所有数据节点都上线、都能交换状态信息后,才能选出Master,该虚拟节点组才能对外提供服务。比如整个集群有3个数据节点,副本数为3,如果3个数据节点都宕机,然后2个数据节点重启,是无法工作的,只有等3个数据节点都重启成功,才能对外服务。