Set the affinity of regular columns prior to computing the values of
generated columns. Ticket [d7c3f125c925c522] FossilOrigin-Name: d47d66e3d360d8aa6203a855228d2bc40d9a00d69c15f5066b7632d8fb1ed2cc
This commit is contained in:
parent
0a8764ad7a
commit
b5f6243f6d
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Rename\sa\slocal\svariable\sto\savoid\smasking\sa\sfunction\sparameter\sand\sthus\ncausing\sa\sharmless\scompiler\swarning.
|
||||
D 2019-12-09T19:44:45.580
|
||||
C Set\sthe\saffinity\sof\sregular\scolumns\sprior\sto\scomputing\sthe\svalues\sof\ngenerated\scolumns.\s\sTicket\s[d7c3f125c925c522]
|
||||
D 2019-12-10T02:48:41.113
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -488,7 +488,7 @@ F src/hash.c 8d7dda241d0ebdafb6ffdeda3149a412d7df75102cecfc1021c98d6219823b19
|
||||
F src/hash.h 9d56a9079d523b648774c1784b74b89bd93fac7b365210157482e4319a468f38
|
||||
F src/hwtime.h cb1d7e3e1ed94b7aa6fde95ae2c2daccc3df826be26fc9ed7fd90d1750ae6144
|
||||
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
||||
F src/insert.c 730455b1530552212ef67bf51dde86090d3995c432fb5806cd1addc58f2919b7
|
||||
F src/insert.c 5de3fd62bd1a692353c8f9c7bbde658f0b579f195620ca3cde1948a53015dddd
|
||||
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
|
||||
F src/loadext.c d74f5e7bd51f3c9d283442473eb65aef359664efd6513591c03f01881c4ae2da
|
||||
F src/main.c 868ae7db7a54fe859bf2ca8b7a4f24e9fa03a6134abfb7c9801d08411ef5dacb
|
||||
@ -599,7 +599,7 @@ F src/upsert.c b445315c8958d8f17ec3297d06842e61dacaad0633ccaec1e4e160de7e562212
|
||||
F src/utf.c 2f0fac345c7660d5c5bd3df9e9d8d33d4c27f366bcfb09e07443064d751a0507
|
||||
F src/util.c 66b22af7b359ce6493c34fef28c87d5c2d1765f212d6e4cd5e08d99ac30b89bb
|
||||
F src/vacuum.c 82dcec9e7b1afa980288718ad11bc499651c722d7b9f32933c4d694d91cb6ebf
|
||||
F src/vdbe.c b67d6af853e03c3dd6d1116351567f62d8a2c10d3bd6db5f7f366e75d11c6653
|
||||
F src/vdbe.c 30fc70ea7f1a47f50cd6557d8073b57fcf2275b537b896ba7e8d602065bc5648
|
||||
F src/vdbe.h fdbc0a11e5768a702b46ce63286f60e22e71351a29bd98b3666405e1fccc7802
|
||||
F src/vdbeInt.h bd589b8b7273286858950717e0e1ec5c88b18af45079a3366dc1371865cea704
|
||||
F src/vdbeapi.c 1252d80c548711e47a6d84dae88ed4e95d3fbb4e7bd0eaa1347299af7efddf02
|
||||
@ -1852,7 +1852,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P c7309ed3c7588c7e51e09418bf5cfd4611539b44c39cef9ed4ae0e385bae7625
|
||||
R c5e9fc97422d66306dffd9a52fafe510
|
||||
P f065cf003bd2a3a580cb5b9fa2eacd8be075fe8c2bbc5688e9a9406abbfb3804
|
||||
R 818408c4725ad345697d1e37e3d5ef64
|
||||
U drh
|
||||
Z 2d277b2fd1fa015a93e6a070ccbdea58
|
||||
Z 7d655f0df3955b1fe800872549949d0e
|
||||
|
@ -1 +1 @@
|
||||
f065cf003bd2a3a580cb5b9fa2eacd8be075fe8c2bbc5688e9a9406abbfb3804
|
||||
d47d66e3d360d8aa6203a855228d2bc40d9a00d69c15f5066b7632d8fb1ed2cc
|
34
src/insert.c
34
src/insert.c
@ -229,6 +229,36 @@ void sqlite3ComputeGeneratedColumns(
|
||||
Walker w;
|
||||
Column *pRedo;
|
||||
int eProgress;
|
||||
VdbeOp *pOp;
|
||||
|
||||
assert( pTab->tabFlags & TF_HasGenerated );
|
||||
testcase( pTab->tabFlags & TF_HasVirtual );
|
||||
testcase( pTab->tabFlags & TF_HasStored );
|
||||
|
||||
/* Before computing generated columns, first go through and make sure
|
||||
** that appropriate affinity has been applied to the regular columns
|
||||
*/
|
||||
sqlite3TableAffinity(pParse->pVdbe, pTab, iRegStore);
|
||||
if( (pTab->tabFlags & TF_HasStored)!=0
|
||||
&& (pOp = sqlite3VdbeGetOp(pParse->pVdbe,-1))->opcode==OP_Affinity
|
||||
){
|
||||
/* Change the OP_Affinity argument to '@' (NONE) for all stored
|
||||
** columns. '@' is the no-op affinity and those columns have not
|
||||
** yet been computed. */
|
||||
int ii, jj;
|
||||
char *zP4 = pOp->p4.z;
|
||||
assert( zP4!=0 );
|
||||
assert( pOp->p4type==P4_DYNAMIC );
|
||||
for(ii=jj=0; zP4[jj]; ii++){
|
||||
if( pTab->aCol[ii].colFlags & COLFLAG_VIRTUAL ){
|
||||
continue;
|
||||
}
|
||||
if( pTab->aCol[ii].colFlags & COLFLAG_STORED ){
|
||||
zP4[jj] = SQLITE_AFF_NONE;
|
||||
}
|
||||
jj++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Because there can be multiple generated columns that refer to one another,
|
||||
** this is a two-pass algorithm. On the first pass, mark all generated
|
||||
@ -1187,10 +1217,8 @@ void sqlite3Insert(
|
||||
/* Compute the new value for generated columns after all other
|
||||
** columns have already been computed. This must be done after
|
||||
** computing the ROWID in case one of the generated columns
|
||||
** refers to the ROWID. */
|
||||
** is derived from the INTEGER PRIMARY KEY. */
|
||||
if( pTab->tabFlags & TF_HasGenerated ){
|
||||
testcase( pTab->tabFlags & TF_HasVirtual );
|
||||
testcase( pTab->tabFlags & TF_HasStored );
|
||||
sqlite3ComputeGeneratedColumns(pParse, regRowid+1, pTab);
|
||||
}
|
||||
#endif
|
||||
|
@ -2818,7 +2818,7 @@ case OP_Affinity: {
|
||||
pIn1 = &aMem[pOp->p1];
|
||||
while( 1 /*exit-by-break*/ ){
|
||||
assert( pIn1 <= &p->aMem[(p->nMem+1 - p->nCursor)] );
|
||||
assert( memIsValid(pIn1) );
|
||||
assert( zAffinity[0]==SQLITE_AFF_NONE || memIsValid(pIn1) );
|
||||
applyAffinity(pIn1, zAffinity[0], encoding);
|
||||
if( zAffinity[0]==SQLITE_AFF_REAL && (pIn1->flags & MEM_Int)!=0 ){
|
||||
/* When applying REAL affinity, if the result is still an MEM_Int
|
||||
|
Loading…
x
Reference in New Issue
Block a user