Skip to content

Commit 2794059

Browse files
quaesitor-scientiamPythonWillRuleclaude
authored
mssql, ci: fix Database CI mssql-driver-tests job (#26850)
* mssql: add tcc linux include path flag for unixODBC headers (fixes #26816) tcc does not search /usr/include by default, causing compilation failures when building the mssql module on Linux with the bundled tcc after unixodbc-dev is installed. Add `#flag linux -I/usr/include` under a `$if tinyc` guard so tcc can locate sql.h and sqlext.h. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * mssql: avoid DROP TABLE IF EXISTS to prevent FreeTDS protocol state pollution DROP TABLE IF EXISTS on a non-existent table causes SQL Server to send an informational TDS token. FreeTDS may not drain this token before the statement handle is freed, leaving the connection in a state where the next SQLAllocHandle(STMT) returns a handle that immediately gives SQL_INVALID_HANDLE on SQLExecDirect (no ODBC diagnostics). Replace with IF OBJECT_ID() IS NOT NULL DROP TABLE, which only sends a done token and avoids the spurious info message. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * ci: skip GPG dearmor if microsoft-prod.gpg already exists on runner Ubuntu 24.04 GitHub Actions runners ship with /usr/share/keyrings/microsoft-prod.gpg pre-installed. The unconditional `gpg --dearmor -o ...` fails with "File exists" because the file is already present. Guard the step so it only runs when the file is absent. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Richard Wheeler <18647491+PythonWillRule@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ef3eae9 commit 2794059

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎.github/workflows/db_ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
- name: Install ODBC dependencies
9797
run: |
9898
.github/workflows/disable_azure_mirror.sh
99-
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --batch --no-tty --dearmor -o /usr/share/keyrings/microsoft-prod.gpg
99+
[ -f /usr/share/keyrings/microsoft-prod.gpg ] || curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --batch --no-tty --dearmor -o /usr/share/keyrings/microsoft-prod.gpg
100100
curl -fsSL https://packages.microsoft.com/config/ubuntu/24.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
101101
./v retry -- sudo apt update
102102
sudo ACCEPT_EULA=Y apt install --quiet -y msodbcsql18 unixodbc-dev

‎vlib/db/mssql/_cdef_nix.c.v‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,11 @@ $if $pkgconfig('odbc') {
1313
#flag darwin -L/opt/local/lib
1414
}
1515

16+
$if tinyc {
17+
// tcc does not search system include paths by default; add /usr/include so
18+
// that it can find the unixODBC headers (sql.h, sqlext.h) on Linux.
19+
#flag linux -I/usr/include
20+
}
21+
1622
#include <sql.h>
1723
#include <sqlext.h>

‎vlib/db/mssql/mssql_test.v‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ fn test_connection_and_query() {
3535
conn.close()
3636
}
3737

38-
conn.query('drop table if exists vlang_mssql_test') or {}
38+
conn.query("if object_id('vlang_mssql_test', 'U') is not null drop table vlang_mssql_test") or {}
3939
defer {
40-
conn.query('drop table if exists vlang_mssql_test') or {}
40+
conn.query("if object_id('vlang_mssql_test', 'U') is not null drop table vlang_mssql_test") or {}
4141
}
4242

4343
create_result := conn.query('create table vlang_mssql_test (

0 commit comments

Comments
 (0)