diff --git a/src/main/java/org/mariadb/jdbc/DatabaseMetaData.java b/src/main/java/org/mariadb/jdbc/DatabaseMetaData.java index 036bc71d3..8145c2748 100644 --- a/src/main/java/org/mariadb/jdbc/DatabaseMetaData.java +++ b/src/main/java/org/mariadb/jdbc/DatabaseMetaData.java @@ -1409,18 +1409,14 @@ public String getIdentifierQuoteString() { */ @Override public String getSQLKeywords() { - return "ACCESSIBLE,ANALYZE,ASENSITIVE,BEFORE,BIGINT,BINARY,BLOB,CALL,CHANGE,CONDITION,DATABASE,DATABASES," - + "DAY_HOUR,DAY_MICROSECOND,DAY_MINUTE,DAY_SECOND,DELAYED,DETERMINISTIC,DISTINCTROW,DIV,DUAL,EACH," - + "ELSEIF,ENCLOSED,ESCAPED,EXIT,EXPLAIN,FLOAT4,FLOAT8,FORCE,FULLTEXT,GENERAL,HIGH_PRIORITY," - + "HOUR_MICROSECOND,HOUR_MINUTE,HOUR_SECOND,IF,IGNORE,IGNORE_SERVER_IDS,INDEX,INFILE,INOUT,INT1,INT2," - + "INT3,INT4,INT8,ITERATE,KEY,KEYS,KILL,LEAVE,LIMIT,LINEAR,LINES,LOAD,LOCALTIME,LOCALTIMESTAMP,LOCK," - + "LONG,LONGBLOB,LONGTEXT,LOOP,LOW_PRIORITY,MASTER_HEARTBEAT_PERIOD,MASTER_SSL_VERIFY_SERVER_CERT," - + "MAXVALUE,MEDIUMBLOB,MEDIUMINT,MEDIUMTEXT,MIDDLEINT,MINUTE_MICROSECOND,MINUTE_SECOND,MOD,MODIFIES," - + "NO_WRITE_TO_BINLOG,OPTIMIZE,OPTIONALLY,OUT,OUTFILE,PURGE,RANGE,READ_WRITE,READS,REGEXP,RELEASE," - + "RENAME,REPEAT,REPLACE,REQUIRE,RESIGNAL,RESTRICT,RETURN,RLIKE,SCHEMAS,SECOND_MICROSECOND,SENSITIVE," - + "SEPARATOR,SHOW,SIGNAL,SLOW,SPATIAL,SPECIFIC,SQL_BIG_RESULT,SQL_CALC_FOUND_ROWS,SQL_SMALL_RESULT," - + "SQLEXCEPTION,SSL,STARTING,STRAIGHT_JOIN,TERMINATED,TINYBLOB,TINYINT,TINYTEXT,TRIGGER,UNDO,UNLOCK," - + "UNSIGNED,USE,UTC_DATE,UTC_TIME,UTC_TIMESTAMP,VARBINARY,VARCHARACTER,WHILE,XOR,YEAR_MONTH,ZEROFILL"; + boolean returnSql2003Keywords = + Boolean.parseBoolean(conf.nonMappedOptions().getProperty("returnSql2003Keywords", "false")); + if (returnSql2003Keywords) { + // expected to return only MariaDB reserved words without SQL:2003 keywords, but for + // compatibility + return "ACCESSIBLE,ACCOUNT,ACTION,ADD,ADDDATE,ADMIN,AFTER,AGAINST,AGGREGATE,ALGORITHM,ALL,ALLOCATE,ALTER,ALWAYS,ANALYZE,AND,ANY,ARE,ARRAY,AS,ASC,ASCII,ASENSITIVE,ASYMMETRIC,AT,ATOMIC,AUTHORIZATION,AUTHORS,AUTO,AUTO_INCREMENT,AUTOEXTEND_SIZE,AVG,AVG_ROW_LENGTH,BACKUP,BEFORE,BEGIN,BETWEEN,BIGINT,BINARY,BINLOG,BIT,BIT_AND,BIT_OR,BIT_XOR,BLOB,BLOCK,BODY,BOOL,BOOLEAN,BOTH,BTREE,BY,BYTE,CACHE,CALL,CALLED,CASCADE,CASCADED,CASE,CAST,CATALOG_NAME,CHAIN,CHANGE,CHANGED,CHANNEL,CHAR,CHARACTER,CHARSET,CHECK,CHECKPOINT,CHECKSUM,CIPHER,CLASS_ORIGIN,CLIENT,CLOB,CLOSE,COALESCE,CODE,COLLATE,COLLATION,COLUMN,COLUMN_ADD,COLUMN_CHECK,COLUMN_CREATE,COLUMN_DELETE,COLUMN_GET,COLUMN_NAME,COLUMNS,COMMENT,COMMIT,COMMITTED,COMPACT,COMPLETION,COMPRESSED,CONCURRENT,CONDITION,CONNECT,CONNECTION,CONSISTENT,CONSTRAINT,CONSTRAINT_CATALOG,CONSTRAINT_NAME,CONSTRAINT_SCHEMA,CONTAINS,CONTEXT,CONTINUE,CONTRIBUTORS,CONVERT,CORRESPONDING,COUNT,CPU,CREATE,CROSS,CUBE,CUME_DIST,CURDATE,CURRENT,CURRENT_DATE,CURRENT_DEFAULT_TRANSFORM_GROUP,CURRENT_PATH,CURRENT_POS,CURRENT_ROLE,CURRENT_TIME,CURRENT_TIMESTAMP,CURRENT_TRANSFORM_GROUP_FOR_TYPE,CURRENT_USER,CURSOR,CURSOR_NAME,CURTIME,CYCLE,DATA,DATABASE,DATABASES,DATAFILE,DATE,DATE_ADD,DATE_SUB,DATETIME,DAY,DAY_HOUR,DAY_MICROSECOND,DAY_MINUTE,DAY_SECOND,DEALLOCATE,DEC,DECIMAL,DECLARE,DEFAULT,DEFINER,DELAY_KEY_WRITE,DELAYED,DELETE,DELETE_DOMAIN_ID,DENSE_RANK,DEREF,DES_KEY_FILE,DESC,DESCRIBE,DETERMINISTIC,DIAGNOSTICS,DIRECTORY,DISABLE,DISCARD,DISCONNECT,DISK,DISTINCT,DISTINCTROW,DIV,DO,DO_DOMAIN_IDS,DOUBLE,DROP,DUAL,DUMPFILE,DUPLICATE,DYNAMIC,EACH,ELEMENT,ELSE,ELSEIF,ELSIF,EMPTY,ENABLE,ENCLOSED,END,ENDS,ENGINE,ENGINES,ENUM,ERROR,ERRORS,ESCAPE,ESCAPED,EVENT,EVENTS,EVERY,EXAMINED,EXCEPT,EXCEPTION,EXCHANGE,EXCLUDE,EXEC,EXECUTE,EXISTS,EXIT,EXPANSION,EXPIRE,EXPLAIN,EXPORT,EXTENDED,EXTENT_SIZE,EXTERNAL,EXTRACT,FALSE,FAST,FAULTS,FEDERATED,FETCH,FIELDS,FILE,FILTER,FIRST,FIRST_VALUE,FIXED,FLOAT,FLOAT4,FLOAT8,FLUSH,FOLLOWING,FOLLOWS,FOR,FORCE,FOREIGN,FORMAT,FOUND,FREE,FROM,FULL,FULLTEXT,FUNCTION,GENERAL,GENERATED,GET,GET_FORMAT,GLOBAL,GOTO,GRANT,GRANTS,GROUP,GROUP_CONCAT,GROUPING,HANDLER,HARD,HASH,HAVING,HELP,HIGH_PRIORITY,HISTORY,HOLD,HOST,HOSTS,HOUR,HOUR_MICROSECOND,HOUR_MINUTE,HOUR_SECOND,ID,IDENTIFIED,IDENTITY,IF,IGNORE,IGNORE_DOMAIN_IDS,IGNORE_SERVER_IDS,IGNORED,IMMEDIATE,IMPORT,IN,INCREMENT,INDEX,INDEXES,INDICATOR,INFILE,INITIAL_SIZE,INNER,INOUT,INPUT,INSENSITIVE,INSERT,INSERT_METHOD,INSTALL,INT,INT1,INT2,INT3,INT4,INT8,INTEGER,INTERSECT,INTERVAL,INTO,INVISIBLE,INVOKER,IO,IO_THREAD,IPC,IS,ISOLATION,ISOPEN,ISSUER,ITERATE,JOIN,JSON,JSON_ARRAYAGG,JSON_OBJECTAGG,JSON_TABLE,KEY,KEY_BLOCK_SIZE,KEYS,KILL,LAG,LANGUAGE,LARGE,LAST,LAST_VALUE,LASTVAL,LATERAL,LEAD,LEADING,LEAVE,LEAVES,LEFT,LESS,LEVEL,LIKE,LIMIT,LINEAR,LINES,LIST,LOAD,LOCAL,LOCALTIME,LOCALTIMESTAMP,LOCK,LOCKED,LOCKS,LOGFILE,LOGS,LONG,LONGBLOB,LONGTEXT,LOOP,LOW_PRIORITY,MASTER,MASTER_CONNECT_RETRY,MASTER_DELAY,MASTER_DEMOTE_TO_SLAVE,MASTER_GTID_POS,MASTER_HEARTBEAT_PERIOD,MASTER_HOST,MASTER_LOG_FILE,MASTER_LOG_POS,MASTER_PASSWORD,MASTER_PORT,MASTER_SERVER_ID,MASTER_SSL,MASTER_SSL_CA,MASTER_SSL_CAPATH,MASTER_SSL_CERT,MASTER_SSL_CIPHER,MASTER_SSL_CRL,MASTER_SSL_CRLPATH,MASTER_SSL_KEY,MASTER_SSL_VERIFY_SERVER_CERT,MASTER_USE_GTID,MASTER_USER,MATCH,MAX,MAX_CONNECTIONS_PER_HOUR,MAX_QUERIES_PER_HOUR,MAX_ROWS,MAX_SIZE,MAX_STATEMENT_TIME,MAX_UPDATES_PER_HOUR,MAX_USER_CONNECTIONS,MAXVALUE,MEDIAN,MEDIUM,MEDIUMBLOB,MEDIUMINT,MEDIUMTEXT,MEMBER,MEMORY,MERGE,MESSAGE_TEXT,METHOD,MICROSECOND,MID,MIDDLEINT,MIGRATE,MIN,MIN_ROWS,MINUS,MINUTE,MINUTE_MICROSECOND,MINUTE_SECOND,MINVALUE,MOD,MODE,MODIFIES,MODIFY,MODULE,MONITOR,MONTH,MULTISET,MUTEX,MYSQL,MYSQL_ERRNO,NAME,NAMES,NATIONAL,NATURAL,NCHAR,NCLOB,NESTED,NEVER,NEW,NEXT,NEXTVAL,NO,NO_WAIT,NO_WRITE_TO_BINLOG,NOCACHE,NOCYCLE,NODEGROUP,NOMAXVALUE,NOMINVALUE,NONE,NOT,NOTFOUND,NOW,NOWAIT,NTH_VALUE,NTILE,NULL,NUMBER,NUMERIC,NVARCHAR,OF,OFFSET,OLD,OLD_PASSWORD,ON,ONE,ONLINE,ONLY,OPEN,OPTIMIZE,OPTION,OPTIONALLY,OPTIONS,OR,ORDER,ORDINALITY,OTHERS,OUT,OUTER,OUTFILE,OUTPUT,OVER,OVERLAPS,OWNER,PACK_KEYS,PACKAGE,PAGE,PAGE_CHECKSUM,PARAMETER,PARSE_VCOL_EXPR,PARSER,PARTIAL,PARTITION,PARTITIONING,PARTITIONS,PASSWORD,PATH,PERCENT_RANK,PERCENTILE_CONT,PERCENTILE_DISC,PERIOD,PERSISTENT,PHASE,PLUGIN,PLUGINS,PORT,PORTION,POSITION,PRECEDES,PRECEDING,PRECISION,PREPARE,PRESERVE,PREV,PREVIOUS,PRIMARY,PRIVILEGES,PROCEDURE,PROCESS,PROCESSLIST,PROFILE,PROFILES,PROXY,PURGE,QUARTER,QUERY,QUICK,RAISE,RANGE,RANK,RAW,READ,READ_ONLY,READ_WRITE,READS,REAL,REBUILD,RECOVER,RECURSIVE,REDO_BUFFER_SIZE,REDOFILE,REDUNDANT,REF,REF_SYSTEM_ID,REFERENCES,REFERENCING,REGEXP,RELAY,RELAY_LOG_FILE,RELAY_LOG_POS,RELAY_THREAD,RELAYLOG,RELEASE,RELOAD,REMOVE,RENAME,REORGANIZE,REPAIR,REPEAT,REPEATABLE,REPLACE,REPLAY,REPLICA,REPLICA_POS,REPLICAS,REPLICATION,REQUIRE,RESET,RESIGNAL,RESTART,RESTORE,RESTRICT,RESULT,RESUME,RETURN,RETURNED_SQLSTATE,RETURNING,RETURNS,REUSE,REVERSE,REVOKE,RIGHT,RLIKE,ROLE,ROLLBACK,ROLLUP,ROUTINE,ROW,ROW_COUNT,ROW_FORMAT,ROW_NUMBER,ROWCOUNT,ROWNUM,ROWS,ROWTYPE,RTREE,SAVEPOINT,SCHEDULE,SCHEMA,SCHEMA_NAME,SCHEMAS,SCOPE,SCROLL,SEARCH,SECOND,SECOND_MICROSECOND,SECURITY,SELECT,SENSITIVE,SEPARATOR,SEQUENCE,SERIAL,SERIALIZABLE,SERVER,SESSION,SESSION_USER,SET,SETVAL,SHARE,SHOW,SHUTDOWN,SIGNAL,SIGNED,SIMILAR,SIMPLE,SKIP,SLAVE,SLAVE_POS,SLAVES,SLOW,SMALLINT,SNAPSHOT,SOCKET,SOFT,SOME,SONAME,SOUNDS,SOURCE,SPATIAL,SPECIFIC,SPECIFICTYPE,SQL,SQL_AFTER_GTIDS,SQL_BEFORE_GTIDS,SQL_BIG_RESULT,SQL_BUFFER_RESULT,SQL_CACHE,SQL_CALC_FOUND_ROWS,SQL_NO_CACHE,SQL_SMALL_RESULT,SQL_THREAD,SQL_TSI_DAY,SQL_TSI_HOUR,SQL_TSI_MINUTE,SQL_TSI_MONTH,SQL_TSI_QUARTER,SQL_TSI_SECOND,SQL_TSI_WEEK,SQL_TSI_YEAR,SQLEXCEPTION,SQLSTATE,SQLWARNING,SSL,STAGE,START,STARTING,STARTS,STATEMENT,STATIC,STATS_AUTO_RECALC,STATS_PERSISTENT,STATS_SAMPLE_PAGES,STATUS,STD,STDDEV,STDDEV_POP,STDDEV_SAMP,STOP,STORAGE,STORED,STRAIGHT_JOIN,STRING,SUBCLASS_ORIGIN,SUBDATE,SUBJECT,SUBMULTISET,SUBPARTITION,SUBPARTITIONS,SUBSTR,SUBSTRING,SUM,SUPER,SUSPEND,SWAPS,SWITCHES,SYMMETRIC,SYSDATE,SYSTEM,SYSTEM_TIME,SYSTEM_USER,TABLE,TABLE_CHECKSUM,TABLE_NAME,TABLES,TABLESAMPLE,TABLESPACE,TEMPORARY,TEMPTABLE,TERMINATED,TEXT,THAN,THEN,THREADS,TIES,TIME,TIMESTAMP,TIMESTAMPADD,TIMESTAMPDIFF,TIMEZONE_HOUR,TIMEZONE_MINUTE,TINYBLOB,TINYINT,TINYTEXT,TO,TRAILING,TRANSACTION,TRANSACTIONAL,TRANSLATION,TREAT,TRIGGER,TRIGGERS,TRIM,TRIM_ORACLE,TRUE,TRUNCATE,TYPE,UNBOUNDED,UNCOMMITTED,UNDEFINED,UNDO,UNDO_BUFFER_SIZE,UNDOFILE,UNICODE,UNINSTALL,UNION,UNIQUE,UNKNOWN,UNLOCK,UNNEST,UNSIGNED,UNTIL,UPDATE,UPGRADE,USAGE,USE,USE_FRM,USER,USER_RESOURCES,USING,UTC_DATE,UTC_TIME,UTC_TIMESTAMP,VALIDATION,VALUE,VALUES,VAR_POP,VAR_SAMP,VARBINARY,VARCHAR,VARCHAR2,VARCHARACTER,VARIABLES,VARIANCE,VARYING,VERSIONING,VIA,VIEW,VIRTUAL,VISIBLE,WAIT,WARNINGS,WEEK,WEIGHT_STRING,WHEN,WHENEVER,WHERE,WHILE,WINDOW,WITH,WITHIN,WITHOUT,WORK,WRAPPER,WRITE,X509,XA,XML,XOR,YEAR,YEAR_MONTH,ZEROFILL"; + } + return "ACCESSIBLE,ACCOUNT,ACTION,ADDDATE,ADMIN,AFTER,AGAINST,AGGREGATE,ALGORITHM,ALWAYS,ANALYZE,ASC,ASCII,AUTHORS,AUTO,AUTO_INCREMENT,AUTOEXTEND_SIZE,AVG,AVG_ROW_LENGTH,BACKUP,BEFORE,BINLOG,BIT,BIT_AND,BIT_OR,BIT_XOR,BLOCK,BODY,BOOL,BTREE,BYTE,CACHE,CASCADE,CATALOG_NAME,CHAIN,CHANGE,CHANGED,CHANNEL,CHARSET,CHECKPOINT,CHECKSUM,CIPHER,CLASS_ORIGIN,CLIENT,COALESCE,CODE,COLLATION,COLUMN_ADD,COLUMN_CHECK,COLUMN_CREATE,COLUMN_DELETE,COLUMN_GET,COLUMN_NAME,COLUMNS,COMMENT,COMMITTED,COMPACT,COMPLETION,COMPRESSED,CONCURRENT,CONNECTION,CONSISTENT,CONSTRAINT_CATALOG,CONSTRAINT_NAME,CONSTRAINT_SCHEMA,CONTAINS,CONTEXT,CONTRIBUTORS,CONVERT,COUNT,CPU,CUME_DIST,CURDATE,CURRENT_POS,CURSOR_NAME,CURTIME,DATA,DATABASE,DATABASES,DATAFILE,DATE_ADD,DATE_SUB,DATETIME,DAY_HOUR,DAY_MICROSECOND,DAY_MINUTE,DAY_SECOND,DEFINER,DELAY_KEY_WRITE,DELAYED,DELETE_DOMAIN_ID,DENSE_RANK,DES_KEY_FILE,DESC,DIAGNOSTICS,DIRECTORY,DISABLE,DISCARD,DISK,DISTINCTROW,DIV,DO_DOMAIN_IDS,DUAL,DUMPFILE,DUPLICATE,ELSIF,EMPTY,ENABLE,ENCLOSED,ENDS,ENGINE,ENGINES,ENUM,ERROR,ERRORS,ESCAPED,EVENT,EVENTS,EVERY,EXAMINED,EXCEPTION,EXCHANGE,EXCLUDE,EXPANSION,EXPIRE,EXPLAIN,EXPORT,EXTENDED,EXTENT_SIZE,EXTRACT,FAST,FAULTS,FEDERATED,FIELDS,FILE,FIRST,FIRST_VALUE,FIXED,FLOAT4,FLOAT8,FLUSH,FOLLOWING,FOLLOWS,FORCE,FORMAT,FOUND,FULLTEXT,GENERAL,GENERATED,GET_FORMAT,GOTO,GRANTS,GROUP_CONCAT,HARD,HASH,HELP,HIGH_PRIORITY,HISTORY,HOST,HOSTS,HOUR_MICROSECOND,HOUR_MINUTE,HOUR_SECOND,ID,IDENTIFIED,IGNORE,IGNORE_DOMAIN_IDS,IGNORE_SERVER_IDS,IGNORED,IMPORT,INCREMENT,INDEX,INDEXES,INFILE,INITIAL_SIZE,INSERT_METHOD,INSTALL,INT1,INT2,INT3,INT4,INT8,INVISIBLE,INVOKER,IO,IO_THREAD,IPC,ISOLATION,ISOPEN,ISSUER,JSON,JSON_ARRAYAGG,JSON_OBJECTAGG,JSON_TABLE,KEY,KEY_BLOCK_SIZE,KEYS,KILL,LAG,LAST,LAST_VALUE,LASTVAL,LEAD,LEAVES,LESS,LEVEL,LIMIT,LINEAR,LINES,LIST,LOAD,LOCK,LOCKED,LOCKS,LOGFILE,LOGS,LONG,LONGBLOB,LONGTEXT,LOW_PRIORITY,MASTER,MASTER_CONNECT_RETRY,MASTER_DELAY,MASTER_DEMOTE_TO_SLAVE,MASTER_GTID_POS,MASTER_HEARTBEAT_PERIOD,MASTER_HOST,MASTER_LOG_FILE,MASTER_LOG_POS,MASTER_PASSWORD,MASTER_PORT,MASTER_SERVER_ID,MASTER_SSL,MASTER_SSL_CA,MASTER_SSL_CAPATH,MASTER_SSL_CERT,MASTER_SSL_CIPHER,MASTER_SSL_CRL,MASTER_SSL_CRLPATH,MASTER_SSL_KEY,MASTER_SSL_VERIFY_SERVER_CERT,MASTER_USE_GTID,MASTER_USER,MAX,MAX_CONNECTIONS_PER_HOUR,MAX_QUERIES_PER_HOUR,MAX_ROWS,MAX_SIZE,MAX_STATEMENT_TIME,MAX_UPDATES_PER_HOUR,MAX_USER_CONNECTIONS,MAXVALUE,MEDIAN,MEDIUM,MEDIUMBLOB,MEDIUMINT,MEDIUMTEXT,MEMORY,MESSAGE_TEXT,MICROSECOND,MID,MIDDLEINT,MIGRATE,MIN,MIN_ROWS,MINUS,MINUTE_MICROSECOND,MINUTE_SECOND,MINVALUE,MOD,MODE,MODIFY,MONITOR,MUTEX,MYSQL,MYSQL_ERRNO,NAME,NAMES,NESTED,NEVER,NEXT,NEXTVAL,NO_WAIT,NO_WRITE_TO_BINLOG,NOCACHE,NOCYCLE,NODEGROUP,NOMAXVALUE,NOMINVALUE,NOTFOUND,NOW,NOWAIT,NTH_VALUE,NTILE,NUMBER,NVARCHAR,OFFSET,OLD_PASSWORD,ONE,ONLINE,OPTIMIZE,OPTION,OPTIONALLY,OPTIONS,ORDINALITY,OTHERS,OUTFILE,OWNER,PACK_KEYS,PACKAGE,PAGE,PAGE_CHECKSUM,PARSE_VCOL_EXPR,PARSER,PARTIAL,PARTITIONING,PARTITIONS,PASSWORD,PATH,PERCENT_RANK,PERCENTILE_CONT,PERCENTILE_DISC,PERIOD,PERSISTENT,PHASE,PLUGIN,PLUGINS,PORT,PORTION,POSITION,PRECEDES,PRECEDING,PRESERVE,PREV,PREVIOUS,PRIMARY,PRIVILEGES,PROCESS,PROCESSLIST,PROFILE,PROFILES,PROXY,PURGE,QUARTER,QUERY,QUICK,RAISE,RANK,RAW,READ,READ_ONLY,READ_WRITE,REBUILD,RECOVER,REDO_BUFFER_SIZE,REDOFILE,REDUNDANT,REF_SYSTEM_ID,REGEXP,RELAY,RELAY_LOG_FILE,RELAY_LOG_POS,RELAY_THREAD,RELAYLOG,RELOAD,REMOVE,RENAME,REORGANIZE,REPAIR,REPEATABLE,REPLACE,REPLAY,REPLICA,REPLICA_POS,REPLICAS,REPLICATION,REQUIRE,RESET,RESTART,RESTORE,RESTRICT,RESUME,RETURNED_SQLSTATE,RETURNING,REUSE,REVERSE,RLIKE,ROLE,ROUTINE,ROW_COUNT,ROW_FORMAT,ROW_NUMBER,ROWCOUNT,ROWNUM,ROWTYPE,RTREE,SCHEDULE,SCHEMA,SCHEMA_NAME,SCHEMAS,SECOND_MICROSECOND,SECURITY,SEPARATOR,SEQUENCE,SERIAL,SERIALIZABLE,SERVER,SESSION,SETVAL,SHARE,SHOW,SHUTDOWN,SIGNED,SIMPLE,SKIP,SLAVE,SLAVE_POS,SLAVES,SLOW,SNAPSHOT,SOCKET,SOFT,SONAME,SOUNDS,SOURCE,SPATIAL,SQL_AFTER_GTIDS,SQL_BEFORE_GTIDS,SQL_BIG_RESULT,SQL_BUFFER_RESULT,SQL_CACHE,SQL_CALC_FOUND_ROWS,SQL_NO_CACHE,SQL_SMALL_RESULT,SQL_THREAD,SQL_TSI_DAY,SQL_TSI_HOUR,SQL_TSI_MINUTE,SQL_TSI_MONTH,SQL_TSI_QUARTER,SQL_TSI_SECOND,SQL_TSI_WEEK,SQL_TSI_YEAR,SSL,STAGE,STARTING,STARTS,STATEMENT,STATS_AUTO_RECALC,STATS_PERSISTENT,STATS_SAMPLE_PAGES,STATUS,STD,STDDEV,STDDEV_POP,STDDEV_SAMP,STOP,STORAGE,STORED,STRAIGHT_JOIN,STRING,SUBCLASS_ORIGIN,SUBDATE,SUBJECT,SUBPARTITION,SUBPARTITIONS,SUBSTR,SUBSTRING,SUM,SUPER,SUSPEND,SWAPS,SWITCHES,SYSDATE,SYSTEM_TIME,TABLE_CHECKSUM,TABLE_NAME,TABLES,TABLESPACE,TEMPORARY,TEMPTABLE,TERMINATED,TEXT,THAN,THREADS,TIES,TIMESTAMPADD,TIMESTAMPDIFF,TINYBLOB,TINYINT,TINYTEXT,TRANSACTION,TRANSACTIONAL,TRIGGERS,TRIM,TRIM_ORACLE,TRUNCATE,TYPE,UNBOUNDED,UNCOMMITTED,UNDEFINED,UNDO_BUFFER_SIZE,UNDOFILE,UNICODE,UNINSTALL,UNLOCK,UNSIGNED,UPGRADE,USAGE,USE,USE_FRM,USER_RESOURCES,UTC_DATE,UTC_TIME,UTC_TIMESTAMP,VALIDATION,VAR_POP,VAR_SAMP,VARBINARY,VARCHAR2,VARCHARACTER,VARIABLES,VARIANCE,VERSIONING,VIA,VIEW,VIRTUAL,VISIBLE,WAIT,WARNINGS,WEEK,WEIGHT_STRING,WORK,WRAPPER,WRITE,X509,XA,XML,XOR,YEAR_MONTH,ZEROFILL"; } /** diff --git a/src/test/java/org/mariadb/jdbc/integration/DatabaseMetadataTest.java b/src/test/java/org/mariadb/jdbc/integration/DatabaseMetadataTest.java index 095855cc9..3c5d542c9 100644 --- a/src/test/java/org/mariadb/jdbc/integration/DatabaseMetadataTest.java +++ b/src/test/java/org/mariadb/jdbc/integration/DatabaseMetadataTest.java @@ -174,7 +174,6 @@ public void primaryKeysTest() throws SQLException { rs = meta.getPrimaryKeys(null, null, "dbpk_test"); assertFalse(rs.next()); } - } private void primaryKeysTest(ResultSet rs) throws SQLException { diff --git a/src/tooling/java/org/mariadb/jdbc/GenerateSqlKeywords.java b/src/tooling/java/org/mariadb/jdbc/GenerateSqlKeywords.java new file mode 100644 index 000000000..da7ade50c --- /dev/null +++ b/src/tooling/java/org/mariadb/jdbc/GenerateSqlKeywords.java @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +// Copyright (c) 2012-2014 Monty Program Ab +// Copyright (c) 2024 MariaDB Corporation Ab + +package org.mariadb.jdbc; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; + +/** + * Permit to generate DatabaseMetaData.getSQLKeywords from server source code, reading sql/lex.h, then removing SQL:2003 keywords + */ +public class GenerateSqlKeywords { + public static final String serverSourcePath = "C:/projects/server"; + public static final String sql2003Keywords = "ADD,ALL,ALLOCATE,ALTER,AND,ANY,ARE,ARRAY,AS,ASENSITIVE,ASYMMETRIC,AT,ATOMIC,AUTHORIZATION,BEGIN,BETWEEN,BIGINT,BINARY,BLOB,BOOLEAN,BOTH,BY,CALL,CALLED,CASCADED,CASE,CAST,CHAR,CHARACTER,CHECK,CLOB,CLOSE,COLLATE,COLUMN,COMMIT,CONDITION,CONNECT,CONSTRAINT,CONTINUE,CORRESPONDING,CREATE,CROSS,CUBE,CURRENT,CURRENT_DATE,CURRENT_DEFAULT_TRANSFORM_GROUP,CURRENT_PATH,CURRENT_ROLE,CURRENT_TIME,CURRENT_TIMESTAMP,CURRENT_TRANSFORM_GROUP_FOR_TYPE,CURRENT_USER,CURSOR,CYCLE,DATE,DAY,DEALLOCATE,DEC,DECIMAL,DECLARE,DEFAULT,DELETE,DEREF,DESCRIBE,DETERMINISTIC,DISCONNECT,DISTINCT,DO,DOUBLE,DROP,DYNAMIC,EACH,ELEMENT,ELSE,ELSEIF,END,ESCAPE,EXCEPT,EXEC,EXECUTE,EXISTS,EXIT,EXTERNAL,FALSE,FETCH,FILTER,FLOAT,FOR,FOREIGN,FREE,FROM,FULL,FUNCTION,GET,GLOBAL,GRANT,GROUP,GROUPING,HANDLER,HAVING,HOLD,HOUR,IDENTITY,IF,IMMEDIATE,IN,INDICATOR,INNER,INOUT,INPUT,INSENSITIVE,INSERT,INT,INTEGER,INTERSECT,INTERVAL,INTO,IS,ITERATE,JOIN,LANGUAGE,LARGE,LATERAL,LEADING,LEAVE,LEFT,LIKE,LOCAL,LOCALTIME,LOCALTIMESTAMP,LOOP,MATCH,MEMBER,MERGE,METHOD,MINUTE,MODIFIES,MODULE,MONTH,MULTISET,NATIONAL,NATURAL,NCHAR,NCLOB,NEW,NO,NONE,NOT,NULL,NUMERIC,OF,OLD,ON,ONLY,OPEN,OR,ORDER,OUT,OUTER,OUTPUT,OVER,OVERLAPS,PARAMETER,PARTITION,PRECISION,PREPARE,PROCEDURE,RANGE,READS,REAL,RECURSIVE,REF,REFERENCES,REFERENCING,RELEASE,REPEAT,RESIGNAL,RESULT,RETURN,RETURNS,REVOKE,RIGHT,ROLLBACK,ROLLUP,ROW,ROWS,SAVEPOINT,SCOPE,SCROLL,SEARCH,SECOND,SELECT,SENSITIVE,SESSION_USER,SET,SIGNAL,SIMILAR,SMALLINT,SOME,SPECIFIC,SPECIFICTYPE,SQL,SQLEXCEPTION,SQLSTATE,SQLWARNING,START,STATIC,SUBMULTISET,SYMMETRIC,SYSTEM,SYSTEM_USER,TABLE,TABLESAMPLE,THEN,TIME,TIMESTAMP,TIMEZONE_HOUR,TIMEZONE_MINUTE,TO,TRAILING,TRANSLATION,TREAT,TRIGGER,TRUE,UNDO,UNION,UNIQUE,UNKNOWN,UNNEST,UNTIL,UPDATE,USER,USING,VALUE,VALUES,VARCHAR,VARYING,WHEN,WHENEVER,WHERE,WHILE,WINDOW,WITH,WITHIN,WITHOUT,YEAR"; + public static void main(String[] args) throws Exception { + Path path = Paths.get(serverSourcePath); + if (!Files.exists(path)) throw new Exception("Wrong server source path: " + serverSourcePath); + List keywords = new ArrayList<>(); + try (BufferedReader reader = new BufferedReader(new FileReader(serverSourcePath + "/sql/lex.h"))) { + boolean firstSymbolLine = false; + + String line = reader.readLine(); + while (line != null) { + if (!firstSymbolLine) { + if (line.startsWith("SYMBOL symbols[] =")) firstSymbolLine = true; + } else { + String[] splitVal = line.split("\""); + if (splitVal.length > 2) { + String keyword = splitVal[1].toUpperCase(Locale.ROOT); + if (keyword.charAt(0) >= 'A' && keyword.charAt(0) <= 'Z') { + keywords.add(keyword); + } + } + } + line = reader.readLine(); + } + } + keywords.sort(String.CASE_INSENSITIVE_ORDER); + System.out.println("TOTAL:" + String.join(",", keywords)); + + List keywordsWithoutSql2003 = new ArrayList<>(); + // remove SQL 2003 keywords + List sql2003KeyWords = Arrays.asList(sql2003Keywords.split(",")); + for (String key : keywords) { + if (sql2003KeyWords.contains(key)) { + System.out.println("removed SQL 2003 keywords " + key); + } else keywordsWithoutSql2003.add(key); + } + System.out.println("TOTAL without SQL2003:" + String.join(",", keywordsWithoutSql2003)); + List completeReservedWords = new ArrayList<>(); + completeReservedWords.addAll(keywordsWithoutSql2003); + completeReservedWords.addAll(sql2003KeyWords); + completeReservedWords.sort(String.CASE_INSENSITIVE_ORDER); + System.out.println("TOTAL with SQL2003:" + String.join(",", completeReservedWords)); + } +}