1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-16 23:02:26 +03:00

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)

FossilOrigin-Name: 0e448bc6096c7ee3b21dbd22dc4ca9470ae7ba31
This commit is contained in:
danielk1977
2008-10-23 05:45:07 +00:00
parent b1cd7308dc
commit f96a3778f9
5 changed files with 36 additions and 15 deletions

View File

@@ -1,5 +1,5 @@
C Updated\sconfigure/makefiles\sto\shandle\sSQLITE_ENABLE*\scompile\soptions.\s\sMade\ssure\smakefile\spasses\scommand\sline\soptions\s(OPTS=-Dfoo)\sto\sthe\scompiler.\s\sAdd\s-DSQLITE_COVERAGE_TEST=1\sif\sgcov\sbeing\sused.\s(CVS\s5838) C Fix\sa\sbug\sin\spragma\stable_info.\sColumn\sdefault\svalues\sspecified\sas\snegative\snumbers\s(col\sDEFAULT\s-1)\swere\sbeing\sreported\sas\sNULL\sby\sthe\spragma.\s(CVS\s5839)
D 2008-10-22T18:27:31 D 2008-10-23T05:45:07
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 3fe17eccd87d385b5adc9766828716cfdd154d6b F Makefile.in 3fe17eccd87d385b5adc9766828716cfdd154d6b
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -141,10 +141,10 @@ F src/os_unix.c 5e3b3c9a54546249c1317cff5343e965192f7f2b
F src/os_win.c a26292f39a73a446aa56b01871e73545da8ce3e4 F src/os_win.c a26292f39a73a446aa56b01871e73545da8ce3e4
F src/pager.c 8377118bd5ae055b66683926b264f6c04442317e F src/pager.c 8377118bd5ae055b66683926b264f6c04442317e
F src/pager.h 4a57b219c0765fe1870238064e3f46e4eb2cf5af F src/pager.h 4a57b219c0765fe1870238064e3f46e4eb2cf5af
F src/parse.y f4620f42b5e0141e20243b5f963d0fc9c180ab9b F src/parse.y 2c4758b4c5ead6de8cf7112f5a7cce7561d313fe
F src/pcache.c 5b80676e664019c1ebc8356cc25332dd69da6269 F src/pcache.c 5b80676e664019c1ebc8356cc25332dd69da6269
F src/pcache.h 2caf2deb6cbaa75c423b8b96fc1411069ee77c75 F src/pcache.h 2caf2deb6cbaa75c423b8b96fc1411069ee77c75
F src/pragma.c 10d61f211d819acd97174a41acc56394bd5bde7e F src/pragma.c 1eb8dad7282ec3985c4e0384f3b264c535e6dbef
F src/prepare.c c7e00ed1b0bdcf699b1aad651247d4dc3d281b0b F src/prepare.c c7e00ed1b0bdcf699b1aad651247d4dc3d281b0b
F src/printf.c 785f87120589c1db672e37c6eb1087c456e6f84d F src/printf.c 785f87120589c1db672e37c6eb1087c456e6f84d
F src/random.c a87afbd598aa877e23ac676ee92fd8ee5c786a51 F src/random.c a87afbd598aa877e23ac676ee92fd8ee5c786a51
@@ -459,7 +459,7 @@ F test/pagesize.test 0d9ff3fedfce6e5ffe8fa7aca9b6d3433a2e843b
F test/pcache.test 515b4c26e9f57660357dfff5b6b697acac1abc5f F test/pcache.test 515b4c26e9f57660357dfff5b6b697acac1abc5f
F test/pcache2.test e2260293e892190be65de89526dbc4f92c8b5a7c F test/pcache2.test e2260293e892190be65de89526dbc4f92c8b5a7c
F test/permutations.test 3f24cf55e9646b138a6980f78f18190f318af9a3 F test/permutations.test 3f24cf55e9646b138a6980f78f18190f318af9a3
F test/pragma.test 583937903d01cad823ae195573d90c02ea945717 F test/pragma.test 165372b62391d233715cde82d99f34d306f9257f
F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47
F test/printf.test 262a5acd3158f788e9bdf7f18d718f3af32ff6ef F test/printf.test 262a5acd3158f788e9bdf7f18d718f3af32ff6ef
F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x
@@ -650,7 +650,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P 5276e31d42070e7b94bd6050c4fa484dfbfe98ca P acb106e51f8bb7449a0e214075c559cc66497277
R f75966f13a1a4c468b2ca255119ec8fb R 8af90eb2367e9d5ee419c115778199bf
U shane U danielk1977
Z 9d361f844e39732b7b3007eb2b6fdc97 Z 1f739540af2aa117842cf86c5210d872

View File

@@ -1 +1 @@
acb106e51f8bb7449a0e214075c559cc66497277 0e448bc6096c7ee3b21dbd22dc4ca9470ae7ba31

View File

@@ -14,7 +14,7 @@
** the parser. Lemon will also generate a header file containing ** the parser. Lemon will also generate a header file containing
** numeric codes for all of the tokens. ** numeric codes for all of the tokens.
** **
** @(#) $Id: parse.y,v 1.261 2008/10/11 17:35:16 drh Exp $ ** @(#) $Id: parse.y,v 1.262 2008/10/23 05:45:07 danielk1977 Exp $
*/ */
// All token codes are small integers with #defines that begin with "TK_" // All token codes are small integers with #defines that begin with "TK_"
@@ -246,8 +246,9 @@ carg ::= ccons.
ccons ::= DEFAULT term(X). {sqlite3AddDefaultValue(pParse,X);} ccons ::= DEFAULT term(X). {sqlite3AddDefaultValue(pParse,X);}
ccons ::= DEFAULT LP expr(X) RP. {sqlite3AddDefaultValue(pParse,X);} ccons ::= DEFAULT LP expr(X) RP. {sqlite3AddDefaultValue(pParse,X);}
ccons ::= DEFAULT PLUS term(X). {sqlite3AddDefaultValue(pParse,X);} ccons ::= DEFAULT PLUS term(X). {sqlite3AddDefaultValue(pParse,X);}
ccons ::= DEFAULT MINUS term(X). { ccons ::= DEFAULT MINUS(A) term(X). {
Expr *p = sqlite3PExpr(pParse, TK_UMINUS, X, 0, 0); Expr *p = sqlite3PExpr(pParse, TK_UMINUS, X, 0, 0);
sqlite3ExprSpan(p,&A,&X->span);
sqlite3AddDefaultValue(pParse,p); sqlite3AddDefaultValue(pParse,p);
} }
ccons ::= DEFAULT id(X). { ccons ::= DEFAULT id(X). {

View File

@@ -11,7 +11,7 @@
************************************************************************* *************************************************************************
** This file contains code used to implement the PRAGMA command. ** This file contains code used to implement the PRAGMA command.
** **
** $Id: pragma.c,v 1.190 2008/10/17 18:51:53 danielk1977 Exp $ ** $Id: pragma.c,v 1.191 2008/10/23 05:45:07 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@@ -777,7 +777,7 @@ void sqlite3Pragma(
sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pCol->zName, 0); sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pCol->zName, 0);
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
pCol->zType ? pCol->zType : "", 0); pCol->zType ? pCol->zType : "", 0);
sqlite3VdbeAddOp2(v, OP_Integer, pCol->notNull, 4); sqlite3VdbeAddOp2(v, OP_Integer, (pCol->notNull ? 1 : 0), 4);
if( pCol->pDflt && (pDflt = &pCol->pDflt->span)->z ){ if( pCol->pDflt && (pDflt = &pCol->pDflt->span)->z ){
sqlite3VdbeAddOp4(v, OP_String8, 0, 5, 0, (char*)pDflt->z, pDflt->n); sqlite3VdbeAddOp4(v, OP_String8, 0, 5, 0, (char*)pDflt->z, pDflt->n);
}else{ }else{

View File

@@ -12,7 +12,7 @@
# #
# This file implements tests for the PRAGMA command. # This file implements tests for the PRAGMA command.
# #
# $Id: pragma.test,v 1.68 2008/10/10 17:47:21 danielk1977 Exp $ # $Id: pragma.test,v 1.69 2008/10/23 05:45:07 danielk1977 Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@@ -568,6 +568,26 @@ ifcapable tempdb {
} }
} {0 col_main {} 0 {} 0} } {0 col_main {} 0 {} 0}
} }
breakpoint
do_test pragma-6.7 {
execsql {
CREATE TABLE test_table(
one INT NOT NULL DEFAULT -1,
two text,
three VARCHAR(45, 65) DEFAULT 'abcde',
four REAL DEFAULT X'abcdef',
five DEFAULT CURRENT_TIME
);
PRAGMA table_info(test_table);
}
} [concat \
{0 one INT 1 -1 0} \
{1 two text 0 {} 0} \
{2 three {VARCHAR(45, 65)} 0 'abcde' 0} \
{3 four REAL 0 X'abcdef' 0} \
{4 five {} 0 CURRENT_TIME 0} \
]
} ;# ifcapable schema_pragmas } ;# ifcapable schema_pragmas
# Miscellaneous tests # Miscellaneous tests
# #