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,247 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * tupmacs.h
4
+ * Tuple macros used by both index tuples and heap tuples.
5
+ *
6
+ *
7
+ * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
8
+ * Portions Copyright (c) 1994, Regents of the University of California
9
+ *
10
+ * src/include/access/tupmacs.h
11
+ *
12
+ *-------------------------------------------------------------------------
13
+ */
14
+ #ifndef TUPMACS_H
15
+ #define TUPMACS_H
16
+
17
+ #include "catalog/pg_type_d.h" /* for TYPALIGN macros */
18
+
19
+
20
+ /*
21
+ * Check a tuple's null bitmap to determine whether the attribute is null.
22
+ * Note that a 0 in the null bitmap indicates a null, while 1 indicates
23
+ * non-null.
24
+ */
25
+ #define att_isnull(ATT, BITS) (!((BITS)[(ATT) >> 3] & (1 << ((ATT) & 0x07))))
26
+
27
+ /*
28
+ * Given a Form_pg_attribute and a pointer into a tuple's data area,
29
+ * return the correct value or pointer.
30
+ *
31
+ * We return a Datum value in all cases. If the attribute has "byval" false,
32
+ * we return the same pointer into the tuple data area that we're passed.
33
+ * Otherwise, we return the correct number of bytes fetched from the data
34
+ * area and extended to Datum form.
35
+ *
36
+ * On machines where Datum is 8 bytes, we support fetching 8-byte byval
37
+ * attributes; otherwise, only 1, 2, and 4-byte values are supported.
38
+ *
39
+ * Note that T must already be properly aligned for this to work correctly.
40
+ */
41
+ #define fetchatt(A,T) fetch_att(T, (A)->attbyval, (A)->attlen)
42
+
43
+ /*
44
+ * Same, but work from byval/len parameters rather than Form_pg_attribute.
45
+ */
46
+ #if SIZEOF_DATUM == 8
47
+
48
+ #define fetch_att(T,attbyval,attlen) \
49
+ ( \
50
+ (attbyval) ? \
51
+ ( \
52
+ (attlen) == (int) sizeof(Datum) ? \
53
+ *((Datum *)(T)) \
54
+ : \
55
+ ( \
56
+ (attlen) == (int) sizeof(int32) ? \
57
+ Int32GetDatum(*((int32 *)(T))) \
58
+ : \
59
+ ( \
60
+ (attlen) == (int) sizeof(int16) ? \
61
+ Int16GetDatum(*((int16 *)(T))) \
62
+ : \
63
+ ( \
64
+ AssertMacro((attlen) == 1), \
65
+ CharGetDatum(*((char *)(T))) \
66
+ ) \
67
+ ) \
68
+ ) \
69
+ ) \
70
+ : \
71
+ PointerGetDatum((char *) (T)) \
72
+ )
73
+ #else /* SIZEOF_DATUM != 8 */
74
+
75
+ #define fetch_att(T,attbyval,attlen) \
76
+ ( \
77
+ (attbyval) ? \
78
+ ( \
79
+ (attlen) == (int) sizeof(int32) ? \
80
+ Int32GetDatum(*((int32 *)(T))) \
81
+ : \
82
+ ( \
83
+ (attlen) == (int) sizeof(int16) ? \
84
+ Int16GetDatum(*((int16 *)(T))) \
85
+ : \
86
+ ( \
87
+ AssertMacro((attlen) == 1), \
88
+ CharGetDatum(*((char *)(T))) \
89
+ ) \
90
+ ) \
91
+ ) \
92
+ : \
93
+ PointerGetDatum((char *) (T)) \
94
+ )
95
+ #endif /* SIZEOF_DATUM == 8 */
96
+
97
+ /*
98
+ * att_align_datum aligns the given offset as needed for a datum of alignment
99
+ * requirement attalign and typlen attlen. attdatum is the Datum variable
100
+ * we intend to pack into a tuple (it's only accessed if we are dealing with
101
+ * a varlena type). Note that this assumes the Datum will be stored as-is;
102
+ * callers that are intending to convert non-short varlena datums to short
103
+ * format have to account for that themselves.
104
+ */
105
+ #define att_align_datum(cur_offset, attalign, attlen, attdatum) \
106
+ ( \
107
+ ((attlen) == -1 && VARATT_IS_SHORT(DatumGetPointer(attdatum))) ? \
108
+ (uintptr_t) (cur_offset) : \
109
+ att_align_nominal(cur_offset, attalign) \
110
+ )
111
+
112
+ /*
113
+ * att_align_pointer performs the same calculation as att_align_datum,
114
+ * but is used when walking a tuple. attptr is the current actual data
115
+ * pointer; when accessing a varlena field we have to "peek" to see if we
116
+ * are looking at a pad byte or the first byte of a 1-byte-header datum.
117
+ * (A zero byte must be either a pad byte, or the first byte of a correctly
118
+ * aligned 4-byte length word; in either case we can align safely. A non-zero
119
+ * byte must be either a 1-byte length word, or the first byte of a correctly
120
+ * aligned 4-byte length word; in either case we need not align.)
121
+ *
122
+ * Note: some callers pass a "char *" pointer for cur_offset. This is
123
+ * a bit of a hack but should work all right as long as uintptr_t is the
124
+ * correct width.
125
+ */
126
+ #define att_align_pointer(cur_offset, attalign, attlen, attptr) \
127
+ ( \
128
+ ((attlen) == -1 && VARATT_NOT_PAD_BYTE(attptr)) ? \
129
+ (uintptr_t) (cur_offset) : \
130
+ att_align_nominal(cur_offset, attalign) \
131
+ )
132
+
133
+ /*
134
+ * att_align_nominal aligns the given offset as needed for a datum of alignment
135
+ * requirement attalign, ignoring any consideration of packed varlena datums.
136
+ * There are three main use cases for using this macro directly:
137
+ * * we know that the att in question is not varlena (attlen != -1);
138
+ * in this case it is cheaper than the above macros and just as good.
139
+ * * we need to estimate alignment padding cost abstractly, ie without
140
+ * reference to a real tuple. We must assume the worst case that
141
+ * all varlenas are aligned.
142
+ * * within arrays, we unconditionally align varlenas (XXX this should be
143
+ * revisited, probably).
144
+ *
145
+ * The attalign cases are tested in what is hopefully something like their
146
+ * frequency of occurrence.
147
+ */
148
+ #define att_align_nominal(cur_offset, attalign) \
149
+ ( \
150
+ ((attalign) == TYPALIGN_INT) ? INTALIGN(cur_offset) : \
151
+ (((attalign) == TYPALIGN_CHAR) ? (uintptr_t) (cur_offset) : \
152
+ (((attalign) == TYPALIGN_DOUBLE) ? DOUBLEALIGN(cur_offset) : \
153
+ ( \
154
+ AssertMacro((attalign) == TYPALIGN_SHORT), \
155
+ SHORTALIGN(cur_offset) \
156
+ ))) \
157
+ )
158
+
159
+ /*
160
+ * att_addlength_datum increments the given offset by the space needed for
161
+ * the given Datum variable. attdatum is only accessed if we are dealing
162
+ * with a variable-length attribute.
163
+ */
164
+ #define att_addlength_datum(cur_offset, attlen, attdatum) \
165
+ att_addlength_pointer(cur_offset, attlen, DatumGetPointer(attdatum))
166
+
167
+ /*
168
+ * att_addlength_pointer performs the same calculation as att_addlength_datum,
169
+ * but is used when walking a tuple --- attptr is the pointer to the field
170
+ * within the tuple.
171
+ *
172
+ * Note: some callers pass a "char *" pointer for cur_offset. This is
173
+ * actually perfectly OK, but probably should be cleaned up along with
174
+ * the same practice for att_align_pointer.
175
+ */
176
+ #define att_addlength_pointer(cur_offset, attlen, attptr) \
177
+ ( \
178
+ ((attlen) > 0) ? \
179
+ ( \
180
+ (cur_offset) + (attlen) \
181
+ ) \
182
+ : (((attlen) == -1) ? \
183
+ ( \
184
+ (cur_offset) + VARSIZE_ANY(attptr) \
185
+ ) \
186
+ : \
187
+ ( \
188
+ AssertMacro((attlen) == -2), \
189
+ (cur_offset) + (strlen((char *) (attptr)) + 1) \
190
+ )) \
191
+ )
192
+
193
+ /*
194
+ * store_att_byval is a partial inverse of fetch_att: store a given Datum
195
+ * value into a tuple data area at the specified address. However, it only
196
+ * handles the byval case, because in typical usage the caller needs to
197
+ * distinguish by-val and by-ref cases anyway, and so a do-it-all macro
198
+ * wouldn't be convenient.
199
+ */
200
+ #if SIZEOF_DATUM == 8
201
+
202
+ #define store_att_byval(T,newdatum,attlen) \
203
+ do { \
204
+ switch (attlen) \
205
+ { \
206
+ case sizeof(char): \
207
+ *(char *) (T) = DatumGetChar(newdatum); \
208
+ break; \
209
+ case sizeof(int16): \
210
+ *(int16 *) (T) = DatumGetInt16(newdatum); \
211
+ break; \
212
+ case sizeof(int32): \
213
+ *(int32 *) (T) = DatumGetInt32(newdatum); \
214
+ break; \
215
+ case sizeof(Datum): \
216
+ *(Datum *) (T) = (newdatum); \
217
+ break; \
218
+ default: \
219
+ elog(ERROR, "unsupported byval length: %d", \
220
+ (int) (attlen)); \
221
+ break; \
222
+ } \
223
+ } while (0)
224
+ #else /* SIZEOF_DATUM != 8 */
225
+
226
+ #define store_att_byval(T,newdatum,attlen) \
227
+ do { \
228
+ switch (attlen) \
229
+ { \
230
+ case sizeof(char): \
231
+ *(char *) (T) = DatumGetChar(newdatum); \
232
+ break; \
233
+ case sizeof(int16): \
234
+ *(int16 *) (T) = DatumGetInt16(newdatum); \
235
+ break; \
236
+ case sizeof(int32): \
237
+ *(int32 *) (T) = DatumGetInt32(newdatum); \
238
+ break; \
239
+ default: \
240
+ elog(ERROR, "unsupported byval length: %d", \
241
+ (int) (attlen)); \
242
+ break; \
243
+ } \
244
+ } while (0)
245
+ #endif /* SIZEOF_DATUM == 8 */
246
+
247
+ #endif
@@ -0,0 +1,61 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * twophase.h
4
+ * Two-phase-commit related declarations.
5
+ *
6
+ *
7
+ * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
8
+ * Portions Copyright (c) 1994, Regents of the University of California
9
+ *
10
+ * src/include/access/twophase.h
11
+ *
12
+ *-------------------------------------------------------------------------
13
+ */
14
+ #ifndef TWOPHASE_H
15
+ #define TWOPHASE_H
16
+
17
+ #include "access/xact.h"
18
+ #include "access/xlogdefs.h"
19
+ #include "datatype/timestamp.h"
20
+ #include "storage/lock.h"
21
+
22
+ /*
23
+ * GlobalTransactionData is defined in twophase.c; other places have no
24
+ * business knowing the internal definition.
25
+ */
26
+ typedef struct GlobalTransactionData *GlobalTransaction;
27
+
28
+ /* GUC variable */
29
+ extern PGDLLIMPORT int max_prepared_xacts;
30
+
31
+ extern Size TwoPhaseShmemSize(void);
32
+ extern void TwoPhaseShmemInit(void);
33
+
34
+ extern void AtAbort_Twophase(void);
35
+ extern void PostPrepare_Twophase(void);
36
+
37
+ extern PGPROC *TwoPhaseGetDummyProc(TransactionId xid, bool lock_held);
38
+ extern BackendId TwoPhaseGetDummyBackendId(TransactionId xid, bool lock_held);
39
+
40
+ extern GlobalTransaction MarkAsPreparing(TransactionId xid, const char *gid,
41
+ TimestampTz prepared_at,
42
+ Oid owner, Oid databaseid);
43
+
44
+ extern void StartPrepare(GlobalTransaction gxact);
45
+ extern void EndPrepare(GlobalTransaction gxact);
46
+ extern bool StandbyTransactionIdIsPrepared(TransactionId xid);
47
+
48
+ extern TransactionId PrescanPreparedTransactions(TransactionId **xids_p,
49
+ int *nxids_p);
50
+ extern void StandbyRecoverPreparedTransactions(void);
51
+ extern void RecoverPreparedTransactions(void);
52
+
53
+ extern void CheckPointTwoPhase(XLogRecPtr redo_horizon);
54
+
55
+ extern void FinishPreparedTransaction(const char *gid, bool isCommit);
56
+
57
+ extern void PrepareRedoAdd(char *buf, XLogRecPtr start_lsn,
58
+ XLogRecPtr end_lsn, RepOriginId origin_id);
59
+ extern void PrepareRedoRemove(TransactionId xid, bool giveWarning);
60
+ extern void restoreTwoPhaseData(void);
61
+ #endif /* TWOPHASE_H */
@@ -0,0 +1,463 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * xact.h
4
+ * postgres transaction system definitions
5
+ *
6
+ *
7
+ * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
8
+ * Portions Copyright (c) 1994, Regents of the University of California
9
+ *
10
+ * src/include/access/xact.h
11
+ *
12
+ *-------------------------------------------------------------------------
13
+ */
14
+ #ifndef XACT_H
15
+ #define XACT_H
16
+
17
+ #include "access/transam.h"
18
+ #include "access/xlogreader.h"
19
+ #include "lib/stringinfo.h"
20
+ #include "nodes/pg_list.h"
21
+ #include "storage/relfilenode.h"
22
+ #include "storage/sinval.h"
23
+ #include "utils/datetime.h"
24
+
25
+ /*
26
+ * Maximum size of Global Transaction ID (including '\0').
27
+ *
28
+ * Note that the max value of GIDSIZE must fit in the uint16 gidlen,
29
+ * specified in TwoPhaseFileHeader.
30
+ */
31
+ #define GIDSIZE 200
32
+
33
+ /*
34
+ * Xact isolation levels
35
+ */
36
+ #define XACT_READ_UNCOMMITTED 0
37
+ #define XACT_READ_COMMITTED 1
38
+ #define XACT_REPEATABLE_READ 2
39
+ #define XACT_SERIALIZABLE 3
40
+
41
+ extern int DefaultXactIsoLevel;
42
+ extern PGDLLIMPORT int XactIsoLevel;
43
+
44
+ /*
45
+ * We implement three isolation levels internally.
46
+ * The two stronger ones use one snapshot per database transaction;
47
+ * the others use one snapshot per statement.
48
+ * Serializable uses predicate locks in addition to snapshots.
49
+ * These macros should be used to check which isolation level is selected.
50
+ */
51
+ #define IsolationUsesXactSnapshot() (XactIsoLevel >= XACT_REPEATABLE_READ)
52
+ #define IsolationIsSerializable() (XactIsoLevel == XACT_SERIALIZABLE)
53
+
54
+ /* Xact read-only state */
55
+ extern bool DefaultXactReadOnly;
56
+ extern bool XactReadOnly;
57
+
58
+ /* flag for logging statements in this transaction */
59
+ extern bool xact_is_sampled;
60
+
61
+ /*
62
+ * Xact is deferrable -- only meaningful (currently) for read only
63
+ * SERIALIZABLE transactions
64
+ */
65
+ extern bool DefaultXactDeferrable;
66
+ extern bool XactDeferrable;
67
+
68
+ typedef enum
69
+ {
70
+ SYNCHRONOUS_COMMIT_OFF, /* asynchronous commit */
71
+ SYNCHRONOUS_COMMIT_LOCAL_FLUSH, /* wait for local flush only */
72
+ SYNCHRONOUS_COMMIT_REMOTE_WRITE, /* wait for local flush and remote
73
+ * write */
74
+ SYNCHRONOUS_COMMIT_REMOTE_FLUSH, /* wait for local and remote flush */
75
+ SYNCHRONOUS_COMMIT_REMOTE_APPLY /* wait for local and remote flush
76
+ and remote apply */
77
+ } SyncCommitLevel;
78
+
79
+ /* Define the default setting for synchronous_commit */
80
+ #define SYNCHRONOUS_COMMIT_ON SYNCHRONOUS_COMMIT_REMOTE_FLUSH
81
+
82
+ /* Synchronous commit level */
83
+ extern int synchronous_commit;
84
+
85
+ /*
86
+ * Miscellaneous flag bits to record events which occur on the top level
87
+ * transaction. These flags are only persisted in MyXactFlags and are intended
88
+ * so we remember to do certain things later in the transaction. This is
89
+ * globally accessible, so can be set from anywhere in the code which requires
90
+ * recording flags.
91
+ */
92
+ extern int MyXactFlags;
93
+
94
+ /*
95
+ * XACT_FLAGS_ACCESSEDTEMPNAMESPACE - set when a temporary object is accessed.
96
+ * We don't allow PREPARE TRANSACTION in that case.
97
+ */
98
+ #define XACT_FLAGS_ACCESSEDTEMPNAMESPACE (1U << 0)
99
+
100
+ /*
101
+ * XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK - records whether the top level xact
102
+ * logged any Access Exclusive Locks.
103
+ */
104
+ #define XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK (1U << 1)
105
+
106
+ /*
107
+ * start- and end-of-transaction callbacks for dynamically loaded modules
108
+ */
109
+ typedef enum
110
+ {
111
+ XACT_EVENT_COMMIT,
112
+ XACT_EVENT_PARALLEL_COMMIT,
113
+ XACT_EVENT_ABORT,
114
+ XACT_EVENT_PARALLEL_ABORT,
115
+ XACT_EVENT_PREPARE,
116
+ XACT_EVENT_PRE_COMMIT,
117
+ XACT_EVENT_PARALLEL_PRE_COMMIT,
118
+ XACT_EVENT_PRE_PREPARE
119
+ } XactEvent;
120
+
121
+ typedef void (*XactCallback) (XactEvent event, void *arg);
122
+
123
+ typedef enum
124
+ {
125
+ SUBXACT_EVENT_START_SUB,
126
+ SUBXACT_EVENT_COMMIT_SUB,
127
+ SUBXACT_EVENT_ABORT_SUB,
128
+ SUBXACT_EVENT_PRE_COMMIT_SUB
129
+ } SubXactEvent;
130
+
131
+ typedef void (*SubXactCallback) (SubXactEvent event, SubTransactionId mySubid,
132
+ SubTransactionId parentSubid, void *arg);
133
+
134
+
135
+ /* ----------------
136
+ * transaction-related XLOG entries
137
+ * ----------------
138
+ */
139
+
140
+ /*
141
+ * XLOG allows to store some information in high 4 bits of log record xl_info
142
+ * field. We use 3 for the opcode, and one about an optional flag variable.
143
+ */
144
+ #define XLOG_XACT_COMMIT 0x00
145
+ #define XLOG_XACT_PREPARE 0x10
146
+ #define XLOG_XACT_ABORT 0x20
147
+ #define XLOG_XACT_COMMIT_PREPARED 0x30
148
+ #define XLOG_XACT_ABORT_PREPARED 0x40
149
+ #define XLOG_XACT_ASSIGNMENT 0x50
150
+ /* free opcode 0x60 */
151
+ /* free opcode 0x70 */
152
+
153
+ /* mask for filtering opcodes out of xl_info */
154
+ #define XLOG_XACT_OPMASK 0x70
155
+
156
+ /* does this record have a 'xinfo' field or not */
157
+ #define XLOG_XACT_HAS_INFO 0x80
158
+
159
+ /*
160
+ * The following flags, stored in xinfo, determine which information is
161
+ * contained in commit/abort records.
162
+ */
163
+ #define XACT_XINFO_HAS_DBINFO (1U << 0)
164
+ #define XACT_XINFO_HAS_SUBXACTS (1U << 1)
165
+ #define XACT_XINFO_HAS_RELFILENODES (1U << 2)
166
+ #define XACT_XINFO_HAS_INVALS (1U << 3)
167
+ #define XACT_XINFO_HAS_TWOPHASE (1U << 4)
168
+ #define XACT_XINFO_HAS_ORIGIN (1U << 5)
169
+ #define XACT_XINFO_HAS_AE_LOCKS (1U << 6)
170
+ #define XACT_XINFO_HAS_GID (1U << 7)
171
+
172
+ /*
173
+ * Also stored in xinfo, these indicating a variety of additional actions that
174
+ * need to occur when emulating transaction effects during recovery.
175
+ *
176
+ * They are named XactCompletion... to differentiate them from
177
+ * EOXact... routines which run at the end of the original transaction
178
+ * completion.
179
+ */
180
+ #define XACT_COMPLETION_APPLY_FEEDBACK (1U << 29)
181
+ #define XACT_COMPLETION_UPDATE_RELCACHE_FILE (1U << 30)
182
+ #define XACT_COMPLETION_FORCE_SYNC_COMMIT (1U << 31)
183
+
184
+ /* Access macros for above flags */
185
+ #define XactCompletionApplyFeedback(xinfo) \
186
+ ((xinfo & XACT_COMPLETION_APPLY_FEEDBACK) != 0)
187
+ #define XactCompletionRelcacheInitFileInval(xinfo) \
188
+ ((xinfo & XACT_COMPLETION_UPDATE_RELCACHE_FILE) != 0)
189
+ #define XactCompletionForceSyncCommit(xinfo) \
190
+ ((xinfo & XACT_COMPLETION_FORCE_SYNC_COMMIT) != 0)
191
+
192
+ typedef struct xl_xact_assignment
193
+ {
194
+ TransactionId xtop; /* assigned XID's top-level XID */
195
+ int nsubxacts; /* number of subtransaction XIDs */
196
+ TransactionId xsub[FLEXIBLE_ARRAY_MEMBER]; /* assigned subxids */
197
+ } xl_xact_assignment;
198
+
199
+ #define MinSizeOfXactAssignment offsetof(xl_xact_assignment, xsub)
200
+
201
+ /*
202
+ * Commit and abort records can contain a lot of information. But a large
203
+ * portion of the records won't need all possible pieces of information. So we
204
+ * only include what's needed.
205
+ *
206
+ * A minimal commit/abort record only consists of a xl_xact_commit/abort
207
+ * struct. The presence of additional information is indicated by bits set in
208
+ * 'xl_xact_xinfo->xinfo'. The presence of the xinfo field itself is signaled
209
+ * by a set XLOG_XACT_HAS_INFO bit in the xl_info field.
210
+ *
211
+ * NB: All the individual data chunks should be sized to multiples of
212
+ * sizeof(int) and only require int32 alignment. If they require bigger
213
+ * alignment, they need to be copied upon reading.
214
+ */
215
+
216
+ /* sub-records for commit/abort */
217
+
218
+ typedef struct xl_xact_xinfo
219
+ {
220
+ /*
221
+ * Even though we right now only require 1 byte of space in xinfo we use
222
+ * four so following records don't have to care about alignment. Commit
223
+ * records can be large, so copying large portions isn't attractive.
224
+ */
225
+ uint32 xinfo;
226
+ } xl_xact_xinfo;
227
+
228
+ typedef struct xl_xact_dbinfo
229
+ {
230
+ Oid dbId; /* MyDatabaseId */
231
+ Oid tsId; /* MyDatabaseTableSpace */
232
+ } xl_xact_dbinfo;
233
+
234
+ typedef struct xl_xact_subxacts
235
+ {
236
+ int nsubxacts; /* number of subtransaction XIDs */
237
+ TransactionId subxacts[FLEXIBLE_ARRAY_MEMBER];
238
+ } xl_xact_subxacts;
239
+ #define MinSizeOfXactSubxacts offsetof(xl_xact_subxacts, subxacts)
240
+
241
+ typedef struct xl_xact_relfilenodes
242
+ {
243
+ int nrels; /* number of relations */
244
+ RelFileNode xnodes[FLEXIBLE_ARRAY_MEMBER];
245
+ } xl_xact_relfilenodes;
246
+ #define MinSizeOfXactRelfilenodes offsetof(xl_xact_relfilenodes, xnodes)
247
+
248
+ typedef struct xl_xact_invals
249
+ {
250
+ int nmsgs; /* number of shared inval msgs */
251
+ SharedInvalidationMessage msgs[FLEXIBLE_ARRAY_MEMBER];
252
+ } xl_xact_invals;
253
+ #define MinSizeOfXactInvals offsetof(xl_xact_invals, msgs)
254
+
255
+ typedef struct xl_xact_twophase
256
+ {
257
+ TransactionId xid;
258
+ } xl_xact_twophase;
259
+
260
+ typedef struct xl_xact_origin
261
+ {
262
+ XLogRecPtr origin_lsn;
263
+ TimestampTz origin_timestamp;
264
+ } xl_xact_origin;
265
+
266
+ typedef struct xl_xact_commit
267
+ {
268
+ TimestampTz xact_time; /* time of commit */
269
+
270
+ /* xl_xact_xinfo follows if XLOG_XACT_HAS_INFO */
271
+ /* xl_xact_dbinfo follows if XINFO_HAS_DBINFO */
272
+ /* xl_xact_subxacts follows if XINFO_HAS_SUBXACT */
273
+ /* xl_xact_relfilenodes follows if XINFO_HAS_RELFILENODES */
274
+ /* xl_xact_invals follows if XINFO_HAS_INVALS */
275
+ /* xl_xact_twophase follows if XINFO_HAS_TWOPHASE */
276
+ /* twophase_gid follows if XINFO_HAS_GID. As a null-terminated string. */
277
+ /* xl_xact_origin follows if XINFO_HAS_ORIGIN, stored unaligned! */
278
+ } xl_xact_commit;
279
+ #define MinSizeOfXactCommit (offsetof(xl_xact_commit, xact_time) + sizeof(TimestampTz))
280
+
281
+ typedef struct xl_xact_abort
282
+ {
283
+ TimestampTz xact_time; /* time of abort */
284
+
285
+ /* xl_xact_xinfo follows if XLOG_XACT_HAS_INFO */
286
+ /* xl_xact_dbinfo follows if XINFO_HAS_DBINFO */
287
+ /* xl_xact_subxacts follows if XINFO_HAS_SUBXACT */
288
+ /* xl_xact_relfilenodes follows if XINFO_HAS_RELFILENODES */
289
+ /* No invalidation messages needed. */
290
+ /* xl_xact_twophase follows if XINFO_HAS_TWOPHASE */
291
+ /* twophase_gid follows if XINFO_HAS_GID. As a null-terminated string. */
292
+ /* xl_xact_origin follows if XINFO_HAS_ORIGIN, stored unaligned! */
293
+ } xl_xact_abort;
294
+ #define MinSizeOfXactAbort sizeof(xl_xact_abort)
295
+
296
+ typedef struct xl_xact_prepare
297
+ {
298
+ uint32 magic; /* format identifier */
299
+ uint32 total_len; /* actual file length */
300
+ TransactionId xid; /* original transaction XID */
301
+ Oid database; /* OID of database it was in */
302
+ TimestampTz prepared_at; /* time of preparation */
303
+ Oid owner; /* user running the transaction */
304
+ int32 nsubxacts; /* number of following subxact XIDs */
305
+ int32 ncommitrels; /* number of delete-on-commit rels */
306
+ int32 nabortrels; /* number of delete-on-abort rels */
307
+ int32 ninvalmsgs; /* number of cache invalidation messages */
308
+ bool initfileinval; /* does relcache init file need invalidation? */
309
+ uint16 gidlen; /* length of the GID - GID follows the header */
310
+ XLogRecPtr origin_lsn; /* lsn of this record at origin node */
311
+ TimestampTz origin_timestamp; /* time of prepare at origin node */
312
+ } xl_xact_prepare;
313
+
314
+ /*
315
+ * Commit/Abort records in the above form are a bit verbose to parse, so
316
+ * there's a deconstructed versions generated by ParseCommit/AbortRecord() for
317
+ * easier consumption.
318
+ */
319
+ typedef struct xl_xact_parsed_commit
320
+ {
321
+ TimestampTz xact_time;
322
+ uint32 xinfo;
323
+
324
+ Oid dbId; /* MyDatabaseId */
325
+ Oid tsId; /* MyDatabaseTableSpace */
326
+
327
+ int nsubxacts;
328
+ TransactionId *subxacts;
329
+
330
+ int nrels;
331
+ RelFileNode *xnodes;
332
+
333
+ int nmsgs;
334
+ SharedInvalidationMessage *msgs;
335
+
336
+ TransactionId twophase_xid; /* only for 2PC */
337
+ char twophase_gid[GIDSIZE]; /* only for 2PC */
338
+ int nabortrels; /* only for 2PC */
339
+ RelFileNode *abortnodes; /* only for 2PC */
340
+
341
+ XLogRecPtr origin_lsn;
342
+ TimestampTz origin_timestamp;
343
+ } xl_xact_parsed_commit;
344
+
345
+ typedef xl_xact_parsed_commit xl_xact_parsed_prepare;
346
+
347
+ typedef struct xl_xact_parsed_abort
348
+ {
349
+ TimestampTz xact_time;
350
+ uint32 xinfo;
351
+
352
+ Oid dbId; /* MyDatabaseId */
353
+ Oid tsId; /* MyDatabaseTableSpace */
354
+
355
+ int nsubxacts;
356
+ TransactionId *subxacts;
357
+
358
+ int nrels;
359
+ RelFileNode *xnodes;
360
+
361
+ TransactionId twophase_xid; /* only for 2PC */
362
+ char twophase_gid[GIDSIZE]; /* only for 2PC */
363
+
364
+ XLogRecPtr origin_lsn;
365
+ TimestampTz origin_timestamp;
366
+ } xl_xact_parsed_abort;
367
+
368
+
369
+ /* ----------------
370
+ * extern definitions
371
+ * ----------------
372
+ */
373
+ extern bool IsTransactionState(void);
374
+ extern bool IsAbortedTransactionBlockState(void);
375
+ extern TransactionId GetTopTransactionId(void);
376
+ extern TransactionId GetTopTransactionIdIfAny(void);
377
+ extern TransactionId GetCurrentTransactionId(void);
378
+ extern TransactionId GetCurrentTransactionIdIfAny(void);
379
+ extern TransactionId GetStableLatestTransactionId(void);
380
+ extern SubTransactionId GetCurrentSubTransactionId(void);
381
+ extern FullTransactionId GetTopFullTransactionId(void);
382
+ extern FullTransactionId GetTopFullTransactionIdIfAny(void);
383
+ extern FullTransactionId GetCurrentFullTransactionId(void);
384
+ extern FullTransactionId GetCurrentFullTransactionIdIfAny(void);
385
+ extern void MarkCurrentTransactionIdLoggedIfAny(void);
386
+ extern bool SubTransactionIsActive(SubTransactionId subxid);
387
+ extern CommandId GetCurrentCommandId(bool used);
388
+ extern void SetParallelStartTimestamps(TimestampTz xact_ts, TimestampTz stmt_ts);
389
+ extern TimestampTz GetCurrentTransactionStartTimestamp(void);
390
+ extern TimestampTz GetCurrentStatementStartTimestamp(void);
391
+ extern TimestampTz GetCurrentTransactionStopTimestamp(void);
392
+ extern void SetCurrentStatementStartTimestamp(void);
393
+ extern int GetCurrentTransactionNestLevel(void);
394
+ extern bool TransactionIdIsCurrentTransactionId(TransactionId xid);
395
+ extern void CommandCounterIncrement(void);
396
+ extern void ForceSyncCommit(void);
397
+ extern void StartTransactionCommand(void);
398
+ extern void SaveTransactionCharacteristics(void);
399
+ extern void RestoreTransactionCharacteristics(void);
400
+ extern void CommitTransactionCommand(void);
401
+ extern void AbortCurrentTransaction(void);
402
+ extern void BeginTransactionBlock(void);
403
+ extern bool EndTransactionBlock(bool chain);
404
+ extern bool PrepareTransactionBlock(const char *gid);
405
+ extern void UserAbortTransactionBlock(bool chain);
406
+ extern void BeginImplicitTransactionBlock(void);
407
+ extern void EndImplicitTransactionBlock(void);
408
+ extern void ReleaseSavepoint(const char *name);
409
+ extern void DefineSavepoint(const char *name);
410
+ extern void RollbackToSavepoint(const char *name);
411
+ extern void BeginInternalSubTransaction(const char *name);
412
+ extern void ReleaseCurrentSubTransaction(void);
413
+ extern void RollbackAndReleaseCurrentSubTransaction(void);
414
+ extern bool IsSubTransaction(void);
415
+ extern Size EstimateTransactionStateSpace(void);
416
+ extern void SerializeTransactionState(Size maxsize, char *start_address);
417
+ extern void StartParallelWorkerTransaction(char *tstatespace);
418
+ extern void EndParallelWorkerTransaction(void);
419
+ extern bool IsTransactionBlock(void);
420
+ extern bool IsTransactionOrTransactionBlock(void);
421
+ extern char TransactionBlockStatusCode(void);
422
+ extern void AbortOutOfAnyTransaction(void);
423
+ extern void PreventInTransactionBlock(bool isTopLevel, const char *stmtType);
424
+ extern void RequireTransactionBlock(bool isTopLevel, const char *stmtType);
425
+ extern void WarnNoTransactionBlock(bool isTopLevel, const char *stmtType);
426
+ extern bool IsInTransactionBlock(bool isTopLevel);
427
+ extern void RegisterXactCallback(XactCallback callback, void *arg);
428
+ extern void UnregisterXactCallback(XactCallback callback, void *arg);
429
+ extern void RegisterSubXactCallback(SubXactCallback callback, void *arg);
430
+ extern void UnregisterSubXactCallback(SubXactCallback callback, void *arg);
431
+
432
+ extern int xactGetCommittedChildren(TransactionId **ptr);
433
+
434
+ extern XLogRecPtr XactLogCommitRecord(TimestampTz commit_time,
435
+ int nsubxacts, TransactionId *subxacts,
436
+ int nrels, RelFileNode *rels,
437
+ int nmsgs, SharedInvalidationMessage *msgs,
438
+ bool relcacheInval, bool forceSync,
439
+ int xactflags,
440
+ TransactionId twophase_xid,
441
+ const char *twophase_gid);
442
+
443
+ extern XLogRecPtr XactLogAbortRecord(TimestampTz abort_time,
444
+ int nsubxacts, TransactionId *subxacts,
445
+ int nrels, RelFileNode *rels,
446
+ int xactflags, TransactionId twophase_xid,
447
+ const char *twophase_gid);
448
+ extern void xact_redo(XLogReaderState *record);
449
+
450
+ /* xactdesc.c */
451
+ extern void xact_desc(StringInfo buf, XLogReaderState *record);
452
+ extern const char *xact_identify(uint8 info);
453
+
454
+ /* also in xactdesc.c, so they can be shared between front/backend code */
455
+ extern void ParseCommitRecord(uint8 info, xl_xact_commit *xlrec, xl_xact_parsed_commit *parsed);
456
+ extern void ParseAbortRecord(uint8 info, xl_xact_abort *xlrec, xl_xact_parsed_abort *parsed);
457
+ extern void ParsePrepareRecord(uint8 info, xl_xact_prepare *xlrec, xl_xact_parsed_prepare *parsed);
458
+
459
+ extern void EnterParallelMode(void);
460
+ extern void ExitParallelMode(void);
461
+ extern bool IsInParallelMode(void);
462
+
463
+ #endif /* XACT_H */