boot920.sql 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. { ************************************************************************* }
  2. { }
  3. { Licensed Materials - Property of IBM and/or HCL }
  4. { }
  5. { IBM Informix Dynamic Server }
  6. { (c) Copyright IBM Corporation 1996, 2004 All rights reserved. }
  7. { (c) Copyright HCL Technologies Ltd. 2017. All Rights Reserved. }
  8. { }
  9. { ************************************************************************* }
  10. { }
  11. { Title: boot920.sql }
  12. { }
  13. { Description: }
  14. { Bootstrapping script for a 9.20 database }
  15. { }
  16. { ************************************************************************* }
  17. { }
  18. { ** IMPORTANT - PLEASE READ }
  19. { }
  20. { All types and routines referenced in this file must be prefixed }
  21. { with the user name "informix". E.g., use "informix.boolean" }
  22. { and not "boolean" }
  23. { }
  24. { Also, please follow the formatting conventions!!! }
  25. { }
  26. { Please ensure that the identifiers that you choose are <= 18 }
  27. { characters in length. Otherwise the changes would affect database }
  28. { reversion. }
  29. { }
  30. { ************************************************************************* }
  31. -- MORE IMPORTANT: MUST READ
  32. -- DO NOT ADD ANYTHING IN THIS FILE. ADDING STUFF IN THIS FILE MAY CAUSE
  33. -- FAILURE IN CONVERSION/REVERSION PROCESS. USE boot920a.sql.
  34. ---Define the hash access method.
  35. ---Do not grant execute to public for these functions as
  36. ---they are special-cased within the engine with the exception
  37. ---of ifx_sha_settrace().
  38. create dba function informix.sha_create(informix.pointer)
  39. returns int
  40. external name '(sha_create)'
  41. language C;
  42. create dba function informix.sha_open(informix.pointer)
  43. returns int
  44. external name '(sha_open)'
  45. language C;
  46. create dba function informix.sha_close(informix.pointer)
  47. returns int
  48. external name '(sha_close)'
  49. language C;
  50. create dba function informix.sha_insert(informix.pointer,
  51. informix.pointer, informix.pointer)
  52. returns int
  53. external name '(sha_insert)'
  54. language C;
  55. create dba function informix.sha_update(informix.pointer,
  56. integer, informix.pointer, informix.pointer,
  57. informix.pointer)
  58. returns int
  59. external name '(sha_update)'
  60. language C;
  61. create dba function informix.sha_delete(informix.pointer, integer)
  62. returns int
  63. external name '(sha_delete)'
  64. language C;
  65. create dba function informix.sha_scancost(informix.pointer,
  66. informix.pointer)
  67. returns float
  68. external name '(sha_scancost)'
  69. language C;
  70. create dba function informix.sha_beginscan(informix.pointer)
  71. returns int
  72. external name '(sha_beginscan)'
  73. language C;
  74. create dba function informix.sha_rescan(informix.pointer)
  75. returns int
  76. external name '(sha_rescan)'
  77. language C;
  78. create dba function informix.sha_getnext(informix.pointer,
  79. informix.pointer, informix.pointer)
  80. returns int
  81. external name '(sha_getnext)'
  82. language C;
  83. create dba function informix.sha_getbyid(informix.pointer,
  84. informix.pointer, integer)
  85. returns int
  86. external name '(sha_getbyid)'
  87. language C;
  88. ---Create function to enable trace.
  89. create dba function informix.ifx_sha_settrace(integer, lvarchar)
  90. returns integer
  91. external name '(ifx_sha_settrace)'
  92. language C;
  93. ---Create the access method
  94. create primary access_method informix.hash(
  95. am_create=informix.sha_create,
  96. am_open=informix.sha_open,
  97. am_close=informix.sha_close,
  98. am_insert=informix.sha_insert,
  99. am_update=informix.sha_update,
  100. am_delete=informix.sha_delete,
  101. am_scancost=informix.sha_scancost,
  102. am_beginscan=informix.sha_beginscan,
  103. am_rescan=informix.sha_rescan,
  104. am_getnext=informix.sha_getnext,
  105. am_getbyid=informix.sha_getbyid,
  106. am_rowids,
  107. am_readwrite,
  108. am_sptype='D');
  109. --- Alter rtree functions to make them parallelizable
  110. alter function informix.rlt_open(pointer)
  111. with (add parallelizable);
  112. alter function informix.rlt_close(pointer)
  113. with (add parallelizable);
  114. alter function informix.rlt_insert(pointer, pointer, pointer)
  115. with (add parallelizable);
  116. alter function informix.rlt_delete(pointer, pointer, pointer)
  117. with (add parallelizable);
  118. {Not yet for rtree update}
  119. {alter function informix.rlt_update}
  120. {(pointer, pointer, pointer, pointer, pointer) }
  121. {with (add parallelizable);}
  122. alter function informix.rlt_beginscan(pointer)
  123. with (add parallelizable);
  124. alter function informix.rlt_endscan(pointer)
  125. with (add parallelizable);
  126. alter function informix.rlt_rescan(pointer)
  127. with (add parallelizable);
  128. alter function informix.rlt_getnext(pointer, pointer, pointer)
  129. with (add parallelizable);
  130. ---Define rtree support function for oncheck
  131. create function informix.rlt_check(pointer, integer)
  132. returns integer
  133. external name '(rlt_check)'
  134. language C;
  135. alter access_method informix.rtree add am_check = informix.rlt_check;
  136. ---Add new collectionsend() to handle all collection types
  137. create dba function informix.collectionsend(collection)
  138. returns informix.sendrecv
  139. external name '(collectionsend)'
  140. language C not variant;
  141. grant execute on function informix.collectionsend(collection)
  142. to public as informix ;
  143. -- create a function to enable unloading of a module.
  144. create dba function informix.unloading_module(varchar(255), varchar(255))
  145. returns int
  146. external name '' language C;
  147. create procedure informix.ifx_unload_module (modulename varchar(255),
  148. languagename varchar(255)) returns int
  149. define retvalue int;
  150. let retvalue = unloading_module(modulename, languagename);
  151. if retvalue = 0 then
  152. return 0;
  153. end if;
  154. if retvalue = -1 then
  155. raise exception -9721;
  156. else
  157. raise exception -9720;
  158. end if;
  159. end procedure;
  160. create opaque type informix.stat
  161. (
  162. internallength=variable,
  163. alignment = 8,
  164. maxlen = 272,
  165. cannothash
  166. );
  167. create dba function informix.statout(informix.stat)
  168. returns informix.lvarchar
  169. external name '(showstat)'
  170. language C not variant;
  171. grant execute on function informix.statout(informix.stat) to
  172. public as informix ;
  173. create explicit cast (informix.stat as informix.lvarchar
  174. with informix.statout);
  175. create dba function informix.assign(informix.stat)
  176. returns informix.stat
  177. external name '(stat_assign)'
  178. language C not variant;
  179. create dba function informix.destroy(informix.stat)
  180. returns informix.stat
  181. external name '(stat_destroy)'
  182. language C not variant;
  183. create dba function informix.send(informix.stat)
  184. returns informix.sendrecv
  185. external name '(stat_send)'
  186. language C not variant;
  187. grant execute on function informix.send(informix.stat) to
  188. public as informix ;
  189. create explicit cast (informix.stat as informix.sendrecv with informix.send);
  190. -- add collectionimport and collectionexport functions
  191. create dba function informix.collectionimport(informix.impexp) returns set
  192. external name '(collectionimport)' language C not variant;
  193. grant execute on function informix.collectionimport(informix.impexp)
  194. to public as informix;
  195. create implicit cast (informix.impexp as collection with
  196. informix.collectionimport);
  197. create implicit cast (informix.impexp as set with
  198. informix.collectionimport);
  199. create implicit cast (informix.impexp as multiset with
  200. informix.collectionimport);
  201. create implicit cast (informix.impexp as list with
  202. informix.collectionimport);
  203. create dba function informix.collectionexport(collection) returns informix.impexp
  204. external name '(collectionexport)' language C not variant;
  205. create dba function informix.collectionexport(set) returns informix.impexp
  206. external name '(collectionexport)' language C not variant;
  207. create dba function informix.collectionexport(multiset) returns informix.impexp
  208. external name '(collectionexport)' language C not variant;
  209. create dba function informix.collectionexport(list) returns informix.impexp
  210. external name '(collectionexport)' language C not variant;
  211. grant execute on function informix.collectionexport(collection)
  212. to public as informix;
  213. grant execute on function informix.collectionexport(set)
  214. to public as informix;
  215. grant execute on function informix.collectionexport(multiset)
  216. to public as informix;
  217. grant execute on function informix.collectionexport(list)
  218. to public as informix;
  219. create implicit cast (collection as informix.impexp with
  220. informix.collectionexport);
  221. create implicit cast (set as informix.impexp with
  222. informix.collectionexport);
  223. create implicit cast (multiset as informix.impexp with
  224. informix.collectionexport);
  225. create implicit cast (list as informix.impexp with
  226. informix.collectionexport);
  227. grant usage on language spl to public;
  228. -- fastpath entry points to support client sblob range locking
  229. create dba function informix.ifx_lo_lock(integer, int8, integer, int8, integer)
  230. returns integer
  231. external name '(sq_lo_lock)'
  232. language c;
  233. grant execute on function informix.ifx_lo_lock(integer, int8, integer, int8, integer) to public as informix;
  234. create dba function informix.ifx_lo_unlock(integer, int8, integer, int8)
  235. returns integer
  236. external name '(sq_lo_unlock)'
  237. language c;
  238. grant execute on function informix.ifx_lo_unlock(integer, int8, integer, int8) to public as informix;
  239. -- cast from byte to blob
  240. create function informix.bytetoblob(references byte)
  241. returns informix.blob
  242. external name '(bytetoblob)'
  243. language c not variant;
  244. grant execute on function informix.bytetoblob(references byte)
  245. to public as informix;
  246. create explicit cast (byte as informix.blob with informix.bytetoblob);
  247. create function informix.bytetoblob(references byte, char(18), char(18))
  248. returns informix.blob
  249. external name '(bytetoblob_colspec)'
  250. language c not variant;
  251. grant execute on function informix.bytetoblob(references byte, char(18), char(18))
  252. to public as informix;
  253. -- cast from text to clob
  254. create function informix.texttoclob(references text)
  255. returns informix.clob
  256. external name '(bytetoblob)'
  257. language c not variant;
  258. grant execute on function informix.texttoclob(references text)
  259. to public as informix;
  260. create explicit cast (text as informix.clob with informix.texttoclob);
  261. create function informix.texttoclob(references text, char(18), char(18))
  262. returns informix.clob
  263. external name '(bytetoblob_colspec)'
  264. language c not variant;
  265. grant execute on function informix.texttoclob(references text, char(18), char(18))
  266. to public as informix;
  267. create dba function informix.rtnparamtypes_send(informix.rtnparamtypes)
  268. returning informix.sendrecv
  269. external name '(rtnparamtypes_send)' language C
  270. not variant;
  271. grant execute on function informix.rtnparamtypes_send(informix.rtnparamtypes) to
  272. public as informix ;
  273. create implicit cast (informix.rtnparamtypes as informix.sendrecv
  274. with informix.rtnparamtypes_send);
  275. ---
  276. --- Register builtin java UDRs for Krakatoa
  277. ---
  278. create dba procedure sqlj.install_jar(varchar(255), varchar(255))
  279. external name 'informix.jvp.dbapplet.impl.JarHandler.installJar(java.lang.String, java.lang.String)' language java end procedure;
  280. grant execute on procedure sqlj.install_jar(varchar(255), varchar(255))
  281. to public as sqlj;
  282. create dba procedure sqlj.remove_jar(varchar(255))
  283. external name 'informix.jvp.dbapplet.impl.JarHandler.removeJar(java.lang.String) ' language java end procedure;
  284. grant execute on procedure sqlj.remove_jar(varchar(255))
  285. to public as sqlj;
  286. create dba procedure sqlj.replace_jar(varchar(255), varchar(255))
  287. external name 'informix.jvp.dbapplet.impl.JarHandler.replaceJar(java.lang.String, java.lang.String)' language java end procedure;
  288. grant execute on procedure sqlj.replace_jar(varchar(255), varchar(255))
  289. to public as sqlj;
  290. create dba procedure sqlj.install_jar_deploy(varchar(255), varchar(255))
  291. external name 'informix.jvp.dbapplet.impl.JarHandler.installJarDeploy(java.lang.String, java.lang.String)' language java end procedure;
  292. grant execute on procedure sqlj.install_jar_deploy(varchar(255),
  293. varchar(255)) to public as sqlj;
  294. create dba procedure sqlj.remove_jar_undeploy(varchar(255))
  295. external name 'informix.jvp.dbapplet.impl.JarHandler.removeJarUndeploy(java.lang.String)' language java end procedure;
  296. grant execute on procedure sqlj.remove_jar_undeploy(varchar(255))
  297. to public as sqlj;
  298. create dba procedure sqlj.alter_java_path(varchar(255), lvarchar)
  299. external name 'informix.jvp.dbapplet.impl.JarHandler.alterJavaPath(java.lang.String, java.lang.String)' language java end procedure;
  300. grant execute on procedure sqlj.alter_java_path(varchar(255),
  301. lvarchar) to public as sqlj;
  302. create dba procedure sqlj.setUDTExtName(varchar(255), varchar(255))
  303. external name 'informix.jvp.dbapplet.impl.JarHandler.setUDTExternalName(java.lang.String, java.lang.String)' language java end procedure;
  304. grant execute on procedure sqlj.setUDTExtName(varchar(255),
  305. varchar(255)) to public as sqlj;
  306. create dba procedure sqlj.unsetUDTExtName(udtSQLName varchar(255))
  307. external name 'informix.jvp.dbapplet.impl.JarHandler.unsetUDTExternalName(java.lang.String)' language java end procedure;
  308. grant execute on procedure sqlj.unsetUDTExtName(varchar(255))
  309. to public as sqlj;
  310. ---
  311. --- end java UDRs
  312. ---
  313. create dba function informix.ifx_update_extern(varchar(255), varchar(255),
  314. varchar(255) )
  315. returns int
  316. external name '' language C;
  317. grant execute on function informix.ifx_update_extern(varchar(255), varchar(255),varchar(255))
  318. to public as informix ;
  319. create dba procedure informix.ifx_replace_module (oldmodulename varchar(255),
  320. newmodulename varchar(255),
  321. languagename varchar(255)) returns int
  322. define retvalue int;
  323. let retvalue = ifx_invalid_module(oldmodulename,
  324. languagename);
  325. if retvalue = 0 then
  326. let retvalue = ifx_update_extern( oldmodulename, newmodulename, languagename);
  327. update informix.sysprocedures
  328. set externalname = ifx_new_external(newmodulename, externalname,
  329. languagename)
  330. where ifx_match_external(oldmodulename, externalname) = 1;
  331. let retvalue = ifx_load_internal(newmodulename, languagename);
  332. end if;
  333. if retvalue = 0 then
  334. return 0;
  335. else
  336. raise exception -9720;
  337. end if;
  338. end procedure;
  339. grant execute on procedure informix.ifx_replace_module (varchar(255),varchar(255),
  340. varchar(255)) to public as informix;
  341. --- Alter blob/clob routines to allow handling nulls
  342. alter function informix.filetoblob(informix.lvarchar, char(6), char(18), char(18))
  343. with (add handlesnulls);
  344. alter function informix.filetoclob(informix.lvarchar, char(6), char(18), char(18))
  345. with (add handlesnulls);
  346. alter function informix.locopy(informix.blob, char(18), char(18))
  347. with (add handlesnulls);
  348. -- Define conversion and reversion functions for rtree index partitions
  349. create dba function informix.rlt_convert(int)
  350. returns int
  351. external name '(rlt_convert)'
  352. language C;
  353. grant execute on function informix.rlt_convert(int) to public as informix ;
  354. create dba function informix.rlt_revert(int)
  355. returns int
  356. external name '(rlt_revert)'
  357. language C;
  358. grant execute on function informix.rlt_revert(int) to public as informix ;