Changeset: 670a6049d90b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=670a6049d90b
Modified Files:
clients/odbc/driver/SQLGetTypeInfo.c
Branch: default
Log Message:
Use actual query for SQLGetTypeInfo.
We still provide all the data, though, so the server just returns what
we fed it. This is to stop using the mapi_virtual_result function.
diffs (truncated from 1785 to 300 lines):
diff --git a/clients/odbc/driver/SQLGetTypeInfo.c
b/clients/odbc/driver/SQLGetTypeInfo.c
--- a/clients/odbc/driver/SQLGetTypeInfo.c
+++ b/clients/odbc/driver/SQLGetTypeInfo.c
@@ -30,78 +30,7 @@
#include <float.h>
-#define NCOLUMNS 19
-
-/* column names of result set */
-static const char *columnnames[NCOLUMNS] = {
- "type_name",
- "data_type",
- "column_size",
- "literal_prefix",
- "literal_suffix",
- "create_params",
- "nullable",
- "case_sensitive",
- "searchable",
- "unsigned_attribute",
- "fixed_prec_scale",
- "auto_unique_value",
- "local_type_name",
- "minimum_scale",
- "maximum_scale",
- "sql_data_type",
- "sql_datetime_sub",
- "num_prec_radix",
- "interval_precision"
-};
-
-/* column types of result set */
-static const char *columntypes[NCOLUMNS] = {
- "varchar",
- "smallint",
- "int",
- "varchar",
- "varchar",
- "varchar",
- "smallint",
- "smallint",
- "smallint",
- "smallint",
- "smallint",
- "smallint",
- "varchar",
- "smallint",
- "smallint",
- "smallint",
- "smallint",
- "int",
- "smallint"
-};
-
-/* column lengths of result set */
-static const int columnlengths[NCOLUMNS] = {
- 128,
- 5,
- 10,
- 128,
- 128,
- 128,
- 5,
- 5,
- 5,
- 5,
- 5,
- 5,
- 128,
- 5,
- 5,
- 5,
- 5,
- 10,
- 5
-};
-
-static struct types {
+static const struct types {
const char *type_name;
const int data_type; /* concise type */
const int column_size;
@@ -121,803 +50,768 @@ static struct types {
const int sql_datetime_sub;
const int num_prec_radix;
const int interval_precision;
- const char **tuple;
} types[] = {
- /* this table is sorted on the value of data_type and then on
+ /* This table is sorted on the value of data_type and then on
* how "close" the type maps to the corresponding ODBC SQL
- * type (i.e. in the order SQLGetTypeInfo wants it) */
+ * type (i.e. in the order SQLGetTypeInfo wants it).
+ * Except for the type_name value, the string values are ready
+ * to paste into an SQL query (i.e. including quotes). */
{
- "uuid", /* type_name */
- SQL_GUID, /* data_type */
- 36, /* column_size */
- NULL, /* literal_prefix */
- NULL, /* literal_suffix */
- NULL, /* create_params */
- SQL_NULLABLE, /* nullable */
- SQL_FALSE, /* case_sensitive */
- SQL_PRED_BASIC, /* searchable */
- -1, /* unsigned_attribute */
- SQL_FALSE, /* fixed_prec_scale */
- -1, /* auto_unique_value */
- NULL, /* local_type_name */
- -1, /* minimum_scale */
- -1, /* maximum_scale */
- SQL_GUID, /* sql_data_type */
- -1, /* sql_datetime_sub */
- -1, /* num_prec_radix */
- -1, /* interval_precision */
- NULL /* tuple */
+ "uuid", /* type_name */
+ SQL_GUID, /* data_type */
+ 36, /* column_size */
+ "NULL", /* literal_prefix */
+ "NULL", /* literal_suffix */
+ "NULL", /* create_params */
+ SQL_NULLABLE, /* nullable */
+ SQL_FALSE, /* case_sensitive */
+ SQL_PRED_BASIC, /* searchable */
+ -1, /* unsigned_attribute */
+ SQL_FALSE, /* fixed_prec_scale */
+ -1, /* auto_unique_value */
+ "NULL", /* local_type_name */
+ -1, /* minimum_scale */
+ -1, /* maximum_scale */
+ SQL_GUID, /* sql_data_type */
+ -1, /* sql_datetime_sub */
+ -1, /* num_prec_radix */
+ -1, /* interval_precision */
},
{
"character large object", /* type_name */
- SQL_WLONGVARCHAR, /* data_type */
- 1000000, /* column_size */
- "'", /* literal_prefix */
- "'", /* literal_suffix */
- NULL, /* create_params */
- SQL_NULLABLE, /* nullable */
- SQL_TRUE, /* case_sensitive */
- SQL_SEARCHABLE, /* searchable */
- -1, /* unsigned_attribute */
- SQL_FALSE, /* fixed_prec_scale */
- SQL_FALSE, /* auto_unique_value */
- NULL, /* local_type_name */
- -1, /* minimum_scale */
- -1, /* maximum_scale */
- SQL_WLONGVARCHAR, /* sql_data_type */
- -1, /* sql_datetime_sub */
- -1, /* num_prec_radix */
- -1, /* interval_precision */
- NULL /* tuple */
+ SQL_WLONGVARCHAR, /* data_type */
+ 1000000, /* column_size */
+ "''''", /* literal_prefix */
+ "''''", /* literal_suffix */
+ "NULL", /* create_params */
+ SQL_NULLABLE, /* nullable */
+ SQL_TRUE, /* case_sensitive */
+ SQL_SEARCHABLE, /* searchable */
+ -1, /* unsigned_attribute */
+ SQL_FALSE, /* fixed_prec_scale */
+ SQL_FALSE, /* auto_unique_value */
+ "NULL", /* local_type_name */
+ -1, /* minimum_scale */
+ -1, /* maximum_scale */
+ SQL_WLONGVARCHAR, /* sql_data_type */
+ -1, /* sql_datetime_sub */
+ -1, /* num_prec_radix */
+ -1, /* interval_precision */
},
{
- "varchar", /* type_name */
- SQL_WVARCHAR, /* data_type */
- 1000000, /* column_size */
- "'", /* literal_prefix */
- "'", /* literal_suffix */
- "length", /* create_params */
- SQL_NULLABLE, /* nullable */
- SQL_TRUE, /* case_sensitive */
- SQL_SEARCHABLE, /* searchable */
- -1, /* unsigned_attribute */
- SQL_FALSE, /* fixed_prec_scale */
- -1, /* auto_unique_value */
- NULL, /* local_type_name */
- -1, /* minimum_scale */
- -1, /* maximum_scale */
- SQL_WVARCHAR, /* sql_data_type */
- -1, /* sql_datetime_sub */
- -1, /* num_prec_radix */
- -1, /* interval_precision */
- NULL /* tuple */
+ "varchar", /* type_name */
+ SQL_WVARCHAR, /* data_type */
+ 1000000, /* column_size */
+ "''''", /* literal_prefix */
+ "''''", /* literal_suffix */
+ "'length'", /* create_params */
+ SQL_NULLABLE, /* nullable */
+ SQL_TRUE, /* case_sensitive */
+ SQL_SEARCHABLE, /* searchable */
+ -1, /* unsigned_attribute */
+ SQL_FALSE, /* fixed_prec_scale */
+ -1, /* auto_unique_value */
+ "NULL", /* local_type_name */
+ -1, /* minimum_scale */
+ -1, /* maximum_scale */
+ SQL_WVARCHAR, /* sql_data_type */
+ -1, /* sql_datetime_sub */
+ -1, /* num_prec_radix */
+ -1, /* interval_precision */
},
{
- "character", /* type_name */
- SQL_WCHAR, /* data_type */
- 1000000, /* column_size */
- "'", /* literal_prefix */
- "'", /* literal_suffix */
- "length", /* create_params */
- SQL_NULLABLE, /* nullable */
- SQL_TRUE, /* case_sensitive */
- SQL_SEARCHABLE, /* searchable */
- -1, /* unsigned_attribute */
- SQL_FALSE, /* fixed_prec_scale */
- SQL_FALSE, /* auto_unique_value */
- NULL, /* local_type_name */
- -1, /* minimum_scale */
- -1, /* maximum_scale */
- SQL_WCHAR, /* sql_data_type */
- -1, /* sql_datetime_sub */
- -1, /* num_prec_radix */
- -1, /* interval_precision */
- NULL /* tuple */
+ "character", /* type_name */
+ SQL_WCHAR, /* data_type */
+ 1000000, /* column_size */
+ "''''", /* literal_prefix */
+ "''''", /* literal_suffix */
+ "'length'", /* create_params */
+ SQL_NULLABLE, /* nullable */
+ SQL_TRUE, /* case_sensitive */
+ SQL_SEARCHABLE, /* searchable */
+ -1, /* unsigned_attribute */
+ SQL_FALSE, /* fixed_prec_scale */
+ SQL_FALSE, /* auto_unique_value */
+ "NULL", /* local_type_name */
+ -1, /* minimum_scale */
+ -1, /* maximum_scale */
+ SQL_WCHAR, /* sql_data_type */
+ -1, /* sql_datetime_sub */
+ -1, /* num_prec_radix */
+ -1, /* interval_precision */
},
{
- "char", /* type_name */
- SQL_WCHAR, /* data_type */
- 1000000, /* column_size */
- "'", /* literal_prefix */
- "'", /* literal_suffix */
- "length", /* create_params */
- SQL_NULLABLE, /* nullable */
- SQL_TRUE, /* case_sensitive */
- SQL_SEARCHABLE, /* searchable */
- -1, /* unsigned_attribute */
- SQL_FALSE, /* fixed_prec_scale */
- SQL_FALSE, /* auto_unique_value */
- NULL, /* local_type_name */
- -1, /* minimum_scale */
- -1, /* maximum_scale */
- SQL_WCHAR, /* sql_data_type */
- -1, /* sql_datetime_sub */
- -1, /* num_prec_radix */
- -1, /* interval_precision */
- NULL /* tuple */
+ "char", /* type_name */
+ SQL_WCHAR, /* data_type */
+ 1000000, /* column_size */
+ "''''", /* literal_prefix */
+ "''''", /* literal_suffix */
+ "'length'", /* create_params */
+ SQL_NULLABLE, /* nullable */
+ SQL_TRUE, /* case_sensitive */
+ SQL_SEARCHABLE, /* searchable */
+ -1, /* unsigned_attribute */
+ SQL_FALSE, /* fixed_prec_scale */
+ SQL_FALSE, /* auto_unique_value */
+ "NULL", /* local_type_name */
+ -1, /* minimum_scale */
+ -1, /* maximum_scale */
+ SQL_WCHAR, /* sql_data_type */
+ -1, /* sql_datetime_sub */
+ -1, /* num_prec_radix */
+ -1, /* interval_precision */
},
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list