mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-01 06:27:03 +03:00
Added the last_insert_rowid() SQL function. (CVS 521)
FossilOrigin-Name: 6aca3f86bc08849e9d806fdd490f98e4daf71025
This commit is contained in:
18
manifest
18
manifest
@ -1,5 +1,5 @@
|
|||||||
C Make\sthe\sFROM\sclause\son\sa\sSELECT\soptional.\s\sIf\somitted,\sthe\sresult\sof\nthe\sSELECT\sis\sa\ssingle\srow\sconsisting\sof\sthe\svalues\sin\sthe\sexpression\slist.\s(CVS\s520)
|
C Added\sthe\slast_insert_rowid()\sSQL\sfunction.\s(CVS\s521)
|
||||||
D 2002-04-06T13:57:43
|
D 2002-04-06T14:10:47
|
||||||
F Makefile.in 50f1b3351df109b5774771350d8c1b8d3640130d
|
F Makefile.in 50f1b3351df109b5774771350d8c1b8d3640130d
|
||||||
F Makefile.template 89e373b2dad0321df00400fa968dc14b61a03296
|
F Makefile.template 89e373b2dad0321df00400fa968dc14b61a03296
|
||||||
F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
|
F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
|
||||||
@ -25,7 +25,7 @@ F src/btree.h 8abeabfe6e0b1a990b64fa457592a6482f6674f3
|
|||||||
F src/build.c d01b81f41481e733e27ab2fa8e1bfcc64f24257d
|
F src/build.c d01b81f41481e733e27ab2fa8e1bfcc64f24257d
|
||||||
F src/delete.c 577da499162291c1855f0b304b211bffcf9da945
|
F src/delete.c 577da499162291c1855f0b304b211bffcf9da945
|
||||||
F src/expr.c e7a1e22bc2ebcd789f0f8c0db544cf16ad664054
|
F src/expr.c e7a1e22bc2ebcd789f0f8c0db544cf16ad664054
|
||||||
F src/func.c 87516e7dc37190c24af77593931a5d09d797520a
|
F src/func.c dca9df811298cd0beb3724d40cee348e884352b2
|
||||||
F src/hash.c cc259475e358baaf299b00a2c7370f2b03dda892
|
F src/hash.c cc259475e358baaf299b00a2c7370f2b03dda892
|
||||||
F src/hash.h dca065dda89d4575f3176e75e9a3dc0f4b4fb8b9
|
F src/hash.h dca065dda89d4575f3176e75e9a3dc0f4b4fb8b9
|
||||||
F src/insert.c 903ff262c90586c99eafd43934517bc3aed5f77e
|
F src/insert.c 903ff262c90586c99eafd43934517bc3aed5f77e
|
||||||
@ -64,7 +64,7 @@ F test/conflict.test c794c6c8f6e59918107dbab2d201ae454bb47db8
|
|||||||
F test/copy.test b3cefcb520c64d7e7dfedbab06b4d4c31fa5b99a
|
F test/copy.test b3cefcb520c64d7e7dfedbab06b4d4c31fa5b99a
|
||||||
F test/delete.test c904a62129fe102b314a96111a8417f10249e4d8
|
F test/delete.test c904a62129fe102b314a96111a8417f10249e4d8
|
||||||
F test/expr.test 846795016b5993a7411f772eebe82ab67bd7230a
|
F test/expr.test 846795016b5993a7411f772eebe82ab67bd7230a
|
||||||
F test/func.test 4359344586067e79abf4c710c4737d67ed3cf963
|
F test/func.test d34e461f0acb0cf2978a4b3a3e098460f2ea8fbc
|
||||||
F test/in.test c09312672e3f0709fa02c8e2e9cd8fb4bd6269aa
|
F test/in.test c09312672e3f0709fa02c8e2e9cd8fb4bd6269aa
|
||||||
F test/index.test c8a471243bbf878974b99baf5badd59407237cf3
|
F test/index.test c8a471243bbf878974b99baf5badd59407237cf3
|
||||||
F test/insert.test c36d534a4ab58c2cd452a273e51b2b0dd1ede1f9
|
F test/insert.test c36d534a4ab58c2cd452a273e51b2b0dd1ede1f9
|
||||||
@ -116,7 +116,7 @@ F www/arch.fig d5f9752a4dbf242e9cfffffd3f5762b6c63b3bcf
|
|||||||
F www/arch.png 82ef36db1143828a7abc88b1e308a5f55d4336f4
|
F www/arch.png 82ef36db1143828a7abc88b1e308a5f55d4336f4
|
||||||
F www/arch.tcl 72a0c80e9054cc7025a50928d28d9c75c02c2b8b
|
F www/arch.tcl 72a0c80e9054cc7025a50928d28d9c75c02c2b8b
|
||||||
F www/c_interface.tcl 567cda531aac9d68a61ef02e26c6b202bd856db2
|
F www/c_interface.tcl 567cda531aac9d68a61ef02e26c6b202bd856db2
|
||||||
F www/changes.tcl 765719e4e445b1c6b60d1d3cfeed65570cb9d877
|
F www/changes.tcl 4083f03195f0ae36411e095a2d18e5fb4a3c40d9
|
||||||
F www/conflict.tcl 81dd21f9a679e60aae049e9dd8ab53d59570cda2
|
F www/conflict.tcl 81dd21f9a679e60aae049e9dd8ab53d59570cda2
|
||||||
F www/crosscompile.tcl 3622ebbe518927a3854a12de51344673eb2dd060
|
F www/crosscompile.tcl 3622ebbe518927a3854a12de51344673eb2dd060
|
||||||
F www/download.tcl 29aa6679ca29621d10613f60ebbbda18f4b91c49
|
F www/download.tcl 29aa6679ca29621d10613f60ebbbda18f4b91c49
|
||||||
@ -124,14 +124,14 @@ F www/dynload.tcl 02eb8273aa78cfa9070dd4501dca937fb22b466c
|
|||||||
F www/faq.tcl fb1e92e2f604546694f83a36d969492f52fb685d
|
F www/faq.tcl fb1e92e2f604546694f83a36d969492f52fb685d
|
||||||
F www/formatchng.tcl 2ce21ff30663fad6618198fe747ce675df577590
|
F www/formatchng.tcl 2ce21ff30663fad6618198fe747ce675df577590
|
||||||
F www/index.tcl 2a9653ebeeaba3aca3401f476ba0e0e4acb40929
|
F www/index.tcl 2a9653ebeeaba3aca3401f476ba0e0e4acb40929
|
||||||
F www/lang.tcl 52a54be934dcbc6ec314c12bcdd4cf899ca54904
|
F www/lang.tcl 75615f1acd8a428d93546ad9edfbf8f78ee1e2df
|
||||||
F www/mingw.tcl f1c7c0a7f53387dd9bb4f8c7e8571b7561510ebc
|
F www/mingw.tcl f1c7c0a7f53387dd9bb4f8c7e8571b7561510ebc
|
||||||
F www/opcode.tcl bdec8ef9f100dbd87bbef8976c54b88e43fd8ccc
|
F www/opcode.tcl bdec8ef9f100dbd87bbef8976c54b88e43fd8ccc
|
||||||
F www/speed.tcl da8afcc1d3ccc5696cfb388a68982bc3d9f7f00f
|
F www/speed.tcl da8afcc1d3ccc5696cfb388a68982bc3d9f7f00f
|
||||||
F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279
|
F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279
|
||||||
F www/tclsqlite.tcl 829b393d1ab187fd7a5e978631b3429318885c49
|
F www/tclsqlite.tcl 829b393d1ab187fd7a5e978631b3429318885c49
|
||||||
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
|
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
|
||||||
P 932274187e045ce331177b1a640ed62da4a22d94
|
P 28ce42f7872e2660faa22e66b508db9b1f046af0
|
||||||
R 3cad40d6183414669ab6e27b1970fbd2
|
R 0b5a813afe2cf2bdabedc7aeca66c0d3
|
||||||
U drh
|
U drh
|
||||||
Z b7a9666e501a84ef150d099ac582d5f8
|
Z 679d6245f83771ba2f6bf195e2401218
|
||||||
|
@ -1 +1 @@
|
|||||||
28ce42f7872e2660faa22e66b508db9b1f046af0
|
6aca3f86bc08849e9d806fdd490f98e4daf71025
|
13
src/func.c
13
src/func.c
@ -16,7 +16,7 @@
|
|||||||
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
|
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
|
||||||
** All other code has file scope.
|
** All other code has file scope.
|
||||||
**
|
**
|
||||||
** $Id: func.c,v 1.14 2002/03/04 02:26:16 drh Exp $
|
** $Id: func.c,v 1.15 2002/04/06 14:10:47 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@ -196,6 +196,15 @@ static void randomFunc(sqlite_func *context, int argc, const char **argv){
|
|||||||
sqlite_set_result_int(context, sqliteRandomInteger());
|
sqlite_set_result_int(context, sqliteRandomInteger());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Implementation of the last_insert_rowid() SQL function. The return
|
||||||
|
** value is the same as the sqlite_last_insert_rowid() API function.
|
||||||
|
*/
|
||||||
|
static void last_insert_rowid(sqlite_func *context, int arg, char **argv){
|
||||||
|
sqlite *db = sqlite_user_data(context);
|
||||||
|
sqlite_set_result_int(context, sqlite_last_insert_rowid(db));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** An instance of the following structure holds the context of a
|
** An instance of the following structure holds the context of a
|
||||||
** sum() or avg() aggregate computation.
|
** sum() or avg() aggregate computation.
|
||||||
@ -408,6 +417,8 @@ void sqliteRegisterBuildinFunctions(sqlite *db){
|
|||||||
sqlite_create_function(db, aFuncs[i].zName,
|
sqlite_create_function(db, aFuncs[i].zName,
|
||||||
aFuncs[i].nArg, aFuncs[i].xFunc, 0);
|
aFuncs[i].nArg, aFuncs[i].xFunc, 0);
|
||||||
}
|
}
|
||||||
|
sqlite_create_function(db, "last_insert_rowid", 0,
|
||||||
|
last_insert_rowid, db);
|
||||||
for(i=0; i<sizeof(aAggs)/sizeof(aAggs[0]); i++){
|
for(i=0; i<sizeof(aAggs)/sizeof(aAggs[0]); i++){
|
||||||
sqlite_create_aggregate(db, aAggs[i].zName,
|
sqlite_create_aggregate(db, aAggs[i].zName,
|
||||||
aAggs[i].nArg, aAggs[i].xStep, aAggs[i].xFinalize, 0);
|
aAggs[i].nArg, aAggs[i].xStep, aAggs[i].xFinalize, 0);
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
# This file implements regression tests for SQLite library. The
|
# This file implements regression tests for SQLite library. The
|
||||||
# focus of this file is testing built-in functions.
|
# focus of this file is testing built-in functions.
|
||||||
#
|
#
|
||||||
# $Id: func.test,v 1.9 2002/03/02 17:04:09 drh Exp $
|
# $Id: func.test,v 1.10 2002/04/06 14:10:47 drh Exp $
|
||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
@ -230,5 +230,11 @@ do_test func-6.2 {
|
|||||||
execsql {SELECT coalesce(upper(a),'nil') FROM t2}
|
execsql {SELECT coalesce(upper(a),'nil') FROM t2}
|
||||||
} {1 nil 345 nil 67890}
|
} {1 nil 345 nil 67890}
|
||||||
|
|
||||||
|
# Test the last_insert_rowid() function
|
||||||
|
#
|
||||||
|
do_test func-7.1 {
|
||||||
|
execsql {SELECT last_insert_rowid()}
|
||||||
|
} [db last_insert_rowid]
|
||||||
|
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
@ -25,10 +25,11 @@ proc chng {date desc} {
|
|||||||
puts "<DD><P><UL>$desc</UL></P></DD>"
|
puts "<DD><P><UL>$desc</UL></P></DD>"
|
||||||
}
|
}
|
||||||
|
|
||||||
chng {2002 Apr 03 (2.4.7)} {
|
chng {2002 Apr 06 (2.4.7)} {
|
||||||
<li>Add the ability to put TABLE.* in the column list of a
|
<li>Add the ability to put TABLE.* in the column list of a
|
||||||
SELECT statement.</li>
|
SELECT statement.</li>
|
||||||
<li>Permit SELECT statements without a FROM clause.</li>
|
<li>Permit SELECT statements without a FROM clause.</li>
|
||||||
|
<li>Added the <b>last_insert_rowid()</b> SQL function.</li>
|
||||||
}
|
}
|
||||||
|
|
||||||
chng {2002 Apr 02 (2.4.6)} {
|
chng {2002 Apr 02 (2.4.6)} {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Run this Tcl script to generate the sqlite.html file.
|
# Run this Tcl script to generate the sqlite.html file.
|
||||||
#
|
#
|
||||||
set rcsid {$Id: lang.tcl,v 1.30 2002/04/06 13:57:44 drh Exp $}
|
set rcsid {$Id: lang.tcl,v 1.31 2002/04/06 14:10:48 drh Exp $}
|
||||||
|
|
||||||
puts {<html>
|
puts {<html>
|
||||||
<head>
|
<head>
|
||||||
@ -566,6 +566,13 @@ their result across all rows of the result set.</p>
|
|||||||
all arguments are NULL then NULL is returned.</td>
|
all arguments are NULL then NULL is returned.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td valign="top" align="right">last_insert_rowid()</td>
|
||||||
|
<td valign="top">Return the ROWID of the last row insert from this
|
||||||
|
connection to the database. This is the same value that would be returned
|
||||||
|
from the <b>sqlite_last_insert_rowid()</b> API function.</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" align="right">length(<i>X</i>)</td>
|
<td valign="top" align="right">length(<i>X</i>)</td>
|
||||||
<td valign="top">Return the string length of <i>X</i> in characters.
|
<td valign="top">Return the string length of <i>X</i> in characters.
|
||||||
|
Reference in New Issue
Block a user