Hex Artifact Content
Not logged in

Artifact 819fa85dc3aac249ed93e2effb2a1550be0d2839:

Wiki page [mod_spatialite] by sandro 2014-06-25 17:03:02.
0000: 44 20 32 30 31 34 2d 30 36 2d 32 35 54 31 37 3a  D 2014-06-25T17:
0010: 30 33 3a 30 32 2e 35 39 37 0a 4c 20 6d 6f 64 5f  03:02.597.L mod_
0020: 73 70 61 74 69 61 6c 69 74 65 0a 55 20 73 61 6e  spatialite.U san
0030: 64 72 6f 0a 57 20 35 33 30 38 0a 62 61 63 6b 20  dro.W 5308.back 
0040: 74 6f 20 3c 61 20 68 72 65 66 3d 22 68 74 74 70  to <a href="http
0050: 73 3a 2f 2f 77 77 77 2e 67 61 69 61 2d 67 69 73  s://www.gaia-gis
0060: 2e 69 74 2f 66 6f 73 73 69 6c 2f 6c 69 62 73 70  .it/fossil/libsp
0070: 61 74 69 61 6c 69 74 65 2f 77 69 6b 69 3f 6e 61  atialite/wiki?na
0080: 6d 65 3d 34 2e 32 2e 30 2d 64 6f 63 22 3e 34 2e  me=4.2.0-doc">4.
0090: 32 2e 30 2d 64 6f 63 3c 2f 61 3e 0d 0a 3c 68 31  2.0-doc</a>..<h1
00a0: 3e 44 79 6e 61 6d 69 63 61 6c 6c 79 20 6c 6f 61  >Dynamically loa
00b0: 64 69 6e 67 20 53 70 61 74 69 61 4c 69 74 65 20  ding SpatiaLite 
00c0: 61 73 20 61 6e 20 3c 75 3e 3c 69 3e 65 78 74 65  as an <u><i>exte
00d0: 6e 73 69 6f 6e 20 6d 6f 64 75 6c 65 3c 2f 69 3e  nsion module</i>
00e0: 3c 2f 75 3e 3c 2f 68 31 3e 0d 0a 3c 68 33 3e 54  </u></h1>..<h3>T
00f0: 68 65 6f 72 65 74 69 63 61 6c 20 66 6f 75 6e 64  heoretical found
0100: 61 74 69 6f 6e 73 3c 2f 68 33 3e 0d 0a 53 70 65  ations</h3>..Spe
0110: 61 63 6b 69 6e 67 20 69 6e 20 72 69 67 6f 72 6f  acking in rigoro
0120: 75 73 20 74 65 63 68 6e 69 63 61 6c 20 74 65 72  us technical ter
0130: 6d 73 2c 20 53 70 61 74 69 61 4c 69 74 65 20 73  ms, SpatiaLite s
0140: 69 6d 70 6c 79 20 69 73 20 61 6e 20 65 78 74 65  imply is an exte
0150: 6e 73 69 6f 6e 20 74 6f 20 53 51 4c 69 74 65 2e  nsion to SQLite.
0160: 3c 62 72 3e 0d 0a 43 6f 6e 73 65 71 75 65 6e 74  <br>..Consequent
0170: 6c 79 20 77 65 20 61 72 65 20 73 74 72 69 63 74  ly we are strict
0180: 6c 79 20 72 65 71 75 69 72 65 64 20 74 6f 20 64  ly required to d
0190: 65 70 6c 6f 79 20 73 6f 6d 65 20 61 70 70 72 6f  eploy some appro
01a0: 70 72 69 61 74 65 20 6d 65 63 68 61 6e 69 73 6d  priate mechanism
01b0: 20 61 6c 6c 6f 77 69 6e 67 20 74 6f 20 6c 6f 61   allowing to loa
01c0: 64 20 62 6f 74 68 20 62 69 6e 61 72 79 20 6c 69  d both binary li
01d0: 62 72 61 72 69 65 73 20 28 3c 69 3e 6c 69 62 73  braries (<i>libs
01e0: 71 6c 69 74 65 33 3c 2f 69 3e 20 61 6e 64 20 3c  qlite3</i> and <
01f0: 69 3e 6c 69 62 73 70 61 74 69 61 6c 69 74 65 3c  i>libspatialite<
0200: 2f 69 3e 29 20 61 6e 64 20 70 72 6f 70 65 72 6c  /i>) and properl
0210: 79 20 72 65 67 69 73 74 65 72 69 6e 67 20 77 69  y registering wi
0220: 74 68 69 6e 20 53 51 4c 69 74 65 33 20 74 68 65  thin SQLite3 the
0230: 20 6d 61 6e 79 20 3c 62 3e 3c 69 3e 65 78 74 65   many <b><i>exte
0240: 6e 64 65 64 20 53 70 61 74 69 61 6c 20 53 51 4c  nded Spatial SQL
0250: 20 66 75 6e 63 74 69 6f 6e 73 3c 2f 69 3e 3c 2f   functions</i></
0260: 62 3e 20 69 6d 70 6c 65 6d 65 6e 74 65 64 20 62  b> implemented b
0270: 79 20 53 70 61 74 69 61 4c 69 74 65 2e 3c 62 72  y SpatiaLite.<br
0280: 3e 0d 0a 41 20 66 75 72 74 68 65 72 20 63 6f 6d  >..A further com
0290: 70 69 63 61 74 69 6f 6e 20 73 68 6f 75 6c 64 20  pication should 
02a0: 62 65 20 74 61 6b 65 6e 20 69 6e 20 70 72 6f 70  be taken in prop
02b0: 65 72 20 64 65 62 74 3b 20 3c 69 3e 6c 69 62 73  er debt; <i>libs
02c0: 70 61 74 69 61 6c 69 74 65 3c 2f 69 3e 20 69 73  patialite</i> is
02d0: 6e 27 74 20 61 20 73 74 61 6e 64 2d 61 6c 6f 6e  n't a stand-alon
02e0: 65 20 73 65 6c 66 2d 63 6f 6e 74 61 69 6e 65 64  e self-contained
02f0: 20 6c 69 62 72 61 72 79 2c 20 61 6e 64 20 64 65   library, and de
0300: 70 65 6e 64 73 20 6f 6e 20 73 65 76 65 72 61 6c  pends on several
0310: 20 66 75 72 74 68 65 72 20 6c 69 62 72 61 72 69   further librari
0320: 65 73 20 28 3c 69 3e 6c 69 62 67 65 6f 73 3c 2f  es (<i>libgeos</
0330: 69 3e 2c 20 3c 69 3e 6c 69 62 70 72 6f 6a 3c 2f  i>, <i>libproj</
0340: 69 3e 2c 20 3c 69 3e 6c 69 62 78 6d 6c 32 3c 2f  i>, <i>libxml2</
0350: 69 3e 20 61 6e 64 20 73 6f 20 6f 6e 29 2e 3c 62  i> and so on).<b
0360: 72 3e 3c 62 72 3e 0d 0a 54 68 65 72 65 20 61 72  r><br>..There ar
0370: 65 20 73 65 76 65 72 61 6c 20 70 6f 73 73 69 62  e several possib
0380: 6c 65 20 61 6c 74 65 72 6e 61 74 69 76 65 20 70  le alternative p
0390: 61 74 68 73 20 6c 65 61 64 69 6e 67 20 74 6f 20  aths leading to 
03a0: 74 68 69 73 20 66 69 6e 61 6c 20 67 6f 61 6c 3a  this final goal:
03b0: 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 75 73 69 6e  ..<ul>..<li>usin
03c0: 67 20 3c 62 3e 3c 69 3e 73 74 61 74 69 63 20 6c  g <b><i>static l
03d0: 69 6e 6b 61 67 65 3c 2f 69 3e 3c 2f 62 3e 3a 20  inkage</i></b>: 
03e0: 61 20 73 74 72 61 69 67 68 66 6f 72 77 61 72 64  a straighforward
03f0: 20 73 6f 6c 75 74 69 6f 6e 20 61 76 6f 69 64 69   solution avoidi
0400: 6e 67 20 6d 61 6e 79 20 73 75 62 73 65 71 75 65  ng many subseque
0410: 6e 74 20 68 65 61 64 68 61 63 68 65 73 20 72 65  nt headhaches re
0420: 6c 61 74 65 64 20 74 6f 20 69 6e 73 74 61 6c 6c  lated to install
0430: 61 74 69 6f 6e 20 61 6e 64 20 72 75 6e 2d 74 69  ation and run-ti
0440: 6d 65 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e  me configuration
0450: 2e 3c 62 72 3e 0d 0a 46 6f 6c 6c 6f 77 69 6e 67  .<br>..Following
0460: 20 74 68 69 73 20 61 70 70 72 6f 61 63 68 20 61   this approach a
0470: 20 73 69 6e 67 6c 65 20 6d 6f 6e 6f 6c 69 74 68   single monolith
0480: 69 63 20 3c 62 3e 3c 69 3e 66 61 74 3c 2f 69 3e  ic <b><i>fat</i>
0490: 3c 2f 62 3e 20 65 78 65 63 75 74 61 62 6c 65 20  </b> executable 
04a0: 69 6e 74 65 72 6e 61 6c 6c 79 20 63 6f 6e 74 61  internally conta
04b0: 69 6e 69 6e 67 20 61 6c 6c 20 72 65 71 75 69 72  ining all requir
04c0: 65 64 20 62 69 6e 61 72 79 20 63 6f 64 65 20 77  ed binary code w
04d0: 69 6c 6c 20 62 65 20 63 72 65 61 74 65 64 20 61  ill be created a
04e0: 74 20 62 75 69 6c 64 20 74 69 6d 65 3b 20 74 68  t build time; th
04f0: 69 73 20 6d 6f 6e 6f 6c 69 74 68 69 63 20 65 78  is monolithic ex
0500: 65 63 75 74 61 62 6c 65 20 77 69 6c 6c 20 68 61  ecutable will ha
0510: 76 65 20 6e 6f 20 65 78 74 65 72 6e 61 6c 20 64  ve no external d
0520: 65 70 65 6e 64 65 6e 63 69 65 73 20 61 74 20 61  ependencies at a
0530: 6c 6c 2c 20 74 68 75 73 20 72 61 64 69 63 61 6c  ll, thus radical
0540: 6c 79 20 73 69 6d 70 6c 69 66 79 69 6e 67 20 61  ly simplifying a
0550: 6e 79 20 69 6e 73 74 61 6c 6c 61 74 69 6f 6e 20  ny installation 
0560: 74 61 73 6b 2e 3c 62 72 3e 0d 0a 53 75 63 68 20  task.<br>..Such 
0570: 73 74 72 61 74 65 67 79 20 6e 69 63 65 6c 79 20  strategy nicely 
0580: 77 6f 72 6b 73 20 69 6e 20 74 68 65 20 63 61 73  works in the cas
0590: 65 20 6f 66 20 73 74 61 6e 64 2d 61 6c 6f 6e 65  e of stand-alone
05a0: 20 73 65 6c 66 2d 63 6f 6e 74 61 69 6e 65 64 20   self-contained 
05b0: 61 70 70 73 20 28 65 2e 67 2e 20 62 6f 74 68 20  apps (e.g. both 
05c0: 3c 62 3e 73 70 61 74 69 61 6c 69 74 65 2e 65 78  <b>spatialite.ex
05d0: 65 3c 2f 62 3e 20 61 6e 64 20 3c 62 3e 73 70 61  e</b> and <b>spa
05e0: 74 69 61 6c 69 74 65 5f 67 75 69 2e 65 78 65 3c  tialite_gui.exe<
05f0: 2f 62 3e 20 57 69 6e 64 6f 77 73 20 62 69 6e 61  /b> Windows bina
0600: 72 69 65 73 20 61 72 65 20 75 73 75 61 6c 6c 79  ries are usually
0610: 20 62 75 69 6c 74 20 74 68 69 73 20 77 61 79 29   built this way)
0620: 2e 3c 62 72 3e 0d 0a 55 6e 68 61 70 70 69 6c 79  .<br>..Unhappily
0630: 20 74 68 69 73 20 65 6c 65 6d 65 6e 74 61 72 79   this elementary
0640: 20 73 69 6d 70 6c 65 20 73 6f 6c 75 74 69 6f 6e   simple solution
0650: 20 64 6f 65 73 6e 27 74 20 66 69 74 20 77 65 6c   doesn't fit wel
0660: 6c 20 69 6e 20 4c 69 6e 75 78 20 61 6e 64 20 55  l in Linux and U
0670: 6e 69 78 2d 6c 69 6b 65 20 65 6e 76 69 72 6f 6e  nix-like environ
0680: 6d 65 6e 74 73 3b 20 61 6e 64 20 65 76 65 6e 20  ments; and even 
0690: 77 6f 72 73 74 20 6f 66 74 65 6e 20 64 69 72 65  worst often dire
06a0: 63 74 6c 79 20 63 6f 6e 66 6c 69 63 74 73 20 77  ctly conflicts w
06b0: 69 74 68 20 74 68 65 20 69 6e 74 65 72 6e 61 6c  ith the internal
06c0: 20 61 72 63 68 69 74 65 63 74 75 72 65 20 73 75   architecture su
06d0: 70 70 6f 72 74 65 64 20 62 79 20 6d 61 6e 79 20  pported by many 
06e0: 6c 61 6e 67 75 61 67 65 20 63 6f 6e 6e 65 63 74  language connect
06f0: 6f 72 73 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 75  ors.</li>..<li>u
0700: 73 69 6e 67 20 3c 62 3e 3c 69 3e 73 68 61 72 65  sing <b><i>share
0710: 64 20 6c 69 62 72 61 72 69 65 73 3c 69 3e 3c 2f  d libraries<i></
0720: 62 3e 20 28 61 6b 61 20 3c 62 3e 3c 69 3e 44 4c  b> (aka <b><i>DL
0730: 4c 73 3c 2f 69 3e 3c 2f 62 3e 20 6f 6e 20 57 69  Ls</i></b> on Wi
0740: 6e 64 6f 77 73 29 2e 3c 62 72 3e 0d 0a 54 68 69  ndows).<br>..Thi
0750: 73 20 73 65 63 6f 6e 64 20 61 70 70 72 6f 61 63  s second approac
0760: 68 20 77 69 6c 6c 20 63 61 72 65 66 75 6c 6c 79  h will carefully
0770: 20 61 76 6f 69 64 20 74 6f 20 6c 69 6e 6b 20 61   avoid to link a
0780: 6c 6c 74 6f 67 65 74 68 65 72 20 61 20 6d 6f 6e  lltogether a mon
0790: 6f 6c 69 74 68 69 63 20 65 78 65 63 75 74 61 62  olithic executab
07a0: 6c 65 3b 20 65 61 63 68 20 73 69 6e 67 6c 65 20  le; each single 
07b0: 63 6f 64 65 20 63 6f 6d 70 6f 6e 65 6e 74 20 77  code component w
07c0: 69 6c 6c 20 62 65 20 73 68 69 70 70 65 64 20 61  ill be shipped a
07d0: 73 20 61 6e 20 61 75 74 6f 6e 6f 6d 6f 75 73 20  s an autonomous 
07e0: 69 6e 64 69 76 69 64 75 61 6c 20 6d 65 6d 62 65  individual membe
07f0: 72 2c 20 61 6e 64 20 6f 6e 6c 79 20 61 74 20 72  r, and only at r
0800: 75 6e 2d 74 69 6d 65 20 61 6c 6c 20 63 6f 6d 70  un-time all comp
0810: 6f 6e 65 6e 74 20 77 69 6c 6c 20 62 65 20 66 69  onent will be fi
0820: 6e 61 6c 6c 79 20 62 6f 75 6e 64 20 74 6f 67 65  nally bound toge
0830: 74 68 65 72 2e 3c 62 72 3e 0d 0a 54 68 65 20 67  ther.<br>..The g
0840: 6f 6f 64 20 6e 65 77 20 69 73 20 74 68 61 74 20  ood new is that 
0850: 74 68 69 73 20 77 61 79 20 65 61 63 68 20 6c 69  this way each li
0860: 62 72 61 72 79 20 77 69 6c 6c 20 62 65 20 28 68  brary will be (h
0870: 6f 70 65 66 75 6c 6c 79 29 20 69 6e 73 74 61 6c  opefully) instal
0880: 6c 65 64 20 6f 6e 6c 79 20 6f 6e 63 65 20 6f 6e  led only once on
0890: 20 79 6f 75 72 20 73 79 73 74 65 6d 2c 20 61 6e   your system, an
08a0: 64 20 74 68 61 74 20 65 76 65 72 79 20 65 78 65  d that every exe
08b0: 63 75 74 61 62 6c 65 20 64 65 70 65 6e 64 69 6e  cutable dependin
08c0: 67 20 6f 6e 20 74 68 61 74 20 6c 69 62 72 61 72  g on that librar
08d0: 79 20 77 69 6c 6c 20 6c 6f 61 64 20 65 78 61 63  y will load exac
08e0: 74 6c 79 20 74 68 65 20 73 61 6d 65 20 62 69 6e  tly the same bin
08f0: 61 72 79 20 63 6f 64 65 2c 20 74 68 75 73 20 67  ary code, thus g
0900: 72 61 6e 74 69 6e 67 20 61 20 72 6f 62 75 73 74  ranting a robust
0910: 20 63 6f 6e 73 69 73 74 65 6e 63 79 2e 3c 62 72   consistency.<br
0920: 3e 0d 0a 54 68 65 20 62 61 64 20 6e 65 77 20 69  >..The bad new i
0930: 73 20 69 6e 20 74 68 61 74 20 69 66 20 61 20 73  s in that if a s
0940: 69 6e 67 6c 65 20 72 65 71 75 69 72 65 64 20 63  ingle required c
0950: 6f 6d 70 6f 6e 65 6e 74 20 63 6f 75 6c 64 6e 27  omponent couldn'
0960: 74 20 62 65 20 6c 6f 61 64 65 64 20 61 74 20 72  t be loaded at r
0970: 75 6e 2d 74 69 6d 65 20 28 66 6f 72 20 61 6e 79  un-time (for any
0980: 20 70 6f 73 73 69 62 6c 65 20 72 65 61 73 6f 6e   possible reason
0990: 29 20 74 68 65 20 65 78 65 63 75 74 61 62 6c 65  ) the executable
09a0: 20 61 73 20 61 20 77 68 6f 6c 65 20 77 69 6c 6c   as a whole will
09b0: 20 66 61 69 6c 20 74 6f 20 72 75 6e 2e 3c 62 72   fail to run.<br
09c0: 3e 0d 0a 54 6f 20 6d 61 6b 65 20 74 68 69 6e 67  >..To make thing
09d0: 73 20 65 76 65 6e 20 77 6f 72 73 74 2c 20 74 68  s even worst, th
09e0: 69 73 20 73 63 68 65 6d 61 20 77 6f 72 6b 73 20  is schema works 
09f0: 6e 69 63 65 6c 79 20 6f 6e 20 4c 69 6e 75 78 2c  nicely on Linux,
0a00: 20 55 6e 69 78 20 61 6e 64 20 4d 61 63 20 4f 53   Unix and Mac OS
0a10: 20 58 20 28 62 65 63 61 75 73 65 20 61 6c 6c 20   X (because all 
0a20: 74 68 65 73 65 20 6f 2e 73 2e 20 61 64 6f 70 74  these o.s. adopt
0a30: 73 20 73 74 72 6f 6e 67 20 72 75 6c 65 73 20 69  s strong rules i
0a40: 6e 74 65 6e 64 65 64 20 74 6f 20 65 6e 66 6f 72  ntended to enfor
0a50: 63 65 20 6f 76 65 72 61 6c 6c 20 73 79 73 74 65  ce overall syste
0a60: 6d 20 72 6f 62 75 73 74 6e 65 73 73 29 3b 20 62  m robustness); b
0a70: 75 74 20 6f 6e 20 57 69 6e 64 6f 77 73 20 69 74  ut on Windows it
0a80: 27 73 20 6e 6f 74 20 61 74 20 61 6c 6c 20 64 69  's not at all di
0a90: 66 66 69 63 75 6c 74 20 74 6f 20 63 72 65 61 74  fficult to creat
0aa0: 65 20 74 68 65 20 69 6e 66 61 6d 6f 75 73 20 3c  e the infamous <
0ab0: 62 3e 3c 69 3e 44 4c 4c 20 68 65 6c 6c 3c 2f 69  b><i>DLL hell</i
0ac0: 3e 3c 2f 62 3e 2c 20 73 69 6d 70 6c 79 20 62 65  ></b>, simply be
0ad0: 63 61 75 73 65 20 74 68 69 73 20 6f 2e 73 2e 20  cause this o.s. 
0ae0: 73 75 62 73 74 61 6e 74 69 61 6c 6c 79 20 68 61  substantially ha
0af0: 73 6e 27 74 20 73 74 72 6f 6e 67 20 72 75 6c 65  sn't strong rule
0b00: 73 20 74 6f 20 62 65 20 72 65 73 70 65 63 74 65  s to be respecte
0b10: 64 2c 20 74 68 75 73 20 76 61 6e 69 73 68 69 6e  d, thus vanishin
0b20: 67 20 61 6e 79 20 70 6f 73 73 69 62 6c 65 20 73  g any possible s
0b30: 79 73 74 65 6d 20 63 6f 6e 73 69 73 74 65 6e 63  ystem consistenc
0b40: 79 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 75 73 69  y.</li>..<li>usi
0b50: 6e 67 20 72 65 61 6c 20 3c 62 3e 3c 69 3e 64 79  ng real <b><i>dy
0b60: 6e 61 6d 69 63 20 6c 69 6e 6b 61 67 65 3c 2f 69  namic linkage</i
0b70: 3e 3c 2f 62 3e 20 28 77 68 69 63 68 20 69 73 6e  ></b> (which isn
0b80: 27 74 20 74 68 65 20 73 61 6d 65 20 6f 66 20 73  't the same of s
0b90: 69 6d 70 6c 79 20 75 73 69 6e 67 20 73 68 61 72  imply using shar
0ba0: 65 64 20 6c 69 62 72 61 72 69 65 73 29 2e 3c 62  ed libraries).<b
0bb0: 72 3e 0d 0a 46 6f 6c 6c 6f 77 69 6e 67 20 74 68  r>..Following th
0bc0: 69 73 20 74 68 69 72 64 20 61 70 70 72 6f 61 63  is third approac
0bd0: 68 20 61 6e 20 65 78 74 65 6e 73 69 6f 6e 20 6d  h an extension m
0be0: 6f 64 75 6c 65 20 63 6f 75 6c 64 20 62 65 20 73  odule could be s
0bf0: 65 6c 65 63 74 69 76 65 6c 79 20 6c 6f 61 64 65  electively loade
0c00: 64 20 6f 72 20 6e 6f 74 3b 20 69 66 20 66 6f 72  d or not; if for
0c10: 20 61 6e 79 20 72 65 61 73 6f 6e 20 74 68 65 20   any reason the 
0c20: 6d 61 69 6e 20 65 78 65 63 75 74 61 62 6c 65 20  main executable 
0c30: 66 61 69 6c 73 20 74 6f 20 6c 6f 61 64 20 61 6e  fails to load an
0c40: 20 65 76 65 6e 74 75 61 6c 20 65 78 74 65 6e 73   eventual extens
0c50: 69 6f 6e 20 6d 6f 64 75 6c 65 2c 20 69 74 20 77  ion module, it w
0c60: 69 6c 6c 20 73 74 69 6c 6c 20 63 6f 6e 74 69 6e  ill still contin
0c70: 75 65 20 74 6f 20 77 6f 72 6b 20 28 6f 62 76 69  ue to work (obvi
0c80: 6f 75 73 6c 79 20 6d 69 73 73 69 6e 67 20 74 6f  ously missing to
0c90: 20 73 75 70 70 6f 72 74 20 74 68 65 20 66 61 69   support the fai
0ca0: 6c 69 6e 67 20 65 78 74 65 6e 73 69 6f 6e 29 2e  ling extension).
0cb0: 3c 62 72 3e 0d 0a 48 61 70 70 69 6c 79 20 65 6e  <br>..Happily en
0cc0: 6f 75 67 68 20 53 51 4c 69 74 65 33 20 66 75 6c  ough SQLite3 ful
0cd0: 6c 79 20 73 75 70 70 6f 72 74 73 20 74 68 69 73  ly supports this
0ce0: 20 74 68 69 72 64 20 6d 6f 72 65 20 73 6f 70 68   third more soph
0cf0: 69 73 74 69 63 61 74 65 64 20 6d 65 63 68 61 6e  isticated mechan
0d00: 69 73 6d 3b 20 61 6e 64 20 74 68 69 73 20 6f 70  ism; and this op
0d10: 74 69 6f 6e 20 69 73 20 77 69 64 65 6c 79 20 73  tion is widely s
0d20: 75 70 70 6f 72 74 65 64 20 62 79 20 6d 61 6e 79  upported by many
0d30: 20 6c 61 6e 67 75 61 67 65 20 63 6f 6e 6e 65 63   language connec
0d40: 74 6f 72 73 2e 3c 2f 6c 69 3e 0d 0a 3c 2f 6c 69  tors.</li>..</li
0d50: 3e 0d 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d 0a 3c 68  >..</ul><br>..<h
0d60: 33 3e 48 6f 77 20 69 74 20 77 6f 72 6b 73 3c 2f  3>How it works</
0d70: 68 33 3e 0d 0a 3c 69 3e 6c 69 62 73 71 6c 69 74  h3>..<i>libsqlit
0d80: 65 33 3c 2f 69 3e 20 68 61 73 20 74 68 65 20 63  e3</i> has the c
0d90: 61 70 61 62 69 6c 69 74 79 20 74 6f 20 64 79 6e  apability to dyn
0da0: 61 6d 69 63 61 6c 6c 79 20 6c 6f 61 64 20 65 78  amically load ex
0db0: 74 65 6e 73 69 6f 6e 20 6d 6f 64 75 6c 65 73 2e  tension modules.
0dc0: 20 54 68 69 73 20 66 65 61 74 75 72 65 20 69 73   This feature is
0dd0: 20 61 76 61 69 6c 61 62 6c 65 20 61 73 20 61 20   available as a 
0de0: 43 2d 6c 61 6e 67 75 61 67 65 20 41 50 49 2c 20  C-language API, 
0df0: 62 75 74 20 69 73 20 61 76 61 69 62 6c 65 73 20  but is avaibles 
0e00: 61 73 20 61 20 3c 69 3e 73 70 65 63 69 61 6c 3c  as a <i>special<
0e10: 2f 69 3e 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e  /i> SQL function
0e20: 20 61 73 20 77 65 6c 6c 3a 0d 0a 3c 76 65 72 62   as well:..<verb
0e30: 61 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 6c 6f  atim>..SELECT lo
0e40: 61 64 5f 65 78 74 65 6e 73 69 6f 6e 28 27 6d 6f  ad_extension('mo
0e50: 64 5f 73 70 61 74 69 61 6c 69 74 65 27 29 3b 0d  d_spatialite');.
0e60: 0a 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 54 68  .</verbatim>..Th
0e70: 69 73 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20  is SQL function 
0e80: 6d 61 6b 65 20 65 6c 65 6d 65 6e 74 61 72 79 20  make elementary 
0e90: 73 69 6d 70 6c 65 20 28 61 6e 64 20 6c 61 6e 67  simple (and lang
0ea0: 75 61 67 65 20 69 6e 64 65 70 65 6e 64 65 6e 74  uage independent
0eb0: 29 20 74 68 65 20 70 72 6f 62 6c 65 6d 20 6f 66  ) the problem of
0ec0: 20 6c 6f 61 64 69 6e 67 20 61 6e 79 20 70 6f 73   loading any pos
0ed0: 73 69 62 6c 65 20 65 78 74 65 6e 73 69 6f 6e 3b  sible extension;
0ee0: 20 79 6f 75 20 61 72 65 20 73 69 6d 70 6c 79 20   you are simply 
0ef0: 65 78 70 65 63 74 65 64 20 74 6f 20 65 78 65 63  expected to exec
0f00: 75 74 65 20 61 20 72 61 74 68 65 72 20 74 72 69  ute a rather tri
0f10: 76 69 61 6c 20 53 51 4c 20 73 74 61 74 65 6d 65  vial SQL stateme
0f20: 6e 74 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 6c  nt in order to l
0f30: 6f 61 64 20 61 6e 20 65 78 74 65 72 6e 61 6c 20  oad an external 
0f40: 65 78 74 65 6e 73 69 6f 6e 2e 3c 62 72 3e 3c 62  extension.<br><b
0f50: 72 3e 0d 0a 4c 6f 61 64 61 62 6c 65 20 65 78 74  r>..Loadable ext
0f60: 65 6e 73 69 6f 6e 20 61 6e 61 74 68 6f 6d 79 3a  ension anathomy:
0f70: 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69 3e 61 6e 79 20  ..<ul>..<li>any 
0f80: 53 51 4c 69 74 65 20 65 78 74 65 6e 73 69 6f 6e  SQLite extension
0f90: 20 6d 6f 64 75 6c 65 20 69 73 20 65 78 70 65 63   module is expec
0fa0: 74 65 64 20 74 6f 20 64 65 63 6c 61 72 65 20 61  ted to declare a
0fb0: 20 63 6f 6e 76 65 6e 74 69 6f 6e 61 6c 20 69 6e   conventional in
0fc0: 74 65 72 66 61 63 65 2e 3c 62 72 3e 0d 0a 45 78  terface.<br>..Ex
0fd0: 63 65 70 74 20 66 6f 72 20 74 68 69 73 2c 20 61  cept for this, a
0fe0: 6e 79 20 53 51 4c 69 74 65 27 73 20 6f 77 6e 20  ny SQLite's own 
0ff0: 65 78 74 65 6e 73 69 6f 6e 20 73 69 6d 70 6c 79  extension simply
1000: 20 69 73 20 61 6e 20 6f 72 64 69 6e 61 72 79 20   is an ordinary 
1010: 73 68 61 72 65 64 20 6c 69 62 72 61 72 79 20 6f  shared library o
1020: 72 20 44 4c 4c 20 61 73 20 61 6e 79 20 6f 74 68  r DLL as any oth
1030: 65 72 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 69 66  er.</li>..<li>if
1040: 20 73 75 63 68 20 69 6e 74 65 72 66 61 63 65 20   such interface 
1050: 69 73 6e 27 74 20 63 6f 72 72 65 63 74 6c 79 20  isn't correctly 
1060: 64 65 63 6c 61 72 65 64 20 62 79 20 74 68 65 20  declared by the 
1070: 73 68 61 72 65 64 20 6c 69 62 72 61 72 79 20 62  shared library b
1080: 65 69 6e 67 20 6c 6f 61 64 65 64 2c 20 74 68 65  eing loaded, the
1090: 6e 20 53 51 4c 69 74 65 33 20 77 69 6c 6c 20 73  n SQLite3 will s
10a0: 69 6d 70 6c 79 20 61 73 73 75 6d 65 20 74 68 61  imply assume tha
10b0: 74 20 69 74 27 73 20 6e 6f 74 20 61 20 76 61 6c  t it's not a val
10c0: 69 64 20 65 78 74 65 6e 73 69 6f 6e 20 6d 6f 64  id extension mod
10d0: 75 6c 65 2e 3c 62 72 3e 0d 0a 41 6e 64 20 63 6f  ule.<br>..And co
10e0: 6e 73 65 71 75 65 6e 74 6c 79 20 77 69 6c 6c 20  nsequently will 
10f0: 72 65 66 75 73 65 20 74 6f 20 6c 6f 61 64 20 74  refuse to load t
1100: 68 65 20 6d 6f 64 75 6c 65 20 77 69 74 68 6f 75  he module withou
1110: 74 20 61 6e 79 20 6f 74 68 65 72 20 63 6f 6e 73  t any other cons
1120: 65 71 75 65 6e 63 65 20 28 65 78 63 65 70 74 20  equence (except 
1130: 6d 61 79 20 62 65 20 70 72 69 6e 74 69 6e 67 20  may be printing 
1140: 73 6f 6d 65 20 61 70 70 72 6f 70 72 69 61 74 65  some appropriate
1150: 20 65 72 72 6f 72 20 6d 65 73 73 61 67 65 29 2e   error message).
1160: 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 61 20 6d 6f 72  </li>..<li>a mor
1170: 65 20 6f 62 76 69 6f 75 73 20 66 61 69 6c 75 72  e obvious failur
1180: 65 20 63 61 75 73 65 20 63 6f 75 6c 64 20 62 65  e cause could be
1190: 20 74 68 65 20 6f 6e 65 20 74 6f 20 61 74 74 65   the one to atte
11a0: 6d 70 74 20 6c 6f 61 64 69 6e 67 20 61 20 6e 6f  mpt loading a no
11b0: 74 20 65 78 69 73 74 69 6e 67 20 6d 6f 64 75 6c  t existing modul
11c0: 65 20 28 6f 72 20 70 6f 73 73 69 62 6c 79 2c 20  e (or possibly, 
11d0: 61 20 6d 6f 64 75 6c 65 20 77 68 6f 6d 20 61 63  a module whom ac
11e0: 74 75 61 6c 20 61 64 64 72 65 73 73 20 63 6f 75  tual address cou
11f0: 6c 64 6e 27 74 20 62 65 20 72 65 73 6f 6c 76 65  ldn't be resolve
1200: 64 20 66 6f 6c 6c 6f 77 69 6e 67 20 74 68 65 20  d following the 
1210: 73 74 61 6e 64 61 72 64 20 73 65 61 63 68 20 72  standard seach r
1220: 75 6c 65 73 29 2e 3c 2f 6c 69 3e 20 0d 0a 3c 6c  ules).</li> ..<l
1230: 69 3e 66 69 6e 61 6c 6c 79 2c 20 74 68 65 20 6d  i>finally, the m
1240: 6f 64 75 6c 65 20 63 6f 75 6c 64 20 65 66 66 65  odule could effe
1250: 63 74 69 76 65 6c 79 20 65 78 69 73 74 73 20 61  ctively exists a
1260: 6e 64 20 63 6f 75 6c 64 20 63 6f 72 72 65 63 74  nd could correct
1270: 6c 79 20 64 65 63 6c 61 72 65 20 61 20 76 61 6c  ly declare a val
1280: 69 64 20 63 6f 6e 76 65 6e 74 69 6f 6e 61 6c 20  id conventional 
1290: 69 6e 74 65 72 66 61 63 65 2e 20 41 6e 79 77 61  interface. Anywa
12a0: 79 2c 20 69 66 20 74 68 65 20 63 6f 72 72 65 73  y, if the corres
12b0: 70 6f 6e 64 69 6e 67 20 73 68 61 72 65 64 20 6c  ponding shared l
12c0: 69 62 72 61 72 79 20 68 61 73 20 66 75 72 74 68  ibrary has furth
12d0: 65 72 20 64 65 70 65 6e 64 65 63 69 65 73 20 73  er dependecies s
12e0: 6f 6d 65 20 62 72 6f 6b 65 6e 20 6c 69 6e 6b 20  ome broken link 
12f0: 63 6f 75 6c 64 20 70 6f 73 73 69 62 6c 79 20 66  could possibly f
1300: 6f 72 62 69 64 20 61 20 73 75 63 63 65 73 66 75  orbid a succesfu
1310: 6c 20 6c 6f 61 64 69 6e 67 2e 3c 2f 6c 69 3e 0d  l loading.</li>.
1320: 0a 3c 6c 69 3e 74 68 65 20 6c 61 73 74 20 68 69  .<li>the last hi
1330: 6c 6c 2d 66 61 74 65 64 20 63 6f 6d 62 69 6e 61  ll-fated combina
1340: 74 69 6f 6e 3a 20 53 51 4c 69 74 65 33 20 69 73  tion: SQLite3 is
1350: 20 61 20 73 74 72 6f 6e 67 6c 79 20 63 6f 6e 66   a strongly conf
1360: 69 67 75 72 61 62 6c 65 20 63 6f 6d 70 6f 6e 65  igurable compone
1370: 6e 74 2e 20 49 66 20 66 6f 72 20 61 6e 79 20 68  nt. If for any h
1380: 69 67 68 6c 79 20 6f 70 69 6e 61 62 6c 65 20 63  ighly opinable c
1390: 68 6f 69 63 65 20 79 6f 75 72 20 73 79 73 74 65  hoice your syste
13a0: 6d 20 70 61 63 6b 61 67 65 73 20 68 61 64 20 64  m packages had d
13b0: 65 63 69 64 65 64 20 74 6f 20 64 69 73 61 62 6c  ecided to disabl
13c0: 65 20 61 74 20 61 6c 6c 20 74 68 65 20 65 78 74  e at all the ext
13d0: 65 6e 73 69 6f 6e 20 6d 6f 64 75 6c 65 20 6d 65  ension module me
13e0: 63 68 61 6d 69 73 6d 20 79 6f 75 27 6c 6c 20 74  chamism you'll t
13f0: 68 65 6e 20 6e 65 76 65 72 20 62 65 20 61 62 6c  hen never be abl
1400: 65 20 74 6f 20 6c 6f 61 64 20 61 6e 79 20 65 78  e to load any ex
1410: 74 65 6e 73 69 6f 6e 2e 20 46 75 6c 6c 20 73 74  tension. Full st
1420: 6f 70 2e 20 28 61 6e 79 77 61 79 20 79 6f 75 27  op. (anyway you'
1430: 6c 6c 20 70 72 6f 62 61 62 6c 79 20 62 65 20 61  ll probably be a
1440: 62 6c 65 20 74 6f 20 73 77 69 74 63 68 20 74 6f  ble to switch to
1450: 20 73 6f 6d 65 20 6d 6f 72 65 20 72 65 61 73 6f   some more reaso
1460: 62 6c 65 20 2f 20 6c 65 73 73 20 70 61 72 61 6e  ble / less paran
1470: 6f 69 64 20 64 69 73 74 72 69 62 75 74 69 6f 6e  oid distribution
1480: 29 2e 0d 0a 3c 2f 75 6c 3e 0d 0a 0d 0a 3c 68 72  )...</ul>....<hr
1490: 3e 3c 62 72 3e 0d 0a 62 61 63 6b 20 74 6f 20 3c  ><br>..back to <
14a0: 61 20 68 72 65 66 3d 22 68 74 74 70 73 3a 2f 2f  a href="https://
14b0: 77 77 77 2e 67 61 69 61 2d 67 69 73 2e 69 74 2f  www.gaia-gis.it/
14c0: 66 6f 73 73 69 6c 2f 6c 69 62 73 70 61 74 69 61  fossil/libspatia
14d0: 6c 69 74 65 2f 77 69 6b 69 3f 6e 61 6d 65 3d 34  lite/wiki?name=4
14e0: 2e 32 2e 30 2d 64 6f 63 22 3e 34 2e 32 2e 30 2d  .2.0-doc">4.2.0-
14f0: 64 6f 63 3c 2f 61 3e 0a 5a 20 38 62 32 65 38 32  doc</a>.Z 8b2e82
1500: 33 30 34 38 62 38 65 63 65 64 65 32 35 33 39 38  3048b8ecede25398
1510: 37 66 65 36 30 35 30 61 64 61 0a                 7fe6050ada.