Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix a problem with handling "k >= ?" constraints in the zonefile module. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | zonefile |
Files: | files | file ages | folders |
SHA3-256: |
9a99afafa3fb9ec4823e5030cb04a685 |
User & Date: | dan 2018-02-23 21:01:15.048 |
Context
2018-02-24
| ||
08:26 | Test edge cases in the zonefile module. Fix a broken error message in the same. (check-in: 1764ade22b user: dan tags: zonefile) | |
2018-02-23
| ||
21:01 | Fix a problem with handling "k >= ?" constraints in the zonefile module. (check-in: 9a99afafa3 user: dan tags: zonefile) | |
19:21 | Add test cases and minor fixes for the zonefile module. (check-in: dbbcbf0066 user: dan tags: zonefile) | |
Changes
Changes to ext/zonefile/zonefile.c.
︙ | ︙ | |||
1983 1984 1985 1986 1987 1988 1989 | */ static int zonefileParseOption( ZonefileTab *pTab, /* Zonefile vtab under construction */ const char *zOption, /* Text of option (column name) */ char **pzErr /* OUT: Error message */ ){ const char *z = zOption; | | < < < < > | 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 | */ static int zonefileParseOption( ZonefileTab *pTab, /* Zonefile vtab under construction */ const char *zOption, /* Text of option (column name) */ char **pzErr /* OUT: Error message */ ){ const char *z = zOption; const char *zOpt = z; int nOpt; const char *zVal; int rc = SQLITE_OK; /* Skip until EOF, whitespace or "=" */ assert( 0==zonefile_isspace(*z) ); while( *z && !zonefile_isspace(*z) && *z!='=' ) z++; nOpt = z-zOpt; /* Skip whitespace. Then check there is an "=". */ while( zonefile_isspace(*z) ) z++; if( *z!='=' ) goto parse_error; z++; |
︙ | ︙ | |||
2083 2084 2085 2086 2087 2088 2089 | } if( rc==SQLITE_OK ){ rc = sqlite3_declare_vtab(db, ZONEFILE_SCHEMA); } for(i=3; i<argc && rc==SQLITE_OK; i++){ | | | 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 | } if( rc==SQLITE_OK ){ rc = sqlite3_declare_vtab(db, ZONEFILE_SCHEMA); } for(i=3; i<argc && rc==SQLITE_OK; i++){ rc = zonefileParseOption(p, argv[i], pzErr); } if( rc==SQLITE_OK && p->nCacheSize<1 ) p->nCacheSize = 1; } if( rc!=SQLITE_OK ){ sqlite3_free(p); p = 0; |
︙ | ︙ | |||
2266 2267 2268 2269 2270 2271 2272 | if( idxNum & 0x01 ){ z1 = "k = ?"; }else{ if( idxNum & 0x02 ) { z1 = "k < ?"; } if( idxNum & 0x04 ) { z1 = "k <= ?"; } if( idxNum & 0x08 ) { if( z1 ) z2 = "k > ?"; else z1 = "k > ?"; } | | | 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 | if( idxNum & 0x01 ){ z1 = "k = ?"; }else{ if( idxNum & 0x02 ) { z1 = "k < ?"; } if( idxNum & 0x04 ) { z1 = "k <= ?"; } if( idxNum & 0x08 ) { if( z1 ) z2 = "k > ?"; else z1 = "k > ?"; } if( idxNum & 0x10 ) { if( z1 ) z2 = "k >= ?"; else z1 = "k >= ?"; } } rc = zonefilePrepare(pTab->db, &pCsr->pSelect, &pTab->base.zErrMsg, "SELECT k, fileid, fofst, fsz, ofst, sz FROM %Q.'%q_shadow_idx'%s%s%s%s", pTab->zDb, pTab->zName, z1 ? " WHERE " : "", z1, z2 ? " AND " : "", z2 |
︙ | ︙ |
Changes to ext/zonefile/zonefile1.test.
︙ | ︙ | |||
415 416 417 418 419 420 421 422 423 424 | do_catchsql_test 8.1 { CREATE VIRTUAL TABLE one USING zonefile_files; } {1 {do not create zonefile_files tables directly!}} do_catchsql_test 8.2 { CREATE VIRTUAL TABLE onetwothree USING zonefile_files; } {1 {do not create zonefile_files tables directly!}} finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | do_catchsql_test 8.1 { CREATE VIRTUAL TABLE one USING zonefile_files; } {1 {do not create zonefile_files tables directly!}} do_catchsql_test 8.2 { CREATE VIRTUAL TABLE onetwothree USING zonefile_files; } {1 {do not create zonefile_files tables directly!}} #------------------------------------------------------------------------- # A zone file containing zero keys. # reset_db load_static_extension db zonefile do_execsql_test 9.0 { CREATE TABLE s(k INTEGER PRIMARY KEY,frame INTEGER,idx INTEGER,v BLOB); SELECT zonefile_write('test.zonefile', 's'); } {{}} do_execsql_test 9.1 { CREATE VIRTUAL TABLE ss USING zonefile; INSERT INTO ss_files(filename) VALUES('test.zonefile'); SELECT * FROM ss; } {} #------------------------------------------------------------------------- # Test UPDATE and DELETE statements on the %_files virtual table. # reset_db load_static_extension db zonefile do_execsql_test 10.0 { CREATE TABLE data(k INTEGER PRIMARY KEY, v BLOB); INSERT INTO data(k, v) VALUES(1, randomblob(100)); INSERT INTO data(k, v) VALUES(2, randomblob(100)); INSERT INTO data(k, v) VALUES(3, randomblob(100)); INSERT INTO data(k, v) VALUES(4, randomblob(100)); INSERT INTO data(k, v) VALUES(5, randomblob(100)); INSERT INTO data(k, v) VALUES(6, randomblob(100)); INSERT INTO data(k, v) VALUES(7, randomblob(100)); INSERT INTO data(k, v) VALUES(8, randomblob(100)); INSERT INTO data(k, v) VALUES(9, randomblob(100)); CREATE VIEW v1 AS SELECT k, -1 AS frame, -1 AS idx, v FROM data WHERE k IN (1,2,3); SELECT zonefile_write('test1.zonefile', 'v1'); CREATE VIEW v2 AS SELECT k, -1 AS frame, -1 AS idx, v FROM data WHERE k IN (4,5,6); SELECT zonefile_write('test2.zonefile', 'v2'); CREATE VIEW v3 AS SELECT k, -1 AS frame, -1 AS idx, v FROM data WHERE k IN (7,8,9); SELECT zonefile_write('test3.zonefile', 'v3'); } {{} {} {}} do_execsql_test 10.1 { CREATE VIRTUAL TABLE "a b" USING zonefile; INSERT INTO "a b_files"(filename) VALUES('test1.zonefile'); SELECT k FROM "a b" } {1 2 3} do_execsql_test 10.2 { UPDATE "a b_files" SET filename = 'test2.zonefile'; SELECT k FROM "a b" } {4 5 6} do_execsql_test 10.3 { INSERT INTO "a b_files"(filename) VALUES('test1.zonefile'); INSERT INTO "a b_files"(filename) VALUES('test3.zonefile'); SELECT k FROM "a b" } {1 2 3 4 5 6 7 8 9} do_execsql_test 10.4 { DELETE FROM "a b_files" WHERE filename = 'test2.zonefile'; SELECT k FROM "a b" } {1 2 3 7 8 9} do_execsql_test 10.5 { DELETE FROM "a b_files" WHERE filename = 'test1.zonefile'; SELECT k FROM "a b" } {7 8 9} #------------------------------------------------------------------------- # reset_db load_static_extension db zonefile do_execsql_test 11.0 { CREATE TABLE data(k INTEGER PRIMARY KEY, v BLOB); INSERT INTO data(k, v) VALUES(-1, randomblob(100)); INSERT INTO data(k, v) VALUES(1000, randomblob(100)); INSERT INTO data(k, v) VALUES(-1000, randomblob(100)); INSERT INTO data(k, v) VALUES(9223372036854775807, randomblob(100)); INSERT INTO data(k, v) VALUES(-9223372036854775807, randomblob(100)); INSERT INTO data(k, v) VALUES(-9223372036854775808, randomblob(100)); CREATE VIEW v1 AS SELECT k, -1 AS frame, -1 AS idx, v FROM data; SELECT zonefile_write('test1.zonefile', 'v1'); } {{}} do_execsql_test 11.1 { CREATE VIRTUAL TABLE one USING zonefile; INSERT INTO "one_files"(filename) VALUES('test1.zonefile'); SELECT k FROM one } {-9223372036854775808 -9223372036854775807 -1000 -1 1000 9223372036854775807} do_execsql_test 11.2 { SELECT count(*) FROM data JOIN one USING (k) WHERE one.v==data.v } 6 #------------------------------------------------------------------------- # do_catchsql_test 12.1 { CREATE VIRTUAL TABLE nm USING zonefile(abcd) } {1 {parse error in option: abcd}} do_catchsql_test 12.2 { CREATE VIRTUAL TABLE nm USING zonefile(a=b) } {1 {parse error in option: a=b}} do_catchsql_test 12.3 { CREATE VIRTUAL TABLE nm USING zonefile(cachesiza=b) } {1 {parse error in option: cachesiza=b}} #------------------------------------------------------------------------- # reset_db load_static_extension db zonefile do_execsql_test 11.0 { CREATE TABLE data(k INTEGER PRIMARY KEY, v BLOB); WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<250 ) INSERT INTO data SELECT i, randomblob(100) FROM s; CREATE VIEW v1 AS SELECT k, -1 AS frame, -1 AS idx, v FROM data; SELECT zonefile_write('test1.zonefile', 'v1'); CREATE VIRTUAL TABLE nm USING zonefile; INSERT INTO nm_files(filename) VALUES('test1.zonefile'); } {{}} foreach {tn cond} { 1 "k > 30" 2 "k >= 100" 3 "k <= 100" 4 "k < 55" 5 "k LIKE '1%'" 6 "k BETWEEN 10 AND 20" 7 "k > 100 AND k < 200" } { do_execsql_test 11.$tn.1 [subst { SELECT count(*) FROM nm WHERE $cond }] [db one "SELECT count(*) FROM data WHERE $cond"] do_execsql_test 11.$tn.2 [subst { SELECT count(*) FROM nm WHERE $cond AND v!=(SELECT v FROM data WHERE k=nm.k); }] 0 } finish_test |
Changes to ext/zonefile/zonefilefault.test.
︙ | ︙ | |||
136 137 138 139 140 141 142 143 144 145 | faultsim_restore_and_reopen load_static_extension db zonefile } -body { execsql { SELECT json_extract(header, '$.magicNumber') FROM zz_files } } -test { faultsim_test_result {0 1179332920} } finish_test | > > > > > > > > > > > > > > > > > > > > > | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | faultsim_restore_and_reopen load_static_extension db zonefile } -body { execsql { SELECT json_extract(header, '$.magicNumber') FROM zz_files } } -test { faultsim_test_result {0 1179332920} } do_faultsim_test 2.3 -faults oom* -prep { faultsim_restore_and_reopen load_static_extension db zonefile } -body { execsql { DELETE FROM zz_files } } -test { faultsim_test_result {0 {}} } #------------------------------------------------------------------------- reset_db faultsim_save_and_close do_faultsim_test 3 -faults oom* -prep { faultsim_restore_and_reopen load_static_extension db zonefile } -body { execsql { CREATE VIRTUAL TABLE t1 USING zonefile(cachesize=5) } } -test { faultsim_test_result {0 {}} } finish_test |