/ Hex Artifact Content
Login

Artifact 7bedde2e6e71fdecd7a2af64b696cd0b3d3a344f5cf1db6785d9e3b5665193cf:


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 64 6f 5f 65  -----------.do_e
12f0: 78 65 63 73 71 6c 5f 74 65 73 74 20 35 2e 30 20  xecsql_test 5.0 
1300: 7b 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  {.  CREATE TABLE
1310: 20 74 32 28 61 29 3b 0a 20 20 43 52 45 41 54 45   t2(a);.  CREATE
1320: 20 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45   TRIGGER r2 AFTE
1330: 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 32 20 57  R INSERT ON t2 W
1340: 48 45 4e 20 6e 65 77 2e 61 20 4e 4f 54 20 4e 55  HEN new.a NOT NU
1350: 4c 4c 20 42 45 47 49 4e 0a 20 20 20 20 53 45 4c  LL BEGIN.    SEL
1360: 45 43 54 20 61 2c 20 73 75 6d 28 61 29 20 4f 56  ECT a, sum(a) OV
1370: 45 52 20 77 31 20 46 52 4f 4d 20 74 32 0a 20 20  ER w1 FROM t2.  
1380: 20 20 20 20 57 49 4e 44 4f 57 20 77 31 20 41 53      WINDOW w1 AS
1390: 20 28 0a 20 20 20 20 20 20 20 20 50 41 52 54 49   (.        PARTI
13a0: 54 49 4f 4e 20 42 59 20 61 20 4f 52 44 45 52 20  TION BY a ORDER 
13b0: 42 59 20 61 20 0a 20 20 20 20 20 20 20 20 52 4f  BY a .        RO
13c0: 57 53 20 42 45 54 57 45 45 4e 20 32 20 50 52 45  WS BETWEEN 2 PRE
13d0: 43 45 44 49 4e 47 20 41 4e 44 20 33 20 46 4f 4c  CEDING AND 3 FOL
13e0: 4c 4f 57 49 4e 47 0a 20 20 20 20 20 20 29 2c 0a  LOWING.      ),.
13f0: 20 20 20 20 20 20 77 32 20 41 53 20 28 0a 20 20        w2 AS (.  
1400: 20 20 20 20 20 20 50 41 52 54 49 54 49 4f 4e 20        PARTITION 
1410: 42 59 20 61 0a 20 20 20 20 20 20 20 20 4f 52 44  BY a.        ORD
1420: 45 52 20 42 59 20 72 6f 77 69 64 20 52 4f 57 53  ER BY rowid ROWS
1430: 20 42 45 54 57 45 45 4e 20 43 55 52 52 45 4e 54   BETWEEN CURRENT
1440: 20 52 4f 57 20 41 4e 44 20 55 4e 42 4f 55 4e 44   ROW AND UNBOUND
1450: 45 44 20 46 4f 4c 4c 4f 57 49 4e 47 0a 20 20 20  ED FOLLOWING.   
1460: 20 20 20 29 3b 0a 20 20 45 4e 44 3b 0a 7d 20 7b     );.  END;.} {
1470: 7d 0a 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65  }..do_execsql_te
1480: 73 74 20 35 2e 30 2e 31 20 7b 0a 20 20 49 4e 53  st 5.0.1 {.  INS
1490: 45 52 54 20 49 4e 54 4f 20 74 32 20 56 41 4c 55  ERT INTO t2 VALU
14a0: 45 53 28 31 29 3b 0a 7d 20 7b 7d 0a 0a 64 6f 5f  ES(1);.} {}..do_
14b0: 65 78 65 63 73 71 6c 5f 74 65 73 74 20 35 2e 31  execsql_test 5.1
14c0: 20 7b 0a 20 20 41 4c 54 45 52 20 54 41 42 4c 45   {.  ALTER TABLE
14d0: 20 74 32 20 52 45 4e 41 4d 45 20 54 4f 20 74 32   t2 RENAME TO t2
14e0: 78 3b 0a 20 20 53 45 4c 45 43 54 20 73 71 6c 20  x;.  SELECT sql 
14f0: 46 52 4f 4d 20 73 71 6c 69 74 65 5f 6d 61 73 74  FROM sqlite_mast
1500: 65 72 20 57 48 45 52 45 20 6e 61 6d 65 20 3d 20  er WHERE name = 
1510: 27 72 32 27 3b 0a 7d 20 7b 0a 20 20 7b 43 52 45  'r2';.} {.  {CRE
1520: 41 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41  ATE TRIGGER r2 A
1530: 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 22  FTER INSERT ON "
1540: 74 32 78 22 20 57 48 45 4e 20 6e 65 77 2e 61 20  t2x" WHEN new.a 
1550: 4e 4f 54 20 4e 55 4c 4c 20 42 45 47 49 4e 0a 20  NOT NULL BEGIN. 
1560: 20 20 20 53 45 4c 45 43 54 20 61 2c 20 73 75 6d     SELECT a, sum
1570: 28 61 29 20 4f 56 45 52 20 77 31 20 46 52 4f 4d  (a) OVER w1 FROM
1580: 20 22 74 32 78 22 0a 20 20 20 20 20 20 57 49 4e   "t2x".      WIN
1590: 44 4f 57 20 77 31 20 41 53 20 28 0a 20 20 20 20  DOW w1 AS (.    
15a0: 20 20 20 20 50 41 52 54 49 54 49 4f 4e 20 42 59      PARTITION BY
15b0: 20 61 20 4f 52 44 45 52 20 42 59 20 61 20 0a 20   a ORDER BY a . 
15c0: 20 20 20 20 20 20 20 52 4f 57 53 20 42 45 54 57         ROWS BETW
15d0: 45 45 4e 20 32 20 50 52 45 43 45 44 49 4e 47 20  EEN 2 PRECEDING 
15e0: 41 4e 44 20 33 20 46 4f 4c 4c 4f 57 49 4e 47 0a  AND 3 FOLLOWING.
15f0: 20 20 20 20 20 20 29 2c 0a 20 20 20 20 20 20 77        ),.      w
1600: 32 20 41 53 20 28 0a 20 20 20 20 20 20 20 20 50  2 AS (.        P
1610: 41 52 54 49 54 49 4f 4e 20 42 59 20 61 0a 20 20  ARTITION BY a.  
1620: 20 20 20 20 20 20 4f 52 44 45 52 20 42 59 20 72        ORDER BY r
1630: 6f 77 69 64 20 52 4f 57 53 20 42 45 54 57 45 45  owid ROWS BETWEE
1640: 4e 20 43 55 52 52 45 4e 54 20 52 4f 57 20 41 4e  N CURRENT ROW AN
1650: 44 20 55 4e 42 4f 55 4e 44 45 44 20 46 4f 4c 4c  D UNBOUNDED FOLL
1660: 4f 57 49 4e 47 0a 20 20 20 20 20 20 29 3b 0a 20  OWING.      );. 
1670: 20 45 4e 44 7d 0a 7d 0a 0a 64 6f 5f 65 78 65 63   END}.}..do_exec
1680: 73 71 6c 5f 74 65 73 74 20 35 2e 32 20 7b 0a 20  sql_test 5.2 {. 
1690: 20 41 4c 54 45 52 20 54 41 42 4c 45 20 74 32 78   ALTER TABLE t2x
16a0: 20 52 45 4e 41 4d 45 20 61 20 54 4f 20 61 61 61   RENAME a TO aaa
16b0: 61 3b 0a 20 20 53 45 4c 45 43 54 20 73 71 6c 20  a;.  SELECT sql 
16c0: 46 52 4f 4d 20 73 71 6c 69 74 65 5f 6d 61 73 74  FROM sqlite_mast
16d0: 65 72 20 57 48 45 52 45 20 6e 61 6d 65 20 3d 20  er WHERE name = 
16e0: 27 72 32 27 3b 0a 7d 20 7b 0a 20 20 7b 43 52 45  'r2';.} {.  {CRE
16f0: 41 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41  ATE TRIGGER r2 A
1700: 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 22  FTER INSERT ON "
1710: 74 32 78 22 20 57 48 45 4e 20 6e 65 77 2e 61 61  t2x" WHEN new.aa
1720: 61 61 20 4e 4f 54 20 4e 55 4c 4c 20 42 45 47 49  aa NOT NULL BEGI
1730: 4e 0a 20 20 20 20 53 45 4c 45 43 54 20 61 61 61  N.    SELECT aaa
1740: 61 2c 20 73 75 6d 28 61 61 61 61 29 20 4f 56 45  a, sum(aaaa) OVE
1750: 52 20 77 31 20 46 52 4f 4d 20 22 74 32 78 22 0a  R w1 FROM "t2x".
1760: 20 20 20 20 20 20 57 49 4e 44 4f 57 20 77 31 20        WINDOW w1 
1770: 41 53 20 28 0a 20 20 20 20 20 20 20 20 50 41 52  AS (.        PAR
1780: 54 49 54 49 4f 4e 20 42 59 20 61 61 61 61 20 4f  TITION BY aaaa O
1790: 52 44 45 52 20 42 59 20 61 61 61 61 20 0a 20 20  RDER BY aaaa .  
17a0: 20 20 20 20 20 20 52 4f 57 53 20 42 45 54 57 45        ROWS BETWE
17b0: 45 4e 20 32 20 50 52 45 43 45 44 49 4e 47 20 41  EN 2 PRECEDING A
17c0: 4e 44 20 33 20 46 4f 4c 4c 4f 57 49 4e 47 0a 20  ND 3 FOLLOWING. 
17d0: 20 20 20 20 20 29 2c 0a 20 20 20 20 20 20 77 32       ),.      w2
17e0: 20 41 53 20 28 0a 20 20 20 20 20 20 20 20 50 41   AS (.        PA
17f0: 52 54 49 54 49 4f 4e 20 42 59 20 61 61 61 61 0a  RTITION BY aaaa.
1800: 20 20 20 20 20 20 20 20 4f 52 44 45 52 20 42 59          ORDER BY
1810: 20 72 6f 77 69 64 20 52 4f 57 53 20 42 45 54 57   rowid ROWS BETW
1820: 45 45 4e 20 43 55 52 52 45 4e 54 20 52 4f 57 20  EEN CURRENT ROW 
1830: 41 4e 44 20 55 4e 42 4f 55 4e 44 45 44 20 46 4f  AND UNBOUNDED FO
1840: 4c 4c 4f 57 49 4e 47 0a 20 20 20 20 20 20 29 3b  LLOWING.      );
1850: 0a 20 20 45 4e 44 7d 0a 7d 0a 0a 64 6f 5f 65 78  .  END}.}..do_ex
1860: 65 63 73 71 6c 5f 74 65 73 74 20 35 2e 33 20 7b  ecsql_test 5.3 {
1870: 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
1880: 32 78 20 56 41 4c 55 45 53 28 31 29 3b 0a 7d 20  2x VALUES(1);.} 
1890: 7b 7d 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  {}..#-----------
18a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
18b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
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 0a 0a  --------------..
18e0: 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20  do_execsql_test 
18f0: 36 2e 30 20 7b 0a 20 20 43 52 45 41 54 45 20 54  6.0 {.  CREATE T
1900: 41 42 4c 45 20 74 33 28 61 2c 62 2c 63 2c 64 29  ABLE t3(a,b,c,d)
1910: 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
1920: 45 52 20 72 33 20 41 46 54 45 52 20 49 4e 53 45  ER r3 AFTER INSE
1930: 52 54 20 4f 4e 20 74 33 20 57 48 45 4e 20 6e 65  RT ON t3 WHEN ne
1940: 77 2e 61 20 4e 4f 54 20 4e 55 4c 4c 20 42 45 47  w.a NOT NULL BEG
1950: 49 4e 0a 20 20 20 20 53 45 4c 45 43 54 20 61 2c  IN.    SELECT a,
1960: 62 2c 63 20 46 52 4f 4d 20 74 33 20 45 58 43 45  b,c FROM t3 EXCE
1970: 50 54 20 53 45 4c 45 43 54 20 61 2c 62 2c 63 20  PT SELECT a,b,c 
1980: 46 52 4f 4d 20 74 33 20 4f 52 44 45 52 20 42 59  FROM t3 ORDER BY
1990: 20 61 3b 0a 20 20 20 20 53 45 4c 45 43 54 20 72   a;.    SELECT r
19a0: 6f 77 69 64 2c 20 2a 20 46 52 4f 4d 20 74 33 3b  owid, * FROM t3;
19b0: 0a 20 20 45 4e 44 3b 0a 7d 20 7b 7d 0a 0a 64 6f  .  END;.} {}..do
19c0: 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 36 2e  _execsql_test 6.
19d0: 31 20 7b 0a 20 20 41 4c 54 45 52 20 54 41 42 4c  1 {.  ALTER TABL
19e0: 45 20 74 33 20 52 45 4e 41 4d 45 20 54 4f 20 74  E t3 RENAME TO t
19f0: 33 78 3b 0a 20 20 53 45 4c 45 43 54 20 73 71 6c  3x;.  SELECT sql
1a00: 20 46 52 4f 4d 20 73 71 6c 69 74 65 5f 6d 61 73   FROM sqlite_mas
1a10: 74 65 72 20 57 48 45 52 45 20 6e 61 6d 65 20 3d  ter WHERE name =
1a20: 20 27 72 33 27 3b 0a 7d 20 7b 0a 20 20 7b 43 52   'r3';.} {.  {CR
1a30: 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20  EATE TRIGGER r3 
1a40: 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20  AFTER INSERT ON 
1a50: 22 74 33 78 22 20 57 48 45 4e 20 6e 65 77 2e 61  "t3x" WHEN new.a
1a60: 20 4e 4f 54 20 4e 55 4c 4c 20 42 45 47 49 4e 0a   NOT NULL BEGIN.
1a70: 20 20 20 20 53 45 4c 45 43 54 20 61 2c 62 2c 63      SELECT a,b,c
1a80: 20 46 52 4f 4d 20 22 74 33 78 22 20 45 58 43 45   FROM "t3x" EXCE
1a90: 50 54 20 53 45 4c 45 43 54 20 61 2c 62 2c 63 20  PT SELECT a,b,c 
1aa0: 46 52 4f 4d 20 22 74 33 78 22 20 4f 52 44 45 52  FROM "t3x" ORDER
1ab0: 20 42 59 20 61 3b 0a 20 20 20 20 53 45 4c 45 43   BY a;.    SELEC
1ac0: 54 20 72 6f 77 69 64 2c 20 2a 20 46 52 4f 4d 20  T rowid, * FROM 
1ad0: 22 74 33 78 22 3b 0a 20 20 45 4e 44 7d 0a 7d 0a  "t3x";.  END}.}.
1ae0: 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74  .do_execsql_test
1af0: 20 36 2e 32 20 7b 0a 20 20 41 4c 54 45 52 20 54   6.2 {.  ALTER T
1b00: 41 42 4c 45 20 74 33 78 20 52 45 4e 41 4d 45 20  ABLE t3x RENAME 
1b10: 61 20 54 4f 20 61 62 63 64 3b 0a 20 20 53 45 4c  a TO abcd;.  SEL
1b20: 45 43 54 20 73 71 6c 20 46 52 4f 4d 20 73 71 6c  ECT sql FROM sql
1b30: 69 74 65 5f 6d 61 73 74 65 72 20 57 48 45 52 45  ite_master WHERE
1b40: 20 6e 61 6d 65 20 3d 20 27 72 33 27 3b 0a 7d 20   name = 'r3';.} 
1b50: 7b 0a 20 20 7b 43 52 45 41 54 45 20 54 52 49 47  {.  {CREATE TRIG
1b60: 47 45 52 20 72 33 20 41 46 54 45 52 20 49 4e 53  GER r3 AFTER INS
1b70: 45 52 54 20 4f 4e 20 22 74 33 78 22 20 57 48 45  ERT ON "t3x" WHE
1b80: 4e 20 6e 65 77 2e 61 62 63 64 20 4e 4f 54 20 4e  N new.abcd NOT N
1b90: 55 4c 4c 20 42 45 47 49 4e 0a 20 20 20 20 53 45  ULL BEGIN.    SE
1ba0: 4c 45 43 54 20 61 62 63 64 2c 62 2c 63 20 46 52  LECT abcd,b,c FR
1bb0: 4f 4d 20 22 74 33 78 22 20 45 58 43 45 50 54 20  OM "t3x" EXCEPT 
1bc0: 53 45 4c 45 43 54 20 61 62 63 64 2c 62 2c 63 20  SELECT abcd,b,c 
1bd0: 46 52 4f 4d 20 22 74 33 78 22 20 4f 52 44 45 52  FROM "t3x" ORDER
1be0: 20 42 59 20 61 62 63 64 3b 0a 20 20 20 20 53 45   BY abcd;.    SE
1bf0: 4c 45 43 54 20 72 6f 77 69 64 2c 20 2a 20 46 52  LECT rowid, * FR
1c00: 4f 4d 20 22 74 33 78 22 3b 0a 20 20 45 4e 44 7d  OM "t3x";.  END}
1c10: 0a 7d 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  .}..#-----------
1c20: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1c30: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
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 0a 72  --------------.r
1c60: 65 73 65 74 5f 64 62 0a 0a 64 6f 5f 65 78 65 63  eset_db..do_exec
1c70: 73 71 6c 5f 74 65 73 74 20 37 2e 30 20 7b 0a 20  sql_test 7.0 {. 
1c80: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
1c90: 28 61 2c 62 2c 63 2c 64 2c 65 2c 66 29 3b 0a 20  (a,b,c,d,e,f);. 
1ca0: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 20   INSERT INTO t1 
1cb0: 56 41 4c 55 45 53 28 31 2c 32 2c 33 2c 34 2c 35  VALUES(1,2,3,4,5
1cc0: 2c 36 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41  ,6);.  CREATE TA
1cd0: 42 4c 45 20 74 32 28 78 2c 79 2c 7a 29 3b 0a 7d  BLE t2(x,y,z);.}
1ce0: 0a 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73  ..do_execsql_tes
1cf0: 74 20 37 2e 31 20 7b 0a 20 20 53 45 4c 45 43 54  t 7.1 {.  SELECT
1d00: 20 61 2c 62 2c 63 20 46 52 4f 4d 20 74 31 20 55   a,b,c FROM t1 U
1d10: 4e 49 4f 4e 20 53 45 4c 45 43 54 20 64 2c 65 2c  NION SELECT d,e,
1d20: 66 20 46 52 4f 4d 20 74 31 20 4f 52 44 45 52 20  f FROM t1 ORDER 
1d30: 42 59 20 62 2c 63 3b 0a 7d 20 7b 31 20 32 20 33  BY b,c;.} {1 2 3
1d40: 20 34 20 35 20 36 7d 0a 0a 64 6f 5f 65 78 65 63   4 5 6}..do_exec
1d50: 73 71 6c 5f 74 65 73 74 20 37 2e 32 20 7b 0a 20  sql_test 7.2 {. 
1d60: 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
1d70: 72 31 20 41 46 54 45 52 20 49 4e 53 45 52 54 20  r1 AFTER INSERT 
1d80: 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
1d90: 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 32 0a 20  INSERT INTO t2. 
1da0: 20 20 20 53 45 4c 45 43 54 20 61 2c 62 2c 63 20     SELECT a,b,c 
1db0: 46 52 4f 4d 20 74 31 20 55 4e 49 4f 4e 20 53 45  FROM t1 UNION SE
1dc0: 4c 45 43 54 20 64 2c 65 2c 66 20 46 52 4f 4d 20  LECT d,e,f FROM 
1dd0: 74 31 20 4f 52 44 45 52 20 42 59 20 62 2c 63 3b  t1 ORDER BY b,c;
1de0: 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54  .  END;.  INSERT
1df0: 20 49 4e 54 4f 20 74 31 20 56 41 4c 55 45 53 28   INTO t1 VALUES(
1e00: 32 2c 33 2c 34 2c 35 2c 36 2c 37 29 3b 0a 20 20  2,3,4,5,6,7);.  
1e10: 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 74 32  SELECT * FROM t2
1e20: 3b 0a 7d 20 7b 31 20 32 20 33 20 20 32 20 33 20  ;.} {1 2 3  2 3 
1e30: 34 20 20 34 20 35 20 36 20 20 35 20 36 20 37 7d  4  4 5 6  5 6 7}
1e40: 0a 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73  ..do_execsql_tes
1e50: 74 20 37 2e 33 20 7b 0a 20 20 41 4c 54 45 52 20  t 7.3 {.  ALTER 
1e60: 54 41 42 4c 45 20 74 31 20 52 45 4e 41 4d 45 20  TABLE t1 RENAME 
1e70: 54 4f 20 78 79 7a 7a 79 3b 0a 20 20 53 45 4c 45  TO xyzzy;.  SELE
1e80: 43 54 20 73 71 6c 20 46 52 4f 4d 20 73 71 6c 69  CT sql FROM sqli
1e90: 74 65 5f 6d 61 73 74 65 72 20 57 48 45 52 45 20  te_master WHERE 
1ea0: 6e 61 6d 65 3d 27 72 31 27 0a 7d 20 7b 0a 20 20  name='r1'.} {.  
1eb0: 7b 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20  {CREATE TRIGGER 
1ec0: 72 31 20 41 46 54 45 52 20 49 4e 53 45 52 54 20  r1 AFTER INSERT 
1ed0: 4f 4e 20 22 78 79 7a 7a 79 22 20 42 45 47 49 4e  ON "xyzzy" BEGIN
1ee0: 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
1ef0: 20 74 32 0a 20 20 20 20 53 45 4c 45 43 54 20 61   t2.    SELECT a
1f00: 2c 62 2c 63 20 46 52 4f 4d 20 22 78 79 7a 7a 79  ,b,c FROM "xyzzy
1f10: 22 20 55 4e 49 4f 4e 20 53 45 4c 45 43 54 20 64  " UNION SELECT d
1f20: 2c 65 2c 66 20 46 52 4f 4d 20 22 78 79 7a 7a 79  ,e,f FROM "xyzzy
1f30: 22 20 4f 52 44 45 52 20 42 59 20 62 2c 63 3b 0a  " ORDER BY b,c;.
1f40: 20 20 45 4e 44 7d 0a 7d 0a 0a 64 6f 5f 65 78 65    END}.}..do_exe
1f50: 63 73 71 6c 5f 74 65 73 74 20 37 2e 33 20 7b 0a  csql_test 7.3 {.
1f60: 20 20 41 4c 54 45 52 20 54 41 42 4c 45 20 78 79    ALTER TABLE xy
1f70: 7a 7a 79 20 52 45 4e 41 4d 45 20 63 20 54 4f 20  zzy RENAME c TO 
1f80: 63 63 63 3b 0a 20 20 53 45 4c 45 43 54 20 73 71  ccc;.  SELECT sq
1f90: 6c 20 46 52 4f 4d 20 73 71 6c 69 74 65 5f 6d 61  l FROM sqlite_ma
1fa0: 73 74 65 72 20 57 48 45 52 45 20 6e 61 6d 65 3d  ster WHERE name=
1fb0: 27 72 31 27 0a 7d 20 7b 0a 20 20 7b 43 52 45 41  'r1'.} {.  {CREA
1fc0: 54 45 20 54 52 49 47 47 45 52 20 72 31 20 41 46  TE TRIGGER r1 AF
1fd0: 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 22 78  TER INSERT ON "x
1fe0: 79 7a 7a 79 22 20 42 45 47 49 4e 0a 20 20 20 20  yzzy" BEGIN.    
1ff0: 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 32 0a 20  INSERT INTO t2. 
2000: 20 20 20 53 45 4c 45 43 54 20 61 2c 62 2c 63 63     SELECT a,b,cc
2010: 63 20 46 52 4f 4d 20 22 78 79 7a 7a 79 22 20 55  c FROM "xyzzy" U
2020: 4e 49 4f 4e 20 53 45 4c 45 43 54 20 64 2c 65 2c  NION SELECT d,e,
2030: 66 20 46 52 4f 4d 20 22 78 79 7a 7a 79 22 20 4f  f FROM "xyzzy" O
2040: 52 44 45 52 20 42 59 20 62 2c 63 63 63 3b 0a 20  RDER BY b,ccc;. 
2050: 20 45 4e 44 7d 0a 7d 0a 0a 23 2d 2d 2d 2d 2d 2d   END}.}..#------
2060: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2070: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2080: 2d 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 0a 72 65 73 65 74 5f 64 62 0a 64 6f 5f  ---.reset_db.do_
20b0: 65 78 65 63 73 71 6c 5f 74 65 73 74 20 38 2e 30  execsql_test 8.0
20c0: 20 7b 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c   {.  CREATE TABL
20d0: 45 20 74 31 28 61 2c 20 62 2c 20 63 29 3b 20 0a  E t1(a, b, c); .
20e0: 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74    CREATE TABLE t
20f0: 32 28 61 2c 20 62 2c 20 63 29 3b 20 0a 20 20 43  2(a, b, c); .  C
2100: 52 45 41 54 45 20 54 41 42 4c 45 20 74 33 28 64  REATE TABLE t3(d
2110: 2c 20 65 2c 20 66 29 3b 0a 20 20 43 52 45 41 54  , e, f);.  CREAT
2120: 45 20 56 49 45 57 20 76 31 20 41 53 20 53 45 4c  E VIEW v1 AS SEL
2130: 45 43 54 20 2a 20 46 52 4f 4d 20 74 31 3b 0a 20  ECT * FROM t1;. 
2140: 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
2150: 74 72 20 41 46 54 45 52 20 49 4e 53 45 52 54 20  tr AFTER INSERT 
2160: 4f 4e 20 74 33 20 42 45 47 49 4e 0a 20 20 20 20  ON t3 BEGIN.    
2170: 55 50 44 41 54 45 20 74 32 20 53 45 54 20 61 20  UPDATE t2 SET a 
2180: 3d 20 6e 65 77 2e 64 3b 0a 20 20 20 20 53 45 4c  = new.d;.    SEL
2190: 45 43 54 20 61 2c 20 62 2c 20 63 20 46 52 4f 4d  ECT a, b, c FROM
21a0: 20 76 31 3b 0a 20 20 45 4e 44 3b 0a 7d 0a 0a 64   v1;.  END;.}..d
21b0: 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 38  o_execsql_test 8
21c0: 2e 31 20 7b 0a 20 20 49 4e 53 45 52 54 20 49 4e  .1 {.  INSERT IN
21d0: 54 4f 20 74 33 20 56 41 4c 55 45 53 28 31 2c 20  TO t3 VALUES(1, 
21e0: 32 2c 20 33 29 3b 0a 7d 0a 0a 23 20 54 68 65 20  2, 3);.}..# The 
21f0: 66 6f 6c 6c 6f 77 69 6e 67 20 41 4c 54 45 52 20  following ALTER 
2200: 54 41 42 4c 45 20 66 61 69 6c 73 20 61 73 20 69  TABLE fails as i
2210: 66 20 63 6f 6c 75 6d 6e 20 22 74 31 2e 61 22 20  f column "t1.a" 
2220: 69 73 20 72 65 6e 61 6d 65 64 20 74 68 65 20 22  is renamed the "
2230: 61 22 0a 23 20 69 6e 20 74 68 65 20 22 53 45 4c  a".# in the "SEL
2240: 45 43 54 20 61 2c 20 62 2c 20 63 20 46 52 4f 4d  ECT a, b, c FROM
2250: 20 76 31 22 20 77 69 74 68 69 6e 20 74 68 65 20   v1" within the 
2260: 74 72 69 67 67 65 72 20 63 61 6e 20 6e 6f 20 6c  trigger can no l
2270: 6f 6e 67 65 72 20 62 65 0a 23 20 72 65 73 6f 6c  onger be.# resol
2280: 76 65 64 2e 20 42 75 74 20 61 74 20 6f 6e 65 20  ved. But at one 
2290: 70 6f 69 6e 74 20 74 68 65 72 65 20 77 61 73 20  point there was 
22a0: 61 20 62 75 67 20 61 6c 6c 6f 77 69 6e 67 20 74  a bug allowing t
22b0: 68 65 20 41 4c 54 45 52 20 54 41 42 4c 45 0a 23  he ALTER TABLE.#
22c0: 20 73 75 63 63 65 65 64 2e 20 57 68 69 63 68 20   succeed. Which 
22d0: 6d 65 61 6e 74 20 74 68 65 20 73 75 62 73 65 71  meant the subseq
22e0: 75 65 6e 74 20 49 4e 53 45 52 54 20 73 74 61 74  uent INSERT stat
22f0: 65 6d 65 6e 74 20 77 6f 75 6c 64 20 66 61 69 6c  ement would fail
2300: 2e 0a 64 6f 5f 63 61 74 63 68 73 71 6c 5f 74 65  ..do_catchsql_te
2310: 73 74 20 38 2e 32 20 7b 0a 20 20 41 4c 54 45 52  st 8.2 {.  ALTER
2320: 20 54 41 42 4c 45 20 74 31 20 52 45 4e 41 4d 45   TABLE t1 RENAME
2330: 20 61 20 54 4f 20 61 61 61 3b 0a 7d 20 7b 31 20   a TO aaa;.} {1 
2340: 7b 65 72 72 6f 72 20 69 6e 20 74 72 69 67 67 65  {error in trigge
2350: 72 20 74 72 20 61 66 74 65 72 20 72 65 6e 61 6d  r tr after renam
2360: 65 3a 20 6e 6f 20 73 75 63 68 20 63 6f 6c 75 6d  e: no such colum
2370: 6e 3a 20 61 7d 7d 0a 64 6f 5f 65 78 65 63 73 71  n: a}}.do_execsq
2380: 6c 5f 74 65 73 74 20 38 2e 33 20 7b 0a 20 20 49  l_test 8.3 {.  I
2390: 4e 53 45 52 54 20 49 4e 54 4f 20 74 33 20 56 41  NSERT INTO t3 VA
23a0: 4c 55 45 53 28 34 2c 20 35 2c 20 36 29 3b 0a 7d  LUES(4, 5, 6);.}
23b0: 0a 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73  ..do_execsql_tes
23c0: 74 20 38 2e 31 20 7b 0a 20 20 43 52 45 41 54 45  t 8.1 {.  CREATE
23d0: 20 54 41 42 4c 45 20 74 34 28 61 2c 20 62 29 3b   TABLE t4(a, b);
23e0: 0a 20 20 43 52 45 41 54 45 20 56 49 45 57 20 76  .  CREATE VIEW v
23f0: 34 20 41 53 20 53 45 4c 45 43 54 20 2a 20 46 52  4 AS SELECT * FR
2400: 4f 4d 20 74 34 20 57 48 45 52 45 20 28 61 3d 31  OM t4 WHERE (a=1
2410: 20 41 4e 44 20 30 29 20 4f 52 20 62 3d 32 3b 0a   AND 0) OR b=2;.
2420: 7d 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73  }.do_execsql_tes
2430: 74 20 38 2e 32 20 7b 0a 20 20 41 4c 54 45 52 20  t 8.2 {.  ALTER 
2440: 54 41 42 4c 45 20 74 34 20 52 45 4e 41 4d 45 20  TABLE t4 RENAME 
2450: 61 20 54 4f 20 63 3b 0a 20 20 53 45 4c 45 43 54  a TO c;.  SELECT
2460: 20 73 71 6c 20 46 52 4f 4d 20 73 71 6c 69 74 65   sql FROM sqlite
2470: 5f 6d 61 73 74 65 72 20 57 48 45 52 45 20 6e 61  _master WHERE na
2480: 6d 65 20 3d 20 27 76 34 27 0a 7d 20 7b 7b 43 52  me = 'v4'.} {{CR
2490: 45 41 54 45 20 56 49 45 57 20 76 34 20 41 53 20  EATE VIEW v4 AS 
24a0: 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 74 34  SELECT * FROM t4
24b0: 20 57 48 45 52 45 20 28 63 3d 31 20 41 4e 44 20   WHERE (c=1 AND 
24c0: 30 29 20 4f 52 20 62 3d 32 7d 7d 0a 0a 66 69 6e  0) OR b=2}}..fin
24d0: 69 73 68 5f 74 65 73 74 0a 0a 0a                 ish_test...