pg_query 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (375) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/ext/pg_query/include/access/amapi.h +246 -0
  4. data/ext/pg_query/include/access/attmap.h +52 -0
  5. data/ext/pg_query/include/access/attnum.h +64 -0
  6. data/ext/pg_query/include/access/clog.h +61 -0
  7. data/ext/pg_query/include/access/commit_ts.h +77 -0
  8. data/ext/pg_query/include/access/detoast.h +92 -0
  9. data/ext/pg_query/include/access/genam.h +228 -0
  10. data/ext/pg_query/include/access/gin.h +78 -0
  11. data/ext/pg_query/include/access/htup.h +89 -0
  12. data/ext/pg_query/include/access/htup_details.h +819 -0
  13. data/ext/pg_query/include/access/itup.h +161 -0
  14. data/ext/pg_query/include/access/parallel.h +82 -0
  15. data/ext/pg_query/include/access/printtup.h +35 -0
  16. data/ext/pg_query/include/access/relation.h +28 -0
  17. data/ext/pg_query/include/access/relscan.h +176 -0
  18. data/ext/pg_query/include/access/rmgr.h +35 -0
  19. data/ext/pg_query/include/access/rmgrlist.h +49 -0
  20. data/ext/pg_query/include/access/sdir.h +58 -0
  21. data/ext/pg_query/include/access/skey.h +151 -0
  22. data/ext/pg_query/include/access/stratnum.h +83 -0
  23. data/ext/pg_query/include/access/sysattr.h +29 -0
  24. data/ext/pg_query/include/access/table.h +27 -0
  25. data/ext/pg_query/include/access/tableam.h +1825 -0
  26. data/ext/pg_query/include/access/transam.h +265 -0
  27. data/ext/pg_query/include/access/tupconvert.h +51 -0
  28. data/ext/pg_query/include/access/tupdesc.h +154 -0
  29. data/ext/pg_query/include/access/tupmacs.h +247 -0
  30. data/ext/pg_query/include/access/twophase.h +61 -0
  31. data/ext/pg_query/include/access/xact.h +463 -0
  32. data/ext/pg_query/include/access/xlog.h +398 -0
  33. data/ext/pg_query/include/access/xlog_internal.h +330 -0
  34. data/ext/pg_query/include/access/xlogdefs.h +109 -0
  35. data/ext/pg_query/include/access/xloginsert.h +64 -0
  36. data/ext/pg_query/include/access/xlogreader.h +327 -0
  37. data/ext/pg_query/include/access/xlogrecord.h +227 -0
  38. data/ext/pg_query/include/bootstrap/bootstrap.h +62 -0
  39. data/ext/pg_query/include/c.h +1322 -0
  40. data/ext/pg_query/include/catalog/catalog.h +42 -0
  41. data/ext/pg_query/include/catalog/catversion.h +58 -0
  42. data/ext/pg_query/include/catalog/dependency.h +275 -0
  43. data/ext/pg_query/include/catalog/genbki.h +64 -0
  44. data/ext/pg_query/include/catalog/index.h +199 -0
  45. data/ext/pg_query/include/catalog/indexing.h +366 -0
  46. data/ext/pg_query/include/catalog/namespace.h +188 -0
  47. data/ext/pg_query/include/catalog/objectaccess.h +197 -0
  48. data/ext/pg_query/include/catalog/objectaddress.h +84 -0
  49. data/ext/pg_query/include/catalog/pg_aggregate.h +176 -0
  50. data/ext/pg_query/include/catalog/pg_aggregate_d.h +77 -0
  51. data/ext/pg_query/include/catalog/pg_am.h +60 -0
  52. data/ext/pg_query/include/catalog/pg_am_d.h +45 -0
  53. data/ext/pg_query/include/catalog/pg_attribute.h +204 -0
  54. data/ext/pg_query/include/catalog/pg_attribute_d.h +59 -0
  55. data/ext/pg_query/include/catalog/pg_authid.h +58 -0
  56. data/ext/pg_query/include/catalog/pg_authid_d.h +49 -0
  57. data/ext/pg_query/include/catalog/pg_class.h +200 -0
  58. data/ext/pg_query/include/catalog/pg_class_d.h +103 -0
  59. data/ext/pg_query/include/catalog/pg_collation.h +73 -0
  60. data/ext/pg_query/include/catalog/pg_collation_d.h +45 -0
  61. data/ext/pg_query/include/catalog/pg_constraint.h +247 -0
  62. data/ext/pg_query/include/catalog/pg_constraint_d.h +67 -0
  63. data/ext/pg_query/include/catalog/pg_control.h +250 -0
  64. data/ext/pg_query/include/catalog/pg_conversion.h +72 -0
  65. data/ext/pg_query/include/catalog/pg_conversion_d.h +35 -0
  66. data/ext/pg_query/include/catalog/pg_depend.h +73 -0
  67. data/ext/pg_query/include/catalog/pg_depend_d.h +34 -0
  68. data/ext/pg_query/include/catalog/pg_event_trigger.h +51 -0
  69. data/ext/pg_query/include/catalog/pg_event_trigger_d.h +34 -0
  70. data/ext/pg_query/include/catalog/pg_index.h +80 -0
  71. data/ext/pg_query/include/catalog/pg_index_d.h +56 -0
  72. data/ext/pg_query/include/catalog/pg_language.h +67 -0
  73. data/ext/pg_query/include/catalog/pg_language_d.h +39 -0
  74. data/ext/pg_query/include/catalog/pg_namespace.h +59 -0
  75. data/ext/pg_query/include/catalog/pg_namespace_d.h +34 -0
  76. data/ext/pg_query/include/catalog/pg_opclass.h +85 -0
  77. data/ext/pg_query/include/catalog/pg_opclass_d.h +49 -0
  78. data/ext/pg_query/include/catalog/pg_operator.h +102 -0
  79. data/ext/pg_query/include/catalog/pg_operator_d.h +106 -0
  80. data/ext/pg_query/include/catalog/pg_opfamily.h +60 -0
  81. data/ext/pg_query/include/catalog/pg_opfamily_d.h +47 -0
  82. data/ext/pg_query/include/catalog/pg_partitioned_table.h +63 -0
  83. data/ext/pg_query/include/catalog/pg_partitioned_table_d.h +35 -0
  84. data/ext/pg_query/include/catalog/pg_proc.h +211 -0
  85. data/ext/pg_query/include/catalog/pg_proc_d.h +99 -0
  86. data/ext/pg_query/include/catalog/pg_publication.h +115 -0
  87. data/ext/pg_query/include/catalog/pg_publication_d.h +36 -0
  88. data/ext/pg_query/include/catalog/pg_replication_origin.h +57 -0
  89. data/ext/pg_query/include/catalog/pg_replication_origin_d.h +29 -0
  90. data/ext/pg_query/include/catalog/pg_statistic.h +275 -0
  91. data/ext/pg_query/include/catalog/pg_statistic_d.h +194 -0
  92. data/ext/pg_query/include/catalog/pg_statistic_ext.h +74 -0
  93. data/ext/pg_query/include/catalog/pg_statistic_ext_d.h +40 -0
  94. data/ext/pg_query/include/catalog/pg_transform.h +45 -0
  95. data/ext/pg_query/include/catalog/pg_transform_d.h +32 -0
  96. data/ext/pg_query/include/catalog/pg_trigger.h +137 -0
  97. data/ext/pg_query/include/catalog/pg_trigger_d.h +106 -0
  98. data/ext/pg_query/include/catalog/pg_ts_config.h +50 -0
  99. data/ext/pg_query/include/catalog/pg_ts_config_d.h +32 -0
  100. data/ext/pg_query/include/catalog/pg_ts_dict.h +54 -0
  101. data/ext/pg_query/include/catalog/pg_ts_dict_d.h +33 -0
  102. data/ext/pg_query/include/catalog/pg_ts_parser.h +57 -0
  103. data/ext/pg_query/include/catalog/pg_ts_parser_d.h +35 -0
  104. data/ext/pg_query/include/catalog/pg_ts_template.h +48 -0
  105. data/ext/pg_query/include/catalog/pg_ts_template_d.h +32 -0
  106. data/ext/pg_query/include/catalog/pg_type.h +372 -0
  107. data/ext/pg_query/include/catalog/pg_type_d.h +285 -0
  108. data/ext/pg_query/include/catalog/storage.h +48 -0
  109. data/ext/pg_query/include/commands/async.h +54 -0
  110. data/ext/pg_query/include/commands/dbcommands.h +35 -0
  111. data/ext/pg_query/include/commands/defrem.h +173 -0
  112. data/ext/pg_query/include/commands/event_trigger.h +88 -0
  113. data/ext/pg_query/include/commands/explain.h +127 -0
  114. data/ext/pg_query/include/commands/prepare.h +61 -0
  115. data/ext/pg_query/include/commands/tablespace.h +67 -0
  116. data/ext/pg_query/include/commands/trigger.h +277 -0
  117. data/ext/pg_query/include/commands/user.h +37 -0
  118. data/ext/pg_query/include/commands/vacuum.h +293 -0
  119. data/ext/pg_query/include/commands/variable.h +38 -0
  120. data/ext/pg_query/include/common/file_perm.h +56 -0
  121. data/ext/pg_query/include/common/hashfn.h +104 -0
  122. data/ext/pg_query/include/common/ip.h +37 -0
  123. data/ext/pg_query/include/common/keywords.h +33 -0
  124. data/ext/pg_query/include/common/kwlookup.h +44 -0
  125. data/ext/pg_query/include/common/relpath.h +90 -0
  126. data/ext/pg_query/include/common/string.h +19 -0
  127. data/ext/pg_query/include/common/unicode_combining_table.h +196 -0
  128. data/ext/pg_query/include/datatype/timestamp.h +197 -0
  129. data/ext/pg_query/include/executor/execdesc.h +70 -0
  130. data/ext/pg_query/include/executor/executor.h +614 -0
  131. data/ext/pg_query/include/executor/functions.h +41 -0
  132. data/ext/pg_query/include/executor/instrument.h +101 -0
  133. data/ext/pg_query/include/executor/spi.h +175 -0
  134. data/ext/pg_query/include/executor/tablefunc.h +67 -0
  135. data/ext/pg_query/include/executor/tuptable.h +487 -0
  136. data/ext/pg_query/include/fmgr.h +775 -0
  137. data/ext/pg_query/include/funcapi.h +348 -0
  138. data/ext/pg_query/include/getaddrinfo.h +162 -0
  139. data/ext/pg_query/include/jit/jit.h +105 -0
  140. data/ext/pg_query/include/kwlist_d.h +1072 -0
  141. data/ext/pg_query/include/lib/ilist.h +727 -0
  142. data/ext/pg_query/include/lib/pairingheap.h +102 -0
  143. data/ext/pg_query/include/lib/simplehash.h +1059 -0
  144. data/ext/pg_query/include/lib/stringinfo.h +161 -0
  145. data/ext/pg_query/include/libpq/auth.h +29 -0
  146. data/ext/pg_query/include/libpq/crypt.h +46 -0
  147. data/ext/pg_query/include/libpq/hba.h +140 -0
  148. data/ext/pg_query/include/libpq/libpq-be.h +326 -0
  149. data/ext/pg_query/include/libpq/libpq.h +133 -0
  150. data/ext/pg_query/include/libpq/pqcomm.h +208 -0
  151. data/ext/pg_query/include/libpq/pqformat.h +210 -0
  152. data/ext/pg_query/include/libpq/pqsignal.h +42 -0
  153. data/ext/pg_query/include/mb/pg_wchar.h +672 -0
  154. data/ext/pg_query/include/mb/stringinfo_mb.h +24 -0
  155. data/ext/pg_query/include/miscadmin.h +476 -0
  156. data/ext/pg_query/include/nodes/bitmapset.h +122 -0
  157. data/ext/pg_query/include/nodes/execnodes.h +2520 -0
  158. data/ext/pg_query/include/nodes/extensible.h +160 -0
  159. data/ext/pg_query/include/nodes/lockoptions.h +61 -0
  160. data/ext/pg_query/include/nodes/makefuncs.h +108 -0
  161. data/ext/pg_query/include/nodes/memnodes.h +108 -0
  162. data/ext/pg_query/include/nodes/nodeFuncs.h +162 -0
  163. data/ext/pg_query/include/nodes/nodes.h +842 -0
  164. data/ext/pg_query/include/nodes/params.h +170 -0
  165. data/ext/pg_query/include/nodes/parsenodes.h +3579 -0
  166. data/ext/pg_query/include/nodes/pathnodes.h +2556 -0
  167. data/ext/pg_query/include/nodes/pg_list.h +605 -0
  168. data/ext/pg_query/include/nodes/plannodes.h +1251 -0
  169. data/ext/pg_query/include/nodes/primnodes.h +1541 -0
  170. data/ext/pg_query/include/nodes/print.h +34 -0
  171. data/ext/pg_query/include/nodes/tidbitmap.h +75 -0
  172. data/ext/pg_query/include/nodes/value.h +61 -0
  173. data/ext/pg_query/include/optimizer/cost.h +206 -0
  174. data/ext/pg_query/include/optimizer/geqo.h +88 -0
  175. data/ext/pg_query/include/optimizer/geqo_gene.h +45 -0
  176. data/ext/pg_query/include/optimizer/optimizer.h +199 -0
  177. data/ext/pg_query/include/optimizer/paths.h +249 -0
  178. data/ext/pg_query/include/optimizer/planmain.h +119 -0
  179. data/ext/pg_query/include/parser/analyze.h +49 -0
  180. data/ext/pg_query/include/parser/gram.h +1067 -0
  181. data/ext/pg_query/include/parser/gramparse.h +75 -0
  182. data/ext/pg_query/include/parser/kwlist.h +477 -0
  183. data/ext/pg_query/include/parser/parse_agg.h +68 -0
  184. data/ext/pg_query/include/parser/parse_clause.h +54 -0
  185. data/ext/pg_query/include/parser/parse_coerce.h +97 -0
  186. data/ext/pg_query/include/parser/parse_collate.h +27 -0
  187. data/ext/pg_query/include/parser/parse_expr.h +26 -0
  188. data/ext/pg_query/include/parser/parse_func.h +73 -0
  189. data/ext/pg_query/include/parser/parse_node.h +327 -0
  190. data/ext/pg_query/include/parser/parse_oper.h +67 -0
  191. data/ext/pg_query/include/parser/parse_relation.h +123 -0
  192. data/ext/pg_query/include/parser/parse_target.h +46 -0
  193. data/ext/pg_query/include/parser/parse_type.h +60 -0
  194. data/ext/pg_query/include/parser/parser.h +41 -0
  195. data/ext/pg_query/include/parser/parsetree.h +61 -0
  196. data/ext/pg_query/include/parser/scanner.h +152 -0
  197. data/ext/pg_query/include/parser/scansup.h +30 -0
  198. data/ext/pg_query/include/partitioning/partdefs.h +26 -0
  199. data/ext/pg_query/include/pg_config.h +988 -0
  200. data/ext/pg_query/include/pg_config_ext.h +8 -0
  201. data/ext/pg_query/include/pg_config_manual.h +350 -0
  202. data/ext/pg_query/include/pg_config_os.h +8 -0
  203. data/ext/pg_query/include/pg_getopt.h +56 -0
  204. data/ext/pg_query/include/pg_query.h +121 -0
  205. data/ext/pg_query/include/pg_query_enum_defs.c +2454 -0
  206. data/ext/pg_query/include/pg_query_fingerprint_conds.c +875 -0
  207. data/ext/pg_query/include/pg_query_fingerprint_defs.c +12413 -0
  208. data/ext/pg_query/include/pg_query_json_helper.c +61 -0
  209. data/ext/pg_query/include/pg_query_outfuncs_conds.c +686 -0
  210. data/ext/pg_query/include/pg_query_outfuncs_defs.c +2437 -0
  211. data/ext/pg_query/include/pg_query_readfuncs_conds.c +222 -0
  212. data/ext/pg_query/include/pg_query_readfuncs_defs.c +2878 -0
  213. data/ext/pg_query/include/pg_trace.h +17 -0
  214. data/ext/pg_query/include/pgstat.h +1487 -0
  215. data/ext/pg_query/include/pgtime.h +84 -0
  216. data/ext/pg_query/include/pl_gram.h +385 -0
  217. data/ext/pg_query/include/pl_reserved_kwlist.h +52 -0
  218. data/ext/pg_query/include/pl_reserved_kwlist_d.h +114 -0
  219. data/ext/pg_query/include/pl_unreserved_kwlist.h +112 -0
  220. data/ext/pg_query/include/pl_unreserved_kwlist_d.h +246 -0
  221. data/ext/pg_query/include/plerrcodes.h +990 -0
  222. data/ext/pg_query/include/plpgsql.h +1347 -0
  223. data/ext/pg_query/include/port.h +524 -0
  224. data/ext/pg_query/include/port/atomics.h +524 -0
  225. data/ext/pg_query/include/port/atomics/arch-arm.h +26 -0
  226. data/ext/pg_query/include/port/atomics/arch-ppc.h +254 -0
  227. data/ext/pg_query/include/port/atomics/arch-x86.h +252 -0
  228. data/ext/pg_query/include/port/atomics/fallback.h +170 -0
  229. data/ext/pg_query/include/port/atomics/generic-gcc.h +286 -0
  230. data/ext/pg_query/include/port/atomics/generic.h +401 -0
  231. data/ext/pg_query/include/port/pg_bitutils.h +226 -0
  232. data/ext/pg_query/include/port/pg_bswap.h +161 -0
  233. data/ext/pg_query/include/port/pg_crc32c.h +101 -0
  234. data/ext/pg_query/include/portability/instr_time.h +256 -0
  235. data/ext/pg_query/include/postgres.h +764 -0
  236. data/ext/pg_query/include/postgres_ext.h +74 -0
  237. data/ext/pg_query/include/postmaster/autovacuum.h +83 -0
  238. data/ext/pg_query/include/postmaster/bgworker.h +161 -0
  239. data/ext/pg_query/include/postmaster/bgworker_internals.h +64 -0
  240. data/ext/pg_query/include/postmaster/bgwriter.h +45 -0
  241. data/ext/pg_query/include/postmaster/fork_process.h +17 -0
  242. data/ext/pg_query/include/postmaster/interrupt.h +32 -0
  243. data/ext/pg_query/include/postmaster/pgarch.h +39 -0
  244. data/ext/pg_query/include/postmaster/postmaster.h +77 -0
  245. data/ext/pg_query/include/postmaster/syslogger.h +98 -0
  246. data/ext/pg_query/include/postmaster/walwriter.h +21 -0
  247. data/ext/pg_query/include/protobuf-c.h +1106 -0
  248. data/ext/pg_query/include/protobuf-c/protobuf-c.h +1106 -0
  249. data/ext/pg_query/include/protobuf/pg_query.pb-c.h +10846 -0
  250. data/ext/pg_query/include/protobuf/pg_query.pb.h +124718 -0
  251. data/ext/pg_query/include/regex/regex.h +184 -0
  252. data/ext/pg_query/include/replication/logicallauncher.h +31 -0
  253. data/ext/pg_query/include/replication/logicalproto.h +110 -0
  254. data/ext/pg_query/include/replication/logicalworker.h +19 -0
  255. data/ext/pg_query/include/replication/origin.h +73 -0
  256. data/ext/pg_query/include/replication/reorderbuffer.h +467 -0
  257. data/ext/pg_query/include/replication/slot.h +219 -0
  258. data/ext/pg_query/include/replication/syncrep.h +115 -0
  259. data/ext/pg_query/include/replication/walreceiver.h +340 -0
  260. data/ext/pg_query/include/replication/walsender.h +74 -0
  261. data/ext/pg_query/include/rewrite/prs2lock.h +46 -0
  262. data/ext/pg_query/include/rewrite/rewriteHandler.h +40 -0
  263. data/ext/pg_query/include/rewrite/rewriteManip.h +87 -0
  264. data/ext/pg_query/include/rewrite/rewriteSupport.h +26 -0
  265. data/ext/pg_query/include/storage/backendid.h +37 -0
  266. data/ext/pg_query/include/storage/block.h +121 -0
  267. data/ext/pg_query/include/storage/buf.h +46 -0
  268. data/ext/pg_query/include/storage/bufmgr.h +292 -0
  269. data/ext/pg_query/include/storage/bufpage.h +459 -0
  270. data/ext/pg_query/include/storage/condition_variable.h +62 -0
  271. data/ext/pg_query/include/storage/dsm.h +61 -0
  272. data/ext/pg_query/include/storage/dsm_impl.h +75 -0
  273. data/ext/pg_query/include/storage/fd.h +168 -0
  274. data/ext/pg_query/include/storage/ipc.h +81 -0
  275. data/ext/pg_query/include/storage/item.h +19 -0
  276. data/ext/pg_query/include/storage/itemid.h +184 -0
  277. data/ext/pg_query/include/storage/itemptr.h +206 -0
  278. data/ext/pg_query/include/storage/large_object.h +100 -0
  279. data/ext/pg_query/include/storage/latch.h +190 -0
  280. data/ext/pg_query/include/storage/lmgr.h +114 -0
  281. data/ext/pg_query/include/storage/lock.h +612 -0
  282. data/ext/pg_query/include/storage/lockdefs.h +59 -0
  283. data/ext/pg_query/include/storage/lwlock.h +232 -0
  284. data/ext/pg_query/include/storage/lwlocknames.h +51 -0
  285. data/ext/pg_query/include/storage/off.h +57 -0
  286. data/ext/pg_query/include/storage/pg_sema.h +61 -0
  287. data/ext/pg_query/include/storage/pg_shmem.h +90 -0
  288. data/ext/pg_query/include/storage/pmsignal.h +94 -0
  289. data/ext/pg_query/include/storage/predicate.h +87 -0
  290. data/ext/pg_query/include/storage/proc.h +333 -0
  291. data/ext/pg_query/include/storage/proclist_types.h +51 -0
  292. data/ext/pg_query/include/storage/procsignal.h +75 -0
  293. data/ext/pg_query/include/storage/relfilenode.h +99 -0
  294. data/ext/pg_query/include/storage/s_lock.h +1047 -0
  295. data/ext/pg_query/include/storage/sharedfileset.h +45 -0
  296. data/ext/pg_query/include/storage/shm_mq.h +85 -0
  297. data/ext/pg_query/include/storage/shm_toc.h +58 -0
  298. data/ext/pg_query/include/storage/shmem.h +81 -0
  299. data/ext/pg_query/include/storage/sinval.h +153 -0
  300. data/ext/pg_query/include/storage/sinvaladt.h +43 -0
  301. data/ext/pg_query/include/storage/smgr.h +109 -0
  302. data/ext/pg_query/include/storage/spin.h +77 -0
  303. data/ext/pg_query/include/storage/standby.h +91 -0
  304. data/ext/pg_query/include/storage/standbydefs.h +74 -0
  305. data/ext/pg_query/include/storage/sync.h +62 -0
  306. data/ext/pg_query/include/tcop/cmdtag.h +58 -0
  307. data/ext/pg_query/include/tcop/cmdtaglist.h +217 -0
  308. data/ext/pg_query/include/tcop/deparse_utility.h +108 -0
  309. data/ext/pg_query/include/tcop/dest.h +149 -0
  310. data/ext/pg_query/include/tcop/fastpath.h +21 -0
  311. data/ext/pg_query/include/tcop/pquery.h +45 -0
  312. data/ext/pg_query/include/tcop/tcopprot.h +89 -0
  313. data/ext/pg_query/include/tcop/utility.h +108 -0
  314. data/ext/pg_query/include/tsearch/ts_cache.h +98 -0
  315. data/ext/pg_query/include/utils/acl.h +312 -0
  316. data/ext/pg_query/include/utils/aclchk_internal.h +45 -0
  317. data/ext/pg_query/include/utils/array.h +458 -0
  318. data/ext/pg_query/include/utils/builtins.h +127 -0
  319. data/ext/pg_query/include/utils/bytea.h +27 -0
  320. data/ext/pg_query/include/utils/catcache.h +231 -0
  321. data/ext/pg_query/include/utils/date.h +90 -0
  322. data/ext/pg_query/include/utils/datetime.h +343 -0
  323. data/ext/pg_query/include/utils/datum.h +68 -0
  324. data/ext/pg_query/include/utils/dsa.h +123 -0
  325. data/ext/pg_query/include/utils/dynahash.h +19 -0
  326. data/ext/pg_query/include/utils/elog.h +439 -0
  327. data/ext/pg_query/include/utils/errcodes.h +352 -0
  328. data/ext/pg_query/include/utils/expandeddatum.h +159 -0
  329. data/ext/pg_query/include/utils/expandedrecord.h +231 -0
  330. data/ext/pg_query/include/utils/float.h +356 -0
  331. data/ext/pg_query/include/utils/fmgroids.h +2657 -0
  332. data/ext/pg_query/include/utils/fmgrprotos.h +2646 -0
  333. data/ext/pg_query/include/utils/fmgrtab.h +48 -0
  334. data/ext/pg_query/include/utils/guc.h +443 -0
  335. data/ext/pg_query/include/utils/guc_tables.h +272 -0
  336. data/ext/pg_query/include/utils/hsearch.h +149 -0
  337. data/ext/pg_query/include/utils/inval.h +64 -0
  338. data/ext/pg_query/include/utils/lsyscache.h +197 -0
  339. data/ext/pg_query/include/utils/memdebug.h +82 -0
  340. data/ext/pg_query/include/utils/memutils.h +225 -0
  341. data/ext/pg_query/include/utils/numeric.h +76 -0
  342. data/ext/pg_query/include/utils/palloc.h +136 -0
  343. data/ext/pg_query/include/utils/partcache.h +102 -0
  344. data/ext/pg_query/include/utils/pg_locale.h +119 -0
  345. data/ext/pg_query/include/utils/pg_lsn.h +29 -0
  346. data/ext/pg_query/include/utils/pidfile.h +56 -0
  347. data/ext/pg_query/include/utils/plancache.h +235 -0
  348. data/ext/pg_query/include/utils/portal.h +241 -0
  349. data/ext/pg_query/include/utils/probes.h +114 -0
  350. data/ext/pg_query/include/utils/ps_status.h +25 -0
  351. data/ext/pg_query/include/utils/queryenvironment.h +74 -0
  352. data/ext/pg_query/include/utils/regproc.h +28 -0
  353. data/ext/pg_query/include/utils/rel.h +644 -0
  354. data/ext/pg_query/include/utils/relcache.h +151 -0
  355. data/ext/pg_query/include/utils/reltrigger.h +81 -0
  356. data/ext/pg_query/include/utils/resowner.h +86 -0
  357. data/ext/pg_query/include/utils/rls.h +50 -0
  358. data/ext/pg_query/include/utils/ruleutils.h +44 -0
  359. data/ext/pg_query/include/utils/sharedtuplestore.h +61 -0
  360. data/ext/pg_query/include/utils/snapmgr.h +158 -0
  361. data/ext/pg_query/include/utils/snapshot.h +206 -0
  362. data/ext/pg_query/include/utils/sortsupport.h +276 -0
  363. data/ext/pg_query/include/utils/syscache.h +219 -0
  364. data/ext/pg_query/include/utils/timeout.h +88 -0
  365. data/ext/pg_query/include/utils/timestamp.h +116 -0
  366. data/ext/pg_query/include/utils/tuplesort.h +277 -0
  367. data/ext/pg_query/include/utils/tuplestore.h +91 -0
  368. data/ext/pg_query/include/utils/typcache.h +202 -0
  369. data/ext/pg_query/include/utils/tzparser.h +39 -0
  370. data/ext/pg_query/include/utils/varlena.h +39 -0
  371. data/ext/pg_query/include/utils/xml.h +84 -0
  372. data/ext/pg_query/include/xxhash.h +5445 -0
  373. data/ext/pg_query/include/xxhash/xxhash.h +5445 -0
  374. data/lib/pg_query/version.rb +1 -1
  375. metadata +372 -1
@@ -0,0 +1,764 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * postgres.h
4
+ * Primary include file for PostgreSQL server .c files
5
+ *
6
+ * This should be the first file included by PostgreSQL backend modules.
7
+ * Client-side code should include postgres_fe.h instead.
8
+ *
9
+ *
10
+ * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
11
+ * Portions Copyright (c) 1995, Regents of the University of California
12
+ *
13
+ * src/include/postgres.h
14
+ *
15
+ *-------------------------------------------------------------------------
16
+ */
17
+ /*
18
+ *----------------------------------------------------------------
19
+ * TABLE OF CONTENTS
20
+ *
21
+ * When adding stuff to this file, please try to put stuff
22
+ * into the relevant section, or add new sections as appropriate.
23
+ *
24
+ * section description
25
+ * ------- ------------------------------------------------
26
+ * 1) variable-length datatypes (TOAST support)
27
+ * 2) Datum type + support macros
28
+ *
29
+ * NOTES
30
+ *
31
+ * In general, this file should contain declarations that are widely needed
32
+ * in the backend environment, but are of no interest outside the backend.
33
+ *
34
+ * Simple type definitions live in c.h, where they are shared with
35
+ * postgres_fe.h. We do that since those type definitions are needed by
36
+ * frontend modules that want to deal with binary data transmission to or
37
+ * from the backend. Type definitions in this file should be for
38
+ * representations that never escape the backend, such as Datum or
39
+ * TOASTed varlena objects.
40
+ *
41
+ *----------------------------------------------------------------
42
+ */
43
+ #ifndef POSTGRES_H
44
+ #define POSTGRES_H
45
+
46
+ #include "c.h"
47
+ #include "utils/elog.h"
48
+ #include "utils/palloc.h"
49
+
50
+ /* ----------------------------------------------------------------
51
+ * Section 1: variable-length datatypes (TOAST support)
52
+ * ----------------------------------------------------------------
53
+ */
54
+
55
+ /*
56
+ * struct varatt_external is a traditional "TOAST pointer", that is, the
57
+ * information needed to fetch a Datum stored out-of-line in a TOAST table.
58
+ * The data is compressed if and only if va_extsize < va_rawsize - VARHDRSZ.
59
+ * This struct must not contain any padding, because we sometimes compare
60
+ * these pointers using memcmp.
61
+ *
62
+ * Note that this information is stored unaligned within actual tuples, so
63
+ * you need to memcpy from the tuple into a local struct variable before
64
+ * you can look at these fields! (The reason we use memcmp is to avoid
65
+ * having to do that just to detect equality of two TOAST pointers...)
66
+ */
67
+ typedef struct varatt_external
68
+ {
69
+ int32 va_rawsize; /* Original data size (includes header) */
70
+ int32 va_extsize; /* External saved size (doesn't) */
71
+ Oid va_valueid; /* Unique ID of value within TOAST table */
72
+ Oid va_toastrelid; /* RelID of TOAST table containing it */
73
+ } varatt_external;
74
+
75
+ /*
76
+ * struct varatt_indirect is a "TOAST pointer" representing an out-of-line
77
+ * Datum that's stored in memory, not in an external toast relation.
78
+ * The creator of such a Datum is entirely responsible that the referenced
79
+ * storage survives for as long as referencing pointer Datums can exist.
80
+ *
81
+ * Note that just as for struct varatt_external, this struct is stored
82
+ * unaligned within any containing tuple.
83
+ */
84
+ typedef struct varatt_indirect
85
+ {
86
+ struct varlena *pointer; /* Pointer to in-memory varlena */
87
+ } varatt_indirect;
88
+
89
+ /*
90
+ * struct varatt_expanded is a "TOAST pointer" representing an out-of-line
91
+ * Datum that is stored in memory, in some type-specific, not necessarily
92
+ * physically contiguous format that is convenient for computation not
93
+ * storage. APIs for this, in particular the definition of struct
94
+ * ExpandedObjectHeader, are in src/include/utils/expandeddatum.h.
95
+ *
96
+ * Note that just as for struct varatt_external, this struct is stored
97
+ * unaligned within any containing tuple.
98
+ */
99
+ typedef struct ExpandedObjectHeader ExpandedObjectHeader;
100
+
101
+ typedef struct varatt_expanded
102
+ {
103
+ ExpandedObjectHeader *eohptr;
104
+ } varatt_expanded;
105
+
106
+ /*
107
+ * Type tag for the various sorts of "TOAST pointer" datums. The peculiar
108
+ * value for VARTAG_ONDISK comes from a requirement for on-disk compatibility
109
+ * with a previous notion that the tag field was the pointer datum's length.
110
+ */
111
+ typedef enum vartag_external
112
+ {
113
+ VARTAG_INDIRECT = 1,
114
+ VARTAG_EXPANDED_RO = 2,
115
+ VARTAG_EXPANDED_RW = 3,
116
+ VARTAG_ONDISK = 18
117
+ } vartag_external;
118
+
119
+ /* this test relies on the specific tag values above */
120
+ #define VARTAG_IS_EXPANDED(tag) \
121
+ (((tag) & ~1) == VARTAG_EXPANDED_RO)
122
+
123
+ #define VARTAG_SIZE(tag) \
124
+ ((tag) == VARTAG_INDIRECT ? sizeof(varatt_indirect) : \
125
+ VARTAG_IS_EXPANDED(tag) ? sizeof(varatt_expanded) : \
126
+ (tag) == VARTAG_ONDISK ? sizeof(varatt_external) : \
127
+ TrapMacro(true, "unrecognized TOAST vartag"))
128
+
129
+ /*
130
+ * These structs describe the header of a varlena object that may have been
131
+ * TOASTed. Generally, don't reference these structs directly, but use the
132
+ * macros below.
133
+ *
134
+ * We use separate structs for the aligned and unaligned cases because the
135
+ * compiler might otherwise think it could generate code that assumes
136
+ * alignment while touching fields of a 1-byte-header varlena.
137
+ */
138
+ typedef union
139
+ {
140
+ struct /* Normal varlena (4-byte length) */
141
+ {
142
+ uint32 va_header;
143
+ char va_data[FLEXIBLE_ARRAY_MEMBER];
144
+ } va_4byte;
145
+ struct /* Compressed-in-line format */
146
+ {
147
+ uint32 va_header;
148
+ uint32 va_rawsize; /* Original data size (excludes header) */
149
+ char va_data[FLEXIBLE_ARRAY_MEMBER]; /* Compressed data */
150
+ } va_compressed;
151
+ } varattrib_4b;
152
+
153
+ typedef struct
154
+ {
155
+ uint8 va_header;
156
+ char va_data[FLEXIBLE_ARRAY_MEMBER]; /* Data begins here */
157
+ } varattrib_1b;
158
+
159
+ /* TOAST pointers are a subset of varattrib_1b with an identifying tag byte */
160
+ typedef struct
161
+ {
162
+ uint8 va_header; /* Always 0x80 or 0x01 */
163
+ uint8 va_tag; /* Type of datum */
164
+ char va_data[FLEXIBLE_ARRAY_MEMBER]; /* Type-specific data */
165
+ } varattrib_1b_e;
166
+
167
+ /*
168
+ * Bit layouts for varlena headers on big-endian machines:
169
+ *
170
+ * 00xxxxxx 4-byte length word, aligned, uncompressed data (up to 1G)
171
+ * 01xxxxxx 4-byte length word, aligned, *compressed* data (up to 1G)
172
+ * 10000000 1-byte length word, unaligned, TOAST pointer
173
+ * 1xxxxxxx 1-byte length word, unaligned, uncompressed data (up to 126b)
174
+ *
175
+ * Bit layouts for varlena headers on little-endian machines:
176
+ *
177
+ * xxxxxx00 4-byte length word, aligned, uncompressed data (up to 1G)
178
+ * xxxxxx10 4-byte length word, aligned, *compressed* data (up to 1G)
179
+ * 00000001 1-byte length word, unaligned, TOAST pointer
180
+ * xxxxxxx1 1-byte length word, unaligned, uncompressed data (up to 126b)
181
+ *
182
+ * The "xxx" bits are the length field (which includes itself in all cases).
183
+ * In the big-endian case we mask to extract the length, in the little-endian
184
+ * case we shift. Note that in both cases the flag bits are in the physically
185
+ * first byte. Also, it is not possible for a 1-byte length word to be zero;
186
+ * this lets us disambiguate alignment padding bytes from the start of an
187
+ * unaligned datum. (We now *require* pad bytes to be filled with zero!)
188
+ *
189
+ * In TOAST pointers the va_tag field (see varattrib_1b_e) is used to discern
190
+ * the specific type and length of the pointer datum.
191
+ */
192
+
193
+ /*
194
+ * Endian-dependent macros. These are considered internal --- use the
195
+ * external macros below instead of using these directly.
196
+ *
197
+ * Note: IS_1B is true for external toast records but VARSIZE_1B will return 0
198
+ * for such records. Hence you should usually check for IS_EXTERNAL before
199
+ * checking for IS_1B.
200
+ */
201
+
202
+ #ifdef WORDS_BIGENDIAN
203
+
204
+ #define VARATT_IS_4B(PTR) \
205
+ ((((varattrib_1b *) (PTR))->va_header & 0x80) == 0x00)
206
+ #define VARATT_IS_4B_U(PTR) \
207
+ ((((varattrib_1b *) (PTR))->va_header & 0xC0) == 0x00)
208
+ #define VARATT_IS_4B_C(PTR) \
209
+ ((((varattrib_1b *) (PTR))->va_header & 0xC0) == 0x40)
210
+ #define VARATT_IS_1B(PTR) \
211
+ ((((varattrib_1b *) (PTR))->va_header & 0x80) == 0x80)
212
+ #define VARATT_IS_1B_E(PTR) \
213
+ ((((varattrib_1b *) (PTR))->va_header) == 0x80)
214
+ #define VARATT_NOT_PAD_BYTE(PTR) \
215
+ (*((uint8 *) (PTR)) != 0)
216
+
217
+ /* VARSIZE_4B() should only be used on known-aligned data */
218
+ #define VARSIZE_4B(PTR) \
219
+ (((varattrib_4b *) (PTR))->va_4byte.va_header & 0x3FFFFFFF)
220
+ #define VARSIZE_1B(PTR) \
221
+ (((varattrib_1b *) (PTR))->va_header & 0x7F)
222
+ #define VARTAG_1B_E(PTR) \
223
+ (((varattrib_1b_e *) (PTR))->va_tag)
224
+
225
+ #define SET_VARSIZE_4B(PTR,len) \
226
+ (((varattrib_4b *) (PTR))->va_4byte.va_header = (len) & 0x3FFFFFFF)
227
+ #define SET_VARSIZE_4B_C(PTR,len) \
228
+ (((varattrib_4b *) (PTR))->va_4byte.va_header = ((len) & 0x3FFFFFFF) | 0x40000000)
229
+ #define SET_VARSIZE_1B(PTR,len) \
230
+ (((varattrib_1b *) (PTR))->va_header = (len) | 0x80)
231
+ #define SET_VARTAG_1B_E(PTR,tag) \
232
+ (((varattrib_1b_e *) (PTR))->va_header = 0x80, \
233
+ ((varattrib_1b_e *) (PTR))->va_tag = (tag))
234
+ #else /* !WORDS_BIGENDIAN */
235
+
236
+ #define VARATT_IS_4B(PTR) \
237
+ ((((varattrib_1b *) (PTR))->va_header & 0x01) == 0x00)
238
+ #define VARATT_IS_4B_U(PTR) \
239
+ ((((varattrib_1b *) (PTR))->va_header & 0x03) == 0x00)
240
+ #define VARATT_IS_4B_C(PTR) \
241
+ ((((varattrib_1b *) (PTR))->va_header & 0x03) == 0x02)
242
+ #define VARATT_IS_1B(PTR) \
243
+ ((((varattrib_1b *) (PTR))->va_header & 0x01) == 0x01)
244
+ #define VARATT_IS_1B_E(PTR) \
245
+ ((((varattrib_1b *) (PTR))->va_header) == 0x01)
246
+ #define VARATT_NOT_PAD_BYTE(PTR) \
247
+ (*((uint8 *) (PTR)) != 0)
248
+
249
+ /* VARSIZE_4B() should only be used on known-aligned data */
250
+ #define VARSIZE_4B(PTR) \
251
+ ((((varattrib_4b *) (PTR))->va_4byte.va_header >> 2) & 0x3FFFFFFF)
252
+ #define VARSIZE_1B(PTR) \
253
+ ((((varattrib_1b *) (PTR))->va_header >> 1) & 0x7F)
254
+ #define VARTAG_1B_E(PTR) \
255
+ (((varattrib_1b_e *) (PTR))->va_tag)
256
+
257
+ #define SET_VARSIZE_4B(PTR,len) \
258
+ (((varattrib_4b *) (PTR))->va_4byte.va_header = (((uint32) (len)) << 2))
259
+ #define SET_VARSIZE_4B_C(PTR,len) \
260
+ (((varattrib_4b *) (PTR))->va_4byte.va_header = (((uint32) (len)) << 2) | 0x02)
261
+ #define SET_VARSIZE_1B(PTR,len) \
262
+ (((varattrib_1b *) (PTR))->va_header = (((uint8) (len)) << 1) | 0x01)
263
+ #define SET_VARTAG_1B_E(PTR,tag) \
264
+ (((varattrib_1b_e *) (PTR))->va_header = 0x01, \
265
+ ((varattrib_1b_e *) (PTR))->va_tag = (tag))
266
+ #endif /* WORDS_BIGENDIAN */
267
+
268
+ #define VARHDRSZ_SHORT offsetof(varattrib_1b, va_data)
269
+ #define VARATT_SHORT_MAX 0x7F
270
+ #define VARATT_CAN_MAKE_SHORT(PTR) \
271
+ (VARATT_IS_4B_U(PTR) && \
272
+ (VARSIZE(PTR) - VARHDRSZ + VARHDRSZ_SHORT) <= VARATT_SHORT_MAX)
273
+ #define VARATT_CONVERTED_SHORT_SIZE(PTR) \
274
+ (VARSIZE(PTR) - VARHDRSZ + VARHDRSZ_SHORT)
275
+
276
+ #define VARHDRSZ_EXTERNAL offsetof(varattrib_1b_e, va_data)
277
+
278
+ #define VARDATA_4B(PTR) (((varattrib_4b *) (PTR))->va_4byte.va_data)
279
+ #define VARDATA_4B_C(PTR) (((varattrib_4b *) (PTR))->va_compressed.va_data)
280
+ #define VARDATA_1B(PTR) (((varattrib_1b *) (PTR))->va_data)
281
+ #define VARDATA_1B_E(PTR) (((varattrib_1b_e *) (PTR))->va_data)
282
+
283
+ #define VARRAWSIZE_4B_C(PTR) \
284
+ (((varattrib_4b *) (PTR))->va_compressed.va_rawsize)
285
+
286
+ /* Externally visible macros */
287
+
288
+ /*
289
+ * In consumers oblivious to data alignment, call PG_DETOAST_DATUM_PACKED(),
290
+ * VARDATA_ANY(), VARSIZE_ANY() and VARSIZE_ANY_EXHDR(). Elsewhere, call
291
+ * PG_DETOAST_DATUM(), VARDATA() and VARSIZE(). Directly fetching an int16,
292
+ * int32 or wider field in the struct representing the datum layout requires
293
+ * aligned data. memcpy() is alignment-oblivious, as are most operations on
294
+ * datatypes, such as text, whose layout struct contains only char fields.
295
+ *
296
+ * Code assembling a new datum should call VARDATA() and SET_VARSIZE().
297
+ * (Datums begin life untoasted.)
298
+ *
299
+ * Other macros here should usually be used only by tuple assembly/disassembly
300
+ * code and code that specifically wants to work with still-toasted Datums.
301
+ */
302
+ #define VARDATA(PTR) VARDATA_4B(PTR)
303
+ #define VARSIZE(PTR) VARSIZE_4B(PTR)
304
+
305
+ #define VARSIZE_SHORT(PTR) VARSIZE_1B(PTR)
306
+ #define VARDATA_SHORT(PTR) VARDATA_1B(PTR)
307
+
308
+ #define VARTAG_EXTERNAL(PTR) VARTAG_1B_E(PTR)
309
+ #define VARSIZE_EXTERNAL(PTR) (VARHDRSZ_EXTERNAL + VARTAG_SIZE(VARTAG_EXTERNAL(PTR)))
310
+ #define VARDATA_EXTERNAL(PTR) VARDATA_1B_E(PTR)
311
+
312
+ #define VARATT_IS_COMPRESSED(PTR) VARATT_IS_4B_C(PTR)
313
+ #define VARATT_IS_EXTERNAL(PTR) VARATT_IS_1B_E(PTR)
314
+ #define VARATT_IS_EXTERNAL_ONDISK(PTR) \
315
+ (VARATT_IS_EXTERNAL(PTR) && VARTAG_EXTERNAL(PTR) == VARTAG_ONDISK)
316
+ #define VARATT_IS_EXTERNAL_INDIRECT(PTR) \
317
+ (VARATT_IS_EXTERNAL(PTR) && VARTAG_EXTERNAL(PTR) == VARTAG_INDIRECT)
318
+ #define VARATT_IS_EXTERNAL_EXPANDED_RO(PTR) \
319
+ (VARATT_IS_EXTERNAL(PTR) && VARTAG_EXTERNAL(PTR) == VARTAG_EXPANDED_RO)
320
+ #define VARATT_IS_EXTERNAL_EXPANDED_RW(PTR) \
321
+ (VARATT_IS_EXTERNAL(PTR) && VARTAG_EXTERNAL(PTR) == VARTAG_EXPANDED_RW)
322
+ #define VARATT_IS_EXTERNAL_EXPANDED(PTR) \
323
+ (VARATT_IS_EXTERNAL(PTR) && VARTAG_IS_EXPANDED(VARTAG_EXTERNAL(PTR)))
324
+ #define VARATT_IS_EXTERNAL_NON_EXPANDED(PTR) \
325
+ (VARATT_IS_EXTERNAL(PTR) && !VARTAG_IS_EXPANDED(VARTAG_EXTERNAL(PTR)))
326
+ #define VARATT_IS_SHORT(PTR) VARATT_IS_1B(PTR)
327
+ #define VARATT_IS_EXTENDED(PTR) (!VARATT_IS_4B_U(PTR))
328
+
329
+ #define SET_VARSIZE(PTR, len) SET_VARSIZE_4B(PTR, len)
330
+ #define SET_VARSIZE_SHORT(PTR, len) SET_VARSIZE_1B(PTR, len)
331
+ #define SET_VARSIZE_COMPRESSED(PTR, len) SET_VARSIZE_4B_C(PTR, len)
332
+
333
+ #define SET_VARTAG_EXTERNAL(PTR, tag) SET_VARTAG_1B_E(PTR, tag)
334
+
335
+ #define VARSIZE_ANY(PTR) \
336
+ (VARATT_IS_1B_E(PTR) ? VARSIZE_EXTERNAL(PTR) : \
337
+ (VARATT_IS_1B(PTR) ? VARSIZE_1B(PTR) : \
338
+ VARSIZE_4B(PTR)))
339
+
340
+ /* Size of a varlena data, excluding header */
341
+ #define VARSIZE_ANY_EXHDR(PTR) \
342
+ (VARATT_IS_1B_E(PTR) ? VARSIZE_EXTERNAL(PTR)-VARHDRSZ_EXTERNAL : \
343
+ (VARATT_IS_1B(PTR) ? VARSIZE_1B(PTR)-VARHDRSZ_SHORT : \
344
+ VARSIZE_4B(PTR)-VARHDRSZ))
345
+
346
+ /* caution: this will not work on an external or compressed-in-line Datum */
347
+ /* caution: this will return a possibly unaligned pointer */
348
+ #define VARDATA_ANY(PTR) \
349
+ (VARATT_IS_1B(PTR) ? VARDATA_1B(PTR) : VARDATA_4B(PTR))
350
+
351
+
352
+ /* ----------------------------------------------------------------
353
+ * Section 2: Datum type + support macros
354
+ * ----------------------------------------------------------------
355
+ */
356
+
357
+ /*
358
+ * A Datum contains either a value of a pass-by-value type or a pointer to a
359
+ * value of a pass-by-reference type. Therefore, we require:
360
+ *
361
+ * sizeof(Datum) == sizeof(void *) == 4 or 8
362
+ *
363
+ * The macros below and the analogous macros for other types should be used to
364
+ * convert between a Datum and the appropriate C type.
365
+ */
366
+
367
+ typedef uintptr_t Datum;
368
+
369
+ /*
370
+ * A NullableDatum is used in places where both a Datum and its nullness needs
371
+ * to be stored. This can be more efficient than storing datums and nullness
372
+ * in separate arrays, due to better spatial locality, even if more space may
373
+ * be wasted due to padding.
374
+ */
375
+ typedef struct NullableDatum
376
+ {
377
+ #define FIELDNO_NULLABLE_DATUM_DATUM 0
378
+ Datum value;
379
+ #define FIELDNO_NULLABLE_DATUM_ISNULL 1
380
+ bool isnull;
381
+ /* due to alignment padding this could be used for flags for free */
382
+ } NullableDatum;
383
+
384
+ #define SIZEOF_DATUM SIZEOF_VOID_P
385
+
386
+ /*
387
+ * DatumGetBool
388
+ * Returns boolean value of a datum.
389
+ *
390
+ * Note: any nonzero value will be considered true.
391
+ */
392
+
393
+ #define DatumGetBool(X) ((bool) ((X) != 0))
394
+
395
+ /*
396
+ * BoolGetDatum
397
+ * Returns datum representation for a boolean.
398
+ *
399
+ * Note: any nonzero value will be considered true.
400
+ */
401
+
402
+ #define BoolGetDatum(X) ((Datum) ((X) ? 1 : 0))
403
+
404
+ /*
405
+ * DatumGetChar
406
+ * Returns character value of a datum.
407
+ */
408
+
409
+ #define DatumGetChar(X) ((char) (X))
410
+
411
+ /*
412
+ * CharGetDatum
413
+ * Returns datum representation for a character.
414
+ */
415
+
416
+ #define CharGetDatum(X) ((Datum) (X))
417
+
418
+ /*
419
+ * Int8GetDatum
420
+ * Returns datum representation for an 8-bit integer.
421
+ */
422
+
423
+ #define Int8GetDatum(X) ((Datum) (X))
424
+
425
+ /*
426
+ * DatumGetUInt8
427
+ * Returns 8-bit unsigned integer value of a datum.
428
+ */
429
+
430
+ #define DatumGetUInt8(X) ((uint8) (X))
431
+
432
+ /*
433
+ * UInt8GetDatum
434
+ * Returns datum representation for an 8-bit unsigned integer.
435
+ */
436
+
437
+ #define UInt8GetDatum(X) ((Datum) (X))
438
+
439
+ /*
440
+ * DatumGetInt16
441
+ * Returns 16-bit integer value of a datum.
442
+ */
443
+
444
+ #define DatumGetInt16(X) ((int16) (X))
445
+
446
+ /*
447
+ * Int16GetDatum
448
+ * Returns datum representation for a 16-bit integer.
449
+ */
450
+
451
+ #define Int16GetDatum(X) ((Datum) (X))
452
+
453
+ /*
454
+ * DatumGetUInt16
455
+ * Returns 16-bit unsigned integer value of a datum.
456
+ */
457
+
458
+ #define DatumGetUInt16(X) ((uint16) (X))
459
+
460
+ /*
461
+ * UInt16GetDatum
462
+ * Returns datum representation for a 16-bit unsigned integer.
463
+ */
464
+
465
+ #define UInt16GetDatum(X) ((Datum) (X))
466
+
467
+ /*
468
+ * DatumGetInt32
469
+ * Returns 32-bit integer value of a datum.
470
+ */
471
+
472
+ #define DatumGetInt32(X) ((int32) (X))
473
+
474
+ /*
475
+ * Int32GetDatum
476
+ * Returns datum representation for a 32-bit integer.
477
+ */
478
+
479
+ #define Int32GetDatum(X) ((Datum) (X))
480
+
481
+ /*
482
+ * DatumGetUInt32
483
+ * Returns 32-bit unsigned integer value of a datum.
484
+ */
485
+
486
+ #define DatumGetUInt32(X) ((uint32) (X))
487
+
488
+ /*
489
+ * UInt32GetDatum
490
+ * Returns datum representation for a 32-bit unsigned integer.
491
+ */
492
+
493
+ #define UInt32GetDatum(X) ((Datum) (X))
494
+
495
+ /*
496
+ * DatumGetObjectId
497
+ * Returns object identifier value of a datum.
498
+ */
499
+
500
+ #define DatumGetObjectId(X) ((Oid) (X))
501
+
502
+ /*
503
+ * ObjectIdGetDatum
504
+ * Returns datum representation for an object identifier.
505
+ */
506
+
507
+ #define ObjectIdGetDatum(X) ((Datum) (X))
508
+
509
+ /*
510
+ * DatumGetTransactionId
511
+ * Returns transaction identifier value of a datum.
512
+ */
513
+
514
+ #define DatumGetTransactionId(X) ((TransactionId) (X))
515
+
516
+ /*
517
+ * TransactionIdGetDatum
518
+ * Returns datum representation for a transaction identifier.
519
+ */
520
+
521
+ #define TransactionIdGetDatum(X) ((Datum) (X))
522
+
523
+ /*
524
+ * MultiXactIdGetDatum
525
+ * Returns datum representation for a multixact identifier.
526
+ */
527
+
528
+ #define MultiXactIdGetDatum(X) ((Datum) (X))
529
+
530
+ /*
531
+ * DatumGetCommandId
532
+ * Returns command identifier value of a datum.
533
+ */
534
+
535
+ #define DatumGetCommandId(X) ((CommandId) (X))
536
+
537
+ /*
538
+ * CommandIdGetDatum
539
+ * Returns datum representation for a command identifier.
540
+ */
541
+
542
+ #define CommandIdGetDatum(X) ((Datum) (X))
543
+
544
+ /*
545
+ * DatumGetPointer
546
+ * Returns pointer value of a datum.
547
+ */
548
+
549
+ #define DatumGetPointer(X) ((Pointer) (X))
550
+
551
+ /*
552
+ * PointerGetDatum
553
+ * Returns datum representation for a pointer.
554
+ */
555
+
556
+ #define PointerGetDatum(X) ((Datum) (X))
557
+
558
+ /*
559
+ * DatumGetCString
560
+ * Returns C string (null-terminated string) value of a datum.
561
+ *
562
+ * Note: C string is not a full-fledged Postgres type at present,
563
+ * but type input functions use this conversion for their inputs.
564
+ */
565
+
566
+ #define DatumGetCString(X) ((char *) DatumGetPointer(X))
567
+
568
+ /*
569
+ * CStringGetDatum
570
+ * Returns datum representation for a C string (null-terminated string).
571
+ *
572
+ * Note: C string is not a full-fledged Postgres type at present,
573
+ * but type output functions use this conversion for their outputs.
574
+ * Note: CString is pass-by-reference; caller must ensure the pointed-to
575
+ * value has adequate lifetime.
576
+ */
577
+
578
+ #define CStringGetDatum(X) PointerGetDatum(X)
579
+
580
+ /*
581
+ * DatumGetName
582
+ * Returns name value of a datum.
583
+ */
584
+
585
+ #define DatumGetName(X) ((Name) DatumGetPointer(X))
586
+
587
+ /*
588
+ * NameGetDatum
589
+ * Returns datum representation for a name.
590
+ *
591
+ * Note: Name is pass-by-reference; caller must ensure the pointed-to
592
+ * value has adequate lifetime.
593
+ */
594
+
595
+ #define NameGetDatum(X) CStringGetDatum(NameStr(*(X)))
596
+
597
+ /*
598
+ * DatumGetInt64
599
+ * Returns 64-bit integer value of a datum.
600
+ *
601
+ * Note: this macro hides whether int64 is pass by value or by reference.
602
+ */
603
+
604
+ #ifdef USE_FLOAT8_BYVAL
605
+ #define DatumGetInt64(X) ((int64) (X))
606
+ #else
607
+ #define DatumGetInt64(X) (* ((int64 *) DatumGetPointer(X)))
608
+ #endif
609
+
610
+ /*
611
+ * Int64GetDatum
612
+ * Returns datum representation for a 64-bit integer.
613
+ *
614
+ * Note: if int64 is pass by reference, this function returns a reference
615
+ * to palloc'd space.
616
+ */
617
+
618
+ #ifdef USE_FLOAT8_BYVAL
619
+ #define Int64GetDatum(X) ((Datum) (X))
620
+ #else
621
+ extern Datum Int64GetDatum(int64 X);
622
+ #endif
623
+
624
+ /*
625
+ * DatumGetUInt64
626
+ * Returns 64-bit unsigned integer value of a datum.
627
+ *
628
+ * Note: this macro hides whether int64 is pass by value or by reference.
629
+ */
630
+
631
+ #ifdef USE_FLOAT8_BYVAL
632
+ #define DatumGetUInt64(X) ((uint64) (X))
633
+ #else
634
+ #define DatumGetUInt64(X) (* ((uint64 *) DatumGetPointer(X)))
635
+ #endif
636
+
637
+ /*
638
+ * UInt64GetDatum
639
+ * Returns datum representation for a 64-bit unsigned integer.
640
+ *
641
+ * Note: if int64 is pass by reference, this function returns a reference
642
+ * to palloc'd space.
643
+ */
644
+
645
+ #ifdef USE_FLOAT8_BYVAL
646
+ #define UInt64GetDatum(X) ((Datum) (X))
647
+ #else
648
+ #define UInt64GetDatum(X) Int64GetDatum((int64) (X))
649
+ #endif
650
+
651
+ /*
652
+ * Float <-> Datum conversions
653
+ *
654
+ * These have to be implemented as inline functions rather than macros, when
655
+ * passing by value, because many machines pass int and float function
656
+ * parameters/results differently; so we need to play weird games with unions.
657
+ */
658
+
659
+ /*
660
+ * DatumGetFloat4
661
+ * Returns 4-byte floating point value of a datum.
662
+ */
663
+ static inline float4
664
+ DatumGetFloat4(Datum X)
665
+ {
666
+ union
667
+ {
668
+ int32 value;
669
+ float4 retval;
670
+ } myunion;
671
+
672
+ myunion.value = DatumGetInt32(X);
673
+ return myunion.retval;
674
+ }
675
+
676
+ /*
677
+ * Float4GetDatum
678
+ * Returns datum representation for a 4-byte floating point number.
679
+ */
680
+ static inline Datum
681
+ Float4GetDatum(float4 X)
682
+ {
683
+ union
684
+ {
685
+ float4 value;
686
+ int32 retval;
687
+ } myunion;
688
+
689
+ myunion.value = X;
690
+ return Int32GetDatum(myunion.retval);
691
+ }
692
+
693
+ /*
694
+ * DatumGetFloat8
695
+ * Returns 8-byte floating point value of a datum.
696
+ *
697
+ * Note: this macro hides whether float8 is pass by value or by reference.
698
+ */
699
+
700
+ #ifdef USE_FLOAT8_BYVAL
701
+ static inline float8
702
+ DatumGetFloat8(Datum X)
703
+ {
704
+ union
705
+ {
706
+ int64 value;
707
+ float8 retval;
708
+ } myunion;
709
+
710
+ myunion.value = DatumGetInt64(X);
711
+ return myunion.retval;
712
+ }
713
+ #else
714
+ #define DatumGetFloat8(X) (* ((float8 *) DatumGetPointer(X)))
715
+ #endif
716
+
717
+ /*
718
+ * Float8GetDatum
719
+ * Returns datum representation for an 8-byte floating point number.
720
+ *
721
+ * Note: if float8 is pass by reference, this function returns a reference
722
+ * to palloc'd space.
723
+ */
724
+
725
+ #ifdef USE_FLOAT8_BYVAL
726
+ static inline Datum
727
+ Float8GetDatum(float8 X)
728
+ {
729
+ union
730
+ {
731
+ float8 value;
732
+ int64 retval;
733
+ } myunion;
734
+
735
+ myunion.value = X;
736
+ return Int64GetDatum(myunion.retval);
737
+ }
738
+ #else
739
+ extern Datum Float8GetDatum(float8 X);
740
+ #endif
741
+
742
+
743
+ /*
744
+ * Int64GetDatumFast
745
+ * Float8GetDatumFast
746
+ *
747
+ * These macros are intended to allow writing code that does not depend on
748
+ * whether int64 and float8 are pass-by-reference types, while not
749
+ * sacrificing performance when they are. The argument must be a variable
750
+ * that will exist and have the same value for as long as the Datum is needed.
751
+ * In the pass-by-ref case, the address of the variable is taken to use as
752
+ * the Datum. In the pass-by-val case, these will be the same as the non-Fast
753
+ * macros.
754
+ */
755
+
756
+ #ifdef USE_FLOAT8_BYVAL
757
+ #define Int64GetDatumFast(X) Int64GetDatum(X)
758
+ #define Float8GetDatumFast(X) Float8GetDatum(X)
759
+ #else
760
+ #define Int64GetDatumFast(X) PointerGetDatum(&(X))
761
+ #define Float8GetDatumFast(X) PointerGetDatum(&(X))
762
+ #endif
763
+
764
+ #endif /* POSTGRES_H */