Update sqlite3_column_decltype() to return NULL as the declartion type for

an expression that is not a column reference. (CVS 1646)

FossilOrigin-Name: ee9dffd986621490af7bd45c7fe070bb7da8c357
This commit is contained in:
danielk1977
2004-06-21 07:36:32 +00:00
parent b28af71a22
commit 00e279d9f7
7 changed files with 66 additions and 77 deletions
+10 -10
View File
@@ -1,5 +1,5 @@
C Update\ssqlite3_changes()\sto\smatch\sthe\sdocumentation\sand\sadd\nsqlite3_total_changes().\s(CVS\s1645)
D 2004-06-21T06:50:27
C Update\ssqlite3_column_decltype()\sto\sreturn\sNULL\sas\sthe\sdeclartion\stype\sfor\nan\sexpression\sthat\sis\snot\sa\scolumn\sreference.\s(CVS\s1646)
D 2004-06-21T07:36:32
F Makefile.in d69d53c543518c1572ee0a8e8723d7e00bdb2266
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -32,7 +32,7 @@ F src/build.c 2ed1f14a72ce94a2e4adf333272d67a49925304b
F src/date.c b3e8b2bef1e3f2ce24e5b057203036defb18c3f1
F src/delete.c 19287dd204569519636a04eca2b66c49c26e9266
F src/encode.c a876af473d1d636faa3dca51c7571f2e007eea37
F src/expr.c 9ae0e55a230802da35a55fd6e87533cca0301af9
F src/expr.c c5c875be667d76f92221f8fa6b30d507a7643612
F src/func.c 3d32878eeb4c6a9977c72ec19984d329b6954c7e
F src/hash.c 440c2f8cb373ee1b4e13a0988489c7cd95d55b6f
F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb
@@ -54,10 +54,10 @@ F src/parse.y 097438674976355a10cf177bd97326c548820b86
F src/pragma.c 318a60581e8420f16e877e62b1dfabbb23c96177
F src/printf.c 823b6a5cbedb6971a9e62f5d83204fe9b0be7c1b
F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
F src/select.c 9aa82bbc63983a304bc51d4a7c259e759f92c8dc
F src/select.c 7305795965f7702c6d95fc023dee138b40e90d41
F src/shell.c 24b641700c9d90f361fcfa4f432c5b4aff704e6d
F src/sqlite.h.in a3d593016d1a1a514d7a26c8a353b58caf62e798
F src/sqliteInt.h 0d2e3647c0c881826eb07430cd3745c1fee03c27
F src/sqliteInt.h b379bc549c9d812090d6c33ff5f229b34346ac0c
F src/table.c af14284fa36c8d41f6829e3f2819dce07d3e2de2
F src/tclsqlite.c 8d093146332b2f0cbf2a8ebe8597d481619308a3
F src/test1.c ee426e026ad9223483e7a84bb68849fc6e9f542e
@@ -93,7 +93,7 @@ F test/btree4.test 3797b4305694c7af6828675b0f4b1424b8ca30e4
F test/btree5.test 8e5ff32c02e685d36516c6499add9375fe1377f2
F test/btree6.test a5ede6bfbbb2ec8b27e62813612c0f28e8f3e027
F test/btree7.test 429b96cfef5b51a7d512cfb4b5b3e453384af293
F test/capi2.test 7ff5ef9efee9f5ad1945e5f80791a7469ae1a040
F test/capi2.test 9ad428f7f228142be1bd9e7d4a906d7d2fa53e6e
F test/capi3.test 6528034f21c4e8e404032124cb58b14ce934598c
F test/collate1.test 2ee4fa3a47a652ccf56c5ddf65dcc44d9bad82ef
F test/collate2.test c1a3b41f761b28853c5696037f92de928f93233b
@@ -151,7 +151,7 @@ F test/select5.test 3f3f0f31e674fa61f8a3bdb6af1517dfae674081
F test/select6.test a9e31906e700e7c7592c4d0acfc022808f718baf
F test/sort.test dbd94673b05054e44ca3f08a80faa1e890ef06d8
F test/subselect.test f0fea8cf9f386d416d64d152e3c65f9116d0f50f
F test/table.test 06c077c82d1a0df45426518064e674d97def6485
F test/table.test b6d07f04c4157d1f2a37fb7febe36b250d468e31
F test/tableapi.test b21ab097e87a5484bb61029e69e1a4e5c5e65ede
F test/tclsqlite.test 2517b10ee2c806fb700548f54540aec7d62ed14a
F test/temptable.test 63a16e3ad19adf073cfbcdf7624c92ac5236522c
@@ -225,7 +225,7 @@ F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
F www/version3.tcl af528563442e3039928f9018327a18157e53a44f
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
P d2ccac9d01994de09a195d71cb63d1bf9fb0d33f
R 2dec0579dc0c3cd8d98bed6d72c511bb
P ae2f4a0943854fedbbb6fab1dc3aaf972722ed95
R 7299ca512e8450a2353e9ae1a8b64125
U danielk1977
Z 2ddd8a9b96a59cb5f116b91751ad2717
Z 6cdb9c41aeb5eb406e77c151d7110ee7
+1 -1
View File
@@ -1 +1 @@
ae2f4a0943854fedbbb6fab1dc3aaf972722ed95
ee9dffd986621490af7bd45c7fe070bb7da8c357
+1 -38
View File
@@ -12,7 +12,7 @@
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
** $Id: expr.c,v 1.145 2004/06/19 14:49:12 drh Exp $
** $Id: expr.c,v 1.146 2004/06/21 07:36:32 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -1059,43 +1059,6 @@ int sqlite3ExprCheck(Parse *pParse, Expr *pExpr, int allowAgg, int *pIsAgg){
return nErr;
}
/*
** Return one of the SQLITE_AFF_* affinity types that indicates the likely
** data type of the result of the given expression.
**
** Not every expression has a fixed type. If the type cannot be determined
** at compile-time, then try to return the type affinity if the expression
** is a column. Otherwise just return SQLITE_AFF_NONE.
**
** The sqlite3ExprResolveIds() and sqlite3ExprCheck() routines must have
** both been called on the expression before it is passed to this routine.
*/
int sqlite3ExprType(Expr *p){
if( p==0 ) return SQLITE_AFF_NONE;
while( p ) switch( p->op ){
case TK_CONCAT:
case TK_STRING:
case TK_BLOB:
return SQLITE_AFF_TEXT;
case TK_AS:
p = p->pLeft;
break;
case TK_VARIABLE:
case TK_NULL:
return SQLITE_AFF_NONE;
case TK_SELECT: /*** FIX ME ****/
case TK_COLUMN: /*** FIX ME ****/
case TK_CASE: /*** FIX ME ****/
default:
return SQLITE_AFF_NUMERIC;
}
return SQLITE_AFF_NONE;
}
/*
** Generate an instruction that will put the integer describe by
** text z[0..n-1] on the stack.
+30 -22
View File
@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.193 2004/06/19 14:49:12 drh Exp $
** $Id: select.c,v 1.194 2004/06/21 07:36:32 danielk1977 Exp $
*/
#include "sqliteInt.h"
@@ -630,30 +630,38 @@ static void generateSortTail(
** The declaration type for a ROWID field is INTEGER.
*/
static const char *columnType(Parse *pParse, SrcList *pTabList, Expr *pExpr){
char const *zType = 0;
char const *zType;
int j;
if( pExpr==0 ) return 0;
if( pExpr->op==TK_COLUMN && pTabList ){
Table *pTab;
int iCol = pExpr->iColumn;
for(j=0; j<pTabList->nSrc && pTabList->a[j].iCursor!=pExpr->iTable; j++){}
assert( j<pTabList->nSrc );
pTab = pTabList->a[j].pTab;
if( iCol<0 ) iCol = pTab->iPKey;
assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );
if( iCol<0 ){
zType = "INTEGER";
}else{
zType = pTab->aCol[iCol].zType;
if( !zType ) zType = "";
if( pExpr==0 || pTabList==0 ) return 0;
switch( pExpr->op ){
case TK_COLUMN: {
Table *pTab;
int iCol = pExpr->iColumn;
for(j=0; j<pTabList->nSrc && pTabList->a[j].iCursor!=pExpr->iTable; j++){}
assert( j<pTabList->nSrc );
pTab = pTabList->a[j].pTab;
if( iCol<0 ) iCol = pTab->iPKey;
assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );
if( iCol<0 ){
zType = "INTEGER";
}else{
zType = pTab->aCol[iCol].zType;
}
break;
}
}else{
switch( sqlite3ExprType(pExpr) ){
case SQLITE_AFF_TEXT: zType = "TEXT"; break;
case SQLITE_AFF_NUMERIC: zType = "NUMERIC"; break;
default: zType = "ANY"; break;
case TK_AS:
zType = columnType(pParse, pTabList, pExpr->pLeft);
break;
case TK_SELECT: {
Select *pS = pExpr->pSelect;
zType = columnType(pParse, pS->pSrc, pS->pEList->a[0].pExpr);
break;
}
default:
zType = 0;
}
return zType;
}
@@ -671,7 +679,7 @@ static void generateColumnTypes(
for(i=0; i<pEList->nExpr; i++){
Expr *p = pEList->a[i].pExpr;
const char *zType = columnType(pParse, pTabList, p);
if( p==0 ) continue;
if( zType==0 ) continue;
/* The vdbe must make it's own copy of the column-type, in case the
** schema is reset before this virtual machine is deleted.
*/
+1 -2
View File
@@ -11,7 +11,7 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.296 2004/06/21 06:50:28 danielk1977 Exp $
** @(#) $Id: sqliteInt.h,v 1.297 2004/06/21 07:36:32 danielk1977 Exp $
*/
#include "config.h"
#include "sqlite3.h"
@@ -1283,7 +1283,6 @@ int sqlite3RunVacuum(char**, sqlite*);
int sqlite3GlobCompare(const unsigned char*,const unsigned char*);
char *sqlite3NameFromToken(Token*);
int sqlite3ExprCheck(Parse*, Expr*, int, int*);
int sqlite3ExprType(Expr*);
int sqlite3ExprCompare(Expr*, Expr*);
int sqliteFuncId(Token*);
int sqlite3ExprResolveIds(Parse*, SrcList*, ExprList*, Expr*);
+2 -2
View File
@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this script testing the callback-free C/C++ API.
#
# $Id: capi2.test,v 1.15 2004/06/21 06:50:29 danielk1977 Exp $
# $Id: capi2.test,v 1.16 2004/06/21 07:36:33 danielk1977 Exp $
#
set testdir [file dirname $argv0]
@@ -208,7 +208,7 @@ do_test capi2-3.7 {
[sqlite3_column_count $VM] \
[get_row_values $VM] \
[get_column_names $VM]
} {SQLITE_ROW 1 {{}} {5/0 NUMERIC}}
} {SQLITE_ROW 1 {{}} {5/0 {}}}
do_test capi2-3.8 {
sqlite3_finalize $VM
} {SQLITE_OK}
+21 -2
View File
@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing the CREATE TABLE statement.
#
# $Id: table.test,v 1.27 2004/06/19 00:16:31 drh Exp $
# $Id: table.test,v 1.28 2004/06/21 07:36:33 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -337,11 +337,15 @@ do_test table-8.3 {
SELECT * FROM [t4'abc];
}
} {cnt 1 max(b+c) 5}
# Update for v3: The declaration type of anything except a column is now a
# NULL pointer, so the created table has no column types. (Changed result
# from {{CREATE TABLE 't4''abc'(cnt NUMERIC,'max(b+c)' NUMERIC)}}).
do_test table-8.3.1 {
execsql {
SELECT sql FROM sqlite_master WHERE name='t4''abc'
}
} {{CREATE TABLE 't4''abc'(cnt NUMERIC,'max(b+c)' NUMERIC)}}
} {{CREATE TABLE 't4''abc'(cnt,'max(b+c)')}}
do_test table-8.4 {
execsql2 {
CREATE TEMPORARY TABLE t5 AS SELECT count(*) AS [y'all] FROM [t3'xyz];
@@ -502,4 +506,19 @@ do_test table-11.2 {
}
} {null null null null}
# Test that when creating a table using CREATE TABLE AS, column types are
# assigned correctly for (SELECT ...) and 'x AS y' expressions.
do_test table-12.1 {
execsql {
CREATE TABLE t8 AS SELECT b, h, a as i, (SELECT f FROM t7) as j FROM t7;
}
} {}
do_test table-12.2 {
execsql {
SELECT sql FROM sqlite_master WHERE tbl_name = 't8'
}
} {{CREATE TABLE t8(b number(5,10),h,i integer,j BLOB)}}
finish_test