aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2019-08-30 23:15:00 +0000
committerdrh <drh@noemail.net>2019-08-30 23:15:00 +0000
commita7ce167e5b89e45d203014fc6ad0dbbfa3d44346 (patch)
treee148d4722c460e106fb8bfa2d8d9aa00a34aae4c /src
parentefb5f9a173e45a1cfb4e03f5680a6307f6e3f17c (diff)
downloadsqlite-a7ce167e5b89e45d203014fc6ad0dbbfa3d44346.tar.gz
sqlite-a7ce167e5b89e45d203014fc6ad0dbbfa3d44346.zip
Make sure OP_RealAffinity has been applied to all columns of type REAL
in the excluded.* pseudo-table of an UPSERT. Ticket [5a3dba8104421320] FossilOrigin-Name: 67381dadede98a55d8d9e085d021e6fa6473071978967b6302e03b28cf2245e1
Diffstat (limited to 'src')
-rw-r--r--src/upsert.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/upsert.c b/src/upsert.c
index 850ae863b..7beb9ffae 100644
--- a/src/upsert.c
+++ b/src/upsert.c
@@ -205,6 +205,7 @@ void sqlite3UpsertDoUpdate(
sqlite3 *db = pParse->db;
SrcList *pSrc; /* FROM clause for the UPDATE */
int iDataCur;
+ int i;
assert( v!=0 );
assert( pUpsert!=0 );
@@ -221,7 +222,6 @@ void sqlite3UpsertDoUpdate(
Index *pPk = sqlite3PrimaryKeyIndex(pTab);
int nPk = pPk->nKeyCol;
int iPk = pParse->nMem+1;
- int i;
pParse->nMem += nPk;
for(i=0; i<nPk; i++){
int k;
@@ -242,6 +242,12 @@ void sqlite3UpsertDoUpdate(
/* pUpsert does not own pUpsertSrc - the outer INSERT statement does. So
** we have to make a copy before passing it down into sqlite3Update() */
pSrc = sqlite3SrcListDup(db, pUpsert->pUpsertSrc, 0);
+ /* excluded.* columns of type REAL need to be converted to a hard real */
+ for(i=0; i<pTab->nCol; i++){
+ if( pTab->aCol[i].affinity==SQLITE_AFF_REAL ){
+ sqlite3VdbeAddOp1(v, OP_RealAffinity, pUpsert->regData+i);
+ }
+ }
sqlite3Update(pParse, pSrc, pUpsert->pUpsertSet,
pUpsert->pUpsertWhere, OE_Abort, 0, 0, pUpsert);
pUpsert->pUpsertSet = 0; /* Will have been deleted by sqlite3Update() */