/ Hex Artifact Content
Login

Artifact 5d423a2d1006085b05cc1b788863d5a860ea2da21c4f892d15e2f2a34c78348a:


0000: 23 20 32 30 31 38 20 53 65 70 74 65 6d 62 65 72  # 2018 September
0010: 20 33 30 0a 23 0a 23 20 54 68 65 20 61 75 74 68   30.#.# The auth
0020: 6f 72 20 64 69 73 63 6c 61 69 6d 73 20 63 6f 70  or disclaims cop
0030: 79 72 69 67 68 74 20 74 6f 20 74 68 69 73 20 73  yright to this s
0040: 6f 75 72 63 65 20 63 6f 64 65 2e 20 20 49 6e 20  ource code.  In 
0050: 70 6c 61 63 65 20 6f 66 0a 23 20 61 20 6c 65 67  place of.# a leg
0060: 61 6c 20 6e 6f 74 69 63 65 2c 20 68 65 72 65 20  al notice, here 
0070: 69 73 20 61 20 62 6c 65 73 73 69 6e 67 3a 0a 23  is a blessing:.#
0080: 0a 23 20 20 20 20 4d 61 79 20 79 6f 75 20 64 6f  .#    May you do
0090: 20 67 6f 6f 64 20 61 6e 64 20 6e 6f 74 20 65 76   good and not ev
00a0: 69 6c 2e 0a 23 20 20 20 20 4d 61 79 20 79 6f 75  il..#    May you
00b0: 20 66 69 6e 64 20 66 6f 72 67 69 76 65 6e 65 73   find forgivenes
00c0: 73 20 66 6f 72 20 79 6f 75 72 73 65 6c 66 20 61  s for yourself a
00d0: 6e 64 20 66 6f 72 67 69 76 65 20 6f 74 68 65 72  nd forgive other
00e0: 73 2e 0a 23 20 20 20 20 4d 61 79 20 79 6f 75 20  s..#    May you 
00f0: 73 68 61 72 65 20 66 72 65 65 6c 79 2c 20 6e 65  share freely, ne
0100: 76 65 72 20 74 61 6b 69 6e 67 20 6d 6f 72 65 20  ver taking more 
0110: 74 68 61 6e 20 79 6f 75 20 67 69 76 65 2e 0a 23  than you give..#
0120: 0a 23 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  .#**************
0130: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0140: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0150: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0160: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 0a 23 0a 0a 73  ***********.#..s
0170: 65 74 20 74 65 73 74 64 69 72 20 5b 66 69 6c 65  et testdir [file
0180: 20 64 69 72 6e 61 6d 65 20 24 61 72 67 76 30 5d   dirname $argv0]
0190: 0a 73 6f 75 72 63 65 20 24 74 65 73 74 64 69 72  .source $testdir
01a0: 2f 74 65 73 74 65 72 2e 74 63 6c 0a 73 65 74 20  /tester.tcl.set 
01b0: 74 65 73 74 70 72 65 66 69 78 20 61 6c 74 65 72  testprefix alter
01c0: 74 61 62 32 0a 0a 23 20 49 66 20 53 51 4c 49 54  tab2..# If SQLIT
01d0: 45 5f 4f 4d 49 54 5f 41 4c 54 45 52 54 41 42 4c  E_OMIT_ALTERTABL
01e0: 45 20 69 73 20 64 65 66 69 6e 65 64 2c 20 6f 6d  E is defined, om
01f0: 69 74 20 74 68 69 73 20 66 69 6c 65 2e 0a 69 66  it this file..if
0200: 63 61 70 61 62 6c 65 20 21 61 6c 74 65 72 74 61  capable !alterta
0210: 62 6c 65 20 7b 0a 20 20 66 69 6e 69 73 68 5f 74  ble {.  finish_t
0220: 65 73 74 0a 20 20 72 65 74 75 72 6e 0a 7d 0a 0a  est.  return.}..
0230: 69 66 63 61 70 61 62 6c 65 20 66 74 73 35 20 7b  ifcapable fts5 {
0240: 0a 20 20 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65  .  do_execsql_te
0250: 73 74 20 31 2e 30 20 7b 0a 20 20 20 20 43 52 45  st 1.0 {.    CRE
0260: 41 54 45 20 54 41 42 4c 45 20 72 72 28 61 2c 20  ATE TABLE rr(a, 
0270: 62 29 3b 0a 20 20 20 20 43 52 45 41 54 45 20 56  b);.    CREATE V
0280: 49 52 54 55 41 4c 20 54 41 42 4c 45 20 66 66 20  IRTUAL TABLE ff 
0290: 55 53 49 4e 47 20 66 74 73 35 28 61 2c 20 62 29  USING fts5(a, b)
02a0: 3b 0a 20 20 20 20 43 52 45 41 54 45 20 54 52 49  ;.    CREATE TRI
02b0: 47 47 45 52 20 74 72 31 20 41 46 54 45 52 20 49  GGER tr1 AFTER I
02c0: 4e 53 45 52 54 20 4f 4e 20 72 72 20 42 45 47 49  NSERT ON rr BEGI
02d0: 4e 0a 20 20 20 20 20 20 49 4e 53 45 52 54 20 49  N.      INSERT I
02e0: 4e 54 4f 20 66 66 20 56 41 4c 55 45 53 28 6e 65  NTO ff VALUES(ne
02f0: 77 2e 61 2c 20 6e 65 77 2e 62 29 3b 0a 20 20 20  w.a, new.b);.   
0300: 20 45 4e 44 3b 0a 20 20 20 20 49 4e 53 45 52 54   END;.    INSERT
0310: 20 49 4e 54 4f 20 72 72 20 56 41 4c 55 45 53 28   INTO rr VALUES(
0320: 27 68 65 6c 6c 6f 27 2c 20 27 77 6f 72 6c 64 27  'hello', 'world'
0330: 29 3b 0a 20 20 20 20 53 45 4c 45 43 54 20 2a 20  );.    SELECT * 
0340: 46 52 4f 4d 20 66 66 3b 0a 20 20 7d 20 7b 68 65  FROM ff;.  } {he
0350: 6c 6c 6f 20 77 6f 72 6c 64 7d 0a 0a 20 20 64 6f  llo world}..  do
0360: 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 31 2e  _execsql_test 1.
0370: 31 20 7b 0a 20 20 20 20 41 4c 54 45 52 20 54 41  1 {.    ALTER TA
0380: 42 4c 45 20 66 66 20 52 45 4e 41 4d 45 20 54 4f  BLE ff RENAME TO
0390: 20 66 66 66 66 3b 0a 20 20 7d 0a 0a 20 20 64 6f   ffff;.  }..  do
03a0: 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 31 2e  _execsql_test 1.
03b0: 32 20 7b 0a 20 20 20 20 49 4e 53 45 52 54 20 49  2 {.    INSERT I
03c0: 4e 54 4f 20 72 72 20 56 41 4c 55 45 53 28 27 69  NTO rr VALUES('i
03d0: 6e 27 2c 20 27 74 63 6c 27 29 3b 0a 20 20 20 20  n', 'tcl');.    
03e0: 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 66 66  SELECT * FROM ff
03f0: 66 66 3b 0a 20 20 7d 20 7b 68 65 6c 6c 6f 20 77  ff;.  } {hello w
0400: 6f 72 6c 64 20 69 6e 20 74 63 6c 7d 0a 7d 0a 0a  orld in tcl}.}..
0410: 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  #---------------
0420: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0430: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0440: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0450: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20 43 68 65  ----------.# Che
0460: 63 6b 20 74 68 61 74 20 74 61 62 6c 65 20 6e 61  ck that table na
0470: 6d 65 73 20 74 68 61 74 20 61 70 70 65 61 72 20  mes that appear 
0480: 69 6e 20 52 45 46 45 52 45 4e 43 45 53 20 63 6c  in REFERENCES cl
0490: 61 75 73 65 73 20 61 72 65 20 75 70 64 61 74 65  auses are update
04a0: 64 0a 23 20 77 68 65 6e 20 61 20 74 61 62 6c 65  d.# when a table
04b0: 20 69 73 20 72 65 6e 61 6d 65 64 20 75 6e 6c 65   is renamed unle
04c0: 73 73 3a 0a 23 0a 23 20 20 20 61 29 20 22 50 52  ss:.#.#   a) "PR
04d0: 41 47 4d 41 20 6c 65 67 61 63 79 5f 61 6c 74 65  AGMA legacy_alte
04e0: 72 5f 74 61 62 6c 65 22 20 69 73 20 74 72 75 65  r_table" is true
04f0: 2c 20 61 6e 64 0a 23 20 20 20 62 29 20 22 50 52  , and.#   b) "PR
0500: 41 47 4d 41 20 66 6f 72 65 69 67 6e 5f 6b 65 79  AGMA foreign_key
0510: 73 22 20 69 73 20 66 61 6c 73 65 2e 0a 23 0a 64  s" is false..#.d
0520: 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 32  o_execsql_test 2
0530: 2e 30 20 7b 0a 20 20 43 52 45 41 54 45 20 54 41  .0 {.  CREATE TA
0540: 42 4c 45 20 70 31 28 61 20 50 52 49 4d 41 52 59  BLE p1(a PRIMARY
0550: 20 4b 45 59 2c 20 62 29 3b 0a 20 20 43 52 45 41   KEY, b);.  CREA
0560: 54 45 20 54 41 42 4c 45 20 63 31 28 78 20 52 45  TE TABLE c1(x RE
0570: 46 45 52 45 4e 43 45 53 20 70 31 29 3b 0a 20 20  FERENCES p1);.  
0580: 43 52 45 41 54 45 20 54 41 42 4c 45 20 63 32 28  CREATE TABLE c2(
0590: 78 2c 20 46 4f 52 45 49 47 4e 20 4b 45 59 20 28  x, FOREIGN KEY (
05a0: 78 29 20 52 45 46 45 52 45 4e 43 45 53 20 70 31  x) REFERENCES p1
05b0: 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c  );.  CREATE TABL
05c0: 45 20 63 33 28 78 2c 20 46 4f 52 45 49 47 4e 20  E c3(x, FOREIGN 
05d0: 4b 45 59 20 28 78 29 20 52 45 46 45 52 45 4e 43  KEY (x) REFERENC
05e0: 45 53 20 70 31 28 61 29 29 3b 0a 7d 0a 0a 64 6f  ES p1(a));.}..do
05f0: 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 32 2e  _execsql_test 2.
0600: 31 20 7b 0a 20 20 41 4c 54 45 52 20 54 41 42 4c  1 {.  ALTER TABL
0610: 45 20 70 31 20 52 45 4e 41 4d 45 20 54 4f 20 70  E p1 RENAME TO p
0620: 32 3b 0a 20 20 53 45 4c 45 43 54 20 73 71 6c 20  2;.  SELECT sql 
0630: 46 52 4f 4d 20 73 71 6c 69 74 65 5f 6d 61 73 74  FROM sqlite_mast
0640: 65 72 20 57 48 45 52 45 20 6e 61 6d 65 20 4c 49  er WHERE name LI
0650: 4b 45 20 27 63 25 27 3b 0a 7d 20 7b 0a 20 20 7b  KE 'c%';.} {.  {
0660: 43 52 45 41 54 45 20 54 41 42 4c 45 20 63 31 28  CREATE TABLE c1(
0670: 78 20 52 45 46 45 52 45 4e 43 45 53 20 22 70 32  x REFERENCES "p2
0680: 22 29 7d 0a 20 20 7b 43 52 45 41 54 45 20 54 41  ")}.  {CREATE TA
0690: 42 4c 45 20 63 32 28 78 2c 20 46 4f 52 45 49 47  BLE c2(x, FOREIG
06a0: 4e 20 4b 45 59 20 28 78 29 20 52 45 46 45 52 45  N KEY (x) REFERE
06b0: 4e 43 45 53 20 22 70 32 22 29 7d 0a 20 20 7b 43  NCES "p2")}.  {C
06c0: 52 45 41 54 45 20 54 41 42 4c 45 20 63 33 28 78  REATE TABLE c3(x
06d0: 2c 20 46 4f 52 45 49 47 4e 20 4b 45 59 20 28 78  , FOREIGN KEY (x
06e0: 29 20 52 45 46 45 52 45 4e 43 45 53 20 22 70 32  ) REFERENCES "p2
06f0: 22 28 61 29 29 7d 0a 7d 0a 0a 64 6f 5f 65 78 65  "(a))}.}..do_exe
0700: 63 73 71 6c 5f 74 65 73 74 20 32 2e 32 20 7b 0a  csql_test 2.2 {.
0710: 20 20 50 52 41 47 4d 41 20 6c 65 67 61 63 79 5f    PRAGMA legacy_
0720: 61 6c 74 65 72 5f 74 61 62 6c 65 20 3d 20 31 3b  alter_table = 1;
0730: 0a 20 20 41 4c 54 45 52 20 54 41 42 4c 45 20 70  .  ALTER TABLE p
0740: 32 20 52 45 4e 41 4d 45 20 54 4f 20 70 33 3b 0a  2 RENAME TO p3;.
0750: 20 20 53 45 4c 45 43 54 20 73 71 6c 20 46 52 4f    SELECT sql FRO
0760: 4d 20 73 71 6c 69 74 65 5f 6d 61 73 74 65 72 20  M sqlite_master 
0770: 57 48 45 52 45 20 6e 61 6d 65 20 4c 49 4b 45 20  WHERE name LIKE 
0780: 27 63 25 27 3b 0a 7d 20 7b 0a 20 20 7b 43 52 45  'c%';.} {.  {CRE
0790: 41 54 45 20 54 41 42 4c 45 20 63 31 28 78 20 52  ATE TABLE c1(x R
07a0: 45 46 45 52 45 4e 43 45 53 20 22 70 32 22 29 7d  EFERENCES "p2")}
07b0: 0a 20 20 7b 43 52 45 41 54 45 20 54 41 42 4c 45  .  {CREATE TABLE
07c0: 20 63 32 28 78 2c 20 46 4f 52 45 49 47 4e 20 4b   c2(x, FOREIGN K
07d0: 45 59 20 28 78 29 20 52 45 46 45 52 45 4e 43 45  EY (x) REFERENCE
07e0: 53 20 22 70 32 22 29 7d 0a 20 20 7b 43 52 45 41  S "p2")}.  {CREA
07f0: 54 45 20 54 41 42 4c 45 20 63 33 28 78 2c 20 46  TE TABLE c3(x, F
0800: 4f 52 45 49 47 4e 20 4b 45 59 20 28 78 29 20 52  OREIGN KEY (x) R
0810: 45 46 45 52 45 4e 43 45 53 20 22 70 32 22 28 61  EFERENCES "p2"(a
0820: 29 29 7d 0a 7d 0a 0a 64 6f 5f 65 78 65 63 73 71  ))}.}..do_execsq
0830: 6c 5f 74 65 73 74 20 32 2e 33 20 7b 0a 20 20 41  l_test 2.3 {.  A
0840: 4c 54 45 52 20 54 41 42 4c 45 20 70 33 20 52 45  LTER TABLE p3 RE
0850: 4e 41 4d 45 20 54 4f 20 70 32 3b 0a 20 20 50 52  NAME TO p2;.  PR
0860: 41 47 4d 41 20 66 6f 72 65 69 67 6e 5f 6b 65 79  AGMA foreign_key
0870: 73 20 3d 20 31 3b 0a 20 20 41 4c 54 45 52 20 54  s = 1;.  ALTER T
0880: 41 42 4c 45 20 70 32 20 52 45 4e 41 4d 45 20 54  ABLE p2 RENAME T
0890: 4f 20 70 33 3b 0a 20 20 53 45 4c 45 43 54 20 73  O p3;.  SELECT s
08a0: 71 6c 20 46 52 4f 4d 20 73 71 6c 69 74 65 5f 6d  ql FROM sqlite_m
08b0: 61 73 74 65 72 20 57 48 45 52 45 20 6e 61 6d 65  aster WHERE name
08c0: 20 4c 49 4b 45 20 27 63 25 27 3b 0a 7d 20 7b 0a   LIKE 'c%';.} {.
08d0: 20 20 7b 43 52 45 41 54 45 20 54 41 42 4c 45 20    {CREATE TABLE 
08e0: 63 31 28 78 20 52 45 46 45 52 45 4e 43 45 53 20  c1(x REFERENCES 
08f0: 22 70 33 22 29 7d 0a 20 20 7b 43 52 45 41 54 45  "p3")}.  {CREATE
0900: 20 54 41 42 4c 45 20 63 32 28 78 2c 20 46 4f 52   TABLE c2(x, FOR
0910: 45 49 47 4e 20 4b 45 59 20 28 78 29 20 52 45 46  EIGN KEY (x) REF
0920: 45 52 45 4e 43 45 53 20 22 70 33 22 29 7d 0a 20  ERENCES "p3")}. 
0930: 20 7b 43 52 45 41 54 45 20 54 41 42 4c 45 20 63   {CREATE TABLE c
0940: 33 28 78 2c 20 46 4f 52 45 49 47 4e 20 4b 45 59  3(x, FOREIGN KEY
0950: 20 28 78 29 20 52 45 46 45 52 45 4e 43 45 53 20   (x) REFERENCES 
0960: 22 70 33 22 28 61 29 29 7d 0a 7d 0a 0a 23 2d 2d  "p3"(a))}.}..#--
0970: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0980: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0990: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
09a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
09b0: 2d 2d 2d 2d 2d 2d 2d 0a 23 20 54 61 62 6c 65 20  -------.# Table 
09c0: 6e 61 6d 65 20 69 6e 20 57 49 54 48 20 63 6c 61  name in WITH cla
09d0: 75 73 65 73 20 74 68 61 74 20 61 72 65 20 70 61  uses that are pa
09e0: 72 74 20 6f 66 20 76 69 65 77 73 20 6f 72 20 74  rt of views or t
09f0: 72 69 67 67 65 72 73 2e 0a 23 0a 66 6f 72 65 61  riggers..#.forea
0a00: 63 68 20 7b 74 6e 20 73 63 68 65 6d 61 7d 20 7b  ch {tn schema} {
0a10: 0a 20 20 31 20 7b 0a 20 20 20 20 43 52 45 41 54  .  1 {.    CREAT
0a20: 45 20 54 41 42 4c 45 20 6c 6f 67 5f 65 6e 74 72  E TABLE log_entr
0a30: 79 28 63 6f 6c 31 2c 20 79 29 3b 0a 20 20 20 20  y(col1, y);.    
0a40: 43 52 45 41 54 45 20 49 4e 44 45 58 20 69 31 20  CREATE INDEX i1 
0a50: 4f 4e 20 6c 6f 67 5f 65 6e 74 72 79 28 63 6f 6c  ON log_entry(col
0a60: 31 29 3b 0a 20 20 7d 0a 0a 20 20 32 20 7b 0a 20  1);.  }..  2 {. 
0a70: 20 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20     CREATE TABLE 
0a80: 74 31 28 61 2c 20 62 2c 20 63 29 3b 0a 20 20 20  t1(a, b, c);.   
0a90: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 32   CREATE TABLE t2
0aa0: 28 78 29 3b 0a 20 20 20 20 43 52 45 41 54 45 20  (x);.    CREATE 
0ab0: 54 41 42 4c 45 20 6c 6f 67 5f 65 6e 74 72 79 28  TABLE log_entry(
0ac0: 63 6f 6c 31 29 3b 0a 20 20 20 20 43 52 45 41 54  col1);.    CREAT
0ad0: 45 20 54 52 49 47 47 45 52 20 74 72 31 20 41 46  E TRIGGER tr1 AF
0ae0: 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 31  TER INSERT ON t1
0af0: 20 42 45 47 49 4e 0a 20 20 20 20 20 20 49 4e 53   BEGIN.      INS
0b00: 45 52 54 20 49 4e 54 4f 20 74 32 20 53 45 4c 45  ERT INTO t2 SELE
0b10: 43 54 20 63 6f 6c 31 20 46 52 4f 4d 20 6c 6f 67  CT col1 FROM log
0b20: 5f 65 6e 74 72 79 3b 0a 20 20 20 20 45 4e 44 3b  _entry;.    END;
0b30: 0a 20 20 7d 0a 0a 20 20 33 20 7b 0a 20 20 20 20  .  }..  3 {.    
0b40: 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28  CREATE TABLE t1(
0b50: 61 2c 20 62 2c 20 63 29 3b 0a 20 20 20 20 43 52  a, b, c);.    CR
0b60: 45 41 54 45 20 54 41 42 4c 45 20 74 32 28 78 29  EATE TABLE t2(x)
0b70: 3b 0a 20 20 20 20 43 52 45 41 54 45 20 54 41 42  ;.    CREATE TAB
0b80: 4c 45 20 6c 6f 67 5f 65 6e 74 72 79 28 63 6f 6c  LE log_entry(col
0b90: 31 29 3b 0a 20 20 20 20 43 52 45 41 54 45 20 54  1);.    CREATE T
0ba0: 52 49 47 47 45 52 20 74 72 31 20 41 46 54 45 52  RIGGER tr1 AFTER
0bb0: 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
0bc0: 47 49 4e 0a 20 20 20 20 20 20 49 4e 53 45 52 54  GIN.      INSERT
0bd0: 20 49 4e 54 4f 20 74 32 0a 20 20 20 20 20 20 20   INTO t2.       
0be0: 20 57 49 54 48 20 78 79 7a 28 78 29 20 41 53 20   WITH xyz(x) AS 
0bf0: 28 53 45 4c 45 43 54 20 63 6f 6c 31 20 46 52 4f  (SELECT col1 FRO
0c00: 4d 20 6c 6f 67 5f 65 6e 74 72 79 29 0a 20 20 20  M log_entry).   
0c10: 20 20 20 20 20 53 45 4c 45 43 54 20 78 20 46 52       SELECT x FR
0c20: 4f 4d 20 78 79 7a 3b 0a 20 20 20 20 45 4e 44 3b  OM xyz;.    END;
0c30: 0a 20 20 7d 0a 0a 20 20 34 20 7b 0a 20 20 20 20  .  }..  4 {.    
0c40: 43 52 45 41 54 45 20 54 41 42 4c 45 20 6c 6f 67  CREATE TABLE log
0c50: 5f 65 6e 74 72 79 28 63 6f 6c 31 29 3b 0a 20 20  _entry(col1);.  
0c60: 20 20 43 52 45 41 54 45 20 56 49 45 57 20 74 74    CREATE VIEW tt
0c70: 74 20 41 53 0a 20 20 20 20 20 20 20 20 57 49 54  t AS.        WIT
0c80: 48 20 78 79 7a 28 78 29 20 41 53 20 28 53 45 4c  H xyz(x) AS (SEL
0c90: 45 43 54 20 63 6f 6c 31 20 46 52 4f 4d 20 6c 6f  ECT col1 FROM lo
0ca0: 67 5f 65 6e 74 72 79 29 0a 20 20 20 20 20 20 20  g_entry).       
0cb0: 20 53 45 4c 45 43 54 20 78 20 46 52 4f 4d 20 78   SELECT x FROM x
0cc0: 79 7a 3b 0a 20 20 7d 0a 7d 20 7b 0a 20 20 72 65  yz;.  }.} {.  re
0cd0: 73 65 74 5f 64 62 0a 20 20 64 6f 5f 65 78 65 63  set_db.  do_exec
0ce0: 73 71 6c 5f 74 65 73 74 20 33 2e 24 74 6e 2e 31  sql_test 3.$tn.1
0cf0: 20 24 73 63 68 65 6d 61 0a 20 20 73 65 74 20 65   $schema.  set e
0d00: 78 70 65 63 74 20 5b 64 62 20 65 76 61 6c 20 22  xpect [db eval "
0d10: 53 45 4c 45 43 54 20 73 71 6c 20 46 52 4f 4d 20  SELECT sql FROM 
0d20: 73 71 6c 69 74 65 5f 6d 61 73 74 65 72 22 5d 0a  sqlite_master"].
0d30: 20 20 73 65 74 20 65 78 70 65 63 74 20 5b 73 74    set expect [st
0d40: 72 69 6e 67 20 6d 61 70 20 7b 6c 6f 67 5f 65 6e  ring map {log_en
0d50: 74 72 79 20 7b 22 6e 65 77 6e 61 6d 65 22 7d 7d  try {"newname"}}
0d60: 20 24 65 78 70 65 63 74 5d 0a 0a 20 20 64 6f 5f   $expect]..  do_
0d70: 65 78 65 63 73 71 6c 5f 74 65 73 74 20 33 2e 24  execsql_test 3.$
0d80: 74 6e 2e 32 20 7b 0a 20 20 20 20 41 4c 54 45 52  tn.2 {.    ALTER
0d90: 20 54 41 42 4c 45 20 6c 6f 67 5f 65 6e 74 72 79   TABLE log_entry
0da0: 20 52 45 4e 41 4d 45 20 54 4f 20 6e 65 77 6e 61   RENAME TO newna
0db0: 6d 65 3b 0a 20 20 20 20 53 45 4c 45 43 54 20 73  me;.    SELECT s
0dc0: 71 6c 20 46 52 4f 4d 20 73 71 6c 69 74 65 5f 6d  ql FROM sqlite_m
0dd0: 61 73 74 65 72 3b 0a 20 20 7d 20 24 65 78 70 65  aster;.  } $expe
0de0: 63 74 0a 0a 20 20 72 65 73 65 74 5f 64 62 0a 20  ct..  reset_db. 
0df0: 20 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74   do_execsql_test
0e00: 20 33 2e 24 74 6e 2e 33 20 24 73 63 68 65 6d 61   3.$tn.3 $schema
0e10: 0a 20 20 73 65 74 20 65 78 70 65 63 74 20 5b 64  .  set expect [d
0e20: 62 20 65 76 61 6c 20 22 53 45 4c 45 43 54 20 73  b eval "SELECT s
0e30: 71 6c 20 46 52 4f 4d 20 73 71 6c 69 74 65 5f 6d  ql FROM sqlite_m
0e40: 61 73 74 65 72 22 5d 0a 20 20 73 65 74 20 65 78  aster"].  set ex
0e50: 70 65 63 74 20 5b 73 74 72 69 6e 67 20 6d 61 70  pect [string map
0e60: 20 7b 63 6f 6c 31 20 6e 65 77 6e 61 6d 65 7d 20   {col1 newname} 
0e70: 24 65 78 70 65 63 74 5d 0a 0a 20 20 64 6f 5f 65  $expect]..  do_e
0e80: 78 65 63 73 71 6c 5f 74 65 73 74 20 33 2e 24 74  xecsql_test 3.$t
0e90: 6e 2e 34 20 7b 0a 20 20 20 20 41 4c 54 45 52 20  n.4 {.    ALTER 
0ea0: 54 41 42 4c 45 20 6c 6f 67 5f 65 6e 74 72 79 20  TABLE log_entry 
0eb0: 52 45 4e 41 4d 45 20 63 6f 6c 31 20 54 4f 20 6e  RENAME col1 TO n
0ec0: 65 77 6e 61 6d 65 3b 0a 20 20 20 20 53 45 4c 45  ewname;.    SELE
0ed0: 43 54 20 73 71 6c 20 46 52 4f 4d 20 73 71 6c 69  CT sql FROM sqli
0ee0: 74 65 5f 6d 61 73 74 65 72 3b 0a 20 20 7d 20 24  te_master;.  } $
0ef0: 65 78 70 65 63 74 0a 7d 0a 0a 23 2d 2d 2d 2d 2d  expect.}..#-----
0f00: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0f10: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0f20: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0f30: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0f40: 2d 2d 2d 2d 0a 72 65 73 65 74 5f 64 62 0a 64 6f  ----.reset_db.do
0f50: 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 34 2e  _execsql_test 4.
0f60: 30 20 7b 0a 20 20 43 52 45 41 54 45 20 54 41 42  0 {.  CREATE TAB
0f70: 4c 45 20 74 31 28 61 2c 62 2c 63 2c 64 2c 65 2c  LE t1(a,b,c,d,e,
0f80: 66 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  f);.  CREATE TRI
0f90: 47 47 45 52 20 72 31 20 41 46 54 45 52 20 49 4e  GGER r1 AFTER IN
0fa0: 53 45 52 54 20 4f 4e 20 74 31 20 57 48 45 4e 20  SERT ON t1 WHEN 
0fb0: 6e 65 77 2e 61 20 4e 4f 54 20 4e 55 4c 4c 20 42  new.a NOT NULL B
0fc0: 45 47 49 4e 0a 20 20 20 20 55 50 44 41 54 45 20  EGIN.    UPDATE 
0fd0: 74 31 20 53 45 54 20 28 63 2c 64 29 3d 28 61 2c  t1 SET (c,d)=(a,
0fe0: 62 29 3b 0a 20 20 45 4e 44 3b 0a 7d 0a 0a 64 6f  b);.  END;.}..do
0ff0: 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 34 2e  _execsql_test 4.
1000: 31 20 7b 0a 20 20 41 4c 54 45 52 20 54 41 42 4c  1 {.  ALTER TABL
1010: 45 20 74 31 20 52 45 4e 41 4d 45 20 54 4f 20 74  E t1 RENAME TO t
1020: 31 78 3b 0a 20 20 53 45 4c 45 43 54 20 73 71 6c  1x;.  SELECT sql
1030: 20 46 52 4f 4d 20 73 71 6c 69 74 65 5f 6d 61 73   FROM sqlite_mas
1040: 74 65 72 20 57 48 45 52 45 20 74 79 70 65 20 3d  ter WHERE type =
1050: 20 27 74 72 69 67 67 65 72 27 3b 0a 7d 20 7b 0a   'trigger';.} {.
1060: 7b 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20  {CREATE TRIGGER 
1070: 72 31 20 41 46 54 45 52 20 49 4e 53 45 52 54 20  r1 AFTER INSERT 
1080: 4f 4e 20 22 74 31 78 22 20 57 48 45 4e 20 6e 65  ON "t1x" WHEN ne
1090: 77 2e 61 20 4e 4f 54 20 4e 55 4c 4c 20 42 45 47  w.a NOT NULL BEG
10a0: 49 4e 0a 20 20 20 20 55 50 44 41 54 45 20 22 74  IN.    UPDATE "t
10b0: 31 78 22 20 53 45 54 20 28 63 2c 64 29 3d 28 61  1x" SET (c,d)=(a
10c0: 2c 62 29 3b 0a 20 20 45 4e 44 7d 0a 7d 0a 0a 64  ,b);.  END}.}..d
10d0: 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 34  o_execsql_test 4
10e0: 2e 32 20 7b 0a 20 20 41 4c 54 45 52 20 54 41 42  .2 {.  ALTER TAB
10f0: 4c 45 20 74 31 78 20 52 45 4e 41 4d 45 20 61 20  LE t1x RENAME a 
1100: 54 4f 20 61 61 61 3b 0a 20 20 53 45 4c 45 43 54  TO aaa;.  SELECT
1110: 20 73 71 6c 20 46 52 4f 4d 20 73 71 6c 69 74 65   sql FROM sqlite
1120: 5f 6d 61 73 74 65 72 20 57 48 45 52 45 20 74 79  _master WHERE ty
1130: 70 65 20 3d 20 27 74 72 69 67 67 65 72 27 3b 0a  pe = 'trigger';.
1140: 7d 20 7b 0a 7b 43 52 45 41 54 45 20 54 52 49 47  } {.{CREATE TRIG
1150: 47 45 52 20 72 31 20 41 46 54 45 52 20 49 4e 53  GER r1 AFTER INS
1160: 45 52 54 20 4f 4e 20 22 74 31 78 22 20 57 48 45  ERT ON "t1x" WHE
1170: 4e 20 6e 65 77 2e 61 61 61 20 4e 4f 54 20 4e 55  N new.aaa NOT NU
1180: 4c 4c 20 42 45 47 49 4e 0a 20 20 20 20 55 50 44  LL BEGIN.    UPD
1190: 41 54 45 20 22 74 31 78 22 20 53 45 54 20 28 63  ATE "t1x" SET (c
11a0: 2c 64 29 3d 28 61 61 61 2c 62 29 3b 0a 20 20 45  ,d)=(aaa,b);.  E
11b0: 4e 44 7d 0a 7d 0a 0a 64 6f 5f 65 78 65 63 73 71  ND}.}..do_execsq
11c0: 6c 5f 74 65 73 74 20 34 2e 33 20 7b 0a 20 20 41  l_test 4.3 {.  A
11d0: 4c 54 45 52 20 54 41 42 4c 45 20 74 31 78 20 52  LTER TABLE t1x R
11e0: 45 4e 41 4d 45 20 64 20 54 4f 20 64 64 64 3b 0a  ENAME d TO ddd;.
11f0: 20 20 53 45 4c 45 43 54 20 73 71 6c 20 46 52 4f    SELECT sql FRO
1200: 4d 20 73 71 6c 69 74 65 5f 6d 61 73 74 65 72 20  M sqlite_master 
1210: 57 48 45 52 45 20 74 79 70 65 20 3d 20 27 74 72  WHERE type = 'tr
1220: 69 67 67 65 72 27 3b 0a 7d 20 7b 0a 7b 43 52 45  igger';.} {.{CRE
1230: 41 54 45 20 54 52 49 47 47 45 52 20 72 31 20 41  ATE TRIGGER r1 A
1240: 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 22  FTER INSERT ON "
1250: 74 31 78 22 20 57 48 45 4e 20 6e 65 77 2e 61 61  t1x" WHEN new.aa
1260: 61 20 4e 4f 54 20 4e 55 4c 4c 20 42 45 47 49 4e  a NOT NULL BEGIN
1270: 0a 20 20 20 20 55 50 44 41 54 45 20 22 74 31 78  .    UPDATE "t1x
1280: 22 20 53 45 54 20 28 63 2c 64 64 64 29 3d 28 61  " SET (c,ddd)=(a
1290: 61 61 2c 62 29 3b 0a 20 20 45 4e 44 7d 0a 7d 0a  aa,b);.  END}.}.
12a0: 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  .#--------------
12b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
12c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
12d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
12e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 69 66 63 61  -----------.ifca
12f0: 70 61 62 6c 65 20 77 69 6e 64 6f 77 66 75 6e 63  pable windowfunc
1300: 20 7b 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65   {.do_execsql_te
1310: 73 74 20 35 2e 30 20 7b 0a 20 20 43 52 45 41 54  st 5.0 {.  CREAT
1320: 45 20 54 41 42 4c 45 20 74 32 28 61 29 3b 0a 20  E TABLE t2(a);. 
1330: 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
1340: 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54 20  r2 AFTER INSERT 
1350: 4f 4e 20 74 32 20 57 48 45 4e 20 6e 65 77 2e 61  ON t2 WHEN new.a
1360: 20 4e 4f 54 20 4e 55 4c 4c 20 42 45 47 49 4e 0a   NOT NULL BEGIN.
1370: 20 20 20 20 53 45 4c 45 43 54 20 61 2c 20 73 75      SELECT a, su
1380: 6d 28 61 29 20 4f 56 45 52 20 77 31 20 46 52 4f  m(a) OVER w1 FRO
1390: 4d 20 74 32 0a 20 20 20 20 20 20 57 49 4e 44 4f  M t2.      WINDO
13a0: 57 20 77 31 20 41 53 20 28 0a 20 20 20 20 20 20  W w1 AS (.      
13b0: 20 20 50 41 52 54 49 54 49 4f 4e 20 42 59 20 61    PARTITION BY a
13c0: 20 4f 52 44 45 52 20 42 59 20 61 20 0a 20 20 20   ORDER BY a .   
13d0: 20 20 20 20 20 52 4f 57 53 20 42 45 54 57 45 45       ROWS BETWEE
13e0: 4e 20 32 20 50 52 45 43 45 44 49 4e 47 20 41 4e  N 2 PRECEDING AN
13f0: 44 20 33 20 46 4f 4c 4c 4f 57 49 4e 47 0a 20 20  D 3 FOLLOWING.  
1400: 20 20 20 20 29 2c 0a 20 20 20 20 20 20 77 32 20      ),.      w2 
1410: 41 53 20 28 0a 20 20 20 20 20 20 20 20 50 41 52  AS (.        PAR
1420: 54 49 54 49 4f 4e 20 42 59 20 61 0a 20 20 20 20  TITION BY a.    
1430: 20 20 20 20 4f 52 44 45 52 20 42 59 20 72 6f 77      ORDER BY row
1440: 69 64 20 52 4f 57 53 20 42 45 54 57 45 45 4e 20  id ROWS BETWEEN 
1450: 43 55 52 52 45 4e 54 20 52 4f 57 20 41 4e 44 20  CURRENT ROW AND 
1460: 55 4e 42 4f 55 4e 44 45 44 20 46 4f 4c 4c 4f 57  UNBOUNDED FOLLOW
1470: 49 4e 47 0a 20 20 20 20 20 20 29 3b 0a 20 20 45  ING.      );.  E
1480: 4e 44 3b 0a 7d 20 7b 7d 0a 0a 64 6f 5f 65 78 65  ND;.} {}..do_exe
1490: 63 73 71 6c 5f 74 65 73 74 20 35 2e 30 2e 31 20  csql_test 5.0.1 
14a0: 7b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  {.  INSERT INTO 
14b0: 74 32 20 56 41 4c 55 45 53 28 31 29 3b 0a 7d 20  t2 VALUES(1);.} 
14c0: 7b 7d 0a 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74  {}..do_execsql_t
14d0: 65 73 74 20 35 2e 31 20 7b 0a 20 20 41 4c 54 45  est 5.1 {.  ALTE
14e0: 52 20 54 41 42 4c 45 20 74 32 20 52 45 4e 41 4d  R TABLE t2 RENAM
14f0: 45 20 54 4f 20 74 32 78 3b 0a 20 20 53 45 4c 45  E TO t2x;.  SELE
1500: 43 54 20 73 71 6c 20 46 52 4f 4d 20 73 71 6c 69  CT sql FROM sqli
1510: 74 65 5f 6d 61 73 74 65 72 20 57 48 45 52 45 20  te_master WHERE 
1520: 6e 61 6d 65 20 3d 20 27 72 32 27 3b 0a 7d 20 7b  name = 'r2';.} {
1530: 0a 20 20 7b 43 52 45 41 54 45 20 54 52 49 47 47  .  {CREATE TRIGG
1540: 45 52 20 72 32 20 41 46 54 45 52 20 49 4e 53 45  ER r2 AFTER INSE
1550: 52 54 20 4f 4e 20 22 74 32 78 22 20 57 48 45 4e  RT ON "t2x" WHEN
1560: 20 6e 65 77 2e 61 20 4e 4f 54 20 4e 55 4c 4c 20   new.a NOT NULL 
1570: 42 45 47 49 4e 0a 20 20 20 20 53 45 4c 45 43 54  BEGIN.    SELECT
1580: 20 61 2c 20 73 75 6d 28 61 29 20 4f 56 45 52 20   a, sum(a) OVER 
1590: 77 31 20 46 52 4f 4d 20 22 74 32 78 22 0a 20 20  w1 FROM "t2x".  
15a0: 20 20 20 20 57 49 4e 44 4f 57 20 77 31 20 41 53      WINDOW w1 AS
15b0: 20 28 0a 20 20 20 20 20 20 20 20 50 41 52 54 49   (.        PARTI
15c0: 54 49 4f 4e 20 42 59 20 61 20 4f 52 44 45 52 20  TION BY a ORDER 
15d0: 42 59 20 61 20 0a 20 20 20 20 20 20 20 20 52 4f  BY a .        RO
15e0: 57 53 20 42 45 54 57 45 45 4e 20 32 20 50 52 45  WS BETWEEN 2 PRE
15f0: 43 45 44 49 4e 47 20 41 4e 44 20 33 20 46 4f 4c  CEDING AND 3 FOL
1600: 4c 4f 57 49 4e 47 0a 20 20 20 20 20 20 29 2c 0a  LOWING.      ),.
1610: 20 20 20 20 20 20 77 32 20 41 53 20 28 0a 20 20        w2 AS (.  
1620: 20 20 20 20 20 20 50 41 52 54 49 54 49 4f 4e 20        PARTITION 
1630: 42 59 20 61 0a 20 20 20 20 20 20 20 20 4f 52 44  BY a.        ORD
1640: 45 52 20 42 59 20 72 6f 77 69 64 20 52 4f 57 53  ER BY rowid ROWS
1650: 20 42 45 54 57 45 45 4e 20 43 55 52 52 45 4e 54   BETWEEN CURRENT
1660: 20 52 4f 57 20 41 4e 44 20 55 4e 42 4f 55 4e 44   ROW AND UNBOUND
1670: 45 44 20 46 4f 4c 4c 4f 57 49 4e 47 0a 20 20 20  ED FOLLOWING.   
1680: 20 20 20 29 3b 0a 20 20 45 4e 44 7d 0a 7d 0a 0a     );.  END}.}..
1690: 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20  do_execsql_test 
16a0: 35 2e 32 20 7b 0a 20 20 41 4c 54 45 52 20 54 41  5.2 {.  ALTER TA
16b0: 42 4c 45 20 74 32 78 20 52 45 4e 41 4d 45 20 61  BLE t2x RENAME a
16c0: 20 54 4f 20 61 61 61 61 3b 0a 20 20 53 45 4c 45   TO aaaa;.  SELE
16d0: 43 54 20 73 71 6c 20 46 52 4f 4d 20 73 71 6c 69  CT sql FROM sqli
16e0: 74 65 5f 6d 61 73 74 65 72 20 57 48 45 52 45 20  te_master WHERE 
16f0: 6e 61 6d 65 20 3d 20 27 72 32 27 3b 0a 7d 20 7b  name = 'r2';.} {
1700: 0a 20 20 7b 43 52 45 41 54 45 20 54 52 49 47 47  .  {CREATE TRIGG
1710: 45 52 20 72 32 20 41 46 54 45 52 20 49 4e 53 45  ER r2 AFTER INSE
1720: 52 54 20 4f 4e 20 22 74 32 78 22 20 57 48 45 4e  RT ON "t2x" WHEN
1730: 20 6e 65 77 2e 61 61 61 61 20 4e 4f 54 20 4e 55   new.aaaa NOT NU
1740: 4c 4c 20 42 45 47 49 4e 0a 20 20 20 20 53 45 4c  LL BEGIN.    SEL
1750: 45 43 54 20 61 61 61 61 2c 20 73 75 6d 28 61 61  ECT aaaa, sum(aa
1760: 61 61 29 20 4f 56 45 52 20 77 31 20 46 52 4f 4d  aa) OVER w1 FROM
1770: 20 22 74 32 78 22 0a 20 20 20 20 20 20 57 49 4e   "t2x".      WIN
1780: 44 4f 57 20 77 31 20 41 53 20 28 0a 20 20 20 20  DOW w1 AS (.    
1790: 20 20 20 20 50 41 52 54 49 54 49 4f 4e 20 42 59      PARTITION BY
17a0: 20 61 61 61 61 20 4f 52 44 45 52 20 42 59 20 61   aaaa ORDER BY a
17b0: 61 61 61 20 0a 20 20 20 20 20 20 20 20 52 4f 57  aaa .        ROW
17c0: 53 20 42 45 54 57 45 45 4e 20 32 20 50 52 45 43  S BETWEEN 2 PREC
17d0: 45 44 49 4e 47 20 41 4e 44 20 33 20 46 4f 4c 4c  EDING AND 3 FOLL
17e0: 4f 57 49 4e 47 0a 20 20 20 20 20 20 29 2c 0a 20  OWING.      ),. 
17f0: 20 20 20 20 20 77 32 20 41 53 20 28 0a 20 20 20       w2 AS (.   
1800: 20 20 20 20 20 50 41 52 54 49 54 49 4f 4e 20 42       PARTITION B
1810: 59 20 61 61 61 61 0a 20 20 20 20 20 20 20 20 4f  Y aaaa.        O
1820: 52 44 45 52 20 42 59 20 72 6f 77 69 64 20 52 4f  RDER BY rowid RO
1830: 57 53 20 42 45 54 57 45 45 4e 20 43 55 52 52 45  WS BETWEEN CURRE
1840: 4e 54 20 52 4f 57 20 41 4e 44 20 55 4e 42 4f 55  NT ROW AND UNBOU
1850: 4e 44 45 44 20 46 4f 4c 4c 4f 57 49 4e 47 0a 20  NDED FOLLOWING. 
1860: 20 20 20 20 20 29 3b 0a 20 20 45 4e 44 7d 0a 7d       );.  END}.}
1870: 0a 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73  ..do_execsql_tes
1880: 74 20 35 2e 33 20 7b 0a 20 20 49 4e 53 45 52 54  t 5.3 {.  INSERT
1890: 20 49 4e 54 4f 20 74 32 78 20 56 41 4c 55 45 53   INTO t2x VALUES
18a0: 28 31 29 3b 0a 7d 20 7b 7d 0a 7d 20 3b 23 20 77  (1);.} {}.} ;# w
18b0: 69 6e 64 6f 77 66 75 6e 63 0a 0a 23 2d 2d 2d 2d  indowfunc..#----
18c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
18d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
18e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
18f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1900: 2d 2d 2d 2d 2d 0a 0a 64 6f 5f 65 78 65 63 73 71  -----..do_execsq
1910: 6c 5f 74 65 73 74 20 36 2e 30 20 7b 0a 20 20 43  l_test 6.0 {.  C
1920: 52 45 41 54 45 20 54 41 42 4c 45 20 74 33 28 61  REATE TABLE t3(a
1930: 2c 62 2c 63 2c 64 29 3b 0a 20 20 43 52 45 41 54  ,b,c,d);.  CREAT
1940: 45 20 54 52 49 47 47 45 52 20 72 33 20 41 46 54  E TRIGGER r3 AFT
1950: 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 33 20  ER INSERT ON t3 
1960: 57 48 45 4e 20 6e 65 77 2e 61 20 4e 4f 54 20 4e  WHEN new.a NOT N
1970: 55 4c 4c 20 42 45 47 49 4e 0a 20 20 20 20 53 45  ULL BEGIN.    SE
1980: 4c 45 43 54 20 61 2c 62 2c 63 20 46 52 4f 4d 20  LECT a,b,c FROM 
1990: 74 33 20 45 58 43 45 50 54 20 53 45 4c 45 43 54  t3 EXCEPT SELECT
19a0: 20 61 2c 62 2c 63 20 46 52 4f 4d 20 74 33 20 4f   a,b,c FROM t3 O
19b0: 52 44 45 52 20 42 59 20 61 3b 0a 20 20 20 20 53  RDER BY a;.    S
19c0: 45 4c 45 43 54 20 72 6f 77 69 64 2c 20 2a 20 46  ELECT rowid, * F
19d0: 52 4f 4d 20 74 33 3b 0a 20 20 45 4e 44 3b 0a 7d  ROM t3;.  END;.}
19e0: 20 7b 7d 0a 0a 64 6f 5f 65 78 65 63 73 71 6c 5f   {}..do_execsql_
19f0: 74 65 73 74 20 36 2e 31 20 7b 0a 20 20 41 4c 54  test 6.1 {.  ALT
1a00: 45 52 20 54 41 42 4c 45 20 74 33 20 52 45 4e 41  ER TABLE t3 RENA
1a10: 4d 45 20 54 4f 20 74 33 78 3b 0a 20 20 53 45 4c  ME TO t3x;.  SEL
1a20: 45 43 54 20 73 71 6c 20 46 52 4f 4d 20 73 71 6c  ECT sql FROM sql
1a30: 69 74 65 5f 6d 61 73 74 65 72 20 57 48 45 52 45  ite_master WHERE
1a40: 20 6e 61 6d 65 20 3d 20 27 72 33 27 3b 0a 7d 20   name = 'r3';.} 
1a50: 7b 0a 20 20 7b 43 52 45 41 54 45 20 54 52 49 47  {.  {CREATE TRIG
1a60: 47 45 52 20 72 33 20 41 46 54 45 52 20 49 4e 53  GER r3 AFTER INS
1a70: 45 52 54 20 4f 4e 20 22 74 33 78 22 20 57 48 45  ERT ON "t3x" WHE
1a80: 4e 20 6e 65 77 2e 61 20 4e 4f 54 20 4e 55 4c 4c  N new.a NOT NULL
1a90: 20 42 45 47 49 4e 0a 20 20 20 20 53 45 4c 45 43   BEGIN.    SELEC
1aa0: 54 20 61 2c 62 2c 63 20 46 52 4f 4d 20 22 74 33  T a,b,c FROM "t3
1ab0: 78 22 20 45 58 43 45 50 54 20 53 45 4c 45 43 54  x" EXCEPT SELECT
1ac0: 20 61 2c 62 2c 63 20 46 52 4f 4d 20 22 74 33 78   a,b,c FROM "t3x
1ad0: 22 20 4f 52 44 45 52 20 42 59 20 61 3b 0a 20 20  " ORDER BY a;.  
1ae0: 20 20 53 45 4c 45 43 54 20 72 6f 77 69 64 2c 20    SELECT rowid, 
1af0: 2a 20 46 52 4f 4d 20 22 74 33 78 22 3b 0a 20 20  * FROM "t3x";.  
1b00: 45 4e 44 7d 0a 7d 0a 0a 64 6f 5f 65 78 65 63 73  END}.}..do_execs
1b10: 71 6c 5f 74 65 73 74 20 36 2e 32 20 7b 0a 20 20  ql_test 6.2 {.  
1b20: 41 4c 54 45 52 20 54 41 42 4c 45 20 74 33 78 20  ALTER TABLE t3x 
1b30: 52 45 4e 41 4d 45 20 61 20 54 4f 20 61 62 63 64  RENAME a TO abcd
1b40: 3b 0a 20 20 53 45 4c 45 43 54 20 73 71 6c 20 46  ;.  SELECT sql F
1b50: 52 4f 4d 20 73 71 6c 69 74 65 5f 6d 61 73 74 65  ROM sqlite_maste
1b60: 72 20 57 48 45 52 45 20 6e 61 6d 65 20 3d 20 27  r WHERE name = '
1b70: 72 33 27 3b 0a 7d 20 7b 0a 20 20 7b 43 52 45 41  r3';.} {.  {CREA
1b80: 54 45 20 54 52 49 47 47 45 52 20 72 33 20 41 46  TE TRIGGER r3 AF
1b90: 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 22 74  TER INSERT ON "t
1ba0: 33 78 22 20 57 48 45 4e 20 6e 65 77 2e 61 62 63  3x" WHEN new.abc
1bb0: 64 20 4e 4f 54 20 4e 55 4c 4c 20 42 45 47 49 4e  d NOT NULL BEGIN
1bc0: 0a 20 20 20 20 53 45 4c 45 43 54 20 61 62 63 64  .    SELECT abcd
1bd0: 2c 62 2c 63 20 46 52 4f 4d 20 22 74 33 78 22 20  ,b,c FROM "t3x" 
1be0: 45 58 43 45 50 54 20 53 45 4c 45 43 54 20 61 62  EXCEPT SELECT ab
1bf0: 63 64 2c 62 2c 63 20 46 52 4f 4d 20 22 74 33 78  cd,b,c FROM "t3x
1c00: 22 20 4f 52 44 45 52 20 42 59 20 61 62 63 64 3b  " ORDER BY abcd;
1c10: 0a 20 20 20 20 53 45 4c 45 43 54 20 72 6f 77 69  .    SELECT rowi
1c20: 64 2c 20 2a 20 46 52 4f 4d 20 22 74 33 78 22 3b  d, * FROM "t3x";
1c30: 0a 20 20 45 4e 44 7d 0a 7d 0a 0a 23 2d 2d 2d 2d  .  END}.}..#----
1c40: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1c50: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1c60: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1c70: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1c80: 2d 2d 2d 2d 2d 0a 72 65 73 65 74 5f 64 62 0a 0a  -----.reset_db..
1c90: 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20  do_execsql_test 
1ca0: 37 2e 30 20 7b 0a 20 20 43 52 45 41 54 45 20 54  7.0 {.  CREATE T
1cb0: 41 42 4c 45 20 74 31 28 61 2c 62 2c 63 2c 64 2c  ABLE t1(a,b,c,d,
1cc0: 65 2c 66 29 3b 0a 20 20 49 4e 53 45 52 54 20 49  e,f);.  INSERT I
1cd0: 4e 54 4f 20 74 31 20 56 41 4c 55 45 53 28 31 2c  NTO t1 VALUES(1,
1ce0: 32 2c 33 2c 34 2c 35 2c 36 29 3b 0a 20 20 43 52  2,3,4,5,6);.  CR
1cf0: 45 41 54 45 20 54 41 42 4c 45 20 74 32 28 78 2c  EATE TABLE t2(x,
1d00: 79 2c 7a 29 3b 0a 7d 0a 0a 64 6f 5f 65 78 65 63  y,z);.}..do_exec
1d10: 73 71 6c 5f 74 65 73 74 20 37 2e 31 20 7b 0a 20  sql_test 7.1 {. 
1d20: 20 53 45 4c 45 43 54 20 61 2c 62 2c 63 20 46 52   SELECT a,b,c FR
1d30: 4f 4d 20 74 31 20 55 4e 49 4f 4e 20 53 45 4c 45  OM t1 UNION SELE
1d40: 43 54 20 64 2c 65 2c 66 20 46 52 4f 4d 20 74 31  CT d,e,f FROM t1
1d50: 20 4f 52 44 45 52 20 42 59 20 62 2c 63 3b 0a 7d   ORDER BY b,c;.}
1d60: 20 7b 31 20 32 20 33 20 34 20 35 20 36 7d 0a 0a   {1 2 3 4 5 6}..
1d70: 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20  do_execsql_test 
1d80: 37 2e 32 20 7b 0a 20 20 43 52 45 41 54 45 20 54  7.2 {.  CREATE T
1d90: 52 49 47 47 45 52 20 72 31 20 41 46 54 45 52 20  RIGGER r1 AFTER 
1da0: 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47  INSERT ON t1 BEG
1db0: 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
1dc0: 54 4f 20 74 32 0a 20 20 20 20 53 45 4c 45 43 54  TO t2.    SELECT
1dd0: 20 61 2c 62 2c 63 20 46 52 4f 4d 20 74 31 20 55   a,b,c FROM t1 U
1de0: 4e 49 4f 4e 20 53 45 4c 45 43 54 20 64 2c 65 2c  NION SELECT d,e,
1df0: 66 20 46 52 4f 4d 20 74 31 20 4f 52 44 45 52 20  f FROM t1 ORDER 
1e00: 42 59 20 62 2c 63 3b 0a 20 20 45 4e 44 3b 0a 20  BY b,c;.  END;. 
1e10: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 20   INSERT INTO t1 
1e20: 56 41 4c 55 45 53 28 32 2c 33 2c 34 2c 35 2c 36  VALUES(2,3,4,5,6
1e30: 2c 37 29 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20  ,7);.  SELECT * 
1e40: 46 52 4f 4d 20 74 32 3b 0a 7d 20 7b 31 20 32 20  FROM t2;.} {1 2 
1e50: 33 20 20 32 20 33 20 34 20 20 34 20 35 20 36 20  3  2 3 4  4 5 6 
1e60: 20 35 20 36 20 37 7d 0a 0a 64 6f 5f 65 78 65 63   5 6 7}..do_exec
1e70: 73 71 6c 5f 74 65 73 74 20 37 2e 33 20 7b 0a 20  sql_test 7.3 {. 
1e80: 20 41 4c 54 45 52 20 54 41 42 4c 45 20 74 31 20   ALTER TABLE t1 
1e90: 52 45 4e 41 4d 45 20 54 4f 20 78 79 7a 7a 79 3b  RENAME TO xyzzy;
1ea0: 0a 20 20 53 45 4c 45 43 54 20 73 71 6c 20 46 52  .  SELECT sql FR
1eb0: 4f 4d 20 73 71 6c 69 74 65 5f 6d 61 73 74 65 72  OM sqlite_master
1ec0: 20 57 48 45 52 45 20 6e 61 6d 65 3d 27 72 31 27   WHERE name='r1'
1ed0: 0a 7d 20 7b 0a 20 20 7b 43 52 45 41 54 45 20 54  .} {.  {CREATE T
1ee0: 52 49 47 47 45 52 20 72 31 20 41 46 54 45 52 20  RIGGER r1 AFTER 
1ef0: 49 4e 53 45 52 54 20 4f 4e 20 22 78 79 7a 7a 79  INSERT ON "xyzzy
1f00: 22 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  " BEGIN.    INSE
1f10: 52 54 20 49 4e 54 4f 20 74 32 0a 20 20 20 20 53  RT INTO t2.    S
1f20: 45 4c 45 43 54 20 61 2c 62 2c 63 20 46 52 4f 4d  ELECT a,b,c FROM
1f30: 20 22 78 79 7a 7a 79 22 20 55 4e 49 4f 4e 20 53   "xyzzy" UNION S
1f40: 45 4c 45 43 54 20 64 2c 65 2c 66 20 46 52 4f 4d  ELECT d,e,f FROM
1f50: 20 22 78 79 7a 7a 79 22 20 4f 52 44 45 52 20 42   "xyzzy" ORDER B
1f60: 59 20 62 2c 63 3b 0a 20 20 45 4e 44 7d 0a 7d 0a  Y b,c;.  END}.}.
1f70: 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74  .do_execsql_test
1f80: 20 37 2e 33 20 7b 0a 20 20 41 4c 54 45 52 20 54   7.3 {.  ALTER T
1f90: 41 42 4c 45 20 78 79 7a 7a 79 20 52 45 4e 41 4d  ABLE xyzzy RENAM
1fa0: 45 20 63 20 54 4f 20 63 63 63 3b 0a 20 20 53 45  E c TO ccc;.  SE
1fb0: 4c 45 43 54 20 73 71 6c 20 46 52 4f 4d 20 73 71  LECT sql FROM sq
1fc0: 6c 69 74 65 5f 6d 61 73 74 65 72 20 57 48 45 52  lite_master WHER
1fd0: 45 20 6e 61 6d 65 3d 27 72 31 27 0a 7d 20 7b 0a  E name='r1'.} {.
1fe0: 20 20 7b 43 52 45 41 54 45 20 54 52 49 47 47 45    {CREATE TRIGGE
1ff0: 52 20 72 31 20 41 46 54 45 52 20 49 4e 53 45 52  R r1 AFTER INSER
2000: 54 20 4f 4e 20 22 78 79 7a 7a 79 22 20 42 45 47  T ON "xyzzy" BEG
2010: 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
2020: 54 4f 20 74 32 0a 20 20 20 20 53 45 4c 45 43 54  TO t2.    SELECT
2030: 20 61 2c 62 2c 63 63 63 20 46 52 4f 4d 20 22 78   a,b,ccc FROM "x
2040: 79 7a 7a 79 22 20 55 4e 49 4f 4e 20 53 45 4c 45  yzzy" UNION SELE
2050: 43 54 20 64 2c 65 2c 66 20 46 52 4f 4d 20 22 78  CT d,e,f FROM "x
2060: 79 7a 7a 79 22 20 4f 52 44 45 52 20 42 59 20 62  yzzy" ORDER BY b
2070: 2c 63 63 63 3b 0a 20 20 45 4e 44 7d 0a 7d 0a 0a  ,ccc;.  END}.}..
2080: 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  #---------------
2090: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
20a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
20b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
20c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 72 65 73 65 74  ----------.reset
20d0: 5f 64 62 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74  _db.do_execsql_t
20e0: 65 73 74 20 38 2e 30 20 7b 0a 20 20 43 52 45 41  est 8.0 {.  CREA
20f0: 54 45 20 54 41 42 4c 45 20 74 31 28 61 2c 20 62  TE TABLE t1(a, b
2100: 2c 20 63 29 3b 20 0a 20 20 43 52 45 41 54 45 20  , c); .  CREATE 
2110: 54 41 42 4c 45 20 74 32 28 61 2c 20 62 2c 20 63  TABLE t2(a, b, c
2120: 29 3b 20 0a 20 20 43 52 45 41 54 45 20 54 41 42  ); .  CREATE TAB
2130: 4c 45 20 74 33 28 64 2c 20 65 2c 20 66 29 3b 0a  LE t3(d, e, f);.
2140: 20 20 43 52 45 41 54 45 20 56 49 45 57 20 76 31    CREATE VIEW v1
2150: 20 41 53 20 53 45 4c 45 43 54 20 2a 20 46 52 4f   AS SELECT * FRO
2160: 4d 20 74 31 3b 0a 20 20 43 52 45 41 54 45 20 54  M t1;.  CREATE T
2170: 52 49 47 47 45 52 20 74 72 20 41 46 54 45 52 20  RIGGER tr AFTER 
2180: 49 4e 53 45 52 54 20 4f 4e 20 74 33 20 42 45 47  INSERT ON t3 BEG
2190: 49 4e 0a 20 20 20 20 55 50 44 41 54 45 20 74 32  IN.    UPDATE t2
21a0: 20 53 45 54 20 61 20 3d 20 6e 65 77 2e 64 3b 0a   SET a = new.d;.
21b0: 20 20 20 20 53 45 4c 45 43 54 20 61 2c 20 62 2c      SELECT a, b,
21c0: 20 63 20 46 52 4f 4d 20 76 31 3b 0a 20 20 45 4e   c FROM v1;.  EN
21d0: 44 3b 0a 7d 0a 0a 64 6f 5f 65 78 65 63 73 71 6c  D;.}..do_execsql
21e0: 5f 74 65 73 74 20 38 2e 31 20 7b 0a 20 20 49 4e  _test 8.1 {.  IN
21f0: 53 45 52 54 20 49 4e 54 4f 20 74 33 20 56 41 4c  SERT INTO t3 VAL
2200: 55 45 53 28 31 2c 20 32 2c 20 33 29 3b 0a 7d 0a  UES(1, 2, 3);.}.
2210: 0a 23 20 54 68 65 20 66 6f 6c 6c 6f 77 69 6e 67  .# The following
2220: 20 41 4c 54 45 52 20 54 41 42 4c 45 20 66 61 69   ALTER TABLE fai
2230: 6c 73 20 61 73 20 69 66 20 63 6f 6c 75 6d 6e 20  ls as if column 
2240: 22 74 31 2e 61 22 20 69 73 20 72 65 6e 61 6d 65  "t1.a" is rename
2250: 64 20 74 68 65 20 22 61 22 0a 23 20 69 6e 20 74  d the "a".# in t
2260: 68 65 20 22 53 45 4c 45 43 54 20 61 2c 20 62 2c  he "SELECT a, b,
2270: 20 63 20 46 52 4f 4d 20 76 31 22 20 77 69 74 68   c FROM v1" with
2280: 69 6e 20 74 68 65 20 74 72 69 67 67 65 72 20 63  in the trigger c
2290: 61 6e 20 6e 6f 20 6c 6f 6e 67 65 72 20 62 65 0a  an no longer be.
22a0: 23 20 72 65 73 6f 6c 76 65 64 2e 20 42 75 74 20  # resolved. But 
22b0: 61 74 20 6f 6e 65 20 70 6f 69 6e 74 20 74 68 65  at one point the
22c0: 72 65 20 77 61 73 20 61 20 62 75 67 20 61 6c 6c  re was a bug all
22d0: 6f 77 69 6e 67 20 74 68 65 20 41 4c 54 45 52 20  owing the ALTER 
22e0: 54 41 42 4c 45 0a 23 20 73 75 63 63 65 65 64 2e  TABLE.# succeed.
22f0: 20 57 68 69 63 68 20 6d 65 61 6e 74 20 74 68 65   Which meant the
2300: 20 73 75 62 73 65 71 75 65 6e 74 20 49 4e 53 45   subsequent INSE
2310: 52 54 20 73 74 61 74 65 6d 65 6e 74 20 77 6f 75  RT statement wou
2320: 6c 64 20 66 61 69 6c 2e 0a 64 6f 5f 63 61 74 63  ld fail..do_catc
2330: 68 73 71 6c 5f 74 65 73 74 20 38 2e 32 20 7b 0a  hsql_test 8.2 {.
2340: 20 20 41 4c 54 45 52 20 54 41 42 4c 45 20 74 31    ALTER TABLE t1
2350: 20 52 45 4e 41 4d 45 20 61 20 54 4f 20 61 61 61   RENAME a TO aaa
2360: 3b 0a 7d 20 7b 31 20 7b 65 72 72 6f 72 20 69 6e  ;.} {1 {error in
2370: 20 74 72 69 67 67 65 72 20 74 72 20 61 66 74 65   trigger tr afte
2380: 72 20 72 65 6e 61 6d 65 3a 20 6e 6f 20 73 75 63  r rename: no suc
2390: 68 20 63 6f 6c 75 6d 6e 3a 20 61 7d 7d 0a 64 6f  h column: a}}.do
23a0: 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 38 2e  _execsql_test 8.
23b0: 33 20 7b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  3 {.  INSERT INT
23c0: 4f 20 74 33 20 56 41 4c 55 45 53 28 34 2c 20 35  O t3 VALUES(4, 5
23d0: 2c 20 36 29 3b 0a 7d 0a 0a 64 6f 5f 65 78 65 63  , 6);.}..do_exec
23e0: 73 71 6c 5f 74 65 73 74 20 38 2e 31 20 7b 0a 20  sql_test 8.1 {. 
23f0: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 34   CREATE TABLE t4
2400: 28 61 2c 20 62 29 3b 0a 20 20 43 52 45 41 54 45  (a, b);.  CREATE
2410: 20 56 49 45 57 20 76 34 20 41 53 20 53 45 4c 45   VIEW v4 AS SELE
2420: 43 54 20 2a 20 46 52 4f 4d 20 74 34 20 57 48 45  CT * FROM t4 WHE
2430: 52 45 20 28 61 3d 31 20 41 4e 44 20 30 29 20 4f  RE (a=1 AND 0) O
2440: 52 20 62 3d 32 3b 0a 7d 0a 64 6f 5f 65 78 65 63  R b=2;.}.do_exec
2450: 73 71 6c 5f 74 65 73 74 20 38 2e 32 20 7b 0a 20  sql_test 8.2 {. 
2460: 20 41 4c 54 45 52 20 54 41 42 4c 45 20 74 34 20   ALTER TABLE t4 
2470: 52 45 4e 41 4d 45 20 61 20 54 4f 20 63 3b 0a 20  RENAME a TO c;. 
2480: 20 53 45 4c 45 43 54 20 73 71 6c 20 46 52 4f 4d   SELECT sql FROM
2490: 20 73 71 6c 69 74 65 5f 6d 61 73 74 65 72 20 57   sqlite_master W
24a0: 48 45 52 45 20 6e 61 6d 65 20 3d 20 27 76 34 27  HERE name = 'v4'
24b0: 0a 7d 20 7b 7b 43 52 45 41 54 45 20 56 49 45 57  .} {{CREATE VIEW
24c0: 20 76 34 20 41 53 20 53 45 4c 45 43 54 20 2a 20   v4 AS SELECT * 
24d0: 46 52 4f 4d 20 74 34 20 57 48 45 52 45 20 28 63  FROM t4 WHERE (c
24e0: 3d 31 20 41 4e 44 20 30 29 20 4f 52 20 62 3d 32  =1 AND 0) OR b=2
24f0: 7d 7d 0a 0a 66 69 6e 69 73 68 5f 74 65 73 74 0a  }}..finish_test.
2500: 0a 0a                                            ..