pg_query 2.0.3 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (557) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +165 -0
  3. data/README.md +67 -29
  4. data/Rakefile +8 -23
  5. data/ext/pg_query/extconf.rb +21 -3
  6. data/ext/pg_query/include/pg_query.h +29 -4
  7. data/ext/pg_query/include/pg_query_enum_defs.c +551 -272
  8. data/ext/pg_query/include/pg_query_fingerprint_conds.c +563 -470
  9. data/ext/pg_query/include/pg_query_fingerprint_defs.c +5403 -3945
  10. data/ext/pg_query/include/pg_query_outfuncs_conds.c +402 -330
  11. data/ext/pg_query/include/pg_query_outfuncs_defs.c +1319 -1059
  12. data/ext/pg_query/include/pg_query_readfuncs_conds.c +141 -118
  13. data/ext/pg_query/include/pg_query_readfuncs_defs.c +1685 -1379
  14. data/ext/pg_query/include/{access → postgres/access}/amapi.h +47 -1
  15. data/ext/pg_query/include/{access → postgres/access}/attmap.h +5 -3
  16. data/ext/pg_query/include/{access → postgres/access}/attnum.h +2 -2
  17. data/ext/pg_query/include/{access → postgres/access}/clog.h +4 -2
  18. data/ext/pg_query/include/{access → postgres/access}/commit_ts.h +6 -9
  19. data/ext/pg_query/include/{access → postgres/access}/detoast.h +1 -11
  20. data/ext/pg_query/include/{access → postgres/access}/genam.h +21 -16
  21. data/ext/pg_query/include/{access → postgres/access}/gin.h +17 -4
  22. data/ext/pg_query/include/{access → postgres/access}/htup.h +1 -1
  23. data/ext/pg_query/include/{access → postgres/access}/htup_details.h +80 -88
  24. data/ext/pg_query/include/{access → postgres/access}/itup.h +61 -52
  25. data/ext/pg_query/include/{access → postgres/access}/parallel.h +2 -2
  26. data/ext/pg_query/include/{access → postgres/access}/printtup.h +1 -1
  27. data/ext/pg_query/include/{access → postgres/access}/relation.h +1 -1
  28. data/ext/pg_query/include/{access → postgres/access}/relscan.h +17 -2
  29. data/ext/pg_query/include/postgres/access/rmgr.h +62 -0
  30. data/ext/pg_query/include/{access → postgres/access}/rmgrlist.h +24 -24
  31. data/ext/pg_query/include/{access → postgres/access}/sdir.h +12 -3
  32. data/ext/pg_query/include/{access → postgres/access}/skey.h +1 -1
  33. data/ext/pg_query/include/{access → postgres/access}/stratnum.h +4 -2
  34. data/ext/pg_query/include/{access → postgres/access}/sysattr.h +1 -1
  35. data/ext/pg_query/include/{access → postgres/access}/table.h +2 -1
  36. data/ext/pg_query/include/{access → postgres/access}/tableam.h +337 -62
  37. data/ext/pg_query/include/postgres/access/toast_compression.h +73 -0
  38. data/ext/pg_query/include/{access → postgres/access}/transam.h +123 -13
  39. data/ext/pg_query/include/postgres/access/tsmapi.h +82 -0
  40. data/ext/pg_query/include/{access → postgres/access}/tupconvert.h +5 -2
  41. data/ext/pg_query/include/{access → postgres/access}/tupdesc.h +2 -2
  42. data/ext/pg_query/include/{access → postgres/access}/tupmacs.h +60 -100
  43. data/ext/pg_query/include/{access → postgres/access}/twophase.h +5 -1
  44. data/ext/pg_query/include/{access → postgres/access}/xact.h +99 -32
  45. data/ext/pg_query/include/{access → postgres/access}/xlog.h +69 -165
  46. data/ext/pg_query/include/{access → postgres/access}/xlog_internal.h +147 -73
  47. data/ext/pg_query/include/postgres/access/xlogbackup.h +41 -0
  48. data/ext/pg_query/include/{access → postgres/access}/xlogdefs.h +13 -40
  49. data/ext/pg_query/include/postgres/access/xlogprefetcher.h +55 -0
  50. data/ext/pg_query/include/{access → postgres/access}/xlogreader.h +154 -37
  51. data/ext/pg_query/include/{access → postgres/access}/xlogrecord.h +34 -13
  52. data/ext/pg_query/include/postgres/access/xlogrecovery.h +158 -0
  53. data/ext/pg_query/include/postgres/archive/archive_module.h +59 -0
  54. data/ext/pg_query/include/{c.h → postgres/c.h} +245 -188
  55. data/ext/pg_query/include/{catalog → postgres/catalog}/catalog.h +6 -3
  56. data/ext/pg_query/include/{catalog → postgres/catalog}/catversion.h +6 -2
  57. data/ext/pg_query/include/{catalog → postgres/catalog}/dependency.h +14 -19
  58. data/ext/pg_query/include/postgres/catalog/genbki.h +143 -0
  59. data/ext/pg_query/include/{catalog → postgres/catalog}/index.h +20 -5
  60. data/ext/pg_query/include/postgres/catalog/indexing.h +54 -0
  61. data/ext/pg_query/include/{catalog → postgres/catalog}/namespace.h +5 -3
  62. data/ext/pg_query/include/{catalog → postgres/catalog}/objectaccess.h +73 -3
  63. data/ext/pg_query/include/{catalog → postgres/catalog}/objectaddress.h +12 -7
  64. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_aggregate.h +14 -10
  65. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_aggregate_d.h +2 -1
  66. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_am.h +4 -1
  67. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_am_d.h +3 -1
  68. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_attribute.h +45 -26
  69. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_attribute_d.h +19 -16
  70. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_authid.h +7 -2
  71. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_authid_d.h +19 -9
  72. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_class.h +45 -15
  73. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_class_d.h +31 -2
  74. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_collation.h +35 -8
  75. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_collation_d.h +21 -3
  76. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_constraint.h +39 -13
  77. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_constraint_d.h +10 -4
  78. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_control.h +13 -5
  79. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_conversion.h +8 -5
  80. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_conversion_d.h +4 -1
  81. data/ext/pg_query/include/postgres/catalog/pg_database.h +124 -0
  82. data/ext/pg_query/include/postgres/catalog/pg_database_d.h +52 -0
  83. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_depend.h +11 -7
  84. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_depend_d.h +3 -1
  85. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_event_trigger.h +9 -3
  86. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_event_trigger_d.h +3 -1
  87. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_index.h +17 -7
  88. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_index_d.h +20 -17
  89. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_language.h +10 -5
  90. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_language_d.h +3 -1
  91. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_namespace.h +7 -2
  92. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_namespace_d.h +3 -1
  93. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_opclass.h +8 -5
  94. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_opclass_d.h +3 -1
  95. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_operator.h +21 -16
  96. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_operator_d.h +37 -1
  97. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_opfamily.h +8 -4
  98. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_opfamily_d.h +6 -2
  99. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_partitioned_table.h +20 -9
  100. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_partitioned_table_d.h +2 -1
  101. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_proc.h +20 -11
  102. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_proc_d.h +10 -8
  103. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_publication.h +49 -6
  104. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_publication_d.h +3 -1
  105. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_replication_origin.h +6 -1
  106. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_replication_origin_d.h +5 -1
  107. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_statistic.h +19 -12
  108. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_statistic_d.h +2 -1
  109. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_statistic_ext.h +19 -5
  110. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_statistic_ext_d.h +7 -2
  111. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_transform.h +8 -5
  112. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_transform_d.h +3 -1
  113. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_trigger.h +24 -8
  114. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_trigger_d.h +4 -1
  115. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_config.h +6 -3
  116. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_config_d.h +3 -1
  117. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_dict.h +8 -3
  118. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_dict_d.h +3 -1
  119. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_parser.h +6 -3
  120. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_parser_d.h +3 -1
  121. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_template.h +6 -3
  122. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_template_d.h +3 -1
  123. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_type.h +56 -24
  124. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_type_d.h +70 -31
  125. data/ext/pg_query/include/{catalog → postgres/catalog}/storage.h +9 -7
  126. data/ext/pg_query/include/{commands → postgres/commands}/async.h +4 -5
  127. data/ext/pg_query/include/{commands → postgres/commands}/dbcommands.h +3 -1
  128. data/ext/pg_query/include/{commands → postgres/commands}/defrem.h +12 -24
  129. data/ext/pg_query/include/{commands → postgres/commands}/event_trigger.h +2 -2
  130. data/ext/pg_query/include/{commands → postgres/commands}/explain.h +3 -1
  131. data/ext/pg_query/include/{commands → postgres/commands}/prepare.h +1 -1
  132. data/ext/pg_query/include/{commands → postgres/commands}/tablespace.h +6 -4
  133. data/ext/pg_query/include/{commands → postgres/commands}/trigger.h +36 -25
  134. data/ext/pg_query/include/{commands → postgres/commands}/user.h +10 -4
  135. data/ext/pg_query/include/{commands → postgres/commands}/vacuum.h +140 -47
  136. data/ext/pg_query/include/postgres/common/cryptohash.h +39 -0
  137. data/ext/pg_query/include/{common → postgres/common}/file_perm.h +4 -4
  138. data/ext/pg_query/include/{common → postgres/common}/hashfn.h +1 -1
  139. data/ext/pg_query/include/postgres/common/int.h +437 -0
  140. data/ext/pg_query/include/{common → postgres/common}/keywords.h +2 -6
  141. data/ext/pg_query/include/{common → postgres/common}/kwlookup.h +2 -2
  142. data/ext/pg_query/include/postgres/common/pg_prng.h +61 -0
  143. data/ext/pg_query/include/{common → postgres/common}/relpath.h +21 -14
  144. data/ext/pg_query/include/postgres/common/scram-common.h +70 -0
  145. data/ext/pg_query/include/postgres/common/sha2.h +32 -0
  146. data/ext/pg_query/include/postgres/common/string.h +44 -0
  147. data/ext/pg_query/include/postgres/common/unicode_east_asian_fw_table.h +125 -0
  148. data/ext/pg_query/include/{common/unicode_combining_table.h → postgres/common/unicode_nonspacing_table.h} +138 -8
  149. data/ext/pg_query/include/postgres/copyfuncs.funcs.c +5013 -0
  150. data/ext/pg_query/include/postgres/copyfuncs.switch.c +938 -0
  151. data/ext/pg_query/include/{datatype → postgres/datatype}/timestamp.h +50 -4
  152. data/ext/pg_query/include/postgres/equalfuncs.funcs.c +3097 -0
  153. data/ext/pg_query/include/postgres/equalfuncs.switch.c +785 -0
  154. data/ext/pg_query/include/{executor → postgres/executor}/execdesc.h +1 -1
  155. data/ext/pg_query/include/{executor → postgres/executor}/executor.h +98 -32
  156. data/ext/pg_query/include/{executor → postgres/executor}/functions.h +17 -3
  157. data/ext/pg_query/include/{executor → postgres/executor}/instrument.h +33 -16
  158. data/ext/pg_query/include/{executor → postgres/executor}/spi.h +42 -4
  159. data/ext/pg_query/include/{executor → postgres/executor}/tablefunc.h +1 -1
  160. data/ext/pg_query/include/{executor → postgres/executor}/tuptable.h +18 -11
  161. data/ext/pg_query/include/{fmgr.h → postgres/fmgr.h} +33 -8
  162. data/ext/pg_query/include/postgres/foreign/fdwapi.h +294 -0
  163. data/ext/pg_query/include/{funcapi.h → postgres/funcapi.h} +22 -10
  164. data/ext/pg_query/include/postgres/gram.h +1127 -0
  165. data/ext/pg_query/include/{parser → postgres}/gramparse.h +4 -4
  166. data/ext/pg_query/include/{jit → postgres/jit}/jit.h +12 -12
  167. data/ext/pg_query/include/postgres/kwlist_d.h +1119 -0
  168. data/ext/pg_query/include/postgres/lib/dshash.h +115 -0
  169. data/ext/pg_query/include/{lib → postgres/lib}/ilist.h +454 -22
  170. data/ext/pg_query/include/{lib → postgres/lib}/pairingheap.h +1 -1
  171. data/ext/pg_query/include/{lib → postgres/lib}/simplehash.h +158 -33
  172. data/ext/pg_query/include/postgres/lib/sort_template.h +432 -0
  173. data/ext/pg_query/include/{lib → postgres/lib}/stringinfo.h +3 -3
  174. data/ext/pg_query/include/{libpq → postgres/libpq}/auth.h +12 -4
  175. data/ext/pg_query/include/{libpq → postgres/libpq}/crypt.h +5 -4
  176. data/ext/pg_query/include/{libpq → postgres/libpq}/hba.h +54 -8
  177. data/ext/pg_query/include/{libpq → postgres/libpq}/libpq-be.h +45 -17
  178. data/ext/pg_query/include/{libpq → postgres/libpq}/libpq.h +31 -20
  179. data/ext/pg_query/include/{libpq → postgres/libpq}/pqcomm.h +26 -71
  180. data/ext/pg_query/include/{libpq → postgres/libpq}/pqformat.h +2 -2
  181. data/ext/pg_query/include/{libpq → postgres/libpq}/pqsignal.h +25 -13
  182. data/ext/pg_query/include/postgres/libpq/sasl.h +136 -0
  183. data/ext/pg_query/include/postgres/libpq/scram.h +37 -0
  184. data/ext/pg_query/include/{mb → postgres/mb}/pg_wchar.h +125 -25
  185. data/ext/pg_query/include/{mb → postgres/mb}/stringinfo_mb.h +1 -1
  186. data/ext/pg_query/include/{miscadmin.h → postgres/miscadmin.h} +96 -65
  187. data/ext/pg_query/include/{nodes → postgres/nodes}/bitmapset.h +11 -7
  188. data/ext/pg_query/include/{nodes → postgres/nodes}/execnodes.h +351 -103
  189. data/ext/pg_query/include/{nodes → postgres/nodes}/extensible.h +8 -4
  190. data/ext/pg_query/include/{nodes → postgres/nodes}/lockoptions.h +1 -1
  191. data/ext/pg_query/include/{nodes → postgres/nodes}/makefuncs.h +19 -6
  192. data/ext/pg_query/include/{nodes → postgres/nodes}/memnodes.h +11 -6
  193. data/ext/pg_query/include/postgres/nodes/miscnodes.h +56 -0
  194. data/ext/pg_query/include/{nodes → postgres/nodes}/nodeFuncs.h +89 -29
  195. data/ext/pg_query/include/{nodes → postgres/nodes}/nodes.h +100 -496
  196. data/ext/pg_query/include/postgres/nodes/nodetags.h +471 -0
  197. data/ext/pg_query/include/{nodes → postgres/nodes}/params.h +3 -3
  198. data/ext/pg_query/include/{nodes → postgres/nodes}/parsenodes.h +678 -207
  199. data/ext/pg_query/include/{nodes → postgres/nodes}/pathnodes.h +1282 -454
  200. data/ext/pg_query/include/{nodes → postgres/nodes}/pg_list.h +103 -73
  201. data/ext/pg_query/include/{nodes → postgres/nodes}/plannodes.h +474 -133
  202. data/ext/pg_query/include/{nodes → postgres/nodes}/primnodes.h +754 -254
  203. data/ext/pg_query/include/{nodes → postgres/nodes}/print.h +1 -1
  204. data/ext/pg_query/include/postgres/nodes/queryjumble.h +86 -0
  205. data/ext/pg_query/include/postgres/nodes/replnodes.h +111 -0
  206. data/ext/pg_query/include/postgres/nodes/supportnodes.h +346 -0
  207. data/ext/pg_query/include/{nodes → postgres/nodes}/tidbitmap.h +1 -1
  208. data/ext/pg_query/include/postgres/nodes/value.h +90 -0
  209. data/ext/pg_query/include/{optimizer → postgres/optimizer}/cost.h +14 -5
  210. data/ext/pg_query/include/{optimizer → postgres/optimizer}/geqo.h +9 -7
  211. data/ext/pg_query/include/{optimizer → postgres/optimizer}/geqo_gene.h +1 -1
  212. data/ext/pg_query/include/{optimizer → postgres/optimizer}/optimizer.h +31 -28
  213. data/ext/pg_query/include/{optimizer → postgres/optimizer}/paths.h +29 -12
  214. data/ext/pg_query/include/{optimizer → postgres/optimizer}/planmain.h +15 -17
  215. data/ext/pg_query/include/{parser → postgres/parser}/analyze.h +20 -5
  216. data/ext/pg_query/include/postgres/parser/kwlist.h +498 -0
  217. data/ext/pg_query/include/{parser → postgres/parser}/parse_agg.h +5 -8
  218. data/ext/pg_query/include/{parser → postgres/parser}/parse_coerce.h +6 -1
  219. data/ext/pg_query/include/{parser → postgres/parser}/parse_expr.h +2 -3
  220. data/ext/pg_query/include/{parser → postgres/parser}/parse_func.h +2 -1
  221. data/ext/pg_query/include/{parser → postgres/parser}/parse_node.h +41 -11
  222. data/ext/pg_query/include/{parser → postgres/parser}/parse_oper.h +3 -5
  223. data/ext/pg_query/include/{parser → postgres/parser}/parse_relation.h +11 -5
  224. data/ext/pg_query/include/{parser → postgres/parser}/parse_type.h +4 -3
  225. data/ext/pg_query/include/postgres/parser/parser.h +68 -0
  226. data/ext/pg_query/include/{parser → postgres/parser}/parsetree.h +1 -1
  227. data/ext/pg_query/include/{parser → postgres/parser}/scanner.h +2 -2
  228. data/ext/pg_query/include/{parser → postgres/parser}/scansup.h +2 -5
  229. data/ext/pg_query/include/{partitioning → postgres/partitioning}/partdefs.h +1 -1
  230. data/ext/pg_query/include/{pg_config.h → postgres/pg_config.h} +216 -228
  231. data/ext/pg_query/include/{pg_config_manual.h → postgres/pg_config_manual.h} +80 -58
  232. data/ext/pg_query/include/postgres/pg_config_os.h +8 -0
  233. data/ext/pg_query/include/{pg_getopt.h → postgres/pg_getopt.h} +6 -6
  234. data/ext/pg_query/include/{pg_trace.h → postgres/pg_trace.h} +1 -1
  235. data/ext/pg_query/include/postgres/pgstat.h +778 -0
  236. data/ext/pg_query/include/{pgtime.h → postgres/pgtime.h} +16 -6
  237. data/ext/pg_query/include/{pl_gram.h → postgres/pl_gram.h} +116 -116
  238. data/ext/pg_query/include/{pl_reserved_kwlist.h → postgres/pl_reserved_kwlist.h} +1 -1
  239. data/ext/pg_query/include/{pl_reserved_kwlist_d.h → postgres/pl_reserved_kwlist_d.h} +10 -10
  240. data/ext/pg_query/include/{pl_unreserved_kwlist.h → postgres/pl_unreserved_kwlist.h} +3 -3
  241. data/ext/pg_query/include/{pl_unreserved_kwlist_d.h → postgres/pl_unreserved_kwlist_d.h} +60 -60
  242. data/ext/pg_query/include/{plerrcodes.h → postgres/plerrcodes.h} +9 -1
  243. data/ext/pg_query/include/{plpgsql.h → postgres/plpgsql.h} +79 -86
  244. data/ext/pg_query/include/{port → postgres/port}/atomics/arch-arm.h +9 -3
  245. data/ext/pg_query/include/postgres/port/atomics/arch-hppa.h +17 -0
  246. data/ext/pg_query/include/{port → postgres/port}/atomics/arch-ppc.h +21 -21
  247. data/ext/pg_query/include/{port → postgres/port}/atomics/arch-x86.h +2 -2
  248. data/ext/pg_query/include/{port → postgres/port}/atomics/fallback.h +3 -3
  249. data/ext/pg_query/include/{port → postgres/port}/atomics/generic-gcc.h +3 -3
  250. data/ext/pg_query/include/postgres/port/atomics/generic-msvc.h +101 -0
  251. data/ext/pg_query/include/postgres/port/atomics/generic-sunpro.h +106 -0
  252. data/ext/pg_query/include/{port → postgres/port}/atomics/generic.h +1 -1
  253. data/ext/pg_query/include/{port → postgres/port}/atomics.h +2 -7
  254. data/ext/pg_query/include/{port → postgres/port}/pg_bitutils.h +129 -16
  255. data/ext/pg_query/include/{port → postgres/port}/pg_bswap.h +1 -1
  256. data/ext/pg_query/include/{port → postgres/port}/pg_crc32c.h +1 -1
  257. data/ext/pg_query/include/postgres/port/simd.h +375 -0
  258. data/ext/pg_query/include/postgres/port/win32/arpa/inet.h +3 -0
  259. data/ext/pg_query/include/postgres/port/win32/dlfcn.h +1 -0
  260. data/ext/pg_query/include/postgres/port/win32/grp.h +1 -0
  261. data/ext/pg_query/include/postgres/port/win32/netdb.h +7 -0
  262. data/ext/pg_query/include/postgres/port/win32/netinet/in.h +3 -0
  263. data/ext/pg_query/include/postgres/port/win32/netinet/tcp.h +7 -0
  264. data/ext/pg_query/include/postgres/port/win32/pwd.h +3 -0
  265. data/ext/pg_query/include/postgres/port/win32/sys/resource.h +20 -0
  266. data/ext/pg_query/include/postgres/port/win32/sys/select.h +3 -0
  267. data/ext/pg_query/include/postgres/port/win32/sys/socket.h +26 -0
  268. data/ext/pg_query/include/postgres/port/win32/sys/un.h +17 -0
  269. data/ext/pg_query/include/postgres/port/win32/sys/wait.h +3 -0
  270. data/ext/pg_query/include/postgres/port/win32.h +59 -0
  271. data/ext/pg_query/include/postgres/port/win32_msvc/dirent.h +34 -0
  272. data/ext/pg_query/include/postgres/port/win32_msvc/sys/file.h +1 -0
  273. data/ext/pg_query/include/postgres/port/win32_msvc/sys/param.h +1 -0
  274. data/ext/pg_query/include/postgres/port/win32_msvc/sys/time.h +1 -0
  275. data/ext/pg_query/include/postgres/port/win32_msvc/unistd.h +9 -0
  276. data/ext/pg_query/include/postgres/port/win32_msvc/utime.h +3 -0
  277. data/ext/pg_query/include/postgres/port/win32_port.h +594 -0
  278. data/ext/pg_query/include/{port.h → postgres/port.h} +107 -111
  279. data/ext/pg_query/include/postgres/portability/instr_time.h +197 -0
  280. data/ext/pg_query/include/postgres/postgres.h +579 -0
  281. data/ext/pg_query/include/{postgres_ext.h → postgres/postgres_ext.h} +0 -1
  282. data/ext/pg_query/include/{postmaster → postgres/postmaster}/autovacuum.h +17 -20
  283. data/ext/pg_query/include/{postmaster → postgres/postmaster}/bgworker.h +3 -2
  284. data/ext/pg_query/include/{postmaster → postgres/postmaster}/bgworker_internals.h +2 -2
  285. data/ext/pg_query/include/{postmaster → postgres/postmaster}/bgwriter.h +6 -6
  286. data/ext/pg_query/include/{postmaster → postgres/postmaster}/interrupt.h +1 -1
  287. data/ext/pg_query/include/{postmaster → postgres/postmaster}/pgarch.h +7 -10
  288. data/ext/pg_query/include/{postmaster → postgres/postmaster}/postmaster.h +21 -17
  289. data/ext/pg_query/include/postgres/postmaster/startup.h +41 -0
  290. data/ext/pg_query/include/{postmaster → postgres/postmaster}/syslogger.h +16 -11
  291. data/ext/pg_query/include/{postmaster → postgres/postmaster}/walwriter.h +5 -3
  292. data/ext/pg_query/include/{regex → postgres/regex}/regex.h +27 -22
  293. data/ext/pg_query/include/{replication → postgres/replication}/logicallauncher.h +8 -5
  294. data/ext/pg_query/include/postgres/replication/logicalproto.h +274 -0
  295. data/ext/pg_query/include/postgres/replication/logicalworker.h +32 -0
  296. data/ext/pg_query/include/{replication → postgres/replication}/origin.h +8 -8
  297. data/ext/pg_query/include/postgres/replication/reorderbuffer.h +753 -0
  298. data/ext/pg_query/include/{replication → postgres/replication}/slot.h +42 -12
  299. data/ext/pg_query/include/{replication → postgres/replication}/syncrep.h +6 -12
  300. data/ext/pg_query/include/{replication → postgres/replication}/walreceiver.h +158 -20
  301. data/ext/pg_query/include/{replication → postgres/replication}/walsender.h +20 -20
  302. data/ext/pg_query/include/{rewrite → postgres/rewrite}/prs2lock.h +1 -1
  303. data/ext/pg_query/include/{rewrite → postgres/rewrite}/rewriteHandler.h +1 -6
  304. data/ext/pg_query/include/{rewrite → postgres/rewrite}/rewriteManip.h +11 -2
  305. data/ext/pg_query/include/{rewrite → postgres/rewrite}/rewriteSupport.h +1 -1
  306. data/ext/pg_query/include/{storage → postgres/storage}/backendid.h +3 -3
  307. data/ext/pg_query/include/{storage → postgres/storage}/block.h +24 -37
  308. data/ext/pg_query/include/{storage → postgres/storage}/buf.h +1 -1
  309. data/ext/pg_query/include/{storage → postgres/storage}/bufmgr.h +196 -95
  310. data/ext/pg_query/include/{storage → postgres/storage}/bufpage.h +152 -101
  311. data/ext/pg_query/include/{storage → postgres/storage}/condition_variable.h +14 -3
  312. data/ext/pg_query/include/{storage → postgres/storage}/dsm.h +6 -6
  313. data/ext/pg_query/include/{storage → postgres/storage}/dsm_impl.h +6 -2
  314. data/ext/pg_query/include/{storage → postgres/storage}/fd.h +48 -14
  315. data/ext/pg_query/include/postgres/storage/fileset.h +40 -0
  316. data/ext/pg_query/include/{storage → postgres/storage}/ipc.h +5 -2
  317. data/ext/pg_query/include/{storage → postgres/storage}/item.h +1 -1
  318. data/ext/pg_query/include/{storage → postgres/storage}/itemid.h +1 -1
  319. data/ext/pg_query/include/{storage → postgres/storage}/itemptr.h +96 -57
  320. data/ext/pg_query/include/{storage → postgres/storage}/large_object.h +2 -2
  321. data/ext/pg_query/include/{storage → postgres/storage}/latch.h +17 -13
  322. data/ext/pg_query/include/{storage → postgres/storage}/lmgr.h +7 -1
  323. data/ext/pg_query/include/{storage → postgres/storage}/lock.h +37 -25
  324. data/ext/pg_query/include/{storage → postgres/storage}/lockdefs.h +4 -4
  325. data/ext/pg_query/include/{storage → postgres/storage}/lwlock.h +21 -33
  326. data/ext/pg_query/include/{storage → postgres/storage}/lwlocknames.h +0 -1
  327. data/ext/pg_query/include/{storage → postgres/storage}/off.h +1 -1
  328. data/ext/pg_query/include/{storage → postgres/storage}/pg_sema.h +1 -1
  329. data/ext/pg_query/include/{storage → postgres/storage}/pg_shmem.h +9 -7
  330. data/ext/pg_query/include/{storage → postgres/storage}/pmsignal.h +15 -4
  331. data/ext/pg_query/include/{storage → postgres/storage}/predicate.h +5 -5
  332. data/ext/pg_query/include/{storage → postgres/storage}/proc.h +200 -67
  333. data/ext/pg_query/include/postgres/storage/procarray.h +99 -0
  334. data/ext/pg_query/include/{storage → postgres/storage}/proclist_types.h +1 -1
  335. data/ext/pg_query/include/{storage → postgres/storage}/procsignal.h +5 -7
  336. data/ext/pg_query/include/postgres/storage/relfilelocator.h +99 -0
  337. data/ext/pg_query/include/{storage → postgres/storage}/s_lock.h +118 -298
  338. data/ext/pg_query/include/{storage → postgres/storage}/sharedfileset.h +3 -11
  339. data/ext/pg_query/include/{storage → postgres/storage}/shm_mq.h +5 -4
  340. data/ext/pg_query/include/{storage → postgres/storage}/shm_toc.h +1 -1
  341. data/ext/pg_query/include/{storage → postgres/storage}/shmem.h +1 -23
  342. data/ext/pg_query/include/{storage → postgres/storage}/sinval.h +5 -5
  343. data/ext/pg_query/include/{storage → postgres/storage}/sinvaladt.h +4 -2
  344. data/ext/pg_query/include/{storage → postgres/storage}/smgr.h +21 -17
  345. data/ext/pg_query/include/{storage → postgres/storage}/spin.h +2 -2
  346. data/ext/pg_query/include/{storage → postgres/storage}/standby.h +17 -9
  347. data/ext/pg_query/include/{storage → postgres/storage}/standbydefs.h +2 -2
  348. data/ext/pg_query/include/{storage → postgres/storage}/sync.h +9 -5
  349. data/ext/pg_query/include/{tcop → postgres/tcop}/cmdtag.h +7 -2
  350. data/ext/pg_query/include/{tcop → postgres/tcop}/cmdtaglist.h +3 -2
  351. data/ext/pg_query/include/{tcop → postgres/tcop}/deparse_utility.h +1 -1
  352. data/ext/pg_query/include/{tcop → postgres/tcop}/dest.h +1 -3
  353. data/ext/pg_query/include/{tcop → postgres/tcop}/fastpath.h +1 -2
  354. data/ext/pg_query/include/{tcop → postgres/tcop}/pquery.h +7 -1
  355. data/ext/pg_query/include/{tcop → postgres/tcop}/tcopprot.h +19 -14
  356. data/ext/pg_query/include/{tcop → postgres/tcop}/utility.h +7 -3
  357. data/ext/pg_query/include/{tsearch → postgres/tsearch}/ts_cache.h +3 -5
  358. data/ext/pg_query/include/{utils → postgres/utils}/acl.h +37 -71
  359. data/ext/pg_query/include/{utils → postgres/utils}/aclchk_internal.h +1 -1
  360. data/ext/pg_query/include/{utils → postgres/utils}/array.h +26 -2
  361. data/ext/pg_query/include/postgres/utils/backend_progress.h +45 -0
  362. data/ext/pg_query/include/postgres/utils/backend_status.h +342 -0
  363. data/ext/pg_query/include/{utils → postgres/utils}/builtins.h +20 -11
  364. data/ext/pg_query/include/{utils → postgres/utils}/bytea.h +3 -2
  365. data/ext/pg_query/include/{utils → postgres/utils}/catcache.h +1 -1
  366. data/ext/pg_query/include/{utils → postgres/utils}/date.h +37 -9
  367. data/ext/pg_query/include/{utils → postgres/utils}/datetime.h +48 -27
  368. data/ext/pg_query/include/{utils → postgres/utils}/datum.h +9 -1
  369. data/ext/pg_query/include/{utils → postgres/utils}/dsa.h +5 -1
  370. data/ext/pg_query/include/{utils → postgres/utils}/elog.h +154 -48
  371. data/ext/pg_query/include/{utils → postgres/utils}/errcodes.h +2 -0
  372. data/ext/pg_query/include/{utils → postgres/utils}/expandeddatum.h +14 -3
  373. data/ext/pg_query/include/{utils → postgres/utils}/expandedrecord.h +14 -4
  374. data/ext/pg_query/include/{utils → postgres/utils}/float.h +13 -12
  375. data/ext/pg_query/include/{utils → postgres/utils}/fmgroids.h +1353 -696
  376. data/ext/pg_query/include/{utils → postgres/utils}/fmgrprotos.h +243 -18
  377. data/ext/pg_query/include/{utils → postgres/utils}/fmgrtab.h +6 -5
  378. data/ext/pg_query/include/{utils → postgres/utils}/guc.h +120 -121
  379. data/ext/pg_query/include/postgres/utils/guc_hooks.h +163 -0
  380. data/ext/pg_query/include/{utils → postgres/utils}/guc_tables.h +71 -21
  381. data/ext/pg_query/include/{utils → postgres/utils}/hsearch.h +15 -11
  382. data/ext/pg_query/include/{utils → postgres/utils}/inval.h +7 -3
  383. data/ext/pg_query/include/postgres/utils/logtape.h +77 -0
  384. data/ext/pg_query/include/{utils → postgres/utils}/lsyscache.h +16 -1
  385. data/ext/pg_query/include/{utils → postgres/utils}/memdebug.h +1 -1
  386. data/ext/pg_query/include/{utils → postgres/utils}/memutils.h +14 -53
  387. data/ext/pg_query/include/postgres/utils/memutils_internal.h +136 -0
  388. data/ext/pg_query/include/postgres/utils/memutils_memorychunk.h +237 -0
  389. data/ext/pg_query/include/{utils → postgres/utils}/numeric.h +38 -9
  390. data/ext/pg_query/include/{utils → postgres/utils}/palloc.h +33 -4
  391. data/ext/pg_query/include/{utils → postgres/utils}/partcache.h +3 -2
  392. data/ext/pg_query/include/{utils → postgres/utils}/pg_locale.h +37 -21
  393. data/ext/pg_query/include/postgres/utils/pgstat_internal.h +814 -0
  394. data/ext/pg_query/include/{utils → postgres/utils}/plancache.h +6 -5
  395. data/ext/pg_query/include/{utils → postgres/utils}/portal.h +12 -1
  396. data/ext/pg_query/include/{utils → postgres/utils}/probes.h +59 -59
  397. data/ext/pg_query/include/postgres/utils/ps_status.h +47 -0
  398. data/ext/pg_query/include/{utils → postgres/utils}/queryenvironment.h +1 -1
  399. data/ext/pg_query/include/postgres/utils/regproc.h +39 -0
  400. data/ext/pg_query/include/{utils → postgres/utils}/rel.h +129 -61
  401. data/ext/pg_query/include/{utils → postgres/utils}/relcache.h +21 -14
  402. data/ext/pg_query/include/{utils → postgres/utils}/reltrigger.h +1 -1
  403. data/ext/pg_query/include/{utils → postgres/utils}/resowner.h +1 -1
  404. data/ext/pg_query/include/{utils → postgres/utils}/ruleutils.h +9 -1
  405. data/ext/pg_query/include/{utils → postgres/utils}/sharedtuplestore.h +1 -1
  406. data/ext/pg_query/include/{utils → postgres/utils}/snapmgr.h +38 -15
  407. data/ext/pg_query/include/{utils → postgres/utils}/snapshot.h +14 -1
  408. data/ext/pg_query/include/{utils → postgres/utils}/sortsupport.h +117 -2
  409. data/ext/pg_query/include/{utils → postgres/utils}/syscache.h +9 -1
  410. data/ext/pg_query/include/{utils → postgres/utils}/timeout.h +11 -4
  411. data/ext/pg_query/include/{utils → postgres/utils}/timestamp.h +46 -15
  412. data/ext/pg_query/include/{utils → postgres/utils}/tuplesort.h +209 -41
  413. data/ext/pg_query/include/{utils → postgres/utils}/tuplestore.h +2 -2
  414. data/ext/pg_query/include/{utils → postgres/utils}/typcache.h +24 -17
  415. data/ext/pg_query/include/{utils → postgres/utils}/varlena.h +17 -3
  416. data/ext/pg_query/include/postgres/utils/wait_event.h +294 -0
  417. data/ext/pg_query/include/{utils → postgres/utils}/xml.h +18 -8
  418. data/ext/pg_query/include/{postgres.h → postgres/varatt.h} +65 -471
  419. data/ext/pg_query/include/protobuf/pg_query.pb-c.h +7494 -6382
  420. data/ext/pg_query/include/protobuf/pg_query.pb.h +116922 -84792
  421. data/ext/pg_query/include/protobuf-c/protobuf-c.h +7 -3
  422. data/ext/pg_query/include/protobuf-c.h +7 -3
  423. data/ext/pg_query/pg_query.c +10 -1
  424. data/ext/pg_query/pg_query.pb-c.c +21026 -17002
  425. data/ext/pg_query/pg_query_deparse.c +1 -9896
  426. data/ext/pg_query/pg_query_fingerprint.c +162 -50
  427. data/ext/pg_query/pg_query_fingerprint.h +3 -1
  428. data/ext/pg_query/pg_query_internal.h +1 -1
  429. data/ext/pg_query/pg_query_json_plpgsql.c +56 -12
  430. data/ext/pg_query/pg_query_normalize.c +259 -64
  431. data/ext/pg_query/pg_query_outfuncs.h +1 -0
  432. data/ext/pg_query/pg_query_outfuncs_json.c +71 -16
  433. data/ext/pg_query/pg_query_outfuncs_protobuf.c +73 -12
  434. data/ext/pg_query/pg_query_parse.c +47 -5
  435. data/ext/pg_query/pg_query_parse_plpgsql.c +86 -21
  436. data/ext/pg_query/pg_query_readfuncs_protobuf.c +43 -8
  437. data/ext/pg_query/pg_query_ruby.c +6 -1
  438. data/ext/pg_query/pg_query_ruby_freebsd.sym +2 -0
  439. data/ext/pg_query/pg_query_scan.c +3 -2
  440. data/ext/pg_query/pg_query_split.c +6 -5
  441. data/ext/pg_query/postgres_deparse.c +11067 -0
  442. data/ext/pg_query/postgres_deparse.h +9 -0
  443. data/ext/pg_query/protobuf-c.c +34 -27
  444. data/ext/pg_query/src_backend_catalog_namespace.c +27 -10
  445. data/ext/pg_query/src_backend_catalog_pg_proc.c +4 -1
  446. data/ext/pg_query/src_backend_commands_define.c +11 -1
  447. data/ext/pg_query/src_backend_nodes_bitmapset.c +13 -70
  448. data/ext/pg_query/src_backend_nodes_copyfuncs.c +103 -5894
  449. data/ext/pg_query/src_backend_nodes_equalfuncs.c +102 -3830
  450. data/ext/pg_query/src_backend_nodes_extensible.c +6 -29
  451. data/ext/pg_query/src_backend_nodes_list.c +99 -12
  452. data/ext/pg_query/src_backend_nodes_makefuncs.c +99 -4
  453. data/ext/pg_query/src_backend_nodes_nodeFuncs.c +325 -131
  454. data/ext/pg_query/src_backend_nodes_nodes.c +38 -0
  455. data/ext/pg_query/src_backend_nodes_value.c +28 -19
  456. data/ext/pg_query/src_backend_parser_gram.c +36104 -32074
  457. data/ext/pg_query/src_backend_parser_parser.c +53 -8
  458. data/ext/pg_query/src_backend_parser_scan.c +4893 -3701
  459. data/ext/pg_query/src_backend_parser_scansup.c +4 -28
  460. data/ext/pg_query/src_backend_storage_ipc_ipc.c +13 -4
  461. data/ext/pg_query/src_backend_tcop_postgres.c +133 -105
  462. data/ext/pg_query/src_backend_utils_activity_pgstat_database.c +140 -0
  463. data/ext/pg_query/src_backend_utils_adt_datum.c +17 -7
  464. data/ext/pg_query/src_backend_utils_adt_expandeddatum.c +1 -1
  465. data/ext/pg_query/src_backend_utils_adt_format_type.c +6 -2
  466. data/ext/pg_query/src_backend_utils_adt_numutils.c +489 -0
  467. data/ext/pg_query/src_backend_utils_adt_ruleutils.c +187 -19
  468. data/ext/pg_query/src_backend_utils_error_assert.c +17 -18
  469. data/ext/pg_query/src_backend_utils_error_elog.c +513 -318
  470. data/ext/pg_query/src_backend_utils_fmgr_fmgr.c +44 -17
  471. data/ext/pg_query/src_backend_utils_init_globals.c +9 -6
  472. data/ext/pg_query/src_backend_utils_mb_mbutils.c +74 -131
  473. data/ext/pg_query/src_backend_utils_misc_guc_tables.c +492 -0
  474. data/ext/pg_query/src_backend_utils_mmgr_alignedalloc.c +163 -0
  475. data/ext/pg_query/src_backend_utils_mmgr_aset.c +453 -314
  476. data/ext/pg_query/src_backend_utils_mmgr_generation.c +1039 -0
  477. data/ext/pg_query/src_backend_utils_mmgr_mcxt.c +549 -76
  478. data/ext/pg_query/src_backend_utils_mmgr_slab.c +1021 -0
  479. data/ext/pg_query/src_common_encnames.c +4 -1
  480. data/ext/pg_query/src_common_hashfn.c +420 -0
  481. data/ext/pg_query/src_common_keywords.c +15 -2
  482. data/ext/pg_query/src_common_kwlist_d.h +545 -498
  483. data/ext/pg_query/src_common_kwlookup.c +1 -1
  484. data/ext/pg_query/src_common_psprintf.c +1 -1
  485. data/ext/pg_query/src_common_stringinfo.c +4 -4
  486. data/ext/pg_query/src_common_wchar.c +717 -113
  487. data/ext/pg_query/src_pl_plpgsql_src_pl_comp.c +49 -22
  488. data/ext/pg_query/src_pl_plpgsql_src_pl_funcs.c +3 -18
  489. data/ext/pg_query/src_pl_plpgsql_src_pl_gram.c +1136 -1195
  490. data/ext/pg_query/src_pl_plpgsql_src_pl_handler.c +1 -1
  491. data/ext/pg_query/src_pl_plpgsql_src_pl_reserved_kwlist_d.h +10 -10
  492. data/ext/pg_query/src_pl_plpgsql_src_pl_scanner.c +2 -2
  493. data/ext/pg_query/src_pl_plpgsql_src_pl_unreserved_kwlist_d.h +60 -60
  494. data/ext/pg_query/src_port_pg_bitutils.c +103 -40
  495. data/ext/pg_query/src_port_pgstrcasecmp.c +29 -1
  496. data/ext/pg_query/src_port_qsort.c +12 -224
  497. data/ext/pg_query/src_port_snprintf.c +51 -29
  498. data/ext/pg_query/src_port_strerror.c +9 -19
  499. data/ext/pg_query/src_port_strlcpy.c +79 -0
  500. data/lib/pg_query/deparse.rb +7 -1
  501. data/lib/pg_query/filter_columns.rb +7 -5
  502. data/lib/pg_query/fingerprint.rb +21 -9
  503. data/lib/pg_query/node.rb +18 -13
  504. data/lib/pg_query/param_refs.rb +1 -1
  505. data/lib/pg_query/parse.rb +141 -50
  506. data/lib/pg_query/pg_query_pb.rb +175 -3031
  507. data/lib/pg_query/treewalker.rb +26 -2
  508. data/lib/pg_query/truncate.rb +54 -8
  509. data/lib/pg_query/version.rb +1 -1
  510. data/lib/pg_query.rb +0 -1
  511. metadata +443 -380
  512. data/ext/pg_query/guc-file.c +0 -0
  513. data/ext/pg_query/include/access/rmgr.h +0 -35
  514. data/ext/pg_query/include/access/xloginsert.h +0 -64
  515. data/ext/pg_query/include/bootstrap/bootstrap.h +0 -62
  516. data/ext/pg_query/include/catalog/genbki.h +0 -64
  517. data/ext/pg_query/include/catalog/indexing.h +0 -366
  518. data/ext/pg_query/include/commands/variable.h +0 -38
  519. data/ext/pg_query/include/common/ip.h +0 -37
  520. data/ext/pg_query/include/common/string.h +0 -19
  521. data/ext/pg_query/include/getaddrinfo.h +0 -162
  522. data/ext/pg_query/include/kwlist_d.h +0 -1072
  523. data/ext/pg_query/include/nodes/value.h +0 -61
  524. data/ext/pg_query/include/parser/gram.h +0 -1067
  525. data/ext/pg_query/include/parser/kwlist.h +0 -477
  526. data/ext/pg_query/include/parser/parse_clause.h +0 -54
  527. data/ext/pg_query/include/parser/parse_collate.h +0 -27
  528. data/ext/pg_query/include/parser/parse_target.h +0 -46
  529. data/ext/pg_query/include/parser/parser.h +0 -41
  530. data/ext/pg_query/include/pg_config_os.h +0 -8
  531. data/ext/pg_query/include/pgstat.h +0 -1487
  532. data/ext/pg_query/include/portability/instr_time.h +0 -256
  533. data/ext/pg_query/include/postmaster/fork_process.h +0 -17
  534. data/ext/pg_query/include/replication/logicalproto.h +0 -110
  535. data/ext/pg_query/include/replication/logicalworker.h +0 -19
  536. data/ext/pg_query/include/replication/reorderbuffer.h +0 -467
  537. data/ext/pg_query/include/storage/relfilenode.h +0 -99
  538. data/ext/pg_query/include/utils/dynahash.h +0 -19
  539. data/ext/pg_query/include/utils/pg_lsn.h +0 -29
  540. data/ext/pg_query/include/utils/pidfile.h +0 -56
  541. data/ext/pg_query/include/utils/ps_status.h +0 -25
  542. data/ext/pg_query/include/utils/regproc.h +0 -28
  543. data/ext/pg_query/include/utils/rls.h +0 -50
  544. data/ext/pg_query/include/utils/tzparser.h +0 -39
  545. data/ext/pg_query/src_backend_libpq_pqcomm.c +0 -651
  546. data/ext/pg_query/src_backend_parser_parse_expr.c +0 -313
  547. data/ext/pg_query/src_backend_postmaster_postmaster.c +0 -2230
  548. data/ext/pg_query/src_backend_storage_lmgr_s_lock.c +0 -370
  549. data/ext/pg_query/src_backend_utils_hash_dynahash.c +0 -1086
  550. data/ext/pg_query/src_backend_utils_misc_guc.c +0 -1831
  551. data/ext/pg_query/src_common_string.c +0 -86
  552. data/ext/pg_query/src_port_erand48.c +0 -127
  553. data/ext/pg_query/src_port_pgsleep.c +0 -69
  554. data/ext/pg_query/src_port_random.c +0 -31
  555. data/ext/pg_query/src_port_strnlen.c +0 -39
  556. data/lib/pg_query/json_field_names.rb +0 -1402
  557. /data/ext/pg_query/include/{pg_config_ext.h → postgres/pg_config_ext.h} +0 -0
@@ -0,0 +1,432 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * sort_template.h
4
+ *
5
+ * A template for a sort algorithm that supports varying degrees of
6
+ * specialization.
7
+ *
8
+ * Copyright (c) 2021-2023, PostgreSQL Global Development Group
9
+ * Portions Copyright (c) 1992-1994, Regents of the University of California
10
+ *
11
+ * Usage notes:
12
+ *
13
+ * To generate functions specialized for a type, the following parameter
14
+ * macros should be #define'd before this file is included.
15
+ *
16
+ * - ST_SORT - the name of a sort function to be generated
17
+ * - ST_ELEMENT_TYPE - type of the referenced elements
18
+ * - ST_DECLARE - if defined the functions and types are declared
19
+ * - ST_DEFINE - if defined the functions and types are defined
20
+ * - ST_SCOPE - scope (e.g. extern, static inline) for functions
21
+ * - ST_CHECK_FOR_INTERRUPTS - if defined the sort is interruptible
22
+ *
23
+ * Instead of ST_ELEMENT_TYPE, ST_ELEMENT_TYPE_VOID can be defined. Then
24
+ * the generated functions will automatically gain an "element_size"
25
+ * parameter. This allows us to generate a traditional qsort function.
26
+ *
27
+ * One of the following macros must be defined, to show how to compare
28
+ * elements. The first two options are arbitrary expressions depending
29
+ * on whether an extra pass-through argument is desired, and the third
30
+ * option should be defined if the sort function should receive a
31
+ * function pointer at runtime.
32
+ *
33
+ * - ST_COMPARE(a, b) - a simple comparison expression
34
+ * - ST_COMPARE(a, b, arg) - variant that takes an extra argument
35
+ * - ST_COMPARE_RUNTIME_POINTER - sort function takes a function pointer
36
+ *
37
+ * To say that the comparator and therefore also sort function should
38
+ * receive an extra pass-through argument, specify the type of the
39
+ * argument.
40
+ *
41
+ * - ST_COMPARE_ARG_TYPE - type of extra argument
42
+ *
43
+ * The prototype of the generated sort function is:
44
+ *
45
+ * void ST_SORT(ST_ELEMENT_TYPE *data, size_t n,
46
+ * [size_t element_size,]
47
+ * [ST_SORT_compare_function compare,]
48
+ * [ST_COMPARE_ARG_TYPE *arg]);
49
+ *
50
+ * ST_SORT_compare_function is a function pointer of the following type:
51
+ *
52
+ * int (*)(const ST_ELEMENT_TYPE *a, const ST_ELEMENT_TYPE *b,
53
+ * [ST_COMPARE_ARG_TYPE *arg])
54
+ *
55
+ * HISTORY
56
+ *
57
+ * Modifications from vanilla NetBSD source:
58
+ * - Add do ... while() macro fix
59
+ * - Remove __inline, _DIAGASSERTs, __P
60
+ * - Remove ill-considered "swap_cnt" switch to insertion sort, in favor
61
+ * of a simple check for presorted input.
62
+ * - Take care to recurse on the smaller partition, to bound stack usage
63
+ * - Convert into a header that can generate specialized functions
64
+ *
65
+ * IDENTIFICATION
66
+ * src/include/lib/sort_template.h
67
+ *
68
+ *-------------------------------------------------------------------------
69
+ */
70
+
71
+ /* $NetBSD: qsort.c,v 1.13 2003/08/07 16:43:42 agc Exp $ */
72
+
73
+ /*-
74
+ * Copyright (c) 1992, 1993
75
+ * The Regents of the University of California. All rights reserved.
76
+ *
77
+ * Redistribution and use in source and binary forms, with or without
78
+ * modification, are permitted provided that the following conditions
79
+ * are met:
80
+ * 1. Redistributions of source code must retain the above copyright
81
+ * notice, this list of conditions and the following disclaimer.
82
+ * 2. Redistributions in binary form must reproduce the above copyright
83
+ * notice, this list of conditions and the following disclaimer in the
84
+ * documentation and/or other materials provided with the distribution.
85
+ * 3. Neither the name of the University nor the names of its contributors
86
+ * may be used to endorse or promote products derived from this software
87
+ * without specific prior written permission.
88
+ *
89
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
90
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
91
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
92
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
93
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
94
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
95
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
96
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
97
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
98
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
99
+ * SUCH DAMAGE.
100
+ */
101
+
102
+ /*
103
+ * Qsort routine based on J. L. Bentley and M. D. McIlroy,
104
+ * "Engineering a sort function",
105
+ * Software--Practice and Experience 23 (1993) 1249-1265.
106
+ *
107
+ * We have modified their original by adding a check for already-sorted
108
+ * input, which seems to be a win per discussions on pgsql-hackers around
109
+ * 2006-03-21.
110
+ *
111
+ * Also, we recurse on the smaller partition and iterate on the larger one,
112
+ * which ensures we cannot recurse more than log(N) levels (since the
113
+ * partition recursed to is surely no more than half of the input). Bentley
114
+ * and McIlroy explicitly rejected doing this on the grounds that it's "not
115
+ * worth the effort", but we have seen crashes in the field due to stack
116
+ * overrun, so that judgment seems wrong.
117
+ */
118
+
119
+ #define ST_MAKE_PREFIX(a) CppConcat(a,_)
120
+ #define ST_MAKE_NAME(a,b) ST_MAKE_NAME_(ST_MAKE_PREFIX(a),b)
121
+ #define ST_MAKE_NAME_(a,b) CppConcat(a,b)
122
+
123
+ /*
124
+ * If the element type is void, we'll also need an element_size argument
125
+ * because we don't know the size.
126
+ */
127
+ #ifdef ST_ELEMENT_TYPE_VOID
128
+ #define ST_ELEMENT_TYPE void
129
+ #define ST_SORT_PROTO_ELEMENT_SIZE , size_t element_size
130
+ #define ST_SORT_INVOKE_ELEMENT_SIZE , element_size
131
+ #else
132
+ #define ST_SORT_PROTO_ELEMENT_SIZE
133
+ #define ST_SORT_INVOKE_ELEMENT_SIZE
134
+ #endif
135
+
136
+ /*
137
+ * If the user wants to be able to pass in compare functions at runtime,
138
+ * we'll need to make that an argument of the sort and med3 functions.
139
+ */
140
+ #ifdef ST_COMPARE_RUNTIME_POINTER
141
+ /*
142
+ * The type of the comparator function pointer that ST_SORT will take, unless
143
+ * you've already declared a type name manually and want to use that instead of
144
+ * having a new one defined.
145
+ */
146
+ #ifndef ST_COMPARATOR_TYPE_NAME
147
+ #define ST_COMPARATOR_TYPE_NAME ST_MAKE_NAME(ST_SORT, compare_function)
148
+ #endif
149
+ #define ST_COMPARE compare
150
+ #ifndef ST_COMPARE_ARG_TYPE
151
+ #define ST_SORT_PROTO_COMPARE , ST_COMPARATOR_TYPE_NAME compare
152
+ #define ST_SORT_INVOKE_COMPARE , compare
153
+ #else
154
+ #define ST_SORT_PROTO_COMPARE , ST_COMPARATOR_TYPE_NAME compare
155
+ #define ST_SORT_INVOKE_COMPARE , compare
156
+ #endif
157
+ #else
158
+ #define ST_SORT_PROTO_COMPARE
159
+ #define ST_SORT_INVOKE_COMPARE
160
+ #endif
161
+
162
+ /*
163
+ * If the user wants to use a compare function or expression that takes an
164
+ * extra argument, we'll need to make that an argument of the sort, compare and
165
+ * med3 functions.
166
+ */
167
+ #ifdef ST_COMPARE_ARG_TYPE
168
+ #define ST_SORT_PROTO_ARG , ST_COMPARE_ARG_TYPE *arg
169
+ #define ST_SORT_INVOKE_ARG , arg
170
+ #else
171
+ #define ST_SORT_PROTO_ARG
172
+ #define ST_SORT_INVOKE_ARG
173
+ #endif
174
+
175
+ #ifdef ST_DECLARE
176
+
177
+ #ifdef ST_COMPARE_RUNTIME_POINTER
178
+ typedef int (*ST_COMPARATOR_TYPE_NAME) (const ST_ELEMENT_TYPE *,
179
+ const ST_ELEMENT_TYPE * ST_SORT_PROTO_ARG);
180
+ #endif
181
+
182
+ /* Declare the sort function. Note optional arguments at end. */
183
+ ST_SCOPE void ST_SORT(ST_ELEMENT_TYPE * first, size_t n
184
+ ST_SORT_PROTO_ELEMENT_SIZE
185
+ ST_SORT_PROTO_COMPARE
186
+ ST_SORT_PROTO_ARG);
187
+
188
+ #endif
189
+
190
+ #ifdef ST_DEFINE
191
+
192
+ /* sort private helper functions */
193
+ #define ST_MED3 ST_MAKE_NAME(ST_SORT, med3)
194
+ #define ST_SWAP ST_MAKE_NAME(ST_SORT, swap)
195
+ #define ST_SWAPN ST_MAKE_NAME(ST_SORT, swapn)
196
+
197
+ /* Users expecting to run very large sorts may need them to be interruptible. */
198
+ #ifdef ST_CHECK_FOR_INTERRUPTS
199
+ #define DO_CHECK_FOR_INTERRUPTS() CHECK_FOR_INTERRUPTS()
200
+ #else
201
+ #define DO_CHECK_FOR_INTERRUPTS()
202
+ #endif
203
+
204
+ /*
205
+ * Create wrapper macros that know how to invoke compare, med3 and sort with
206
+ * the right arguments.
207
+ */
208
+ #ifdef ST_COMPARE_RUNTIME_POINTER
209
+ #define DO_COMPARE(a_, b_) ST_COMPARE((a_), (b_) ST_SORT_INVOKE_ARG)
210
+ #elif defined(ST_COMPARE_ARG_TYPE)
211
+ #define DO_COMPARE(a_, b_) ST_COMPARE((a_), (b_), arg)
212
+ #else
213
+ #define DO_COMPARE(a_, b_) ST_COMPARE((a_), (b_))
214
+ #endif
215
+ #define DO_MED3(a_, b_, c_) \
216
+ ST_MED3((a_), (b_), (c_) \
217
+ ST_SORT_INVOKE_COMPARE \
218
+ ST_SORT_INVOKE_ARG)
219
+ #define DO_SORT(a_, n_) \
220
+ ST_SORT((a_), (n_) \
221
+ ST_SORT_INVOKE_ELEMENT_SIZE \
222
+ ST_SORT_INVOKE_COMPARE \
223
+ ST_SORT_INVOKE_ARG)
224
+
225
+ /*
226
+ * If we're working with void pointers, we'll use pointer arithmetic based on
227
+ * uint8, and use the runtime element_size to step through the array and swap
228
+ * elements. Otherwise we'll work with ST_ELEMENT_TYPE.
229
+ */
230
+ #ifndef ST_ELEMENT_TYPE_VOID
231
+ #define ST_POINTER_TYPE ST_ELEMENT_TYPE
232
+ #define ST_POINTER_STEP 1
233
+ #define DO_SWAPN(a_, b_, n_) ST_SWAPN((a_), (b_), (n_))
234
+ #define DO_SWAP(a_, b_) ST_SWAP((a_), (b_))
235
+ #else
236
+ #define ST_POINTER_TYPE uint8
237
+ #define ST_POINTER_STEP element_size
238
+ #define DO_SWAPN(a_, b_, n_) ST_SWAPN((a_), (b_), (n_))
239
+ #define DO_SWAP(a_, b_) DO_SWAPN((a_), (b_), element_size)
240
+ #endif
241
+
242
+ /*
243
+ * Find the median of three values. Currently, performance seems to be best
244
+ * if the comparator is inlined here, but the med3 function is not inlined
245
+ * in the qsort function.
246
+ */
247
+ static pg_noinline ST_ELEMENT_TYPE *
248
+ ST_MED3(ST_ELEMENT_TYPE * a,
249
+ ST_ELEMENT_TYPE * b,
250
+ ST_ELEMENT_TYPE * c
251
+ ST_SORT_PROTO_COMPARE
252
+ ST_SORT_PROTO_ARG)
253
+ {
254
+ return DO_COMPARE(a, b) < 0 ?
255
+ (DO_COMPARE(b, c) < 0 ? b : (DO_COMPARE(a, c) < 0 ? c : a))
256
+ : (DO_COMPARE(b, c) > 0 ? b : (DO_COMPARE(a, c) < 0 ? a : c));
257
+ }
258
+
259
+ static inline void
260
+ ST_SWAP(ST_POINTER_TYPE * a, ST_POINTER_TYPE * b)
261
+ {
262
+ ST_POINTER_TYPE tmp = *a;
263
+
264
+ *a = *b;
265
+ *b = tmp;
266
+ }
267
+
268
+ static inline void
269
+ ST_SWAPN(ST_POINTER_TYPE * a, ST_POINTER_TYPE * b, size_t n)
270
+ {
271
+ for (size_t i = 0; i < n; ++i)
272
+ ST_SWAP(&a[i], &b[i]);
273
+ }
274
+
275
+ /*
276
+ * Sort an array.
277
+ */
278
+ ST_SCOPE void
279
+ ST_SORT(ST_ELEMENT_TYPE * data, size_t n
280
+ ST_SORT_PROTO_ELEMENT_SIZE
281
+ ST_SORT_PROTO_COMPARE
282
+ ST_SORT_PROTO_ARG)
283
+ {
284
+ ST_POINTER_TYPE *a = (ST_POINTER_TYPE *) data,
285
+ *pa,
286
+ *pb,
287
+ *pc,
288
+ *pd,
289
+ *pl,
290
+ *pm,
291
+ *pn;
292
+ size_t d1,
293
+ d2;
294
+ int r,
295
+ presorted;
296
+
297
+ loop:
298
+ DO_CHECK_FOR_INTERRUPTS();
299
+ if (n < 7)
300
+ {
301
+ for (pm = a + ST_POINTER_STEP; pm < a + n * ST_POINTER_STEP;
302
+ pm += ST_POINTER_STEP)
303
+ for (pl = pm; pl > a && DO_COMPARE(pl - ST_POINTER_STEP, pl) > 0;
304
+ pl -= ST_POINTER_STEP)
305
+ DO_SWAP(pl, pl - ST_POINTER_STEP);
306
+ return;
307
+ }
308
+ presorted = 1;
309
+ for (pm = a + ST_POINTER_STEP; pm < a + n * ST_POINTER_STEP;
310
+ pm += ST_POINTER_STEP)
311
+ {
312
+ DO_CHECK_FOR_INTERRUPTS();
313
+ if (DO_COMPARE(pm - ST_POINTER_STEP, pm) > 0)
314
+ {
315
+ presorted = 0;
316
+ break;
317
+ }
318
+ }
319
+ if (presorted)
320
+ return;
321
+ pm = a + (n / 2) * ST_POINTER_STEP;
322
+ if (n > 7)
323
+ {
324
+ pl = a;
325
+ pn = a + (n - 1) * ST_POINTER_STEP;
326
+ if (n > 40)
327
+ {
328
+ size_t d = (n / 8) * ST_POINTER_STEP;
329
+
330
+ pl = DO_MED3(pl, pl + d, pl + 2 * d);
331
+ pm = DO_MED3(pm - d, pm, pm + d);
332
+ pn = DO_MED3(pn - 2 * d, pn - d, pn);
333
+ }
334
+ pm = DO_MED3(pl, pm, pn);
335
+ }
336
+ DO_SWAP(a, pm);
337
+ pa = pb = a + ST_POINTER_STEP;
338
+ pc = pd = a + (n - 1) * ST_POINTER_STEP;
339
+ for (;;)
340
+ {
341
+ while (pb <= pc && (r = DO_COMPARE(pb, a)) <= 0)
342
+ {
343
+ if (r == 0)
344
+ {
345
+ DO_SWAP(pa, pb);
346
+ pa += ST_POINTER_STEP;
347
+ }
348
+ pb += ST_POINTER_STEP;
349
+ DO_CHECK_FOR_INTERRUPTS();
350
+ }
351
+ while (pb <= pc && (r = DO_COMPARE(pc, a)) >= 0)
352
+ {
353
+ if (r == 0)
354
+ {
355
+ DO_SWAP(pc, pd);
356
+ pd -= ST_POINTER_STEP;
357
+ }
358
+ pc -= ST_POINTER_STEP;
359
+ DO_CHECK_FOR_INTERRUPTS();
360
+ }
361
+ if (pb > pc)
362
+ break;
363
+ DO_SWAP(pb, pc);
364
+ pb += ST_POINTER_STEP;
365
+ pc -= ST_POINTER_STEP;
366
+ }
367
+ pn = a + n * ST_POINTER_STEP;
368
+ d1 = Min(pa - a, pb - pa);
369
+ DO_SWAPN(a, pb - d1, d1);
370
+ d1 = Min(pd - pc, pn - pd - ST_POINTER_STEP);
371
+ DO_SWAPN(pb, pn - d1, d1);
372
+ d1 = pb - pa;
373
+ d2 = pd - pc;
374
+ if (d1 <= d2)
375
+ {
376
+ /* Recurse on left partition, then iterate on right partition */
377
+ if (d1 > ST_POINTER_STEP)
378
+ DO_SORT(a, d1 / ST_POINTER_STEP);
379
+ if (d2 > ST_POINTER_STEP)
380
+ {
381
+ /* Iterate rather than recurse to save stack space */
382
+ /* DO_SORT(pn - d2, d2 / ST_POINTER_STEP) */
383
+ a = pn - d2;
384
+ n = d2 / ST_POINTER_STEP;
385
+ goto loop;
386
+ }
387
+ }
388
+ else
389
+ {
390
+ /* Recurse on right partition, then iterate on left partition */
391
+ if (d2 > ST_POINTER_STEP)
392
+ DO_SORT(pn - d2, d2 / ST_POINTER_STEP);
393
+ if (d1 > ST_POINTER_STEP)
394
+ {
395
+ /* Iterate rather than recurse to save stack space */
396
+ /* DO_SORT(a, d1 / ST_POINTER_STEP) */
397
+ n = d1 / ST_POINTER_STEP;
398
+ goto loop;
399
+ }
400
+ }
401
+ }
402
+ #endif
403
+
404
+ #undef DO_CHECK_FOR_INTERRUPTS
405
+ #undef DO_COMPARE
406
+ #undef DO_MED3
407
+ #undef DO_SORT
408
+ #undef DO_SWAP
409
+ #undef DO_SWAPN
410
+ #undef ST_CHECK_FOR_INTERRUPTS
411
+ #undef ST_COMPARATOR_TYPE_NAME
412
+ #undef ST_COMPARE
413
+ #undef ST_COMPARE_ARG_TYPE
414
+ #undef ST_COMPARE_RUNTIME_POINTER
415
+ #undef ST_ELEMENT_TYPE
416
+ #undef ST_ELEMENT_TYPE_VOID
417
+ #undef ST_MAKE_NAME
418
+ #undef ST_MAKE_NAME_
419
+ #undef ST_MAKE_PREFIX
420
+ #undef ST_MED3
421
+ #undef ST_POINTER_STEP
422
+ #undef ST_POINTER_TYPE
423
+ #undef ST_SCOPE
424
+ #undef ST_SORT
425
+ #undef ST_SORT_INVOKE_ARG
426
+ #undef ST_SORT_INVOKE_COMPARE
427
+ #undef ST_SORT_INVOKE_ELEMENT_SIZE
428
+ #undef ST_SORT_PROTO_ARG
429
+ #undef ST_SORT_PROTO_COMPARE
430
+ #undef ST_SORT_PROTO_ELEMENT_SIZE
431
+ #undef ST_SWAP
432
+ #undef ST_SWAPN
@@ -8,7 +8,7 @@
8
8
  * (null-terminated text) or arbitrary binary data. All storage is allocated
9
9
  * with palloc() (falling back to malloc in frontend code).
10
10
  *
11
- * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
11
+ * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
12
12
  * Portions Copyright (c) 1994, Regents of the University of California
13
13
  *
14
14
  * src/include/lib/stringinfo.h
@@ -142,7 +142,7 @@ extern void appendStringInfoSpaces(StringInfo str, int count);
142
142
  * if necessary.
143
143
  */
144
144
  extern void appendBinaryStringInfo(StringInfo str,
145
- const char *data, int datalen);
145
+ const void *data, int datalen);
146
146
 
147
147
  /*------------------------
148
148
  * appendBinaryStringInfoNT
@@ -150,7 +150,7 @@ extern void appendBinaryStringInfo(StringInfo str,
150
150
  * if necessary. Does not ensure a trailing null-byte exists.
151
151
  */
152
152
  extern void appendBinaryStringInfoNT(StringInfo str,
153
- const char *data, int datalen);
153
+ const void *data, int datalen);
154
154
 
155
155
  /*------------------------
156
156
  * enlargeStringInfo
@@ -4,7 +4,7 @@
4
4
  * Definitions for network authentication routines
5
5
  *
6
6
  *
7
- * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
7
+ * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
8
8
  * Portions Copyright (c) 1994, Regents of the University of California
9
9
  *
10
10
  * src/include/libpq/auth.h
@@ -16,14 +16,22 @@
16
16
 
17
17
  #include "libpq/libpq-be.h"
18
18
 
19
- extern char *pg_krb_server_keyfile;
20
- extern bool pg_krb_caseins_users;
21
- extern char *pg_krb_realm;
19
+ extern PGDLLIMPORT char *pg_krb_server_keyfile;
20
+ extern PGDLLIMPORT bool pg_krb_caseins_users;
21
+ extern PGDLLIMPORT bool pg_gss_accept_delegation;
22
22
 
23
23
  extern void ClientAuthentication(Port *port);
24
+ extern void sendAuthRequest(Port *port, AuthRequest areq, const char *extradata,
25
+ int extralen);
24
26
 
25
27
  /* Hook for plugins to get control in ClientAuthentication() */
26
28
  typedef void (*ClientAuthentication_hook_type) (Port *, int);
27
29
  extern PGDLLIMPORT ClientAuthentication_hook_type ClientAuthentication_hook;
28
30
 
31
+ /* hook type for password manglers */
32
+ typedef char *(*auth_password_hook_typ) (char *input);
33
+
34
+ /* Default LDAP password mutator hook, can be overridden by a shared library */
35
+ extern PGDLLIMPORT auth_password_hook_typ ldap_password_hook;
36
+
29
37
  #endif /* AUTH_H */
@@ -3,7 +3,7 @@
3
3
  * crypt.h
4
4
  * Interface to libpq/crypt.c
5
5
  *
6
- * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
6
+ * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
7
7
  * Portions Copyright (c) 1994, Regents of the University of California
8
8
  *
9
9
  * src/include/libpq/crypt.h
@@ -35,12 +35,13 @@ extern PasswordType get_password_type(const char *shadow_pass);
35
35
  extern char *encrypt_password(PasswordType target_type, const char *role,
36
36
  const char *password);
37
37
 
38
- extern char *get_role_password(const char *role, char **logdetail);
38
+ extern char *get_role_password(const char *role, const char **logdetail);
39
39
 
40
40
  extern int md5_crypt_verify(const char *role, const char *shadow_pass,
41
41
  const char *client_pass, const char *md5_salt,
42
- int md5_salt_len, char **logdetail);
42
+ int md5_salt_len, const char **logdetail);
43
43
  extern int plain_crypt_verify(const char *role, const char *shadow_pass,
44
- const char *client_pass, char **logdetail);
44
+ const char *client_pass,
45
+ const char **logdetail);
45
46
 
46
47
  #endif
@@ -71,19 +71,41 @@ typedef enum ClientCertMode
71
71
  clientCertFull
72
72
  } ClientCertMode;
73
73
 
74
+ typedef enum ClientCertName
75
+ {
76
+ clientCertCN,
77
+ clientCertDN
78
+ } ClientCertName;
79
+
80
+ /*
81
+ * A single string token lexed from an authentication configuration file
82
+ * (pg_ident.conf or pg_hba.conf), together with whether the token has
83
+ * been quoted. If "string" begins with a slash, it may optionally
84
+ * contain a regular expression (currently used for pg_ident.conf when
85
+ * building IdentLines and for pg_hba.conf when building HbaLines).
86
+ */
87
+ typedef struct AuthToken
88
+ {
89
+ char *string;
90
+ bool quoted;
91
+ regex_t *regex;
92
+ } AuthToken;
93
+
74
94
  typedef struct HbaLine
75
95
  {
96
+ char *sourcefile;
76
97
  int linenumber;
77
98
  char *rawline;
78
99
  ConnType conntype;
79
100
  List *databases;
80
101
  List *roles;
81
102
  struct sockaddr_storage addr;
103
+ int addrlen; /* zero if we don't have a valid addr */
82
104
  struct sockaddr_storage mask;
105
+ int masklen; /* zero if we don't have a valid mask */
83
106
  IPCompareMethod ip_cmp_method;
84
107
  char *hostname;
85
108
  UserAuth auth_method;
86
-
87
109
  char *usermap;
88
110
  char *pamservice;
89
111
  bool pam_use_hostname;
@@ -100,6 +122,7 @@ typedef struct HbaLine
100
122
  char *ldapprefix;
101
123
  char *ldapsuffix;
102
124
  ClientCertMode clientcert;
125
+ ClientCertName clientcertname;
103
126
  char *krb_realm;
104
127
  bool include_realm;
105
128
  bool compat_realm;
@@ -112,8 +135,6 @@ typedef struct HbaLine
112
135
  char *radiusidentifiers_s;
113
136
  List *radiusports;
114
137
  char *radiusports_s;
115
- int addrlen; /* zero if we don't have a valid addr */
116
- int masklen; /* zero if we don't have a valid mask */
117
138
  } HbaLine;
118
139
 
119
140
  typedef struct IdentLine
@@ -121,20 +142,45 @@ typedef struct IdentLine
121
142
  int linenumber;
122
143
 
123
144
  char *usermap;
124
- char *ident_user;
125
- char *pg_role;
126
- regex_t re;
145
+ AuthToken *system_user;
146
+ AuthToken *pg_user;
127
147
  } IdentLine;
128
148
 
149
+ /*
150
+ * TokenizedAuthLine represents one line lexed from an authentication
151
+ * configuration file. Each item in the "fields" list is a sub-list of
152
+ * AuthTokens. We don't emit a TokenizedAuthLine for empty or all-comment
153
+ * lines, so "fields" is never NIL (nor are any of its sub-lists).
154
+ *
155
+ * Exception: if an error occurs during tokenization, we might have
156
+ * fields == NIL, in which case err_msg != NULL.
157
+ */
158
+ typedef struct TokenizedAuthLine
159
+ {
160
+ List *fields; /* List of lists of AuthTokens */
161
+ char *file_name; /* File name of origin */
162
+ int line_num; /* Line number */
163
+ char *raw_line; /* Raw line text */
164
+ char *err_msg; /* Error message if any */
165
+ } TokenizedAuthLine;
166
+
129
167
  /* kluge to avoid including libpq/libpq-be.h here */
130
168
  typedef struct Port hbaPort;
131
169
 
132
170
  extern bool load_hba(void);
133
171
  extern bool load_ident(void);
172
+ extern const char *hba_authname(UserAuth auth_method);
134
173
  extern void hba_getauthmethod(hbaPort *port);
135
174
  extern int check_usermap(const char *usermap_name,
136
- const char *pg_role, const char *auth_user,
137
- bool case_sensitive);
175
+ const char *pg_user, const char *system_user,
176
+ bool case_insensitive);
177
+ extern HbaLine *parse_hba_line(TokenizedAuthLine *tok_line, int elevel);
178
+ extern IdentLine *parse_ident_line(TokenizedAuthLine *tok_line, int elevel);
138
179
  extern bool pg_isblank(const char c);
180
+ extern FILE *open_auth_file(const char *filename, int elevel, int depth,
181
+ char **err_msg);
182
+ extern void free_auth_file(FILE *file, int depth);
183
+ extern void tokenize_auth_file(const char *filename, FILE *file,
184
+ List **tok_lines, int elevel, int depth);
139
185
 
140
186
  #endif /* HBA_H */