mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-08 10:50:28 +00:00
Add pk/fk_conflicts iterator methods to SQLite Lua API
This commit is contained in:
parent
284afb72a0
commit
0dcce516a8
1 changed files with 28 additions and 0 deletions
|
@ -1896,6 +1896,32 @@ static int liter_conflict(lua_State *L) {
|
||||||
return liter_table(L, sqlite3changeset_conflict);
|
return liter_table(L, sqlite3changeset_conflict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int liter_fk_conflicts(lua_State *L) {
|
||||||
|
int rc, nOut;
|
||||||
|
liter *litr = lsqlite_checkiter(L, 1);
|
||||||
|
if ((rc = sqlite3changeset_fk_conflicts(litr->itr, &nOut)) != LUA_OK) {
|
||||||
|
return pusherr(L, rc);
|
||||||
|
}
|
||||||
|
lua_pushinteger(L, nOut);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int liter_pk(lua_State *L) {
|
||||||
|
const char *zTab;
|
||||||
|
int n, rc, nCol;
|
||||||
|
unsigned char *abPK;
|
||||||
|
liter *litr = lsqlite_checkiter(L, 1);
|
||||||
|
if ((rc = sqlite3changeset_pk(litr->itr, &abPK, &nCol)) != LUA_OK) {
|
||||||
|
return pusherr(L, rc);
|
||||||
|
}
|
||||||
|
lua_createtable(L, nCol, 0);
|
||||||
|
for (n = 0; n < nCol; n++) {
|
||||||
|
lua_pushboolean(L, abPK[n]);
|
||||||
|
lua_rawseti(L, -2, n+1);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** =======================================================
|
** =======================================================
|
||||||
** Rebaser functions (for session support)
|
** Rebaser functions (for session support)
|
||||||
|
@ -2626,9 +2652,11 @@ static const luaL_Reg reblib[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const luaL_Reg itrlib[] = {
|
static const luaL_Reg itrlib[] = {
|
||||||
|
{"pk", liter_pk },
|
||||||
{"new", liter_new },
|
{"new", liter_new },
|
||||||
{"old", liter_old },
|
{"old", liter_old },
|
||||||
{"conflict", liter_conflict },
|
{"conflict", liter_conflict },
|
||||||
|
{"fk_conflicts", liter_fk_conflicts },
|
||||||
|
|
||||||
{"__tostring", liter_tostring },
|
{"__tostring", liter_tostring },
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue