Hex Artifact Content
Not logged in

Artifact 82b94891d619877775688d00ecb4e5caa4d86fc9:

Wiki page [4.1.0 Changes] by sandro 2013-05-30 14:26:33.
0000: 44 20 32 30 31 33 2d 30 35 2d 33 30 54 31 34 3a  D 2013-05-30T14:
0010: 32 36 3a 33 33 2e 33 30 33 0a 4c 20 34 2e 31 2e  26:33.303.L 4.1.
0020: 30 5c 73 43 68 61 6e 67 65 73 0a 50 20 33 32 34  0\sChanges.P 324
0030: 31 39 61 64 66 61 33 61 62 37 33 32 39 35 34 62  19adfa3ab732954b
0040: 64 34 36 62 32 35 63 65 64 33 39 64 36 61 62 39  d46b25ced39d6ab9
0050: 35 63 34 63 37 0a 55 20 73 61 6e 64 72 6f 0a 57  5c4c7.U sandro.W
0060: 20 31 39 35 33 39 0a 62 61 63 6b 20 74 6f 20 3c   19539.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 3f 63 69 72 63 6c 65 73 2d 65 6c 6c 69  iki?circles-elli
0250: 70 73 65 73 22 3e 43 69 72 63 6c 65 73 20 61 6e  pses">Circles an
0260: 64 20 45 6c 6c 69 70 73 65 73 3c 2f 61 3e 3c 2f  d Ellipses</a></
0270: 6c 69 3e 3c 2f 75 6c 3e 3c 2f 6c 69 3e 0d 0a 3c  li></ul></li>..<
0280: 6c 69 3e 53 51 4c 20 66 75 6e 63 74 69 6f 6e 73  li>SQL functions
0290: 20 73 75 70 70 6f 72 74 69 6e 67 20 3c 61 20 68   supporting <a h
02a0: 72 65 66 3d 22 23 75 6e 73 61 66 65 22 3e 75 6e  ref="#unsafe">un
02b0: 73 61 66 65 3c 2f 61 3e 20 64 69 72 65 63 74 20  safe</a> direct 
02c0: 49 6d 70 6f 72 74 2f 45 78 70 6f 72 74 3c 2f 6c  Import/Export</l
02d0: 69 3e 0d 0a 3c 2f 75 6c 3e 0d 0a 3c 68 33 3e 3c  i>..</ul>..<h3><
02e0: 61 20 6e 61 6d 65 3d 22 67 65 6e 65 72 69 63 22  a name="generic"
02f0: 3e 63 61 73 74 3c 2f 61 3e 20 53 51 4c 20 66 75  >cast</a> SQL fu
0300: 6e 63 74 69 6f 6e 73 20 2d 20 74 79 70 65 20 63  nctions - type c
0310: 61 73 74 69 6e 67 3c 2f 68 33 3e 0d 0a 53 51 4c  asting</h3>..SQL
0320: 69 74 65 20 6f 66 66 65 72 73 20 6a 75 73 74 20  ite offers just 
0330: 61 20 76 65 72 79 20 62 61 73 69 63 20 74 79 70  a very basic typ
0340: 65 20 63 68 65 63 6b 69 6e 67 3b 20 74 68 69 73  e checking; this
0350: 20 69 73 20 73 6f 6d 65 74 69 6d 65 73 20 75 73   is sometimes us
0360: 65 66 75 6c 2c 20 62 75 74 20 63 6f 75 6c 64 20  eful, but could 
0370: 62 65 20 72 65 61 6c 6c 79 20 61 6e 6e 6f 79 69  be really annoyi
0380: 6e 67 20 76 65 72 79 20 6f 66 74 65 6e 2e 3c 62  ng very often.<b
0390: 72 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a  r>..<verbatim>..
03a0: 53 45 4c 45 43 54 20 27 31 27 2c 20 54 79 70 65  SELECT '1', Type
03b0: 4f 66 28 20 27 31 27 20 29 2c 20 43 41 53 54 20  Of( '1' ), CAST 
03c0: 28 20 27 31 27 20 41 53 20 49 4e 54 45 47 45 52  ( '1' AS INTEGER
03d0: 20 29 2c 20 54 79 70 65 4f 66 28 20 43 41 53 54   ), TypeOf( CAST
03e0: 20 28 20 27 31 27 20 41 53 20 49 4e 54 45 47 45   ( '1' AS INTEGE
03f0: 52 20 29 20 29 3b 0d 0a 3c 2f 76 65 72 62 61 74  R ) );..</verbat
0400: 69 6d 3e 0d 0a 3c 74 61 62 6c 65 20 62 6f 72 64  im>..<table bord
0410: 65 72 3d 22 31 22 20 63 65 6c 6c 73 70 61 63 69  er="1" cellspaci
0420: 6e 67 3d 22 34 22 20 63 65 6c 6c 70 61 64 64 69  ng="4" cellpaddi
0430: 6e 67 3d 22 34 22 3e 0d 0a 3c 74 72 3e 3c 74 68  ng="4">..<tr><th
0440: 3e 27 31 27 3c 2f 74 68 3e 3c 74 68 3e 54 79 70  >'1'</th><th>Typ
0450: 65 4f 66 28 20 27 31 27 20 29 3c 2f 74 68 3e 3c  eOf( '1' )</th><
0460: 74 68 3e 43 41 53 54 20 28 20 27 31 27 20 41 53  th>CAST ( '1' AS
0470: 20 49 4e 54 45 47 45 52 20 29 3c 2f 74 68 3e 3c   INTEGER )</th><
0480: 74 68 3e 54 79 70 65 4f 66 28 20 43 41 53 54 20  th>TypeOf( CAST 
0490: 28 20 27 31 27 20 41 53 20 49 4e 54 45 47 45 52  ( '1' AS INTEGER
04a0: 20 29 20 29 3c 2f 74 68 3e 3c 2f 74 72 3e 0d 0a   ) )</th></tr>..
04b0: 3c 74 72 3e 3c 74 64 3e 31 3c 2f 74 64 3e 3c 74  <tr><td>1</td><t
04c0: 64 3e 74 65 78 74 3c 2f 74 64 3e 3c 74 64 20 61  d>text</td><td a
04d0: 6c 69 67 6e 3d 22 72 69 67 68 74 22 3e 31 3c 2f  lign="right">1</
04e0: 74 64 3e 3c 74 64 3e 69 6e 74 65 67 65 72 3c 2f  td><td>integer</
04f0: 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e  td></tr></table>
0500: 3c 62 72 3e 0d 0a 54 68 65 20 53 51 4c 20 3c 62  <br>..The SQL <b
0510: 3e 43 41 53 54 3c 2f 62 3e 20 6f 70 65 72 61 74  >CAST</b> operat
0520: 6f 72 20 61 6c 72 65 61 64 79 20 73 75 70 70 6f  or already suppo
0530: 72 74 73 20 74 68 65 20 70 6f 73 73 69 62 69 6c  rts the possibil
0540: 69 74 79 20 74 6f 20 65 78 70 6c 69 63 69 74 6c  ity to explicitl
0550: 79 20 73 65 74 20 61 20 64 61 74 61 2d 74 79 70  y set a data-typ
0560: 65 3b 20 6e 6f 77 20 73 74 61 72 74 69 6e 67 20  e; now starting 
0570: 73 69 6e 63 65 20 34 2e 31 2e 30 20 53 70 61 74  since 4.1.0 Spat
0580: 69 61 4c 69 74 65 20 73 75 70 70 6f 72 74 73 20  iaLite supports 
0590: 66 65 77 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e  few SQL function
05a0: 73 20 70 65 72 66 6f 72 6d 69 6e 67 20 74 68 65  s performing the
05b0: 20 73 61 6d 65 20 74 61 73 6b 2e 3c 62 72 3e 0d   same task.<br>.
05c0: 0a 3c 75 3e 50 6c 65 61 73 65 20 6e 6f 74 65 3c  .<u>Please note<
05d0: 2f 75 3e 3a 20 73 6f 6d 65 20 73 75 62 74 6c 65  /u>: some subtle
05e0: 20 64 69 66 66 65 72 65 6e 63 65 73 20 65 78 69   differences exi
05f0: 73 74 73 20 68 65 72 65 20 61 6e 64 20 74 68 65  sts here and the
0600: 72 65 3b 20 70 6c 65 61 73 65 20 63 61 72 65 66  re; please caref
0610: 75 6c 6c 79 20 72 65 61 64 20 74 68 69 73 20 64  ully read this d
0620: 6f 63 75 6d 65 6e 74 61 74 69 6f 6e 20 70 61 67  ocumentation pag
0630: 65 2e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a  e...<verbatim>..
0640: 53 45 4c 45 43 54 20 43 61 73 74 54 6f 49 6e 74  SELECT CastToInt
0650: 65 67 65 72 28 20 31 20 29 2c 20 43 61 73 74 54  eger( 1 ), CastT
0660: 6f 49 6e 74 65 67 65 72 28 20 31 2e 34 20 29 2c  oInteger( 1.4 ),
0670: 20 43 61 73 74 54 6f 49 6e 74 65 67 65 72 28 20   CastToInteger( 
0680: 31 2e 36 20 29 2c 20 0d 0a 20 20 20 20 43 61 73  1.6 ), ..    Cas
0690: 74 54 6f 49 6e 74 65 67 65 72 28 20 27 31 32 33  tToInteger( '123
06a0: 27 20 29 2c 20 43 61 73 74 54 6f 49 6e 74 65 67  ' ), CastToInteg
06b0: 65 72 28 20 27 61 6c 70 68 61 27 20 29 2c 20 43  er( 'alpha' ), C
06c0: 61 73 74 54 6f 49 6e 74 65 67 65 72 20 28 20 7a  astToInteger ( z
06d0: 65 72 6f 62 6c 6f 62 28 34 29 20 29 3b 0d 0a 3c  eroblob(4) );..<
06e0: 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 3c 74 61 62  /verbatim>..<tab
06f0: 6c 65 20 62 6f 72 64 65 72 3d 22 31 22 20 63 65  le border="1" ce
0700: 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63 65  llspacing="4" ce
0710: 6c 6c 70 61 64 64 69 6e 67 3d 22 34 22 3e 0d 0a  llpadding="4">..
0720: 3c 74 72 3e 3c 74 68 3e 43 61 73 74 54 6f 49 6e  <tr><th>CastToIn
0730: 74 65 67 65 72 28 20 31 20 29 3c 2f 74 68 3e 3c  teger( 1 )</th><
0740: 74 68 3e 43 61 73 74 54 6f 49 6e 74 65 67 65 72  th>CastToInteger
0750: 28 20 31 2e 34 20 29 3c 2f 74 68 3e 3c 74 68 3e  ( 1.4 )</th><th>
0760: 43 61 73 74 54 6f 49 6e 74 65 67 65 72 28 20 31  CastToInteger( 1
0770: 2e 36 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 73  .6 )</th><th>Cas
0780: 74 54 6f 49 6e 74 65 67 65 72 28 20 27 31 32 33  tToInteger( '123
0790: 27 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 74  ' )</th><th>Cast
07a0: 54 6f 49 6e 74 65 67 65 72 28 20 27 61 6c 70 68  ToInteger( 'alph
07b0: 61 27 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 73  a' )</th><th>Cas
07c0: 74 54 6f 49 6e 74 65 67 65 72 20 28 20 7a 65 72  tToInteger ( zer
07d0: 6f 62 6c 6f 62 28 34 29 20 29 3c 2f 74 68 3e 3c  oblob(4) )</th><
07e0: 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 20 61 6c  /tr>..<tr><td al
07f0: 69 67 6e 3d 22 72 69 67 68 74 22 3e 31 3c 2f 74  ign="right">1</t
0800: 64 3e 3c 74 64 20 61 6c 69 67 6e 3d 22 72 69 67  d><td align="rig
0810: 68 74 22 3e 31 3c 2f 74 64 3e 3c 74 64 20 61 6c  ht">1</td><td al
0820: 69 67 6e 3d 22 72 69 67 68 74 22 3e 32 3c 2f 74  ign="right">2</t
0830: 64 3e 3c 74 64 20 61 6c 69 67 6e 3d 22 72 69 67  d><td align="rig
0840: 68 74 22 3e 31 32 33 3c 2f 74 64 3e 3c 74 64 3e  ht">123</td><td>
0850: 4e 55 4c 4c 3c 2f 74 64 3e 3c 74 64 3e 4e 55 4c  NULL</td><td>NUL
0860: 4c 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62  L</td></tr></tab
0870: 6c 65 3e 3c 62 72 3e 0d 0a 54 68 65 20 3c 62 3e  le><br>..The <b>
0880: 43 61 73 74 54 6f 49 6e 74 65 67 65 72 28 29 3c  CastToInteger()<
0890: 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e  /b> SQL function
08a0: 20 77 69 6c 6c 20 61 74 74 65 6d 70 74 20 74 6f   will attempt to
08b0: 20 72 65 74 75 72 6e 20 61 20 76 61 6c 75 65 20   return a value 
08c0: 6f 66 20 74 68 65 20 3c 62 3e 49 6e 74 65 67 65  of the <b>Intege
08d0: 72 3c 2f 62 3e 20 64 61 74 61 2d 74 79 70 65 2c  r</b> data-type,
08e0: 20 6f 72 20 3c 62 3e 4e 55 4c 4c 3c 2f 62 3e 20   or <b>NULL</b> 
08f0: 69 66 20 6e 6f 20 63 6f 6e 76 65 72 73 69 6f 6e  if no conversion
0900: 20 69 73 20 70 6f 73 73 69 62 6c 65 2e 0d 0a 3c   is possible...<
0910: 75 6c 3e 0d 0a 3c 6c 69 3e 61 6e 20 49 6e 74 65  ul>..<li>an Inte
0920: 67 65 72 20 69 6e 70 75 74 20 61 72 67 75 6d 65  ger input argume
0930: 6e 74 20 77 69 6c 6c 20 62 65 20 72 65 74 75 72  nt will be retur
0940: 6e 65 64 20 61 62 73 6f 6c 75 74 65 6c 79 20 75  ned absolutely u
0950: 6e 61 66 66 65 63 74 65 64 2e 3c 2f 6c 69 3e 0d  naffected.</li>.
0960: 0a 3c 6c 69 3e 61 20 44 6f 75 62 6c 65 20 69 6e  .<li>a Double in
0970: 70 75 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c  put argument wil
0980: 6c 20 72 65 74 75 72 6e 20 74 68 65 20 3c 75 3e  l return the <u>
0990: 6e 65 61 72 65 73 74 3c 2f 75 3e 20 49 6e 74 65  nearest</u> Inte
09a0: 67 65 72 20 76 61 6c 75 65 20 28 61 66 74 65 72  ger value (after
09b0: 20 61 70 70 6c 79 69 6e 67 20 3c 62 3e 34 2f 35   applying <b>4/5
09c0: 3c 2f 62 3e 20 72 6f 75 6e 64 69 6e 67 29 2e 3c  </b> rounding).<
09d0: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 20 54 65 78 74  /li>..<li>a Text
09e0: 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 20   input argument 
09f0: 77 69 6c 6c 20 72 65 74 75 72 6e 20 74 68 65 20  will return the 
0a00: 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20 49 6e  corresponding In
0a10: 74 65 67 65 72 20 76 61 6c 75 65 20 6f 6e 6c 79  teger value only
0a20: 20 69 66 20 74 68 65 20 74 65 78 74 20 73 74 72   if the text str
0a30: 69 6e 67 20 72 65 70 72 65 73 65 6e 74 73 20 61  ing represents a
0a40: 20 76 61 6c 69 64 20 6e 75 6d 62 65 72 20 28 65   valid number (e
0a50: 76 65 6e 20 61 20 64 65 63 69 6d 61 6c 20 6f 6e  ven a decimal on
0a60: 65 29 3a 20 69 66 20 74 68 65 20 74 65 78 74 20  e): if the text 
0a70: 73 74 72 69 6e 67 20 63 61 6e 6e 6f 74 20 62 65  string cannot be
0a80: 20 63 6f 6e 76 65 72 74 65 64 20 74 6f 20 61 20   converted to a 
0a90: 6e 75 6d 62 65 72 20 4e 55 4c 4c 20 77 69 6c 6c  number NULL will
0aa0: 20 62 65 20 72 65 74 75 72 6e 65 64 2e 3c 2f 6c   be returned.</l
0ab0: 69 3e 0d 0a 3c 6c 69 3e 61 6e 79 20 42 4c 4f 42  i>..<li>any BLOB
0ac0: 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 20   input argument 
0ad0: 77 69 6c 6c 20 72 65 74 75 72 6e 20 61 20 4e 55  will return a NU
0ae0: 4c 4c 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a  LL value.</li>..
0af0: 3c 6c 69 3e 61 6e 79 20 4e 55 4c 4c 20 69 6e 70  <li>any NULL inp
0b00: 75 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c  ut argument will
0b10: 20 72 65 74 75 72 6e 20 61 20 4e 55 4c 4c 20 76   return a NULL v
0b20: 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c  alue.</li>..</ul
0b30: 3e 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c 76 65  ><br>..<hr>..<ve
0b40: 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20  rbatim>..SELECT 
0b50: 43 61 73 74 54 6f 44 6f 75 62 6c 65 28 20 31 20  CastToDouble( 1 
0b60: 29 2c 20 43 61 73 74 54 6f 44 6f 75 62 6c 65 28  ), CastToDouble(
0b70: 20 31 2e 32 33 20 29 2c 20 43 61 73 74 54 6f 44   1.23 ), CastToD
0b80: 6f 75 62 6c 65 28 20 27 31 32 33 2e 34 35 27 20  ouble( '123.45' 
0b90: 29 2c 0d 0a 20 20 20 20 43 61 73 74 54 6f 44 6f  ),..    CastToDo
0ba0: 75 62 6c 65 28 20 27 61 6c 70 68 61 27 20 29 2c  uble( 'alpha' ),
0bb0: 20 43 61 73 74 54 6f 44 6f 75 62 6c 65 20 28 20   CastToDouble ( 
0bc0: 7a 65 72 6f 62 6c 6f 62 28 34 29 20 29 3b 0d 0a  zeroblob(4) );..
0bd0: 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 3c 74 61  </verbatim>..<ta
0be0: 62 6c 65 20 62 6f 72 64 65 72 3d 22 31 22 20 63  ble border="1" c
0bf0: 65 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63  ellspacing="4" c
0c00: 65 6c 6c 70 61 64 64 69 6e 67 3d 22 34 22 3e 0d  ellpadding="4">.
0c10: 0a 3c 74 72 3e 3c 74 68 3e 43 61 73 74 54 6f 44  .<tr><th>CastToD
0c20: 6f 75 62 6c 65 28 20 31 20 29 3c 2f 74 68 3e 3c  ouble( 1 )</th><
0c30: 74 68 3e 43 61 73 74 54 6f 44 6f 75 62 6c 65 28  th>CastToDouble(
0c40: 20 31 2e 32 33 20 29 3c 2f 74 68 3e 3c 74 68 3e   1.23 )</th><th>
0c50: 43 61 73 74 54 6f 44 6f 75 62 6c 65 28 20 27 31  CastToDouble( '1
0c60: 32 33 2e 34 35 27 20 29 3c 2f 74 68 3e 3c 74 68  23.45' )</th><th
0c70: 3e 43 61 73 74 54 6f 44 6f 75 62 6c 65 28 20 27  >CastToDouble( '
0c80: 61 6c 70 68 61 27 20 29 3c 2f 74 68 3e 3c 74 68  alpha' )</th><th
0c90: 3e 43 61 73 74 54 6f 44 6f 75 62 6c 65 20 28 20  >CastToDouble ( 
0ca0: 7a 65 72 6f 62 6c 6f 62 28 34 29 20 29 3c 2f 74  zeroblob(4) )</t
0cb0: 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64  h></tr>..<tr><td
0cc0: 20 61 6c 69 67 6e 3d 22 72 69 67 68 74 22 3e 31   align="right">1
0cd0: 2e 30 30 30 30 30 30 3c 2f 74 64 3e 3c 74 64 20  .000000</td><td 
0ce0: 61 6c 69 67 6e 3d 22 72 69 67 68 74 22 3e 31 2e  align="right">1.
0cf0: 32 33 30 30 30 30 3c 2f 74 64 3e 3c 74 64 20 61  230000</td><td a
0d00: 6c 69 67 6e 3d 22 72 69 67 68 74 22 3e 31 32 33  lign="right">123
0d10: 2e 34 35 30 30 30 3c 2f 74 64 3e 3c 74 64 3e 4e  .45000</td><td>N
0d20: 55 4c 4c 3c 2f 74 64 3e 3c 74 64 3e 4e 55 4c 4c  ULL</td><td>NULL
0d30: 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c  </td></tr></tabl
0d40: 65 3e 3c 62 72 3e 0d 0a 54 68 65 20 3c 62 3e 43  e><br>..The <b>C
0d50: 61 73 74 54 6f 44 6f 75 62 6c 65 28 29 3c 2f 62  astToDouble()</b
0d60: 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 77  > SQL function w
0d70: 69 6c 6c 20 61 74 74 65 6d 70 74 20 74 6f 20 72  ill attempt to r
0d80: 65 74 75 72 6e 20 61 20 76 61 6c 75 65 20 6f 66  eturn a value of
0d90: 20 74 68 65 20 3c 62 3e 44 6f 75 62 6c 65 3c 2f   the <b>Double</
0da0: 62 3e 20 64 61 74 61 2d 74 79 70 65 2c 20 6f 72  b> data-type, or
0db0: 20 3c 62 3e 4e 55 4c 4c 3c 2f 62 3e 20 69 66 20   <b>NULL</b> if 
0dc0: 6e 6f 20 63 6f 6e 76 65 72 73 69 6f 6e 20 69 73  no conversion is
0dd0: 20 70 6f 73 73 69 62 6c 65 2e 0d 0a 3c 75 6c 3e   possible...<ul>
0de0: 0d 0a 3c 6c 69 3e 61 6e 20 49 6e 74 65 67 65 72  ..<li>an Integer
0df0: 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 20   input argument 
0e00: 77 69 6c 6c 20 72 65 74 75 72 6e 20 74 68 65 20  will return the 
0e10: 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20 44 6f  corresponding Do
0e20: 75 62 6c 65 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e  uble value.</li>
0e30: 0d 0a 3c 6c 69 3e 61 20 44 6f 75 62 6c 65 20 69  ..<li>a Double i
0e40: 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 20 77 69  nput argument wi
0e50: 6c 6c 20 62 65 20 72 65 74 75 72 6e 65 64 20 61  ll be returned a
0e60: 62 73 6f 6c 75 74 65 6c 79 20 75 6e 61 66 66 65  bsolutely unaffe
0e70: 63 74 65 64 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e  cted.</li>..<li>
0e80: 61 20 54 65 78 74 20 69 6e 70 75 74 20 61 72 67  a Text input arg
0e90: 75 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75 72  ument will retur
0ea0: 6e 20 74 68 65 20 63 6f 72 72 65 73 70 6f 6e 64  n the correspond
0eb0: 69 6e 67 20 44 6f 75 62 6c 65 20 76 61 6c 75 65  ing Double value
0ec0: 20 6f 6e 6c 79 20 69 66 20 74 68 65 20 74 65 78   only if the tex
0ed0: 74 20 73 74 72 69 6e 67 20 72 65 70 72 65 73 65  t string represe
0ee0: 6e 74 73 20 61 20 76 61 6c 69 64 20 6e 75 6d 62  nts a valid numb
0ef0: 65 72 3a 20 69 66 20 74 68 65 20 74 65 78 74 20  er: if the text 
0f00: 73 74 72 69 6e 67 20 63 61 6e 6e 6f 74 20 62 65  string cannot be
0f10: 20 63 6f 6e 76 65 72 74 65 64 20 74 6f 20 61 20   converted to a 
0f20: 6e 75 6d 62 65 72 20 4e 55 4c 4c 20 77 69 6c 6c  number NULL will
0f30: 20 62 65 20 72 65 74 75 72 6e 65 64 2e 3c 2f 6c   be returned.</l
0f40: 69 3e 0d 0a 3c 6c 69 3e 61 6e 79 20 42 4c 4f 42  i>..<li>any BLOB
0f50: 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 20   input argument 
0f60: 77 69 6c 6c 20 72 65 74 75 72 6e 20 61 20 4e 55  will return a NU
0f70: 4c 4c 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a  LL value.</li>..
0f80: 3c 6c 69 3e 61 6e 79 20 4e 55 4c 4c 20 69 6e 70  <li>any NULL inp
0f90: 75 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c  ut argument will
0fa0: 20 72 65 74 75 72 6e 20 61 20 4e 55 4c 4c 20 76   return a NULL v
0fb0: 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c  alue.</li>..</ul
0fc0: 3e 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c 76 65  ><br>..<hr>..<ve
0fd0: 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20  rbatim>..SELECT 
0fe0: 43 61 73 74 54 6f 54 65 78 74 28 20 31 20 29 2c  CastToText( 1 ),
0ff0: 20 43 61 73 74 54 6f 54 65 78 74 28 20 31 2e 35   CastToText( 1.5
1000: 20 29 2c 20 43 61 73 74 54 6f 54 65 78 74 28 20   ), CastToText( 
1010: 27 61 6c 70 68 61 27 20 29 2c 20 43 61 73 74 54  'alpha' ), CastT
1020: 6f 54 65 78 74 20 28 20 7a 65 72 6f 62 6c 6f 62  oText ( zeroblob
1030: 28 34 29 20 29 3b 0d 0a 3c 2f 76 65 72 62 61 74  (4) );..</verbat
1040: 69 6d 3e 0d 0a 3c 74 61 62 6c 65 20 62 6f 72 64  im>..<table bord
1050: 65 72 3d 22 31 22 20 63 65 6c 6c 73 70 61 63 69  er="1" cellspaci
1060: 6e 67 3d 22 34 22 20 63 65 6c 6c 70 61 64 64 69  ng="4" cellpaddi
1070: 6e 67 3d 22 34 22 3e 0d 0a 3c 74 72 3e 3c 74 68  ng="4">..<tr><th
1080: 3e 43 61 73 74 54 6f 54 65 78 74 28 20 31 20 29  >CastToText( 1 )
1090: 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 74 54 6f 54  </th><th>CastToT
10a0: 65 78 74 28 20 31 2e 35 20 29 3c 2f 74 68 3e 3c  ext( 1.5 )</th><
10b0: 74 68 3e 43 61 73 74 54 6f 54 65 78 74 28 20 27  th>CastToText( '
10c0: 61 6c 70 68 61 27 20 29 3c 2f 74 68 3e 3c 74 68  alpha' )</th><th
10d0: 3e 43 61 73 74 54 6f 54 65 78 74 20 28 20 7a 65  >CastToText ( ze
10e0: 72 6f 62 6c 6f 62 28 34 29 20 29 3c 2f 74 68 3e  roblob(4) )</th>
10f0: 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 31  </tr>..<tr><td>1
1100: 3c 2f 74 64 3e 3c 74 64 3e 31 2e 35 3c 2f 74 64  </td><td>1.5</td
1110: 3e 3c 74 64 3e 61 6c 70 68 61 3c 2f 74 64 3e 3c  ><td>alpha</td><
1120: 74 64 3e 4e 55 4c 4c 3c 2f 74 64 3e 3c 2f 74 72  td>NULL</td></tr
1130: 3e 3c 2f 74 61 62 6c 65 3e 3c 62 72 3e 0d 0a 54  ></table><br>..T
1140: 68 65 20 3c 62 3e 43 61 73 74 54 6f 54 65 78 74  he <b>CastToText
1150: 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74  ()</b> SQL funct
1160: 69 6f 6e 20 77 69 6c 6c 20 61 74 74 65 6d 70 74  ion will attempt
1170: 20 74 6f 20 72 65 74 75 72 6e 20 61 20 76 61 6c   to return a val
1180: 75 65 20 6f 66 20 74 68 65 20 3c 62 3e 54 65 78  ue of the <b>Tex
1190: 74 3c 2f 62 3e 20 64 61 74 61 2d 74 79 70 65 2c  t</b> data-type,
11a0: 20 6f 72 20 3c 62 3e 4e 55 4c 4c 3c 2f 62 3e 20   or <b>NULL</b> 
11b0: 69 66 20 6e 6f 20 63 6f 6e 76 65 72 73 69 6f 6e  if no conversion
11c0: 20 69 73 20 70 6f 73 73 69 62 6c 65 2e 0d 0a 3c   is possible...<
11d0: 75 6c 3e 0d 0a 3c 6c 69 3e 61 6e 20 49 6e 74 65  ul>..<li>an Inte
11e0: 67 65 72 20 69 6e 70 75 74 20 61 72 67 75 6d 65  ger input argume
11f0: 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 74  nt will return t
1200: 68 65 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67  he corresponding
1210: 20 54 65 78 74 20 76 61 6c 75 65 2e 3c 2f 6c 69   Text value.</li
1220: 3e 0d 0a 3c 6c 69 3e 61 20 44 6f 75 62 6c 65 20  >..<li>a Double 
1230: 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 20 77  input argument w
1240: 69 6c 6c 20 62 65 20 72 65 74 75 72 6e 20 74 68  ill be return th
1250: 65 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20  e corresponding 
1260: 54 65 78 74 20 76 61 6c 75 65 3b 20 6e 6f 20 73  Text value; no s
1270: 69 67 6e 69 66 69 63 61 6e 74 20 64 65 63 69 6d  ignificant decim
1280: 61 6c 20 64 69 67 69 74 20 77 69 6c 6c 20 62 65  al digit will be
1290: 20 73 75 70 70 72 65 73 73 65 64 2e 3c 2f 6c 69   suppressed.</li
12a0: 3e 0d 0a 3c 6c 69 3e 61 20 54 65 78 74 20 69 6e  >..<li>a Text in
12b0: 70 75 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c  put argument wil
12c0: 6c 20 72 65 74 75 72 6e 20 74 68 65 20 63 6f 72  l return the cor
12d0: 72 65 73 70 6f 6e 64 69 6e 67 20 44 6f 75 62 6c  responding Doubl
12e0: 65 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c  e value.</li>..<
12f0: 6c 69 3e 61 6e 79 20 42 4c 4f 42 20 69 6e 70 75  li>any BLOB inpu
1300: 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20  t argument will 
1310: 72 65 74 75 72 6e 20 61 20 4e 55 4c 4c 20 76 61  return a NULL va
1320: 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61  lue.</li>..<li>a
1330: 6e 79 20 4e 55 4c 4c 20 69 6e 70 75 74 20 61 72  ny NULL input ar
1340: 67 75 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75  gument will retu
1350: 72 6e 20 61 20 4e 55 4c 4c 20 76 61 6c 75 65 2e  rn a NULL value.
1360: 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 0d 0a 3c 76  </li>..</ul>..<v
1370: 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54  erbatim>..SELECT
1380: 20 43 61 73 74 54 6f 54 65 78 74 28 20 31 2c 20   CastToText( 1, 
1390: 34 20 29 2c 20 43 61 73 74 54 6f 54 65 78 74 28  4 ), CastToText(
13a0: 20 31 32 33 34 2c 20 32 20 29 2c 20 43 61 73 74   1234, 2 ), Cast
13b0: 54 6f 54 65 78 74 28 20 31 2c 20 38 20 29 2c 20  ToText( 1, 8 ), 
13c0: 43 61 73 74 54 6f 54 65 78 74 28 20 31 2e 35 2c  CastToText( 1.5,
13d0: 20 34 20 29 3b 0d 0a 3c 2f 76 65 72 62 61 74 69   4 );..</verbati
13e0: 6d 3e 0d 0a 3c 74 61 62 6c 65 20 62 6f 72 64 65  m>..<table borde
13f0: 72 3d 22 31 22 20 63 65 6c 6c 73 70 61 63 69 6e  r="1" cellspacin
1400: 67 3d 22 34 22 20 63 65 6c 6c 70 61 64 64 69 6e  g="4" cellpaddin
1410: 67 3d 22 34 22 3e 0d 0a 3c 74 72 3e 3c 74 68 3e  g="4">..<tr><th>
1420: 43 61 73 74 54 6f 54 65 78 74 28 20 31 2c 20 34  CastToText( 1, 4
1430: 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 74 54   )</th><th>CastT
1440: 6f 54 65 78 74 28 20 31 32 33 34 2c 20 32 20 29  oText( 1234, 2 )
1450: 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 74 54 6f 54  </th><th>CastToT
1460: 65 78 74 28 20 31 2c 20 38 20 29 3c 2f 74 68 3e  ext( 1, 8 )</th>
1470: 3c 74 68 3e 43 61 73 74 54 6f 54 65 78 74 28 20  <th>CastToText( 
1480: 31 2e 35 2c 20 34 20 29 3c 2f 74 68 3e 3c 2f 74  1.5, 4 )</th></t
1490: 72 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 30 30 30 31  r>..<tr><td>0001
14a0: 3c 2f 74 64 3e 3c 74 64 3e 31 32 33 34 3c 2f 74  </td><td>1234</t
14b0: 64 3e 3c 74 64 3e 30 30 30 30 30 30 30 31 3c 2f  d><td>00000001</
14c0: 74 64 3e 3c 74 64 3e 30 30 30 31 2e 35 3c 2f 74  td><td>0001.5</t
14d0: 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 3c  d></tr></table><
14e0: 62 72 3e 0d 0a 41 6e 20 6f 76 65 72 6c 6f 61 64  br>..An overload
14f0: 65 64 20 76 65 72 73 69 6f 6e 20 6f 66 20 3c 62  ed version of <b
1500: 3e 43 61 73 74 54 6f 54 65 78 74 28 29 3c 2f 62  >CastToText()</b
1510: 3e 20 69 73 20 73 75 70 70 6f 72 74 65 64 20 61  > is supported a
1520: 73 20 77 65 6c 6c 2c 20 62 75 74 20 6f 6e 6c 79  s well, but only
1530: 20 77 68 65 6e 20 74 68 65 20 69 6e 70 75 74 20   when the input 
1540: 61 72 67 75 6d 65 6e 74 20 69 73 20 6f 66 20 74  argument is of t
1550: 68 65 20 49 6e 74 65 67 65 72 20 6f 72 20 44 6f  he Integer or Do
1560: 75 62 6c 65 20 64 61 74 61 2d 74 79 70 65 3a 20  uble data-type: 
1570: 69 6e 20 74 68 69 73 20 63 61 73 65 20 61 20 73  in this case a s
1580: 65 63 6f 6e 64 20 49 6e 74 65 67 65 72 20 61 72  econd Integer ar
1590: 67 75 6d 65 6e 74 20 63 6f 75 6c 64 20 62 65 20  gument could be 
15a0: 6f 70 74 69 6f 6e 61 6c 6c 79 20 73 70 65 63 69  optionally speci
15b0: 66 69 65 64 2c 20 61 6e 64 20 77 69 6c 6c 20 62  fied, and will b
15c0: 65 20 69 6e 74 65 72 70 72 65 74 65 64 20 61 64  e interpreted ad
15d0: 20 3c 62 3e 7a 65 72 6f 2d 70 61 64 64 69 6e 67   <b>zero-padding
15e0: 2d 6c 65 6e 67 74 68 3c 2f 62 3e 2e 3c 62 72 3e  -length</b>.<br>
15f0: 0d 0a 69 2e 65 2e 20 74 68 65 20 72 65 74 75 72  ..i.e. the retur
1600: 6e 65 64 20 54 65 78 74 20 73 74 72 69 6e 67 20  ned Text string 
1610: 69 6e 20 74 68 69 73 20 63 61 73 65 20 77 69 6c  in this case wil
1620: 6c 20 68 61 76 65 20 61 6e 20 69 6e 74 65 67 65  l have an intege
1630: 72 20 70 61 72 74 20 61 74 20 6c 65 61 73 74 20  r part at least 
1640: 6f 66 20 74 68 65 20 73 70 65 63 69 66 69 65 64  of the specified
1650: 20 6c 65 6e 67 74 68 2c 20 61 6e 64 20 65 76 65   length, and eve
1660: 6e 74 75 61 6c 6c 79 20 70 61 64 64 65 64 20 62  ntually padded b
1670: 79 20 69 6e 73 65 72 74 69 6e 67 20 6e 6f 74 20  y inserting not 
1680: 73 69 67 6e 69 66 69 63 61 6e 74 20 6c 65 61 64  significant lead
1690: 69 6e 67 20 5a 45 52 4f 65 73 2e 3c 62 72 3e 3c  ing ZEROes.<br><
16a0: 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72 62  br>..<hr>..<verb
16b0: 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 43 61  atim>..SELECT Ca
16c0: 73 74 54 6f 42 6c 6f 62 28 20 31 20 29 2c 20 43  stToBlob( 1 ), C
16d0: 61 73 74 54 6f 42 6c 6f 62 28 20 31 2e 35 20 29  astToBlob( 1.5 )
16e0: 2c 20 48 65 78 28 20 43 61 73 74 54 6f 42 6c 6f  , Hex( CastToBlo
16f0: 62 28 20 27 61 6c 70 68 61 27 20 29 20 29 2c 20  b( 'alpha' ) ), 
1700: 48 65 78 20 28 20 43 61 73 74 54 6f 42 6c 6f 62  Hex ( CastToBlob
1710: 20 28 20 7a 65 72 6f 62 6c 6f 62 28 34 29 20 29   ( zeroblob(4) )
1720: 20 29 3b 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e   );..</verbatim>
1730: 0d 0a 3c 74 61 62 6c 65 20 62 6f 72 64 65 72 3d  ..<table border=
1740: 22 31 22 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d  "1" cellspacing=
1750: 22 34 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d  "4" cellpadding=
1760: 22 34 22 3e 0d 0a 3c 74 72 3e 3c 74 68 3e 43 61  "4">..<tr><th>Ca
1770: 73 74 54 6f 42 6c 6f 62 28 20 31 20 29 3c 2f 74  stToBlob( 1 )</t
1780: 68 3e 3c 74 68 3e 43 61 73 74 54 6f 42 6c 6f 62  h><th>CastToBlob
1790: 28 20 31 2e 35 20 29 3c 2f 74 68 3e 3c 74 68 3e  ( 1.5 )</th><th>
17a0: 48 65 78 28 20 43 61 73 74 54 6f 42 6c 6f 62 28  Hex( CastToBlob(
17b0: 20 27 61 6c 70 68 61 27 20 29 20 29 3c 2f 74 68   'alpha' ) )</th
17c0: 3e 3c 74 68 3e 48 65 78 28 20 43 61 73 74 54 6f  ><th>Hex( CastTo
17d0: 54 65 78 74 20 28 20 7a 65 72 6f 62 6c 6f 62 28  Text ( zeroblob(
17e0: 34 29 20 29 20 29 3c 2f 74 68 3e 3c 2f 74 72 3e  4) ) )</th></tr>
17f0: 0d 0a 3c 74 72 3e 3c 74 64 3e 4e 55 4c 4c 3c 2f  ..<tr><td>NULL</
1800: 74 64 3e 3c 74 64 3e 4e 55 4c 4c 3c 2f 74 64 3e  td><td>NULL</td>
1810: 3c 74 64 3e 36 31 36 43 37 30 36 38 36 31 3c 2f  <td>616C706861</
1820: 74 64 3e 3c 74 64 3e 30 30 30 30 30 30 30 30 3c  td><td>00000000<
1830: 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65  /td></tr></table
1840: 3e 3c 62 72 3e 0d 0a 54 68 65 20 3c 62 3e 43 61  ><br>..The <b>Ca
1850: 73 74 54 6f 42 6c 6f 62 28 29 3c 2f 62 3e 20 53  stToBlob()</b> S
1860: 51 4c 20 66 75 6e 63 74 69 6f 6e 20 77 69 6c 6c  QL function will
1870: 20 61 74 74 65 6d 70 74 20 74 6f 20 72 65 74 75   attempt to retu
1880: 72 6e 20 61 20 76 61 6c 75 65 20 6f 66 20 74 68  rn a value of th
1890: 65 20 3c 62 3e 42 4c 4f 42 3c 2f 62 3e 20 64 61  e <b>BLOB</b> da
18a0: 74 61 2d 74 79 70 65 2c 20 6f 72 20 3c 62 3e 4e  ta-type, or <b>N
18b0: 55 4c 4c 3c 2f 62 3e 20 69 66 20 6e 6f 20 63 6f  ULL</b> if no co
18c0: 6e 76 65 72 73 69 6f 6e 20 69 73 20 70 6f 73 73  nversion is poss
18d0: 69 62 6c 65 2e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69  ible...<ul>..<li
18e0: 3e 61 6e 20 49 6e 74 65 67 65 72 20 69 6e 70 75  >an Integer inpu
18f0: 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20  t argument will 
1900: 72 65 74 75 72 6e 20 61 20 4e 55 4c 4c 20 76 61  return a NULL va
1910: 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61  lue.</li>..<li>a
1920: 20 44 6f 75 62 6c 65 20 69 6e 70 75 74 20 61 72   Double input ar
1930: 67 75 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75  gument will retu
1940: 72 6e 20 61 20 4e 55 4c 4c 20 76 61 6c 75 65 2e  rn a NULL value.
1950: 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 20 54 65 78  </li>..<li>a Tex
1960: 74 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74  t input argument
1970: 20 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 74 68    will return th
1980: 65 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20  e corresponding 
1990: 42 4c 4f 42 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e  BLOB value.</li>
19a0: 0d 0a 3c 6c 69 3e 61 6e 79 20 42 4c 4f 42 20 69  ..<li>any BLOB i
19b0: 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 20 77 69  nput argument wi
19c0: 6c 6c 20 72 65 74 75 72 6e 20 74 68 65 20 63 6f  ll return the co
19d0: 72 72 65 73 70 6f 6e 64 69 6e 67 20 42 4c 4f 42  rresponding BLOB
19e0: 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c   value.</li>..<l
19f0: 69 3e 61 6e 79 20 4e 55 4c 4c 20 69 6e 70 75 74  i>any NULL input
1a00: 20 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20 72   argument will r
1a10: 65 74 75 72 6e 20 61 20 4e 55 4c 4c 20 76 61 6c  eturn a NULL val
1a20: 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 0d  ue.</li>..</ul>.
1a30: 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c  .<verbatim>..SEL
1a40: 45 43 54 20 48 65 78 28 20 43 61 73 74 54 6f 42  ECT Hex( CastToB
1a50: 6c 6f 62 28 20 27 30 31 32 33 34 35 36 37 38 39  lob( '0123456789
1a60: 61 42 63 44 65 46 66 45 64 43 62 41 39 38 37 36  aBcDeFfEdCbA9876
1a70: 35 34 33 32 31 30 27 2c 20 31 20 29 20 29 3b 0d  543210', 1 ) );.
1a80: 0a 2d 2d 2d 2d 2d 0d 0a 30 31 32 33 34 35 36 37  .-----..01234567
1a90: 38 39 41 42 43 44 45 46 46 45 44 43 42 41 39 38  89ABCDEFFEDCBA98
1aa0: 37 36 35 34 33 32 31 30 0d 0a 0d 0a 53 45 4c 45  76543210....SELE
1ab0: 43 54 20 43 61 73 74 54 6f 42 6c 6f 62 28 20 27  CT CastToBlob( '
1ac0: 31 32 66 27 2c 20 31 20 29 3b 0d 0a 2d 2d 2d 2d  12f', 1 );..----
1ad0: 2d 0d 0a 4e 55 4c 4c 0d 0a 0d 0a 53 45 4c 45 43  -..NULL....SELEC
1ae0: 54 20 43 61 73 74 54 6f 42 6c 6f 62 28 20 27 31  T CastToBlob( '1
1af0: 32 48 46 27 2c 20 31 20 29 3b 0d 0a 2d 2d 2d 2d  2HF', 1 );..----
1b00: 2d 0d 0a 4e 55 4c 4c 0d 0a 3c 2f 76 65 72 62 61  -..NULL..</verba
1b10: 74 69 6d 3e 0d 0a 41 20 73 65 63 6f 6e 64 20 6f  tim>..A second o
1b20: 76 65 72 6c 6f 61 64 65 64 20 76 65 72 73 69 6f  verloaded versio
1b30: 6e 20 6f 66 20 3c 62 3e 43 61 73 74 54 6f 42 6c  n of <b>CastToBl
1b40: 6f 62 28 29 3c 2f 62 3e 20 69 73 20 73 75 70 70  ob()</b> is supp
1b50: 6f 72 74 65 64 20 61 73 20 77 65 6c 6c 3b 20 62  orted as well; b
1b60: 79 20 73 70 65 63 69 66 79 69 6e 67 20 61 20 66  y specifying a f
1b70: 75 72 74 68 65 72 20 3c 62 3e 68 65 78 5f 69 6e  urther <b>hex_in
1b80: 70 75 74 3c 2f 62 3e 20 3c 75 3e 62 6f 6f 6c 65  put</b> <u>boole
1b90: 61 6e 3c 2f 75 3e 20 61 72 67 75 6d 65 6e 74 20  an</u> argument 
1ba0: 73 65 74 20 61 73 20 3c 62 3e 54 52 55 45 3c 2f  set as <b>TRUE</
1bb0: 62 3e 20 74 68 65 20 69 6e 70 75 74 20 73 74 72  b> the input str
1bc0: 69 6e 67 20 77 69 6c 6c 20 62 65 20 61 73 73 75  ing will be assu
1bd0: 6d 65 64 20 74 6f 20 62 65 20 3c 75 3e 48 65 78  med to be <u>Hex
1be0: 61 64 65 63 69 6d 61 6c 6c 79 20 65 6e 63 6f 64  adecimally encod
1bf0: 65 64 3c 2f 75 3e 2e 20 49 6e 20 74 68 69 73 20  ed</u>. In this 
1c00: 63 61 73 65 20 4e 55 4c 4c 20 77 69 6c 6c 20 62  case NULL will b
1c10: 65 20 72 65 74 75 72 6e 65 64 20 69 66 20 74 68  e returned if th
1c20: 65 20 69 6e 70 75 74 20 73 74 72 69 6e 67 20 64  e input string d
1c30: 6f 65 73 6e 27 74 20 63 6f 72 72 65 73 70 6f 6e  oesn't correspon
1c40: 64 73 20 74 6f 20 61 20 76 61 6c 69 64 20 48 65  ds to a valid He
1c50: 78 61 64 65 63 69 6d 61 6c 20 6e 6f 74 61 74 69  xadecimal notati
1c60: 6f 6e 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68 72  on.<br><br>..<hr
1c70: 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53  >..<verbatim>..S
1c80: 45 4c 45 43 54 20 46 6f 72 63 65 41 73 4e 75 6c  ELECT ForceAsNul
1c90: 6c 28 20 27 61 27 2c 20 27 62 27 20 29 2c 20 46  l( 'a', 'b' ), F
1ca0: 6f 72 63 65 41 73 4e 75 6c 6c 28 20 27 61 62 63  orceAsNull( 'abc
1cb0: 64 27 2c 20 27 61 62 63 64 27 20 29 2c 20 46 6f  d', 'abcd' ), Fo
1cc0: 72 63 65 41 73 4e 75 6c 6c 28 20 31 2c 20 31 29  rceAsNull( 1, 1)
1cd0: 2c 20 46 6f 72 63 65 41 73 4e 75 6c 6c 28 20 31  , ForceAsNull( 1
1ce0: 2e 31 2c 20 31 20 29 3b 0d 0a 3c 2f 76 65 72 62  .1, 1 );..</verb
1cf0: 61 74 69 6d 3e 0d 0a 3c 74 61 62 6c 65 20 62 6f  atim>..<table bo
1d00: 72 64 65 72 3d 22 31 22 20 63 65 6c 6c 73 70 61  rder="1" cellspa
1d10: 63 69 6e 67 3d 22 34 22 20 63 65 6c 6c 70 61 64  cing="4" cellpad
1d20: 64 69 6e 67 3d 22 34 22 3e 0d 0a 3c 74 72 3e 3c  ding="4">..<tr><
1d30: 74 68 3e 46 6f 72 63 65 41 73 4e 75 6c 6c 28 20  th>ForceAsNull( 
1d40: 27 61 27 2c 20 27 62 27 20 29 3c 2f 74 68 3e 3c  'a', 'b' )</th><
1d50: 74 68 3e 46 6f 72 63 65 41 73 4e 75 6c 6c 28 20  th>ForceAsNull( 
1d60: 27 61 62 63 64 27 2c 20 27 61 62 63 64 27 20 29  'abcd', 'abcd' )
1d70: 3c 2f 74 68 3e 3c 74 68 3e 46 6f 72 63 65 41 73  </th><th>ForceAs
1d80: 4e 75 6c 6c 28 20 31 2c 20 31 29 3c 2f 74 68 3e  Null( 1, 1)</th>
1d90: 3c 74 68 3e 46 6f 72 63 65 41 73 4e 75 6c 6c 28  <th>ForceAsNull(
1da0: 20 31 2e 31 2c 20 2d 39 39 39 39 20 29 3c 2f 74   1.1, -9999 )</t
1db0: 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64  h></tr>..<tr><td
1dc0: 3e 61 3c 2f 74 64 3e 3c 74 64 3e 4e 55 4c 4c 3c  >a</td><td>NULL<
1dd0: 2f 74 64 3e 3c 74 64 3e 4e 55 4c 4c 3c 2f 74 64  /td><td>NULL</td
1de0: 3e 3c 74 64 20 61 6c 69 67 6e 3d 22 72 69 67 68  ><td align="righ
1df0: 74 22 3e 31 2e 31 3c 2f 74 64 3e 3c 2f 74 72 3e  t">1.1</td></tr>
1e00: 3c 2f 74 61 62 6c 65 3e 3c 62 72 3e 0d 0a 54 68  </table><br>..Th
1e10: 65 20 3c 62 3e 46 6f 72 63 65 41 73 4e 75 6c 6c  e <b>ForceAsNull
1e20: 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74  ()</b> SQL funct
1e30: 69 6f 6e 20 77 69 6c 6c 20 65 76 61 6c 75 61 74  ion will evaluat
1e40: 65 20 74 77 6f 20 61 72 62 69 74 72 61 72 79 20  e two arbitrary 
1e50: 61 72 67 75 6d 65 6e 74 73 2e 3c 62 72 3e 0d 0a  arguments.<br>..
1e60: 49 66 20 74 68 65 79 20 61 72 65 20 65 71 75 61  If they are equa
1e70: 6c 20 61 6e 64 20 65 78 61 63 74 6c 79 20 6f 66  l and exactly of
1e80: 20 74 68 65 20 73 61 6d 65 20 64 61 74 61 2d 74   the same data-t
1e90: 79 70 65 20 4e 55 4c 4c 20 77 69 6c 6c 20 62 65  ype NULL will be
1ea0: 20 72 65 74 75 72 6e 65 64 3b 20 6f 74 68 65 72   returned; other
1eb0: 77 69 73 65 20 74 68 65 20 66 69 72 73 74 20 61  wise the first a
1ec0: 72 67 75 6d 65 6e 74 20 76 61 6c 75 65 20 77 69  rgument value wi
1ed0: 6c 6c 20 62 65 20 72 65 74 75 72 6e 65 64 2e 3c  ll be returned.<
1ee0: 62 72 3e 0d 0a 55 73 65 66 75 6c 20 65 2e 67 2e  br>..Useful e.g.
1ef0: 20 77 68 69 6c 65 20 70 72 6f 63 65 73 73 69 6e   while processin
1f00: 67 20 64 61 74 61 20 69 6d 70 6f 72 74 65 64 20  g data imported 
1f10: 66 72 6f 6d 20 61 6e 79 20 3c 62 3e 53 68 61 70  from any <b>Shap
1f20: 65 66 69 6c 65 3c 2f 62 3e 20 6f 72 20 3c 62 3e  efile</b> or <b>
1f30: 44 42 46 20 66 69 6c 65 3c 2f 62 3e 20 28 73 75  DBF file</b> (su
1f40: 63 68 20 66 6f 72 6d 61 74 73 20 64 6f 65 73 6e  ch formats doesn
1f50: 27 74 20 73 75 70 70 6f 72 74 20 61 6e 79 20 72  't support any r
1f60: 65 61 6c 20 4e 55 4c 4c 20 76 61 6c 75 65 2c 20  eal NULL value, 
1f70: 6f 66 74 65 6e 20 62 65 69 6e 67 20 72 65 70 6c  often being repl
1f80: 61 63 65 64 20 62 79 20 73 6f 6d 65 20 63 6f 6e  aced by some con
1f90: 76 65 6e 74 69 6f 6e 61 6c 20 76 61 6c 75 65 20  ventional value 
1fa0: 65 2e 67 2e 20 3c 62 3e 30 3c 2f 62 3e 20 6f 72  e.g. <b>0</b> or
1fb0: 20 3c 62 3e 2d 39 39 39 39 3c 2f 62 3e 20 61 6e   <b>-9999</b> an
1fc0: 64 20 61 6c 69 6b 65 29 2e 3c 62 72 3e 3c 62 72  d alike).<br><br
1fd0: 3e 0d 0a 3c 68 72 3e 0d 0a 3c 68 33 3e 3c 61 20  >..<hr>..<h3><a 
1fe0: 6e 61 6d 65 3d 22 75 75 69 64 22 3e 47 65 6e 65  name="uuid">Gene
1ff0: 72 69 63 3c 2f 61 3e 20 53 51 4c 20 66 75 6e 63  ric</a> SQL func
2000: 74 69 6f 6e 20 2d 20 55 55 49 44 20 67 65 6e 65  tion - UUID gene
2010: 72 61 74 6f 72 3c 2f 68 33 3e 0d 0a 41 6e 20 3c  rator</h3>..An <
2020: 61 20 68 72 65 66 3d 22 68 74 74 70 3a 2f 2f 65  a href="http://e
2030: 6e 2e 77 69 6b 69 70 65 64 69 61 2e 6f 72 67 2f  n.wikipedia.org/
2040: 77 69 6b 69 2f 55 6e 69 76 65 72 73 61 6c 6c 79  wiki/Universally
2050: 5f 75 6e 69 71 75 65 5f 69 64 65 6e 74 69 66 69  _unique_identifi
2060: 65 72 22 3e 55 6e 69 76 65 72 73 61 6c 6c 79 20  er">Universally 
2070: 75 6e 69 71 75 65 20 69 64 65 6e 74 69 66 69 65  unique identifie
2080: 72 3c 2f 61 3e 20 28 61 6b 61 20 3c 62 3e 55 55  r</a> (aka <b>UU
2090: 49 44 3c 2f 62 3e 29 20 73 69 6d 70 6c 79 20 69  ID</b>) simply i
20a0: 73 20 61 20 3c 75 3e 31 32 38 20 62 69 74 3c 2f  s a <u>128 bit</
20b0: 75 3e 20 49 6e 74 65 67 65 72 3b 20 61 63 63 6f  u> Integer; acco
20c0: 72 64 69 6e 67 6c 79 20 74 6f 20 3c 61 20 68 72  rdingly to <a hr
20d0: 65 66 3d 22 68 74 74 70 3a 2f 2f 65 6e 2e 77 69  ef="http://en.wi
20e0: 6b 69 70 65 64 69 61 2e 6f 72 67 2f 77 69 6b 69  kipedia.org/wiki
20f0: 2f 55 55 49 44 23 52 61 6e 64 6f 6d 5f 55 55 49  /UUID#Random_UUI
2100: 44 5f 70 72 6f 62 61 62 69 6c 69 74 79 5f 6f 66  D_probability_of
2110: 5f 64 75 70 6c 69 63 61 74 65 73 22 3e 74 68 65  _duplicates">the
2120: 6f 72 79 3c 2f 61 3e 2c 20 74 68 65 20 70 72 6f  ory</a>, the pro
2130: 62 61 62 69 6c 69 74 79 20 74 68 61 74 20 74 77  bability that tw
2140: 6f 20 72 61 6e 64 6f 6d 6c 79 20 67 65 6e 65 72  o randomly gener
2150: 61 74 65 64 20 55 55 49 44 73 20 63 6f 75 6c 64  ated UUIDs could
2160: 20 61 73 73 75 6d 65 20 74 68 65 20 73 61 6d 65   assume the same
2170: 20 76 61 6c 75 65 20 69 73 20 6e 65 61 72 20 74   value is near t
2180: 6f 20 7a 65 72 6f 20 66 6f 72 20 6d 61 6e 79 20  o zero for many 
2190: 70 72 61 63 74 69 63 61 6c 20 70 75 72 70 6f 73  practical purpos
21a0: 65 73 2e 20 41 6e 64 20 63 6f 6e 73 65 71 75 65  es. And conseque
21b0: 6e 74 6c 79 20 55 55 49 44 73 20 61 72 65 20 77  ntly UUIDs are w
21c0: 69 64 65 6c 79 20 75 73 65 64 20 61 73 20 3c 75  idely used as <u
21d0: 3e 75 6e 69 76 65 72 73 61 6c 6c 79 20 75 6e 69  >universally uni
21e0: 71 75 65 20 49 44 73 3c 2f 75 3e 2e 3c 62 72 3e  que IDs</u>.<br>
21f0: 0d 0a 55 73 75 61 6c 6c 79 20 55 55 49 44 73 20  ..Usually UUIDs 
2200: 61 72 65 20 72 65 70 72 65 73 65 6e 74 65 64 20  are represented 
2210: 69 6e 20 74 68 65 69 72 20 3c 75 3e 63 61 6e 6f  in their <u>cano
2220: 6e 69 63 61 6c 20 66 6f 72 6d 3c 2f 75 3e 2c 20  nical form</u>, 
2230: 69 2e 65 2e 20 61 73 20 61 20 73 65 71 75 65 6e  i.e. as a sequen
2240: 63 65 20 6f 66 20 33 32 20 68 65 78 61 64 65 63  ce of 32 hexadec
2250: 69 6d 61 6c 20 64 69 67 69 74 73 20 73 65 70 61  imal digits sepa
2260: 72 61 74 65 64 20 69 6e 74 6f 20 66 69 76 65 20  rated into five 
2270: 64 69 73 74 69 6e 63 74 20 62 6c 6f 63 6b 2c 20  distinct block, 
2280: 61 63 63 6f 72 64 69 6e 67 6c 79 20 74 6f 20 61  accordingly to a
2290: 20 3c 62 3e 38 2d 34 2d 34 2d 34 2d 31 32 3c 2f   <b>8-4-4-4-12</
22a0: 62 3e 20 73 63 68 65 6d 61 2e 0d 0a 3c 76 65 72  b> schema...<ver
22b0: 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 43  batim>..SELECT C
22c0: 72 65 61 74 65 55 55 49 44 28 29 3b 0d 0a 2d 2d  reateUUID();..--
22d0: 2d 2d 2d 2d 2d 2d 0d 0a 66 66 66 35 66 61 66 31  ------..fff5faf1
22e0: 2d 64 63 63 30 2d 34 33 39 31 2d 38 30 35 34 2d  -dcc0-4391-8054-
22f0: 36 65 37 64 65 37 35 64 38 35 62 31 0d 0a 3c 2f  6e7de75d85b1..</
2300: 76 65 72 62 61 74 69 6d 3e 0d 0a 54 68 65 20 3c  verbatim>..The <
2310: 62 3e 43 72 65 61 74 65 55 55 49 44 28 29 3c 2f  b>CreateUUID()</
2320: 62 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20  b> SQL function 
2330: 69 73 20 62 75 69 6c 74 20 6f 6e 20 74 68 65 20  is built on the 
2340: 74 6f 70 20 74 68 65 20 3c 69 3e 48 69 67 68 20  top the <i>High 
2350: 51 75 61 6c 69 74 79 20 50 73 65 75 64 6f 2d 52  Quality Pseudo-R
2360: 61 6e 64 6f 6d 20 4e 75 6d 62 65 72 20 47 65 6e  andom Number Gen
2370: 65 72 61 74 6f 72 3c 2f 69 3e 20 3c 61 20 68 72  erator</i> <a hr
2380: 65 66 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e 73  ef="http://www.s
2390: 71 6c 69 74 65 2e 6f 72 67 2f 63 33 72 65 66 2f  qlite.org/c3ref/
23a0: 72 61 6e 64 6f 6d 6e 65 73 73 2e 68 74 6d 6c 22  randomness.html"
23b0: 3e 69 6e 74 65 72 6e 61 6c 6c 79 20 69 6d 70 6c  >internally impl
23c0: 65 6d 65 6e 74 65 64 3c 2f 61 3e 20 62 79 20 53  emented</a> by S
23d0: 51 4c 69 74 65 2e 3c 62 72 3e 0d 0a 54 68 65 20  QLite.<br>..The 
23e0: 72 65 74 75 72 6e 65 64 20 55 55 49 44 20 69 73  returned UUID is
23f0: 20 63 6f 6e 66 6f 72 6d 61 6e 74 20 74 6f 20 3c   conformant to <
2400: 75 3e 56 65 72 73 69 6f 6e 20 34 20 28 72 61 6e  u>Version 4 (ran
2410: 64 6f 6d 29 3c 2f 75 3e 20 28 69 2e 65 2e 20 74  dom)</u> (i.e. t
2420: 68 65 20 66 69 72 73 74 20 64 69 67 69 74 20 69  he first digit i
2430: 6e 74 6f 20 74 68 65 20 74 68 69 72 64 20 62 6c  nto the third bl
2440: 6f 63 6b 20 77 69 6c 6c 20 61 6c 77 61 79 73 20  ock will always 
2450: 62 65 20 3c 62 3e 34 3c 2f 62 3e 20 61 6e 64 20  be <b>4</b> and 
2460: 74 68 65 20 66 69 72 73 74 20 64 69 67 69 74 20  the first digit 
2470: 69 6e 74 6f 20 74 68 65 20 66 6f 75 72 74 68 20  into the fourth 
2480: 62 6c 6f 63 6b 20 77 69 6c 6c 20 61 6c 77 61 79  block will alway
2490: 73 20 62 65 20 3c 62 3e 38 3c 2f 62 3e 29 2e 3c  s be <b>8</b>).<
24a0: 62 72 3e 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c  br><br>..<hr>..<
24b0: 68 33 3e 3c 61 20 6e 61 6d 65 3d 22 67 65 6f 6d  h3><a name="geom
24c0: 22 3e 53 70 61 74 69 61 6c 3c 2f 61 3e 20 53 51  ">Spatial</a> SQ
24d0: 4c 20 66 75 6e 63 74 69 6f 6e 73 3c 2f 68 33 3e  L functions</h3>
24e0: 0d 0a 46 65 77 20 6d 6f 72 65 20 53 70 61 74 69  ..Few more Spati
24f0: 61 6c 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 73  al SQL functions
2500: 20 61 72 65 20 6e 6f 77 20 73 75 70 70 6f 72 74   are now support
2510: 65 64 2e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d  ed...<verbatim>.
2520: 0a 53 45 4c 45 43 54 20 53 54 5f 41 73 54 65 78  .SELECT ST_AsTex
2530: 74 28 20 53 54 5f 41 64 64 50 6f 69 6e 74 28 20  t( ST_AddPoint( 
2540: 0d 0a 20 20 53 54 5f 47 65 6f 6d 46 72 6f 6d 54  ..  ST_GeomFromT
2550: 65 78 74 28 20 27 4c 49 4e 45 53 54 52 49 4e 47  ext( 'LINESTRING
2560: 28 20 30 20 30 2c 20 31 20 30 20 29 27 20 29 2c  ( 0 0, 1 0 )' ),
2570: 20 0d 0a 20 20 53 54 5f 47 65 6f 6d 46 72 6f 6d   ..  ST_GeomFrom
2580: 54 65 78 74 28 20 27 50 4f 49 4e 54 28 20 31 20  Text( 'POINT( 1 
2590: 31 20 29 27 20 29 20 29 20 29 3b 0d 0a 2d 2d 2d  1 )' ) ) );..---
25a0: 2d 2d 2d 2d 2d 0d 0a 4c 49 4e 45 53 54 52 49 4e  -----..LINESTRIN
25b0: 47 28 30 20 30 2c 20 31 20 30 2c 20 31 20 31 29  G(0 0, 1 0, 1 1)
25c0: 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 54  ..</verbatim>..T
25d0: 68 65 20 3c 62 3e 53 54 5f 41 64 64 50 6f 69 6e  he <b>ST_AddPoin
25e0: 74 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63  t()</b> SQL func
25f0: 74 69 6f 6e 20 61 64 64 73 20 61 20 66 75 72 74  tion adds a furt
2600: 68 65 72 20 50 6f 69 6e 74 2f 56 65 72 74 65 78  her Point/Vertex
2610: 20 61 74 20 74 68 65 20 65 6e 64 20 6f 66 20 61   at the end of a
2620: 20 4c 69 6e 65 73 74 72 69 6e 67 3b 20 74 68 65   Linestring; the
2630: 20 66 69 72 73 74 20 61 72 67 75 6d 65 6e 74 20   first argument 
2640: 69 73 20 61 6c 77 61 79 73 20 65 78 70 65 63 74  is always expect
2650: 65 64 20 74 6f 20 62 65 20 6f 66 20 74 68 65 20  ed to be of the 
2660: 4c 69 6e 65 73 74 72 69 6e 67 20 74 79 70 65 2c  Linestring type,
2670: 20 74 68 65 20 73 65 63 6f 6e 64 20 6f 6e 65 20   the second one 
2680: 6d 75 73 74 20 62 65 20 61 20 50 6f 69 6e 74 2e  must be a Point.
2690: 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45  ..<verbatim>..SE
26a0: 4c 45 43 54 20 53 54 5f 41 73 54 65 78 74 28 20  LECT ST_AsText( 
26b0: 53 54 5f 41 64 64 50 6f 69 6e 74 28 20 0d 0a 20  ST_AddPoint( .. 
26c0: 20 53 54 5f 47 65 6f 6d 46 72 6f 6d 54 65 78 74   ST_GeomFromText
26d0: 28 20 27 4c 49 4e 45 53 54 52 49 4e 47 28 20 31  ( 'LINESTRING( 1
26e0: 20 30 2c 20 31 20 31 20 29 27 20 29 2c 20 0d 0a   0, 1 1 )' ), ..
26f0: 20 20 53 54 5f 47 65 6f 6d 46 72 6f 6d 54 65 78    ST_GeomFromTex
2700: 74 28 20 27 50 4f 49 4e 54 28 20 30 20 30 20 29  t( 'POINT( 0 0 )
2710: 27 20 29 2c 20 30 20 29 20 29 3b 0d 0a 2d 2d 2d  ' ), 0 ) );..---
2720: 2d 2d 2d 2d 2d 2d 0d 0a 4c 49 4e 45 53 54 52 49  ------..LINESTRI
2730: 4e 47 28 30 20 30 2c 20 31 20 30 2c 20 31 20 31  NG(0 0, 1 0, 1 1
2740: 29 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a  )..</verbatim>..
2750: 49 66 20 61 6e 20 6f 70 74 69 6f 6e 61 6c 20 74  If an optional t
2760: 68 69 72 64 20 61 72 67 75 6d 65 6e 74 20 28 6f  hird argument (o
2770: 66 20 74 68 65 20 49 6e 74 65 67 65 72 20 74 79  f the Integer ty
2780: 70 65 29 20 69 73 20 70 61 73 73 65 64 20 74 6f  pe) is passed to
2790: 20 3c 62 3e 53 54 5f 41 64 64 50 6f 69 6e 74 28   <b>ST_AddPoint(
27a0: 29 3c 2f 62 3e 20 69 74 27 73 20 69 6e 74 65 6e  )</b> it's inten
27b0: 64 65 64 20 74 6f 20 73 70 65 63 69 66 79 20 74  ded to specify t
27c0: 68 65 20 3c 75 3e 69 6e 64 65 78 3c 2f 75 3e 20  he <u>index</u> 
27d0: 6f 66 20 74 68 65 20 6e 65 77 20 56 65 72 74 65  of the new Verte
27e0: 78 20 28 66 69 72 73 74 20 56 65 72 74 65 78 20  x (first Vertex 
27f0: 68 61 73 20 69 6e 64 65 78 20 30 2c 20 73 65 63  has index 0, sec
2800: 6f 6e 64 20 56 65 72 74 65 78 20 68 61 73 20 69  ond Vertex has i
2810: 6e 64 65 78 20 31 20 61 6e 64 20 73 6f 20 6f 6e  ndex 1 and so on
2820: 29 2e 3c 62 72 3e 0d 0a 52 65 66 65 72 65 6e 63  ).<br>..Referenc
2830: 69 6e 67 20 61 20 6e 6f 74 20 65 78 69 73 74 69  ing a not existi
2840: 6e 67 20 69 6e 64 65 78 20 69 73 20 61 6e 20 65  ng index is an e
2850: 72 72 6f 72 2c 20 61 6e 64 20 77 69 6c 6c 20 72  rror, and will r
2860: 65 74 75 72 6e 20 4e 55 4c 4c 2e 0d 0a 3c 76 65  eturn NULL...<ve
2870: 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20  rbatim>..SELECT 
2880: 53 54 5f 41 73 54 65 78 74 28 20 53 54 5f 41 64  ST_AsText( ST_Ad
2890: 64 50 6f 69 6e 74 28 20 0d 0a 20 20 53 54 5f 47  dPoint( ..  ST_G
28a0: 65 6f 6d 46 72 6f 6d 54 65 78 74 28 20 27 4c 49  eomFromText( 'LI
28b0: 4e 45 53 54 52 49 4e 47 28 20 30 20 30 2c 20 31  NESTRING( 0 0, 1
28c0: 20 30 20 29 27 20 29 2c 20 0d 0a 20 20 53 54 5f   0 )' ), ..  ST_
28d0: 47 65 6f 6d 46 72 6f 6d 54 65 78 74 28 20 27 50  GeomFromText( 'P
28e0: 4f 49 4e 54 28 20 31 20 31 20 29 27 20 29 2c 20  OINT( 1 1 )' ), 
28f0: 2d 31 20 29 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d  -1 ) );..-------
2900: 2d 0d 0a 4c 49 4e 45 53 54 52 49 4e 47 28 30 20  -..LINESTRING(0 
2910: 30 2c 20 31 20 30 2c 20 31 20 31 29 0d 0a 3c 2f  0, 1 0, 1 1)..</
2920: 76 65 72 62 61 74 69 6d 3e 0d 0a 50 61 73 73 69  verbatim>..Passi
2930: 6e 67 20 61 20 6e 65 67 61 74 69 76 65 20 69 6e  ng a negative in
2940: 64 65 78 20 69 73 20 61 20 73 75 70 70 6f 72 74  dex is a support
2950: 65 64 20 6f 70 74 69 6f 6e 2c 20 61 6e 64 20 73  ed option, and s
2960: 69 6d 70 6c 79 20 63 6f 72 72 65 73 70 6f 6e 64  imply correspond
2970: 73 20 74 6f 20 74 68 65 20 64 65 66 61 75 6c 74  s to the default
2980: 20 62 65 68 61 76 69 6f 75 72 20 28 69 2e 65 2e   behaviour (i.e.
2990: 20 3c 69 3e 61 70 70 65 6e 64 69 6e 67 20 74 68   <i>appending th
29a0: 65 20 50 6f 69 6e 74 20 74 6f 20 74 68 65 20 65  e Point to the e
29b0: 6e 64 20 6f 66 20 74 68 65 20 4c 69 6e 65 73 74  nd of the Linest
29c0: 72 69 6e 67 3c 2f 69 3e 29 2e 3c 62 72 3e 3c 62  ring</i>).<br><b
29d0: 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72 62 61  r>..<hr>..<verba
29e0: 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 53 54 5f  tim>..SELECT ST_
29f0: 41 73 54 65 78 74 28 20 53 54 5f 53 65 74 50 6f  AsText( ST_SetPo
2a00: 69 6e 74 28 20 0d 0a 20 20 53 54 5f 47 65 6f 6d  int( ..  ST_Geom
2a10: 46 72 6f 6d 54 65 78 74 28 20 27 4c 49 4e 45 53  FromText( 'LINES
2a20: 54 52 49 4e 47 28 20 30 20 30 2c 20 31 20 30 2c  TRING( 0 0, 1 0,
2a30: 20 31 20 31 20 29 27 20 29 2c 20 0d 0a 20 20 31   1 1 )' ), ..  1
2a40: 2c 20 53 54 5f 47 65 6f 6d 46 72 6f 6d 54 65 78  , ST_GeomFromTex
2a50: 74 28 20 27 50 4f 49 4e 54 28 20 32 20 31 20 29  t( 'POINT( 2 1 )
2a60: 27 20 29 20 29 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d  ' ) ) );..------
2a70: 2d 2d 2d 0d 0a 4c 49 4e 45 53 54 52 49 4e 47 28  ---..LINESTRING(
2a80: 30 20 30 2c 20 32 20 31 2c 20 31 20 31 29 0d 0a  0 0, 2 1, 1 1)..
2a90: 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 54 68 65  </verbatim>..The
2aa0: 20 3c 62 3e 53 54 5f 53 65 74 50 6f 69 6e 74 28   <b>ST_SetPoint(
2ab0: 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 69  )</b> SQL functi
2ac0: 6f 6e 20 63 61 6e 20 72 65 70 6c 61 63 65 20 61  on can replace a
2ad0: 20 50 6f 69 6e 74 2f 56 65 72 74 65 78 20 66 72   Point/Vertex fr
2ae0: 6f 6d 20 77 69 74 68 69 6e 20 61 20 4c 69 6e 65  om within a Line
2af0: 73 74 72 69 6e 67 3b 20 74 68 65 20 66 69 72 73  string; the firs
2b00: 74 20 61 72 67 75 6d 65 6e 74 20 69 73 20 61 6c  t argument is al
2b10: 77 61 79 73 20 65 78 70 65 63 74 65 64 20 74 6f  ways expected to
2b20: 20 62 65 20 6f 66 20 74 68 65 20 4c 69 6e 65 73   be of the Lines
2b30: 74 72 69 6e 67 20 74 79 70 65 2c 20 74 68 65 20  tring type, the 
2b40: 73 65 63 6f 6e 64 20 69 73 20 61 6e 20 49 6e 74  second is an Int
2b50: 65 67 65 72 20 73 70 65 63 69 66 79 69 6e 67 20  eger specifying 
2b60: 74 68 65 20 3c 75 3e 69 6e 64 65 78 3c 2f 75 3e  the <u>index</u>
2b70: 20 6f 66 20 74 68 65 20 61 66 66 65 63 74 65 64   of the affected
2b80: 20 56 65 72 74 65 78 20 61 6e 64 20 74 68 65 20   Vertex and the 
2b90: 74 68 69 72 64 20 6f 6e 65 20 6d 75 73 74 20 62  third one must b
2ba0: 65 20 61 20 50 6f 69 6e 74 2e 3c 62 72 3e 0d 0a  e a Point.<br>..
2bb0: 52 65 66 65 72 65 6e 63 69 6e 67 20 61 20 6e 6f  Referencing a no
2bc0: 74 20 65 78 69 73 74 69 6e 67 20 69 6e 64 65 78  t existing index
2bd0: 20 69 73 20 61 6e 20 65 72 72 6f 72 2c 20 61 6e   is an error, an
2be0: 64 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 4e 55  d will return NU
2bf0: 4c 4c 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68 72  LL.<br><br>..<hr
2c00: 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53  >..<verbatim>..S
2c10: 45 4c 45 43 54 20 53 54 5f 41 73 54 65 78 74 28  ELECT ST_AsText(
2c20: 20 53 54 5f 52 65 6d 6f 76 65 50 6f 69 6e 74 28   ST_RemovePoint(
2c30: 20 0d 0a 20 20 53 54 5f 47 65 6f 6d 46 72 6f 6d   ..  ST_GeomFrom
2c40: 54 65 78 74 28 20 27 4c 49 4e 45 53 54 52 49 4e  Text( 'LINESTRIN
2c50: 47 28 20 30 20 30 2c 20 31 20 30 2c 20 31 20 31  G( 0 0, 1 0, 1 1
2c60: 20 29 27 20 29 2c 20 31 20 29 20 29 3b 0d 0a 2d   )' ), 1 ) );..-
2c70: 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 4c 49 4e 45 53 54  --------..LINEST
2c80: 52 49 4e 47 28 30 20 30 2c 20 31 20 31 29 0d 0a  RING(0 0, 1 1)..
2c90: 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 54 68 65  </verbatim>..The
2ca0: 20 3c 62 3e 53 54 5f 52 65 6d 6f 76 65 50 6f 69   <b>ST_RemovePoi
2cb0: 6e 74 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e  nt()</b> SQL fun
2cc0: 63 74 69 6f 6e 20 63 61 6e 20 72 65 6d 6f 76 65  ction can remove
2cd0: 20 61 20 50 6f 69 6e 74 2f 56 65 72 74 65 78 20   a Point/Vertex 
2ce0: 66 72 6f 6d 20 77 69 74 68 69 6e 20 61 20 4c 69  from within a Li
2cf0: 6e 65 73 74 72 69 6e 67 3b 20 74 68 65 20 66 69  nestring; the fi
2d00: 72 73 74 20 61 72 67 75 6d 65 6e 74 20 69 73 20  rst argument is 
2d10: 61 6c 77 61 79 73 20 65 78 70 65 63 74 65 64 20  always expected 
2d20: 74 6f 20 62 65 20 6f 66 20 74 68 65 20 4c 69 6e  to be of the Lin
2d30: 65 73 74 72 69 6e 67 20 74 79 70 65 2c 20 74 68  estring type, th
2d40: 65 20 73 65 63 6f 6e 64 20 69 73 20 61 6e 20 49  e second is an I
2d50: 6e 74 65 67 65 72 20 73 70 65 63 69 66 79 69 6e  nteger specifyin
2d60: 67 20 74 68 65 20 3c 75 3e 69 6e 64 65 78 3c 2f  g the <u>index</
2d70: 75 3e 20 6f 66 20 74 68 65 20 61 66 66 65 63 74  u> of the affect
2d80: 65 64 20 56 65 72 74 65 78 2e 3c 62 72 3e 0d 0a  ed Vertex.<br>..
2d90: 52 65 66 65 72 65 6e 63 69 6e 67 20 61 20 6e 6f  Referencing a no
2da0: 74 20 65 78 69 73 74 69 6e 67 20 69 6e 64 65 78  t existing index
2db0: 20 69 73 20 61 6e 20 65 72 72 6f 72 2c 20 61 6e   is an error, an
2dc0: 64 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 4e 55  d will return NU
2dd0: 4c 4c 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68 72  LL.<br><br>..<hr
2de0: 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53  >..<verbatim>..S
2df0: 45 4c 45 43 54 20 53 54 5f 41 73 54 65 78 74 28  ELECT ST_AsText(
2e00: 20 53 54 5f 50 6f 69 6e 74 28 31 30 2c 20 32 30   ST_Point(10, 20
2e10: 29 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ) );..----------
2e20: 0d 0a 50 4f 49 4e 54 28 31 30 20 31 30 29 0d 0a  ..POINT(10 10)..
2e30: 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 54 68 65  </verbatim>..The
2e40: 20 3c 62 3e 53 54 5f 50 6f 69 6e 74 28 29 3c 2f   <b>ST_Point()</
2e50: 62 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20  b> SQL function 
2e60: 73 69 6d 70 6c 79 20 69 73 20 79 65 74 20 61 6e  simply is yet an
2e70: 6f 74 68 65 72 20 3c 69 3e 61 6c 69 61 73 2d 6e  other <i>alias-n
2e80: 61 6d 65 3c 2f 69 3e 20 63 6f 72 72 65 73 70 6f  ame</i> correspo
2e90: 6e 64 69 6e 67 20 74 6f 20 3c 62 3e 4d 61 6b 65  nding to <b>Make
2ea0: 50 6f 69 6e 74 28 29 3c 2f 62 3e 3b 20 74 68 69  Point()</b>; thi
2eb0: 73 20 66 75 72 74 68 65 72 20 61 6c 69 61 73 20  s further alias 
2ec0: 68 61 73 20 62 65 65 6e 20 69 6e 74 72 6f 64 75  has been introdu
2ed0: 63 65 64 20 73 6f 20 74 6f 20 73 75 70 70 6f 72  ced so to suppor
2ee0: 74 20 61 20 73 74 72 69 63 74 20 50 6f 73 74 47  t a strict PostG
2ef0: 49 53 20 63 6f 6e 66 6f 72 6d 61 6e 63 65 2e 3c  IS conformance.<
2f00: 62 72 3e 0d 0a 3c 75 3e 50 6c 65 61 73 65 20 6e  br>..<u>Please n
2f10: 6f 74 65 3c 2f 75 3e 3a 20 64 69 66 66 65 72 65  ote</u>: differe
2f20: 6e 74 6c 79 20 66 72 6f 6d 20 4d 61 6b 65 50 6f  ntly from MakePo
2f30: 69 6e 74 28 29 2c 20 53 54 5f 50 6f 69 6e 74 28  int(), ST_Point(
2f40: 29 20 64 6f 6e 27 74 20 73 75 70 70 6f 72 74 73  ) don't supports
2f50: 20 74 68 65 20 6f 70 74 69 6f 6e 61 6c 20 3c 62   the optional <b
2f60: 3e 53 52 49 44 3c 2f 62 3e 20 61 72 67 75 6d 65  >SRID</b> argume
2f70: 6e 74 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68 72  nt.<br><br>..<hr
2f80: 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53  >..<verbatim>..S
2f90: 45 4c 45 43 54 20 53 54 5f 41 73 54 65 78 74 28  ELECT ST_AsText(
2fa0: 20 4d 61 6b 65 4c 69 6e 65 28 20 53 54 5f 47 65   MakeLine( ST_Ge
2fb0: 6f 6d 46 72 6f 6d 54 65 78 74 28 20 27 4d 55 4c  omFromText( 'MUL
2fc0: 54 49 50 4f 49 4e 54 28 30 20 30 2c 20 31 20 30  TIPOINT(0 0, 1 0
2fd0: 2c 20 31 20 31 29 27 20 29 20 29 20 2c 20 31 20  , 1 1)' ) ) , 1 
2fe0: 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a  );..----------..
2ff0: 4c 49 4e 45 53 54 52 49 4e 47 28 30 20 30 2c 20  LINESTRING(0 0, 
3000: 31 20 30 2c 20 31 20 31 29 0d 0a 0d 0a 53 45 4c  1 0, 1 1)....SEL
3010: 45 43 54 20 53 54 5f 41 73 54 65 78 74 28 20 4d  ECT ST_AsText( M
3020: 61 6b 65 4c 69 6e 65 28 20 53 54 5f 47 65 6f 6d  akeLine( ST_Geom
3030: 46 72 6f 6d 54 65 78 74 28 20 27 4d 55 4c 54 49  FromText( 'MULTI
3040: 50 4f 49 4e 54 28 30 20 30 2c 20 31 20 30 2c 20  POINT(0 0, 1 0, 
3050: 31 20 31 29 27 20 29 20 29 20 2c 20 30 20 29 3b  1 1)' ) ) , 0 );
3060: 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 4c 49  ..----------..LI
3070: 4e 45 53 54 52 49 4e 47 28 31 20 31 2c 20 31 20  NESTRING(1 1, 1 
3080: 30 2c 20 30 20 30 29 0d 0a 3c 2f 76 65 72 62 61  0, 0 0)..</verba
3090: 74 69 6d 3e 0d 0a 4e 6f 74 20 72 65 61 6c 6c 79  tim>..Not really
30a0: 20 61 20 62 72 61 6e 64 20 6e 65 77 20 53 51 4c   a brand new SQL
30b0: 20 66 75 6e 63 74 69 6f 6e 3b 20 6d 6f 72 65 20   function; more 
30c0: 73 69 6d 70 6c 79 20 61 20 66 75 72 74 68 65 72  simply a further
30d0: 20 6f 76 65 72 6c 6f 61 64 65 64 20 66 6c 61 76   overloaded flav
30e0: 6f 72 20 6f 66 20 74 68 65 20 61 6c 72 65 61 64  or of the alread
30f0: 79 20 65 78 69 73 74 69 6e 67 20 3c 62 3e 4d 61  y existing <b>Ma
3100: 6b 65 4c 69 6e 65 28 29 3c 2f 62 3e 2e 3c 62 72  keLine()</b>.<br
3110: 3e 0d 0a 4e 6f 77 20 74 68 65 20 69 6e 70 75 74  >..Now the input
3120: 20 47 65 6f 6d 65 74 72 79 20 28 66 69 72 73 74   Geometry (first
3130: 20 61 72 67 75 6d 65 6e 74 29 20 63 6f 75 6c 64   argument) could
3140: 20 62 65 20 6f 66 20 74 68 65 20 4d 55 4c 54 49   be of the MULTI
3150: 50 4f 49 4e 54 20 74 79 70 65 20 61 6e 64 20 74  POINT type and t
3160: 68 65 20 73 65 63 6f 6e 64 20 61 72 67 75 6d 65  he second argume
3170: 6e 74 20 69 66 20 6f 66 20 74 68 65 20 3c 62 3e  nt if of the <b>
3180: 42 6f 6f 6c 65 61 6e 3c 2f 62 3e 20 74 79 70 65  Boolean</b> type
3190: 3b 20 69 66 20 74 68 65 20 73 65 63 6f 6e 64 20  ; if the second 
31a0: 61 72 67 75 6d 65 6e 74 20 63 6f 72 72 65 73 70  argument corresp
31b0: 6f 6e 64 73 20 74 6f 20 3c 62 3e 54 52 55 45 3c  onds to <b>TRUE<
31c0: 2f 62 3e 20 74 68 65 20 72 65 74 75 72 6e 65 64  /b> the returned
31d0: 20 4c 49 4e 45 53 54 52 49 4e 47 20 77 69 6c 6c   LINESTRING will
31e0: 20 62 65 20 6f 72 69 65 6e 74 65 64 20 61 63 63   be oriented acc
31f0: 6f 72 64 69 6e 67 6c 79 20 74 6f 20 74 68 65 20  ordingly to the 
3200: 50 6f 69 6e 74 2d 73 65 71 75 65 6e 63 65 20 61  Point-sequence a
3210: 73 20 73 70 65 63 69 66 69 65 64 20 62 79 20 74  s specified by t
3220: 68 65 20 4d 75 6c 74 69 50 6f 69 6e 74 2c 20 6f  he MultiPoint, o
3230: 74 68 65 72 77 69 73 65 20 3c 75 3e 72 65 76 65  therwise <u>reve
3240: 72 73 65 20 6f 72 64 65 72 3c 2f 75 3e 20 77 69  rse order</u> wi
3250: 6c 6c 20 62 65 20 61 73 73 75 6d 65 64 2c 20 74  ll be assumed, t
3260: 68 75 73 20 72 65 74 75 72 6e 69 6e 67 20 61 20  hus returning a 
3270: 4c 69 6e 65 73 74 72 69 6e 67 20 6f 66 20 6f 70  Linestring of op
3280: 70 6f 73 69 74 65 20 6f 72 69 65 6e 74 61 74 69  posite orientati
3290: 6f 6e 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68 72  on.<br><br>..<hr
32a0: 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53  >..<verbatim>..S
32b0: 45 4c 45 43 54 20 53 54 5f 41 72 65 61 28 20 53  ELECT ST_Area( S
32c0: 54 5f 47 65 6f 6d 46 72 6f 6d 54 65 78 74 28 20  T_GeomFromText( 
32d0: 27 50 4f 4c 59 47 4f 4e 28 28 32 30 20 32 30 2c  'POLYGON((20 20,
32e0: 20 32 31 20 32 30 2c 20 32 31 20 32 31 2c 20 32   21 20, 21 21, 2
32f0: 30 20 32 31 2c 20 32 30 20 32 30 29 29 27 2c 20  0 21, 20 20))', 
3300: 34 33 32 36 20 29 2c 20 31 20 29 3b 0d 0a 2d 2d  4326 ), 1 );..--
3310: 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 31 31 35 34 38 35  --------..115485
3320: 35 35 39 32 36 2e 36 34 37 37 33 36 0d 0a 0d 0a  55926.647736....
3330: 0d 0a 53 45 4c 45 43 54 20 53 54 5f 41 72 65 61  ..SELECT ST_Area
3340: 28 20 53 54 5f 47 65 6f 6d 46 72 6f 6d 54 65 78  ( ST_GeomFromTex
3350: 74 28 20 27 50 4f 4c 59 47 4f 4e 28 28 32 30 20  t( 'POLYGON((20 
3360: 32 30 2c 20 32 31 20 32 30 2c 20 32 31 20 32 31  20, 21 20, 21 21
3370: 2c 20 32 30 20 32 31 2c 20 32 30 20 32 30 29 29  , 20 21, 20 20))
3380: 27 2c 20 34 33 32 36 20 29 2c 20 30 20 29 3b 0d  ', 4326 ), 0 );.
3390: 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 31 31 35  .----------..115
33a0: 38 31 33 37 37 36 32 33 2e 31 31 34 31 38 39 0d  81377623.114189.
33b0: 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 4f 6e  .</verbatim>..On
33c0: 63 65 20 61 67 61 69 6e 2c 20 73 69 6d 70 6c 79  ce again, simply
33d0: 20 61 20 66 75 72 74 68 65 72 20 65 78 74 65 6e   a further exten
33e0: 73 69 6f 6e 20 6f 66 20 74 68 65 20 61 6c 72 65  sion of the alre
33f0: 61 64 79 20 65 78 69 73 74 69 6e 67 20 3c 62 3e  ady existing <b>
3400: 53 54 5f 41 72 65 61 28 29 3c 2f 62 3e 2e 3c 62  ST_Area()</b>.<b
3410: 72 3e 0d 0a 4e 6f 77 20 69 66 20 74 68 65 20 69  r>..Now if the i
3420: 6e 70 75 74 20 47 65 6f 6d 65 74 72 79 20 61 64  nput Geometry ad
3430: 6f 70 74 73 20 3c 75 3e 67 65 6f 67 72 61 70 68  opts <u>geograph
3440: 69 63 20 63 6f 6f 72 64 69 6e 61 74 65 73 3c 2f  ic coordinates</
3450: 75 3e 20 28 69 2e 65 2e 20 62 61 73 65 64 20 6f  u> (i.e. based o
3460: 6e 20 3c 75 3e 6c 6f 6e 67 69 74 75 64 65 3c 2f  n <u>longitude</
3470: 75 3e 20 61 6e 64 20 3c 75 3e 6c 61 74 69 74 75  u> and <u>latitu
3480: 64 65 3c 2f 75 3e 20 61 6e 67 6c 65 73 29 2c 20  de</u> angles), 
3490: 61 20 73 65 63 6f 6e 64 20 61 72 67 75 6d 65 6e  a second argumen
34a0: 74 20 6f 66 20 74 68 65 20 3c 62 3e 42 6f 6f 6c  t of the <b>Bool
34b0: 65 61 6e 3c 2f 62 3e 20 64 61 74 61 2d 74 79 70  ean</b> data-typ
34c0: 65 20 63 6f 75 6c 64 20 62 65 20 6f 70 74 69 6f  e could be optio
34d0: 6e 61 6c 6c 79 20 73 70 65 63 69 66 69 65 64 2e  nally specified.
34e0: 3c 62 72 3e 0d 0a 49 6e 20 74 68 69 73 20 63 61  <br>..In this ca
34f0: 73 65 20 74 68 65 20 72 65 74 75 72 6e 65 64 20  se the returned 
3500: 41 72 65 61 20 77 69 6c 6c 20 62 65 20 6d 65 61  Area will be mea
3510: 73 75 72 65 64 20 69 6e 20 3c 62 3e 6d 65 74 65  sured in <b>mete
3520: 72 73 3c 2f 62 3e 2e 0d 0a 3c 75 6c 3e 0d 0a 3c  rs</b>...<ul>..<
3530: 6c 69 3e 69 66 20 74 68 65 20 73 65 63 6f 6e 64  li>if the second
3540: 20 61 72 67 20 69 73 20 3c 62 3e 54 52 55 45 3c   arg is <b>TRUE<
3550: 2f 62 3e 20 74 68 65 20 41 72 65 61 20 77 69 6c  /b> the Area wil
3560: 6c 20 62 65 20 6d 65 61 73 75 72 65 64 20 3c 75  l be measured <u
3570: 3e 6f 6e 20 74 68 65 20 45 6c 6c 69 70 73 6f 69  >on the Ellipsoi
3580: 64 3c 2f 75 3e 20 28 6d 6f 72 65 20 61 63 63 75  d</u> (more accu
3590: 72 61 74 65 2c 20 62 75 74 20 73 6c 6f 77 65 72  rate, but slower
35a0: 29 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 69 66 20  ).</li>..<li>if 
35b0: 74 68 65 20 73 65 63 6f 6e 64 20 61 72 67 20 69  the second arg i
35c0: 73 20 3c 62 3e 46 41 4c 53 45 3c 2f 62 3e 20 74  s <b>FALSE</b> t
35d0: 68 65 20 41 72 65 61 20 77 69 6c 6c 20 62 65 20  he Area will be 
35e0: 6d 65 61 73 75 72 65 20 3c 75 3e 6f 6e 20 74 68  measure <u>on th
35f0: 65 20 53 70 68 65 72 65 3c 2f 75 3e 20 28 66 61  e Sphere</u> (fa
3600: 73 74 65 72 2c 20 62 75 74 20 6c 65 73 73 20 61  ster, but less a
3610: 63 63 75 72 61 74 65 29 2e 3c 2f 6c 69 3e 0d 0a  ccurate).</li>..
3620: 3c 6c 69 3e 4e 55 4c 4c 20 77 69 6c 6c 20 62 65  <li>NULL will be
3630: 20 72 65 74 75 72 6e 65 64 20 6f 6e 20 69 6e 76   returned on inv
3640: 61 6c 69 64 20 61 72 67 73 2e 3c 2f 6c 69 3e 0d  alid args.</li>.
3650: 0a 3c 6c 69 3e 3c 75 3e 50 6c 65 61 73 65 20 6e  .<li><u>Please n
3660: 6f 74 65 3c 2f 75 3e 3a 20 74 68 69 73 20 73 70  ote</u>: this sp
3670: 65 63 69 66 69 63 20 66 6c 61 76 6f 72 20 6f 66  ecific flavor of
3680: 20 3c 62 3e 53 54 5f 41 72 65 61 28 29 3c 2f 62   <b>ST_Area()</b
3690: 3e 20 6e 65 63 65 73 73 61 72 69 6c 79 20 72 65  > necessarily re
36a0: 71 75 69 72 65 73 20 74 68 65 20 3c 62 3e 4c 57  quires the <b>LW
36b0: 47 45 4f 4d 3c 2f 62 3e 20 73 75 70 70 6f 72 74  GEOM</b> support
36c0: 20 74 6f 20 62 65 20 61 63 74 69 76 61 74 65 64   to be activated
36d0: 20 61 74 20 62 75 69 6c 64 20 74 69 6d 65 2e 3c   at build time.<
36e0: 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d  /li>..</ul><br>.
36f0: 0a 3c 68 72 3e 0d 0a 3c 76 65 72 62 61 74 69 6d  .<hr>..<verbatim
3700: 3e 0d 0a 53 45 4c 45 43 54 20 53 54 5f 41 73 54  >..SELECT ST_AsT
3710: 65 78 74 28 20 53 54 5f 50 72 6f 6a 65 63 74 28  ext( ST_Project(
3720: 20 4d 61 6b 65 50 6f 69 6e 74 28 20 31 31 2e 35   MakePoint( 11.5
3730: 32 2c 20 34 32 2e 33 38 2c 20 34 33 32 36 20 29  2, 42.38, 4326 )
3740: 2c 20 35 30 30 30 30 2c 20 52 61 64 69 61 6e 73  , 50000, Radians
3750: 28 20 34 35 20 29 20 29 20 29 3b 0d 0a 2d 2d 2d  ( 45 ) ) );..---
3760: 2d 2d 2d 2d 2d 2d 2d 0d 0a 50 4f 49 4e 54 28 31  -------..POINT(1
3770: 31 2e 39 35 31 34 37 39 20 34 32 2e 36 39 37 34  1.951479 42.6974
3780: 36 37 29 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e  67)..</verbatim>
3790: 0d 0a 54 68 65 20 3c 62 3e 53 54 5f 50 72 6f 6a  ..The <b>ST_Proj
37a0: 65 63 74 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75  ect()</b> SQL fu
37b0: 6e 63 74 69 6f 6e 20 77 69 6c 6c 20 72 65 74 75  nction will retu
37c0: 72 6e 20 74 68 65 20 64 65 73 74 69 6e 61 74 69  rn the destinati
37d0: 6f 6e 20 50 6f 69 6e 74 20 3c 75 3e 6f 6e 20 74  on Point <u>on t
37e0: 68 65 20 65 6c 6c 69 70 73 6f 69 64 3c 2f 75 3e  he ellipsoid</u>
37f0: 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20 74   corresponding t
3800: 6f 20 61 20 3c 62 3e 73 74 61 72 74 5f 70 6f 69  o a <b>start_poi
3810: 6e 74 3c 2f 62 3e 2c 20 61 20 3c 62 3e 64 69 73  nt</b>, a <b>dis
3820: 74 61 6e 63 65 3c 2f 62 3e 20 61 6e 64 20 61 20  tance</b> and a 
3830: 3c 62 3e 62 65 61 72 69 6e 67 3c 2f 62 3e 20 28  <b>bearing</b> (
3840: 61 6b 61 20 3c 75 3e 61 7a 69 6d 75 74 68 3c 2f  aka <u>azimuth</
3850: 75 3e 20 61 6b 61 20 3c 75 3e 64 69 72 65 63 74  u> aka <u>direct
3860: 69 6f 6e 3c 2f 75 3e 20 61 6b 61 20 3c 75 3e 68  ion</u> aka <u>h
3870: 65 61 64 69 6e 67 3c 2f 75 3e 29 2e 0d 0a 3c 75  eading</u>)...<u
3880: 6c 3e 0d 0a 3c 6c 69 3e 74 68 65 20 3c 62 3e 73  l>..<li>the <b>s
3890: 74 61 72 74 5f 70 6f 69 6e 74 3c 2f 62 3e 20 69  tart_point</b> i
38a0: 73 20 65 78 70 65 63 74 65 64 20 74 6f 20 61 64  s expected to ad
38b0: 6f 70 74 20 3c 75 3e 67 65 6f 67 72 61 70 68 69  opt <u>geographi
38c0: 63 20 63 6f 6f 72 64 69 6e 61 74 65 73 3c 2f 75  c coordinates</u
38d0: 3e 20 28 69 2e 65 2e 20 62 61 73 65 64 20 6f 6e  > (i.e. based on
38e0: 20 3c 75 3e 6c 6f 6e 67 69 74 75 64 65 3c 2f 75   <u>longitude</u
38f0: 3e 20 61 6e 64 20 3c 75 3e 6c 61 74 69 74 75 64  > and <u>latitud
3900: 65 3c 2f 75 3e 20 61 6e 67 6c 65 73 29 2e 3c 2f  e</u> angles).</
3910: 6c 69 3e 0d 0a 3c 6c 69 3e 74 68 65 20 3c 62 3e  li>..<li>the <b>
3920: 64 69 73 74 61 6e 63 65 3c 2f 62 3e 20 69 73 20  distance</b> is 
3930: 61 6c 77 61 79 73 20 65 78 70 65 63 74 65 64 20  always expected 
3940: 74 6f 20 62 65 20 65 78 70 72 65 73 73 65 64 20  to be expressed 
3950: 69 6e 20 3c 62 3e 6d 65 74 65 72 73 3c 2f 62 3e  in <b>meters</b>
3960: 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 74 68 65 20  .</li>..<li>the 
3970: 3c 62 3e 61 7a 69 6d 75 74 68 3c 2f 62 3e 20 61  <b>azimuth</b> a
3980: 6e 67 6c 65 20 69 73 20 65 78 70 65 63 74 65 64  ngle is expected
3990: 20 74 6f 20 62 65 20 65 78 70 72 65 73 73 65 64   to be expressed
39a0: 20 69 6e 20 3c 62 3e 72 61 64 69 61 6e 73 3c 2f   in <b>radians</
39b0: 62 3e 3a 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 4e  b>:..<ul>..<li>N
39c0: 6f 72 74 68 20 63 6f 72 72 65 73 70 6f 6e 64 73  orth corresponds
39d0: 20 74 6f 20 30 20 64 65 67 72 65 65 73 20 28 30   to 0 degrees (0
39e0: 20 72 61 64 69 61 6e 73 29 2e 3c 2f 6c 69 3e 0d   radians).</li>.
39f0: 0a 3c 6c 69 3e 45 61 73 74 20 63 6f 72 72 65 73  .<li>East corres
3a00: 70 6f 6e 64 73 20 74 6f 20 39 30 20 64 65 67 72  ponds to 90 degr
3a10: 65 65 73 20 28 50 49 2f 32 20 72 61 64 69 61 6e  ees (PI/2 radian
3a20: 73 29 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 53 6f  s).</li>..<li>So
3a30: 75 74 68 20 63 6f 72 72 65 73 70 6f 6e 64 73 20  uth corresponds 
3a40: 74 6f 20 31 38 30 20 64 65 67 72 65 65 73 20 28  to 180 degrees (
3a50: 50 49 20 72 61 64 69 61 6e 73 29 2e 3c 2f 6c 69  PI radians).</li
3a60: 3e 0d 0a 3c 6c 69 3e 57 65 73 74 20 63 6f 72 72  >..<li>West corr
3a70: 65 73 70 6f 6e 64 73 20 74 6f 20 32 37 30 20 64  esponds to 270 d
3a80: 65 67 72 65 65 73 20 28 33 50 49 2f 32 20 72 61  egrees (3PI/2 ra
3a90: 64 69 61 6e 73 29 2e 3c 2f 6c 69 3e 0d 0a 3c 6c  dians).</li>..<l
3aa0: 69 3e 69 2e 65 2e 20 69 74 20 68 61 73 20 74 68  i>i.e. it has th
3ab0: 65 20 73 61 6d 65 20 69 64 65 6e 74 69 63 61 6c  e same identical
3ac0: 20 6d 65 61 6e 69 6e 67 20 61 73 20 69 6e 20 3c   meaning as in <
3ad0: 62 3e 53 54 5f 41 7a 69 6d 75 74 68 28 29 3c 2f  b>ST_Azimuth()</
3ae0: 62 3e 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 3c  b>.</li>..</ul><
3af0: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 74 68 69 73 20 66  /li>..<li>this f
3b00: 75 6e 63 74 69 6f 6e 20 65 78 61 63 74 6c 79 20  unction exactly 
3b10: 63 6f 72 72 65 73 70 6f 6e 64 73 20 74 6f 20 74  corresponds to t
3b20: 68 65 20 6f 6e 65 20 73 75 70 70 6f 72 74 65 64  he one supported
3b30: 20 62 79 20 3c 62 3e 50 6f 73 74 47 49 53 3c 2f   by <b>PostGIS</
3b40: 62 3e 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 3c 75  b>.</li>..<li><u
3b50: 3e 50 6c 65 61 73 65 20 6e 6f 74 65 3c 2f 75 3e  >Please note</u>
3b60: 3a 20 3c 62 3e 53 54 5f 50 72 6f 6a 65 63 74 28  : <b>ST_Project(
3b70: 29 3c 2f 62 3e 20 6e 65 63 65 73 73 61 72 69 6c  )</b> necessaril
3b80: 79 20 72 65 71 75 69 72 65 73 20 74 68 65 20 3c  y requires the <
3b90: 62 3e 4c 57 47 45 4f 4d 3c 2f 62 3e 20 73 75 70  b>LWGEOM</b> sup
3ba0: 70 6f 72 74 20 74 6f 20 62 65 20 61 63 74 69 76  port to be activ
3bb0: 61 74 65 64 20 61 74 20 62 75 69 6c 64 20 74 69  ated at build ti
3bc0: 6d 65 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 3c  me.</li>..</ul><
3bd0: 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c 68 33 3e 3c  br>..<hr>..<h3><
3be0: 61 20 6e 61 6d 65 3d 22 75 6e 73 61 66 65 22 3e  a name="unsafe">
3bf0: 55 6e 73 61 66 65 3c 2f 61 3e 20 28 62 75 74 20  Unsafe</a> (but 
3c00: 75 73 65 66 75 6c 29 20 49 6d 70 6f 72 74 2f 45  useful) Import/E
3c10: 78 70 6f 72 74 20 53 51 4c 20 66 75 6e 63 74 69  xport SQL functi
3c20: 6f 6e 73 3c 2f 68 33 3e 0d 0a 41 6c 6c 20 74 68  ons</h3>..All th
3c30: 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 53 51 4c 20  e following SQL 
3c40: 66 75 6e 63 74 69 6f 6e 73 20 63 6f 75 6c 64 20  functions could 
3c50: 62 65 20 72 65 61 6c 6c 79 20 75 73 65 66 75 6c  be really useful
3c60: 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 73 75 70   in order to sup
3c70: 70 6f 72 74 20 49 6d 70 6f 72 74 2f 45 78 70 6f  port Import/Expo
3c80: 72 74 20 6f 70 65 72 61 74 69 6f 6e 73 2e 3c 62  rt operations.<b
3c90: 72 3e 0d 0a 41 6e 79 77 61 79 20 79 6f 75 20 73  r>..Anyway you s
3ca0: 68 6f 75 6c 64 20 62 65 20 3c 75 3e 77 65 6c 6c  hould be <u>well
3cb0: 20 61 77 61 72 65 3c 2f 75 3e 20 74 68 61 74 20   aware</u> that 
3cc0: 61 6c 6c 20 74 68 65 6d 20 63 6f 75 6c 64 20 62  all them could b
3cd0: 65 20 70 6f 74 65 6e 74 69 61 6c 6c 79 20 3c 75  e potentially <u
3ce0: 3e 75 6e 73 61 66 65 3c 2f 75 3e 20 61 6e 64 20  >unsafe</u> and 
3cf0: 63 6f 75 6c 64 20 62 65 20 70 6f 74 65 6e 74 69  could be potenti
3d00: 61 6c 6c 79 20 75 73 65 64 20 62 79 20 73 6f 6d  ally used by som
3d10: 65 20 3c 75 3e 6d 61 6c 69 63 69 6f 75 73 20 68  e <u>malicious h
3d20: 61 63 6b 65 72 3c 2f 75 3e 20 69 6e 20 6f 72 64  acker</u> in ord
3d30: 65 72 20 74 6f 20 63 72 65 61 74 65 20 61 6e 64  er to create and
3d40: 20 65 78 70 6c 6f 69 74 20 73 6f 6d 65 20 3c 75   exploit some <u
3d50: 3e 73 65 63 75 72 69 74 79 20 62 72 65 61 63 68  >security breach
3d60: 3c 2f 75 3e 2e 3c 62 72 3e 0d 0a 54 68 65 20 63  </u>.<br>..The c
3d70: 61 75 73 65 20 69 73 20 76 65 72 79 20 65 61 73  ause is very eas
3d80: 79 20 74 6f 20 62 65 20 75 6e 64 65 72 73 74 6f  y to be understo
3d90: 6f 64 3a 20 74 68 65 73 65 20 66 75 6e 63 74 69  od: these functi
3da0: 6f 6e 73 20 61 6c 6c 6f 77 20 74 6f 20 74 72 61  ons allow to tra
3db0: 6e 73 66 65 72 20 61 72 62 69 74 72 61 72 79 20  nsfer arbitrary 
3dc0: 70 61 79 6c 6f 61 64 73 20 66 72 6f 6d 20 2f 20  payloads from / 
3dd0: 74 6f 20 74 68 65 20 44 61 74 61 62 61 73 65 20  to the Database 
3de0: 61 6e 64 20 74 68 65 20 6c 6f 63 61 6c 20 46 69  and the local Fi
3df0: 6c 65 2d 53 79 73 74 65 6d 2e 0d 0a 41 20 6d 61  le-System...A ma
3e00: 6c 69 63 69 6f 75 73 20 61 74 74 61 63 6b 20 63  licious attack c
3e10: 6f 75 6c 64 20 62 65 20 74 68 75 73 20 69 6d 70  ould be thus imp
3e20: 6c 65 6d 65 6e 74 65 64 20 65 2e 67 2e 20 62 79  lemented e.g. by
3e30: 20 65 78 65 63 75 74 69 6e 67 20 73 6f 6d 65 20   executing some 
3e40: 53 51 4c 20 73 63 72 69 70 74 20 6f 72 20 62 79  SQL script or by
3e50: 20 64 65 66 69 6e 69 6e 67 20 61 20 70 75 72 70   defining a purp
3e60: 6f 73 65 6c 79 20 66 6f 72 67 65 64 20 54 72 69  osely forged Tri
3e70: 67 67 65 72 2c 20 61 6e 64 20 74 68 65 20 65 6e  gger, and the en
3e80: 64 20 75 73 65 72 73 20 77 6f 75 6c 64 20 62 65  d users would be
3e90: 20 61 62 73 6f 6c 75 74 65 6c 79 20 75 6e 61 77   absolutely unaw
3ea0: 61 72 65 20 6f 66 20 77 68 61 74 20 69 73 20 72  are of what is r
3eb0: 65 61 6c 6c 79 20 68 61 70 70 65 6e 69 6e 67 2e  eally happening.
3ec0: 0d 0a 53 6f 20 69 6e 20 6f 72 64 65 72 20 74 6f  ..So in order to
3ed0: 20 65 66 66 65 63 74 69 76 65 6c 79 20 73 68 69   effectively shi
3ee0: 65 6c 64 20 75 73 65 72 73 20 61 67 61 69 6e 73  eld users agains
3ef0: 74 20 74 68 65 73 65 20 70 6f 74 65 6e 74 69 61  t these potentia
3f00: 6c 6c 79 20 64 61 6e 67 65 72 6f 75 73 20 73 65  lly dangerous se
3f10: 63 75 72 69 74 79 20 70 69 74 66 61 6c 6c 73 20  curity pitfalls 
3f20: 61 6c 6c 20 74 68 65 73 65 20 53 51 4c 20 66 75  all these SQL fu
3f30: 6e 63 74 69 6f 6e 73 20 61 72 65 20 61 6c 77 61  nctions are alwa
3f40: 79 73 20 3c 75 3e 64 69 73 61 62 6c 65 64 20 62  ys <u>disabled b
3f50: 79 20 64 65 66 61 75 6c 74 3c 2f 75 3e 2e 0d 0a  y default</u>...
3f60: 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 65 78 70 6f  <verbatim>..expo
3f70: 72 74 20 22 53 50 41 54 49 41 4c 49 54 45 5f 53  rt "SPATIALITE_S
3f80: 45 43 55 52 49 54 59 3d 72 65 6c 61 78 65 64 22  ECURITY=relaxed"
3f90: 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 49  ..</verbatim>..I
3fa0: 6e 20 6f 72 64 65 72 20 74 6f 20 72 65 61 6c 6c  n order to reall
3fb0: 79 20 65 6e 61 62 6c 65 20 74 68 65 73 65 20 66  y enable these f
3fc0: 75 6e 63 74 69 6f 6e 73 20 74 68 65 20 75 73 65  unctions the use
3fd0: 72 20 69 73 20 72 65 71 75 69 72 65 64 20 74 6f  r is required to
3fe0: 20 74 61 6b 65 20 61 6e 20 65 78 70 6c 69 63 69   take an explici
3ff0: 74 20 61 63 74 69 6f 6e 3b 20 69 2e 65 2e 20 74  t action; i.e. t
4000: 68 65 20 3c 75 3e 65 6e 76 69 72 6f 6e 6d 65 6e  he <u>environmen
4010: 74 20 76 61 72 69 61 62 6c 65 3c 2f 75 3e 20 3c  t variable</u> <
4020: 62 3e 53 50 41 54 49 41 4c 49 54 45 5f 53 45 43  b>SPATIALITE_SEC
4030: 55 52 49 54 59 3d 72 65 6c 61 78 65 64 3c 2f 62  URITY=relaxed</b
4040: 3e 20 68 61 73 20 74 6f 20 62 65 20 64 65 66 69  > has to be defi
4050: 6e 65 64 2e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e  ned...<verbatim>
4060: 0d 0a 53 45 4c 45 43 54 20 43 6f 75 6e 74 55 6e  ..SELECT CountUn
4070: 73 61 66 65 54 72 69 67 67 65 72 73 28 29 3b 0d  safeTriggers();.
4080: 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 30 0d 0a 3c  .---------..0..<
4090: 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 54 68 65 20  /verbatim>..The 
40a0: 3c 62 3e 43 6f 75 6e 74 55 6e 73 61 66 65 54 72  <b>CountUnsafeTr
40b0: 69 67 67 65 72 73 28 29 3c 2f 62 3e 20 61 63 74  iggers()</b> act
40c0: 75 61 6c 6c 79 20 63 68 65 63 6b 73 20 69 66 20  ually checks if 
40d0: 74 68 65 20 63 6f 6e 6e 65 63 74 65 64 20 44 61  the connected Da
40e0: 74 61 62 61 73 65 20 64 6f 65 73 20 63 6f 6e 74  tabase does cont
40f0: 61 69 6e 73 20 61 6e 79 20 73 75 73 70 65 63 74  ains any suspect
4100: 20 54 72 69 67 67 65 72 3b 20 63 68 65 63 6b 69   Trigger; checki
4110: 6e 67 20 74 68 69 73 20 76 65 72 73 69 6f 6e 20  ng this version 
4120: 62 65 66 6f 72 65 20 65 6e 61 62 6c 69 6e 67 20  before enabling 
4130: 74 68 65 20 75 6e 73 61 66 65 20 53 51 4c 20 46  the unsafe SQL F
4140: 75 6e 63 74 69 6f 6e 73 20 69 73 20 61 6c 77 61  unctions is alwa
4150: 79 73 20 68 69 67 68 6c 79 20 72 65 63 6f 6d 6d  ys highly recomm
4160: 65 6e 64 65 64 2e 3c 62 72 3e 0d 0a 41 20 72 65  ended.<br>..A re
4170: 73 75 6c 74 20 64 69 66 66 65 72 65 6e 74 20 66  sult different f
4180: 72 6f 6d 20 5a 45 52 4f 20 69 6d 70 6c 69 65 73  rom ZERO implies
4190: 20 74 68 61 74 20 73 6f 6d 65 20 6d 61 6c 69 63   that some malic
41a0: 69 6f 75 73 20 54 72 69 67 67 65 72 20 68 61 73  ious Trigger has
41b0: 20 62 65 65 6e 20 69 64 65 6e 74 69 66 69 65 64   been identified
41c0: 3b 20 69 6e 20 74 68 69 73 20 63 61 73 65 20 79  ; in this case y
41d0: 6f 75 20 63 61 6e 20 70 65 72 66 6f 72 6d 20 61  ou can perform a
41e0: 20 64 65 65 70 65 73 74 20 69 6e 73 70 65 63 74   deepest inspect
41f0: 69 6f 6e 20 62 79 20 65 78 65 63 75 74 69 6e 67  ion by executing
4200: 20 74 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 53   the following S
4210: 51 4c 20 71 75 65 72 79 3a 0d 0a 3c 76 65 72 62  QL query:..<verb
4220: 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 74 79  atim>..SELECT ty
4230: 70 65 2c 20 6e 61 6d 65 2c 20 74 62 6c 5f 6e 61  pe, name, tbl_na
4240: 6d 65 2c 20 73 71 6c 20 0d 0a 46 52 4f 4d 20 73  me, sql ..FROM s
4250: 71 6c 69 74 65 5f 6d 61 73 74 65 72 20 0d 0a 57  qlite_master ..W
4260: 48 45 52 45 20 74 79 70 65 20 49 4e 20 28 27 74  HERE type IN ('t
4270: 72 69 67 67 65 72 27 2c 20 27 76 69 65 77 27 29  rigger', 'view')
4280: 20 41 4e 44 20 28 73 71 6c 20 4c 49 4b 45 20 27   AND (sql LIKE '
4290: 25 42 6c 6f 62 46 72 6f 6d 46 69 6c 65 25 27 20  %BlobFromFile%' 
42a0: 0d 0a 20 20 20 4f 52 20 73 71 6c 20 4c 49 4b 45  ..   OR sql LIKE
42b0: 20 27 25 42 6c 6f 62 54 6f 46 69 6c 65 25 27 20   '%BlobToFile%' 
42c0: 4f 52 20 73 71 6c 20 4c 49 4b 45 20 27 25 58 42  OR sql LIKE '%XB
42d0: 5f 4c 6f 61 64 58 4d 4c 25 27 20 0d 0a 20 20 20  _LoadXML%' ..   
42e0: 4f 52 20 73 71 6c 20 4c 49 4b 45 20 27 25 58 42  OR sql LIKE '%XB
42f0: 5f 53 74 6f 72 65 58 4d 4c 25 27 29 3b 0d 0a 3c  _StoreXML%');..<
4300: 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 74 68 69 73  /verbatim>..this
4310: 20 77 69 6c 6c 20 67 69 76 65 20 61 20 66 75 6c   will give a ful
4320: 6c 20 72 65 70 6f 72 74 20 66 6f 72 20 61 6e 79  l report for any
4330: 20 6d 61 6c 69 63 69 6f 75 73 20 54 72 69 67 67   malicious Trigg
4340: 65 72 20 65 76 65 6e 74 75 61 6c 6c 79 20 66 6f  er eventually fo
4350: 75 6e 64 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68  und.<br><br>..<h
4360: 72 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a  r>..<verbatim>..
4370: 53 45 4c 45 43 54 20 42 6c 6f 62 46 72 6f 6d 46  SELECT BlobFromF
4380: 69 6c 65 28 20 27 43 3a 2f 6d 79 70 69 63 74 75  ile( 'C:/mypictu
4390: 72 65 73 2f 73 75 6e 73 65 74 2e 6a 70 67 27 20  res/sunset.jpg' 
43a0: 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 42  );..---------..B
43b0: 4c 4f 42 2d 76 61 6c 75 65 0d 0a 3c 2f 76 65 72  LOB-value..</ver
43c0: 62 61 74 69 6d 3e 0d 0a 54 68 65 20 3c 62 3e 42  batim>..The <b>B
43d0: 6c 6f 62 46 72 6f 6d 46 69 6c 65 28 29 3c 2f 62  lobFromFile()</b
43e0: 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 61  > SQL function a
43f0: 6c 6c 6f 77 73 20 74 6f 20 69 6d 70 6f 72 74 20  llows to import 
4400: 61 20 77 68 6f 6c 65 20 66 69 6c 65 20 69 6e 20  a whole file in 
4410: 61 20 73 69 6e 67 6c 65 20 73 74 65 70 3b 20 74  a single step; t
4420: 68 65 20 66 75 6c 6c 20 66 69 6c 65 20 70 61 79  he full file pay
4430: 6c 6f 61 64 20 77 69 6c 6c 20 62 65 20 72 65 74  load will be ret
4440: 75 72 6e 65 64 20 61 73 20 61 20 42 4c 4f 42 20  urned as a BLOB 
4450: 76 61 6c 75 65 2e 3c 62 72 3e 0d 0a 49 66 20 74  value.<br>..If t
4460: 68 65 20 61 72 67 75 6d 65 6e 74 20 28 3c 62 3e  he argument (<b>
4470: 66 69 6c 65 2d 70 61 74 68 3c 2f 62 3e 29 20 64  file-path</b>) d
4480: 6f 65 73 6e 27 74 20 63 6f 72 72 65 73 70 6f 6e  oesn't correspon
4490: 64 73 20 74 6f 20 61 20 76 61 6c 69 64 20 66 69  ds to a valid fi
44a0: 6c 65 20 6f 72 20 69 66 20 74 68 65 20 65 78 74  le or if the ext
44b0: 65 72 6e 61 6c 20 66 69 6c 65 20 63 61 6e 6e 6f  ernal file canno
44c0: 74 20 62 65 20 61 63 63 65 73 73 65 64 20 66 6f  t be accessed fo
44d0: 72 20 61 6e 79 20 72 65 61 73 6f 6e 20 4e 55 4c  r any reason NUL
44e0: 4c 20 77 69 6c 6c 20 62 65 20 72 65 74 75 72 6e  L will be return
44f0: 65 64 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68 72  ed.<br><br>..<hr
4500: 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53  >..<verbatim>..S
4510: 45 4c 45 43 54 20 42 6c 6f 62 54 6f 46 69 6c 65  ELECT BlobToFile
4520: 28 20 73 6f 6d 65 42 6c 6f 62 20 2c 20 27 43 3a  ( someBlob , 'C:
4530: 2f 6d 79 70 69 63 74 75 72 65 73 2f 73 75 6e 73  /mypictures/suns
4540: 65 74 2e 6a 70 67 27 20 29 3b 0d 0a 2d 2d 2d 2d  et.jpg' );..----
4550: 2d 2d 2d 2d 2d 0d 0a 31 0d 0a 3c 2f 76 65 72 62  -----..1..</verb
4560: 61 74 69 6d 3e 0d 0a 54 68 65 20 3c 62 3e 42 6c  atim>..The <b>Bl
4570: 6f 62 54 6f 46 69 6c 65 28 29 3c 2f 62 3e 20 53  obToFile()</b> S
4580: 51 4c 20 66 75 6e 63 74 69 6f 6e 20 70 65 72 66  QL function perf
4590: 6f 72 6d 73 20 74 68 65 20 6f 70 70 6f 73 69 74  orms the opposit
45a0: 65 20 74 61 73 6b 2c 20 69 2e 65 2e 20 69 74 20  e task, i.e. it 
45b0: 65 78 70 6f 72 74 73 20 61 20 77 68 6f 6c 65 20  exports a whole 
45c0: 42 4c 4f 42 20 69 6e 74 6f 20 61 6e 20 65 78 74  BLOB into an ext
45d0: 65 72 6e 61 6c 20 66 69 6c 65 3b 20 74 68 65 20  ernal file; the 
45e0: 66 69 72 73 74 20 61 72 67 75 6d 65 6e 74 20 6d  first argument m
45f0: 75 73 74 20 63 6f 72 72 65 73 70 6f 6e 64 20 74  ust correspond t
4600: 6f 20 73 6f 6d 65 20 42 4c 4f 42 2c 20 74 68 65  o some BLOB, the
4610: 20 73 65 63 6f 6e 64 20 6f 6e 65 20 69 73 20 74   second one is t
4620: 68 65 20 3c 62 3e 66 69 6c 65 2d 70 61 74 68 3c  he <b>file-path<
4630: 2f 62 3e 20 69 64 65 6e 74 69 66 79 69 6e 67 20  /b> identifying 
4640: 74 68 65 20 66 69 6c 65 20 74 6f 20 62 65 20 63  the file to be c
4650: 72 65 61 74 65 64 20 6f 72 20 6f 76 65 72 77 72  reated or overwr
4660: 69 74 74 65 6e 2e 3c 62 72 3e 3c 62 72 3e 0d 0a  itten.<br><br>..
4670: 3c 75 3e 50 6c 65 61 73 65 20 6e 6f 74 65 3c 2f  <u>Please note</
4680: 75 3e 3a 20 62 6f 74 68 20 3c 62 3e 42 6c 6f 62  u>: both <b>Blob
4690: 46 72 6f 6d 46 69 6c 65 28 29 3c 2f 62 3e 20 61  FromFile()</b> a
46a0: 6e 64 20 3c 62 3e 42 6c 6f 62 54 6f 46 69 6c 65  nd <b>BlobToFile
46b0: 28 29 3c 2f 62 3e 20 77 65 72 65 20 61 6c 72 65  ()</b> were alre
46c0: 61 64 79 20 73 75 70 70 6f 72 74 65 64 20 62 79  ady supported by
46d0: 20 34 2e 30 2e 30 2c 20 62 75 74 20 61 20 71 75   4.0.0, but a qu
46e0: 69 63 6b 20 72 65 63 61 6c 6c 20 69 73 20 61 6e  ick recall is an
46f0: 79 77 61 79 20 75 73 65 66 75 6c 20 73 6f 20 74  yway useful so t
4700: 6f 20 72 65 63 61 6c 6c 20 61 20 63 6c 65 61 72  o recall a clear
4710: 65 72 20 63 6f 6e 74 65 78 74 2e 3c 62 72 3e 3c  er context.<br><
4720: 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72 62  br>..<hr>..<verb
4730: 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 58 42  atim>..SELECT XB
4740: 5f 4c 6f 61 64 58 4d 4c 28 20 27 43 3a 2f 6d 79  _LoadXML( 'C:/my
4750: 64 6f 63 73 2f 69 73 6f 6d 65 74 61 64 61 74 61  docs/isometadata
4760: 2d 73 61 6d 70 6c 65 2e 78 6d 6c 27 20 29 3b 0d  -sample.xml' );.
4770: 0a 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 42 4c 4f 42 2d  .--------..BLOB-
4780: 76 61 6c 75 65 0d 0a 0d 0a 53 45 4c 45 43 54 20  value....SELECT 
4790: 58 42 5f 4c 6f 61 64 58 4d 4c 28 20 27 68 74 74  XB_LoadXML( 'htt
47a0: 70 3a 2f 2f 77 77 77 2e 61 63 6d 65 2e 63 6f 6d  p://www.acme.com
47b0: 2f 70 75 62 6c 69 63 2f 69 73 6f 6d 65 74 61 64  /public/isometad
47c0: 61 74 61 2d 73 61 6d 70 6c 65 2e 78 6d 6c 27 20  ata-sample.xml' 
47d0: 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 42 4c  );..--------..BL
47e0: 4f 42 2d 76 61 6c 75 65 0d 0a 3c 2f 76 65 72 62  OB-value..</verb
47f0: 61 74 69 6d 3e 0d 0a 54 68 65 20 3c 62 3e 58 42  atim>..The <b>XB
4800: 5f 4c 6f 61 64 58 4d 4c 28 29 3c 2f 62 3e 20 53  _LoadXML()</b> S
4810: 51 4c 20 66 75 6e 63 74 69 6f 6e 20 61 6c 6c 6f  QL function allo
4820: 77 73 20 74 6f 20 69 6d 70 6f 72 74 20 61 6e 20  ws to import an 
4830: 58 4d 4c 20 44 6f 63 75 6d 65 6e 74 20 69 6e 20  XML Document in 
4840: 61 20 73 69 6e 67 6c 65 20 73 74 65 70 3a 20 74  a single step: t
4850: 68 65 20 66 75 6c 6c 20 58 4d 4c 20 44 6f 63 75  he full XML Docu
4860: 6d 65 6e 74 20 70 61 79 6c 6f 61 64 20 77 69 6c  ment payload wil
4870: 6c 20 62 65 20 72 65 74 75 72 6e 65 64 20 61 73  l be returned as
4880: 20 61 20 42 4c 4f 42 20 76 61 6c 75 65 2e 3c 62   a BLOB value.<b
4890: 72 3e 0d 0a 54 68 65 20 70 61 73 73 65 64 20 61  r>..The passed a
48a0: 72 67 75 6d 65 6e 74 20 63 61 6e 20 69 6e 64 69  rgument can indi
48b0: 66 66 65 72 65 6e 74 6c 79 20 62 65 20 61 20 3c  fferently be a <
48c0: 62 3e 66 69 6c 65 2d 70 61 74 68 3c 2f 62 3e 20  b>file-path</b> 
48d0: 6f 72 20 61 20 3c 62 3e 55 52 4c 3c 2f 62 3e 3b  or a <b>URL</b>;
48e0: 20 69 66 20 74 68 65 20 64 61 74 61 73 6f 75 72   if the datasour
48f0: 63 65 20 63 61 6e 6e 6f 74 20 62 65 20 61 63 63  ce cannot be acc
4900: 65 73 73 65 64 2c 20 6f 72 20 69 66 20 69 74 20  essed, or if it 
4910: 64 6f 65 73 6e 27 74 20 63 6f 6e 74 61 69 6e 73  doesn't contains
4920: 20 61 20 3c 75 3e 77 65 6c 6c 2d 66 6f 72 6d 65   a <u>well-forme
4930: 64 3c 2f 75 3e 20 58 4d 4c 20 44 6f 63 75 6d 65  d</u> XML Docume
4940: 6e 74 20 4e 55 4c 4c 20 77 69 6c 6c 20 62 65 20  nt NULL will be 
4950: 72 65 74 75 72 6e 65 64 2e 3c 62 72 3e 3c 62 72  returned.<br><br
4960: 3e 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72 62 61 74  >..<hr>..<verbat
4970: 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 58 42 5f 53  im>..SELECT XB_S
4980: 74 6f 72 65 58 4d 4c 28 20 73 6f 6d 65 58 6d 6c  toreXML( someXml
4990: 42 6c 6f 62 2c 20 27 43 3a 2f 6d 79 64 6f 63 73  Blob, 'C:/mydocs
49a0: 2f 69 73 6f 6d 65 74 61 64 61 74 61 2d 73 61 6d  /isometadata-sam
49b0: 70 6c 65 2e 78 6d 6c 27 20 29 3b 0d 0a 2d 2d 2d  ple.xml' );..---
49c0: 2d 2d 2d 2d 2d 2d 0d 0a 31 0d 0a 3c 2f 76 65 72  ------..1..</ver
49d0: 62 61 74 69 6d 3e 0d 0a 54 68 65 20 3c 62 3e 58  batim>..The <b>X
49e0: 42 5f 53 74 6f 72 65 58 4d 4c 28 29 3c 2f 62 3e  B_StoreXML()</b>
49f0: 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 70 65   SQL function pe
4a00: 72 66 6f 72 6d 73 20 74 68 65 20 6f 70 70 6f 73  rforms the oppos
4a10: 69 74 65 20 74 61 73 6b 2c 20 69 2e 65 2e 20 69  ite task, i.e. i
4a20: 74 20 65 78 70 6f 72 74 73 20 61 20 77 68 6f 6c  t exports a whol
4a30: 65 20 58 6d 6c 42 4c 4f 42 20 69 6e 74 6f 20 61  e XmlBLOB into a
4a40: 6e 20 65 78 74 65 72 6e 61 6c 20 66 69 6c 65 20  n external file 
4a50: 61 73 20 61 6e 20 58 4d 4c 20 44 6f 63 75 6d 65  as an XML Docume
4a60: 6e 74 3b 20 74 68 65 20 66 69 72 73 74 20 61 72  nt; the first ar
4a70: 67 75 6d 65 6e 74 20 6d 75 73 74 20 63 6f 72 72  gument must corr
4a80: 65 73 70 6f 6e 64 20 74 6f 20 73 6f 6d 65 20 76  espond to some v
4a90: 61 6c 69 64 20 58 6d 6c 42 4c 4f 42 2c 20 74 68  alid XmlBLOB, th
4aa0: 65 20 73 65 63 6f 6e 64 20 6f 6e 65 20 69 73 20  e second one is 
4ab0: 74 68 65 20 3c 62 3e 66 69 6c 65 2d 70 61 74 68  the <b>file-path
4ac0: 3c 2f 62 3e 20 69 64 65 6e 74 69 66 79 69 6e 67  </b> identifying
4ad0: 20 74 68 65 20 66 69 6c 65 20 74 6f 20 62 65 20   the file to be 
4ae0: 63 72 65 61 74 65 64 20 6f 72 20 6f 76 65 72 77  created or overw
4af0: 72 69 74 74 65 6e 2e 20 0d 0a 3c 76 65 72 62 61  ritten. ..<verba
4b00: 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 58 42 5f  tim>..SELECT XB_
4b10: 53 74 6f 72 65 58 4d 4c 28 20 73 6f 6d 65 58 6d  StoreXML( someXm
4b20: 6c 42 6c 6f 62 2c 20 27 43 3a 2f 6d 79 64 6f 63  lBlob, 'C:/mydoc
4b30: 73 2f 69 73 6f 6d 65 74 61 64 61 74 61 2d 73 61  s/isometadata-sa
4b40: 6d 70 6c 65 2e 78 6d 6c 27 2c 20 34 20 29 3b 0d  mple.xml', 4 );.
4b50: 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 31 0d 0a 3c  .---------..1..<
4b60: 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 41 20 66 75  /verbatim>..A fu
4b70: 72 74 68 65 72 20 6f 70 74 69 6f 6e 61 6c 20 3c  rther optional <
4b80: 62 3e 69 6e 64 65 6e 74 61 74 69 6f 6e 3c 2f 62  b>indentation</b
4b90: 3e 20 61 72 67 75 6d 65 6e 74 20 63 61 6e 20 62  > argument can b
4ba0: 65 20 65 76 65 6e 74 75 61 6c 6c 79 20 73 70 65  e eventually spe
4bb0: 63 69 66 69 65 64 3b 20 74 68 69 73 20 61 72 67  cified; this arg
4bc0: 75 6d 65 6e 74 20 77 69 6c 6c 20 62 65 20 68 61  ument will be ha
4bd0: 6e 64 6c 65 64 20 65 78 61 63 74 6c 79 20 69 6e  ndled exactly in
4be0: 20 74 68 65 20 73 61 6d 65 20 77 61 79 20 61 6c   the same way al
4bf0: 72 65 61 64 79 20 73 70 65 63 69 66 69 65 64 20  ready specified 
4c00: 66 6f 72 20 62 6f 74 68 20 3c 62 3e 58 42 5f 47  for both <b>XB_G
4c10: 65 74 50 61 79 6c 6f 61 64 28 29 3c 2f 62 3e 20  etPayload()</b> 
4c20: 61 6e 64 20 3c 62 3e 58 42 5f 47 65 74 44 6f 63  and <b>XB_GetDoc
4c30: 75 6d 65 6e 74 28 29 3c 2f 62 3e 20 66 75 6e 63  ument()</b> func
4c40: 74 69 6f 6e 73 2e 3c 62 72 3e 3c 62 72 3e 0d 0a  tions.<br><br>..
4c50: 3c 68 72 3e 3c 62 72 3e 0d 0a 62 61 63 6b 20 74  <hr><br>..back t
4c60: 6f 20 3c 61 20 68 72 65 66 3d 22 68 74 74 70 73  o <a href="https
4c70: 3a 2f 2f 77 77 77 2e 67 61 69 61 2d 67 69 73 2e  ://www.gaia-gis.
4c80: 69 74 2f 66 6f 73 73 69 6c 2f 6c 69 62 73 70 61  it/fossil/libspa
4c90: 74 69 61 6c 69 74 65 2f 77 69 6b 69 3f 6e 61 6d  tialite/wiki?nam
4ca0: 65 3d 34 2e 31 2e 30 2d 64 6f 63 22 3e 34 2e 31  e=4.1.0-doc">4.1
4cb0: 2e 30 2d 64 6f 63 3c 2f 61 3e 0a 5a 20 65 33 30  .0-doc</a>.Z e30
4cc0: 39 35 32 32 37 61 62 35 64 36 34 32 33 31 34 36  95227ab5d6423146
4cd0: 64 31 64 38 61 30 33 33 61 66 62 39 30 0a        d1d8a033afb90.