gitlab-pg_query 1.3.1 → 2.0.4

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