Do not attempt to omit unused columns of a view in an instead-of trigger
since sometimes those columns can be used in ways that we do not expect. Ticket #3055. (CVS 5012) FossilOrigin-Name: f5fc42e96d36b78797d7fa10b01d22b8501112b1
This commit is contained in:
parent
191b54cb5d
commit
f93d99990c
19
manifest
19
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\sa\scode\sgenerator\sbug\scaused\sby\sthe\snew\sCSE\soptimization.\s\sAdd\stest\scases\nto\sprevent\sa\srecurrence.\s(CVS\s5011)
|
||||
D 2008-04-15T12:14:22
|
||||
C Do\snot\sattempt\sto\somit\sunused\scolumns\sof\sa\sview\sin\san\sinstead-of\strigger\nsince\ssometimes\sthose\scolumns\scan\sbe\sused\sin\sways\sthat\swe\sdo\snot\sexpect.\nTicket\s#3055.\s(CVS\s5012)
|
||||
D 2008-04-15T14:36:42
|
||||
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
|
||||
F Makefile.in 25b3282a4ac39388632c2fb0e044ff494d490952
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -93,7 +93,7 @@ F src/build.c e6f17bbb031c78e55389e3b90cd5cb150efef2b1
|
||||
F src/callback.c 77b302b0d41468dcda78c70e706e5b84577f0fa0
|
||||
F src/complete.c 4cf68fd75d60257524cbe74f87351b9848399131
|
||||
F src/date.c e41ce4513fb0e359dc678d6bddb4ace135fe365d
|
||||
F src/delete.c 555cedf9e59db9ead1c2f8db0c4344201ea7caaa
|
||||
F src/delete.c e4bd53c46969c9fb05cfbba4abc0c93a923f8072
|
||||
F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
|
||||
F src/expr.c 7aecda0fb4f078718281a9b56993677c1f45a399
|
||||
F src/fault.c 83057e86815d473e526f7df0b0108dfdd022ff23
|
||||
@ -140,7 +140,7 @@ F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
|
||||
F src/shell.c 22297fffa6f00a6c6d44020fa13b1184a1bb372d
|
||||
F src/sqlite.h.in 824f823b341e9c979f82edebf710c87b74d1b7f5
|
||||
F src/sqlite3ext.h faacd0e6a81aabee0861c6d7883c9172e74ef5b3
|
||||
F src/sqliteInt.h ef381f6a169d824e8ba54a389187836c4cd48420
|
||||
F src/sqliteInt.h 625375d9327f0d79bf6f0f7864cc4a0543aec440
|
||||
F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
|
||||
F src/table.c 2c48c575dd59b3a6c5c306bc55f51a9402cf429a
|
||||
F src/tclsqlite.c c4892f48927cb3db19faeb448ea8abddfd4846a8
|
||||
@ -171,7 +171,7 @@ F src/test_tclvar.c b2d1115e4d489179d3f029e765211b2ad527ba59
|
||||
F src/test_thread.c e297dd41db0b249646e69f97d36ec13e56e8b730
|
||||
F src/tokenize.c a96abe15a8db6fea2e964cdce2acba9ed17bc26f
|
||||
F src/trigger.c 9bd3b6fa0beff4a02d262c96466f752ec15a7fc3
|
||||
F src/update.c d6f214aad7eab5aaec5f966058b0828b3f7d6706
|
||||
F src/update.c 57282dae1ffffaf4aedc3201ed77f8ef09be4f45
|
||||
F src/utf.c 8c94fa10efc78c2568d08d436acc59df4df7191b
|
||||
F src/util.c 8b17ea7ad27914c6e2c4a377ca7db743fb7e29a8
|
||||
F src/vacuum.c 3524411bfb58aac0d87eadd3e5b7cd532772af30
|
||||
@ -200,7 +200,7 @@ F test/attach.test 4ab582932e3c815689f61afcdb9bce245f0bac53
|
||||
F test/attach2.test a295d2d7061adcee5884ef4a93c7c96a82765437
|
||||
F test/attach3.test 7b92dc8e40c1ebca9732ca6f2d3fefbd46f196df
|
||||
F test/attachmalloc.test 56c5e55563dba6d64641ef2f70ce06900df16912
|
||||
F test/auth.test d5896499f901eeda88c9f441b13aaccf22d5ceee
|
||||
F test/auth.test 100cde29a9913530994289038ec80ef5f63d38d3
|
||||
F test/auth2.test 65ac294b8d52cbdd463f61e77ad0165268373126
|
||||
F test/autoinc.test 0555aa5c789520f16d86a39c6c49b87998e01bea
|
||||
F test/autovacuum.test 4339e66003b9cf813dd667a83aed2dee27c4c36d
|
||||
@ -513,6 +513,7 @@ F test/trigger7.test 194984b3f6f851eb905cd0a7bffac09f36cf1244
|
||||
F test/trigger8.test 3a09275aa2214fdff56f731b1e775d8dfee4408a
|
||||
F test/trigger9.test b42703c378916d52a5e240ba98b25b155d3927a3
|
||||
F test/triggerA.test 8dbf5bffa3190bd513785a24a573a166a885fc1b
|
||||
F test/triggerB.test abee76e59736a2d10b726d4d361e1ac2e0ce3309
|
||||
F test/types.test 98e7a631bddf0806204358b452b02d0e319318a6
|
||||
F test/types2.test 3555aacf8ed8dc883356e59efc314707e6247a84
|
||||
F test/types3.test b730a7db03ef69f0fdb85b2addc20d1a0a04039b
|
||||
@ -629,7 +630,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
|
||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
|
||||
P c5435f71efa0b34c759bac4a15fdf43abf39ddfc
|
||||
R 6394eb4f4998e17e7d31653fe6234a16
|
||||
P d04246a46399e839e70b1bd57e209f80143f0d5b
|
||||
R 9aa82907da3af5df652408937e80bf8c
|
||||
U drh
|
||||
Z de8ad5aae1cda6ab722570506572bc31
|
||||
Z f9388fd458988059dfc693a19920893a
|
||||
|
@ -1 +1 @@
|
||||
d04246a46399e839e70b1bd57e209f80143f0d5b
|
||||
f5fc42e96d36b78797d7fa10b01d22b8501112b1
|
@ -12,7 +12,7 @@
|
||||
** This file contains C code routines that are called by the parser
|
||||
** in order to generate code for DELETE FROM statements.
|
||||
**
|
||||
** $Id: delete.c,v 1.167 2008/04/11 19:18:25 drh Exp $
|
||||
** $Id: delete.c,v 1.168 2008/04/15 14:36:42 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@ -91,7 +91,6 @@ void sqlite3MaterializeView(
|
||||
Parse *pParse, /* Parsing context */
|
||||
Select *pView, /* View definition */
|
||||
Expr *pWhere, /* Optional WHERE clause to be added */
|
||||
u32 col_mask, /* Render only the columns in this mask. */
|
||||
int iCur /* Cursor number for ephemerial table */
|
||||
){
|
||||
SelectDest dest;
|
||||
@ -106,7 +105,6 @@ void sqlite3MaterializeView(
|
||||
pFrom = sqlite3SrcListAppendFromTerm(pParse, 0, 0, 0, 0, pDup, 0, 0);
|
||||
pDup = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
sqlite3SelectMask(pParse, pDup, col_mask);
|
||||
sqlite3SelectDestInit(&dest, SRT_EphemTab, iCur);
|
||||
sqlite3Select(pParse, pDup, &dest, 0, 0, 0, 0);
|
||||
sqlite3SelectDelete(pDup);
|
||||
@ -248,7 +246,7 @@ void sqlite3DeleteFrom(
|
||||
** a ephemeral table.
|
||||
*/
|
||||
if( isView ){
|
||||
sqlite3MaterializeView(pParse, pTab->pSelect, pWhere, old_col_mask, iCur);
|
||||
sqlite3MaterializeView(pParse, pTab->pSelect, pWhere, iCur);
|
||||
}
|
||||
|
||||
/* Resolve the column names in the WHERE clause.
|
||||
|
@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** Internal interface definitions for SQLite.
|
||||
**
|
||||
** @(#) $Id: sqliteInt.h,v 1.692 2008/04/15 12:14:22 drh Exp $
|
||||
** @(#) $Id: sqliteInt.h,v 1.693 2008/04/15 14:36:42 drh Exp $
|
||||
*/
|
||||
#ifndef _SQLITEINT_H_
|
||||
#define _SQLITEINT_H_
|
||||
@ -1935,7 +1935,7 @@ void sqlite3RegisterDateTimeFunctions(sqlite3*);
|
||||
int sqlite3SafetyCheckOk(sqlite3*);
|
||||
int sqlite3SafetyCheckSickOrOk(sqlite3*);
|
||||
void sqlite3ChangeCookie(Parse*, int);
|
||||
void sqlite3MaterializeView(Parse*, Select*, Expr*, u32, int);
|
||||
void sqlite3MaterializeView(Parse*, Select*, Expr*, int);
|
||||
|
||||
#ifndef SQLITE_OMIT_TRIGGER
|
||||
void sqlite3BeginTrigger(Parse*, Token*,Token*,int,int,IdList*,SrcList*,
|
||||
@ -1955,14 +1955,12 @@ void sqlite3MaterializeView(Parse*, Select*, Expr*, u32, int);
|
||||
TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr*);
|
||||
void sqlite3DeleteTrigger(Trigger*);
|
||||
void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);
|
||||
void sqlite3SelectMask(Parse *, Select *, u32);
|
||||
#else
|
||||
# define sqlite3TriggersExist(A,B,C,D,E,F) 0
|
||||
# define sqlite3DeleteTrigger(A)
|
||||
# define sqlite3DropTriggerPtr(A,B)
|
||||
# define sqlite3UnlinkAndDeleteTrigger(A,B,C)
|
||||
# define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I,J,K) 0
|
||||
# define sqlite3SelectMask(A, B, C)
|
||||
#endif
|
||||
|
||||
int sqlite3JoinType(Parse*, Token*, Token*, Token*);
|
||||
|
@ -12,7 +12,7 @@
|
||||
** This file contains C code routines that are called by the parser
|
||||
** to handle UPDATE statements.
|
||||
**
|
||||
** $Id: update.c,v 1.176 2008/04/10 13:33:18 drh Exp $
|
||||
** $Id: update.c,v 1.177 2008/04/15 14:36:42 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@ -329,8 +329,7 @@ void sqlite3Update(
|
||||
** a ephemeral table.
|
||||
*/
|
||||
if( isView ){
|
||||
sqlite3MaterializeView(pParse, pTab->pSelect, pWhere,
|
||||
old_col_mask|new_col_mask, iCur);
|
||||
sqlite3MaterializeView(pParse, pTab->pSelect, pWhere, iCur);
|
||||
}
|
||||
|
||||
/* Resolve the column names in all the expressions in the
|
||||
|
@ -12,7 +12,7 @@
|
||||
# focus of this script is testing the sqlite3_set_authorizer() API
|
||||
# and related functionality.
|
||||
#
|
||||
# $Id: auth.test,v 1.41 2008/02/12 16:52:14 drh Exp $
|
||||
# $Id: auth.test,v 1.42 2008/04/15 14:36:42 drh Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@ -2248,10 +2248,10 @@ do_test auth-4.3 {
|
||||
SQLITE_INSERT v1chng {} main r2 \
|
||||
SQLITE_READ v1 x main r2 \
|
||||
SQLITE_READ v1 x main r2 \
|
||||
SQLITE_SELECT {} {} {} v1 \
|
||||
SQLITE_READ t2 a main v1 \
|
||||
SQLITE_READ t2 b main v1 \
|
||||
SQLITE_SELECT {} {} {} v1 \
|
||||
SQLITE_SELECT {} {} {} v1 \
|
||||
SQLITE_READ v1 x main v1 \
|
||||
]
|
||||
do_test auth-4.4 {
|
||||
@ -2272,10 +2272,10 @@ do_test auth-4.5 {
|
||||
SQLITE_DELETE v1 {} main {} \
|
||||
SQLITE_INSERT v1chng {} main r3 \
|
||||
SQLITE_READ v1 x main r3 \
|
||||
SQLITE_SELECT {} {} {} v1 \
|
||||
SQLITE_READ t2 a main v1 \
|
||||
SQLITE_READ t2 b main v1 \
|
||||
SQLITE_SELECT {} {} {} v1 \
|
||||
SQLITE_SELECT {} {} {} v1 \
|
||||
SQLITE_READ v1 x main v1 \
|
||||
]
|
||||
|
||||
|
45
test/triggerB.test
Normal file
45
test/triggerB.test
Normal file
@ -0,0 +1,45 @@
|
||||
# 2008 April 15
|
||||
#
|
||||
# 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. Specifically,
|
||||
# it tests updating tables with constraints within a trigger. Ticket #3055.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
ifcapable {!trigger} {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
# Create test tables with constraints.
|
||||
#
|
||||
do_test triggerB-1.1 {
|
||||
execsql {
|
||||
CREATE TABLE x(x INTEGER PRIMARY KEY, y INT NOT NULL);
|
||||
INSERT INTO x(y) VALUES(1);
|
||||
INSERT INTO x(y) VALUES(1);
|
||||
CREATE TEMP VIEW vx AS SELECT x, y, 0 AS yy FROM x;
|
||||
CREATE TEMP TRIGGER tx INSTEAD OF UPDATE OF y ON vx
|
||||
BEGIN
|
||||
UPDATE x SET y = new.y WHERE x = new.x;
|
||||
END;
|
||||
SELECT * FROM vx;
|
||||
}
|
||||
} {1 1 0 2 1 0}
|
||||
do_test triggerB-1.2 {
|
||||
breakpoint
|
||||
execsql {
|
||||
UPDATE vx SET y = yy;
|
||||
SELECT * FROM vx;
|
||||
}
|
||||
} {1 0 0 2 0 0}
|
||||
|
||||
finish_test
|
Loading…
Reference in New Issue
Block a user