Fix eponymous virtual tables so that they do not automatically make the first

column the rowid.  Enhance the generate_series virtual table to support rowid.

FossilOrigin-Name: a325a08599759471047e234ef9cfcc3cb110aafd
This commit is contained in:
drh 2015-08-19 19:01:28 +00:00
parent bc550df32f
commit 509c3fc004
5 changed files with 20 additions and 10 deletions

View File

@ -84,6 +84,7 @@ typedef struct series_cursor series_cursor;
struct series_cursor {
sqlite3_vtab_cursor base; /* Base class - must be first */
int isDesc; /* True to count down rather than up */
sqlite3_int64 iRowid; /* The rowid */
sqlite3_int64 iValue; /* Current value ("value") */
sqlite3_int64 mnValue; /* Mimimum value ("start") */
sqlite3_int64 mxValue; /* Maximum value ("stop") */
@ -165,6 +166,7 @@ static int seriesNext(sqlite3_vtab_cursor *cur){
}else{
pCur->iValue += pCur->iStep;
}
pCur->iRowid++;
return SQLITE_OK;
}
@ -195,7 +197,7 @@ static int seriesColumn(
*/
static int seriesRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){
series_cursor *pCur = (series_cursor*)cur;
*pRowid = pCur->iValue;
*pRowid = pCur->iRowid;
return SQLITE_OK;
}
@ -266,6 +268,7 @@ static int seriesFilter(
pCur->isDesc = 0;
pCur->iValue = pCur->mnValue;
}
pCur->iRowid = 1;
return SQLITE_OK;
}

View File

@ -1,5 +1,5 @@
C Improved\scomments\son\sthe\sgenerate_series\svirtual\stable.\s\sTest\scases\sfor\nORDER\sBY\srowid\sDESC\swith\sgenerate_series.
D 2015-08-19T18:19:49.786
C Fix\seponymous\svirtual\stables\sso\sthat\sthey\sdo\snot\sautomatically\smake\sthe\sfirst\ncolumn\sthe\srowid.\s\sEnhance\sthe\sgenerate_series\svirtual\stable\sto\ssupport\srowid.
D 2015-08-19T19:01:28.078
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 4f663b6b4954b9b1eb0e6f08387688a93b57542d
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -196,7 +196,7 @@ F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342
F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63
F ext/misc/regexp.c af92cdaa5058fcec1451e49becc7ba44dba023dc
F ext/misc/rot13.c 1ac6f95f99b575907b9b09c81a349114cf9be45a
F ext/misc/series.c 1484bc674b5cd0fcf18cb803514101799800c0c8
F ext/misc/series.c 5b84c6584af085b55ae07e2ee7b133b6db03e323
F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52
F ext/misc/spellfix.c 86998fb73aefb7b5dc346ba8a58912f312da4996
F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512
@ -408,7 +408,7 @@ F src/vdbeblob.c 4f2e8e075d238392df98c5e03a64342465b03f90
F src/vdbemem.c ae38a0d35ae71cf604381a887c170466ba518090
F src/vdbesort.c f5009e7a35e3065635d8918b9a31f498a499976b
F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0
F src/vtab.c 1e3405f78e9f248bdee6ef7a8903fadaa7222f9c
F src/vtab.c 05395350f947ec0b1af25e8502b9cfec84f17ea7
F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb
F src/wal.c 6fb6b68969e4692593c2552c4e7bff5882de2cb8
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
@ -1031,7 +1031,7 @@ F test/superlock.test 1cde669f68d2dd37d6c9bd35eee1d95491ae3fc2
F test/sync.test a34cd43e98b7fb84eabbf38f7ed8f7349b3f3d85
F test/syscall.test d2fdaad713f103ac611fe7ef9b724c7b69f8149c
F test/sysfault.test fa776e60bf46bdd3ae69f0b73e46ee3977a58ae6
F test/tabfunc01.test d69034069c911094cfcd58abba60bf431e1be6b4
F test/tabfunc01.test 61d185dde74aa2ff70085d33bc5f9a0ce8d6a318
F test/table.test 33bf0d1fd07f304582695184b8e6feb017303816
F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126
F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930
@ -1376,7 +1376,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 40e12cfe4c29475417ba89fb637b4c763cf74016
R 9b15d3824a7951b7bf35b7a0abf173ef
P fef44c37f31ca9fd7891cecdbe95cc46a987067b
R a41603407a6c0b327e60b148f02b0042
U drh
Z a9a479d5c8daf866b811a88820752d86
Z aa56d5c64521b30a9993ce3328198562

View File

@ -1 +1 @@
fef44c37f31ca9fd7891cecdbe95cc46a987067b
a325a08599759471047e234ef9cfcc3cb110aafd

View File

@ -1120,6 +1120,7 @@ int sqlite3VtabEponymousTableInit(Parse *pParse, Module *pMod){
pTab->pSchema = db->aDb[0].pSchema;
pTab->tabFlags |= TF_Virtual;
pTab->nModuleArg = 0;
pTab->iPKey = -1;
addModuleArgument(db, pTab, pTab->zName);
addModuleArgument(db, pTab, 0);
addModuleArgument(db, pTab, pTab->zName);

View File

@ -48,6 +48,12 @@ do_catchsql_test tabfunc01-1.7 {
do_execsql_test tabfunc01-1.8 {
SELECT * FROM generate_series(0,32,5) ORDER BY rowid DESC;
} {30 25 20 15 10 5 0}
do_execsql_test tabfunc01-1.9 {
SELECT rowid, * FROM generate_series(0,32,5) ORDER BY value DESC;
} {1 30 2 25 3 20 4 15 5 10 6 5 7 0}
do_execsql_test tabfunc01-1.10 {
SELECT rowid, * FROM generate_series(0,32,5) ORDER BY +value DESC;
} {7 30 6 25 5 20 4 15 3 10 2 5 1 0}
do_execsql_test tabfunc01-2.1 {
CREATE TABLE t1(x);