Mercurial > hg > monetdb-java
changeset 781:71d32f1a4d60
Improved DatabaseMetaData.getSystemFunctions(). It now also returns functions: current_sessionid, greatest, ifnull, least, sql_max, sql_min. Function ifnull will only be returned for servers Jun2023 (11.47 or higher).
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 12 Oct 2023 13:21:55 +0200 (18 months ago) |
parents | 3b09f0c93cdd |
children | e234659cfd61 |
files | ChangeLog src/main/java/org/monetdb/jdbc/MonetDatabaseMetaData.java |
diffstat | 2 files changed, 22 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,11 @@ # ChangeLog file for monetdb-java # This file is updated with Maddlog +* Thu Oct 12 2023 Martin van Dinther <martin.van.dinther@monetdbsolutions.com> +- Improved DatabaseMetaData.getSystemFunctions(). It now also returns + functions: current_sessionid, greatest, ifnull, least, sql_max, sql_min. + Function ifnull will only be returned for servers Jun2023 (11.47 or higher). + * Wed Aug 9 2023 Martin van Dinther <martin.van.dinther@monetdbsolutions.com> - Implemented ResultSet methods: <T> T getObject(int columnIndex, Class<T> type)
--- a/src/main/java/org/monetdb/jdbc/MonetDatabaseMetaData.java +++ b/src/main/java/org/monetdb/jdbc/MonetDatabaseMetaData.java @@ -453,13 +453,24 @@ public final class MonetDatabaseMetaData @Override public String getSystemFunctions() { final String wherePart = - "f.\"name\" IN ('columnsize','database','debug','get_value_for','hash','hashsize','heapsize'" + - ",'ifnull','ifthenelse','imprintsize','isaurl','isauuid','isnull','masterclock','mastertick'" + - ",'newurl','next_value_for','password_hash','replicaclock','replicatick','uuid')" + + "f.\"name\" IN ('columnsize','current_sessionid','database','debug'" + + ",'get_value_for','greatest','hash','hashsize','heapsize'" + + ",'ifthenelse','imprintsize','isaurl','isauuid','isnull','least'" + + ",'masterclock','mastertick'" + // wlc/wlr functions + ",'newurl','next_value_for','password_hash'" + + ",'replicaclock','replicatick'" + // wlc/wlr functions + ",'sql_max','sql_min','uuid')"; + String unionPart = // add functions which are not listed in sys.functions but implemented in the SQL parser (see sql/server/sql_parser.y) - " UNION ALL SELECT * FROM (VALUES('cast'),('coalesce'),('convert'),('nullif')) as sf"; - // ToDo: from release 11.47.1 we also support function: ifnull, but only with odbc escape notation, so {fn ifnull(null, 2)}. Related issue: 6933. - return getConcatenatedStringFromQuery(FunctionsSelect + wherePart + FunctionsOrderBy1); + " UNION SELECT * FROM (VALUES('cast'),('coalesce'),('convert'),('ifnull'),('nullif')) as sf"; + try { + // from release 11.47.1 we support function: ifnull, but only with odbc escape notation, so {fn ifnull(null, 2)}. See issue: 6933. + // from release 11.49.1 we support function: ifnull also without odbc escape notation. + if ((con.getDatabaseMajorVersion() == 11) && (con.getDatabaseMinorVersion() <= 45)) + // release 11.45 (Sep2022) or older did not support function: ifnull. + unionPart = unionPart.replace(",('ifnull')", ""); + } catch (SQLException e) { /* ignore */ } + return getConcatenatedStringFromQuery(FunctionsSelect + wherePart + unionPart + FunctionsOrderBy1); } @Override