/ Check-in [0e448bc6]
Login

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

Overview
Comment:Fix a bug in pragma table_info. Column default values specified as negative numbers (col DEFAULT -1) were being reported as NULL by the pragma. (CVS 5839)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:0e448bc6096c7ee3b21dbd22dc4ca9470ae7ba31
User & Date: danielk1977 2008-10-23 05:45:07
Context
2008-10-25
09:35
Add file tkt3461.test with a few examples of bug #3461. Because these tests currently fail they are disabled for now. (CVS 5840) check-in: f2cc1591 user: danielk1977 tags: trunk
2008-10-23
05:45
Fix a bug in pragma table_info. Column default values specified as negative numbers (col DEFAULT -1) were being reported as NULL by the pragma. (CVS 5839) check-in: 0e448bc6 user: danielk1977 tags: trunk
2008-10-22
18:27
Updated configure/makefiles to handle SQLITE_ENABLE* compile options. Made sure makefile passes command line options (OPTS=-Dfoo) to the compiler. Add -DSQLITE_COVERAGE_TEST=1 if gcov being used. (CVS 5838) check-in: acb106e5 user: shane tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/parse.y.

    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains SQLite's grammar for SQL.  Process this file
    13     13   ** using the lemon parser generator to generate C code that runs
    14     14   ** the parser.  Lemon will also generate a header file containing
    15     15   ** numeric codes for all of the tokens.
    16     16   **
    17         -** @(#) $Id: parse.y,v 1.261 2008/10/11 17:35:16 drh Exp $
           17  +** @(#) $Id: parse.y,v 1.262 2008/10/23 05:45:07 danielk1977 Exp $
    18     18   */
    19     19   
    20     20   // All token codes are small integers with #defines that begin with "TK_"
    21     21   %token_prefix TK_
    22     22   
    23     23   // The type of the data attached to each token is Token.  This is also the
    24     24   // default type for non-terminals.
................................................................................
   242    242   carglist ::= carglist carg.
   243    243   carglist ::= .
   244    244   carg ::= CONSTRAINT nm ccons.
   245    245   carg ::= ccons.
   246    246   ccons ::= DEFAULT term(X).            {sqlite3AddDefaultValue(pParse,X);}
   247    247   ccons ::= DEFAULT LP expr(X) RP.      {sqlite3AddDefaultValue(pParse,X);}
   248    248   ccons ::= DEFAULT PLUS term(X).       {sqlite3AddDefaultValue(pParse,X);}
   249         -ccons ::= DEFAULT MINUS term(X).      {
          249  +ccons ::= DEFAULT MINUS(A) term(X).      {
   250    250     Expr *p = sqlite3PExpr(pParse, TK_UMINUS, X, 0, 0);
          251  +  sqlite3ExprSpan(p,&A,&X->span);
   251    252     sqlite3AddDefaultValue(pParse,p);
   252    253   }
   253    254   ccons ::= DEFAULT id(X).              {
   254    255     Expr *p = sqlite3PExpr(pParse, TK_STRING, 0, 0, &X);
   255    256     sqlite3AddDefaultValue(pParse,p);
   256    257   }
   257    258   

Changes to src/pragma.c.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used to implement the PRAGMA command.
    13     13   **
    14         -** $Id: pragma.c,v 1.190 2008/10/17 18:51:53 danielk1977 Exp $
           14  +** $Id: pragma.c,v 1.191 2008/10/23 05:45:07 danielk1977 Exp $
    15     15   */
    16     16   #include "sqliteInt.h"
    17     17   #include <ctype.h>
    18     18   
    19     19   /* Ignore this whole file if pragmas are disabled
    20     20   */
    21     21   #if !defined(SQLITE_OMIT_PRAGMA) && !defined(SQLITE_OMIT_PARSER)
................................................................................
   773    773             nHidden++;
   774    774             continue;
   775    775           }
   776    776           sqlite3VdbeAddOp2(v, OP_Integer, i-nHidden, 1);
   777    777           sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pCol->zName, 0);
   778    778           sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
   779    779              pCol->zType ? pCol->zType : "", 0);
   780         -        sqlite3VdbeAddOp2(v, OP_Integer, pCol->notNull, 4);
          780  +        sqlite3VdbeAddOp2(v, OP_Integer, (pCol->notNull ? 1 : 0), 4);
   781    781           if( pCol->pDflt && (pDflt = &pCol->pDflt->span)->z ){
   782    782             sqlite3VdbeAddOp4(v, OP_String8, 0, 5, 0, (char*)pDflt->z, pDflt->n);
   783    783           }else{
   784    784             sqlite3VdbeAddOp2(v, OP_Null, 0, 5);
   785    785           }
   786    786           sqlite3VdbeAddOp2(v, OP_Integer, pCol->isPrimKey, 6);
   787    787           sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);

Changes to test/pragma.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # This file implements tests for the PRAGMA command.
    14     14   #
    15         -# $Id: pragma.test,v 1.68 2008/10/10 17:47:21 danielk1977 Exp $
           15  +# $Id: pragma.test,v 1.69 2008/10/23 05:45:07 danielk1977 Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Test organization:
    21     21   #
    22     22   # pragma-1.*: Test cache_size, default_cache_size and synchronous on main db.
................................................................................
   564    564     } {0 col_temp {} 0 {} 0}
   565    565     do_test pragma-6.6.4 {
   566    566       execsql {
   567    567         PRAGMA main.table_info(trial);
   568    568       }
   569    569     } {0 col_main {} 0 {} 0}
   570    570   }
          571  +
          572  +breakpoint
          573  +do_test pragma-6.7 {
          574  +  execsql {
          575  +    CREATE TABLE test_table(
          576  +      one INT NOT NULL DEFAULT -1, 
          577  +      two text,
          578  +      three VARCHAR(45, 65) DEFAULT 'abcde',
          579  +      four REAL DEFAULT X'abcdef',
          580  +      five DEFAULT CURRENT_TIME
          581  +    );
          582  +    PRAGMA table_info(test_table);
          583  +  }
          584  +} [concat \
          585  +  {0 one INT 1 -1 0} \
          586  +  {1 two text 0 {} 0} \
          587  +  {2 three {VARCHAR(45, 65)} 0 'abcde' 0} \
          588  +  {3 four REAL 0 X'abcdef' 0} \
          589  +  {4 five {} 0 CURRENT_TIME 0} \
          590  +]
   571    591   } ;# ifcapable schema_pragmas
   572    592   # Miscellaneous tests
   573    593   #
   574    594   ifcapable schema_pragmas {
   575    595   do_test pragma-7.1 {
   576    596     # Make sure a pragma knows to read the schema if it needs to
   577    597     db close