/ Check-in [2cb37b95]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Silently ignore parser stack overflow when parsing a malformed schema in PRAGMA writable_schema mode.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2cb37b959c66b5ae3535ab81ba14a4ebf9732df7
User & Date: drh 2015-04-19 22:31:45
Context
2015-04-19
22:41
Fix a broken assert() and comparison for INSERT INTO ... SELECT when the SELECT uses an unknown collating sequence. check-in: e73ac0cb user: drh tags: trunk
22:31
Silently ignore parser stack overflow when parsing a malformed schema in PRAGMA writable_schema mode. check-in: 2cb37b95 user: drh tags: trunk
21:59
Fix another assert() that is not true if the database schema is corrupt. check-in: bc97cec6 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/build.c.

2447
2448
2449
2450
2451
2452
2453

2454
2455
2456
2457
2458
2459
2460
  int iDb;

  if( db->mallocFailed ){
    goto exit_drop_table;
  }
  assert( pParse->nErr==0 );
  assert( pName->nSrc==1 );

  if( noErr ) db->suppressErr++;
  pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]);
  if( noErr ) db->suppressErr--;

  if( pTab==0 ){
    if( noErr ) sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);
    goto exit_drop_table;







>







2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
  int iDb;

  if( db->mallocFailed ){
    goto exit_drop_table;
  }
  assert( pParse->nErr==0 );
  assert( pName->nSrc==1 );
  if( sqlite3ReadSchema(pParse) ) goto exit_drop_table;
  if( noErr ) db->suppressErr++;
  pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]);
  if( noErr ) db->suppressErr--;

  if( pTab==0 ){
    if( noErr ) sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);
    goto exit_drop_table;

Changes to test/misc5.test.

578
579
580
581
582
583
584


















585
586
587
588
589
590
591
  for {set i 0} {$i<200} {incr i} {
    append sql "(1+"
    append tail ")"
  }
  append sql 2$tail
  catchsql $sql
} {1 {parser stack overflow}}



















# Ticket #1911
#
ifcapable compound {
  do_test misc5-9.1 {
    execsql {
      SELECT name, type FROM sqlite_master WHERE name IS NULL







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
  for {set i 0} {$i<200} {incr i} {
    append sql "(1+"
    append tail ")"
  }
  append sql 2$tail
  catchsql $sql
} {1 {parser stack overflow}}

# Parser stack overflow is silently ignored when it occurs while parsing the
# schema and PRAGMA writable_schema is turned on.
#
do_test misc5-7.2 {
  sqlite3 db2 :memory:
  catchsql {
    CREATE TABLE t1(x UNIQUE);
    PRAGMA writable_schema=ON;
    UPDATE sqlite_master SET sql='CREATE table t(o CHECK(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((;VALUES(o)';
    BEGIN;
    CREATE TABLE t2(y);
    ROLLBACK;
    DROP TABLE IF EXISTS D;
  } db2
} {0 {}}
db2 close
  

# Ticket #1911
#
ifcapable compound {
  do_test misc5-9.1 {
    execsql {
      SELECT name, type FROM sqlite_master WHERE name IS NULL