SQLite

Check-in [b3692c406f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Combine the implementations of the key and hexkey pragmas into a single case. Have both pragmas return "ok" if they are implemented.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b3692c406f7ba62587c9d3256f888748393519680e9e2db53f59557f1a300e05
User & Date: drh 2019-05-21 17:04:27.540
Context
2019-05-22
14:22
Fix a buffer overread that could in fts3 when dealing with corrupt records. (check-in: 1660d7733e user: dan tags: trunk)
2019-05-21
17:04
Combine the implementations of the key and hexkey pragmas into a single case. Have both pragmas return "ok" if they are implemented. (check-in: b3692c406f user: drh tags: trunk)
16:32
Fix a problem in [b5ca442a] causing an assert() to fail in REINDEX commands. (check-in: a3e77c7776 user: dan tags: trunk)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/pragma.c.
2126
2127
2128
2129
2130
2131
2132


2133
2134


2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145


2146
2147
2148
2149
2150









2151
2152

2153
2154






2155
2156
2157
2158
2159
2160
2161
2126
2127
2128
2129
2130
2131
2132
2133
2134


2135
2136











2137
2138





2139
2140
2141
2142
2143
2144
2145
2146
2147
2148

2149
2150

2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163







+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+

-
+

-
+
+
+
+
+
+







  **  hexkey        2
  **  hexrekey      3
  **  textkey       4
  **  textrekey     5
  */
  case PragTyp_KEY: {
    if( zRight ){
      char zBuf[40];
      const char *zKey = zRight;
      int n = pPragma->iArg<4 ? sqlite3Strlen30(zRight) : -1;
      if( (pPragma->iArg & 1)==0 ){
      int n;
      if( pPragma->iArg==2 || pPragma->iArg==3 ){
        sqlite3_key_v2(db, zDb, zRight, n);
      }else{
        sqlite3_rekey_v2(db, zDb, zRight, n);
      }
    }
    break;
  }
  case PragTyp_HEXKEY: {
    if( zRight ){
      u8 iByte;
      int i;
        u8 iByte;
        int i;
      char zKey[40];
      for(i=0, iByte=0; i<sizeof(zKey)*2 && sqlite3Isxdigit(zRight[i]); i++){
        iByte = (iByte<<4) + sqlite3HexToInt(zRight[i]);
        if( (i&1)!=0 ) zKey[i/2] = iByte;
      }
        for(i=0, iByte=0; i<sizeof(zBuf)*2 && sqlite3Isxdigit(zRight[i]); i++){
          iByte = (iByte<<4) + sqlite3HexToInt(zRight[i]);
          if( (i&1)!=0 ) zBuf[i/2] = iByte;
        }
        zKey = zBuf;
        n = i/2;
      }else{
        n = pPragma->iArg<4 ? sqlite3Strlen30(zRight) : -1;
      }
      if( (pPragma->iArg & 1)==0 ){
        sqlite3_key_v2(db, zDb, zKey, i/2);
        rc = sqlite3_key_v2(db, zDb, zKey, n);
      }else{
        sqlite3_rekey_v2(db, zDb, zKey, i/2);
        rc = sqlite3_rekey_v2(db, zDb, zKey, n);
      }
      if( rc==SQLITE_OK && n!=0 ){
        sqlite3VdbeSetNumCols(v, 1);
        sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "ok", SQLITE_STATIC);
        returnSingleText(v, "ok");
      }
    }
    break;
  }
#endif
#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)
  case PragTyp_ACTIVATE_EXTENSIONS: if( zRight ){
Changes to src/pragma.h.
42
43
44
45
46
47
48
49
50
51
52



53
54
55
56
57
58
59
42
43
44
45
46
47
48




49
50
51
52
53
54
55
56
57
58







-
-
-
-
+
+
+







#define PragTyp_TABLE_INFO                    34
#define PragTyp_TEMP_STORE                    35
#define PragTyp_TEMP_STORE_DIRECTORY          36
#define PragTyp_THREADS                       37
#define PragTyp_WAL_AUTOCHECKPOINT            38
#define PragTyp_WAL_CHECKPOINT                39
#define PragTyp_ACTIVATE_EXTENSIONS           40
#define PragTyp_HEXKEY                        41
#define PragTyp_KEY                           42
#define PragTyp_LOCK_STATUS                   43
#define PragTyp_STATS                         44
#define PragTyp_KEY                           41
#define PragTyp_LOCK_STATUS                   42
#define PragTyp_STATS                         43

/* Property flags associated with various pragma. */
#define PragFlg_NeedSchema 0x01 /* Force schema load before running */
#define PragFlg_NoColumns  0x02 /* OP_ResultRow called with zero columns */
#define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */
#define PragFlg_ReadOnly   0x08 /* Read-only HEADER_VALUE */
#define PragFlg_Result0    0x10 /* Acts as query when no argument */
318
319
320
321
322
323
324
325

326
327
328
329
330

331
332
333
334
335
336
337
317
318
319
320
321
322
323

324
325
326
327
328

329
330
331
332
333
334
335
336







-
+




-
+







  /* ePragFlg:  */ PragFlg_Result0,
  /* ColNames:  */ 41, 2,
  /* iArg:      */ 0 },
#endif
#endif
#if defined(SQLITE_HAS_CODEC)
 {/* zName:     */ "hexkey",
  /* ePragTyp:  */ PragTyp_HEXKEY,
  /* ePragTyp:  */ PragTyp_KEY,
  /* ePragFlg:  */ 0,
  /* ColNames:  */ 0, 0,
  /* iArg:      */ 2 },
 {/* zName:     */ "hexrekey",
  /* ePragTyp:  */ PragTyp_HEXKEY,
  /* ePragTyp:  */ PragTyp_KEY,
  /* ePragFlg:  */ 0,
  /* ColNames:  */ 0, 0,
  /* iArg:      */ 3 },
#endif
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
#if !defined(SQLITE_OMIT_CHECK)
 {/* zName:     */ "ignore_check_constraints",
Changes to tool/mkpragmatab.tcl.
377
378
379
380
381
382
383
384

385
386
387
388
389

390
391
392
393
394
395
396
377
378
379
380
381
382
383

384
385
386
387
388

389
390
391
392
393
394
395
396







-
+




-
+








  NAME: rekey
  TYPE: KEY
  ARG:  1
  IF:   defined(SQLITE_HAS_CODEC)

  NAME: hexkey
  TYPE: HEXKEY
  TYPE: KEY
  ARG:  2
  IF:   defined(SQLITE_HAS_CODEC)

  NAME: hexrekey
  TYPE: HEXKEY
  TYPE: KEY
  ARG:  3
  IF:   defined(SQLITE_HAS_CODEC)

  NAME: textkey
  TYPE: KEY
  ARG:  4
  IF:   defined(SQLITE_HAS_CODEC)