Skip to content

Commit 9fe5cba

Browse files
committed
Introduce new varchar limitation option (#229)
* introduce new varchar limitation option This commit adds a new feature that allows the user to limit the size of the string types (TEXT, KEYWORD & co.). This is needed for those applications that won't accept the large maxes that ES does for the fields of these types. The change will manifest itself as: - limitation of the COLUMN_SIZE, BUFFER_LENGHT and CHAR_OCTET_LENGTH in the SQLColumns output; - limitation of the "display size" attribute in the description of the columns of the above mentioned types; - truncation of the results to the configured limit for the columns of the above mentioned types. The commit also adds unit tests for the "faked" (i.e. driver-returned results) catalog functions, removes stale DSN attribute definition (left over from #215) and corrects the row index in a debug statement. * add new integration testing running mode Add new option to execute only the tests requiring no indexing of data (currently server info-fetching tests and the protocol tests). The commit also sets the autocommit as parameter to connection function, instead of the subsequent operation. (cherry picked from commit 77dc4ff)
1 parent 96f17cb commit 9fe5cba

File tree

15 files changed

+702
-175
lines changed

15 files changed

+702
-175
lines changed

driver/catalogue.c

Lines changed: 309 additions & 89 deletions
Large diffs are not rendered by default.

driver/catalogue.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,33 @@
1010
#include "error.h"
1111
#include "handles.h"
1212

13+
/* SQLColumns' name to (1-based) index mapping */
14+
enum {
15+
SQLCOLS_IDX_TABLE_CAT = 1,
16+
SQLCOLS_IDX_TABLE_SCHEM,
17+
SQLCOLS_IDX_TABLE_NAME,
18+
SQLCOLS_IDX_COLUMN_NAME,
19+
SQLCOLS_IDX_DATA_TYPE,
20+
SQLCOLS_IDX_TYPE_NAME,
21+
SQLCOLS_IDX_COLUMN_SIZE,
22+
SQLCOLS_IDX_BUFFER_LENGTH,
23+
SQLCOLS_IDX_DECIMAL_DIGITS,
24+
SQLCOLS_IDX_NUM_PREC_RADIX,
25+
SQLCOLS_IDX_NULLABLE,
26+
SQLCOLS_IDX_REMARKS,
27+
SQLCOLS_IDX_COLUMN_DEF,
28+
SQLCOLS_IDX_SQL_DATA_TYPE,
29+
SQLCOLS_IDX_SQL_DATETIME_SUB,
30+
SQLCOLS_IDX_CHAR_OCTET_LENGTH,
31+
SQLCOLS_IDX_ORDINAL_POSITION,
32+
SQLCOLS_IDX_IS_NULLABLE, /* 18 */
33+
SQLCOLS_IDX_MAX = 18
34+
};
1335

1436
SQLSMALLINT fetch_server_attr(esodbc_dbc_st *dbc, SQLINTEGER attr_id,
1537
SQLWCHAR *dest, SQLSMALLINT room);
1638
BOOL TEST_API set_current_catalog(esodbc_dbc_st *dbc, wstr_st *catalog);
39+
SQLRETURN TEST_API update_varchar_defs(esodbc_stmt_st *stmt);
1740

1841

1942
SQLRETURN EsSQLStatisticsW(

driver/connect.c

Lines changed: 68 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,8 +1133,7 @@ SQLRETURN config_dbc(esodbc_dbc_st *dbc, esodbc_dsn_attrs_st *attrs)
11331133
const static wstr_st https_prefix = WSTR_INIT("https://");
11341134
wstr_st prefix;
11351135
int cnt, ipv6;
1136-
SQLBIGINT secure;
1137-
long long timeout, max_body_size, max_fetch_size;
1136+
SQLBIGINT secure, timeout, max_body_size, max_fetch_size, varchar_limit;
11381137
SQLWCHAR buff_url[ESODBC_MAX_URL_LEN];
11391138
wstr_st url = (wstr_st) {
11401139
buff_url, /*will be init'ed later*/0
@@ -1188,7 +1187,7 @@ SQLRETURN config_dbc(esodbc_dbc_st *dbc, esodbc_dsn_attrs_st *attrs)
11881187
SET_HDIAG(dbc, SQL_STATE_HY000, "invalid security setting", 0);
11891188
goto err;
11901189
} else {
1191-
dbc->secure = (long)secure;
1190+
dbc->secure = (int)secure;
11921191
INFOH(dbc, "connection security level: %ld.", dbc->secure);
11931192
}
11941193

@@ -1297,16 +1296,16 @@ SQLRETURN config_dbc(esodbc_dbc_st *dbc, esodbc_dsn_attrs_st *attrs)
12971296
/*
12981297
* request timeout for liburl: negative reset to 0
12991298
*/
1300-
if (str2bigint(&attrs->timeout, /*wide?*/TRUE,
1301-
(SQLBIGINT *)&timeout, /*strict*/TRUE) < 0) {
1299+
if (str2bigint(&attrs->timeout, /*wide?*/TRUE, &timeout,
1300+
/*strict*/TRUE) < 0) {
13021301
ERRH(dbc, "failed to convert `" LWPDL "` [%zu] to big int.",
13031302
LWSTR(&attrs->timeout), attrs->timeout.cnt);
13041303
SET_HDIAG(dbc, SQL_STATE_HY000, "timeout setting number "
13051304
"conversion failure", 0);
13061305
goto err;
13071306
}
1308-
if (timeout < 0) {
1309-
WARNH(dbc, "set timeout is negative (%ld), normalized to 0.", timeout);
1307+
if (ULONG_MAX <= timeout || timeout < 0) {
1308+
WARNH(dbc, "invalid timeout value (%lld), normalized to 0.", timeout);
13101309
timeout = 0;
13111310
}
13121311
dbc->timeout = (SQLUINTEGER)timeout;
@@ -1315,19 +1314,18 @@ SQLRETURN config_dbc(esodbc_dbc_st *dbc, esodbc_dsn_attrs_st *attrs)
13151314
/*
13161315
* set max body size
13171316
*/
1318-
if (str2bigint(&attrs->max_body_size, /*wide?*/TRUE,
1319-
(SQLBIGINT *)&max_body_size, /*strict*/TRUE) < 0) {
1320-
ERRH(dbc, "failed to convert max body size `" LWPDL "` [%zu] to LL.",
1321-
LWSTR(&attrs->max_body_size), attrs->max_body_size.cnt);
1317+
if (str2bigint(&attrs->max_body_size, /*wide?*/TRUE, &max_body_size,
1318+
/*strict*/TRUE) < 0) {
1319+
ERRH(dbc, "failed to convert max body size [%zu] `" LWPDL "`.",
1320+
attrs->max_body_size.cnt, LWSTR(&attrs->max_body_size));
13221321
SET_HDIAG(dbc, SQL_STATE_HY000, "max body size setting number "
13231322
"conversion failure", 0);
13241323
goto err;
13251324
}
1326-
if (max_body_size < 0) {
1327-
ERRH(dbc, "'%s' setting can't be negative (%ld).",
1325+
if ((SIZE_MAX / (1024 * 1024)) <= max_body_size || max_body_size < 0) {
1326+
ERRH(dbc, "invalid '%s' setting value (%lld).",
13281327
ESODBC_DSN_MAX_BODY_SIZE_MB, max_body_size);
1329-
SET_HDIAG(dbc, SQL_STATE_HY000, "invalid max body size setting "
1330-
"(negative)", 0);
1328+
SET_HDIAG(dbc, SQL_STATE_HY000, "invalid max body size setting", 0);
13311329
goto err;
13321330
} else {
13331331
dbc->amax = (size_t)max_body_size * 1024 * 1024;
@@ -1340,19 +1338,18 @@ SQLRETURN config_dbc(esodbc_dbc_st *dbc, esodbc_dsn_attrs_st *attrs)
13401338
/*
13411339
* set max fetch size
13421340
*/
1343-
if (str2bigint(&attrs->max_fetch_size, /*wide?*/TRUE,
1344-
(SQLBIGINT *)&max_fetch_size, /*strict*/TRUE) < 0) {
1345-
ERRH(dbc, "failed to convert max fetch size `" LWPDL "` [%zu] to LL.",
1346-
LWSTR(&attrs->max_fetch_size), attrs->max_fetch_size.cnt);
1341+
if (str2bigint(&attrs->max_fetch_size, /*wide?*/TRUE, &max_fetch_size,
1342+
/*strict*/TRUE) < 0) {
1343+
ERRH(dbc, "failed to convert max fetch size [%zu] `" LWPDL "`.",
1344+
attrs->max_fetch_size.cnt, LWSTR(&attrs->max_fetch_size));
13471345
SET_HDIAG(dbc, SQL_STATE_HY000, "max fetch size setting number "
13481346
"conversion failure", 0);
13491347
goto err;
13501348
}
1351-
if (max_fetch_size < 0) {
1352-
ERRH(dbc, "'%s' setting can't be negative (%ld).",
1349+
if (SIZE_MAX <= max_fetch_size || max_fetch_size < 0) {
1350+
ERRH(dbc, "invalid '%s' setting value (%lld).",
13531351
ESODBC_DSN_MAX_FETCH_SIZE, max_fetch_size);
1354-
SET_HDIAG(dbc, SQL_STATE_HY000, "invalid max fetch size setting "
1355-
"(negative)", 0);
1352+
SET_HDIAG(dbc, SQL_STATE_HY000, "invalid max fetch size setting", 0);
13561353
goto err;
13571354
} else {
13581355
dbc->fetch.max = (size_t)max_fetch_size;
@@ -1370,7 +1367,6 @@ SQLRETURN config_dbc(esodbc_dbc_st *dbc, esodbc_dsn_attrs_st *attrs)
13701367
}
13711368
INFOH(dbc, "fetch_size: %s.", dbc->fetch.str ? dbc->fetch.str : "none" );
13721369

1373-
// TODO: catalog handling
13741370

13751371
/*
13761372
* set the REST body format: JSON/CBOR
@@ -1433,6 +1429,35 @@ SQLRETURN config_dbc(esodbc_dbc_st *dbc, esodbc_dsn_attrs_st *attrs)
14331429
/* auto escape pattern value argument */
14341430
dbc->auto_esc_pva = wstr2bool(&attrs->auto_esc_pva);
14351431
INFOH(dbc, "auto escape PVA: %s.", dbc->auto_esc_pva ? "true" : "false");
1432+
/* varchar limit */
1433+
if (str2bigint(&attrs->varchar_limit, /*wide?*/TRUE, &varchar_limit,
1434+
/*strict*/TRUE) < 0) {
1435+
ERRH(dbc, "failed to convert varchar limit [%zu] `" LWPDL "`.",
1436+
attrs->varchar_limit.cnt, LWSTR(&attrs->varchar_limit));
1437+
SET_HDIAG(dbc, SQL_STATE_HY000, "varchar limit value conversion "
1438+
"failure", 0);
1439+
goto err;
1440+
} else if (ESODBC_MAX_KEYWORD_PRECISION < varchar_limit ||
1441+
varchar_limit < 0) {
1442+
ERRH(dbc, "varchar limit (`" LWPDL "`) outside the allowed range "
1443+
"[%d, %d].", LWSTR(&attrs->varchar_limit), 0,
1444+
ESODBC_MAX_KEYWORD_PRECISION);
1445+
SET_HDIAG(dbc, SQL_STATE_HY000, "invalid varchar limit setting", 0);
1446+
goto err;
1447+
} else {
1448+
dbc->varchar_limit = (SQLUINTEGER)varchar_limit;
1449+
/* duplicate w-char setting */
1450+
if (! (dbc->varchar_limit_str.str = calloc(attrs->varchar_limit.cnt +
1451+
/*\0*/1, sizeof(SQLWCHAR)))) {
1452+
ERRNH(dbc, "OOM: %zu w-chars.", attrs->varchar_limit.cnt + 1);
1453+
SET_HDIAG(dbc, SQL_STATE_HY001, "Memory allocation error", 0);
1454+
goto err;
1455+
}
1456+
wmemcpy(dbc->varchar_limit_str.str, attrs->varchar_limit.str,
1457+
attrs->varchar_limit.cnt);
1458+
dbc->varchar_limit_str.cnt = attrs->varchar_limit.cnt;
1459+
INFOH(dbc, "varchar limit: %lu.", dbc->varchar_limit);
1460+
}
14361461

14371462
return SQL_SUCCESS;
14381463
err:
@@ -1524,6 +1549,11 @@ void cleanup_dbc(esodbc_dbc_st *dbc)
15241549
} else {
15251550
assert(dbc->catalog.cnt == 0);
15261551
}
1552+
if (dbc->varchar_limit_str.str) {
1553+
free(dbc->varchar_limit_str.str);
1554+
dbc->varchar_limit_str.str = NULL;
1555+
dbc->varchar_limit_str.cnt = 0;
1556+
}
15271557

15281558
assert(dbc->abuff == NULL);
15291559
cleanup_curl(dbc);
@@ -2516,7 +2546,7 @@ static void *copy_types_rows(esodbc_dbc_st *dbc, estype_row_st *type_row,
25162546
types[i].maximum_scale, types[i].minimum_scale);
25172547
}
25182548

2519-
/* resolve ES type to SQL C type */
2549+
/* resolve ES type to SQL and SQL C type */
25202550
if (! elastic_name2types(&types[i].type_name, &types[i].c_concise_type,
25212551
&sql_type)) {
25222552
/* ES version newer than driver's? */
@@ -2529,8 +2559,8 @@ static void *copy_types_rows(esodbc_dbc_st *dbc, estype_row_st *type_row,
25292559

25302560
/* BOOLEAN is used in catalog calls (like SYS TYPES / SQLGetTypeInfo),
25312561
* and the data type is piped through to the app (just like with any
2532-
* other statement), which causes issues, since it's a non-SQL type
2533-
* => change it to SQL_BIT */
2562+
* other statement), which causes issues, since it's not a standard
2563+
* type => change it to SQL_BIT */
25342564
if (types[i].data_type == ESODBC_SQL_BOOLEAN) {
25352565
types[i].data_type = ES_BOOLEAN_TO_SQL;
25362566
}
@@ -2555,6 +2585,15 @@ static void *copy_types_rows(esodbc_dbc_st *dbc, estype_row_st *type_row,
25552585
concise_to_type_code(types[i].data_type, &types[i].sql_data_type,
25562586
&types[i].sql_datetime_sub);
25572587

2588+
/* if there's a varchar limit, apply it to string types */
2589+
if (types[i].sql_data_type == ESODBC_SQL_STRING) {
2590+
assert(0 <= types[i].column_size);
2591+
if (dbc->varchar_limit &&
2592+
dbc->varchar_limit < (SQLUINTEGER)types[i].column_size) {
2593+
types[i].column_size = dbc->varchar_limit;
2594+
}
2595+
}
2596+
25582597
set_display_size(types + i);
25592598

25602599
/* There's no explicit coverage in the docs on how to communicate the
@@ -2691,10 +2730,10 @@ static BOOL load_es_types(esodbc_dbc_st *dbc)
26912730
goto end;
26922731
} else if (col_cnt != ESODBC_TYPES_COLUMNS) {
26932732
ERRH(stmt, "Elasticsearch returned an unexpected number of columns "
2694-
"(%d vs expected %d).", col_cnt, ESODBC_TYPES_COLUMNS);
2733+
"(%hd vs expected %d).", col_cnt, ESODBC_TYPES_COLUMNS);
26952734
goto end;
26962735
} else {
2697-
DBGH(stmt, "Elasticsearch types columns count: %d.", col_cnt);
2736+
DBGH(stmt, "Elasticsearch types columns count: %hd.", col_cnt);
26982737
}
26992738

27002739
/* check that we have received proper number of rows (non-0, less than

driver/convert.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,7 @@ static SQLRETURN wstr_to_cstr(esodbc_rec_st *arec, esodbc_rec_st *irec,
14501450

14511451
assert(xstr.w.str[xstr.w.cnt] == L'\0');
14521452
/* how much space would the converted string take? */
1453-
in_bytes = U16WC_TO_MBU8(xstr.w.str, xstr.w.cnt + 1, NULL, 0);
1453+
in_bytes = U16WC_TO_MBU8(xstr.w.str, xstr.w.cnt + /*\0*/1, NULL, 0);
14541454
if (in_bytes <= 0) {
14551455
ERRNH(stmt, "failed to convert wchar* to char* for string `"
14561456
LWPDL "`.", LWSTR(&xstr.w));
@@ -3321,6 +3321,26 @@ static SQLRETURN wstr_to_string(esodbc_rec_st *arec, esodbc_rec_st *irec,
33213321
return ret;
33223322
}
33233323

3324+
/* apply early truncation to the source data, to the limit enforced by the
3325+
* varchar limit; many functions downstream expect the 0-terminator in place,
3326+
* so an update of the count only would not suffice. */
3327+
void varchar_limit_apply(esodbc_rec_st *irec, wchar_t *wstr, size_t *chars_0)
3328+
{
3329+
esodbc_stmt_st *stmt = HDRH(irec->desc)->stmt;
3330+
SQLUINTEGER varchar_limit = HDRH(stmt)->dbc->varchar_limit;
3331+
3332+
if (varchar_limit <= 0) {
3333+
return;
3334+
}
3335+
if (*chars_0 - /*\0*/1 <= varchar_limit) {
3336+
return;
3337+
}
3338+
DBGH(stmt, "applying varchar limit truncation: %zu -> [%lu] `" LWPDL "`.",
3339+
*chars_0 - 1, varchar_limit, varchar_limit, wstr);
3340+
*chars_0 = varchar_limit + 1;
3341+
wstr[varchar_limit] = L'\0';
3342+
}
3343+
33243344
/*
33253345
* wstr: is 0-terminated and terminator is counted in 'chars_0'.
33263346
* However: "[w]hen C strings are used to hold character data, the
@@ -3344,6 +3364,11 @@ SQLRETURN sql2c_string(esodbc_rec_st *arec, esodbc_rec_st *irec,
33443364

33453365
stmt = arec->desc->hdr.stmt;
33463366

3367+
/* function updates the const wstr; this is however not the
3368+
* originally received network buffer, but a re-allocated chunk by the
3369+
* respective parsing library (json/cbor), so it should be safe; */
3370+
varchar_limit_apply(irec, (wchar_t *)wstr, &chars_0);
3371+
33473372
assert(1 <= chars_0); /* _0 is really counted */
33483373

33493374
/* pointer where to write how many characters we will/would use */

driver/defs.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* columns than this def, recs will be allocated dynamically. */
3838
#define ESODBC_GD_DESC_COUNT 128
3939
/* values for SQL_ATTR_MAX_LENGTH statement attribute */
40-
#define ESODBC_UP_MAX_LENGTH 0 // USHORT_MAX
40+
#define ESODBC_UP_MAX_LENGTH 0
4141
#define ESODBC_LO_MAX_LENGTH 0
4242
/* Prepare a STMT for a new SQL operation.
4343
* To be used with catalog functions, that can be all called with same stmt.
@@ -82,6 +82,8 @@
8282
* (Should move to 9 with nanosecond implementation) */
8383
#define ESODBC_MAX_SEC_PRECISION 9
8484
#define ESODBC_DEF_SEC_PRECISION 3
85+
/* max keyword column/"buffer" size ("Lucene's term byte-length limit") */
86+
#define ESODBC_MAX_KEYWORD_PRECISION 32766
8587
/*
8688
* standard specified defaults:
8789
* https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlsetdescfield-function##record-fields
@@ -184,6 +186,7 @@
184186
#define ESODBC_DEF_MFIELD_LENIENT "true"
185187
#define ESODBC_DEF_ESC_PVA "true"
186188
#define ESODBC_DEF_IDX_INC_FROZEN "false"
189+
#define ESODBC_DEF_VARCHAR_LIMIT "0"
187190

188191
/*
189192
*
@@ -401,6 +404,9 @@
401404
#define ODBC_SQL92_VALUE_EXPRESSIONS (0LU | \
402405
SQL_SVE_CASE | SQL_SVE_CAST | SQL_SVE_COALESCE | SQL_SVE_NULLIF)
403406

407+
/* the type ES/SQL uses for string types (KEYWORD, TEXT, CONSTANT_KEYWORD),
408+
* plus IP and GEO */
409+
#define ESODBC_SQL_STRING SQL_VARCHAR
404410
/*
405411
* ES specific data types
406412
*/

driver/dsn.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ int assign_dsn_attr(esodbc_dsn_attrs_st *attrs,
7878
{&MK_WSTR(ESODBC_DSN_APPLY_TZ), &attrs->apply_tz},
7979
{&MK_WSTR(ESODBC_DSN_EARLY_EXEC), &attrs->early_exec},
8080
{&MK_WSTR(ESODBC_DSN_SCI_FLOATS), &attrs->sci_floats},
81-
{&MK_WSTR(ESODBC_DSN_VERSION_CHECKING), &attrs->version_checking},
81+
{&MK_WSTR(ESODBC_DSN_VARCHAR_LIMIT), &attrs->varchar_limit},
8282
{&MK_WSTR(ESODBC_DSN_MFIELD_LENIENT), &attrs->mfield_lenient},
8383
{&MK_WSTR(ESODBC_DSN_ESC_PVA), &attrs->auto_esc_pva},
8484
{&MK_WSTR(ESODBC_DSN_IDX_INC_FROZEN), &attrs->idx_inc_frozen},
@@ -414,7 +414,7 @@ long TEST_API write_00_list(esodbc_dsn_attrs_st *attrs,
414414
{&MK_WSTR(ESODBC_DSN_APPLY_TZ), &attrs->apply_tz},
415415
{&MK_WSTR(ESODBC_DSN_EARLY_EXEC), &attrs->early_exec},
416416
{&MK_WSTR(ESODBC_DSN_SCI_FLOATS), &attrs->sci_floats},
417-
{&MK_WSTR(ESODBC_DSN_VERSION_CHECKING), &attrs->version_checking},
417+
{&MK_WSTR(ESODBC_DSN_VARCHAR_LIMIT), &attrs->varchar_limit},
418418
{&MK_WSTR(ESODBC_DSN_MFIELD_LENIENT), &attrs->mfield_lenient},
419419
{&MK_WSTR(ESODBC_DSN_ESC_PVA), &attrs->auto_esc_pva},
420420
{&MK_WSTR(ESODBC_DSN_IDX_INC_FROZEN), &attrs->idx_inc_frozen},
@@ -686,9 +686,8 @@ BOOL write_system_dsn(esodbc_dsn_attrs_st *new_attrs,
686686
old_attrs ? &old_attrs->sci_floats : NULL
687687
},
688688
{
689-
&MK_WSTR(ESODBC_DSN_VERSION_CHECKING),
690-
&new_attrs->version_checking,
691-
old_attrs ? &old_attrs->version_checking : NULL
689+
&MK_WSTR(ESODBC_DSN_VARCHAR_LIMIT), &new_attrs->varchar_limit,
690+
old_attrs ? &old_attrs->varchar_limit : NULL
692691
},
693692
{
694693
&MK_WSTR(ESODBC_DSN_MFIELD_LENIENT),
@@ -794,7 +793,7 @@ long TEST_API write_connection_string(esodbc_dsn_attrs_st *attrs,
794793
{&attrs->apply_tz, &MK_WSTR(ESODBC_DSN_APPLY_TZ)},
795794
{&attrs->early_exec, &MK_WSTR(ESODBC_DSN_EARLY_EXEC)},
796795
{&attrs->sci_floats, &MK_WSTR(ESODBC_DSN_SCI_FLOATS)},
797-
{&attrs->version_checking, &MK_WSTR(ESODBC_DSN_VERSION_CHECKING)},
796+
{&attrs->varchar_limit, &MK_WSTR(ESODBC_DSN_VARCHAR_LIMIT)},
798797
{&attrs->mfield_lenient, &MK_WSTR(ESODBC_DSN_MFIELD_LENIENT)},
799798
{&attrs->auto_esc_pva, &MK_WSTR(ESODBC_DSN_ESC_PVA)},
800799
{&attrs->idx_inc_frozen, &MK_WSTR(ESODBC_DSN_IDX_INC_FROZEN)},
@@ -897,6 +896,9 @@ void assign_dsn_defaults(esodbc_dsn_attrs_st *attrs)
897896
res |= assign_dsn_attr(attrs,
898897
&MK_WSTR(ESODBC_DSN_SCI_FLOATS), &MK_WSTR(ESODBC_DEF_SCI_FLOATS),
899898
/*overwrite?*/FALSE);
899+
res |= assign_dsn_attr(attrs,
900+
&MK_WSTR(ESODBC_DSN_VARCHAR_LIMIT),
901+
&MK_WSTR(ESODBC_DEF_VARCHAR_LIMIT), /*overwrite?*/FALSE);
900902
res |= assign_dsn_attr(attrs,
901903
&MK_WSTR(ESODBC_DSN_MFIELD_LENIENT),
902904
&MK_WSTR(ESODBC_DEF_MFIELD_LENIENT), /*overwrite?*/FALSE);

driver/dsn.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#define ESODBC_DSN_APPLY_TZ "ApplyTZ"
3838
#define ESODBC_DSN_EARLY_EXEC "EarlyExecution"
3939
#define ESODBC_DSN_SCI_FLOATS "ScientificFloats"
40-
#define ESODBC_DSN_VERSION_CHECKING "VersionChecking"
40+
#define ESODBC_DSN_VARCHAR_LIMIT "VarcharLimit"
4141
#define ESODBC_DSN_MFIELD_LENIENT "MultiFieldLenient"
4242
#define ESODBC_DSN_ESC_PVA "AutoEscapePVA"
4343
#define ESODBC_DSN_IDX_INC_FROZEN "IndexIncludeFrozen"
@@ -81,7 +81,7 @@ typedef struct {
8181
wstr_st apply_tz;
8282
wstr_st early_exec;
8383
wstr_st sci_floats;
84-
wstr_st version_checking;
84+
wstr_st varchar_limit;
8585
wstr_st mfield_lenient;
8686
wstr_st auto_esc_pva;
8787
wstr_st idx_inc_frozen;

driver/handles.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ typedef struct struct_dbc {
176176
/* maximum precision/length of types using same SQL data type ID */
177177
esodbc_estype_st *max_varchar_type; /* pointer to TEXT type */
178178
esodbc_estype_st *max_float_type; /* pointer to DOUBLE type */
179+
/* configuration imposed lenghts for the ES/SQL string types */
180+
SQLUINTEGER varchar_limit;
181+
wstr_st varchar_limit_str; /* convenience w-string of varchar limit */
179182

180183
CURL *curl; /* cURL handle */
181184
CURLcode curl_err;

0 commit comments

Comments
 (0)