Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Added the last_insert_rowid() SQL function. (CVS 521) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
6aca3f86bc08849e9d806fdd490f98e4 |
User & Date: | drh 2002-04-06 14:10:47.000 |
Context
2002-04-08
| ||
02:42 | Add a -column option to the sqlite command-line utility. Patch from Matthew O. Persico. (CVS 522) (check-in: 760bf568c8 user: drh tags: trunk) | |
2002-04-06
| ||
14:10 | Added the last_insert_rowid() SQL function. (CVS 521) (check-in: 6aca3f86bc user: drh tags: trunk) | |
13:57 | Make the FROM clause on a SELECT optional. If omitted, the result of the SELECT is a single row consisting of the values in the expression list. (CVS 520) (check-in: 28ce42f787 user: drh tags: trunk) | |
Changes
Changes to src/func.c.
︙ | ︙ | |||
12 13 14 15 16 17 18 | ** This file contains the C functions that implement various SQL ** functions of SQLite. ** ** There is only one exported symbol in this file - the function ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ** This file contains the C functions that implement various SQL ** functions of SQLite. ** ** There is only one exported symbol in this file - the function ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** ** $Id: func.c,v 1.15 2002/04/06 14:10:47 drh Exp $ */ #include <ctype.h> #include <math.h> #include <stdlib.h> #include <assert.h> #include "sqliteInt.h" |
︙ | ︙ | |||
191 192 193 194 195 196 197 198 199 200 201 202 203 204 | /* ** Implementation of random(). Return a random integer. */ static void randomFunc(sqlite_func *context, int argc, const char **argv){ sqlite_set_result_int(context, sqliteRandomInteger()); } /* ** An instance of the following structure holds the context of a ** sum() or avg() aggregate computation. */ typedef struct SumCtx SumCtx; struct SumCtx { | > > > > > > > > > | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | /* ** Implementation of random(). Return a random integer. */ static void randomFunc(sqlite_func *context, int argc, const char **argv){ 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 ** sum() or avg() aggregate computation. */ typedef struct SumCtx SumCtx; struct SumCtx { |
︙ | ︙ | |||
404 405 406 407 408 409 410 411 412 413 414 415 | }; int i; for(i=0; i<sizeof(aFuncs)/sizeof(aFuncs[0]); i++){ sqlite_create_function(db, aFuncs[i].zName, aFuncs[i].nArg, aFuncs[i].xFunc, 0); } for(i=0; i<sizeof(aAggs)/sizeof(aAggs[0]); i++){ sqlite_create_aggregate(db, aAggs[i].zName, aAggs[i].nArg, aAggs[i].xStep, aAggs[i].xFinalize, 0); } } | > > | 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | }; int i; for(i=0; i<sizeof(aFuncs)/sizeof(aFuncs[0]); i++){ sqlite_create_function(db, aFuncs[i].zName, 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++){ sqlite_create_aggregate(db, aAggs[i].zName, aAggs[i].nArg, aAggs[i].xStep, aAggs[i].xFinalize, 0); } } |
Changes to test/func.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing built-in functions. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing built-in functions. # # $Id: func.test,v 1.10 2002/04/06 14:10:47 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Create a table to work with. # do_test func-0.0 { |
︙ | ︙ | |||
225 226 227 228 229 230 231 232 233 234 | # do_test func-6.1 { execsql {SELECT coalesce(a,'xyz') FROM t2} } {1 xyz 345 xyz 67890} do_test func-6.2 { execsql {SELECT coalesce(upper(a),'nil') FROM t2} } {1 nil 345 nil 67890} finish_test | > > > > > > | 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | # do_test func-6.1 { execsql {SELECT coalesce(a,'xyz') FROM t2} } {1 xyz 345 xyz 67890} do_test func-6.2 { execsql {SELECT coalesce(upper(a),'nil') FROM t2} } {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 |
Changes to www/changes.tcl.
︙ | ︙ | |||
21 22 23 24 25 26 27 | proc chng {date desc} { puts "<DT><B>$date</B></DT>" puts "<DD><P><UL>$desc</UL></P></DD>" } | | > | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | proc chng {date desc} { puts "<DT><B>$date</B></DT>" puts "<DD><P><UL>$desc</UL></P></DD>" } chng {2002 Apr 06 (2.4.7)} { <li>Add the ability to put TABLE.* in the column list of a SELECT statement.</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)} { <li>Bug fix: Correctly handle terms in the WHERE clause of a join that do not contain a comparison operator.</li> } |
︙ | ︙ |
Changes to www/lang.tcl.
1 2 3 | # # Run this Tcl script to generate the sqlite.html file. # | | | 1 2 3 4 5 6 7 8 9 10 11 | # # Run this Tcl script to generate the sqlite.html file. # set rcsid {$Id: lang.tcl,v 1.31 2002/04/06 14:10:48 drh Exp $} puts {<html> <head> <title>Query Language Understood By SQLite</title> </head> <body bgcolor=white> <h1 align=center> |
︙ | ︙ | |||
562 563 564 565 566 567 568 569 570 571 572 573 574 575 | <tr> <td valign="top" align="right">coalesce(<i>X</i>,<i>Y</i>,...)</td> <td valign="top">Return a copy of the first non-NULL argument. If all arguments are NULL then NULL is returned.</td> </tr> <tr> <td valign="top" align="right">length(<i>X</i>)</td> <td valign="top">Return the string length of <i>X</i> in characters. If SQLite is configured to support UTF-8, then the number of UTF-8 characters is returned, not the number of bytes.</td> </tr> | > > > > > > > | 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 | <tr> <td valign="top" align="right">coalesce(<i>X</i>,<i>Y</i>,...)</td> <td valign="top">Return a copy of the first non-NULL argument. If all arguments are NULL then NULL is returned.</td> </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> <td valign="top" align="right">length(<i>X</i>)</td> <td valign="top">Return the string length of <i>X</i> in characters. If SQLite is configured to support UTF-8, then the number of UTF-8 characters is returned, not the number of bytes.</td> </tr> |
︙ | ︙ |