pg_cast.dat 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. #----------------------------------------------------------------------
  2. #
  3. # pg_cast.dat
  4. # Initial contents of the pg_cast system catalog.
  5. #
  6. # Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
  7. # Portions Copyright (c) 1994, Regents of the University of California
  8. #
  9. # src/include/catalog/pg_cast.dat
  10. #
  11. #----------------------------------------------------------------------
  12. [
  13. # Note: this table has OIDs, but we don't bother to assign them manually,
  14. # since nothing needs to know the specific OID of any built-in cast.
  15. # Numeric category: implicit casts are allowed in the direction
  16. # int2->int4->int8->numeric->float4->float8, while casts in the
  17. # reverse direction are assignment-only.
  18. { castsource => 'int8', casttarget => 'int2', castfunc => 'int2(int8)',
  19. castcontext => 'a', castmethod => 'f' },
  20. { castsource => 'int8', casttarget => 'int4', castfunc => 'int4(int8)',
  21. castcontext => 'a', castmethod => 'f' },
  22. { castsource => 'int8', casttarget => 'float4', castfunc => 'float4(int8)',
  23. castcontext => 'i', castmethod => 'f' },
  24. { castsource => 'int8', casttarget => 'float8', castfunc => 'float8(int8)',
  25. castcontext => 'i', castmethod => 'f' },
  26. { castsource => 'int8', casttarget => 'numeric', castfunc => 'numeric(int8)',
  27. castcontext => 'i', castmethod => 'f' },
  28. { castsource => 'int2', casttarget => 'int8', castfunc => 'int8(int2)',
  29. castcontext => 'i', castmethod => 'f' },
  30. { castsource => 'int2', casttarget => 'int4', castfunc => 'int4(int2)',
  31. castcontext => 'i', castmethod => 'f' },
  32. { castsource => 'int2', casttarget => 'float4', castfunc => 'float4(int2)',
  33. castcontext => 'i', castmethod => 'f' },
  34. { castsource => 'int2', casttarget => 'float8', castfunc => 'float8(int2)',
  35. castcontext => 'i', castmethod => 'f' },
  36. { castsource => 'int2', casttarget => 'numeric', castfunc => 'numeric(int2)',
  37. castcontext => 'i', castmethod => 'f' },
  38. { castsource => 'int4', casttarget => 'int8', castfunc => 'int8(int4)',
  39. castcontext => 'i', castmethod => 'f' },
  40. { castsource => 'int4', casttarget => 'int2', castfunc => 'int2(int4)',
  41. castcontext => 'a', castmethod => 'f' },
  42. { castsource => 'int4', casttarget => 'float4', castfunc => 'float4(int4)',
  43. castcontext => 'i', castmethod => 'f' },
  44. { castsource => 'int4', casttarget => 'float8', castfunc => 'float8(int4)',
  45. castcontext => 'i', castmethod => 'f' },
  46. { castsource => 'int4', casttarget => 'numeric', castfunc => 'numeric(int4)',
  47. castcontext => 'i', castmethod => 'f' },
  48. { castsource => 'float4', casttarget => 'int8', castfunc => 'int8(float4)',
  49. castcontext => 'a', castmethod => 'f' },
  50. { castsource => 'float4', casttarget => 'int2', castfunc => 'int2(float4)',
  51. castcontext => 'a', castmethod => 'f' },
  52. { castsource => 'float4', casttarget => 'int4', castfunc => 'int4(float4)',
  53. castcontext => 'a', castmethod => 'f' },
  54. { castsource => 'float4', casttarget => 'float8', castfunc => 'float8(float4)',
  55. castcontext => 'i', castmethod => 'f' },
  56. { castsource => 'float4', casttarget => 'numeric',
  57. castfunc => 'numeric(float4)', castcontext => 'a', castmethod => 'f' },
  58. { castsource => 'float8', casttarget => 'int8', castfunc => 'int8(float8)',
  59. castcontext => 'a', castmethod => 'f' },
  60. { castsource => 'float8', casttarget => 'int2', castfunc => 'int2(float8)',
  61. castcontext => 'a', castmethod => 'f' },
  62. { castsource => 'float8', casttarget => 'int4', castfunc => 'int4(float8)',
  63. castcontext => 'a', castmethod => 'f' },
  64. { castsource => 'float8', casttarget => 'float4', castfunc => 'float4(float8)',
  65. castcontext => 'a', castmethod => 'f' },
  66. { castsource => 'float8', casttarget => 'numeric',
  67. castfunc => 'numeric(float8)', castcontext => 'a', castmethod => 'f' },
  68. { castsource => 'numeric', casttarget => 'int8', castfunc => 'int8(numeric)',
  69. castcontext => 'a', castmethod => 'f' },
  70. { castsource => 'numeric', casttarget => 'int2', castfunc => 'int2(numeric)',
  71. castcontext => 'a', castmethod => 'f' },
  72. { castsource => 'numeric', casttarget => 'int4', castfunc => 'int4(numeric)',
  73. castcontext => 'a', castmethod => 'f' },
  74. { castsource => 'numeric', casttarget => 'float4',
  75. castfunc => 'float4(numeric)', castcontext => 'i', castmethod => 'f' },
  76. { castsource => 'numeric', casttarget => 'float8',
  77. castfunc => 'float8(numeric)', castcontext => 'i', castmethod => 'f' },
  78. { castsource => 'money', casttarget => 'numeric', castfunc => 'numeric(money)',
  79. castcontext => 'a', castmethod => 'f' },
  80. { castsource => 'numeric', casttarget => 'money', castfunc => 'money(numeric)',
  81. castcontext => 'a', castmethod => 'f' },
  82. { castsource => 'int4', casttarget => 'money', castfunc => 'money(int4)',
  83. castcontext => 'a', castmethod => 'f' },
  84. { castsource => 'int8', casttarget => 'money', castfunc => 'money(int8)',
  85. castcontext => 'a', castmethod => 'f' },
  86. # Allow explicit coercions between int4 and bool
  87. { castsource => 'int4', casttarget => 'bool', castfunc => 'bool(int4)',
  88. castcontext => 'e', castmethod => 'f' },
  89. { castsource => 'bool', casttarget => 'int4', castfunc => 'int4(bool)',
  90. castcontext => 'e', castmethod => 'f' },
  91. # Allow explicit coercions between xid8 and xid
  92. { castsource => 'xid8', casttarget => 'xid', castfunc => 'xid(xid8)',
  93. castcontext => 'e', castmethod => 'f' },
  94. # OID category: allow implicit conversion from any integral type (including
  95. # int8, to support OID literals > 2G) to OID, as well as assignment coercion
  96. # from OID to int4 or int8. Similarly for each OID-alias type. Also allow
  97. # implicit coercions between OID and each OID-alias type, as well as
  98. # regproc<->regprocedure and regoper<->regoperator. (Other coercions
  99. # between alias types must pass through OID.) Lastly, there are implicit
  100. # casts from text and varchar to regclass, which exist mainly to support
  101. # legacy forms of nextval() and related functions.
  102. { castsource => 'int8', casttarget => 'oid', castfunc => 'oid',
  103. castcontext => 'i', castmethod => 'f' },
  104. { castsource => 'int2', casttarget => 'oid', castfunc => 'int4(int2)',
  105. castcontext => 'i', castmethod => 'f' },
  106. { castsource => 'int4', casttarget => 'oid', castfunc => '0',
  107. castcontext => 'i', castmethod => 'b' },
  108. { castsource => 'oid', casttarget => 'int8', castfunc => 'int8(oid)',
  109. castcontext => 'a', castmethod => 'f' },
  110. { castsource => 'oid', casttarget => 'int4', castfunc => '0',
  111. castcontext => 'a', castmethod => 'b' },
  112. { castsource => 'oid', casttarget => 'regproc', castfunc => '0',
  113. castcontext => 'i', castmethod => 'b' },
  114. { castsource => 'regproc', casttarget => 'oid', castfunc => '0',
  115. castcontext => 'i', castmethod => 'b' },
  116. { castsource => 'int8', casttarget => 'regproc', castfunc => 'oid',
  117. castcontext => 'i', castmethod => 'f' },
  118. { castsource => 'int2', casttarget => 'regproc', castfunc => 'int4(int2)',
  119. castcontext => 'i', castmethod => 'f' },
  120. { castsource => 'int4', casttarget => 'regproc', castfunc => '0',
  121. castcontext => 'i', castmethod => 'b' },
  122. { castsource => 'regproc', casttarget => 'int8', castfunc => 'int8(oid)',
  123. castcontext => 'a', castmethod => 'f' },
  124. { castsource => 'regproc', casttarget => 'int4', castfunc => '0',
  125. castcontext => 'a', castmethod => 'b' },
  126. { castsource => 'regproc', casttarget => 'regprocedure', castfunc => '0',
  127. castcontext => 'i', castmethod => 'b' },
  128. { castsource => 'regprocedure', casttarget => 'regproc', castfunc => '0',
  129. castcontext => 'i', castmethod => 'b' },
  130. { castsource => 'oid', casttarget => 'regprocedure', castfunc => '0',
  131. castcontext => 'i', castmethod => 'b' },
  132. { castsource => 'regprocedure', casttarget => 'oid', castfunc => '0',
  133. castcontext => 'i', castmethod => 'b' },
  134. { castsource => 'int8', casttarget => 'regprocedure', castfunc => 'oid',
  135. castcontext => 'i', castmethod => 'f' },
  136. { castsource => 'int2', casttarget => 'regprocedure', castfunc => 'int4(int2)',
  137. castcontext => 'i', castmethod => 'f' },
  138. { castsource => 'int4', casttarget => 'regprocedure', castfunc => '0',
  139. castcontext => 'i', castmethod => 'b' },
  140. { castsource => 'regprocedure', casttarget => 'int8', castfunc => 'int8(oid)',
  141. castcontext => 'a', castmethod => 'f' },
  142. { castsource => 'regprocedure', casttarget => 'int4', castfunc => '0',
  143. castcontext => 'a', castmethod => 'b' },
  144. { castsource => 'oid', casttarget => 'regoper', castfunc => '0',
  145. castcontext => 'i', castmethod => 'b' },
  146. { castsource => 'regoper', casttarget => 'oid', castfunc => '0',
  147. castcontext => 'i', castmethod => 'b' },
  148. { castsource => 'int8', casttarget => 'regoper', castfunc => 'oid',
  149. castcontext => 'i', castmethod => 'f' },
  150. { castsource => 'int2', casttarget => 'regoper', castfunc => 'int4(int2)',
  151. castcontext => 'i', castmethod => 'f' },
  152. { castsource => 'int4', casttarget => 'regoper', castfunc => '0',
  153. castcontext => 'i', castmethod => 'b' },
  154. { castsource => 'regoper', casttarget => 'int8', castfunc => 'int8(oid)',
  155. castcontext => 'a', castmethod => 'f' },
  156. { castsource => 'regoper', casttarget => 'int4', castfunc => '0',
  157. castcontext => 'a', castmethod => 'b' },
  158. { castsource => 'regoper', casttarget => 'regoperator', castfunc => '0',
  159. castcontext => 'i', castmethod => 'b' },
  160. { castsource => 'regoperator', casttarget => 'regoper', castfunc => '0',
  161. castcontext => 'i', castmethod => 'b' },
  162. { castsource => 'oid', casttarget => 'regoperator', castfunc => '0',
  163. castcontext => 'i', castmethod => 'b' },
  164. { castsource => 'regoperator', casttarget => 'oid', castfunc => '0',
  165. castcontext => 'i', castmethod => 'b' },
  166. { castsource => 'int8', casttarget => 'regoperator', castfunc => 'oid',
  167. castcontext => 'i', castmethod => 'f' },
  168. { castsource => 'int2', casttarget => 'regoperator', castfunc => 'int4(int2)',
  169. castcontext => 'i', castmethod => 'f' },
  170. { castsource => 'int4', casttarget => 'regoperator', castfunc => '0',
  171. castcontext => 'i', castmethod => 'b' },
  172. { castsource => 'regoperator', casttarget => 'int8', castfunc => 'int8(oid)',
  173. castcontext => 'a', castmethod => 'f' },
  174. { castsource => 'regoperator', casttarget => 'int4', castfunc => '0',
  175. castcontext => 'a', castmethod => 'b' },
  176. { castsource => 'oid', casttarget => 'regclass', castfunc => '0',
  177. castcontext => 'i', castmethod => 'b' },
  178. { castsource => 'regclass', casttarget => 'oid', castfunc => '0',
  179. castcontext => 'i', castmethod => 'b' },
  180. { castsource => 'int8', casttarget => 'regclass', castfunc => 'oid',
  181. castcontext => 'i', castmethod => 'f' },
  182. { castsource => 'int2', casttarget => 'regclass', castfunc => 'int4(int2)',
  183. castcontext => 'i', castmethod => 'f' },
  184. { castsource => 'int4', casttarget => 'regclass', castfunc => '0',
  185. castcontext => 'i', castmethod => 'b' },
  186. { castsource => 'regclass', casttarget => 'int8', castfunc => 'int8(oid)',
  187. castcontext => 'a', castmethod => 'f' },
  188. { castsource => 'regclass', casttarget => 'int4', castfunc => '0',
  189. castcontext => 'a', castmethod => 'b' },
  190. { castsource => 'oid', casttarget => 'regcollation', castfunc => '0',
  191. castcontext => 'i', castmethod => 'b' },
  192. { castsource => 'regcollation', casttarget => 'oid', castfunc => '0',
  193. castcontext => 'i', castmethod => 'b' },
  194. { castsource => 'int8', casttarget => 'regcollation', castfunc => 'oid',
  195. castcontext => 'i', castmethod => 'f' },
  196. { castsource => 'int2', casttarget => 'regcollation', castfunc => 'int4(int2)',
  197. castcontext => 'i', castmethod => 'f' },
  198. { castsource => 'int4', casttarget => 'regcollation', castfunc => '0',
  199. castcontext => 'i', castmethod => 'b' },
  200. { castsource => 'regcollation', casttarget => 'int8', castfunc => 'int8(oid)',
  201. castcontext => 'a', castmethod => 'f' },
  202. { castsource => 'regcollation', casttarget => 'int4', castfunc => '0',
  203. castcontext => 'a', castmethod => 'b' },
  204. { castsource => 'oid', casttarget => 'regtype', castfunc => '0',
  205. castcontext => 'i', castmethod => 'b' },
  206. { castsource => 'regtype', casttarget => 'oid', castfunc => '0',
  207. castcontext => 'i', castmethod => 'b' },
  208. { castsource => 'int8', casttarget => 'regtype', castfunc => 'oid',
  209. castcontext => 'i', castmethod => 'f' },
  210. { castsource => 'int2', casttarget => 'regtype', castfunc => 'int4(int2)',
  211. castcontext => 'i', castmethod => 'f' },
  212. { castsource => 'int4', casttarget => 'regtype', castfunc => '0',
  213. castcontext => 'i', castmethod => 'b' },
  214. { castsource => 'regtype', casttarget => 'int8', castfunc => 'int8(oid)',
  215. castcontext => 'a', castmethod => 'f' },
  216. { castsource => 'regtype', casttarget => 'int4', castfunc => '0',
  217. castcontext => 'a', castmethod => 'b' },
  218. { castsource => 'oid', casttarget => 'regconfig', castfunc => '0',
  219. castcontext => 'i', castmethod => 'b' },
  220. { castsource => 'regconfig', casttarget => 'oid', castfunc => '0',
  221. castcontext => 'i', castmethod => 'b' },
  222. { castsource => 'int8', casttarget => 'regconfig', castfunc => 'oid',
  223. castcontext => 'i', castmethod => 'f' },
  224. { castsource => 'int2', casttarget => 'regconfig', castfunc => 'int4(int2)',
  225. castcontext => 'i', castmethod => 'f' },
  226. { castsource => 'int4', casttarget => 'regconfig', castfunc => '0',
  227. castcontext => 'i', castmethod => 'b' },
  228. { castsource => 'regconfig', casttarget => 'int8', castfunc => 'int8(oid)',
  229. castcontext => 'a', castmethod => 'f' },
  230. { castsource => 'regconfig', casttarget => 'int4', castfunc => '0',
  231. castcontext => 'a', castmethod => 'b' },
  232. { castsource => 'oid', casttarget => 'regdictionary', castfunc => '0',
  233. castcontext => 'i', castmethod => 'b' },
  234. { castsource => 'regdictionary', casttarget => 'oid', castfunc => '0',
  235. castcontext => 'i', castmethod => 'b' },
  236. { castsource => 'int8', casttarget => 'regdictionary', castfunc => 'oid',
  237. castcontext => 'i', castmethod => 'f' },
  238. { castsource => 'int2', casttarget => 'regdictionary', castfunc => 'int4(int2)',
  239. castcontext => 'i', castmethod => 'f' },
  240. { castsource => 'int4', casttarget => 'regdictionary', castfunc => '0',
  241. castcontext => 'i', castmethod => 'b' },
  242. { castsource => 'regdictionary', casttarget => 'int8', castfunc => 'int8(oid)',
  243. castcontext => 'a', castmethod => 'f' },
  244. { castsource => 'regdictionary', casttarget => 'int4', castfunc => '0',
  245. castcontext => 'a', castmethod => 'b' },
  246. { castsource => 'text', casttarget => 'regclass', castfunc => 'regclass',
  247. castcontext => 'i', castmethod => 'f' },
  248. { castsource => 'varchar', casttarget => 'regclass', castfunc => 'regclass',
  249. castcontext => 'i', castmethod => 'f' },
  250. { castsource => 'oid', casttarget => 'regrole', castfunc => '0',
  251. castcontext => 'i', castmethod => 'b' },
  252. { castsource => 'regrole', casttarget => 'oid', castfunc => '0',
  253. castcontext => 'i', castmethod => 'b' },
  254. { castsource => 'int8', casttarget => 'regrole', castfunc => 'oid',
  255. castcontext => 'i', castmethod => 'f' },
  256. { castsource => 'int2', casttarget => 'regrole', castfunc => 'int4(int2)',
  257. castcontext => 'i', castmethod => 'f' },
  258. { castsource => 'int4', casttarget => 'regrole', castfunc => '0',
  259. castcontext => 'i', castmethod => 'b' },
  260. { castsource => 'regrole', casttarget => 'int8', castfunc => 'int8(oid)',
  261. castcontext => 'a', castmethod => 'f' },
  262. { castsource => 'regrole', casttarget => 'int4', castfunc => '0',
  263. castcontext => 'a', castmethod => 'b' },
  264. { castsource => 'oid', casttarget => 'regnamespace', castfunc => '0',
  265. castcontext => 'i', castmethod => 'b' },
  266. { castsource => 'regnamespace', casttarget => 'oid', castfunc => '0',
  267. castcontext => 'i', castmethod => 'b' },
  268. { castsource => 'int8', casttarget => 'regnamespace', castfunc => 'oid',
  269. castcontext => 'i', castmethod => 'f' },
  270. { castsource => 'int2', casttarget => 'regnamespace', castfunc => 'int4(int2)',
  271. castcontext => 'i', castmethod => 'f' },
  272. { castsource => 'int4', casttarget => 'regnamespace', castfunc => '0',
  273. castcontext => 'i', castmethod => 'b' },
  274. { castsource => 'regnamespace', casttarget => 'int8', castfunc => 'int8(oid)',
  275. castcontext => 'a', castmethod => 'f' },
  276. { castsource => 'regnamespace', casttarget => 'int4', castfunc => '0',
  277. castcontext => 'a', castmethod => 'b' },
  278. # String category
  279. { castsource => 'text', casttarget => 'bpchar', castfunc => '0',
  280. castcontext => 'i', castmethod => 'b' },
  281. { castsource => 'text', casttarget => 'varchar', castfunc => '0',
  282. castcontext => 'i', castmethod => 'b' },
  283. { castsource => 'bpchar', casttarget => 'text', castfunc => 'text(bpchar)',
  284. castcontext => 'i', castmethod => 'f' },
  285. { castsource => 'bpchar', casttarget => 'varchar', castfunc => 'text(bpchar)',
  286. castcontext => 'i', castmethod => 'f' },
  287. { castsource => 'varchar', casttarget => 'text', castfunc => '0',
  288. castcontext => 'i', castmethod => 'b' },
  289. { castsource => 'varchar', casttarget => 'bpchar', castfunc => '0',
  290. castcontext => 'i', castmethod => 'b' },
  291. { castsource => 'char', casttarget => 'text', castfunc => 'text(char)',
  292. castcontext => 'i', castmethod => 'f' },
  293. { castsource => 'char', casttarget => 'bpchar', castfunc => 'bpchar(char)',
  294. castcontext => 'a', castmethod => 'f' },
  295. { castsource => 'char', casttarget => 'varchar', castfunc => 'text(char)',
  296. castcontext => 'a', castmethod => 'f' },
  297. { castsource => 'name', casttarget => 'text', castfunc => 'text(name)',
  298. castcontext => 'i', castmethod => 'f' },
  299. { castsource => 'name', casttarget => 'bpchar', castfunc => 'bpchar(name)',
  300. castcontext => 'a', castmethod => 'f' },
  301. { castsource => 'name', casttarget => 'varchar', castfunc => 'varchar(name)',
  302. castcontext => 'a', castmethod => 'f' },
  303. { castsource => 'text', casttarget => 'char', castfunc => 'char(text)',
  304. castcontext => 'a', castmethod => 'f' },
  305. { castsource => 'bpchar', casttarget => 'char', castfunc => 'char(text)',
  306. castcontext => 'a', castmethod => 'f' },
  307. { castsource => 'varchar', casttarget => 'char', castfunc => 'char(text)',
  308. castcontext => 'a', castmethod => 'f' },
  309. { castsource => 'text', casttarget => 'name', castfunc => 'name(text)',
  310. castcontext => 'i', castmethod => 'f' },
  311. { castsource => 'bpchar', casttarget => 'name', castfunc => 'name(bpchar)',
  312. castcontext => 'i', castmethod => 'f' },
  313. { castsource => 'varchar', casttarget => 'name', castfunc => 'name(varchar)',
  314. castcontext => 'i', castmethod => 'f' },
  315. # Allow explicit coercions between int4 and "char"
  316. { castsource => 'char', casttarget => 'int4', castfunc => 'int4(char)',
  317. castcontext => 'e', castmethod => 'f' },
  318. { castsource => 'int4', casttarget => 'char', castfunc => 'char(int4)',
  319. castcontext => 'e', castmethod => 'f' },
  320. # pg_node_tree can be coerced to, but not from, text
  321. { castsource => 'pg_node_tree', casttarget => 'text', castfunc => '0',
  322. castcontext => 'i', castmethod => 'b' },
  323. # pg_ndistinct can be coerced to, but not from, bytea and text
  324. { castsource => 'pg_ndistinct', casttarget => 'bytea', castfunc => '0',
  325. castcontext => 'i', castmethod => 'b' },
  326. { castsource => 'pg_ndistinct', casttarget => 'text', castfunc => '0',
  327. castcontext => 'i', castmethod => 'i' },
  328. # pg_dependencies can be coerced to, but not from, bytea and text
  329. { castsource => 'pg_dependencies', casttarget => 'bytea', castfunc => '0',
  330. castcontext => 'i', castmethod => 'b' },
  331. { castsource => 'pg_dependencies', casttarget => 'text', castfunc => '0',
  332. castcontext => 'i', castmethod => 'i' },
  333. # pg_mcv_list can be coerced to, but not from, bytea and text
  334. { castsource => 'pg_mcv_list', casttarget => 'bytea', castfunc => '0',
  335. castcontext => 'i', castmethod => 'b' },
  336. { castsource => 'pg_mcv_list', casttarget => 'text', castfunc => '0',
  337. castcontext => 'i', castmethod => 'i' },
  338. # Datetime category
  339. { castsource => 'date', casttarget => 'timestamp',
  340. castfunc => 'timestamp(date)', castcontext => 'i', castmethod => 'f' },
  341. { castsource => 'date', casttarget => 'timestamptz',
  342. castfunc => 'timestamptz(date)', castcontext => 'i', castmethod => 'f' },
  343. { castsource => 'time', casttarget => 'interval', castfunc => 'interval(time)',
  344. castcontext => 'i', castmethod => 'f' },
  345. { castsource => 'time', casttarget => 'timetz', castfunc => 'timetz(time)',
  346. castcontext => 'i', castmethod => 'f' },
  347. { castsource => 'timestamp', casttarget => 'date',
  348. castfunc => 'date(timestamp)', castcontext => 'a', castmethod => 'f' },
  349. { castsource => 'timestamp', casttarget => 'time',
  350. castfunc => 'time(timestamp)', castcontext => 'a', castmethod => 'f' },
  351. { castsource => 'timestamp', casttarget => 'timestamptz',
  352. castfunc => 'timestamptz(timestamp)', castcontext => 'i', castmethod => 'f' },
  353. { castsource => 'timestamptz', casttarget => 'date',
  354. castfunc => 'date(timestamptz)', castcontext => 'a', castmethod => 'f' },
  355. { castsource => 'timestamptz', casttarget => 'time',
  356. castfunc => 'time(timestamptz)', castcontext => 'a', castmethod => 'f' },
  357. { castsource => 'timestamptz', casttarget => 'timestamp',
  358. castfunc => 'timestamp(timestamptz)', castcontext => 'a', castmethod => 'f' },
  359. { castsource => 'timestamptz', casttarget => 'timetz',
  360. castfunc => 'timetz(timestamptz)', castcontext => 'a', castmethod => 'f' },
  361. { castsource => 'interval', casttarget => 'time', castfunc => 'time(interval)',
  362. castcontext => 'a', castmethod => 'f' },
  363. { castsource => 'timetz', casttarget => 'time', castfunc => 'time(timetz)',
  364. castcontext => 'a', castmethod => 'f' },
  365. # Geometric category
  366. { castsource => 'point', casttarget => 'box', castfunc => 'box(point)',
  367. castcontext => 'a', castmethod => 'f' },
  368. { castsource => 'lseg', casttarget => 'point', castfunc => 'point(lseg)',
  369. castcontext => 'e', castmethod => 'f' },
  370. { castsource => 'path', casttarget => 'polygon', castfunc => 'polygon(path)',
  371. castcontext => 'a', castmethod => 'f' },
  372. { castsource => 'box', casttarget => 'point', castfunc => 'point(box)',
  373. castcontext => 'e', castmethod => 'f' },
  374. { castsource => 'box', casttarget => 'lseg', castfunc => 'lseg(box)',
  375. castcontext => 'e', castmethod => 'f' },
  376. { castsource => 'box', casttarget => 'polygon', castfunc => 'polygon(box)',
  377. castcontext => 'a', castmethod => 'f' },
  378. { castsource => 'box', casttarget => 'circle', castfunc => 'circle(box)',
  379. castcontext => 'e', castmethod => 'f' },
  380. { castsource => 'polygon', casttarget => 'point', castfunc => 'point(polygon)',
  381. castcontext => 'e', castmethod => 'f' },
  382. { castsource => 'polygon', casttarget => 'path', castfunc => 'path',
  383. castcontext => 'a', castmethod => 'f' },
  384. { castsource => 'polygon', casttarget => 'box', castfunc => 'box(polygon)',
  385. castcontext => 'e', castmethod => 'f' },
  386. { castsource => 'polygon', casttarget => 'circle',
  387. castfunc => 'circle(polygon)', castcontext => 'e', castmethod => 'f' },
  388. { castsource => 'circle', casttarget => 'point', castfunc => 'point(circle)',
  389. castcontext => 'e', castmethod => 'f' },
  390. { castsource => 'circle', casttarget => 'box', castfunc => 'box(circle)',
  391. castcontext => 'e', castmethod => 'f' },
  392. { castsource => 'circle', casttarget => 'polygon',
  393. castfunc => 'polygon(circle)', castcontext => 'e', castmethod => 'f' },
  394. # MAC address category
  395. { castsource => 'macaddr', casttarget => 'macaddr8', castfunc => 'macaddr8',
  396. castcontext => 'i', castmethod => 'f' },
  397. { castsource => 'macaddr8', casttarget => 'macaddr', castfunc => 'macaddr',
  398. castcontext => 'i', castmethod => 'f' },
  399. # INET category
  400. { castsource => 'cidr', casttarget => 'inet', castfunc => '0',
  401. castcontext => 'i', castmethod => 'b' },
  402. { castsource => 'inet', casttarget => 'cidr', castfunc => 'cidr',
  403. castcontext => 'a', castmethod => 'f' },
  404. # BitString category
  405. { castsource => 'bit', casttarget => 'varbit', castfunc => '0',
  406. castcontext => 'i', castmethod => 'b' },
  407. { castsource => 'varbit', casttarget => 'bit', castfunc => '0',
  408. castcontext => 'i', castmethod => 'b' },
  409. # Cross-category casts between bit and int4, int8
  410. { castsource => 'int8', casttarget => 'bit', castfunc => 'bit(int8,int4)',
  411. castcontext => 'e', castmethod => 'f' },
  412. { castsource => 'int4', casttarget => 'bit', castfunc => 'bit(int4,int4)',
  413. castcontext => 'e', castmethod => 'f' },
  414. { castsource => 'bit', casttarget => 'int8', castfunc => 'int8(bit)',
  415. castcontext => 'e', castmethod => 'f' },
  416. { castsource => 'bit', casttarget => 'int4', castfunc => 'int4(bit)',
  417. castcontext => 'e', castmethod => 'f' },
  418. # Cross-category casts to and from TEXT
  419. # We need entries here only for a few specialized cases where the behavior
  420. # of the cast function differs from the datatype's I/O functions. Otherwise,
  421. # parse_coerce.c will generate CoerceViaIO operations without any prompting.
  422. # Note that the castcontext values specified here should be no stronger than
  423. # parse_coerce.c's automatic casts ('a' to text, 'e' from text) else odd
  424. # behavior will ensue when the automatic cast is applied instead of the
  425. # pg_cast entry!
  426. { castsource => 'cidr', casttarget => 'text', castfunc => 'text(inet)',
  427. castcontext => 'a', castmethod => 'f' },
  428. { castsource => 'inet', casttarget => 'text', castfunc => 'text(inet)',
  429. castcontext => 'a', castmethod => 'f' },
  430. { castsource => 'bool', casttarget => 'text', castfunc => 'text(bool)',
  431. castcontext => 'a', castmethod => 'f' },
  432. { castsource => 'xml', casttarget => 'text', castfunc => '0',
  433. castcontext => 'a', castmethod => 'b' },
  434. { castsource => 'text', casttarget => 'xml', castfunc => 'xml',
  435. castcontext => 'e', castmethod => 'f' },
  436. # Cross-category casts to and from VARCHAR
  437. # We support all the same casts as for TEXT.
  438. { castsource => 'cidr', casttarget => 'varchar', castfunc => 'text(inet)',
  439. castcontext => 'a', castmethod => 'f' },
  440. { castsource => 'inet', casttarget => 'varchar', castfunc => 'text(inet)',
  441. castcontext => 'a', castmethod => 'f' },
  442. { castsource => 'bool', casttarget => 'varchar', castfunc => 'text(bool)',
  443. castcontext => 'a', castmethod => 'f' },
  444. { castsource => 'xml', casttarget => 'varchar', castfunc => '0',
  445. castcontext => 'a', castmethod => 'b' },
  446. { castsource => 'varchar', casttarget => 'xml', castfunc => 'xml',
  447. castcontext => 'e', castmethod => 'f' },
  448. # Cross-category casts to and from BPCHAR
  449. # We support all the same casts as for TEXT.
  450. { castsource => 'cidr', casttarget => 'bpchar', castfunc => 'text(inet)',
  451. castcontext => 'a', castmethod => 'f' },
  452. { castsource => 'inet', casttarget => 'bpchar', castfunc => 'text(inet)',
  453. castcontext => 'a', castmethod => 'f' },
  454. { castsource => 'bool', casttarget => 'bpchar', castfunc => 'text(bool)',
  455. castcontext => 'a', castmethod => 'f' },
  456. { castsource => 'xml', casttarget => 'bpchar', castfunc => '0',
  457. castcontext => 'a', castmethod => 'b' },
  458. { castsource => 'bpchar', casttarget => 'xml', castfunc => 'xml',
  459. castcontext => 'e', castmethod => 'f' },
  460. # Length-coercion functions
  461. { castsource => 'bpchar', casttarget => 'bpchar',
  462. castfunc => 'bpchar(bpchar,int4,bool)', castcontext => 'i',
  463. castmethod => 'f' },
  464. { castsource => 'varchar', casttarget => 'varchar',
  465. castfunc => 'varchar(varchar,int4,bool)', castcontext => 'i',
  466. castmethod => 'f' },
  467. { castsource => 'time', casttarget => 'time', castfunc => 'time(time,int4)',
  468. castcontext => 'i', castmethod => 'f' },
  469. { castsource => 'timestamp', casttarget => 'timestamp',
  470. castfunc => 'timestamp(timestamp,int4)', castcontext => 'i',
  471. castmethod => 'f' },
  472. { castsource => 'timestamptz', casttarget => 'timestamptz',
  473. castfunc => 'timestamptz(timestamptz,int4)', castcontext => 'i',
  474. castmethod => 'f' },
  475. { castsource => 'interval', casttarget => 'interval',
  476. castfunc => 'interval(interval,int4)', castcontext => 'i',
  477. castmethod => 'f' },
  478. { castsource => 'timetz', casttarget => 'timetz',
  479. castfunc => 'timetz(timetz,int4)', castcontext => 'i', castmethod => 'f' },
  480. { castsource => 'bit', casttarget => 'bit', castfunc => 'bit(bit,int4,bool)',
  481. castcontext => 'i', castmethod => 'f' },
  482. { castsource => 'varbit', casttarget => 'varbit', castfunc => 'varbit',
  483. castcontext => 'i', castmethod => 'f' },
  484. { castsource => 'numeric', casttarget => 'numeric',
  485. castfunc => 'numeric(numeric,int4)', castcontext => 'i', castmethod => 'f' },
  486. # json to/from jsonb
  487. { castsource => 'json', casttarget => 'jsonb', castfunc => '0',
  488. castcontext => 'a', castmethod => 'i' },
  489. { castsource => 'jsonb', casttarget => 'json', castfunc => '0',
  490. castcontext => 'a', castmethod => 'i' },
  491. # jsonb to numeric and bool types
  492. { castsource => 'jsonb', casttarget => 'bool', castfunc => 'bool(jsonb)',
  493. castcontext => 'e', castmethod => 'f' },
  494. { castsource => 'jsonb', casttarget => 'numeric', castfunc => 'numeric(jsonb)',
  495. castcontext => 'e', castmethod => 'f' },
  496. { castsource => 'jsonb', casttarget => 'int2', castfunc => 'int2(jsonb)',
  497. castcontext => 'e', castmethod => 'f' },
  498. { castsource => 'jsonb', casttarget => 'int4', castfunc => 'int4(jsonb)',
  499. castcontext => 'e', castmethod => 'f' },
  500. { castsource => 'jsonb', casttarget => 'int8', castfunc => 'int8(jsonb)',
  501. castcontext => 'e', castmethod => 'f' },
  502. { castsource => 'jsonb', casttarget => 'float4', castfunc => 'float4(jsonb)',
  503. castcontext => 'e', castmethod => 'f' },
  504. { castsource => 'jsonb', casttarget => 'float8', castfunc => 'float8(jsonb)',
  505. castcontext => 'e', castmethod => 'f' },
  506. # range to multirange
  507. { castsource => 'int4range', casttarget => 'int4multirange',
  508. castfunc => 'int4multirange(int4range)', castcontext => 'e',
  509. castmethod => 'f' },
  510. { castsource => 'int8range', casttarget => 'int8multirange',
  511. castfunc => 'int8multirange(int8range)', castcontext => 'e',
  512. castmethod => 'f' },
  513. { castsource => 'numrange', casttarget => 'nummultirange',
  514. castfunc => 'nummultirange(numrange)', castcontext => 'e',
  515. castmethod => 'f' },
  516. { castsource => 'daterange', casttarget => 'datemultirange',
  517. castfunc => 'datemultirange(daterange)', castcontext => 'e',
  518. castmethod => 'f' },
  519. { castsource => 'tsrange', casttarget => 'tsmultirange',
  520. castfunc => 'tsmultirange(tsrange)', castcontext => 'e', castmethod => 'f' },
  521. { castsource => 'tstzrange', casttarget => 'tstzmultirange',
  522. castfunc => 'tstzmultirange(tstzrange)', castcontext => 'e',
  523. castmethod => 'f' },
  524. ]