comparison src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java @ 136:4320e6891536

Replace AssertionError() with SQLException(). JDBC driver should not throw an AssertionError as it may stop the calling application.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 13 Jul 2017 19:06:12 +0200 (2017-07-13)
parents b9b35ca2eec2
children d6abd1ffffbb
comparison
equal deleted inserted replaced
135:f638f5257b2e 136:4320e6891536
1932 * sufficient to be consistant 1932 * sufficient to be consistant
1933 */ 1933 */
1934 @Override 1934 @Override
1935 public void complete() throws SQLException { 1935 public void complete() throws SQLException {
1936 String error = ""; 1936 String error = "";
1937 if (!isSet[NAMES]) error += "name header missing\n"; 1937 if (!isSet[NAMES]) error = "name header missing\n";
1938 if (!isSet[TYPES]) error += "type header missing\n"; 1938 if (!isSet[TYPES]) error += "type header missing\n";
1939 if (!isSet[TABLES]) error += "table name header missing\n"; 1939 if (!isSet[TABLES]) error += "table name header missing\n";
1940 if (!isSet[LENS]) error += "column width header missing\n"; 1940 if (!isSet[LENS]) error += "column width header missing\n";
1941 if (error != "") throw new SQLException(error, "M0M10"); 1941 if (!error.isEmpty())
1942 throw new SQLException(error, "M0M10");
1942 } 1943 }
1943 1944
1944 /** 1945 /**
1945 * Returns the names of the columns 1946 * Returns the names of the columns
1946 * 1947 *
2013 return parent.rsconcur; 2014 return parent.rsconcur;
2014 } 2015 }
2015 2016
2016 /** 2017 /**
2017 * Returns a line from the cache. If the line is already present in the 2018 * Returns a line from the cache. If the line is already present in the
2018 * cache, it is returned, if not apropriate actions are taken to make 2019 * cache, it is returned, if not appropriate actions are taken to make
2019 * sure the right block is being fetched and as soon as the requested 2020 * sure the right block is being fetched and as soon as the requested
2020 * line is fetched it is returned. 2021 * line is fetched it is returned.
2021 * 2022 *
2022 * @param row the row in the result set to return 2023 * @param row the row in the result set to return
2023 * @return the exact row read as requested or null if the requested row 2024 * @return the exact row read as requested or null if the requested row
2077 blockLine = (row - blockOffset) % cacheSize; 2078 blockLine = (row - blockOffset) % cacheSize;
2078 } 2079 }
2079 } 2080 }
2080 2081
2081 // ok, need to fetch cache block first 2082 // ok, need to fetch cache block first
2082 parent.executeQuery( 2083 parent.executeQuery(commandTempl,
2083 commandTempl, 2084 "export " + id + " " + ((block * cacheSize) + blockOffset) + " " + cacheSize);
2084 "export " + id + " " + ((block * cacheSize) + blockOffset) + " " + cacheSize
2085 );
2086 rawr = resultBlocks[block]; 2085 rawr = resultBlocks[block];
2087 if (rawr == null) 2086 if (rawr == null)
2088 throw new AssertionError("block " + block + " should have been fetched by now :("); 2087 throw new SQLException("resultBlocks[" + block + "] should have been fetched by now", "M0M10");
2089 } 2088 }
2090 2089
2091 return rawr.getRow(blockLine); 2090 return rawr.getRow(blockLine);
2092 } 2091 }
2093 2092