From 132b9b8279009f980150c613635fabed3983e7b8 Mon Sep 17 00:00:00 2001 From: Paul Kulchenko Date: Fri, 14 Oct 2022 22:12:49 -0700 Subject: [PATCH] Add operation details to conflict handler in SQLite Lua API --- tool/net/lsqlite3.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tool/net/lsqlite3.c b/tool/net/lsqlite3.c index 945c787a7..490300ac0 100644 --- a/tool/net/lsqlite3.c +++ b/tool/net/lsqlite3.c @@ -1968,12 +1968,22 @@ static int db_changeset_conflict_callback( lua_State *L = db->L; int top = lua_gettop(L); int result, isint; + const char *zTab; + int nCol, Op, bIndirect; + + if (sqlite3changeset_op(p, &zTab, &nCol, &Op, &bIndirect) != LUA_OK) { + lua_pushliteral(L, "invalid return from changeset iterator"); + return lua_error(L); + } lua_rawgeti(L, LUA_REGISTRYINDEX, changeset_conflict_cb); /* get callback */ lua_rawgeti(L, LUA_REGISTRYINDEX, changeset_cb_udata); /* get callback user data */ lua_pushinteger(L, eConflict); + lua_pushstring(L, zTab); + lua_pushinteger(L, Op); + lua_pushboolean(L, bIndirect); - if (lua_pcall(L, 2, 1, 0) != LUA_OK) return lua_error(L); + if (lua_pcall(L, 5, 1, 0) != LUA_OK) return lua_error(L); result = lua_tointegerx(L, -1, &isint); /* use result if there was no error */ if (!isint) {