From b097449afefa53e05637aaa43197c66cece575c7 Mon Sep 17 00:00:00 2001
From: guiyao <guiyao@huawei.com>
Date: Tue, 17 Dec 2019 10:53:58 -0500
Subject: [PATCH] Backport Fix CVE-2019-19646

---
 src/pragma.c  |  4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/pragma.c b/src/pragma.c
index 4699c96..eda1a16 100644
--- a/src/pragma.c
+++ b/src/pragma.c
@@ -1571,7 +1571,9 @@ void sqlite3Pragma(
           if( j==pTab->iPKey ) continue;
           if( pTab->aCol[j].notNull==0 ) continue;
           sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, j, 3);
-          sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
+          if( sqlite3VdbeGetOp(v,-1)->opcode==OP_Column ){
+             sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
+          }
           jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v);
           zErr = sqlite3MPrintf(db, "NULL value in %s.%s", pTab->zName,
                               pTab->aCol[j].zName);
-- 
1.8.3.1

