From fa5c62ef2ee00ea32320133da89b278ccf21b143 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 11 Oct 2018 18:41:50 +0000 Subject: [PATCH] Add the textkey and textrekey pragmas. FossilOrigin-Name: f03164d45450cd7ff2162999aa9e51eec7fb5e7cab1fa83d876b544f8f841097 --- manifest | 17 +++++++++-------- manifest.uuid | 2 +- src/pragma.c | 24 ++++++++++++++++++------ src/pragma.h | 29 ++++++++++++++++++++--------- tool/mkpragmatab.tcl | 17 +++++++++++++++++ 5 files changed, 65 insertions(+), 24 deletions(-) diff --git a/manifest b/manifest index fadcf41d71..ac92d94aaf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sin\sthe\sCLI. -D 2018-10-11T16:53:37.019 +C Add\sthe\stextkey\sand\stextrekey\spragmas. +D 2018-10-11T18:41:50.384 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 01e95208a78b57d056131382c493c963518f36da4c42b12a97eb324401b3a334 @@ -496,8 +496,8 @@ F src/parse.y 6840fe7c0b5eb4dd25ee5d075213bc8255ed4c0678d71bfb6744d0520d91c179 F src/pcache.c 4196eb6ed3bbf00b80596c8e0b4f50e57eb7d890c19fb27a7354306abb7f983d F src/pcache.h 072f94d29281cffd99e46c1539849f248c4b56ae7684c1f36626797fee375170 F src/pcache1.c 716975564c15eb6679e97f734cec1bfd6c16ac3d4010f05f1f8e509fc7d19880 -F src/pragma.c a656ff043a03bd94153e6d731a3fbf1bb420207edc969d8fc04b4d2448387901 -F src/pragma.h 0ea639401ed7b8275c145e3a814119831e296118b545421e76ae2e1516f10ad8 +F src/pragma.c 35efa85894f1ae533c03c64591dfc82f916ad78250591082bbae72a2811bceab +F src/pragma.h e50df79399da8c2efc6bd4b7034e242d0dc6ab2016564f08e94103367098b1e4 F src/prepare.c f8e260d940a0e08494c0f30744521b2f832d7263eca9d02b050cea0ba144b097 F src/printf.c 0f1177cf1dd4d7827bf64d840768514ec76409abecaca9e8b577dbd065150381 F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 @@ -1704,7 +1704,7 @@ F tool/mkmsvcmin.tcl cad0c7b54d7dd92bc87d59f36d4cc4f070eb2e625f14159dc2f5c4204e6 F tool/mkopcodec.tcl d1b6362bd3aa80d5520d4d6f3765badf01f6c43c F tool/mkopcodeh.tcl 352a4319c0ad869eb26442bf7c3b015aa15594c21f1cce5a6420dbe999367c21 F tool/mkopts.tcl 680f785fdb09729fd9ac50632413da4eadbdf9071535e3f26d03795828ab07fa -F tool/mkpragmatab.tcl fc895d5a40e725b19b866b058b3994bfc45db3e7fef40db9e6c6fd921bf8a337 +F tool/mkpragmatab.tcl 656e64fc4e8b5d91525bac1e81834de3217507657e846b1a08375ca195fa8479 F tool/mkshellc.tcl 1f45770aea226ac093a9c72f718efbb88a2a2833409ec2e1c4cecae4202626f5 F tool/mksourceid.c d458f9004c837bee87a6382228ac20d3eae3c49ea3b0a5aace936f8b60748d3b F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 @@ -1771,7 +1771,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0bf0fd242b93c3bd308ab46db1be9edef141b89db07a0f5a4ed8b23c963da0d5 -R 39f23ee94b2c360e452a32e265e4dde1 +P 1916d2912a4ef5c251853de3c9d66417e20f0c0fc8ddfbc84c131dfd798439f6 +Q +f829099d2558011d2f19ed3e91778b97e4ce0bdaa4a7cd6b0009f705554398ca +R 63af1cda40897d849945c1a22dbd668a U drh -Z 4b0c86ae06c4aa2155872fd34a461306 +Z 865f15d326c847ade3537f91a0382191 diff --git a/manifest.uuid b/manifest.uuid index 0f1c49939f..54e36d8a4f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1916d2912a4ef5c251853de3c9d66417e20f0c0fc8ddfbc84c131dfd798439f6 \ No newline at end of file +f03164d45450cd7ff2162999aa9e51eec7fb5e7cab1fa83d876b544f8f841097 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index fd08cc202c..c3c62a722c 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -2118,12 +2118,24 @@ void sqlite3Pragma( #endif #ifdef SQLITE_HAS_CODEC + /* Pragma iArg + ** ---------- ------ + ** key 0 + ** rekey 1 + ** hexkey 2 + ** hexrekey 3 + ** textkey 4 + ** textrekey 5 + */ case PragTyp_KEY: { - if( zRight ) sqlite3_key_v2(db, zDb, zRight, sqlite3Strlen30(zRight)); - break; - } - case PragTyp_REKEY: { - if( zRight ) sqlite3_rekey_v2(db, zDb, zRight, sqlite3Strlen30(zRight)); + if( zRight ){ + int n = pPragma->iArg<4 ? sqlite3Strlen30(zRight) : -1; + if( (pPragma->iArg & 1)==0 ){ + sqlite3_key_v2(db, zDb, zRight, n); + }else{ + sqlite3_rekey_v2(db, zDb, zRight, n); + } + } break; } case PragTyp_HEXKEY: { @@ -2135,7 +2147,7 @@ void sqlite3Pragma( iByte = (iByte<<4) + sqlite3HexToInt(zRight[i]); if( (i&1)!=0 ) zKey[i/2] = iByte; } - if( (zLeft[3] & 0xf)==0xb ){ + if( (pPragma->iArg & 1)==0 ){ sqlite3_key_v2(db, zDb, zKey, i/2); }else{ sqlite3_rekey_v2(db, zDb, zKey, i/2); diff --git a/src/pragma.h b/src/pragma.h index 3d1ba4f341..93e7116f0e 100644 --- a/src/pragma.h +++ b/src/pragma.h @@ -48,10 +48,9 @@ #define PragTyp_ACTIVATE_EXTENSIONS 40 #define PragTyp_HEXKEY 41 #define PragTyp_KEY 42 -#define PragTyp_REKEY 43 -#define PragTyp_LOCK_STATUS 44 -#define PragTyp_PARSER_TRACE 45 -#define PragTyp_STATS 46 +#define PragTyp_LOCK_STATUS 43 +#define PragTyp_PARSER_TRACE 44 +#define PragTyp_STATS 45 /* Property flags associated with various pragma. */ #define PragFlg_NeedSchema 0x01 /* Force schema load before running */ @@ -325,12 +324,12 @@ static const PragmaName aPragmaName[] = { /* ePragTyp: */ PragTyp_HEXKEY, /* ePragFlg: */ 0, /* ColNames: */ 0, 0, - /* iArg: */ 0 }, + /* iArg: */ 2 }, {/* zName: */ "hexrekey", /* ePragTyp: */ PragTyp_HEXKEY, /* ePragFlg: */ 0, /* ColNames: */ 0, 0, - /* iArg: */ 0 }, + /* iArg: */ 3 }, #endif #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) #if !defined(SQLITE_OMIT_CHECK) @@ -504,10 +503,10 @@ static const PragmaName aPragmaName[] = { #endif #if defined(SQLITE_HAS_CODEC) {/* zName: */ "rekey", - /* ePragTyp: */ PragTyp_REKEY, + /* ePragTyp: */ PragTyp_KEY, /* ePragFlg: */ 0, /* ColNames: */ 0, 0, - /* iArg: */ 0 }, + /* iArg: */ 1 }, #endif #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) {/* zName: */ "reverse_unordered_selects", @@ -593,6 +592,18 @@ static const PragmaName aPragmaName[] = { /* ePragFlg: */ PragFlg_NoColumns1, /* ColNames: */ 0, 0, /* iArg: */ 0 }, +#endif +#if defined(SQLITE_HAS_CODEC) + {/* zName: */ "textkey", + /* ePragTyp: */ PragTyp_KEY, + /* ePragFlg: */ 0, + /* ColNames: */ 0, 0, + /* iArg: */ 4 }, + {/* zName: */ "textrekey", + /* ePragTyp: */ PragTyp_KEY, + /* ePragFlg: */ 0, + /* ColNames: */ 0, 0, + /* iArg: */ 5 }, #endif {/* zName: */ "threads", /* ePragTyp: */ PragTyp_THREADS, @@ -655,4 +666,4 @@ static const PragmaName aPragmaName[] = { /* iArg: */ SQLITE_WriteSchema }, #endif }; -/* Number of pragmas: 62 on by default, 79 total. */ +/* Number of pragmas: 62 on by default, 81 total. */ diff --git a/tool/mkpragmatab.tcl b/tool/mkpragmatab.tcl index c40e3f5b77..63fe7ce8e4 100644 --- a/tool/mkpragmatab.tcl +++ b/tool/mkpragmatab.tcl @@ -367,16 +367,33 @@ set pragma_def { IF: defined(SQLITE_DEBUG) || defined(SQLITE_TEST) NAME: key + TYPE: KEY + ARG: 0 IF: defined(SQLITE_HAS_CODEC) NAME: rekey + TYPE: KEY + ARG: 1 IF: defined(SQLITE_HAS_CODEC) NAME: hexkey + TYPE: HEXKEY + ARG: 2 IF: defined(SQLITE_HAS_CODEC) NAME: hexrekey TYPE: HEXKEY + ARG: 3 + IF: defined(SQLITE_HAS_CODEC) + + NAME: textkey + TYPE: KEY + ARG: 4 + IF: defined(SQLITE_HAS_CODEC) + + NAME: textrekey + TYPE: KEY + ARG: 5 IF: defined(SQLITE_HAS_CODEC) NAME: activate_extensions