Hex Artifact Content
Not logged in

Artifact 45b890ec7de19476a9cb57aed119f2df9a2658db:

Wiki page [4.1.0 Changes] by sandro 2013-05-30 14:27:42.
0000: 44 20 32 30 31 33 2d 30 35 2d 33 30 54 31 34 3a  D 2013-05-30T14:
0010: 32 37 3a 34 32 2e 30 36 35 0a 4c 20 34 2e 31 2e  27:42.065.L 4.1.
0020: 30 5c 73 43 68 61 6e 67 65 73 0a 50 20 38 32 62  0\sChanges.P 82b
0030: 39 34 38 39 31 64 36 31 39 38 37 37 37 37 35 36  94891d6198777756
0040: 38 38 64 30 30 65 63 62 34 65 35 63 61 61 34 64  88d00ecb4e5caa4d
0050: 38 36 66 63 39 0a 55 20 73 61 6e 64 72 6f 0a 57  86fc9.U sandro.W
0060: 20 31 39 35 34 34 0a 62 61 63 6b 20 74 6f 20 3c   19544.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 6e 61 6d 65 3d 63 69 72 63 6c 65 73  iki?name=circles
0250: 2d 65 6c 6c 69 70 73 65 73 22 3e 43 69 72 63 6c  -ellipses">Circl
0260: 65 73 20 61 6e 64 20 45 6c 6c 69 70 73 65 73 3c  es and Ellipses<
0270: 2f 61 3e 3c 2f 6c 69 3e 3c 2f 75 6c 3e 3c 2f 6c  /a></li></ul></l
0280: 69 3e 0d 0a 3c 6c 69 3e 53 51 4c 20 66 75 6e 63  i>..<li>SQL func
0290: 74 69 6f 6e 73 20 73 75 70 70 6f 72 74 69 6e 67  tions supporting
02a0: 20 3c 61 20 68 72 65 66 3d 22 23 75 6e 73 61 66   <a href="#unsaf
02b0: 65 22 3e 75 6e 73 61 66 65 3c 2f 61 3e 20 64 69  e">unsafe</a> di
02c0: 72 65 63 74 20 49 6d 70 6f 72 74 2f 45 78 70 6f  rect Import/Expo
02d0: 72 74 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 0d 0a  rt</li>..</ul>..
02e0: 3c 68 33 3e 3c 61 20 6e 61 6d 65 3d 22 67 65 6e  <h3><a name="gen
02f0: 65 72 69 63 22 3e 63 61 73 74 3c 2f 61 3e 20 53  eric">cast</a> S
0300: 51 4c 20 66 75 6e 63 74 69 6f 6e 73 20 2d 20 74  QL functions - t
0310: 79 70 65 20 63 61 73 74 69 6e 67 3c 2f 68 33 3e  ype casting</h3>
0320: 0d 0a 53 51 4c 69 74 65 20 6f 66 66 65 72 73 20  ..SQLite offers 
0330: 6a 75 73 74 20 61 20 76 65 72 79 20 62 61 73 69  just a very basi
0340: 63 20 74 79 70 65 20 63 68 65 63 6b 69 6e 67 3b  c type checking;
0350: 20 74 68 69 73 20 69 73 20 73 6f 6d 65 74 69 6d   this is sometim
0360: 65 73 20 75 73 65 66 75 6c 2c 20 62 75 74 20 63  es useful, but c
0370: 6f 75 6c 64 20 62 65 20 72 65 61 6c 6c 79 20 61  ould be really a
0380: 6e 6e 6f 79 69 6e 67 20 76 65 72 79 20 6f 66 74  nnoying very oft
0390: 65 6e 2e 3c 62 72 3e 0d 0a 3c 76 65 72 62 61 74  en.<br>..<verbat
03a0: 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 27 31 27 2c  im>..SELECT '1',
03b0: 20 54 79 70 65 4f 66 28 20 27 31 27 20 29 2c 20   TypeOf( '1' ), 
03c0: 43 41 53 54 20 28 20 27 31 27 20 41 53 20 49 4e  CAST ( '1' AS IN
03d0: 54 45 47 45 52 20 29 2c 20 54 79 70 65 4f 66 28  TEGER ), TypeOf(
03e0: 20 43 41 53 54 20 28 20 27 31 27 20 41 53 20 49   CAST ( '1' AS I
03f0: 4e 54 45 47 45 52 20 29 20 29 3b 0d 0a 3c 2f 76  NTEGER ) );..</v
0400: 65 72 62 61 74 69 6d 3e 0d 0a 3c 74 61 62 6c 65  erbatim>..<table
0410: 20 62 6f 72 64 65 72 3d 22 31 22 20 63 65 6c 6c   border="1" cell
0420: 73 70 61 63 69 6e 67 3d 22 34 22 20 63 65 6c 6c  spacing="4" cell
0430: 70 61 64 64 69 6e 67 3d 22 34 22 3e 0d 0a 3c 74  padding="4">..<t
0440: 72 3e 3c 74 68 3e 27 31 27 3c 2f 74 68 3e 3c 74  r><th>'1'</th><t
0450: 68 3e 54 79 70 65 4f 66 28 20 27 31 27 20 29 3c  h>TypeOf( '1' )<
0460: 2f 74 68 3e 3c 74 68 3e 43 41 53 54 20 28 20 27  /th><th>CAST ( '
0470: 31 27 20 41 53 20 49 4e 54 45 47 45 52 20 29 3c  1' AS INTEGER )<
0480: 2f 74 68 3e 3c 74 68 3e 54 79 70 65 4f 66 28 20  /th><th>TypeOf( 
0490: 43 41 53 54 20 28 20 27 31 27 20 41 53 20 49 4e  CAST ( '1' AS IN
04a0: 54 45 47 45 52 20 29 20 29 3c 2f 74 68 3e 3c 2f  TEGER ) )</th></
04b0: 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 31 3c 2f  tr>..<tr><td>1</
04c0: 74 64 3e 3c 74 64 3e 74 65 78 74 3c 2f 74 64 3e  td><td>text</td>
04d0: 3c 74 64 20 61 6c 69 67 6e 3d 22 72 69 67 68 74  <td align="right
04e0: 22 3e 31 3c 2f 74 64 3e 3c 74 64 3e 69 6e 74 65  ">1</td><td>inte
04f0: 67 65 72 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74  ger</td></tr></t
0500: 61 62 6c 65 3e 3c 62 72 3e 0d 0a 54 68 65 20 53  able><br>..The S
0510: 51 4c 20 3c 62 3e 43 41 53 54 3c 2f 62 3e 20 6f  QL <b>CAST</b> o
0520: 70 65 72 61 74 6f 72 20 61 6c 72 65 61 64 79 20  perator already 
0530: 73 75 70 70 6f 72 74 73 20 74 68 65 20 70 6f 73  supports the pos
0540: 73 69 62 69 6c 69 74 79 20 74 6f 20 65 78 70 6c  sibility to expl
0550: 69 63 69 74 6c 79 20 73 65 74 20 61 20 64 61 74  icitly set a dat
0560: 61 2d 74 79 70 65 3b 20 6e 6f 77 20 73 74 61 72  a-type; now star
0570: 74 69 6e 67 20 73 69 6e 63 65 20 34 2e 31 2e 30  ting since 4.1.0
0580: 20 53 70 61 74 69 61 4c 69 74 65 20 73 75 70 70   SpatiaLite supp
0590: 6f 72 74 73 20 66 65 77 20 53 51 4c 20 66 75 6e  orts few SQL fun
05a0: 63 74 69 6f 6e 73 20 70 65 72 66 6f 72 6d 69 6e  ctions performin
05b0: 67 20 74 68 65 20 73 61 6d 65 20 74 61 73 6b 2e  g the same task.
05c0: 3c 62 72 3e 0d 0a 3c 75 3e 50 6c 65 61 73 65 20  <br>..<u>Please 
05d0: 6e 6f 74 65 3c 2f 75 3e 3a 20 73 6f 6d 65 20 73  note</u>: some s
05e0: 75 62 74 6c 65 20 64 69 66 66 65 72 65 6e 63 65  ubtle difference
05f0: 73 20 65 78 69 73 74 73 20 68 65 72 65 20 61 6e  s exists here an
0600: 64 20 74 68 65 72 65 3b 20 70 6c 65 61 73 65 20  d there; please 
0610: 63 61 72 65 66 75 6c 6c 79 20 72 65 61 64 20 74  carefully read t
0620: 68 69 73 20 64 6f 63 75 6d 65 6e 74 61 74 69 6f  his documentatio
0630: 6e 20 70 61 67 65 2e 0d 0a 3c 76 65 72 62 61 74  n page...<verbat
0640: 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 43 61 73 74  im>..SELECT Cast
0650: 54 6f 49 6e 74 65 67 65 72 28 20 31 20 29 2c 20  ToInteger( 1 ), 
0660: 43 61 73 74 54 6f 49 6e 74 65 67 65 72 28 20 31  CastToInteger( 1
0670: 2e 34 20 29 2c 20 43 61 73 74 54 6f 49 6e 74 65  .4 ), CastToInte
0680: 67 65 72 28 20 31 2e 36 20 29 2c 20 0d 0a 20 20  ger( 1.6 ), ..  
0690: 20 20 43 61 73 74 54 6f 49 6e 74 65 67 65 72 28    CastToInteger(
06a0: 20 27 31 32 33 27 20 29 2c 20 43 61 73 74 54 6f   '123' ), CastTo
06b0: 49 6e 74 65 67 65 72 28 20 27 61 6c 70 68 61 27  Integer( 'alpha'
06c0: 20 29 2c 20 43 61 73 74 54 6f 49 6e 74 65 67 65   ), CastToIntege
06d0: 72 20 28 20 7a 65 72 6f 62 6c 6f 62 28 34 29 20  r ( zeroblob(4) 
06e0: 29 3b 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d  );..</verbatim>.
06f0: 0a 3c 74 61 62 6c 65 20 62 6f 72 64 65 72 3d 22  .<table border="
0700: 31 22 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 22  1" cellspacing="
0710: 34 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22  4" cellpadding="
0720: 34 22 3e 0d 0a 3c 74 72 3e 3c 74 68 3e 43 61 73  4">..<tr><th>Cas
0730: 74 54 6f 49 6e 74 65 67 65 72 28 20 31 20 29 3c  tToInteger( 1 )<
0740: 2f 74 68 3e 3c 74 68 3e 43 61 73 74 54 6f 49 6e  /th><th>CastToIn
0750: 74 65 67 65 72 28 20 31 2e 34 20 29 3c 2f 74 68  teger( 1.4 )</th
0760: 3e 3c 74 68 3e 43 61 73 74 54 6f 49 6e 74 65 67  ><th>CastToInteg
0770: 65 72 28 20 31 2e 36 20 29 3c 2f 74 68 3e 3c 74  er( 1.6 )</th><t
0780: 68 3e 43 61 73 74 54 6f 49 6e 74 65 67 65 72 28  h>CastToInteger(
0790: 20 27 31 32 33 27 20 29 3c 2f 74 68 3e 3c 74 68   '123' )</th><th
07a0: 3e 43 61 73 74 54 6f 49 6e 74 65 67 65 72 28 20  >CastToInteger( 
07b0: 27 61 6c 70 68 61 27 20 29 3c 2f 74 68 3e 3c 74  'alpha' )</th><t
07c0: 68 3e 43 61 73 74 54 6f 49 6e 74 65 67 65 72 20  h>CastToInteger 
07d0: 28 20 7a 65 72 6f 62 6c 6f 62 28 34 29 20 29 3c  ( zeroblob(4) )<
07e0: 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c  /th></tr>..<tr><
07f0: 74 64 20 61 6c 69 67 6e 3d 22 72 69 67 68 74 22  td align="right"
0800: 3e 31 3c 2f 74 64 3e 3c 74 64 20 61 6c 69 67 6e  >1</td><td align
0810: 3d 22 72 69 67 68 74 22 3e 31 3c 2f 74 64 3e 3c  ="right">1</td><
0820: 74 64 20 61 6c 69 67 6e 3d 22 72 69 67 68 74 22  td align="right"
0830: 3e 32 3c 2f 74 64 3e 3c 74 64 20 61 6c 69 67 6e  >2</td><td align
0840: 3d 22 72 69 67 68 74 22 3e 31 32 33 3c 2f 74 64  ="right">123</td
0850: 3e 3c 74 64 3e 4e 55 4c 4c 3c 2f 74 64 3e 3c 74  ><td>NULL</td><t
0860: 64 3e 4e 55 4c 4c 3c 2f 74 64 3e 3c 2f 74 72 3e  d>NULL</td></tr>
0870: 3c 2f 74 61 62 6c 65 3e 3c 62 72 3e 0d 0a 54 68  </table><br>..Th
0880: 65 20 3c 62 3e 43 61 73 74 54 6f 49 6e 74 65 67  e <b>CastToInteg
0890: 65 72 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e  er()</b> SQL fun
08a0: 63 74 69 6f 6e 20 77 69 6c 6c 20 61 74 74 65 6d  ction will attem
08b0: 70 74 20 74 6f 20 72 65 74 75 72 6e 20 61 20 76  pt to return a v
08c0: 61 6c 75 65 20 6f 66 20 74 68 65 20 3c 62 3e 49  alue of the <b>I
08d0: 6e 74 65 67 65 72 3c 2f 62 3e 20 64 61 74 61 2d  nteger</b> data-
08e0: 74 79 70 65 2c 20 6f 72 20 3c 62 3e 4e 55 4c 4c  type, or <b>NULL
08f0: 3c 2f 62 3e 20 69 66 20 6e 6f 20 63 6f 6e 76 65  </b> if no conve
0900: 72 73 69 6f 6e 20 69 73 20 70 6f 73 73 69 62 6c  rsion is possibl
0910: 65 2e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 61 6e  e...<ul>..<li>an
0920: 20 49 6e 74 65 67 65 72 20 69 6e 70 75 74 20 61   Integer input a
0930: 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20 62 65 20  rgument will be 
0940: 72 65 74 75 72 6e 65 64 20 61 62 73 6f 6c 75 74  returned absolut
0950: 65 6c 79 20 75 6e 61 66 66 65 63 74 65 64 2e 3c  ely unaffected.<
0960: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 20 44 6f 75 62  /li>..<li>a Doub
0970: 6c 65 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e  le input argumen
0980: 74 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 74 68  t will return th
0990: 65 20 3c 75 3e 6e 65 61 72 65 73 74 3c 2f 75 3e  e <u>nearest</u>
09a0: 20 49 6e 74 65 67 65 72 20 76 61 6c 75 65 20 28   Integer value (
09b0: 61 66 74 65 72 20 61 70 70 6c 79 69 6e 67 20 3c  after applying <
09c0: 62 3e 34 2f 35 3c 2f 62 3e 20 72 6f 75 6e 64 69  b>4/5</b> roundi
09d0: 6e 67 29 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61  ng).</li>..<li>a
09e0: 20 54 65 78 74 20 69 6e 70 75 74 20 61 72 67 75   Text input argu
09f0: 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 6e  ment will return
0a00: 20 74 68 65 20 63 6f 72 72 65 73 70 6f 6e 64 69   the correspondi
0a10: 6e 67 20 49 6e 74 65 67 65 72 20 76 61 6c 75 65  ng Integer value
0a20: 20 6f 6e 6c 79 20 69 66 20 74 68 65 20 74 65 78   only if the tex
0a30: 74 20 73 74 72 69 6e 67 20 72 65 70 72 65 73 65  t string represe
0a40: 6e 74 73 20 61 20 76 61 6c 69 64 20 6e 75 6d 62  nts a valid numb
0a50: 65 72 20 28 65 76 65 6e 20 61 20 64 65 63 69 6d  er (even a decim
0a60: 61 6c 20 6f 6e 65 29 3a 20 69 66 20 74 68 65 20  al one): if the 
0a70: 74 65 78 74 20 73 74 72 69 6e 67 20 63 61 6e 6e  text string cann
0a80: 6f 74 20 62 65 20 63 6f 6e 76 65 72 74 65 64 20  ot be converted 
0a90: 74 6f 20 61 20 6e 75 6d 62 65 72 20 4e 55 4c 4c  to a number NULL
0aa0: 20 77 69 6c 6c 20 62 65 20 72 65 74 75 72 6e 65   will be returne
0ab0: 64 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 6e 79  d.</li>..<li>any
0ac0: 20 42 4c 4f 42 20 69 6e 70 75 74 20 61 72 67 75   BLOB input argu
0ad0: 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 6e  ment will return
0ae0: 20 61 20 4e 55 4c 4c 20 76 61 6c 75 65 2e 3c 2f   a NULL value.</
0af0: 6c 69 3e 0d 0a 3c 6c 69 3e 61 6e 79 20 4e 55 4c  li>..<li>any NUL
0b00: 4c 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74  L input argument
0b10: 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 61 20 4e   will return a N
0b20: 55 4c 4c 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d  ULL value.</li>.
0b30: 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d 0a 3c 68 72 3e  .</ul><br>..<hr>
0b40: 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45  ..<verbatim>..SE
0b50: 4c 45 43 54 20 43 61 73 74 54 6f 44 6f 75 62 6c  LECT CastToDoubl
0b60: 65 28 20 31 20 29 2c 20 43 61 73 74 54 6f 44 6f  e( 1 ), CastToDo
0b70: 75 62 6c 65 28 20 31 2e 32 33 20 29 2c 20 43 61  uble( 1.23 ), Ca
0b80: 73 74 54 6f 44 6f 75 62 6c 65 28 20 27 31 32 33  stToDouble( '123
0b90: 2e 34 35 27 20 29 2c 0d 0a 20 20 20 20 43 61 73  .45' ),..    Cas
0ba0: 74 54 6f 44 6f 75 62 6c 65 28 20 27 61 6c 70 68  tToDouble( 'alph
0bb0: 61 27 20 29 2c 20 43 61 73 74 54 6f 44 6f 75 62  a' ), CastToDoub
0bc0: 6c 65 20 28 20 7a 65 72 6f 62 6c 6f 62 28 34 29  le ( zeroblob(4)
0bd0: 20 29 3b 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e   );..</verbatim>
0be0: 0d 0a 3c 74 61 62 6c 65 20 62 6f 72 64 65 72 3d  ..<table border=
0bf0: 22 31 22 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d  "1" cellspacing=
0c00: 22 34 22 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d  "4" cellpadding=
0c10: 22 34 22 3e 0d 0a 3c 74 72 3e 3c 74 68 3e 43 61  "4">..<tr><th>Ca
0c20: 73 74 54 6f 44 6f 75 62 6c 65 28 20 31 20 29 3c  stToDouble( 1 )<
0c30: 2f 74 68 3e 3c 74 68 3e 43 61 73 74 54 6f 44 6f  /th><th>CastToDo
0c40: 75 62 6c 65 28 20 31 2e 32 33 20 29 3c 2f 74 68  uble( 1.23 )</th
0c50: 3e 3c 74 68 3e 43 61 73 74 54 6f 44 6f 75 62 6c  ><th>CastToDoubl
0c60: 65 28 20 27 31 32 33 2e 34 35 27 20 29 3c 2f 74  e( '123.45' )</t
0c70: 68 3e 3c 74 68 3e 43 61 73 74 54 6f 44 6f 75 62  h><th>CastToDoub
0c80: 6c 65 28 20 27 61 6c 70 68 61 27 20 29 3c 2f 74  le( 'alpha' )</t
0c90: 68 3e 3c 74 68 3e 43 61 73 74 54 6f 44 6f 75 62  h><th>CastToDoub
0ca0: 6c 65 20 28 20 7a 65 72 6f 62 6c 6f 62 28 34 29  le ( zeroblob(4)
0cb0: 20 29 3c 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c 74   )</th></tr>..<t
0cc0: 72 3e 3c 74 64 20 61 6c 69 67 6e 3d 22 72 69 67  r><td align="rig
0cd0: 68 74 22 3e 31 2e 30 30 30 30 30 30 3c 2f 74 64  ht">1.000000</td
0ce0: 3e 3c 74 64 20 61 6c 69 67 6e 3d 22 72 69 67 68  ><td align="righ
0cf0: 74 22 3e 31 2e 32 33 30 30 30 30 3c 2f 74 64 3e  t">1.230000</td>
0d00: 3c 74 64 20 61 6c 69 67 6e 3d 22 72 69 67 68 74  <td align="right
0d10: 22 3e 31 32 33 2e 34 35 30 30 30 3c 2f 74 64 3e  ">123.45000</td>
0d20: 3c 74 64 3e 4e 55 4c 4c 3c 2f 74 64 3e 3c 74 64  <td>NULL</td><td
0d30: 3e 4e 55 4c 4c 3c 2f 74 64 3e 3c 2f 74 72 3e 3c  >NULL</td></tr><
0d40: 2f 74 61 62 6c 65 3e 3c 62 72 3e 0d 0a 54 68 65  /table><br>..The
0d50: 20 3c 62 3e 43 61 73 74 54 6f 44 6f 75 62 6c 65   <b>CastToDouble
0d60: 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74  ()</b> SQL funct
0d70: 69 6f 6e 20 77 69 6c 6c 20 61 74 74 65 6d 70 74  ion will attempt
0d80: 20 74 6f 20 72 65 74 75 72 6e 20 61 20 76 61 6c   to return a val
0d90: 75 65 20 6f 66 20 74 68 65 20 3c 62 3e 44 6f 75  ue of the <b>Dou
0da0: 62 6c 65 3c 2f 62 3e 20 64 61 74 61 2d 74 79 70  ble</b> data-typ
0db0: 65 2c 20 6f 72 20 3c 62 3e 4e 55 4c 4c 3c 2f 62  e, or <b>NULL</b
0dc0: 3e 20 69 66 20 6e 6f 20 63 6f 6e 76 65 72 73 69  > if no conversi
0dd0: 6f 6e 20 69 73 20 70 6f 73 73 69 62 6c 65 2e 0d  on is possible..
0de0: 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 61 6e 20 49 6e  .<ul>..<li>an In
0df0: 74 65 67 65 72 20 69 6e 70 75 74 20 61 72 67 75  teger input argu
0e00: 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 6e  ment will return
0e10: 20 74 68 65 20 63 6f 72 72 65 73 70 6f 6e 64 69   the correspondi
0e20: 6e 67 20 44 6f 75 62 6c 65 20 76 61 6c 75 65 2e  ng Double value.
0e30: 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 20 44 6f 75  </li>..<li>a Dou
0e40: 62 6c 65 20 69 6e 70 75 74 20 61 72 67 75 6d 65  ble input argume
0e50: 6e 74 20 77 69 6c 6c 20 62 65 20 72 65 74 75 72  nt will be retur
0e60: 6e 65 64 20 61 62 73 6f 6c 75 74 65 6c 79 20 75  ned absolutely u
0e70: 6e 61 66 66 65 63 74 65 64 2e 3c 2f 6c 69 3e 0d  naffected.</li>.
0e80: 0a 3c 6c 69 3e 61 20 54 65 78 74 20 69 6e 70 75  .<li>a Text inpu
0e90: 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20  t argument will 
0ea0: 72 65 74 75 72 6e 20 74 68 65 20 63 6f 72 72 65  return the corre
0eb0: 73 70 6f 6e 64 69 6e 67 20 44 6f 75 62 6c 65 20  sponding Double 
0ec0: 76 61 6c 75 65 20 6f 6e 6c 79 20 69 66 20 74 68  value only if th
0ed0: 65 20 74 65 78 74 20 73 74 72 69 6e 67 20 72 65  e text string re
0ee0: 70 72 65 73 65 6e 74 73 20 61 20 76 61 6c 69 64  presents a valid
0ef0: 20 6e 75 6d 62 65 72 3a 20 69 66 20 74 68 65 20   number: if the 
0f00: 74 65 78 74 20 73 74 72 69 6e 67 20 63 61 6e 6e  text string cann
0f10: 6f 74 20 62 65 20 63 6f 6e 76 65 72 74 65 64 20  ot be converted 
0f20: 74 6f 20 61 20 6e 75 6d 62 65 72 20 4e 55 4c 4c  to a number NULL
0f30: 20 77 69 6c 6c 20 62 65 20 72 65 74 75 72 6e 65   will be returne
0f40: 64 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 6e 79  d.</li>..<li>any
0f50: 20 42 4c 4f 42 20 69 6e 70 75 74 20 61 72 67 75   BLOB input argu
0f60: 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 6e  ment will return
0f70: 20 61 20 4e 55 4c 4c 20 76 61 6c 75 65 2e 3c 2f   a NULL value.</
0f80: 6c 69 3e 0d 0a 3c 6c 69 3e 61 6e 79 20 4e 55 4c  li>..<li>any NUL
0f90: 4c 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74  L input argument
0fa0: 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 61 20 4e   will return a N
0fb0: 55 4c 4c 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d  ULL value.</li>.
0fc0: 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d 0a 3c 68 72 3e  .</ul><br>..<hr>
0fd0: 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45  ..<verbatim>..SE
0fe0: 4c 45 43 54 20 43 61 73 74 54 6f 54 65 78 74 28  LECT CastToText(
0ff0: 20 31 20 29 2c 20 43 61 73 74 54 6f 54 65 78 74   1 ), CastToText
1000: 28 20 31 2e 35 20 29 2c 20 43 61 73 74 54 6f 54  ( 1.5 ), CastToT
1010: 65 78 74 28 20 27 61 6c 70 68 61 27 20 29 2c 20  ext( 'alpha' ), 
1020: 43 61 73 74 54 6f 54 65 78 74 20 28 20 7a 65 72  CastToText ( zer
1030: 6f 62 6c 6f 62 28 34 29 20 29 3b 0d 0a 3c 2f 76  oblob(4) );..</v
1040: 65 72 62 61 74 69 6d 3e 0d 0a 3c 74 61 62 6c 65  erbatim>..<table
1050: 20 62 6f 72 64 65 72 3d 22 31 22 20 63 65 6c 6c   border="1" cell
1060: 73 70 61 63 69 6e 67 3d 22 34 22 20 63 65 6c 6c  spacing="4" cell
1070: 70 61 64 64 69 6e 67 3d 22 34 22 3e 0d 0a 3c 74  padding="4">..<t
1080: 72 3e 3c 74 68 3e 43 61 73 74 54 6f 54 65 78 74  r><th>CastToText
1090: 28 20 31 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 61  ( 1 )</th><th>Ca
10a0: 73 74 54 6f 54 65 78 74 28 20 31 2e 35 20 29 3c  stToText( 1.5 )<
10b0: 2f 74 68 3e 3c 74 68 3e 43 61 73 74 54 6f 54 65  /th><th>CastToTe
10c0: 78 74 28 20 27 61 6c 70 68 61 27 20 29 3c 2f 74  xt( 'alpha' )</t
10d0: 68 3e 3c 74 68 3e 43 61 73 74 54 6f 54 65 78 74  h><th>CastToText
10e0: 20 28 20 7a 65 72 6f 62 6c 6f 62 28 34 29 20 29   ( zeroblob(4) )
10f0: 3c 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e  </th></tr>..<tr>
1100: 3c 74 64 3e 31 3c 2f 74 64 3e 3c 74 64 3e 31 2e  <td>1</td><td>1.
1110: 35 3c 2f 74 64 3e 3c 74 64 3e 61 6c 70 68 61 3c  5</td><td>alpha<
1120: 2f 74 64 3e 3c 74 64 3e 4e 55 4c 4c 3c 2f 74 64  /td><td>NULL</td
1130: 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 3c 62  ></tr></table><b
1140: 72 3e 0d 0a 54 68 65 20 3c 62 3e 43 61 73 74 54  r>..The <b>CastT
1150: 6f 54 65 78 74 28 29 3c 2f 62 3e 20 53 51 4c 20  oText()</b> SQL 
1160: 66 75 6e 63 74 69 6f 6e 20 77 69 6c 6c 20 61 74  function will at
1170: 74 65 6d 70 74 20 74 6f 20 72 65 74 75 72 6e 20  tempt to return 
1180: 61 20 76 61 6c 75 65 20 6f 66 20 74 68 65 20 3c  a value of the <
1190: 62 3e 54 65 78 74 3c 2f 62 3e 20 64 61 74 61 2d  b>Text</b> data-
11a0: 74 79 70 65 2c 20 6f 72 20 3c 62 3e 4e 55 4c 4c  type, or <b>NULL
11b0: 3c 2f 62 3e 20 69 66 20 6e 6f 20 63 6f 6e 76 65  </b> if no conve
11c0: 72 73 69 6f 6e 20 69 73 20 70 6f 73 73 69 62 6c  rsion is possibl
11d0: 65 2e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 61 6e  e...<ul>..<li>an
11e0: 20 49 6e 74 65 67 65 72 20 69 6e 70 75 74 20 61   Integer input a
11f0: 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20 72 65 74  rgument will ret
1200: 75 72 6e 20 74 68 65 20 63 6f 72 72 65 73 70 6f  urn the correspo
1210: 6e 64 69 6e 67 20 54 65 78 74 20 76 61 6c 75 65  nding Text value
1220: 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 20 44 6f  .</li>..<li>a Do
1230: 75 62 6c 65 20 69 6e 70 75 74 20 61 72 67 75 6d  uble input argum
1240: 65 6e 74 20 77 69 6c 6c 20 62 65 20 72 65 74 75  ent will be retu
1250: 72 6e 20 74 68 65 20 63 6f 72 72 65 73 70 6f 6e  rn the correspon
1260: 64 69 6e 67 20 54 65 78 74 20 76 61 6c 75 65 3b  ding Text value;
1270: 20 6e 6f 20 73 69 67 6e 69 66 69 63 61 6e 74 20   no significant 
1280: 64 65 63 69 6d 61 6c 20 64 69 67 69 74 20 77 69  decimal digit wi
1290: 6c 6c 20 62 65 20 73 75 70 70 72 65 73 73 65 64  ll be suppressed
12a0: 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 20 54 65  .</li>..<li>a Te
12b0: 78 74 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e  xt input argumen
12c0: 74 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 74 68  t will return th
12d0: 65 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20  e corresponding 
12e0: 44 6f 75 62 6c 65 20 76 61 6c 75 65 2e 3c 2f 6c  Double value.</l
12f0: 69 3e 0d 0a 3c 6c 69 3e 61 6e 79 20 42 4c 4f 42  i>..<li>any BLOB
1300: 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 20   input argument 
1310: 77 69 6c 6c 20 72 65 74 75 72 6e 20 61 20 4e 55  will return a NU
1320: 4c 4c 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a  LL value.</li>..
1330: 3c 6c 69 3e 61 6e 79 20 4e 55 4c 4c 20 69 6e 70  <li>any NULL inp
1340: 75 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c  ut argument will
1350: 20 72 65 74 75 72 6e 20 61 20 4e 55 4c 4c 20 76   return a NULL v
1360: 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c  alue.</li>..</ul
1370: 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53  >..<verbatim>..S
1380: 45 4c 45 43 54 20 43 61 73 74 54 6f 54 65 78 74  ELECT CastToText
1390: 28 20 31 2c 20 34 20 29 2c 20 43 61 73 74 54 6f  ( 1, 4 ), CastTo
13a0: 54 65 78 74 28 20 31 32 33 34 2c 20 32 20 29 2c  Text( 1234, 2 ),
13b0: 20 43 61 73 74 54 6f 54 65 78 74 28 20 31 2c 20   CastToText( 1, 
13c0: 38 20 29 2c 20 43 61 73 74 54 6f 54 65 78 74 28  8 ), CastToText(
13d0: 20 31 2e 35 2c 20 34 20 29 3b 0d 0a 3c 2f 76 65   1.5, 4 );..</ve
13e0: 72 62 61 74 69 6d 3e 0d 0a 3c 74 61 62 6c 65 20  rbatim>..<table 
13f0: 62 6f 72 64 65 72 3d 22 31 22 20 63 65 6c 6c 73  border="1" cells
1400: 70 61 63 69 6e 67 3d 22 34 22 20 63 65 6c 6c 70  pacing="4" cellp
1410: 61 64 64 69 6e 67 3d 22 34 22 3e 0d 0a 3c 74 72  adding="4">..<tr
1420: 3e 3c 74 68 3e 43 61 73 74 54 6f 54 65 78 74 28  ><th>CastToText(
1430: 20 31 2c 20 34 20 29 3c 2f 74 68 3e 3c 74 68 3e   1, 4 )</th><th>
1440: 43 61 73 74 54 6f 54 65 78 74 28 20 31 32 33 34  CastToText( 1234
1450: 2c 20 32 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 61  , 2 )</th><th>Ca
1460: 73 74 54 6f 54 65 78 74 28 20 31 2c 20 38 20 29  stToText( 1, 8 )
1470: 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 74 54 6f 54  </th><th>CastToT
1480: 65 78 74 28 20 31 2e 35 2c 20 34 20 29 3c 2f 74  ext( 1.5, 4 )</t
1490: 68 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64  h></tr>..<tr><td
14a0: 3e 30 30 30 31 3c 2f 74 64 3e 3c 74 64 3e 31 32  >0001</td><td>12
14b0: 33 34 3c 2f 74 64 3e 3c 74 64 3e 30 30 30 30 30  34</td><td>00000
14c0: 30 30 31 3c 2f 74 64 3e 3c 74 64 3e 30 30 30 31  001</td><td>0001
14d0: 2e 35 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61  .5</td></tr></ta
14e0: 62 6c 65 3e 3c 62 72 3e 0d 0a 41 6e 20 6f 76 65  ble><br>..An ove
14f0: 72 6c 6f 61 64 65 64 20 76 65 72 73 69 6f 6e 20  rloaded version 
1500: 6f 66 20 3c 62 3e 43 61 73 74 54 6f 54 65 78 74  of <b>CastToText
1510: 28 29 3c 2f 62 3e 20 69 73 20 73 75 70 70 6f 72  ()</b> is suppor
1520: 74 65 64 20 61 73 20 77 65 6c 6c 2c 20 62 75 74  ted as well, but
1530: 20 6f 6e 6c 79 20 77 68 65 6e 20 74 68 65 20 69   only when the i
1540: 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 20 69 73  nput argument is
1550: 20 6f 66 20 74 68 65 20 49 6e 74 65 67 65 72 20   of the Integer 
1560: 6f 72 20 44 6f 75 62 6c 65 20 64 61 74 61 2d 74  or Double data-t
1570: 79 70 65 3a 20 69 6e 20 74 68 69 73 20 63 61 73  ype: in this cas
1580: 65 20 61 20 73 65 63 6f 6e 64 20 49 6e 74 65 67  e a second Integ
1590: 65 72 20 61 72 67 75 6d 65 6e 74 20 63 6f 75 6c  er argument coul
15a0: 64 20 62 65 20 6f 70 74 69 6f 6e 61 6c 6c 79 20  d be optionally 
15b0: 73 70 65 63 69 66 69 65 64 2c 20 61 6e 64 20 77  specified, and w
15c0: 69 6c 6c 20 62 65 20 69 6e 74 65 72 70 72 65 74  ill be interpret
15d0: 65 64 20 61 64 20 3c 62 3e 7a 65 72 6f 2d 70 61  ed ad <b>zero-pa
15e0: 64 64 69 6e 67 2d 6c 65 6e 67 74 68 3c 2f 62 3e  dding-length</b>
15f0: 2e 3c 62 72 3e 0d 0a 69 2e 65 2e 20 74 68 65 20  .<br>..i.e. the 
1600: 72 65 74 75 72 6e 65 64 20 54 65 78 74 20 73 74  returned Text st
1610: 72 69 6e 67 20 69 6e 20 74 68 69 73 20 63 61 73  ring in this cas
1620: 65 20 77 69 6c 6c 20 68 61 76 65 20 61 6e 20 69  e will have an i
1630: 6e 74 65 67 65 72 20 70 61 72 74 20 61 74 20 6c  nteger part at l
1640: 65 61 73 74 20 6f 66 20 74 68 65 20 73 70 65 63  east of the spec
1650: 69 66 69 65 64 20 6c 65 6e 67 74 68 2c 20 61 6e  ified length, an
1660: 64 20 65 76 65 6e 74 75 61 6c 6c 79 20 70 61 64  d eventually pad
1670: 64 65 64 20 62 79 20 69 6e 73 65 72 74 69 6e 67  ded by inserting
1680: 20 6e 6f 74 20 73 69 67 6e 69 66 69 63 61 6e 74   not significant
1690: 20 6c 65 61 64 69 6e 67 20 5a 45 52 4f 65 73 2e   leading ZEROes.
16a0: 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a  <br><br>..<hr>..
16b0: 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45  <verbatim>..SELE
16c0: 43 54 20 43 61 73 74 54 6f 42 6c 6f 62 28 20 31  CT CastToBlob( 1
16d0: 20 29 2c 20 43 61 73 74 54 6f 42 6c 6f 62 28 20   ), CastToBlob( 
16e0: 31 2e 35 20 29 2c 20 48 65 78 28 20 43 61 73 74  1.5 ), Hex( Cast
16f0: 54 6f 42 6c 6f 62 28 20 27 61 6c 70 68 61 27 20  ToBlob( 'alpha' 
1700: 29 20 29 2c 20 48 65 78 20 28 20 43 61 73 74 54  ) ), Hex ( CastT
1710: 6f 42 6c 6f 62 20 28 20 7a 65 72 6f 62 6c 6f 62  oBlob ( zeroblob
1720: 28 34 29 20 29 20 29 3b 0d 0a 3c 2f 76 65 72 62  (4) ) );..</verb
1730: 61 74 69 6d 3e 0d 0a 3c 74 61 62 6c 65 20 62 6f  atim>..<table bo
1740: 72 64 65 72 3d 22 31 22 20 63 65 6c 6c 73 70 61  rder="1" cellspa
1750: 63 69 6e 67 3d 22 34 22 20 63 65 6c 6c 70 61 64  cing="4" cellpad
1760: 64 69 6e 67 3d 22 34 22 3e 0d 0a 3c 74 72 3e 3c  ding="4">..<tr><
1770: 74 68 3e 43 61 73 74 54 6f 42 6c 6f 62 28 20 31  th>CastToBlob( 1
1780: 20 29 3c 2f 74 68 3e 3c 74 68 3e 43 61 73 74 54   )</th><th>CastT
1790: 6f 42 6c 6f 62 28 20 31 2e 35 20 29 3c 2f 74 68  oBlob( 1.5 )</th
17a0: 3e 3c 74 68 3e 48 65 78 28 20 43 61 73 74 54 6f  ><th>Hex( CastTo
17b0: 42 6c 6f 62 28 20 27 61 6c 70 68 61 27 20 29 20  Blob( 'alpha' ) 
17c0: 29 3c 2f 74 68 3e 3c 74 68 3e 48 65 78 28 20 43  )</th><th>Hex( C
17d0: 61 73 74 54 6f 54 65 78 74 20 28 20 7a 65 72 6f  astToText ( zero
17e0: 62 6c 6f 62 28 34 29 20 29 20 29 3c 2f 74 68 3e  blob(4) ) )</th>
17f0: 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 4e  </tr>..<tr><td>N
1800: 55 4c 4c 3c 2f 74 64 3e 3c 74 64 3e 4e 55 4c 4c  ULL</td><td>NULL
1810: 3c 2f 74 64 3e 3c 74 64 3e 36 31 36 43 37 30 36  </td><td>616C706
1820: 38 36 31 3c 2f 74 64 3e 3c 74 64 3e 30 30 30 30  861</td><td>0000
1830: 30 30 30 30 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f  0000</td></tr></
1840: 74 61 62 6c 65 3e 3c 62 72 3e 0d 0a 54 68 65 20  table><br>..The 
1850: 3c 62 3e 43 61 73 74 54 6f 42 6c 6f 62 28 29 3c  <b>CastToBlob()<
1860: 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e  /b> SQL function
1870: 20 77 69 6c 6c 20 61 74 74 65 6d 70 74 20 74 6f   will attempt to
1880: 20 72 65 74 75 72 6e 20 61 20 76 61 6c 75 65 20   return a value 
1890: 6f 66 20 74 68 65 20 3c 62 3e 42 4c 4f 42 3c 2f  of the <b>BLOB</
18a0: 62 3e 20 64 61 74 61 2d 74 79 70 65 2c 20 6f 72  b> data-type, or
18b0: 20 3c 62 3e 4e 55 4c 4c 3c 2f 62 3e 20 69 66 20   <b>NULL</b> if 
18c0: 6e 6f 20 63 6f 6e 76 65 72 73 69 6f 6e 20 69 73  no conversion is
18d0: 20 70 6f 73 73 69 62 6c 65 2e 0d 0a 3c 75 6c 3e   possible...<ul>
18e0: 0d 0a 3c 6c 69 3e 61 6e 20 49 6e 74 65 67 65 72  ..<li>an Integer
18f0: 20 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 20   input argument 
1900: 77 69 6c 6c 20 72 65 74 75 72 6e 20 61 20 4e 55  will return a NU
1910: 4c 4c 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a  LL value.</li>..
1920: 3c 6c 69 3e 61 20 44 6f 75 62 6c 65 20 69 6e 70  <li>a Double inp
1930: 75 74 20 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c  ut argument will
1940: 20 72 65 74 75 72 6e 20 61 20 4e 55 4c 4c 20 76   return a NULL v
1950: 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e  alue.</li>..<li>
1960: 61 20 54 65 78 74 20 69 6e 70 75 74 20 61 72 67  a Text input arg
1970: 75 6d 65 6e 74 20 20 77 69 6c 6c 20 72 65 74 75  ument  will retu
1980: 72 6e 20 74 68 65 20 63 6f 72 72 65 73 70 6f 6e  rn the correspon
1990: 64 69 6e 67 20 42 4c 4f 42 20 76 61 6c 75 65 2e  ding BLOB value.
19a0: 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 6e 79 20 42  </li>..<li>any B
19b0: 4c 4f 42 20 69 6e 70 75 74 20 61 72 67 75 6d 65  LOB input argume
19c0: 6e 74 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 74  nt will return t
19d0: 68 65 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67  he corresponding
19e0: 20 42 4c 4f 42 20 76 61 6c 75 65 2e 3c 2f 6c 69   BLOB value.</li
19f0: 3e 0d 0a 3c 6c 69 3e 61 6e 79 20 4e 55 4c 4c 20  >..<li>any NULL 
1a00: 69 6e 70 75 74 20 61 72 67 75 6d 65 6e 74 20 77  input argument w
1a10: 69 6c 6c 20 72 65 74 75 72 6e 20 61 20 4e 55 4c  ill return a NUL
1a20: 4c 20 76 61 6c 75 65 2e 3c 2f 6c 69 3e 0d 0a 3c  L value.</li>..<
1a30: 2f 75 6c 3e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e  /ul>..<verbatim>
1a40: 0d 0a 53 45 4c 45 43 54 20 48 65 78 28 20 43 61  ..SELECT Hex( Ca
1a50: 73 74 54 6f 42 6c 6f 62 28 20 27 30 31 32 33 34  stToBlob( '01234
1a60: 35 36 37 38 39 61 42 63 44 65 46 66 45 64 43 62  56789aBcDeFfEdCb
1a70: 41 39 38 37 36 35 34 33 32 31 30 27 2c 20 31 20  A9876543210', 1 
1a80: 29 20 29 3b 0d 0a 2d 2d 2d 2d 2d 0d 0a 30 31 32  ) );..-----..012
1a90: 33 34 35 36 37 38 39 41 42 43 44 45 46 46 45 44  3456789ABCDEFFED
1aa0: 43 42 41 39 38 37 36 35 34 33 32 31 30 0d 0a 0d  CBA9876543210...
1ab0: 0a 53 45 4c 45 43 54 20 43 61 73 74 54 6f 42 6c  .SELECT CastToBl
1ac0: 6f 62 28 20 27 31 32 66 27 2c 20 31 20 29 3b 0d  ob( '12f', 1 );.
1ad0: 0a 2d 2d 2d 2d 2d 0d 0a 4e 55 4c 4c 0d 0a 0d 0a  .-----..NULL....
1ae0: 53 45 4c 45 43 54 20 43 61 73 74 54 6f 42 6c 6f  SELECT CastToBlo
1af0: 62 28 20 27 31 32 48 46 27 2c 20 31 20 29 3b 0d  b( '12HF', 1 );.
1b00: 0a 2d 2d 2d 2d 2d 0d 0a 4e 55 4c 4c 0d 0a 3c 2f  .-----..NULL..</
1b10: 76 65 72 62 61 74 69 6d 3e 0d 0a 41 20 73 65 63  verbatim>..A sec
1b20: 6f 6e 64 20 6f 76 65 72 6c 6f 61 64 65 64 20 76  ond overloaded v
1b30: 65 72 73 69 6f 6e 20 6f 66 20 3c 62 3e 43 61 73  ersion of <b>Cas
1b40: 74 54 6f 42 6c 6f 62 28 29 3c 2f 62 3e 20 69 73  tToBlob()</b> is
1b50: 20 73 75 70 70 6f 72 74 65 64 20 61 73 20 77 65   supported as we
1b60: 6c 6c 3b 20 62 79 20 73 70 65 63 69 66 79 69 6e  ll; by specifyin
1b70: 67 20 61 20 66 75 72 74 68 65 72 20 3c 62 3e 68  g a further <b>h
1b80: 65 78 5f 69 6e 70 75 74 3c 2f 62 3e 20 3c 75 3e  ex_input</b> <u>
1b90: 62 6f 6f 6c 65 61 6e 3c 2f 75 3e 20 61 72 67 75  boolean</u> argu
1ba0: 6d 65 6e 74 20 73 65 74 20 61 73 20 3c 62 3e 54  ment set as <b>T
1bb0: 52 55 45 3c 2f 62 3e 20 74 68 65 20 69 6e 70 75  RUE</b> the inpu
1bc0: 74 20 73 74 72 69 6e 67 20 77 69 6c 6c 20 62 65  t string will be
1bd0: 20 61 73 73 75 6d 65 64 20 74 6f 20 62 65 20 3c   assumed to be <
1be0: 75 3e 48 65 78 61 64 65 63 69 6d 61 6c 6c 79 20  u>Hexadecimally 
1bf0: 65 6e 63 6f 64 65 64 3c 2f 75 3e 2e 20 49 6e 20  encoded</u>. In 
1c00: 74 68 69 73 20 63 61 73 65 20 4e 55 4c 4c 20 77  this case NULL w
1c10: 69 6c 6c 20 62 65 20 72 65 74 75 72 6e 65 64 20  ill be returned 
1c20: 69 66 20 74 68 65 20 69 6e 70 75 74 20 73 74 72  if the input str
1c30: 69 6e 67 20 64 6f 65 73 6e 27 74 20 63 6f 72 72  ing doesn't corr
1c40: 65 73 70 6f 6e 64 73 20 74 6f 20 61 20 76 61 6c  esponds to a val
1c50: 69 64 20 48 65 78 61 64 65 63 69 6d 61 6c 20 6e  id Hexadecimal n
1c60: 6f 74 61 74 69 6f 6e 2e 3c 62 72 3e 3c 62 72 3e  otation.<br><br>
1c70: 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72 62 61 74 69  ..<hr>..<verbati
1c80: 6d 3e 0d 0a 53 45 4c 45 43 54 20 46 6f 72 63 65  m>..SELECT Force
1c90: 41 73 4e 75 6c 6c 28 20 27 61 27 2c 20 27 62 27  AsNull( 'a', 'b'
1ca0: 20 29 2c 20 46 6f 72 63 65 41 73 4e 75 6c 6c 28   ), ForceAsNull(
1cb0: 20 27 61 62 63 64 27 2c 20 27 61 62 63 64 27 20   'abcd', 'abcd' 
1cc0: 29 2c 20 46 6f 72 63 65 41 73 4e 75 6c 6c 28 20  ), ForceAsNull( 
1cd0: 31 2c 20 31 29 2c 20 46 6f 72 63 65 41 73 4e 75  1, 1), ForceAsNu
1ce0: 6c 6c 28 20 31 2e 31 2c 20 31 20 29 3b 0d 0a 3c  ll( 1.1, 1 );..<
1cf0: 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 3c 74 61 62  /verbatim>..<tab
1d00: 6c 65 20 62 6f 72 64 65 72 3d 22 31 22 20 63 65  le border="1" ce
1d10: 6c 6c 73 70 61 63 69 6e 67 3d 22 34 22 20 63 65  llspacing="4" ce
1d20: 6c 6c 70 61 64 64 69 6e 67 3d 22 34 22 3e 0d 0a  llpadding="4">..
1d30: 3c 74 72 3e 3c 74 68 3e 46 6f 72 63 65 41 73 4e  <tr><th>ForceAsN
1d40: 75 6c 6c 28 20 27 61 27 2c 20 27 62 27 20 29 3c  ull( 'a', 'b' )<
1d50: 2f 74 68 3e 3c 74 68 3e 46 6f 72 63 65 41 73 4e  /th><th>ForceAsN
1d60: 75 6c 6c 28 20 27 61 62 63 64 27 2c 20 27 61 62  ull( 'abcd', 'ab
1d70: 63 64 27 20 29 3c 2f 74 68 3e 3c 74 68 3e 46 6f  cd' )</th><th>Fo
1d80: 72 63 65 41 73 4e 75 6c 6c 28 20 31 2c 20 31 29  rceAsNull( 1, 1)
1d90: 3c 2f 74 68 3e 3c 74 68 3e 46 6f 72 63 65 41 73  </th><th>ForceAs
1da0: 4e 75 6c 6c 28 20 31 2e 31 2c 20 2d 39 39 39 39  Null( 1.1, -9999
1db0: 20 29 3c 2f 74 68 3e 3c 2f 74 72 3e 0d 0a 3c 74   )</th></tr>..<t
1dc0: 72 3e 3c 74 64 3e 61 3c 2f 74 64 3e 3c 74 64 3e  r><td>a</td><td>
1dd0: 4e 55 4c 4c 3c 2f 74 64 3e 3c 74 64 3e 4e 55 4c  NULL</td><td>NUL
1de0: 4c 3c 2f 74 64 3e 3c 74 64 20 61 6c 69 67 6e 3d  L</td><td align=
1df0: 22 72 69 67 68 74 22 3e 31 2e 31 3c 2f 74 64 3e  "right">1.1</td>
1e00: 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 3c 62 72  </tr></table><br
1e10: 3e 0d 0a 54 68 65 20 3c 62 3e 46 6f 72 63 65 41  >..The <b>ForceA
1e20: 73 4e 75 6c 6c 28 29 3c 2f 62 3e 20 53 51 4c 20  sNull()</b> SQL 
1e30: 66 75 6e 63 74 69 6f 6e 20 77 69 6c 6c 20 65 76  function will ev
1e40: 61 6c 75 61 74 65 20 74 77 6f 20 61 72 62 69 74  aluate two arbit
1e50: 72 61 72 79 20 61 72 67 75 6d 65 6e 74 73 2e 3c  rary arguments.<
1e60: 62 72 3e 0d 0a 49 66 20 74 68 65 79 20 61 72 65  br>..If they are
1e70: 20 65 71 75 61 6c 20 61 6e 64 20 65 78 61 63 74   equal and exact
1e80: 6c 79 20 6f 66 20 74 68 65 20 73 61 6d 65 20 64  ly of the same d
1e90: 61 74 61 2d 74 79 70 65 20 4e 55 4c 4c 20 77 69  ata-type NULL wi
1ea0: 6c 6c 20 62 65 20 72 65 74 75 72 6e 65 64 3b 20  ll be returned; 
1eb0: 6f 74 68 65 72 77 69 73 65 20 74 68 65 20 66 69  otherwise the fi
1ec0: 72 73 74 20 61 72 67 75 6d 65 6e 74 20 76 61 6c  rst argument val
1ed0: 75 65 20 77 69 6c 6c 20 62 65 20 72 65 74 75 72  ue will be retur
1ee0: 6e 65 64 2e 3c 62 72 3e 0d 0a 55 73 65 66 75 6c  ned.<br>..Useful
1ef0: 20 65 2e 67 2e 20 77 68 69 6c 65 20 70 72 6f 63   e.g. while proc
1f00: 65 73 73 69 6e 67 20 64 61 74 61 20 69 6d 70 6f  essing data impo
1f10: 72 74 65 64 20 66 72 6f 6d 20 61 6e 79 20 3c 62  rted from any <b
1f20: 3e 53 68 61 70 65 66 69 6c 65 3c 2f 62 3e 20 6f  >Shapefile</b> o
1f30: 72 20 3c 62 3e 44 42 46 20 66 69 6c 65 3c 2f 62  r <b>DBF file</b
1f40: 3e 20 28 73 75 63 68 20 66 6f 72 6d 61 74 73 20  > (such formats 
1f50: 64 6f 65 73 6e 27 74 20 73 75 70 70 6f 72 74 20  doesn't support 
1f60: 61 6e 79 20 72 65 61 6c 20 4e 55 4c 4c 20 76 61  any real NULL va
1f70: 6c 75 65 2c 20 6f 66 74 65 6e 20 62 65 69 6e 67  lue, often being
1f80: 20 72 65 70 6c 61 63 65 64 20 62 79 20 73 6f 6d   replaced by som
1f90: 65 20 63 6f 6e 76 65 6e 74 69 6f 6e 61 6c 20 76  e conventional v
1fa0: 61 6c 75 65 20 65 2e 67 2e 20 3c 62 3e 30 3c 2f  alue e.g. <b>0</
1fb0: 62 3e 20 6f 72 20 3c 62 3e 2d 39 39 39 39 3c 2f  b> or <b>-9999</
1fc0: 62 3e 20 61 6e 64 20 61 6c 69 6b 65 29 2e 3c 62  b> and alike).<b
1fd0: 72 3e 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c 68  r><br>..<hr>..<h
1fe0: 33 3e 3c 61 20 6e 61 6d 65 3d 22 75 75 69 64 22  3><a name="uuid"
1ff0: 3e 47 65 6e 65 72 69 63 3c 2f 61 3e 20 53 51 4c  >Generic</a> SQL
2000: 20 66 75 6e 63 74 69 6f 6e 20 2d 20 55 55 49 44   function - UUID
2010: 20 67 65 6e 65 72 61 74 6f 72 3c 2f 68 33 3e 0d   generator</h3>.
2020: 0a 41 6e 20 3c 61 20 68 72 65 66 3d 22 68 74 74  .An <a href="htt
2030: 70 3a 2f 2f 65 6e 2e 77 69 6b 69 70 65 64 69 61  p://en.wikipedia
2040: 2e 6f 72 67 2f 77 69 6b 69 2f 55 6e 69 76 65 72  .org/wiki/Univer
2050: 73 61 6c 6c 79 5f 75 6e 69 71 75 65 5f 69 64 65  sally_unique_ide
2060: 6e 74 69 66 69 65 72 22 3e 55 6e 69 76 65 72 73  ntifier">Univers
2070: 61 6c 6c 79 20 75 6e 69 71 75 65 20 69 64 65 6e  ally unique iden
2080: 74 69 66 69 65 72 3c 2f 61 3e 20 28 61 6b 61 20  tifier</a> (aka 
2090: 3c 62 3e 55 55 49 44 3c 2f 62 3e 29 20 73 69 6d  <b>UUID</b>) sim
20a0: 70 6c 79 20 69 73 20 61 20 3c 75 3e 31 32 38 20  ply is a <u>128 
20b0: 62 69 74 3c 2f 75 3e 20 49 6e 74 65 67 65 72 3b  bit</u> Integer;
20c0: 20 61 63 63 6f 72 64 69 6e 67 6c 79 20 74 6f 20   accordingly to 
20d0: 3c 61 20 68 72 65 66 3d 22 68 74 74 70 3a 2f 2f  <a href="http://
20e0: 65 6e 2e 77 69 6b 69 70 65 64 69 61 2e 6f 72 67  en.wikipedia.org
20f0: 2f 77 69 6b 69 2f 55 55 49 44 23 52 61 6e 64 6f  /wiki/UUID#Rando
2100: 6d 5f 55 55 49 44 5f 70 72 6f 62 61 62 69 6c 69  m_UUID_probabili
2110: 74 79 5f 6f 66 5f 64 75 70 6c 69 63 61 74 65 73  ty_of_duplicates
2120: 22 3e 74 68 65 6f 72 79 3c 2f 61 3e 2c 20 74 68  ">theory</a>, th
2130: 65 20 70 72 6f 62 61 62 69 6c 69 74 79 20 74 68  e probability th
2140: 61 74 20 74 77 6f 20 72 61 6e 64 6f 6d 6c 79 20  at two randomly 
2150: 67 65 6e 65 72 61 74 65 64 20 55 55 49 44 73 20  generated UUIDs 
2160: 63 6f 75 6c 64 20 61 73 73 75 6d 65 20 74 68 65  could assume the
2170: 20 73 61 6d 65 20 76 61 6c 75 65 20 69 73 20 6e   same value is n
2180: 65 61 72 20 74 6f 20 7a 65 72 6f 20 66 6f 72 20  ear to zero for 
2190: 6d 61 6e 79 20 70 72 61 63 74 69 63 61 6c 20 70  many practical p
21a0: 75 72 70 6f 73 65 73 2e 20 41 6e 64 20 63 6f 6e  urposes. And con
21b0: 73 65 71 75 65 6e 74 6c 79 20 55 55 49 44 73 20  sequently UUIDs 
21c0: 61 72 65 20 77 69 64 65 6c 79 20 75 73 65 64 20  are widely used 
21d0: 61 73 20 3c 75 3e 75 6e 69 76 65 72 73 61 6c 6c  as <u>universall
21e0: 79 20 75 6e 69 71 75 65 20 49 44 73 3c 2f 75 3e  y unique IDs</u>
21f0: 2e 3c 62 72 3e 0d 0a 55 73 75 61 6c 6c 79 20 55  .<br>..Usually U
2200: 55 49 44 73 20 61 72 65 20 72 65 70 72 65 73 65  UIDs are represe
2210: 6e 74 65 64 20 69 6e 20 74 68 65 69 72 20 3c 75  nted in their <u
2220: 3e 63 61 6e 6f 6e 69 63 61 6c 20 66 6f 72 6d 3c  >canonical form<
2230: 2f 75 3e 2c 20 69 2e 65 2e 20 61 73 20 61 20 73  /u>, i.e. as a s
2240: 65 71 75 65 6e 63 65 20 6f 66 20 33 32 20 68 65  equence of 32 he
2250: 78 61 64 65 63 69 6d 61 6c 20 64 69 67 69 74 73  xadecimal digits
2260: 20 73 65 70 61 72 61 74 65 64 20 69 6e 74 6f 20   separated into 
2270: 66 69 76 65 20 64 69 73 74 69 6e 63 74 20 62 6c  five distinct bl
2280: 6f 63 6b 2c 20 61 63 63 6f 72 64 69 6e 67 6c 79  ock, accordingly
2290: 20 74 6f 20 61 20 3c 62 3e 38 2d 34 2d 34 2d 34   to a <b>8-4-4-4
22a0: 2d 31 32 3c 2f 62 3e 20 73 63 68 65 6d 61 2e 0d  -12</b> schema..
22b0: 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c  .<verbatim>..SEL
22c0: 45 43 54 20 43 72 65 61 74 65 55 55 49 44 28 29  ECT CreateUUID()
22d0: 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 66 66 66  ;..--------..fff
22e0: 35 66 61 66 31 2d 64 63 63 30 2d 34 33 39 31 2d  5faf1-dcc0-4391-
22f0: 38 30 35 34 2d 36 65 37 64 65 37 35 64 38 35 62  8054-6e7de75d85b
2300: 31 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a  1..</verbatim>..
2310: 54 68 65 20 3c 62 3e 43 72 65 61 74 65 55 55 49  The <b>CreateUUI
2320: 44 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63  D()</b> SQL func
2330: 74 69 6f 6e 20 69 73 20 62 75 69 6c 74 20 6f 6e  tion is built on
2340: 20 74 68 65 20 74 6f 70 20 74 68 65 20 3c 69 3e   the top the <i>
2350: 48 69 67 68 20 51 75 61 6c 69 74 79 20 50 73 65  High Quality Pse
2360: 75 64 6f 2d 52 61 6e 64 6f 6d 20 4e 75 6d 62 65  udo-Random Numbe
2370: 72 20 47 65 6e 65 72 61 74 6f 72 3c 2f 69 3e 20  r Generator</i> 
2380: 3c 61 20 68 72 65 66 3d 22 68 74 74 70 3a 2f 2f  <a href="http://
2390: 77 77 77 2e 73 71 6c 69 74 65 2e 6f 72 67 2f 63  www.sqlite.org/c
23a0: 33 72 65 66 2f 72 61 6e 64 6f 6d 6e 65 73 73 2e  3ref/randomness.
23b0: 68 74 6d 6c 22 3e 69 6e 74 65 72 6e 61 6c 6c 79  html">internally
23c0: 20 69 6d 70 6c 65 6d 65 6e 74 65 64 3c 2f 61 3e   implemented</a>
23d0: 20 62 79 20 53 51 4c 69 74 65 2e 3c 62 72 3e 0d   by SQLite.<br>.
23e0: 0a 54 68 65 20 72 65 74 75 72 6e 65 64 20 55 55  .The returned UU
23f0: 49 44 20 69 73 20 63 6f 6e 66 6f 72 6d 61 6e 74  ID is conformant
2400: 20 74 6f 20 3c 75 3e 56 65 72 73 69 6f 6e 20 34   to <u>Version 4
2410: 20 28 72 61 6e 64 6f 6d 29 3c 2f 75 3e 20 28 69   (random)</u> (i
2420: 2e 65 2e 20 74 68 65 20 66 69 72 73 74 20 64 69  .e. the first di
2430: 67 69 74 20 69 6e 74 6f 20 74 68 65 20 74 68 69  git into the thi
2440: 72 64 20 62 6c 6f 63 6b 20 77 69 6c 6c 20 61 6c  rd block will al
2450: 77 61 79 73 20 62 65 20 3c 62 3e 34 3c 2f 62 3e  ways be <b>4</b>
2460: 20 61 6e 64 20 74 68 65 20 66 69 72 73 74 20 64   and the first d
2470: 69 67 69 74 20 69 6e 74 6f 20 74 68 65 20 66 6f  igit into the fo
2480: 75 72 74 68 20 62 6c 6f 63 6b 20 77 69 6c 6c 20  urth block will 
2490: 61 6c 77 61 79 73 20 62 65 20 3c 62 3e 38 3c 2f  always be <b>8</
24a0: 62 3e 29 2e 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68  b>).<br><br>..<h
24b0: 72 3e 0d 0a 3c 68 33 3e 3c 61 20 6e 61 6d 65 3d  r>..<h3><a name=
24c0: 22 67 65 6f 6d 22 3e 53 70 61 74 69 61 6c 3c 2f  "geom">Spatial</
24d0: 61 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 73  a> SQL functions
24e0: 3c 2f 68 33 3e 0d 0a 46 65 77 20 6d 6f 72 65 20  </h3>..Few more 
24f0: 53 70 61 74 69 61 6c 20 53 51 4c 20 66 75 6e 63  Spatial SQL func
2500: 74 69 6f 6e 73 20 61 72 65 20 6e 6f 77 20 73 75  tions are now su
2510: 70 70 6f 72 74 65 64 2e 0d 0a 3c 76 65 72 62 61  pported...<verba
2520: 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 53 54 5f  tim>..SELECT ST_
2530: 41 73 54 65 78 74 28 20 53 54 5f 41 64 64 50 6f  AsText( ST_AddPo
2540: 69 6e 74 28 20 0d 0a 20 20 53 54 5f 47 65 6f 6d  int( ..  ST_Geom
2550: 46 72 6f 6d 54 65 78 74 28 20 27 4c 49 4e 45 53  FromText( 'LINES
2560: 54 52 49 4e 47 28 20 30 20 30 2c 20 31 20 30 20  TRING( 0 0, 1 0 
2570: 29 27 20 29 2c 20 0d 0a 20 20 53 54 5f 47 65 6f  )' ), ..  ST_Geo
2580: 6d 46 72 6f 6d 54 65 78 74 28 20 27 50 4f 49 4e  mFromText( 'POIN
2590: 54 28 20 31 20 31 20 29 27 20 29 20 29 20 29 3b  T( 1 1 )' ) ) );
25a0: 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 4c 49 4e 45  ..--------..LINE
25b0: 53 54 52 49 4e 47 28 30 20 30 2c 20 31 20 30 2c  STRING(0 0, 1 0,
25c0: 20 31 20 31 29 0d 0a 3c 2f 76 65 72 62 61 74 69   1 1)..</verbati
25d0: 6d 3e 0d 0a 54 68 65 20 3c 62 3e 53 54 5f 41 64  m>..The <b>ST_Ad
25e0: 64 50 6f 69 6e 74 28 29 3c 2f 62 3e 20 53 51 4c  dPoint()</b> SQL
25f0: 20 66 75 6e 63 74 69 6f 6e 20 61 64 64 73 20 61   function adds a
2600: 20 66 75 72 74 68 65 72 20 50 6f 69 6e 74 2f 56   further Point/V
2610: 65 72 74 65 78 20 61 74 20 74 68 65 20 65 6e 64  ertex at the end
2620: 20 6f 66 20 61 20 4c 69 6e 65 73 74 72 69 6e 67   of a Linestring
2630: 3b 20 74 68 65 20 66 69 72 73 74 20 61 72 67 75  ; the first argu
2640: 6d 65 6e 74 20 69 73 20 61 6c 77 61 79 73 20 65  ment is always e
2650: 78 70 65 63 74 65 64 20 74 6f 20 62 65 20 6f 66  xpected to be of
2660: 20 74 68 65 20 4c 69 6e 65 73 74 72 69 6e 67 20   the Linestring 
2670: 74 79 70 65 2c 20 74 68 65 20 73 65 63 6f 6e 64  type, the second
2680: 20 6f 6e 65 20 6d 75 73 74 20 62 65 20 61 20 50   one must be a P
2690: 6f 69 6e 74 2e 0d 0a 3c 76 65 72 62 61 74 69 6d  oint...<verbatim
26a0: 3e 0d 0a 53 45 4c 45 43 54 20 53 54 5f 41 73 54  >..SELECT ST_AsT
26b0: 65 78 74 28 20 53 54 5f 41 64 64 50 6f 69 6e 74  ext( ST_AddPoint
26c0: 28 20 0d 0a 20 20 53 54 5f 47 65 6f 6d 46 72 6f  ( ..  ST_GeomFro
26d0: 6d 54 65 78 74 28 20 27 4c 49 4e 45 53 54 52 49  mText( 'LINESTRI
26e0: 4e 47 28 20 31 20 30 2c 20 31 20 31 20 29 27 20  NG( 1 0, 1 1 )' 
26f0: 29 2c 20 0d 0a 20 20 53 54 5f 47 65 6f 6d 46 72  ), ..  ST_GeomFr
2700: 6f 6d 54 65 78 74 28 20 27 50 4f 49 4e 54 28 20  omText( 'POINT( 
2710: 30 20 30 20 29 27 20 29 2c 20 30 20 29 20 29 3b  0 0 )' ), 0 ) );
2720: 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 4c 49 4e  ..---------..LIN
2730: 45 53 54 52 49 4e 47 28 30 20 30 2c 20 31 20 30  ESTRING(0 0, 1 0
2740: 2c 20 31 20 31 29 0d 0a 3c 2f 76 65 72 62 61 74  , 1 1)..</verbat
2750: 69 6d 3e 0d 0a 49 66 20 61 6e 20 6f 70 74 69 6f  im>..If an optio
2760: 6e 61 6c 20 74 68 69 72 64 20 61 72 67 75 6d 65  nal third argume
2770: 6e 74 20 28 6f 66 20 74 68 65 20 49 6e 74 65 67  nt (of the Integ
2780: 65 72 20 74 79 70 65 29 20 69 73 20 70 61 73 73  er type) is pass
2790: 65 64 20 74 6f 20 3c 62 3e 53 54 5f 41 64 64 50  ed to <b>ST_AddP
27a0: 6f 69 6e 74 28 29 3c 2f 62 3e 20 69 74 27 73 20  oint()</b> it's 
27b0: 69 6e 74 65 6e 64 65 64 20 74 6f 20 73 70 65 63  intended to spec
27c0: 69 66 79 20 74 68 65 20 3c 75 3e 69 6e 64 65 78  ify the <u>index
27d0: 3c 2f 75 3e 20 6f 66 20 74 68 65 20 6e 65 77 20  </u> of the new 
27e0: 56 65 72 74 65 78 20 28 66 69 72 73 74 20 56 65  Vertex (first Ve
27f0: 72 74 65 78 20 68 61 73 20 69 6e 64 65 78 20 30  rtex has index 0
2800: 2c 20 73 65 63 6f 6e 64 20 56 65 72 74 65 78 20  , second Vertex 
2810: 68 61 73 20 69 6e 64 65 78 20 31 20 61 6e 64 20  has index 1 and 
2820: 73 6f 20 6f 6e 29 2e 3c 62 72 3e 0d 0a 52 65 66  so on).<br>..Ref
2830: 65 72 65 6e 63 69 6e 67 20 61 20 6e 6f 74 20 65  erencing a not e
2840: 78 69 73 74 69 6e 67 20 69 6e 64 65 78 20 69 73  xisting index is
2850: 20 61 6e 20 65 72 72 6f 72 2c 20 61 6e 64 20 77   an error, and w
2860: 69 6c 6c 20 72 65 74 75 72 6e 20 4e 55 4c 4c 2e  ill return NULL.
2870: 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45  ..<verbatim>..SE
2880: 4c 45 43 54 20 53 54 5f 41 73 54 65 78 74 28 20  LECT ST_AsText( 
2890: 53 54 5f 41 64 64 50 6f 69 6e 74 28 20 0d 0a 20  ST_AddPoint( .. 
28a0: 20 53 54 5f 47 65 6f 6d 46 72 6f 6d 54 65 78 74   ST_GeomFromText
28b0: 28 20 27 4c 49 4e 45 53 54 52 49 4e 47 28 20 30  ( 'LINESTRING( 0
28c0: 20 30 2c 20 31 20 30 20 29 27 20 29 2c 20 0d 0a   0, 1 0 )' ), ..
28d0: 20 20 53 54 5f 47 65 6f 6d 46 72 6f 6d 54 65 78    ST_GeomFromTex
28e0: 74 28 20 27 50 4f 49 4e 54 28 20 31 20 31 20 29  t( 'POINT( 1 1 )
28f0: 27 20 29 2c 20 2d 31 20 29 20 29 3b 0d 0a 2d 2d  ' ), -1 ) );..--
2900: 2d 2d 2d 2d 2d 2d 0d 0a 4c 49 4e 45 53 54 52 49  ------..LINESTRI
2910: 4e 47 28 30 20 30 2c 20 31 20 30 2c 20 31 20 31  NG(0 0, 1 0, 1 1
2920: 29 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a  )..</verbatim>..
2930: 50 61 73 73 69 6e 67 20 61 20 6e 65 67 61 74 69  Passing a negati
2940: 76 65 20 69 6e 64 65 78 20 69 73 20 61 20 73 75  ve index is a su
2950: 70 70 6f 72 74 65 64 20 6f 70 74 69 6f 6e 2c 20  pported option, 
2960: 61 6e 64 20 73 69 6d 70 6c 79 20 63 6f 72 72 65  and simply corre
2970: 73 70 6f 6e 64 73 20 74 6f 20 74 68 65 20 64 65  sponds to the de
2980: 66 61 75 6c 74 20 62 65 68 61 76 69 6f 75 72 20  fault behaviour 
2990: 28 69 2e 65 2e 20 3c 69 3e 61 70 70 65 6e 64 69  (i.e. <i>appendi
29a0: 6e 67 20 74 68 65 20 50 6f 69 6e 74 20 74 6f 20  ng the Point to 
29b0: 74 68 65 20 65 6e 64 20 6f 66 20 74 68 65 20 4c  the end of the L
29c0: 69 6e 65 73 74 72 69 6e 67 3c 2f 69 3e 29 2e 3c  inestring</i>).<
29d0: 62 72 3e 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c  br><br>..<hr>..<
29e0: 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43  verbatim>..SELEC
29f0: 54 20 53 54 5f 41 73 54 65 78 74 28 20 53 54 5f  T ST_AsText( ST_
2a00: 53 65 74 50 6f 69 6e 74 28 20 0d 0a 20 20 53 54  SetPoint( ..  ST
2a10: 5f 47 65 6f 6d 46 72 6f 6d 54 65 78 74 28 20 27  _GeomFromText( '
2a20: 4c 49 4e 45 53 54 52 49 4e 47 28 20 30 20 30 2c  LINESTRING( 0 0,
2a30: 20 31 20 30 2c 20 31 20 31 20 29 27 20 29 2c 20   1 0, 1 1 )' ), 
2a40: 0d 0a 20 20 31 2c 20 53 54 5f 47 65 6f 6d 46 72  ..  1, ST_GeomFr
2a50: 6f 6d 54 65 78 74 28 20 27 50 4f 49 4e 54 28 20  omText( 'POINT( 
2a60: 32 20 31 20 29 27 20 29 20 29 20 29 3b 0d 0a 2d  2 1 )' ) ) );..-
2a70: 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 4c 49 4e 45 53 54  --------..LINEST
2a80: 52 49 4e 47 28 30 20 30 2c 20 32 20 31 2c 20 31  RING(0 0, 2 1, 1
2a90: 20 31 29 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e   1)..</verbatim>
2aa0: 0d 0a 54 68 65 20 3c 62 3e 53 54 5f 53 65 74 50  ..The <b>ST_SetP
2ab0: 6f 69 6e 74 28 29 3c 2f 62 3e 20 53 51 4c 20 66  oint()</b> SQL f
2ac0: 75 6e 63 74 69 6f 6e 20 63 61 6e 20 72 65 70 6c  unction can repl
2ad0: 61 63 65 20 61 20 50 6f 69 6e 74 2f 56 65 72 74  ace a Point/Vert
2ae0: 65 78 20 66 72 6f 6d 20 77 69 74 68 69 6e 20 61  ex from within a
2af0: 20 4c 69 6e 65 73 74 72 69 6e 67 3b 20 74 68 65   Linestring; the
2b00: 20 66 69 72 73 74 20 61 72 67 75 6d 65 6e 74 20   first argument 
2b10: 69 73 20 61 6c 77 61 79 73 20 65 78 70 65 63 74  is always expect
2b20: 65 64 20 74 6f 20 62 65 20 6f 66 20 74 68 65 20  ed to be of the 
2b30: 4c 69 6e 65 73 74 72 69 6e 67 20 74 79 70 65 2c  Linestring type,
2b40: 20 74 68 65 20 73 65 63 6f 6e 64 20 69 73 20 61   the second is a
2b50: 6e 20 49 6e 74 65 67 65 72 20 73 70 65 63 69 66  n Integer specif
2b60: 79 69 6e 67 20 74 68 65 20 3c 75 3e 69 6e 64 65  ying the <u>inde
2b70: 78 3c 2f 75 3e 20 6f 66 20 74 68 65 20 61 66 66  x</u> of the aff
2b80: 65 63 74 65 64 20 56 65 72 74 65 78 20 61 6e 64  ected Vertex and
2b90: 20 74 68 65 20 74 68 69 72 64 20 6f 6e 65 20 6d   the third one m
2ba0: 75 73 74 20 62 65 20 61 20 50 6f 69 6e 74 2e 3c  ust be a Point.<
2bb0: 62 72 3e 0d 0a 52 65 66 65 72 65 6e 63 69 6e 67  br>..Referencing
2bc0: 20 61 20 6e 6f 74 20 65 78 69 73 74 69 6e 67 20   a not existing 
2bd0: 69 6e 64 65 78 20 69 73 20 61 6e 20 65 72 72 6f  index is an erro
2be0: 72 2c 20 61 6e 64 20 77 69 6c 6c 20 72 65 74 75  r, and will retu
2bf0: 72 6e 20 4e 55 4c 4c 2e 3c 62 72 3e 3c 62 72 3e  rn NULL.<br><br>
2c00: 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72 62 61 74 69  ..<hr>..<verbati
2c10: 6d 3e 0d 0a 53 45 4c 45 43 54 20 53 54 5f 41 73  m>..SELECT ST_As
2c20: 54 65 78 74 28 20 53 54 5f 52 65 6d 6f 76 65 50  Text( ST_RemoveP
2c30: 6f 69 6e 74 28 20 0d 0a 20 20 53 54 5f 47 65 6f  oint( ..  ST_Geo
2c40: 6d 46 72 6f 6d 54 65 78 74 28 20 27 4c 49 4e 45  mFromText( 'LINE
2c50: 53 54 52 49 4e 47 28 20 30 20 30 2c 20 31 20 30  STRING( 0 0, 1 0
2c60: 2c 20 31 20 31 20 29 27 20 29 2c 20 31 20 29 20  , 1 1 )' ), 1 ) 
2c70: 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 4c  );..---------..L
2c80: 49 4e 45 53 54 52 49 4e 47 28 30 20 30 2c 20 31  INESTRING(0 0, 1
2c90: 20 31 29 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e   1)..</verbatim>
2ca0: 0d 0a 54 68 65 20 3c 62 3e 53 54 5f 52 65 6d 6f  ..The <b>ST_Remo
2cb0: 76 65 50 6f 69 6e 74 28 29 3c 2f 62 3e 20 53 51  vePoint()</b> SQ
2cc0: 4c 20 66 75 6e 63 74 69 6f 6e 20 63 61 6e 20 72  L function can r
2cd0: 65 6d 6f 76 65 20 61 20 50 6f 69 6e 74 2f 56 65  emove a Point/Ve
2ce0: 72 74 65 78 20 66 72 6f 6d 20 77 69 74 68 69 6e  rtex from within
2cf0: 20 61 20 4c 69 6e 65 73 74 72 69 6e 67 3b 20 74   a Linestring; t
2d00: 68 65 20 66 69 72 73 74 20 61 72 67 75 6d 65 6e  he first argumen
2d10: 74 20 69 73 20 61 6c 77 61 79 73 20 65 78 70 65  t is always expe
2d20: 63 74 65 64 20 74 6f 20 62 65 20 6f 66 20 74 68  cted to be of th
2d30: 65 20 4c 69 6e 65 73 74 72 69 6e 67 20 74 79 70  e Linestring typ
2d40: 65 2c 20 74 68 65 20 73 65 63 6f 6e 64 20 69 73  e, the second is
2d50: 20 61 6e 20 49 6e 74 65 67 65 72 20 73 70 65 63   an Integer spec
2d60: 69 66 79 69 6e 67 20 74 68 65 20 3c 75 3e 69 6e  ifying the <u>in
2d70: 64 65 78 3c 2f 75 3e 20 6f 66 20 74 68 65 20 61  dex</u> of the a
2d80: 66 66 65 63 74 65 64 20 56 65 72 74 65 78 2e 3c  ffected Vertex.<
2d90: 62 72 3e 0d 0a 52 65 66 65 72 65 6e 63 69 6e 67  br>..Referencing
2da0: 20 61 20 6e 6f 74 20 65 78 69 73 74 69 6e 67 20   a not existing 
2db0: 69 6e 64 65 78 20 69 73 20 61 6e 20 65 72 72 6f  index is an erro
2dc0: 72 2c 20 61 6e 64 20 77 69 6c 6c 20 72 65 74 75  r, and will retu
2dd0: 72 6e 20 4e 55 4c 4c 2e 3c 62 72 3e 3c 62 72 3e  rn NULL.<br><br>
2de0: 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72 62 61 74 69  ..<hr>..<verbati
2df0: 6d 3e 0d 0a 53 45 4c 45 43 54 20 53 54 5f 41 73  m>..SELECT ST_As
2e00: 54 65 78 74 28 20 53 54 5f 50 6f 69 6e 74 28 31  Text( ST_Point(1
2e10: 30 2c 20 32 30 29 20 29 3b 0d 0a 2d 2d 2d 2d 2d  0, 20) );..-----
2e20: 2d 2d 2d 2d 2d 0d 0a 50 4f 49 4e 54 28 31 30 20  -----..POINT(10 
2e30: 31 30 29 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e  10)..</verbatim>
2e40: 0d 0a 54 68 65 20 3c 62 3e 53 54 5f 50 6f 69 6e  ..The <b>ST_Poin
2e50: 74 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63  t()</b> SQL func
2e60: 74 69 6f 6e 20 73 69 6d 70 6c 79 20 69 73 20 79  tion simply is y
2e70: 65 74 20 61 6e 6f 74 68 65 72 20 3c 69 3e 61 6c  et another <i>al
2e80: 69 61 73 2d 6e 61 6d 65 3c 2f 69 3e 20 63 6f 72  ias-name</i> cor
2e90: 72 65 73 70 6f 6e 64 69 6e 67 20 74 6f 20 3c 62  responding to <b
2ea0: 3e 4d 61 6b 65 50 6f 69 6e 74 28 29 3c 2f 62 3e  >MakePoint()</b>
2eb0: 3b 20 74 68 69 73 20 66 75 72 74 68 65 72 20 61  ; this further a
2ec0: 6c 69 61 73 20 68 61 73 20 62 65 65 6e 20 69 6e  lias has been in
2ed0: 74 72 6f 64 75 63 65 64 20 73 6f 20 74 6f 20 73  troduced so to s
2ee0: 75 70 70 6f 72 74 20 61 20 73 74 72 69 63 74 20  upport a strict 
2ef0: 50 6f 73 74 47 49 53 20 63 6f 6e 66 6f 72 6d 61  PostGIS conforma
2f00: 6e 63 65 2e 3c 62 72 3e 0d 0a 3c 75 3e 50 6c 65  nce.<br>..<u>Ple
2f10: 61 73 65 20 6e 6f 74 65 3c 2f 75 3e 3a 20 64 69  ase note</u>: di
2f20: 66 66 65 72 65 6e 74 6c 79 20 66 72 6f 6d 20 4d  fferently from M
2f30: 61 6b 65 50 6f 69 6e 74 28 29 2c 20 53 54 5f 50  akePoint(), ST_P
2f40: 6f 69 6e 74 28 29 20 64 6f 6e 27 74 20 73 75 70  oint() don't sup
2f50: 70 6f 72 74 73 20 74 68 65 20 6f 70 74 69 6f 6e  ports the option
2f60: 61 6c 20 3c 62 3e 53 52 49 44 3c 2f 62 3e 20 61  al <b>SRID</b> a
2f70: 72 67 75 6d 65 6e 74 2e 3c 62 72 3e 3c 62 72 3e  rgument.<br><br>
2f80: 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72 62 61 74 69  ..<hr>..<verbati
2f90: 6d 3e 0d 0a 53 45 4c 45 43 54 20 53 54 5f 41 73  m>..SELECT ST_As
2fa0: 54 65 78 74 28 20 4d 61 6b 65 4c 69 6e 65 28 20  Text( MakeLine( 
2fb0: 53 54 5f 47 65 6f 6d 46 72 6f 6d 54 65 78 74 28  ST_GeomFromText(
2fc0: 20 27 4d 55 4c 54 49 50 4f 49 4e 54 28 30 20 30   'MULTIPOINT(0 0
2fd0: 2c 20 31 20 30 2c 20 31 20 31 29 27 20 29 20 29  , 1 0, 1 1)' ) )
2fe0: 20 2c 20 31 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d   , 1 );..-------
2ff0: 2d 2d 2d 0d 0a 4c 49 4e 45 53 54 52 49 4e 47 28  ---..LINESTRING(
3000: 30 20 30 2c 20 31 20 30 2c 20 31 20 31 29 0d 0a  0 0, 1 0, 1 1)..
3010: 0d 0a 53 45 4c 45 43 54 20 53 54 5f 41 73 54 65  ..SELECT ST_AsTe
3020: 78 74 28 20 4d 61 6b 65 4c 69 6e 65 28 20 53 54  xt( MakeLine( ST
3030: 5f 47 65 6f 6d 46 72 6f 6d 54 65 78 74 28 20 27  _GeomFromText( '
3040: 4d 55 4c 54 49 50 4f 49 4e 54 28 30 20 30 2c 20  MULTIPOINT(0 0, 
3050: 31 20 30 2c 20 31 20 31 29 27 20 29 20 29 20 2c  1 0, 1 1)' ) ) ,
3060: 20 30 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d   0 );..---------
3070: 2d 0d 0a 4c 49 4e 45 53 54 52 49 4e 47 28 31 20  -..LINESTRING(1 
3080: 31 2c 20 31 20 30 2c 20 30 20 30 29 0d 0a 3c 2f  1, 1 0, 0 0)..</
3090: 76 65 72 62 61 74 69 6d 3e 0d 0a 4e 6f 74 20 72  verbatim>..Not r
30a0: 65 61 6c 6c 79 20 61 20 62 72 61 6e 64 20 6e 65  eally a brand ne
30b0: 77 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 3b 20  w SQL function; 
30c0: 6d 6f 72 65 20 73 69 6d 70 6c 79 20 61 20 66 75  more simply a fu
30d0: 72 74 68 65 72 20 6f 76 65 72 6c 6f 61 64 65 64  rther overloaded
30e0: 20 66 6c 61 76 6f 72 20 6f 66 20 74 68 65 20 61   flavor of the a
30f0: 6c 72 65 61 64 79 20 65 78 69 73 74 69 6e 67 20  lready existing 
3100: 3c 62 3e 4d 61 6b 65 4c 69 6e 65 28 29 3c 2f 62  <b>MakeLine()</b
3110: 3e 2e 3c 62 72 3e 0d 0a 4e 6f 77 20 74 68 65 20  >.<br>..Now the 
3120: 69 6e 70 75 74 20 47 65 6f 6d 65 74 72 79 20 28  input Geometry (
3130: 66 69 72 73 74 20 61 72 67 75 6d 65 6e 74 29 20  first argument) 
3140: 63 6f 75 6c 64 20 62 65 20 6f 66 20 74 68 65 20  could be of the 
3150: 4d 55 4c 54 49 50 4f 49 4e 54 20 74 79 70 65 20  MULTIPOINT type 
3160: 61 6e 64 20 74 68 65 20 73 65 63 6f 6e 64 20 61  and the second a
3170: 72 67 75 6d 65 6e 74 20 69 66 20 6f 66 20 74 68  rgument if of th
3180: 65 20 3c 62 3e 42 6f 6f 6c 65 61 6e 3c 2f 62 3e  e <b>Boolean</b>
3190: 20 74 79 70 65 3b 20 69 66 20 74 68 65 20 73 65   type; if the se
31a0: 63 6f 6e 64 20 61 72 67 75 6d 65 6e 74 20 63 6f  cond argument co
31b0: 72 72 65 73 70 6f 6e 64 73 20 74 6f 20 3c 62 3e  rresponds to <b>
31c0: 54 52 55 45 3c 2f 62 3e 20 74 68 65 20 72 65 74  TRUE</b> the ret
31d0: 75 72 6e 65 64 20 4c 49 4e 45 53 54 52 49 4e 47  urned LINESTRING
31e0: 20 77 69 6c 6c 20 62 65 20 6f 72 69 65 6e 74 65   will be oriente
31f0: 64 20 61 63 63 6f 72 64 69 6e 67 6c 79 20 74 6f  d accordingly to
3200: 20 74 68 65 20 50 6f 69 6e 74 2d 73 65 71 75 65   the Point-seque
3210: 6e 63 65 20 61 73 20 73 70 65 63 69 66 69 65 64  nce as specified
3220: 20 62 79 20 74 68 65 20 4d 75 6c 74 69 50 6f 69   by the MultiPoi
3230: 6e 74 2c 20 6f 74 68 65 72 77 69 73 65 20 3c 75  nt, otherwise <u
3240: 3e 72 65 76 65 72 73 65 20 6f 72 64 65 72 3c 2f  >reverse order</
3250: 75 3e 20 77 69 6c 6c 20 62 65 20 61 73 73 75 6d  u> will be assum
3260: 65 64 2c 20 74 68 75 73 20 72 65 74 75 72 6e 69  ed, thus returni
3270: 6e 67 20 61 20 4c 69 6e 65 73 74 72 69 6e 67 20  ng a Linestring 
3280: 6f 66 20 6f 70 70 6f 73 69 74 65 20 6f 72 69 65  of opposite orie
3290: 6e 74 61 74 69 6f 6e 2e 3c 62 72 3e 3c 62 72 3e  ntation.<br><br>
32a0: 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72 62 61 74 69  ..<hr>..<verbati
32b0: 6d 3e 0d 0a 53 45 4c 45 43 54 20 53 54 5f 41 72  m>..SELECT ST_Ar
32c0: 65 61 28 20 53 54 5f 47 65 6f 6d 46 72 6f 6d 54  ea( ST_GeomFromT
32d0: 65 78 74 28 20 27 50 4f 4c 59 47 4f 4e 28 28 32  ext( 'POLYGON((2
32e0: 30 20 32 30 2c 20 32 31 20 32 30 2c 20 32 31 20  0 20, 21 20, 21 
32f0: 32 31 2c 20 32 30 20 32 31 2c 20 32 30 20 32 30  21, 20 21, 20 20
3300: 29 29 27 2c 20 34 33 32 36 20 29 2c 20 31 20 29  ))', 4326 ), 1 )
3310: 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 31  ;..----------..1
3320: 31 35 34 38 35 35 35 39 32 36 2e 36 34 37 37 33  1548555926.64773
3330: 36 0d 0a 0d 0a 0d 0a 53 45 4c 45 43 54 20 53 54  6......SELECT ST
3340: 5f 41 72 65 61 28 20 53 54 5f 47 65 6f 6d 46 72  _Area( ST_GeomFr
3350: 6f 6d 54 65 78 74 28 20 27 50 4f 4c 59 47 4f 4e  omText( 'POLYGON
3360: 28 28 32 30 20 32 30 2c 20 32 31 20 32 30 2c 20  ((20 20, 21 20, 
3370: 32 31 20 32 31 2c 20 32 30 20 32 31 2c 20 32 30  21 21, 20 21, 20
3380: 20 32 30 29 29 27 2c 20 34 33 32 36 20 29 2c 20   20))', 4326 ), 
3390: 30 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  0 );..----------
33a0: 0d 0a 31 31 35 38 31 33 37 37 36 32 33 2e 31 31  ..11581377623.11
33b0: 34 31 38 39 0d 0a 3c 2f 76 65 72 62 61 74 69 6d  4189..</verbatim
33c0: 3e 0d 0a 4f 6e 63 65 20 61 67 61 69 6e 2c 20 73  >..Once again, s
33d0: 69 6d 70 6c 79 20 61 20 66 75 72 74 68 65 72 20  imply a further 
33e0: 65 78 74 65 6e 73 69 6f 6e 20 6f 66 20 74 68 65  extension of the
33f0: 20 61 6c 72 65 61 64 79 20 65 78 69 73 74 69 6e   already existin
3400: 67 20 3c 62 3e 53 54 5f 41 72 65 61 28 29 3c 2f  g <b>ST_Area()</
3410: 62 3e 2e 3c 62 72 3e 0d 0a 4e 6f 77 20 69 66 20  b>.<br>..Now if 
3420: 74 68 65 20 69 6e 70 75 74 20 47 65 6f 6d 65 74  the input Geomet
3430: 72 79 20 61 64 6f 70 74 73 20 3c 75 3e 67 65 6f  ry adopts <u>geo
3440: 67 72 61 70 68 69 63 20 63 6f 6f 72 64 69 6e 61  graphic coordina
3450: 74 65 73 3c 2f 75 3e 20 28 69 2e 65 2e 20 62 61  tes</u> (i.e. ba
3460: 73 65 64 20 6f 6e 20 3c 75 3e 6c 6f 6e 67 69 74  sed on <u>longit
3470: 75 64 65 3c 2f 75 3e 20 61 6e 64 20 3c 75 3e 6c  ude</u> and <u>l
3480: 61 74 69 74 75 64 65 3c 2f 75 3e 20 61 6e 67 6c  atitude</u> angl
3490: 65 73 29 2c 20 61 20 73 65 63 6f 6e 64 20 61 72  es), a second ar
34a0: 67 75 6d 65 6e 74 20 6f 66 20 74 68 65 20 3c 62  gument of the <b
34b0: 3e 42 6f 6f 6c 65 61 6e 3c 2f 62 3e 20 64 61 74  >Boolean</b> dat
34c0: 61 2d 74 79 70 65 20 63 6f 75 6c 64 20 62 65 20  a-type could be 
34d0: 6f 70 74 69 6f 6e 61 6c 6c 79 20 73 70 65 63 69  optionally speci
34e0: 66 69 65 64 2e 3c 62 72 3e 0d 0a 49 6e 20 74 68  fied.<br>..In th
34f0: 69 73 20 63 61 73 65 20 74 68 65 20 72 65 74 75  is case the retu
3500: 72 6e 65 64 20 41 72 65 61 20 77 69 6c 6c 20 62  rned Area will b
3510: 65 20 6d 65 61 73 75 72 65 64 20 69 6e 20 3c 62  e measured in <b
3520: 3e 6d 65 74 65 72 73 3c 2f 62 3e 2e 0d 0a 3c 75  >meters</b>...<u
3530: 6c 3e 0d 0a 3c 6c 69 3e 69 66 20 74 68 65 20 73  l>..<li>if the s
3540: 65 63 6f 6e 64 20 61 72 67 20 69 73 20 3c 62 3e  econd arg is <b>
3550: 54 52 55 45 3c 2f 62 3e 20 74 68 65 20 41 72 65  TRUE</b> the Are
3560: 61 20 77 69 6c 6c 20 62 65 20 6d 65 61 73 75 72  a will be measur
3570: 65 64 20 3c 75 3e 6f 6e 20 74 68 65 20 45 6c 6c  ed <u>on the Ell
3580: 69 70 73 6f 69 64 3c 2f 75 3e 20 28 6d 6f 72 65  ipsoid</u> (more
3590: 20 61 63 63 75 72 61 74 65 2c 20 62 75 74 20 73   accurate, but s
35a0: 6c 6f 77 65 72 29 2e 3c 2f 6c 69 3e 0d 0a 3c 6c  lower).</li>..<l
35b0: 69 3e 69 66 20 74 68 65 20 73 65 63 6f 6e 64 20  i>if the second 
35c0: 61 72 67 20 69 73 20 3c 62 3e 46 41 4c 53 45 3c  arg is <b>FALSE<
35d0: 2f 62 3e 20 74 68 65 20 41 72 65 61 20 77 69 6c  /b> the Area wil
35e0: 6c 20 62 65 20 6d 65 61 73 75 72 65 20 3c 75 3e  l be measure <u>
35f0: 6f 6e 20 74 68 65 20 53 70 68 65 72 65 3c 2f 75  on the Sphere</u
3600: 3e 20 28 66 61 73 74 65 72 2c 20 62 75 74 20 6c  > (faster, but l
3610: 65 73 73 20 61 63 63 75 72 61 74 65 29 2e 3c 2f  ess accurate).</
3620: 6c 69 3e 0d 0a 3c 6c 69 3e 4e 55 4c 4c 20 77 69  li>..<li>NULL wi
3630: 6c 6c 20 62 65 20 72 65 74 75 72 6e 65 64 20 6f  ll be returned o
3640: 6e 20 69 6e 76 61 6c 69 64 20 61 72 67 73 2e 3c  n invalid args.<
3650: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 3c 75 3e 50 6c 65  /li>..<li><u>Ple
3660: 61 73 65 20 6e 6f 74 65 3c 2f 75 3e 3a 20 74 68  ase note</u>: th
3670: 69 73 20 73 70 65 63 69 66 69 63 20 66 6c 61 76  is specific flav
3680: 6f 72 20 6f 66 20 3c 62 3e 53 54 5f 41 72 65 61  or of <b>ST_Area
3690: 28 29 3c 2f 62 3e 20 6e 65 63 65 73 73 61 72 69  ()</b> necessari
36a0: 6c 79 20 72 65 71 75 69 72 65 73 20 74 68 65 20  ly requires the 
36b0: 3c 62 3e 4c 57 47 45 4f 4d 3c 2f 62 3e 20 73 75  <b>LWGEOM</b> su
36c0: 70 70 6f 72 74 20 74 6f 20 62 65 20 61 63 74 69  pport to be acti
36d0: 76 61 74 65 64 20 61 74 20 62 75 69 6c 64 20 74  vated at build t
36e0: 69 6d 65 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e  ime.</li>..</ul>
36f0: 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72  <br>..<hr>..<ver
3700: 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 53  batim>..SELECT S
3710: 54 5f 41 73 54 65 78 74 28 20 53 54 5f 50 72 6f  T_AsText( ST_Pro
3720: 6a 65 63 74 28 20 4d 61 6b 65 50 6f 69 6e 74 28  ject( MakePoint(
3730: 20 31 31 2e 35 32 2c 20 34 32 2e 33 38 2c 20 34   11.52, 42.38, 4
3740: 33 32 36 20 29 2c 20 35 30 30 30 30 2c 20 52 61  326 ), 50000, Ra
3750: 64 69 61 6e 73 28 20 34 35 20 29 20 29 20 29 3b  dians( 45 ) ) );
3760: 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 50 4f  ..----------..PO
3770: 49 4e 54 28 31 31 2e 39 35 31 34 37 39 20 34 32  INT(11.951479 42
3780: 2e 36 39 37 34 36 37 29 0d 0a 3c 2f 76 65 72 62  .697467)..</verb
3790: 61 74 69 6d 3e 0d 0a 54 68 65 20 3c 62 3e 53 54  atim>..The <b>ST
37a0: 5f 50 72 6f 6a 65 63 74 28 29 3c 2f 62 3e 20 53  _Project()</b> S
37b0: 51 4c 20 66 75 6e 63 74 69 6f 6e 20 77 69 6c 6c  QL function will
37c0: 20 72 65 74 75 72 6e 20 74 68 65 20 64 65 73 74   return the dest
37d0: 69 6e 61 74 69 6f 6e 20 50 6f 69 6e 74 20 3c 75  ination Point <u
37e0: 3e 6f 6e 20 74 68 65 20 65 6c 6c 69 70 73 6f 69  >on the ellipsoi
37f0: 64 3c 2f 75 3e 20 63 6f 72 72 65 73 70 6f 6e 64  d</u> correspond
3800: 69 6e 67 20 74 6f 20 61 20 3c 62 3e 73 74 61 72  ing to a <b>star
3810: 74 5f 70 6f 69 6e 74 3c 2f 62 3e 2c 20 61 20 3c  t_point</b>, a <
3820: 62 3e 64 69 73 74 61 6e 63 65 3c 2f 62 3e 20 61  b>distance</b> a
3830: 6e 64 20 61 20 3c 62 3e 62 65 61 72 69 6e 67 3c  nd a <b>bearing<
3840: 2f 62 3e 20 28 61 6b 61 20 3c 75 3e 61 7a 69 6d  /b> (aka <u>azim
3850: 75 74 68 3c 2f 75 3e 20 61 6b 61 20 3c 75 3e 64  uth</u> aka <u>d
3860: 69 72 65 63 74 69 6f 6e 3c 2f 75 3e 20 61 6b 61  irection</u> aka
3870: 20 3c 75 3e 68 65 61 64 69 6e 67 3c 2f 75 3e 29   <u>heading</u>)
3880: 2e 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 74 68 65  ...<ul>..<li>the
3890: 20 3c 62 3e 73 74 61 72 74 5f 70 6f 69 6e 74 3c   <b>start_point<
38a0: 2f 62 3e 20 69 73 20 65 78 70 65 63 74 65 64 20  /b> is expected 
38b0: 74 6f 20 61 64 6f 70 74 20 3c 75 3e 67 65 6f 67  to adopt <u>geog
38c0: 72 61 70 68 69 63 20 63 6f 6f 72 64 69 6e 61 74  raphic coordinat
38d0: 65 73 3c 2f 75 3e 20 28 69 2e 65 2e 20 62 61 73  es</u> (i.e. bas
38e0: 65 64 20 6f 6e 20 3c 75 3e 6c 6f 6e 67 69 74 75  ed on <u>longitu
38f0: 64 65 3c 2f 75 3e 20 61 6e 64 20 3c 75 3e 6c 61  de</u> and <u>la
3900: 74 69 74 75 64 65 3c 2f 75 3e 20 61 6e 67 6c 65  titude</u> angle
3910: 73 29 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 74 68  s).</li>..<li>th
3920: 65 20 3c 62 3e 64 69 73 74 61 6e 63 65 3c 2f 62  e <b>distance</b
3930: 3e 20 69 73 20 61 6c 77 61 79 73 20 65 78 70 65  > is always expe
3940: 63 74 65 64 20 74 6f 20 62 65 20 65 78 70 72 65  cted to be expre
3950: 73 73 65 64 20 69 6e 20 3c 62 3e 6d 65 74 65 72  ssed in <b>meter
3960: 73 3c 2f 62 3e 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69  s</b>.</li>..<li
3970: 3e 74 68 65 20 3c 62 3e 61 7a 69 6d 75 74 68 3c  >the <b>azimuth<
3980: 2f 62 3e 20 61 6e 67 6c 65 20 69 73 20 65 78 70  /b> angle is exp
3990: 65 63 74 65 64 20 74 6f 20 62 65 20 65 78 70 72  ected to be expr
39a0: 65 73 73 65 64 20 69 6e 20 3c 62 3e 72 61 64 69  essed in <b>radi
39b0: 61 6e 73 3c 2f 62 3e 3a 0d 0a 3c 75 6c 3e 0d 0a  ans</b>:..<ul>..
39c0: 3c 6c 69 3e 4e 6f 72 74 68 20 63 6f 72 72 65 73  <li>North corres
39d0: 70 6f 6e 64 73 20 74 6f 20 30 20 64 65 67 72 65  ponds to 0 degre
39e0: 65 73 20 28 30 20 72 61 64 69 61 6e 73 29 2e 3c  es (0 radians).<
39f0: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 45 61 73 74 20 63  /li>..<li>East c
3a00: 6f 72 72 65 73 70 6f 6e 64 73 20 74 6f 20 39 30  orresponds to 90
3a10: 20 64 65 67 72 65 65 73 20 28 50 49 2f 32 20 72   degrees (PI/2 r
3a20: 61 64 69 61 6e 73 29 2e 3c 2f 6c 69 3e 0d 0a 3c  adians).</li>..<
3a30: 6c 69 3e 53 6f 75 74 68 20 63 6f 72 72 65 73 70  li>South corresp
3a40: 6f 6e 64 73 20 74 6f 20 31 38 30 20 64 65 67 72  onds to 180 degr
3a50: 65 65 73 20 28 50 49 20 72 61 64 69 61 6e 73 29  ees (PI radians)
3a60: 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 57 65 73 74  .</li>..<li>West
3a70: 20 63 6f 72 72 65 73 70 6f 6e 64 73 20 74 6f 20   corresponds to 
3a80: 32 37 30 20 64 65 67 72 65 65 73 20 28 33 50 49  270 degrees (3PI
3a90: 2f 32 20 72 61 64 69 61 6e 73 29 2e 3c 2f 6c 69  /2 radians).</li
3aa0: 3e 0d 0a 3c 6c 69 3e 69 2e 65 2e 20 69 74 20 68  >..<li>i.e. it h
3ab0: 61 73 20 74 68 65 20 73 61 6d 65 20 69 64 65 6e  as the same iden
3ac0: 74 69 63 61 6c 20 6d 65 61 6e 69 6e 67 20 61 73  tical meaning as
3ad0: 20 69 6e 20 3c 62 3e 53 54 5f 41 7a 69 6d 75 74   in <b>ST_Azimut
3ae0: 68 28 29 3c 2f 62 3e 2e 3c 2f 6c 69 3e 0d 0a 3c  h()</b>.</li>..<
3af0: 2f 75 6c 3e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 74  /ul></li>..<li>t
3b00: 68 69 73 20 66 75 6e 63 74 69 6f 6e 20 65 78 61  his function exa
3b10: 63 74 6c 79 20 63 6f 72 72 65 73 70 6f 6e 64 73  ctly corresponds
3b20: 20 74 6f 20 74 68 65 20 6f 6e 65 20 73 75 70 70   to the one supp
3b30: 6f 72 74 65 64 20 62 79 20 3c 62 3e 50 6f 73 74  orted by <b>Post
3b40: 47 49 53 3c 2f 62 3e 2e 3c 2f 6c 69 3e 0d 0a 3c  GIS</b>.</li>..<
3b50: 6c 69 3e 3c 75 3e 50 6c 65 61 73 65 20 6e 6f 74  li><u>Please not
3b60: 65 3c 2f 75 3e 3a 20 3c 62 3e 53 54 5f 50 72 6f  e</u>: <b>ST_Pro
3b70: 6a 65 63 74 28 29 3c 2f 62 3e 20 6e 65 63 65 73  ject()</b> neces
3b80: 73 61 72 69 6c 79 20 72 65 71 75 69 72 65 73 20  sarily requires 
3b90: 74 68 65 20 3c 62 3e 4c 57 47 45 4f 4d 3c 2f 62  the <b>LWGEOM</b
3ba0: 3e 20 73 75 70 70 6f 72 74 20 74 6f 20 62 65 20  > support to be 
3bb0: 61 63 74 69 76 61 74 65 64 20 61 74 20 62 75 69  activated at bui
3bc0: 6c 64 20 74 69 6d 65 2e 3c 2f 6c 69 3e 0d 0a 3c  ld time.</li>..<
3bd0: 2f 75 6c 3e 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a  /ul><br>..<hr>..
3be0: 3c 68 33 3e 3c 61 20 6e 61 6d 65 3d 22 75 6e 73  <h3><a name="uns
3bf0: 61 66 65 22 3e 55 6e 73 61 66 65 3c 2f 61 3e 20  afe">Unsafe</a> 
3c00: 28 62 75 74 20 75 73 65 66 75 6c 29 20 49 6d 70  (but useful) Imp
3c10: 6f 72 74 2f 45 78 70 6f 72 74 20 53 51 4c 20 66  ort/Export SQL f
3c20: 75 6e 63 74 69 6f 6e 73 3c 2f 68 33 3e 0d 0a 41  unctions</h3>..A
3c30: 6c 6c 20 74 68 65 20 66 6f 6c 6c 6f 77 69 6e 67  ll the following
3c40: 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 73 20 63   SQL functions c
3c50: 6f 75 6c 64 20 62 65 20 72 65 61 6c 6c 79 20 75  ould be really u
3c60: 73 65 66 75 6c 20 69 6e 20 6f 72 64 65 72 20 74  seful in order t
3c70: 6f 20 73 75 70 70 6f 72 74 20 49 6d 70 6f 72 74  o support Import
3c80: 2f 45 78 70 6f 72 74 20 6f 70 65 72 61 74 69 6f  /Export operatio
3c90: 6e 73 2e 3c 62 72 3e 0d 0a 41 6e 79 77 61 79 20  ns.<br>..Anyway 
3ca0: 79 6f 75 20 73 68 6f 75 6c 64 20 62 65 20 3c 75  you should be <u
3cb0: 3e 77 65 6c 6c 20 61 77 61 72 65 3c 2f 75 3e 20  >well aware</u> 
3cc0: 74 68 61 74 20 61 6c 6c 20 74 68 65 6d 20 63 6f  that all them co
3cd0: 75 6c 64 20 62 65 20 70 6f 74 65 6e 74 69 61 6c  uld be potential
3ce0: 6c 79 20 3c 75 3e 75 6e 73 61 66 65 3c 2f 75 3e  ly <u>unsafe</u>
3cf0: 20 61 6e 64 20 63 6f 75 6c 64 20 62 65 20 70 6f   and could be po
3d00: 74 65 6e 74 69 61 6c 6c 79 20 75 73 65 64 20 62  tentially used b
3d10: 79 20 73 6f 6d 65 20 3c 75 3e 6d 61 6c 69 63 69  y some <u>malici
3d20: 6f 75 73 20 68 61 63 6b 65 72 3c 2f 75 3e 20 69  ous hacker</u> i
3d30: 6e 20 6f 72 64 65 72 20 74 6f 20 63 72 65 61 74  n order to creat
3d40: 65 20 61 6e 64 20 65 78 70 6c 6f 69 74 20 73 6f  e and exploit so
3d50: 6d 65 20 3c 75 3e 73 65 63 75 72 69 74 79 20 62  me <u>security b
3d60: 72 65 61 63 68 3c 2f 75 3e 2e 3c 62 72 3e 0d 0a  reach</u>.<br>..
3d70: 54 68 65 20 63 61 75 73 65 20 69 73 20 76 65 72  The cause is ver
3d80: 79 20 65 61 73 79 20 74 6f 20 62 65 20 75 6e 64  y easy to be und
3d90: 65 72 73 74 6f 6f 64 3a 20 74 68 65 73 65 20 66  erstood: these f
3da0: 75 6e 63 74 69 6f 6e 73 20 61 6c 6c 6f 77 20 74  unctions allow t
3db0: 6f 20 74 72 61 6e 73 66 65 72 20 61 72 62 69 74  o transfer arbit
3dc0: 72 61 72 79 20 70 61 79 6c 6f 61 64 73 20 66 72  rary payloads fr
3dd0: 6f 6d 20 2f 20 74 6f 20 74 68 65 20 44 61 74 61  om / to the Data
3de0: 62 61 73 65 20 61 6e 64 20 74 68 65 20 6c 6f 63  base and the loc
3df0: 61 6c 20 46 69 6c 65 2d 53 79 73 74 65 6d 2e 0d  al File-System..
3e00: 0a 41 20 6d 61 6c 69 63 69 6f 75 73 20 61 74 74  .A malicious att
3e10: 61 63 6b 20 63 6f 75 6c 64 20 62 65 20 74 68 75  ack could be thu
3e20: 73 20 69 6d 70 6c 65 6d 65 6e 74 65 64 20 65 2e  s implemented e.
3e30: 67 2e 20 62 79 20 65 78 65 63 75 74 69 6e 67 20  g. by executing 
3e40: 73 6f 6d 65 20 53 51 4c 20 73 63 72 69 70 74 20  some SQL script 
3e50: 6f 72 20 62 79 20 64 65 66 69 6e 69 6e 67 20 61  or by defining a
3e60: 20 70 75 72 70 6f 73 65 6c 79 20 66 6f 72 67 65   purposely forge
3e70: 64 20 54 72 69 67 67 65 72 2c 20 61 6e 64 20 74  d Trigger, and t
3e80: 68 65 20 65 6e 64 20 75 73 65 72 73 20 77 6f 75  he end users wou
3e90: 6c 64 20 62 65 20 61 62 73 6f 6c 75 74 65 6c 79  ld be absolutely
3ea0: 20 75 6e 61 77 61 72 65 20 6f 66 20 77 68 61 74   unaware of what
3eb0: 20 69 73 20 72 65 61 6c 6c 79 20 68 61 70 70 65   is really happe
3ec0: 6e 69 6e 67 2e 0d 0a 53 6f 20 69 6e 20 6f 72 64  ning...So in ord
3ed0: 65 72 20 74 6f 20 65 66 66 65 63 74 69 76 65 6c  er to effectivel
3ee0: 79 20 73 68 69 65 6c 64 20 75 73 65 72 73 20 61  y shield users a
3ef0: 67 61 69 6e 73 74 20 74 68 65 73 65 20 70 6f 74  gainst these pot
3f00: 65 6e 74 69 61 6c 6c 79 20 64 61 6e 67 65 72 6f  entially dangero
3f10: 75 73 20 73 65 63 75 72 69 74 79 20 70 69 74 66  us security pitf
3f20: 61 6c 6c 73 20 61 6c 6c 20 74 68 65 73 65 20 53  alls all these S
3f30: 51 4c 20 66 75 6e 63 74 69 6f 6e 73 20 61 72 65  QL functions are
3f40: 20 61 6c 77 61 79 73 20 3c 75 3e 64 69 73 61 62   always <u>disab
3f50: 6c 65 64 20 62 79 20 64 65 66 61 75 6c 74 3c 2f  led by default</
3f60: 75 3e 2e 0d 0a 3c 76 65 72 62 61 74 69 6d 3e 0d  u>...<verbatim>.
3f70: 0a 65 78 70 6f 72 74 20 22 53 50 41 54 49 41 4c  .export "SPATIAL
3f80: 49 54 45 5f 53 45 43 55 52 49 54 59 3d 72 65 6c  ITE_SECURITY=rel
3f90: 61 78 65 64 22 0d 0a 3c 2f 76 65 72 62 61 74 69  axed"..</verbati
3fa0: 6d 3e 0d 0a 49 6e 20 6f 72 64 65 72 20 74 6f 20  m>..In order to 
3fb0: 72 65 61 6c 6c 79 20 65 6e 61 62 6c 65 20 74 68  really enable th
3fc0: 65 73 65 20 66 75 6e 63 74 69 6f 6e 73 20 74 68  ese functions th
3fd0: 65 20 75 73 65 72 20 69 73 20 72 65 71 75 69 72  e user is requir
3fe0: 65 64 20 74 6f 20 74 61 6b 65 20 61 6e 20 65 78  ed to take an ex
3ff0: 70 6c 69 63 69 74 20 61 63 74 69 6f 6e 3b 20 69  plicit action; i
4000: 2e 65 2e 20 74 68 65 20 3c 75 3e 65 6e 76 69 72  .e. the <u>envir
4010: 6f 6e 6d 65 6e 74 20 76 61 72 69 61 62 6c 65 3c  onment variable<
4020: 2f 75 3e 20 3c 62 3e 53 50 41 54 49 41 4c 49 54  /u> <b>SPATIALIT
4030: 45 5f 53 45 43 55 52 49 54 59 3d 72 65 6c 61 78  E_SECURITY=relax
4040: 65 64 3c 2f 62 3e 20 68 61 73 20 74 6f 20 62 65  ed</b> has to be
4050: 20 64 65 66 69 6e 65 64 2e 0d 0a 3c 76 65 72 62   defined...<verb
4060: 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 43 6f  atim>..SELECT Co
4070: 75 6e 74 55 6e 73 61 66 65 54 72 69 67 67 65 72  untUnsafeTrigger
4080: 73 28 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d  s();..---------.
4090: 0a 30 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d  .0..</verbatim>.
40a0: 0a 54 68 65 20 3c 62 3e 43 6f 75 6e 74 55 6e 73  .The <b>CountUns
40b0: 61 66 65 54 72 69 67 67 65 72 73 28 29 3c 2f 62  afeTriggers()</b
40c0: 3e 20 61 63 74 75 61 6c 6c 79 20 63 68 65 63 6b  > actually check
40d0: 73 20 69 66 20 74 68 65 20 63 6f 6e 6e 65 63 74  s if the connect
40e0: 65 64 20 44 61 74 61 62 61 73 65 20 64 6f 65 73  ed Database does
40f0: 20 63 6f 6e 74 61 69 6e 73 20 61 6e 79 20 73 75   contains any su
4100: 73 70 65 63 74 20 54 72 69 67 67 65 72 3b 20 63  spect Trigger; c
4110: 68 65 63 6b 69 6e 67 20 74 68 69 73 20 76 65 72  hecking this ver
4120: 73 69 6f 6e 20 62 65 66 6f 72 65 20 65 6e 61 62  sion before enab
4130: 6c 69 6e 67 20 74 68 65 20 75 6e 73 61 66 65 20  ling the unsafe 
4140: 53 51 4c 20 46 75 6e 63 74 69 6f 6e 73 20 69 73  SQL Functions is
4150: 20 61 6c 77 61 79 73 20 68 69 67 68 6c 79 20 72   always highly r
4160: 65 63 6f 6d 6d 65 6e 64 65 64 2e 3c 62 72 3e 0d  ecommended.<br>.
4170: 0a 41 20 72 65 73 75 6c 74 20 64 69 66 66 65 72  .A result differ
4180: 65 6e 74 20 66 72 6f 6d 20 5a 45 52 4f 20 69 6d  ent from ZERO im
4190: 70 6c 69 65 73 20 74 68 61 74 20 73 6f 6d 65 20  plies that some 
41a0: 6d 61 6c 69 63 69 6f 75 73 20 54 72 69 67 67 65  malicious Trigge
41b0: 72 20 68 61 73 20 62 65 65 6e 20 69 64 65 6e 74  r has been ident
41c0: 69 66 69 65 64 3b 20 69 6e 20 74 68 69 73 20 63  ified; in this c
41d0: 61 73 65 20 79 6f 75 20 63 61 6e 20 70 65 72 66  ase you can perf
41e0: 6f 72 6d 20 61 20 64 65 65 70 65 73 74 20 69 6e  orm a deepest in
41f0: 73 70 65 63 74 69 6f 6e 20 62 79 20 65 78 65 63  spection by exec
4200: 75 74 69 6e 67 20 74 68 65 20 66 6f 6c 6c 6f 77  uting the follow
4210: 69 6e 67 20 53 51 4c 20 71 75 65 72 79 3a 0d 0a  ing SQL query:..
4220: 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45  <verbatim>..SELE
4230: 43 54 20 74 79 70 65 2c 20 6e 61 6d 65 2c 20 74  CT type, name, t
4240: 62 6c 5f 6e 61 6d 65 2c 20 73 71 6c 20 0d 0a 46  bl_name, sql ..F
4250: 52 4f 4d 20 73 71 6c 69 74 65 5f 6d 61 73 74 65  ROM sqlite_maste
4260: 72 20 0d 0a 57 48 45 52 45 20 74 79 70 65 20 49  r ..WHERE type I
4270: 4e 20 28 27 74 72 69 67 67 65 72 27 2c 20 27 76  N ('trigger', 'v
4280: 69 65 77 27 29 20 41 4e 44 20 28 73 71 6c 20 4c  iew') AND (sql L
4290: 49 4b 45 20 27 25 42 6c 6f 62 46 72 6f 6d 46 69  IKE '%BlobFromFi
42a0: 6c 65 25 27 20 0d 0a 20 20 20 4f 52 20 73 71 6c  le%' ..   OR sql
42b0: 20 4c 49 4b 45 20 27 25 42 6c 6f 62 54 6f 46 69   LIKE '%BlobToFi
42c0: 6c 65 25 27 20 4f 52 20 73 71 6c 20 4c 49 4b 45  le%' OR sql LIKE
42d0: 20 27 25 58 42 5f 4c 6f 61 64 58 4d 4c 25 27 20   '%XB_LoadXML%' 
42e0: 0d 0a 20 20 20 4f 52 20 73 71 6c 20 4c 49 4b 45  ..   OR sql LIKE
42f0: 20 27 25 58 42 5f 53 74 6f 72 65 58 4d 4c 25 27   '%XB_StoreXML%'
4300: 29 3b 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d  );..</verbatim>.
4310: 0a 74 68 69 73 20 77 69 6c 6c 20 67 69 76 65 20  .this will give 
4320: 61 20 66 75 6c 6c 20 72 65 70 6f 72 74 20 66 6f  a full report fo
4330: 72 20 61 6e 79 20 6d 61 6c 69 63 69 6f 75 73 20  r any malicious 
4340: 54 72 69 67 67 65 72 20 65 76 65 6e 74 75 61 6c  Trigger eventual
4350: 6c 79 20 66 6f 75 6e 64 2e 3c 62 72 3e 3c 62 72  ly found.<br><br
4360: 3e 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72 62 61 74  >..<hr>..<verbat
4370: 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 42 6c 6f 62  im>..SELECT Blob
4380: 46 72 6f 6d 46 69 6c 65 28 20 27 43 3a 2f 6d 79  FromFile( 'C:/my
4390: 70 69 63 74 75 72 65 73 2f 73 75 6e 73 65 74 2e  pictures/sunset.
43a0: 6a 70 67 27 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d  jpg' );..-------
43b0: 2d 2d 0d 0a 42 4c 4f 42 2d 76 61 6c 75 65 0d 0a  --..BLOB-value..
43c0: 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 54 68 65  </verbatim>..The
43d0: 20 3c 62 3e 42 6c 6f 62 46 72 6f 6d 46 69 6c 65   <b>BlobFromFile
43e0: 28 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74  ()</b> SQL funct
43f0: 69 6f 6e 20 61 6c 6c 6f 77 73 20 74 6f 20 69 6d  ion allows to im
4400: 70 6f 72 74 20 61 20 77 68 6f 6c 65 20 66 69 6c  port a whole fil
4410: 65 20 69 6e 20 61 20 73 69 6e 67 6c 65 20 73 74  e in a single st
4420: 65 70 3b 20 74 68 65 20 66 75 6c 6c 20 66 69 6c  ep; the full fil
4430: 65 20 70 61 79 6c 6f 61 64 20 77 69 6c 6c 20 62  e payload will b
4440: 65 20 72 65 74 75 72 6e 65 64 20 61 73 20 61 20  e returned as a 
4450: 42 4c 4f 42 20 76 61 6c 75 65 2e 3c 62 72 3e 0d  BLOB value.<br>.
4460: 0a 49 66 20 74 68 65 20 61 72 67 75 6d 65 6e 74  .If the argument
4470: 20 28 3c 62 3e 66 69 6c 65 2d 70 61 74 68 3c 2f   (<b>file-path</
4480: 62 3e 29 20 64 6f 65 73 6e 27 74 20 63 6f 72 72  b>) doesn't corr
4490: 65 73 70 6f 6e 64 73 20 74 6f 20 61 20 76 61 6c  esponds to a val
44a0: 69 64 20 66 69 6c 65 20 6f 72 20 69 66 20 74 68  id file or if th
44b0: 65 20 65 78 74 65 72 6e 61 6c 20 66 69 6c 65 20  e external file 
44c0: 63 61 6e 6e 6f 74 20 62 65 20 61 63 63 65 73 73  cannot be access
44d0: 65 64 20 66 6f 72 20 61 6e 79 20 72 65 61 73 6f  ed for any reaso
44e0: 6e 20 4e 55 4c 4c 20 77 69 6c 6c 20 62 65 20 72  n NULL will be r
44f0: 65 74 75 72 6e 65 64 2e 3c 62 72 3e 3c 62 72 3e  eturned.<br><br>
4500: 0d 0a 3c 68 72 3e 0d 0a 3c 76 65 72 62 61 74 69  ..<hr>..<verbati
4510: 6d 3e 0d 0a 53 45 4c 45 43 54 20 42 6c 6f 62 54  m>..SELECT BlobT
4520: 6f 46 69 6c 65 28 20 73 6f 6d 65 42 6c 6f 62 20  oFile( someBlob 
4530: 2c 20 27 43 3a 2f 6d 79 70 69 63 74 75 72 65 73  , 'C:/mypictures
4540: 2f 73 75 6e 73 65 74 2e 6a 70 67 27 20 29 3b 0d  /sunset.jpg' );.
4550: 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 31 0d 0a 3c  .---------..1..<
4560: 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 54 68 65 20  /verbatim>..The 
4570: 3c 62 3e 42 6c 6f 62 54 6f 46 69 6c 65 28 29 3c  <b>BlobToFile()<
4580: 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e  /b> SQL function
4590: 20 70 65 72 66 6f 72 6d 73 20 74 68 65 20 6f 70   performs the op
45a0: 70 6f 73 69 74 65 20 74 61 73 6b 2c 20 69 2e 65  posite task, i.e
45b0: 2e 20 69 74 20 65 78 70 6f 72 74 73 20 61 20 77  . it exports a w
45c0: 68 6f 6c 65 20 42 4c 4f 42 20 69 6e 74 6f 20 61  hole BLOB into a
45d0: 6e 20 65 78 74 65 72 6e 61 6c 20 66 69 6c 65 3b  n external file;
45e0: 20 74 68 65 20 66 69 72 73 74 20 61 72 67 75 6d   the first argum
45f0: 65 6e 74 20 6d 75 73 74 20 63 6f 72 72 65 73 70  ent must corresp
4600: 6f 6e 64 20 74 6f 20 73 6f 6d 65 20 42 4c 4f 42  ond to some BLOB
4610: 2c 20 74 68 65 20 73 65 63 6f 6e 64 20 6f 6e 65  , the second one
4620: 20 69 73 20 74 68 65 20 3c 62 3e 66 69 6c 65 2d   is the <b>file-
4630: 70 61 74 68 3c 2f 62 3e 20 69 64 65 6e 74 69 66  path</b> identif
4640: 79 69 6e 67 20 74 68 65 20 66 69 6c 65 20 74 6f  ying the file to
4650: 20 62 65 20 63 72 65 61 74 65 64 20 6f 72 20 6f   be created or o
4660: 76 65 72 77 72 69 74 74 65 6e 2e 3c 62 72 3e 3c  verwritten.<br><
4670: 62 72 3e 0d 0a 3c 75 3e 50 6c 65 61 73 65 20 6e  br>..<u>Please n
4680: 6f 74 65 3c 2f 75 3e 3a 20 62 6f 74 68 20 3c 62  ote</u>: both <b
4690: 3e 42 6c 6f 62 46 72 6f 6d 46 69 6c 65 28 29 3c  >BlobFromFile()<
46a0: 2f 62 3e 20 61 6e 64 20 3c 62 3e 42 6c 6f 62 54  /b> and <b>BlobT
46b0: 6f 46 69 6c 65 28 29 3c 2f 62 3e 20 77 65 72 65  oFile()</b> were
46c0: 20 61 6c 72 65 61 64 79 20 73 75 70 70 6f 72 74   already support
46d0: 65 64 20 62 79 20 34 2e 30 2e 30 2c 20 62 75 74  ed by 4.0.0, but
46e0: 20 61 20 71 75 69 63 6b 20 72 65 63 61 6c 6c 20   a quick recall 
46f0: 69 73 20 61 6e 79 77 61 79 20 75 73 65 66 75 6c  is anyway useful
4700: 20 73 6f 20 74 6f 20 72 65 63 61 6c 6c 20 61 20   so to recall a 
4710: 63 6c 65 61 72 65 72 20 63 6f 6e 74 65 78 74 2e  clearer context.
4720: 3c 62 72 3e 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a  <br><br>..<hr>..
4730: 3c 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45  <verbatim>..SELE
4740: 43 54 20 58 42 5f 4c 6f 61 64 58 4d 4c 28 20 27  CT XB_LoadXML( '
4750: 43 3a 2f 6d 79 64 6f 63 73 2f 69 73 6f 6d 65 74  C:/mydocs/isomet
4760: 61 64 61 74 61 2d 73 61 6d 70 6c 65 2e 78 6d 6c  adata-sample.xml
4770: 27 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a  ' );..--------..
4780: 42 4c 4f 42 2d 76 61 6c 75 65 0d 0a 0d 0a 53 45  BLOB-value....SE
4790: 4c 45 43 54 20 58 42 5f 4c 6f 61 64 58 4d 4c 28  LECT XB_LoadXML(
47a0: 20 27 68 74 74 70 3a 2f 2f 77 77 77 2e 61 63 6d   'http://www.acm
47b0: 65 2e 63 6f 6d 2f 70 75 62 6c 69 63 2f 69 73 6f  e.com/public/iso
47c0: 6d 65 74 61 64 61 74 61 2d 73 61 6d 70 6c 65 2e  metadata-sample.
47d0: 78 6d 6c 27 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d  xml' );..-------
47e0: 2d 0d 0a 42 4c 4f 42 2d 76 61 6c 75 65 0d 0a 3c  -..BLOB-value..<
47f0: 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 54 68 65 20  /verbatim>..The 
4800: 3c 62 3e 58 42 5f 4c 6f 61 64 58 4d 4c 28 29 3c  <b>XB_LoadXML()<
4810: 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e  /b> SQL function
4820: 20 61 6c 6c 6f 77 73 20 74 6f 20 69 6d 70 6f 72   allows to impor
4830: 74 20 61 6e 20 58 4d 4c 20 44 6f 63 75 6d 65 6e  t an XML Documen
4840: 74 20 69 6e 20 61 20 73 69 6e 67 6c 65 20 73 74  t in a single st
4850: 65 70 3a 20 74 68 65 20 66 75 6c 6c 20 58 4d 4c  ep: the full XML
4860: 20 44 6f 63 75 6d 65 6e 74 20 70 61 79 6c 6f 61   Document payloa
4870: 64 20 77 69 6c 6c 20 62 65 20 72 65 74 75 72 6e  d will be return
4880: 65 64 20 61 73 20 61 20 42 4c 4f 42 20 76 61 6c  ed as a BLOB val
4890: 75 65 2e 3c 62 72 3e 0d 0a 54 68 65 20 70 61 73  ue.<br>..The pas
48a0: 73 65 64 20 61 72 67 75 6d 65 6e 74 20 63 61 6e  sed argument can
48b0: 20 69 6e 64 69 66 66 65 72 65 6e 74 6c 79 20 62   indifferently b
48c0: 65 20 61 20 3c 62 3e 66 69 6c 65 2d 70 61 74 68  e a <b>file-path
48d0: 3c 2f 62 3e 20 6f 72 20 61 20 3c 62 3e 55 52 4c  </b> or a <b>URL
48e0: 3c 2f 62 3e 3b 20 69 66 20 74 68 65 20 64 61 74  </b>; if the dat
48f0: 61 73 6f 75 72 63 65 20 63 61 6e 6e 6f 74 20 62  asource cannot b
4900: 65 20 61 63 63 65 73 73 65 64 2c 20 6f 72 20 69  e accessed, or i
4910: 66 20 69 74 20 64 6f 65 73 6e 27 74 20 63 6f 6e  f it doesn't con
4920: 74 61 69 6e 73 20 61 20 3c 75 3e 77 65 6c 6c 2d  tains a <u>well-
4930: 66 6f 72 6d 65 64 3c 2f 75 3e 20 58 4d 4c 20 44  formed</u> XML D
4940: 6f 63 75 6d 65 6e 74 20 4e 55 4c 4c 20 77 69 6c  ocument NULL wil
4950: 6c 20 62 65 20 72 65 74 75 72 6e 65 64 2e 3c 62  l be returned.<b
4960: 72 3e 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c 76  r><br>..<hr>..<v
4970: 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54  erbatim>..SELECT
4980: 20 58 42 5f 53 74 6f 72 65 58 4d 4c 28 20 73 6f   XB_StoreXML( so
4990: 6d 65 58 6d 6c 42 6c 6f 62 2c 20 27 43 3a 2f 6d  meXmlBlob, 'C:/m
49a0: 79 64 6f 63 73 2f 69 73 6f 6d 65 74 61 64 61 74  ydocs/isometadat
49b0: 61 2d 73 61 6d 70 6c 65 2e 78 6d 6c 27 20 29 3b  a-sample.xml' );
49c0: 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 31 0d 0a  ..---------..1..
49d0: 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 54 68 65  </verbatim>..The
49e0: 20 3c 62 3e 58 42 5f 53 74 6f 72 65 58 4d 4c 28   <b>XB_StoreXML(
49f0: 29 3c 2f 62 3e 20 53 51 4c 20 66 75 6e 63 74 69  )</b> SQL functi
4a00: 6f 6e 20 70 65 72 66 6f 72 6d 73 20 74 68 65 20  on performs the 
4a10: 6f 70 70 6f 73 69 74 65 20 74 61 73 6b 2c 20 69  opposite task, i
4a20: 2e 65 2e 20 69 74 20 65 78 70 6f 72 74 73 20 61  .e. it exports a
4a30: 20 77 68 6f 6c 65 20 58 6d 6c 42 4c 4f 42 20 69   whole XmlBLOB i
4a40: 6e 74 6f 20 61 6e 20 65 78 74 65 72 6e 61 6c 20  nto an external 
4a50: 66 69 6c 65 20 61 73 20 61 6e 20 58 4d 4c 20 44  file as an XML D
4a60: 6f 63 75 6d 65 6e 74 3b 20 74 68 65 20 66 69 72  ocument; the fir
4a70: 73 74 20 61 72 67 75 6d 65 6e 74 20 6d 75 73 74  st argument must
4a80: 20 63 6f 72 72 65 73 70 6f 6e 64 20 74 6f 20 73   correspond to s
4a90: 6f 6d 65 20 76 61 6c 69 64 20 58 6d 6c 42 4c 4f  ome valid XmlBLO
4aa0: 42 2c 20 74 68 65 20 73 65 63 6f 6e 64 20 6f 6e  B, the second on
4ab0: 65 20 69 73 20 74 68 65 20 3c 62 3e 66 69 6c 65  e is the <b>file
4ac0: 2d 70 61 74 68 3c 2f 62 3e 20 69 64 65 6e 74 69  -path</b> identi
4ad0: 66 79 69 6e 67 20 74 68 65 20 66 69 6c 65 20 74  fying the file t
4ae0: 6f 20 62 65 20 63 72 65 61 74 65 64 20 6f 72 20  o be created or 
4af0: 6f 76 65 72 77 72 69 74 74 65 6e 2e 20 0d 0a 3c  overwritten. ..<
4b00: 76 65 72 62 61 74 69 6d 3e 0d 0a 53 45 4c 45 43  verbatim>..SELEC
4b10: 54 20 58 42 5f 53 74 6f 72 65 58 4d 4c 28 20 73  T XB_StoreXML( s
4b20: 6f 6d 65 58 6d 6c 42 6c 6f 62 2c 20 27 43 3a 2f  omeXmlBlob, 'C:/
4b30: 6d 79 64 6f 63 73 2f 69 73 6f 6d 65 74 61 64 61  mydocs/isometada
4b40: 74 61 2d 73 61 6d 70 6c 65 2e 78 6d 6c 27 2c 20  ta-sample.xml', 
4b50: 34 20 29 3b 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d  4 );..---------.
4b60: 0a 31 0d 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d  .1..</verbatim>.
4b70: 0a 41 20 66 75 72 74 68 65 72 20 6f 70 74 69 6f  .A further optio
4b80: 6e 61 6c 20 3c 62 3e 69 6e 64 65 6e 74 61 74 69  nal <b>indentati
4b90: 6f 6e 3c 2f 62 3e 20 61 72 67 75 6d 65 6e 74 20  on</b> argument 
4ba0: 63 61 6e 20 62 65 20 65 76 65 6e 74 75 61 6c 6c  can be eventuall
4bb0: 79 20 73 70 65 63 69 66 69 65 64 3b 20 74 68 69  y specified; thi
4bc0: 73 20 61 72 67 75 6d 65 6e 74 20 77 69 6c 6c 20  s argument will 
4bd0: 62 65 20 68 61 6e 64 6c 65 64 20 65 78 61 63 74  be handled exact
4be0: 6c 79 20 69 6e 20 74 68 65 20 73 61 6d 65 20 77  ly in the same w
4bf0: 61 79 20 61 6c 72 65 61 64 79 20 73 70 65 63 69  ay already speci
4c00: 66 69 65 64 20 66 6f 72 20 62 6f 74 68 20 3c 62  fied for both <b
4c10: 3e 58 42 5f 47 65 74 50 61 79 6c 6f 61 64 28 29  >XB_GetPayload()
4c20: 3c 2f 62 3e 20 61 6e 64 20 3c 62 3e 58 42 5f 47  </b> and <b>XB_G
4c30: 65 74 44 6f 63 75 6d 65 6e 74 28 29 3c 2f 62 3e  etDocument()</b>
4c40: 20 66 75 6e 63 74 69 6f 6e 73 2e 3c 62 72 3e 3c   functions.<br><
4c50: 62 72 3e 0d 0a 3c 68 72 3e 3c 62 72 3e 0d 0a 62  br>..<hr><br>..b
4c60: 61 63 6b 20 74 6f 20 3c 61 20 68 72 65 66 3d 22  ack to <a href="
4c70: 68 74 74 70 73 3a 2f 2f 77 77 77 2e 67 61 69 61  https://www.gaia
4c80: 2d 67 69 73 2e 69 74 2f 66 6f 73 73 69 6c 2f 6c  -gis.it/fossil/l
4c90: 69 62 73 70 61 74 69 61 6c 69 74 65 2f 77 69 6b  ibspatialite/wik
4ca0: 69 3f 6e 61 6d 65 3d 34 2e 31 2e 30 2d 64 6f 63  i?name=4.1.0-doc
4cb0: 22 3e 34 2e 31 2e 30 2d 64 6f 63 3c 2f 61 3e 0a  ">4.1.0-doc</a>.
4cc0: 5a 20 32 61 30 39 37 37 38 61 37 32 63 62 61 64  Z 2a09778a72cbad
4cd0: 64 66 31 31 32 39 61 62 33 31 36 37 38 36 64 31  df1129ab316786d1
4ce0: 63 34 0a                                         c4.