Changeset: a55059413281 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a55059413281
Added Files:
        clients/odbc/driver/ODBCQueries.h
Modified Files:
        clients/ChangeLog.Mar2018
        clients/odbc/driver/Makefile.ag
        clients/odbc/driver/SQLColumns.c
        clients/odbc/driver/SQLGetFunctions.c
        clients/odbc/driver/SQLProcedureColumns.c
Branch: Mar2018
Log Message:

Implemented SQLProcedureColumns.


diffs (truncated from 930 to 300 lines):

diff --git a/clients/ChangeLog.Mar2018 b/clients/ChangeLog.Mar2018
--- a/clients/ChangeLog.Mar2018
+++ b/clients/ChangeLog.Mar2018
@@ -1,6 +1,9 @@
 # ChangeLog file for clients
 # This file is updated with Maddlog
 
+* Wed Feb 28 2018 Sjoerd Mullender <sjo...@acm.org>
+- ODBC: The driver function SQLProcedureColumns was implemented.
+
 * Thu Feb  1 2018 Sjoerd Mullender <sjo...@acm.org>
 - ODBC: Changed table types as used by SQLTables from "LOCAL TEMPORARY"
   and "GLOBAL TEMPORARY" to "LOCAL TEMPORARY TABLE" and "GLOBAL TEMPORARY
diff --git a/clients/odbc/driver/Makefile.ag b/clients/odbc/driver/Makefile.ag
--- a/clients/odbc/driver/Makefile.ag
+++ b/clients/odbc/driver/Makefile.ag
@@ -24,6 +24,7 @@ lib_MonetODBC = {
        ODBCError.c \
        ODBCError.h \
        ODBCGlobal.h \
+       ODBCQueries.h \
        ODBCStmt.c \
        ODBCStmt.h \
        ODBCUtil.c \
diff --git a/clients/odbc/driver/ODBCQueries.h 
b/clients/odbc/driver/ODBCQueries.h
new file mode 100644
--- /dev/null
+++ b/clients/odbc/driver/ODBCQueries.h
@@ -0,0 +1,292 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2018 MonetDB B.V.
+ */
+
+/* this file contains parts of queries that are used in multiple
+ * places */
+
+#define DATA_TYPE(t)                                   \
+               "case " #t ".type "                     \
+                    "when 'bigint' then %d "           \
+                    "when 'blob' then %d "             \
+                    "when 'boolean' then %d "          \
+                    "when 'char' then %d "             \
+                    "when 'clob' then %d "             \
+                    "when 'date' then %d "             \
+                    "when 'decimal' then %d "          \
+                    "when 'double' then %d "           \
+                    "when 'hugeint' then %d "          \
+                    "when 'int' then %d "              \
+                    "when 'month_interval' then "      \
+                         "case " #t ".type_digits "    \
+                              "when 1 then %d "        \
+                              "when 2 then %d "        \
+                              "when 3 then %d "        \
+                         "end "                        \
+                    "when 'real' then %d "             \
+                    "when 'sec_interval' then "        \
+                         "case " #t ".type_digits "    \
+                              "when 4 then %d "        \
+                              "when 5 then %d "        \
+                              "when 6 then %d "        \
+                              "when 7 then %d "        \
+                              "when 8 then %d "        \
+                              "when 9 then %d "        \
+                              "when 10 then %d "       \
+                              "when 11 then %d "       \
+                              "when 12 then %d "       \
+                              "when 13 then %d "       \
+                         "end "                        \
+                    "when 'smallint' then %d "         \
+                    "when 'time' then %d "             \
+                    "when 'timestamp' then %d "        \
+                    "when 'timestamptz' then %d "      \
+                    "when 'timetz' then %d "           \
+                    "when 'tinyint' then %d "          \
+                    "when 'varchar' then %d "          \
+               "end as data_type"
+#define DATA_TYPE_ARGS                                                 \
+               SQL_BIGINT, SQL_LONGVARBINARY, SQL_BIT, SQL_WCHAR,      \
+               SQL_WLONGVARCHAR, SQL_TYPE_DATE, SQL_DECIMAL,           \
+               SQL_DOUBLE, SQL_HUGEINT, SQL_INTEGER,                   \
+               SQL_INTERVAL_YEAR, SQL_INTERVAL_YEAR_TO_MONTH,          \
+               SQL_INTERVAL_MONTH, SQL_REAL, SQL_INTERVAL_DAY,         \
+               SQL_INTERVAL_DAY_TO_HOUR, SQL_INTERVAL_DAY_TO_MINUTE,   \
+               SQL_INTERVAL_DAY_TO_SECOND, SQL_INTERVAL_HOUR,          \
+               SQL_INTERVAL_HOUR_TO_MINUTE,                            \
+               SQL_INTERVAL_HOUR_TO_SECOND, SQL_INTERVAL_MINUTE,       \
+               SQL_INTERVAL_MINUTE_TO_SECOND, SQL_INTERVAL_SECOND,     \
+               SQL_SMALLINT, SQL_TYPE_TIME, SQL_TYPE_TIMESTAMP,        \
+               SQL_TYPE_TIMESTAMP, SQL_TYPE_TIME, SQL_TINYINT,         \
+               SQL_WVARCHAR
+
+#define TYPE_NAME(t)                                                   \
+               "case " #t ".type "                                     \
+                    "when 'bigint' then 'BIGINT' "                     \
+                    "when 'blob' then 'BINARY LARGE OBJECT' "          \
+                    "when 'boolean' then 'BOOLEAN' "                   \
+                    "when 'char' then 'CHARACTER' "                    \
+                    "when 'clob' then 'CHARACTER LARGE OBJECT' "       \
+                    "when 'date' then 'DATE' "                         \
+                    "when 'decimal' then 'DECIMAL' "                   \
+                    "when 'double' then 'DOUBLE' "                     \
+                    "when 'hugeint' then 'HUGEINT' "                   \
+                    "when 'int' then 'INTEGER' "                       \
+                    "when 'month_interval' then "                      \
+                         "case " #t ".type_digits "                    \
+                              "when 1 then 'INTERVAL YEAR' "           \
+                              "when 2 then 'INTERVAL YEAR TO MONTH' "  \
+                              "when 3 then 'INTERVAL MONTH' "          \
+                         "end "                                        \
+                    "when 'real' then 'REAL' "                         \
+                    "when 'sec_interval' then "                        \
+                         "case " #t ".type_digits "                    \
+                              "when 4 then 'INTERVAL DAY' "            \
+                              "when 5 then 'INTERVAL DAY TO HOUR' "    \
+                              "when 6 then 'INTERVAL DAY TO MINUTE' "  \
+                              "when 7 then 'INTERVAL DAY TO SECOND' "  \
+                              "when 8 then 'INTERVAL HOUR' "           \
+                              "when 9 then 'INTERVAL HOUR TO MINUTE' " \
+                              "when 10 then 'INTERVAL HOUR TO SECOND' " \
+                              "when 11 then 'INTERVAL MINUTE' "        \
+                              "when 12 then 'INTERVAL MINUTE TO SECOND' " \
+                              "when 13 then 'INTERVAL SECOND' "        \
+                         "end "                                        \
+                    "when 'smallint' then 'SMALLINT' "                 \
+                    "when 'time' then 'TIME' "                         \
+                    "when 'timestamp' then 'TIMESTAMP' "               \
+                    "when 'timestamptz' then 'TIMESTAMP' "             \
+                    "when 'timetz' then 'TIME' "                       \
+                    "when 'tinyint' then 'TINYINT' "                   \
+                    "when 'varchar' then 'VARCHAR' "                   \
+               "end as type_name"
+
+#define COLUMN_SIZE(t)                                 \
+               "case " #t ".type "                     \
+                    "when 'date' then 10 "             \
+                    "when 'month_interval' then "      \
+                         "case " #t ".type_digits "    \
+                              "when 1 then 26 "        \
+                              "when 2 then 38 "        \
+                              "when 3 then 27 "        \
+                         "end "                        \
+                    "when 'sec_interval' then "        \
+                         "case " #t ".type_digits "    \
+                              "when 4 then 25 "        \
+                              "when 5 then 36 "        \
+                              "when 6 then 41 "        \
+                              "when 7 then 47 "        \
+                              "when 8 then 26 "        \
+                              "when 9 then 39 "        \
+                              "when 10 then 45 "       \
+                              "when 11 then 28 "       \
+                              "when 12 then 44 "       \
+                              "when 13 then 30 "       \
+                         "end "                        \
+                    "when 'time' then 12 "             \
+                    "when 'timestamp' then 23 "        \
+                    "when 'timestamptz' then 23 "      \
+                    "when 'timetz' then 12 "           \
+                    "else " #t ".type_digits "         \
+               "end as column_size"
+
+#define BUFFER_LENGTH(t) "case " #t ".type "                           \
+                    "when 'bigint' then 20 "                           \
+                    "when 'char' then 2 * " #t ".type_digits "         \
+                    "when 'clob' then 2 * " #t ".type_digits "         \
+                    "when 'date' then 10 "                             \
+                    "when 'double' then 24 "                           \
+                    "when 'hugeint' then 40 "                          \
+                    "when 'int' then 11 "                              \
+                    "when 'month_interval' then "                      \
+                         "case " #t ".type_digits "                    \
+                              "when 1 then 26 "                        \
+                              "when 2 then 38 "                        \
+                              "when 3 then 27 "                        \
+                         "end "                                        \
+                    "when 'real' then 14 "                             \
+                    "when 'sec_interval' then "                        \
+                         "case " #t ".type_digits "                    \
+                              "when 4 then 25 "                        \
+                              "when 5 then 36 "                        \
+                              "when 6 then 41 "                        \
+                              "when 7 then 47 "                        \
+                              "when 8 then 26 "                        \
+                              "when 9 then 39 "                        \
+                              "when 10 then 45 "                       \
+                              "when 11 then 28 "                       \
+                              "when 12 then 44 "                       \
+                              "when 13 then 30 "                       \
+                         "end "                                        \
+                    "when 'smallint' then 6 "                          \
+                    "when 'time' then 12 "                             \
+                    "when 'timestamp' then 23 "                        \
+                    "when 'timestamptz' then 23 "                      \
+                    "when 'timetz' then 12 "                           \
+                    "when 'tinyint' then 4 "                           \
+                    "when 'varchar' then 2 * " #t ".type_digits "      \
+                    "else " #t ".type_digits "                         \
+               "end as buffer_length"
+
+#define DECIMAL_DIGITS(t) "case " #t ".type "                          \
+                    "when 'bigint' then 0 "                            \
+                    "when 'decimal' then " #t ".type_scale "           \
+                    "when 'double' then "                              \
+                         "case when " #t ".type_digits = 53 and " #t 
".type_scale = 0 then 15 " \
+                         "else " #t ".type_digits "                    \
+                         "end "                                        \
+                    "when 'hugeint' then 0 "                           \
+                    "when 'int' then 0 "                               \
+                    "when 'month_interval' then 0 "                    \
+                    "when 'real' then "                                \
+                         "case when " #t ".type_digits = 24 and " #t 
".type_scale = 0 then 7 " \
+                         "else " #t ".type_digits "                    \
+                         "end "                                        \
+                    "when 'sec_interval' then 0 "                      \
+                    "when 'smallint' then 0 "                          \
+                    "when 'time' then " #t ".type_digits - 1 "         \
+                    "when 'timestamp' then " #t ".type_digits - 1 "    \
+                    "when 'timestamptz' then " #t ".type_digits - 1 "  \
+                    "when 'timetz' then " #t ".type_digits - 1 "       \
+                    "when 'tinyint' then 0 "                           \
+                    "else cast(null as smallint) "                     \
+               "end as decimal_digits"
+
+#define NUM_PREC_RADIX(t) "case " #t ".type "                          \
+                    "when 'bigint' then 2 "                            \
+                    "when 'decimal' then 10 "                          \
+                    "when 'double' then "                              \
+                         "case when " #t ".type_digits = 53 and " #t 
".type_scale = 0 then 2 " \
+                         "else 10 "                                    \
+                         "end "                                        \
+                    "when 'hugeint' then 2 "                           \
+                    "when 'int' then 2 "                               \
+                    "when 'real' then "                                \
+                         "case when " #t ".type_digits = 24 and " #t ". 
type_scale = 0 then 2 " \
+                         "else 10 "                                    \
+                         "end "                                        \
+                    "when 'smallint' then 2 "                          \
+                    "when 'tinyint' then 2 "                           \
+                    "else cast(null as smallint) "                     \
+               "end as num_prec_radix"
+
+#define SQL_DATA_TYPE(t)                               \
+               "case " #t ".type "                     \
+                    "when 'bigint' then %d "           \
+                    "when 'blob' then %d "             \
+                    "when 'boolean' then %d "          \
+                    "when 'char' then %d "             \
+                    "when 'clob' then %d "             \
+                    "when 'date' then %d "             \
+                    "when 'decimal' then %d "          \
+                    "when 'double' then %d "           \
+                    "when 'hugeint' then %d "          \
+                    "when 'int' then %d "              \
+                    "when 'month_interval' then %d "   \
+                    "when 'real' then %d "             \
+                    "when 'sec_interval' then %d "     \
+                    "when 'smallint' then %d "         \
+                    "when 'time' then %d "             \
+                    "when 'timestamp' then %d "        \
+                    "when 'timestamptz' then %d "      \
+                    "when 'timetz' then %d "           \
+                    "when 'tinyint' then %d "          \
+                    "when 'varchar' then %d "          \
+               "end as sql_data_type"
+#define SQL_DATA_TYPE_ARGS                                             \
+               SQL_BIGINT, SQL_LONGVARBINARY, SQL_BIT, SQL_WCHAR,      \
+               SQL_WLONGVARCHAR, SQL_DATETIME, SQL_DECIMAL, SQL_DOUBLE, \
+               SQL_HUGEINT, SQL_INTEGER, SQL_INTERVAL, SQL_REAL,       \
+               SQL_INTERVAL, SQL_SMALLINT, SQL_DATETIME, SQL_DATETIME, \
+               SQL_DATETIME, SQL_DATETIME, SQL_TINYINT, SQL_WVARCHAR
+
+#define SQL_DATETIME_SUB(t)                            \
+               "case " #t ".type "                     \
+                    "when 'date' then %d "             \
+                    "when 'month_interval' then "      \
+                         "case " #t ".type_digits "    \
+                              "when 1 then %d "        \
+                              "when 2 then %d "        \
+                              "when 3 then %d "        \
+                         "end "                        \
+                    "when 'sec_interval' then "        \
+                         "case " #t ".type_digits "    \
+                              "when 4 then %d "        \
+                              "when 5 then %d "        \
+                              "when 6 then %d "        \
+                              "when 7 then %d "        \
+                              "when 8 then %d "        \
+                              "when 9 then %d "        \
+                              "when 10 then %d "       \
+                              "when 11 then %d "       \
+                              "when 12 then %d "       \
+                              "when 13 then %d "       \
+                         "end "                        \
+                    "when 'time' then %d "             \
+                    "when 'timestamp' then %d "        \
+                    "when 'timestamptz' then %d "      \
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to