Implement a "counter" SQL function that can be used to insert a sequence
number each row of a result set. Currently in the test harness only, but a candidate to move into the core. (CVS 5614) FossilOrigin-Name: c84d46c71233bbf869513f433b1d18cbd7f2a35e
This commit is contained in:
parent
229cf702f0
commit
1a4e3162d9
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Do\snot\sflatten\ssubqueries\swhere\sthe\ssubquery\shas\sa\sLIMIT\sand\sthe\souter\nquery\shas\sa\sWHERE\sclause.\s\sTicket\s#3334.\s(CVS\s5613)
|
||||
D 2008-08-26T12:56:14
|
||||
C Implement\sa\s"counter"\sSQL\sfunction\sthat\scan\sbe\sused\sto\sinsert\sa\ssequence\nnumber\seach\srow\sof\sa\sresult\sset.\s\sCurrently\sin\sthe\stest\sharness\sonly,\sbut\na\scandidate\sto\smove\sinto\sthe\score.\s(CVS\s5614)
|
||||
D 2008-08-26T14:42:15
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in 689e14735f862a5553bceef206d8c13e29504e44
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -168,7 +168,7 @@ F src/test_autoext.c f53b0cdf7bf5f08100009572a5d65cdb540bd0ad
|
||||
F src/test_btree.c 7170e0c922ed3979f2d38f4a3f84728e5740dfc3
|
||||
F src/test_config.c 224f699a34d45eb8ac5c22a7ad6cdbb8edf0ba28
|
||||
F src/test_devsym.c 6012cb8e3acf812513511025a4fa5d626e0ba19b
|
||||
F src/test_func.c df7ddd5abfc5c8d6cd3e36ae9ecb0c276b0e9039
|
||||
F src/test_func.c 18c727c11461a21bc2ef404a32672517f6eb7587
|
||||
F src/test_hexio.c 2f1122aa3f012fa0142ee3c36ce5c902a70cd12f
|
||||
F src/test_loadext.c 97dc8800e46a46ed002c2968572656f37e9c0dd9
|
||||
F src/test_malloc.c 49abbf5d9c71fb06cf7a7cf96f9b9a799b77a421
|
||||
@ -624,7 +624,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
P 3b6ffb4492b6c43897692c49dcccbfb55963a46c
|
||||
R 0ea5c2219f101d8498478c6075393d46
|
||||
P 4995a1d1c9530be9ce647d338169620cd95a72eb
|
||||
R 53057febb14c48765135eac34d009c5b
|
||||
U drh
|
||||
Z 5e5db29fb87e2cab5c4bf06a60b36872
|
||||
Z 0de0cfc7bacf48ec9c7d1199a1a02018
|
||||
|
@ -1 +1 @@
|
||||
4995a1d1c9530be9ce647d338169620cd95a72eb
|
||||
c84d46c71233bbf869513f433b1d18cbd7f2a35e
|
@ -12,7 +12,7 @@
|
||||
** Code for testing all sorts of SQLite interfaces. This code
|
||||
** implements new SQL functions used by the test scripts.
|
||||
**
|
||||
** $Id: test_func.c,v 1.10 2008/08/02 03:50:39 drh Exp $
|
||||
** $Id: test_func.c,v 1.11 2008/08/26 14:42:15 drh Exp $
|
||||
*/
|
||||
#include "sqlite3.h"
|
||||
#include "tcl.h"
|
||||
@ -206,6 +206,36 @@ static void test_error(
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Implementation of the counter(X) function. If X is an integer
|
||||
** constant, then the first invocation will return X. The second X+1.
|
||||
** and so forth. Can be used (for example) to provide a sequence number
|
||||
** in a result set.
|
||||
*/
|
||||
static void counterFunc(
|
||||
sqlite3_context *pCtx, /* Function context */
|
||||
int nArg, /* Number of function arguments */
|
||||
sqlite3_value **argv /* Values for all function arguments */
|
||||
){
|
||||
int i;
|
||||
int *pCounter;
|
||||
|
||||
pCounter = (int*)sqlite3_get_auxdata(pCtx, 0);
|
||||
if( pCounter==0 ){
|
||||
pCounter = sqlite3_malloc( sizeof(*pCounter) );
|
||||
if( pCounter==0 ){
|
||||
sqlite3_result_error_nomem(pCtx);
|
||||
return;
|
||||
}
|
||||
*pCounter = sqlite3_value_int(argv[0]);
|
||||
sqlite3_set_auxdata(pCtx, 0, pCounter, sqlite3_free);
|
||||
}else{
|
||||
++*pCounter;
|
||||
}
|
||||
sqlite3_result_int(pCtx, *pCounter);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** This function takes two arguments. It performance UTF-8/16 type
|
||||
** conversions on the first argument then returns a copy of the second
|
||||
@ -283,6 +313,7 @@ static int registerTestFunctions(sqlite3 *db){
|
||||
{ "test_error", 2, SQLITE_UTF8, test_error},
|
||||
{ "test_eval", 1, SQLITE_UTF8, test_eval},
|
||||
{ "test_isolation", 2, SQLITE_UTF8, test_isolation},
|
||||
{ "test_counter", 1, SQLITE_UTF8, counterFunc},
|
||||
};
|
||||
int i;
|
||||
extern int Md5_Register(sqlite3*);
|
||||
|
Loading…
x
Reference in New Issue
Block a user