mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-21 09:00:59 +03:00
Add OP_Affinity opcodes to the VMs generated by sqlite3_index_writer().
FossilOrigin-Name: b9b38cb8e21826ddfb4c87a1f166ad33c3c7b6eb
This commit is contained in:
54
ext/ota/ota3.test
Normal file
54
ext/ota/ota3.test
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
# 2014 August 30
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
#***********************************************************************
|
||||||
|
#
|
||||||
|
|
||||||
|
set testdir [file join [file dirname $argv0] .. .. test]
|
||||||
|
source $testdir/tester.tcl
|
||||||
|
set ::testprefix ota3
|
||||||
|
|
||||||
|
|
||||||
|
# Run the OTA in file $ota on target database $target until completion.
|
||||||
|
#
|
||||||
|
proc run_ota {target ota} {
|
||||||
|
sqlite3ota ota $target $ota
|
||||||
|
while { [ota step]=="SQLITE_OK" } {}
|
||||||
|
ota close
|
||||||
|
}
|
||||||
|
|
||||||
|
forcedelete test.db-oal ota.db
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# Test that for an OTA to be applied, no corruption results if the
|
||||||
|
# affinities on the source and target table do not match.
|
||||||
|
#
|
||||||
|
do_execsql_test 1.0 {
|
||||||
|
CREATE TABLE x1(a INTEGER PRIMARY KEY, b TEXT, c REAL);
|
||||||
|
CREATE INDEX i1 ON x1(b, c);
|
||||||
|
} {}
|
||||||
|
|
||||||
|
do_test 1.1 {
|
||||||
|
sqlite3 db2 ota.db
|
||||||
|
db2 eval {
|
||||||
|
CREATE TABLE data_x1(a, b, c, ota_control);
|
||||||
|
INSERT INTO data_x1 VALUES(1, '123', '123', 0);
|
||||||
|
INSERT INTO data_x1 VALUES(2, 123, 123, 0);
|
||||||
|
}
|
||||||
|
db2 close
|
||||||
|
run_ota test.db ota.db
|
||||||
|
} {SQLITE_DONE}
|
||||||
|
|
||||||
|
do_execsql_test 1.2 {
|
||||||
|
PRAGMA integrity_check;
|
||||||
|
} {ok}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
finish_test
|
||||||
13
manifest
13
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Add\ssupport\sfor\supdate\sstatements\sto\ssqlite3ota.c.
|
C Add\sOP_Affinity\sopcodes\sto\sthe\sVMs\sgenerated\sby\ssqlite3_index_writer().
|
||||||
D 2014-09-08T17:50:35.158
|
D 2014-09-15T10:44:24.271
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
|
F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -124,6 +124,7 @@ F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212
|
|||||||
F ext/ota/ota.c d37097e92a005d3915883adefbb93019ea6f8841
|
F ext/ota/ota.c d37097e92a005d3915883adefbb93019ea6f8841
|
||||||
F ext/ota/ota1.test fe0bb8acf0caef6c19937b84c6547b788342610d
|
F ext/ota/ota1.test fe0bb8acf0caef6c19937b84c6547b788342610d
|
||||||
F ext/ota/ota2.test 13f76922446c62ed96192e938b8e625ebf0142fa
|
F ext/ota/ota2.test 13f76922446c62ed96192e938b8e625ebf0142fa
|
||||||
|
F ext/ota/ota3.test 9e3e42c6083e92909c408f1fe62aa07b0c9f905c
|
||||||
F ext/ota/sqlite3ota.c 3697f6db2d51d5f7c0f0306fe94514785361e521
|
F ext/ota/sqlite3ota.c 3697f6db2d51d5f7c0f0306fe94514785361e521
|
||||||
F ext/ota/sqlite3ota.h 545f0008b5f02f2595899cb9841caddada5c17c0
|
F ext/ota/sqlite3ota.h 545f0008b5f02f2595899cb9841caddada5c17c0
|
||||||
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
|
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
|
||||||
@@ -295,7 +296,7 @@ F src/vdbe.h c63fad052c9e7388d551e556e119c0bcf6bebdf8
|
|||||||
F src/vdbeInt.h cdc8e421f85beb1ac9b4669ec5beadab6faa15e0
|
F src/vdbeInt.h cdc8e421f85beb1ac9b4669ec5beadab6faa15e0
|
||||||
F src/vdbeapi.c 09677a53dd8c71bcd670b0bd073bb9aefa02b441
|
F src/vdbeapi.c 09677a53dd8c71bcd670b0bd073bb9aefa02b441
|
||||||
F src/vdbeaux.c cef5d34a64ae3a65b56d96d3fd663246ec8e1c36
|
F src/vdbeaux.c cef5d34a64ae3a65b56d96d3fd663246ec8e1c36
|
||||||
F src/vdbeblob.c b1b8b2cd86617db009f027f116b335f86e95b617
|
F src/vdbeblob.c 7a28ade0cae13bd99f5c4c8f008f68e942c23115
|
||||||
F src/vdbemem.c 921d5468a68ac06f369810992e84ca22cc730a62
|
F src/vdbemem.c 921d5468a68ac06f369810992e84ca22cc730a62
|
||||||
F src/vdbesort.c 7c45bfcd823f30d172bbbc1b9f51ef4402fbfe8d
|
F src/vdbesort.c 7c45bfcd823f30d172bbbc1b9f51ef4402fbfe8d
|
||||||
F src/vdbetrace.c 6f52bc0c51e144b7efdcfb2a8f771167a8816767
|
F src/vdbetrace.c 6f52bc0c51e144b7efdcfb2a8f771167a8816767
|
||||||
@@ -1198,7 +1199,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||||
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
||||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||||
P f988234ba54d7c667f7deef1d04beed4e7fe6182
|
P e109b27e4d66b83e1a804e7556d9c91aa37fea28
|
||||||
R c23b09bc3993f39690d272fa85636507
|
R 75f9e5319b2343a328ed4364426b7add
|
||||||
U dan
|
U dan
|
||||||
Z 28e28dd83293020abb0c0fb47ae5ab2c
|
Z c56c0b8cb355334f7ef68c91cc8c371e
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
e109b27e4d66b83e1a804e7556d9c91aa37fea28
|
b9b38cb8e21826ddfb4c87a1f166ad33c3c7b6eb
|
||||||
@@ -478,6 +478,7 @@ int sqlite3_index_writer(
|
|||||||
Vdbe *v = 0;
|
Vdbe *v = 0;
|
||||||
int regRec; /* Register to assemble record in */
|
int regRec; /* Register to assemble record in */
|
||||||
int *aiCol = 0;
|
int *aiCol = 0;
|
||||||
|
const char *zAffinity = 0; /* Affinity string for the current index */
|
||||||
|
|
||||||
sqlite3_mutex_enter(db->mutex);
|
sqlite3_mutex_enter(db->mutex);
|
||||||
sqlite3BtreeEnterAll(db);
|
sqlite3BtreeEnterAll(db);
|
||||||
@@ -499,6 +500,7 @@ int sqlite3_index_writer(
|
|||||||
goto index_writer_out;
|
goto index_writer_out;
|
||||||
}
|
}
|
||||||
pTab = pIdx->pTable;
|
pTab = pIdx->pTable;
|
||||||
|
zAffinity = sqlite3IndexAffinityStr(v, pIdx);
|
||||||
|
|
||||||
/* Populate the two output variables, *pnCol and *pnAiCol. */
|
/* Populate the two output variables, *pnCol and *pnAiCol. */
|
||||||
*pnCol = pIdx->nColumn;
|
*pnCol = pIdx->nColumn;
|
||||||
@@ -548,7 +550,7 @@ int sqlite3_index_writer(
|
|||||||
regRec = ++pParse->nMem;
|
regRec = ++pParse->nMem;
|
||||||
|
|
||||||
if( bDelete==0 ){
|
if( bDelete==0 ){
|
||||||
sqlite3VdbeAddOp3(v, OP_MakeRecord, 1, pIdx->nColumn, regRec);
|
sqlite3VdbeAddOp4(v, OP_MakeRecord, 1, pIdx->nColumn, regRec, zAffinity, 0);
|
||||||
|
|
||||||
/* If this is a UNIQUE index, check the constraint. */
|
/* If this is a UNIQUE index, check the constraint. */
|
||||||
if( pIdx->onError ){
|
if( pIdx->onError ){
|
||||||
@@ -561,6 +563,7 @@ int sqlite3_index_writer(
|
|||||||
sqlite3VdbeAddOp2(v, OP_IdxInsert, 0, regRec);
|
sqlite3VdbeAddOp2(v, OP_IdxInsert, 0, regRec);
|
||||||
}else{
|
}else{
|
||||||
/* Code the IdxDelete to remove the entry from the b-tree index. */
|
/* Code the IdxDelete to remove the entry from the b-tree index. */
|
||||||
|
sqlite3VdbeAddOp4(v, OP_Affinity, 0, pIdx->nColumn, 0, zAffinity, 0);
|
||||||
sqlite3VdbeAddOp3(v, OP_IdxDelete, 0, 1, pIdx->nColumn);
|
sqlite3VdbeAddOp3(v, OP_IdxDelete, 0, 1, pIdx->nColumn);
|
||||||
}
|
}
|
||||||
sqlite3FinishCoding(pParse);
|
sqlite3FinishCoding(pParse);
|
||||||
|
|||||||
Reference in New Issue
Block a user