MCPcopy Create free account
hub / github.com/asg017/sqlite-vss / shadow_data_insert

Function shadow_data_insert

src/sqlite-vss.cpp:416–467  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

414}
415
416static int shadow_data_insert(sqlite3 *db,
417 char *schema,
418 char *name,
419 sqlite3_int64 *rowid,
420 sqlite3_int64 *retRowid) {
421
422 sqlite3_stmt *stmt;
423
424 if (rowid == nullptr) {
425
426 auto sql = sqlite3_mprintf(
427 "insert into \"%w\".\"%w_data\"(_) values (?)", schema, name);
428
429 int rc = sqlite3_prepare_v2(db, sql, -1, &stmt, 0);
430 sqlite3_free(sql);
431
432 if (rc != SQLITE_OK || stmt == nullptr) {
433 return SQLITE_ERROR;
434 }
435
436 sqlite3_bind_null(stmt, 1);
437 if (sqlite3_step(stmt) != SQLITE_DONE) {
438 sqlite3_finalize(stmt);
439 return SQLITE_ERROR;
440 }
441
442 } else {
443
444 auto sql = sqlite3_mprintf(
445 "insert into \"%w\".\"%w_data\"(rowid, _) values (?, ?);", schema,
446 name);
447
448 int rc = sqlite3_prepare_v2(db, sql, -1, &stmt, 0);
449 sqlite3_free(sql);
450
451 if (rc != SQLITE_OK || stmt == nullptr)
452 return SQLITE_ERROR;
453
454 sqlite3_bind_int64(stmt, 1, *rowid);
455 sqlite3_bind_null(stmt, 2);
456 if (sqlite3_step(stmt) != SQLITE_DONE) {
457 sqlite3_finalize(stmt);
458 return SQLITE_ERROR;
459 }
460
461 if (retRowid != nullptr)
462 *retRowid = sqlite3_last_insert_rowid(db);
463 }
464
465 sqlite3_finalize(stmt);
466 return SQLITE_OK;
467}
468
469static int shadow_data_delete(sqlite3 *db,
470 char *schema,

Callers 1

vssIndexUpdateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected