Changeset: 90b3c951a5ec for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/90b3c951a5ec Modified Files: clients/odbc/driver/ODBCAttrs.c clients/odbc/driver/SQLBrowseConnect.c clients/odbc/tests/odbcconnect.c sql/odbc/tests/Tests/ODBCconnect.py Branch: Aug2024 Log Message:
Restore mapToLongVarchar setting It was available on the URL but not in ODBC diffs (109 lines): diff --git a/clients/odbc/driver/ODBCAttrs.c b/clients/odbc/driver/ODBCAttrs.c --- a/clients/odbc/driver/ODBCAttrs.c +++ b/clients/odbc/driver/ODBCAttrs.c @@ -50,6 +50,7 @@ const struct attr_setting attr_settings[ { "CLIENTINFO", "Send Client Info", MP_CLIENT_INFO }, { "APPNAME", "Application Name", MP_CLIENT_APPLICATION }, { "CLIENTREMARK", "Client Remark", MP_CLIENT_REMARK }, + { "MAPTOLONGVARCHAR", NULL, MP_MAPTOLONGVARCHAR }, }; const int attr_setting_count = sizeof(attr_settings) / sizeof(attr_settings[0]); diff --git a/clients/odbc/driver/SQLBrowseConnect.c b/clients/odbc/driver/SQLBrowseConnect.c --- a/clients/odbc/driver/SQLBrowseConnect.c +++ b/clients/odbc/driver/SQLBrowseConnect.c @@ -53,7 +53,12 @@ suggest_settings(ODBCDbc *dbc, char **bu mparm parm = entry->parm; if (dbc->setting_touched[(int)parm] == touched_as) { const char *sep = *pos > 0 ? ";" : ""; - reallocprintf(buf, pos, cap, "%s%s%s:%s=?", sep, prefix, entry->name, entry->alt_name); + reallocprintf( + buf, pos, cap, + "%s%s%s%s%s=?", + sep, prefix, entry->name, + entry->alt_name ? ":" : "", + entry->alt_name ? entry->alt_name : ""); if (entry->is_enum) { assert(entry->values != NULL); *pos -= 1; // eat the '?' diff --git a/clients/odbc/tests/odbcconnect.c b/clients/odbc/tests/odbcconnect.c --- a/clients/odbc/tests/odbcconnect.c +++ b/clients/odbc/tests/odbcconnect.c @@ -455,7 +455,45 @@ do_execute_stmt(void) SQL_HANDLE_STMT, stmt, "SQLNumResultCols", SQLNumResultCols(stmt, &colcount)); - printf("RESULT rows=%ld cols=%d \n", rowcount, colcount); + printf("RESULT rows=%ld: ", rowcount); + char *sep = ""; + for (int i = 1; i <= colcount; i++) { + printf("%s", sep); + sep = "; "; + SQLSMALLINT n; + ensure_ok( + SQL_HANDLE_STMT, stmt, "SQLColAttributeW SQL_DESC_NAME", + SQLColAttributeW(stmt, i, SQL_DESC_NAME, outwbuf, sizeof(outwbuf) /* in bytes! */, &n, NULL)); + convert_outw_outa(n); + printf("%s", outabuf); + SQLLEN typenr; + ensure_ok( + SQL_HANDLE_STMT, stmt, "SQLColAttributeW SQL_DESC_TYPE", + SQLColAttributeW(stmt, i, SQL_DESC_CONCISE_TYPE, NULL, 0, NULL, &typenr)); + ensure_ok( + SQL_HANDLE_STMT, stmt, "SQLColAttributeW SQL_DESC_TYPE_NAME", + SQLColAttributeW(stmt, i, SQL_DESC_TYPE_NAME, outwbuf, sizeof(outwbuf) /* in bytes! */, &n, NULL)); + convert_outw_outa(n); + char *marker = typenr == SQL_LONGVARCHAR || typenr == SQL_WLONGVARCHAR ? "*" : ""; + printf(":%s%s", marker, outabuf); + SQLLEN fixed, len, scale; + ensure_ok( + SQL_HANDLE_STMT, stmt, "SQLColAttributeW SQL_DESC_LENGTH", + SQLColAttributeW(stmt, i, SQL_DESC_FIXED_PREC_SCALE, NULL, 0, NULL, &fixed)); + ensure_ok( + SQL_HANDLE_STMT, stmt, "SQLColAttributeW SQL_DESC_LENGTH", + SQLColAttributeW(stmt, i, SQL_DESC_LENGTH, NULL, 0, NULL, &len)); + ensure_ok( + SQL_HANDLE_STMT, stmt, "SQLColAttributeW SQL_DESC_SCALE", + SQLColAttributeW(stmt, i, SQL_DESC_SCALE, NULL, 0, NULL, &scale)); + if (!fixed || scale) { + if (scale > 0) + printf("(%ld,%ld)", len, scale); + else + printf("(%ld)", len); + } + } + printf("\n"); while (colcount > 0 && SQL_SUCCEEDED(SQLFetch(stmt))) { printf(" - "); diff --git a/sql/odbc/tests/Tests/ODBCconnect.py b/sql/odbc/tests/Tests/ODBCconnect.py --- a/sql/odbc/tests/Tests/ODBCconnect.py +++ b/sql/odbc/tests/Tests/ODBCconnect.py @@ -284,6 +284,27 @@ ex = Execution('-w', '-d', f'DSN={dsn};C ex.expect('OK', f'CLIENTREMARK={unicode_text}') ex.end() +# test maptolongvarchar +ex = Execution( + '-d', f'DSN={dsn}', + '-q', "SELECT 'xxx' AS a, 'xxxyyyzzz' AS b" +) +ex.expect('OK') +ex.expect('RESULT', 'a:varchar', 'b:varchar') +ex.expect('-') +ex.end() + +ex = Execution( + '-d', f'DSN={dsn};mapToLongVarchar=5', # enable maptolong + '-q', "SELECT 'xxx' AS a, 'xxxyyyzzz' AS b" +) +ex.expect('OK') +ex.expect('RESULT', 'a:varchar', 'b:*varchar') # second must now be longvarchar +ex.expect('-') +ex.end() + + + ####################################################################### # Test SQLBrowseConnect ####################################################################### _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org