aboutsummaryrefslogtreecommitdiff
path: root/src/insert.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2017-01-25 20:55:11 +0000
committerdrh <drh@noemail.net>2017-01-25 20:55:11 +0000
commitd447dced96050d3a5cc77a53eea8473612df18a9 (patch)
treec6fc4b33ed02961963f82f31504d19f260929b99 /src/insert.c
parent7888d14caa853827e60bac132ffcb0c6b25036c8 (diff)
parent7271d7a19c2d651146fed05680e1b393c4901d2c (diff)
downloadsqlite-d447dced96050d3a5cc77a53eea8473612df18a9.tar.gz
sqlite-d447dced96050d3a5cc77a53eea8473612df18a9.zip
Trim NULL values off the end of records when the SQLITE_ENABLE_TRIM_NULLS
compile-time option is used. Increase the size of the P5 operand to 16 bits. Fix a problem with short records in the sessions extension. FossilOrigin-Name: 4801bd59a01dcc11a3eb9e776e7599b36f162d2a
Diffstat (limited to 'src/insert.c')
-rw-r--r--src/insert.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/insert.c b/src/insert.c
index 93c22ae3f..5370ef77e 100644
--- a/src/insert.c
+++ b/src/insert.c
@@ -1668,6 +1668,25 @@ void sqlite3GenerateConstraintChecks(
VdbeModuleComment((v, "END: GenCnstCks(%d)", seenReplace));
}
+#ifdef SQLITE_ENABLE_NULL_TRIM
+/*
+** Change the P5 operand on the last opcode (which should be an OP_MakeRecord)
+** to be the number of columns in table pTab that must not be NULL-trimmed.
+**
+** Or if no columns of pTab may be NULL-trimmed, leave P5 at zero.
+*/
+void sqlite3SetMakeRecordP5(Vdbe *v, Table *pTab){
+ u16 i;
+
+ /* Records with omitted columns are only allowed for schema format
+ ** version 2 and later (SQLite version 3.1.4, 2005-02-20). */
+ if( pTab->pSchema->file_format<2 ) return;
+
+ for(i=pTab->nCol; i>1 && pTab->aCol[i-1].pDflt==0; i--){}
+ sqlite3VdbeChangeP5(v, i);
+}
+#endif
+
/*
** This routine generates code to finish the INSERT or UPDATE operation
** that was started by a prior call to sqlite3GenerateConstraintChecks.
@@ -1727,6 +1746,7 @@ void sqlite3CompleteInsertion(
regData = regNewData + 1;
regRec = sqlite3GetTempReg(pParse);
sqlite3VdbeAddOp3(v, OP_MakeRecord, regData, pTab->nCol, regRec);
+ sqlite3SetMakeRecordP5(v, pTab);
if( !bAffinityDone ){
sqlite3TableAffinity(v, pTab, 0);
sqlite3ExprCacheAffinityChange(pParse, regData, pTab->nCol);