| OLD | NEW |
| 1 # 2008 September 16 | 1 # 2008 September 16 |
| 2 # | 2 # |
| 3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
| 4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
| 5 # | 5 # |
| 6 # May you do good and not evil. | 6 # May you do good and not evil. |
| 7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
| 8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
| 9 # | 9 # |
| 10 #*********************************************************************** | 10 #*********************************************************************** |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 do_test selectC-1.14.2 { | 144 do_test selectC-1.14.2 { |
| 145 execsql { | 145 execsql { |
| 146 SELECT uppercaseconversionfunctionwithaverylongname(b) AS x | 146 SELECT uppercaseconversionfunctionwithaverylongname(b) AS x |
| 147 FROM t1 | 147 FROM t1 |
| 148 ORDER BY x DESC | 148 ORDER BY x DESC |
| 149 } | 149 } |
| 150 } {CCC AAA AAA} | 150 } {CCC AAA AAA} |
| 151 | 151 |
| 152 # The following query used to leak memory. Verify that has been fixed. | 152 # The following query used to leak memory. Verify that has been fixed. |
| 153 # | 153 # |
| 154 do_test selectC-2.1 { | 154 ifcapable trigger { |
| 155 catchsql { | 155 do_test selectC-2.1 { |
| 156 CREATE TABLE t21a(a,b); | 156 catchsql { |
| 157 INSERT INTO t21a VALUES(1,2); | 157 CREATE TABLE t21a(a,b); |
| 158 CREATE TABLE t21b(n); | 158 INSERT INTO t21a VALUES(1,2); |
| 159 CREATE TRIGGER r21 AFTER INSERT ON t21b BEGIN | 159 CREATE TABLE t21b(n); |
| 160 SELECT a FROM t21a WHERE a>new.x UNION ALL | 160 CREATE TRIGGER r21 AFTER INSERT ON t21b BEGIN |
| 161 SELECT b FROM t21a WHERE b>new.x ORDER BY 1 LIMIT 2; | 161 SELECT a FROM t21a WHERE a>new.x UNION ALL |
| 162 END; | 162 SELECT b FROM t21a WHERE b>new.x ORDER BY 1 LIMIT 2; |
| 163 INSERT INTO t21b VALUES(6); | 163 END; |
| 164 INSERT INTO t21b VALUES(6); |
| 165 } |
| 166 } {1 {no such column: new.x}} |
| 167 } |
| 168 |
| 169 # Check that ticket [883034dcb5] is fixed. |
| 170 # |
| 171 do_test selectC-3.1 { |
| 172 execsql { |
| 173 CREATE TABLE person ( |
| 174 org_id TEXT NOT NULL, |
| 175 nickname TEXT NOT NULL, |
| 176 license TEXT, |
| 177 CONSTRAINT person_pk PRIMARY KEY (org_id, nickname), |
| 178 CONSTRAINT person_license_uk UNIQUE (license) |
| 179 ); |
| 180 INSERT INTO person VALUES('meyers', 'jack', '2GAT123'); |
| 181 INSERT INTO person VALUES('meyers', 'hill', 'V345FMP'); |
| 182 INSERT INTO person VALUES('meyers', 'jim', '2GAT138'); |
| 183 INSERT INTO person VALUES('smith', 'maggy', ''); |
| 184 INSERT INTO person VALUES('smith', 'jose', 'JJZ109'); |
| 185 INSERT INTO person VALUES('smith', 'jack', 'THX138'); |
| 186 INSERT INTO person VALUES('lakeside', 'dave', '953OKG'); |
| 187 INSERT INTO person VALUES('lakeside', 'amy', NULL); |
| 188 INSERT INTO person VALUES('lake-apts', 'tom', NULL); |
| 189 INSERT INTO person VALUES('acorn', 'hideo', 'CQB421'); |
| 190 |
| 191 SELECT |
| 192 org_id, |
| 193 count((NOT (org_id IS NULL)) AND (NOT (nickname IS NULL))) |
| 194 FROM person |
| 195 WHERE (CASE WHEN license != '' THEN 1 ELSE 0 END) |
| 196 GROUP BY 1; |
| 164 } | 197 } |
| 165 } {1 {no such column: new.x}} | 198 } {acorn 1 lakeside 1 meyers 3 smith 2} |
| 199 do_test selectC-3.2 { |
| 200 execsql { |
| 201 CREATE TABLE t2(a PRIMARY KEY, b); |
| 202 INSERT INTO t2 VALUES('abc', 'xxx'); |
| 203 INSERT INTO t2 VALUES('def', 'yyy'); |
| 204 SELECT a, max(b || a) FROM t2 WHERE (b||b||b)!='value' GROUP BY a; |
| 205 } |
| 206 } {abc xxxabc def yyydef} |
| 207 do_test selectC-3.3 { |
| 208 execsql { |
| 209 SELECT b, max(a || b) FROM t2 WHERE (b||b||b)!='value' GROUP BY a; |
| 210 } |
| 211 } {xxx abcxxx yyy defyyy} |
| 212 |
| 213 |
| 214 proc udf {} { incr ::udf } |
| 215 set ::udf 0 |
| 216 db function udf udf |
| 217 |
| 218 do_execsql_test selectC-4.1 { |
| 219 create table t_distinct_bug (a, b, c); |
| 220 insert into t_distinct_bug values ('1', '1', 'a'); |
| 221 insert into t_distinct_bug values ('1', '2', 'b'); |
| 222 insert into t_distinct_bug values ('1', '3', 'c'); |
| 223 insert into t_distinct_bug values ('1', '1', 'd'); |
| 224 insert into t_distinct_bug values ('1', '2', 'e'); |
| 225 insert into t_distinct_bug values ('1', '3', 'f'); |
| 226 } {} |
| 227 |
| 228 do_execsql_test selectC-4.2 { |
| 229 select a from (select distinct a, b from t_distinct_bug) |
| 230 } {1 1 1} |
| 231 |
| 232 do_execsql_test selectC-4.3 { |
| 233 select a, udf() from (select distinct a, b from t_distinct_bug) |
| 234 } {1 1 1 2 1 3} |
| 166 | 235 |
| 167 finish_test | 236 finish_test |
| OLD | NEW |