Mercurial > hg > monetdb-java
comparison tests/JDBC_API_Tester.java @ 925:4dfdb62e3e9d
Extend JDBC_API_Tester program with optional second startup argument '-skipMALoutput'.
This allows the JDBC_API_Tester program to be called to skip the comparing the MAL output of tests which return MAL output such as PLAN, EXPLAIN and TRACE statements.
It is intended for internal development use only.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 08 Aug 2024 15:26:28 +0200 (8 months ago) |
parents | 3b29fb3f537a |
children | d311affc65f0 |
comparison
equal
deleted
inserted
replaced
924:ace9f8f617f1 | 925:4dfdb62e3e9d |
---|---|
45 final private int dbmsMajorVersion; | 45 final private int dbmsMajorVersion; |
46 final private int dbmsMinorVersion; | 46 final private int dbmsMinorVersion; |
47 final private boolean isPostDec2023; // flag to support version specific output | 47 final private boolean isPostDec2023; // flag to support version specific output |
48 private boolean foundDifferences = false; | 48 private boolean foundDifferences = false; |
49 | 49 |
50 final private static int sbInitLen = 5468; | 50 final private static int sbInitLen = 5468; // max needed size of sb |
51 | 51 |
52 /** | 52 /** |
53 * constructor | 53 * constructor |
54 */ | 54 */ |
55 JDBC_API_Tester(Connection con_) throws SQLException { | 55 JDBC_API_Tester(Connection con_) throws SQLException { |
64 isPostDec2023 = versionIsAtLeast(11, 50); | 64 isPostDec2023 = versionIsAtLeast(11, 50); |
65 } | 65 } |
66 | 66 |
67 /** | 67 /** |
68 * main function | 68 * main function |
69 * @param args this should contain the connectionURL string | 69 * @param args args[0] should contain the connectionURL string, args[1] an optional flag: -skipMALoutput |
70 * @throws Exception if a database access error occurs | 70 * @throws Exception if a connection or database access error occurs |
71 */ | 71 */ |
72 public static void main(String[] args) throws Exception { | 72 public static void main(String[] args) throws Exception { |
73 String con_URL = args[0]; | 73 if (args.length < 1) { |
74 System.err.println("Error: Missing required connection URL as first startup argument!"); | |
75 System.exit(-1); | |
76 } | |
77 | |
78 final String con_URL = args[0]; | |
79 final boolean skipMALoutput = (args.length >= 2) ? args[1].equals("-skipMALoutput") : false; | |
80 // System.err.println("skipMALoutput = " + skipMALoutput); | |
74 | 81 |
75 // Test this before trying to connect | 82 // Test this before trying to connect |
76 UrlTester.runAllTests(); | 83 UrlTester.runAllTests(); |
77 | 84 |
78 Connection conn = DriverManager.getConnection(con_URL); | 85 final Connection conn = DriverManager.getConnection(con_URL); |
79 JDBC_API_Tester jt = new JDBC_API_Tester(conn); | 86 JDBC_API_Tester jt = new JDBC_API_Tester(conn); |
80 | |
81 | 87 |
82 // run the tests | 88 // run the tests |
83 jt.Test_Cautocommit(con_URL); | 89 jt.Test_Cautocommit(con_URL); |
84 jt.Test_CisValid(); | 90 jt.Test_CisValid(); |
85 jt.Test_Clargequery(); | 91 jt.Test_Clargequery(); |
91 jt.Test_DBCmetadata(); | 97 jt.Test_DBCmetadata(); |
92 jt.Test_EmptySql(); | 98 jt.Test_EmptySql(); |
93 jt.Test_FetchSize(); | 99 jt.Test_FetchSize(); |
94 jt.Test_Int128(); | 100 jt.Test_Int128(); |
95 jt.Test_Interval_Types(); | 101 jt.Test_Interval_Types(); |
96 jt.Test_PlanExplainTraceDebugCmds(); | 102 jt.Test_PlanExplainTraceDebugCmds(skipMALoutput); |
97 jt.Test_PSgeneratedkeys(); | 103 jt.Test_PSgeneratedkeys(); |
98 jt.Test_PSgetObject(); | 104 jt.Test_PSgetObject(); |
99 jt.Test_PSlargebatchval(); | 105 jt.Test_PSlargebatchval(); |
100 jt.Test_PSlargeresponse(con_URL); | 106 jt.Test_PSlargeresponse(con_URL); |
101 jt.Test_PSmanycon(con_URL); | 107 jt.Test_PSmanycon(con_URL); |
1942 "ParameterTypeName: interval hour to minute Precision: 13 Scale: 0 ParameterType: 3 ParameterClassName: java.math.BigDecimal\n" + | 1948 "ParameterTypeName: interval hour to minute Precision: 13 Scale: 0 ParameterType: 3 ParameterClassName: java.math.BigDecimal\n" + |
1943 "ParameterTypeName: interval hour to second Precision: 15 Scale: 0 ParameterType: 3 ParameterClassName: java.math.BigDecimal\n" + | 1949 "ParameterTypeName: interval hour to second Precision: 15 Scale: 0 ParameterType: 3 ParameterClassName: java.math.BigDecimal\n" + |
1944 "ParameterTypeName: interval minute to second Precision: 15 Scale: 0 ParameterType: 3 ParameterClassName: java.math.BigDecimal\n"); | 1950 "ParameterTypeName: interval minute to second Precision: 15 Scale: 0 ParameterType: 3 ParameterClassName: java.math.BigDecimal\n"); |
1945 } | 1951 } |
1946 | 1952 |
1947 private void Test_PlanExplainTraceDebugCmds() { | 1953 private void Test_PlanExplainTraceDebugCmds(boolean skipMALoutput) { |
1948 sb.setLength(0); // clear the output log buffer | 1954 sb.setLength(0); // clear the output log buffer |
1949 | 1955 |
1950 Statement stmt = null; | 1956 Statement stmt = null; |
1951 ResultSet rs = null; | 1957 ResultSet rs = null; |
1952 try { | 1958 try { |
1964 sb.setLength(0); // clear the output log buffer | 1970 sb.setLength(0); // clear the output log buffer |
1965 | 1971 |
1966 // plan statements are supported via JDBC | 1972 // plan statements are supported via JDBC |
1967 qry = "plan SELECT 2;"; | 1973 qry = "plan SELECT 2;"; |
1968 rs = stmt.executeQuery(qry); | 1974 rs = stmt.executeQuery(qry); |
1969 compareResultSet(rs, qry, | 1975 if (!skipMALoutput) { |
1970 ! isPreJan2022 ? | 1976 compareResultSet(rs, qry, |
1971 "Resultset with 1 columns\n" + | 1977 ! isPreJan2022 ? |
1972 "rel\n" + | 1978 "Resultset with 1 columns\n" + |
1973 (isPostDec2023 ? "varchar" : "clob") + "(37)\n" + | 1979 "rel\n" + |
1974 "project (\n" + | 1980 (isPostDec2023 ? "varchar" : "clob") + "(37)\n" + |
1975 "| [ boolean(1) \"true\" as \"%1\".\"%1\" ]\n" + | 1981 "project (\n" + |
1976 ") [ tinyint(2) \"2\" ]\n" | 1982 "| [ boolean(1) \"true\" as \"%1\".\"%1\" ]\n" + |
1977 : | 1983 ") [ tinyint(2) \"2\" ]\n" |
1978 "Resultset with 1 columns\n" + | 1984 : |
1979 "rel\n" + | 1985 "Resultset with 1 columns\n" + |
1980 "clob(21)\n" + | 1986 "rel\n" + |
1981 "project (\n" + | 1987 "clob(21)\n" + |
1982 "| [ boolean \"true\" ]\n" + | 1988 "project (\n" + |
1983 ") [ tinyint \"2\" ]\n"); | 1989 "| [ boolean \"true\" ]\n" + |
1990 ") [ tinyint \"2\" ]\n"); | |
1991 } | |
1984 rs.close(); | 1992 rs.close(); |
1985 rs = null; | 1993 rs = null; |
1986 sb.setLength(0); // clear the output log buffer | 1994 sb.setLength(0); // clear the output log buffer |
1987 | 1995 |
1988 // explain statements are supported via JDBC | 1996 // explain statements are supported via JDBC |
1993 if (!val.startsWith("#")) | 2001 if (!val.startsWith("#")) |
1994 sb.append(val).append("\n"); | 2002 sb.append(val).append("\n"); |
1995 } | 2003 } |
1996 rs.close(); | 2004 rs.close(); |
1997 rs = null; | 2005 rs = null; |
1998 compareExpectedOutput("Test_PlanExplainTraceDebugCmds: " + qry, | 2006 if (!skipMALoutput) { |
1999 "function user.main():void;\n" + | 2007 compareExpectedOutput("Test_PlanExplainTraceDebugCmds: " + qry, |
2000 " X_1:void := querylog.define(\"explain select 3;\":str, \"default_pipe\":str, 6:int);\n" + | 2008 "function user.main():void;\n" + |
2001 " X_10:int := sql.resultSet(\".%2\":str, \"%2\":str, \"tinyint\":str, 2:int, 0:int, 7:int, 3:bte);\n" + | 2009 " X_1:void := querylog.define(\"explain select 3;\":str, \"default_pipe\":str, 6:int);\n" + |
2002 "end user.main;\n"); | 2010 " X_10:int := sql.resultSet(\".%2\":str, \"%2\":str, \"tinyint\":str, 2:int, 0:int, 7:int, 3:bte);\n" + |
2011 "end user.main;\n"); | |
2012 } | |
2003 sb.setLength(0); // clear the output log buffer | 2013 sb.setLength(0); // clear the output log buffer |
2004 | 2014 |
2005 // trace statements are supported via JDBC. Note that it returns two resultsets, one with the query result and next one with the trace result. | 2015 // trace statements are supported via JDBC. Note that it returns two resultsets, one with the query result and next one with the trace result. |
2006 qry = "trace SELECT 4;"; | 2016 qry = "trace SELECT 4;"; |
2007 rs = stmt.executeQuery(qry); | 2017 rs = stmt.executeQuery(qry); |
2015 sb.append(rs.getString(2)).append("\n"); | 2025 sb.append(rs.getString(2)).append("\n"); |
2016 } | 2026 } |
2017 } | 2027 } |
2018 rs.close(); | 2028 rs.close(); |
2019 rs = null; | 2029 rs = null; |
2020 compareExpectedOutput("Test_PlanExplainTraceDebugCmds: " + qry, | 2030 if (!skipMALoutput) { |
2021 ! isPreJan2022 ? | 2031 compareExpectedOutput("Test_PlanExplainTraceDebugCmds: " + qry, |
2022 "4\n" + | 2032 ! isPreJan2022 ? |
2023 "Another resultset\n" + | 2033 "4\n" + |
2024 " X_1=0@0:void := querylog.define(\"trace select 4;\":str, \"default_pipe\":str, 6:int);\n" + | 2034 "Another resultset\n" + |
2025 " X_10=0:int := sql.resultSet(\".%2\":str, \"%2\":str, \"tinyint\":str, 3:int, 0:int, 7:int, 4:bte);\n" | 2035 " X_1=0@0:void := querylog.define(\"trace select 4;\":str, \"default_pipe\":str, 6:int);\n" + |
2026 : | 2036 " X_10=0:int := sql.resultSet(\".%2\":str, \"%2\":str, \"tinyint\":str, 3:int, 0:int, 7:int, 4:bte);\n" |
2027 "4\n" + | 2037 : |
2028 "Another resultset\n" + | 2038 "4\n" + |
2029 "X_0=0@0:void := querylog.define(\"trace select 4;\":str, \"default_pipe\":str, 6:int);\n" + | 2039 "Another resultset\n" + |
2030 "X_1=0:int := sql.resultSet(\".%2\":str, \"%2\":str, \"tinyint\":str, 3:int, 0:int, 7:int, 4:bte);\n"); | 2040 "X_0=0@0:void := querylog.define(\"trace select 4;\":str, \"default_pipe\":str, 6:int);\n" + |
2041 "X_1=0:int := sql.resultSet(\".%2\":str, \"%2\":str, \"tinyint\":str, 3:int, 0:int, 7:int, 4:bte);\n"); | |
2042 } | |
2031 sb.setLength(0); // clear the output log buffer | 2043 sb.setLength(0); // clear the output log buffer |
2032 | 2044 |
2033 // debug statements are NOT supported via JDBC driver, so the execution should throw an SQLException | 2045 // debug statements are NOT supported via JDBC driver, so the execution should throw an SQLException |
2034 // Note: as of release 11.47 (Jun2023) the debug statement is not supported anymore, error msg: syntax error in: "debug" | 2046 // Note: as of release 11.47 (Jun2023) the debug statement is not supported anymore, error msg: syntax error in: "debug" |
2035 qry = "debug SELECT 5;"; | 2047 qry = "debug SELECT 5;"; |