xref: /titanic_50/usr/src/lib/libsqlite/test/rowid.test (revision 7eea693d6b672899726e75993fddc4e95b52647f)
1
2#pragma ident	"%Z%%M%	%I%	%E% SMI"
3
4# 2001 September 15
5#
6# The author disclaims copyright to this source code.  In place of
7# a legal notice, here is a blessing:
8#
9#    May you do good and not evil.
10#    May you find forgiveness for yourself and forgive others.
11#    May you share freely, never taking more than you give.
12#
13#***********************************************************************
14# This file implements regression tests for SQLite library.  The
15# focus of this file is testing the magic ROWID column that is
16# found on all tables.
17#
18# $Id: rowid.test,v 1.13 2004/01/14 21:59:24 drh Exp $
19
20set testdir [file dirname $argv0]
21source $testdir/tester.tcl
22
23# Basic ROWID functionality tests.
24#
25do_test rowid-1.1 {
26  execsql {
27    CREATE TABLE t1(x int, y int);
28    INSERT INTO t1 VALUES(1,2);
29    INSERT INTO t1 VALUES(3,4);
30    SELECT x FROM t1 ORDER BY y;
31  }
32} {1 3}
33do_test rowid-1.2 {
34  set r [execsql {SELECT rowid FROM t1 ORDER BY x}]
35  global x2rowid rowid2x
36  set x2rowid(1) [lindex $r 0]
37  set x2rowid(3) [lindex $r 1]
38  set rowid2x($x2rowid(1)) 1
39  set rowid2x($x2rowid(3)) 3
40  llength $r
41} {2}
42do_test rowid-1.3 {
43  global x2rowid
44  set sql "SELECT x FROM t1 WHERE rowid==$x2rowid(1)"
45  execsql $sql
46} {1}
47do_test rowid-1.4 {
48  global x2rowid
49  set sql "SELECT x FROM t1 WHERE rowid==$x2rowid(3)"
50  execsql $sql
51} {3}
52do_test rowid-1.5 {
53  global x2rowid
54  set sql "SELECT x FROM t1 WHERE oid==$x2rowid(1)"
55  execsql $sql
56} {1}
57do_test rowid-1.6 {
58  global x2rowid
59  set sql "SELECT x FROM t1 WHERE OID==$x2rowid(3)"
60  execsql $sql
61} {3}
62do_test rowid-1.7 {
63  global x2rowid
64  set sql "SELECT x FROM t1 WHERE _rowid_==$x2rowid(1)"
65  execsql $sql
66} {1}
67do_test rowid-1.7.1 {
68  while 1 {
69    set norow [expr {int(rand()*1000000)}]
70    if {$norow!=$x2rowid(1) && $norow!=$x2rowid(3)} break
71  }
72  execsql "SELECT x FROM t1 WHERE rowid=$norow"
73} {}
74do_test rowid-1.8 {
75  global x2rowid
76  set v [execsql {SELECT x, oid FROM t1 order by x}]
77  set v2 [list 1 $x2rowid(1) 3 $x2rowid(3)]
78  expr {$v==$v2}
79} {1}
80do_test rowid-1.9 {
81  global x2rowid
82  set v [execsql {SELECT x, RowID FROM t1 order by x}]
83  set v2 [list 1 $x2rowid(1) 3 $x2rowid(3)]
84  expr {$v==$v2}
85} {1}
86do_test rowid-1.9 {
87  global x2rowid
88  set v [execsql {SELECT x, _rowid_ FROM t1 order by x}]
89  set v2 [list 1 $x2rowid(1) 3 $x2rowid(3)]
90  expr {$v==$v2}
91} {1}
92
93# We can insert or update the ROWID column.
94#
95do_test rowid-2.1 {
96  catchsql {
97    INSERT INTO t1(rowid,x,y) VALUES(1234,5,6);
98    SELECT rowid, * FROM t1;
99  }
100} {0 {1 1 2 2 3 4 1234 5 6}}
101do_test rowid-2.2 {
102  catchsql {
103    UPDATE t1 SET rowid=12345 WHERE x==1;
104    SELECT rowid, * FROM t1
105  }
106} {0 {2 3 4 1234 5 6 12345 1 2}}
107do_test rowid-2.3 {
108  catchsql {
109    INSERT INTO t1(y,x,oid) VALUES(8,7,1235);
110    SELECT rowid, * FROM t1 WHERE rowid>1000;
111  }
112} {0 {1234 5 6 1235 7 8 12345 1 2}}
113do_test rowid-2.4 {
114  catchsql {
115    UPDATE t1 SET oid=12346 WHERE x==1;
116    SELECT rowid, * FROM t1;
117  }
118} {0 {2 3 4 1234 5 6 1235 7 8 12346 1 2}}
119do_test rowid-2.5 {
120  catchsql {
121    INSERT INTO t1(x,_rowid_,y) VALUES(9,1236,10);
122    SELECT rowid, * FROM t1 WHERE rowid>1000;
123  }
124} {0 {1234 5 6 1235 7 8 1236 9 10 12346 1 2}}
125do_test rowid-2.6 {
126  catchsql {
127    UPDATE t1 SET _rowid_=12347 WHERE x==1;
128    SELECT rowid, * FROM t1 WHERE rowid>1000;
129  }
130} {0 {1234 5 6 1235 7 8 1236 9 10 12347 1 2}}
131
132# But we can use ROWID in the WHERE clause of an UPDATE that does not
133# change the ROWID.
134#
135do_test rowid-2.7 {
136  global x2rowid
137  set sql "UPDATE t1 SET x=2 WHERE OID==$x2rowid(3)"
138  execsql $sql
139  execsql {SELECT x FROM t1 ORDER BY x}
140} {1 2 5 7 9}
141do_test rowid-2.8 {
142  global x2rowid
143  set sql "UPDATE t1 SET x=3 WHERE _rowid_==$x2rowid(3)"
144  execsql $sql
145  execsql {SELECT x FROM t1 ORDER BY x}
146} {1 3 5 7 9}
147
148# We cannot index by ROWID
149#
150do_test rowid-2.9 {
151  set v [catch {execsql {CREATE INDEX idxt1 ON t1(rowid)}} msg]
152  lappend v $msg
153} {1 {table t1 has no column named rowid}}
154do_test rowid-2.10 {
155  set v [catch {execsql {CREATE INDEX idxt1 ON t1(_rowid_)}} msg]
156  lappend v $msg
157} {1 {table t1 has no column named _rowid_}}
158do_test rowid-2.11 {
159  set v [catch {execsql {CREATE INDEX idxt1 ON t1(oid)}} msg]
160  lappend v $msg
161} {1 {table t1 has no column named oid}}
162do_test rowid-2.12 {
163  set v [catch {execsql {CREATE INDEX idxt1 ON t1(x, rowid)}} msg]
164  lappend v $msg
165} {1 {table t1 has no column named rowid}}
166
167# Columns defined in the CREATE statement override the buildin ROWID
168# column names.
169#
170do_test rowid-3.1 {
171  execsql {
172    CREATE TABLE t2(rowid int, x int, y int);
173    INSERT INTO t2 VALUES(0,2,3);
174    INSERT INTO t2 VALUES(4,5,6);
175    INSERT INTO t2 VALUES(7,8,9);
176    SELECT * FROM t2 ORDER BY x;
177  }
178} {0 2 3 4 5 6 7 8 9}
179do_test rowid-3.2 {
180  execsql {SELECT * FROM t2 ORDER BY rowid}
181} {0 2 3 4 5 6 7 8 9}
182do_test rowid-3.3 {
183  execsql {SELECT rowid, x, y FROM t2 ORDER BY rowid}
184} {0 2 3 4 5 6 7 8 9}
185do_test rowid-3.4 {
186  set r1 [execsql {SELECT _rowid_, rowid FROM t2 ORDER BY rowid}]
187  foreach {a b c d e f} $r1 {}
188  set r2 [execsql {SELECT _rowid_, rowid FROM t2 ORDER BY x DESC}]
189  foreach {u v w x y z} $r2 {}
190  expr {$u==$e && $w==$c && $y==$a}
191} {1}
192do_probtest rowid-3.5 {
193  set r1 [execsql {SELECT _rowid_, rowid FROM t2 ORDER BY rowid}]
194  foreach {a b c d e f} $r1 {}
195  expr {$a!=$b && $c!=$d && $e!=$f}
196} {1}
197
198# Let's try some more complex examples, including some joins.
199#
200do_test rowid-4.1 {
201  execsql {
202    DELETE FROM t1;
203    DELETE FROM t2;
204  }
205  for {set i 1} {$i<=50} {incr i} {
206    execsql "INSERT INTO t1(x,y) VALUES($i,[expr {$i*$i}])"
207  }
208  execsql {INSERT INTO t2 SELECT _rowid_, x*y, y*y FROM t1}
209  execsql {SELECT t2.y FROM t1, t2 WHERE t1.x==4 AND t1.rowid==t2.rowid}
210} {256}
211do_test rowid-4.2 {
212  execsql {SELECT t2.y FROM t2, t1 WHERE t1.x==4 AND t1.rowid==t2.rowid}
213} {256}
214do_test rowid-4.2.1 {
215  execsql {SELECT t2.y FROM t2, t1 WHERE t1.x==4 AND t1.oid==t2.rowid}
216} {256}
217do_test rowid-4.2.2 {
218  execsql {SELECT t2.y FROM t2, t1 WHERE t1.x==4 AND t1._rowid_==t2.rowid}
219} {256}
220do_test rowid-4.2.3 {
221  execsql {SELECT t2.y FROM t2, t1 WHERE t1.x==4 AND t2.rowid==t1.rowid}
222} {256}
223do_test rowid-4.2.4 {
224  execsql {SELECT t2.y FROM t2, t1 WHERE t2.rowid==t1.oid AND t1.x==4}
225} {256}
226do_test rowid-4.2.5 {
227  execsql {SELECT t2.y FROM t1, t2 WHERE t1.x==4 AND t1._rowid_==t2.rowid}
228} {256}
229do_test rowid-4.2.6 {
230  execsql {SELECT t2.y FROM t1, t2 WHERE t1.x==4 AND t2.rowid==t1.rowid}
231} {256}
232do_test rowid-4.2.7 {
233  execsql {SELECT t2.y FROM t1, t2 WHERE t2.rowid==t1.oid AND t1.x==4}
234} {256}
235do_test rowid-4.3 {
236  execsql {CREATE INDEX idxt1 ON t1(x)}
237  execsql {SELECT t2.y FROM t1, t2 WHERE t1.x==4 AND t1.rowid==t2.rowid}
238} {256}
239do_test rowid-4.3.1 {
240  execsql {SELECT t2.y FROM t1, t2 WHERE t1.x==4 AND t1._rowid_==t2.rowid}
241} {256}
242do_test rowid-4.3.2 {
243  execsql {SELECT t2.y FROM t1, t2 WHERE t2.rowid==t1.oid AND 4==t1.x}
244} {256}
245do_test rowid-4.4 {
246  execsql {SELECT t2.y FROM t2, t1 WHERE t1.x==4 AND t1.rowid==t2.rowid}
247} {256}
248do_test rowid-4.4.1 {
249  execsql {SELECT t2.y FROM t2, t1 WHERE t1.x==4 AND t1._rowid_==t2.rowid}
250} {256}
251do_test rowid-4.4.2 {
252  execsql {SELECT t2.y FROM t2, t1 WHERE t2.rowid==t1.oid AND 4==t1.x}
253} {256}
254do_test rowid-4.5 {
255  execsql {CREATE INDEX idxt2 ON t2(y)}
256  set sqlite_search_count 0
257  concat [execsql {
258    SELECT t1.x FROM t2, t1
259    WHERE t2.y==256 AND t1.rowid==t2.rowid
260  }] $sqlite_search_count
261} {4 3}
262do_test rowid-4.5.1 {
263  set sqlite_search_count 0
264  concat [execsql {
265    SELECT t1.x FROM t2, t1
266    WHERE t1.OID==t2.rowid AND t2.y==81
267  }] $sqlite_search_count
268} {3 3}
269do_test rowid-4.6 {
270  execsql {
271    SELECT t1.x FROM t1, t2
272    WHERE t2.y==256 AND t1.rowid==t2.rowid
273  }
274} {4}
275
276do_test rowid-5.1 {
277  execsql {DELETE FROM t1 WHERE _rowid_ IN (SELECT oid FROM t1 WHERE x>8)}
278  execsql {SELECT max(x) FROM t1}
279} {8}
280
281# Make sure a "WHERE rowid=X" clause works when there is no ROWID of X.
282#
283do_test rowid-6.1 {
284  execsql {
285    SELECT x FROM t1
286  }
287} {1 2 3 4 5 6 7 8}
288do_test rowid-6.2 {
289  for {set ::norow 1} {1} {incr ::norow} {
290    if {[execsql "SELECT x FROM t1 WHERE rowid=$::norow"]==""}  break
291  }
292  execsql [subst {
293    DELETE FROM t1 WHERE rowid=$::norow
294  }]
295} {}
296do_test rowid-6.3 {
297  execsql {
298    SELECT x FROM t1
299  }
300} {1 2 3 4 5 6 7 8}
301
302# Beginning with version 2.3.4, SQLite computes rowids of new rows by
303# finding the maximum current rowid and adding one.  It falls back to
304# the old random algorithm if the maximum rowid is the largest integer.
305# The following tests are for this new behavior.
306#
307do_test rowid-7.0 {
308  execsql {
309    DELETE FROM t1;
310    DROP TABLE t2;
311    DROP INDEX idxt1;
312    INSERT INTO t1 VALUES(1,2);
313    SELECT rowid, * FROM t1;
314  }
315} {1 1 2}
316do_test rowid-7.1 {
317  execsql {
318    INSERT INTO t1 VALUES(99,100);
319    SELECT rowid,* FROM t1
320  }
321} {1 1 2 2 99 100}
322do_test rowid-7.2 {
323  execsql {
324    CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
325    INSERT INTO t2(b) VALUES(55);
326    SELECT * FROM t2;
327  }
328} {1 55}
329do_test rowid-7.3 {
330  execsql {
331    INSERT INTO t2(b) VALUES(66);
332    SELECT * FROM t2;
333  }
334} {1 55 2 66}
335do_test rowid-7.4 {
336  execsql {
337    INSERT INTO t2(a,b) VALUES(1000000,77);
338    INSERT INTO t2(b) VALUES(88);
339    SELECT * FROM t2;
340  }
341} {1 55 2 66 1000000 77 1000001 88}
342do_test rowid-7.5 {
343  execsql {
344    INSERT INTO t2(a,b) VALUES(2147483647,99);
345    INSERT INTO t2(b) VALUES(11);
346    SELECT b FROM t2 ORDER BY b;
347  }
348} {11 55 66 77 88 99}
349do_test rowid-7.6 {
350  execsql {
351    SELECT b FROM t2 WHERE a NOT IN(1,2,1000000,1000001,2147483647);
352  }
353} {11}
354do_test rowid-7.7 {
355  execsql {
356    INSERT INTO t2(b) VALUES(22);
357    INSERT INTO t2(b) VALUES(33);
358    INSERT INTO t2(b) VALUES(44);
359    INSERT INTO t2(b) VALUES(55);
360    SELECT b FROM t2 WHERE a NOT IN(1,2,1000000,1000001,2147483647) ORDER BY b;
361  }
362} {11 22 33 44 55}
363do_test rowid-7.8 {
364  execsql {
365    DELETE FROM t2 WHERE a!=2;
366    INSERT INTO t2(b) VALUES(111);
367    SELECT * FROM t2;
368  }
369} {2 66 3 111}
370
371# Make sure AFTER triggers that do INSERTs do not change the last_insert_rowid.
372# Ticket #290
373#
374do_test rowid-8.1 {
375  execsql {
376    CREATE TABLE t3(a integer primary key);
377    CREATE TABLE t4(x);
378    INSERT INTO t4 VALUES(1);
379    CREATE TRIGGER r3 AFTER INSERT on t3 FOR EACH ROW BEGIN
380      INSERT INTO t4 VALUES(NEW.a+10);
381    END;
382    SELECT * FROM t3;
383  }
384} {}
385do_test rowid-8.2 {
386  execsql {
387    SELECT rowid, * FROM t4;
388  }
389} {1 1}
390do_test rowid-8.3 {
391  execsql {
392    INSERT INTO t3 VALUES(123);
393    SELECT last_insert_rowid();
394  }
395} {123}
396do_test rowid-8.4 {
397  execsql {
398    SELECT * FROM t3;
399  }
400} {123}
401do_test rowid-8.5 {
402  execsql {
403    SELECT rowid, * FROM t4;
404  }
405} {1 1 2 133}
406do_test rowid-8.6 {
407  execsql {
408    INSERT INTO t3 VALUES(NULL);
409    SELECT last_insert_rowid();
410  }
411} {124}
412do_test rowid-8.7 {
413  execsql {
414    SELECT * FROM t3;
415  }
416} {123 124}
417do_test rowid-8.8 {
418  execsql {
419    SELECT rowid, * FROM t4;
420  }
421} {1 1 2 133 3 134}
422
423# ticket #377: Comparison between integer primiary key and floating point
424# values.
425#
426do_test rowid-9.1 {
427  execsql {
428    SELECT * FROM t3 WHERE a<123.5
429  }
430} {123}
431do_test rowid-9.2 {
432  execsql {
433    SELECT * FROM t3 WHERE a<124.5
434  }
435} {123 124}
436do_test rowid-9.3 {
437  execsql {
438    SELECT * FROM t3 WHERE a>123.5
439  }
440} {124}
441do_test rowid-9.4 {
442  execsql {
443    SELECT * FROM t3 WHERE a>122.5
444  }
445} {123 124}
446do_test rowid-9.5 {
447  execsql {
448    SELECT * FROM t3 WHERE a==123.5
449  }
450} {}
451do_test rowid-9.6 {
452  execsql {
453    SELECT * FROM t3 WHERE a==123.000
454  }
455} {123}
456do_test rowid-9.7 {
457  execsql {
458    SELECT * FROM t3 WHERE a>100.5 AND a<200.5
459  }
460} {123 124}
461do_test rowid-9.8 {
462  execsql {
463    SELECT * FROM t3 WHERE a>'xyz';
464  }
465} {}
466do_test rowid-9.9 {
467  execsql {
468    SELECT * FROM t3 WHERE a<'xyz';
469  }
470} {123 124}
471do_test rowid-9.10 {
472  execsql {
473    SELECT * FROM t3 WHERE a>=122.9 AND a<=123.1
474  }
475} {123}
476
477# Ticket #567.  Comparisons of ROWID or integery primary key against
478# floating point numbers still do not always work.
479#
480do_test rowid-10.1 {
481  execsql {
482    CREATE TABLE t5(a);
483    INSERT INTO t5 VALUES(1);
484    INSERT INTO t5 VALUES(2);
485    INSERT INTO t5 SELECT a+2 FROM t5;
486    INSERT INTO t5 SELECT a+4 FROM t5;
487    SELECT rowid, * FROM t5;
488  }
489} {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8}
490do_test rowid-10.2 {
491  execsql {SELECT rowid, a FROM t5 WHERE rowid>=5.5}
492} {6 6 7 7 8 8}
493do_test rowid-10.3 {
494  execsql {SELECT rowid, a FROM t5 WHERE rowid>=5.0}
495} {5 5 6 6 7 7 8 8}
496do_test rowid-10.4 {
497  execsql {SELECT rowid, a FROM t5 WHERE rowid>5.5}
498} {6 6 7 7 8 8}
499do_test rowid-10.3.2 {
500  execsql {SELECT rowid, a FROM t5 WHERE rowid>5.0}
501} {6 6 7 7 8 8}
502do_test rowid-10.5 {
503  execsql {SELECT rowid, a FROM t5 WHERE 5.5<=rowid}
504} {6 6 7 7 8 8}
505do_test rowid-10.6 {
506  execsql {SELECT rowid, a FROM t5 WHERE 5.5<rowid}
507} {6 6 7 7 8 8}
508do_test rowid-10.7 {
509  execsql {SELECT rowid, a FROM t5 WHERE rowid<=5.5}
510} {1 1 2 2 3 3 4 4 5 5}
511do_test rowid-10.8 {
512  execsql {SELECT rowid, a FROM t5 WHERE rowid<5.5}
513} {1 1 2 2 3 3 4 4 5 5}
514do_test rowid-10.9 {
515  execsql {SELECT rowid, a FROM t5 WHERE 5.5>=rowid}
516} {1 1 2 2 3 3 4 4 5 5}
517do_test rowid-10.10 {
518  execsql {SELECT rowid, a FROM t5 WHERE 5.5>rowid}
519} {1 1 2 2 3 3 4 4 5 5}
520do_test rowid-10.11 {
521  execsql {SELECT rowid, a FROM t5 WHERE rowid>=5.5 ORDER BY rowid DESC}
522} {8 8 7 7 6 6}
523do_test rowid-10.11.2 {
524  execsql {SELECT rowid, a FROM t5 WHERE rowid>=5.0 ORDER BY rowid DESC}
525} {8 8 7 7 6 6 5 5}
526do_test rowid-10.12 {
527  execsql {SELECT rowid, a FROM t5 WHERE rowid>5.5 ORDER BY rowid DESC}
528} {8 8 7 7 6 6}
529do_test rowid-10.12.2 {
530  execsql {SELECT rowid, a FROM t5 WHERE rowid>5.0 ORDER BY rowid DESC}
531} {8 8 7 7 6 6}
532do_test rowid-10.13 {
533  execsql {SELECT rowid, a FROM t5 WHERE 5.5<=rowid ORDER BY rowid DESC}
534} {8 8 7 7 6 6}
535do_test rowid-10.14 {
536  execsql {SELECT rowid, a FROM t5 WHERE 5.5<rowid ORDER BY rowid DESC}
537} {8 8 7 7 6 6}
538do_test rowid-10.15 {
539  execsql {SELECT rowid, a FROM t5 WHERE rowid<=5.5 ORDER BY rowid DESC}
540} {5 5 4 4 3 3 2 2 1 1}
541do_test rowid-10.16 {
542  execsql {SELECT rowid, a FROM t5 WHERE rowid<5.5 ORDER BY rowid DESC}
543} {5 5 4 4 3 3 2 2 1 1}
544do_test rowid-10.17 {
545  execsql {SELECT rowid, a FROM t5 WHERE 5.5>=rowid ORDER BY rowid DESC}
546} {5 5 4 4 3 3 2 2 1 1}
547do_test rowid-10.18 {
548  execsql {SELECT rowid, a FROM t5 WHERE 5.5>rowid ORDER BY rowid DESC}
549} {5 5 4 4 3 3 2 2 1 1}
550
551do_test rowid-10.30 {
552  execsql {
553    CREATE TABLE t6(a);
554    INSERT INTO t6(rowid,a) SELECT -a,a FROM t5;
555    SELECT rowid, * FROM t6;
556  }
557} {-8 8 -7 7 -6 6 -5 5 -4 4 -3 3 -2 2 -1 1}
558do_test rowid-10.31.1 {
559  execsql {SELECT rowid, a FROM t6 WHERE rowid>=-5.5}
560} {-5 5 -4 4 -3 3 -2 2 -1 1}
561do_test rowid-10.31.2 {
562  execsql {SELECT rowid, a FROM t6 WHERE rowid>=-5.0}
563} {-5 5 -4 4 -3 3 -2 2 -1 1}
564do_test rowid-10.32.1 {
565  execsql {SELECT rowid, a FROM t6 WHERE rowid>=-5.5 ORDER BY rowid DESC}
566} {-1 1 -2 2 -3 3 -4 4 -5 5}
567do_test rowid-10.32.1 {
568  execsql {SELECT rowid, a FROM t6 WHERE rowid>=-5.0 ORDER BY rowid DESC}
569} {-1 1 -2 2 -3 3 -4 4 -5 5}
570do_test rowid-10.33 {
571  execsql {SELECT rowid, a FROM t6 WHERE -5.5<=rowid}
572} {-5 5 -4 4 -3 3 -2 2 -1 1}
573do_test rowid-10.34 {
574  execsql {SELECT rowid, a FROM t6 WHERE -5.5<=rowid ORDER BY rowid DESC}
575} {-1 1 -2 2 -3 3 -4 4 -5 5}
576do_test rowid-10.35.1 {
577  execsql {SELECT rowid, a FROM t6 WHERE rowid>-5.5}
578} {-5 5 -4 4 -3 3 -2 2 -1 1}
579do_test rowid-10.35.2 {
580  execsql {SELECT rowid, a FROM t6 WHERE rowid>-5.0}
581} {-4 4 -3 3 -2 2 -1 1}
582do_test rowid-10.36.1 {
583  execsql {SELECT rowid, a FROM t6 WHERE rowid>-5.5 ORDER BY rowid DESC}
584} {-1 1 -2 2 -3 3 -4 4 -5 5}
585do_test rowid-10.36.2 {
586  execsql {SELECT rowid, a FROM t6 WHERE rowid>-5.0 ORDER BY rowid DESC}
587} {-1 1 -2 2 -3 3 -4 4}
588do_test rowid-10.37 {
589  execsql {SELECT rowid, a FROM t6 WHERE -5.5<rowid}
590} {-5 5 -4 4 -3 3 -2 2 -1 1}
591do_test rowid-10.38 {
592  execsql {SELECT rowid, a FROM t6 WHERE -5.5<rowid ORDER BY rowid DESC}
593} {-1 1 -2 2 -3 3 -4 4 -5 5}
594do_test rowid-10.39 {
595  execsql {SELECT rowid, a FROM t6 WHERE rowid<=-5.5}
596} {-8 8 -7 7 -6 6}
597do_test rowid-10.40 {
598  execsql {SELECT rowid, a FROM t6 WHERE rowid<=-5.5 ORDER BY rowid DESC}
599} {-6 6 -7 7 -8 8}
600do_test rowid-10.41 {
601  execsql {SELECT rowid, a FROM t6 WHERE -5.5>=rowid}
602} {-8 8 -7 7 -6 6}
603do_test rowid-10.42 {
604  execsql {SELECT rowid, a FROM t6 WHERE -5.5>=rowid ORDER BY rowid DESC}
605} {-6 6 -7 7 -8 8}
606do_test rowid-10.43 {
607  execsql {SELECT rowid, a FROM t6 WHERE rowid<-5.5}
608} {-8 8 -7 7 -6 6}
609do_test rowid-10.44 {
610  execsql {SELECT rowid, a FROM t6 WHERE rowid<-5.5 ORDER BY rowid DESC}
611} {-6 6 -7 7 -8 8}
612do_test rowid-10.44 {
613  execsql {SELECT rowid, a FROM t6 WHERE -5.5>rowid}
614} {-8 8 -7 7 -6 6}
615do_test rowid-10.46 {
616  execsql {SELECT rowid, a FROM t6 WHERE -5.5>rowid ORDER BY rowid DESC}
617} {-6 6 -7 7 -8 8}
618
619# Comparison of rowid against string values.
620#
621do_test rowid-11.1 {
622  execsql {SELECT rowid, a FROM t5 WHERE rowid>'abc'}
623} {}
624do_test rowid-11.2 {
625  execsql {SELECT rowid, a FROM t5 WHERE rowid>='abc'}
626} {}
627do_test rowid-11.3 {
628  execsql {SELECT rowid, a FROM t5 WHERE rowid<'abc'}
629} {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8}
630do_test rowid-11.4 {
631  execsql {SELECT rowid, a FROM t5 WHERE rowid<='abc'}
632} {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8}
633
634
635
636finish_test
637