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,127 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * builtins.h
4
+ * Declarations for operations on built-in types.
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/builtins.h
11
+ *
12
+ *-------------------------------------------------------------------------
13
+ */
14
+ #ifndef BUILTINS_H
15
+ #define BUILTINS_H
16
+
17
+ #include "fmgr.h"
18
+ #include "nodes/nodes.h"
19
+ #include "utils/fmgrprotos.h"
20
+
21
+ /* Sign + the most decimal digits an 8-byte number could have */
22
+ #define MAXINT8LEN 20
23
+
24
+ /* bool.c */
25
+ extern bool parse_bool(const char *value, bool *result);
26
+ extern bool parse_bool_with_len(const char *value, size_t len, bool *result);
27
+
28
+ /* domains.c */
29
+ extern void domain_check(Datum value, bool isnull, Oid domainType,
30
+ void **extra, MemoryContext mcxt);
31
+ extern int errdatatype(Oid datatypeOid);
32
+ extern int errdomainconstraint(Oid datatypeOid, const char *conname);
33
+
34
+ /* encode.c */
35
+ extern uint64 hex_encode(const char *src, size_t len, char *dst);
36
+ extern uint64 hex_decode(const char *src, size_t len, char *dst);
37
+
38
+ /* int.c */
39
+ extern int2vector *buildint2vector(const int16 *int2s, int n);
40
+
41
+ /* name.c */
42
+ extern int namecpy(Name n1, const NameData *n2);
43
+ extern int namestrcpy(Name name, const char *str);
44
+ extern int namestrcmp(Name name, const char *str);
45
+
46
+ /* numutils.c */
47
+ extern int32 pg_atoi(const char *s, int size, int c);
48
+ extern int16 pg_strtoint16(const char *s);
49
+ extern int32 pg_strtoint32(const char *s);
50
+ extern void pg_itoa(int16 i, char *a);
51
+ extern int pg_ultoa_n(uint32 l, char *a);
52
+ extern int pg_ulltoa_n(uint64 l, char *a);
53
+ extern void pg_ltoa(int32 l, char *a);
54
+ extern void pg_lltoa(int64 ll, char *a);
55
+ extern char *pg_ultostr_zeropad(char *str, uint32 value, int32 minwidth);
56
+ extern char *pg_ultostr(char *str, uint32 value);
57
+ extern uint64 pg_strtouint64(const char *str, char **endptr, int base);
58
+
59
+ /* oid.c */
60
+ extern oidvector *buildoidvector(const Oid *oids, int n);
61
+ extern Oid oidparse(Node *node);
62
+ extern int oid_cmp(const void *p1, const void *p2);
63
+
64
+ /* regexp.c */
65
+ extern char *regexp_fixed_prefix(text *text_re, bool case_insensitive,
66
+ Oid collation, bool *exact);
67
+
68
+ /* ruleutils.c */
69
+ extern __thread bool quote_all_identifiers;
70
+ extern const char *quote_identifier(const char *ident);
71
+ extern char *quote_qualified_identifier(const char *qualifier,
72
+ const char *ident);
73
+ extern void generate_operator_clause(fmStringInfo buf,
74
+ const char *leftop, Oid leftoptype,
75
+ Oid opoid,
76
+ const char *rightop, Oid rightoptype);
77
+
78
+ /* varchar.c */
79
+ extern int bpchartruelen(char *s, int len);
80
+
81
+ /* popular functions from varlena.c */
82
+ extern text *cstring_to_text(const char *s);
83
+ extern text *cstring_to_text_with_len(const char *s, int len);
84
+ extern char *text_to_cstring(const text *t);
85
+ extern void text_to_cstring_buffer(const text *src, char *dst, size_t dst_len);
86
+
87
+ #define CStringGetTextDatum(s) PointerGetDatum(cstring_to_text(s))
88
+ #define TextDatumGetCString(d) text_to_cstring((text *) DatumGetPointer(d))
89
+
90
+ /* xid.c */
91
+ extern int xidComparator(const void *arg1, const void *arg2);
92
+
93
+ /* inet_cidr_ntop.c */
94
+ extern char *pg_inet_cidr_ntop(int af, const void *src, int bits,
95
+ char *dst, size_t size);
96
+
97
+ /* inet_net_pton.c */
98
+ extern int pg_inet_net_pton(int af, const char *src,
99
+ void *dst, size_t size);
100
+
101
+ /* network.c */
102
+ extern double convert_network_to_scalar(Datum value, Oid typid, bool *failure);
103
+ extern Datum network_scan_first(Datum in);
104
+ extern Datum network_scan_last(Datum in);
105
+ extern void clean_ipv6_addr(int addr_family, char *addr);
106
+
107
+ /* numeric.c */
108
+ extern Datum numeric_float8_no_overflow(PG_FUNCTION_ARGS);
109
+
110
+ /* format_type.c */
111
+
112
+ /* Control flags for format_type_extended */
113
+ #define FORMAT_TYPE_TYPEMOD_GIVEN 0x01 /* typemod defined by caller */
114
+ #define FORMAT_TYPE_ALLOW_INVALID 0x02 /* allow invalid types */
115
+ #define FORMAT_TYPE_FORCE_QUALIFY 0x04 /* force qualification of type */
116
+ extern char *format_type_extended(Oid type_oid, int32 typemod, bits16 flags);
117
+
118
+ extern char *format_type_be(Oid type_oid);
119
+ extern char *format_type_be_qualified(Oid type_oid);
120
+ extern char *format_type_with_typemod(Oid type_oid, int32 typemod);
121
+
122
+ extern int32 type_maximum_size(Oid type_oid, int32 typemod);
123
+
124
+ /* quote.c */
125
+ extern char *quote_literal_cstr(const char *rawstr);
126
+
127
+ #endif /* BUILTINS_H */
@@ -0,0 +1,27 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * bytea.h
4
+ * Declarations for BYTEA data type support.
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/bytea.h
11
+ *
12
+ *-------------------------------------------------------------------------
13
+ */
14
+ #ifndef BYTEA_H
15
+ #define BYTEA_H
16
+
17
+
18
+
19
+ typedef enum
20
+ {
21
+ BYTEA_OUTPUT_ESCAPE,
22
+ BYTEA_OUTPUT_HEX
23
+ } ByteaOutputType;
24
+
25
+ extern int bytea_output; /* ByteaOutputType, but int for GUC enum */
26
+
27
+ #endif /* BYTEA_H */
@@ -0,0 +1,231 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * catcache.h
4
+ * Low-level catalog cache definitions.
5
+ *
6
+ * NOTE: every catalog cache must have a corresponding unique index on
7
+ * the system table that it caches --- ie, the index must match the keys
8
+ * used to do lookups in this cache. All cache fetches are done with
9
+ * indexscans (under normal conditions). The index should be unique to
10
+ * guarantee that there can only be one matching row for a key combination.
11
+ *
12
+ *
13
+ * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
14
+ * Portions Copyright (c) 1994, Regents of the University of California
15
+ *
16
+ * src/include/utils/catcache.h
17
+ *
18
+ *-------------------------------------------------------------------------
19
+ */
20
+ #ifndef CATCACHE_H
21
+ #define CATCACHE_H
22
+
23
+ #include "access/htup.h"
24
+ #include "access/skey.h"
25
+ #include "lib/ilist.h"
26
+ #include "utils/relcache.h"
27
+
28
+ /*
29
+ * struct catctup: individual tuple in the cache.
30
+ * struct catclist: list of tuples matching a partial key.
31
+ * struct catcache: information for managing a cache.
32
+ * struct catcacheheader: information for managing all the caches.
33
+ */
34
+
35
+ #define CATCACHE_MAXKEYS 4
36
+
37
+
38
+ /* function computing a datum's hash */
39
+ typedef uint32 (*CCHashFN) (Datum datum);
40
+
41
+ /* function computing equality of two datums */
42
+ typedef bool (*CCFastEqualFN) (Datum a, Datum b);
43
+
44
+ typedef struct catcache
45
+ {
46
+ int id; /* cache identifier --- see syscache.h */
47
+ int cc_nbuckets; /* # of hash buckets in this cache */
48
+ TupleDesc cc_tupdesc; /* tuple descriptor (copied from reldesc) */
49
+ dlist_head *cc_bucket; /* hash buckets */
50
+ CCHashFN cc_hashfunc[CATCACHE_MAXKEYS]; /* hash function for each key */
51
+ CCFastEqualFN cc_fastequal[CATCACHE_MAXKEYS]; /* fast equal function for
52
+ * each key */
53
+ int cc_keyno[CATCACHE_MAXKEYS]; /* AttrNumber of each key */
54
+ dlist_head cc_lists; /* list of CatCList structs */
55
+ int cc_ntup; /* # of tuples currently in this cache */
56
+ int cc_nkeys; /* # of keys (1..CATCACHE_MAXKEYS) */
57
+ const char *cc_relname; /* name of relation the tuples come from */
58
+ Oid cc_reloid; /* OID of relation the tuples come from */
59
+ Oid cc_indexoid; /* OID of index matching cache keys */
60
+ bool cc_relisshared; /* is relation shared across databases? */
61
+ slist_node cc_next; /* list link */
62
+ ScanKeyData cc_skey[CATCACHE_MAXKEYS]; /* precomputed key info for heap
63
+ * scans */
64
+
65
+ /*
66
+ * Keep these at the end, so that compiling catcache.c with CATCACHE_STATS
67
+ * doesn't break ABI for other modules
68
+ */
69
+ #ifdef CATCACHE_STATS
70
+ long cc_searches; /* total # searches against this cache */
71
+ long cc_hits; /* # of matches against existing entry */
72
+ long cc_neg_hits; /* # of matches against negative entry */
73
+ long cc_newloads; /* # of successful loads of new entry */
74
+
75
+ /*
76
+ * cc_searches - (cc_hits + cc_neg_hits + cc_newloads) is number of failed
77
+ * searches, each of which will result in loading a negative entry
78
+ */
79
+ long cc_invals; /* # of entries invalidated from cache */
80
+ long cc_lsearches; /* total # list-searches */
81
+ long cc_lhits; /* # of matches against existing lists */
82
+ #endif
83
+ } CatCache;
84
+
85
+
86
+ typedef struct catctup
87
+ {
88
+ int ct_magic; /* for identifying CatCTup entries */
89
+ #define CT_MAGIC 0x57261502
90
+
91
+ uint32 hash_value; /* hash value for this tuple's keys */
92
+
93
+ /*
94
+ * Lookup keys for the entry. By-reference datums point into the tuple for
95
+ * positive cache entries, and are separately allocated for negative ones.
96
+ */
97
+ Datum keys[CATCACHE_MAXKEYS];
98
+
99
+ /*
100
+ * Each tuple in a cache is a member of a dlist that stores the elements
101
+ * of its hash bucket. We keep each dlist in LRU order to speed repeated
102
+ * lookups.
103
+ */
104
+ dlist_node cache_elem; /* list member of per-bucket list */
105
+
106
+ /*
107
+ * A tuple marked "dead" must not be returned by subsequent searches.
108
+ * However, it won't be physically deleted from the cache until its
109
+ * refcount goes to zero. (If it's a member of a CatCList, the list's
110
+ * refcount must go to zero, too; also, remember to mark the list dead at
111
+ * the same time the tuple is marked.)
112
+ *
113
+ * A negative cache entry is an assertion that there is no tuple matching
114
+ * a particular key. This is just as useful as a normal entry so far as
115
+ * avoiding catalog searches is concerned. Management of positive and
116
+ * negative entries is identical.
117
+ */
118
+ int refcount; /* number of active references */
119
+ bool dead; /* dead but not yet removed? */
120
+ bool negative; /* negative cache entry? */
121
+ HeapTupleData tuple; /* tuple management header */
122
+
123
+ /*
124
+ * The tuple may also be a member of at most one CatCList. (If a single
125
+ * catcache is list-searched with varying numbers of keys, we may have to
126
+ * make multiple entries for the same tuple because of this restriction.
127
+ * Currently, that's not expected to be common, so we accept the potential
128
+ * inefficiency.)
129
+ */
130
+ struct catclist *c_list; /* containing CatCList, or NULL if none */
131
+
132
+ CatCache *my_cache; /* link to owning catcache */
133
+ /* properly aligned tuple data follows, unless a negative entry */
134
+ } CatCTup;
135
+
136
+
137
+ /*
138
+ * A CatCList describes the result of a partial search, ie, a search using
139
+ * only the first K key columns of an N-key cache. We store the keys used
140
+ * into the keys attribute to represent the stored key set. The CatCList
141
+ * object contains links to cache entries for all the table rows satisfying
142
+ * the partial key. (Note: none of these will be negative cache entries.)
143
+ *
144
+ * A CatCList is only a member of a per-cache list; we do not currently
145
+ * divide them into hash buckets.
146
+ *
147
+ * A list marked "dead" must not be returned by subsequent searches.
148
+ * However, it won't be physically deleted from the cache until its
149
+ * refcount goes to zero. (A list should be marked dead if any of its
150
+ * member entries are dead.)
151
+ *
152
+ * If "ordered" is true then the member tuples appear in the order of the
153
+ * cache's underlying index. This will be true in normal operation, but
154
+ * might not be true during bootstrap or recovery operations. (namespace.c
155
+ * is able to save some cycles when it is true.)
156
+ */
157
+ typedef struct catclist
158
+ {
159
+ int cl_magic; /* for identifying CatCList entries */
160
+ #define CL_MAGIC 0x52765103
161
+
162
+ uint32 hash_value; /* hash value for lookup keys */
163
+
164
+ dlist_node cache_elem; /* list member of per-catcache list */
165
+
166
+ /*
167
+ * Lookup keys for the entry, with the first nkeys elements being valid.
168
+ * All by-reference are separately allocated.
169
+ */
170
+ Datum keys[CATCACHE_MAXKEYS];
171
+
172
+ int refcount; /* number of active references */
173
+ bool dead; /* dead but not yet removed? */
174
+ bool ordered; /* members listed in index order? */
175
+ short nkeys; /* number of lookup keys specified */
176
+ int n_members; /* number of member tuples */
177
+ CatCache *my_cache; /* link to owning catcache */
178
+ CatCTup *members[FLEXIBLE_ARRAY_MEMBER]; /* members */
179
+ } CatCList;
180
+
181
+
182
+ typedef struct catcacheheader
183
+ {
184
+ slist_head ch_caches; /* head of list of CatCache structs */
185
+ int ch_ntup; /* # of tuples in all caches */
186
+ } CatCacheHeader;
187
+
188
+
189
+ /* this extern duplicates utils/memutils.h... */
190
+ extern PGDLLIMPORT MemoryContext CacheMemoryContext;
191
+
192
+ extern void CreateCacheMemoryContext(void);
193
+
194
+ extern CatCache *InitCatCache(int id, Oid reloid, Oid indexoid,
195
+ int nkeys, const int *key,
196
+ int nbuckets);
197
+ extern void InitCatCachePhase2(CatCache *cache, bool touch_index);
198
+
199
+ extern HeapTuple SearchCatCache(CatCache *cache,
200
+ Datum v1, Datum v2, Datum v3, Datum v4);
201
+ extern HeapTuple SearchCatCache1(CatCache *cache,
202
+ Datum v1);
203
+ extern HeapTuple SearchCatCache2(CatCache *cache,
204
+ Datum v1, Datum v2);
205
+ extern HeapTuple SearchCatCache3(CatCache *cache,
206
+ Datum v1, Datum v2, Datum v3);
207
+ extern HeapTuple SearchCatCache4(CatCache *cache,
208
+ Datum v1, Datum v2, Datum v3, Datum v4);
209
+ extern void ReleaseCatCache(HeapTuple tuple);
210
+
211
+ extern uint32 GetCatCacheHashValue(CatCache *cache,
212
+ Datum v1, Datum v2,
213
+ Datum v3, Datum v4);
214
+
215
+ extern CatCList *SearchCatCacheList(CatCache *cache, int nkeys,
216
+ Datum v1, Datum v2,
217
+ Datum v3);
218
+ extern void ReleaseCatCacheList(CatCList *list);
219
+
220
+ extern void ResetCatalogCaches(void);
221
+ extern void CatalogCacheFlushCatalog(Oid catId);
222
+ extern void CatCacheInvalidate(CatCache *cache, uint32 hashValue);
223
+ extern void PrepareToInvalidateCacheTuple(Relation relation,
224
+ HeapTuple tuple,
225
+ HeapTuple newtuple,
226
+ void (*function) (int, uint32, Oid));
227
+
228
+ extern void PrintCatCacheLeakWarning(HeapTuple tuple);
229
+ extern void PrintCatCacheListLeakWarning(CatCList *list);
230
+
231
+ #endif /* CATCACHE_H */
@@ -0,0 +1,90 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * date.h
4
+ * Definitions for the SQL "date" and "time" types.
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/date.h
11
+ *
12
+ *-------------------------------------------------------------------------
13
+ */
14
+ #ifndef DATE_H
15
+ #define DATE_H
16
+
17
+ #include <math.h>
18
+
19
+ #include "datatype/timestamp.h"
20
+ #include "fmgr.h"
21
+ #include "pgtime.h"
22
+
23
+ typedef int32 DateADT;
24
+
25
+ typedef int64 TimeADT;
26
+
27
+ typedef struct
28
+ {
29
+ TimeADT time; /* all time units other than months and years */
30
+ int32 zone; /* numeric time zone, in seconds */
31
+ } TimeTzADT;
32
+
33
+ /*
34
+ * Infinity and minus infinity must be the max and min values of DateADT.
35
+ */
36
+ #define DATEVAL_NOBEGIN ((DateADT) PG_INT32_MIN)
37
+ #define DATEVAL_NOEND ((DateADT) PG_INT32_MAX)
38
+
39
+ #define DATE_NOBEGIN(j) ((j) = DATEVAL_NOBEGIN)
40
+ #define DATE_IS_NOBEGIN(j) ((j) == DATEVAL_NOBEGIN)
41
+ #define DATE_NOEND(j) ((j) = DATEVAL_NOEND)
42
+ #define DATE_IS_NOEND(j) ((j) == DATEVAL_NOEND)
43
+ #define DATE_NOT_FINITE(j) (DATE_IS_NOBEGIN(j) || DATE_IS_NOEND(j))
44
+
45
+ /*
46
+ * Macros for fmgr-callable functions.
47
+ *
48
+ * For TimeADT, we make use of the same support routines as for int64.
49
+ * Therefore TimeADT is pass-by-reference if and only if int64 is!
50
+ */
51
+ #define MAX_TIME_PRECISION 6
52
+
53
+ #define DatumGetDateADT(X) ((DateADT) DatumGetInt32(X))
54
+ #define DatumGetTimeADT(X) ((TimeADT) DatumGetInt64(X))
55
+ #define DatumGetTimeTzADTP(X) ((TimeTzADT *) DatumGetPointer(X))
56
+
57
+ #define DateADTGetDatum(X) Int32GetDatum(X)
58
+ #define TimeADTGetDatum(X) Int64GetDatum(X)
59
+ #define TimeTzADTPGetDatum(X) PointerGetDatum(X)
60
+
61
+ #define PG_GETARG_DATEADT(n) DatumGetDateADT(PG_GETARG_DATUM(n))
62
+ #define PG_GETARG_TIMEADT(n) DatumGetTimeADT(PG_GETARG_DATUM(n))
63
+ #define PG_GETARG_TIMETZADT_P(n) DatumGetTimeTzADTP(PG_GETARG_DATUM(n))
64
+
65
+ #define PG_RETURN_DATEADT(x) return DateADTGetDatum(x)
66
+ #define PG_RETURN_TIMEADT(x) return TimeADTGetDatum(x)
67
+ #define PG_RETURN_TIMETZADT_P(x) return TimeTzADTPGetDatum(x)
68
+
69
+
70
+ /* date.c */
71
+ extern int32 anytime_typmod_check(bool istz, int32 typmod);
72
+ extern double date2timestamp_no_overflow(DateADT dateVal);
73
+ extern Timestamp date2timestamp_opt_overflow(DateADT dateVal, int *overflow);
74
+ extern TimestampTz date2timestamptz_opt_overflow(DateADT dateVal, int *overflow);
75
+ extern int32 date_cmp_timestamp_internal(DateADT dateVal, Timestamp dt2);
76
+ extern int32 date_cmp_timestamptz_internal(DateADT dateVal, TimestampTz dt2);
77
+
78
+ extern void EncodeSpecialDate(DateADT dt, char *str);
79
+ extern DateADT GetSQLCurrentDate(void);
80
+ extern TimeTzADT *GetSQLCurrentTime(int32 typmod);
81
+ extern TimeADT GetSQLLocalTime(int32 typmod);
82
+ extern int time2tm(TimeADT time, struct pg_tm *tm, fsec_t *fsec);
83
+ extern int timetz2tm(TimeTzADT *time, struct pg_tm *tm, fsec_t *fsec, int *tzp);
84
+ extern int tm2time(struct pg_tm *tm, fsec_t fsec, TimeADT *result);
85
+ extern int tm2timetz(struct pg_tm *tm, fsec_t fsec, int tz, TimeTzADT *result);
86
+ extern bool time_overflows(int hour, int min, int sec, fsec_t fsec);
87
+ extern bool float_time_overflows(int hour, int min, double sec);
88
+ extern void AdjustTimeForTypmod(TimeADT *time, int32 typmod);
89
+
90
+ #endif /* DATE_H */