pg_query 4.2.1 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (531) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -0
  3. data/README.md +6 -8
  4. data/Rakefile +5 -6
  5. data/ext/pg_query/extconf.rb +14 -4
  6. data/ext/pg_query/include/pg_query.h +27 -3
  7. data/ext/pg_query/include/pg_query_enum_defs.c +311 -149
  8. data/ext/pg_query/include/pg_query_fingerprint_conds.c +545 -489
  9. data/ext/pg_query/include/pg_query_fingerprint_defs.c +5092 -4432
  10. data/ext/pg_query/include/pg_query_outfuncs_conds.c +385 -343
  11. data/ext/pg_query/include/pg_query_outfuncs_defs.c +1294 -1161
  12. data/ext/pg_query/include/pg_query_readfuncs_conds.c +137 -123
  13. data/ext/pg_query/include/pg_query_readfuncs_defs.c +1657 -1496
  14. data/ext/pg_query/include/{access → postgres/access}/amapi.h +3 -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 +1 -1
  17. data/ext/pg_query/include/{access → postgres/access}/clog.h +1 -1
  18. data/ext/pg_query/include/{access → postgres/access}/commit_ts.h +1 -1
  19. data/ext/pg_query/include/{access → postgres/access}/detoast.h +1 -1
  20. data/ext/pg_query/include/{access → postgres/access}/genam.h +7 -5
  21. data/ext/pg_query/include/{access → postgres/access}/gin.h +16 -3
  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 +6 -2
  24. data/ext/pg_query/include/{access → postgres/access}/itup.h +61 -58
  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 +1 -1
  29. data/ext/pg_query/include/{access → postgres/access}/rmgrlist.h +2 -2
  30. data/ext/pg_query/include/{access → postgres/access}/sdir.h +12 -3
  31. data/ext/pg_query/include/{access → postgres/access}/skey.h +1 -1
  32. data/ext/pg_query/include/{access → postgres/access}/stratnum.h +1 -1
  33. data/ext/pg_query/include/{access → postgres/access}/sysattr.h +1 -1
  34. data/ext/pg_query/include/{access → postgres/access}/table.h +1 -1
  35. data/ext/pg_query/include/{access → postgres/access}/tableam.h +68 -45
  36. data/ext/pg_query/include/{access → postgres/access}/toast_compression.h +1 -1
  37. data/ext/pg_query/include/{access → postgres/access}/transam.h +1 -1
  38. data/ext/pg_query/include/postgres/access/tsmapi.h +82 -0
  39. data/ext/pg_query/include/{access → postgres/access}/tupconvert.h +5 -2
  40. data/ext/pg_query/include/{access → postgres/access}/tupdesc.h +2 -2
  41. data/ext/pg_query/include/{access → postgres/access}/tupmacs.h +58 -98
  42. data/ext/pg_query/include/{access → postgres/access}/twophase.h +2 -2
  43. data/ext/pg_query/include/{access → postgres/access}/xact.h +25 -18
  44. data/ext/pg_query/include/{access → postgres/access}/xlog.h +15 -16
  45. data/ext/pg_query/include/{access → postgres/access}/xlog_internal.h +100 -62
  46. data/ext/pg_query/include/postgres/access/xlogbackup.h +41 -0
  47. data/ext/pg_query/include/{access → postgres/access}/xlogdefs.h +6 -25
  48. data/ext/pg_query/include/{access → postgres/access}/xlogprefetcher.h +1 -1
  49. data/ext/pg_query/include/{access → postgres/access}/xlogreader.h +7 -6
  50. data/ext/pg_query/include/{access → postgres/access}/xlogrecord.h +17 -5
  51. data/ext/pg_query/include/{access → postgres/access}/xlogrecovery.h +4 -3
  52. data/ext/pg_query/include/postgres/archive/archive_module.h +59 -0
  53. data/ext/pg_query/include/{c.h → postgres/c.h} +144 -156
  54. data/ext/pg_query/include/{catalog → postgres/catalog}/catalog.h +4 -3
  55. data/ext/pg_query/include/{catalog → postgres/catalog}/catversion.h +6 -2
  56. data/ext/pg_query/include/{catalog → postgres/catalog}/dependency.h +5 -4
  57. data/ext/pg_query/include/{catalog → postgres/catalog}/genbki.h +7 -6
  58. data/ext/pg_query/include/{catalog → postgres/catalog}/index.h +4 -4
  59. data/ext/pg_query/include/{catalog → postgres/catalog}/indexing.h +1 -1
  60. data/ext/pg_query/include/{catalog → postgres/catalog}/namespace.h +2 -2
  61. data/ext/pg_query/include/{catalog → postgres/catalog}/objectaccess.h +10 -8
  62. data/ext/pg_query/include/{catalog → postgres/catalog}/objectaddress.h +3 -3
  63. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_aggregate.h +1 -1
  64. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_aggregate_d.h +1 -1
  65. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_am.h +1 -1
  66. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_am_d.h +1 -1
  67. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_attribute.h +19 -17
  68. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_attribute_d.h +19 -19
  69. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_authid.h +1 -1
  70. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_authid_d.h +3 -1
  71. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_class.h +1 -1
  72. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_class_d.h +1 -1
  73. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_collation.h +3 -1
  74. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_collation_d.h +4 -3
  75. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_constraint.h +2 -2
  76. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_constraint_d.h +1 -1
  77. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_control.h +9 -1
  78. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_conversion.h +2 -2
  79. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_conversion_d.h +1 -1
  80. data/ext/pg_query/include/postgres/catalog/pg_database.h +124 -0
  81. data/ext/pg_query/include/postgres/catalog/pg_database_d.h +52 -0
  82. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_depend.h +1 -1
  83. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_depend_d.h +1 -1
  84. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_event_trigger.h +1 -1
  85. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_event_trigger_d.h +1 -1
  86. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_index.h +1 -1
  87. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_index_d.h +1 -1
  88. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_language.h +1 -1
  89. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_language_d.h +1 -1
  90. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_namespace.h +1 -1
  91. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_namespace_d.h +1 -1
  92. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_opclass.h +1 -1
  93. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_opclass_d.h +1 -1
  94. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_operator.h +1 -1
  95. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_operator_d.h +1 -1
  96. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_opfamily.h +3 -2
  97. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_opfamily_d.h +4 -2
  98. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_partitioned_table.h +1 -1
  99. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_partitioned_table_d.h +1 -1
  100. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_proc.h +1 -1
  101. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_proc_d.h +1 -1
  102. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_publication.h +2 -5
  103. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_publication_d.h +1 -1
  104. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_replication_origin.h +1 -1
  105. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_replication_origin_d.h +1 -1
  106. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_statistic.h +1 -1
  107. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_statistic_d.h +1 -1
  108. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_statistic_ext.h +1 -1
  109. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_statistic_ext_d.h +1 -1
  110. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_transform.h +1 -1
  111. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_transform_d.h +1 -1
  112. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_trigger.h +1 -1
  113. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_trigger_d.h +1 -1
  114. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_config.h +1 -1
  115. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_config_d.h +1 -1
  116. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_dict.h +1 -1
  117. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_dict_d.h +1 -1
  118. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_parser.h +1 -1
  119. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_parser_d.h +1 -1
  120. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_template.h +1 -1
  121. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_template_d.h +1 -1
  122. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_type.h +1 -1
  123. data/ext/pg_query/include/{catalog → postgres/catalog}/pg_type_d.h +1 -1
  124. data/ext/pg_query/include/{catalog → postgres/catalog}/storage.h +6 -6
  125. data/ext/pg_query/include/{commands → postgres/commands}/async.h +1 -1
  126. data/ext/pg_query/include/{commands → postgres/commands}/dbcommands.h +2 -1
  127. data/ext/pg_query/include/{commands → postgres/commands}/defrem.h +2 -1
  128. data/ext/pg_query/include/{commands → postgres/commands}/event_trigger.h +1 -1
  129. data/ext/pg_query/include/{commands → postgres/commands}/explain.h +3 -1
  130. data/ext/pg_query/include/{commands → postgres/commands}/prepare.h +1 -1
  131. data/ext/pg_query/include/{commands → postgres/commands}/tablespace.h +4 -4
  132. data/ext/pg_query/include/{commands → postgres/commands}/trigger.h +15 -14
  133. data/ext/pg_query/include/{commands → postgres/commands}/user.h +9 -3
  134. data/ext/pg_query/include/{commands → postgres/commands}/vacuum.h +60 -14
  135. data/ext/pg_query/include/postgres/common/cryptohash.h +39 -0
  136. data/ext/pg_query/include/{common → postgres/common}/file_perm.h +1 -1
  137. data/ext/pg_query/include/{common → postgres/common}/hashfn.h +1 -1
  138. data/ext/pg_query/include/postgres/common/int.h +437 -0
  139. data/ext/pg_query/include/{common → postgres/common}/keywords.h +1 -1
  140. data/ext/pg_query/include/{common → postgres/common}/kwlookup.h +2 -2
  141. data/ext/pg_query/include/{common → postgres/common}/pg_prng.h +3 -2
  142. data/ext/pg_query/include/{common → postgres/common}/relpath.h +20 -13
  143. data/ext/pg_query/include/postgres/common/scram-common.h +70 -0
  144. data/ext/pg_query/include/postgres/common/sha2.h +32 -0
  145. data/ext/pg_query/include/{common → postgres/common}/string.h +5 -3
  146. data/ext/pg_query/include/{common → postgres/common}/unicode_east_asian_fw_table.h +10 -10
  147. data/ext/pg_query/include/{common/unicode_combining_table.h → postgres/common/unicode_nonspacing_table.h} +31 -13
  148. data/ext/pg_query/include/postgres/copyfuncs.funcs.c +5013 -0
  149. data/ext/pg_query/include/postgres/copyfuncs.switch.c +938 -0
  150. data/ext/pg_query/include/{datatype → postgres/datatype}/timestamp.h +11 -4
  151. data/ext/pg_query/include/postgres/equalfuncs.funcs.c +3097 -0
  152. data/ext/pg_query/include/postgres/equalfuncs.switch.c +785 -0
  153. data/ext/pg_query/include/{executor → postgres/executor}/execdesc.h +1 -1
  154. data/ext/pg_query/include/{executor → postgres/executor}/executor.h +34 -17
  155. data/ext/pg_query/include/{executor → postgres/executor}/functions.h +1 -1
  156. data/ext/pg_query/include/{executor → postgres/executor}/instrument.h +1 -1
  157. data/ext/pg_query/include/{executor → postgres/executor}/spi.h +2 -2
  158. data/ext/pg_query/include/{executor → postgres/executor}/tablefunc.h +1 -1
  159. data/ext/pg_query/include/{executor → postgres/executor}/tuptable.h +18 -11
  160. data/ext/pg_query/include/{fmgr.h → postgres/fmgr.h} +21 -2
  161. data/ext/pg_query/include/postgres/foreign/fdwapi.h +294 -0
  162. data/ext/pg_query/include/{funcapi.h → postgres/funcapi.h} +12 -12
  163. data/ext/pg_query/include/postgres/gram.h +1127 -0
  164. data/ext/pg_query/include/{parser → postgres}/gramparse.h +4 -4
  165. data/ext/pg_query/include/{jit → postgres/jit}/jit.h +2 -2
  166. data/ext/pg_query/include/postgres/kwlist_d.h +1119 -0
  167. data/ext/pg_query/include/{lib → postgres/lib}/dshash.h +4 -1
  168. data/ext/pg_query/include/{lib → postgres/lib}/ilist.h +435 -22
  169. data/ext/pg_query/include/{lib → postgres/lib}/pairingheap.h +1 -1
  170. data/ext/pg_query/include/{lib → postgres/lib}/simplehash.h +9 -9
  171. data/ext/pg_query/include/{lib → postgres/lib}/sort_template.h +1 -1
  172. data/ext/pg_query/include/{lib → postgres/lib}/stringinfo.h +3 -3
  173. data/ext/pg_query/include/{libpq → postgres/libpq}/auth.h +8 -2
  174. data/ext/pg_query/include/{libpq → postgres/libpq}/crypt.h +1 -1
  175. data/ext/pg_query/include/{libpq → postgres/libpq}/hba.h +24 -17
  176. data/ext/pg_query/include/{libpq → postgres/libpq}/libpq-be.h +36 -25
  177. data/ext/pg_query/include/{libpq → postgres/libpq}/libpq.h +1 -1
  178. data/ext/pg_query/include/{libpq → postgres/libpq}/pqcomm.h +10 -41
  179. data/ext/pg_query/include/{libpq → postgres/libpq}/pqformat.h +2 -2
  180. data/ext/pg_query/include/{libpq → postgres/libpq}/pqsignal.h +22 -10
  181. data/ext/pg_query/include/postgres/libpq/sasl.h +136 -0
  182. data/ext/pg_query/include/postgres/libpq/scram.h +37 -0
  183. data/ext/pg_query/include/{mb → postgres/mb}/pg_wchar.h +35 -18
  184. data/ext/pg_query/include/{mb → postgres/mb}/stringinfo_mb.h +1 -1
  185. data/ext/pg_query/include/{miscadmin.h → postgres/miscadmin.h} +27 -15
  186. data/ext/pg_query/include/{nodes → postgres/nodes}/bitmapset.h +11 -7
  187. data/ext/pg_query/include/{nodes → postgres/nodes}/execnodes.h +83 -30
  188. data/ext/pg_query/include/{nodes → postgres/nodes}/extensible.h +5 -3
  189. data/ext/pg_query/include/{nodes → postgres/nodes}/lockoptions.h +1 -1
  190. data/ext/pg_query/include/{nodes → postgres/nodes}/makefuncs.h +14 -2
  191. data/ext/pg_query/include/{nodes → postgres/nodes}/memnodes.h +7 -4
  192. data/ext/pg_query/include/postgres/nodes/miscnodes.h +56 -0
  193. data/ext/pg_query/include/{nodes → postgres/nodes}/nodeFuncs.h +89 -29
  194. data/ext/pg_query/include/{nodes → postgres/nodes}/nodes.h +96 -511
  195. data/ext/pg_query/include/postgres/nodes/nodetags.h +471 -0
  196. data/ext/pg_query/include/{nodes → postgres/nodes}/params.h +3 -3
  197. data/ext/pg_query/include/{nodes → postgres/nodes}/parsenodes.h +377 -139
  198. data/ext/pg_query/include/{nodes → postgres/nodes}/pathnodes.h +1090 -440
  199. data/ext/pg_query/include/{nodes → postgres/nodes}/pg_list.h +30 -7
  200. data/ext/pg_query/include/{nodes → postgres/nodes}/plannodes.h +367 -124
  201. data/ext/pg_query/include/{nodes → postgres/nodes}/primnodes.h +670 -222
  202. data/ext/pg_query/include/{nodes → postgres/nodes}/print.h +1 -1
  203. data/ext/pg_query/include/{utils → postgres/nodes}/queryjumble.h +5 -7
  204. data/ext/pg_query/include/postgres/nodes/replnodes.h +111 -0
  205. data/ext/pg_query/include/postgres/nodes/supportnodes.h +346 -0
  206. data/ext/pg_query/include/{nodes → postgres/nodes}/tidbitmap.h +1 -1
  207. data/ext/pg_query/include/{nodes → postgres/nodes}/value.h +12 -2
  208. data/ext/pg_query/include/{optimizer → postgres/optimizer}/cost.h +6 -4
  209. data/ext/pg_query/include/{optimizer → postgres/optimizer}/geqo.h +1 -1
  210. data/ext/pg_query/include/{optimizer → postgres/optimizer}/geqo_gene.h +1 -1
  211. data/ext/pg_query/include/{optimizer → postgres/optimizer}/optimizer.h +8 -8
  212. data/ext/pg_query/include/{optimizer → postgres/optimizer}/paths.h +16 -7
  213. data/ext/pg_query/include/{optimizer → postgres/optimizer}/planmain.h +3 -6
  214. data/ext/pg_query/include/{parser → postgres/parser}/analyze.h +4 -3
  215. data/ext/pg_query/include/{parser → postgres/parser}/kwlist.h +12 -1
  216. data/ext/pg_query/include/{parser → postgres/parser}/parse_agg.h +4 -2
  217. data/ext/pg_query/include/{parser → postgres/parser}/parse_coerce.h +3 -1
  218. data/ext/pg_query/include/{parser → postgres/parser}/parse_expr.h +1 -1
  219. data/ext/pg_query/include/{parser → postgres/parser}/parse_func.h +1 -1
  220. data/ext/pg_query/include/{parser → postgres/parser}/parse_node.h +22 -4
  221. data/ext/pg_query/include/{parser → postgres/parser}/parse_oper.h +3 -3
  222. data/ext/pg_query/include/{parser → postgres/parser}/parse_relation.h +8 -3
  223. data/ext/pg_query/include/{parser → postgres/parser}/parse_type.h +4 -3
  224. data/ext/pg_query/include/{parser → postgres/parser}/parser.h +4 -4
  225. data/ext/pg_query/include/{parser → postgres/parser}/parsetree.h +1 -1
  226. data/ext/pg_query/include/{parser → postgres/parser}/scanner.h +2 -2
  227. data/ext/pg_query/include/{parser → postgres/parser}/scansup.h +1 -1
  228. data/ext/pg_query/include/{partitioning → postgres/partitioning}/partdefs.h +1 -1
  229. data/ext/pg_query/include/{pg_config.h → postgres/pg_config.h} +158 -218
  230. data/ext/pg_query/include/{pg_config_manual.h → postgres/pg_config_manual.h} +8 -46
  231. data/ext/pg_query/include/postgres/pg_config_os.h +8 -0
  232. data/ext/pg_query/include/{pg_getopt.h → postgres/pg_getopt.h} +1 -1
  233. data/ext/pg_query/include/{pg_trace.h → postgres/pg_trace.h} +1 -1
  234. data/ext/pg_query/include/{pgstat.h → postgres/pgstat.h} +173 -94
  235. data/ext/pg_query/include/{pgtime.h → postgres/pgtime.h} +3 -3
  236. data/ext/pg_query/include/{pl_gram.h → postgres/pl_gram.h} +66 -64
  237. data/ext/pg_query/include/{pl_reserved_kwlist.h → postgres/pl_reserved_kwlist.h} +1 -1
  238. data/ext/pg_query/include/{pl_reserved_kwlist_d.h → postgres/pl_reserved_kwlist_d.h} +1 -1
  239. data/ext/pg_query/include/{pl_unreserved_kwlist.h → postgres/pl_unreserved_kwlist.h} +2 -1
  240. data/ext/pg_query/include/{pl_unreserved_kwlist_d.h → postgres/pl_unreserved_kwlist_d.h} +48 -46
  241. data/ext/pg_query/include/{plpgsql.h → postgres/plpgsql.h} +28 -33
  242. data/ext/pg_query/include/{port → postgres/port}/atomics/arch-arm.h +3 -3
  243. data/ext/pg_query/include/postgres/port/atomics/arch-hppa.h +17 -0
  244. data/ext/pg_query/include/{port → postgres/port}/atomics/arch-ppc.h +21 -21
  245. data/ext/pg_query/include/{port → postgres/port}/atomics/arch-x86.h +2 -2
  246. data/ext/pg_query/include/{port → postgres/port}/atomics/fallback.h +3 -3
  247. data/ext/pg_query/include/{port → postgres/port}/atomics/generic-gcc.h +1 -1
  248. data/ext/pg_query/include/postgres/port/atomics/generic-msvc.h +101 -0
  249. data/ext/pg_query/include/postgres/port/atomics/generic-sunpro.h +106 -0
  250. data/ext/pg_query/include/{port → postgres/port}/atomics/generic.h +1 -1
  251. data/ext/pg_query/include/{port → postgres/port}/atomics.h +2 -7
  252. data/ext/pg_query/include/{port → postgres/port}/pg_bitutils.h +62 -25
  253. data/ext/pg_query/include/{port → postgres/port}/pg_bswap.h +1 -1
  254. data/ext/pg_query/include/{port → postgres/port}/pg_crc32c.h +1 -1
  255. data/ext/pg_query/include/postgres/port/simd.h +375 -0
  256. data/ext/pg_query/include/postgres/port/win32/arpa/inet.h +3 -0
  257. data/ext/pg_query/include/postgres/port/win32/dlfcn.h +1 -0
  258. data/ext/pg_query/include/postgres/port/win32/grp.h +1 -0
  259. data/ext/pg_query/include/postgres/port/win32/netdb.h +7 -0
  260. data/ext/pg_query/include/postgres/port/win32/netinet/in.h +3 -0
  261. data/ext/pg_query/include/postgres/port/win32/netinet/tcp.h +7 -0
  262. data/ext/pg_query/include/postgres/port/win32/pwd.h +3 -0
  263. data/ext/pg_query/include/postgres/port/win32/sys/resource.h +20 -0
  264. data/ext/pg_query/include/postgres/port/win32/sys/select.h +3 -0
  265. data/ext/pg_query/include/postgres/port/win32/sys/socket.h +26 -0
  266. data/ext/pg_query/include/postgres/port/win32/sys/un.h +17 -0
  267. data/ext/pg_query/include/postgres/port/win32/sys/wait.h +3 -0
  268. data/ext/pg_query/include/postgres/port/win32.h +59 -0
  269. data/ext/pg_query/include/postgres/port/win32_msvc/dirent.h +34 -0
  270. data/ext/pg_query/include/postgres/port/win32_msvc/sys/file.h +1 -0
  271. data/ext/pg_query/include/postgres/port/win32_msvc/sys/param.h +1 -0
  272. data/ext/pg_query/include/postgres/port/win32_msvc/sys/time.h +1 -0
  273. data/ext/pg_query/include/postgres/port/win32_msvc/unistd.h +9 -0
  274. data/ext/pg_query/include/postgres/port/win32_msvc/utime.h +3 -0
  275. data/ext/pg_query/include/postgres/port/win32_port.h +594 -0
  276. data/ext/pg_query/include/{port.h → postgres/port.h} +42 -75
  277. data/ext/pg_query/include/postgres/portability/instr_time.h +197 -0
  278. data/ext/pg_query/include/postgres/postgres.h +579 -0
  279. data/ext/pg_query/include/{postgres_ext.h → postgres/postgres_ext.h} +0 -1
  280. data/ext/pg_query/include/{postmaster → postgres/postmaster}/autovacuum.h +1 -4
  281. data/ext/pg_query/include/{postmaster → postgres/postmaster}/bgworker.h +2 -2
  282. data/ext/pg_query/include/{postmaster → postgres/postmaster}/bgworker_internals.h +1 -1
  283. data/ext/pg_query/include/{postmaster → postgres/postmaster}/bgwriter.h +2 -2
  284. data/ext/pg_query/include/{postmaster → postgres/postmaster}/interrupt.h +1 -1
  285. data/ext/pg_query/include/postgres/postmaster/pgarch.h +36 -0
  286. data/ext/pg_query/include/{postmaster → postgres/postmaster}/postmaster.h +6 -3
  287. data/ext/pg_query/include/{postmaster → postgres/postmaster}/startup.h +3 -1
  288. data/ext/pg_query/include/{postmaster → postgres/postmaster}/syslogger.h +2 -2
  289. data/ext/pg_query/include/{postmaster → postgres/postmaster}/walwriter.h +3 -1
  290. data/ext/pg_query/include/{regex → postgres/regex}/regex.h +9 -6
  291. data/ext/pg_query/include/{replication → postgres/replication}/logicallauncher.h +6 -1
  292. data/ext/pg_query/include/{replication → postgres/replication}/logicalproto.h +30 -10
  293. data/ext/pg_query/include/postgres/replication/logicalworker.h +32 -0
  294. data/ext/pg_query/include/{replication → postgres/replication}/origin.h +4 -4
  295. data/ext/pg_query/include/{replication → postgres/replication}/reorderbuffer.h +113 -45
  296. data/ext/pg_query/include/{replication → postgres/replication}/slot.h +25 -6
  297. data/ext/pg_query/include/{replication → postgres/replication}/syncrep.h +2 -8
  298. data/ext/pg_query/include/{replication → postgres/replication}/walreceiver.h +15 -9
  299. data/ext/pg_query/include/{replication → postgres/replication}/walsender.h +13 -13
  300. data/ext/pg_query/include/{rewrite → postgres/rewrite}/prs2lock.h +1 -1
  301. data/ext/pg_query/include/{rewrite → postgres/rewrite}/rewriteHandler.h +1 -4
  302. data/ext/pg_query/include/{rewrite → postgres/rewrite}/rewriteManip.h +11 -2
  303. data/ext/pg_query/include/{rewrite → postgres/rewrite}/rewriteSupport.h +1 -1
  304. data/ext/pg_query/include/{storage → postgres/storage}/backendid.h +1 -1
  305. data/ext/pg_query/include/{storage → postgres/storage}/block.h +24 -31
  306. data/ext/pg_query/include/{storage → postgres/storage}/buf.h +1 -1
  307. data/ext/pg_query/include/{storage → postgres/storage}/bufmgr.h +183 -87
  308. data/ext/pg_query/include/{storage → postgres/storage}/bufpage.h +146 -93
  309. data/ext/pg_query/include/{storage → postgres/storage}/condition_variable.h +2 -2
  310. data/ext/pg_query/include/{storage → postgres/storage}/dsm.h +3 -6
  311. data/ext/pg_query/include/{storage → postgres/storage}/dsm_impl.h +4 -1
  312. data/ext/pg_query/include/{storage → postgres/storage}/fd.h +24 -20
  313. data/ext/pg_query/include/{storage → postgres/storage}/fileset.h +1 -1
  314. data/ext/pg_query/include/{storage → postgres/storage}/ipc.h +2 -2
  315. data/ext/pg_query/include/{storage → postgres/storage}/item.h +1 -1
  316. data/ext/pg_query/include/{storage → postgres/storage}/itemid.h +1 -1
  317. data/ext/pg_query/include/{storage → postgres/storage}/itemptr.h +94 -57
  318. data/ext/pg_query/include/{storage → postgres/storage}/large_object.h +1 -1
  319. data/ext/pg_query/include/{storage → postgres/storage}/latch.h +9 -1
  320. data/ext/pg_query/include/{storage → postgres/storage}/lmgr.h +6 -1
  321. data/ext/pg_query/include/{storage → postgres/storage}/lock.h +21 -13
  322. data/ext/pg_query/include/{storage → postgres/storage}/lockdefs.h +3 -3
  323. data/ext/pg_query/include/{storage → postgres/storage}/lwlock.h +16 -2
  324. data/ext/pg_query/include/{storage → postgres/storage}/off.h +1 -1
  325. data/ext/pg_query/include/{storage → postgres/storage}/pg_sema.h +1 -1
  326. data/ext/pg_query/include/{storage → postgres/storage}/pg_shmem.h +1 -1
  327. data/ext/pg_query/include/{storage → postgres/storage}/pmsignal.h +1 -1
  328. data/ext/pg_query/include/{storage → postgres/storage}/predicate.h +2 -2
  329. data/ext/pg_query/include/{storage → postgres/storage}/proc.h +22 -17
  330. data/ext/pg_query/include/{storage → postgres/storage}/procarray.h +3 -2
  331. data/ext/pg_query/include/{storage → postgres/storage}/proclist_types.h +1 -1
  332. data/ext/pg_query/include/{storage → postgres/storage}/procsignal.h +3 -1
  333. data/ext/pg_query/include/postgres/storage/relfilelocator.h +99 -0
  334. data/ext/pg_query/include/{storage → postgres/storage}/s_lock.h +66 -309
  335. data/ext/pg_query/include/{storage → postgres/storage}/sharedfileset.h +1 -1
  336. data/ext/pg_query/include/{storage → postgres/storage}/shm_mq.h +1 -1
  337. data/ext/pg_query/include/{storage → postgres/storage}/shm_toc.h +1 -1
  338. data/ext/pg_query/include/{storage → postgres/storage}/shmem.h +1 -23
  339. data/ext/pg_query/include/{storage → postgres/storage}/sinval.h +3 -3
  340. data/ext/pg_query/include/{storage → postgres/storage}/sinvaladt.h +4 -2
  341. data/ext/pg_query/include/{storage → postgres/storage}/smgr.h +12 -10
  342. data/ext/pg_query/include/{storage → postgres/storage}/spin.h +1 -1
  343. data/ext/pg_query/include/{storage → postgres/storage}/standby.h +9 -8
  344. data/ext/pg_query/include/{storage → postgres/storage}/standbydefs.h +1 -1
  345. data/ext/pg_query/include/{storage → postgres/storage}/sync.h +3 -3
  346. data/ext/pg_query/include/{tcop → postgres/tcop}/cmdtag.h +7 -2
  347. data/ext/pg_query/include/{tcop → postgres/tcop}/cmdtaglist.h +1 -1
  348. data/ext/pg_query/include/{tcop → postgres/tcop}/deparse_utility.h +1 -1
  349. data/ext/pg_query/include/{tcop → postgres/tcop}/dest.h +1 -3
  350. data/ext/pg_query/include/{tcop → postgres/tcop}/fastpath.h +1 -1
  351. data/ext/pg_query/include/{tcop → postgres/tcop}/pquery.h +1 -1
  352. data/ext/pg_query/include/{tcop → postgres/tcop}/tcopprot.h +3 -6
  353. data/ext/pg_query/include/{tcop → postgres/tcop}/utility.h +1 -1
  354. data/ext/pg_query/include/{tsearch → postgres/tsearch}/ts_cache.h +2 -4
  355. data/ext/pg_query/include/{utils → postgres/utils}/acl.h +26 -81
  356. data/ext/pg_query/include/{utils → postgres/utils}/aclchk_internal.h +1 -1
  357. data/ext/pg_query/include/{utils → postgres/utils}/array.h +19 -1
  358. data/ext/pg_query/include/{utils → postgres/utils}/backend_progress.h +2 -1
  359. data/ext/pg_query/include/{utils → postgres/utils}/backend_status.h +24 -3
  360. data/ext/pg_query/include/{utils → postgres/utils}/builtins.h +15 -6
  361. data/ext/pg_query/include/{utils → postgres/utils}/bytea.h +1 -1
  362. data/ext/pg_query/include/{utils → postgres/utils}/catcache.h +1 -1
  363. data/ext/pg_query/include/{utils → postgres/utils}/date.h +37 -9
  364. data/ext/pg_query/include/{utils → postgres/utils}/datetime.h +41 -21
  365. data/ext/pg_query/include/{utils → postgres/utils}/datum.h +1 -1
  366. data/ext/pg_query/include/{utils → postgres/utils}/dsa.h +5 -1
  367. data/ext/pg_query/include/{utils → postgres/utils}/elog.h +104 -29
  368. data/ext/pg_query/include/{utils → postgres/utils}/expandeddatum.h +14 -3
  369. data/ext/pg_query/include/{utils → postgres/utils}/expandedrecord.h +14 -4
  370. data/ext/pg_query/include/{utils → postgres/utils}/float.h +7 -6
  371. data/ext/pg_query/include/{utils → postgres/utils}/fmgroids.h +54 -1
  372. data/ext/pg_query/include/{utils → postgres/utils}/fmgrprotos.h +45 -3
  373. data/ext/pg_query/include/{utils → postgres/utils}/fmgrtab.h +1 -1
  374. data/ext/pg_query/include/{utils → postgres/utils}/guc.h +59 -86
  375. data/ext/pg_query/include/postgres/utils/guc_hooks.h +163 -0
  376. data/ext/pg_query/include/{utils → postgres/utils}/guc_tables.h +49 -3
  377. data/ext/pg_query/include/{utils → postgres/utils}/hsearch.h +1 -1
  378. data/ext/pg_query/include/{utils → postgres/utils}/inval.h +3 -3
  379. data/ext/pg_query/include/postgres/utils/logtape.h +77 -0
  380. data/ext/pg_query/include/{utils → postgres/utils}/lsyscache.h +5 -1
  381. data/ext/pg_query/include/{utils → postgres/utils}/memdebug.h +1 -1
  382. data/ext/pg_query/include/{utils → postgres/utils}/memutils.h +7 -51
  383. data/ext/pg_query/include/postgres/utils/memutils_internal.h +136 -0
  384. data/ext/pg_query/include/postgres/utils/memutils_memorychunk.h +237 -0
  385. data/ext/pg_query/include/{utils → postgres/utils}/numeric.h +20 -5
  386. data/ext/pg_query/include/{utils → postgres/utils}/palloc.h +9 -2
  387. data/ext/pg_query/include/{utils → postgres/utils}/partcache.h +3 -2
  388. data/ext/pg_query/include/{utils → postgres/utils}/pg_locale.h +22 -14
  389. data/ext/pg_query/include/{utils → postgres/utils}/pgstat_internal.h +37 -7
  390. data/ext/pg_query/include/{utils → postgres/utils}/plancache.h +1 -1
  391. data/ext/pg_query/include/{utils → postgres/utils}/portal.h +1 -1
  392. data/ext/pg_query/include/{utils → postgres/utils}/probes.h +6 -6
  393. data/ext/pg_query/include/postgres/utils/ps_status.h +47 -0
  394. data/ext/pg_query/include/{utils → postgres/utils}/queryenvironment.h +1 -1
  395. data/ext/pg_query/include/{utils → postgres/utils}/regproc.h +3 -3
  396. data/ext/pg_query/include/{utils → postgres/utils}/rel.h +60 -43
  397. data/ext/pg_query/include/{utils → postgres/utils}/relcache.h +13 -8
  398. data/ext/pg_query/include/{utils → postgres/utils}/reltrigger.h +1 -1
  399. data/ext/pg_query/include/{utils → postgres/utils}/resowner.h +1 -1
  400. data/ext/pg_query/include/{utils → postgres/utils}/ruleutils.h +6 -1
  401. data/ext/pg_query/include/{utils → postgres/utils}/sharedtuplestore.h +1 -1
  402. data/ext/pg_query/include/{utils → postgres/utils}/snapmgr.h +4 -2
  403. data/ext/pg_query/include/{utils → postgres/utils}/snapshot.h +1 -1
  404. data/ext/pg_query/include/{utils → postgres/utils}/sortsupport.h +2 -2
  405. data/ext/pg_query/include/{utils → postgres/utils}/syscache.h +4 -1
  406. data/ext/pg_query/include/{utils → postgres/utils}/timeout.h +1 -1
  407. data/ext/pg_query/include/{utils → postgres/utils}/timestamp.h +41 -11
  408. data/ext/pg_query/include/{utils → postgres/utils}/tuplesort.h +189 -35
  409. data/ext/pg_query/include/{utils → postgres/utils}/tuplestore.h +1 -1
  410. data/ext/pg_query/include/{utils → postgres/utils}/typcache.h +1 -1
  411. data/ext/pg_query/include/{utils → postgres/utils}/varlena.h +13 -1
  412. data/ext/pg_query/include/{utils → postgres/utils}/wait_event.h +9 -4
  413. data/ext/pg_query/include/{utils → postgres/utils}/xml.h +15 -5
  414. data/ext/pg_query/include/{postgres.h → postgres/varatt.h} +7 -457
  415. data/ext/pg_query/include/protobuf/pg_query.pb-c.h +6186 -5585
  416. data/ext/pg_query/include/protobuf/pg_query.pb.h +112443 -91222
  417. data/ext/pg_query/pg_query.c +10 -1
  418. data/ext/pg_query/pg_query.pb-c.c +19755 -17757
  419. data/ext/pg_query/pg_query_deparse.c +1 -10635
  420. data/ext/pg_query/pg_query_fingerprint.c +12 -8
  421. data/ext/pg_query/pg_query_fingerprint.h +1 -1
  422. data/ext/pg_query/pg_query_internal.h +1 -1
  423. data/ext/pg_query/pg_query_json_plpgsql.c +1 -0
  424. data/ext/pg_query/pg_query_normalize.c +1 -1
  425. data/ext/pg_query/pg_query_outfuncs_json.c +6 -0
  426. data/ext/pg_query/pg_query_outfuncs_protobuf.c +3 -2
  427. data/ext/pg_query/pg_query_parse.c +47 -5
  428. data/ext/pg_query/pg_query_parse_plpgsql.c +7 -5
  429. data/ext/pg_query/pg_query_readfuncs_protobuf.c +1 -0
  430. data/ext/pg_query/pg_query_ruby.c +5 -0
  431. data/ext/pg_query/pg_query_ruby_freebsd.sym +2 -0
  432. data/ext/pg_query/pg_query_scan.c +1 -1
  433. data/ext/pg_query/pg_query_split.c +3 -3
  434. data/ext/pg_query/postgres_deparse.c +11067 -0
  435. data/ext/pg_query/postgres_deparse.h +9 -0
  436. data/ext/pg_query/src_backend_catalog_namespace.c +7 -2
  437. data/ext/pg_query/src_backend_catalog_pg_proc.c +1 -1
  438. data/ext/pg_query/src_backend_commands_define.c +1 -1
  439. data/ext/pg_query/src_backend_nodes_bitmapset.c +11 -70
  440. data/ext/pg_query/src_backend_nodes_copyfuncs.c +96 -6202
  441. data/ext/pg_query/src_backend_nodes_equalfuncs.c +95 -4068
  442. data/ext/pg_query/src_backend_nodes_extensible.c +6 -29
  443. data/ext/pg_query/src_backend_nodes_list.c +14 -2
  444. data/ext/pg_query/src_backend_nodes_makefuncs.c +95 -1
  445. data/ext/pg_query/src_backend_nodes_nodeFuncs.c +283 -132
  446. data/ext/pg_query/src_backend_nodes_nodes.c +38 -0
  447. data/ext/pg_query/src_backend_nodes_value.c +1 -1
  448. data/ext/pg_query/src_backend_parser_gram.c +33208 -31806
  449. data/ext/pg_query/src_backend_parser_parser.c +28 -2
  450. data/ext/pg_query/src_backend_parser_scan.c +4318 -3329
  451. data/ext/pg_query/src_backend_parser_scansup.c +1 -1
  452. data/ext/pg_query/src_backend_storage_ipc_ipc.c +1 -1
  453. data/ext/pg_query/src_backend_tcop_postgres.c +66 -87
  454. data/ext/pg_query/src_backend_utils_activity_pgstat_database.c +1 -1
  455. data/ext/pg_query/src_backend_utils_adt_datum.c +5 -7
  456. data/ext/pg_query/src_backend_utils_adt_expandeddatum.c +1 -1
  457. data/ext/pg_query/src_backend_utils_adt_format_type.c +1 -1
  458. data/ext/pg_query/src_backend_utils_adt_numutils.c +489 -0
  459. data/ext/pg_query/src_backend_utils_adt_ruleutils.c +79 -5
  460. data/ext/pg_query/src_backend_utils_error_assert.c +4 -7
  461. data/ext/pg_query/src_backend_utils_error_elog.c +371 -249
  462. data/ext/pg_query/src_backend_utils_fmgr_fmgr.c +33 -1
  463. data/ext/pg_query/src_backend_utils_init_globals.c +6 -3
  464. data/ext/pg_query/src_backend_utils_mb_mbutils.c +21 -67
  465. data/ext/pg_query/src_backend_utils_misc_guc_tables.c +492 -0
  466. data/ext/pg_query/src_backend_utils_mmgr_alignedalloc.c +163 -0
  467. data/ext/pg_query/src_backend_utils_mmgr_aset.c +449 -312
  468. data/ext/pg_query/src_backend_utils_mmgr_generation.c +1039 -0
  469. data/ext/pg_query/src_backend_utils_mmgr_mcxt.c +398 -49
  470. data/ext/pg_query/src_backend_utils_mmgr_slab.c +1021 -0
  471. data/ext/pg_query/src_common_encnames.c +4 -1
  472. data/ext/pg_query/src_common_hashfn.c +1 -1
  473. data/ext/pg_query/src_common_keywords.c +1 -1
  474. data/ext/pg_query/src_common_kwlist_d.h +534 -510
  475. data/ext/pg_query/src_common_kwlookup.c +1 -1
  476. data/ext/pg_query/src_common_psprintf.c +1 -1
  477. data/ext/pg_query/src_common_stringinfo.c +4 -4
  478. data/ext/pg_query/src_common_wchar.c +9 -8
  479. data/ext/pg_query/src_pl_plpgsql_src_pl_comp.c +1 -1
  480. data/ext/pg_query/src_pl_plpgsql_src_pl_funcs.c +3 -1
  481. data/ext/pg_query/src_pl_plpgsql_src_pl_gram.c +661 -694
  482. data/ext/pg_query/src_pl_plpgsql_src_pl_handler.c +1 -1
  483. data/ext/pg_query/src_pl_plpgsql_src_pl_reserved_kwlist_d.h +1 -1
  484. data/ext/pg_query/src_pl_plpgsql_src_pl_scanner.c +1 -1
  485. data/ext/pg_query/src_pl_plpgsql_src_pl_unreserved_kwlist_d.h +48 -46
  486. data/ext/pg_query/src_port_pg_bitutils.c +79 -5
  487. data/ext/pg_query/src_port_pgstrcasecmp.c +29 -1
  488. data/ext/pg_query/src_port_snprintf.c +6 -10
  489. data/ext/pg_query/src_port_strerror.c +1 -1
  490. data/ext/pg_query/src_port_strlcpy.c +79 -0
  491. data/lib/pg_query/fingerprint.rb +2 -3
  492. data/lib/pg_query/node.rb +16 -11
  493. data/lib/pg_query/parse.rb +1 -1
  494. data/lib/pg_query/pg_query_pb.rb +166 -3191
  495. data/lib/pg_query/treewalker.rb +23 -5
  496. data/lib/pg_query/version.rb +1 -1
  497. metadata +432 -380
  498. data/ext/pg_query/guc-file.c +0 -0
  499. data/ext/pg_query/include/catalog/pg_parameter_acl.h +0 -60
  500. data/ext/pg_query/include/catalog/pg_parameter_acl_d.h +0 -34
  501. data/ext/pg_query/include/commands/variable.h +0 -38
  502. data/ext/pg_query/include/common/ip.h +0 -31
  503. data/ext/pg_query/include/getaddrinfo.h +0 -162
  504. data/ext/pg_query/include/kwlist_d.h +0 -1095
  505. data/ext/pg_query/include/parser/gram.h +0 -1101
  506. data/ext/pg_query/include/pg_config_os.h +0 -8
  507. data/ext/pg_query/include/portability/instr_time.h +0 -256
  508. data/ext/pg_query/include/postmaster/auxprocess.h +0 -20
  509. data/ext/pg_query/include/postmaster/fork_process.h +0 -17
  510. data/ext/pg_query/include/postmaster/pgarch.h +0 -73
  511. data/ext/pg_query/include/replication/logicalworker.h +0 -19
  512. data/ext/pg_query/include/storage/relfilenode.h +0 -99
  513. data/ext/pg_query/include/utils/dynahash.h +0 -20
  514. data/ext/pg_query/include/utils/pg_lsn.h +0 -29
  515. data/ext/pg_query/include/utils/pidfile.h +0 -56
  516. data/ext/pg_query/include/utils/ps_status.h +0 -25
  517. data/ext/pg_query/include/utils/rls.h +0 -50
  518. data/ext/pg_query/include/utils/tzparser.h +0 -39
  519. data/ext/pg_query/src_backend_postmaster_postmaster.c +0 -2201
  520. data/ext/pg_query/src_backend_storage_lmgr_s_lock.c +0 -371
  521. data/ext/pg_query/src_backend_utils_hash_dynahash.c +0 -1116
  522. data/ext/pg_query/src_backend_utils_misc_guc.c +0 -1993
  523. data/ext/pg_query/src_common_pg_prng.c +0 -152
  524. data/ext/pg_query/src_common_string.c +0 -92
  525. data/ext/pg_query/src_port_pgsleep.c +0 -69
  526. data/ext/pg_query/src_port_strnlen.c +0 -39
  527. /data/ext/pg_query/include/{access → postgres/access}/rmgr.h +0 -0
  528. /data/ext/pg_query/include/{pg_config_ext.h → postgres/pg_config_ext.h} +0 -0
  529. /data/ext/pg_query/include/{plerrcodes.h → postgres/plerrcodes.h} +0 -0
  530. /data/ext/pg_query/include/{storage → postgres/storage}/lwlocknames.h +0 -0
  531. /data/ext/pg_query/include/{utils → postgres/utils}/errcodes.h +0 -0
@@ -1,1993 +0,0 @@
1
- /*--------------------------------------------------------------------
2
- * Symbols referenced in this file:
3
- * - log_min_messages
4
- * - client_min_messages
5
- * - backtrace_functions
6
- * - backtrace_symbol_list
7
- * - check_function_bodies
8
- *--------------------------------------------------------------------
9
- */
10
-
11
- /*--------------------------------------------------------------------
12
- * guc.c
13
- *
14
- * Support for grand unified configuration scheme, including SET
15
- * command, configuration file, and command line options.
16
- * See src/backend/utils/misc/README for more information.
17
- *
18
- *
19
- * Copyright (c) 2000-2022, PostgreSQL Global Development Group
20
- * Written by Peter Eisentraut <peter_e@gmx.net>.
21
- *
22
- * IDENTIFICATION
23
- * src/backend/utils/misc/guc.c
24
- *
25
- *--------------------------------------------------------------------
26
- */
27
- #include "postgres.h"
28
-
29
- #include <ctype.h>
30
- #include <float.h>
31
- #include <math.h>
32
- #include <limits.h>
33
- #ifdef HAVE_POLL_H
34
- #include <poll.h>
35
- #endif
36
- #ifndef WIN32
37
- #include <sys/mman.h>
38
- #endif
39
- #include <sys/stat.h>
40
- #ifdef HAVE_SYSLOG
41
- #include <syslog.h>
42
- #endif
43
- #include <unistd.h>
44
-
45
- #include "access/commit_ts.h"
46
- #include "access/gin.h"
47
- #include "access/rmgr.h"
48
- #include "access/tableam.h"
49
- #include "access/toast_compression.h"
50
- #include "access/transam.h"
51
- #include "access/twophase.h"
52
- #include "access/xact.h"
53
- #include "access/xlog_internal.h"
54
- #include "access/xlogprefetcher.h"
55
- #include "access/xlogrecovery.h"
56
- #include "catalog/namespace.h"
57
- #include "catalog/objectaccess.h"
58
- #include "catalog/pg_authid.h"
59
- #include "catalog/pg_parameter_acl.h"
60
- #include "catalog/storage.h"
61
- #include "commands/async.h"
62
- #include "commands/prepare.h"
63
- #include "commands/tablespace.h"
64
- #include "commands/trigger.h"
65
- #include "commands/user.h"
66
- #include "commands/vacuum.h"
67
- #include "commands/variable.h"
68
- #include "common/string.h"
69
- #include "funcapi.h"
70
- #include "jit/jit.h"
71
- #include "libpq/auth.h"
72
- #include "libpq/libpq.h"
73
- #include "libpq/pqformat.h"
74
- #include "miscadmin.h"
75
- #include "optimizer/cost.h"
76
- #include "optimizer/geqo.h"
77
- #include "optimizer/optimizer.h"
78
- #include "optimizer/paths.h"
79
- #include "optimizer/planmain.h"
80
- #include "parser/parse_expr.h"
81
- #include "parser/parse_type.h"
82
- #include "parser/parser.h"
83
- #include "parser/scansup.h"
84
- #include "pgstat.h"
85
- #include "postmaster/autovacuum.h"
86
- #include "postmaster/bgworker_internals.h"
87
- #include "postmaster/bgwriter.h"
88
- #include "postmaster/postmaster.h"
89
- #include "postmaster/startup.h"
90
- #include "postmaster/syslogger.h"
91
- #include "postmaster/walwriter.h"
92
- #include "replication/logicallauncher.h"
93
- #include "replication/reorderbuffer.h"
94
- #include "replication/slot.h"
95
- #include "replication/syncrep.h"
96
- #include "replication/walreceiver.h"
97
- #include "replication/walsender.h"
98
- #include "storage/bufmgr.h"
99
- #include "storage/dsm_impl.h"
100
- #include "storage/fd.h"
101
- #include "storage/large_object.h"
102
- #include "storage/pg_shmem.h"
103
- #include "storage/predicate.h"
104
- #include "storage/proc.h"
105
- #include "storage/standby.h"
106
- #include "tcop/tcopprot.h"
107
- #include "tsearch/ts_cache.h"
108
- #include "utils/acl.h"
109
- #include "utils/backend_status.h"
110
- #include "utils/builtins.h"
111
- #include "utils/bytea.h"
112
- #include "utils/float.h"
113
- #include "utils/guc_tables.h"
114
- #include "utils/memutils.h"
115
- #include "utils/pg_locale.h"
116
- #include "utils/pg_lsn.h"
117
- #include "utils/plancache.h"
118
- #include "utils/portal.h"
119
- #include "utils/ps_status.h"
120
- #include "utils/queryjumble.h"
121
- #include "utils/rls.h"
122
- #include "utils/snapmgr.h"
123
- #include "utils/tzparser.h"
124
- #include "utils/inval.h"
125
- #include "utils/varlena.h"
126
- #include "utils/xml.h"
127
-
128
- #ifndef PG_KRB_SRVTAB
129
- #define PG_KRB_SRVTAB ""
130
- #endif
131
-
132
- #define CONFIG_FILENAME "postgresql.conf"
133
- #define HBA_FILENAME "pg_hba.conf"
134
- #define IDENT_FILENAME "pg_ident.conf"
135
-
136
- #ifdef EXEC_BACKEND
137
- #define CONFIG_EXEC_PARAMS "global/config_exec_params"
138
- #define CONFIG_EXEC_PARAMS_NEW "global/config_exec_params.new"
139
- #endif
140
-
141
- /*
142
- * Precision with which REAL type guc values are to be printed for GUC
143
- * serialization.
144
- */
145
- #define REALTYPE_PRECISION 17
146
-
147
- /* XXX these should appear in other modules' header files */
148
- extern bool Log_disconnections;
149
- extern int CommitDelay;
150
- extern int CommitSiblings;
151
- extern char *default_tablespace;
152
- extern char *temp_tablespaces;
153
- extern bool ignore_checksum_failure;
154
- extern bool ignore_invalid_pages;
155
- extern bool synchronize_seqscans;
156
-
157
- #ifdef TRACE_SYNCSCAN
158
- extern bool trace_syncscan;
159
- #endif
160
- #ifdef DEBUG_BOUNDED_SORT
161
- extern bool optimize_bounded_sort;
162
- #endif
163
-
164
-
165
-
166
-
167
-
168
- /* global variables for check hook support */
169
-
170
-
171
-
172
-
173
- static void do_serialize(char **destptr, Size *maxbytes, const char *fmt,...) pg_attribute_printf(3, 4);
174
-
175
- static void set_config_sourcefile(const char *name, char *sourcefile,
176
- int sourceline);
177
- static bool call_bool_check_hook(struct config_bool *conf, bool *newval,
178
- void **extra, GucSource source, int elevel);
179
- static bool call_int_check_hook(struct config_int *conf, int *newval,
180
- void **extra, GucSource source, int elevel);
181
- static bool call_real_check_hook(struct config_real *conf, double *newval,
182
- void **extra, GucSource source, int elevel);
183
- static bool call_string_check_hook(struct config_string *conf, char **newval,
184
- void **extra, GucSource source, int elevel);
185
- static bool call_enum_check_hook(struct config_enum *conf, int *newval,
186
- void **extra, GucSource source, int elevel);
187
-
188
- static bool check_log_destination(char **newval, void **extra, GucSource source);
189
- static void assign_log_destination(const char *newval, void *extra);
190
-
191
- static bool check_wal_consistency_checking(char **newval, void **extra,
192
- GucSource source);
193
- static void assign_wal_consistency_checking(const char *newval, void *extra);
194
-
195
- #ifdef HAVE_SYSLOG
196
-
197
- #else
198
- static int syslog_facility = 0;
199
- #endif
200
-
201
- static void assign_syslog_facility(int newval, void *extra);
202
- static void assign_syslog_ident(const char *newval, void *extra);
203
- static void assign_session_replication_role(int newval, void *extra);
204
- static bool check_temp_buffers(int *newval, void **extra, GucSource source);
205
- static bool check_bonjour(bool *newval, void **extra, GucSource source);
206
- static bool check_ssl(bool *newval, void **extra, GucSource source);
207
- static bool check_stage_log_stats(bool *newval, void **extra, GucSource source);
208
- static bool check_log_stats(bool *newval, void **extra, GucSource source);
209
- static bool check_canonical_path(char **newval, void **extra, GucSource source);
210
- static bool check_timezone_abbreviations(char **newval, void **extra, GucSource source);
211
- static void assign_timezone_abbreviations(const char *newval, void *extra);
212
- static void pg_timezone_abbrev_initialize(void);
213
- static const char *show_archive_command(void);
214
- static void assign_tcp_keepalives_idle(int newval, void *extra);
215
- static void assign_tcp_keepalives_interval(int newval, void *extra);
216
- static void assign_tcp_keepalives_count(int newval, void *extra);
217
- static void assign_tcp_user_timeout(int newval, void *extra);
218
- static const char *show_tcp_keepalives_idle(void);
219
- static const char *show_tcp_keepalives_interval(void);
220
- static const char *show_tcp_keepalives_count(void);
221
- static const char *show_tcp_user_timeout(void);
222
- static bool check_maxconnections(int *newval, void **extra, GucSource source);
223
- static bool check_max_worker_processes(int *newval, void **extra, GucSource source);
224
- static bool check_autovacuum_max_workers(int *newval, void **extra, GucSource source);
225
- static bool check_max_wal_senders(int *newval, void **extra, GucSource source);
226
- static bool check_autovacuum_work_mem(int *newval, void **extra, GucSource source);
227
- static bool check_effective_io_concurrency(int *newval, void **extra, GucSource source);
228
- static bool check_maintenance_io_concurrency(int *newval, void **extra, GucSource source);
229
- static bool check_huge_page_size(int *newval, void **extra, GucSource source);
230
- static bool check_client_connection_check_interval(int *newval, void **extra, GucSource source);
231
- static void assign_maintenance_io_concurrency(int newval, void *extra);
232
- static bool check_application_name(char **newval, void **extra, GucSource source);
233
- static void assign_application_name(const char *newval, void *extra);
234
- static bool check_cluster_name(char **newval, void **extra, GucSource source);
235
- static const char *show_unix_socket_permissions(void);
236
- static const char *show_log_file_mode(void);
237
- static const char *show_data_directory_mode(void);
238
- static const char *show_in_hot_standby(void);
239
- static bool check_backtrace_functions(char **newval, void **extra, GucSource source);
240
- static void assign_backtrace_functions(const char *newval, void *extra);
241
- static bool check_recovery_target_timeline(char **newval, void **extra, GucSource source);
242
- static void assign_recovery_target_timeline(const char *newval, void *extra);
243
- static bool check_recovery_target(char **newval, void **extra, GucSource source);
244
- static void assign_recovery_target(const char *newval, void *extra);
245
- static bool check_recovery_target_xid(char **newval, void **extra, GucSource source);
246
- static void assign_recovery_target_xid(const char *newval, void *extra);
247
- static bool check_recovery_target_time(char **newval, void **extra, GucSource source);
248
- static void assign_recovery_target_time(const char *newval, void *extra);
249
- static bool check_recovery_target_name(char **newval, void **extra, GucSource source);
250
- static void assign_recovery_target_name(const char *newval, void *extra);
251
- static bool check_recovery_target_lsn(char **newval, void **extra, GucSource source);
252
- static void assign_recovery_target_lsn(const char *newval, void *extra);
253
- static bool check_primary_slot_name(char **newval, void **extra, GucSource source);
254
- static bool check_default_with_oids(bool *newval, void **extra, GucSource source);
255
-
256
- /* Private functions in guc-file.l that need to be called from guc.c */
257
- static ConfigVariable *ProcessConfigFileInternal(GucContext context,
258
- bool applySettings, int elevel);
259
-
260
- /*
261
- * Track whether there were any deferred checks for custom resource managers
262
- * specified in wal_consistency_checking.
263
- */
264
-
265
-
266
- /*
267
- * Options for enum values defined in this module.
268
- *
269
- * NOTE! Option values may not contain double quotes!
270
- */
271
-
272
-
273
-
274
- StaticAssertDecl(lengthof(bytea_output_options) == (BYTEA_OUTPUT_HEX + 2),
275
- "array length mismatch");
276
-
277
- /*
278
- * We have different sets for client and server message level options because
279
- * they sort slightly different (see "log" level), and because "fatal"/"panic"
280
- * aren't sensible for client_min_messages.
281
- */
282
-
283
-
284
-
285
-
286
-
287
-
288
- StaticAssertDecl(lengthof(intervalstyle_options) == (INTSTYLE_ISO_8601 + 2),
289
- "array length mismatch");
290
-
291
-
292
-
293
- StaticAssertDecl(lengthof(log_error_verbosity_options) == (PGERROR_VERBOSE + 2),
294
- "array length mismatch");
295
-
296
-
297
-
298
- StaticAssertDecl(lengthof(log_statement_options) == (LOGSTMT_ALL + 2),
299
- "array length mismatch");
300
-
301
-
302
-
303
-
304
-
305
- StaticAssertDecl(lengthof(session_replication_role_options) == (SESSION_REPLICATION_ROLE_LOCAL + 2),
306
- "array length mismatch");
307
-
308
- #ifdef HAVE_SYSLOG
309
- #else
310
- #endif
311
-
312
-
313
-
314
- StaticAssertDecl(lengthof(track_function_options) == (TRACK_FUNC_ALL + 2),
315
- "array length mismatch");
316
-
317
-
318
-
319
- StaticAssertDecl(lengthof(stats_fetch_consistency) == (PGSTAT_FETCH_CONSISTENCY_SNAPSHOT + 2),
320
- "array length mismatch");
321
-
322
-
323
-
324
- StaticAssertDecl(lengthof(xmlbinary_options) == (XMLBINARY_HEX + 2),
325
- "array length mismatch");
326
-
327
-
328
-
329
- StaticAssertDecl(lengthof(xmloption_options) == (XMLOPTION_CONTENT + 2),
330
- "array length mismatch");
331
-
332
- /*
333
- * Although only "on", "off", and "safe_encoding" are documented, we
334
- * accept all the likely variants of "on" and "off".
335
- */
336
-
337
-
338
- /*
339
- * Although only "on", "off", and "auto" are documented, we accept
340
- * all the likely variants of "on" and "off".
341
- */
342
-
343
-
344
- /*
345
- * Although only "on", "off", and "partition" are documented, we
346
- * accept all the likely variants of "on" and "off".
347
- */
348
-
349
-
350
- /*
351
- * Although only "on", "off", "remote_apply", "remote_write", and "local" are
352
- * documented, we accept all the likely variants of "on" and "off".
353
- */
354
-
355
-
356
- /*
357
- * Although only "on", "off", "try" are documented, we accept all the likely
358
- * variants of "on" and "off".
359
- */
360
-
361
-
362
-
363
-
364
-
365
-
366
-
367
-
368
-
369
-
370
-
371
-
372
- StaticAssertDecl(lengthof(ssl_protocol_versions_info) == (PG_TLS1_3_VERSION + 2),
373
- "array length mismatch");
374
-
375
- #ifdef HAVE_SYNCFS
376
- #endif
377
-
378
- #ifndef WIN32
379
- #endif
380
- #ifndef EXEC_BACKEND
381
- #endif
382
- #ifdef WIN32
383
- #endif
384
-
385
- #ifdef USE_LZ4
386
- #endif
387
-
388
- #ifdef USE_LZ4
389
- #endif
390
- #ifdef USE_ZSTD
391
- #endif
392
-
393
- /*
394
- * Options for enum values stored in other modules
395
- */
396
- extern const struct config_enum_entry wal_level_options[];
397
- extern const struct config_enum_entry archive_mode_options[];
398
- extern const struct config_enum_entry recovery_target_action_options[];
399
- extern const struct config_enum_entry sync_method_options[];
400
- extern const struct config_enum_entry dynamic_shared_memory_options[];
401
-
402
- /*
403
- * GUC option variables that are exported from this module
404
- */
405
-
406
-
407
-
408
-
409
-
410
-
411
-
412
-
413
-
414
- /* this is sort of all three above
415
- * together */
416
-
417
-
418
-
419
-
420
- __thread bool check_function_bodies = true;
421
-
422
-
423
- /*
424
- * This GUC exists solely for backward compatibility, check its definition for
425
- * details.
426
- */
427
-
428
-
429
-
430
-
431
- __thread int log_min_messages = WARNING;
432
-
433
- __thread int client_min_messages = NOTICE;
434
-
435
-
436
-
437
-
438
-
439
-
440
-
441
-
442
-
443
- __thread char *backtrace_functions;
444
-
445
- __thread char *backtrace_symbol_list;
446
-
447
-
448
-
449
-
450
-
451
-
452
-
453
-
454
-
455
-
456
-
457
-
458
-
459
-
460
-
461
-
462
-
463
-
464
-
465
-
466
-
467
- /*
468
- * SSL renegotiation was been removed in PostgreSQL 9.5, but we tolerate it
469
- * being set to zero (meaning never renegotiate) for backward compatibility.
470
- * This avoids breaking compatibility with clients that have never supported
471
- * renegotiation and therefore always try to zero it.
472
- */
473
-
474
-
475
- /*
476
- * This really belongs in pg_shmem.c, but is defined here so that it doesn't
477
- * need to be duplicated in all the different implementations of pg_shmem.c.
478
- */
479
-
480
-
481
-
482
- /*
483
- * These variables are all dummies that don't do anything, except in some
484
- * cases provide the value for SHOW to display. The real state is elsewhere
485
- * and is kept in sync by assign_hooks.
486
- */
487
-
488
-
489
-
490
-
491
-
492
-
493
-
494
-
495
-
496
-
497
-
498
-
499
-
500
-
501
-
502
-
503
-
504
-
505
-
506
-
507
-
508
-
509
-
510
-
511
-
512
-
513
-
514
-
515
-
516
-
517
-
518
-
519
-
520
- /* should be static, but commands/variable.c needs to get at this */
521
-
522
-
523
-
524
- /*
525
- * Displayable names for context types (enum GucContext)
526
- *
527
- * Note: these strings are deliberately not localized.
528
- */
529
-
530
-
531
- StaticAssertDecl(lengthof(GucContext_Names) == (PGC_USERSET + 1),
532
- "array length mismatch");
533
-
534
- /*
535
- * Displayable names for source types (enum GucSource)
536
- *
537
- * Note: these strings are deliberately not localized.
538
- */
539
-
540
-
541
- StaticAssertDecl(lengthof(GucSource_Names) == (PGC_S_SESSION + 1),
542
- "array length mismatch");
543
-
544
- /*
545
- * Displayable names for the groupings defined in enum config_group
546
- */
547
-
548
-
549
- StaticAssertDecl(lengthof(config_group_names) == (DEVELOPER_OPTIONS + 2),
550
- "array length mismatch");
551
-
552
- /*
553
- * Displayable names for GUC variable types (enum config_type)
554
- *
555
- * Note: these strings are deliberately not localized.
556
- */
557
-
558
-
559
- StaticAssertDecl(lengthof(config_type_names) == (PGC_ENUM + 1),
560
- "array length mismatch");
561
-
562
- /*
563
- * Unit conversion tables.
564
- *
565
- * There are two tables, one for memory units, and another for time units.
566
- * For each supported conversion from one unit to another, we have an entry
567
- * in the table.
568
- *
569
- * To keep things simple, and to avoid possible roundoff error,
570
- * conversions are never chained. There needs to be a direct conversion
571
- * between all units (of the same type).
572
- *
573
- * The conversions for each base unit must be kept in order from greatest to
574
- * smallest human-friendly unit; convert_xxx_from_base_unit() rely on that.
575
- * (The order of the base-unit groups does not matter.)
576
- */
577
- #define MAX_UNIT_LEN 3 /* length of longest recognized unit string */
578
-
579
- typedef struct
580
- {
581
- char unit[MAX_UNIT_LEN + 1]; /* unit, as a string, like "kB" or
582
- * "min" */
583
- int base_unit; /* GUC_UNIT_XXX */
584
- double multiplier; /* Factor for converting unit -> base_unit */
585
- } unit_conversion;
586
-
587
- /* Ensure that the constants in the tables don't overflow or underflow */
588
- #if BLCKSZ < 1024 || BLCKSZ > (1024*1024)
589
- #error BLCKSZ must be between 1KB and 1MB
590
- #endif
591
- #if XLOG_BLCKSZ < 1024 || XLOG_BLCKSZ > (1024*1024)
592
- #error XLOG_BLCKSZ must be between 1KB and 1MB
593
- #endif
594
-
595
-
596
-
597
-
598
-
599
-
600
-
601
-
602
-
603
- /*
604
- * Contents of GUC tables
605
- *
606
- * See src/backend/utils/misc/README for design notes.
607
- *
608
- * TO ADD AN OPTION:
609
- *
610
- * 1. Declare a global variable of type bool, int, double, or char*
611
- * and make use of it.
612
- *
613
- * 2. Decide at what times it's safe to set the option. See guc.h for
614
- * details.
615
- *
616
- * 3. Decide on a name, a default value, upper and lower bounds (if
617
- * applicable), etc.
618
- *
619
- * 4. Add a record below.
620
- *
621
- * 5. Add it to src/backend/utils/misc/postgresql.conf.sample, if
622
- * appropriate.
623
- *
624
- * 6. Don't forget to document the option (at least in config.sgml).
625
- *
626
- * 7. If it's a new GUC_LIST_QUOTE option, you must add it to
627
- * variable_is_guc_list_quote() in src/bin/pg_dump/dumputils.c.
628
- */
629
-
630
-
631
- /******** option records follow ********/
632
-
633
- #ifdef USE_ASSERT_CHECKING
634
- #else
635
- #endif
636
- #ifdef BTREE_BUILD_STATS
637
- #endif
638
- #ifdef WIN32
639
- #else
640
- #endif
641
- #ifdef LOCK_DEBUG
642
- #endif
643
- #ifdef TRACE_SORT
644
- #endif
645
- #ifdef TRACE_SYNCSCAN
646
- #endif
647
- #ifdef DEBUG_BOUNDED_SORT
648
- #endif
649
- #ifdef WAL_DEBUG
650
- #endif
651
-
652
-
653
- #ifdef LOCK_DEBUG
654
- #endif
655
- #ifdef USE_PREFETCH
656
- #else
657
- #endif
658
- #ifdef USE_PREFETCH
659
- #else
660
- #endif
661
- #ifdef DISCARD_CACHES_ENABLED
662
- #if defined(CLOBBER_CACHE_RECURSIVELY)
663
- #else
664
- #endif
665
- #else /* not DISCARD_CACHES_ENABLED */
666
- #endif /* not DISCARD_CACHES_ENABLED */
667
-
668
-
669
-
670
-
671
-
672
- #ifdef HAVE_UNIX_SOCKETS
673
- #else
674
- #endif
675
- #ifdef USE_SSL
676
- #else
677
- #endif
678
- #ifdef USE_OPENSSL
679
- #else
680
- #endif
681
- #ifdef USE_SSL
682
- #else
683
- #endif
684
-
685
-
686
- #ifdef HAVE_SYSLOG
687
- #else
688
- #endif
689
-
690
- /******** end of options list ********/
691
-
692
-
693
- /*
694
- * To allow continued support of obsolete names for GUC variables, we apply
695
- * the following mappings to any unrecognized name. Note that an old name
696
- * should be mapped to a new one only if the new variable has very similar
697
- * semantics to the old.
698
- */
699
-
700
-
701
-
702
- /*
703
- * Actual lookup of variables is done through this single, sorted array.
704
- */
705
-
706
-
707
- /* Current number of variables contained in the vector */
708
-
709
-
710
- /* Vector capacity */
711
-
712
-
713
-
714
- /* true if need to do commit/abort work */
715
-
716
- /* true to enable GUC_REPORT */
717
-
718
- /* true if any GUC_REPORT reports are needed */
719
-
720
- /* 1 when in main transaction */
721
-
722
-
723
- static int guc_var_compare(const void *a, const void *b);
724
- static int guc_name_compare(const char *namea, const char *nameb);
725
- static void InitializeGUCOptionsFromEnvironment(void);
726
- static void InitializeOneGUCOption(struct config_generic *gconf);
727
- static void push_old_value(struct config_generic *gconf, GucAction action);
728
- static void ReportGUCOption(struct config_generic *record);
729
- static void reapply_stacked_values(struct config_generic *variable,
730
- struct config_string *pHolder,
731
- GucStack *stack,
732
- const char *curvalue,
733
- GucContext curscontext, GucSource cursource,
734
- Oid cursrole);
735
- static void ShowGUCConfigOption(const char *name, DestReceiver *dest);
736
- static void ShowAllGUCConfig(DestReceiver *dest);
737
- static char *_ShowOption(struct config_generic *record, bool use_units);
738
- static bool validate_option_array_item(const char *name, const char *value,
739
- bool skipIfNoPermissions);
740
- static void write_auto_conf_file(int fd, const char *filename, ConfigVariable *head_p);
741
- static void replace_auto_config_value(ConfigVariable **head_p, ConfigVariable **tail_p,
742
- const char *name, const char *value);
743
-
744
-
745
- /*
746
- * Some infrastructure for checking malloc/strdup/realloc calls
747
- */
748
-
749
-
750
-
751
-
752
-
753
-
754
-
755
- /*
756
- * Detect whether strval is referenced anywhere in a GUC string item
757
- */
758
-
759
-
760
- /*
761
- * Support for assigning to a field of a string GUC item. Free the prior
762
- * value if it's not referenced anywhere else in the item (including stacked
763
- * states).
764
- */
765
-
766
-
767
- /*
768
- * Detect whether an "extra" struct is referenced anywhere in a GUC item
769
- */
770
-
771
-
772
- /*
773
- * Support for assigning to an "extra" field of a GUC item. Free the prior
774
- * value if it's not referenced anywhere else in the item (including stacked
775
- * states).
776
- */
777
-
778
-
779
- /*
780
- * Support for copying a variable's active value into a stack entry.
781
- * The "extra" field associated with the active value is copied, too.
782
- *
783
- * NB: be sure stringval and extra fields of a new stack entry are
784
- * initialized to NULL before this is used, else we'll try to free() them.
785
- */
786
-
787
-
788
- /*
789
- * Support for discarding a no-longer-needed value in a stack entry.
790
- * The "extra" field associated with the stack entry is cleared, too.
791
- */
792
-
793
-
794
-
795
- /*
796
- * Fetch the sorted array pointer (exported for help_config.c's use ONLY)
797
- */
798
-
799
-
800
-
801
- /*
802
- * Build the sorted array. This is split out so that it could be
803
- * re-executed after startup (e.g., we could allow loadable modules to
804
- * add vars, and then we'd need to re-sort).
805
- */
806
-
807
-
808
- /*
809
- * Add a new GUC variable to the list of known variables. The
810
- * list is expanded if needed.
811
- */
812
-
813
-
814
- /*
815
- * Decide whether a proposed custom variable name is allowed.
816
- *
817
- * It must be two or more identifiers separated by dots, where the rules
818
- * for what is an identifier agree with scan.l. (If you change this rule,
819
- * adjust the errdetail in find_option().)
820
- */
821
-
822
-
823
- /*
824
- * Create and add a placeholder variable for a custom variable name.
825
- */
826
-
827
-
828
- /*
829
- * Look up option "name". If it exists, return a pointer to its record.
830
- * Otherwise, if create_placeholders is true and name is a valid-looking
831
- * custom variable name, we'll create and return a placeholder record.
832
- * Otherwise, if skip_errors is true, then we silently return NULL for
833
- * an unrecognized or invalid name. Otherwise, the error is reported at
834
- * error level elevel (and we return NULL if that's less than ERROR).
835
- *
836
- * Note: internal errors, primarily out-of-memory, draw an elevel-level
837
- * report and NULL return regardless of skip_errors. Hence, callers must
838
- * handle a NULL return whenever elevel < ERROR, but they should not need
839
- * to emit any additional error message. (In practice, internal errors
840
- * can only happen when create_placeholders is true, so callers passing
841
- * false need not think terribly hard about this.)
842
- */
843
-
844
-
845
-
846
- /*
847
- * comparator for qsorting and bsearching guc_variables array
848
- */
849
-
850
-
851
- /*
852
- * the bare comparison function for GUC names
853
- */
854
-
855
-
856
-
857
- /*
858
- * Convert a GUC name to the form that should be used in pg_parameter_acl.
859
- *
860
- * We need to canonicalize entries since, for example, case should not be
861
- * significant. In addition, we apply the map_old_guc_names[] mapping so that
862
- * any obsolete names will be converted when stored in a new PG version.
863
- * Note however that this function does not verify legality of the name.
864
- *
865
- * The result is a palloc'd string.
866
- */
867
-
868
-
869
- /*
870
- * Check whether we should allow creation of a pg_parameter_acl entry
871
- * for the given name. (This can be applied either before or after
872
- * canonicalizing it.)
873
- */
874
-
875
-
876
-
877
- /*
878
- * Initialize GUC options during program startup.
879
- *
880
- * Note that we cannot read the config file yet, since we have not yet
881
- * processed command-line switches.
882
- */
883
-
884
-
885
- /*
886
- * If any custom resource managers were specified in the
887
- * wal_consistency_checking GUC, processing was deferred. Now that
888
- * shared_preload_libraries have been loaded, process wal_consistency_checking
889
- * again.
890
- */
891
-
892
-
893
- /*
894
- * Assign any GUC values that can come from the server's environment.
895
- *
896
- * This is called from InitializeGUCOptions, and also from ProcessConfigFile
897
- * to deal with the possibility that a setting has been removed from
898
- * postgresql.conf and should now get a value from the environment.
899
- * (The latter is a kludge that should probably go away someday; if so,
900
- * fold this back into InitializeGUCOptions.)
901
- */
902
-
903
-
904
- /*
905
- * Initialize one GUC option variable to its compiled-in default.
906
- *
907
- * Note: the reason for calling check_hooks is not that we think the boot_val
908
- * might fail, but that the hooks might wish to compute an "extra" struct.
909
- */
910
-
911
-
912
-
913
- /*
914
- * Select the configuration files and data directory to be used, and
915
- * do the initial read of postgresql.conf.
916
- *
917
- * This is called after processing command-line switches.
918
- * userDoption is the -D switch value if any (NULL if unspecified).
919
- * progname is just for use in error messages.
920
- *
921
- * Returns true on success; on failure, prints a suitable error message
922
- * to stderr and returns false.
923
- */
924
-
925
-
926
-
927
- /*
928
- * Reset all options to their saved default values (implements RESET ALL)
929
- */
930
-
931
-
932
-
933
- /*
934
- * push_old_value
935
- * Push previous state during transactional assignment to a GUC variable.
936
- */
937
-
938
-
939
-
940
- /*
941
- * Do GUC processing at main transaction start.
942
- */
943
-
944
-
945
- /*
946
- * Enter a new nesting level for GUC values. This is called at subtransaction
947
- * start, and when entering a function that has proconfig settings, and in
948
- * some other places where we want to set GUC variables transiently.
949
- * NOTE we must not risk error here, else subtransaction start will be unhappy.
950
- */
951
-
952
-
953
- /*
954
- * Do GUC processing at transaction or subtransaction commit or abort, or
955
- * when exiting a function that has proconfig settings, or when undoing a
956
- * transient assignment to some GUC variables. (The name is thus a bit of
957
- * a misnomer; perhaps it should be ExitGUCNestLevel or some such.)
958
- * During abort, we discard all GUC settings that were applied at nesting
959
- * levels >= nestLevel. nestLevel == 1 corresponds to the main transaction.
960
- */
961
-
962
-
963
-
964
- /*
965
- * Start up automatic reporting of changes to variables marked GUC_REPORT.
966
- * This is executed at completion of backend startup.
967
- */
968
-
969
-
970
- /*
971
- * ReportChangedGUCOptions: report recently-changed GUC_REPORT variables
972
- *
973
- * This is called just before we wait for a new client query.
974
- *
975
- * By handling things this way, we ensure that a ParameterStatus message
976
- * is sent at most once per variable per query, even if the variable
977
- * changed multiple times within the query. That's quite possible when
978
- * using features such as function SET clauses. Function SET clauses
979
- * also tend to cause values to change intraquery but eventually revert
980
- * to their prevailing values; ReportGUCOption is responsible for avoiding
981
- * redundant reports in such cases.
982
- */
983
-
984
-
985
- /*
986
- * ReportGUCOption: if appropriate, transmit option value to frontend
987
- *
988
- * We need not transmit the value if it's the same as what we last
989
- * transmitted. However, clear the NEEDS_REPORT flag in any case.
990
- */
991
-
992
-
993
- /*
994
- * Convert a value from one of the human-friendly units ("kB", "min" etc.)
995
- * to the given base unit. 'value' and 'unit' are the input value and unit
996
- * to convert from (there can be trailing spaces in the unit string).
997
- * The converted value is stored in *base_value.
998
- * It's caller's responsibility to round off the converted value as necessary
999
- * and check for out-of-range.
1000
- *
1001
- * Returns true on success, false if the input unit is not recognized.
1002
- */
1003
-
1004
-
1005
- /*
1006
- * Convert an integer value in some base unit to a human-friendly unit.
1007
- *
1008
- * The output unit is chosen so that it's the greatest unit that can represent
1009
- * the value without loss. For example, if the base unit is GUC_UNIT_KB, 1024
1010
- * is converted to 1 MB, but 1025 is represented as 1025 kB.
1011
- */
1012
-
1013
-
1014
- /*
1015
- * Convert a floating-point value in some base unit to a human-friendly unit.
1016
- *
1017
- * Same as above, except we have to do the math a bit differently, and
1018
- * there's a possibility that we don't find any exact divisor.
1019
- */
1020
-
1021
-
1022
- /*
1023
- * Return the name of a GUC's base unit (e.g. "ms") given its flags.
1024
- * Return NULL if the GUC is unitless.
1025
- */
1026
-
1027
-
1028
-
1029
- /*
1030
- * Try to parse value as an integer. The accepted formats are the
1031
- * usual decimal, octal, or hexadecimal formats, as well as floating-point
1032
- * formats (which will be rounded to integer after any units conversion).
1033
- * Optionally, the value can be followed by a unit name if "flags" indicates
1034
- * a unit is allowed.
1035
- *
1036
- * If the string parses okay, return true, else false.
1037
- * If okay and result is not NULL, return the value in *result.
1038
- * If not okay and hintmsg is not NULL, *hintmsg is set to a suitable
1039
- * HINT message, or NULL if no hint provided.
1040
- */
1041
-
1042
-
1043
- /*
1044
- * Try to parse value as a floating point number in the usual format.
1045
- * Optionally, the value can be followed by a unit name if "flags" indicates
1046
- * a unit is allowed.
1047
- *
1048
- * If the string parses okay, return true, else false.
1049
- * If okay and result is not NULL, return the value in *result.
1050
- * If not okay and hintmsg is not NULL, *hintmsg is set to a suitable
1051
- * HINT message, or NULL if no hint provided.
1052
- */
1053
-
1054
-
1055
-
1056
- /*
1057
- * Lookup the name for an enum option with the selected value.
1058
- * Should only ever be called with known-valid values, so throws
1059
- * an elog(ERROR) if the enum option is not found.
1060
- *
1061
- * The returned string is a pointer to static data and not
1062
- * allocated for modification.
1063
- */
1064
-
1065
-
1066
-
1067
- /*
1068
- * Lookup the value for an enum option with the selected name
1069
- * (case-insensitive).
1070
- * If the enum option is found, sets the retval value and returns
1071
- * true. If it's not found, return false and retval is set to 0.
1072
- */
1073
-
1074
-
1075
-
1076
- /*
1077
- * Return a list of all available options for an enum, excluding
1078
- * hidden ones, separated by the given separator.
1079
- * If prefix is non-NULL, it is added before the first enum value.
1080
- * If suffix is non-NULL, it is added to the end of the string.
1081
- */
1082
-
1083
-
1084
- /*
1085
- * Parse and validate a proposed value for the specified configuration
1086
- * parameter.
1087
- *
1088
- * This does built-in checks (such as range limits for an integer parameter)
1089
- * and also calls any check hook the parameter may have.
1090
- *
1091
- * record: GUC variable's info record
1092
- * name: variable name (should match the record of course)
1093
- * value: proposed value, as a string
1094
- * source: identifies source of value (check hooks may need this)
1095
- * elevel: level to log any error reports at
1096
- * newval: on success, converted parameter value is returned here
1097
- * newextra: on success, receives any "extra" data returned by check hook
1098
- * (caller must initialize *newextra to NULL)
1099
- *
1100
- * Returns true if OK, false if not (or throws error, if elevel >= ERROR)
1101
- */
1102
-
1103
-
1104
-
1105
- /*
1106
- * set_config_option: sets option `name' to given value.
1107
- *
1108
- * The value should be a string, which will be parsed and converted to
1109
- * the appropriate data type. The context and source parameters indicate
1110
- * in which context this function is being called, so that it can apply the
1111
- * access restrictions properly.
1112
- *
1113
- * If value is NULL, set the option to its default value (normally the
1114
- * reset_val, but if source == PGC_S_DEFAULT we instead use the boot_val).
1115
- *
1116
- * action indicates whether to set the value globally in the session, locally
1117
- * to the current top transaction, or just for the duration of a function call.
1118
- *
1119
- * If changeVal is false then don't really set the option but do all
1120
- * the checks to see if it would work.
1121
- *
1122
- * elevel should normally be passed as zero, allowing this function to make
1123
- * its standard choice of ereport level. However some callers need to be
1124
- * able to override that choice; they should pass the ereport level to use.
1125
- *
1126
- * is_reload should be true only when called from read_nondefault_variables()
1127
- * or RestoreGUCState(), where we are trying to load some other process's
1128
- * GUC settings into a new process.
1129
- *
1130
- * Return value:
1131
- * +1: the value is valid and was successfully applied.
1132
- * 0: the name or value is invalid (but see below).
1133
- * -1: the value was not applied because of context, priority, or changeVal.
1134
- *
1135
- * If there is an error (non-existing option, invalid value) then an
1136
- * ereport(ERROR) is thrown *unless* this is called for a source for which
1137
- * we don't want an ERROR (currently, those are defaults, the config file,
1138
- * and per-database or per-user settings, as well as callers who specify
1139
- * a less-than-ERROR elevel). In those cases we write a suitable error
1140
- * message via ereport() and return 0.
1141
- *
1142
- * See also SetConfigOption for an external interface.
1143
- */
1144
-
1145
-
1146
- /*
1147
- * set_config_option_ext: sets option `name' to given value.
1148
- *
1149
- * This API adds the ability to explicitly specify which role OID
1150
- * is considered to be setting the value. Most external callers can use
1151
- * set_config_option() and let it determine that based on the GucSource,
1152
- * but there are a few that are supplying a value that was determined
1153
- * in some special way and need to override the decision. Also, when
1154
- * restoring a previously-assigned value, it's important to supply the
1155
- * same role OID that set the value originally; so all guc.c callers
1156
- * that are doing that type of thing need to call this directly.
1157
- *
1158
- * Generally, srole should be GetUserId() when the source is a SQL operation,
1159
- * or BOOTSTRAP_SUPERUSERID if the source is a config file or similar.
1160
- */
1161
- #define newval (newval_union.boolval)
1162
- #undef newval
1163
- #define newval (newval_union.intval)
1164
- #undef newval
1165
- #define newval (newval_union.realval)
1166
- #undef newval
1167
- #define newval (newval_union.stringval)
1168
- #undef newval
1169
- #define newval (newval_union.enumval)
1170
- #undef newval
1171
-
1172
-
1173
- /*
1174
- * Set the fields for source file and line number the setting came from.
1175
- */
1176
-
1177
-
1178
- /*
1179
- * Set a config option to the given value.
1180
- *
1181
- * See also set_config_option; this is just the wrapper to be called from
1182
- * outside GUC. (This function should be used when possible, because its API
1183
- * is more stable than set_config_option's.)
1184
- *
1185
- * Note: there is no support here for setting source file/line, as it
1186
- * is currently not needed.
1187
- */
1188
-
1189
-
1190
-
1191
-
1192
- /*
1193
- * Fetch the current value of the option `name', as a string.
1194
- *
1195
- * If the option doesn't exist, return NULL if missing_ok is true (NOTE that
1196
- * this cannot be distinguished from a string variable with a NULL value!),
1197
- * otherwise throw an ereport and don't return.
1198
- *
1199
- * If restrict_privileged is true, we also enforce that only superusers and
1200
- * members of the pg_read_all_settings role can see GUC_SUPERUSER_ONLY
1201
- * variables. This should only be passed as true in user-driven calls.
1202
- *
1203
- * The string is *not* allocated for modification and is really only
1204
- * valid until the next call to configuration related functions.
1205
- */
1206
-
1207
-
1208
- /*
1209
- * Get the RESET value associated with the given option.
1210
- *
1211
- * Note: this is not re-entrant, due to use of static result buffer;
1212
- * not to mention that a string variable could have its reset_val changed.
1213
- * Beware of assuming the result value is good for very long.
1214
- */
1215
-
1216
-
1217
- /*
1218
- * Get the GUC flags associated with the given option.
1219
- *
1220
- * If the option doesn't exist, return 0 if missing_ok is true,
1221
- * otherwise throw an ereport and don't return.
1222
- */
1223
-
1224
-
1225
-
1226
- /*
1227
- * flatten_set_variable_args
1228
- * Given a parsenode List as emitted by the grammar for SET,
1229
- * convert to the flat string representation used by GUC.
1230
- *
1231
- * We need to be told the name of the variable the args are for, because
1232
- * the flattening rules vary (ugh).
1233
- *
1234
- * The result is NULL if args is NIL (i.e., SET ... TO DEFAULT), otherwise
1235
- * a palloc'd string.
1236
- */
1237
-
1238
-
1239
- /*
1240
- * Write updated configuration parameter values into a temporary file.
1241
- * This function traverses the list of parameters and quotes the string
1242
- * values before writing them.
1243
- */
1244
-
1245
-
1246
- /*
1247
- * Update the given list of configuration parameters, adding, replacing
1248
- * or deleting the entry for item "name" (delete if "value" == NULL).
1249
- */
1250
-
1251
-
1252
-
1253
- /*
1254
- * Execute ALTER SYSTEM statement.
1255
- *
1256
- * Read the old PG_AUTOCONF_FILENAME file, merge in the new variable value,
1257
- * and write out an updated file. If the command is ALTER SYSTEM RESET ALL,
1258
- * we can skip reading the old file and just write an empty file.
1259
- *
1260
- * An LWLock is used to serialize updates of the configuration file.
1261
- *
1262
- * In case of an error, we leave the original automatic
1263
- * configuration file (PG_AUTOCONF_FILENAME) intact.
1264
- */
1265
-
1266
-
1267
- /*
1268
- * SET command
1269
- */
1270
-
1271
-
1272
- /*
1273
- * Get the value to assign for a VariableSetStmt, or NULL if it's RESET.
1274
- * The result is palloc'd.
1275
- *
1276
- * This is exported for use by actions such as ALTER ROLE SET.
1277
- */
1278
-
1279
-
1280
- /*
1281
- * SetPGVariable - SET command exported as an easily-C-callable function.
1282
- *
1283
- * This provides access to SET TO value, as well as SET TO DEFAULT (expressed
1284
- * by passing args == NIL), but not SET FROM CURRENT functionality.
1285
- */
1286
-
1287
-
1288
- /*
1289
- * SET command wrapped as a SQL callable function.
1290
- */
1291
-
1292
-
1293
-
1294
- /*
1295
- * Common code for DefineCustomXXXVariable subroutines: allocate the
1296
- * new variable's config struct and fill in generic fields.
1297
- */
1298
-
1299
-
1300
- /*
1301
- * Common code for DefineCustomXXXVariable subroutines: insert the new
1302
- * variable into the GUC variable array, replacing any placeholder.
1303
- */
1304
-
1305
-
1306
- /*
1307
- * Recursive subroutine for define_custom_variable: reapply non-reset values
1308
- *
1309
- * We recurse so that the values are applied in the same order as originally.
1310
- * At each recursion level, apply the upper-level value (passed in) in the
1311
- * fashion implied by the stack entry.
1312
- */
1313
-
1314
-
1315
- /*
1316
- * Functions for extensions to call to define their custom GUC variables.
1317
- */
1318
-
1319
-
1320
-
1321
-
1322
-
1323
-
1324
-
1325
-
1326
-
1327
-
1328
- /*
1329
- * Mark the given GUC prefix as "reserved".
1330
- *
1331
- * This deletes any existing placeholders matching the prefix,
1332
- * and then prevents new ones from being created.
1333
- * Extensions should call this after they've defined all of their custom
1334
- * GUCs, to help catch misspelled config-file entries.
1335
- */
1336
-
1337
-
1338
-
1339
- /*
1340
- * SHOW command
1341
- */
1342
-
1343
-
1344
-
1345
-
1346
-
1347
- /*
1348
- * SHOW command
1349
- */
1350
-
1351
-
1352
- /*
1353
- * SHOW ALL command
1354
- */
1355
-
1356
-
1357
- /*
1358
- * Return an array of modified GUC options to show in EXPLAIN.
1359
- *
1360
- * We only report options related to query planning (marked with GUC_EXPLAIN),
1361
- * with values different from their built-in defaults.
1362
- */
1363
-
1364
-
1365
- /*
1366
- * Return GUC variable value by name; optionally return canonical form of
1367
- * name. If the GUC is unset, then throw an error unless missing_ok is true,
1368
- * in which case return NULL. Return value is palloc'd (but *varname isn't).
1369
- */
1370
-
1371
-
1372
- /*
1373
- * Return some of the flags associated to the specified GUC in the shape of
1374
- * a text array, and NULL if it does not exist. An empty array is returned
1375
- * if the GUC exists without any meaningful flags to show.
1376
- */
1377
- #define MAX_GUC_FLAGS 5
1378
-
1379
- /*
1380
- * Return GUC variable value by variable number; optionally return canonical
1381
- * form of name. Return value is palloc'd.
1382
- */
1383
-
1384
-
1385
- /*
1386
- * Return the total number of GUC variables
1387
- */
1388
-
1389
-
1390
- /*
1391
- * show_config_by_name - equiv to SHOW X command but implemented as
1392
- * a function.
1393
- */
1394
-
1395
-
1396
- /*
1397
- * show_config_by_name_missing_ok - equiv to SHOW X command but implemented as
1398
- * a function. If X does not exist, suppress the error and just return NULL
1399
- * if missing_ok is true.
1400
- */
1401
-
1402
-
1403
- /*
1404
- * show_all_settings - equiv to SHOW ALL command but implemented as
1405
- * a Table Function.
1406
- */
1407
- #define NUM_PG_SETTINGS_ATTS 17
1408
-
1409
-
1410
-
1411
- /*
1412
- * show_all_file_settings
1413
- *
1414
- * Returns a table of all parameter settings in all configuration files
1415
- * which includes the config file pathname, the line number, a sequence number
1416
- * indicating the order in which the settings were encountered, the parameter
1417
- * name and value, a bool showing if the value could be applied, and possibly
1418
- * an associated error message. (For problems such as syntax errors, the
1419
- * parameter name/value might be NULL.)
1420
- *
1421
- * Note: no filtering is done here, instead we depend on the GRANT system
1422
- * to prevent unprivileged users from accessing this function or the view
1423
- * built on top of it.
1424
- */
1425
- #define NUM_PG_FILE_SETTINGS_ATTS 7
1426
-
1427
-
1428
-
1429
-
1430
- #ifdef EXEC_BACKEND
1431
-
1432
- /*
1433
- * These routines dump out all non-default GUC options into a binary
1434
- * file that is read by all exec'ed backends. The format is:
1435
- *
1436
- * variable name, string, null terminated
1437
- * variable value, string, null terminated
1438
- * variable sourcefile, string, null terminated (empty if none)
1439
- * variable sourceline, integer
1440
- * variable source, integer
1441
- * variable scontext, integer
1442
- * variable srole, OID
1443
- */
1444
- static void
1445
- write_one_nondefault_variable(FILE *fp, struct config_generic *gconf)
1446
- {
1447
- if (gconf->source == PGC_S_DEFAULT)
1448
- return;
1449
-
1450
- fprintf(fp, "%s", gconf->name);
1451
- fputc(0, fp);
1452
-
1453
- switch (gconf->vartype)
1454
- {
1455
- case PGC_BOOL:
1456
- {
1457
- struct config_bool *conf = (struct config_bool *) gconf;
1458
-
1459
- if (*conf->variable)
1460
- fprintf(fp, "true");
1461
- else
1462
- fprintf(fp, "false");
1463
- }
1464
- break;
1465
-
1466
- case PGC_INT:
1467
- {
1468
- struct config_int *conf = (struct config_int *) gconf;
1469
-
1470
- fprintf(fp, "%d", *conf->variable);
1471
- }
1472
- break;
1473
-
1474
- case PGC_REAL:
1475
- {
1476
- struct config_real *conf = (struct config_real *) gconf;
1477
-
1478
- fprintf(fp, "%.17g", *conf->variable);
1479
- }
1480
- break;
1481
-
1482
- case PGC_STRING:
1483
- {
1484
- struct config_string *conf = (struct config_string *) gconf;
1485
-
1486
- fprintf(fp, "%s", *conf->variable);
1487
- }
1488
- break;
1489
-
1490
- case PGC_ENUM:
1491
- {
1492
- struct config_enum *conf = (struct config_enum *) gconf;
1493
-
1494
- fprintf(fp, "%s",
1495
- config_enum_lookup_by_value(conf, *conf->variable));
1496
- }
1497
- break;
1498
- }
1499
-
1500
- fputc(0, fp);
1501
-
1502
- if (gconf->sourcefile)
1503
- fprintf(fp, "%s", gconf->sourcefile);
1504
- fputc(0, fp);
1505
-
1506
- fwrite(&gconf->sourceline, 1, sizeof(gconf->sourceline), fp);
1507
- fwrite(&gconf->source, 1, sizeof(gconf->source), fp);
1508
- fwrite(&gconf->scontext, 1, sizeof(gconf->scontext), fp);
1509
- fwrite(&gconf->srole, 1, sizeof(gconf->srole), fp);
1510
- }
1511
-
1512
- void
1513
- write_nondefault_variables(GucContext context)
1514
- {
1515
- int elevel;
1516
- FILE *fp;
1517
- int i;
1518
-
1519
- Assert(context == PGC_POSTMASTER || context == PGC_SIGHUP);
1520
-
1521
- elevel = (context == PGC_SIGHUP) ? LOG : ERROR;
1522
-
1523
- /*
1524
- * Open file
1525
- */
1526
- fp = AllocateFile(CONFIG_EXEC_PARAMS_NEW, "w");
1527
- if (!fp)
1528
- {
1529
- ereport(elevel,
1530
- (errcode_for_file_access(),
1531
- errmsg("could not write to file \"%s\": %m",
1532
- CONFIG_EXEC_PARAMS_NEW)));
1533
- return;
1534
- }
1535
-
1536
- for (i = 0; i < num_guc_variables; i++)
1537
- {
1538
- write_one_nondefault_variable(fp, guc_variables[i]);
1539
- }
1540
-
1541
- if (FreeFile(fp))
1542
- {
1543
- ereport(elevel,
1544
- (errcode_for_file_access(),
1545
- errmsg("could not write to file \"%s\": %m",
1546
- CONFIG_EXEC_PARAMS_NEW)));
1547
- return;
1548
- }
1549
-
1550
- /*
1551
- * Put new file in place. This could delay on Win32, but we don't hold
1552
- * any exclusive locks.
1553
- */
1554
- rename(CONFIG_EXEC_PARAMS_NEW, CONFIG_EXEC_PARAMS);
1555
- }
1556
-
1557
-
1558
- /*
1559
- * Read string, including null byte from file
1560
- *
1561
- * Return NULL on EOF and nothing read
1562
- */
1563
- static char *
1564
- read_string_with_null(FILE *fp)
1565
- {
1566
- int i = 0,
1567
- ch,
1568
- maxlen = 256;
1569
- char *str = NULL;
1570
-
1571
- do
1572
- {
1573
- if ((ch = fgetc(fp)) == EOF)
1574
- {
1575
- if (i == 0)
1576
- return NULL;
1577
- else
1578
- elog(FATAL, "invalid format of exec config params file");
1579
- }
1580
- if (i == 0)
1581
- str = guc_malloc(FATAL, maxlen);
1582
- else if (i == maxlen)
1583
- str = guc_realloc(FATAL, str, maxlen *= 2);
1584
- str[i++] = ch;
1585
- } while (ch != 0);
1586
-
1587
- return str;
1588
- }
1589
-
1590
-
1591
- /*
1592
- * This routine loads a previous postmaster dump of its non-default
1593
- * settings.
1594
- */
1595
- void
1596
- read_nondefault_variables(void)
1597
- {
1598
- FILE *fp;
1599
- char *varname,
1600
- *varvalue,
1601
- *varsourcefile;
1602
- int varsourceline;
1603
- GucSource varsource;
1604
- GucContext varscontext;
1605
- Oid varsrole;
1606
-
1607
- /*
1608
- * Open file
1609
- */
1610
- fp = AllocateFile(CONFIG_EXEC_PARAMS, "r");
1611
- if (!fp)
1612
- {
1613
- /* File not found is fine */
1614
- if (errno != ENOENT)
1615
- ereport(FATAL,
1616
- (errcode_for_file_access(),
1617
- errmsg("could not read from file \"%s\": %m",
1618
- CONFIG_EXEC_PARAMS)));
1619
- return;
1620
- }
1621
-
1622
- for (;;)
1623
- {
1624
- struct config_generic *record;
1625
-
1626
- if ((varname = read_string_with_null(fp)) == NULL)
1627
- break;
1628
-
1629
- if ((record = find_option(varname, true, false, FATAL)) == NULL)
1630
- elog(FATAL, "failed to locate variable \"%s\" in exec config params file", varname);
1631
-
1632
- if ((varvalue = read_string_with_null(fp)) == NULL)
1633
- elog(FATAL, "invalid format of exec config params file");
1634
- if ((varsourcefile = read_string_with_null(fp)) == NULL)
1635
- elog(FATAL, "invalid format of exec config params file");
1636
- if (fread(&varsourceline, 1, sizeof(varsourceline), fp) != sizeof(varsourceline))
1637
- elog(FATAL, "invalid format of exec config params file");
1638
- if (fread(&varsource, 1, sizeof(varsource), fp) != sizeof(varsource))
1639
- elog(FATAL, "invalid format of exec config params file");
1640
- if (fread(&varscontext, 1, sizeof(varscontext), fp) != sizeof(varscontext))
1641
- elog(FATAL, "invalid format of exec config params file");
1642
- if (fread(&varsrole, 1, sizeof(varsrole), fp) != sizeof(varsrole))
1643
- elog(FATAL, "invalid format of exec config params file");
1644
-
1645
- (void) set_config_option_ext(varname, varvalue,
1646
- varscontext, varsource, varsrole,
1647
- GUC_ACTION_SET, true, 0, true);
1648
- if (varsourcefile[0])
1649
- set_config_sourcefile(varname, varsourcefile, varsourceline);
1650
-
1651
- free(varname);
1652
- free(varvalue);
1653
- free(varsourcefile);
1654
- }
1655
-
1656
- FreeFile(fp);
1657
- }
1658
- #endif /* EXEC_BACKEND */
1659
-
1660
- /*
1661
- * can_skip_gucvar:
1662
- * Decide whether SerializeGUCState can skip sending this GUC variable,
1663
- * or whether RestoreGUCState can skip resetting this GUC to default.
1664
- *
1665
- * It is somewhat magical and fragile that the same test works for both cases.
1666
- * Realize in particular that we are very likely selecting different sets of
1667
- * GUCs on the leader and worker sides! Be sure you've understood the
1668
- * comments here and in RestoreGUCState thoroughly before changing this.
1669
- */
1670
-
1671
-
1672
- /*
1673
- * estimate_variable_size:
1674
- * Compute space needed for dumping the given GUC variable.
1675
- *
1676
- * It's OK to overestimate, but not to underestimate.
1677
- */
1678
-
1679
-
1680
- /*
1681
- * EstimateGUCStateSpace:
1682
- * Returns the size needed to store the GUC state for the current process
1683
- */
1684
-
1685
-
1686
- /*
1687
- * do_serialize:
1688
- * Copies the formatted string into the destination. Moves ahead the
1689
- * destination pointer, and decrements the maxbytes by that many bytes. If
1690
- * maxbytes is not sufficient to copy the string, error out.
1691
- */
1692
-
1693
-
1694
- /* Binary copy version of do_serialize() */
1695
-
1696
-
1697
- /*
1698
- * serialize_variable:
1699
- * Dumps name, value and other information of a GUC variable into destptr.
1700
- */
1701
-
1702
-
1703
- /*
1704
- * SerializeGUCState:
1705
- * Dumps the complete GUC state onto the memory location at start_address.
1706
- */
1707
-
1708
-
1709
- /*
1710
- * read_gucstate:
1711
- * Actually it does not read anything, just returns the srcptr. But it does
1712
- * move the srcptr past the terminating zero byte, so that the caller is ready
1713
- * to read the next string.
1714
- */
1715
-
1716
-
1717
- /* Binary read version of read_gucstate(). Copies into dest */
1718
-
1719
-
1720
- /*
1721
- * Callback used to add a context message when reporting errors that occur
1722
- * while trying to restore GUCs in parallel workers.
1723
- */
1724
-
1725
-
1726
- /*
1727
- * RestoreGUCState:
1728
- * Reads the GUC state at the specified address and sets this process's
1729
- * GUCs to match.
1730
- *
1731
- * Note that this provides the worker with only a very shallow view of the
1732
- * leader's GUC state: we'll know about the currently active values, but not
1733
- * about stacked or reset values. That's fine since the worker is just
1734
- * executing one part of a query, within which the active values won't change
1735
- * and the stacked values are invisible.
1736
- */
1737
-
1738
-
1739
- /*
1740
- * A little "long argument" simulation, although not quite GNU
1741
- * compliant. Takes a string of the form "some-option=some value" and
1742
- * returns name = "some_option" and value = "some value" in malloc'ed
1743
- * storage. Note that '-' is converted to '_' in the option name. If
1744
- * there is no '=' in the input string then value will be NULL.
1745
- */
1746
-
1747
-
1748
-
1749
- /*
1750
- * Handle options fetched from pg_db_role_setting.setconfig,
1751
- * pg_proc.proconfig, etc. Caller must specify proper context/source/action.
1752
- *
1753
- * The array parameter must be an array of TEXT (it must not be NULL).
1754
- */
1755
-
1756
-
1757
-
1758
- /*
1759
- * Add an entry to an option array. The array parameter may be NULL
1760
- * to indicate the current table entry is NULL.
1761
- */
1762
-
1763
-
1764
-
1765
- /*
1766
- * Delete an entry from an option array. The array parameter may be NULL
1767
- * to indicate the current table entry is NULL. Also, if the return value
1768
- * is NULL then a null should be stored.
1769
- */
1770
-
1771
-
1772
-
1773
- /*
1774
- * Given a GUC array, delete all settings from it that our permission
1775
- * level allows: if superuser, delete them all; if regular user, only
1776
- * those that are PGC_USERSET or we have permission to set
1777
- */
1778
-
1779
-
1780
- /*
1781
- * Validate a proposed option setting for GUCArrayAdd/Delete/Reset.
1782
- *
1783
- * name is the option name. value is the proposed value for the Add case,
1784
- * or NULL for the Delete/Reset cases. If skipIfNoPermissions is true, it's
1785
- * not an error to have no permissions to set the option.
1786
- *
1787
- * Returns true if OK, false if skipIfNoPermissions is true and user does not
1788
- * have permission to change this option (all other error cases result in an
1789
- * error being thrown).
1790
- */
1791
-
1792
-
1793
-
1794
- /*
1795
- * Called by check_hooks that want to override the normal
1796
- * ERRCODE_INVALID_PARAMETER_VALUE SQLSTATE for check hook failures.
1797
- *
1798
- * Note that GUC_check_errmsg() etc are just macros that result in a direct
1799
- * assignment to the associated variables. That is ugly, but forced by the
1800
- * limitations of C's macro mechanisms.
1801
- */
1802
-
1803
-
1804
-
1805
- /*
1806
- * Convenience functions to manage calling a variable's check_hook.
1807
- * These mostly take care of the protocol for letting check hooks supply
1808
- * portions of the error report on failure.
1809
- */
1810
-
1811
-
1812
-
1813
-
1814
-
1815
-
1816
-
1817
-
1818
-
1819
-
1820
-
1821
-
1822
- /*
1823
- * check_hook, assign_hook and show_hook subroutines
1824
- */
1825
-
1826
-
1827
-
1828
-
1829
-
1830
- #ifdef HAVE_SYSLOG
1831
- #endif
1832
- #ifdef WIN32
1833
- #endif
1834
-
1835
-
1836
-
1837
- #ifdef HAVE_SYSLOG
1838
- #endif
1839
-
1840
- #ifdef HAVE_SYSLOG
1841
- #endif
1842
-
1843
-
1844
-
1845
-
1846
-
1847
-
1848
- #ifndef USE_BONJOUR
1849
- #endif
1850
-
1851
- #ifndef USE_SSL
1852
- #endif
1853
-
1854
-
1855
-
1856
-
1857
-
1858
-
1859
-
1860
-
1861
-
1862
-
1863
-
1864
- /*
1865
- * pg_timezone_abbrev_initialize --- set default value if not done already
1866
- *
1867
- * This is called after initial loading of postgresql.conf. If no
1868
- * timezone_abbreviations setting was found therein, select default.
1869
- * If a non-default value is already installed, nothing will happen.
1870
- *
1871
- * This can also be called from ProcessConfigFile to establish the default
1872
- * value after a postgresql.conf entry for it is removed.
1873
- */
1874
-
1875
-
1876
-
1877
-
1878
-
1879
-
1880
-
1881
-
1882
-
1883
-
1884
-
1885
-
1886
-
1887
-
1888
-
1889
-
1890
-
1891
-
1892
-
1893
-
1894
-
1895
-
1896
-
1897
-
1898
-
1899
-
1900
-
1901
-
1902
-
1903
-
1904
- #ifndef USE_PREFETCH
1905
- #endif /* USE_PREFETCH */
1906
-
1907
- #ifndef USE_PREFETCH
1908
- #endif /* USE_PREFETCH */
1909
-
1910
- #if !(defined(MAP_HUGE_MASK) && defined(MAP_HUGE_SHIFT))
1911
- #endif
1912
-
1913
-
1914
-
1915
- #ifdef USE_PREFETCH
1916
- #endif
1917
-
1918
-
1919
-
1920
-
1921
-
1922
-
1923
-
1924
-
1925
-
1926
-
1927
-
1928
-
1929
-
1930
-
1931
-
1932
- /*
1933
- * We split the input string, where commas separate function names
1934
- * and certain whitespace chars are ignored, into a \0-separated (and
1935
- * \0\0-terminated) list of function names. This formulation allows
1936
- * easy scanning when an error is thrown while avoiding the use of
1937
- * non-reentrant strtok(), as well as keeping the output data in a
1938
- * single palloc() chunk.
1939
- */
1940
-
1941
-
1942
-
1943
-
1944
-
1945
-
1946
-
1947
-
1948
- /*
1949
- * Recovery target settings: Only one of the several recovery_target* settings
1950
- * may be set. Setting a second one results in an error. The global variable
1951
- * recoveryTarget tracks which kind of recovery target was chosen. Other
1952
- * variables store the actual target value (for example a string or a xid).
1953
- * The assign functions of the parameters check whether a competing parameter
1954
- * was already set. But we want to allow setting the same parameter multiple
1955
- * times. We also want to allow unsetting a parameter and setting a different
1956
- * one, so we unset recoveryTarget when the parameter is set to an empty
1957
- * string.
1958
- */
1959
-
1960
-
1961
-
1962
-
1963
-
1964
-
1965
-
1966
-
1967
-
1968
-
1969
-
1970
- /*
1971
- * The interpretation of the recovery_target_time string can depend on the
1972
- * time zone setting, so we need to wait until after all GUC processing is
1973
- * done before we can do the final parsing of the string. This check function
1974
- * only does a parsing pass to catch syntax errors, but we store the string
1975
- * and parse it again when we need to use it.
1976
- */
1977
-
1978
-
1979
-
1980
-
1981
-
1982
-
1983
-
1984
-
1985
-
1986
-
1987
-
1988
-
1989
-
1990
-
1991
-
1992
-
1993
- #include "guc-file.c"