/ Hex Artifact Content
Login

Artifact b15a5784e47199d68fa1182157ba7e790f467d9f:


0000: 23 20 32 30 30 37 20 4d 61 79 20 38 0a 23 0a 23  # 2007 May 8.#.#
0010: 20 54 68 65 20 61 75 74 68 6f 72 20 64 69 73 63   The author disc
0020: 6c 61 69 6d 73 20 63 6f 70 79 72 69 67 68 74 20  laims copyright 
0030: 74 6f 20 74 68 69 73 20 73 6f 75 72 63 65 20 63  to this source c
0040: 6f 64 65 2e 20 20 49 6e 20 70 6c 61 63 65 20 6f  ode.  In place o
0050: 66 0a 23 20 61 20 6c 65 67 61 6c 20 6e 6f 74 69  f.# a legal noti
0060: 63 65 2c 20 68 65 72 65 20 69 73 20 61 20 62 6c  ce, here is a bl
0070: 65 73 73 69 6e 67 3a 0a 23 0a 23 20 20 20 20 4d  essing:.#.#    M
0080: 61 79 20 79 6f 75 20 64 6f 20 67 6f 6f 64 20 61  ay you do good a
0090: 6e 64 20 6e 6f 74 20 65 76 69 6c 2e 0a 23 20 20  nd not evil..#  
00a0: 20 20 4d 61 79 20 79 6f 75 20 66 69 6e 64 20 66    May you find f
00b0: 6f 72 67 69 76 65 6e 65 73 73 20 66 6f 72 20 79  orgiveness for y
00c0: 6f 75 72 73 65 6c 66 20 61 6e 64 20 66 6f 72 67  ourself and forg
00d0: 69 76 65 20 6f 74 68 65 72 73 2e 0a 23 20 20 20  ive others..#   
00e0: 20 4d 61 79 20 79 6f 75 20 73 68 61 72 65 20 66   May you share f
00f0: 72 65 65 6c 79 2c 20 6e 65 76 65 72 20 74 61 6b  reely, never tak
0100: 69 6e 67 20 6d 6f 72 65 20 74 68 61 6e 20 79 6f  ing more than yo
0110: 75 20 67 69 76 65 2e 0a 23 0a 23 2a 2a 2a 2a 2a  u give..#.#*****
0120: 2a 2a 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 0a 23 0a 23 20 54 68 69 73 20 66 69 6c 65  **.#.# This file
0170: 20 63 6f 6e 74 61 69 6e 73 20 74 65 73 74 73 20   contains tests 
0180: 74 6f 20 76 65 72 69 66 79 20 74 68 61 74 20 74  to verify that t
0190: 68 65 20 6c 69 6d 69 74 73 20 64 65 66 69 6e 65  he limits define
01a0: 64 20 69 6e 0a 23 20 73 71 6c 69 74 65 20 73 6f  d in.# sqlite so
01b0: 75 72 63 65 20 66 69 6c 65 20 6c 69 6d 69 74 73  urce file limits
01c0: 2e 68 20 61 72 65 20 65 6e 66 6f 72 63 65 64 2e  .h are enforced.
01d0: 0a 23 0a 23 20 24 49 64 3a 20 73 71 6c 6c 69 6d  .#.# $Id: sqllim
01e0: 69 74 73 31 2e 74 65 73 74 2c 76 20 31 2e 38 20  its1.test,v 1.8 
01f0: 32 30 30 37 2f 30 35 2f 31 30 20 31 31 3a 34 33  2007/05/10 11:43
0200: 3a 35 33 20 64 61 6e 69 65 6c 6b 31 39 37 37 20  :53 danielk1977 
0210: 45 78 70 20 24 0a 0a 73 65 74 20 74 65 73 74 64  Exp $..set testd
0220: 69 72 20 5b 66 69 6c 65 20 64 69 72 6e 61 6d 65  ir [file dirname
0230: 20 24 61 72 67 76 30 5d 0a 73 6f 75 72 63 65 20   $argv0].source 
0240: 24 74 65 73 74 64 69 72 2f 74 65 73 74 65 72 2e  $testdir/tester.
0250: 74 63 6c 0a 0a 23 20 54 65 73 74 20 6f 72 67 61  tcl..# Test orga
0260: 6e 69 7a 61 74 69 6f 6e 3a 0a 23 0a 23 20 20 20  nization:.#.#   
0270: 20 20 73 71 6c 6c 69 6d 69 74 73 2d 31 2e 2a 3a    sqllimits-1.*:
0280: 20 20 53 51 4c 49 54 45 5f 4d 41 58 5f 4c 45 4e    SQLITE_MAX_LEN
0290: 47 54 48 0a 23 20 20 20 20 20 73 71 6c 6c 69 6d  GTH.#     sqllim
02a0: 69 74 73 2d 32 2e 2a 3a 20 20 53 51 4c 49 54 45  its-2.*:  SQLITE
02b0: 5f 4d 41 58 5f 53 51 4c 5f 4c 45 4e 47 54 48 0a  _MAX_SQL_LENGTH.
02c0: 23 20 20 20 20 20 73 71 6c 6c 69 6d 69 74 73 2d  #     sqllimits-
02d0: 33 2e 2a 3a 20 20 53 51 4c 49 54 45 5f 4d 41 58  3.*:  SQLITE_MAX
02e0: 5f 50 41 47 45 5f 43 4f 55 4e 54 0a 23 20 20 20  _PAGE_COUNT.#   
02f0: 20 20 73 71 6c 6c 69 6d 69 74 73 2d 34 2e 2a 3a    sqllimits-4.*:
0300: 20 20 53 51 4c 49 54 45 5f 4d 41 58 5f 43 4f 4c    SQLITE_MAX_COL
0310: 55 4d 4e 0a 23 0a 23 0a 23 20 20 20 20 20 73 71  UMN.#.#.#     sq
0320: 6c 6c 69 6d 69 74 73 2d 37 2e 2a 3a 20 20 20 53  llimits-7.*:   S
0330: 51 4c 49 54 45 5f 4d 41 58 5f 46 55 4e 43 54 49  QLITE_MAX_FUNCTI
0340: 4f 4e 5f 41 52 47 20 20 0a 23 20 20 20 20 20 73  ON_ARG  .#     s
0350: 71 6c 6c 69 6d 69 74 73 2d 38 2e 2a 3a 20 20 20  qllimits-8.*:   
0360: 53 51 4c 49 54 45 5f 4d 41 58 5f 41 54 54 41 43  SQLITE_MAX_ATTAC
0370: 48 45 44 0a 23 20 20 20 20 20 73 71 6c 6c 69 6d  HED.#     sqllim
0380: 69 74 73 2d 39 2e 2a 3a 20 20 20 53 51 4c 49 54  its-9.*:   SQLIT
0390: 45 5f 4d 41 58 5f 56 41 52 49 41 42 4c 45 5f 4e  E_MAX_VARIABLE_N
03a0: 55 4d 42 45 52 0a 23 20 20 20 20 20 73 71 6c 6c  UMBER.#     sqll
03b0: 69 6d 69 74 73 2d 31 30 2e 2a 3a 20 20 53 51 4c  imits-10.*:  SQL
03c0: 49 54 45 5f 4d 41 58 5f 50 41 47 45 5f 53 49 5a  ITE_MAX_PAGE_SIZ
03d0: 45 0a 23 20 20 20 20 20 73 71 6c 6c 69 6d 69 74  E.#     sqllimit
03e0: 73 2d 31 31 2e 2a 3a 20 20 53 51 4c 49 54 45 5f  s-11.*:  SQLITE_
03f0: 4d 41 58 5f 4c 49 4b 45 5f 50 41 54 54 45 52 4e  MAX_LIKE_PATTERN
0400: 5f 4c 45 4e 47 54 48 0a 23 0a 23 20 54 6f 64 6f  _LENGTH.#.# Todo
0410: 3a 0a 23 0a 23 20 20 20 20 20 73 71 6c 6c 69 6d  :.#.#     sqllim
0420: 69 74 73 2d 35 2e 2a 3a 20 20 20 53 51 4c 49 54  its-5.*:   SQLIT
0430: 45 5f 4d 41 58 5f 45 58 50 52 5f 44 45 50 54 48  E_MAX_EXPR_DEPTH
0440: 20 20 20 20 20 20 20 20 20 20 20 20 28 73 71 6c              (sql
0450: 69 74 65 20 74 6f 64 6f 29 0a 23 20 20 20 20 20  ite todo).#     
0460: 73 71 6c 6c 69 6d 69 74 73 2d 36 2e 2a 3a 20 20  sqllimits-6.*:  
0470: 20 53 51 4c 49 54 45 5f 4d 41 58 5f 56 44 42 45   SQLITE_MAX_VDBE
0480: 5f 4f 50 20 20 20 20 20 20 20 20 20 20 20 20 20  _OP             
0490: 20 20 28 73 71 6c 69 74 65 20 74 6f 64 6f 29 0a    (sqlite todo).
04a0: 23 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  #..#------------
04b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
04c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
04d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
04e0: 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20 54 65 73 74 20  --------.# Test 
04f0: 63 61 73 65 73 20 73 71 6c 6c 69 6d 69 74 73 2d  cases sqllimits-
0500: 31 2e 2a 20 74 65 73 74 20 74 68 61 74 20 74 68  1.* test that th
0510: 65 20 53 51 4c 49 54 45 5f 4d 41 58 5f 4c 45 4e  e SQLITE_MAX_LEN
0520: 47 54 48 20 6c 69 6d 69 74 0a 23 20 69 73 20 65  GTH limit.# is e
0530: 6e 66 6f 72 63 65 64 2e 0a 23 0a 64 6f 5f 74 65  nforced..#.do_te
0540: 73 74 20 73 71 6c 6c 69 6d 69 74 73 2d 31 2e 31  st sqllimits-1.1
0550: 20 7b 0a 20 20 63 61 74 63 68 73 71 6c 20 7b 20   {.  catchsql { 
0560: 53 45 4c 45 43 54 20 72 61 6e 64 6f 6d 62 6c 6f  SELECT randomblo
0570: 62 28 32 31 34 37 34 38 33 36 34 37 29 20 7d 0a  b(2147483647) }.
0580: 7d 20 7b 31 20 7b 73 74 72 69 6e 67 20 6f 72 20  } {1 {string or 
0590: 62 6c 6f 62 20 74 6f 6f 20 62 69 67 7d 7d 0a 0a  blob too big}}..
05a0: 23 20 4c 61 72 67 65 2c 20 62 75 74 20 61 6c 6c  # Large, but all
05b0: 6f 77 61 62 6c 65 2c 20 62 6c 6f 62 2d 73 69 7a  owable, blob-siz
05c0: 65 2e 0a 23 0a 73 65 74 20 3a 3a 4c 41 52 47 45  e..#.set ::LARGE
05d0: 53 49 5a 45 20 5b 65 78 70 72 20 24 53 51 4c 49  SIZE [expr $SQLI
05e0: 54 45 5f 4d 41 58 5f 4c 45 4e 47 54 48 20 2d 20  TE_MAX_LENGTH - 
05f0: 31 5d 20 0a 0a 64 6f 5f 74 65 73 74 20 73 71 6c  1] ..do_test sql
0600: 6c 69 6d 69 74 73 2d 31 2e 32 20 7b 0a 20 20 63  limits-1.2 {.  c
0610: 61 74 63 68 73 71 6c 20 7b 20 53 45 4c 45 43 54  atchsql { SELECT
0620: 20 4c 45 4e 47 54 48 28 72 61 6e 64 6f 6d 62 6c   LENGTH(randombl
0630: 6f 62 28 24 3a 3a 4c 41 52 47 45 53 49 5a 45 29  ob($::LARGESIZE)
0640: 29 20 7d 0a 7d 20 22 30 20 24 3a 3a 4c 41 52 47  ) }.} "0 $::LARG
0650: 45 53 49 5a 45 22 0a 0a 64 6f 5f 74 65 73 74 20  ESIZE"..do_test 
0660: 73 71 6c 6c 69 6d 69 74 73 2d 31 2e 33 20 7b 0a  sqllimits-1.3 {.
0670: 20 20 63 61 74 63 68 73 71 6c 20 7b 20 53 45 4c    catchsql { SEL
0680: 45 43 54 20 71 75 6f 74 65 28 72 61 6e 64 6f 6d  ECT quote(random
0690: 62 6c 6f 62 28 24 3a 3a 4c 41 52 47 45 53 49 5a  blob($::LARGESIZ
06a0: 45 29 29 20 7d 0a 7d 20 7b 31 20 7b 73 74 72 69  E)) }.} {1 {stri
06b0: 6e 67 20 6f 72 20 62 6c 6f 62 20 74 6f 6f 20 62  ng or blob too b
06c0: 69 67 7d 7d 0a 0a 64 6f 5f 74 65 73 74 20 73 71  ig}}..do_test sq
06d0: 6c 6c 69 6d 69 74 73 2d 31 2e 34 20 7b 0a 20 20  llimits-1.4 {.  
06e0: 73 65 74 20 3a 3a 73 74 72 20 5b 73 74 72 69 6e  set ::str [strin
06f0: 67 20 72 65 70 65 61 74 20 41 20 36 35 35 33 37  g repeat A 65537
0700: 5d 0a 20 20 73 65 74 20 3a 3a 72 65 70 20 5b 73  ].  set ::rep [s
0710: 74 72 69 6e 67 20 72 65 70 65 61 74 20 42 20 36  tring repeat B 6
0720: 35 35 33 37 5d 0a 20 20 63 61 74 63 68 73 71 6c  5537].  catchsql
0730: 20 7b 20 53 45 4c 45 43 54 20 72 65 70 6c 61 63   { SELECT replac
0740: 65 28 24 3a 3a 73 74 72 2c 20 27 41 27 2c 20 24  e($::str, 'A', $
0750: 3a 3a 72 65 70 29 20 7d 0a 7d 20 7b 31 20 7b 73  ::rep) }.} {1 {s
0760: 74 72 69 6e 67 20 6f 72 20 62 6c 6f 62 20 74 6f  tring or blob to
0770: 6f 20 62 69 67 7d 7d 0a 0a 23 2d 2d 2d 2d 2d 2d  o big}}..#------
0780: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0790: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
07a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
07b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23  --------------.#
07c0: 20 54 65 73 74 20 63 61 73 65 73 20 73 71 6c 6c   Test cases sqll
07d0: 69 6d 69 74 73 2d 32 2e 2a 20 74 65 73 74 20 74  imits-2.* test t
07e0: 68 61 74 20 74 68 65 20 53 51 4c 49 54 45 5f 4d  hat the SQLITE_M
07f0: 41 58 5f 53 51 4c 5f 4c 45 4e 47 54 48 20 6c 69  AX_SQL_LENGTH li
0800: 6d 69 74 0a 23 20 69 73 20 65 6e 66 6f 72 63 65  mit.# is enforce
0810: 64 2e 0a 23 0a 64 6f 5f 74 65 73 74 20 73 71 6c  d..#.do_test sql
0820: 6c 69 6d 69 74 73 2d 32 2e 31 20 7b 0a 20 20 73  limits-2.1 {.  s
0830: 65 74 20 20 20 20 73 71 6c 20 22 53 45 4c 45 43  et    sql "SELEC
0840: 54 20 31 20 57 48 45 52 45 20 31 3d 3d 31 22 0a  T 1 WHERE 1==1".
0850: 20 20 73 65 74 20 4e 20 5b 65 78 70 72 20 7b 24    set N [expr {$
0860: 3a 3a 53 51 4c 49 54 45 5f 4d 41 58 5f 53 51 4c  ::SQLITE_MAX_SQL
0870: 5f 4c 45 4e 47 54 48 20 2f 20 5b 73 74 72 69 6e  _LENGTH / [strin
0880: 67 20 6c 65 6e 67 74 68 20 22 20 41 4e 44 20 31  g length " AND 1
0890: 3d 3d 31 22 5d 7d 5d 0a 20 20 61 70 70 65 6e 64  ==1"]}].  append
08a0: 20 73 71 6c 20 5b 73 74 72 69 6e 67 20 72 65 70   sql [string rep
08b0: 65 61 74 20 22 20 41 4e 44 20 31 3d 3d 31 22 20  eat " AND 1==1" 
08c0: 24 4e 5d 0a 20 20 63 61 74 63 68 73 71 6c 20 24  $N].  catchsql $
08d0: 73 71 6c 0a 7d 20 7b 31 20 7b 53 74 72 69 6e 67  sql.} {1 {String
08e0: 20 6f 72 20 42 4c 4f 42 20 65 78 63 65 65 64 65   or BLOB exceede
08f0: 64 20 73 69 7a 65 20 6c 69 6d 69 74 7d 7d 0a 0a  d size limit}}..
0900: 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  #---------------
0910: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0920: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0930: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0940: 2d 2d 2d 2d 2d 0a 23 20 54 65 73 74 20 63 61 73  -----.# Test cas
0950: 65 73 20 73 71 6c 6c 69 6d 69 74 73 2d 33 2e 2a  es sqllimits-3.*
0960: 20 74 65 73 74 20 74 68 61 74 20 74 68 65 20 6c   test that the l
0970: 69 6d 69 74 20 73 65 74 20 75 73 69 6e 67 20 74  imit set using t
0980: 68 65 0a 23 20 6d 61 78 5f 70 61 67 65 5f 63 6f  he.# max_page_co
0990: 75 6e 74 20 70 72 61 67 6d 61 2e 0a 23 0a 64 6f  unt pragma..#.do
09a0: 5f 74 65 73 74 20 73 71 6c 6c 69 6d 69 74 73 2d  _test sqllimits-
09b0: 33 2e 31 20 7b 0a 20 20 65 78 65 63 73 71 6c 20  3.1 {.  execsql 
09c0: 7b 0a 20 20 20 20 50 52 41 47 4d 41 20 6d 61 78  {.    PRAGMA max
09d0: 5f 70 61 67 65 5f 63 6f 75 6e 74 20 3d 20 31 30  _page_count = 10
09e0: 30 30 3b 0a 20 20 7d 0a 7d 20 7b 31 30 30 30 7d  00;.  }.} {1000}
09f0: 0a 64 6f 5f 74 65 73 74 20 73 71 6c 6c 69 6d 69  .do_test sqllimi
0a00: 74 73 2d 33 2e 32 20 7b 0a 20 20 65 78 65 63 73  ts-3.2 {.  execs
0a10: 71 6c 20 7b 20 43 52 45 41 54 45 20 54 41 42 4c  ql { CREATE TABL
0a20: 45 20 74 72 69 67 20 28 61 20 49 4e 54 45 47 45  E trig (a INTEGE
0a30: 52 2c 20 62 20 49 4e 54 45 47 45 52 29 3b 20 7d  R, b INTEGER); }
0a40: 0a 0a 20 20 23 20 53 65 74 20 75 70 20 61 20 74  ..  # Set up a t
0a50: 72 65 65 20 6f 66 20 74 72 69 67 67 65 72 73 20  ree of triggers 
0a60: 74 6f 20 66 69 72 65 20 77 68 65 6e 20 61 20 72  to fire when a r
0a70: 6f 77 20 69 73 20 69 6e 73 65 72 74 65 64 0a 20  ow is inserted. 
0a80: 20 23 20 69 6e 74 6f 20 74 61 62 6c 65 20 22 74   # into table "t
0a90: 72 69 67 22 2e 0a 20 20 23 0a 20 20 23 20 49 4e  rig"..  #.  # IN
0aa0: 53 45 52 54 20 2d 3e 20 69 6e 73 65 72 74 5f 62  SERT -> insert_b
0ab0: 20 2d 3e 20 75 70 64 61 74 65 5f 62 20 2d 3e 20   -> update_b -> 
0ac0: 69 6e 73 65 72 74 5f 61 20 2d 3e 20 75 70 64 61  insert_a -> upda
0ad0: 74 65 5f 61 20 20 20 20 20 20 28 63 68 61 69 6e  te_a      (chain
0ae0: 20 31 29 0a 20 20 23 20 20 20 20 20 20 20 20 20   1).  #         
0af0: 20 20 20 20 20 20 20 20 20 20 20 2d 3e 20 75 70             -> up
0b00: 64 61 74 65 5f 61 20 2d 3e 20 69 6e 73 65 72 74  date_a -> insert
0b10: 5f 61 20 2d 3e 20 75 70 64 61 74 65 5f 62 20 20  _a -> update_b  
0b20: 20 20 20 20 28 63 68 61 69 6e 20 32 29 0a 20 20      (chain 2).  
0b30: 23 20 20 20 20 20 20 20 20 2d 3e 20 69 6e 73 65  #        -> inse
0b40: 72 74 5f 61 20 2d 3e 20 75 70 64 61 74 65 5f 62  rt_a -> update_b
0b50: 20 2d 3e 20 69 6e 73 65 72 74 5f 62 20 2d 3e 20   -> insert_b -> 
0b60: 75 70 64 61 74 65 5f 61 20 20 20 20 20 20 28 63  update_a      (c
0b70: 68 61 69 6e 20 33 29 0a 20 20 23 20 20 20 20 20  hain 3).  #     
0b80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d                 -
0b90: 3e 20 75 70 64 61 74 65 5f 61 20 2d 3e 20 69 6e  > update_a -> in
0ba0: 73 65 72 74 5f 62 20 2d 3e 20 75 70 64 61 74 65  sert_b -> update
0bb0: 5f 62 20 20 20 20 20 20 28 63 68 61 69 6e 20 34  _b      (chain 4
0bc0: 29 0a 20 20 23 0a 20 20 23 20 54 61 62 6c 65 20  ).  #.  # Table 
0bd0: 73 74 61 72 74 73 20 77 69 74 68 20 4e 20 72 6f  starts with N ro
0be0: 77 73 2e 0a 20 20 23 0a 20 20 23 20 20 20 43 68  ws..  #.  #   Ch
0bf0: 61 69 6e 20 31 3a 20 69 6e 73 65 72 74 5f 62 20  ain 1: insert_b 
0c00: 28 75 70 64 61 74 65 20 4e 20 72 6f 77 73 29 0a  (update N rows).
0c10: 20 20 23 20 20 20 20 20 20 20 20 20 20 20 20 20    #             
0c20: 20 2d 3e 20 75 70 64 61 74 65 5f 62 20 28 69 6e   -> update_b (in
0c30: 73 65 72 74 20 31 20 72 6f 77 73 29 0a 20 20 23  sert 1 rows).  #
0c40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0c50: 2d 3e 20 69 6e 73 65 72 74 5f 61 20 28 75 70 64  -> insert_a (upd
0c60: 61 74 65 20 4e 20 72 6f 77 73 29 0a 20 20 23 20  ate N rows).  # 
0c70: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0c80: 20 2d 3e 20 75 70 64 61 74 65 5f 61 20 28 69 6e   -> update_a (in
0c90: 73 65 72 74 20 31 20 72 6f 77 73 29 0a 20 20 23  sert 1 rows).  #
0ca0: 0a 20 20 23 20 63 68 61 69 6e 73 20 32 2c 20 33  .  # chains 2, 3
0cb0: 20 61 6e 64 20 34 20 61 72 65 20 73 69 6d 69 6c   and 4 are simil
0cc0: 61 72 2e 20 45 61 63 68 20 69 6e 73 65 72 74 73  ar. Each inserts
0cd0: 20 6d 6f 72 65 20 74 68 61 6e 20 4e 5e 32 20 72   more than N^2 r
0ce0: 6f 77 73 2c 20 77 68 65 72 65 0a 20 20 23 20 4e  ows, where.  # N
0cf0: 20 69 73 20 74 68 65 20 6e 75 6d 62 65 72 20 6f   is the number o
0d00: 66 20 72 6f 77 73 20 61 74 20 74 68 65 20 63 6f  f rows at the co
0d10: 6e 63 6c 75 73 69 6f 6e 20 6f 66 20 74 68 65 20  nclusion of the 
0d20: 70 72 65 76 69 6f 75 73 20 63 68 61 69 6e 2e 0a  previous chain..
0d30: 20 20 23 0a 20 20 23 20 54 68 65 72 65 66 6f 72    #.  # Therefor
0d40: 65 2c 20 61 20 73 69 6e 67 6c 65 20 69 6e 73 65  e, a single inse
0d50: 72 74 20 61 64 64 73 20 28 4e 5e 31 36 20 70 6c  rt adds (N^16 pl
0d60: 75 73 20 73 6f 6d 65 29 20 72 6f 77 73 20 74 6f  us some) rows to
0d70: 20 74 68 65 20 64 61 74 61 62 61 73 65 2e 0a 20   the database.. 
0d80: 20 23 20 41 20 72 65 61 6c 6c 79 20 6c 6f 6e 67   # A really long
0d90: 20 6c 6f 6f 70 2e 2e 2e 0a 20 20 23 20 20 20 20   loop....  #    
0da0: 20 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20   .  execsql {.  
0db0: 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
0dc0: 20 75 70 64 61 74 65 5f 62 20 42 45 46 4f 52 45   update_b BEFORE
0dd0: 20 55 50 44 41 54 45 20 4f 4e 20 74 72 69 67 0a   UPDATE ON trig.
0de0: 20 20 20 20 20 20 46 4f 52 20 45 41 43 48 20 52        FOR EACH R
0df0: 4f 57 20 42 45 47 49 4e 0a 20 20 20 20 20 20 20  OW BEGIN.       
0e00: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 72 69   INSERT INTO tri
0e10: 67 20 56 41 4c 55 45 53 20 28 36 35 2c 20 27 75  g VALUES (65, 'u
0e20: 70 64 61 74 65 5f 62 27 29 3b 0a 20 20 20 20 20  pdate_b');.     
0e30: 20 45 4e 44 3b 0a 0a 20 20 20 20 43 52 45 41 54   END;..    CREAT
0e40: 45 20 54 52 49 47 47 45 52 20 75 70 64 61 74 65  E TRIGGER update
0e50: 5f 61 20 41 46 54 45 52 20 55 50 44 41 54 45 20  _a AFTER UPDATE 
0e60: 4f 4e 20 74 72 69 67 0a 20 20 20 20 20 20 46 4f  ON trig.      FO
0e70: 52 20 45 41 43 48 20 52 4f 57 20 42 45 47 49 4e  R EACH ROW BEGIN
0e80: 0a 20 20 20 20 20 20 20 20 49 4e 53 45 52 54 20  .        INSERT 
0e90: 49 4e 54 4f 20 74 72 69 67 20 56 41 4c 55 45 53  INTO trig VALUES
0ea0: 20 28 36 35 2c 20 27 75 70 64 61 74 65 5f 61 27   (65, 'update_a'
0eb0: 29 3b 0a 20 20 20 20 20 20 45 4e 44 3b 0a 0a 20  );.      END;.. 
0ec0: 20 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45     CREATE TRIGGE
0ed0: 52 20 69 6e 73 65 72 74 5f 62 20 42 45 46 4f 52  R insert_b BEFOR
0ee0: 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 72 69 67  E INSERT ON trig
0ef0: 0a 20 20 20 20 20 20 46 4f 52 20 45 41 43 48 20  .      FOR EACH 
0f00: 52 4f 57 20 42 45 47 49 4e 0a 20 20 20 20 20 20  ROW BEGIN.      
0f10: 20 20 55 50 44 41 54 45 20 74 72 69 67 20 53 45    UPDATE trig SE
0f20: 54 20 61 20 3d 20 31 3b 0a 20 20 20 20 20 20 45  T a = 1;.      E
0f30: 4e 44 3b 0a 0a 20 20 20 20 43 52 45 41 54 45 20  ND;..    CREATE 
0f40: 54 52 49 47 47 45 52 20 69 6e 73 65 72 74 5f 61  TRIGGER insert_a
0f50: 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e   AFTER INSERT ON
0f60: 20 74 72 69 67 0a 20 20 20 20 20 20 46 4f 52 20   trig.      FOR 
0f70: 45 41 43 48 20 52 4f 57 20 42 45 47 49 4e 0a 20  EACH ROW BEGIN. 
0f80: 20 20 20 20 20 20 20 55 50 44 41 54 45 20 74 72         UPDATE tr
0f90: 69 67 20 53 45 54 20 61 20 3d 20 31 3b 0a 20 20  ig SET a = 1;.  
0fa0: 20 20 20 20 45 4e 44 3b 0a 20 20 7d 0a 7d 20 7b      END;.  }.} {
0fb0: 7d 0a 0a 64 6f 5f 74 65 73 74 20 73 71 6c 6c 69  }..do_test sqlli
0fc0: 6d 69 74 73 31 2d 33 2e 33 20 7b 0a 20 20 65 78  mits1-3.3 {.  ex
0fd0: 65 63 73 71 6c 20 7b 0a 20 20 20 20 49 4e 53 45  ecsql {.    INSE
0fe0: 52 54 20 49 4e 54 4f 20 74 72 69 67 20 56 41 4c  RT INTO trig VAL
0ff0: 55 45 53 20 28 31 2c 31 29 3b 20 0a 20 20 7d 0a  UES (1,1); .  }.
1000: 7d 20 7b 7d 0a 0a 64 6f 5f 74 65 73 74 20 73 71  } {}..do_test sq
1010: 6c 6c 69 6d 69 74 73 31 2d 33 2e 34 20 7b 0a 20  llimits1-3.4 {. 
1020: 20 65 78 65 63 73 71 6c 20 7b 0a 20 20 20 20 53   execsql {.    S
1030: 45 4c 45 43 54 20 43 4f 55 4e 54 28 2a 29 20 46  ELECT COUNT(*) F
1040: 52 4f 4d 20 74 72 69 67 3b 0a 20 20 7d 0a 7d 20  ROM trig;.  }.} 
1050: 7b 37 7d 0a 0a 23 20 54 68 69 73 20 74 72 69 65  {7}..# This trie
1060: 73 20 74 6f 20 69 6e 73 65 72 74 20 73 6f 20 6d  s to insert so m
1070: 61 6e 79 20 72 6f 77 73 20 69 74 20 66 69 6c 6c  any rows it fill
1080: 73 20 75 70 20 74 68 65 20 64 61 74 61 62 61 73  s up the databas
1090: 65 20 28 6c 69 6d 69 74 65 64 0a 23 20 74 6f 20  e (limited.# to 
10a0: 31 4d 42 2c 20 73 6f 20 6e 6f 74 20 74 68 61 74  1MB, so not that
10b0: 20 6e 6f 74 65 77 6f 72 74 68 79 20 61 6e 20 61   noteworthy an a
10c0: 63 68 69 65 76 65 6d 65 6e 74 29 2e 0a 23 0a 64  chievement)..#.d
10d0: 6f 5f 74 65 73 74 20 73 71 6c 6c 69 6d 69 74 73  o_test sqllimits
10e0: 31 2d 33 2e 35 20 7b 0a 20 20 63 61 74 63 68 73  1-3.5 {.  catchs
10f0: 71 6c 20 7b 0a 20 20 20 20 49 4e 53 45 52 54 20  ql {.    INSERT 
1100: 49 4e 54 4f 20 74 72 69 67 20 56 41 4c 55 45 53  INTO trig VALUES
1110: 20 28 31 2c 31 30 29 3b 0a 20 20 7d 0a 7d 20 7b   (1,10);.  }.} {
1120: 31 20 7b 64 61 74 61 62 61 73 65 20 6f 72 20 64  1 {database or d
1130: 69 73 6b 20 69 73 20 66 75 6c 6c 7d 7d 0a 0a 64  isk is full}}..d
1140: 6f 5f 74 65 73 74 20 73 71 6c 6c 69 6d 69 74 73  o_test sqllimits
1150: 31 2d 33 2e 36 20 7b 0a 20 20 63 61 74 63 68 73  1-3.6 {.  catchs
1160: 71 6c 20 7b 0a 20 20 20 20 53 45 4c 45 43 54 20  ql {.    SELECT 
1170: 43 4f 55 4e 54 28 2a 29 20 46 52 4f 4d 20 74 72  COUNT(*) FROM tr
1180: 69 67 3b 0a 20 20 7d 0a 7d 20 7b 30 20 37 7d 0a  ig;.  }.} {0 7}.
1190: 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  .#--------------
11a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
11b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
11c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
11d0: 2d 2d 2d 2d 2d 2d 0a 23 20 54 65 73 74 20 63 61  ------.# Test ca
11e0: 73 65 73 20 73 71 6c 6c 69 6d 69 74 73 31 2d 34  ses sqllimits1-4
11f0: 2e 2a 20 74 65 73 74 20 74 68 65 20 53 51 4c 49  .* test the SQLI
1200: 54 45 5f 4d 41 58 5f 43 4f 4c 55 4d 4e 20 6c 69  TE_MAX_COLUMN li
1210: 6d 69 74 2e 0a 23 0a 64 6f 5f 74 65 73 74 20 73  mit..#.do_test s
1220: 71 6c 6c 69 6d 69 74 73 2d 31 2e 34 2e 31 20 7b  qllimits-1.4.1 {
1230: 0a 20 20 23 20 43 6f 6c 75 6d 6e 73 20 69 6e 20  .  # Columns in 
1240: 61 20 74 61 62 6c 65 2e 0a 20 20 73 65 74 20 63  a table..  set c
1250: 6f 6c 73 20 5b 6c 69 73 74 5d 0a 20 20 66 6f 72  ols [list].  for
1260: 20 7b 73 65 74 20 69 20 30 7d 20 7b 24 69 20 3c   {set i 0} {$i <
1270: 3d 20 24 53 51 4c 49 54 45 5f 4d 41 58 5f 43 4f  = $SQLITE_MAX_CO
1280: 4c 55 4d 4e 7d 20 7b 69 6e 63 72 20 69 7d 20 7b  LUMN} {incr i} {
1290: 0a 20 20 20 20 6c 61 70 70 65 6e 64 20 63 6f 6c  .    lappend col
12a0: 73 20 22 63 24 69 22 0a 20 20 7d 0a 20 20 63 61  s "c$i".  }.  ca
12b0: 74 63 68 73 71 6c 20 22 43 52 45 41 54 45 20 54  tchsql "CREATE T
12c0: 41 42 4c 45 20 74 28 5b 6a 6f 69 6e 20 24 63 6f  ABLE t([join $co
12d0: 6c 73 20 2c 5d 29 22 20 0a 7d 20 7b 31 20 7b 74  ls ,])" .} {1 {t
12e0: 6f 6f 20 6d 61 6e 79 20 63 6f 6c 75 6d 6e 73 20  oo many columns 
12f0: 6f 6e 20 74 7d 7d 0a 0a 64 6f 5f 74 65 73 74 20  on t}}..do_test 
1300: 73 71 6c 6c 69 6d 69 74 73 2d 31 2e 34 2e 32 20  sqllimits-1.4.2 
1310: 7b 0a 20 20 23 20 43 6f 6c 75 6d 6e 73 20 69 6e  {.  # Columns in
1320: 20 74 68 65 20 72 65 73 75 6c 74 2d 73 65 74 20   the result-set 
1330: 6f 66 20 61 20 53 45 4c 45 43 54 2e 0a 20 20 73  of a SELECT..  s
1340: 65 74 20 63 6f 6c 73 20 5b 6c 69 73 74 5d 0a 20  et cols [list]. 
1350: 20 66 6f 72 20 7b 73 65 74 20 69 20 30 7d 20 7b   for {set i 0} {
1360: 24 69 20 3c 3d 20 24 53 51 4c 49 54 45 5f 4d 41  $i <= $SQLITE_MA
1370: 58 5f 43 4f 4c 55 4d 4e 7d 20 7b 69 6e 63 72 20  X_COLUMN} {incr 
1380: 69 7d 20 7b 0a 20 20 20 20 6c 61 70 70 65 6e 64  i} {.    lappend
1390: 20 63 6f 6c 73 20 22 73 71 6c 20 41 53 20 73 71   cols "sql AS sq
13a0: 6c 24 69 22 0a 20 20 7d 0a 20 20 63 61 74 63 68  l$i".  }.  catch
13b0: 73 71 6c 20 22 53 45 4c 45 43 54 20 5b 6a 6f 69  sql "SELECT [joi
13c0: 6e 20 24 63 6f 6c 73 20 2c 5d 20 46 52 4f 4d 20  n $cols ,] FROM 
13d0: 73 71 6c 69 74 65 5f 6d 61 73 74 65 72 22 0a 7d  sqlite_master".}
13e0: 20 7b 31 20 7b 74 6f 6f 20 6d 61 6e 79 20 63 6f   {1 {too many co
13f0: 6c 75 6d 6e 73 20 69 6e 20 72 65 73 75 6c 74 20  lumns in result 
1400: 73 65 74 7d 7d 0a 0a 64 6f 5f 74 65 73 74 20 73  set}}..do_test s
1410: 71 6c 6c 69 6d 69 74 73 2d 31 2e 34 2e 33 20 7b  qllimits-1.4.3 {
1420: 0a 20 20 23 20 43 6f 6c 75 6d 6e 73 20 69 6e 20  .  # Columns in 
1430: 74 68 65 20 72 65 73 75 6c 74 2d 73 65 74 20 6f  the result-set o
1440: 66 20 61 20 73 75 62 2d 53 45 4c 45 43 54 2e 0a  f a sub-SELECT..
1450: 20 20 73 65 74 20 63 6f 6c 73 20 5b 6c 69 73 74    set cols [list
1460: 5d 0a 20 20 66 6f 72 20 7b 73 65 74 20 69 20 30  ].  for {set i 0
1470: 7d 20 7b 24 69 20 3c 3d 20 24 53 51 4c 49 54 45  } {$i <= $SQLITE
1480: 5f 4d 41 58 5f 43 4f 4c 55 4d 4e 7d 20 7b 69 6e  _MAX_COLUMN} {in
1490: 63 72 20 69 7d 20 7b 0a 20 20 20 20 6c 61 70 70  cr i} {.    lapp
14a0: 65 6e 64 20 63 6f 6c 73 20 22 73 71 6c 20 41 53  end cols "sql AS
14b0: 20 73 71 6c 24 69 22 0a 20 20 7d 0a 20 20 63 61   sql$i".  }.  ca
14c0: 74 63 68 73 71 6c 20 22 53 45 4c 45 43 54 20 73  tchsql "SELECT s
14d0: 71 6c 34 20 46 52 4f 4d 20 28 53 45 4c 45 43 54  ql4 FROM (SELECT
14e0: 20 5b 6a 6f 69 6e 20 24 63 6f 6c 73 20 2c 5d 20   [join $cols ,] 
14f0: 46 52 4f 4d 20 73 71 6c 69 74 65 5f 6d 61 73 74  FROM sqlite_mast
1500: 65 72 29 22 0a 7d 20 7b 31 20 7b 74 6f 6f 20 6d  er)".} {1 {too m
1510: 61 6e 79 20 63 6f 6c 75 6d 6e 73 20 69 6e 20 72  any columns in r
1520: 65 73 75 6c 74 20 73 65 74 7d 7d 0a 0a 64 6f 5f  esult set}}..do_
1530: 74 65 73 74 20 73 71 6c 6c 69 6d 69 74 73 2d 31  test sqllimits-1
1540: 2e 34 2e 34 20 7b 0a 20 20 23 20 43 6f 6c 75 6d  .4.4 {.  # Colum
1550: 6e 73 20 69 6e 20 61 6e 20 69 6e 64 65 78 2e 0a  ns in an index..
1560: 20 20 73 65 74 20 63 6f 6c 73 20 5b 6c 69 73 74    set cols [list
1570: 5d 0a 20 20 66 6f 72 20 7b 73 65 74 20 69 20 30  ].  for {set i 0
1580: 7d 20 7b 24 69 20 3c 3d 20 24 53 51 4c 49 54 45  } {$i <= $SQLITE
1590: 5f 4d 41 58 5f 43 4f 4c 55 4d 4e 7d 20 7b 69 6e  _MAX_COLUMN} {in
15a0: 63 72 20 69 7d 20 7b 0a 20 20 20 20 6c 61 70 70  cr i} {.    lapp
15b0: 65 6e 64 20 63 6f 6c 73 20 63 0a 20 20 7d 0a 20  end cols c.  }. 
15c0: 20 73 65 74 20 73 71 6c 31 20 22 43 52 45 41 54   set sql1 "CREAT
15d0: 45 20 54 41 42 4c 45 20 74 31 28 63 29 3b 22 0a  E TABLE t1(c);".
15e0: 20 20 73 65 74 20 73 71 6c 32 20 22 43 52 45 41    set sql2 "CREA
15f0: 54 45 20 49 4e 44 45 58 20 69 31 20 4f 4e 20 74  TE INDEX i1 ON t
1600: 31 28 5b 6a 6f 69 6e 20 24 63 6f 6c 73 20 2c 5d  1([join $cols ,]
1610: 29 3b 22 0a 20 20 63 61 74 63 68 73 71 6c 20 22  );".  catchsql "
1620: 24 73 71 6c 31 20 3b 20 24 73 71 6c 32 22 0a 7d  $sql1 ; $sql2".}
1630: 20 7b 31 20 7b 74 6f 6f 20 6d 61 6e 79 20 63 6f   {1 {too many co
1640: 6c 75 6d 6e 73 20 69 6e 20 69 6e 64 65 78 7d 7d  lumns in index}}
1650: 0a 0a 64 6f 5f 74 65 73 74 20 73 71 6c 6c 69 6d  ..do_test sqllim
1660: 69 74 73 2d 31 2e 34 2e 35 20 7b 0a 20 20 23 20  its-1.4.5 {.  # 
1670: 43 6f 6c 75 6d 6e 73 20 69 6e 20 61 20 47 52 4f  Columns in a GRO
1680: 55 50 20 42 59 20 63 6c 61 75 73 65 2e 0a 20 20  UP BY clause..  
1690: 63 61 74 63 68 73 71 6c 20 22 53 45 4c 45 43 54  catchsql "SELECT
16a0: 20 2a 20 46 52 4f 4d 20 74 31 20 47 52 4f 55 50   * FROM t1 GROUP
16b0: 20 42 59 20 5b 6a 6f 69 6e 20 24 63 6f 6c 73 20   BY [join $cols 
16c0: 2c 5d 22 0a 7d 20 7b 31 20 7b 74 6f 6f 20 6d 61  ,]".} {1 {too ma
16d0: 6e 79 20 74 65 72 6d 73 20 69 6e 20 47 52 4f 55  ny terms in GROU
16e0: 50 20 42 59 20 63 6c 61 75 73 65 7d 7d 0a 0a 64  P BY clause}}..d
16f0: 6f 5f 74 65 73 74 20 73 71 6c 6c 69 6d 69 74 73  o_test sqllimits
1700: 2d 31 2e 34 2e 36 20 7b 0a 20 20 23 20 43 6f 6c  -1.4.6 {.  # Col
1710: 75 6d 6e 73 20 69 6e 20 61 6e 20 4f 52 44 45 52  umns in an ORDER
1720: 20 42 59 20 63 6c 61 75 73 65 2e 0a 20 20 63 61   BY clause..  ca
1730: 74 63 68 73 71 6c 20 22 53 45 4c 45 43 54 20 2a  tchsql "SELECT *
1740: 20 46 52 4f 4d 20 74 31 20 4f 52 44 45 52 20 42   FROM t1 ORDER B
1750: 59 20 5b 6a 6f 69 6e 20 24 63 6f 6c 73 20 2c 5d  Y [join $cols ,]
1760: 22 0a 7d 20 7b 31 20 7b 74 6f 6f 20 6d 61 6e 79  ".} {1 {too many
1770: 20 74 65 72 6d 73 20 69 6e 20 4f 52 44 45 52 20   terms in ORDER 
1780: 42 59 20 63 6c 61 75 73 65 7d 7d 0a 0a 64 6f 5f  BY clause}}..do_
1790: 74 65 73 74 20 73 71 6c 6c 69 6d 69 74 73 2d 31  test sqllimits-1
17a0: 2e 34 2e 37 20 7b 0a 20 20 23 20 41 73 73 69 67  .4.7 {.  # Assig
17b0: 6e 6d 65 6e 74 73 20 69 6e 20 61 6e 20 55 50 44  nments in an UPD
17c0: 41 54 45 20 73 74 61 74 65 6d 65 6e 74 2e 0a 20  ATE statement.. 
17d0: 20 73 65 74 20 63 6f 6c 73 20 5b 6c 69 73 74 5d   set cols [list]
17e0: 0a 20 20 66 6f 72 20 7b 73 65 74 20 69 20 30 7d  .  for {set i 0}
17f0: 20 7b 24 69 20 3c 3d 20 24 53 51 4c 49 54 45 5f   {$i <= $SQLITE_
1800: 4d 41 58 5f 43 4f 4c 55 4d 4e 7d 20 7b 69 6e 63  MAX_COLUMN} {inc
1810: 72 20 69 7d 20 7b 0a 20 20 20 20 6c 61 70 70 65  r i} {.    lappe
1820: 6e 64 20 63 6f 6c 73 20 22 63 20 3d 20 31 22 0a  nd cols "c = 1".
1830: 20 20 7d 0a 20 20 63 61 74 63 68 73 71 6c 20 22    }.  catchsql "
1840: 55 50 44 41 54 45 20 74 31 20 53 45 54 20 5b 6a  UPDATE t1 SET [j
1850: 6f 69 6e 20 24 63 6f 6c 73 20 2c 5d 3b 22 0a 7d  oin $cols ,];".}
1860: 20 7b 31 20 7b 74 6f 6f 20 6d 61 6e 79 20 63 6f   {1 {too many co
1870: 6c 75 6d 6e 73 20 69 6e 20 73 65 74 20 6c 69 73  lumns in set lis
1880: 74 7d 7d 0a 0a 64 6f 5f 74 65 73 74 20 73 71 6c  t}}..do_test sql
1890: 6c 69 6d 69 74 73 2d 31 2e 34 2e 38 20 7b 0a 20  limits-1.4.8 {. 
18a0: 20 23 20 43 6f 6c 75 6d 6e 73 20 69 6e 20 61 20   # Columns in a 
18b0: 76 69 65 77 20 64 65 66 69 6e 69 74 69 6f 6e 3a  view definition:
18c0: 0a 20 20 73 65 74 20 63 6f 6c 73 20 5b 6c 69 73  .  set cols [lis
18d0: 74 5d 0a 20 20 66 6f 72 20 7b 73 65 74 20 69 20  t].  for {set i 
18e0: 30 7d 20 7b 24 69 20 3c 3d 20 24 53 51 4c 49 54  0} {$i <= $SQLIT
18f0: 45 5f 4d 41 58 5f 43 4f 4c 55 4d 4e 7d 20 7b 69  E_MAX_COLUMN} {i
1900: 6e 63 72 20 69 7d 20 7b 0a 20 20 20 20 6c 61 70  ncr i} {.    lap
1910: 70 65 6e 64 20 63 6f 6c 73 20 22 63 24 69 22 0a  pend cols "c$i".
1920: 20 20 7d 0a 20 20 63 61 74 63 68 73 71 6c 20 22    }.  catchsql "
1930: 43 52 45 41 54 45 20 56 49 45 57 20 76 31 20 41  CREATE VIEW v1 A
1940: 53 20 53 45 4c 45 43 54 20 5b 6a 6f 69 6e 20 24  S SELECT [join $
1950: 63 6f 6c 73 20 2c 5d 20 46 52 4f 4d 20 74 31 3b  cols ,] FROM t1;
1960: 22 0a 7d 20 7b 31 20 7b 74 6f 6f 20 6d 61 6e 79  ".} {1 {too many
1970: 20 63 6f 6c 75 6d 6e 73 20 69 6e 20 72 65 73 75   columns in resu
1980: 6c 74 20 73 65 74 7d 7d 0a 0a 64 6f 5f 74 65 73  lt set}}..do_tes
1990: 74 20 73 71 6c 6c 69 6d 69 74 73 2d 31 2e 34 2e  t sqllimits-1.4.
19a0: 39 20 7b 0a 20 20 23 20 43 6f 6c 75 6d 6e 73 20  9 {.  # Columns 
19b0: 69 6e 20 61 20 76 69 65 77 20 64 65 66 69 6e 69  in a view defini
19c0: 74 69 6f 6e 20 28 74 65 73 74 69 6e 67 20 2a 20  tion (testing * 
19d0: 65 78 70 61 6e 73 69 6f 6e 29 3a 0a 20 20 73 65  expansion):.  se
19e0: 74 20 63 6f 6c 73 20 5b 6c 69 73 74 5d 0a 20 20  t cols [list].  
19f0: 66 6f 72 20 7b 73 65 74 20 69 20 30 7d 20 7b 24  for {set i 0} {$
1a00: 69 20 3c 20 24 53 51 4c 49 54 45 5f 4d 41 58 5f  i < $SQLITE_MAX_
1a10: 43 4f 4c 55 4d 4e 7d 20 7b 69 6e 63 72 20 69 7d  COLUMN} {incr i}
1a20: 20 7b 0a 20 20 20 20 6c 61 70 70 65 6e 64 20 63   {.    lappend c
1a30: 6f 6c 73 20 22 63 24 69 22 0a 20 20 7d 0a 20 20  ols "c$i".  }.  
1a40: 63 61 74 63 68 73 71 6c 20 22 43 52 45 41 54 45  catchsql "CREATE
1a50: 20 54 41 42 4c 45 20 74 32 28 5b 6a 6f 69 6e 20   TABLE t2([join 
1a60: 24 63 6f 6c 73 20 2c 5d 29 22 0a 20 20 63 61 74  $cols ,])".  cat
1a70: 63 68 73 71 6c 20 22 43 52 45 41 54 45 20 56 49  chsql "CREATE VI
1a80: 45 57 20 76 31 20 41 53 20 53 45 4c 45 43 54 20  EW v1 AS SELECT 
1a90: 2a 2c 20 63 31 20 41 53 20 6f 20 46 52 4f 4d 20  *, c1 AS o FROM 
1aa0: 74 32 3b 22 0a 7d 20 7b 31 20 7b 74 6f 6f 20 6d  t2;".} {1 {too m
1ab0: 61 6e 79 20 63 6f 6c 75 6d 6e 73 20 69 6e 20 72  any columns in r
1ac0: 65 73 75 6c 74 20 73 65 74 7d 7d 0a 0a 23 2d 2d  esult set}}..#--
1ad0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1ae0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1af0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1b00: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1b10: 2d 2d 0a 23 20 54 68 65 73 65 20 74 65 73 74 73  --.# These tests
1b20: 20 2d 20 73 71 6c 6c 69 6d 69 74 73 2d 35 2e 2a   - sqllimits-5.*
1b30: 20 2d 20 74 65 73 74 20 74 68 61 74 20 74 68 65   - test that the
1b40: 20 53 51 4c 49 54 45 5f 4d 41 58 5f 45 58 50 52   SQLITE_MAX_EXPR
1b50: 5f 44 45 50 54 48 0a 23 20 6c 69 6d 69 74 20 69  _DEPTH.# limit i
1b60: 73 20 65 6e 66 6f 72 63 65 64 2e 20 54 68 65 20  s enforced. The 
1b70: 6c 69 6d 69 74 20 72 65 66 65 72 73 20 74 6f 20  limit refers to 
1b80: 74 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 74 65  the number of te
1b90: 72 6d 73 20 69 6e 20 0a 23 20 74 68 65 20 65 78  rms in .# the ex
1ba0: 70 72 65 73 73 69 6f 6e 2e 0a 23 0a 69 66 20 7b  pression..#.if {
1bb0: 24 3a 3a 53 51 4c 49 54 45 5f 4d 41 58 5f 45 58  $::SQLITE_MAX_EX
1bc0: 50 52 5f 44 45 50 54 48 20 21 3d 20 31 30 30 30  PR_DEPTH != 1000
1bd0: 7d 20 7b 0a 20 20 70 75 74 73 20 2d 6e 6f 6e 65  } {.  puts -none
1be0: 77 6c 69 6e 65 20 73 74 64 65 72 72 20 22 57 41  wline stderr "WA
1bf0: 52 4e 49 4e 47 3a 20 43 6f 6d 70 69 6c 65 20 77  RNING: Compile w
1c00: 69 74 68 20 2d 44 53 51 4c 49 54 45 5f 4d 41 58  ith -DSQLITE_MAX
1c10: 5f 45 58 50 52 5f 44 45 50 54 48 20 74 6f 20 72  _EXPR_DEPTH to r
1c20: 75 6e 20 22 0a 20 20 70 75 74 73 20 73 74 64 65  un ".  puts stde
1c30: 72 72 20 22 74 65 73 74 73 20 73 71 6c 6c 69 6d  rr "tests sqllim
1c40: 69 74 73 2d 31 2e 35 2e 58 22 0a 7d 20 65 6c 73  its-1.5.X".} els
1c50: 65 20 7b 0a 20 20 64 6f 5f 74 65 73 74 20 73 71  e {.  do_test sq
1c60: 6c 6c 69 6d 69 74 73 2d 31 2e 35 2e 31 20 7b 0a  llimits-1.5.1 {.
1c70: 20 20 20 20 73 65 74 20 6d 61 78 20 24 3a 3a 53      set max $::S
1c80: 51 4c 49 54 45 5f 4d 41 58 5f 45 58 50 52 5f 44  QLITE_MAX_EXPR_D
1c90: 45 50 54 48 0a 20 20 20 20 73 65 74 20 65 78 70  EPTH.    set exp
1ca0: 72 20 22 28 31 20 5b 73 74 72 69 6e 67 20 72 65  r "(1 [string re
1cb0: 70 65 61 74 20 7b 41 4e 44 20 31 20 7d 20 24 6d  peat {AND 1 } $m
1cc0: 61 78 5d 29 22 0a 20 20 20 20 63 61 74 63 68 73  ax])".    catchs
1cd0: 71 6c 20 5b 73 75 62 73 74 20 7b 0a 20 20 20 20  ql [subst {.    
1ce0: 20 20 53 45 4c 45 43 54 20 24 65 78 70 72 0a 20    SELECT $expr. 
1cf0: 20 20 20 7d 5d 0a 20 20 7d 20 22 31 20 7b 45 78     }].  } "1 {Ex
1d00: 70 72 65 73 73 69 6f 6e 20 74 72 65 65 20 69 73  pression tree is
1d10: 20 74 6f 6f 20 6c 61 72 67 65 20 28 6d 61 78 69   too large (maxi
1d20: 6d 75 6d 20 64 65 70 74 68 20 24 3a 3a 53 51 4c  mum depth $::SQL
1d30: 49 54 45 5f 4d 41 58 5f 45 58 50 52 5f 44 45 50  ITE_MAX_EXPR_DEP
1d40: 54 48 29 7d 22 0a 20 20 0a 20 20 23 20 41 74 74  TH)}".  .  # Att
1d50: 65 6d 70 74 69 6e 67 20 74 6f 20 62 65 61 74 20  empting to beat 
1d60: 74 68 65 20 65 78 70 72 65 73 73 69 6f 6e 20 64  the expression d
1d70: 65 70 74 68 20 6c 69 6d 69 74 20 75 73 69 6e 67  epth limit using
1d80: 20 6e 65 73 74 65 64 20 53 45 4c 45 43 54 0a 20   nested SELECT. 
1d90: 20 23 20 71 75 65 72 69 65 73 20 63 61 75 73 65   # queries cause
1da0: 73 20 61 20 70 61 72 73 65 72 20 73 74 61 63 6b  s a parser stack
1db0: 20 6f 76 65 72 66 6c 6f 77 2e 20 0a 20 20 64 6f   overflow. .  do
1dc0: 5f 74 65 73 74 20 73 71 6c 6c 69 6d 69 74 73 2d  _test sqllimits-
1dd0: 31 2e 35 2e 32 20 7b 0a 20 20 20 20 73 65 74 20  1.5.2 {.    set 
1de0: 6d 61 78 20 24 3a 3a 53 51 4c 49 54 45 5f 4d 41  max $::SQLITE_MA
1df0: 58 5f 45 58 50 52 5f 44 45 50 54 48 0a 20 20 20  X_EXPR_DEPTH.   
1e00: 20 73 65 74 20 65 78 70 72 20 22 53 45 4c 45 43   set expr "SELEC
1e10: 54 20 31 22 0a 20 20 20 20 66 6f 72 20 7b 73 65  T 1".    for {se
1e20: 74 20 69 20 30 7d 20 7b 24 69 20 3c 3d 20 24 6d  t i 0} {$i <= $m
1e30: 61 78 7d 20 7b 69 6e 63 72 20 69 7d 20 7b 0a 20  ax} {incr i} {. 
1e40: 20 20 20 20 20 73 65 74 20 65 78 70 72 20 22 53       set expr "S
1e50: 45 4c 45 43 54 20 28 24 65 78 70 72 29 22 0a 20  ELECT ($expr)". 
1e60: 20 20 20 7d 0a 20 20 20 20 63 61 74 63 68 73 71     }.    catchsq
1e70: 6c 20 5b 73 75 62 73 74 20 7b 0a 20 20 20 20 20  l [subst {.     
1e80: 20 53 45 4c 45 43 54 20 24 65 78 70 72 0a 20 20   SELECT $expr.  
1e90: 20 20 7d 5d 0a 20 20 7d 20 22 31 20 7b 70 61 72    }].  } "1 {par
1ea0: 73 65 72 20 73 74 61 63 6b 20 6f 76 65 72 66 6c  ser stack overfl
1eb0: 6f 77 7d 22 0a 20 20 0a 20 20 0a 20 20 64 6f 5f  ow}".  .  .  do_
1ec0: 74 65 73 74 20 73 71 6c 6c 69 6d 69 74 73 2d 31  test sqllimits-1
1ed0: 2e 35 2e 33 20 7b 0a 20 20 20 20 65 78 65 63 73  .5.3 {.    execs
1ee0: 71 6c 20 7b 0a 20 20 20 20 20 20 50 52 41 47 4d  ql {.      PRAGM
1ef0: 41 20 6d 61 78 5f 70 61 67 65 5f 63 6f 75 6e 74  A max_page_count
1f00: 20 3d 20 31 30 30 30 30 30 30 3b 20 20 2d 2d 20   = 1000000;  -- 
1f10: 31 20 47 42 0a 20 20 20 20 20 20 43 52 45 41 54  1 GB.      CREAT
1f20: 45 20 54 41 42 4c 45 20 76 30 28 61 29 3b 0a 20  E TABLE v0(a);. 
1f30: 20 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f       INSERT INTO
1f40: 20 76 30 20 56 41 4c 55 45 53 28 31 29 3b 0a 20   v0 VALUES(1);. 
1f50: 20 20 20 7d 0a 20 20 20 20 64 62 20 74 72 61 6e     }.    db tran
1f60: 73 61 63 74 69 6f 6e 20 7b 0a 20 20 20 20 20 20  saction {.      
1f70: 66 6f 72 20 7b 73 65 74 20 69 20 31 7d 20 7b 24  for {set i 1} {$
1f80: 69 20 3c 20 32 30 30 7d 20 7b 69 6e 63 72 20 69  i < 200} {incr i
1f90: 7d 20 7b 0a 20 20 20 20 20 20 20 20 73 65 74 20  } {.        set 
1fa0: 65 78 70 72 20 22 28 61 20 5b 73 74 72 69 6e 67  expr "(a [string
1fb0: 20 72 65 70 65 61 74 20 7b 41 4e 44 20 31 20 7d   repeat {AND 1 }
1fc0: 20 35 30 5d 29 20 41 53 20 61 22 0a 20 20 20 20   50]) AS a".    
1fd0: 20 20 20 20 65 78 65 63 73 71 6c 20 5b 73 75 62      execsql [sub
1fe0: 73 74 20 7b 0a 20 20 20 20 20 20 20 20 20 20 43  st {.          C
1ff0: 52 45 41 54 45 20 56 49 45 57 20 76 24 7b 69 7d  REATE VIEW v${i}
2000: 20 41 53 20 53 45 4c 45 43 54 20 24 65 78 70 72   AS SELECT $expr
2010: 20 46 52 4f 4d 20 76 5b 65 78 70 72 20 7b 24 69   FROM v[expr {$i
2020: 2d 31 7d 5d 0a 20 20 20 20 20 20 20 20 7d 5d 0a  -1}].        }].
2030: 20 20 20 20 20 20 7d 0a 20 20 20 20 7d 0a 20 20        }.    }.  
2040: 7d 20 7b 7d 0a 20 20 0a 20 20 64 6f 5f 74 65 73  } {}.  .  do_tes
2050: 74 20 73 71 6c 6c 69 6d 69 74 73 2d 31 2e 35 2e  t sqllimits-1.5.
2060: 34 20 7b 0a 20 20 20 20 63 61 74 63 68 73 71 6c  4 {.    catchsql
2070: 20 7b 0a 20 20 20 20 20 20 53 45 4c 45 43 54 20   {.      SELECT 
2080: 61 20 46 52 4f 4d 20 76 31 39 39 0a 20 20 20 20  a FROM v199.    
2090: 7d 0a 20 20 7d 20 22 31 20 7b 45 78 70 72 65 73  }.  } "1 {Expres
20a0: 73 69 6f 6e 20 74 72 65 65 20 69 73 20 74 6f 6f  sion tree is too
20b0: 20 6c 61 72 67 65 20 28 6d 61 78 69 6d 75 6d 20   large (maximum 
20c0: 64 65 70 74 68 20 24 3a 3a 53 51 4c 49 54 45 5f  depth $::SQLITE_
20d0: 4d 41 58 5f 45 58 50 52 5f 44 45 50 54 48 29 7d  MAX_EXPR_DEPTH)}
20e0: 22 0a 7d 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ".}..#----------
20f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2100: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2110: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2120: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20 54 65 73  ----------.# Tes
2130: 74 20 63 61 73 65 73 20 73 71 6c 6c 69 6d 69 74  t cases sqllimit
2140: 73 2d 36 2e 2a 20 74 65 73 74 20 74 68 61 74 20  s-6.* test that 
2150: 74 68 65 20 53 51 4c 49 54 45 5f 4d 41 58 5f 56  the SQLITE_MAX_V
2160: 44 42 45 5f 4f 50 0a 23 20 6c 69 6d 69 74 20 77  DBE_OP.# limit w
2170: 6f 72 6b 73 20 61 73 20 65 78 70 65 63 74 65 64  orks as expected
2180: 2e 20 54 68 65 20 6c 69 6d 69 74 20 72 65 66 65  . The limit refe
2190: 72 73 20 74 6f 20 74 68 65 20 6e 75 6d 62 65 72  rs to the number
21a0: 20 6f 66 20 6f 70 63 6f 64 65 73 0a 23 20 69 6e   of opcodes.# in
21b0: 20 61 20 73 69 6e 67 6c 65 20 56 44 42 45 20 70   a single VDBE p
21c0: 72 6f 67 72 61 6d 2e 0a 23 0a 23 20 54 4f 44 4f  rogram..#.# TODO
21d0: 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ..#-------------
21e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
21f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2200: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2210: 2d 2d 2d 2d 2d 2d 2d 0a 23 20 54 65 73 74 20 74  -------.# Test t
2220: 68 65 20 53 51 4c 49 54 45 5f 4d 41 58 5f 46 55  he SQLITE_MAX_FU
2230: 4e 43 54 49 4f 4e 5f 41 52 47 20 6c 69 6d 69 74  NCTION_ARG limit
2240: 20 77 6f 72 6b 73 2e 20 54 65 73 74 20 63 61 73   works. Test cas
2250: 65 20 6e 61 6d 65 73 0a 23 20 6d 61 74 63 68 20  e names.# match 
2260: 74 68 65 20 70 61 74 74 65 72 6e 20 22 73 71 6c  the pattern "sql
2270: 6c 69 6d 69 74 73 2d 37 2e 2a 22 2e 0a 23 0a 64  limits-7.*"..#.d
2280: 6f 5f 74 65 73 74 20 73 71 6c 6c 69 6d 69 74 73  o_test sqllimits
2290: 2d 31 2e 37 2e 31 20 7b 0a 20 20 73 65 74 20 6d  -1.7.1 {.  set m
22a0: 61 78 20 24 3a 3a 53 51 4c 49 54 45 5f 4d 41 58  ax $::SQLITE_MAX
22b0: 5f 46 55 4e 43 54 49 4f 4e 5f 41 52 47 0a 20 20  _FUNCTION_ARG.  
22c0: 73 65 74 20 76 61 6c 73 20 5b 6c 69 73 74 5d 0a  set vals [list].
22d0: 20 20 66 6f 72 20 7b 73 65 74 20 69 20 30 7d 20    for {set i 0} 
22e0: 7b 24 69 20 3c 20 24 53 51 4c 49 54 45 5f 4d 41  {$i < $SQLITE_MA
22f0: 58 5f 46 55 4e 43 54 49 4f 4e 5f 41 52 47 7d 20  X_FUNCTION_ARG} 
2300: 7b 69 6e 63 72 20 69 7d 20 7b 0a 20 20 20 20 6c  {incr i} {.    l
2310: 61 70 70 65 6e 64 20 76 61 6c 73 20 24 69 0a 20  append vals $i. 
2320: 20 7d 0a 20 20 63 61 74 63 68 73 71 6c 20 22 53   }.  catchsql "S
2330: 45 4c 45 43 54 20 6d 61 78 28 5b 6a 6f 69 6e 20  ELECT max([join 
2340: 24 76 61 6c 73 20 2c 5d 29 22 0a 7d 20 22 30 20  $vals ,])".} "0 
2350: 5b 65 78 70 72 20 7b 24 3a 3a 53 51 4c 49 54 45  [expr {$::SQLITE
2360: 5f 4d 41 58 5f 46 55 4e 43 54 49 4f 4e 5f 41 52  _MAX_FUNCTION_AR
2370: 47 20 2d 20 31 7d 5d 22 0a 64 6f 5f 74 65 73 74  G - 1}]".do_test
2380: 20 73 71 6c 6c 69 6d 69 74 73 2d 31 2e 37 2e 32   sqllimits-1.7.2
2390: 20 7b 0a 20 20 73 65 74 20 6d 61 78 20 24 3a 3a   {.  set max $::
23a0: 53 51 4c 49 54 45 5f 4d 41 58 5f 46 55 4e 43 54  SQLITE_MAX_FUNCT
23b0: 49 4f 4e 5f 41 52 47 0a 20 20 73 65 74 20 76 61  ION_ARG.  set va
23c0: 6c 73 20 5b 6c 69 73 74 5d 0a 20 20 66 6f 72 20  ls [list].  for 
23d0: 7b 73 65 74 20 69 20 30 7d 20 7b 24 69 20 3c 3d  {set i 0} {$i <=
23e0: 20 24 53 51 4c 49 54 45 5f 4d 41 58 5f 46 55 4e   $SQLITE_MAX_FUN
23f0: 43 54 49 4f 4e 5f 41 52 47 7d 20 7b 69 6e 63 72  CTION_ARG} {incr
2400: 20 69 7d 20 7b 0a 20 20 20 20 6c 61 70 70 65 6e   i} {.    lappen
2410: 64 20 76 61 6c 73 20 24 69 0a 20 20 7d 0a 20 20  d vals $i.  }.  
2420: 63 61 74 63 68 73 71 6c 20 22 53 45 4c 45 43 54  catchsql "SELECT
2430: 20 6d 61 78 28 5b 6a 6f 69 6e 20 24 76 61 6c 73   max([join $vals
2440: 20 2c 5d 29 22 0a 7d 20 7b 31 20 7b 74 6f 6f 20   ,])".} {1 {too 
2450: 6d 61 6e 79 20 61 72 67 75 6d 65 6e 74 73 20 6f  many arguments o
2460: 6e 20 66 75 6e 63 74 69 6f 6e 20 6d 61 78 7d 7d  n function max}}
2470: 0a 0a 23 20 54 65 73 74 20 74 68 61 74 20 69 74  ..# Test that it
2480: 20 69 73 20 53 51 4c 69 74 65 2c 20 61 6e 64 20   is SQLite, and 
2490: 6e 6f 74 20 74 68 65 20 69 6d 70 6c 65 6d 65 6e  not the implemen
24a0: 74 61 74 69 6f 6e 20 6f 66 20 74 68 65 0a 23 20  tation of the.# 
24b0: 75 73 65 72 20 66 75 6e 63 74 69 6f 6e 20 74 68  user function th
24c0: 61 74 20 69 73 20 74 68 72 6f 77 69 6e 67 20 74  at is throwing t
24d0: 68 65 20 65 72 72 6f 72 2e 0a 70 72 6f 63 20 6d  he error..proc m
24e0: 79 66 75 6e 63 20 7b 61 72 67 73 7d 20 7b 65 72  yfunc {args} {er
24f0: 72 6f 72 20 22 49 20 64 6f 6e 27 74 20 6c 69 6b  ror "I don't lik
2500: 65 20 74 6f 20 62 65 20 63 61 6c 6c 65 64 21 22  e to be called!"
2510: 7d 0a 64 6f 5f 74 65 73 74 20 73 71 6c 6c 69 6d  }.do_test sqllim
2520: 69 74 73 2d 31 2e 37 2e 32 20 7b 0a 20 20 64 62  its-1.7.2 {.  db
2530: 20 66 75 6e 63 74 69 6f 6e 20 6d 79 66 75 6e 63   function myfunc
2540: 20 6d 79 66 75 6e 63 0a 20 20 73 65 74 20 6d 61   myfunc.  set ma
2550: 78 20 24 3a 3a 53 51 4c 49 54 45 5f 4d 41 58 5f  x $::SQLITE_MAX_
2560: 46 55 4e 43 54 49 4f 4e 5f 41 52 47 0a 20 20 73  FUNCTION_ARG.  s
2570: 65 74 20 76 61 6c 73 20 5b 6c 69 73 74 5d 0a 20  et vals [list]. 
2580: 20 66 6f 72 20 7b 73 65 74 20 69 20 30 7d 20 7b   for {set i 0} {
2590: 24 69 20 3c 3d 20 24 53 51 4c 49 54 45 5f 4d 41  $i <= $SQLITE_MA
25a0: 58 5f 46 55 4e 43 54 49 4f 4e 5f 41 52 47 7d 20  X_FUNCTION_ARG} 
25b0: 7b 69 6e 63 72 20 69 7d 20 7b 0a 20 20 20 20 6c  {incr i} {.    l
25c0: 61 70 70 65 6e 64 20 76 61 6c 73 20 24 69 0a 20  append vals $i. 
25d0: 20 7d 0a 20 20 63 61 74 63 68 73 71 6c 20 22 53   }.  catchsql "S
25e0: 45 4c 45 43 54 20 6d 79 66 75 6e 63 28 5b 6a 6f  ELECT myfunc([jo
25f0: 69 6e 20 24 76 61 6c 73 20 2c 5d 29 22 0a 7d 20  in $vals ,])".} 
2600: 7b 31 20 7b 74 6f 6f 20 6d 61 6e 79 20 61 72 67  {1 {too many arg
2610: 75 6d 65 6e 74 73 20 6f 6e 20 66 75 6e 63 74 69  uments on functi
2620: 6f 6e 20 6d 79 66 75 6e 63 7d 7d 0a 0a 23 2d 2d  on myfunc}}..#--
2630: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2640: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2650: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2660: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2670: 2d 2d 0a 23 20 54 65 73 74 20 63 61 73 65 73 20  --.# Test cases 
2680: 73 71 6c 6c 69 6d 69 74 73 2d 38 2e 2a 3a 20 54  sqllimits-8.*: T
2690: 65 73 74 20 74 68 65 20 53 51 4c 49 54 45 5f 4d  est the SQLITE_M
26a0: 41 58 5f 41 54 54 41 43 48 45 44 20 6c 69 6d 69  AX_ATTACHED limi
26b0: 74 2e 0a 23 0a 23 20 54 4f 44 4f 0a 64 6f 5f 74  t..#.# TODO.do_t
26c0: 65 73 74 20 73 71 6c 6c 69 6d 69 74 73 2d 31 2e  est sqllimits-1.
26d0: 38 2e 31 20 7b 0a 20 20 73 65 74 20 6d 61 78 20  8.1 {.  set max 
26e0: 24 3a 3a 53 51 4c 49 54 45 5f 4d 41 58 5f 41 54  $::SQLITE_MAX_AT
26f0: 54 41 43 48 45 44 0a 20 20 66 6f 72 20 7b 73 65  TACHED.  for {se
2700: 74 20 69 20 30 7d 20 7b 24 69 20 3c 20 28 24 6d  t i 0} {$i < ($m
2710: 61 78 29 7d 20 7b 69 6e 63 72 20 69 7d 20 7b 0a  ax)} {incr i} {.
2720: 20 20 20 20 65 78 65 63 73 71 6c 20 22 41 54 54      execsql "ATT
2730: 41 43 48 20 27 74 65 73 74 24 7b 69 7d 2e 64 62  ACH 'test${i}.db
2740: 27 20 41 53 20 61 75 78 24 7b 69 7d 22 0a 20 20  ' AS aux${i}".  
2750: 7d 0a 20 20 63 61 74 63 68 73 71 6c 20 22 41 54  }.  catchsql "AT
2760: 54 41 43 48 20 27 74 65 73 74 24 7b 69 7d 2e 64  TACH 'test${i}.d
2770: 62 27 20 41 53 20 61 75 78 24 7b 69 7d 22 0a 7d  b' AS aux${i}".}
2780: 20 22 31 20 7b 74 6f 6f 20 6d 61 6e 79 20 61 74   "1 {too many at
2790: 74 61 63 68 65 64 20 64 61 74 61 62 61 73 65 73  tached databases
27a0: 20 2d 20 6d 61 78 20 24 3a 3a 53 51 4c 49 54 45   - max $::SQLITE
27b0: 5f 4d 41 58 5f 41 54 54 41 43 48 45 44 7d 22 0a  _MAX_ATTACHED}".
27c0: 64 6f 5f 74 65 73 74 20 73 71 6c 6c 69 6d 69 74  do_test sqllimit
27d0: 73 2d 31 2e 38 2e 32 20 7b 0a 20 20 73 65 74 20  s-1.8.2 {.  set 
27e0: 6d 61 78 20 24 3a 3a 53 51 4c 49 54 45 5f 4d 41  max $::SQLITE_MA
27f0: 58 5f 41 54 54 41 43 48 45 44 0a 20 20 66 6f 72  X_ATTACHED.  for
2800: 20 7b 73 65 74 20 69 20 30 7d 20 7b 24 69 20 3c   {set i 0} {$i <
2810: 20 28 24 6d 61 78 29 7d 20 7b 69 6e 63 72 20 69   ($max)} {incr i
2820: 7d 20 7b 0a 20 20 20 20 65 78 65 63 73 71 6c 20  } {.    execsql 
2830: 22 44 45 54 41 43 48 20 61 75 78 24 7b 69 7d 22  "DETACH aux${i}"
2840: 0a 20 20 7d 0a 7d 20 7b 7d 0a 0a 23 2d 2d 2d 2d  .  }.} {}..#----
2850: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2860: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2870: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2880: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2890: 0a 23 20 54 65 73 74 20 63 61 73 65 73 20 73 71  .# Test cases sq
28a0: 6c 6c 69 6d 69 74 73 2d 39 2e 2a 3a 20 43 68 65  llimits-9.*: Che
28b0: 63 6b 20 74 68 61 74 20 74 68 65 20 53 51 4c 49  ck that the SQLI
28c0: 54 45 5f 4d 41 58 5f 56 41 52 49 41 42 4c 45 5f  TE_MAX_VARIABLE_
28d0: 4e 55 4d 42 45 52 20 0a 23 20 6c 69 6d 69 74 20  NUMBER .# limit 
28e0: 77 6f 72 6b 73 2e 0a 23 0a 64 6f 5f 74 65 73 74  works..#.do_test
28f0: 20 73 71 6c 6c 69 6d 69 74 73 2d 31 2e 39 2e 31   sqllimits-1.9.1
2900: 20 7b 0a 20 20 73 65 74 20 6d 61 78 20 24 3a 3a   {.  set max $::
2910: 53 51 4c 49 54 45 5f 4d 41 58 5f 56 41 52 49 41  SQLITE_MAX_VARIA
2920: 42 4c 45 5f 4e 55 4d 42 45 52 0a 20 20 63 61 74  BLE_NUMBER.  cat
2930: 63 68 73 71 6c 20 22 53 45 4c 45 43 54 20 3f 5b  chsql "SELECT ?[
2940: 65 78 70 72 20 7b 24 6d 61 78 2b 31 7d 5d 20 46  expr {$max+1}] F
2950: 52 4f 4d 20 74 31 22 0a 7d 20 22 31 20 7b 76 61  ROM t1".} "1 {va
2960: 72 69 61 62 6c 65 20 6e 75 6d 62 65 72 20 6d 75  riable number mu
2970: 73 74 20 62 65 20 62 65 74 77 65 65 6e 20 3f 31  st be between ?1
2980: 20 61 6e 64 20 3f 24 3a 3a 53 51 4c 49 54 45 5f   and ?$::SQLITE_
2990: 4d 41 58 5f 56 41 52 49 41 42 4c 45 5f 4e 55 4d  MAX_VARIABLE_NUM
29a0: 42 45 52 7d 22 0a 64 6f 5f 74 65 73 74 20 73 71  BER}".do_test sq
29b0: 6c 6c 69 6d 69 74 73 2d 31 2e 39 2e 32 20 7b 0a  llimits-1.9.2 {.
29c0: 20 20 73 65 74 20 6d 61 78 20 24 3a 3a 53 51 4c    set max $::SQL
29d0: 49 54 45 5f 4d 41 58 5f 56 41 52 49 41 42 4c 45  ITE_MAX_VARIABLE
29e0: 5f 4e 55 4d 42 45 52 0a 20 20 73 65 74 20 76 61  _NUMBER.  set va
29f0: 6c 73 20 5b 6c 69 73 74 5d 0a 20 20 66 6f 72 20  ls [list].  for 
2a00: 7b 73 65 74 20 69 20 30 7d 20 7b 24 69 20 3c 20  {set i 0} {$i < 
2a10: 28 24 6d 61 78 2b 33 29 7d 20 7b 69 6e 63 72 20  ($max+3)} {incr 
2a20: 69 7d 20 7b 0a 20 20 20 20 6c 61 70 70 65 6e 64  i} {.    lappend
2a30: 20 76 61 6c 73 20 3f 0a 20 20 7d 0a 20 20 63 61   vals ?.  }.  ca
2a40: 74 63 68 73 71 6c 20 22 53 45 4c 45 43 54 20 5b  tchsql "SELECT [
2a50: 6a 6f 69 6e 20 24 76 61 6c 73 20 2c 5d 20 46 52  join $vals ,] FR
2a60: 4f 4d 20 74 31 22 0a 7d 20 22 31 20 7b 74 6f 6f  OM t1".} "1 {too
2a70: 20 6d 61 6e 79 20 53 51 4c 20 76 61 72 69 61 62   many SQL variab
2a80: 6c 65 73 7d 22 0a 0a 0a 23 2d 2d 2d 2d 2d 2d 2d  les}"...#-------
2a90: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2aa0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2ab0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2ac0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20  -------------.# 
2ad0: 73 71 6c 6c 69 6d 69 74 73 2d 31 30 2e 2a 3a 20  sqllimits-10.*: 
2ae0: 20 54 65 73 74 20 74 68 65 20 53 51 4c 49 54 45   Test the SQLITE
2af0: 5f 4d 41 58 5f 50 41 47 45 5f 53 49 5a 45 20 64  _MAX_PAGE_SIZE d
2b00: 65 66 69 6e 65 20 69 73 20 65 6e 66 6f 72 63 65  efine is enforce
2b10: 64 2e 20 0a 23 20 54 68 69 73 20 69 73 20 70 72  d. .# This is pr
2b20: 6f 62 61 62 6c 79 20 74 65 73 74 65 64 20 65 6c  obably tested el
2b30: 73 65 77 68 65 72 65 20 74 6f 6f 20 28 70 61 67  sewhere too (pag
2b40: 65 72 58 2e 74 65 73 74 29 2e 20 41 74 74 65 6d  erX.test). Attem
2b50: 70 74 73 0a 23 20 74 6f 20 72 61 69 73 65 20 74  pts.# to raise t
2b60: 68 65 20 70 61 67 65 20 73 69 7a 65 20 61 62 6f  he page size abo
2b70: 76 65 20 74 68 69 73 20 6c 69 6d 69 74 20 61 72  ve this limit ar
2b80: 65 20 73 69 6c 65 6e 74 6c 79 20 69 67 6e 6f 72  e silently ignor
2b90: 65 64 2e 0a 23 0a 64 6f 5f 74 65 73 74 20 73 71  ed..#.do_test sq
2ba0: 6c 6c 69 6d 69 74 73 2d 31 2e 31 30 2e 31 20 7b  llimits-1.10.1 {
2bb0: 0a 20 20 64 62 20 63 6c 6f 73 65 0a 20 20 66 69  .  db close.  fi
2bc0: 6c 65 20 64 65 6c 65 74 65 20 2d 66 6f 72 63 65  le delete -force
2bd0: 20 74 65 73 74 2e 64 62 20 74 65 73 74 2e 64 62   test.db test.db
2be0: 2d 6a 6f 75 72 6e 61 6c 0a 20 20 73 71 6c 69 74  -journal.  sqlit
2bf0: 65 33 20 64 62 20 74 65 73 74 2e 64 62 0a 20 20  e3 db test.db.  
2c00: 73 65 74 20 6d 61 78 20 24 3a 3a 53 51 4c 49 54  set max $::SQLIT
2c10: 45 5f 4d 41 58 5f 50 41 47 45 5f 53 49 5a 45 0a  E_MAX_PAGE_SIZE.
2c20: 20 20 63 61 74 63 68 73 71 6c 20 22 50 52 41 47    catchsql "PRAG
2c30: 4d 41 20 70 61 67 65 5f 73 69 7a 65 20 3d 20 5b  MA page_size = [
2c40: 65 78 70 72 20 7b 24 6d 61 78 2a 32 7d 5d 22 0a  expr {$max*2}]".
2c50: 7d 20 7b 30 20 7b 7d 7d 0a 64 6f 5f 74 65 73 74  } {0 {}}.do_test
2c60: 20 73 71 6c 6c 69 6d 69 74 73 2d 31 2e 31 30 2e   sqllimits-1.10.
2c70: 32 20 7b 0a 20 20 63 61 74 63 68 73 71 6c 20 22  2 {.  catchsql "
2c80: 50 52 41 47 4d 41 20 70 61 67 65 5f 73 69 7a 65  PRAGMA page_size
2c90: 22 0a 7d 20 7b 30 20 31 30 32 34 7d 0a 64 6f 5f  ".} {0 1024}.do_
2ca0: 74 65 73 74 20 73 71 6c 6c 69 6d 69 74 73 2d 31  test sqllimits-1
2cb0: 2e 31 30 2e 33 20 7b 0a 20 20 73 65 74 20 6d 61  .10.3 {.  set ma
2cc0: 78 20 24 3a 3a 53 51 4c 49 54 45 5f 4d 41 58 5f  x $::SQLITE_MAX_
2cd0: 50 41 47 45 5f 53 49 5a 45 0a 20 20 63 61 74 63  PAGE_SIZE.  catc
2ce0: 68 73 71 6c 20 22 50 52 41 47 4d 41 20 70 61 67  hsql "PRAGMA pag
2cf0: 65 5f 73 69 7a 65 20 3d 20 24 6d 61 78 22 0a 7d  e_size = $max".}
2d00: 20 7b 30 20 7b 7d 7d 0a 64 6f 5f 74 65 73 74 20   {0 {}}.do_test 
2d10: 73 71 6c 6c 69 6d 69 74 73 2d 31 2e 31 30 2e 34  sqllimits-1.10.4
2d20: 20 7b 0a 20 20 65 78 65 63 73 71 6c 20 22 70 72   {.  execsql "pr
2d30: 61 67 6d 61 20 70 61 67 65 5f 73 69 7a 65 22 0a  agma page_size".
2d40: 7d 20 24 3a 3a 53 51 4c 49 54 45 5f 4d 41 58 5f  } $::SQLITE_MAX_
2d50: 50 41 47 45 5f 53 49 5a 45 0a 64 6f 5f 74 65 73  PAGE_SIZE.do_tes
2d60: 74 20 73 71 6c 6c 69 6d 69 74 73 2d 31 2e 31 30  t sqllimits-1.10
2d70: 2e 35 20 7b 0a 20 20 73 65 74 20 6d 61 78 20 24  .5 {.  set max $
2d80: 3a 3a 53 51 4c 49 54 45 5f 4d 41 58 5f 50 41 47  ::SQLITE_MAX_PAG
2d90: 45 5f 53 49 5a 45 0a 20 20 65 78 65 63 73 71 6c  E_SIZE.  execsql
2da0: 20 22 70 72 61 67 6d 61 20 70 61 67 65 5f 73 69   "pragma page_si
2db0: 7a 65 20 3d 20 5b 65 78 70 72 20 7b 24 6d 61 78  ze = [expr {$max
2dc0: 20 2d 20 35 7d 5d 22 0a 20 20 65 78 65 63 73 71   - 5}]".  execsq
2dd0: 6c 20 22 70 72 61 67 6d 61 20 70 61 67 65 5f 73  l "pragma page_s
2de0: 69 7a 65 22 0a 7d 20 24 3a 3a 53 51 4c 49 54 45  ize".} $::SQLITE
2df0: 5f 4d 41 58 5f 50 41 47 45 5f 53 49 5a 45 0a 0a  _MAX_PAGE_SIZE..
2e00: 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  #---------------
2e10: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2e20: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2e30: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2e40: 2d 2d 2d 2d 2d 0a 23 20 54 65 73 74 20 63 61 73  -----.# Test cas
2e50: 65 73 20 73 71 6c 6c 69 6d 69 74 73 2d 31 31 2e  es sqllimits-11.
2e60: 2a 20 76 65 72 69 66 79 20 74 68 61 74 20 74 68  * verify that th
2e70: 65 20 0a 23 20 53 51 4c 49 54 45 5f 4d 41 58 5f  e .# SQLITE_MAX_
2e80: 4c 49 4b 45 5f 50 41 54 54 45 52 4e 5f 4c 45 4e  LIKE_PATTERN_LEN
2e90: 47 54 48 20 6c 69 6d 69 74 20 69 73 20 65 6e 66  GTH limit is enf
2ea0: 6f 72 63 65 64 2e 20 54 68 69 73 20 6c 69 6d 69  orced. This limi
2eb0: 74 20 6f 6e 6c 79 0a 23 20 61 70 70 6c 69 65 73  t only.# applies
2ec0: 20 74 6f 20 74 68 65 20 62 75 69 6c 74 2d 69 6e   to the built-in
2ed0: 20 4c 49 4b 45 20 6f 70 65 72 61 74 6f 72 2c 20   LIKE operator, 
2ee0: 73 75 70 70 6c 79 69 6e 67 20 61 6e 20 65 78 74  supplying an ext
2ef0: 65 72 6e 61 6c 20 0a 23 20 69 6d 70 6c 65 6d 65  ernal .# impleme
2f00: 6e 74 61 74 69 6f 6e 20 62 79 20 6f 76 65 72 72  ntation by overr
2f10: 69 64 69 6e 67 20 74 68 65 20 6c 69 6b 65 28 29  iding the like()
2f20: 20 73 63 61 6c 61 72 20 66 75 6e 63 74 69 6f 6e   scalar function
2f30: 20 62 79 70 61 73 73 65 73 0a 23 20 74 68 69 73   bypasses.# this
2f40: 20 6c 69 6d 69 74 61 74 69 6f 6e 2e 0a 23 0a 23   limitation..#.#
2f50: 20 54 68 65 73 65 20 74 65 73 74 73 20 63 68 65   These tests che
2f60: 63 6b 20 74 68 61 74 20 74 68 65 20 6c 69 6d 69  ck that the limi
2f70: 74 20 69 73 20 6e 6f 74 20 69 6e 63 6f 72 72 65  t is not incorre
2f80: 63 74 6c 79 20 61 70 70 6c 69 65 64 20 74 6f 0a  ctly applied to.
2f90: 23 20 74 68 65 20 6c 65 66 74 2d 68 61 6e 64 2d  # the left-hand-
2fa0: 73 69 64 65 20 6f 66 20 74 68 65 20 4c 49 4b 45  side of the LIKE
2fb0: 20 6f 70 65 72 61 74 6f 72 20 28 74 68 65 20 73   operator (the s
2fc0: 74 72 69 6e 67 20 62 65 69 6e 67 20 74 65 73 74  tring being test
2fd0: 65 64 0a 23 20 61 67 61 69 6e 73 74 20 74 68 65  ed.# against the
2fe0: 20 70 61 74 74 65 72 6e 29 2e 0a 23 0a 64 6f 5f   pattern)..#.do_
2ff0: 74 65 73 74 20 73 71 6c 6c 69 6d 69 74 73 2d 31  test sqllimits-1
3000: 2e 31 31 2e 31 20 7b 0a 20 20 73 65 74 20 6d 61  .11.1 {.  set ma
3010: 78 20 24 3a 3a 53 51 4c 49 54 45 5f 4d 41 58 5f  x $::SQLITE_MAX_
3020: 4c 49 4b 45 5f 50 41 54 54 45 52 4e 5f 4c 45 4e  LIKE_PATTERN_LEN
3030: 47 54 48 0a 20 20 73 65 74 20 3a 3a 70 61 74 74  GTH.  set ::patt
3040: 65 72 6e 20 5b 73 74 72 69 6e 67 20 72 65 70 65  ern [string repe
3050: 61 74 20 22 41 25 22 20 5b 65 78 70 72 20 24 6d  at "A%" [expr $m
3060: 61 78 2f 32 5d 5d 0a 20 20 73 65 74 20 3a 3a 73  ax/2]].  set ::s
3070: 74 72 69 6e 67 20 20 5b 73 74 72 69 6e 67 20 72  tring  [string r
3080: 65 70 65 61 74 20 22 41 22 20 5b 65 78 70 72 20  epeat "A" [expr 
3090: 7b 24 6d 61 78 2a 32 7d 5d 5d 0a 20 20 65 78 65  {$max*2}]].  exe
30a0: 63 73 71 6c 20 7b 0a 20 20 20 20 53 45 4c 45 43  csql {.    SELEC
30b0: 54 20 24 3a 3a 73 74 72 69 6e 67 20 4c 49 4b 45  T $::string LIKE
30c0: 20 24 3a 3a 70 61 74 74 65 72 6e 3b 0a 20 20 7d   $::pattern;.  }
30d0: 0a 7d 20 7b 31 7d 0a 64 6f 5f 74 65 73 74 20 73  .} {1}.do_test s
30e0: 71 6c 6c 69 6d 69 74 73 2d 31 2e 31 31 2e 32 20  qllimits-1.11.2 
30f0: 7b 0a 20 20 73 65 74 20 6d 61 78 20 24 3a 3a 53  {.  set max $::S
3100: 51 4c 49 54 45 5f 4d 41 58 5f 4c 49 4b 45 5f 50  QLITE_MAX_LIKE_P
3110: 41 54 54 45 52 4e 5f 4c 45 4e 47 54 48 0a 20 20  ATTERN_LENGTH.  
3120: 73 65 74 20 3a 3a 70 61 74 74 65 72 6e 20 5b 73  set ::pattern [s
3130: 74 72 69 6e 67 20 72 65 70 65 61 74 20 22 41 25  tring repeat "A%
3140: 22 20 5b 65 78 70 72 20 7b 28 24 6d 61 78 2f 32  " [expr {($max/2
3150: 29 20 2b 20 31 7d 5d 5d 0a 20 20 73 65 74 20 3a  ) + 1}]].  set :
3160: 3a 73 74 72 69 6e 67 20 20 5b 73 74 72 69 6e 67  :string  [string
3170: 20 72 65 70 65 61 74 20 22 41 22 20 5b 65 78 70   repeat "A" [exp
3180: 72 20 7b 24 6d 61 78 2a 32 7d 5d 5d 0a 20 20 63  r {$max*2}]].  c
3190: 61 74 63 68 73 71 6c 20 7b 0a 20 20 20 20 53 45  atchsql {.    SE
31a0: 4c 45 43 54 20 24 3a 3a 73 74 72 69 6e 67 20 4c  LECT $::string L
31b0: 49 4b 45 20 24 3a 3a 70 61 74 74 65 72 6e 3b 0a  IKE $::pattern;.
31c0: 20 20 7d 0a 7d 20 7b 31 20 7b 4c 49 4b 45 20 6f    }.} {1 {LIKE o
31d0: 72 20 47 4c 4f 42 20 70 61 74 74 65 72 6e 20 74  r GLOB pattern t
31e0: 6f 6f 20 63 6f 6d 70 6c 65 78 7d 7d 0a 0a 23 2d  oo complex}}..#-
31f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
3200: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
3210: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
3220: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
3230: 2d 2d 2d 0a 23 20 54 68 69 73 20 74 65 73 74 20  ---.# This test 
3240: 63 61 73 65 20 64 6f 65 73 6e 27 74 20 72 65 61  case doesn't rea
3250: 6c 6c 79 20 62 65 6c 6f 6e 67 20 77 69 74 68 20  lly belong with 
3260: 74 68 65 20 6f 74 68 65 72 20 6c 69 6d 69 74 73  the other limits
3270: 20 74 65 73 74 73 2e 0a 23 20 49 74 20 69 73 20   tests..# It is 
3280: 69 6e 20 74 68 69 73 20 66 69 6c 65 20 62 65 63  in this file bec
3290: 61 75 73 65 20 69 74 20 69 73 20 74 61 78 69 6e  ause it is taxin
32a0: 67 20 74 6f 20 72 75 6e 2c 20 6c 69 6b 65 20 74  g to run, like t
32b0: 68 65 20 6c 69 6d 69 74 73 20 74 65 73 74 73 2e  he limits tests.
32c0: 0a 23 0a 64 6f 5f 74 65 73 74 20 73 71 6c 6c 69  .#.do_test sqlli
32d0: 6d 69 74 73 2d 31 2e 31 32 2e 31 20 7b 0a 20 20  mits-1.12.1 {.  
32e0: 73 65 74 20 3a 3a 4e 20 5b 65 78 70 72 20 69 6e  set ::N [expr in
32f0: 74 28 28 5b 65 78 70 72 20 70 6f 77 28 32 2c 33  t(([expr pow(2,3
3300: 32 29 5d 2f 35 30 29 20 2b 20 31 29 5d 0a 20 20  2)]/50) + 1)].  
3310: 65 78 70 72 20 28 28 24 3a 3a 4e 2a 35 30 29 20  expr (($::N*50) 
3320: 26 20 30 78 66 66 66 66 66 66 66 66 29 3c 35 35  & 0xffffffff)<55
3330: 0a 7d 20 7b 31 7d 0a 64 6f 5f 74 65 73 74 20 73  .} {1}.do_test s
3340: 71 6c 6c 69 6d 69 74 73 2d 31 2e 31 32 2e 32 20  qllimits-1.12.2 
3350: 7b 0a 20 20 73 65 74 20 3a 3a 66 6f 72 6d 61 74  {.  set ::format
3360: 20 22 5b 73 74 72 69 6e 67 20 72 65 70 65 61 74   "[string repeat
3370: 20 41 20 36 30 5d 5b 73 74 72 69 6e 67 20 72 65   A 60][string re
3380: 70 65 61 74 20 22 25 4a 22 20 24 3a 3a 4e 5d 22  peat "%J" $::N]"
3390: 0a 20 20 63 61 74 63 68 73 71 6c 20 7b 0a 20 20  .  catchsql {.  
33a0: 20 20 53 45 4c 45 43 54 20 73 74 72 66 74 69 6d    SELECT strftim
33b0: 65 28 24 3a 3a 66 6f 72 6d 61 74 2c 20 31 29 3b  e($::format, 1);
33c0: 0a 20 20 7d 0a 7d 20 7b 31 20 7b 73 74 72 69 6e  .  }.} {1 {strin
33d0: 67 20 6f 72 20 62 6c 6f 62 20 74 6f 6f 20 62 69  g or blob too bi
33e0: 67 7d 7d 0a 0a 66 69 6e 69 73 68 5f 74 65 73 74  g}}..finish_test
33f0: 0a 0a 0a                                         ...