Skip to content

Commit d165048

Browse files
authored
Add unsigned_long ES type support (#304)
This adds support for the ES/SQL UNSIGNED_LONG type. Values with this type can be received by the driver and forwarded to the application as SQL_C_UBIGINT types. The driver will also accept parameters of this type. The driver-internal conversion to/from UNSIGNED_LONG is also supported. The commit also adds logging of the name of the application loading the driver. When at the end of a tagged value, the CBOR parser no longer needs to be skipping the end-of-tag value, since the tagged value won't be inspected any further.
1 parent b608f56 commit d165048

17 files changed

+1418
-226
lines changed

driver/connect.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
#define TYPE_UNSUPPORTED "UNSUPPORTED"
7070
/* 12 */
7171
#define TYPE_SCALED_FLOAT "SCALED_FLOAT"
72+
/* 13 */
73+
#define TYPE_UNSIGNED_LONG "UNSIGNED_LONG"
7274

7375
/*
7476
* intervals
@@ -2386,6 +2388,17 @@ static BOOL elastic_name2types(wstr_st *type_name,
23862388
return TRUE;
23872389
}
23882390
break;
2391+
2392+
/* 13: UNSIGNED_LONG */
2393+
case sizeof(TYPE_UNSIGNED_LONG) - 1:
2394+
if (! wmemncasecmp(type_name->str, MK_WPTR(TYPE_UNSIGNED_LONG),
2395+
type_name->cnt)) {
2396+
*c_sql = ES_ULONG_TO_CSQL;
2397+
*sql = ES_ULONG_TO_SQL;
2398+
return TRUE;
2399+
}
2400+
break;
2401+
23892402
}
23902403

23912404
return elastic_intervals_name2types(type_name, c_sql, sql);
@@ -2422,7 +2435,7 @@ static void set_display_size(esodbc_estype_st *es_type)
24222435
es_type->display_size ++;
24232436
}
24242437
break;
2425-
case SQL_BIGINT: /* LONG */
2438+
case SQL_BIGINT: /* LONG, UNSIGNED_LONG */
24262439
es_type->display_size = es_type->column_size;
24272440
if (es_type->unsigned_attribute) {
24282441
es_type->display_size ++;
@@ -2713,13 +2726,15 @@ static void set_es_types(esodbc_dbc_st *dbc, SQLULEN rows_fetched,
27132726
{
27142727
SQLULEN i;
27152728
SQLINTEGER max_float_size, max_varchar_size;
2729+
size_t lgst_name_len;
27162730

27172731
dbc->es_types = types;
27182732
dbc->no_types = rows_fetched;
27192733

27202734
assert(dbc->max_float_type == NULL);
27212735
assert(dbc->max_varchar_type == NULL);
27222736

2737+
lgst_name_len = 0;
27232738
for (i = 0; i < rows_fetched; i ++) {
27242739
switch (types[i].data_type) {
27252740
case SQL_DOUBLE:
@@ -2736,11 +2751,20 @@ static void set_es_types(esodbc_dbc_st *dbc, SQLULEN rows_fetched,
27362751
if (max_varchar_size < types[i].column_size) {
27372752
dbc->max_varchar_type = &types[i];
27382753
}
2754+
break;
2755+
}
2756+
if (types[i].c_concise_type == ES_ULONG_TO_CSQL) {
2757+
dbc->ulong = &types[i];
2758+
}
2759+
if (lgst_name_len < types[i].type_name.cnt) {
2760+
lgst_name_len = types[i].type_name.cnt;
2761+
dbc->lgst_name = &types[i];
27392762
}
27402763
}
27412764

27422765
assert(dbc->max_float_type);
27432766
assert(dbc->max_varchar_type);
2767+
assert(dbc->lgst_name);
27442768

27452769
DBGH(dbc, "%lu ES/SQL types available, maximum sizes supported for: "
27462770
"floats: %ld, varchar: %ld.", (unsigned long)rows_fetched,

0 commit comments

Comments
 (0)