1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Arrange for sqlite3_last_insert_rowid() to work with virtual tables. (CVS 3259)

FossilOrigin-Name: afa39a46320e9996a5478ea6e19eb4c2014327ac
This commit is contained in:
danielk1977
2006-06-16 06:17:47 +00:00
parent dbf5a848c6
commit 1f6eec547c
8 changed files with 139 additions and 27 deletions

View File

@@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
** $Id: test8.c,v 1.23 2006/06/15 15:38:42 danielk1977 Exp $
** $Id: test8.c,v 1.24 2006/06/16 06:17:47 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
@@ -512,7 +512,12 @@ static void string_concat(char **pzStr, char *zAppend, int doFree){
** NULL INTEGER (nCol args) INSERT (incl. rowid value)
**
*/
int echoUpdate(sqlite3_vtab *tab, int nData, sqlite3_value **apData){
int echoUpdate(
sqlite3_vtab *tab,
int nData,
sqlite3_value **apData,
sqlite_int64 *pRowid
){
echo_vtab *pVtab = (echo_vtab *)tab;
sqlite3 *db = pVtab->db;
int rc = SQLITE_OK;
@@ -557,7 +562,7 @@ int echoUpdate(sqlite3_vtab *tab, int nData, sqlite3_value **apData){
int ii;
char *zInsert = 0;
char *zValues = 0;
zInsert = sqlite3_mprintf("INSERT OR REPLACE INTO %Q (", pVtab->zTableName);
if( sqlite3_value_type(apData[1])==SQLITE_INTEGER ){
bindArgOne = 1;
@@ -602,6 +607,10 @@ int echoUpdate(sqlite3_vtab *tab, int nData, sqlite3_value **apData){
rc = sqlite3_finalize(pStmt);
}
if( pRowid && rc==SQLITE_OK ){
*pRowid = sqlite3_last_insert_rowid(db);
}
return rc;
}