gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

214 lines
10KB

  1. /* contrib/citext/citext--unpackaged--1.0.sql */
  2. -- complain if script is sourced in psql, rather than via CREATE EXTENSION
  3. \echo Use "CREATE EXTENSION citext FROM unpackaged" to load this file. \quit
  4. ALTER EXTENSION citext ADD type citext;
  5. ALTER EXTENSION citext ADD function citextin(cstring);
  6. ALTER EXTENSION citext ADD function citextout(citext);
  7. ALTER EXTENSION citext ADD function citextrecv(internal);
  8. ALTER EXTENSION citext ADD function citextsend(citext);
  9. ALTER EXTENSION citext ADD function citext(character);
  10. ALTER EXTENSION citext ADD function citext(boolean);
  11. ALTER EXTENSION citext ADD function citext(inet);
  12. ALTER EXTENSION citext ADD cast (citext as text);
  13. ALTER EXTENSION citext ADD cast (citext as character varying);
  14. ALTER EXTENSION citext ADD cast (citext as character);
  15. ALTER EXTENSION citext ADD cast (text as citext);
  16. ALTER EXTENSION citext ADD cast (character varying as citext);
  17. ALTER EXTENSION citext ADD cast (character as citext);
  18. ALTER EXTENSION citext ADD cast (boolean as citext);
  19. ALTER EXTENSION citext ADD cast (inet as citext);
  20. ALTER EXTENSION citext ADD function citext_eq(citext,citext);
  21. ALTER EXTENSION citext ADD function citext_ne(citext,citext);
  22. ALTER EXTENSION citext ADD function citext_lt(citext,citext);
  23. ALTER EXTENSION citext ADD function citext_le(citext,citext);
  24. ALTER EXTENSION citext ADD function citext_gt(citext,citext);
  25. ALTER EXTENSION citext ADD function citext_ge(citext,citext);
  26. ALTER EXTENSION citext ADD operator <>(citext,citext);
  27. ALTER EXTENSION citext ADD operator =(citext,citext);
  28. ALTER EXTENSION citext ADD operator >(citext,citext);
  29. ALTER EXTENSION citext ADD operator >=(citext,citext);
  30. ALTER EXTENSION citext ADD operator <(citext,citext);
  31. ALTER EXTENSION citext ADD operator <=(citext,citext);
  32. ALTER EXTENSION citext ADD function citext_cmp(citext,citext);
  33. ALTER EXTENSION citext ADD function citext_hash(citext);
  34. ALTER EXTENSION citext ADD operator family citext_ops using btree;
  35. ALTER EXTENSION citext ADD operator class citext_ops using btree;
  36. ALTER EXTENSION citext ADD operator family citext_ops using hash;
  37. ALTER EXTENSION citext ADD operator class citext_ops using hash;
  38. ALTER EXTENSION citext ADD function citext_smaller(citext,citext);
  39. ALTER EXTENSION citext ADD function citext_larger(citext,citext);
  40. ALTER EXTENSION citext ADD function min(citext);
  41. ALTER EXTENSION citext ADD function max(citext);
  42. ALTER EXTENSION citext ADD function texticlike(citext,citext);
  43. ALTER EXTENSION citext ADD function texticnlike(citext,citext);
  44. ALTER EXTENSION citext ADD function texticregexeq(citext,citext);
  45. ALTER EXTENSION citext ADD function texticregexne(citext,citext);
  46. ALTER EXTENSION citext ADD operator !~(citext,citext);
  47. ALTER EXTENSION citext ADD operator ~(citext,citext);
  48. ALTER EXTENSION citext ADD operator !~*(citext,citext);
  49. ALTER EXTENSION citext ADD operator ~*(citext,citext);
  50. ALTER EXTENSION citext ADD operator !~~(citext,citext);
  51. ALTER EXTENSION citext ADD operator ~~(citext,citext);
  52. ALTER EXTENSION citext ADD operator !~~*(citext,citext);
  53. ALTER EXTENSION citext ADD operator ~~*(citext,citext);
  54. ALTER EXTENSION citext ADD function texticlike(citext,text);
  55. ALTER EXTENSION citext ADD function texticnlike(citext,text);
  56. ALTER EXTENSION citext ADD function texticregexeq(citext,text);
  57. ALTER EXTENSION citext ADD function texticregexne(citext,text);
  58. ALTER EXTENSION citext ADD operator !~(citext,text);
  59. ALTER EXTENSION citext ADD operator ~(citext,text);
  60. ALTER EXTENSION citext ADD operator !~*(citext,text);
  61. ALTER EXTENSION citext ADD operator ~*(citext,text);
  62. ALTER EXTENSION citext ADD operator !~~(citext,text);
  63. ALTER EXTENSION citext ADD operator ~~(citext,text);
  64. ALTER EXTENSION citext ADD operator !~~*(citext,text);
  65. ALTER EXTENSION citext ADD operator ~~*(citext,text);
  66. ALTER EXTENSION citext ADD function regexp_matches(citext,citext);
  67. ALTER EXTENSION citext ADD function regexp_matches(citext,citext,text);
  68. ALTER EXTENSION citext ADD function regexp_replace(citext,citext,text);
  69. ALTER EXTENSION citext ADD function regexp_replace(citext,citext,text,text);
  70. ALTER EXTENSION citext ADD function regexp_split_to_array(citext,citext);
  71. ALTER EXTENSION citext ADD function regexp_split_to_array(citext,citext,text);
  72. ALTER EXTENSION citext ADD function regexp_split_to_table(citext,citext);
  73. ALTER EXTENSION citext ADD function regexp_split_to_table(citext,citext,text);
  74. ALTER EXTENSION citext ADD function strpos(citext,citext);
  75. ALTER EXTENSION citext ADD function replace(citext,citext,citext);
  76. ALTER EXTENSION citext ADD function split_part(citext,citext,integer);
  77. ALTER EXTENSION citext ADD function translate(citext,citext,text);
  78. --
  79. -- As of 9.1, type citext should be marked collatable. There is no ALTER TYPE
  80. -- command for this, so we have to do it by poking the pg_type entry directly.
  81. -- We have to poke any derived copies in pg_attribute or pg_index as well,
  82. -- as well as those for arrays/domains based directly or indirectly on citext.
  83. -- Notes: 100 is the OID of the "pg_catalog.default" collation --- it seems
  84. -- easier and more reliable to hard-wire that here than to pull it out of
  85. -- pg_collation. Also, we don't need to make pg_depend entries since the
  86. -- default collation is pinned.
  87. --
  88. DO LANGUAGE plpgsql
  89. $$
  90. DECLARE
  91. my_schema pg_catalog.text := pg_catalog.quote_ident(pg_catalog.current_schema());
  92. old_path pg_catalog.text := pg_catalog.current_setting('search_path');
  93. BEGIN
  94. -- for safety, transiently set search_path to just pg_catalog+pg_temp
  95. PERFORM pg_catalog.set_config('search_path', 'pg_catalog, pg_temp', true);
  96. WITH RECURSIVE typeoids(typoid) AS
  97. ( SELECT (my_schema || '.citext')::pg_catalog.regtype UNION
  98. SELECT oid FROM pg_catalog.pg_type, typeoids
  99. WHERE typelem = typoid OR typbasetype = typoid )
  100. UPDATE pg_catalog.pg_type SET typcollation = 100
  101. FROM typeoids
  102. WHERE oid = typeoids.typoid;
  103. WITH RECURSIVE typeoids(typoid) AS
  104. ( SELECT (my_schema || '.citext')::pg_catalog.regtype UNION
  105. SELECT oid FROM pg_catalog.pg_type, typeoids
  106. WHERE typelem = typoid OR typbasetype = typoid )
  107. UPDATE pg_catalog.pg_attribute SET attcollation = 100
  108. FROM typeoids
  109. WHERE atttypid = typeoids.typoid;
  110. -- Updating the index indcollations is particularly tedious, but since we
  111. -- don't currently allow SQL assignment to individual elements of oidvectors,
  112. -- there's little choice.
  113. UPDATE pg_catalog.pg_index SET indcollation =
  114. pg_catalog.regexp_replace(indcollation::pg_catalog.text, '^0', '100')::pg_catalog.oidvector
  115. WHERE indclass[0] IN (
  116. WITH RECURSIVE typeoids(typoid) AS
  117. ( SELECT (my_schema || '.citext')::pg_catalog.regtype UNION
  118. SELECT oid FROM pg_catalog.pg_type, typeoids
  119. WHERE typelem = typoid OR typbasetype = typoid )
  120. SELECT oid FROM pg_catalog.pg_opclass, typeoids
  121. WHERE opcintype = typeoids.typoid
  122. );
  123. UPDATE pg_catalog.pg_index SET indcollation =
  124. pg_catalog.regexp_replace(indcollation::pg_catalog.text, E'^(\\d+) 0', E'\\1 100')::pg_catalog.oidvector
  125. WHERE indclass[1] IN (
  126. WITH RECURSIVE typeoids(typoid) AS
  127. ( SELECT (my_schema || '.citext')::pg_catalog.regtype UNION
  128. SELECT oid FROM pg_catalog.pg_type, typeoids
  129. WHERE typelem = typoid OR typbasetype = typoid )
  130. SELECT oid FROM pg_catalog.pg_opclass, typeoids
  131. WHERE opcintype = typeoids.typoid
  132. );
  133. UPDATE pg_catalog.pg_index SET indcollation =
  134. pg_catalog.regexp_replace(indcollation::pg_catalog.text, E'^(\\d+ \\d+) 0', E'\\1 100')::pg_catalog.oidvector
  135. WHERE indclass[2] IN (
  136. WITH RECURSIVE typeoids(typoid) AS
  137. ( SELECT (my_schema || '.citext')::pg_catalog.regtype UNION
  138. SELECT oid FROM pg_catalog.pg_type, typeoids
  139. WHERE typelem = typoid OR typbasetype = typoid )
  140. SELECT oid FROM pg_catalog.pg_opclass, typeoids
  141. WHERE opcintype = typeoids.typoid
  142. );
  143. UPDATE pg_catalog.pg_index SET indcollation =
  144. pg_catalog.regexp_replace(indcollation::pg_catalog.text, E'^(\\d+ \\d+ \\d+) 0', E'\\1 100')::pg_catalog.oidvector
  145. WHERE indclass[3] IN (
  146. WITH RECURSIVE typeoids(typoid) AS
  147. ( SELECT (my_schema || '.citext')::pg_catalog.regtype UNION
  148. SELECT oid FROM pg_catalog.pg_type, typeoids
  149. WHERE typelem = typoid OR typbasetype = typoid )
  150. SELECT oid FROM pg_catalog.pg_opclass, typeoids
  151. WHERE opcintype = typeoids.typoid
  152. );
  153. UPDATE pg_catalog.pg_index SET indcollation =
  154. pg_catalog.regexp_replace(indcollation::pg_catalog.text, E'^(\\d+ \\d+ \\d+ \\d+) 0', E'\\1 100')::pg_catalog.oidvector
  155. WHERE indclass[4] IN (
  156. WITH RECURSIVE typeoids(typoid) AS
  157. ( SELECT (my_schema || '.citext')::pg_catalog.regtype UNION
  158. SELECT oid FROM pg_catalog.pg_type, typeoids
  159. WHERE typelem = typoid OR typbasetype = typoid )
  160. SELECT oid FROM pg_catalog.pg_opclass, typeoids
  161. WHERE opcintype = typeoids.typoid
  162. );
  163. UPDATE pg_catalog.pg_index SET indcollation =
  164. pg_catalog.regexp_replace(indcollation::pg_catalog.text, E'^(\\d+ \\d+ \\d+ \\d+ \\d+) 0', E'\\1 100')::pg_catalog.oidvector
  165. WHERE indclass[5] IN (
  166. WITH RECURSIVE typeoids(typoid) AS
  167. ( SELECT (my_schema || '.citext')::pg_catalog.regtype UNION
  168. SELECT oid FROM pg_catalog.pg_type, typeoids
  169. WHERE typelem = typoid OR typbasetype = typoid )
  170. SELECT oid FROM pg_catalog.pg_opclass, typeoids
  171. WHERE opcintype = typeoids.typoid
  172. );
  173. UPDATE pg_catalog.pg_index SET indcollation =
  174. pg_catalog.regexp_replace(indcollation::pg_catalog.text, E'^(\\d+ \\d+ \\d+ \\d+ \\d+ \\d+) 0', E'\\1 100')::pg_catalog.oidvector
  175. WHERE indclass[6] IN (
  176. WITH RECURSIVE typeoids(typoid) AS
  177. ( SELECT (my_schema || '.citext')::pg_catalog.regtype UNION
  178. SELECT oid FROM pg_catalog.pg_type, typeoids
  179. WHERE typelem = typoid OR typbasetype = typoid )
  180. SELECT oid FROM pg_catalog.pg_opclass, typeoids
  181. WHERE opcintype = typeoids.typoid
  182. );
  183. UPDATE pg_catalog.pg_index SET indcollation =
  184. pg_catalog.regexp_replace(indcollation::pg_catalog.text, E'^(\\d+ \\d+ \\d+ \\d+ \\d+ \\d+ \\d+) 0', E'\\1 100')::pg_catalog.oidvector
  185. WHERE indclass[7] IN (
  186. WITH RECURSIVE typeoids(typoid) AS
  187. ( SELECT (my_schema || '.citext')::pg_catalog.regtype UNION
  188. SELECT oid FROM pg_catalog.pg_type, typeoids
  189. WHERE typelem = typoid OR typbasetype = typoid )
  190. SELECT oid FROM pg_catalog.pg_opclass, typeoids
  191. WHERE opcintype = typeoids.typoid
  192. );
  193. -- somewhat arbitrarily, we assume no citext indexes have more than 8 columns
  194. PERFORM pg_catalog.set_config('search_path', old_path, true);
  195. END
  196. $$;
上海开阖软件有限公司 沪ICP备12045867号-1