Changeset: 0e52ba88168c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0e52ba88168c
Modified Files:
        clients/odbc/driver/SQLConnect.c
        clients/odbc/driver/SQLTables.c
Branch: Jun2016
Log Message:

Don't check for server version number when we can work around it.
The check in SQLConnect was for such an old version that we can remove
it, the check in SQLTables we could work around in the SQL query.
This (actually the SQLConnect part) should fix bug 4032.


diffs (168 lines):

diff --git a/clients/odbc/driver/SQLConnect.c b/clients/odbc/driver/SQLConnect.c
--- a/clients/odbc/driver/SQLConnect.c
+++ b/clients/odbc/driver/SQLConnect.c
@@ -258,9 +258,7 @@ MNDBConnect(ODBCDbc *dbc,
                mapi_setAutocommit(mid, dbc->sql_attr_autocommit == 
SQL_AUTOCOMMIT_ON);
                set_timezone(mid);
                get_serverinfo(dbc);
-               if (dbc->major > 11 ||
-                   (dbc->major == 11 && dbc->minor >= 5))
-                       mapi_set_size_header(mid, 1);
+               mapi_set_size_header(mid, 1);
                /* set timeout after we're connected */
                mapi_timeout(mid, dbc->sql_attr_connection_timeout * 1000);
        }
diff --git a/clients/odbc/driver/SQLTables.c b/clients/odbc/driver/SQLTables.c
--- a/clients/odbc/driver/SQLTables.c
+++ b/clients/odbc/driver/SQLTables.c
@@ -232,87 +232,69 @@ MNDBTables(ODBCStmt *stmt,
                strcpy(query_end, "with ot as (");
                query_end += strlen(query_end);
 
-               if (stmt->Dbc->major < 11 || (stmt->Dbc->major == 11 && 
stmt->Dbc->minor < 21)) {
-                       strcpy(query_end,
-                              "select e.value as table_cat, "
-                                     "s.name as table_schem, "
-                                     "t.name as table_name, "
-                                     "case when t.type = 0 and "
-                                               "t.system = false and "
-                                               "t.temporary = 0 and "
-                                               "s.name <> 'tmp' "
-                                          "then cast('TABLE' as varchar(20)) "
-                                          "when t.type = 0 and "
-                                               "t.system = false and "
-                                               "t.temporary = 0 and "
-                                               "s.name = 'tmp' "
-                                          "then cast('GLOBAL TEMPORARY' as 
varchar(20)) "
-                                          "when t.type = 0 and "
-                                               "t.system = true and "
-                                               "t.temporary = 0 "
-                                          "then cast('SYSTEM TABLE' as 
varchar(20)) "
-                                          "when t.type = 1 and "
-                                               "t.system = true and "
-                                               "t.temporary = 0 "
-                                          "then cast('SYSTEM VIEW' as 
varchar(20)) "
-                                          "when t.type = 1 "
-                                          "then cast('VIEW' as varchar(20)) "
-                                          "when t.type = 0 and "
-                                               "t.system = false and "
-                                               "t.temporary = 1 "
-                                          "then cast('LOCAL TEMPORARY' as 
varchar(20)) "
-                                          "else cast('INTERNAL TABLE TYPE' as 
varchar(20)) end as table_type, "
-                                     "cast(null as varchar(1)) as remarks "
-                              "from sys.schemas s, "
-                                   "sys.tables t, "
-                                   "sys.env() e "
-                              "where s.id = t.schema_id and "
-                                    "e.name = 'gdk_dbname'");
-               } else {
-                       strcpy(query_end,
-                              "select e.value as table_cat, "
-                                     "s.name as table_schem, "
-                                     "t.name as table_name, "
-                                     "case when t.type = 0 and "
-                                               "t.system = false and "
-                                               "t.temporary = 0 and "
-                                               "s.name <> 'tmp' "
-                                          "then cast('TABLE' as varchar(20)) "
-                                          "when t.type = 10 and "
-                                               "t.system = true and "
-                                               "t.temporary = 0 "
-                                          "then cast('SYSTEM TABLE' as 
varchar(20)) "
-                                          "when t.type = 11 and "
-                                               "t.system = true and "
-                                               "t.temporary = 0 "
-                                          "then cast('SYSTEM VIEW' as 
varchar(20)) "
-                                          "when t.type = 1 "
-                                          "then cast('VIEW' as varchar(20)) "
-                                          "when t.type = 3 "
-                                          "then cast('MERGE TABLE' as 
varchar(20)) "
-                                          "when t.type = 4 "
-                                          "then cast('STREAM TABLE' as 
varchar(20)) "
-                                          "when t.type = 5 "
-                                          "then cast('REMOTE TABLE' as 
varchar(20)) "
-                                          "when t.type = 6 "
-                                          "then cast('REPLICA TABLE' as 
varchar(20)) "
-                                          "when t.type = 20 and "
-                                               "t.system = false and "
-                                               "t.temporary = 1 and "
-                                               "s.name = 'tmp' "
-                                          "then cast('GLOBAL TEMPORARY' as 
varchar(20)) "
-                                          "when t.type = 30 and "
-                                               "t.system = false and "
-                                               "t.temporary = 1 "
-                                          "then cast('LOCAL TEMPORARY' as 
varchar(20)) "
-                                          "else cast('INTERNAL TABLE TYPE' as 
varchar(20)) end as table_type, "
-                                     "cast(null as varchar(1)) as remarks "
-                              "from sys.schemas s, "
-                                   "sys.tables t, "
-                                   "sys.env() e "
-                              "where s.id = t.schema_id and "
-                                    "e.name = 'gdk_dbname'");
-               }
+               strcpy(query_end,
+                      "select e.value as table_cat, "
+                             "s.name as table_schem, "
+                             "t.name as table_name, "
+                             "case when t.type = 0 and "
+                                       "t.system = false and "
+                                       "t.temporary = 0 and "
+                                       "s.name <> 'tmp' "
+                                  "then cast('TABLE' as varchar(20)) "
+/* start <= 11.21.X (at some point this code can be removed) */
+                                  "when t.type = 0 and "
+                                       "t.system = false and "
+                                       "t.temporary = 0 and "
+                                       "s.name = 'tmp' "
+                                  "then cast('GLOBAL TEMPORARY' as 
varchar(20)) "
+                                  "when t.type = 0 and "
+                                       "t.system = true and "
+                                       "t.temporary = 0 "
+                                  "then cast('SYSTEM TABLE' as varchar(20)) "
+                                  "when t.type = 0 and "
+                                       "t.system = false and "
+                                       "t.temporary = 1 "
+                                  "then cast('LOCAL TEMPORARY' as varchar(20)) 
"
+                                  "when t.type = 1 and "
+                                       "t.system = true and "
+                                       "t.temporary = 0 "
+                                  "then cast('SYSTEM VIEW' as varchar(20)) "
+/* end <= 11.21.X */
+                                  "when t.type = 1 "
+                                  "then cast('VIEW' as varchar(20)) "
+                                  "when t.type = 3 "
+                                  "then cast('MERGE TABLE' as varchar(20)) "
+                                  "when t.type = 4 "
+                                  "then cast('STREAM TABLE' as varchar(20)) "
+                                  "when t.type = 5 "
+                                  "then cast('REMOTE TABLE' as varchar(20)) "
+                                  "when t.type = 6 "
+                                  "then cast('REPLICA TABLE' as varchar(20)) "
+                                  "when t.type = 10 and "
+                                       "t.system = true and "
+                                       "t.temporary = 0 "
+                                  "then cast('SYSTEM TABLE' as varchar(20)) "
+                                  "when t.type = 11 and "
+                                       "t.system = true and "
+                                       "t.temporary = 0 "
+                                  "then cast('SYSTEM VIEW' as varchar(20)) "
+                                  "when t.type = 20 and "
+                                       "t.system = false and "
+                                       "t.temporary = 1 and "
+                                       "s.name = 'tmp' "
+                                  "then cast('GLOBAL TEMPORARY' as 
varchar(20)) "
+                                  "when t.type = 30 and "
+                                       "t.system = false and "
+                                       "t.temporary = 1 "
+                                  "then cast('LOCAL TEMPORARY' as varchar(20)) 
"
+                                  "else cast('INTERNAL TABLE TYPE' as 
varchar(20)) "
+                             "end as table_type, "
+                             "cast(null as varchar(1)) as remarks "
+                      "from sys.schemas s, "
+                           "sys.tables t, "
+                           "sys.env() e "
+                      "where s.id = t.schema_id and "
+                            "e.name = 'gdk_dbname'");
                assert(strlen(query) < 1100);
                query_end += strlen(query_end);
 
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to