Changeset: bfb17492495d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=bfb17492495d
Modified Files:
clients/odbc/driver/SQLTables.c
Branch: Jan2014
Log Message:
Don't use server round trip to return table types.
diffs (77 lines):
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
@@ -41,6 +41,52 @@
#include "ODBCUtil.h"
+#define NCOLUMNS 5
+#define NROWS 5
+static const char *columnnames[NCOLUMNS] = {
+ "table_cat",
+ "table_schem",
+ "table_name",
+ "table_type",
+ "remarks"
+};
+static const char *columntypes[NCOLUMNS] = {
+ "varchar",
+ "varchar",
+ "varchar",
+ "varchar",
+ "varchar"
+};
+static const int columnlengths[NCOLUMNS] = {
+ 1,
+ 1,
+ 1,
+ 20,
+ 1
+};
+static const char *tuples0[NCOLUMNS] = {
+ NULL, NULL, NULL, "GLOBAL TEMPORARY", NULL
+};
+static const char *tuples1[NCOLUMNS] = {
+ NULL, NULL, NULL, "LOCAL TEMPORARY", NULL
+};
+static const char *tuples2[NCOLUMNS] = {
+ NULL, NULL, NULL, "SYSTEM TABLE", NULL
+};
+static const char *tuples3[NCOLUMNS] = {
+ NULL, NULL, NULL, "TABLE", NULL
+};
+static const char *tuples4[NCOLUMNS] = {
+ NULL, NULL, NULL, "VIEW", NULL
+};
+static const char **tuples[NROWS] = {
+ tuples0,
+ tuples1,
+ tuples2,
+ tuples3,
+ tuples4
+};
+
static SQLRETURN
SQLTables_(ODBCStmt *stmt,
SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
@@ -115,17 +161,9 @@ SQLTables_(ODBCStmt *stmt,
TableType &&
strcmp((char *) TableType, SQL_ALL_TABLE_TYPES) == 0) {
/* Special case query to fetch all Table type names. */
- query = strdup("select distinct "
- "cast(null as varchar(1)) as table_cat, "
- "cast(null as varchar(1)) as table_schem, "
- "cast(null as varchar(1)) as table_name, "
- "case when t.\"type\" = 0 and t.\"system\" =
false and t.\"temporary\" = 0 then cast('TABLE' 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 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.\"tables\" t order by table_type");
+ mapi_virtual_result(stmt->hdl, NCOLUMNS, columnnames,
+ columntypes, columnlengths, NROWS, tuples);
+ return ODBCInitResult(stmt);
} else {
/* no special case argument values */
char *query_end;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list