/ Check-in [64c9ccf6]
Login

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

Overview
Comment:Return SQLITE_CONSTRAINT if a user attempts to update a zipfile table.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 64c9ccf6c5598a68135e78dad128ec070afa49416e1d1f35745a24276e7aeeea
User & Date: dan 2018-01-09 20:44:04
Context
2018-01-09
20:49
Fix harmless compiler warnings. check-in: 0fb42090 user: mistachkin tags: trunk
20:44
Return SQLITE_CONSTRAINT if a user attempts to update a zipfile table. check-in: 64c9ccf6 user: dan tags: trunk
20:34
In the os_unix.c implementation of xOpen(), do not return SQLITE_READONLY_DIRECTORY in cases where the file cannot be opened for reasons other than a readonly directory, such as the process running out of file descriptors. check-in: fa8b80bb user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/misc/zipfile.c.

1217
1218
1219
1220
1221
1222
1223



1224
1225
1226
1227
1228
1229
1230
1231
1232

1233
1234
1235
1236
1237
1238
1239

  int mNull;

  assert( pTab->zFile );
  assert( pTab->pWriteFd );

  if( sqlite3_value_type(apVal[0])!=SQLITE_NULL ){



    i64 iDelete = sqlite3_value_int64(apVal[0]);
    ZipfileEntry *p;
    for(p=pTab->pFirstEntry; p; p=p->pNext){
      if( p->iRowid==iDelete ){
        p->bDeleted = 1;
        break;
      }
    }
    if( nVal==1 ) return SQLITE_OK;

  }

  mNull = (sqlite3_value_type(apVal[5])==SQLITE_NULL ? 0x0 : 0x8)  /* sz */
        + (sqlite3_value_type(apVal[6])==SQLITE_NULL ? 0x0 : 0x4)  /* rawdata */
        + (sqlite3_value_type(apVal[7])==SQLITE_NULL ? 0x0 : 0x2)  /* data */
        + (sqlite3_value_type(apVal[8])==SQLITE_NULL ? 0x0 : 0x1); /* method */
  if( mNull==0x00 ){     







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







1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243

  int mNull;

  assert( pTab->zFile );
  assert( pTab->pWriteFd );

  if( sqlite3_value_type(apVal[0])!=SQLITE_NULL ){
    if( nVal>1 ){
      return SQLITE_CONSTRAINT;
    }else{
      i64 iDelete = sqlite3_value_int64(apVal[0]);
      ZipfileEntry *p;
      for(p=pTab->pFirstEntry; p; p=p->pNext){
        if( p->iRowid==iDelete ){
          p->bDeleted = 1;
          break;
        }
      }
      return SQLITE_OK;
    }
  }

  mNull = (sqlite3_value_type(apVal[5])==SQLITE_NULL ? 0x0 : 0x8)  /* sz */
        + (sqlite3_value_type(apVal[6])==SQLITE_NULL ? 0x0 : 0x4)  /* rawdata */
        + (sqlite3_value_type(apVal[7])==SQLITE_NULL ? 0x0 : 0x2)  /* data */
        + (sqlite3_value_type(apVal[8])==SQLITE_NULL ? 0x0 : 0x1); /* method */
  if( mNull==0x00 ){     

Changes to test/zipfile.test.

98
99
100
101
102
103
104










105
106
107
108
  SELECT name, mode, data FROM zzz;
} {
  dirname 16877 {}
  dirname2 16877 {}
  dirname2/file1.txt 33188 abcdefghijklmnop
}













finish_test








>
>
>
>
>
>
>
>
>
>




98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
  SELECT name, mode, data FROM zzz;
} {
  dirname 16877 {}
  dirname2 16877 {}
  dirname2/file1.txt 33188 abcdefghijklmnop
}

do_catchsql_test 2.3 {
  UPDATE zzz SET name = 'dirname3' WHERE name = 'dirname';
} {1 {constraint failed}}
do_execsql_test 2.4 {
  SELECT name, mode, data FROM zzz;
} {
  dirname 16877 {}
  dirname2 16877 {}
  dirname2/file1.txt 33188 abcdefghijklmnop
}


finish_test