Hex Artifact Content
Not logged in

Artifact 7e78a17f6d8ab93a72a8616b9eddb2833e306fc2:

Ticket change [7e78a17f6d] - New ticket [1b33d171d1] AddGeometryColumn missing SRID trigger. by anonymous 2019-07-26 20:54:51.
0000: 44 20 32 30 31 39 2d 30 37 2d 32 36 54 32 30 3a  D 2019-07-26T20:
0010: 35 34 3a 35 31 2e 33 36 36 0a 4a 20 66 6f 75 6e  54:51.366.J foun
0020: 64 69 6e 20 34 2e 33 30 61 0a 4a 20 69 63 6f 6d  din 4.30a.J icom
0030: 6d 65 6e 74 20 54 68 65 5c 73 73 63 68 65 6d 61  ment The\sschema
0040: 5c 73 72 65 73 75 6c 74 73 5c 73 73 68 6f 75 6c  \sresults\sshoul
0050: 64 5c 73 62 65 5c 73 74 68 65 5c 73 73 61 6d 65  d\sbe\sthe\ssame
0060: 5c 73 77 68 65 6e 5c 73 75 73 69 6e 67 5c 73 41  \swhen\susing\sA
0070: 64 64 47 65 6f 6d 65 74 72 79 43 6f 6c 75 6d 6e  ddGeometryColumn
0080: 5c 73 76 73 5c 73 52 65 63 6f 76 65 72 47 65 6f  \svs\sRecoverGeo
0090: 6d 65 74 72 79 43 6f 6c 75 6d 6e 5c 72 5c 6e 5c  metryColumn\r\n\
00a0: 72 5c 6e 54 68 65 5c 73 73 63 68 65 6d 61 5c 73  r\nThe\sschema\s
00b0: 72 65 73 75 6c 74 69 6e 67 5c 73 66 72 6f 6d 5c  resulting\sfrom\
00c0: 73 41 64 64 47 65 6f 6d 65 74 72 79 43 6f 6c 75  sAddGeometryColu
00d0: 6d 6e 5c 73 77 69 6c 6c 5c 73 62 65 5c 73 6d 69  mn\swill\sbe\smi
00e0: 73 73 69 6e 67 5c 73 74 72 69 67 67 65 72 73 5c  ssing\striggers\
00f0: 72 5c 6e 5c 72 5c 6e 54 68 65 5c 73 66 6f 6c 6c  r\n\r\nThe\sfoll
0100: 6f 77 69 6e 67 5c 73 74 72 69 67 67 65 72 73 5c  owing\striggers\
0110: 73 77 69 6c 6c 5c 73 62 65 5c 73 6d 69 73 73 69  swill\sbe\smissi
0120: 6e 67 2e 5c 73 61 6c 6c 5c 73 6f 74 68 65 72 5c  ng.\sall\sother\
0130: 73 70 61 72 74 73 5c 73 6f 66 5c 73 74 68 65 5c  sparts\sof\sthe\
0140: 73 60 2e 73 63 68 65 6d 61 60 5c 73 6f 75 74 70  s`.schema`\soutp
0150: 75 74 5c 73 61 72 65 5c 73 74 68 65 5c 73 73 61  ut\sare\sthe\ssa
0160: 6d 65 3a 5c 72 5c 6e 5c 72 5c 6e 3c 70 72 65 3e  me:\r\n\r\n<pre>
0170: 5c 72 5c 6e 43 52 45 41 54 45 5c 73 54 52 49 47  \r\nCREATE\sTRIG
0180: 47 45 52 5c 73 22 67 67 69 5f 67 65 6f 74 61 62  GER\s"ggi_geotab
0190: 6c 65 5f 4c 4f 43 41 54 49 4f 4e 22 5c 73 42 45  le_LOCATION"\sBE
01a0: 46 4f 52 45 5c 73 49 4e 53 45 52 54 5c 73 4f 4e  FORE\sINSERT\sON
01b0: 5c 73 22 67 65 6f 74 61 62 6c 65 22 5c 72 5c 6e  \s"geotable"\r\n
01c0: 46 4f 52 5c 73 45 41 43 48 5c 73 52 4f 57 5c 73  FOR\sEACH\sROW\s
01d0: 42 45 47 49 4e 5c 72 5c 6e 53 45 4c 45 43 54 5c  BEGIN\r\nSELECT\
01e0: 73 52 41 49 53 45 28 52 4f 4c 4c 42 41 43 4b 2c  sRAISE(ROLLBACK,
01f0: 5c 73 27 67 65 6f 74 61 62 6c 65 2e 4c 4f 43 41  \s'geotable.LOCA
0200: 54 49 4f 4e 5c 73 76 69 6f 6c 61 74 65 73 5c 73  TION\sviolates\s
0210: 47 65 6f 6d 65 74 72 79 5c 73 63 6f 6e 73 74 72  Geometry\sconstr
0220: 61 69 6e 74 5c 73 5b 67 65 6f 6d 2d 74 79 70 65  aint\s[geom-type
0230: 5c 73 6f 72 5c 73 53 52 49 44 5c 73 6e 6f 74 5c  \sor\sSRID\snot\
0240: 73 61 6c 6c 6f 77 65 64 5d 27 29 5c 72 5c 6e 57  sallowed]')\r\nW
0250: 48 45 52 45 5c 73 28 53 45 4c 45 43 54 5c 73 67  HERE\s(SELECT\sg
0260: 65 6f 6d 65 74 72 79 5f 74 79 70 65 5c 73 46 52  eometry_type\sFR
0270: 4f 4d 5c 73 67 65 6f 6d 65 74 72 79 5f 63 6f 6c  OM\sgeometry_col
0280: 75 6d 6e 73 5c 72 5c 6e 57 48 45 52 45 5c 73 4c  umns\r\nWHERE\sL
0290: 6f 77 65 72 28 66 5f 74 61 62 6c 65 5f 6e 61 6d  ower(f_table_nam
02a0: 65 29 5c 73 3d 5c 73 4c 6f 77 65 72 28 27 67 65  e)\s=\sLower('ge
02b0: 6f 74 61 62 6c 65 27 29 5c 73 41 4e 44 5c 73 4c  otable')\sAND\sL
02c0: 6f 77 65 72 28 66 5f 67 65 6f 6d 65 74 72 79 5f  ower(f_geometry_
02d0: 63 6f 6c 75 6d 6e 29 5c 73 3d 5c 73 4c 6f 77 65  column)\s=\sLowe
02e0: 72 28 27 4c 4f 43 41 54 49 4f 4e 27 29 5c 72 5c  r('LOCATION')\r\
02f0: 6e 41 4e 44 5c 73 47 65 6f 6d 65 74 72 79 43 6f  nAND\sGeometryCo
0300: 6e 73 74 72 61 69 6e 74 73 28 4e 45 57 2e 22 4c  nstraints(NEW."L
0310: 4f 43 41 54 49 4f 4e 22 2c 5c 73 67 65 6f 6d 65  OCATION",\sgeome
0320: 74 72 79 5f 74 79 70 65 2c 5c 73 73 72 69 64 29  try_type,\ssrid)
0330: 5c 73 3d 5c 73 31 29 5c 73 49 53 5c 73 4e 55 4c  \s=\s1)\sIS\sNUL
0340: 4c 3b 5c 72 5c 6e 45 4e 44 3b 5c 72 5c 6e 43 52  L;\r\nEND;\r\nCR
0350: 45 41 54 45 5c 73 54 52 49 47 47 45 52 5c 73 22  EATE\sTRIGGER\s"
0360: 67 67 75 5f 67 65 6f 74 61 62 6c 65 5f 4c 4f 43  ggu_geotable_LOC
0370: 41 54 49 4f 4e 22 5c 73 42 45 46 4f 52 45 5c 73  ATION"\sBEFORE\s
0380: 55 50 44 41 54 45 5c 73 4f 46 5c 73 22 4c 4f 43  UPDATE\sOF\s"LOC
0390: 41 54 49 4f 4e 22 5c 73 4f 4e 5c 73 22 67 65 6f  ATION"\sON\s"geo
03a0: 74 61 62 6c 65 22 5c 72 5c 6e 46 4f 52 5c 73 45  table"\r\nFOR\sE
03b0: 41 43 48 5c 73 52 4f 57 5c 73 42 45 47 49 4e 5c  ACH\sROW\sBEGIN\
03c0: 72 5c 6e 53 45 4c 45 43 54 5c 73 52 41 49 53 45  r\nSELECT\sRAISE
03d0: 28 52 4f 4c 4c 42 41 43 4b 2c 5c 73 27 67 65 6f  (ROLLBACK,\s'geo
03e0: 74 61 62 6c 65 2e 4c 4f 43 41 54 49 4f 4e 5c 73  table.LOCATION\s
03f0: 76 69 6f 6c 61 74 65 73 5c 73 47 65 6f 6d 65 74  violates\sGeomet
0400: 72 79 5c 73 63 6f 6e 73 74 72 61 69 6e 74 5c 73  ry\sconstraint\s
0410: 5b 67 65 6f 6d 2d 74 79 70 65 5c 73 6f 72 5c 73  [geom-type\sor\s
0420: 53 52 49 44 5c 73 6e 6f 74 5c 73 61 6c 6c 6f 77  SRID\snot\sallow
0430: 65 64 5d 27 29 5c 72 5c 6e 57 48 45 52 45 5c 73  ed]')\r\nWHERE\s
0440: 28 53 45 4c 45 43 54 5c 73 67 65 6f 6d 65 74 72  (SELECT\sgeometr
0450: 79 5f 74 79 70 65 5c 73 46 52 4f 4d 5c 73 67 65  y_type\sFROM\sge
0460: 6f 6d 65 74 72 79 5f 63 6f 6c 75 6d 6e 73 5c 72  ometry_columns\r
0470: 5c 6e 57 48 45 52 45 5c 73 4c 6f 77 65 72 28 66  \nWHERE\sLower(f
0480: 5f 74 61 62 6c 65 5f 6e 61 6d 65 29 5c 73 3d 5c  _table_name)\s=\
0490: 73 4c 6f 77 65 72 28 27 67 65 6f 74 61 62 6c 65  sLower('geotable
04a0: 27 29 5c 73 41 4e 44 5c 73 4c 6f 77 65 72 28 66  ')\sAND\sLower(f
04b0: 5f 67 65 6f 6d 65 74 72 79 5f 63 6f 6c 75 6d 6e  _geometry_column
04c0: 29 5c 73 3d 5c 73 4c 6f 77 65 72 28 27 4c 4f 43  )\s=\sLower('LOC
04d0: 41 54 49 4f 4e 27 29 5c 72 5c 6e 41 4e 44 5c 73  ATION')\r\nAND\s
04e0: 47 65 6f 6d 65 74 72 79 43 6f 6e 73 74 72 61 69  GeometryConstrai
04f0: 6e 74 73 28 4e 45 57 2e 22 4c 4f 43 41 54 49 4f  nts(NEW."LOCATIO
0500: 4e 22 2c 5c 73 67 65 6f 6d 65 74 72 79 5f 74 79  N",\sgeometry_ty
0510: 70 65 2c 5c 73 73 72 69 64 29 5c 73 3d 5c 73 31  pe,\ssrid)\s=\s1
0520: 29 5c 73 49 53 5c 73 4e 55 4c 4c 3b 5c 72 5c 6e  )\sIS\sNULL;\r\n
0530: 45 4e 44 3b 5c 72 5c 6e 43 52 45 41 54 45 5c 73  END;\r\nCREATE\s
0540: 54 52 49 47 47 45 52 5c 73 22 74 6d 64 5f 67 65  TRIGGER\s"tmd_ge
0550: 6f 74 61 62 6c 65 5f 4c 4f 43 41 54 49 4f 4e 22  otable_LOCATION"
0560: 5c 73 41 46 54 45 52 5c 73 44 45 4c 45 54 45 5c  \sAFTER\sDELETE\
0570: 73 4f 4e 5c 73 22 67 65 6f 74 61 62 6c 65 22 5c  sON\s"geotable"\
0580: 72 5c 6e 46 4f 52 5c 73 45 41 43 48 5c 73 52 4f  r\nFOR\sEACH\sRO
0590: 57 5c 73 42 45 47 49 4e 5c 72 5c 6e 55 50 44 41  W\sBEGIN\r\nUPDA
05a0: 54 45 5c 73 67 65 6f 6d 65 74 72 79 5f 63 6f 6c  TE\sgeometry_col
05b0: 75 6d 6e 73 5f 74 69 6d 65 5c 73 53 45 54 5c 73  umns_time\sSET\s
05c0: 6c 61 73 74 5f 64 65 6c 65 74 65 5c 73 3d 5c 73  last_delete\s=\s
05d0: 73 74 72 66 74 69 6d 65 28 27 25 59 2d 25 6d 2d  strftime('%Y-%m-
05e0: 25 64 54 25 48 3a 25 4d 3a 25 66 5a 27 2c 5c 73  %dT%H:%M:%fZ',\s
05f0: 27 6e 6f 77 27 29 5c 72 5c 6e 57 48 45 52 45 5c  'now')\r\nWHERE\
0600: 73 4c 6f 77 65 72 28 66 5f 74 61 62 6c 65 5f 6e  sLower(f_table_n
0610: 61 6d 65 29 5c 73 3d 5c 73 4c 6f 77 65 72 28 27  ame)\s=\sLower('
0620: 67 65 6f 74 61 62 6c 65 27 29 5c 73 41 4e 44 5c  geotable')\sAND\
0630: 73 4c 6f 77 65 72 28 66 5f 67 65 6f 6d 65 74 72  sLower(f_geometr
0640: 79 5f 63 6f 6c 75 6d 6e 29 5c 73 3d 5c 73 4c 6f  y_column)\s=\sLo
0650: 77 65 72 28 27 4c 4f 43 41 54 49 4f 4e 27 29 3b  wer('LOCATION');
0660: 5c 72 5c 6e 45 4e 44 3b 5c 72 5c 6e 43 52 45 41  \r\nEND;\r\nCREA
0670: 54 45 5c 73 54 52 49 47 47 45 52 5c 73 22 74 6d  TE\sTRIGGER\s"tm
0680: 69 5f 67 65 6f 74 61 62 6c 65 5f 4c 4f 43 41 54  i_geotable_LOCAT
0690: 49 4f 4e 22 5c 73 41 46 54 45 52 5c 73 49 4e 53  ION"\sAFTER\sINS
06a0: 45 52 54 5c 73 4f 4e 5c 73 22 67 65 6f 74 61 62  ERT\sON\s"geotab
06b0: 6c 65 22 5c 72 5c 6e 46 4f 52 5c 73 45 41 43 48  le"\r\nFOR\sEACH
06c0: 5c 73 52 4f 57 5c 73 42 45 47 49 4e 5c 72 5c 6e  \sROW\sBEGIN\r\n
06d0: 55 50 44 41 54 45 5c 73 67 65 6f 6d 65 74 72 79  UPDATE\sgeometry
06e0: 5f 63 6f 6c 75 6d 6e 73 5f 74 69 6d 65 5c 73 53  _columns_time\sS
06f0: 45 54 5c 73 6c 61 73 74 5f 69 6e 73 65 72 74 5c  ET\slast_insert\
0700: 73 3d 5c 73 73 74 72 66 74 69 6d 65 28 27 25 59  s=\sstrftime('%Y
0710: 2d 25 6d 2d 25 64 54 25 48 3a 25 4d 3a 25 66 5a  -%m-%dT%H:%M:%fZ
0720: 27 2c 5c 73 27 6e 6f 77 27 29 5c 72 5c 6e 57 48  ',\s'now')\r\nWH
0730: 45 52 45 5c 73 4c 6f 77 65 72 28 66 5f 74 61 62  ERE\sLower(f_tab
0740: 6c 65 5f 6e 61 6d 65 29 5c 73 3d 5c 73 4c 6f 77  le_name)\s=\sLow
0750: 65 72 28 27 67 65 6f 74 61 62 6c 65 27 29 5c 73  er('geotable')\s
0760: 41 4e 44 5c 73 4c 6f 77 65 72 28 66 5f 67 65 6f  AND\sLower(f_geo
0770: 6d 65 74 72 79 5f 63 6f 6c 75 6d 6e 29 5c 73 3d  metry_column)\s=
0780: 5c 73 4c 6f 77 65 72 28 27 4c 4f 43 41 54 49 4f  \sLower('LOCATIO
0790: 4e 27 29 3b 5c 72 5c 6e 45 4e 44 3b 5c 72 5c 6e  N');\r\nEND;\r\n
07a0: 43 52 45 41 54 45 5c 73 54 52 49 47 47 45 52 5c  CREATE\sTRIGGER\
07b0: 73 22 74 6d 75 5f 67 65 6f 74 61 62 6c 65 5f 4c  s"tmu_geotable_L
07c0: 4f 43 41 54 49 4f 4e 22 5c 73 41 46 54 45 52 5c  OCATION"\sAFTER\
07d0: 73 55 50 44 41 54 45 5c 73 4f 4e 5c 73 22 67 65  sUPDATE\sON\s"ge
07e0: 6f 74 61 62 6c 65 22 5c 72 5c 6e 46 4f 52 5c 73  otable"\r\nFOR\s
07f0: 45 41 43 48 5c 73 52 4f 57 5c 73 42 45 47 49 4e  EACH\sROW\sBEGIN
0800: 5c 72 5c 6e 55 50 44 41 54 45 5c 73 67 65 6f 6d  \r\nUPDATE\sgeom
0810: 65 74 72 79 5f 63 6f 6c 75 6d 6e 73 5f 74 69 6d  etry_columns_tim
0820: 65 5c 73 53 45 54 5c 73 6c 61 73 74 5f 75 70 64  e\sSET\slast_upd
0830: 61 74 65 5c 73 3d 5c 73 73 74 72 66 74 69 6d 65  ate\s=\sstrftime
0840: 28 27 25 59 2d 25 6d 2d 25 64 54 25 48 3a 25 4d  ('%Y-%m-%dT%H:%M
0850: 3a 25 66 5a 27 2c 5c 73 27 6e 6f 77 27 29 5c 72  :%fZ',\s'now')\r
0860: 5c 6e 57 48 45 52 45 5c 73 4c 6f 77 65 72 28 66  \nWHERE\sLower(f
0870: 5f 74 61 62 6c 65 5f 6e 61 6d 65 29 5c 73 3d 5c  _table_name)\s=\
0880: 73 4c 6f 77 65 72 28 27 67 65 6f 74 61 62 6c 65  sLower('geotable
0890: 27 29 5c 73 41 4e 44 5c 73 4c 6f 77 65 72 28 66  ')\sAND\sLower(f
08a0: 5f 67 65 6f 6d 65 74 72 79 5f 63 6f 6c 75 6d 6e  _geometry_column
08b0: 29 5c 73 3d 5c 73 4c 6f 77 65 72 28 27 4c 4f 43  )\s=\sLower('LOC
08c0: 41 54 49 4f 4e 27 29 3b 5c 72 5c 6e 45 4e 44 3b  ATION');\r\nEND;
08d0: 3c 2f 70 72 65 3e 0a 4a 20 6c 6f 67 69 6e 20 61  </pre>.J login a
08e0: 6e 6f 6e 79 6d 6f 75 73 0a 4a 20 6d 69 6d 65 74  nonymous.J mimet
08f0: 79 70 65 20 74 65 78 74 2f 78 2d 66 6f 73 73 69  ype text/x-fossi
0900: 6c 2d 77 69 6b 69 0a 4a 20 70 72 69 76 61 74 65  l-wiki.J private
0910: 5f 63 6f 6e 74 61 63 74 20 37 61 32 66 35 34 33  _contact 7a2f543
0920: 37 64 38 37 66 32 65 36 39 63 32 66 66 36 66 33  7d87f2e69c2ff6f3
0930: 30 39 31 34 32 62 32 34 66 62 36 65 35 36 33 32  09142b24fb6e5632
0940: 31 0a 4a 20 73 65 76 65 72 69 74 79 20 49 6d 70  1.J severity Imp
0950: 6f 72 74 61 6e 74 0a 4a 20 73 74 61 74 75 73 20  ortant.J status 
0960: 4f 70 65 6e 0a 4a 20 74 69 74 6c 65 20 41 64 64  Open.J title Add
0970: 47 65 6f 6d 65 74 72 79 43 6f 6c 75 6d 6e 5c 73  GeometryColumn\s
0980: 6d 69 73 73 69 6e 67 5c 73 53 52 49 44 5c 73 74  missing\sSRID\st
0990: 72 69 67 67 65 72 0a 4a 20 74 79 70 65 20 43 6f  rigger.J type Co
09a0: 64 65 5f 44 65 66 65 63 74 0a 4b 20 31 62 33 33  de_Defect.K 1b33
09b0: 64 31 37 31 64 31 64 65 61 38 38 63 64 31 34 64  d171d1dea88cd14d
09c0: 61 37 33 38 62 64 66 34 32 39 62 34 32 33 37 30  a738bdf429b42370
09d0: 37 30 30 35 0a 55 20 61 6e 6f 6e 79 6d 6f 75 73  7005.U anonymous
09e0: 0a 5a 20 31 30 30 38 64 34 64 36 33 31 36 64 37  .Z 1008d4d6316d7
09f0: 31 65 63 33 30 31 33 63 37 64 37 64 37 31 33 32  1ec3013c7d7d7132
0a00: 64 31 31 0a                                      d11.