Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0f22584
Fix ODBC metadata and value binding
Nov 6, 2026
bef7502
Fix binary fetches and unsigned precision
Nov 6, 2026
93ed55e
Fix ODBC consumer compatibility
Nov 6, 2026
17583ea
Fix ODBC bindings without consumer patches
Nov 9, 2026
cafd25f
Preserve wide temporal fixture types
Nov 9, 2026
f944aaf
Return only relations from SQLTables
Nov 9, 2026
59504b0
Restore the stock append-to-new-table call
Nov 9, 2026
5ac01f6
Support binary input for character parameters
Nov 9, 2026
5a437f9
Use YDB binary literals in binding fixtures
Nov 9, 2026
5360d0f
Preserve NULL binary fixture literals
Nov 9, 2026
b919017
Describe floating arithmetic parameters
Nov 9, 2026
447d848
Describe system-view columns
Nov 9, 2026
93be284
Report reproduced upstream consumer failures
Nov 9, 2026
ddfa3b2
Preserve Qt binding calls in YDB fixtures
Nov 9, 2026
f3a40cc
Fix ODBC metadata and complete consumer coverage
Nov 10, 2026
efe2f6a
Fix PHP type-info fixture context
Nov 10, 2026
8b882c8
Support cursor-library statement allocation
Nov 11, 2026
4ea2747
Restore applicable consumer coverage
Nov 11, 2026
5b748dd
Fix ODBC test linkage and crash reporting
Nov 11, 2026
c161059
Fix ODBC parameter limits and cursor docs
Nov 11, 2026
31a8774
Use Ubuntu mirrors for CI dependencies
Nov 11, 2026
2c43eb2
Restore CI dependency setup
Nov 11, 2026
c043ed8
Fix ODBC integration fixtures and runtime dependencies
Nov 11, 2026
bbc133e
Fix ODBC temporal bindings and metadata
Nov 12, 2026
66c6e2b
Wait for IAM storage readiness
Nov 12, 2026
c3aca3d
Keep consumer health probes read-only
Shfdis Nov 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/actions/prepare_vm/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ runs:
ccache --set-config=cache_dir="$HOME/.ccache"
ccache --zero-stats
else
sudo apt-get -y install libidn12 libodbc2 libodbcinst2 libssl3 libstdc++6
# unixODBC loads libodbccr.so through the development package's symlink.
sudo apt-get -y install libidn12 libodbc2 libodbcinst2 libssl3 libstdc++6 unixodbc-dev
fi
6 changes: 2 additions & 4 deletions .github/scripts/run_iam_integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ cleanup_iam() {

wait_for_iam_ydb() {
for _ in $(seq 1 "${IAM_READY_ATTEMPTS}"); do
if docker exec -e "YDB_TOKEN=${IAM_TOKEN}" "${IAM_CONTAINER_NAME}" /ydb \
--endpoint grpc://localhost:2236 \
--database /local \
sql -s 'select 1' >/dev/null 2>&1; then
if docker exec -e "YDB_TOKEN=${IAM_TOKEN}" "${IAM_CONTAINER_NAME}" \
bash /health_check --readiness >/dev/null 2>&1; then
return 0
fi
sleep "${IAM_READY_SLEEP_SECONDS}"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/odbc-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
ydb:
image: ${{ fromJSON(needs.build.outputs.config).ydb.image }}
ports: [2136:2136]
env: {YDB_USE_IN_MEMORY_PDISKS: true, YDB_TABLE_ENABLE_PREPARED_DDL: true}
env: {YDB_USE_IN_MEMORY_PDISKS: true, YDB_TABLE_ENABLE_PREPARED_DDL: true, YDB_READINESS_ENABLE_DDL: 'false'}
options: --hostname localhost
steps:
- uses: actions/checkout@v4
Expand All @@ -111,8 +111,8 @@ jobs:
shell: bash
run: |
for attempt in $(seq 1 60); do
docker exec '${{ job.services.ydb.id }}' /ydb \
-e grpc://localhost:2136 -d /local scheme ls >/dev/null 2>&1 && exit 0
docker exec -e YDB_READINESS_ENABLE_DDL=true '${{ job.services.ydb.id }}' \
bash /health_check --readiness >/dev/null 2>&1 && exit 0
sleep 2
done
docker logs '${{ job.services.ydb.id }}' || true
Expand Down
3 changes: 3 additions & 0 deletions odbc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ in the DSN.
| `Database` | YDB database path. |
| `DSN` | DSN section to load before applying the remaining connection-string attributes. |
| `AuthMode` | `Anonymous`, `Token`, `Static`, `Metadata`, `ServiceAccount`, `OAuth2`, or `Environment`. Values are case-insensitive. |
| `AnsiSQL` | `1` enables YDB's ANSI lexer and Unicode string literals for SQL-generating clients. `SQLNativeSql` includes the `--!ansi_lexer` / `PRAGMA UnicodeLiterals;` prologue. Defaults to `0` (native YQL). |
| `Token` | Access token for `Token` mode. `AccessToken` is an alias. |
| `User`, `Password` | Credentials for `Static` mode. `UID` and `PWD` are aliases. |
| `MetadataHost`, `MetadataPort` | Optional metadata service address for `Metadata` mode. |
Expand Down Expand Up @@ -265,6 +266,8 @@ For statements without an applicable count, it returns `-1`.
`?` placeholders are rewritten to `$p1`, `$p2`, ... with auto-generated
`DECLARE` statements derived from `SQLBindParameter` types. Null values use an
optional YDB type. YDB-native `$pN` syntax also works.
Statements support at most 32767 parameters; larger counts or `$pN` indices
return `HY000`.

## License

Expand Down
6 changes: 3 additions & 3 deletions odbc/proposal.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ The cursor also owns:
- typed YDB rows and column metadata;
- row-wise and column-wise bindings;
- row-array status and processed-row counters;
- a separate chunk offset for each `SQLGetData` column;
- a statement-local spill file that bounds the retained static-cursor snapshot
after the SDK result has been materialized.
- an offset for the active `SQLGetData` stream;
- static-cursor rows cached in memory until the cursor is closed or replaced,
in addition to the SDK's materialized result.

Re-execution replaces the cursor. Close, cancel, commit, rollback, and disconnect release it according to the advertised cursor behavior.

Expand Down
11 changes: 10 additions & 1 deletion odbc/src/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ void TConnection::ApplyResolvedSettings(TResolvedConnectionSettings&& settings)
Database_ = std::move(settings.Database);
ServerName_ = std::move(settings.Endpoint);
DataSourceName_ = std::move(settings.DataSourceName);
AnsiSql_ = settings.AnsiSql;
DriverConfig_.emplace(std::move(settings.DriverConfig));
RecreateYdbClients();
Attributes_.SetCurrentCatalog(Database_);
Expand Down Expand Up @@ -381,8 +382,16 @@ TConnectionAttributes::TCatalogBinding TConnection::GetCatalogBinding() const {
return Attributes_.BuildCatalogBinding(Database_);
}

std::string TConnection::PrepareSql(std::string sql) const {
Comment thread
Shfdis marked this conversation as resolved.
Resolved
constexpr std::string_view prefix = "--!ansi_lexer\nPRAGMA UnicodeLiterals;\n";
if (AnsiSql_ && !sql.empty() && !sql.starts_with(prefix)) {
sql.insert(0, prefix);
}
return sql;
}

SQLRETURN TConnection::NativeSql(const std::string& inSql, SQLCHAR* outSql, SQLINTEGER outMax, SQLINTEGER* outLen) {
const std::string nativeSql = RewriteOdbcEscapes(inSql);
const std::string nativeSql = RewriteOdbcEscapes(PrepareSql(inSql));
Comment thread
Shfdis marked this conversation as resolved.
Resolved
return Diag::WriteOptionalOdbcString(*this, nativeSql, outSql, outMax, outLen);
}

Expand Down
2 changes: 2 additions & 0 deletions odbc/src/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class TConnection : public THandle {
std::string Database_;
std::string ServerName_;
std::string DataSourceName_;
bool AnsiSql_ = false;

TConnectionAttributes Attributes_;
mutable std::optional<std::string> DbmsVersionCache_;
Expand Down Expand Up @@ -95,6 +96,7 @@ class TConnection : public THandle {
NQuery::TTxSettings MakeTxSettings() const;

std::string WrapQueryForCurrentCatalog(const std::string& sql) const;
std::string PrepareSql(std::string sql) const;
TConnectionAttributes::TCatalogBinding GetCatalogBinding() const;
const std::string& GetDbmsVersion();
const std::string& GetDatabaseName() const;
Expand Down
6 changes: 6 additions & 0 deletions odbc/src/connection_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ constexpr std::array ConnectionKeys = {
TConnectionKeySpec{"DSN"},
TConnectionKeySpec{"Endpoint", "Server"},
TConnectionKeySpec{"Database"},
TConnectionKeySpec{"AnsiSQL"},
TConnectionKeySpec{"AuthMode"},
TConnectionKeySpec{"Token", "AccessToken", uint8_t(EAuthenticationMode::Token) | SelectsAuth},
TConnectionKeySpec{"User", "UID", uint8_t(EAuthenticationMode::Static) | SelectsAuth},
Expand Down Expand Up @@ -271,6 +272,10 @@ void OverlayConnectionParameters(TConnectionParameters& destination, const TConn
}

TResolvedConnectionSettings ResolveConnectionSettings(TConnectionParameters parameters, std::string dataSourceName) {
const auto ansiSql = Get(parameters, "AnsiSQL");
if (!ansiSql.empty() && ansiSql != "0" && ansiSql != "1") {
ThrowInvalidAttribute("AnsiSQL", "expected 0 or 1");
}
const std::string endpointValue(Get(parameters, "Endpoint"));
const std::string database(Get(parameters, "Database"));
if (endpointValue.empty() || database.empty()) {
Expand Down Expand Up @@ -372,6 +377,7 @@ TResolvedConnectionSettings ResolveConnectionSettings(TConnectionParameters para
.Database = database,
.DataSourceName = std::move(dataSourceName),
.DriverConfig = std::move(driverConfig),
.AnsiSql = ansiSql == "1",
};
}

Expand Down
1 change: 1 addition & 0 deletions odbc/src/connection_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct TResolvedConnectionSettings {
std::string Database;
std::string DataSourceName;
TDriverConfig DriverConfig;
bool AnsiSql = false;
};
TConnectionParameters ParseAndNormalizeConnectionString(
std::string_view connectionString, std::vector<std::string>& ignoredAttributes);
Expand Down
6 changes: 4 additions & 2 deletions odbc/src/descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ using TRecordProperties = TScalarProperties<
TScalarProperty<SQL_DESC_CONCISE_TYPE, &TDescRecord::Type>,
TScalarProperty<SQL_DESC_LENGTH, &TDescRecord::Length>,
TScalarProperty<SQL_DESC_OCTET_LENGTH, &TDescRecord::OctetLength>,
TScalarProperty<SQL_DESC_DISPLAY_SIZE, &TDescRecord::Length, true, false>,
TScalarProperty<SQL_DESC_PRECISION, &TDescRecord::Precision>,
TScalarProperty<SQL_DESC_SCALE, &TDescRecord::Scale>,
TScalarProperty<SQL_DESC_NULLABLE, &TDescRecord::Nullable>,
Expand Down Expand Up @@ -174,6 +173,8 @@ SQLRETURN TDescriptor::GetDescField(SQLSMALLINT recNumber, SQLSMALLINT field, SQ
return *result;
}
switch (field) {
case SQL_DESC_DISPLAY_SIZE:
Comment thread
Shfdis marked this conversation as resolved.
Resolved
return WriteScalar(value, GetDisplaySize(record->Type, record->Length, record->Unsigned));
case SQL_DESC_BASE_COLUMN_NAME:
case SQL_DESC_NAME:
return Diag::WriteString<Diag::EStringWriteMode::Descriptor>(
Expand Down Expand Up @@ -202,7 +203,8 @@ SQLRETURN TDescriptor::GetDescField(SQLSMALLINT recNumber, SQLSMALLINT field, SQ
case SQL_DESC_UNNAMED:
return WriteScalar(value, static_cast<SQLSMALLINT>(
record->Name.empty() ? SQL_UNNAMED : SQL_NAMED));
case SQL_DESC_UNSIGNED: return WriteScalar(value, static_cast<SQLSMALLINT>(SQL_FALSE));
case SQL_DESC_UNSIGNED:
return WriteScalar(value, static_cast<SQLSMALLINT>(record->Unsigned ? SQL_TRUE : SQL_FALSE));
case SQL_DESC_UPDATABLE:
return WriteScalar(value, static_cast<SQLSMALLINT>(SQL_ATTR_READONLY));
default: return Diag::AddNotImplemented(*this);
Expand Down
4 changes: 4 additions & 0 deletions odbc/src/descriptor.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#pragma once

#include "utils/attr.h"
#include "utils/bindings.h"
#include "connection.h"

#include "odbc_compat.h"

#include <optional>
#include <string>
#include <vector>

Expand All @@ -29,12 +31,14 @@ struct TDescRecord {
SQLSMALLINT Precision = 0;
SQLSMALLINT Scale = 0;
SQLSMALLINT Nullable = SQL_NULLABLE;
bool Unsigned = false;
SQLPOINTER DataPtr = nullptr;
SQLLEN* IndicatorPtr = nullptr;
SQLLEN* OctetLengthPtr = nullptr;
SQLSMALLINT ParameterType = SQL_PARAM_INPUT;
bool Active = false;
bool Inferred = false;
std::optional<EWideTemporal> WideTemporalType;
};

struct TResolvedBinding {
Expand Down
6 changes: 4 additions & 2 deletions odbc/src/metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ struct TFunctionRange {
};

constexpr TFunctionRange kSupportedFunctions[] = {
{SQL_API_SQLBINDCOL, SQL_API_SQLDISCONNECT},
{SQL_API_SQLALLOCSTMT, SQL_API_SQLDISCONNECT},
Comment thread
Shfdis marked this conversation as resolved.
Resolved
Comment thread
Shfdis marked this conversation as resolved.
Resolved
{SQL_API_SQLEXECDIRECT, SQL_API_SQLFETCH},
{SQL_API_SQLFREESTMT, SQL_API_SQLSETCURSORNAME},
{SQL_API_SQLCOLUMNS, SQL_API_SQLDRIVERCONNECT},
Expand Down Expand Up @@ -312,12 +312,14 @@ SQLRETURN NMetadata::ColAttribute(TStatement* statement, SQLUSMALLINT columnNumb
case SQL_DESC_CONCISE_TYPE:
return WriteAttributeNumber(statement, column.SqlType, numericAttributePtr);
case SQL_DESC_LENGTH:
case SQL_DESC_DISPLAY_SIZE:
case SQL_DESC_OCTET_LENGTH:
case SQL_COLUMN_LENGTH:
case SQL_DESC_PRECISION:
case SQL_COLUMN_PRECISION:
return WriteAttributeNumber(statement, static_cast<SQLLEN>(column.Size), numericAttributePtr);
case SQL_DESC_DISPLAY_SIZE:
return WriteAttributeNumber(statement,
GetDisplaySize(column.SqlType, column.Size, column.Unsigned), numericAttributePtr);
case SQL_DESC_SCALE:
case SQL_COLUMN_SCALE:
return WriteAttributeNumber(statement, column.DecimalDigits, numericAttributePtr);
Expand Down
11 changes: 9 additions & 2 deletions odbc/src/odbc_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ SQLRETURN SQL_API SQLAllocHandle(SQLSMALLINT handleType,
}
}

SQLRETURN SQL_API SQLAllocStmt(SQLHDBC connectionHandle, SQLHSTMT* statementHandle) {
if (statementHandle) {
*statementHandle = SQL_NULL_HSTMT;
}
return Allocate<TStatement>(connectionHandle, statementHandle);
}

SQLRETURN SQL_API SQLFreeHandle(SQLSMALLINT handleType, SQLHANDLE handle) {
switch (handleType) {
case SQL_HANDLE_ENV: return Free<TEnvironment>(handle);
Expand Down Expand Up @@ -421,9 +428,9 @@ ODBC_FORWARD(SQLStatistics, TStatement, TStatement::Statistics,
ODBC_FORWARD(SQLSpecialColumns, TStatement, TStatement::SpecialColumns,
(SQLHSTMT statementHandle, SQLUSMALLINT identifierType, SQLCHAR* catalogName,
SQLSMALLINT nameLength1, SQLCHAR* schemaName, SQLSMALLINT nameLength2,
SQLCHAR* tableName, SQLSMALLINT nameLength3, SQLUSMALLINT scope, SQLUSMALLINT),
SQLCHAR* tableName, SQLSMALLINT nameLength3, SQLUSMALLINT scope, SQLUSMALLINT nullable),
(statementHandle, OptionalText(catalogName, nameLength1), OptionalText(schemaName, nameLength2),
OptionalText(tableName, nameLength3), identifierType, scope))
OptionalText(tableName, nameLength3), identifierType, scope, nullable))

ODBC_FORWARD(SQLColAttribute, TStatement, Odbc::NMetadata::ColAttribute,
(SQLHSTMT statementHandle, SQLUSMALLINT columnNumber, SQLUSMALLINT fieldIdentifier,
Expand Down
Loading
Loading