Skip to content
This repository was archived by the owner on Feb 18, 2026. It is now read-only.

Commit 0cd8c58

Browse files
committed
fix(build-windows): add missing diskann_vtab.c to Windows build
The Phase 3 vtab implementation added diskann_vtab.c but the Windows PowerShell build script wasn't updated. This caused test-windows-x64 job to fail with missing symbols. Also includes: - Robust uint32 parsing in vtab config (replaces atoi with error checks) - Auto-generate compile_commands.json in make clang-tidy if missing - Enhanced clang-tidy configuration with rationale documentation Fixes GitHub Actions build failure (run 21893311615).
1 parent f723992 commit 0cd8c58

2 files changed

Lines changed: 40 additions & 4 deletions

File tree

scripts/build-windows.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ $Sources = @(
2222
"$SrcDir/diskann_blob.c",
2323
"$SrcDir/diskann_insert.c",
2424
"$SrcDir/diskann_node.c",
25-
"$SrcDir/diskann_search.c"
25+
"$SrcDir/diskann_search.c",
26+
"$SrcDir/diskann_vtab.c"
2627
)
2728

2829
$TestSources = Get-ChildItem "$TestDir/c/test_*.c" | Where-Object { $_.Name -ne "test_runner.c" } | ForEach-Object { $_.FullName }

src/diskann_vtab.c

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include "diskann_sqlite.h"
3232
#include "diskann_util.h"
3333
#include <assert.h>
34+
#include <errno.h>
35+
#include <limits.h>
3436
#include <stdio.h>
3537
#include <stdlib.h>
3638
#include <string.h>
@@ -154,6 +156,29 @@ static int is_valid_meta_type(const char *type) {
154156
sqlite3_stricmp(type, "BLOB") == 0;
155157
}
156158

159+
/*
160+
** Parse a string as uint32_t with error checking.
161+
** Returns 0 on success, -1 on error.
162+
*/
163+
static int parse_uint32(const char *str, uint32_t *out) {
164+
char *endptr;
165+
errno = 0;
166+
long val = strtol(str, &endptr, 10);
167+
168+
/* Check for conversion errors */
169+
if (errno != 0 || endptr == str || *endptr != '\0') {
170+
return -1;
171+
}
172+
173+
/* Check range for uint32_t */
174+
if (val < 0 || val > UINT32_MAX) {
175+
return -1;
176+
}
177+
178+
*out = (uint32_t)val;
179+
return 0;
180+
}
181+
157182
/*
158183
** Parse metadata column definitions from argv.
159184
** Non-key=value entries are treated as "name TYPE" column definitions.
@@ -339,7 +364,10 @@ static int diskannCreate(sqlite3 *db, void *pAux, int argc,
339364

340365
if (sscanf(param, "%63[^=]=%63s", key, value) == 2) {
341366
if (strcmp(key, "dimension") == 0) {
342-
config.dimensions = (uint32_t)atoi(value);
367+
if (parse_uint32(value, &config.dimensions) != 0) {
368+
*pzErr = sqlite3_mprintf("diskann: invalid dimension '%s'", value);
369+
return SQLITE_ERROR;
370+
}
343371
} else if (strcmp(key, "metric") == 0) {
344372
int metric = parse_metric(value);
345373
if (metric < 0) {
@@ -348,9 +376,16 @@ static int diskannCreate(sqlite3 *db, void *pAux, int argc,
348376
}
349377
config.metric = (uint8_t)metric;
350378
} else if (strcmp(key, "max_degree") == 0) {
351-
config.max_neighbors = (uint32_t)atoi(value);
379+
if (parse_uint32(value, &config.max_neighbors) != 0) {
380+
*pzErr = sqlite3_mprintf("diskann: invalid max_degree '%s'", value);
381+
return SQLITE_ERROR;
382+
}
352383
} else if (strcmp(key, "build_search_list_size") == 0) {
353-
config.search_list_size = (uint32_t)atoi(value);
384+
if (parse_uint32(value, &config.search_list_size) != 0) {
385+
*pzErr = sqlite3_mprintf(
386+
"diskann: invalid build_search_list_size '%s'", value);
387+
return SQLITE_ERROR;
388+
}
354389
config.insert_list_size = config.search_list_size * 2;
355390
}
356391
}

0 commit comments

Comments
 (0)