1468327f1Sshane# 2008 August 01 2468327f1Sshane# 3468327f1Sshane# The author disclaims copyright to this source code. In place of 4468327f1Sshane# a legal notice, here is a blessing: 5468327f1Sshane# 6468327f1Sshane# May you do good and not evil. 7468327f1Sshane# May you find forgiveness for yourself and forgive others. 8468327f1Sshane# May you share freely, never taking more than you give. 9468327f1Sshane# 10468327f1Sshane#*********************************************************************** 11468327f1Sshane# 12468327f1Sshane# This test script checks malloc failures in LIMIT operations for 13468327f1Sshane# UPDATE/DELETE statements. 14468327f1Sshane# 15*1c767f0dSdrh# $Id: mallocJ.test,v 1.6 2009/01/09 02:49:32 drh Exp $ 16468327f1Sshane 17468327f1Sshaneset testdir [file dirname $argv0] 18468327f1Sshanesource $testdir/tester.tcl 19468327f1Sshanesource $testdir/malloc_common.tcl 20468327f1Sshane 21468327f1Sshaneifcapable {update_delete_limit} { 22468327f1Sshane 231c0dc825Sdrh do_malloc_test mallocJ-1 -sqlprep { 24468327f1Sshane DROP TABLE IF EXISTS t1; 25468327f1Sshane CREATE TABLE t1(x int, y int); 26468327f1Sshane INSERT INTO t1 VALUES(1,1); 27468327f1Sshane INSERT INTO t1 VALUES(1,2); 28468327f1Sshane INSERT INTO t1 VALUES(1,2); 29468327f1Sshane INSERT INTO t1 VALUES(2,1); 30468327f1Sshane INSERT INTO t1 VALUES(2,2); 31468327f1Sshane INSERT INTO t1 VALUES(2,3); 32468327f1Sshane } -sqlbody { 33468327f1Sshane UPDATE t1 SET x=1 ORDER BY y LIMIT 2 OFFSET 2; 34468327f1Sshane UPDATE t1 SET x=2 WHERE y=1 ORDER BY y LIMIT 2 OFFSET 2; 35468327f1Sshane DELETE FROM t1 WHERE x=1 ORDER BY y LIMIT 2 OFFSET 2; 36468327f1Sshane DELETE FROM t1 ORDER BY y LIMIT 2 OFFSET 2; 37468327f1Sshane } 38468327f1Sshane 39468327f1Sshane} 40468327f1Sshane 411c0dc825Sdrh# ticket #3467 42a78c22c4Sdrhdo_malloc_test mallocJ-2 -sqlprep { 431c0dc825Sdrh CREATE TABLE t1(a,b); 441c0dc825Sdrh INSERT INTO t1 VALUES(1,2); 45753cc107Sdrh PRAGMA vdbe_trace=ON; 461c0dc825Sdrh} -sqlbody { 471c0dc825Sdrh SELECT a, b, 'abc' FROM t1 481c0dc825Sdrh UNION 491c0dc825Sdrh SELECT b, a, 'xyz' FROM t1 501c0dc825Sdrh ORDER BY 2, 3; 511c0dc825Sdrh} 521c0dc825Sdrh 53c46f5203Sdrh# ticket #3478 54c46f5203Sdrhdo_malloc_test mallocJ-3 -sqlbody { 55c46f5203Sdrh EXPLAIN COMMIT 56c46f5203Sdrh} 57c46f5203Sdrh 58a78c22c4Sdrh# ticket #3485 59a78c22c4Sdrhdo_malloc_test mallocJ-4 -sqlprep { 60a78c22c4Sdrh CREATE TABLE t1(a,b,c); 61a78c22c4Sdrh CREATE TABLE t2(x,y,z); 62a78c22c4Sdrh} -sqlbody { 63a78c22c4Sdrh SELECT * FROM (SELECT a,b FROM t1 UNION ALL SELECT x, y FROM t2) ORDER BY 1 64a78c22c4Sdrh} 65a78c22c4Sdrh 66*1c767f0dSdrh# coverage testing 67*1c767f0dSdrhdo_malloc_test mallocJ-5 -sqlprep { 68*1c767f0dSdrh CREATE TABLE t1(["a"]); 69*1c767f0dSdrh} -sqlbody { 70*1c767f0dSdrh SELECT * FROM t1 71*1c767f0dSdrh} 72*1c767f0dSdrh 73468327f1Sshanefinish_test 74