Fix incorrect type conversions when copying from a table into itself.

Ticket #1536. (CVS 2773)

FossilOrigin-Name: a2e55a3828d74d78b0b76f956a537a0d906f3191
This commit is contained in:
drh 2005-11-24 13:15:32 +00:00
parent 32daab6cb0
commit 3eda040be9
5 changed files with 60 additions and 18 deletions

View File

@ -1,5 +1,5 @@
C Less\sverbose\soutput\swhen\sEXPLAIN\sQUERY\sPLAN\sidentifies\suse\sof\sthe\sprimary\skey.\s(CVS\s2772)
D 2005-11-21T12:48:24
C Fix\sincorrect\stype\sconversions\swhen\scopying\sfrom\sa\stable\sinto\sitself.\nTicket\s#1536.\s(CVS\s2773)
D 2005-11-24T13:15:33
F Makefile.in 12784cdce5ffc8dfb707300c34e4f1eb3b8a14f1
F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@ -45,7 +45,7 @@ F src/expr.c 3b1a24aab6a17e7cc62d904eba802beccc3e925f
F src/func.c 7d81dccd9c440c6c4e761056333e629192814af0
F src/hash.c 8747cf51d12de46512880dfcf1b68b4e24072863
F src/hash.h 1b0c445e1c89ff2aaad9b4605ba61375af001e84
F src/insert.c e57626dab37b14a1010f2d0304e5c54eedc9cc8b
F src/insert.c da031c3ed8e1675fac891990095d277c2ba6e205
F src/legacy.c d58ea507bce885298a2c8c3cbb0f4bff5d47830b
F src/main.c 97bb830cdbd378d1f87469618471f52d9d263d09
F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070
@ -229,6 +229,7 @@ F test/tkt1473.test e4637c27d606fd002de78113a8e1a142e48ffb18
F test/tkt1501.test 0cf859299f0052ecfaf7db6f0984f122c7db5d15
F test/tkt1512.test 8efd8d07e27e99d7462f75b5711de65eb7708baf
F test/tkt1514.test baa587a69fa2e8d575ebdaf1460f711281dcba49
F test/tkt1536.test 83ff7a7b6e248016f8d682d4f7a4ae114070d466
F test/trace.test 9fd28695c463b90c2d32c387a432e01eb26e8ccf
F test/trans.test 10506dc30305cfb8c4098359f7f6f64786f69c5e
F test/trigger1.test 152aed5a1fa90709fe171f2ca501a6b7f7901479
@ -308,7 +309,7 @@ F www/omitted.tcl ee6b46f83d513b2187869740da829a700e1a355e
F www/opcode.tcl 5bd68059416b223515a680d410a9f7cb6736485f
F www/optimizer.tcl d6812a10269bd0d7c488987aac0ad5036cace9dc
F www/optimizing.tcl f0b2538988d1bbad16cbfe63ec6e8f48c9eb04e5
F www/optoverview.tcl 28b6f114a33bfd91bbe3440611ceed6090587211
F www/optoverview.tcl 815df406a38c9f69b27d37e8f7ede004c6d9f19e
F www/pragma.tcl 44f7b665ca598ad24724f35991653638a36a6e3f
F www/quickstart.tcl 6f6f694b6139be2d967b1492eb9a6bdf7058aa60
F www/speed.tcl 656ed5be8cc9d536353e1a96927b925634a62933
@ -319,7 +320,7 @@ F www/tclsqlite.tcl ddcf912ea48695603c8ed7efb29f0812ef8d1b49
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
P 80721e2c9033abb2e9eed32892c4e486c293e1fa
R 07f401794e6561d03f78d5565e75d287
P 5045f09933f57e4ae897969710b19d09b7af6022
R 4997ed11edd337d9e88b262aa1b4e874
U drh
Z 4ee63401320da7daeff5f4c350998836
Z 5126499ecc4de071954687fb6cbd6696

View File

@ -1 +1 @@
5045f09933f57e4ae897969710b19d09b7af6022
a2e55a3828d74d78b0b76f956a537a0d906f3191

View File

@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle INSERT statements in SQLite.
**
** $Id: insert.c,v 1.148 2005/11/14 22:29:05 drh Exp $
** $Id: insert.c,v 1.149 2005/11/24 13:15:33 drh Exp $
*/
#include "sqliteInt.h"
@ -23,9 +23,11 @@
**
** Character Column affinity
** ------------------------------
** 'n' NUMERIC
** 't' TEXT
** 'o' NONE
** 'a' TEXT
** 'b' NONE
** 'c' NUMERIC
** 'd' INTEGER
** 'e' REAL
*/
void sqlite3IndexAffinityStr(Vdbe *v, Index *pIdx){
if( !pIdx->zColAff ){
@ -60,9 +62,11 @@ void sqlite3IndexAffinityStr(Vdbe *v, Index *pIdx){
**
** Character Column affinity
** ------------------------------
** 'n' NUMERIC
** 't' TEXT
** 'o' NONE
** 'a' TEXT
** 'b' NONE
** 'c' NUMERIC
** 'd' INTEGER
** 'e' REAL
*/
void sqlite3TableAffinityStr(Vdbe *v, Table *pTab){
/* The first time a column affinity string for a particular table
@ -360,7 +364,6 @@ void sqlite3Insert(
srcTab = pParse->nTab++;
sqlite3VdbeResolveLabel(v, iInsertBlock);
sqlite3VdbeAddOp(v, OP_MakeRecord, nColumn, 0);
sqlite3TableAffinityStr(v, pTab);
sqlite3VdbeAddOp(v, OP_NewRowid, srcTab, 0);
sqlite3VdbeAddOp(v, OP_Pull, 1, 0);
sqlite3VdbeAddOp(v, OP_Insert, srcTab, 0);

38
test/tkt1536.test Normal file
View File

@ -0,0 +1,38 @@
# 2005 November 24
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests to verify that ticket #1536 is
# fixed.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
do_test tkt1536-1.1 {
execsql {
CREATE TABLE t1(
a INTEGER PRIMARY KEY,
b TEXT
);
INSERT INTO t1 VALUES(1,'01');
SELECT typeof(a), typeof(b) FROM t1;
}
} {integer text}
do_test tkt1536-1.2 {
execsql {
INSERT INTO t1(b) SELECT b FROM t1;
SELECT b FROM t1 WHERE rowid=2;
}
} {01}
finish_test

View File

@ -1,7 +1,7 @@
#
# Run this TCL script to generate HTML for the goals.html file.
#
set rcsid {$Id: optoverview.tcl,v 1.4 2005/09/20 01:36:30 drh Exp $}
set rcsid {$Id: optoverview.tcl,v 1.5 2005/11/24 13:15:34 drh Exp $}
source common.tcl
header {The SQLite Query Optimizer Overview}
@ -88,7 +88,7 @@ PARAGRAPH {
}
PARAGRAPH {
In order be used by an index, a term must be of one of the following
To be usable by an index a term must be of one of the following
forms:
}
SYNTAX {