From: drh <> Date: Sun, 16 Feb 2025 10:50:44 +0000 (+0000) Subject: Cleanup of the changes for this branch. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=664876965e032571ac0e3e985cc32cbe44401d93;p=thirdparty%2Fsqlite.git Cleanup of the changes for this branch. FossilOrigin-Name: 9349398e15195318ded786330fc33edea9d1d6d44e3428e5f9a643a3b48ee248 --- diff --git a/manifest b/manifest index 78f247b97f..dfd66de45d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Bug\sfixes\sin\sthe\sINSERT\slogic\sfor\sVALUES\scontaining\sDEFAULT\sterms. -D 2025-02-15T23:47:25.843 +C Cleanup\sof\sthe\schanges\sfor\sthis\sbranch. +D 2025-02-16T10:50:44.058 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -729,7 +729,7 @@ F src/date.c 842c08ac143a56a627b05ac51d68624f2b7b03e3b4cba596205e735eed64ee57 F src/dbpage.c 2e677acb658a29965e55398bbc61161cb7819da538057c8032adac7ab8e4a8c0 F src/dbstat.c 73362c0df0f40ad5523a6f5501224959d0976757b511299bf892313e79d14f5c F src/delete.c 03a77ba20e54f0f42ebd8eddf15411ed6bdb06a2c472ac4b6b336521bf7cea42 -F src/expr.c 7a78794a6432f90e6f029f79907a8c649b2c1cce7e3782a05466f0141a94209f +F src/expr.c 78b8d7cec11c4d4dee381cc1893037254da98b862d955b4e5fc06c5d5e490e4b F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 928ed2517e8732113d2b9821aa37af639688d752f4ea9ac6e0e393d713eeb76f F src/func.c b2fb33139972d7d65640b27ea962a49f1616265428001090cab39fcf270228e1 @@ -738,7 +738,7 @@ F src/hash.c 73934a7f7ab1cb110614a9388cb516893b0cf5b7b69e4fd1a0780ac4ce166be7 F src/hash.h 46b92795a95bfefb210f52f0c316e9d7cdbcdd7e7fcfb0d8be796d3a5767cddf F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c 1525752ebd9a3fc09692a631a8b3a3a3d51e0df479a598164e268d9886f90d2e +F src/insert.c cb5baffb416bbbf7dd22b1effb8d1840f08fde2c02e194220c1ebcdf130b29e6 F src/json.c 2663a0c7e574cb928de944720dcdcc11c931877d877549b8f1258a4002efd6f7 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 @@ -783,7 +783,7 @@ F src/shell.c.in b377a59822f207106424f08aead37e78b609222e98f86f04cc8a03563ccf323 F src/sqlite.h.in d2902f13ace94d3d3609646bd6d12a2d7a4f6cbdf6a5a4097580ac305f54c3f0 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h a844632bfd2814d13fcad0c535ea0654b869930142a827c41818a1e8d1bcb1a2 +F src/sqliteInt.h 522450a18f7d3ba5ff95cecb342ae27bc47c91f9429ecad5f31f44af5e90d990 F src/sqliteLimit.h 1bbdbf72bd0411d003267ffebc59a262f061df5653027a75627d03f48ca30523 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -842,7 +842,7 @@ F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 375a772e2342274f4bf73605a70633237da09deed00a9bf4c4816a56777ea7c9 F src/treeview.c d85ce76e6d1498d781957c07cb234da6d77ce0ed2d196480d516f54dabc62279 F src/trigger.c da3c25786870d8bf97cd46b493374c2375d1abaf20a9b0f5f8629a3f2f2ce383 -F src/update.c f46f629c6df90b940f8d5d50da568aab0c9fa4c08c68febd49c97b00cc514174 +F src/update.c a431db0e255cf9f53506c1e377cdb703df1f338a353a96ee7090655aaaaaa8ea F src/upsert.c 215328c3f91623c520ec8672c44323553f12caeb4f01b1090ebdca99fdf7b4f1 F src/utf.c 8b29d9a5956569ea2700f869669b8ef67a9662ee5e724ff77ab3c387e27094ba F src/util.c 9ff6470dabcf943fd796d2da766c98bd328c8f6fe036a31e5b338e628603f989 @@ -2207,8 +2207,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 1902a0c16875c46b7e6f6a99d0d90c407b93fa44c4962474b13301e375f217b4 -R ee73b001203f5bc2912c6537f9cb08ca +P 2b129c3761315791becdf36289f5076b8db84c8ab7404518b7de2711e498ba8f +R f664a23899b9a2d544da09176a6ca449 U drh -Z 72f3edef63ba837099141ae37b5faae7 +Z 1d806d6ec1d9203ebf64215b302f699c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 24d5b3ecb3..7269a3c087 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2b129c3761315791becdf36289f5076b8db84c8ab7404518b7de2711e498ba8f +9349398e15195318ded786330fc33edea9d1d6d44e3428e5f9a643a3b48ee248 diff --git a/src/expr.c b/src/expr.c index 4be0a6c1df..5290fc9461 100644 --- a/src/expr.c +++ b/src/expr.c @@ -4897,6 +4897,8 @@ expr_code_doover: return target; } case TK_DEFAULT: { + /* If the DEFAULT keyword ever gets this far, that means it was used + ** in a context that is not supported. So raise an error. */ sqlite3ErrorMsg(pParse, "near \"default\": syntax error"); sqlite3RecordErrorOffsetOfExpr(pParse->db, pExpr); return target; diff --git a/src/insert.c b/src/insert.c index 3f2936fd6a..adb9a25c13 100644 --- a/src/insert.c +++ b/src/insert.c @@ -676,7 +676,8 @@ static int exprListIsNoAffinity(Parse *pParse, ExprList *pRow){ ** e) The DEFAULT keyword cannot have been used in any of the terms ** of the VALUES clause. This optimization won't work in that case ** because we do not yet know the mapping from VALUES-clause terms -** into table columns, so we cannot construct the mapping. +** into table columns, so we cannot figure out which column default +** value to use in place of the DEFAULT keyword. */ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){ @@ -831,6 +832,7 @@ static int *computeColTabMap( aColTabMap = sqlite3DbMallocZero(pParse->db, sizeof(int)*nId); if( aColTabMap==0 ) return 0; if( aTabColMap ){ + /* Invert the aTabColMap[] */ int i; assert( sqlite3DbMallocSize(pParse->db, aTabColMap) >= sizeof(int)*pTab->nCol ); @@ -840,6 +842,7 @@ static int *computeColTabMap( } } }else{ + /* Construct a new mapping that merely skips over non-insertable terms */ int i, j; for(i=j=0; inCol; i++){ if( (pTab->aCol[i].colFlags & COLFLAG_NOINSERT)==0 ){ @@ -850,9 +853,32 @@ static int *computeColTabMap( return aColTabMap; } +/* +** Expression pExpr is a DEFAULT keyword. Transform that expression to +** an expansion of the actual default value for the iCol-th column of +** table pTab. +*/ +void sqlite3ExpandDefaultValue( + Parse *pParse, /* Parsing context */ + Expr *pExpr, /* Expression to be transformed */ + Table *pTab, /* Table that supplies the new value to pExpr */ + int iCol /* Column of pTab that contains the new value for pExpr */ +){ + assert( pExpr->op==TK_DEFAULT ); + assert( iCol>=0 && iColnCol ); + if( pTab->aCol[iCol].iDflt==0 ){ + pExpr->op = TK_NULL; + }else{ + Expr *pDfltVal = sqlite3ColumnExpr(pTab, &pTab->aCol[iCol]); + pExpr->op = TK_UPLUS; + assert( pExpr->pLeft==0 ); + pExpr->pLeft = sqlite3ExprDup(pParse->db, pDfltVal, 0); + } +} + /* ** Scan all expressions in pList. If any is just a DEFAULT keyword, -** convert that expression into a new expressionthat evaluates to +** convert that expression into a new expression that evaluates to ** the default value of the corresponding table. */ static void convertDefaultExpr( @@ -862,19 +888,13 @@ static void convertDefaultExpr( ExprList *pList, /* The list to scan */ int nId /* Number of columns in aColTabMap */ ){ - int i, iCol; + int i; + assert( aColTabMap!=0 ); + assert( sqlite3DbMallocSize(pParse->db, aColTabMap) >= sizeof(int)*nId ); for(i=0; inExpr && ia[i].pExpr; - if( p->op!=TK_DEFAULT ) continue; - iCol = aColTabMap[i]; - assert( iCol>=0 && iColnCol ); - if( pTab->aCol[iCol].iDflt==0 ){ - p->op = TK_NULL; - }else{ - p->op = TK_UPLUS; - assert( p->pLeft==0 ); - p->pLeft = sqlite3ExprDup(pParse->db, - sqlite3ColumnExpr(pTab, &pTab->aCol[iCol]), 0); + if( p->op==TK_DEFAULT ){ + sqlite3ExpandDefaultValue(pParse, p, pTab, aColTabMap[i]); } } } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 639a7e4926..4f7f2f630c 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -4976,6 +4976,7 @@ void sqlite3FreeIndex(sqlite3*, Index*); # define sqlite3AutoincrementBegin(X) # define sqlite3AutoincrementEnd(X) #endif +void sqlite3ExpandDefaultValue(Parse*, Expr*, Table*, int); void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int, Upsert*); #ifndef SQLITE_OMIT_GENERATED_COLUMNS void sqlite3ComputeGeneratedColumns(Parse*, int, Table*); diff --git a/src/update.c b/src/update.c index 9b2f123d36..8456e2cc4b 100644 --- a/src/update.c +++ b/src/update.c @@ -491,15 +491,7 @@ void sqlite3Update( #endif aXRef[j] = i; if( pChanges->a[i].pExpr->op==TK_DEFAULT ){ - Expr *p = pChanges->a[i].pExpr; - if( pTab->aCol[j].iDflt==0 ){ - p->op = TK_NULL; - }else{ - p->op = TK_UPLUS; - assert( p->pLeft==0 ); - p->pLeft = sqlite3ExprDup(pParse->db, - sqlite3ColumnExpr(pTab, &pTab->aCol[j]), 0); - } + sqlite3ExpandDefaultValue(pParse, pChanges->a[i].pExpr, pTab, j); } }else{ if( pPk==0 && sqlite3IsRowid(pChanges->a[i].zEName) ){