pg_query 1.1.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (478) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +163 -52
  3. data/README.md +80 -69
  4. data/Rakefile +82 -1
  5. data/ext/pg_query/extconf.rb +3 -31
  6. data/ext/pg_query/guc-file.c +0 -0
  7. data/ext/pg_query/include/access/amapi.h +246 -0
  8. data/ext/pg_query/include/access/attmap.h +52 -0
  9. data/ext/pg_query/include/access/attnum.h +64 -0
  10. data/ext/pg_query/include/access/clog.h +61 -0
  11. data/ext/pg_query/include/access/commit_ts.h +77 -0
  12. data/ext/pg_query/include/access/detoast.h +92 -0
  13. data/ext/pg_query/include/access/genam.h +228 -0
  14. data/ext/pg_query/include/access/gin.h +78 -0
  15. data/ext/pg_query/include/access/htup.h +89 -0
  16. data/ext/pg_query/include/access/htup_details.h +819 -0
  17. data/ext/pg_query/include/access/itup.h +161 -0
  18. data/ext/pg_query/include/access/parallel.h +82 -0
  19. data/ext/pg_query/include/access/printtup.h +35 -0
  20. data/ext/pg_query/include/access/relation.h +28 -0
  21. data/ext/pg_query/include/access/relscan.h +176 -0
  22. data/ext/pg_query/include/access/rmgr.h +35 -0
  23. data/ext/pg_query/include/access/rmgrlist.h +49 -0
  24. data/ext/pg_query/include/access/sdir.h +58 -0
  25. data/ext/pg_query/include/access/skey.h +151 -0
  26. data/ext/pg_query/include/access/stratnum.h +83 -0
  27. data/ext/pg_query/include/access/sysattr.h +29 -0
  28. data/ext/pg_query/include/access/table.h +27 -0
  29. data/ext/pg_query/include/access/tableam.h +1825 -0
  30. data/ext/pg_query/include/access/transam.h +265 -0
  31. data/ext/pg_query/include/access/tupconvert.h +51 -0
  32. data/ext/pg_query/include/access/tupdesc.h +154 -0
  33. data/ext/pg_query/include/access/tupmacs.h +247 -0
  34. data/ext/pg_query/include/access/twophase.h +61 -0
  35. data/ext/pg_query/include/access/xact.h +463 -0
  36. data/ext/pg_query/include/access/xlog.h +398 -0
  37. data/ext/pg_query/include/access/xlog_internal.h +330 -0
  38. data/ext/pg_query/include/access/xlogdefs.h +109 -0
  39. data/ext/pg_query/include/access/xloginsert.h +64 -0
  40. data/ext/pg_query/include/access/xlogreader.h +327 -0
  41. data/ext/pg_query/include/access/xlogrecord.h +227 -0
  42. data/ext/pg_query/include/bootstrap/bootstrap.h +62 -0
  43. data/ext/pg_query/include/c.h +1322 -0
  44. data/ext/pg_query/include/catalog/catalog.h +42 -0
  45. data/ext/pg_query/include/catalog/catversion.h +58 -0
  46. data/ext/pg_query/include/catalog/dependency.h +275 -0
  47. data/ext/pg_query/include/catalog/genbki.h +64 -0
  48. data/ext/pg_query/include/catalog/index.h +199 -0
  49. data/ext/pg_query/include/catalog/indexing.h +366 -0
  50. data/ext/pg_query/include/catalog/namespace.h +188 -0
  51. data/ext/pg_query/include/catalog/objectaccess.h +197 -0
  52. data/ext/pg_query/include/catalog/objectaddress.h +84 -0
  53. data/ext/pg_query/include/catalog/pg_aggregate.h +176 -0
  54. data/ext/pg_query/include/catalog/pg_aggregate_d.h +77 -0
  55. data/ext/pg_query/include/catalog/pg_am.h +60 -0
  56. data/ext/pg_query/include/catalog/pg_am_d.h +45 -0
  57. data/ext/pg_query/include/catalog/pg_attribute.h +204 -0
  58. data/ext/pg_query/include/catalog/pg_attribute_d.h +59 -0
  59. data/ext/pg_query/include/catalog/pg_authid.h +58 -0
  60. data/ext/pg_query/include/catalog/pg_authid_d.h +49 -0
  61. data/ext/pg_query/include/catalog/pg_class.h +200 -0
  62. data/ext/pg_query/include/catalog/pg_class_d.h +103 -0
  63. data/ext/pg_query/include/catalog/pg_collation.h +73 -0
  64. data/ext/pg_query/include/catalog/pg_collation_d.h +45 -0
  65. data/ext/pg_query/include/catalog/pg_constraint.h +247 -0
  66. data/ext/pg_query/include/catalog/pg_constraint_d.h +67 -0
  67. data/ext/pg_query/include/catalog/pg_control.h +250 -0
  68. data/ext/pg_query/include/catalog/pg_conversion.h +72 -0
  69. data/ext/pg_query/include/catalog/pg_conversion_d.h +35 -0
  70. data/ext/pg_query/include/catalog/pg_depend.h +73 -0
  71. data/ext/pg_query/include/catalog/pg_depend_d.h +34 -0
  72. data/ext/pg_query/include/catalog/pg_event_trigger.h +51 -0
  73. data/ext/pg_query/include/catalog/pg_event_trigger_d.h +34 -0
  74. data/ext/pg_query/include/catalog/pg_index.h +80 -0
  75. data/ext/pg_query/include/catalog/pg_index_d.h +56 -0
  76. data/ext/pg_query/include/catalog/pg_language.h +67 -0
  77. data/ext/pg_query/include/catalog/pg_language_d.h +39 -0
  78. data/ext/pg_query/include/catalog/pg_namespace.h +59 -0
  79. data/ext/pg_query/include/catalog/pg_namespace_d.h +34 -0
  80. data/ext/pg_query/include/catalog/pg_opclass.h +85 -0
  81. data/ext/pg_query/include/catalog/pg_opclass_d.h +49 -0
  82. data/ext/pg_query/include/catalog/pg_operator.h +102 -0
  83. data/ext/pg_query/include/catalog/pg_operator_d.h +106 -0
  84. data/ext/pg_query/include/catalog/pg_opfamily.h +60 -0
  85. data/ext/pg_query/include/catalog/pg_opfamily_d.h +47 -0
  86. data/ext/pg_query/include/catalog/pg_partitioned_table.h +63 -0
  87. data/ext/pg_query/include/catalog/pg_partitioned_table_d.h +35 -0
  88. data/ext/pg_query/include/catalog/pg_proc.h +211 -0
  89. data/ext/pg_query/include/catalog/pg_proc_d.h +99 -0
  90. data/ext/pg_query/include/catalog/pg_publication.h +115 -0
  91. data/ext/pg_query/include/catalog/pg_publication_d.h +36 -0
  92. data/ext/pg_query/include/catalog/pg_replication_origin.h +57 -0
  93. data/ext/pg_query/include/catalog/pg_replication_origin_d.h +29 -0
  94. data/ext/pg_query/include/catalog/pg_statistic.h +275 -0
  95. data/ext/pg_query/include/catalog/pg_statistic_d.h +194 -0
  96. data/ext/pg_query/include/catalog/pg_statistic_ext.h +74 -0
  97. data/ext/pg_query/include/catalog/pg_statistic_ext_d.h +40 -0
  98. data/ext/pg_query/include/catalog/pg_transform.h +45 -0
  99. data/ext/pg_query/include/catalog/pg_transform_d.h +32 -0
  100. data/ext/pg_query/include/catalog/pg_trigger.h +137 -0
  101. data/ext/pg_query/include/catalog/pg_trigger_d.h +106 -0
  102. data/ext/pg_query/include/catalog/pg_ts_config.h +50 -0
  103. data/ext/pg_query/include/catalog/pg_ts_config_d.h +32 -0
  104. data/ext/pg_query/include/catalog/pg_ts_dict.h +54 -0
  105. data/ext/pg_query/include/catalog/pg_ts_dict_d.h +33 -0
  106. data/ext/pg_query/include/catalog/pg_ts_parser.h +57 -0
  107. data/ext/pg_query/include/catalog/pg_ts_parser_d.h +35 -0
  108. data/ext/pg_query/include/catalog/pg_ts_template.h +48 -0
  109. data/ext/pg_query/include/catalog/pg_ts_template_d.h +32 -0
  110. data/ext/pg_query/include/catalog/pg_type.h +372 -0
  111. data/ext/pg_query/include/catalog/pg_type_d.h +285 -0
  112. data/ext/pg_query/include/catalog/storage.h +48 -0
  113. data/ext/pg_query/include/commands/async.h +54 -0
  114. data/ext/pg_query/include/commands/dbcommands.h +35 -0
  115. data/ext/pg_query/include/commands/defrem.h +173 -0
  116. data/ext/pg_query/include/commands/event_trigger.h +88 -0
  117. data/ext/pg_query/include/commands/explain.h +127 -0
  118. data/ext/pg_query/include/commands/prepare.h +61 -0
  119. data/ext/pg_query/include/commands/tablespace.h +67 -0
  120. data/ext/pg_query/include/commands/trigger.h +277 -0
  121. data/ext/pg_query/include/commands/user.h +37 -0
  122. data/ext/pg_query/include/commands/vacuum.h +293 -0
  123. data/ext/pg_query/include/commands/variable.h +38 -0
  124. data/ext/pg_query/include/common/file_perm.h +56 -0
  125. data/ext/pg_query/include/common/hashfn.h +104 -0
  126. data/ext/pg_query/include/common/ip.h +37 -0
  127. data/ext/pg_query/include/common/keywords.h +33 -0
  128. data/ext/pg_query/include/common/kwlookup.h +44 -0
  129. data/ext/pg_query/include/common/relpath.h +90 -0
  130. data/ext/pg_query/include/common/string.h +19 -0
  131. data/ext/pg_query/include/common/unicode_combining_table.h +196 -0
  132. data/ext/pg_query/include/datatype/timestamp.h +197 -0
  133. data/ext/pg_query/include/executor/execdesc.h +70 -0
  134. data/ext/pg_query/include/executor/executor.h +614 -0
  135. data/ext/pg_query/include/executor/functions.h +41 -0
  136. data/ext/pg_query/include/executor/instrument.h +101 -0
  137. data/ext/pg_query/include/executor/spi.h +175 -0
  138. data/ext/pg_query/include/executor/tablefunc.h +67 -0
  139. data/ext/pg_query/include/executor/tuptable.h +487 -0
  140. data/ext/pg_query/include/fmgr.h +775 -0
  141. data/ext/pg_query/include/funcapi.h +348 -0
  142. data/ext/pg_query/include/getaddrinfo.h +162 -0
  143. data/ext/pg_query/include/jit/jit.h +105 -0
  144. data/ext/pg_query/include/kwlist_d.h +1072 -0
  145. data/ext/pg_query/include/lib/ilist.h +727 -0
  146. data/ext/pg_query/include/lib/pairingheap.h +102 -0
  147. data/ext/pg_query/include/lib/simplehash.h +1059 -0
  148. data/ext/pg_query/include/lib/stringinfo.h +161 -0
  149. data/ext/pg_query/include/libpq/auth.h +29 -0
  150. data/ext/pg_query/include/libpq/crypt.h +46 -0
  151. data/ext/pg_query/include/libpq/hba.h +140 -0
  152. data/ext/pg_query/include/libpq/libpq-be.h +326 -0
  153. data/ext/pg_query/include/libpq/libpq.h +133 -0
  154. data/ext/pg_query/include/libpq/pqcomm.h +208 -0
  155. data/ext/pg_query/include/libpq/pqformat.h +210 -0
  156. data/ext/pg_query/include/libpq/pqsignal.h +42 -0
  157. data/ext/pg_query/include/mb/pg_wchar.h +672 -0
  158. data/ext/pg_query/include/mb/stringinfo_mb.h +24 -0
  159. data/ext/pg_query/include/miscadmin.h +476 -0
  160. data/ext/pg_query/include/nodes/bitmapset.h +122 -0
  161. data/ext/pg_query/include/nodes/execnodes.h +2520 -0
  162. data/ext/pg_query/include/nodes/extensible.h +160 -0
  163. data/ext/pg_query/include/nodes/lockoptions.h +61 -0
  164. data/ext/pg_query/include/nodes/makefuncs.h +108 -0
  165. data/ext/pg_query/include/nodes/memnodes.h +108 -0
  166. data/ext/pg_query/include/nodes/nodeFuncs.h +162 -0
  167. data/ext/pg_query/include/nodes/nodes.h +842 -0
  168. data/ext/pg_query/include/nodes/params.h +170 -0
  169. data/ext/pg_query/include/nodes/parsenodes.h +3579 -0
  170. data/ext/pg_query/include/nodes/pathnodes.h +2556 -0
  171. data/ext/pg_query/include/nodes/pg_list.h +605 -0
  172. data/ext/pg_query/include/nodes/plannodes.h +1251 -0
  173. data/ext/pg_query/include/nodes/primnodes.h +1541 -0
  174. data/ext/pg_query/include/nodes/print.h +34 -0
  175. data/ext/pg_query/include/nodes/tidbitmap.h +75 -0
  176. data/ext/pg_query/include/nodes/value.h +61 -0
  177. data/ext/pg_query/include/optimizer/cost.h +206 -0
  178. data/ext/pg_query/include/optimizer/geqo.h +88 -0
  179. data/ext/pg_query/include/optimizer/geqo_gene.h +45 -0
  180. data/ext/pg_query/include/optimizer/optimizer.h +199 -0
  181. data/ext/pg_query/include/optimizer/paths.h +249 -0
  182. data/ext/pg_query/include/optimizer/planmain.h +119 -0
  183. data/ext/pg_query/include/parser/analyze.h +49 -0
  184. data/ext/pg_query/include/parser/gram.h +1067 -0
  185. data/ext/pg_query/include/parser/gramparse.h +75 -0
  186. data/ext/pg_query/include/parser/kwlist.h +477 -0
  187. data/ext/pg_query/include/parser/parse_agg.h +68 -0
  188. data/ext/pg_query/include/parser/parse_clause.h +54 -0
  189. data/ext/pg_query/include/parser/parse_coerce.h +97 -0
  190. data/ext/pg_query/include/parser/parse_collate.h +27 -0
  191. data/ext/pg_query/include/parser/parse_expr.h +26 -0
  192. data/ext/pg_query/include/parser/parse_func.h +73 -0
  193. data/ext/pg_query/include/parser/parse_node.h +327 -0
  194. data/ext/pg_query/include/parser/parse_oper.h +67 -0
  195. data/ext/pg_query/include/parser/parse_relation.h +123 -0
  196. data/ext/pg_query/include/parser/parse_target.h +46 -0
  197. data/ext/pg_query/include/parser/parse_type.h +60 -0
  198. data/ext/pg_query/include/parser/parser.h +41 -0
  199. data/ext/pg_query/include/parser/parsetree.h +61 -0
  200. data/ext/pg_query/include/parser/scanner.h +152 -0
  201. data/ext/pg_query/include/parser/scansup.h +30 -0
  202. data/ext/pg_query/include/partitioning/partdefs.h +26 -0
  203. data/ext/pg_query/include/pg_config.h +988 -0
  204. data/ext/pg_query/include/pg_config_ext.h +8 -0
  205. data/ext/pg_query/include/pg_config_manual.h +350 -0
  206. data/ext/pg_query/include/pg_config_os.h +8 -0
  207. data/ext/pg_query/include/pg_getopt.h +56 -0
  208. data/ext/pg_query/include/pg_query.h +121 -0
  209. data/ext/pg_query/include/pg_query_enum_defs.c +2454 -0
  210. data/ext/pg_query/include/pg_query_fingerprint_conds.c +875 -0
  211. data/ext/pg_query/include/pg_query_fingerprint_defs.c +12413 -0
  212. data/ext/pg_query/include/pg_query_json_helper.c +61 -0
  213. data/ext/pg_query/include/pg_query_outfuncs_conds.c +686 -0
  214. data/ext/pg_query/include/pg_query_outfuncs_defs.c +2437 -0
  215. data/ext/pg_query/include/pg_query_readfuncs_conds.c +222 -0
  216. data/ext/pg_query/include/pg_query_readfuncs_defs.c +2878 -0
  217. data/ext/pg_query/include/pg_trace.h +17 -0
  218. data/ext/pg_query/include/pgstat.h +1487 -0
  219. data/ext/pg_query/include/pgtime.h +84 -0
  220. data/ext/pg_query/include/pl_gram.h +385 -0
  221. data/ext/pg_query/include/pl_reserved_kwlist.h +52 -0
  222. data/ext/pg_query/include/pl_reserved_kwlist_d.h +114 -0
  223. data/ext/pg_query/include/pl_unreserved_kwlist.h +112 -0
  224. data/ext/pg_query/include/pl_unreserved_kwlist_d.h +246 -0
  225. data/ext/pg_query/include/plerrcodes.h +990 -0
  226. data/ext/pg_query/include/plpgsql.h +1347 -0
  227. data/ext/pg_query/include/port.h +524 -0
  228. data/ext/pg_query/include/port/atomics.h +524 -0
  229. data/ext/pg_query/include/port/atomics/arch-arm.h +26 -0
  230. data/ext/pg_query/include/port/atomics/arch-ppc.h +254 -0
  231. data/ext/pg_query/include/port/atomics/arch-x86.h +252 -0
  232. data/ext/pg_query/include/port/atomics/fallback.h +170 -0
  233. data/ext/pg_query/include/port/atomics/generic-gcc.h +286 -0
  234. data/ext/pg_query/include/port/atomics/generic.h +401 -0
  235. data/ext/pg_query/include/port/pg_bitutils.h +226 -0
  236. data/ext/pg_query/include/port/pg_bswap.h +161 -0
  237. data/ext/pg_query/include/port/pg_crc32c.h +101 -0
  238. data/ext/pg_query/include/portability/instr_time.h +256 -0
  239. data/ext/pg_query/include/postgres.h +764 -0
  240. data/ext/pg_query/include/postgres_ext.h +74 -0
  241. data/ext/pg_query/include/postmaster/autovacuum.h +83 -0
  242. data/ext/pg_query/include/postmaster/bgworker.h +161 -0
  243. data/ext/pg_query/include/postmaster/bgworker_internals.h +64 -0
  244. data/ext/pg_query/include/postmaster/bgwriter.h +45 -0
  245. data/ext/pg_query/include/postmaster/fork_process.h +17 -0
  246. data/ext/pg_query/include/postmaster/interrupt.h +32 -0
  247. data/ext/pg_query/include/postmaster/pgarch.h +39 -0
  248. data/ext/pg_query/include/postmaster/postmaster.h +77 -0
  249. data/ext/pg_query/include/postmaster/syslogger.h +98 -0
  250. data/ext/pg_query/include/postmaster/walwriter.h +21 -0
  251. data/ext/pg_query/include/protobuf-c.h +1106 -0
  252. data/ext/pg_query/include/protobuf-c/protobuf-c.h +1106 -0
  253. data/ext/pg_query/include/protobuf/pg_query.pb-c.h +10846 -0
  254. data/ext/pg_query/include/protobuf/pg_query.pb.h +124718 -0
  255. data/ext/pg_query/include/regex/regex.h +184 -0
  256. data/ext/pg_query/include/replication/logicallauncher.h +31 -0
  257. data/ext/pg_query/include/replication/logicalproto.h +110 -0
  258. data/ext/pg_query/include/replication/logicalworker.h +19 -0
  259. data/ext/pg_query/include/replication/origin.h +73 -0
  260. data/ext/pg_query/include/replication/reorderbuffer.h +467 -0
  261. data/ext/pg_query/include/replication/slot.h +219 -0
  262. data/ext/pg_query/include/replication/syncrep.h +115 -0
  263. data/ext/pg_query/include/replication/walreceiver.h +340 -0
  264. data/ext/pg_query/include/replication/walsender.h +74 -0
  265. data/ext/pg_query/include/rewrite/prs2lock.h +46 -0
  266. data/ext/pg_query/include/rewrite/rewriteHandler.h +40 -0
  267. data/ext/pg_query/include/rewrite/rewriteManip.h +87 -0
  268. data/ext/pg_query/include/rewrite/rewriteSupport.h +26 -0
  269. data/ext/pg_query/include/storage/backendid.h +37 -0
  270. data/ext/pg_query/include/storage/block.h +121 -0
  271. data/ext/pg_query/include/storage/buf.h +46 -0
  272. data/ext/pg_query/include/storage/bufmgr.h +292 -0
  273. data/ext/pg_query/include/storage/bufpage.h +459 -0
  274. data/ext/pg_query/include/storage/condition_variable.h +62 -0
  275. data/ext/pg_query/include/storage/dsm.h +61 -0
  276. data/ext/pg_query/include/storage/dsm_impl.h +75 -0
  277. data/ext/pg_query/include/storage/fd.h +168 -0
  278. data/ext/pg_query/include/storage/ipc.h +81 -0
  279. data/ext/pg_query/include/storage/item.h +19 -0
  280. data/ext/pg_query/include/storage/itemid.h +184 -0
  281. data/ext/pg_query/include/storage/itemptr.h +206 -0
  282. data/ext/pg_query/include/storage/large_object.h +100 -0
  283. data/ext/pg_query/include/storage/latch.h +190 -0
  284. data/ext/pg_query/include/storage/lmgr.h +114 -0
  285. data/ext/pg_query/include/storage/lock.h +612 -0
  286. data/ext/pg_query/include/storage/lockdefs.h +59 -0
  287. data/ext/pg_query/include/storage/lwlock.h +232 -0
  288. data/ext/pg_query/include/storage/lwlocknames.h +51 -0
  289. data/ext/pg_query/include/storage/off.h +57 -0
  290. data/ext/pg_query/include/storage/pg_sema.h +61 -0
  291. data/ext/pg_query/include/storage/pg_shmem.h +90 -0
  292. data/ext/pg_query/include/storage/pmsignal.h +94 -0
  293. data/ext/pg_query/include/storage/predicate.h +87 -0
  294. data/ext/pg_query/include/storage/proc.h +333 -0
  295. data/ext/pg_query/include/storage/proclist_types.h +51 -0
  296. data/ext/pg_query/include/storage/procsignal.h +75 -0
  297. data/ext/pg_query/include/storage/relfilenode.h +99 -0
  298. data/ext/pg_query/include/storage/s_lock.h +1047 -0
  299. data/ext/pg_query/include/storage/sharedfileset.h +45 -0
  300. data/ext/pg_query/include/storage/shm_mq.h +85 -0
  301. data/ext/pg_query/include/storage/shm_toc.h +58 -0
  302. data/ext/pg_query/include/storage/shmem.h +81 -0
  303. data/ext/pg_query/include/storage/sinval.h +153 -0
  304. data/ext/pg_query/include/storage/sinvaladt.h +43 -0
  305. data/ext/pg_query/include/storage/smgr.h +109 -0
  306. data/ext/pg_query/include/storage/spin.h +77 -0
  307. data/ext/pg_query/include/storage/standby.h +91 -0
  308. data/ext/pg_query/include/storage/standbydefs.h +74 -0
  309. data/ext/pg_query/include/storage/sync.h +62 -0
  310. data/ext/pg_query/include/tcop/cmdtag.h +58 -0
  311. data/ext/pg_query/include/tcop/cmdtaglist.h +217 -0
  312. data/ext/pg_query/include/tcop/deparse_utility.h +108 -0
  313. data/ext/pg_query/include/tcop/dest.h +149 -0
  314. data/ext/pg_query/include/tcop/fastpath.h +21 -0
  315. data/ext/pg_query/include/tcop/pquery.h +45 -0
  316. data/ext/pg_query/include/tcop/tcopprot.h +89 -0
  317. data/ext/pg_query/include/tcop/utility.h +108 -0
  318. data/ext/pg_query/include/tsearch/ts_cache.h +98 -0
  319. data/ext/pg_query/include/utils/acl.h +312 -0
  320. data/ext/pg_query/include/utils/aclchk_internal.h +45 -0
  321. data/ext/pg_query/include/utils/array.h +458 -0
  322. data/ext/pg_query/include/utils/builtins.h +127 -0
  323. data/ext/pg_query/include/utils/bytea.h +27 -0
  324. data/ext/pg_query/include/utils/catcache.h +231 -0
  325. data/ext/pg_query/include/utils/date.h +90 -0
  326. data/ext/pg_query/include/utils/datetime.h +343 -0
  327. data/ext/pg_query/include/utils/datum.h +68 -0
  328. data/ext/pg_query/include/utils/dsa.h +123 -0
  329. data/ext/pg_query/include/utils/dynahash.h +19 -0
  330. data/ext/pg_query/include/utils/elog.h +439 -0
  331. data/ext/pg_query/include/utils/errcodes.h +352 -0
  332. data/ext/pg_query/include/utils/expandeddatum.h +159 -0
  333. data/ext/pg_query/include/utils/expandedrecord.h +231 -0
  334. data/ext/pg_query/include/utils/float.h +356 -0
  335. data/ext/pg_query/include/utils/fmgroids.h +2657 -0
  336. data/ext/pg_query/include/utils/fmgrprotos.h +2646 -0
  337. data/ext/pg_query/include/utils/fmgrtab.h +48 -0
  338. data/ext/pg_query/include/utils/guc.h +443 -0
  339. data/ext/pg_query/include/utils/guc_tables.h +272 -0
  340. data/ext/pg_query/include/utils/hsearch.h +149 -0
  341. data/ext/pg_query/include/utils/inval.h +64 -0
  342. data/ext/pg_query/include/utils/lsyscache.h +197 -0
  343. data/ext/pg_query/include/utils/memdebug.h +82 -0
  344. data/ext/pg_query/include/utils/memutils.h +225 -0
  345. data/ext/pg_query/include/utils/numeric.h +76 -0
  346. data/ext/pg_query/include/utils/palloc.h +136 -0
  347. data/ext/pg_query/include/utils/partcache.h +102 -0
  348. data/ext/pg_query/include/utils/pg_locale.h +119 -0
  349. data/ext/pg_query/include/utils/pg_lsn.h +29 -0
  350. data/ext/pg_query/include/utils/pidfile.h +56 -0
  351. data/ext/pg_query/include/utils/plancache.h +235 -0
  352. data/ext/pg_query/include/utils/portal.h +241 -0
  353. data/ext/pg_query/include/utils/probes.h +114 -0
  354. data/ext/pg_query/include/utils/ps_status.h +25 -0
  355. data/ext/pg_query/include/utils/queryenvironment.h +74 -0
  356. data/ext/pg_query/include/utils/regproc.h +28 -0
  357. data/ext/pg_query/include/utils/rel.h +644 -0
  358. data/ext/pg_query/include/utils/relcache.h +151 -0
  359. data/ext/pg_query/include/utils/reltrigger.h +81 -0
  360. data/ext/pg_query/include/utils/resowner.h +86 -0
  361. data/ext/pg_query/include/utils/rls.h +50 -0
  362. data/ext/pg_query/include/utils/ruleutils.h +44 -0
  363. data/ext/pg_query/include/utils/sharedtuplestore.h +61 -0
  364. data/ext/pg_query/include/utils/snapmgr.h +158 -0
  365. data/ext/pg_query/include/utils/snapshot.h +206 -0
  366. data/ext/pg_query/include/utils/sortsupport.h +276 -0
  367. data/ext/pg_query/include/utils/syscache.h +219 -0
  368. data/ext/pg_query/include/utils/timeout.h +88 -0
  369. data/ext/pg_query/include/utils/timestamp.h +116 -0
  370. data/ext/pg_query/include/utils/tuplesort.h +277 -0
  371. data/ext/pg_query/include/utils/tuplestore.h +91 -0
  372. data/ext/pg_query/include/utils/typcache.h +202 -0
  373. data/ext/pg_query/include/utils/tzparser.h +39 -0
  374. data/ext/pg_query/include/utils/varlena.h +39 -0
  375. data/ext/pg_query/include/utils/xml.h +84 -0
  376. data/ext/pg_query/include/xxhash.h +5445 -0
  377. data/ext/pg_query/include/xxhash/xxhash.h +5445 -0
  378. data/ext/pg_query/pg_query.c +104 -0
  379. data/ext/pg_query/pg_query.pb-c.c +37628 -0
  380. data/ext/pg_query/pg_query_deparse.c +9953 -0
  381. data/ext/pg_query/pg_query_fingerprint.c +292 -0
  382. data/ext/pg_query/pg_query_fingerprint.h +8 -0
  383. data/ext/pg_query/pg_query_internal.h +24 -0
  384. data/ext/pg_query/pg_query_json_plpgsql.c +738 -0
  385. data/ext/pg_query/pg_query_json_plpgsql.h +9 -0
  386. data/ext/pg_query/pg_query_normalize.c +437 -0
  387. data/ext/pg_query/pg_query_outfuncs.h +10 -0
  388. data/ext/pg_query/pg_query_outfuncs_json.c +297 -0
  389. data/ext/pg_query/pg_query_outfuncs_protobuf.c +237 -0
  390. data/ext/pg_query/pg_query_parse.c +148 -0
  391. data/ext/pg_query/pg_query_parse_plpgsql.c +460 -0
  392. data/ext/pg_query/pg_query_readfuncs.h +11 -0
  393. data/ext/pg_query/pg_query_readfuncs_protobuf.c +142 -0
  394. data/ext/pg_query/pg_query_ruby.c +108 -12
  395. data/ext/pg_query/pg_query_scan.c +173 -0
  396. data/ext/pg_query/pg_query_split.c +221 -0
  397. data/ext/pg_query/protobuf-c.c +3660 -0
  398. data/ext/pg_query/src_backend_catalog_namespace.c +1051 -0
  399. data/ext/pg_query/src_backend_catalog_pg_proc.c +142 -0
  400. data/ext/pg_query/src_backend_commands_define.c +117 -0
  401. data/ext/pg_query/src_backend_libpq_pqcomm.c +651 -0
  402. data/ext/pg_query/src_backend_nodes_bitmapset.c +513 -0
  403. data/ext/pg_query/src_backend_nodes_copyfuncs.c +6013 -0
  404. data/ext/pg_query/src_backend_nodes_equalfuncs.c +4003 -0
  405. data/ext/pg_query/src_backend_nodes_extensible.c +99 -0
  406. data/ext/pg_query/src_backend_nodes_list.c +922 -0
  407. data/ext/pg_query/src_backend_nodes_makefuncs.c +417 -0
  408. data/ext/pg_query/src_backend_nodes_nodeFuncs.c +1363 -0
  409. data/ext/pg_query/src_backend_nodes_value.c +84 -0
  410. data/ext/pg_query/src_backend_parser_gram.c +47456 -0
  411. data/ext/pg_query/src_backend_parser_parse_expr.c +313 -0
  412. data/ext/pg_query/src_backend_parser_parser.c +497 -0
  413. data/ext/pg_query/src_backend_parser_scan.c +7091 -0
  414. data/ext/pg_query/src_backend_parser_scansup.c +160 -0
  415. data/ext/pg_query/src_backend_postmaster_postmaster.c +2230 -0
  416. data/ext/pg_query/src_backend_storage_ipc_ipc.c +192 -0
  417. data/ext/pg_query/src_backend_storage_lmgr_s_lock.c +370 -0
  418. data/ext/pg_query/src_backend_tcop_postgres.c +776 -0
  419. data/ext/pg_query/src_backend_utils_adt_datum.c +326 -0
  420. data/ext/pg_query/src_backend_utils_adt_expandeddatum.c +98 -0
  421. data/ext/pg_query/src_backend_utils_adt_format_type.c +136 -0
  422. data/ext/pg_query/src_backend_utils_adt_ruleutils.c +1683 -0
  423. data/ext/pg_query/src_backend_utils_error_assert.c +74 -0
  424. data/ext/pg_query/src_backend_utils_error_elog.c +1748 -0
  425. data/ext/pg_query/src_backend_utils_fmgr_fmgr.c +570 -0
  426. data/ext/pg_query/src_backend_utils_hash_dynahash.c +1086 -0
  427. data/ext/pg_query/src_backend_utils_init_globals.c +168 -0
  428. data/ext/pg_query/src_backend_utils_mb_mbutils.c +839 -0
  429. data/ext/pg_query/src_backend_utils_misc_guc.c +1831 -0
  430. data/ext/pg_query/src_backend_utils_mmgr_aset.c +1560 -0
  431. data/ext/pg_query/src_backend_utils_mmgr_mcxt.c +1006 -0
  432. data/ext/pg_query/src_common_encnames.c +158 -0
  433. data/ext/pg_query/src_common_keywords.c +39 -0
  434. data/ext/pg_query/src_common_kwlist_d.h +1081 -0
  435. data/ext/pg_query/src_common_kwlookup.c +91 -0
  436. data/ext/pg_query/src_common_psprintf.c +158 -0
  437. data/ext/pg_query/src_common_string.c +86 -0
  438. data/ext/pg_query/src_common_stringinfo.c +336 -0
  439. data/ext/pg_query/src_common_wchar.c +1651 -0
  440. data/ext/pg_query/src_pl_plpgsql_src_pl_comp.c +1133 -0
  441. data/ext/pg_query/src_pl_plpgsql_src_pl_funcs.c +877 -0
  442. data/ext/pg_query/src_pl_plpgsql_src_pl_gram.c +6533 -0
  443. data/ext/pg_query/src_pl_plpgsql_src_pl_handler.c +107 -0
  444. data/ext/pg_query/src_pl_plpgsql_src_pl_reserved_kwlist_d.h +123 -0
  445. data/ext/pg_query/src_pl_plpgsql_src_pl_scanner.c +671 -0
  446. data/ext/pg_query/src_pl_plpgsql_src_pl_unreserved_kwlist_d.h +255 -0
  447. data/ext/pg_query/src_port_erand48.c +127 -0
  448. data/ext/pg_query/src_port_pg_bitutils.c +246 -0
  449. data/ext/pg_query/src_port_pgsleep.c +69 -0
  450. data/ext/pg_query/src_port_pgstrcasecmp.c +83 -0
  451. data/ext/pg_query/src_port_qsort.c +240 -0
  452. data/ext/pg_query/src_port_random.c +31 -0
  453. data/ext/pg_query/src_port_snprintf.c +1449 -0
  454. data/ext/pg_query/src_port_strerror.c +324 -0
  455. data/ext/pg_query/src_port_strnlen.c +39 -0
  456. data/ext/pg_query/xxhash.c +43 -0
  457. data/lib/pg_query.rb +7 -4
  458. data/lib/pg_query/constants.rb +21 -0
  459. data/lib/pg_query/deparse.rb +16 -1117
  460. data/lib/pg_query/filter_columns.rb +86 -85
  461. data/lib/pg_query/fingerprint.rb +122 -87
  462. data/lib/pg_query/json_field_names.rb +1402 -0
  463. data/lib/pg_query/node.rb +31 -0
  464. data/lib/pg_query/param_refs.rb +42 -37
  465. data/lib/pg_query/parse.rb +220 -200
  466. data/lib/pg_query/parse_error.rb +1 -1
  467. data/lib/pg_query/pg_query_pb.rb +3211 -0
  468. data/lib/pg_query/scan.rb +23 -0
  469. data/lib/pg_query/treewalker.rb +24 -40
  470. data/lib/pg_query/truncate.rb +64 -43
  471. data/lib/pg_query/version.rb +2 -2
  472. metadata +473 -11
  473. data/ext/pg_query/pg_query_ruby.h +0 -10
  474. data/lib/pg_query/deep_dup.rb +0 -16
  475. data/lib/pg_query/deparse/alter_table.rb +0 -42
  476. data/lib/pg_query/deparse/interval.rb +0 -105
  477. data/lib/pg_query/legacy_parsetree.rb +0 -109
  478. data/lib/pg_query/node_types.rb +0 -284
@@ -0,0 +1,114 @@
1
+ #define TRACE_POSTGRESQL_TRANSACTION_START(INT1)
2
+ #define TRACE_POSTGRESQL_TRANSACTION_START_ENABLED() (0)
3
+ #define TRACE_POSTGRESQL_TRANSACTION_COMMIT(INT1)
4
+ #define TRACE_POSTGRESQL_TRANSACTION_COMMIT_ENABLED() (0)
5
+ #define TRACE_POSTGRESQL_TRANSACTION_ABORT(INT1)
6
+ #define TRACE_POSTGRESQL_TRANSACTION_ABORT_ENABLED() (0)
7
+ #define TRACE_POSTGRESQL_LWLOCK_ACQUIRE(INT1, INT2)
8
+ #define TRACE_POSTGRESQL_LWLOCK_ACQUIRE_ENABLED() (0)
9
+ #define TRACE_POSTGRESQL_LWLOCK_RELEASE(INT1)
10
+ #define TRACE_POSTGRESQL_LWLOCK_RELEASE_ENABLED() (0)
11
+ #define TRACE_POSTGRESQL_LWLOCK_WAIT_START(INT1, INT2)
12
+ #define TRACE_POSTGRESQL_LWLOCK_WAIT_START_ENABLED() (0)
13
+ #define TRACE_POSTGRESQL_LWLOCK_WAIT_DONE(INT1, INT2)
14
+ #define TRACE_POSTGRESQL_LWLOCK_WAIT_DONE_ENABLED() (0)
15
+ #define TRACE_POSTGRESQL_LWLOCK_CONDACQUIRE(INT1, INT2)
16
+ #define TRACE_POSTGRESQL_LWLOCK_CONDACQUIRE_ENABLED() (0)
17
+ #define TRACE_POSTGRESQL_LWLOCK_CONDACQUIRE_FAIL(INT1, INT2)
18
+ #define TRACE_POSTGRESQL_LWLOCK_CONDACQUIRE_FAIL_ENABLED() (0)
19
+ #define TRACE_POSTGRESQL_LWLOCK_ACQUIRE_OR_WAIT(INT1, INT2)
20
+ #define TRACE_POSTGRESQL_LWLOCK_ACQUIRE_OR_WAIT_ENABLED() (0)
21
+ #define TRACE_POSTGRESQL_LWLOCK_ACQUIRE_OR_WAIT_FAIL(INT1, INT2)
22
+ #define TRACE_POSTGRESQL_LWLOCK_ACQUIRE_OR_WAIT_FAIL_ENABLED() (0)
23
+ #define TRACE_POSTGRESQL_LOCK_WAIT_START(INT1, INT2, INT3, INT4, INT5, INT6)
24
+ #define TRACE_POSTGRESQL_LOCK_WAIT_START_ENABLED() (0)
25
+ #define TRACE_POSTGRESQL_LOCK_WAIT_DONE(INT1, INT2, INT3, INT4, INT5, INT6)
26
+ #define TRACE_POSTGRESQL_LOCK_WAIT_DONE_ENABLED() (0)
27
+ #define TRACE_POSTGRESQL_QUERY_PARSE_START(INT1)
28
+ #define TRACE_POSTGRESQL_QUERY_PARSE_START_ENABLED() (0)
29
+ #define TRACE_POSTGRESQL_QUERY_PARSE_DONE(INT1)
30
+ #define TRACE_POSTGRESQL_QUERY_PARSE_DONE_ENABLED() (0)
31
+ #define TRACE_POSTGRESQL_QUERY_REWRITE_START(INT1)
32
+ #define TRACE_POSTGRESQL_QUERY_REWRITE_START_ENABLED() (0)
33
+ #define TRACE_POSTGRESQL_QUERY_REWRITE_DONE(INT1)
34
+ #define TRACE_POSTGRESQL_QUERY_REWRITE_DONE_ENABLED() (0)
35
+ #define TRACE_POSTGRESQL_QUERY_PLAN_START()
36
+ #define TRACE_POSTGRESQL_QUERY_PLAN_START_ENABLED() (0)
37
+ #define TRACE_POSTGRESQL_QUERY_PLAN_DONE()
38
+ #define TRACE_POSTGRESQL_QUERY_PLAN_DONE_ENABLED() (0)
39
+ #define TRACE_POSTGRESQL_QUERY_EXECUTE_START()
40
+ #define TRACE_POSTGRESQL_QUERY_EXECUTE_START_ENABLED() (0)
41
+ #define TRACE_POSTGRESQL_QUERY_EXECUTE_DONE()
42
+ #define TRACE_POSTGRESQL_QUERY_EXECUTE_DONE_ENABLED() (0)
43
+ #define TRACE_POSTGRESQL_QUERY_START(INT1)
44
+ #define TRACE_POSTGRESQL_QUERY_START_ENABLED() (0)
45
+ #define TRACE_POSTGRESQL_QUERY_DONE(INT1)
46
+ #define TRACE_POSTGRESQL_QUERY_DONE_ENABLED() (0)
47
+ #define TRACE_POSTGRESQL_STATEMENT_STATUS(INT1)
48
+ #define TRACE_POSTGRESQL_STATEMENT_STATUS_ENABLED() (0)
49
+ #define TRACE_POSTGRESQL_SORT_START(INT1, INT2, INT3, INT4, INT5, INT6)
50
+ #define TRACE_POSTGRESQL_SORT_START_ENABLED() (0)
51
+ #define TRACE_POSTGRESQL_SORT_DONE(INT1, INT2)
52
+ #define TRACE_POSTGRESQL_SORT_DONE_ENABLED() (0)
53
+ #define TRACE_POSTGRESQL_BUFFER_READ_START(INT1, INT2, INT3, INT4, INT5, INT6, INT7)
54
+ #define TRACE_POSTGRESQL_BUFFER_READ_START_ENABLED() (0)
55
+ #define TRACE_POSTGRESQL_BUFFER_READ_DONE(INT1, INT2, INT3, INT4, INT5, INT6, INT7, INT8)
56
+ #define TRACE_POSTGRESQL_BUFFER_READ_DONE_ENABLED() (0)
57
+ #define TRACE_POSTGRESQL_BUFFER_FLUSH_START(INT1, INT2, INT3, INT4, INT5)
58
+ #define TRACE_POSTGRESQL_BUFFER_FLUSH_START_ENABLED() (0)
59
+ #define TRACE_POSTGRESQL_BUFFER_FLUSH_DONE(INT1, INT2, INT3, INT4, INT5)
60
+ #define TRACE_POSTGRESQL_BUFFER_FLUSH_DONE_ENABLED() (0)
61
+ #define TRACE_POSTGRESQL_BUFFER_CHECKPOINT_START(INT1)
62
+ #define TRACE_POSTGRESQL_BUFFER_CHECKPOINT_START_ENABLED() (0)
63
+ #define TRACE_POSTGRESQL_BUFFER_CHECKPOINT_SYNC_START()
64
+ #define TRACE_POSTGRESQL_BUFFER_CHECKPOINT_SYNC_START_ENABLED() (0)
65
+ #define TRACE_POSTGRESQL_BUFFER_CHECKPOINT_DONE()
66
+ #define TRACE_POSTGRESQL_BUFFER_CHECKPOINT_DONE_ENABLED() (0)
67
+ #define TRACE_POSTGRESQL_BUFFER_SYNC_START(INT1, INT2)
68
+ #define TRACE_POSTGRESQL_BUFFER_SYNC_START_ENABLED() (0)
69
+ #define TRACE_POSTGRESQL_BUFFER_SYNC_WRITTEN(INT1)
70
+ #define TRACE_POSTGRESQL_BUFFER_SYNC_WRITTEN_ENABLED() (0)
71
+ #define TRACE_POSTGRESQL_BUFFER_SYNC_DONE(INT1, INT2, INT3)
72
+ #define TRACE_POSTGRESQL_BUFFER_SYNC_DONE_ENABLED() (0)
73
+ #define TRACE_POSTGRESQL_BUFFER_WRITE_DIRTY_START(INT1, INT2, INT3, INT4, INT5)
74
+ #define TRACE_POSTGRESQL_BUFFER_WRITE_DIRTY_START_ENABLED() (0)
75
+ #define TRACE_POSTGRESQL_BUFFER_WRITE_DIRTY_DONE(INT1, INT2, INT3, INT4, INT5)
76
+ #define TRACE_POSTGRESQL_BUFFER_WRITE_DIRTY_DONE_ENABLED() (0)
77
+ #define TRACE_POSTGRESQL_DEADLOCK_FOUND()
78
+ #define TRACE_POSTGRESQL_DEADLOCK_FOUND_ENABLED() (0)
79
+ #define TRACE_POSTGRESQL_CHECKPOINT_START(INT1)
80
+ #define TRACE_POSTGRESQL_CHECKPOINT_START_ENABLED() (0)
81
+ #define TRACE_POSTGRESQL_CHECKPOINT_DONE(INT1, INT2, INT3, INT4, INT5)
82
+ #define TRACE_POSTGRESQL_CHECKPOINT_DONE_ENABLED() (0)
83
+ #define TRACE_POSTGRESQL_CLOG_CHECKPOINT_START(INT1)
84
+ #define TRACE_POSTGRESQL_CLOG_CHECKPOINT_START_ENABLED() (0)
85
+ #define TRACE_POSTGRESQL_CLOG_CHECKPOINT_DONE(INT1)
86
+ #define TRACE_POSTGRESQL_CLOG_CHECKPOINT_DONE_ENABLED() (0)
87
+ #define TRACE_POSTGRESQL_SUBTRANS_CHECKPOINT_START(INT1)
88
+ #define TRACE_POSTGRESQL_SUBTRANS_CHECKPOINT_START_ENABLED() (0)
89
+ #define TRACE_POSTGRESQL_SUBTRANS_CHECKPOINT_DONE(INT1)
90
+ #define TRACE_POSTGRESQL_SUBTRANS_CHECKPOINT_DONE_ENABLED() (0)
91
+ #define TRACE_POSTGRESQL_MULTIXACT_CHECKPOINT_START(INT1)
92
+ #define TRACE_POSTGRESQL_MULTIXACT_CHECKPOINT_START_ENABLED() (0)
93
+ #define TRACE_POSTGRESQL_MULTIXACT_CHECKPOINT_DONE(INT1)
94
+ #define TRACE_POSTGRESQL_MULTIXACT_CHECKPOINT_DONE_ENABLED() (0)
95
+ #define TRACE_POSTGRESQL_TWOPHASE_CHECKPOINT_START()
96
+ #define TRACE_POSTGRESQL_TWOPHASE_CHECKPOINT_START_ENABLED() (0)
97
+ #define TRACE_POSTGRESQL_TWOPHASE_CHECKPOINT_DONE()
98
+ #define TRACE_POSTGRESQL_TWOPHASE_CHECKPOINT_DONE_ENABLED() (0)
99
+ #define TRACE_POSTGRESQL_SMGR_MD_READ_START(INT1, INT2, INT3, INT4, INT5, INT6)
100
+ #define TRACE_POSTGRESQL_SMGR_MD_READ_START_ENABLED() (0)
101
+ #define TRACE_POSTGRESQL_SMGR_MD_READ_DONE(INT1, INT2, INT3, INT4, INT5, INT6, INT7, INT8)
102
+ #define TRACE_POSTGRESQL_SMGR_MD_READ_DONE_ENABLED() (0)
103
+ #define TRACE_POSTGRESQL_SMGR_MD_WRITE_START(INT1, INT2, INT3, INT4, INT5, INT6)
104
+ #define TRACE_POSTGRESQL_SMGR_MD_WRITE_START_ENABLED() (0)
105
+ #define TRACE_POSTGRESQL_SMGR_MD_WRITE_DONE(INT1, INT2, INT3, INT4, INT5, INT6, INT7, INT8)
106
+ #define TRACE_POSTGRESQL_SMGR_MD_WRITE_DONE_ENABLED() (0)
107
+ #define TRACE_POSTGRESQL_WAL_INSERT(INT1, INT2)
108
+ #define TRACE_POSTGRESQL_WAL_INSERT_ENABLED() (0)
109
+ #define TRACE_POSTGRESQL_WAL_SWITCH()
110
+ #define TRACE_POSTGRESQL_WAL_SWITCH_ENABLED() (0)
111
+ #define TRACE_POSTGRESQL_WAL_BUFFER_WRITE_DIRTY_START()
112
+ #define TRACE_POSTGRESQL_WAL_BUFFER_WRITE_DIRTY_START_ENABLED() (0)
113
+ #define TRACE_POSTGRESQL_WAL_BUFFER_WRITE_DIRTY_DONE()
114
+ #define TRACE_POSTGRESQL_WAL_BUFFER_WRITE_DIRTY_DONE_ENABLED() (0)
@@ -0,0 +1,25 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * ps_status.h
4
+ *
5
+ * Declarations for backend/utils/misc/ps_status.c
6
+ *
7
+ * src/include/utils/ps_status.h
8
+ *
9
+ *-------------------------------------------------------------------------
10
+ */
11
+
12
+ #ifndef PS_STATUS_H
13
+ #define PS_STATUS_H
14
+
15
+ extern bool update_process_title;
16
+
17
+ extern char **save_ps_display_args(int argc, char **argv);
18
+
19
+ extern void init_ps_display(const char *fixed_part);
20
+
21
+ extern void set_ps_display(const char *activity);
22
+
23
+ extern const char *get_ps_display(int *displen);
24
+
25
+ #endif /* PS_STATUS_H */
@@ -0,0 +1,74 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * queryenvironment.h
4
+ * Access to functions to mutate the query environment and retrieve the
5
+ * actual data related to entries (if any).
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/utils/queryenvironment.h
11
+ *
12
+ *-------------------------------------------------------------------------
13
+ */
14
+ #ifndef QUERYENVIRONMENT_H
15
+ #define QUERYENVIRONMENT_H
16
+
17
+ #include "access/tupdesc.h"
18
+
19
+
20
+ typedef enum EphemeralNameRelationType
21
+ {
22
+ ENR_NAMED_TUPLESTORE /* named tuplestore relation; e.g., deltas */
23
+ } EphemeralNameRelationType;
24
+
25
+ /*
26
+ * Some ephemeral named relations must match some relation (e.g., trigger
27
+ * transition tables), so to properly handle cached plans and DDL, we should
28
+ * carry the OID of that relation. In other cases an ENR might be independent
29
+ * of any relation which is stored in the system catalogs, so we need to be
30
+ * able to directly store the TupleDesc. We never need both.
31
+ */
32
+ typedef struct EphemeralNamedRelationMetadataData
33
+ {
34
+ char *name; /* name used to identify the relation */
35
+
36
+ /* only one of the next two fields should be used */
37
+ Oid reliddesc; /* oid of relation to get tupdesc */
38
+ TupleDesc tupdesc; /* description of result rows */
39
+
40
+ EphemeralNameRelationType enrtype; /* to identify type of relation */
41
+ double enrtuples; /* estimated number of tuples */
42
+ } EphemeralNamedRelationMetadataData;
43
+
44
+ typedef EphemeralNamedRelationMetadataData *EphemeralNamedRelationMetadata;
45
+
46
+ /*
47
+ * Ephemeral Named Relation data; used for parsing named relations not in the
48
+ * catalog, like transition tables in AFTER triggers.
49
+ */
50
+ typedef struct EphemeralNamedRelationData
51
+ {
52
+ EphemeralNamedRelationMetadataData md;
53
+ void *reldata; /* structure for execution-time access to data */
54
+ } EphemeralNamedRelationData;
55
+
56
+ typedef EphemeralNamedRelationData *EphemeralNamedRelation;
57
+
58
+ /*
59
+ * This is an opaque structure outside of queryenvironment.c itself. The
60
+ * intention is to be able to change the implementation or add new context
61
+ * features without needing to change existing code for use of existing
62
+ * features.
63
+ */
64
+ typedef struct QueryEnvironment QueryEnvironment;
65
+
66
+
67
+ extern QueryEnvironment *create_queryEnv(void);
68
+ extern EphemeralNamedRelationMetadata get_visible_ENR_metadata(QueryEnvironment *queryEnv, const char *refname);
69
+ extern void register_ENR(QueryEnvironment *queryEnv, EphemeralNamedRelation enr);
70
+ extern void unregister_ENR(QueryEnvironment *queryEnv, const char *name);
71
+ extern EphemeralNamedRelation get_ENR(QueryEnvironment *queryEnv, const char *name);
72
+ extern TupleDesc ENRMetadataGetTupDesc(EphemeralNamedRelationMetadata enrmd);
73
+
74
+ #endif /* QUERYENVIRONMENT_H */
@@ -0,0 +1,28 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * regproc.h
4
+ * Functions for the built-in types regproc, regclass, regtype, etc.
5
+ *
6
+ * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
7
+ * Portions Copyright (c) 1994, Regents of the University of California
8
+ *
9
+ * src/include/utils/regproc.h
10
+ *
11
+ *-------------------------------------------------------------------------
12
+ */
13
+ #ifndef REGPROC_H
14
+ #define REGPROC_H
15
+
16
+ #include "nodes/pg_list.h"
17
+
18
+ extern List *stringToQualifiedNameList(const char *string);
19
+ extern char *format_procedure(Oid procedure_oid);
20
+ extern char *format_procedure_qualified(Oid procedure_oid);
21
+ extern void format_procedure_parts(Oid operator_oid, List **objnames,
22
+ List **objargs);
23
+ extern char *format_operator(Oid operator_oid);
24
+ extern char *format_operator_qualified(Oid operator_oid);
25
+ extern void format_operator_parts(Oid operator_oid, List **objnames,
26
+ List **objargs);
27
+
28
+ #endif
@@ -0,0 +1,644 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * rel.h
4
+ * POSTGRES relation descriptor (a/k/a relcache entry) 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/utils/rel.h
11
+ *
12
+ *-------------------------------------------------------------------------
13
+ */
14
+ #ifndef REL_H
15
+ #define REL_H
16
+
17
+ #include "access/tupdesc.h"
18
+ #include "access/xlog.h"
19
+ #include "catalog/pg_class.h"
20
+ #include "catalog/pg_index.h"
21
+ #include "catalog/pg_publication.h"
22
+ #include "nodes/bitmapset.h"
23
+ #include "partitioning/partdefs.h"
24
+ #include "rewrite/prs2lock.h"
25
+ #include "storage/block.h"
26
+ #include "storage/relfilenode.h"
27
+ #include "utils/relcache.h"
28
+ #include "utils/reltrigger.h"
29
+
30
+
31
+ /*
32
+ * LockRelId and LockInfo really belong to lmgr.h, but it's more convenient
33
+ * to declare them here so we can have a LockInfoData field in a Relation.
34
+ */
35
+
36
+ typedef struct LockRelId
37
+ {
38
+ Oid relId; /* a relation identifier */
39
+ Oid dbId; /* a database identifier */
40
+ } LockRelId;
41
+
42
+ typedef struct LockInfoData
43
+ {
44
+ LockRelId lockRelId;
45
+ } LockInfoData;
46
+
47
+ typedef LockInfoData *LockInfo;
48
+
49
+ /*
50
+ * Here are the contents of a relation cache entry.
51
+ */
52
+
53
+ typedef struct RelationData
54
+ {
55
+ RelFileNode rd_node; /* relation physical identifier */
56
+ /* use "struct" here to avoid needing to include smgr.h: */
57
+ struct SMgrRelationData *rd_smgr; /* cached file handle, or NULL */
58
+ int rd_refcnt; /* reference count */
59
+ BackendId rd_backend; /* owning backend id, if temporary relation */
60
+ bool rd_islocaltemp; /* rel is a temp rel of this session */
61
+ bool rd_isnailed; /* rel is nailed in cache */
62
+ bool rd_isvalid; /* relcache entry is valid */
63
+ bool rd_indexvalid; /* is rd_indexlist valid? (also rd_pkindex and
64
+ * rd_replidindex) */
65
+ bool rd_statvalid; /* is rd_statlist valid? */
66
+
67
+ /*----------
68
+ * rd_createSubid is the ID of the highest subtransaction the rel has
69
+ * survived into or zero if the rel or its rd_node was created before the
70
+ * current top transaction. (IndexStmt.oldNode leads to the case of a new
71
+ * rel with an old rd_node.) rd_firstRelfilenodeSubid is the ID of the
72
+ * highest subtransaction an rd_node change has survived into or zero if
73
+ * rd_node matches the value it had at the start of the current top
74
+ * transaction. (Rolling back the subtransaction that
75
+ * rd_firstRelfilenodeSubid denotes would restore rd_node to the value it
76
+ * had at the start of the current top transaction. Rolling back any
77
+ * lower subtransaction would not.) Their accuracy is critical to
78
+ * RelationNeedsWAL().
79
+ *
80
+ * rd_newRelfilenodeSubid is the ID of the highest subtransaction the
81
+ * most-recent relfilenode change has survived into or zero if not changed
82
+ * in the current transaction (or we have forgotten changing it). This
83
+ * field is accurate when non-zero, but it can be zero when a relation has
84
+ * multiple new relfilenodes within a single transaction, with one of them
85
+ * occurring in a subsequently aborted subtransaction, e.g.
86
+ * BEGIN;
87
+ * TRUNCATE t;
88
+ * SAVEPOINT save;
89
+ * TRUNCATE t;
90
+ * ROLLBACK TO save;
91
+ * -- rd_newRelfilenodeSubid is now forgotten
92
+ *
93
+ * If every rd_*Subid field is zero, they are read-only outside
94
+ * relcache.c. Files that trigger rd_node changes by updating
95
+ * pg_class.reltablespace and/or pg_class.relfilenode call
96
+ * RelationAssumeNewRelfilenode() to update rd_*Subid.
97
+ *
98
+ * rd_droppedSubid is the ID of the highest subtransaction that a drop of
99
+ * the rel has survived into. In entries visible outside relcache.c, this
100
+ * is always zero.
101
+ */
102
+ SubTransactionId rd_createSubid; /* rel was created in current xact */
103
+ SubTransactionId rd_newRelfilenodeSubid; /* highest subxact changing
104
+ * rd_node to current value */
105
+ SubTransactionId rd_firstRelfilenodeSubid; /* highest subxact changing
106
+ * rd_node to any value */
107
+ SubTransactionId rd_droppedSubid; /* dropped with another Subid set */
108
+
109
+ Form_pg_class rd_rel; /* RELATION tuple */
110
+ TupleDesc rd_att; /* tuple descriptor */
111
+ Oid rd_id; /* relation's object id */
112
+ LockInfoData rd_lockInfo; /* lock mgr's info for locking relation */
113
+ RuleLock *rd_rules; /* rewrite rules */
114
+ MemoryContext rd_rulescxt; /* private memory cxt for rd_rules, if any */
115
+ TriggerDesc *trigdesc; /* Trigger info, or NULL if rel has none */
116
+ /* use "struct" here to avoid needing to include rowsecurity.h: */
117
+ struct RowSecurityDesc *rd_rsdesc; /* row security policies, or NULL */
118
+
119
+ /* data managed by RelationGetFKeyList: */
120
+ List *rd_fkeylist; /* list of ForeignKeyCacheInfo (see below) */
121
+ bool rd_fkeyvalid; /* true if list has been computed */
122
+
123
+ /* data managed by RelationGetPartitionKey: */
124
+ PartitionKey rd_partkey; /* partition key, or NULL */
125
+ MemoryContext rd_partkeycxt; /* private context for rd_partkey, if any */
126
+
127
+ /* data managed by RelationGetPartitionDesc: */
128
+ PartitionDesc rd_partdesc; /* partition descriptor, or NULL */
129
+ MemoryContext rd_pdcxt; /* private context for rd_partdesc, if any */
130
+
131
+ /* data managed by RelationGetPartitionQual: */
132
+ List *rd_partcheck; /* partition CHECK quals */
133
+ bool rd_partcheckvalid; /* true if list has been computed */
134
+ MemoryContext rd_partcheckcxt; /* private cxt for rd_partcheck, if any */
135
+
136
+ /* data managed by RelationGetIndexList: */
137
+ List *rd_indexlist; /* list of OIDs of indexes on relation */
138
+ Oid rd_pkindex; /* OID of primary key, if any */
139
+ Oid rd_replidindex; /* OID of replica identity index, if any */
140
+
141
+ /* data managed by RelationGetStatExtList: */
142
+ List *rd_statlist; /* list of OIDs of extended stats */
143
+
144
+ /* data managed by RelationGetIndexAttrBitmap: */
145
+ Bitmapset *rd_indexattr; /* identifies columns used in indexes */
146
+ Bitmapset *rd_keyattr; /* cols that can be ref'd by foreign keys */
147
+ Bitmapset *rd_pkattr; /* cols included in primary key */
148
+ Bitmapset *rd_idattr; /* included in replica identity index */
149
+
150
+ PublicationActions *rd_pubactions; /* publication actions */
151
+
152
+ /*
153
+ * rd_options is set whenever rd_rel is loaded into the relcache entry.
154
+ * Note that you can NOT look into rd_rel for this data. NULL means "use
155
+ * defaults".
156
+ */
157
+ bytea *rd_options; /* parsed pg_class.reloptions */
158
+
159
+ /*
160
+ * Oid of the handler for this relation. For an index this is a function
161
+ * returning IndexAmRoutine, for table like relations a function returning
162
+ * TableAmRoutine. This is stored separately from rd_indam, rd_tableam as
163
+ * its lookup requires syscache access, but during relcache bootstrap we
164
+ * need to be able to initialize rd_tableam without syscache lookups.
165
+ */
166
+ Oid rd_amhandler; /* OID of index AM's handler function */
167
+
168
+ /*
169
+ * Table access method.
170
+ */
171
+ const struct TableAmRoutine *rd_tableam;
172
+
173
+ /* These are non-NULL only for an index relation: */
174
+ Form_pg_index rd_index; /* pg_index tuple describing this index */
175
+ /* use "struct" here to avoid needing to include htup.h: */
176
+ struct HeapTupleData *rd_indextuple; /* all of pg_index tuple */
177
+
178
+ /*
179
+ * index access support info (used only for an index relation)
180
+ *
181
+ * Note: only default support procs for each opclass are cached, namely
182
+ * those with lefttype and righttype equal to the opclass's opcintype. The
183
+ * arrays are indexed by support function number, which is a sufficient
184
+ * identifier given that restriction.
185
+ */
186
+ MemoryContext rd_indexcxt; /* private memory cxt for this stuff */
187
+ /* use "struct" here to avoid needing to include amapi.h: */
188
+ struct IndexAmRoutine *rd_indam; /* index AM's API struct */
189
+ Oid *rd_opfamily; /* OIDs of op families for each index col */
190
+ Oid *rd_opcintype; /* OIDs of opclass declared input data types */
191
+ RegProcedure *rd_support; /* OIDs of support procedures */
192
+ struct FmgrInfo *rd_supportinfo; /* lookup info for support procedures */
193
+ int16 *rd_indoption; /* per-column AM-specific flags */
194
+ List *rd_indexprs; /* index expression trees, if any */
195
+ List *rd_indpred; /* index predicate tree, if any */
196
+ Oid *rd_exclops; /* OIDs of exclusion operators, if any */
197
+ Oid *rd_exclprocs; /* OIDs of exclusion ops' procs, if any */
198
+ uint16 *rd_exclstrats; /* exclusion ops' strategy numbers, if any */
199
+ Oid *rd_indcollation; /* OIDs of index collations */
200
+ bytea **rd_opcoptions; /* parsed opclass-specific options */
201
+
202
+ /*
203
+ * rd_amcache is available for index and table AMs to cache private data
204
+ * about the relation. This must be just a cache since it may get reset
205
+ * at any time (in particular, it will get reset by a relcache inval
206
+ * message for the relation). If used, it must point to a single memory
207
+ * chunk palloc'd in CacheMemoryContext, or in rd_indexcxt for an index
208
+ * relation. A relcache reset will include freeing that chunk and setting
209
+ * rd_amcache = NULL.
210
+ */
211
+ void *rd_amcache; /* available for use by index/table AM */
212
+
213
+ /*
214
+ * foreign-table support
215
+ *
216
+ * rd_fdwroutine must point to a single memory chunk palloc'd in
217
+ * CacheMemoryContext. It will be freed and reset to NULL on a relcache
218
+ * reset.
219
+ */
220
+
221
+ /* use "struct" here to avoid needing to include fdwapi.h: */
222
+ struct FdwRoutine *rd_fdwroutine; /* cached function pointers, or NULL */
223
+
224
+ /*
225
+ * Hack for CLUSTER, rewriting ALTER TABLE, etc: when writing a new
226
+ * version of a table, we need to make any toast pointers inserted into it
227
+ * have the existing toast table's OID, not the OID of the transient toast
228
+ * table. If rd_toastoid isn't InvalidOid, it is the OID to place in
229
+ * toast pointers inserted into this rel. (Note it's set on the new
230
+ * version of the main heap, not the toast table itself.) This also
231
+ * causes toast_save_datum() to try to preserve toast value OIDs.
232
+ */
233
+ Oid rd_toastoid; /* Real TOAST table's OID, or InvalidOid */
234
+
235
+ /* use "struct" here to avoid needing to include pgstat.h: */
236
+ struct PgStat_TableStatus *pgstat_info; /* statistics collection area */
237
+ } RelationData;
238
+
239
+
240
+ /*
241
+ * ForeignKeyCacheInfo
242
+ * Information the relcache can cache about foreign key constraints
243
+ *
244
+ * This is basically just an image of relevant columns from pg_constraint.
245
+ * We make it a subclass of Node so that copyObject() can be used on a list
246
+ * of these, but we also ensure it is a "flat" object without substructure,
247
+ * so that list_free_deep() is sufficient to free such a list.
248
+ * The per-FK-column arrays can be fixed-size because we allow at most
249
+ * INDEX_MAX_KEYS columns in a foreign key constraint.
250
+ *
251
+ * Currently, we mostly cache fields of interest to the planner, but the set
252
+ * of fields has already grown the constraint OID for other uses.
253
+ */
254
+ typedef struct ForeignKeyCacheInfo
255
+ {
256
+ NodeTag type;
257
+ Oid conoid; /* oid of the constraint itself */
258
+ Oid conrelid; /* relation constrained by the foreign key */
259
+ Oid confrelid; /* relation referenced by the foreign key */
260
+ int nkeys; /* number of columns in the foreign key */
261
+ /* these arrays each have nkeys valid entries: */
262
+ AttrNumber conkey[INDEX_MAX_KEYS]; /* cols in referencing table */
263
+ AttrNumber confkey[INDEX_MAX_KEYS]; /* cols in referenced table */
264
+ Oid conpfeqop[INDEX_MAX_KEYS]; /* PK = FK operator OIDs */
265
+ } ForeignKeyCacheInfo;
266
+
267
+
268
+ /*
269
+ * StdRdOptions
270
+ * Standard contents of rd_options for heaps.
271
+ *
272
+ * RelationGetFillFactor() and RelationGetTargetPageFreeSpace() can only
273
+ * be applied to relations that use this format or a superset for
274
+ * private options data.
275
+ */
276
+ /* autovacuum-related reloptions. */
277
+ typedef struct AutoVacOpts
278
+ {
279
+ bool enabled;
280
+ int vacuum_threshold;
281
+ int vacuum_ins_threshold;
282
+ int analyze_threshold;
283
+ int vacuum_cost_limit;
284
+ int freeze_min_age;
285
+ int freeze_max_age;
286
+ int freeze_table_age;
287
+ int multixact_freeze_min_age;
288
+ int multixact_freeze_max_age;
289
+ int multixact_freeze_table_age;
290
+ int log_min_duration;
291
+ float8 vacuum_cost_delay;
292
+ float8 vacuum_scale_factor;
293
+ float8 vacuum_ins_scale_factor;
294
+ float8 analyze_scale_factor;
295
+ } AutoVacOpts;
296
+
297
+ typedef struct StdRdOptions
298
+ {
299
+ int32 vl_len_; /* varlena header (do not touch directly!) */
300
+ int fillfactor; /* page fill factor in percent (0..100) */
301
+ /* fraction of newly inserted tuples prior to trigger index cleanup */
302
+ int toast_tuple_target; /* target for tuple toasting */
303
+ AutoVacOpts autovacuum; /* autovacuum-related options */
304
+ bool user_catalog_table; /* use as an additional catalog relation */
305
+ int parallel_workers; /* max number of parallel workers */
306
+ bool vacuum_index_cleanup; /* enables index vacuuming and cleanup */
307
+ bool vacuum_truncate; /* enables vacuum to truncate a relation */
308
+ } StdRdOptions;
309
+
310
+ #define HEAP_MIN_FILLFACTOR 10
311
+ #define HEAP_DEFAULT_FILLFACTOR 100
312
+
313
+ /*
314
+ * RelationGetToastTupleTarget
315
+ * Returns the relation's toast_tuple_target. Note multiple eval of argument!
316
+ */
317
+ #define RelationGetToastTupleTarget(relation, defaulttarg) \
318
+ ((relation)->rd_options ? \
319
+ ((StdRdOptions *) (relation)->rd_options)->toast_tuple_target : (defaulttarg))
320
+
321
+ /*
322
+ * RelationGetFillFactor
323
+ * Returns the relation's fillfactor. Note multiple eval of argument!
324
+ */
325
+ #define RelationGetFillFactor(relation, defaultff) \
326
+ ((relation)->rd_options ? \
327
+ ((StdRdOptions *) (relation)->rd_options)->fillfactor : (defaultff))
328
+
329
+ /*
330
+ * RelationGetTargetPageUsage
331
+ * Returns the relation's desired space usage per page in bytes.
332
+ */
333
+ #define RelationGetTargetPageUsage(relation, defaultff) \
334
+ (BLCKSZ * RelationGetFillFactor(relation, defaultff) / 100)
335
+
336
+ /*
337
+ * RelationGetTargetPageFreeSpace
338
+ * Returns the relation's desired freespace per page in bytes.
339
+ */
340
+ #define RelationGetTargetPageFreeSpace(relation, defaultff) \
341
+ (BLCKSZ * (100 - RelationGetFillFactor(relation, defaultff)) / 100)
342
+
343
+ /*
344
+ * RelationIsUsedAsCatalogTable
345
+ * Returns whether the relation should be treated as a catalog table
346
+ * from the pov of logical decoding. Note multiple eval of argument!
347
+ */
348
+ #define RelationIsUsedAsCatalogTable(relation) \
349
+ ((relation)->rd_options && \
350
+ ((relation)->rd_rel->relkind == RELKIND_RELATION || \
351
+ (relation)->rd_rel->relkind == RELKIND_MATVIEW) ? \
352
+ ((StdRdOptions *) (relation)->rd_options)->user_catalog_table : false)
353
+
354
+ /*
355
+ * RelationGetParallelWorkers
356
+ * Returns the relation's parallel_workers reloption setting.
357
+ * Note multiple eval of argument!
358
+ */
359
+ #define RelationGetParallelWorkers(relation, defaultpw) \
360
+ ((relation)->rd_options ? \
361
+ ((StdRdOptions *) (relation)->rd_options)->parallel_workers : (defaultpw))
362
+
363
+ /* ViewOptions->check_option values */
364
+ typedef enum ViewOptCheckOption
365
+ {
366
+ VIEW_OPTION_CHECK_OPTION_NOT_SET,
367
+ VIEW_OPTION_CHECK_OPTION_LOCAL,
368
+ VIEW_OPTION_CHECK_OPTION_CASCADED
369
+ } ViewOptCheckOption;
370
+
371
+ /*
372
+ * ViewOptions
373
+ * Contents of rd_options for views
374
+ */
375
+ typedef struct ViewOptions
376
+ {
377
+ int32 vl_len_; /* varlena header (do not touch directly!) */
378
+ bool security_barrier;
379
+ ViewOptCheckOption check_option;
380
+ } ViewOptions;
381
+
382
+ /*
383
+ * RelationIsSecurityView
384
+ * Returns whether the relation is security view, or not. Note multiple
385
+ * eval of argument!
386
+ */
387
+ #define RelationIsSecurityView(relation) \
388
+ (AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW), \
389
+ (relation)->rd_options ? \
390
+ ((ViewOptions *) (relation)->rd_options)->security_barrier : false)
391
+
392
+ /*
393
+ * RelationHasCheckOption
394
+ * Returns true if the relation is a view defined with either the local
395
+ * or the cascaded check option. Note multiple eval of argument!
396
+ */
397
+ #define RelationHasCheckOption(relation) \
398
+ (AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW), \
399
+ (relation)->rd_options && \
400
+ ((ViewOptions *) (relation)->rd_options)->check_option != \
401
+ VIEW_OPTION_CHECK_OPTION_NOT_SET)
402
+
403
+ /*
404
+ * RelationHasLocalCheckOption
405
+ * Returns true if the relation is a view defined with the local check
406
+ * option. Note multiple eval of argument!
407
+ */
408
+ #define RelationHasLocalCheckOption(relation) \
409
+ (AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW), \
410
+ (relation)->rd_options && \
411
+ ((ViewOptions *) (relation)->rd_options)->check_option == \
412
+ VIEW_OPTION_CHECK_OPTION_LOCAL)
413
+
414
+ /*
415
+ * RelationHasCascadedCheckOption
416
+ * Returns true if the relation is a view defined with the cascaded check
417
+ * option. Note multiple eval of argument!
418
+ */
419
+ #define RelationHasCascadedCheckOption(relation) \
420
+ (AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW), \
421
+ (relation)->rd_options && \
422
+ ((ViewOptions *) (relation)->rd_options)->check_option == \
423
+ VIEW_OPTION_CHECK_OPTION_CASCADED)
424
+
425
+ /*
426
+ * RelationIsValid
427
+ * True iff relation descriptor is valid.
428
+ */
429
+ #define RelationIsValid(relation) PointerIsValid(relation)
430
+
431
+ #define InvalidRelation ((Relation) NULL)
432
+
433
+ /*
434
+ * RelationHasReferenceCountZero
435
+ * True iff relation reference count is zero.
436
+ *
437
+ * Note:
438
+ * Assumes relation descriptor is valid.
439
+ */
440
+ #define RelationHasReferenceCountZero(relation) \
441
+ ((bool)((relation)->rd_refcnt == 0))
442
+
443
+ /*
444
+ * RelationGetForm
445
+ * Returns pg_class tuple for a relation.
446
+ *
447
+ * Note:
448
+ * Assumes relation descriptor is valid.
449
+ */
450
+ #define RelationGetForm(relation) ((relation)->rd_rel)
451
+
452
+ /*
453
+ * RelationGetRelid
454
+ * Returns the OID of the relation
455
+ */
456
+ #define RelationGetRelid(relation) ((relation)->rd_id)
457
+
458
+ /*
459
+ * RelationGetNumberOfAttributes
460
+ * Returns the total number of attributes in a relation.
461
+ */
462
+ #define RelationGetNumberOfAttributes(relation) ((relation)->rd_rel->relnatts)
463
+
464
+ /*
465
+ * IndexRelationGetNumberOfAttributes
466
+ * Returns the number of attributes in an index.
467
+ */
468
+ #define IndexRelationGetNumberOfAttributes(relation) \
469
+ ((relation)->rd_index->indnatts)
470
+
471
+ /*
472
+ * IndexRelationGetNumberOfKeyAttributes
473
+ * Returns the number of key attributes in an index.
474
+ */
475
+ #define IndexRelationGetNumberOfKeyAttributes(relation) \
476
+ ((relation)->rd_index->indnkeyatts)
477
+
478
+ /*
479
+ * RelationGetDescr
480
+ * Returns tuple descriptor for a relation.
481
+ */
482
+ #define RelationGetDescr(relation) ((relation)->rd_att)
483
+
484
+ /*
485
+ * RelationGetRelationName
486
+ * Returns the rel's name.
487
+ *
488
+ * Note that the name is only unique within the containing namespace.
489
+ */
490
+ #define RelationGetRelationName(relation) \
491
+ (NameStr((relation)->rd_rel->relname))
492
+
493
+ /*
494
+ * RelationGetNamespace
495
+ * Returns the rel's namespace OID.
496
+ */
497
+ #define RelationGetNamespace(relation) \
498
+ ((relation)->rd_rel->relnamespace)
499
+
500
+ /*
501
+ * RelationIsMapped
502
+ * True if the relation uses the relfilenode map. Note multiple eval
503
+ * of argument!
504
+ */
505
+ #define RelationIsMapped(relation) \
506
+ (RELKIND_HAS_STORAGE((relation)->rd_rel->relkind) && \
507
+ ((relation)->rd_rel->relfilenode == InvalidOid))
508
+
509
+ /*
510
+ * RelationOpenSmgr
511
+ * Open the relation at the smgr level, if not already done.
512
+ */
513
+ #define RelationOpenSmgr(relation) \
514
+ do { \
515
+ if ((relation)->rd_smgr == NULL) \
516
+ smgrsetowner(&((relation)->rd_smgr), smgropen((relation)->rd_node, (relation)->rd_backend)); \
517
+ } while (0)
518
+
519
+ /*
520
+ * RelationCloseSmgr
521
+ * Close the relation at the smgr level, if not already done.
522
+ *
523
+ * Note: smgrclose should unhook from owner pointer, hence the Assert.
524
+ */
525
+ #define RelationCloseSmgr(relation) \
526
+ do { \
527
+ if ((relation)->rd_smgr != NULL) \
528
+ { \
529
+ smgrclose((relation)->rd_smgr); \
530
+ Assert((relation)->rd_smgr == NULL); \
531
+ } \
532
+ } while (0)
533
+
534
+ /*
535
+ * RelationGetTargetBlock
536
+ * Fetch relation's current insertion target block.
537
+ *
538
+ * Returns InvalidBlockNumber if there is no current target block. Note
539
+ * that the target block status is discarded on any smgr-level invalidation.
540
+ */
541
+ #define RelationGetTargetBlock(relation) \
542
+ ( (relation)->rd_smgr != NULL ? (relation)->rd_smgr->smgr_targblock : InvalidBlockNumber )
543
+
544
+ /*
545
+ * RelationSetTargetBlock
546
+ * Set relation's current insertion target block.
547
+ */
548
+ #define RelationSetTargetBlock(relation, targblock) \
549
+ do { \
550
+ RelationOpenSmgr(relation); \
551
+ (relation)->rd_smgr->smgr_targblock = (targblock); \
552
+ } while (0)
553
+
554
+ /*
555
+ * RelationNeedsWAL
556
+ * True if relation needs WAL.
557
+ *
558
+ * Returns false if wal_level = minimal and this relation is created or
559
+ * truncated in the current transaction. See "Skipping WAL for New
560
+ * RelFileNode" in src/backend/access/transam/README.
561
+ */
562
+ #define RelationNeedsWAL(relation) \
563
+ ((relation)->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT && \
564
+ (XLogIsNeeded() || \
565
+ (relation->rd_createSubid == InvalidSubTransactionId && \
566
+ relation->rd_firstRelfilenodeSubid == InvalidSubTransactionId)))
567
+
568
+ /*
569
+ * RelationUsesLocalBuffers
570
+ * True if relation's pages are stored in local buffers.
571
+ */
572
+ #define RelationUsesLocalBuffers(relation) \
573
+ ((relation)->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
574
+
575
+ /*
576
+ * RELATION_IS_LOCAL
577
+ * If a rel is either temp or newly created in the current transaction,
578
+ * it can be assumed to be accessible only to the current backend.
579
+ * This is typically used to decide that we can skip acquiring locks.
580
+ *
581
+ * Beware of multiple eval of argument
582
+ */
583
+ #define RELATION_IS_LOCAL(relation) \
584
+ ((relation)->rd_islocaltemp || \
585
+ (relation)->rd_createSubid != InvalidSubTransactionId)
586
+
587
+ /*
588
+ * RELATION_IS_OTHER_TEMP
589
+ * Test for a temporary relation that belongs to some other session.
590
+ *
591
+ * Beware of multiple eval of argument
592
+ */
593
+ #define RELATION_IS_OTHER_TEMP(relation) \
594
+ ((relation)->rd_rel->relpersistence == RELPERSISTENCE_TEMP && \
595
+ !(relation)->rd_islocaltemp)
596
+
597
+
598
+ /*
599
+ * RelationIsScannable
600
+ * Currently can only be false for a materialized view which has not been
601
+ * populated by its query. This is likely to get more complicated later,
602
+ * so use a macro which looks like a function.
603
+ */
604
+ #define RelationIsScannable(relation) ((relation)->rd_rel->relispopulated)
605
+
606
+ /*
607
+ * RelationIsPopulated
608
+ * Currently, we don't physically distinguish the "populated" and
609
+ * "scannable" properties of matviews, but that may change later.
610
+ * Hence, use the appropriate one of these macros in code tests.
611
+ */
612
+ #define RelationIsPopulated(relation) ((relation)->rd_rel->relispopulated)
613
+
614
+ /*
615
+ * RelationIsAccessibleInLogicalDecoding
616
+ * True if we need to log enough information to have access via
617
+ * decoding snapshot.
618
+ */
619
+ #define RelationIsAccessibleInLogicalDecoding(relation) \
620
+ (XLogLogicalInfoActive() && \
621
+ RelationNeedsWAL(relation) && \
622
+ (IsCatalogRelation(relation) || RelationIsUsedAsCatalogTable(relation)))
623
+
624
+ /*
625
+ * RelationIsLogicallyLogged
626
+ * True if we need to log enough information to extract the data from the
627
+ * WAL stream.
628
+ *
629
+ * We don't log information for unlogged tables (since they don't WAL log
630
+ * anyway) and for system tables (their content is hard to make sense of, and
631
+ * it would complicate decoding slightly for little gain). Note that we *do*
632
+ * log information for user defined catalog tables since they presumably are
633
+ * interesting to the user...
634
+ */
635
+ #define RelationIsLogicallyLogged(relation) \
636
+ (XLogLogicalInfoActive() && \
637
+ RelationNeedsWAL(relation) && \
638
+ !IsCatalogRelation(relation))
639
+
640
+ /* routines in utils/cache/relcache.c */
641
+ extern void RelationIncrementReferenceCount(Relation rel);
642
+ extern void RelationDecrementReferenceCount(Relation rel);
643
+
644
+ #endif /* REL_H */