dropdeepcopy.sql 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. ----------------------------------------------------------------------------
  2. --
  3. -- Licensed Materials - Property of HCL
  4. -- (c) Copyright HCL Technologies Ltd. 2017. All Rights Reserved.
  5. --
  6. -- dropdeepcopy.sql
  7. --
  8. -- Background
  9. -- ==========
  10. -- Spatial datatypes (ST_LineString, ST_Polygon, etc) are "multirep",
  11. -- which means that a small value gets stored entirely in the table
  12. -- ("in-row") and a large value gets stored in a smart blob ("out-of-row").
  13. -- A large value always has a small in-row component which contains a
  14. -- reference to the out-of-row smart blob.
  15. --
  16. --
  17. -- The problem
  18. -- ===========
  19. -- When a large out-of-row value is created, it initially consists of
  20. -- a small data structure which contains a memory reference to an
  21. -- out-of-row memory cache. When, and if, this value actually gets
  22. -- saved in a table, the data in the out-of-row memory cache gets
  23. -- flushed to a smart blob and the small data structure becomes
  24. -- the in-row component of the multirep value.
  25. --
  26. -- A problem can occur when the server needs to copy a multirep value
  27. -- which contains a memory reference. Version 9.2 of the server doesn't
  28. -- know anything about the out-of-row memory cache, so it doesn't copy it.
  29. -- This means that the multirep value doesn't always persist as long as
  30. -- it should, leading to data corruption. Usually the Spatial DataBlade
  31. -- detects the error immediately and raises this error:
  32. --
  33. -- (USE21) - Geometry integrity error in <function_name>.
  34. --
  35. -- You may also see errors like these, which may be indicative of
  36. -- corrupt data:
  37. --
  38. -- (USE06) - Unknown ESRI shape library error (-2000) in <function_name>
  39. -- (USE31) - Too few points for geometry type in <function_name>
  40. -- (USE32) - Polygon does not close in <function_name>
  41. --
  42. --
  43. -- The solution
  44. -- ============
  45. -- Starting with version 9.3, the server will execute the Spatial
  46. -- DataBlade's DeepCopy support function for all known scenarios in
  47. -- which it needs to copy a large value. As the name implies,
  48. -- DeepCopy makes a full copy of the large value, including the
  49. -- portion in the out-of-row memory cache. This eliminates the
  50. -- data corruption problem by making sure that the entire value
  51. -- persists long enough.
  52. --
  53. --
  54. -- What to do if DeepCopy does not solve your problem
  55. -- ==================================================
  56. -- If your application makes extensive use of SPL, you may encounter
  57. -- a scenario which has not yet been examined, and you might experience
  58. -- data corruption errors. In this case, please contact
  59. -- IBM Informix Technical Support.
  60. -- They will work with you to isolate your problem.
  61. -- If it can be determined that you have a DeepCopy-related problem, you
  62. -- may be instructed to run this script. You can do this using
  63. -- dbaccess:
  64. --
  65. -- dbaccess mydb dropdeepcopy.sql
  66. --
  67. -- After running this script, you should stop and restart the
  68. -- server.
  69. --
  70. --
  71. -- Restoring DeepCopy functions
  72. -- ============================
  73. -- If, after running this script, you wish to restore the DeepCopy
  74. -- functions, you may do so by re-registering the Spatial DataBlade
  75. -- using blademgr:
  76. --
  77. -- % blademgr
  78. -- myserver> register spatial.8.11.UC1 mydb
  79. -- Register module spatial.8.11.UC1 into database mydb? [Y/n] y
  80. -- DataBlade module(s) that will be replaced by spatial.8.11.UC1:
  81. -- spatial.8.11.UC1
  82. -- Are these changes ok? [Y/n] y
  83. -- Registering DataBlade module... (may take a while).
  84. -- DataBlade spatial.8.11.UC1 was successfully registered in database mydb.
  85. -- myserver> bye
  86. --
  87. --
  88. -- If you are using server version 9.2
  89. -- ===================================
  90. -- The DeepCopy support function is only used by version 9.3, or later,
  91. -- of the server. Running this script will have no effect on an older
  92. -- server. Please see the "Working with Spatial Types in SPL Routines"
  93. -- tech note on the IDN website for information on developing a workaround:
  94. --
  95. -- http://www.informix.com/idn-secure/foundation/Library/spatial_spl.htm
  96. --
  97. ----------------------------------------------------------------------------
  98. delete from sysbldobjects
  99. where obj_signature = 'deepcopy.sql'
  100. and bld_id like 'spatial%';
  101. delete from sysbldobjects
  102. where obj_signature = 'alterdeepcopy.sql'
  103. and bld_id like 'spatial%';
  104. delete from sysbldobjdepends
  105. where obj_signature = 'deepcopy.sql'
  106. and bld_id like 'spatial%';
  107. delete from sysbldobjdepends
  108. where obj_signature = 'alterdeepcopy.sql'
  109. and bld_id like 'spatial%';
  110. drop function DeepCopy(ST_Geometry);
  111. drop function DeepCopy(ST_Curve);
  112. drop function DeepCopy(ST_MultiCurve);
  113. drop function DeepCopy(ST_Surface);
  114. drop function DeepCopy(ST_MultiSurface);
  115. drop function DeepCopy(ST_Point);
  116. drop function DeepCopy(ST_MultiPoint);
  117. drop function DeepCopy(ST_LineString);
  118. drop function DeepCopy(ST_MultiLineString);
  119. drop function DeepCopy(ST_Polygon);
  120. drop function DeepCopy(ST_MultiPolygon);
  121. drop function DeepCopy(ST_GeomCollection);