SQLite

Check-in [8bf5154bc6]
Login

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

Overview
Comment:Remove, for now, the "priority" column from the zonefile_files virtual table.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | zonefile
Files: files | file ages | folders
SHA3-256: 8bf5154bc6e31e206931d97c743eadaba4ef938c11e006082d795439dadaeb8f
User & Date: dan 2018-02-13 18:02:00.303
Context
2018-02-13
19:01
Enhance ext/zonefile/README.md to describe the currently available functionality. (check-in: 100137c7f6 user: dan tags: zonefile)
18:02
Remove, for now, the "priority" column from the zonefile_files virtual table. (check-in: 8bf5154bc6 user: dan tags: zonefile)
17:33
Pad the 26 byte Zonefile header to 32 bytes so that the ZonefileIndex object is 8-byte aligned. (check-in: fdb6c0c5dc user: dan tags: zonefile)
Changes
Unified Diff Ignore Whitespace Patch
Changes to ext/zonefile/README.md.
1
2
3


4

5




6



7

8
9
10
11
12


13
14

Notes:



  *  Using 32-bit frame numbers (not 16-bit).






  *  The ZonefileHeader object is 26 bytes in size. Which means that the



     ZoneFileIndex will not be 8-byte aligned. Problem?


  *  The offsets in the ZoneFileIndex.byteOffsetZoneFrame[] array are
     relative to the offset in ZoneFileHeader.byteOffsetFrames. This is
     necessary as we may not know the offset of the start of the frame data
     until after the ZoneFileIndex structure is compressed.







>
>
|
>
|
>
>
>
>
|
>
>
>
|
>





>
>


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

Notes:

  *  Contrary to the spec, the implementation uses 32-bit (not 16-bit) frame
     numbers. So the KeyOffsetPair structure becomes:

     KeyOffsetPair
     {
       uint64  key;
       uint32  frameNo;
       uint32  frameByteOffset;
     };

     Also, the ZonefileHeader.numFrames field is now 32-bit. Which makes
     the ZonefileHeader structure 26 bytes in size. The implementation
     pads this out to 32 bytes so that the ZoneFileIndex is 8-byte aligned.

  *  Multi-byte integer values are big-endian.

  *  The offsets in the ZoneFileIndex.byteOffsetZoneFrame[] array are
     relative to the offset in ZoneFileHeader.byteOffsetFrames. This is
     necessary as we may not know the offset of the start of the frame data
     until after the ZoneFileIndex structure is compressed.

  *  Currently there is no support for encryption or compression.


Changes to ext/zonefile/zonefile.c.
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
  "  ofst INTEGER,"              \
  "  sz INTEGER"                 \
  ")"

#define ZONEFILE_FILES_SCHEMA    \
  "CREATE TABLE z2("             \
  "  filename TEXT,"             \
  "  priority INTEGER,"          \
  "  ekey BLOB,"                 \
  "  header JSON HIDDEN"         \
  ")"


#include <stdio.h>
#include <string.h>







<







54
55
56
57
58
59
60

61
62
63
64
65
66
67
  "  ofst INTEGER,"              \
  "  sz INTEGER"                 \
  ")"

#define ZONEFILE_FILES_SCHEMA    \
  "CREATE TABLE z2("             \
  "  filename TEXT,"             \

  "  ekey BLOB,"                 \
  "  header JSON HIDDEN"         \
  ")"


#include <stdio.h>
#include <string.h>
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
*/
static int zffColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){
  ZonefileFilesCsr *pCsr = (ZonefileFilesCsr*)cur;
  switch( i ){
    case 0: /* filename */
      sqlite3_result_value(ctx, sqlite3_column_value(pCsr->pSelect, 0));
      break;
    case 1: /* priority */
      break;
    case 2: /* ekey */
      break;
    case 3: { /* header */
      const char *zFile = (const char*)sqlite3_column_text(pCsr->pSelect, 0);
      zonefileJsonHeader(ctx, zFile);
      break;
    }
  }
  return SQLITE_OK;
}







|

<
<
|







740
741
742
743
744
745
746
747
748


749
750
751
752
753
754
755
756
*/
static int zffColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){
  ZonefileFilesCsr *pCsr = (ZonefileFilesCsr*)cur;
  switch( i ){
    case 0: /* filename */
      sqlite3_result_value(ctx, sqlite3_column_value(pCsr->pSelect, 0));
      break;
    case 1: /* ekey */
      break;


    case 2: { /* header */
      const char *zFile = (const char*)sqlite3_column_text(pCsr->pSelect, 0);
      zonefileJsonHeader(ctx, zFile);
      break;
    }
  }
  return SQLITE_OK;
}
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
**
** A delete specifies a single argument - the rowid of the row to remove.
** 
** Update and insert operations pass:
**
**   1. The "old" rowid, or NULL.
**   2. The "new" rowid.
**   3. Values for each of the 4 columns: (filename,priority,ekey,header)
*/
static int zffUpdate(
  sqlite3_vtab *pVtab, 
  int nVal, 
  sqlite3_value **apVal, 
  sqlite_int64 *pRowid
){







|







865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
**
** A delete specifies a single argument - the rowid of the row to remove.
** 
** Update and insert operations pass:
**
**   1. The "old" rowid, or NULL.
**   2. The "new" rowid.
**   3. Values for each of the 3 columns: (filename,ekey,header)
*/
static int zffUpdate(
  sqlite3_vtab *pVtab, 
  int nVal, 
  sqlite3_value **apVal, 
  sqlite_int64 *pRowid
){
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
          "  fileid INTEGER,"
          "  frame INTEGER,"
          "  ofst INTEGER,"
          "  sz INTEGER"
          ");"
          "CREATE TABLE %Q.'%q_shadow_file'(" 
          "  filename TEXT,"
          "  priority INTEGER,"
          "  fileid INTEGER PRIMARY KEY"
          ");" 
          "CREATE VIRTUAL TABLE %Q.'%q_files' USING zonefile_files;",
          zDb, zName, zDb, zName, zDb, zName
      );
  
      if( zSql==0 ){







<







988
989
990
991
992
993
994

995
996
997
998
999
1000
1001
          "  fileid INTEGER,"
          "  frame INTEGER,"
          "  ofst INTEGER,"
          "  sz INTEGER"
          ");"
          "CREATE TABLE %Q.'%q_shadow_file'(" 
          "  filename TEXT,"

          "  fileid INTEGER PRIMARY KEY"
          ");" 
          "CREATE VIRTUAL TABLE %Q.'%q_files' USING zonefile_files;",
          zDb, zName, zDb, zName, zDb, zName
      );
  
      if( zSql==0 ){