/ Check-in [594ebc69]
Login

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

Overview
Comment:Enhance ALTER TABLE ADD COLUMN to support "DEFAULT true" and "DEFAULT false".
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 594ebc69557095c9262db39129dd50a3dbf038556a3d2a3ea69b82ed4c61e2b9
User & Date: drh 2018-04-18 11:35:35
Context
2018-04-18
16:03
Add support for PostgreSQL UPSERT syntax and functionality. check-in: fba24aec user: drh tags: trunk
11:35
Enhance ALTER TABLE ADD COLUMN to support "DEFAULT true" and "DEFAULT false". check-in: 594ebc69 user: drh tags: trunk
10:44
Add checks to the CLI that issue a warning if SQLite gets initialized prior to the last sqlite3_config() call. check-in: 40b11734 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbemem.c.

  1474   1474       zVal = &pExpr->u.zToken[2];
  1475   1475       nVal = sqlite3Strlen30(zVal)-1;
  1476   1476       assert( zVal[nVal]=='\'' );
  1477   1477       sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2,
  1478   1478                            0, SQLITE_DYNAMIC);
  1479   1479     }
  1480   1480   #endif
  1481         -
  1482   1481   #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
  1483   1482     else if( op==TK_FUNCTION && pCtx!=0 ){
  1484   1483       rc = valueFromFunction(db, pExpr, enc, affinity, &pVal, pCtx);
  1485   1484     }
  1486   1485   #endif
         1486  +  else if( op==TK_TRUEFALSE ){
         1487  +     pVal = valueNew(db, pCtx);
         1488  +     pVal->flags = MEM_Int;
         1489  +     pVal->u.i = pExpr->u.zToken[4]==0;
         1490  +  }
  1487   1491   
  1488   1492     *ppVal = pVal;
  1489   1493     return rc;
  1490   1494   
  1491   1495   no_mem:
  1492   1496   #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
  1493   1497     if( pCtx==0 || pCtx->pParse->nErr==0 )

Changes to test/istrue.test.

   139    139       SELECT x IS TRUE FROM t1;
   140    140     } [expr {$tn in [list 5 6] ? {1} : {0}}]
   141    141     do_execsql_test istrue-600.$tn.4 {
   142    142       SELECT x IS FALSE FROM t1;
   143    143     } {0}
   144    144   }
   145    145   
          146  +do_execsql_test istrue-700 {
          147  +  CREATE TABLE t7(
          148  +    a INTEGER PRIMARY KEY,
          149  +    b BOOLEAN DEFAULT false,
          150  +    c BOOLEAN DEFAULT true
          151  +  );
          152  +  INSERT INTO t7(a) VALUES(1);
          153  +  INSERT INTO t7(a,b,c) VALUES(2,true,false);
          154  +  ALTER TABLE t7 ADD COLUMN d BOOLEAN DEFAULT false;
          155  +  ALTER TABLE t7 ADD COLUMN e BOOLEAN DEFAULT true;
          156  +  INSERT INTO t7(a,b,c) VALUES(3,true,false);
          157  +  INSERT INTO t7 VALUES(4,false,true,true,false);
          158  +  SELECT *,'x' FROM t7 ORDER BY a;
          159  +} {1 0 1 0 1 x 2 1 0 0 1 x 3 1 0 0 1 x 4 0 1 1 0 x}
          160  +
   146    161   finish_test