SQLite4
Hex Artifact Content
Not logged in

Artifact 183c496df8547ac9c9a72ecbfae89f1eb37876a7:


0000: 23 0a 23 20 32 30 30 37 20 4d 61 79 20 37 0a 23  #.# 2007 May 7.#
0010: 0a 23 20 54 68 65 20 61 75 74 68 6f 72 20 64 69  .# The author di
0020: 73 63 6c 61 69 6d 73 20 63 6f 70 79 72 69 67 68  sclaims copyrigh
0030: 74 20 74 6f 20 74 68 69 73 20 73 6f 75 72 63 65  t to this source
0040: 20 63 6f 64 65 2e 20 20 49 6e 20 70 6c 61 63 65   code.  In place
0050: 20 6f 66 0a 23 20 61 20 6c 65 67 61 6c 20 6e 6f   of.# a legal no
0060: 74 69 63 65 2c 20 68 65 72 65 20 69 73 20 61 20  tice, here is a 
0070: 62 6c 65 73 73 69 6e 67 3a 0a 23 0a 23 20 20 20  blessing:.#.#   
0080: 20 4d 61 79 20 79 6f 75 20 64 6f 20 67 6f 6f 64   May you do good
0090: 20 61 6e 64 20 6e 6f 74 20 65 76 69 6c 2e 0a 23   and not evil..#
00a0: 20 20 20 20 4d 61 79 20 79 6f 75 20 66 69 6e 64      May you find
00b0: 20 66 6f 72 67 69 76 65 6e 65 73 73 20 66 6f 72   forgiveness for
00c0: 20 79 6f 75 72 73 65 6c 66 20 61 6e 64 20 66 6f   yourself and fo
00d0: 72 67 69 76 65 20 6f 74 68 65 72 73 2e 0a 23 20  rgive others..# 
00e0: 20 20 20 4d 61 79 20 79 6f 75 20 73 68 61 72 65     May you share
00f0: 20 66 72 65 65 6c 79 2c 20 6e 65 76 65 72 20 74   freely, never t
0100: 61 6b 69 6e 67 20 6d 6f 72 65 20 74 68 61 6e 20  aking more than 
0110: 79 6f 75 20 67 69 76 65 2e 0a 23 0a 23 2a 2a 2a  you 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 2a 2a 0a 23 0a 23 20 54 68 69 73 20 66 69  ****.#.# This fi
0170: 6c 65 20 69 6d 70 6c 65 6d 65 6e 74 73 20 72 65  le implements re
0180: 67 72 65 73 73 69 6f 6e 20 74 65 73 74 73 20 66  gression tests f
0190: 6f 72 20 53 51 4c 69 74 65 20 6c 69 62 72 61 72  or SQLite librar
01a0: 79 2e 20 54 68 65 0a 23 20 66 6f 63 75 73 20 6f  y. The.# focus o
01b0: 66 20 74 68 69 73 20 73 63 72 69 70 74 20 69 73  f this script is
01c0: 20 74 68 65 20 73 71 6c 69 74 65 34 5f 63 72 65   the sqlite4_cre
01d0: 61 74 65 5f 63 6f 6c 6c 61 74 69 6f 6e 28 29 20  ate_collation() 
01e0: 61 6e 64 20 0a 23 20 63 6f 6c 6c 61 74 69 6f 6e  and .# collation
01f0: 5f 6e 65 65 64 65 64 28 29 20 41 50 49 73 2e 20  _needed() APIs. 
0200: 4d 6f 72 65 20 73 70 65 63 69 66 69 63 61 6c 6c  More specificall
0210: 79 2c 20 74 68 65 20 66 6f 63 75 73 20 69 73 20  y, the focus is 
0220: 6f 6e 20 74 65 73 74 69 6e 67 20 74 68 61 74 20  on testing that 
0230: 0a 23 20 64 65 73 74 72 75 63 74 6f 72 20 63 61  .# destructor ca
0240: 6c 6c 62 61 63 6b 73 20 61 72 65 20 69 6e 76 6f  llbacks are invo
0250: 6b 65 64 20 63 6f 72 72 65 63 74 6c 79 2e 0a 23  ked correctly..#
0260: 0a 0a 73 65 74 20 74 65 73 74 64 69 72 20 5b 66  ..set testdir [f
0270: 69 6c 65 20 64 69 72 6e 61 6d 65 20 24 61 72 67  ile dirname $arg
0280: 76 30 5d 0a 73 6f 75 72 63 65 20 24 74 65 73 74  v0].source $test
0290: 64 69 72 2f 74 65 73 74 65 72 2e 74 63 6c 0a 73  dir/tester.tcl.s
02a0: 65 74 20 3a 3a 74 65 73 74 70 72 65 66 69 78 20  et ::testprefix 
02b0: 63 6f 6c 6c 61 74 65 37 0a 0a 0a 23 20 49 6d 70  collate7...# Imp
02c0: 6c 65 6d 65 6e 74 61 74 69 6f 6e 20 6f 66 20 63  lementation of c
02d0: 6f 6c 6c 61 74 69 6f 6e 20 73 65 71 75 65 6e 63  ollation sequenc
02e0: 65 20 63 61 6c 6c 62 61 63 6b 73 2e 0a 23 0a 70  e callbacks..#.p
02f0: 72 6f 63 20 63 61 73 65 6c 65 73 73 5f 63 6d 70  roc caseless_cmp
0300: 20 7b 7a 4c 65 66 74 20 7a 52 69 67 68 74 7d 20   {zLeft zRight} 
0310: 7b 0a 20 20 73 74 72 69 6e 67 20 63 6f 6d 70 61  {.  string compa
0320: 72 65 20 2d 6e 6f 63 61 73 65 20 24 7a 4c 65 66  re -nocase $zLef
0330: 74 20 24 7a 52 69 67 68 74 0a 7d 0a 70 72 6f 63  t $zRight.}.proc
0340: 20 63 61 73 65 6c 65 73 73 5f 6d 6b 6b 65 79 20   caseless_mkkey 
0350: 7b 7a 49 6e 7d 20 7b 0a 20 20 73 74 72 69 6e 67  {zIn} {.  string
0360: 20 74 6f 6c 6f 77 65 72 20 24 7a 49 6e 0a 7d 0a   tolower $zIn.}.
0370: 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  .#--------------
0380: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0390: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
03a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
03b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20 54 65  -----------.# Te
03c0: 73 74 20 74 68 65 20 64 65 73 74 72 75 63 74 6f  st the destructo
03d0: 72 20 69 73 20 69 6e 76 6f 6b 65 64 20 77 68 65  r is invoked whe
03e0: 6e 20 61 20 63 6f 6c 6c 61 74 69 6f 6e 20 73 65  n a collation se
03f0: 71 75 65 6e 63 65 20 69 73 20 6f 76 65 72 72 69  quence is overri
0400: 64 64 65 6e 2e 0a 23 0a 64 6f 5f 74 65 73 74 20  dden..#.do_test 
0410: 31 2e 31 20 7b 0a 20 20 73 65 74 20 3a 3a 63 61  1.1 {.  set ::ca
0420: 73 65 6c 65 73 73 5f 64 65 6c 20 30 0a 20 20 73  seless_del 0.  s
0430: 65 74 20 64 65 6c 20 5b 6c 69 73 74 20 69 6e 63  et del [list inc
0440: 72 20 3a 3a 63 61 73 65 6c 65 73 73 5f 64 65 6c  r ::caseless_del
0450: 5d 0a 20 20 73 71 6c 69 74 65 34 5f 63 72 65 61  ].  sqlite4_crea
0460: 74 65 5f 63 6f 6c 6c 61 74 69 6f 6e 20 64 62 20  te_collation db 
0470: 43 41 53 45 4c 45 53 53 20 63 61 73 65 6c 65 73  CASELESS caseles
0480: 73 5f 63 6d 70 20 63 61 73 65 6c 65 73 73 5f 6d  s_cmp caseless_m
0490: 6b 6b 65 79 20 24 64 65 6c 0a 20 20 73 65 74 20  kkey $del.  set 
04a0: 3a 3a 63 61 73 65 6c 65 73 73 5f 64 65 6c 0a 7d  ::caseless_del.}
04b0: 20 7b 30 7d 0a 0a 64 6f 5f 74 65 73 74 20 31 2e   {0}..do_test 1.
04c0: 32 20 7b 0a 20 20 73 65 74 20 3a 3a 63 61 73 65  2 {.  set ::case
04d0: 6c 65 73 73 5f 64 65 6c 20 30 0a 20 20 73 71 6c  less_del 0.  sql
04e0: 69 74 65 34 5f 63 72 65 61 74 65 5f 63 6f 6c 6c  ite4_create_coll
04f0: 61 74 69 6f 6e 20 64 62 20 43 41 53 45 4c 45 53  ation db CASELES
0500: 53 20 7b 7d 20 7b 7d 20 7b 7d 0a 20 20 73 65 74  S {} {} {}.  set
0510: 20 3a 3a 63 61 73 65 6c 65 73 73 5f 64 65 6c 0a   ::caseless_del.
0520: 7d 20 7b 31 7d 0a 0a 64 6f 5f 63 61 74 63 68 73  } {1}..do_catchs
0530: 71 6c 5f 74 65 73 74 20 31 2e 33 20 7b 20 0a 20  ql_test 1.3 { . 
0540: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 61 62   CREATE TABLE ab
0550: 63 28 61 20 43 4f 4c 4c 41 54 45 20 43 41 53 45  c(a COLLATE CASE
0560: 4c 45 53 53 2c 20 62 2c 20 63 29 3b 20 0a 7d 20  LESS, b, c); .} 
0570: 7b 31 20 7b 6e 6f 20 73 75 63 68 20 63 6f 6c 6c  {1 {no such coll
0580: 61 74 69 6f 6e 20 73 65 71 75 65 6e 63 65 3a 20  ation sequence: 
0590: 43 41 53 45 4c 45 53 53 7d 7d 0a 0a 64 6f 5f 74  CASELESS}}..do_t
05a0: 65 73 74 20 31 2e 34 20 7b 0a 20 20 73 65 74 20  est 1.4 {.  set 
05b0: 3a 3a 63 61 73 65 6c 65 73 73 5f 64 65 6c 20 30  ::caseless_del 0
05c0: 0a 20 20 73 71 6c 69 74 65 34 5f 63 72 65 61 74  .  sqlite4_creat
05d0: 65 5f 63 6f 6c 6c 61 74 69 6f 6e 20 64 62 20 43  e_collation db C
05e0: 41 53 45 4c 45 53 53 20 7b 7d 20 7b 7d 20 7b 7d  ASELESS {} {} {}
05f0: 0a 20 20 73 65 74 20 3a 3a 63 61 73 65 6c 65 73  .  set ::caseles
0600: 73 5f 64 65 6c 0a 7d 20 7b 30 7d 0a 0a 23 2d 2d  s_del.} {0}..#--
0610: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0620: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0630: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0640: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0650: 2d 2d 2d 2d 2d 2d 2d 0a 23 20 54 65 73 74 20 74  -------.# Test t
0660: 68 65 20 64 65 73 74 72 75 63 74 6f 72 20 69 73  he destructor is
0670: 20 69 6e 76 6f 6b 65 64 20 77 68 65 6e 20 74 68   invoked when th
0680: 65 20 64 61 74 61 62 61 73 65 20 68 61 6e 64 6c  e database handl
0690: 65 20 69 73 20 63 6c 6f 73 65 64 2e 0a 23 0a 64  e is closed..#.d
06a0: 6f 5f 74 65 73 74 20 32 2e 31 20 7b 0a 20 20 73  o_test 2.1 {.  s
06b0: 65 74 20 3a 3a 63 61 73 65 6c 65 73 73 5f 64 65  et ::caseless_de
06c0: 6c 20 30 0a 20 20 73 65 74 20 64 65 6c 20 5b 6c  l 0.  set del [l
06d0: 69 73 74 20 69 6e 63 72 20 3a 3a 63 61 73 65 6c  ist incr ::casel
06e0: 65 73 73 5f 64 65 6c 5d 0a 20 20 73 71 6c 69 74  ess_del].  sqlit
06f0: 65 34 5f 63 72 65 61 74 65 5f 63 6f 6c 6c 61 74  e4_create_collat
0700: 69 6f 6e 20 64 62 20 43 41 53 45 4c 45 53 53 20  ion db CASELESS 
0710: 63 61 73 65 6c 65 73 73 5f 63 6d 70 20 63 61 73  caseless_cmp cas
0720: 65 6c 65 73 73 5f 6d 6b 6b 65 79 20 24 64 65 6c  eless_mkkey $del
0730: 0a 20 20 64 62 20 63 6c 6f 73 65 0a 20 20 73 65  .  db close.  se
0740: 74 20 3a 3a 63 61 73 65 6c 65 73 73 5f 64 65 6c  t ::caseless_del
0750: 0a 7d 20 7b 31 7d 0a 0a 23 2d 2d 2d 2d 2d 2d 2d  .} {1}..#-------
0760: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0770: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
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 0a 23 20 54 65 73 74 20 74 68 65 20 64 65  --.# Test the de
07b0: 73 74 72 75 63 74 6f 72 20 69 73 20 69 6e 76 6f  structor is invo
07c0: 6b 65 64 20 69 66 20 61 6e 20 65 72 72 6f 72 20  ked if an error 
07d0: 6f 63 63 75 72 73 20 77 69 74 68 69 6e 0a 23 20  occurs within.# 
07e0: 73 71 6c 69 74 65 34 5f 63 72 65 61 74 65 5f 63  sqlite4_create_c
07f0: 6f 6c 6c 61 74 69 6f 6e 28 29 2e 20 54 68 65 20  ollation(). The 
0800: 65 61 73 69 65 73 74 20 65 72 72 6f 72 20 74 6f  easiest error to
0810: 20 70 72 6f 76 6f 6b 65 20 68 65 72 65 20 69 73   provoke here is
0820: 20 0a 23 20 53 51 4c 49 54 45 34 5f 42 55 53 59   .# SQLITE4_BUSY
0830: 20 2d 20 77 68 69 63 68 20 69 73 20 72 65 74 75   - which is retu
0840: 72 6e 65 64 20 69 66 20 61 6e 20 61 74 74 65 6d  rned if an attem
0850: 70 74 20 69 73 20 6d 61 64 65 20 74 6f 20 6f 76  pt is made to ov
0860: 65 72 72 69 64 65 20 61 0a 23 20 63 6f 6c 6c 61  erride a.# colla
0870: 74 69 6f 6e 20 77 68 69 6c 65 20 74 68 65 72 65  tion while there
0880: 20 61 72 65 20 61 63 74 69 76 65 20 73 74 61 74   are active stat
0890: 65 6d 65 6e 74 73 2e 0a 23 0a 72 65 73 65 74 5f  ements..#.reset_
08a0: 64 62 0a 64 6f 5f 74 65 73 74 20 33 2e 31 20 7b  db.do_test 3.1 {
08b0: 0a 20 20 73 65 74 20 3a 3a 63 61 73 65 6c 65 73  .  set ::caseles
08c0: 73 5f 64 65 6c 20 30 0a 20 20 73 65 74 20 64 65  s_del 0.  set de
08d0: 6c 20 5b 6c 69 73 74 20 69 6e 63 72 20 3a 3a 63  l [list incr ::c
08e0: 61 73 65 6c 65 73 73 5f 64 65 6c 5d 0a 20 20 73  aseless_del].  s
08f0: 71 6c 69 74 65 34 5f 63 72 65 61 74 65 5f 63 6f  qlite4_create_co
0900: 6c 6c 61 74 69 6f 6e 20 64 62 20 43 41 53 45 4c  llation db CASEL
0910: 45 53 53 20 63 61 73 65 6c 65 73 73 5f 63 6d 70  ESS caseless_cmp
0920: 20 63 61 73 65 6c 65 73 73 5f 6d 6b 6b 65 79 20   caseless_mkkey 
0930: 24 64 65 6c 0a 20 20 65 78 65 63 73 71 6c 20 7b  $del.  execsql {
0940: 0a 20 20 20 20 43 52 45 41 54 45 20 54 41 42 4c  .    CREATE TABL
0950: 45 20 74 31 28 61 20 43 4f 4c 4c 41 54 45 20 63  E t1(a COLLATE c
0960: 61 73 65 6c 65 73 73 29 3b 0a 20 20 20 20 49 4e  aseless);.    IN
0970: 53 45 52 54 20 49 4e 54 4f 20 74 31 20 56 41 4c  SERT INTO t1 VAL
0980: 55 45 53 28 27 61 62 63 27 29 3b 0a 20 20 20 20  UES('abc');.    
0990: 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 20 56  INSERT INTO t1 V
09a0: 41 4c 55 45 53 28 27 64 65 66 27 29 3b 0a 20 20  ALUES('def');.  
09b0: 7d 0a 0a 20 20 73 65 74 20 3a 3a 73 74 6d 74 20  }..  set ::stmt 
09c0: 5b 73 71 6c 69 74 65 34 5f 70 72 65 70 61 72 65  [sqlite4_prepare
09d0: 20 64 62 20 22 53 45 4c 45 43 54 20 61 20 46 52   db "SELECT a FR
09e0: 4f 4d 20 74 31 22 20 2d 31 20 44 55 4d 4d 59 5d  OM t1" -1 DUMMY]
09f0: 0a 20 20 73 71 6c 69 74 65 34 5f 73 74 65 70 20  .  sqlite4_step 
0a00: 24 3a 3a 73 74 6d 74 0a 7d 20 7b 53 51 4c 49 54  $::stmt.} {SQLIT
0a10: 45 34 5f 52 4f 57 7d 0a 0a 64 6f 5f 74 65 73 74  E4_ROW}..do_test
0a20: 20 33 2e 32 20 7b 0a 20 20 73 65 74 20 3a 3a 63   3.2 {.  set ::c
0a30: 61 73 65 6c 65 73 73 5f 64 65 6c 32 20 30 0a 20  aseless_del2 0. 
0a40: 20 73 65 74 20 64 65 6c 20 5b 6c 69 73 74 20 69   set del [list i
0a50: 6e 63 72 20 3a 3a 63 61 73 65 6c 65 73 73 5f 64  ncr ::caseless_d
0a60: 65 6c 32 5d 0a 20 20 73 65 74 20 72 63 20 5b 63  el2].  set rc [c
0a70: 61 74 63 68 20 7b 0a 20 20 20 20 73 71 6c 69 74  atch {.    sqlit
0a80: 65 34 5f 63 72 65 61 74 65 5f 63 6f 6c 6c 61 74  e4_create_collat
0a90: 69 6f 6e 20 64 62 20 43 41 53 45 4c 45 53 53 20  ion db CASELESS 
0aa0: 63 61 73 65 6c 65 73 73 5f 63 6d 70 20 63 61 73  caseless_cmp cas
0ab0: 65 6c 65 73 73 5f 6d 6b 6b 65 79 20 24 64 65 6c  eless_mkkey $del
0ac0: 0a 20 20 7d 20 6d 73 67 5d 0a 20 20 0a 20 20 6c  .  } msg].  .  l
0ad0: 69 73 74 20 24 3a 3a 63 61 73 65 6c 65 73 73 5f  ist $::caseless_
0ae0: 64 65 6c 20 24 63 61 73 65 6c 65 73 73 5f 64 65  del $caseless_de
0af0: 6c 32 20 24 72 63 20 24 6d 73 67 0a 7d 20 7b 30  l2 $rc $msg.} {0
0b00: 20 31 20 31 20 53 51 4c 49 54 45 34 5f 42 55 53   1 1 SQLITE4_BUS
0b10: 59 7d 0a 0a 64 6f 5f 74 65 73 74 20 33 2e 33 20  Y}..do_test 3.3 
0b20: 7b 20 73 71 6c 69 74 65 34 5f 65 72 72 63 6f 64  { sqlite4_errcod
0b30: 65 20 64 62 20 7d 20 7b 53 51 4c 49 54 45 34 5f  e db } {SQLITE4_
0b40: 42 55 53 59 7d 0a 64 6f 5f 74 65 73 74 20 33 2e  BUSY}.do_test 3.
0b50: 34 20 7b 20 0a 20 20 73 71 6c 69 74 65 34 5f 65  4 { .  sqlite4_e
0b60: 72 72 6d 73 67 20 64 62 20 0a 7d 20 7b 75 6e 61  rrmsg db .} {una
0b70: 62 6c 65 20 74 6f 20 64 65 6c 65 74 65 2f 6d 6f  ble to delete/mo
0b80: 64 69 66 79 20 63 6f 6c 6c 61 74 69 6f 6e 20 73  dify collation s
0b90: 65 71 75 65 6e 63 65 20 64 75 65 20 74 6f 20 61  equence due to a
0ba0: 63 74 69 76 65 20 73 74 61 74 65 6d 65 6e 74 73  ctive statements
0bb0: 7d 0a 0a 64 6f 5f 74 65 73 74 20 33 2e 35 20 7b  }..do_test 3.5 {
0bc0: 20 73 71 6c 69 74 65 34 5f 66 69 6e 61 6c 69 7a   sqlite4_finaliz
0bd0: 65 20 24 3a 3a 73 74 6d 74 20 7d 20 7b 53 51 4c  e $::stmt } {SQL
0be0: 49 54 45 34 5f 4f 4b 7d 0a 64 6f 5f 74 65 73 74  ITE4_OK}.do_test
0bf0: 20 33 2e 36 20 7b 20 73 71 6c 69 74 65 34 5f 65   3.6 { sqlite4_e
0c00: 72 72 63 6f 64 65 20 64 62 20 20 20 20 20 20 20  rrcode db       
0c10: 7d 20 7b 53 51 4c 49 54 45 34 5f 4f 4b 7d 0a 64  } {SQLITE4_OK}.d
0c20: 6f 5f 74 65 73 74 20 33 2e 37 20 7b 20 73 71 6c  o_test 3.7 { sql
0c30: 69 74 65 34 5f 65 72 72 6d 73 67 20 64 62 20 20  ite4_errmsg db  
0c40: 20 20 20 20 20 20 7d 20 7b 6e 6f 74 20 61 6e 20        } {not an 
0c50: 65 72 72 6f 72 7d 0a 0a 23 2d 2d 2d 2d 2d 2d 2d  error}..#-------
0c60: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0c70: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0c80: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0c90: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0ca0: 2d 2d 0a 23 20 54 68 65 20 66 6f 6c 6c 6f 77 69  --.# The followi
0cb0: 6e 67 20 74 65 73 74 73 20 76 65 72 69 66 79 20  ng tests verify 
0cc0: 74 68 61 74 20 74 68 65 20 63 6f 6c 6c 61 74 69  that the collati
0cd0: 6f 6e 20 6e 65 65 64 65 64 20 64 65 73 74 72 75  on needed destru
0ce0: 63 74 6f 72 20 69 73 0a 23 20 69 6e 76 6f 6b 65  ctor is.# invoke
0cf0: 64 3a 0a 23 0a 23 20 20 20 31 2e 20 57 68 65 6e  d:.#.#   1. When
0d00: 20 69 74 20 69 73 20 6f 76 65 72 72 69 64 64 65   it is overridde
0d10: 6e 2c 20 61 6e 64 0a 23 20 20 20 32 2e 20 57 68  n, and.#   2. Wh
0d20: 65 6e 20 74 68 65 20 64 61 74 61 62 61 73 65 20  en the database 
0d30: 63 6f 6e 6e 65 63 74 69 6f 6e 20 69 73 20 63 6c  connection is cl
0d40: 6f 73 65 64 2e 0a 23 0a 23 20 49 74 20 77 6f 75  osed..#.# It wou
0d50: 6c 64 20 62 65 20 67 6f 6f 64 20 74 6f 20 74 65  ld be good to te
0d60: 73 74 20 74 68 61 74 20 69 66 20 61 6e 20 65 72  st that if an er
0d70: 72 6f 72 20 6f 63 63 75 72 73 20 77 69 74 68 69  ror occurs withi
0d80: 6e 20 74 68 65 20 0a 23 20 63 6f 6c 6c 61 74 69  n the .# collati
0d90: 6f 6e 5f 6e 65 65 64 65 64 28 29 20 74 68 65 20  on_needed() the 
0da0: 64 65 73 74 72 75 63 74 6f 72 20 69 73 20 69 6e  destructor is in
0db0: 76 6f 6b 65 64 20 69 6d 6d 65 64 69 61 74 65 6c  voked immediatel
0dc0: 79 20 28 61 73 20 74 68 65 20 0a 23 20 64 6f 63  y (as the .# doc
0dd0: 75 6d 65 6e 74 61 74 69 6f 6e 20 73 61 79 73 29  umentation says)
0de0: 2e 20 48 6f 77 65 76 65 72 20 74 68 65 72 65 20  . However there 
0df0: 69 73 20 63 75 72 72 65 6e 74 6c 79 20 6e 6f 20  is currently no 
0e00: 77 61 79 20 74 6f 20 63 61 75 73 65 0a 23 20 73  way to cause.# s
0e10: 71 6c 69 74 65 34 5f 63 6f 6c 6c 61 74 69 6f 6e  qlite4_collation
0e20: 5f 6e 65 65 64 65 64 28 29 20 74 6f 20 66 61 69  _needed() to fai
0e30: 6c 2e 20 73 71 6c 69 74 65 34 5f 63 6f 6c 6c 61  l. sqlite4_colla
0e40: 74 69 6f 6e 5f 6e 65 65 64 65 64 28 29 20 0a 23  tion_needed() .#
0e50: 20 63 75 72 72 65 6e 74 6c 79 20 2a 61 6c 77 61   currently *alwa
0e60: 79 73 2a 20 72 65 74 75 72 6e 73 20 53 51 4c 49  ys* returns SQLI
0e70: 54 45 34 5f 4f 4b 2e 0a 23 0a 64 6f 5f 74 65 73  TE4_OK..#.do_tes
0e80: 74 20 34 2e 31 2e 31 20 7b 0a 20 20 73 65 74 20  t 4.1.1 {.  set 
0e90: 3a 3a 63 6f 6c 6c 5f 6e 65 65 64 65 64 5f 64 65  ::coll_needed_de
0ea0: 6c 20 30 0a 20 20 73 71 6c 69 74 65 34 5f 63 6f  l 0.  sqlite4_co
0eb0: 6c 6c 61 74 69 6f 6e 5f 6e 65 65 64 65 64 20 64  llation_needed d
0ec0: 62 20 63 6f 6c 6c 5f 6e 65 65 64 65 64 20 7b 69  b coll_needed {i
0ed0: 6e 63 72 20 3a 3a 63 6f 6c 6c 5f 6e 65 65 64 65  ncr ::coll_neede
0ee0: 64 5f 64 65 6c 7d 0a 20 20 73 65 74 20 3a 3a 63  d_del}.  set ::c
0ef0: 6f 6c 6c 5f 6e 65 65 64 65 64 5f 64 65 6c 0a 7d  oll_needed_del.}
0f00: 20 7b 30 7d 0a 0a 64 6f 5f 74 65 73 74 20 34 2e   {0}..do_test 4.
0f10: 31 2e 32 20 7b 0a 20 20 73 65 74 20 3a 3a 63 6f  1.2 {.  set ::co
0f20: 6c 6c 5f 6e 65 65 64 65 64 5f 64 65 6c 32 20 30  ll_needed_del2 0
0f30: 0a 20 20 73 71 6c 69 74 65 34 5f 63 6f 6c 6c 61  .  sqlite4_colla
0f40: 74 69 6f 6e 5f 6e 65 65 64 65 64 20 64 62 20 63  tion_needed db c
0f50: 6f 6c 6c 5f 6e 65 65 64 65 64 20 7b 69 6e 63 72  oll_needed {incr
0f60: 20 3a 3a 63 6f 6c 6c 5f 6e 65 65 64 65 64 5f 64   ::coll_needed_d
0f70: 65 6c 32 7d 0a 20 20 6c 69 73 74 20 24 3a 3a 63  el2}.  list $::c
0f80: 6f 6c 6c 5f 6e 65 65 64 65 64 5f 64 65 6c 20 24  oll_needed_del $
0f90: 3a 3a 63 6f 6c 6c 5f 6e 65 65 64 65 64 5f 64 65  ::coll_needed_de
0fa0: 6c 32 0a 7d 20 7b 31 20 30 7d 0a 0a 64 6f 5f 74  l2.} {1 0}..do_t
0fb0: 65 73 74 20 34 2e 32 20 7b 0a 20 20 64 62 20 63  est 4.2 {.  db c
0fc0: 6c 6f 73 65 0a 20 20 6c 69 73 74 20 24 3a 3a 63  lose.  list $::c
0fd0: 6f 6c 6c 5f 6e 65 65 64 65 64 5f 64 65 6c 20 24  oll_needed_del $
0fe0: 3a 3a 63 6f 6c 6c 5f 6e 65 65 64 65 64 5f 64 65  ::coll_needed_de
0ff0: 6c 32 0a 7d 20 7b 31 20 31 7d 0a 0a 66 69 6e 69  l2.} {1 1}..fini
1000: 73 68 5f 74 65 73 74 0a 0a                       sh_test..