Simplification of the initialization code for CREATE TABLE AS.
FossilOrigin-Name: 937f659e8933011c44e822328a97cb5f0607c04d
This commit is contained in:
parent
9df25c4736
commit
9263220487
15
manifest
15
manifest
@ -1,5 +1,5 @@
|
||||
C A\sproposed\sfix\sfor\sthe\sproblem\sof\sCREATE\sTABLE\sAS\sgenerating\sa\stable\sthat\nhas\sINTEGER\svalues\sin\sa\sTEXT\scolumn.\s\sTicket\s[f2ad7de056ab1dc92].
|
||||
D 2015-05-20T15:51:09.466
|
||||
C Simplification\sof\sthe\sinitialization\scode\sfor\sCREATE\sTABLE\sAS.
|
||||
D 2015-05-20T17:18:29.382
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in 0a6ae26396ec696221021780dffbb894ff3cead7
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -195,7 +195,7 @@ F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79
|
||||
F src/btree.c 30a80340481098d699398cba3536c895373b2e2c
|
||||
F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1
|
||||
F src/btreeInt.h 973a22a6fd61350b454ad614832b1f0a5e25a1e4
|
||||
F src/build.c 857606eac00ffdcc35267e2b78aaebb5c4a4bd06
|
||||
F src/build.c d5d9090788118178190c5724c19f93953b8c7a4e
|
||||
F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0
|
||||
F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575
|
||||
F src/ctime.c 5a0b735dc95604766f5dac73973658eef782ee8b
|
||||
@ -1278,10 +1278,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||
P c403502cdce8b82e570e6fc49ab7f5144800c189
|
||||
R 50de0e4641ea4d7735e732fb73d3af44
|
||||
T *branch * create-table-as-type-fix
|
||||
T *sym-create-table-as-type-fix *
|
||||
T -sym-trunk *
|
||||
P d5e2c1fc7625130a3cbacc95c28bb553a0119cb8
|
||||
R 6555861550de93cc52d9bfcbb7f3a817
|
||||
U drh
|
||||
Z 78e916760aff70e5689a89cd2eb362da
|
||||
Z 1fd362c4cfc736e2f31eca469b4265bd
|
||||
|
@ -1 +1 @@
|
||||
d5e2c1fc7625130a3cbacc95c28bb553a0119cb8
|
||||
937f659e8933011c44e822328a97cb5f0607c04d
|
49
src/build.c
49
src/build.c
@ -1913,12 +1913,17 @@ void sqlite3EndTable(
|
||||
** be redundant.
|
||||
*/
|
||||
if( pSelect ){
|
||||
SelectDest dest;
|
||||
Table *pSelTab;
|
||||
SelectDest dest; /* Where the SELECT should store results */
|
||||
int regYield; /* Register holding co-routine entry-point */
|
||||
int addrTop; /* Top of the co-routine */
|
||||
int regRec; /* A record to be insert into the new table */
|
||||
int regRowid; /* Rowid of the next row to insert */
|
||||
int addrInsLoop; /* Top of the loop for inserting rows */
|
||||
Table *pSelTab; /* A table that describes the SELECT results */
|
||||
|
||||
regYield = ++pParse->nMem;
|
||||
regRec = ++pParse->nMem;
|
||||
regRowid = ++pParse->nMem;
|
||||
assert(pParse->nTab==1);
|
||||
sqlite3VdbeAddOp3(v, OP_OpenWrite, 1, pParse->regRoot, iDb);
|
||||
sqlite3VdbeChangeP5(v, OPFLAG_P2ISREG);
|
||||
@ -1929,28 +1934,24 @@ void sqlite3EndTable(
|
||||
sqlite3Select(pParse, pSelect, &dest);
|
||||
sqlite3VdbeAddOp1(v, OP_EndCoroutine, regYield);
|
||||
sqlite3VdbeJumpHere(v, addrTop - 1);
|
||||
if( pParse->nErr==0 ){
|
||||
int regRec = ++pParse->nMem;
|
||||
int regRowid = ++pParse->nMem;
|
||||
int addrInsLoop;
|
||||
pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect);
|
||||
if( pSelTab==0 ) return;
|
||||
assert( p->aCol==0 );
|
||||
p->nCol = pSelTab->nCol;
|
||||
p->aCol = pSelTab->aCol;
|
||||
pSelTab->nCol = 0;
|
||||
pSelTab->aCol = 0;
|
||||
sqlite3DeleteTable(db, pSelTab);
|
||||
addrInsLoop = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm);
|
||||
VdbeCoverage(v);
|
||||
sqlite3VdbeAddOp3(v, OP_MakeRecord, dest.iSdst, dest.nSdst, regRec);
|
||||
sqlite3TableAffinity(v, p, 0);
|
||||
sqlite3VdbeAddOp2(v, OP_NewRowid, 1, regRowid);
|
||||
sqlite3VdbeAddOp3(v, OP_Insert, 1, regRec, regRowid);
|
||||
sqlite3VdbeAddOp2(v, OP_Goto, 0, addrInsLoop);
|
||||
sqlite3VdbeJumpHere(v, addrInsLoop);
|
||||
sqlite3VdbeAddOp1(v, OP_Close, 1);
|
||||
}
|
||||
if( pParse->nErr ) return;
|
||||
pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect);
|
||||
if( pSelTab==0 ) return;
|
||||
assert( p->aCol==0 );
|
||||
p->nCol = pSelTab->nCol;
|
||||
p->aCol = pSelTab->aCol;
|
||||
pSelTab->nCol = 0;
|
||||
pSelTab->aCol = 0;
|
||||
sqlite3DeleteTable(db, pSelTab);
|
||||
addrInsLoop = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm);
|
||||
VdbeCoverage(v);
|
||||
sqlite3VdbeAddOp3(v, OP_MakeRecord, dest.iSdst, dest.nSdst, regRec);
|
||||
sqlite3TableAffinity(v, p, 0);
|
||||
sqlite3VdbeAddOp2(v, OP_NewRowid, 1, regRowid);
|
||||
sqlite3VdbeAddOp3(v, OP_Insert, 1, regRec, regRowid);
|
||||
sqlite3VdbeAddOp2(v, OP_Goto, 0, addrInsLoop);
|
||||
sqlite3VdbeJumpHere(v, addrInsLoop);
|
||||
sqlite3VdbeAddOp1(v, OP_Close, 1);
|
||||
}
|
||||
|
||||
/* Compute the complete text of the CREATE statement */
|
||||
|
Loading…
x
Reference in New Issue
Block a user