Hex Artifact Content
Not logged in

Artifact 32419adfa3ab732954bd46b25ced39d6ab95c4c7:

Wiki page [4.1.0 Changes] by sandro 2013-05-30 12:18:38.
0000: 44 20 32 30 31 33 2d 30 35 2d 33 30 54 31 32 3a  D 2013-05-30T12:
0010: 31 38 3a 33 38 2e 33 37 31 0a 4c 20 34 2e 31 2e  18:38.371.L 4.1.
0020: 30 5c 73 43 68 61 6e 67 65 73 0a 50 20 66 61 39  0\sChanges.P fa9
0030: 65 61 34 32 38 64 63 35 37 39 32 32 39 35 36 62  ea428dc57922956b
0040: 38 35 63 39 33 66 39 36 34 65 63 37 65 39 35 34  85c93f964ec7e954
0050: 62 39 33 66 33 0a 55 20 73 61 6e 64 72 6f 0a 57  b93f3.U sandro.W
0060: 20 31 39 35 34 38 0a 62 61 63 6b 20 74 6f 20 3c   19548.back to <
0070: 61 20 68 72 65 66 3d 22 68 74 74 70 73 3a 2f 2f  a href="https://
0080: 77 77 77 2e 67 61 69 61 2d 67 69 73 2e 69 74 2f  www.gaia-gis.it/
0090: 66 6f 73 73 69 6c 2f 6c 69 62 73 70 61 74 69 61  fossil/libspatia
00a0: 6c 69 74 65 2f 77 69 6b 69 3f 6e 61 6d 65 3d 34  lite/wiki?name=4
00b0: 2e 31 2e 30 2d 64 6f 63 22 3e 34 2e 31 2e 30 2d  .1.0-doc">4.1.0-
00c0: 64 6f 63 3c 2f 61 3e 0d 0a 3c 68 32 3e 4e 65 77  doc</a>..<h2>New
00d0: 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 73 20 69   SQL functions i
00e0: 6e 74 72 6f 64 75 63 65 64 20 69 6e 20 34 2e 31  ntroduced in 4.1
00f0: 2e 30 3c 2f 68 32 3e 0d 0a 54 61 62 6c 65 20 6f  .0</h2>..Table o
0100: 66 20 63 6f 6e 74 65 6e 74 73 3a 0d 0a 3c 75 6c  f contents:..<ul
0110: 3e 0d 0a 3c 6c 69 3e 53 51 4c 20 66 75 6e 63 74  >..<li>SQL funct
0120: 69 6f 6e 73 20 73 75 70 70 6f 72 74 69 6e 67 20  ions supporting 
0130: 3c 61 20 68 72 65 66 3d 22 23 63 61 73 74 22 3e  <a href="#cast">
0140: 64 61 74 61 2d 74 79 70 65 20 63 61 73 74 69 6e  data-type castin
0150: 67 3c 2f 61 3e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e  g</a></li>..<li>
0160: 53 51 4c 20 66 75 6e 63 74 69 6f 6e 73 20 73 75  SQL functions su
0170: 70 70 6f 72 74 69 6e 67 20 3c 61 20 68 72 65 66  pporting <a href
0180: 3d 22 23 75 75 69 64 22 3e 55 55 49 44 20 67 65  ="#uuid">UUID ge
0190: 6e 65 72 61 74 69 6f 6e 3c 2f 61 3e 3c 2f 6c 69  neration</a></li
01a0: 3e 0d 0a 3c 6c 69 3e 53 70 61 74 69 61 6c 20 53  >..<li>Spatial S
01b0: 51 4c 20 66 75 6e 63 74 69 6f 6e 73 20 73 75 70  QL functions sup
01c0: 70 6f 72 74 69 6e 67 20 3c 61 20 68 72 65 66 3d  porting <a href=
01d0: 22 23 67 65 6f 6d 22 3e 47 65 6f 6d 65 74 72 69  "#geom">Geometri
01e0: 65 73 3c 2f 61 3e 3c 75 6c 3e 0d 0a 3c 6c 69 3e  es</a><ul>..<li>
01f0: 53 51 4c 20 66 75 6e 63 74 69 6f 6e 73 20 73 75  SQL functions su
0200: 70 70 6f 72 74 69 6e 67 20 3c 61 20 68 72 65 66  pporting <a href
0210: 3d 22 68 74 74 70 73 3a 2f 2f 77 77 77 2e 67 61  ="https://www.ga
0220: 69 61 2d 67 69 73 2e 69 74 2f 66 6f 73 73 69 6c  ia-gis.it/fossil
0230: 2f 6c 69 62 73 70 61 74 69 61 6c 69 74 65 2f 77  /libspatialite/w
0240: 69 6b 69 65 64 69 74 3f 6e 61 6d 65 3d 63 69 72  ikiedit?name=cir
0250: 63 6c 65 73 2d 65 6c 6c 69 70 73 65 73 22 3e 43  cles-ellipses">C
0260: 69 72 63 6c 65 73 20 61 6e 64 20 45 6c 6c 69 70  ircles and Ellip
0270: 73 65 73 3c 2f 61 3e 3c 2f 6c 69 3e 3c 2f 75 6c  ses</a></li></ul
0280: 3e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 53 51 4c 20  ></li>..<li>SQL 
0290: 66 75 6e 63 74 69 6f 6e 73 20 73 75 70 70 6f 72  functions suppor
02a0: 74 69 6e 67 20 3c 61 20 68 72 65 66 3d 22 23 75  ting <a href="#u
02b0: 6e 73 61 66 65 22 3e 75 6e 73 61 66 65 3c 2f 61  nsafe">unsafe</a
02c0: 3e 20 64 69 72 65 63 74 20 49 6d 70 6f 72 74 2f  > direct Import/
02d0: 45 78 70 6f 72 74 3c 2f 6c 69 3e 0d 0a 3c 2f 75  Export</li>..</u
02e0: 6c 3e 0d 0a 3c 68 33 3e 3c 61 20 6e 61 6d 65 3d  l>..<h3><a name=
02f0: 22 67 65 6e 65 72 69 63 22 3e 63 61 73 74 3c 2f  "generic">cast</
0300: 61 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 73  a> SQL functions
0310: 20 2d 20 74 79 70 65 20 63 61 73 74 69 6e 67 3c   - type casting<
0320: 2f 68 33 3e 0d 0a 53 51 4c 69 74 65 20 6f 66 66  /h3>..SQLite off
0330: 65 72 73 20 6a 75 73 74 20 61 20 76 65 72 79 20  ers just a very 
0340: 62 61 73 69 63 20 74 79 70 65 20 63 68 65 63 6b  basic type check
0350: 69 6e 67 3b 20 74 68 69 73 20 69 73 20 73 6f 6d  ing; this is som
0360: 65 74 69 6d 65 73 20 75 73 65 66 75 6c 2c 20 62  etimes useful, b
0370: 75 74 20 63 6f 75 6c 64 20 62 65 20 72 65 61 6c  ut could be real
0380: 6c 79 20 61 6e 6e 6f 79 69 6e 67 20 76 65 72 79  ly annoying very
0390: 20 6f 66 74 65 6e 2e 3c 62 72 3e 0d 0a 3c 76 65   often.<br>..<ve
03a0: 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20  rbatim>..SELECT 
03b0: 27 31 27 2c 20 54 79 70 65 4f 66 28 20 27 31 27  '1', TypeOf( '1'
03c0: 20 29 2c 20 43 41 53 54 20 28 20 27 31 27 20 41   ), CAST ( '1' A
03d0: 53 20 49 4e 54 45 47 45 52 20 29 2c 20 54 79 70  S INTEGER ), Typ
03e0: 65 4f 66 28 20 43 41 53 54 20 28 20 27 31 27 20  eOf( CAST ( '1' 
03f0: 41 53 20 49 4e 54 45 47 45 52 20 29 20 29 3b 0d  AS INTEGER ) );.
0400: 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 3c 74  .</verbatim>..<t
0410: 61 62 6c 65 20 62 6f 72 64 65 72 3d 22 31 22 20  able border="1" 
0420: 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20  cellspacing="4" 
0430: 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 34 22 3e  cellpadding="4">
0440: 0d 0a 3c 74 72 3e 3c 74 68 3e 27 31 27 3c 2f 74  ..<tr><th>'1'</t
0450: 68 3e 3c 74 68 3e 54 79 70 65 4f 66 28 20 27 31  h><th>TypeOf( '1
0460: 27 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 41 53 54  ' )</th><th>CAST
0470: 20 28 20 27 31 27 20 41 53 20 49 4e 54 45 47 45   ( '1' AS INTEGE
0480: 52 20 29 3c 2f 74 68 3e 3c 74 68 3e 54 79 70 65  R )</th><th>Type
0490: 4f 66 28 20 43 41 53 54 20 28 20 27 31 27 20 41  Of( CAST ( '1' A
04a0: 53 20 49 4e 54 45 47 45 52 20 29 20 29 3c 2f 74  S INTEGER ) )</t
04b0: 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64  h></tr>..<tr><td
04c0: 3e 31 3c 2f 74 64 3e 3c 74 64 3e 74 65 78 74 3c  >1</td><td>text<
04d0: 2f 74 64 3e 3c 74 64 20 61 6c 69 67 6e 3d 22 72  /td><td align="r
04e0: 69 67 68 74 22 3e 31 3c 2f 74 64 3e 3c 74 64 3e  ight">1</td><td>
04f0: 69 6e 74 65 67 65 72 3c 2f 74 64 3e 3c 2f 74 72  integer</td></tr
0500: 3e 3c 2f 74 61 62 6c 65 3e 3c 62 72 3e 0d 0a 54  ></table><br>..T
0510: 68 65 20 53 51 4c 20 3c 62 3e 43 41 53 54 3c 2f  he SQL <b>CAST</
0520: 62 3e 20 6f 70 65 72 61 74 6f 72 20 61 6c 72 65  b> operator alre
0530: 61 64 79 20 73 75 70 70 6f 72 74 73 20 74 68 65  ady supports the
0540: 20 70 6f 73 73 69 62 69 6c 69 74 79 20 74 6f 20   possibility to 
0550: 65 78 70 6c 69 63 69 74 6c 79 20 73 65 74 20 61  explicitly set a
0560: 20 64 61 74 61 2d 74 79 70 65 3b 20 6e 6f 77 20   data-type; now 
0570: 73 74 61 72 74 69 6e 67 20 73 69 6e 63 65 20 34  starting since 4
0580: 2e 31 2e 30 20 53 70 61 74 69 61 4c 69 74 65 20  .1.0 SpatiaLite 
0590: 73 75 70 70 6f 72 74 73 20 66 65 77 20 53 51 4c  supports few SQL
05a0: 20 66 75 6e 63 74 69 6f 6e 73 20 70 65 72 66 6f   functions perfo
05b0: 72 6d 69 6e 67 20 74 68 65 20 73 61 6d 65 20 74  rming the same t
05c0: 61 73 6b 2e 3c 62 72 3e 0d 0a 3c 75 3e 50 6c 65  ask.<br>..<u>Ple
05d0: 61 73 65 20 6e 6f 74 65 3c 2f 75 3e 3a 20 73 6f  ase note</u>: so
05e0: 6d 65 20 73 75 62 74 6c 65 20 64 69 66 66 65 72  me subtle differ
05f0: 65 6e 63 65 73 20 65 78 69 73 74 73 20 68 65 72  ences exists her
0600: 65 20 61 6e 64 20 74 68 65 72 65 3b 20 70 6c 65  e and there; ple
0610: 61 73 65 20 63 61 72 65 66 75 6c 6c 79 20 72 65  ase carefully re
0620: 61 64 20 74 68 69 73 20 64 6f 63 75 6d 65 6e 74  ad this document
0630: 61 74 69 6f 6e 20 70 61 67 65 2e 0d 0a 3c 76 65  ation page...<ve
0640: 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20  rbatim>..SELECT 
0650: 43 61 73 74 54 6f 49 6e 74 65 67 65 72 28 20 31  CastToInteger( 1
0660: 20 29 2c 20 43 61 73 74 54 6f 49 6e 74 65 67 65   ), CastToIntege
0670: 72 28 20 31 2e 34 20 29 2c 20 43 61 73 74 54 6f  r( 1.4 ), CastTo
0680: 49 6e 74 65 67 65 72 28 20 31 2e 36 20 29 2c 20  Integer( 1.6 ), 
0690: 0d 0a 20 20 20 20 43 61 73 74 54 6f 49 6e 74 65  ..    CastToInte
06a0: 67 65 72 28 20 27 31 32 33 27 20 29 2c 20 43 61  ger( '123' ), Ca
06b0: 73 74 54 6f 49 6e 74 65 67 65 72 28 20 27 61 6c  stToInteger( 'al
06c0: 70 68 61 27 20 29 2c 20 43 61 73 74 54 6f 49 6e  pha' ), CastToIn
06d0: 74 65 67 65 72 20 28 20 7a 65 72 6f 62 6c 6f 62  teger ( zeroblob
06e0: 28 34 29 20 29 3b 0d 0a 3c 2f 76 65 72 62 61 74  (4) );..</verbat
06f0: 69 6d 3e 0d 0a 3c 74 61 62 6c 65 20 62 6f 72 64  im>..<table bord
0700: 65 72 3d 22 31 22 20 63 65 6c 6c 73 70 61 63 69  er="1" cellspaci
0710: 6e 67 3d 22 34 22 20 63 65 6c 6c 70 61 64 64 69  ng="4" cellpaddi
0720: 6e 67 3d 22 34 22 3e 0d 0a 3c 74 72 3e 3c 74 68  ng="4">..<tr><th
0730: 3e 43 61 73 74 54 6f 49 6e 74 65 67 65 72 28 20  >CastToInteger( 
0740: 31 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 74  1 )</th><th>Cast
0750: 54 6f 49 6e 74 65 67 65 72 28 20 31 2e 34 20 29  ToInteger( 1.4 )
0760: 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 74 54 6f 49  </th><th>CastToI
0770: 6e 74 65 67 65 72 28 20 31 2e 36 20 29 3c 2f 74  nteger( 1.6 )</t
0780: 68 3e 3c 74 68 3e 43 61 73 74 54 6f 49 6e 74 65  h><th>CastToInte
0790: 67 65 72 28 20 27 31 32 33 27 20 29 3c 2f 74 68  ger( '123' )</th
07a0: 3e 3c 74 68 3e 43 61 73 74 54 6f 49 6e 74 65 67  ><th>CastToInteg
07b0: 65 72 28 20 27 61 6c 70 68 61 27 20 29 3c 2f 74  er( 'alpha' )</t
07c0: 68 3e 3c 74 68 3e 43 61 73 74 54 6f 49 6e 74 65  h><th>CastToInte
07d0: 67 65 72 20 28 20 7a 65 72 6f 62 6c 6f 62 28 34  ger ( zeroblob(4
07e0: 29 20 29 3c 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c  ) )</th></tr>..<
07f0: 74 72 3e 3c 74 64 20 61 6c 69 67 6e 3d 22 72 69  tr><td align="ri
0800: 67 68 74 22 3e 31 3c 2f 74 64 3e 3c 74 64 20 61  ght">1</td><td a
0810: 6c 69 67 6e 3d 22 72 69 67 68 74 22 3e 31 3c 2f  lign="right">1</
0820: 74 64 3e 3c 74 64 20 61 6c 69 67 6e 3d 22 72 69  td><td align="ri
0830: 67 68 74 22 3e 32 3c 2f 74 64 3e 3c 74 64 20 61  ght">2</td><td a
0840: 6c 69 67 6e 3d 22 72 69 67 68 74 22 3e 31 32 33  lign="right">123
0850: 3c 2f 74 64 3e 3c 74 64 3e 4e 55 4c 4c 3c 2f 74  </td><td>NULL</t
0860: 64 3e 3c 74 64 3e 4e 55 4c 4c 3c 2f 74 64 3e 3c  d><td>NULL</td><
0870: 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 3c 62 72 3e  /tr></table><br>
0880: 0d 0a 54 68 65 20 3c 62 3e 43 61 73 74 54 6f 49  ..The <b>CastToI
0890: 6e 74 65 67 65 72 28 29 3c 2f 62 3e 20 53 51 4c  nteger()</b> SQL
08a0: 20 66 75 6e 63 74 69 6f 6e 20 77 69 6c 6c 20 61   function will a
08b0: 74 74 65 6d 70 74 20 74 6f 20 72 65 74 75 72 6e  ttempt to return
08c0: 20 61 20 76 61 6c 75 65 20 6f 66 20 74 68 65 20   a value of the 
08d0: 3c 62 3e 49 6e 74 65 67 65 72 3c 2f 62 3e 20 64  <b>Integer</b> d
08e0: 61 74 61 2d 74 79 70 65 2c 20 6f 72 20 3c 62 3e  ata-type, or <b>
08f0: 4e 55 4c 4c 3c 2f 62 3e 20 69 66 20 6e 6f 20 63  NULL</b> if no c
0900: 6f 6e 76 65 72 73 69 6f 6e 20 69 73 20 70 6f 73  onversion is pos
0910: 73 69 62 6c 65 2e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c  sible...<ul>..<l
0920: 69 3e 61 6e 20 49 6e 74 65 67 65 72 20 69 6e 70  i>an Integer inp
0930: 75 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c  ut argument will
0940: 20 62 65 20 72 65 74 75 72 6e 65 64 20 61 62 73   be returned abs
0950: 6f 6c 75 74 65 6c 79 20 75 6e 61 66 66 65 63 74  olutely unaffect
0960: 65 64 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 20  ed.</li>..<li>a 
0970: 44 6f 75 62 6c 65 20 69 6e 70 75 74 20 61 72 67  Double input arg
0980: 75 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75 72  ument will retur
0990: 6e 20 74 68 65 20 3c 75 3e 6e 65 61 72 65 73 74  n the <u>nearest
09a0: 3c 2f 75 3e 20 49 6e 74 65 67 65 72 20 76 61 6c  </u> Integer val
09b0: 75 65 20 28 61 66 74 65 72 20 61 70 70 6c 79 69  ue (after applyi
09c0: 6e 67 20 3c 62 3e 34 2f 35 3c 2f 62 3e 20 72 6f  ng <b>4/5</b> ro
09d0: 75 6e 64 69 6e 67 29 2e 3c 2f 6c 69 3e 0d 0a 3c  unding).</li>..<
09e0: 6c 69 3e 61 20 54 65 78 74 20 69 6e 70 75 74 20  li>a Text input 
09f0: 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20 72 65  argument will re
0a00: 74 75 72 6e 20 74 68 65 20 63 6f 72 72 65 73 70  turn the corresp
0a10: 6f 6e 64 69 6e 67 20 49 6e 74 65 67 65 72 20 76  onding Integer v
0a20: 61 6c 75 65 20 6f 6e 6c 79 20 69 66 20 74 68 65  alue only if the
0a30: 20 74 65 78 74 20 73 74 72 69 6e 67 20 72 65 70   text string rep
0a40: 72 65 73 65 6e 74 73 20 61 20 76 61 6c 69 64 20  resents a valid 
0a50: 6e 75 6d 62 65 72 20 28 65 76 65 6e 20 61 20 64  number (even a d
0a60: 65 63 69 6d 61 6c 20 6f 6e 65 29 3a 20 69 66 20  ecimal one): if 
0a70: 74 68 65 20 74 65 78 74 20 73 74 72 69 6e 67 20  the text string 
0a80: 63 61 6e 6e 6f 74 20 62 65 20 63 6f 6e 76 65 72  cannot be conver
0a90: 74 65 64 20 74 6f 20 61 20 6e 75 6d 62 65 72 20  ted to a number 
0aa0: 4e 55 4c 4c 20 77 69 6c 6c 20 62 65 20 72 65 74  NULL will be ret
0ab0: 75 72 6e 65 64 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69  urned.</li>..<li
0ac0: 3e 61 6e 79 20 42 4c 4f 42 20 69 6e 70 75 74 20  >any BLOB input 
0ad0: 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20 72 65  argument will re
0ae0: 74 75 72 6e 20 61 20 4e 55 4c 4c 20 76 61 6c 75  turn a NULL valu
0af0: 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 6e 79  e.</li>..<li>any
0b00: 20 4e 55 4c 4c 20 69 6e 70 75 74 20 61 72 67 75   NULL input argu
0b10: 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 6e  ment will return
0b20: 20 61 20 4e 55 4c 4c 20 76 61 6c 75 65 2e 3c 2f   a NULL value.</
0b30: 6c 69 3e 0d 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d 0a  li>..</ul><br>..
0b40: 3c 68 72 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e  <hr>..<verbatim>
0b50: 0d 0a 53 45 4c 45 43 54 20 43 61 73 74 54 6f 44  ..SELECT CastToD
0b60: 6f 75 62 6c 65 28 20 31 20 29 2c 20 43 61 73 74  ouble( 1 ), Cast
0b70: 54 6f 44 6f 75 62 6c 65 28 20 31 2e 32 33 20 29  ToDouble( 1.23 )
0b80: 2c 20 43 61 73 74 54 6f 44 6f 75 62 6c 65 28 20  , CastToDouble( 
0b90: 27 31 32 33 2e 34 35 27 20 29 2c 0d 0a 20 20 20  '123.45' ),..   
0ba0: 20 43 61 73 74 54 6f 44 6f 75 62 6c 65 28 20 27   CastToDouble( '
0bb0: 61 6c 70 68 61 27 20 29 2c 20 43 61 73 74 54 6f  alpha' ), CastTo
0bc0: 44 6f 75 62 6c 65 20 28 20 7a 65 72 6f 62 6c 6f  Double ( zeroblo
0bd0: 62 28 34 29 20 29 3b 0d 0a 3c 2f 76 65 72 62 61  b(4) );..</verba
0be0: 74 69 6d 3e 0d 0a 3c 74 61 62 6c 65 20 62 6f 72  tim>..<table bor
0bf0: 64 65 72 3d 22 31 22 20 63 65 6c 6c 73 70 61 63  der="1" cellspac
0c00: 69 6e 67 3d 22 34 22 20 63 65 6c 6c 70 61 64 64  ing="4" cellpadd
0c10: 69 6e 67 3d 22 34 22 3e 0d 0a 3c 74 72 3e 3c 74  ing="4">..<tr><t
0c20: 68 3e 43 61 73 74 54 6f 44 6f 75 62 6c 65 28 20  h>CastToDouble( 
0c30: 31 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 74  1 )</th><th>Cast
0c40: 54 6f 44 6f 75 62 6c 65 28 20 31 2e 32 33 20 29  ToDouble( 1.23 )
0c50: 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 74 54 6f 44  </th><th>CastToD
0c60: 6f 75 62 6c 65 28 20 27 31 32 33 2e 34 35 27 20  ouble( '123.45' 
0c70: 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 74 54 6f  )</th><th>CastTo
0c80: 44 6f 75 62 6c 65 28 20 27 61 6c 70 68 61 27 20  Double( 'alpha' 
0c90: 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 74 54 6f  )</th><th>CastTo
0ca0: 44 6f 75 62 6c 65 20 28 20 7a 65 72 6f 62 6c 6f  Double ( zeroblo
0cb0: 62 28 34 29 20 29 3c 2f 74 68 3e 3c 2f 74 72 3e  b(4) )</th></tr>
0cc0: 0d 0a 3c 74 72 3e 3c 74 64 20 61 6c 69 67 6e 3d  ..<tr><td align=
0cd0: 22 72 69 67 68 74 22 3e 31 2e 30 30 30 30 30 30  "right">1.000000
0ce0: 3c 2f 74 64 3e 3c 74 64 20 61 6c 69 67 6e 3d 22  </td><td align="
0cf0: 72 69 67 68 74 22 3e 31 2e 32 33 30 30 30 30 3c  right">1.230000<
0d00: 2f 74 64 3e 3c 74 64 20 61 6c 69 67 6e 3d 22 72  /td><td align="r
0d10: 69 67 68 74 22 3e 31 32 33 2e 34 35 30 30 30 3c  ight">123.45000<
0d20: 2f 74 64 3e 3c 74 64 3e 4e 55 4c 4c 3c 2f 74 64  /td><td>NULL</td
0d30: 3e 3c 74 64 3e 4e 55 4c 4c 3c 2f 74 64 3e 3c 2f  ><td>NULL</td></
0d40: 74 72 3e 3c 2f 74 61 62 6c 65 3e 3c 62 72 3e 0d  tr></table><br>.
0d50: 0a 54 68 65 20 3c 62 3e 43 61 73 74 54 6f 44 6f  .The <b>CastToDo
0d60: 75 62 6c 65 28 29 3c 2f 62 3e 20 53 51 4c 20 66  uble()</b> SQL f
0d70: 75 6e 63 74 69 6f 6e 20 77 69 6c 6c 20 61 74 74  unction will att
0d80: 65 6d 70 74 20 74 6f 20 72 65 74 75 72 6e 20 61  empt to return a
0d90: 20 76 61 6c 75 65 20 6f 66 20 74 68 65 20 3c 62   value of the <b
0da0: 3e 44 6f 75 62 6c 65 3c 2f 62 3e 20 64 61 74 61  >Double</b> data
0db0: 2d 74 79 70 65 2c 20 6f 72 20 3c 62 3e 4e 55 4c  -type, or <b>NUL
0dc0: 4c 3c 2f 62 3e 20 69 66 20 6e 6f 20 63 6f 6e 76  L</b> if no conv
0dd0: 65 72 73 69 6f 6e 20 69 73 20 70 6f 73 73 69 62  ersion is possib
0de0: 6c 65 2e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 61  le...<ul>..<li>a
0df0: 6e 20 49 6e 74 65 67 65 72 20 69 6e 70 75 74 20  n Integer input 
0e00: 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20 72 65  argument will re
0e10: 74 75 72 6e 20 74 68 65 20 63 6f 72 72 65 73 70  turn the corresp
0e20: 6f 6e 64 69 6e 67 20 44 6f 75 62 6c 65 20 76 61  onding Double va
0e30: 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61  lue.</li>..<li>a
0e40: 20 44 6f 75 62 6c 65 20 69 6e 70 75 74 20 61 72   Double input ar
0e50: 67 75 6d 65 6e 74 20 77 69 6c 6c 20 62 65 20 72  gument will be r
0e60: 65 74 75 72 6e 65 64 20 61 62 73 6f 6c 75 74 65  eturned absolute
0e70: 6c 79 20 75 6e 61 66 66 65 63 74 65 64 2e 3c 2f  ly unaffected.</
0e80: 6c 69 3e 0d 0a 3c 6c 69 3e 61 20 54 65 78 74 20  li>..<li>a Text 
0e90: 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 20 77  input argument w
0ea0: 69 6c 6c 20 72 65 74 75 72 6e 20 74 68 65 20 63  ill return the c
0eb0: 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20 44 6f 75  orresponding Dou
0ec0: 62 6c 65 20 76 61 6c 75 65 20 6f 6e 6c 79 20 69  ble value only i
0ed0: 66 20 74 68 65 20 74 65 78 74 20 73 74 72 69 6e  f the text strin
0ee0: 67 20 72 65 70 72 65 73 65 6e 74 73 20 61 20 76  g represents a v
0ef0: 61 6c 69 64 20 6e 75 6d 62 65 72 3a 20 69 66 20  alid number: if 
0f00: 74 68 65 20 74 65 78 74 20 73 74 72 69 6e 67 20  the text string 
0f10: 63 61 6e 6e 6f 74 20 62 65 20 63 6f 6e 76 65 72  cannot be conver
0f20: 74 65 64 20 74 6f 20 61 20 6e 75 6d 62 65 72 20  ted to a number 
0f30: 4e 55 4c 4c 20 77 69 6c 6c 20 62 65 20 72 65 74  NULL will be ret
0f40: 75 72 6e 65 64 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69  urned.</li>..<li
0f50: 3e 61 6e 79 20 42 4c 4f 42 20 69 6e 70 75 74 20  >any BLOB input 
0f60: 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20 72 65  argument will re
0f70: 74 75 72 6e 20 61 20 4e 55 4c 4c 20 76 61 6c 75  turn a NULL valu
0f80: 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 6e 79  e.</li>..<li>any
0f90: 20 4e 55 4c 4c 20 69 6e 70 75 74 20 61 72 67 75   NULL input argu
0fa0: 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 6e  ment will return
0fb0: 20 61 20 4e 55 4c 4c 20 76 61 6c 75 65 2e 3c 2f   a NULL value.</
0fc0: 6c 69 3e 0d 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d 0a  li>..</ul><br>..
0fd0: 3c 68 72 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e  <hr>..<verbatim>
0fe0: 0d 0a 53 45 4c 45 43 54 20 43 61 73 74 54 6f 54  ..SELECT CastToT
0ff0: 65 78 74 28 20 31 20 29 2c 20 43 61 73 74 54 6f  ext( 1 ), CastTo
1000: 54 65 78 74 28 20 31 2e 35 20 29 2c 20 43 61 73  Text( 1.5 ), Cas
1010: 74 54 6f 54 65 78 74 28 20 27 61 6c 70 68 61 27  tToText( 'alpha'
1020: 20 29 2c 20 43 61 73 74 54 6f 54 65 78 74 20 28   ), CastToText (
1030: 20 7a 65 72 6f 62 6c 6f 62 28 34 29 20 29 3b 0d   zeroblob(4) );.
1040: 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 3c 74  .</verbatim>..<t
1050: 61 62 6c 65 20 62 6f 72 64 65 72 3d 22 31 22 20  able border="1" 
1060: 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20  cellspacing="4" 
1070: 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 34 22 3e  cellpadding="4">
1080: 0d 0a 3c 74 72 3e 3c 74 68 3e 43 61 73 74 54 6f  ..<tr><th>CastTo
1090: 54 65 78 74 28 20 31 20 29 3c 2f 74 68 3e 3c 74  Text( 1 )</th><t
10a0: 68 3e 43 61 73 74 54 6f 54 65 78 74 28 20 31 2e  h>CastToText( 1.
10b0: 35 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 74  5 )</th><th>Cast
10c0: 54 6f 54 65 78 74 28 20 27 61 6c 70 68 61 27 20  ToText( 'alpha' 
10d0: 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 74 54 6f  )</th><th>CastTo
10e0: 54 65 78 74 20 28 20 7a 65 72 6f 62 6c 6f 62 28  Text ( zeroblob(
10f0: 34 29 20 29 3c 2f 74 68 3e 3c 2f 74 72 3e 0d 0a  4) )</th></tr>..
1100: 3c 74 72 3e 3c 74 64 3e 31 3c 2f 74 64 3e 3c 74  <tr><td>1</td><t
1110: 64 3e 31 2e 35 3c 2f 74 64 3e 3c 74 64 3e 61 6c  d>1.5</td><td>al
1120: 70 68 61 3c 2f 74 64 3e 3c 74 64 3e 4e 55 4c 4c  pha</td><td>NULL
1130: 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c  </td></tr></tabl
1140: 65 3e 3c 62 72 3e 0d 0a 54 68 65 20 3c 62 3e 43  e><br>..The <b>C
1150: 61 73 74 54 6f 54 65 78 74 28 29 3c 2f 62 3e 20  astToText()</b> 
1160: 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 77 69 6c  SQL function wil
1170: 6c 20 61 74 74 65 6d 70 74 20 74 6f 20 72 65 74  l attempt to ret
1180: 75 72 6e 20 61 20 76 61 6c 75 65 20 6f 66 20 74  urn a value of t
1190: 68 65 20 3c 62 3e 54 65 78 74 3c 2f 62 3e 20 64  he <b>Text</b> d
11a0: 61 74 61 2d 74 79 70 65 2c 20 6f 72 20 3c 62 3e  ata-type, or <b>
11b0: 4e 55 4c 4c 3c 2f 62 3e 20 69 66 20 6e 6f 20 63  NULL</b> if no c
11c0: 6f 6e 76 65 72 73 69 6f 6e 20 69 73 20 70 6f 73  onversion is pos
11d0: 73 69 62 6c 65 2e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c  sible...<ul>..<l
11e0: 69 3e 61 6e 20 49 6e 74 65 67 65 72 20 69 6e 70  i>an Integer inp
11f0: 75 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c  ut argument will
1200: 20 72 65 74 75 72 6e 20 74 68 65 20 63 6f 72 72   return the corr
1210: 65 73 70 6f 6e 64 69 6e 67 20 54 65 78 74 20 76  esponding Text v
1220: 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e  alue.</li>..<li>
1230: 61 20 44 6f 75 62 6c 65 20 69 6e 70 75 74 20 61  a Double input a
1240: 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20 62 65 20  rgument will be 
1250: 72 65 74 75 72 6e 20 74 68 65 20 63 6f 72 72 65  return the corre
1260: 73 70 6f 6e 64 69 6e 67 20 54 65 78 74 20 76 61  sponding Text va
1270: 6c 75 65 3b 20 6e 6f 20 73 69 67 6e 69 66 69 63  lue; no signific
1280: 61 6e 74 20 64 65 63 69 6d 61 6c 20 64 69 67 69  ant decimal digi
1290: 74 20 77 69 6c 6c 20 62 65 20 73 75 70 70 72 65  t will be suppre
12a0: 73 73 65 64 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e  ssed.</li>..<li>
12b0: 61 20 54 65 78 74 20 69 6e 70 75 74 20 61 72 67  a Text input arg
12c0: 75 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75 72  ument will retur
12d0: 6e 20 74 68 65 20 63 6f 72 72 65 73 70 6f 6e 64  n the correspond
12e0: 69 6e 67 20 44 6f 75 62 6c 65 20 76 61 6c 75 65  ing Double value
12f0: 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 6e 79 20  .</li>..<li>any 
1300: 42 4c 4f 42 20 69 6e 70 75 74 20 61 72 67 75 6d  BLOB input argum
1310: 65 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 6e 20  ent will return 
1320: 61 20 4e 55 4c 4c 20 76 61 6c 75 65 2e 3c 2f 6c  a NULL value.</l
1330: 69 3e 0d 0a 3c 6c 69 3e 61 6e 79 20 4e 55 4c 4c  i>..<li>any NULL
1340: 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 20   input argument 
1350: 77 69 6c 6c 20 72 65 74 75 72 6e 20 61 20 4e 55  will return a NU
1360: 4c 4c 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a  LL value.</li>..
1370: 3c 2f 75 6c 3e 0d 0a 3c 76 65 72 62 61 74 69 6d  </ul>..<verbatim
1380: 3e 0d 0a 53 45 4c 45 43 54 20 43 61 73 74 54 6f  >..SELECT CastTo
1390: 54 65 78 74 28 20 31 2c 20 34 20 29 2c 20 43 61  Text( 1, 4 ), Ca
13a0: 73 74 54 6f 54 65 78 74 28 20 31 32 33 34 2c 20  stToText( 1234, 
13b0: 32 20 29 2c 20 43 61 73 74 54 6f 54 65 78 74 28  2 ), CastToText(
13c0: 20 31 2c 20 38 20 29 2c 20 43 61 73 74 54 6f 54   1, 8 ), CastToT
13d0: 65 78 74 28 20 31 2e 35 2c 20 34 20 29 3b 0d 0a  ext( 1.5, 4 );..
13e0: 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 3c 74 61  </verbatim>..<ta
13f0: 62 6c 65 20 62 6f 72 64 65 72 3d 22 31 22 20 63  ble border="1" c
1400: 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63  ellspacing="4" c
1410: 65 6c 6c 70 61 64 64 69 6e 67 3d 22 34 22 3e 0d  ellpadding="4">.
1420: 0a 3c 74 72 3e 3c 74 68 3e 43 61 73 74 54 6f 54  .<tr><th>CastToT
1430: 65 78 74 28 20 31 2c 20 34 20 29 3c 2f 74 68 3e  ext( 1, 4 )</th>
1440: 3c 74 68 3e 43 61 73 74 54 6f 54 65 78 74 28 20  <th>CastToText( 
1450: 31 32 33 34 2c 20 32 20 29 3c 2f 74 68 3e 3c 74  1234, 2 )</th><t
1460: 68 3e 43 61 73 74 54 6f 54 65 78 74 28 20 31 2c  h>CastToText( 1,
1470: 20 38 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 73   8 )</th><th>Cas
1480: 74 54 6f 54 65 78 74 28 20 31 2e 35 2c 20 34 20  tToText( 1.5, 4 
1490: 29 3c 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 72  )</th></tr>..<tr
14a0: 3e 3c 74 64 3e 30 30 30 31 3c 2f 74 64 3e 3c 74  ><td>0001</td><t
14b0: 64 3e 31 32 33 34 3c 2f 74 64 3e 3c 74 64 3e 30  d>1234</td><td>0
14c0: 30 30 30 30 30 30 31 3c 2f 74 64 3e 3c 74 64 3e  0000001</td><td>
14d0: 30 30 30 31 2e 35 3c 2f 74 64 3e 3c 2f 74 72 3e  0001.5</td></tr>
14e0: 3c 2f 74 61 62 6c 65 3e 3c 62 72 3e 0d 0a 41 6e  </table><br>..An
14f0: 20 6f 76 65 72 6c 6f 61 64 65 64 20 76 65 72 73   overloaded vers
1500: 69 6f 6e 20 6f 66 20 3c 62 3e 43 61 73 74 54 6f  ion of <b>CastTo
1510: 54 65 78 74 28 29 3c 2f 62 3e 20 69 73 20 73 75  Text()</b> is su
1520: 70 70 6f 72 74 65 64 20 61 73 20 77 65 6c 6c 2c  pported as well,
1530: 20 62 75 74 20 6f 6e 6c 79 20 77 68 65 6e 20 74   but only when t
1540: 68 65 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e  he input argumen
1550: 74 20 69 73 20 6f 66 20 74 68 65 20 49 6e 74 65  t is of the Inte
1560: 67 65 72 20 6f 72 20 44 6f 75 62 6c 65 20 64 61  ger or Double da
1570: 74 61 2d 74 79 70 65 3a 20 69 6e 20 74 68 69 73  ta-type: in this
1580: 20 63 61 73 65 20 61 20 73 65 63 6f 6e 64 20 49   case a second I
1590: 6e 74 65 67 65 72 20 61 72 67 75 6d 65 6e 74 20  nteger argument 
15a0: 63 6f 75 6c 64 20 62 65 20 6f 70 74 69 6f 6e 61  could be optiona
15b0: 6c 6c 79 20 73 70 65 63 69 66 69 65 64 2c 20 61  lly specified, a
15c0: 6e 64 20 77 69 6c 6c 20 62 65 20 69 6e 74 65 72  nd will be inter
15d0: 70 72 65 74 65 64 20 61 64 20 3c 62 3e 7a 65 72  preted ad <b>zer
15e0: 6f 2d 70 61 64 64 69 6e 67 2d 6c 65 6e 67 74 68  o-padding-length
15f0: 3c 2f 62 3e 2e 3c 62 72 3e 0d 0a 69 2e 65 2e 20  </b>.<br>..i.e. 
1600: 74 68 65 20 72 65 74 75 72 6e 65 64 20 54 65 78  the returned Tex
1610: 74 20 73 74 72 69 6e 67 20 69 6e 20 74 68 69 73  t string in this
1620: 20 63 61 73 65 20 77 69 6c 6c 20 68 61 76 65 20   case will have 
1630: 61 6e 20 69 6e 74 65 67 65 72 20 70 61 72 74 20  an integer part 
1640: 61 74 20 6c 65 61 73 74 20 6f 66 20 74 68 65 20  at least of the 
1650: 73 70 65 63 69 66 69 65 64 20 6c 65 6e 67 74 68  specified length
1660: 2c 20 61 6e 64 20 65 76 65 6e 74 75 61 6c 6c 79  , and eventually
1670: 20 70 61 64 64 65 64 20 62 79 20 69 6e 73 65 72   padded by inser
1680: 74 69 6e 67 20 6e 6f 74 20 73 69 67 6e 69 66 69  ting not signifi
1690: 63 61 6e 74 20 6c 65 61 64 69 6e 67 20 5a 45 52  cant leading ZER
16a0: 4f 65 73 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68  Oes.<br><br>..<h
16b0: 72 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a  r>..<verbatim>..
16c0: 53 45 4c 45 43 54 20 43 61 73 74 54 6f 42 6c 6f  SELECT CastToBlo
16d0: 62 28 20 31 20 29 2c 20 43 61 73 74 54 6f 42 6c  b( 1 ), CastToBl
16e0: 6f 62 28 20 31 2e 35 20 29 2c 20 48 65 78 28 20  ob( 1.5 ), Hex( 
16f0: 43 61 73 74 54 6f 42 6c 6f 62 28 20 27 61 6c 70  CastToBlob( 'alp
1700: 68 61 27 20 29 20 29 2c 20 48 65 78 20 28 20 43  ha' ) ), Hex ( C
1710: 61 73 74 54 6f 42 6c 6f 62 20 28 20 7a 65 72 6f  astToBlob ( zero
1720: 62 6c 6f 62 28 34 29 20 29 20 29 3b 0d 0a 3c 2f  blob(4) ) );..</
1730: 76 65 72 62 61 74 69 6d 3e 0d 0a 3c 74 61 62 6c  verbatim>..<tabl
1740: 65 20 62 6f 72 64 65 72 3d 22 31 22 20 63 65 6c  e border="1" cel
1750: 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63 65 6c  lspacing="4" cel
1760: 6c 70 61 64 64 69 6e 67 3d 22 34 22 3e 0d 0a 3c  lpadding="4">..<
1770: 74 72 3e 3c 74 68 3e 43 61 73 74 54 6f 42 6c 6f  tr><th>CastToBlo
1780: 62 28 20 31 20 29 3c 2f 74 68 3e 3c 74 68 3e 43  b( 1 )</th><th>C
1790: 61 73 74 54 6f 42 6c 6f 62 28 20 31 2e 35 20 29  astToBlob( 1.5 )
17a0: 3c 2f 74 68 3e 3c 74 68 3e 48 65 78 28 20 43 61  </th><th>Hex( Ca
17b0: 73 74 54 6f 42 6c 6f 62 28 20 27 61 6c 70 68 61  stToBlob( 'alpha
17c0: 27 20 29 20 29 3c 2f 74 68 3e 3c 74 68 3e 48 65  ' ) )</th><th>He
17d0: 78 28 20 43 61 73 74 54 6f 54 65 78 74 20 28 20  x( CastToText ( 
17e0: 7a 65 72 6f 62 6c 6f 62 28 34 29 20 29 20 29 3c  zeroblob(4) ) )<
17f0: 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c  /th></tr>..<tr><
1800: 74 64 3e 4e 55 4c 4c 3c 2f 74 64 3e 3c 74 64 3e  td>NULL</td><td>
1810: 4e 55 4c 4c 3c 2f 74 64 3e 3c 74 64 3e 36 31 36  NULL</td><td>616
1820: 43 37 30 36 38 36 31 3c 2f 74 64 3e 3c 74 64 3e  C706861</td><td>
1830: 30 30 30 30 30 30 30 30 3c 2f 74 64 3e 3c 2f 74  00000000</td></t
1840: 72 3e 3c 2f 74 61 62 6c 65 3e 3c 62 72 3e 0d 0a  r></table><br>..
1850: 54 68 65 20 3c 62 3e 43 61 73 74 54 6f 42 6c 6f  The <b>CastToBlo
1860: 62 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63  b()</b> SQL func
1870: 74 69 6f 6e 20 77 69 6c 6c 20 61 74 74 65 6d 70  tion will attemp
1880: 74 20 74 6f 20 72 65 74 75 72 6e 20 61 20 76 61  t to return a va
1890: 6c 75 65 20 6f 66 20 74 68 65 20 3c 62 3e 42 4c  lue of the <b>BL
18a0: 4f 42 3c 2f 62 3e 20 64 61 74 61 2d 74 79 70 65  OB</b> data-type
18b0: 2c 20 6f 72 20 3c 62 3e 4e 55 4c 4c 3c 2f 62 3e  , or <b>NULL</b>
18c0: 20 69 66 20 6e 6f 20 63 6f 6e 76 65 72 73 69 6f   if no conversio
18d0: 6e 20 69 73 20 70 6f 73 73 69 62 6c 65 2e 0d 0a  n is possible...
18e0: 3c 75 6c 3e 0d 0a 3c 6c 69 3e 61 6e 20 49 6e 74  <ul>..<li>an Int
18f0: 65 67 65 72 20 69 6e 70 75 74 20 61 72 67 75 6d  eger input argum
1900: 65 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 6e 20  ent will return 
1910: 61 20 4e 55 4c 4c 20 76 61 6c 75 65 2e 3c 2f 6c  a NULL value.</l
1920: 69 3e 0d 0a 3c 6c 69 3e 61 20 44 6f 75 62 6c 65  i>..<li>a Double
1930: 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 20   input argument 
1940: 77 69 6c 6c 20 72 65 74 75 72 6e 20 61 20 4e 55  will return a NU
1950: 4c 4c 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a  LL value.</li>..
1960: 3c 6c 69 3e 61 20 54 65 78 74 20 69 6e 70 75 74  <li>a Text input
1970: 20 61 72 67 75 6d 65 6e 74 20 20 77 69 6c 6c 20   argument  will 
1980: 72 65 74 75 72 6e 20 74 68 65 20 63 6f 72 72 65  return the corre
1990: 73 70 6f 6e 64 69 6e 67 20 42 4c 4f 42 20 76 61  sponding BLOB va
19a0: 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61  lue.</li>..<li>a
19b0: 6e 79 20 42 4c 4f 42 20 69 6e 70 75 74 20 61 72  ny BLOB input ar
19c0: 67 75 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75  gument will retu
19d0: 72 6e 20 74 68 65 20 63 6f 72 72 65 73 70 6f 6e  rn the correspon
19e0: 64 69 6e 67 20 42 4c 4f 42 20 76 61 6c 75 65 2e  ding BLOB value.
19f0: 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 6e 79 20 4e  </li>..<li>any N
1a00: 55 4c 4c 20 69 6e 70 75 74 20 61 72 67 75 6d 65  ULL input argume
1a10: 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 61  nt will return a
1a20: 20 4e 55 4c 4c 20 76 61 6c 75 65 2e 3c 2f 6c 69   NULL value.</li
1a30: 3e 0d 0a 3c 2f 75 6c 3e 0d 0a 3c 76 65 72 62 61  >..</ul>..<verba
1a40: 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 48 65 78  tim>..SELECT Hex
1a50: 28 20 43 61 73 74 54 6f 42 6c 6f 62 28 20 27 30  ( CastToBlob( '0
1a60: 31 32 33 34 35 36 37 38 39 61 42 63 44 65 46 66  123456789aBcDeFf
1a70: 45 64 43 62 41 39 38 37 36 35 34 33 32 31 30 27  EdCbA9876543210'
1a80: 2c 20 31 20 29 20 29 3b 0d 0a 2d 2d 2d 2d 2d 0d  , 1 ) );..-----.
1a90: 0a 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45  .0123456789ABCDE
1aa0: 46 46 45 44 43 42 41 39 38 37 36 35 34 33 32 31  FFEDCBA987654321
1ab0: 30 0d 0a 0d 0a 53 45 4c 45 43 54 20 43 61 73 74  0....SELECT Cast
1ac0: 54 6f 42 6c 6f 62 28 20 27 31 32 66 27 2c 20 31  ToBlob( '12f', 1
1ad0: 20 29 3b 0d 0a 2d 2d 2d 2d 2d 0d 0a 4e 55 4c 4c   );..-----..NULL
1ae0: 0d 0a 0d 0a 53 45 4c 45 43 54 20 43 61 73 74 54  ....SELECT CastT
1af0: 6f 42 6c 6f 62 28 20 27 31 32 48 46 27 2c 20 31  oBlob( '12HF', 1
1b00: 20 29 3b 0d 0a 2d 2d 2d 2d 2d 0d 0a 4e 55 4c 4c   );..-----..NULL
1b10: 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 41  ..</verbatim>..A
1b20: 20 73 65 63 6f 6e 64 20 6f 76 65 72 6c 6f 61 64   second overload
1b30: 65 64 20 76 65 72 73 69 6f 6e 20 6f 66 20 3c 62  ed version of <b
1b40: 3e 43 61 73 74 54 6f 42 6c 6f 62 28 29 3c 2f 62  >CastToBlob()</b
1b50: 3e 20 69 73 20 73 75 70 70 6f 72 74 65 64 20 61  > is supported a
1b60: 73 20 77 65 6c 6c 3b 20 62 79 20 73 70 65 63 69  s well; by speci
1b70: 66 79 69 6e 67 20 61 20 66 75 72 74 68 65 72 20  fying a further 
1b80: 3c 62 3e 68 65 78 5f 69 6e 70 75 74 3c 2f 62 3e  <b>hex_input</b>
1b90: 20 3c 75 3e 62 6f 6f 6c 65 61 6e 3c 2f 75 3e 20   <u>boolean</u> 
1ba0: 61 72 67 75 6d 65 6e 74 20 73 65 74 20 61 73 20  argument set as 
1bb0: 3c 62 3e 54 52 55 45 3c 2f 62 3e 20 74 68 65 20  <b>TRUE</b> the 
1bc0: 69 6e 70 75 74 20 73 74 72 69 6e 67 20 77 69 6c  input string wil
1bd0: 6c 20 62 65 20 61 73 73 75 6d 65 64 20 74 6f 20  l be assumed to 
1be0: 62 65 20 3c 75 3e 48 65 78 61 64 65 63 69 6d 61  be <u>Hexadecima
1bf0: 6c 6c 79 20 65 6e 63 6f 64 65 64 3c 2f 75 3e 2e  lly encoded</u>.
1c00: 20 49 6e 20 74 68 69 73 20 63 61 73 65 20 4e 55   In this case NU
1c10: 4c 4c 20 77 69 6c 6c 20 62 65 20 72 65 74 75 72  LL will be retur
1c20: 6e 65 64 20 69 66 20 74 68 65 20 69 6e 70 75 74  ned if the input
1c30: 20 73 74 72 69 6e 67 20 64 6f 65 73 6e 27 74 20   string doesn't 
1c40: 63 6f 72 72 65 73 70 6f 6e 64 73 20 74 6f 20 61  corresponds to a
1c50: 20 76 61 6c 69 64 20 48 65 78 61 64 65 63 69 6d   valid Hexadecim
1c60: 61 6c 20 6e 6f 74 61 74 69 6f 6e 2e 3c 62 72 3e  al notation.<br>
1c70: 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72  <br>..<hr>..<ver
1c80: 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 46  batim>..SELECT F
1c90: 6f 72 63 65 41 73 4e 75 6c 6c 28 20 27 61 27 2c  orceAsNull( 'a',
1ca0: 20 27 62 27 20 29 2c 20 46 6f 72 63 65 41 73 4e   'b' ), ForceAsN
1cb0: 75 6c 6c 28 20 27 61 62 63 64 27 2c 20 27 61 62  ull( 'abcd', 'ab
1cc0: 63 64 27 20 29 2c 20 46 6f 72 63 65 41 73 4e 75  cd' ), ForceAsNu
1cd0: 6c 6c 28 20 31 2c 20 31 29 2c 20 46 6f 72 63 65  ll( 1, 1), Force
1ce0: 41 73 4e 75 6c 6c 28 20 31 2e 31 2c 20 31 20 29  AsNull( 1.1, 1 )
1cf0: 3b 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a  ;..</verbatim>..
1d00: 3c 74 61 62 6c 65 20 62 6f 72 64 65 72 3d 22 31  <table border="1
1d10: 22 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34  " cellspacing="4
1d20: 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 34  " cellpadding="4
1d30: 22 3e 0d 0a 3c 74 72 3e 3c 74 68 3e 46 6f 72 63  ">..<tr><th>Forc
1d40: 65 41 73 4e 75 6c 6c 28 20 27 61 27 2c 20 27 62  eAsNull( 'a', 'b
1d50: 27 20 29 3c 2f 74 68 3e 3c 74 68 3e 46 6f 72 63  ' )</th><th>Forc
1d60: 65 41 73 4e 75 6c 6c 28 20 27 61 62 63 64 27 2c  eAsNull( 'abcd',
1d70: 20 27 61 62 63 64 27 20 29 3c 2f 74 68 3e 3c 74   'abcd' )</th><t
1d80: 68 3e 46 6f 72 63 65 41 73 4e 75 6c 6c 28 20 31  h>ForceAsNull( 1
1d90: 2c 20 31 29 3c 2f 74 68 3e 3c 74 68 3e 46 6f 72  , 1)</th><th>For
1da0: 63 65 41 73 4e 75 6c 6c 28 20 31 2e 31 2c 20 2d  ceAsNull( 1.1, -
1db0: 39 39 39 39 20 29 3c 2f 74 68 3e 3c 2f 74 72 3e  9999 )</th></tr>
1dc0: 0d 0a 3c 74 72 3e 3c 74 64 3e 61 3c 2f 74 64 3e  ..<tr><td>a</td>
1dd0: 3c 74 64 3e 4e 55 4c 4c 3c 2f 74 64 3e 3c 74 64  <td>NULL</td><td
1de0: 3e 4e 55 4c 4c 3c 2f 74 64 3e 3c 74 64 20 61 6c  >NULL</td><td al
1df0: 69 67 6e 3d 22 72 69 67 68 74 22 3e 31 2e 31 3c  ign="right">1.1<
1e00: 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65  /td></tr></table
1e10: 3e 3c 62 72 3e 0d 0a 54 68 65 20 3c 62 3e 46 6f  ><br>..The <b>Fo
1e20: 72 63 65 41 73 4e 75 6c 6c 28 29 3c 2f 62 3e 20  rceAsNull()</b> 
1e30: 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 77 69 6c  SQL function wil
1e40: 6c 20 65 76 61 6c 75 61 74 65 20 74 77 6f 20 61  l evaluate two a
1e50: 72 62 69 74 72 61 72 79 20 61 72 67 75 6d 65 6e  rbitrary argumen
1e60: 74 73 2e 3c 62 72 3e 0d 0a 49 66 20 74 68 65 79  ts.<br>..If they
1e70: 20 61 72 65 20 65 71 75 61 6c 20 61 6e 64 20 65   are equal and e
1e80: 78 61 63 74 6c 79 20 6f 66 20 74 68 65 20 73 61  xactly of the sa
1e90: 6d 65 20 64 61 74 61 2d 74 79 70 65 20 4e 55 4c  me data-type NUL
1ea0: 4c 20 77 69 6c 6c 20 62 65 20 72 65 74 75 72 6e  L will be return
1eb0: 65 64 3b 20 6f 74 68 65 72 77 69 73 65 20 74 68  ed; otherwise th
1ec0: 65 20 66 69 72 73 74 20 61 72 67 75 6d 65 6e 74  e first argument
1ed0: 20 76 61 6c 75 65 20 77 69 6c 6c 20 62 65 20 72   value will be r
1ee0: 65 74 75 72 6e 65 64 2e 3c 62 72 3e 0d 0a 55 73  eturned.<br>..Us
1ef0: 65 66 75 6c 20 65 2e 67 2e 20 77 68 69 6c 65 20  eful e.g. while 
1f00: 70 72 6f 63 65 73 73 69 6e 67 20 64 61 74 61 20  processing data 
1f10: 69 6d 70 6f 72 74 65 64 20 66 72 6f 6d 20 61 6e  imported from an
1f20: 79 20 3c 62 3e 53 68 61 70 65 66 69 6c 65 3c 2f  y <b>Shapefile</
1f30: 62 3e 20 6f 72 20 3c 62 3e 44 42 46 20 66 69 6c  b> or <b>DBF fil
1f40: 65 3c 2f 62 3e 20 28 73 75 63 68 20 66 6f 72 6d  e</b> (such form
1f50: 61 74 73 20 64 6f 65 73 6e 27 74 20 73 75 70 70  ats doesn't supp
1f60: 6f 72 74 20 61 6e 79 20 72 65 61 6c 20 4e 55 4c  ort any real NUL
1f70: 4c 20 76 61 6c 75 65 2c 20 6f 66 74 65 6e 20 62  L value, often b
1f80: 65 69 6e 67 20 72 65 70 6c 61 63 65 64 20 62 79  eing replaced by
1f90: 20 73 6f 6d 65 20 63 6f 6e 76 65 6e 74 69 6f 6e   some convention
1fa0: 61 6c 20 76 61 6c 75 65 20 65 2e 67 2e 20 3c 62  al value e.g. <b
1fb0: 3e 30 3c 2f 62 3e 20 6f 72 20 3c 62 3e 2d 39 39  >0</b> or <b>-99
1fc0: 39 39 3c 2f 62 3e 20 61 6e 64 20 61 6c 69 6b 65  99</b> and alike
1fd0: 29 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68 72 3e  ).<br><br>..<hr>
1fe0: 0d 0a 3c 68 33 3e 3c 61 20 6e 61 6d 65 3d 22 75  ..<h3><a name="u
1ff0: 75 69 64 22 3e 47 65 6e 65 72 69 63 3c 2f 61 3e  uid">Generic</a>
2000: 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 2d 20   SQL function - 
2010: 55 55 49 44 20 67 65 6e 65 72 61 74 6f 72 3c 2f  UUID generator</
2020: 68 33 3e 0d 0a 41 6e 20 3c 61 20 68 72 65 66 3d  h3>..An <a href=
2030: 22 68 74 74 70 3a 2f 2f 65 6e 2e 77 69 6b 69 70  "http://en.wikip
2040: 65 64 69 61 2e 6f 72 67 2f 77 69 6b 69 2f 55 6e  edia.org/wiki/Un
2050: 69 76 65 72 73 61 6c 6c 79 5f 75 6e 69 71 75 65  iversally_unique
2060: 5f 69 64 65 6e 74 69 66 69 65 72 22 3e 55 6e 69  _identifier">Uni
2070: 76 65 72 73 61 6c 6c 79 20 75 6e 69 71 75 65 20  versally unique 
2080: 69 64 65 6e 74 69 66 69 65 72 3c 2f 61 3e 20 28  identifier</a> (
2090: 61 6b 61 20 3c 62 3e 55 55 49 44 3c 2f 62 3e 29  aka <b>UUID</b>)
20a0: 20 73 69 6d 70 6c 79 20 69 73 20 61 20 3c 75 3e   simply is a <u>
20b0: 31 32 38 20 62 69 74 3c 2f 75 3e 20 49 6e 74 65  128 bit</u> Inte
20c0: 67 65 72 3b 20 61 63 63 6f 72 64 69 6e 67 6c 79  ger; accordingly
20d0: 20 74 6f 20 3c 61 20 68 72 65 66 3d 22 68 74 74   to <a href="htt
20e0: 70 3a 2f 2f 65 6e 2e 77 69 6b 69 70 65 64 69 61  p://en.wikipedia
20f0: 2e 6f 72 67 2f 77 69 6b 69 2f 55 55 49 44 23 52  .org/wiki/UUID#R
2100: 61 6e 64 6f 6d 5f 55 55 49 44 5f 70 72 6f 62 61  andom_UUID_proba
2110: 62 69 6c 69 74 79 5f 6f 66 5f 64 75 70 6c 69 63  bility_of_duplic
2120: 61 74 65 73 22 3e 74 68 65 6f 72 79 3c 2f 61 3e  ates">theory</a>
2130: 2c 20 74 68 65 20 70 72 6f 62 61 62 69 6c 69 74  , the probabilit
2140: 79 20 74 68 61 74 20 74 77 6f 20 72 61 6e 64 6f  y that two rando
2150: 6d 6c 79 20 67 65 6e 65 72 61 74 65 64 20 55 55  mly generated UU
2160: 49 44 73 20 63 6f 75 6c 64 20 61 73 73 75 6d 65  IDs could assume
2170: 20 74 68 65 20 73 61 6d 65 20 76 61 6c 75 65 20   the same value 
2180: 69 73 20 6e 65 61 72 20 74 6f 20 7a 65 72 6f 20  is near to zero 
2190: 66 6f 72 20 6d 61 6e 79 20 70 72 61 63 74 69 63  for many practic
21a0: 61 6c 20 70 75 72 70 6f 73 65 73 2e 20 41 6e 64  al purposes. And
21b0: 20 63 6f 6e 73 65 71 75 65 6e 74 6c 79 20 55 55   consequently UU
21c0: 49 44 73 20 61 72 65 20 77 69 64 65 6c 79 20 75  IDs are widely u
21d0: 73 65 64 20 61 73 20 3c 75 3e 75 6e 69 76 65 72  sed as <u>univer
21e0: 73 61 6c 6c 79 20 75 6e 69 71 75 65 20 49 44 73  sally unique IDs
21f0: 3c 2f 75 3e 2e 3c 62 72 3e 0d 0a 55 73 75 61 6c  </u>.<br>..Usual
2200: 6c 79 20 55 55 49 44 73 20 61 72 65 20 72 65 70  ly UUIDs are rep
2210: 72 65 73 65 6e 74 65 64 20 69 6e 20 74 68 65 69  resented in thei
2220: 72 20 3c 75 3e 63 61 6e 6f 6e 69 63 61 6c 20 66  r <u>canonical f
2230: 6f 72 6d 3c 2f 75 3e 2c 20 69 2e 65 2e 20 61 73  orm</u>, i.e. as
2240: 20 61 20 73 65 71 75 65 6e 63 65 20 6f 66 20 33   a sequence of 3
2250: 32 20 68 65 78 61 64 65 63 69 6d 61 6c 20 64 69  2 hexadecimal di
2260: 67 69 74 73 20 73 65 70 61 72 61 74 65 64 20 69  gits separated i
2270: 6e 74 6f 20 66 69 76 65 20 64 69 73 74 69 6e 63  nto five distinc
2280: 74 20 62 6c 6f 63 6b 2c 20 61 63 63 6f 72 64 69  t block, accordi
2290: 6e 67 6c 79 20 74 6f 20 61 20 3c 62 3e 38 2d 34  ngly to a <b>8-4
22a0: 2d 34 2d 34 2d 31 32 3c 2f 62 3e 20 73 63 68 65  -4-4-12</b> sche
22b0: 6d 61 2e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d  ma...<verbatim>.
22c0: 0a 53 45 4c 45 43 54 20 43 72 65 61 74 65 55 55  .SELECT CreateUU
22d0: 49 44 28 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 0d  ID();..--------.
22e0: 0a 66 66 66 35 66 61 66 31 2d 64 63 63 30 2d 34  .fff5faf1-dcc0-4
22f0: 33 39 31 2d 38 30 35 34 2d 36 65 37 64 65 37 35  391-8054-6e7de75
2300: 64 38 35 62 31 0d 0a 3c 2f 76 65 72 62 61 74 69  d85b1..</verbati
2310: 6d 3e 0d 0a 54 68 65 20 3c 62 3e 43 72 65 61 74  m>..The <b>Creat
2320: 65 55 55 49 44 28 29 3c 2f 62 3e 20 53 51 4c 20  eUUID()</b> SQL 
2330: 66 75 6e 63 74 69 6f 6e 20 69 73 20 62 75 69 6c  function is buil
2340: 74 20 6f 6e 20 74 68 65 20 74 6f 70 20 74 68 65  t on the top the
2350: 20 3c 69 3e 48 69 67 68 20 51 75 61 6c 69 74 79   <i>High Quality
2360: 20 50 73 65 75 64 6f 2d 52 61 6e 64 6f 6d 20 4e   Pseudo-Random N
2370: 75 6d 62 65 72 20 47 65 6e 65 72 61 74 6f 72 3c  umber Generator<
2380: 2f 69 3e 20 3c 61 20 68 72 65 66 3d 22 68 74 74  /i> <a href="htt
2390: 70 3a 2f 2f 77 77 77 2e 73 71 6c 69 74 65 2e 6f  p://www.sqlite.o
23a0: 72 67 2f 63 33 72 65 66 2f 72 61 6e 64 6f 6d 6e  rg/c3ref/randomn
23b0: 65 73 73 2e 68 74 6d 6c 22 3e 69 6e 74 65 72 6e  ess.html">intern
23c0: 61 6c 6c 79 20 69 6d 70 6c 65 6d 65 6e 74 65 64  ally implemented
23d0: 3c 2f 61 3e 20 62 79 20 53 51 4c 69 74 65 2e 3c  </a> by SQLite.<
23e0: 62 72 3e 0d 0a 54 68 65 20 72 65 74 75 72 6e 65  br>..The returne
23f0: 64 20 55 55 49 44 20 69 73 20 63 6f 6e 66 6f 72  d UUID is confor
2400: 6d 61 6e 74 20 74 6f 20 3c 75 3e 56 65 72 73 69  mant to <u>Versi
2410: 6f 6e 20 34 20 28 72 61 6e 64 6f 6d 29 3c 2f 75  on 4 (random)</u
2420: 3e 20 28 69 2e 65 2e 20 74 68 65 20 66 69 72 73  > (i.e. the firs
2430: 74 20 64 69 67 69 74 20 69 6e 74 6f 20 74 68 65  t digit into the
2440: 20 74 68 69 72 64 20 62 6c 6f 63 6b 20 77 69 6c   third block wil
2450: 6c 20 61 6c 77 61 79 73 20 62 65 20 3c 62 3e 34  l always be <b>4
2460: 3c 2f 62 3e 20 61 6e 64 20 74 68 65 20 66 69 72  </b> and the fir
2470: 73 74 20 64 69 67 69 74 20 69 6e 74 6f 20 74 68  st digit into th
2480: 65 20 66 6f 75 72 74 68 20 62 6c 6f 63 6b 20 77  e fourth block w
2490: 69 6c 6c 20 61 6c 77 61 79 73 20 62 65 20 3c 62  ill always be <b
24a0: 3e 38 3c 2f 62 3e 29 2e 3c 62 72 3e 3c 62 72 3e  >8</b>).<br><br>
24b0: 0d 0a 3c 68 72 3e 0d 0a 3c 68 33 3e 3c 61 20 6e  ..<hr>..<h3><a n
24c0: 61 6d 65 3d 22 67 65 6f 6d 22 3e 53 70 61 74 69  ame="geom">Spati
24d0: 61 6c 3c 2f 61 3e 20 53 51 4c 20 66 75 6e 63 74  al</a> SQL funct
24e0: 69 6f 6e 73 3c 2f 68 33 3e 0d 0a 46 65 77 20 6d  ions</h3>..Few m
24f0: 6f 72 65 20 53 70 61 74 69 61 6c 20 53 51 4c 20  ore Spatial SQL 
2500: 66 75 6e 63 74 69 6f 6e 73 20 61 72 65 20 6e 6f  functions are no
2510: 77 20 73 75 70 70 6f 72 74 65 64 2e 0d 0a 3c 76  w supported...<v
2520: 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54  erbatim>..SELECT
2530: 20 53 54 5f 41 73 54 65 78 74 28 20 53 54 5f 41   ST_AsText( ST_A
2540: 64 64 50 6f 69 6e 74 28 20 0d 0a 20 20 53 54 5f  ddPoint( ..  ST_
2550: 47 65 6f 6d 46 72 6f 6d 54 65 78 74 28 20 27 4c  GeomFromText( 'L
2560: 49 4e 45 53 54 52 49 4e 47 28 20 30 20 30 2c 20  INESTRING( 0 0, 
2570: 31 20 30 20 29 27 20 29 2c 20 0d 0a 20 20 53 54  1 0 )' ), ..  ST
2580: 5f 47 65 6f 6d 46 72 6f 6d 54 65 78 74 28 20 27  _GeomFromText( '
2590: 50 4f 49 4e 54 28 20 31 20 31 20 29 27 20 29 20  POINT( 1 1 )' ) 
25a0: 29 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a  ) );..--------..
25b0: 4c 49 4e 45 53 54 52 49 4e 47 28 30 20 30 2c 20  LINESTRING(0 0, 
25c0: 31 20 30 2c 20 31 20 31 29 0d 0a 3c 2f 76 65 72  1 0, 1 1)..</ver
25d0: 62 61 74 69 6d 3e 0d 0a 54 68 65 20 3c 62 3e 53  batim>..The <b>S
25e0: 54 5f 41 64 64 50 6f 69 6e 74 28 29 3c 2f 62 3e  T_AddPoint()</b>
25f0: 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 61 64   SQL function ad
2600: 64 73 20 61 20 66 75 72 74 68 65 72 20 50 6f 69  ds a further Poi
2610: 6e 74 2f 56 65 72 74 65 78 20 61 74 20 74 68 65  nt/Vertex at the
2620: 20 65 6e 64 20 6f 66 20 61 20 4c 69 6e 65 73 74   end of a Linest
2630: 72 69 6e 67 3b 20 74 68 65 20 66 69 72 73 74 20  ring; the first 
2640: 61 72 67 75 6d 65 6e 74 20 69 73 20 61 6c 77 61  argument is alwa
2650: 79 73 20 65 78 70 65 63 74 65 64 20 74 6f 20 62  ys expected to b
2660: 65 20 6f 66 20 74 68 65 20 4c 69 6e 65 73 74 72  e of the Linestr
2670: 69 6e 67 20 74 79 70 65 2c 20 74 68 65 20 73 65  ing type, the se
2680: 63 6f 6e 64 20 6f 6e 65 20 6d 75 73 74 20 62 65  cond one must be
2690: 20 61 20 50 6f 69 6e 74 2e 0d 0a 3c 76 65 72 62   a Point...<verb
26a0: 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 53 54  atim>..SELECT ST
26b0: 5f 41 73 54 65 78 74 28 20 53 54 5f 41 64 64 50  _AsText( ST_AddP
26c0: 6f 69 6e 74 28 20 0d 0a 20 20 53 54 5f 47 65 6f  oint( ..  ST_Geo
26d0: 6d 46 72 6f 6d 54 65 78 74 28 20 27 4c 49 4e 45  mFromText( 'LINE
26e0: 53 54 52 49 4e 47 28 20 31 20 30 2c 20 31 20 31  STRING( 1 0, 1 1
26f0: 20 29 27 20 29 2c 20 0d 0a 20 20 53 54 5f 47 65   )' ), ..  ST_Ge
2700: 6f 6d 46 72 6f 6d 54 65 78 74 28 20 27 50 4f 49  omFromText( 'POI
2710: 4e 54 28 20 30 20 30 20 29 27 20 29 2c 20 30 20  NT( 0 0 )' ), 0 
2720: 29 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d  ) );..---------.
2730: 0a 4c 49 4e 45 53 54 52 49 4e 47 28 30 20 30 2c  .LINESTRING(0 0,
2740: 20 31 20 30 2c 20 31 20 31 29 0d 0a 3c 2f 76 65   1 0, 1 1)..</ve
2750: 72 62 61 74 69 6d 3e 0d 0a 49 66 20 61 6e 20 6f  rbatim>..If an o
2760: 70 74 69 6f 6e 61 6c 20 74 68 69 72 64 20 61 72  ptional third ar
2770: 67 75 6d 65 6e 74 20 28 6f 66 20 74 68 65 20 49  gument (of the I
2780: 6e 74 65 67 65 72 20 74 79 70 65 29 20 69 73 20  nteger type) is 
2790: 70 61 73 73 65 64 20 74 6f 20 3c 62 3e 53 54 5f  passed to <b>ST_
27a0: 41 64 64 50 6f 69 6e 74 28 29 3c 2f 62 3e 20 69  AddPoint()</b> i
27b0: 74 27 73 20 69 6e 74 65 6e 64 65 64 20 74 6f 20  t's intended to 
27c0: 73 70 65 63 69 66 79 20 74 68 65 20 3c 75 3e 69  specify the <u>i
27d0: 6e 64 65 78 3c 2f 75 3e 20 6f 66 20 74 68 65 20  ndex</u> of the 
27e0: 6e 65 77 20 56 65 72 74 65 78 20 28 66 69 72 73  new Vertex (firs
27f0: 74 20 56 65 72 74 65 78 20 68 61 73 20 69 6e 64  t Vertex has ind
2800: 65 78 20 30 2c 20 73 65 63 6f 6e 64 20 56 65 72  ex 0, second Ver
2810: 74 65 78 20 68 61 73 20 69 6e 64 65 78 20 31 20  tex has index 1 
2820: 61 6e 64 20 73 6f 20 6f 6e 29 2e 3c 62 72 3e 0d  and so on).<br>.
2830: 0a 52 65 66 65 72 65 6e 63 69 6e 67 20 61 20 6e  .Referencing a n
2840: 6f 74 20 65 78 69 73 74 69 6e 67 20 69 6e 64 65  ot existing inde
2850: 78 20 69 73 20 61 6e 20 65 72 72 6f 72 2c 20 61  x is an error, a
2860: 6e 64 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 4e  nd will return N
2870: 55 4c 4c 2e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e  ULL...<verbatim>
2880: 0d 0a 53 45 4c 45 43 54 20 53 54 5f 41 73 54 65  ..SELECT ST_AsTe
2890: 78 74 28 20 53 54 5f 41 64 64 50 6f 69 6e 74 28  xt( ST_AddPoint(
28a0: 20 0d 0a 20 20 53 54 5f 47 65 6f 6d 46 72 6f 6d   ..  ST_GeomFrom
28b0: 54 65 78 74 28 20 27 4c 49 4e 45 53 54 52 49 4e  Text( 'LINESTRIN
28c0: 47 28 20 30 20 30 2c 20 31 20 30 20 29 27 20 29  G( 0 0, 1 0 )' )
28d0: 2c 20 0d 0a 20 20 53 54 5f 47 65 6f 6d 46 72 6f  , ..  ST_GeomFro
28e0: 6d 54 65 78 74 28 20 27 50 4f 49 4e 54 28 20 31  mText( 'POINT( 1
28f0: 20 31 20 29 27 20 29 2c 20 2d 31 20 29 20 29 3b   1 )' ), -1 ) );
2900: 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 4c 49 4e 45  ..--------..LINE
2910: 53 54 52 49 4e 47 28 30 20 30 2c 20 31 20 30 2c  STRING(0 0, 1 0,
2920: 20 31 20 31 29 0d 0a 3c 2f 76 65 72 62 61 74 69   1 1)..</verbati
2930: 6d 3e 0d 0a 50 61 73 73 69 6e 67 20 61 20 6e 65  m>..Passing a ne
2940: 67 61 74 69 76 65 20 69 6e 64 65 78 20 69 73 20  gative index is 
2950: 61 20 73 75 70 70 6f 72 74 65 64 20 6f 70 74 69  a supported opti
2960: 6f 6e 2c 20 61 6e 64 20 73 69 6d 70 6c 79 20 63  on, and simply c
2970: 6f 72 72 65 73 70 6f 6e 64 73 20 74 6f 20 74 68  orresponds to th
2980: 65 20 64 65 66 61 75 6c 74 20 62 65 68 61 76 69  e default behavi
2990: 6f 75 72 20 28 69 2e 65 2e 20 3c 69 3e 61 70 70  our (i.e. <i>app
29a0: 65 6e 64 69 6e 67 20 74 68 65 20 50 6f 69 6e 74  ending the Point
29b0: 20 74 6f 20 74 68 65 20 65 6e 64 20 6f 66 20 74   to the end of t
29c0: 68 65 20 4c 69 6e 65 73 74 72 69 6e 67 3c 2f 69  he Linestring</i
29d0: 3e 29 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68 72  >).<br><br>..<hr
29e0: 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53  >..<verbatim>..S
29f0: 45 4c 45 43 54 20 53 54 5f 41 73 54 65 78 74 28  ELECT ST_AsText(
2a00: 20 53 54 5f 53 65 74 50 6f 69 6e 74 28 20 0d 0a   ST_SetPoint( ..
2a10: 20 20 53 54 5f 47 65 6f 6d 46 72 6f 6d 54 65 78    ST_GeomFromTex
2a20: 74 28 20 27 4c 49 4e 45 53 54 52 49 4e 47 28 20  t( 'LINESTRING( 
2a30: 30 20 30 2c 20 31 20 30 2c 20 31 20 31 20 29 27  0 0, 1 0, 1 1 )'
2a40: 20 29 2c 20 0d 0a 20 20 31 2c 20 53 54 5f 47 65   ), ..  1, ST_Ge
2a50: 6f 6d 46 72 6f 6d 54 65 78 74 28 20 27 50 4f 49  omFromText( 'POI
2a60: 4e 54 28 20 32 20 31 20 29 27 20 29 20 29 20 29  NT( 2 1 )' ) ) )
2a70: 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 4c 49  ;..---------..LI
2a80: 4e 45 53 54 52 49 4e 47 28 30 20 30 2c 20 32 20  NESTRING(0 0, 2 
2a90: 31 2c 20 31 20 31 29 0d 0a 3c 2f 76 65 72 62 61  1, 1 1)..</verba
2aa0: 74 69 6d 3e 0d 0a 54 68 65 20 3c 62 3e 53 54 5f  tim>..The <b>ST_
2ab0: 53 65 74 50 6f 69 6e 74 28 29 3c 2f 62 3e 20 53  SetPoint()</b> S
2ac0: 51 4c 20 66 75 6e 63 74 69 6f 6e 20 63 61 6e 20  QL function can 
2ad0: 72 65 70 6c 61 63 65 20 61 20 50 6f 69 6e 74 2f  replace a Point/
2ae0: 56 65 72 74 65 78 20 66 72 6f 6d 20 77 69 74 68  Vertex from with
2af0: 69 6e 20 61 20 4c 69 6e 65 73 74 72 69 6e 67 3b  in a Linestring;
2b00: 20 74 68 65 20 66 69 72 73 74 20 61 72 67 75 6d   the first argum
2b10: 65 6e 74 20 69 73 20 61 6c 77 61 79 73 20 65 78  ent is always ex
2b20: 70 65 63 74 65 64 20 74 6f 20 62 65 20 6f 66 20  pected to be of 
2b30: 74 68 65 20 4c 69 6e 65 73 74 72 69 6e 67 20 74  the Linestring t
2b40: 79 70 65 2c 20 74 68 65 20 73 65 63 6f 6e 64 20  ype, the second 
2b50: 69 73 20 61 6e 20 49 6e 74 65 67 65 72 20 73 70  is an Integer sp
2b60: 65 63 69 66 79 69 6e 67 20 74 68 65 20 3c 75 3e  ecifying the <u>
2b70: 69 6e 64 65 78 3c 2f 75 3e 20 6f 66 20 74 68 65  index</u> of the
2b80: 20 61 66 66 65 63 74 65 64 20 56 65 72 74 65 78   affected Vertex
2b90: 20 61 6e 64 20 74 68 65 20 74 68 69 72 64 20 6f   and the third o
2ba0: 6e 65 20 6d 75 73 74 20 62 65 20 61 20 50 6f 69  ne must be a Poi
2bb0: 6e 74 2e 3c 62 72 3e 0d 0a 52 65 66 65 72 65 6e  nt.<br>..Referen
2bc0: 63 69 6e 67 20 61 20 6e 6f 74 20 65 78 69 73 74  cing a not exist
2bd0: 69 6e 67 20 69 6e 64 65 78 20 69 73 20 61 6e 20  ing index is an 
2be0: 65 72 72 6f 72 2c 20 61 6e 64 20 77 69 6c 6c 20  error, and will 
2bf0: 72 65 74 75 72 6e 20 4e 55 4c 4c 2e 3c 62 72 3e  return NULL.<br>
2c00: 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72  <br>..<hr>..<ver
2c10: 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 53  batim>..SELECT S
2c20: 54 5f 41 73 54 65 78 74 28 20 53 54 5f 52 65 6d  T_AsText( ST_Rem
2c30: 6f 76 65 50 6f 69 6e 74 28 20 0d 0a 20 20 53 54  ovePoint( ..  ST
2c40: 5f 47 65 6f 6d 46 72 6f 6d 54 65 78 74 28 20 27  _GeomFromText( '
2c50: 4c 49 4e 45 53 54 52 49 4e 47 28 20 30 20 30 2c  LINESTRING( 0 0,
2c60: 20 31 20 30 2c 20 31 20 31 20 29 27 20 29 2c 20   1 0, 1 1 )' ), 
2c70: 31 20 29 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d  1 ) );..--------
2c80: 2d 0d 0a 4c 49 4e 45 53 54 52 49 4e 47 28 30 20  -..LINESTRING(0 
2c90: 30 2c 20 31 20 31 29 0d 0a 3c 2f 76 65 72 62 61  0, 1 1)..</verba
2ca0: 74 69 6d 3e 0d 0a 54 68 65 20 3c 62 3e 53 54 5f  tim>..The <b>ST_
2cb0: 52 65 6d 6f 76 65 50 6f 69 6e 74 28 29 3c 2f 62  RemovePoint()</b
2cc0: 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 63  > SQL function c
2cd0: 61 6e 20 72 65 6d 6f 76 65 20 61 20 50 6f 69 6e  an remove a Poin
2ce0: 74 2f 56 65 72 74 65 78 20 66 72 6f 6d 20 77 69  t/Vertex from wi
2cf0: 74 68 69 6e 20 61 20 4c 69 6e 65 73 74 72 69 6e  thin a Linestrin
2d00: 67 3b 20 74 68 65 20 66 69 72 73 74 20 61 72 67  g; the first arg
2d10: 75 6d 65 6e 74 20 69 73 20 61 6c 77 61 79 73 20  ument is always 
2d20: 65 78 70 65 63 74 65 64 20 74 6f 20 62 65 20 6f  expected to be o
2d30: 66 20 74 68 65 20 4c 69 6e 65 73 74 72 69 6e 67  f the Linestring
2d40: 20 74 79 70 65 2c 20 74 68 65 20 73 65 63 6f 6e   type, the secon
2d50: 64 20 69 73 20 61 6e 20 49 6e 74 65 67 65 72 20  d is an Integer 
2d60: 73 70 65 63 69 66 79 69 6e 67 20 74 68 65 20 3c  specifying the <
2d70: 75 3e 69 6e 64 65 78 3c 2f 75 3e 20 6f 66 20 74  u>index</u> of t
2d80: 68 65 20 61 66 66 65 63 74 65 64 20 56 65 72 74  he affected Vert
2d90: 65 78 2e 3c 62 72 3e 0d 0a 52 65 66 65 72 65 6e  ex.<br>..Referen
2da0: 63 69 6e 67 20 61 20 6e 6f 74 20 65 78 69 73 74  cing a not exist
2db0: 69 6e 67 20 69 6e 64 65 78 20 69 73 20 61 6e 20  ing index is an 
2dc0: 65 72 72 6f 72 2c 20 61 6e 64 20 77 69 6c 6c 20  error, and will 
2dd0: 72 65 74 75 72 6e 20 4e 55 4c 4c 2e 3c 62 72 3e  return NULL.<br>
2de0: 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72  <br>..<hr>..<ver
2df0: 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 53  batim>..SELECT S
2e00: 54 5f 41 73 54 65 78 74 28 20 53 54 5f 50 6f 69  T_AsText( ST_Poi
2e10: 6e 74 28 31 30 2c 20 32 30 29 20 29 3b 0d 0a 2d  nt(10, 20) );..-
2e20: 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 50 4f 49 4e 54  ---------..POINT
2e30: 28 31 30 20 31 30 29 0d 0a 3c 2f 76 65 72 62 61  (10 10)..</verba
2e40: 74 69 6d 3e 0d 0a 54 68 65 20 3c 62 3e 53 54 5f  tim>..The <b>ST_
2e50: 50 6f 69 6e 74 28 29 3c 2f 62 3e 20 53 51 4c 20  Point()</b> SQL 
2e60: 66 75 6e 63 74 69 6f 6e 20 73 69 6d 70 6c 79 20  function simply 
2e70: 69 73 20 79 65 74 20 61 6e 6f 74 68 65 72 20 3c  is yet another <
2e80: 69 3e 61 6c 69 61 73 2d 6e 61 6d 65 3c 2f 69 3e  i>alias-name</i>
2e90: 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20 74   corresponding t
2ea0: 6f 20 3c 62 3e 4d 61 6b 65 50 6f 69 6e 74 28 29  o <b>MakePoint()
2eb0: 3c 2f 62 3e 3b 20 74 68 69 73 20 66 75 72 74 68  </b>; this furth
2ec0: 65 72 20 61 6c 69 61 73 20 68 61 73 20 62 65 65  er alias has bee
2ed0: 6e 20 69 6e 74 72 6f 64 75 63 65 64 20 73 6f 20  n introduced so 
2ee0: 74 6f 20 73 75 70 70 6f 72 74 20 61 20 73 74 72  to support a str
2ef0: 69 63 74 20 50 6f 73 74 47 49 53 20 63 6f 6e 66  ict PostGIS conf
2f00: 6f 72 6d 61 6e 63 65 2e 3c 62 72 3e 0d 0a 3c 75  ormance.<br>..<u
2f10: 3e 50 6c 65 61 73 65 20 6e 6f 74 65 3c 2f 75 3e  >Please note</u>
2f20: 3a 20 64 69 66 66 65 72 65 6e 74 6c 79 20 66 72  : differently fr
2f30: 6f 6d 20 4d 61 6b 65 50 6f 69 6e 74 28 29 2c 20  om MakePoint(), 
2f40: 53 54 5f 50 6f 69 6e 74 28 29 20 64 6f 6e 27 74  ST_Point() don't
2f50: 20 73 75 70 70 6f 72 74 73 20 74 68 65 20 6f 70   supports the op
2f60: 74 69 6f 6e 61 6c 20 3c 62 3e 53 52 49 44 3c 2f  tional <b>SRID</
2f70: 62 3e 20 61 72 67 75 6d 65 6e 74 2e 3c 62 72 3e  b> argument.<br>
2f80: 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72  <br>..<hr>..<ver
2f90: 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 53  batim>..SELECT S
2fa0: 54 5f 41 73 54 65 78 74 28 20 4d 61 6b 65 4c 69  T_AsText( MakeLi
2fb0: 6e 65 28 20 53 54 5f 47 65 6f 6d 46 72 6f 6d 54  ne( ST_GeomFromT
2fc0: 65 78 74 28 20 27 4d 55 4c 54 49 50 4f 49 4e 54  ext( 'MULTIPOINT
2fd0: 28 30 20 30 2c 20 31 20 30 2c 20 31 20 31 29 27  (0 0, 1 0, 1 1)'
2fe0: 20 29 20 29 20 2c 20 31 20 29 3b 0d 0a 2d 2d 2d   ) ) , 1 );..---
2ff0: 2d 2d 2d 2d 2d 2d 2d 0d 0a 4c 49 4e 45 53 54 52  -------..LINESTR
3000: 49 4e 47 28 30 20 30 2c 20 31 20 30 2c 20 31 20  ING(0 0, 1 0, 1 
3010: 31 29 0d 0a 0d 0a 53 45 4c 45 43 54 20 53 54 5f  1)....SELECT ST_
3020: 41 73 54 65 78 74 28 20 4d 61 6b 65 4c 69 6e 65  AsText( MakeLine
3030: 28 20 53 54 5f 47 65 6f 6d 46 72 6f 6d 54 65 78  ( ST_GeomFromTex
3040: 74 28 20 27 4d 55 4c 54 49 50 4f 49 4e 54 28 30  t( 'MULTIPOINT(0
3050: 20 30 2c 20 31 20 30 2c 20 31 20 31 29 27 20 29   0, 1 0, 1 1)' )
3060: 20 29 20 2c 20 30 20 29 3b 0d 0a 2d 2d 2d 2d 2d   ) , 0 );..-----
3070: 2d 2d 2d 2d 2d 0d 0a 4c 49 4e 45 53 54 52 49 4e  -----..LINESTRIN
3080: 47 28 31 20 31 2c 20 31 20 30 2c 20 30 20 30 29  G(1 1, 1 0, 0 0)
3090: 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 4e  ..</verbatim>..N
30a0: 6f 74 20 72 65 61 6c 6c 79 20 61 20 62 72 61 6e  ot really a bran
30b0: 64 20 6e 65 77 20 53 51 4c 20 66 75 6e 63 74 69  d new SQL functi
30c0: 6f 6e 3b 20 6d 6f 72 65 20 73 69 6d 70 6c 79 20  on; more simply 
30d0: 61 20 66 75 72 74 68 65 72 20 6f 76 65 72 6c 6f  a further overlo
30e0: 61 64 65 64 20 66 6c 61 76 6f 72 20 6f 66 20 74  aded flavor of t
30f0: 68 65 20 61 6c 72 65 61 64 79 20 65 78 69 73 74  he already exist
3100: 69 6e 67 20 3c 62 3e 4d 61 6b 65 4c 69 6e 65 28  ing <b>MakeLine(
3110: 29 3c 2f 62 3e 2e 3c 62 72 3e 0d 0a 4e 6f 77 20  )</b>.<br>..Now 
3120: 74 68 65 20 69 6e 70 75 74 20 47 65 6f 6d 65 74  the input Geomet
3130: 72 79 20 28 66 69 72 73 74 20 61 72 67 75 6d 65  ry (first argume
3140: 6e 74 29 20 63 6f 75 6c 64 20 62 65 20 6f 66 20  nt) could be of 
3150: 74 68 65 20 4d 55 4c 54 49 50 4f 49 4e 54 20 74  the MULTIPOINT t
3160: 79 70 65 20 61 6e 64 20 74 68 65 20 73 65 63 6f  ype and the seco
3170: 6e 64 20 61 72 67 75 6d 65 6e 74 20 69 66 20 6f  nd argument if o
3180: 66 20 74 68 65 20 3c 62 3e 42 6f 6f 6c 65 61 6e  f the <b>Boolean
3190: 3c 2f 62 3e 20 74 79 70 65 3b 20 69 66 20 74 68  </b> type; if th
31a0: 65 20 73 65 63 6f 6e 64 20 61 72 67 75 6d 65 6e  e second argumen
31b0: 74 20 63 6f 72 72 65 73 70 6f 6e 64 73 20 74 6f  t corresponds to
31c0: 20 3c 62 3e 54 52 55 45 3c 2f 62 3e 20 74 68 65   <b>TRUE</b> the
31d0: 20 72 65 74 75 72 6e 65 64 20 4c 49 4e 45 53 54   returned LINEST
31e0: 52 49 4e 47 20 77 69 6c 6c 20 62 65 20 6f 72 69  RING will be ori
31f0: 65 6e 74 65 64 20 61 63 63 6f 72 64 69 6e 67 6c  ented accordingl
3200: 79 20 74 6f 20 74 68 65 20 50 6f 69 6e 74 2d 73  y to the Point-s
3210: 65 71 75 65 6e 63 65 20 61 73 20 73 70 65 63 69  equence as speci
3220: 66 69 65 64 20 62 79 20 74 68 65 20 4d 75 6c 74  fied by the Mult
3230: 69 50 6f 69 6e 74 2c 20 6f 74 68 65 72 77 69 73  iPoint, otherwis
3240: 65 20 3c 75 3e 72 65 76 65 72 73 65 20 6f 72 64  e <u>reverse ord
3250: 65 72 3c 2f 75 3e 20 77 69 6c 6c 20 62 65 20 61  er</u> will be a
3260: 73 73 75 6d 65 64 2c 20 74 68 75 73 20 72 65 74  ssumed, thus ret
3270: 75 72 6e 69 6e 67 20 61 20 4c 69 6e 65 73 74 72  urning a Linestr
3280: 69 6e 67 20 6f 66 20 6f 70 70 6f 73 69 74 65 20  ing of opposite 
3290: 6f 72 69 65 6e 74 61 74 69 6f 6e 2e 3c 62 72 3e  orientation.<br>
32a0: 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72  <br>..<hr>..<ver
32b0: 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 53  batim>..SELECT S
32c0: 54 5f 41 72 65 61 28 20 53 54 5f 47 65 6f 6d 46  T_Area( ST_GeomF
32d0: 72 6f 6d 54 65 78 74 28 20 27 50 4f 4c 59 47 4f  romText( 'POLYGO
32e0: 4e 28 28 32 30 20 32 30 2c 20 32 31 20 32 30 2c  N((20 20, 21 20,
32f0: 20 32 31 20 32 31 2c 20 32 30 20 32 31 2c 20 32   21 21, 20 21, 2
3300: 30 20 32 30 29 29 27 2c 20 34 33 32 36 20 29 2c  0 20))', 4326 ),
3310: 20 31 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d   1 );..---------
3320: 2d 0d 0a 31 31 35 34 38 35 35 35 39 32 36 2e 36  -..11548555926.6
3330: 34 37 37 33 36 0d 0a 0d 0a 0d 0a 53 45 4c 45 43  47736......SELEC
3340: 54 20 53 54 5f 41 72 65 61 28 20 53 54 5f 47 65  T ST_Area( ST_Ge
3350: 6f 6d 46 72 6f 6d 54 65 78 74 28 20 27 50 4f 4c  omFromText( 'POL
3360: 59 47 4f 4e 28 28 32 30 20 32 30 2c 20 32 31 20  YGON((20 20, 21 
3370: 32 30 2c 20 32 31 20 32 31 2c 20 32 30 20 32 31  20, 21 21, 20 21
3380: 2c 20 32 30 20 32 30 29 29 27 2c 20 34 33 32 36  , 20 20))', 4326
3390: 20 29 2c 20 30 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d   ), 0 );..------
33a0: 2d 2d 2d 2d 0d 0a 31 31 35 38 31 33 37 37 36 32  ----..1158137762
33b0: 33 2e 31 31 34 31 38 39 0d 0a 3c 2f 76 65 72 62  3.114189..</verb
33c0: 61 74 69 6d 3e 0d 0a 4f 6e 63 65 20 61 67 61 69  atim>..Once agai
33d0: 6e 2c 20 73 69 6d 70 6c 79 20 61 20 66 75 72 74  n, simply a furt
33e0: 68 65 72 20 65 78 74 65 6e 73 69 6f 6e 20 6f 66  her extension of
33f0: 20 74 68 65 20 61 6c 72 65 61 64 79 20 65 78 69   the already exi
3400: 73 74 69 6e 67 20 3c 62 3e 53 54 5f 41 72 65 61  sting <b>ST_Area
3410: 28 29 3c 2f 62 3e 2e 3c 62 72 3e 0d 0a 4e 6f 77  ()</b>.<br>..Now
3420: 20 69 66 20 74 68 65 20 69 6e 70 75 74 20 47 65   if the input Ge
3430: 6f 6d 65 74 72 79 20 61 64 6f 70 74 73 20 3c 75  ometry adopts <u
3440: 3e 67 65 6f 67 72 61 70 68 69 63 20 63 6f 6f 72  >geographic coor
3450: 64 69 6e 61 74 65 73 3c 2f 75 3e 20 28 69 2e 65  dinates</u> (i.e
3460: 2e 20 62 61 73 65 64 20 6f 6e 20 3c 75 3e 6c 6f  . based on <u>lo
3470: 6e 67 69 74 75 64 65 3c 2f 75 3e 20 61 6e 64 20  ngitude</u> and 
3480: 3c 75 3e 6c 61 74 69 74 75 64 65 3c 2f 75 3e 20  <u>latitude</u> 
3490: 61 6e 67 6c 65 73 29 2c 20 61 20 73 65 63 6f 6e  angles), a secon
34a0: 64 20 61 72 67 75 6d 65 6e 74 20 6f 66 20 74 68  d argument of th
34b0: 65 20 3c 62 3e 42 6f 6f 6c 65 61 6e 3c 2f 62 3e  e <b>Boolean</b>
34c0: 20 64 61 74 61 2d 74 79 70 65 20 63 6f 75 6c 64   data-type could
34d0: 20 62 65 20 6f 70 74 69 6f 6e 61 6c 6c 79 20 73   be optionally s
34e0: 70 65 63 69 66 69 65 64 2e 3c 62 72 3e 0d 0a 49  pecified.<br>..I
34f0: 6e 20 74 68 69 73 20 63 61 73 65 20 74 68 65 20  n this case the 
3500: 72 65 74 75 72 6e 65 64 20 41 72 65 61 20 77 69  returned Area wi
3510: 6c 6c 20 62 65 20 6d 65 61 73 75 72 65 64 20 69  ll be measured i
3520: 6e 20 3c 62 3e 6d 65 74 65 72 73 3c 2f 62 3e 2e  n <b>meters</b>.
3530: 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 69 66 20 74  ..<ul>..<li>if t
3540: 68 65 20 73 65 63 6f 6e 64 20 61 72 67 20 69 73  he second arg is
3550: 20 3c 62 3e 54 52 55 45 3c 2f 62 3e 20 74 68 65   <b>TRUE</b> the
3560: 20 41 72 65 61 20 77 69 6c 6c 20 62 65 20 6d 65   Area will be me
3570: 61 73 75 72 65 64 20 3c 75 3e 6f 6e 20 74 68 65  asured <u>on the
3580: 20 45 6c 6c 69 70 73 6f 69 64 3c 2f 75 3e 20 28   Ellipsoid</u> (
3590: 6d 6f 72 65 20 61 63 63 75 72 61 74 65 2c 20 62  more accurate, b
35a0: 75 74 20 73 6c 6f 77 65 72 29 2e 3c 2f 6c 69 3e  ut slower).</li>
35b0: 0d 0a 3c 6c 69 3e 69 66 20 74 68 65 20 73 65 63  ..<li>if the sec
35c0: 6f 6e 64 20 61 72 67 20 69 73 20 3c 62 3e 46 41  ond arg is <b>FA
35d0: 4c 53 45 3c 2f 62 3e 20 74 68 65 20 41 72 65 61  LSE</b> the Area
35e0: 20 77 69 6c 6c 20 62 65 20 6d 65 61 73 75 72 65   will be measure
35f0: 20 3c 75 3e 6f 6e 20 74 68 65 20 53 70 68 65 72   <u>on the Spher
3600: 65 3c 2f 75 3e 20 28 66 61 73 74 65 72 2c 20 62  e</u> (faster, b
3610: 75 74 20 6c 65 73 73 20 61 63 63 75 72 61 74 65  ut less accurate
3620: 29 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 4e 55 4c  ).</li>..<li>NUL
3630: 4c 20 77 69 6c 6c 20 62 65 20 72 65 74 75 72 6e  L will be return
3640: 65 64 20 6f 6e 20 69 6e 76 61 6c 69 64 20 61 72  ed on invalid ar
3650: 67 73 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 3c 75  gs.</li>..<li><u
3660: 3e 50 6c 65 61 73 65 20 6e 6f 74 65 3c 2f 75 3e  >Please note</u>
3670: 3a 20 74 68 69 73 20 73 70 65 63 69 66 69 63 20  : this specific 
3680: 66 6c 61 76 6f 72 20 6f 66 20 3c 62 3e 53 54 5f  flavor of <b>ST_
3690: 41 72 65 61 28 29 3c 2f 62 3e 20 6e 65 63 65 73  Area()</b> neces
36a0: 73 61 72 69 6c 79 20 72 65 71 75 69 72 65 73 20  sarily requires 
36b0: 74 68 65 20 3c 62 3e 4c 57 47 45 4f 4d 3c 2f 62  the <b>LWGEOM</b
36c0: 3e 20 73 75 70 70 6f 72 74 20 74 6f 20 62 65 20  > support to be 
36d0: 61 63 74 69 76 61 74 65 64 20 61 74 20 62 75 69  activated at bui
36e0: 6c 64 20 74 69 6d 65 2e 3c 2f 6c 69 3e 0d 0a 3c  ld time.</li>..<
36f0: 2f 75 6c 3e 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a  /ul><br>..<hr>..
3700: 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45  <verbatim>..SELE
3710: 43 54 20 53 54 5f 41 73 54 65 78 74 28 20 53 54  CT ST_AsText( ST
3720: 5f 50 72 6f 6a 65 63 74 28 20 4d 61 6b 65 50 6f  _Project( MakePo
3730: 69 6e 74 28 20 31 31 2e 35 32 2c 20 34 32 2e 33  int( 11.52, 42.3
3740: 38 2c 20 34 33 32 36 20 29 2c 20 35 30 30 30 30  8, 4326 ), 50000
3750: 2c 20 52 61 64 69 61 6e 73 28 20 34 35 20 29 20  , Radians( 45 ) 
3760: 29 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ) );..----------
3770: 0d 0a 50 4f 49 4e 54 28 31 31 2e 39 35 31 34 37  ..POINT(11.95147
3780: 39 20 34 32 2e 36 39 37 34 36 37 29 0d 0a 3c 2f  9 42.697467)..</
3790: 76 65 72 62 61 74 69 6d 3e 0d 0a 54 68 65 20 3c  verbatim>..The <
37a0: 62 3e 53 54 5f 50 72 6f 6a 65 63 74 28 29 3c 2f  b>ST_Project()</
37b0: 62 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20  b> SQL function 
37c0: 77 69 6c 6c 20 72 65 74 75 72 6e 20 74 68 65 20  will return the 
37d0: 64 65 73 74 69 6e 61 74 69 6f 6e 20 50 6f 69 6e  destination Poin
37e0: 74 20 3c 75 3e 6f 6e 20 74 68 65 20 65 6c 6c 69  t <u>on the elli
37f0: 70 73 6f 69 64 3c 2f 75 3e 20 63 6f 72 72 65 73  psoid</u> corres
3800: 70 6f 6e 64 69 6e 67 20 74 6f 20 61 20 3c 62 3e  ponding to a <b>
3810: 73 74 61 72 74 5f 70 6f 69 6e 74 3c 2f 62 3e 2c  start_point</b>,
3820: 20 61 20 3c 62 3e 64 69 73 74 61 6e 63 65 3c 2f   a <b>distance</
3830: 62 3e 20 61 6e 64 20 61 20 3c 62 3e 62 65 61 72  b> and a <b>bear
3840: 69 6e 67 3c 2f 62 3e 20 28 61 6b 61 20 3c 75 3e  ing</b> (aka <u>
3850: 61 7a 69 6d 75 74 68 3c 2f 75 3e 20 61 6b 61 20  azimuth</u> aka 
3860: 3c 75 3e 64 69 72 65 63 74 69 6f 6e 3c 2f 75 3e  <u>direction</u>
3870: 20 61 6b 61 20 3c 75 3e 68 65 61 64 69 6e 67 3c   aka <u>heading<
3880: 2f 75 3e 29 2e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69  /u>)...<ul>..<li
3890: 3e 74 68 65 20 3c 62 3e 73 74 61 72 74 5f 70 6f  >the <b>start_po
38a0: 69 6e 74 3c 2f 62 3e 20 69 73 20 65 78 70 65 63  int</b> is expec
38b0: 74 65 64 20 74 6f 20 61 64 6f 70 74 20 3c 75 3e  ted to adopt <u>
38c0: 67 65 6f 67 72 61 70 68 69 63 20 63 6f 6f 72 64  geographic coord
38d0: 69 6e 61 74 65 73 3c 2f 75 3e 20 28 69 2e 65 2e  inates</u> (i.e.
38e0: 20 62 61 73 65 64 20 6f 6e 20 3c 75 3e 6c 6f 6e   based on <u>lon
38f0: 67 69 74 75 64 65 3c 2f 75 3e 20 61 6e 64 20 3c  gitude</u> and <
3900: 75 3e 6c 61 74 69 74 75 64 65 3c 2f 75 3e 20 61  u>latitude</u> a
3910: 6e 67 6c 65 73 29 2e 3c 2f 6c 69 3e 0d 0a 3c 6c  ngles).</li>..<l
3920: 69 3e 74 68 65 20 3c 62 3e 64 69 73 74 61 6e 63  i>the <b>distanc
3930: 65 3c 2f 62 3e 20 69 73 20 61 6c 77 61 79 73 20  e</b> is always 
3940: 65 78 70 65 63 74 65 64 20 74 6f 20 62 65 20 65  expected to be e
3950: 78 70 72 65 73 73 65 64 20 69 6e 20 3c 62 3e 6d  xpressed in <b>m
3960: 65 74 65 72 73 3c 2f 62 3e 2e 3c 2f 6c 69 3e 0d  eters</b>.</li>.
3970: 0a 3c 6c 69 3e 74 68 65 20 3c 62 3e 61 7a 69 6d  .<li>the <b>azim
3980: 75 74 68 3c 2f 62 3e 20 61 6e 67 6c 65 20 69 73  uth</b> angle is
3990: 20 65 78 70 65 63 74 65 64 20 74 6f 20 62 65 20   expected to be 
39a0: 65 78 70 72 65 73 73 65 64 20 69 6e 20 3c 62 3e  expressed in <b>
39b0: 72 61 64 69 61 6e 73 3c 2f 62 3e 3a 0d 0a 3c 75  radians</b>:..<u
39c0: 6c 3e 0d 0a 3c 6c 69 3e 4e 6f 72 74 68 20 63 6f  l>..<li>North co
39d0: 72 72 65 73 70 6f 6e 64 73 20 74 6f 20 30 20 64  rresponds to 0 d
39e0: 65 67 72 65 65 73 20 28 30 20 72 61 64 69 61 6e  egrees (0 radian
39f0: 73 29 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 45 61  s).</li>..<li>Ea
3a00: 73 74 20 63 6f 72 72 65 73 70 6f 6e 64 73 20 74  st corresponds t
3a10: 6f 20 39 30 20 64 65 67 72 65 65 73 20 28 50 49  o 90 degrees (PI
3a20: 2f 32 20 72 61 64 69 61 6e 73 29 2e 3c 2f 6c 69  /2 radians).</li
3a30: 3e 0d 0a 3c 6c 69 3e 53 6f 75 74 68 20 63 6f 72  >..<li>South cor
3a40: 72 65 73 70 6f 6e 64 73 20 74 6f 20 31 38 30 20  responds to 180 
3a50: 64 65 67 72 65 65 73 20 28 50 49 20 72 61 64 69  degrees (PI radi
3a60: 61 6e 73 29 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e  ans).</li>..<li>
3a70: 57 65 73 74 20 63 6f 72 72 65 73 70 6f 6e 64 73  West corresponds
3a80: 20 74 6f 20 32 37 30 20 64 65 67 72 65 65 73 20   to 270 degrees 
3a90: 28 33 50 49 2f 32 20 72 61 64 69 61 6e 73 29 2e  (3PI/2 radians).
3aa0: 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 69 2e 65 2e 20  </li>..<li>i.e. 
3ab0: 69 74 20 68 61 73 20 74 68 65 20 73 61 6d 65 20  it has the same 
3ac0: 69 64 65 6e 74 69 63 61 6c 20 6d 65 61 6e 69 6e  identical meanin
3ad0: 67 20 61 73 20 69 6e 20 3c 62 3e 53 54 5f 41 7a  g as in <b>ST_Az
3ae0: 69 6d 75 74 68 28 29 3c 2f 62 3e 2e 3c 2f 6c 69  imuth()</b>.</li
3af0: 3e 0d 0a 3c 2f 75 6c 3e 3c 2f 6c 69 3e 0d 0a 3c  >..</ul></li>..<
3b00: 6c 69 3e 74 68 69 73 20 66 75 6e 63 74 69 6f 6e  li>this function
3b10: 20 65 78 61 63 74 6c 79 20 63 6f 72 72 65 73 70   exactly corresp
3b20: 6f 6e 64 73 20 74 6f 20 74 68 65 20 6f 6e 65 20  onds to the one 
3b30: 73 75 70 70 6f 72 74 65 64 20 62 79 20 3c 62 3e  supported by <b>
3b40: 50 6f 73 74 47 49 53 3c 2f 62 3e 2e 3c 2f 6c 69  PostGIS</b>.</li
3b50: 3e 0d 0a 3c 6c 69 3e 3c 75 3e 50 6c 65 61 73 65  >..<li><u>Please
3b60: 20 6e 6f 74 65 3c 2f 75 3e 3a 20 3c 62 3e 53 54   note</u>: <b>ST
3b70: 5f 50 72 6f 6a 65 63 74 28 29 3c 2f 62 3e 20 6e  _Project()</b> n
3b80: 65 63 65 73 73 61 72 69 6c 79 20 72 65 71 75 69  ecessarily requi
3b90: 72 65 73 20 74 68 65 20 3c 62 3e 4c 57 47 45 4f  res the <b>LWGEO
3ba0: 4d 3c 2f 62 3e 20 73 75 70 70 6f 72 74 20 74 6f  M</b> support to
3bb0: 20 62 65 20 61 63 74 69 76 61 74 65 64 20 61 74   be activated at
3bc0: 20 62 75 69 6c 64 20 74 69 6d 65 2e 3c 2f 6c 69   build time.</li
3bd0: 3e 0d 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d 0a 3c 68  >..</ul><br>..<h
3be0: 72 3e 0d 0a 3c 68 33 3e 3c 61 20 6e 61 6d 65 3d  r>..<h3><a name=
3bf0: 22 75 6e 73 61 66 65 22 3e 55 6e 73 61 66 65 3c  "unsafe">Unsafe<
3c00: 2f 61 3e 20 28 62 75 74 20 75 73 65 66 75 6c 29  /a> (but useful)
3c10: 20 49 6d 70 6f 72 74 2f 45 78 70 6f 72 74 20 53   Import/Export S
3c20: 51 4c 20 66 75 6e 63 74 69 6f 6e 73 3c 2f 68 33  QL functions</h3
3c30: 3e 0d 0a 41 6c 6c 20 74 68 65 20 66 6f 6c 6c 6f  >..All the follo
3c40: 77 69 6e 67 20 53 51 4c 20 66 75 6e 63 74 69 6f  wing SQL functio
3c50: 6e 73 20 63 6f 75 6c 64 20 62 65 20 72 65 61 6c  ns could be real
3c60: 6c 79 20 75 73 65 66 75 6c 20 69 6e 20 6f 72 64  ly useful in ord
3c70: 65 72 20 74 6f 20 73 75 70 70 6f 72 74 20 49 6d  er to support Im
3c80: 70 6f 72 74 2f 45 78 70 6f 72 74 20 6f 70 65 72  port/Export oper
3c90: 61 74 69 6f 6e 73 2e 3c 62 72 3e 0d 0a 41 6e 79  ations.<br>..Any
3ca0: 77 61 79 20 79 6f 75 20 73 68 6f 75 6c 64 20 62  way you should b
3cb0: 65 20 3c 75 3e 77 65 6c 6c 20 61 77 61 72 65 3c  e <u>well aware<
3cc0: 2f 75 3e 20 74 68 61 74 20 61 6c 6c 20 74 68 65  /u> that all the
3cd0: 6d 20 63 6f 75 6c 64 20 62 65 20 70 6f 74 65 6e  m could be poten
3ce0: 74 69 61 6c 6c 79 20 3c 75 3e 75 6e 73 61 66 65  tially <u>unsafe
3cf0: 3c 2f 75 3e 20 61 6e 64 20 63 6f 75 6c 64 20 62  </u> and could b
3d00: 65 20 70 6f 74 65 6e 74 69 61 6c 6c 79 20 75 73  e potentially us
3d10: 65 64 20 62 79 20 73 6f 6d 65 20 3c 75 3e 6d 61  ed by some <u>ma
3d20: 6c 69 63 69 6f 75 73 20 68 61 63 6b 65 72 3c 2f  licious hacker</
3d30: 75 3e 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 63  u> in order to c
3d40: 72 65 61 74 65 20 61 6e 64 20 65 78 70 6c 6f 69  reate and exploi
3d50: 74 20 73 6f 6d 65 20 3c 75 3e 73 65 63 75 72 69  t some <u>securi
3d60: 74 79 20 62 72 65 61 63 68 3c 2f 75 3e 2e 3c 62  ty breach</u>.<b
3d70: 72 3e 0d 0a 54 68 65 20 63 61 75 73 65 20 69 73  r>..The cause is
3d80: 20 76 65 72 79 20 65 61 73 79 20 74 6f 20 62 65   very easy to be
3d90: 20 75 6e 64 65 72 73 74 6f 6f 64 3a 20 74 68 65   understood: the
3da0: 73 65 20 66 75 6e 63 74 69 6f 6e 73 20 61 6c 6c  se functions all
3db0: 6f 77 20 74 6f 20 74 72 61 6e 73 66 65 72 20 61  ow to transfer a
3dc0: 72 62 69 74 72 61 72 79 20 70 61 79 6c 6f 61 64  rbitrary payload
3dd0: 73 20 66 72 6f 6d 20 2f 20 74 6f 20 74 68 65 20  s from / to the 
3de0: 44 61 74 61 62 61 73 65 20 61 6e 64 20 74 68 65  Database and the
3df0: 20 6c 6f 63 61 6c 20 46 69 6c 65 2d 53 79 73 74   local File-Syst
3e00: 65 6d 2e 0d 0a 41 20 6d 61 6c 69 63 69 6f 75 73  em...A malicious
3e10: 20 61 74 74 61 63 6b 20 63 6f 75 6c 64 20 62 65   attack could be
3e20: 20 74 68 75 73 20 69 6d 70 6c 65 6d 65 6e 74 65   thus implemente
3e30: 64 20 65 2e 67 2e 20 62 79 20 65 78 65 63 75 74  d e.g. by execut
3e40: 69 6e 67 20 73 6f 6d 65 20 53 51 4c 20 73 63 72  ing some SQL scr
3e50: 69 70 74 20 6f 72 20 62 79 20 64 65 66 69 6e 69  ipt or by defini
3e60: 6e 67 20 61 20 70 75 72 70 6f 73 65 6c 79 20 66  ng a purposely f
3e70: 6f 72 67 65 64 20 54 72 69 67 67 65 72 2c 20 61  orged Trigger, a
3e80: 6e 64 20 74 68 65 20 65 6e 64 20 75 73 65 72 73  nd the end users
3e90: 20 77 6f 75 6c 64 20 62 65 20 61 62 73 6f 6c 75   would be absolu
3ea0: 74 65 6c 79 20 75 6e 61 77 61 72 65 20 6f 66 20  tely unaware of 
3eb0: 77 68 61 74 20 69 73 20 72 65 61 6c 6c 79 20 68  what is really h
3ec0: 61 70 70 65 6e 69 6e 67 2e 0d 0a 53 6f 20 69 6e  appening...So in
3ed0: 20 6f 72 64 65 72 20 74 6f 20 65 66 66 65 63 74   order to effect
3ee0: 69 76 65 6c 79 20 73 68 69 65 6c 64 20 75 73 65  ively shield use
3ef0: 72 73 20 61 67 61 69 6e 73 74 20 74 68 65 73 65  rs against these
3f00: 20 70 6f 74 65 6e 74 69 61 6c 6c 79 20 64 61 6e   potentially dan
3f10: 67 65 72 6f 75 73 20 73 65 63 75 72 69 74 79 20  gerous security 
3f20: 70 69 74 66 61 6c 6c 73 20 61 6c 6c 20 74 68 65  pitfalls all the
3f30: 73 65 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 73  se SQL functions
3f40: 20 61 72 65 20 61 6c 77 61 79 73 20 3c 75 3e 64   are always <u>d
3f50: 69 73 61 62 6c 65 64 20 62 79 20 64 65 66 61 75  isabled by defau
3f60: 6c 74 3c 2f 75 3e 2e 0d 0a 3c 76 65 72 62 61 74  lt</u>...<verbat
3f70: 69 6d 3e 0d 0a 65 78 70 6f 72 74 20 22 53 50 41  im>..export "SPA
3f80: 54 49 41 4c 49 54 45 5f 53 45 43 55 52 49 54 59  TIALITE_SECURITY
3f90: 3d 72 65 6c 61 78 65 64 22 0d 0a 3c 2f 76 65 72  =relaxed"..</ver
3fa0: 62 61 74 69 6d 3e 0d 0a 49 6e 20 6f 72 64 65 72  batim>..In order
3fb0: 20 74 6f 20 72 65 61 6c 6c 79 20 65 6e 61 62 6c   to really enabl
3fc0: 65 20 74 68 65 73 65 20 66 75 6e 63 74 69 6f 6e  e these function
3fd0: 73 20 74 68 65 20 75 73 65 72 20 69 73 20 72 65  s the user is re
3fe0: 71 75 69 72 65 64 20 74 6f 20 74 61 6b 65 20 61  quired to take a
3ff0: 6e 20 65 78 70 6c 69 63 69 74 20 61 63 74 69 6f  n explicit actio
4000: 6e 3b 20 69 2e 65 2e 20 74 68 65 20 3c 75 3e 65  n; i.e. the <u>e
4010: 6e 76 69 72 6f 6e 6d 65 6e 74 20 76 61 72 69 61  nvironment varia
4020: 62 6c 65 3c 2f 75 3e 20 3c 62 3e 53 50 41 54 49  ble</u> <b>SPATI
4030: 41 4c 49 54 45 5f 53 45 43 55 52 49 54 59 3d 72  ALITE_SECURITY=r
4040: 65 6c 61 78 65 64 3c 2f 62 3e 20 68 61 73 20 74  elaxed</b> has t
4050: 6f 20 62 65 20 64 65 66 69 6e 65 64 2e 0d 0a 3c  o be defined...<
4060: 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43  verbatim>..SELEC
4070: 54 20 43 6f 75 6e 74 55 6e 73 61 66 65 54 72 69  T CountUnsafeTri
4080: 67 67 65 72 73 28 29 3b 0d 0a 2d 2d 2d 2d 2d 2d  ggers();..------
4090: 2d 2d 2d 0d 0a 30 0d 0a 3c 2f 76 65 72 62 61 74  ---..0..</verbat
40a0: 69 6d 3e 0d 0a 54 68 65 20 3c 62 3e 43 6f 75 6e  im>..The <b>Coun
40b0: 74 55 6e 73 61 66 65 54 72 69 67 67 65 72 73 28  tUnsafeTriggers(
40c0: 29 3c 2f 62 3e 20 61 63 74 75 61 6c 6c 79 20 63  )</b> actually c
40d0: 68 65 63 6b 73 20 69 66 20 74 68 65 20 63 6f 6e  hecks if the con
40e0: 6e 65 63 74 65 64 20 44 61 74 61 62 61 73 65 20  nected Database 
40f0: 64 6f 65 73 20 63 6f 6e 74 61 69 6e 73 20 61 6e  does contains an
4100: 79 20 73 75 73 70 65 63 74 20 54 72 69 67 67 65  y suspect Trigge
4110: 72 3b 20 63 68 65 63 6b 69 6e 67 20 74 68 69 73  r; checking this
4120: 20 76 65 72 73 69 6f 6e 20 62 65 66 6f 72 65 20   version before 
4130: 65 6e 61 62 6c 69 6e 67 20 74 68 65 20 75 6e 73  enabling the uns
4140: 61 66 65 20 53 51 4c 20 46 75 6e 63 74 69 6f 6e  afe SQL Function
4150: 73 20 69 73 20 61 6c 77 61 79 73 20 68 69 67 68  s is always high
4160: 6c 79 20 72 65 63 6f 6d 6d 65 6e 64 65 64 2e 3c  ly recommended.<
4170: 62 72 3e 0d 0a 41 20 72 65 73 75 6c 74 20 64 69  br>..A result di
4180: 66 66 65 72 65 6e 74 20 66 72 6f 6d 20 5a 45 52  fferent from ZER
4190: 4f 20 69 6d 70 6c 69 65 73 20 74 68 61 74 20 73  O implies that s
41a0: 6f 6d 65 20 6d 61 6c 69 63 69 6f 75 73 20 54 72  ome malicious Tr
41b0: 69 67 67 65 72 20 68 61 73 20 62 65 65 6e 20 69  igger has been i
41c0: 64 65 6e 74 69 66 69 65 64 3b 20 69 6e 20 74 68  dentified; in th
41d0: 69 73 20 63 61 73 65 20 79 6f 75 20 63 61 6e 20  is case you can 
41e0: 70 65 72 66 6f 72 6d 20 61 20 64 65 65 70 65 73  perform a deepes
41f0: 74 20 69 6e 73 70 65 63 74 69 6f 6e 20 62 79 20  t inspection by 
4200: 65 78 65 63 75 74 69 6e 67 20 74 68 65 20 66 6f  executing the fo
4210: 6c 6c 6f 77 69 6e 67 20 53 51 4c 20 71 75 65 72  llowing SQL quer
4220: 79 3a 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a  y:..<verbatim>..
4230: 53 45 4c 45 43 54 20 74 79 70 65 2c 20 6e 61 6d  SELECT type, nam
4240: 65 2c 20 74 62 6c 5f 6e 61 6d 65 2c 20 73 71 6c  e, tbl_name, sql
4250: 20 0d 0a 46 52 4f 4d 20 73 71 6c 69 74 65 5f 6d   ..FROM sqlite_m
4260: 61 73 74 65 72 20 0d 0a 57 48 45 52 45 20 74 79  aster ..WHERE ty
4270: 70 65 20 49 4e 20 28 27 74 72 69 67 67 65 72 27  pe IN ('trigger'
4280: 2c 20 27 76 69 65 77 27 29 20 41 4e 44 20 28 73  , 'view') AND (s
4290: 71 6c 20 4c 49 4b 45 20 27 25 42 6c 6f 62 46 72  ql LIKE '%BlobFr
42a0: 6f 6d 46 69 6c 65 25 27 20 0d 0a 20 20 20 4f 52  omFile%' ..   OR
42b0: 20 73 71 6c 20 4c 49 4b 45 20 27 25 42 6c 6f 62   sql LIKE '%Blob
42c0: 54 6f 46 69 6c 65 25 27 20 4f 52 20 73 71 6c 20  ToFile%' OR sql 
42d0: 4c 49 4b 45 20 27 25 58 42 5f 4c 6f 61 64 58 4d  LIKE '%XB_LoadXM
42e0: 4c 25 27 20 0d 0a 20 20 20 4f 52 20 73 71 6c 20  L%' ..   OR sql 
42f0: 4c 49 4b 45 20 27 25 58 42 5f 53 74 6f 72 65 58  LIKE '%XB_StoreX
4300: 4d 4c 25 27 29 3b 0d 0a 3c 2f 76 65 72 62 61 74  ML%');..</verbat
4310: 69 6d 3e 0d 0a 74 68 69 73 20 77 69 6c 6c 20 67  im>..this will g
4320: 69 76 65 20 61 20 66 75 6c 6c 20 72 65 70 6f 72  ive a full repor
4330: 74 20 66 6f 72 20 61 6e 79 20 6d 61 6c 69 63 69  t for any malici
4340: 6f 75 73 20 54 72 69 67 67 65 72 20 65 76 65 6e  ous Trigger even
4350: 74 75 61 6c 6c 79 20 66 6f 75 6e 64 2e 3c 62 72  tually found.<br
4360: 3e 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c 76 65  ><br>..<hr>..<ve
4370: 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20  rbatim>..SELECT 
4380: 42 6c 6f 62 46 72 6f 6d 46 69 6c 65 28 20 27 43  BlobFromFile( 'C
4390: 3a 2f 6d 79 70 69 63 74 75 72 65 73 2f 73 75 6e  :/mypictures/sun
43a0: 73 65 74 2e 6a 70 67 27 20 29 3b 0d 0a 2d 2d 2d  set.jpg' );..---
43b0: 2d 2d 2d 2d 2d 2d 0d 0a 42 4c 4f 42 2d 76 61 6c  ------..BLOB-val
43c0: 75 65 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d  ue..</verbatim>.
43d0: 0a 54 68 65 20 3c 62 3e 42 6c 6f 62 46 72 6f 6d  .The <b>BlobFrom
43e0: 46 69 6c 65 28 29 3c 2f 62 3e 20 53 51 4c 20 66  File()</b> SQL f
43f0: 75 6e 63 74 69 6f 6e 20 61 6c 6c 6f 77 73 20 74  unction allows t
4400: 6f 20 69 6d 70 6f 72 74 20 61 20 77 68 6f 6c 65  o import a whole
4410: 20 66 69 6c 65 20 69 6e 20 61 20 73 69 6e 67 6c   file in a singl
4420: 65 20 73 74 65 70 3b 20 74 68 65 20 66 75 6c 6c  e step; the full
4430: 20 66 69 6c 65 20 70 61 79 6c 6f 61 64 20 77 69   file payload wi
4440: 6c 6c 20 62 65 20 72 65 74 75 72 6e 65 64 20 61  ll be returned a
4450: 73 20 61 20 42 4c 4f 42 20 76 61 6c 75 65 2e 3c  s a BLOB value.<
4460: 62 72 3e 0d 0a 49 66 20 74 68 65 20 61 72 67 75  br>..If the argu
4470: 6d 65 6e 74 20 28 3c 62 3e 66 69 6c 65 2d 70 61  ment (<b>file-pa
4480: 74 68 3c 2f 62 3e 29 20 64 6f 65 73 6e 27 74 20  th</b>) doesn't 
4490: 63 6f 72 72 65 73 70 6f 6e 64 73 20 74 6f 20 61  corresponds to a
44a0: 20 76 61 6c 69 64 20 66 69 6c 65 20 6f 72 20 69   valid file or i
44b0: 66 20 74 68 65 20 65 78 74 65 72 6e 61 6c 20 66  f the external f
44c0: 69 6c 65 20 63 61 6e 6e 6f 74 20 62 65 20 61 63  ile cannot be ac
44d0: 63 65 73 73 65 64 20 66 6f 72 20 61 6e 79 20 72  cessed for any r
44e0: 65 61 73 6f 6e 20 4e 55 4c 4c 20 77 69 6c 6c 20  eason NULL will 
44f0: 62 65 20 72 65 74 75 72 6e 65 64 2e 3c 62 72 3e  be returned.<br>
4500: 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72  <br>..<hr>..<ver
4510: 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 42  batim>..SELECT B
4520: 6c 6f 62 54 6f 46 69 6c 65 28 20 73 6f 6d 65 42  lobToFile( someB
4530: 6c 6f 62 20 2c 20 27 43 3a 2f 6d 79 70 69 63 74  lob , 'C:/mypict
4540: 75 72 65 73 2f 73 75 6e 73 65 74 2e 6a 70 67 27  ures/sunset.jpg'
4550: 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a   );..---------..
4560: 31 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a  1..</verbatim>..
4570: 54 68 65 20 3c 62 3e 42 6c 6f 62 54 6f 46 69 6c  The <b>BlobToFil
4580: 65 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63  e()</b> SQL func
4590: 74 69 6f 6e 20 70 65 72 66 6f 72 6d 73 20 74 68  tion performs th
45a0: 65 20 6f 70 70 6f 73 69 74 65 20 74 61 73 6b 2c  e opposite task,
45b0: 20 69 2e 65 2e 20 69 74 20 65 78 70 6f 72 74 73   i.e. it exports
45c0: 20 61 20 77 68 6f 6c 65 20 42 4c 4f 42 20 69 6e   a whole BLOB in
45d0: 74 6f 20 61 6e 20 65 78 74 65 72 6e 61 6c 20 66  to an external f
45e0: 69 6c 65 3b 20 74 68 65 20 66 69 72 73 74 20 61  ile; the first a
45f0: 72 67 75 6d 65 6e 74 20 6d 75 73 74 20 63 6f 72  rgument must cor
4600: 72 65 73 70 6f 6e 64 20 74 6f 20 73 6f 6d 65 20  respond to some 
4610: 42 4c 4f 42 2c 20 74 68 65 20 73 65 63 6f 6e 64  BLOB, the second
4620: 20 6f 6e 65 20 69 73 20 74 68 65 20 3c 62 3e 66   one is the <b>f
4630: 69 6c 65 2d 70 61 74 68 3c 2f 62 3e 20 69 64 65  ile-path</b> ide
4640: 6e 74 69 66 79 69 6e 67 20 74 68 65 20 66 69 6c  ntifying the fil
4650: 65 20 74 6f 20 62 65 20 63 72 65 61 74 65 64 20  e to be created 
4660: 6f 72 20 6f 76 65 72 77 72 69 74 74 65 6e 2e 3c  or overwritten.<
4670: 62 72 3e 3c 62 72 3e 0d 0a 3c 75 3e 50 6c 65 61  br><br>..<u>Plea
4680: 73 65 20 6e 6f 74 65 3c 2f 75 3e 3a 20 62 6f 74  se note</u>: bot
4690: 68 20 3c 62 3e 42 6c 6f 62 46 72 6f 6d 46 69 6c  h <b>BlobFromFil
46a0: 65 28 29 3c 2f 62 3e 20 61 6e 64 20 3c 62 3e 42  e()</b> and <b>B
46b0: 6c 6f 62 54 6f 46 69 6c 65 28 29 3c 2f 62 3e 20  lobToFile()</b> 
46c0: 77 65 72 65 20 61 6c 72 65 61 64 79 20 73 75 70  were already sup
46d0: 70 6f 72 74 65 64 20 62 79 20 34 2e 30 2e 30 2c  ported by 4.0.0,
46e0: 20 62 75 74 20 61 20 71 75 69 63 6b 20 72 65 63   but a quick rec
46f0: 61 6c 6c 20 69 73 20 61 6e 79 77 61 79 20 75 73  all is anyway us
4700: 65 66 75 6c 20 73 6f 20 74 6f 20 72 65 63 61 6c  eful so to recal
4710: 6c 20 61 20 63 6c 65 61 72 65 72 20 63 6f 6e 74  l a clearer cont
4720: 65 78 74 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68  ext.<br><br>..<h
4730: 72 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a  r>..<verbatim>..
4740: 53 45 4c 45 43 54 20 58 42 5f 4c 6f 61 64 58 4d  SELECT XB_LoadXM
4750: 4c 28 20 27 43 3a 2f 6d 79 64 6f 63 73 2f 69 73  L( 'C:/mydocs/is
4760: 6f 6d 65 74 61 64 61 74 61 2d 73 61 6d 70 6c 65  ometadata-sample
4770: 2e 78 6d 6c 27 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d  .xml' );..------
4780: 2d 2d 0d 0a 42 4c 4f 42 2d 76 61 6c 75 65 0d 0a  --..BLOB-value..
4790: 0d 0a 53 45 4c 45 43 54 20 58 42 5f 4c 6f 61 64  ..SELECT XB_Load
47a0: 58 4d 4c 28 20 27 68 74 74 70 3a 2f 2f 77 77 77  XML( 'http://www
47b0: 2e 61 63 6d 65 2e 63 6f 6d 2f 70 75 62 6c 69 63  .acme.com/public
47c0: 2f 69 73 6f 6d 65 74 61 64 61 74 61 2d 73 61 6d  /isometadata-sam
47d0: 70 6c 65 2e 78 6d 6c 27 20 29 3b 0d 0a 2d 2d 2d  ple.xml' );..---
47e0: 2d 2d 2d 2d 2d 0d 0a 42 4c 4f 42 2d 76 61 6c 75  -----..BLOB-valu
47f0: 65 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a  e..</verbatim>..
4800: 54 68 65 20 3c 62 3e 58 42 5f 4c 6f 61 64 58 4d  The <b>XB_LoadXM
4810: 4c 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63  L()</b> SQL func
4820: 74 69 6f 6e 20 61 6c 6c 6f 77 73 20 74 6f 20 69  tion allows to i
4830: 6d 70 6f 72 74 20 61 6e 20 58 4d 4c 20 44 6f 63  mport an XML Doc
4840: 75 6d 65 6e 74 20 69 6e 20 61 20 73 69 6e 67 6c  ument in a singl
4850: 65 20 73 74 65 70 3a 20 74 68 65 20 66 75 6c 6c  e step: the full
4860: 20 58 4d 4c 20 44 6f 63 75 6d 65 6e 74 20 70 61   XML Document pa
4870: 79 6c 6f 61 64 20 77 69 6c 6c 20 62 65 20 72 65  yload will be re
4880: 74 75 72 6e 65 64 20 61 73 20 61 20 42 4c 4f 42  turned as a BLOB
4890: 20 76 61 6c 75 65 2e 3c 62 72 3e 0d 0a 54 68 65   value.<br>..The
48a0: 20 70 61 73 73 65 64 20 61 72 67 75 6d 65 6e 74   passed argument
48b0: 20 63 61 6e 20 69 6e 64 69 66 66 65 72 65 6e 74   can indifferent
48c0: 6c 79 20 62 65 20 61 20 3c 62 3e 66 69 6c 65 2d  ly be a <b>file-
48d0: 70 61 74 68 3c 2f 62 3e 20 6f 72 20 61 20 3c 62  path</b> or a <b
48e0: 3e 55 52 4c 3c 2f 62 3e 3b 20 69 66 20 74 68 65  >URL</b>; if the
48f0: 20 64 61 74 61 73 6f 75 72 63 65 20 63 61 6e 6e   datasource cann
4900: 6f 74 20 62 65 20 61 63 63 65 73 73 65 64 2c 20  ot be accessed, 
4910: 6f 72 20 69 66 20 69 74 20 64 6f 65 73 6e 27 74  or if it doesn't
4920: 20 63 6f 6e 74 61 69 6e 73 20 61 20 3c 75 3e 77   contains a <u>w
4930: 65 6c 6c 2d 66 6f 72 6d 65 64 3c 2f 75 3e 20 58  ell-formed</u> X
4940: 4d 4c 20 44 6f 63 75 6d 65 6e 74 20 4e 55 4c 4c  ML Document NULL
4950: 20 77 69 6c 6c 20 62 65 20 72 65 74 75 72 6e 65   will be returne
4960: 64 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68 72 3e  d.<br><br>..<hr>
4970: 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45  ..<verbatim>..SE
4980: 4c 45 43 54 20 58 42 5f 53 74 6f 72 65 58 4d 4c  LECT XB_StoreXML
4990: 28 20 73 6f 6d 65 58 6d 6c 42 6c 6f 62 2c 20 27  ( someXmlBlob, '
49a0: 43 3a 2f 6d 79 64 6f 63 73 2f 69 73 6f 6d 65 74  C:/mydocs/isomet
49b0: 61 64 61 74 61 2d 73 61 6d 70 6c 65 2e 78 6d 6c  adata-sample.xml
49c0: 27 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d  ' );..---------.
49d0: 0a 31 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d  .1..</verbatim>.
49e0: 0a 54 68 65 20 3c 62 3e 58 42 5f 53 74 6f 72 65  .The <b>XB_Store
49f0: 58 4d 4c 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75  XML()</b> SQL fu
4a00: 6e 63 74 69 6f 6e 20 70 65 72 66 6f 72 6d 73 20  nction performs 
4a10: 74 68 65 20 6f 70 70 6f 73 69 74 65 20 74 61 73  the opposite tas
4a20: 6b 2c 20 69 2e 65 2e 20 69 74 20 65 78 70 6f 72  k, i.e. it expor
4a30: 74 73 20 61 20 77 68 6f 6c 65 20 58 6d 6c 42 4c  ts a whole XmlBL
4a40: 4f 42 20 69 6e 74 6f 20 61 6e 20 65 78 74 65 72  OB into an exter
4a50: 6e 61 6c 20 66 69 6c 65 20 61 73 20 61 6e 20 58  nal file as an X
4a60: 4d 4c 20 44 6f 63 75 6d 65 6e 74 3b 20 74 68 65  ML Document; the
4a70: 20 66 69 72 73 74 20 61 72 67 75 6d 65 6e 74 20   first argument 
4a80: 6d 75 73 74 20 63 6f 72 72 65 73 70 6f 6e 64 20  must correspond 
4a90: 74 6f 20 73 6f 6d 65 20 76 61 6c 69 64 20 58 6d  to some valid Xm
4aa0: 6c 42 4c 4f 42 2c 20 74 68 65 20 73 65 63 6f 6e  lBLOB, the secon
4ab0: 64 20 6f 6e 65 20 69 73 20 74 68 65 20 3c 62 3e  d one is the <b>
4ac0: 66 69 6c 65 2d 70 61 74 68 3c 2f 62 3e 20 69 64  file-path</b> id
4ad0: 65 6e 74 69 66 79 69 6e 67 20 74 68 65 20 66 69  entifying the fi
4ae0: 6c 65 20 74 6f 20 62 65 20 63 72 65 61 74 65 64  le to be created
4af0: 20 6f 72 20 6f 76 65 72 77 72 69 74 74 65 6e 2e   or overwritten.
4b00: 20 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53   ..<verbatim>..S
4b10: 45 4c 45 43 54 20 58 42 5f 53 74 6f 72 65 58 4d  ELECT XB_StoreXM
4b20: 4c 28 20 73 6f 6d 65 58 6d 6c 42 6c 6f 62 2c 20  L( someXmlBlob, 
4b30: 27 43 3a 2f 6d 79 64 6f 63 73 2f 69 73 6f 6d 65  'C:/mydocs/isome
4b40: 74 61 64 61 74 61 2d 73 61 6d 70 6c 65 2e 78 6d  tadata-sample.xm
4b50: 6c 27 2c 20 34 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d  l', 4 );..------
4b60: 2d 2d 2d 0d 0a 31 0d 0a 3c 2f 76 65 72 62 61 74  ---..1..</verbat
4b70: 69 6d 3e 0d 0a 41 20 66 75 72 74 68 65 72 20 6f  im>..A further o
4b80: 70 74 69 6f 6e 61 6c 20 3c 62 3e 69 6e 64 65 6e  ptional <b>inden
4b90: 74 61 74 69 6f 6e 3c 2f 62 3e 20 61 72 67 75 6d  tation</b> argum
4ba0: 65 6e 74 20 63 61 6e 20 62 65 20 65 76 65 6e 74  ent can be event
4bb0: 75 61 6c 6c 79 20 73 70 65 63 69 66 69 65 64 3b  ually specified;
4bc0: 20 74 68 69 73 20 61 72 67 75 6d 65 6e 74 20 77   this argument w
4bd0: 69 6c 6c 20 62 65 20 68 61 6e 64 6c 65 64 20 65  ill be handled e
4be0: 78 61 63 74 6c 79 20 69 6e 20 74 68 65 20 73 61  xactly in the sa
4bf0: 6d 65 20 77 61 79 20 61 6c 72 65 61 64 79 20 73  me way already s
4c00: 70 65 63 69 66 69 65 64 20 66 6f 72 20 62 6f 74  pecified for bot
4c10: 68 20 3c 62 3e 58 42 5f 47 65 74 50 61 79 6c 6f  h <b>XB_GetPaylo
4c20: 61 64 28 29 3c 2f 62 3e 20 61 6e 64 20 3c 62 3e  ad()</b> and <b>
4c30: 58 42 5f 47 65 74 44 6f 63 75 6d 65 6e 74 28 29  XB_GetDocument()
4c40: 3c 2f 62 3e 20 66 75 6e 63 74 69 6f 6e 73 2e 3c  </b> functions.<
4c50: 62 72 3e 3c 62 72 3e 0d 0a 3c 68 72 3e 3c 62 72  br><br>..<hr><br
4c60: 3e 0d 0a 62 61 63 6b 20 74 6f 20 3c 61 20 68 72  >..back to <a hr
4c70: 65 66 3d 22 68 74 74 70 73 3a 2f 2f 77 77 77 2e  ef="https://www.
4c80: 67 61 69 61 2d 67 69 73 2e 69 74 2f 66 6f 73 73  gaia-gis.it/foss
4c90: 69 6c 2f 6c 69 62 73 70 61 74 69 61 6c 69 74 65  il/libspatialite
4ca0: 2f 77 69 6b 69 3f 6e 61 6d 65 3d 34 2e 31 2e 30  /wiki?name=4.1.0
4cb0: 2d 64 6f 63 22 3e 34 2e 31 2e 30 2d 64 6f 63 3c  -doc">4.1.0-doc<
4cc0: 2f 61 3e 0a 5a 20 66 66 38 31 32 64 33 38 32 37  /a>.Z ff812d3827
4cd0: 35 36 32 35 38 38 66 66 35 62 62 30 30 39 34 61  562588ff5bb0094a
4ce0: 39 38 36 39 61 31 0a                             9869a1.