SQLite

Check-in [aa512f72]
Login

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

Overview
Comment:Always create a statement journal when using the OP_ParseSchema opcode, as you never know when it might fail. See the discussion on forum post daa2c728cc.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: aa512f72cf5adfece6299db17bd122aeff0cdee2a25f83f60e2ebb05e99c9591
User & Date: drh 2020-10-26 18:14:12
Context
2020-10-31
16:33
Update the ALTER TABLE command to correctly handle UPDATE ... FROM statements within trigger programs. (check-in: 3e6af890 user: dan tags: trunk)
2020-10-27
11:13
Typo in btree.h (and unwanted merge; this branch for cherrypicking btree.h only) (check-in: eb6e5fc1 user: shearer tags: btree-code-documentation)
2020-10-26
18:14
Always create a statement journal when using the OP_ParseSchema opcode, as you never know when it might fail. See the discussion on forum post daa2c728cc. (check-in: aa512f72 user: drh tags: trunk)
16:22
Ensure that the table argument passed to Tcl_GetIndexFromObjStruct() in the sessions module test code is declared "static". (check-in: 80eba105 user: dan tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbeaux.c.

471
472
473
474
475
476
477

478
479
480
481
482
483
484
** The zWhere string must have been obtained from sqlite3_malloc().
** This routine will take ownership of the allocated memory.
*/
void sqlite3VdbeAddParseSchemaOp(Vdbe *p, int iDb, char *zWhere){
  int j;
  sqlite3VdbeAddOp4(p, OP_ParseSchema, iDb, 0, 0, zWhere, P4_DYNAMIC);
  for(j=0; j<p->db->nDb; j++) sqlite3VdbeUsesBtree(p, j);

}

/*
** Add an opcode that includes the p4 value as an integer.
*/
int sqlite3VdbeAddOp4Int(
  Vdbe *p,            /* Add the opcode to this VM */







>







471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
** The zWhere string must have been obtained from sqlite3_malloc().
** This routine will take ownership of the allocated memory.
*/
void sqlite3VdbeAddParseSchemaOp(Vdbe *p, int iDb, char *zWhere){
  int j;
  sqlite3VdbeAddOp4(p, OP_ParseSchema, iDb, 0, 0, zWhere, P4_DYNAMIC);
  for(j=0; j<p->db->nDb; j++) sqlite3VdbeUsesBtree(p, j);
  sqlite3MayAbort(p->pParse);
}

/*
** Add an opcode that includes the p4 value as an integer.
*/
int sqlite3VdbeAddOp4Int(
  Vdbe *p,            /* Add the opcode to this VM */
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
  sIter.v = v;

  while( (pOp = opIterNext(&sIter))!=0 ){
    int opcode = pOp->opcode;
    if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename 
     || opcode==OP_VDestroy
     || opcode==OP_VCreate
     || (opcode==OP_ParseSchema && pOp->p4.z==0)
     || ((opcode==OP_Halt || opcode==OP_HaltIfNull) 
      && ((pOp->p1)!=SQLITE_OK && pOp->p2==OE_Abort))
    ){
      hasAbort = 1;
      break;
    }
    if( opcode==OP_CreateBtree && pOp->p3==BTREE_INTKEY ) hasCreateTable = 1;







|







700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
  sIter.v = v;

  while( (pOp = opIterNext(&sIter))!=0 ){
    int opcode = pOp->opcode;
    if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename 
     || opcode==OP_VDestroy
     || opcode==OP_VCreate
     || opcode==OP_ParseSchema
     || ((opcode==OP_Halt || opcode==OP_HaltIfNull) 
      && ((pOp->p1)!=SQLITE_OK && pOp->p2==OE_Abort))
    ){
      hasAbort = 1;
      break;
    }
    if( opcode==OP_CreateBtree && pOp->p3==BTREE_INTKEY ) hasCreateTable = 1;

Changes to test/view.test.

782
783
784
785
786
787
788














789
790
}
do_execsql_test view-28.1 {
  SELECT 0 IN (c0) FROM t0;
} {0}
do_execsql_test view-28.2 {
  SELECT 0 IN (c0) FROM (SELECT c0 FROM t0);
} {0}















finish_test







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


782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
}
do_execsql_test view-28.1 {
  SELECT 0 IN (c0) FROM t0;
} {0}
do_execsql_test view-28.2 {
  SELECT 0 IN (c0) FROM (SELECT c0 FROM t0);
} {0}

#-------------------------------------------------------------------------
# 2020-10-26.  https://sqlite.org/forum/forumpost/daa2c728cc
#
reset_db
do_catchsql_test view-29.0 {
  CREATE TABLE t1(a,b,c);
  CREATE VIEW IF NOT EXISTS IF AS SELECT null;
} {1 {malformed database schema (IF) - near "AS": syntax error}}
do_catchsql_test view-29.1 {
  CREATE TABLE t2(c,d,e);
  SELECT name FROM sqlite_schema ORDER BY name;
} {0 {t1 t2}}


finish_test