pg_query 1.2.0 → 2.0.3

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 +80 -69
  4. data/Rakefile +85 -5
  5. data/ext/pg_query/extconf.rb +4 -31
  6. data/ext/pg_query/guc-file.c +0 -0
  7. data/ext/pg_query/include/access/amapi.h +246 -0
  8. data/ext/pg_query/include/access/attmap.h +52 -0
  9. data/ext/pg_query/include/access/attnum.h +64 -0
  10. data/ext/pg_query/include/access/clog.h +61 -0
  11. data/ext/pg_query/include/access/commit_ts.h +77 -0
  12. data/ext/pg_query/include/access/detoast.h +92 -0
  13. data/ext/pg_query/include/access/genam.h +228 -0
  14. data/ext/pg_query/include/access/gin.h +78 -0
  15. data/ext/pg_query/include/access/htup.h +89 -0
  16. data/ext/pg_query/include/access/htup_details.h +819 -0
  17. data/ext/pg_query/include/access/itup.h +161 -0
  18. data/ext/pg_query/include/access/parallel.h +82 -0
  19. data/ext/pg_query/include/access/printtup.h +35 -0
  20. data/ext/pg_query/include/access/relation.h +28 -0
  21. data/ext/pg_query/include/access/relscan.h +176 -0
  22. data/ext/pg_query/include/access/rmgr.h +35 -0
  23. data/ext/pg_query/include/access/rmgrlist.h +49 -0
  24. data/ext/pg_query/include/access/sdir.h +58 -0
  25. data/ext/pg_query/include/access/skey.h +151 -0
  26. data/ext/pg_query/include/access/stratnum.h +83 -0
  27. data/ext/pg_query/include/access/sysattr.h +29 -0
  28. data/ext/pg_query/include/access/table.h +27 -0
  29. data/ext/pg_query/include/access/tableam.h +1825 -0
  30. data/ext/pg_query/include/access/transam.h +265 -0
  31. data/ext/pg_query/include/access/tupconvert.h +51 -0
  32. data/ext/pg_query/include/access/tupdesc.h +154 -0
  33. data/ext/pg_query/include/access/tupmacs.h +247 -0
  34. data/ext/pg_query/include/access/twophase.h +61 -0
  35. data/ext/pg_query/include/access/xact.h +463 -0
  36. data/ext/pg_query/include/access/xlog.h +398 -0
  37. data/ext/pg_query/include/access/xlog_internal.h +330 -0
  38. data/ext/pg_query/include/access/xlogdefs.h +109 -0
  39. data/ext/pg_query/include/access/xloginsert.h +64 -0
  40. data/ext/pg_query/include/access/xlogreader.h +327 -0
  41. data/ext/pg_query/include/access/xlogrecord.h +227 -0
  42. data/ext/pg_query/include/bootstrap/bootstrap.h +62 -0
  43. data/ext/pg_query/include/c.h +1322 -0
  44. data/ext/pg_query/include/catalog/catalog.h +42 -0
  45. data/ext/pg_query/include/catalog/catversion.h +58 -0
  46. data/ext/pg_query/include/catalog/dependency.h +275 -0
  47. data/ext/pg_query/include/catalog/genbki.h +64 -0
  48. data/ext/pg_query/include/catalog/index.h +199 -0
  49. data/ext/pg_query/include/catalog/indexing.h +366 -0
  50. data/ext/pg_query/include/catalog/namespace.h +188 -0
  51. data/ext/pg_query/include/catalog/objectaccess.h +197 -0
  52. data/ext/pg_query/include/catalog/objectaddress.h +84 -0
  53. data/ext/pg_query/include/catalog/pg_aggregate.h +176 -0
  54. data/ext/pg_query/include/catalog/pg_aggregate_d.h +77 -0
  55. data/ext/pg_query/include/catalog/pg_am.h +60 -0
  56. data/ext/pg_query/include/catalog/pg_am_d.h +45 -0
  57. data/ext/pg_query/include/catalog/pg_attribute.h +204 -0
  58. data/ext/pg_query/include/catalog/pg_attribute_d.h +59 -0
  59. data/ext/pg_query/include/catalog/pg_authid.h +58 -0
  60. data/ext/pg_query/include/catalog/pg_authid_d.h +49 -0
  61. data/ext/pg_query/include/catalog/pg_class.h +200 -0
  62. data/ext/pg_query/include/catalog/pg_class_d.h +103 -0
  63. data/ext/pg_query/include/catalog/pg_collation.h +73 -0
  64. data/ext/pg_query/include/catalog/pg_collation_d.h +45 -0
  65. data/ext/pg_query/include/catalog/pg_constraint.h +247 -0
  66. data/ext/pg_query/include/catalog/pg_constraint_d.h +67 -0
  67. data/ext/pg_query/include/catalog/pg_control.h +250 -0
  68. data/ext/pg_query/include/catalog/pg_conversion.h +72 -0
  69. data/ext/pg_query/include/catalog/pg_conversion_d.h +35 -0
  70. data/ext/pg_query/include/catalog/pg_depend.h +73 -0
  71. data/ext/pg_query/include/catalog/pg_depend_d.h +34 -0
  72. data/ext/pg_query/include/catalog/pg_event_trigger.h +51 -0
  73. data/ext/pg_query/include/catalog/pg_event_trigger_d.h +34 -0
  74. data/ext/pg_query/include/catalog/pg_index.h +80 -0
  75. data/ext/pg_query/include/catalog/pg_index_d.h +56 -0
  76. data/ext/pg_query/include/catalog/pg_language.h +67 -0
  77. data/ext/pg_query/include/catalog/pg_language_d.h +39 -0
  78. data/ext/pg_query/include/catalog/pg_namespace.h +59 -0
  79. data/ext/pg_query/include/catalog/pg_namespace_d.h +34 -0
  80. data/ext/pg_query/include/catalog/pg_opclass.h +85 -0
  81. data/ext/pg_query/include/catalog/pg_opclass_d.h +49 -0
  82. data/ext/pg_query/include/catalog/pg_operator.h +102 -0
  83. data/ext/pg_query/include/catalog/pg_operator_d.h +106 -0
  84. data/ext/pg_query/include/catalog/pg_opfamily.h +60 -0
  85. data/ext/pg_query/include/catalog/pg_opfamily_d.h +47 -0
  86. data/ext/pg_query/include/catalog/pg_partitioned_table.h +63 -0
  87. data/ext/pg_query/include/catalog/pg_partitioned_table_d.h +35 -0
  88. data/ext/pg_query/include/catalog/pg_proc.h +211 -0
  89. data/ext/pg_query/include/catalog/pg_proc_d.h +99 -0
  90. data/ext/pg_query/include/catalog/pg_publication.h +115 -0
  91. data/ext/pg_query/include/catalog/pg_publication_d.h +36 -0
  92. data/ext/pg_query/include/catalog/pg_replication_origin.h +57 -0
  93. data/ext/pg_query/include/catalog/pg_replication_origin_d.h +29 -0
  94. data/ext/pg_query/include/catalog/pg_statistic.h +275 -0
  95. data/ext/pg_query/include/catalog/pg_statistic_d.h +194 -0
  96. data/ext/pg_query/include/catalog/pg_statistic_ext.h +74 -0
  97. data/ext/pg_query/include/catalog/pg_statistic_ext_d.h +40 -0
  98. data/ext/pg_query/include/catalog/pg_transform.h +45 -0
  99. data/ext/pg_query/include/catalog/pg_transform_d.h +32 -0
  100. data/ext/pg_query/include/catalog/pg_trigger.h +137 -0
  101. data/ext/pg_query/include/catalog/pg_trigger_d.h +106 -0
  102. data/ext/pg_query/include/catalog/pg_ts_config.h +50 -0
  103. data/ext/pg_query/include/catalog/pg_ts_config_d.h +32 -0
  104. data/ext/pg_query/include/catalog/pg_ts_dict.h +54 -0
  105. data/ext/pg_query/include/catalog/pg_ts_dict_d.h +33 -0
  106. data/ext/pg_query/include/catalog/pg_ts_parser.h +57 -0
  107. data/ext/pg_query/include/catalog/pg_ts_parser_d.h +35 -0
  108. data/ext/pg_query/include/catalog/pg_ts_template.h +48 -0
  109. data/ext/pg_query/include/catalog/pg_ts_template_d.h +32 -0
  110. data/ext/pg_query/include/catalog/pg_type.h +372 -0
  111. data/ext/pg_query/include/catalog/pg_type_d.h +285 -0
  112. data/ext/pg_query/include/catalog/storage.h +48 -0
  113. data/ext/pg_query/include/commands/async.h +54 -0
  114. data/ext/pg_query/include/commands/dbcommands.h +35 -0
  115. data/ext/pg_query/include/commands/defrem.h +173 -0
  116. data/ext/pg_query/include/commands/event_trigger.h +88 -0
  117. data/ext/pg_query/include/commands/explain.h +127 -0
  118. data/ext/pg_query/include/commands/prepare.h +61 -0
  119. data/ext/pg_query/include/commands/tablespace.h +67 -0
  120. data/ext/pg_query/include/commands/trigger.h +277 -0
  121. data/ext/pg_query/include/commands/user.h +37 -0
  122. data/ext/pg_query/include/commands/vacuum.h +293 -0
  123. data/ext/pg_query/include/commands/variable.h +38 -0
  124. data/ext/pg_query/include/common/file_perm.h +56 -0
  125. data/ext/pg_query/include/common/hashfn.h +104 -0
  126. data/ext/pg_query/include/common/ip.h +37 -0
  127. data/ext/pg_query/include/common/keywords.h +33 -0
  128. data/ext/pg_query/include/common/kwlookup.h +44 -0
  129. data/ext/pg_query/include/common/relpath.h +90 -0
  130. data/ext/pg_query/include/common/string.h +19 -0
  131. data/ext/pg_query/include/common/unicode_combining_table.h +196 -0
  132. data/ext/pg_query/include/datatype/timestamp.h +197 -0
  133. data/ext/pg_query/include/executor/execdesc.h +70 -0
  134. data/ext/pg_query/include/executor/executor.h +614 -0
  135. data/ext/pg_query/include/executor/functions.h +41 -0
  136. data/ext/pg_query/include/executor/instrument.h +101 -0
  137. data/ext/pg_query/include/executor/spi.h +175 -0
  138. data/ext/pg_query/include/executor/tablefunc.h +67 -0
  139. data/ext/pg_query/include/executor/tuptable.h +487 -0
  140. data/ext/pg_query/include/fmgr.h +775 -0
  141. data/ext/pg_query/include/funcapi.h +348 -0
  142. data/ext/pg_query/include/getaddrinfo.h +162 -0
  143. data/ext/pg_query/include/jit/jit.h +105 -0
  144. data/ext/pg_query/include/kwlist_d.h +1072 -0
  145. data/ext/pg_query/include/lib/ilist.h +727 -0
  146. data/ext/pg_query/include/lib/pairingheap.h +102 -0
  147. data/ext/pg_query/include/lib/simplehash.h +1059 -0
  148. data/ext/pg_query/include/lib/stringinfo.h +161 -0
  149. data/ext/pg_query/include/libpq/auth.h +29 -0
  150. data/ext/pg_query/include/libpq/crypt.h +46 -0
  151. data/ext/pg_query/include/libpq/hba.h +140 -0
  152. data/ext/pg_query/include/libpq/libpq-be.h +326 -0
  153. data/ext/pg_query/include/libpq/libpq.h +133 -0
  154. data/ext/pg_query/include/libpq/pqcomm.h +208 -0
  155. data/ext/pg_query/include/libpq/pqformat.h +210 -0
  156. data/ext/pg_query/include/libpq/pqsignal.h +42 -0
  157. data/ext/pg_query/include/mb/pg_wchar.h +672 -0
  158. data/ext/pg_query/include/mb/stringinfo_mb.h +24 -0
  159. data/ext/pg_query/include/miscadmin.h +476 -0
  160. data/ext/pg_query/include/nodes/bitmapset.h +122 -0
  161. data/ext/pg_query/include/nodes/execnodes.h +2520 -0
  162. data/ext/pg_query/include/nodes/extensible.h +160 -0
  163. data/ext/pg_query/include/nodes/lockoptions.h +61 -0
  164. data/ext/pg_query/include/nodes/makefuncs.h +108 -0
  165. data/ext/pg_query/include/nodes/memnodes.h +108 -0
  166. data/ext/pg_query/include/nodes/nodeFuncs.h +162 -0
  167. data/ext/pg_query/include/nodes/nodes.h +842 -0
  168. data/ext/pg_query/include/nodes/params.h +170 -0
  169. data/ext/pg_query/include/nodes/parsenodes.h +3579 -0
  170. data/ext/pg_query/include/nodes/pathnodes.h +2556 -0
  171. data/ext/pg_query/include/nodes/pg_list.h +605 -0
  172. data/ext/pg_query/include/nodes/plannodes.h +1251 -0
  173. data/ext/pg_query/include/nodes/primnodes.h +1541 -0
  174. data/ext/pg_query/include/nodes/print.h +34 -0
  175. data/ext/pg_query/include/nodes/tidbitmap.h +75 -0
  176. data/ext/pg_query/include/nodes/value.h +61 -0
  177. data/ext/pg_query/include/optimizer/cost.h +206 -0
  178. data/ext/pg_query/include/optimizer/geqo.h +88 -0
  179. data/ext/pg_query/include/optimizer/geqo_gene.h +45 -0
  180. data/ext/pg_query/include/optimizer/optimizer.h +199 -0
  181. data/ext/pg_query/include/optimizer/paths.h +249 -0
  182. data/ext/pg_query/include/optimizer/planmain.h +119 -0
  183. data/ext/pg_query/include/parser/analyze.h +49 -0
  184. data/ext/pg_query/include/parser/gram.h +1067 -0
  185. data/ext/pg_query/include/parser/gramparse.h +75 -0
  186. data/ext/pg_query/include/parser/kwlist.h +477 -0
  187. data/ext/pg_query/include/parser/parse_agg.h +68 -0
  188. data/ext/pg_query/include/parser/parse_clause.h +54 -0
  189. data/ext/pg_query/include/parser/parse_coerce.h +97 -0
  190. data/ext/pg_query/include/parser/parse_collate.h +27 -0
  191. data/ext/pg_query/include/parser/parse_expr.h +26 -0
  192. data/ext/pg_query/include/parser/parse_func.h +73 -0
  193. data/ext/pg_query/include/parser/parse_node.h +327 -0
  194. data/ext/pg_query/include/parser/parse_oper.h +67 -0
  195. data/ext/pg_query/include/parser/parse_relation.h +123 -0
  196. data/ext/pg_query/include/parser/parse_target.h +46 -0
  197. data/ext/pg_query/include/parser/parse_type.h +60 -0
  198. data/ext/pg_query/include/parser/parser.h +41 -0
  199. data/ext/pg_query/include/parser/parsetree.h +61 -0
  200. data/ext/pg_query/include/parser/scanner.h +152 -0
  201. data/ext/pg_query/include/parser/scansup.h +30 -0
  202. data/ext/pg_query/include/partitioning/partdefs.h +26 -0
  203. data/ext/pg_query/include/pg_config.h +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 -1478
  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 -200
  466. data/lib/pg_query/parse_error.rb +1 -1
  467. data/lib/pg_query/pg_query_pb.rb +3211 -0
  468. data/lib/pg_query/scan.rb +23 -0
  469. data/lib/pg_query/treewalker.rb +24 -40
  470. data/lib/pg_query/truncate.rb +71 -42
  471. data/lib/pg_query/version.rb +2 -2
  472. metadata +473 -12
  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 -293
@@ -0,0 +1,1051 @@
1
+ /*--------------------------------------------------------------------
2
+ * Symbols referenced in this file:
3
+ * - NameListToString
4
+ * - get_collation_oid
5
+ *--------------------------------------------------------------------
6
+ */
7
+
8
+ /*-------------------------------------------------------------------------
9
+ *
10
+ * namespace.c
11
+ * code to support accessing and searching namespaces
12
+ *
13
+ * This is separate from pg_namespace.c, which contains the routines that
14
+ * directly manipulate the pg_namespace system catalog. This module
15
+ * provides routines associated with defining a "namespace search path"
16
+ * and implementing search-path-controlled searches.
17
+ *
18
+ *
19
+ * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
20
+ * Portions Copyright (c) 1994, Regents of the University of California
21
+ *
22
+ * IDENTIFICATION
23
+ * src/backend/catalog/namespace.c
24
+ *
25
+ *-------------------------------------------------------------------------
26
+ */
27
+ #include "postgres.h"
28
+
29
+ #include "access/htup_details.h"
30
+ #include "access/parallel.h"
31
+ #include "access/xact.h"
32
+ #include "access/xlog.h"
33
+ #include "catalog/dependency.h"
34
+ #include "catalog/objectaccess.h"
35
+ #include "catalog/pg_authid.h"
36
+ #include "catalog/pg_collation.h"
37
+ #include "catalog/pg_conversion.h"
38
+ #include "catalog/pg_namespace.h"
39
+ #include "catalog/pg_opclass.h"
40
+ #include "catalog/pg_operator.h"
41
+ #include "catalog/pg_opfamily.h"
42
+ #include "catalog/pg_proc.h"
43
+ #include "catalog/pg_statistic_ext.h"
44
+ #include "catalog/pg_ts_config.h"
45
+ #include "catalog/pg_ts_dict.h"
46
+ #include "catalog/pg_ts_parser.h"
47
+ #include "catalog/pg_ts_template.h"
48
+ #include "catalog/pg_type.h"
49
+ #include "commands/dbcommands.h"
50
+ #include "funcapi.h"
51
+ #include "mb/pg_wchar.h"
52
+ #include "miscadmin.h"
53
+ #include "nodes/makefuncs.h"
54
+ #include "parser/parse_func.h"
55
+ #include "storage/ipc.h"
56
+ #include "storage/lmgr.h"
57
+ #include "storage/sinvaladt.h"
58
+ #include "utils/acl.h"
59
+ #include "utils/builtins.h"
60
+ #include "utils/catcache.h"
61
+ #include "utils/guc.h"
62
+ #include "utils/inval.h"
63
+ #include "utils/lsyscache.h"
64
+ #include "utils/memutils.h"
65
+ #include "utils/syscache.h"
66
+ #include "utils/varlena.h"
67
+
68
+
69
+ /*
70
+ * The namespace search path is a possibly-empty list of namespace OIDs.
71
+ * In addition to the explicit list, implicitly-searched namespaces
72
+ * may be included:
73
+ *
74
+ * 1. If a TEMP table namespace has been initialized in this session, it
75
+ * is implicitly searched first. (The only time this doesn't happen is
76
+ * when we are obeying an override search path spec that says not to use the
77
+ * temp namespace, or the temp namespace is included in the explicit list.)
78
+ *
79
+ * 2. The system catalog namespace is always searched. If the system
80
+ * namespace is present in the explicit path then it will be searched in
81
+ * the specified order; otherwise it will be searched after TEMP tables and
82
+ * *before* the explicit list. (It might seem that the system namespace
83
+ * should be implicitly last, but this behavior appears to be required by
84
+ * SQL99. Also, this provides a way to search the system namespace first
85
+ * without thereby making it the default creation target namespace.)
86
+ *
87
+ * For security reasons, searches using the search path will ignore the temp
88
+ * namespace when searching for any object type other than relations and
89
+ * types. (We must allow types since temp tables have rowtypes.)
90
+ *
91
+ * The default creation target namespace is always the first element of the
92
+ * explicit list. If the explicit list is empty, there is no default target.
93
+ *
94
+ * The textual specification of search_path can include "$user" to refer to
95
+ * the namespace named the same as the current user, if any. (This is just
96
+ * ignored if there is no such namespace.) Also, it can include "pg_temp"
97
+ * to refer to the current backend's temp namespace. This is usually also
98
+ * ignorable if the temp namespace hasn't been set up, but there's a special
99
+ * case: if "pg_temp" appears first then it should be the default creation
100
+ * target. We kluge this case a little bit so that the temp namespace isn't
101
+ * set up until the first attempt to create something in it. (The reason for
102
+ * klugery is that we can't create the temp namespace outside a transaction,
103
+ * but initial GUC processing of search_path happens outside a transaction.)
104
+ * activeTempCreationPending is true if "pg_temp" appears first in the string
105
+ * but is not reflected in activeCreationNamespace because the namespace isn't
106
+ * set up yet.
107
+ *
108
+ * In bootstrap mode, the search path is set equal to "pg_catalog", so that
109
+ * the system namespace is the only one searched or inserted into.
110
+ * initdb is also careful to set search_path to "pg_catalog" for its
111
+ * post-bootstrap standalone backend runs. Otherwise the default search
112
+ * path is determined by GUC. The factory default path contains the PUBLIC
113
+ * namespace (if it exists), preceded by the user's personal namespace
114
+ * (if one exists).
115
+ *
116
+ * We support a stack of "override" search path settings for use within
117
+ * specific sections of backend code. namespace_search_path is ignored
118
+ * whenever the override stack is nonempty. activeSearchPath is always
119
+ * the actually active path; it points either to the search list of the
120
+ * topmost stack entry, or to baseSearchPath which is the list derived
121
+ * from namespace_search_path.
122
+ *
123
+ * If baseSearchPathValid is false, then baseSearchPath (and other
124
+ * derived variables) need to be recomputed from namespace_search_path.
125
+ * We mark it invalid upon an assignment to namespace_search_path or receipt
126
+ * of a syscache invalidation event for pg_namespace. The recomputation
127
+ * is done during the next non-overridden lookup attempt. Note that an
128
+ * override spec is never subject to recomputation.
129
+ *
130
+ * Any namespaces mentioned in namespace_search_path that are not readable
131
+ * by the current user ID are simply left out of baseSearchPath; so
132
+ * we have to be willing to recompute the path when current userid changes.
133
+ * namespaceUser is the userid the path has been computed for.
134
+ *
135
+ * Note: all data pointed to by these List variables is in TopMemoryContext.
136
+ *
137
+ * activePathGeneration is incremented whenever the effective values of
138
+ * activeSearchPath/activeCreationNamespace/activeTempCreationPending change.
139
+ * This can be used to quickly detect whether any change has happened since
140
+ * a previous examination of the search path state.
141
+ */
142
+
143
+ /* These variables define the actually active state: */
144
+
145
+
146
+
147
+ /* default place to create stuff; if InvalidOid, no default */
148
+
149
+
150
+ /* if true, activeCreationNamespace is wrong, it should be temp namespace */
151
+
152
+
153
+ /* current generation counter; make sure this is never zero */
154
+
155
+
156
+ /* These variables are the values last derived from namespace_search_path: */
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+ /* The above four values are valid only if baseSearchPathValid */
167
+
168
+
169
+ /* Override requests are remembered in a stack of OverrideStackEntry structs */
170
+
171
+ typedef struct
172
+ {
173
+ List *searchPath; /* the desired search path */
174
+ Oid creationNamespace; /* the desired creation namespace */
175
+ int nestLevel; /* subtransaction nesting level */
176
+ } OverrideStackEntry;
177
+
178
+
179
+
180
+ /*
181
+ * myTempNamespace is InvalidOid until and unless a TEMP namespace is set up
182
+ * in a particular backend session (this happens when a CREATE TEMP TABLE
183
+ * command is first executed). Thereafter it's the OID of the temp namespace.
184
+ *
185
+ * myTempToastNamespace is the OID of the namespace for my temp tables' toast
186
+ * tables. It is set when myTempNamespace is, and is InvalidOid before that.
187
+ *
188
+ * myTempNamespaceSubID shows whether we've created the TEMP namespace in the
189
+ * current subtransaction. The flag propagates up the subtransaction tree,
190
+ * so the main transaction will correctly recognize the flag if all
191
+ * intermediate subtransactions commit. When it is InvalidSubTransactionId,
192
+ * we either haven't made the TEMP namespace yet, or have successfully
193
+ * committed its creation, depending on whether myTempNamespace is valid.
194
+ */
195
+
196
+
197
+
198
+
199
+
200
+
201
+ /*
202
+ * This is the user's textual search path specification --- it's the value
203
+ * of the GUC variable 'search_path'.
204
+ */
205
+
206
+
207
+
208
+ /* Local functions */
209
+ static void recomputeNamespacePath(void);
210
+ static void AccessTempTableNamespace(bool force);
211
+ static void InitTempTableNamespace(void);
212
+ static void RemoveTempRelations(Oid tempNamespaceId);
213
+ static void RemoveTempRelationsCallback(int code, Datum arg);
214
+ static void NamespaceCallback(Datum arg, int cacheid, uint32 hashvalue);
215
+ static bool MatchNamedCall(HeapTuple proctup, int nargs, List *argnames,
216
+ int **argnumbers);
217
+
218
+
219
+ /*
220
+ * RangeVarGetRelidExtended
221
+ * Given a RangeVar describing an existing relation,
222
+ * select the proper namespace and look up the relation OID.
223
+ *
224
+ * If the schema or relation is not found, return InvalidOid if flags contains
225
+ * RVR_MISSING_OK, otherwise raise an error.
226
+ *
227
+ * If flags contains RVR_NOWAIT, throw an error if we'd have to wait for a
228
+ * lock.
229
+ *
230
+ * If flags contains RVR_SKIP_LOCKED, return InvalidOid if we'd have to wait
231
+ * for a lock.
232
+ *
233
+ * flags cannot contain both RVR_NOWAIT and RVR_SKIP_LOCKED.
234
+ *
235
+ * Note that if RVR_MISSING_OK and RVR_SKIP_LOCKED are both specified, a
236
+ * return value of InvalidOid could either mean the relation is missing or it
237
+ * could not be locked.
238
+ *
239
+ * Callback allows caller to check permissions or acquire additional locks
240
+ * prior to grabbing the relation lock.
241
+ */
242
+
243
+
244
+ /*
245
+ * RangeVarGetCreationNamespace
246
+ * Given a RangeVar describing a to-be-created relation,
247
+ * choose which namespace to create it in.
248
+ *
249
+ * Note: calling this may result in a CommandCounterIncrement operation.
250
+ * That will happen on the first request for a temp table in any particular
251
+ * backend run; we will need to either create or clean out the temp schema.
252
+ */
253
+
254
+
255
+ /*
256
+ * RangeVarGetAndCheckCreationNamespace
257
+ *
258
+ * This function returns the OID of the namespace in which a new relation
259
+ * with a given name should be created. If the user does not have CREATE
260
+ * permission on the target namespace, this function will instead signal
261
+ * an ERROR.
262
+ *
263
+ * If non-NULL, *existing_relation_id is set to the OID of any existing relation
264
+ * with the same name which already exists in that namespace, or to InvalidOid
265
+ * if no such relation exists.
266
+ *
267
+ * If lockmode != NoLock, the specified lock mode is acquired on the existing
268
+ * relation, if any, provided that the current user owns the target relation.
269
+ * However, if lockmode != NoLock and the user does not own the target
270
+ * relation, we throw an ERROR, as we must not try to lock relations the
271
+ * user does not have permissions on.
272
+ *
273
+ * As a side effect, this function acquires AccessShareLock on the target
274
+ * namespace. Without this, the namespace could be dropped before our
275
+ * transaction commits, leaving behind relations with relnamespace pointing
276
+ * to a no-longer-existent namespace.
277
+ *
278
+ * As a further side-effect, if the selected namespace is a temporary namespace,
279
+ * we mark the RangeVar as RELPERSISTENCE_TEMP.
280
+ */
281
+
282
+
283
+ /*
284
+ * Adjust the relpersistence for an about-to-be-created relation based on the
285
+ * creation namespace, and throw an error for invalid combinations.
286
+ */
287
+
288
+
289
+ /*
290
+ * RelnameGetRelid
291
+ * Try to resolve an unqualified relation name.
292
+ * Returns OID if relation found in search path, else InvalidOid.
293
+ */
294
+
295
+
296
+
297
+ /*
298
+ * RelationIsVisible
299
+ * Determine whether a relation (identified by OID) is visible in the
300
+ * current search path. Visible means "would be found by searching
301
+ * for the unqualified relation name".
302
+ */
303
+
304
+
305
+
306
+ /*
307
+ * TypenameGetTypid
308
+ * Wrapper for binary compatibility.
309
+ */
310
+
311
+
312
+ /*
313
+ * TypenameGetTypidExtended
314
+ * Try to resolve an unqualified datatype name.
315
+ * Returns OID if type found in search path, else InvalidOid.
316
+ *
317
+ * This is essentially the same as RelnameGetRelid.
318
+ */
319
+
320
+
321
+ /*
322
+ * TypeIsVisible
323
+ * Determine whether a type (identified by OID) is visible in the
324
+ * current search path. Visible means "would be found by searching
325
+ * for the unqualified type name".
326
+ */
327
+
328
+
329
+
330
+ /*
331
+ * FuncnameGetCandidates
332
+ * Given a possibly-qualified function name and argument count,
333
+ * retrieve a list of the possible matches.
334
+ *
335
+ * If nargs is -1, we return all functions matching the given name,
336
+ * regardless of argument count. (argnames must be NIL, and expand_variadic
337
+ * and expand_defaults must be false, in this case.)
338
+ *
339
+ * If argnames isn't NIL, we are considering a named- or mixed-notation call,
340
+ * and only functions having all the listed argument names will be returned.
341
+ * (We assume that length(argnames) <= nargs and all the passed-in names are
342
+ * distinct.) The returned structs will include an argnumbers array showing
343
+ * the actual argument index for each logical argument position.
344
+ *
345
+ * If expand_variadic is true, then variadic functions having the same number
346
+ * or fewer arguments will be retrieved, with the variadic argument and any
347
+ * additional argument positions filled with the variadic element type.
348
+ * nvargs in the returned struct is set to the number of such arguments.
349
+ * If expand_variadic is false, variadic arguments are not treated specially,
350
+ * and the returned nvargs will always be zero.
351
+ *
352
+ * If expand_defaults is true, functions that could match after insertion of
353
+ * default argument values will also be retrieved. In this case the returned
354
+ * structs could have nargs > passed-in nargs, and ndargs is set to the number
355
+ * of additional args (which can be retrieved from the function's
356
+ * proargdefaults entry).
357
+ *
358
+ * It is not possible for nvargs and ndargs to both be nonzero in the same
359
+ * list entry, since default insertion allows matches to functions with more
360
+ * than nargs arguments while the variadic transformation requires the same
361
+ * number or less.
362
+ *
363
+ * When argnames isn't NIL, the returned args[] type arrays are not ordered
364
+ * according to the functions' declarations, but rather according to the call:
365
+ * first any positional arguments, then the named arguments, then defaulted
366
+ * arguments (if needed and allowed by expand_defaults). The argnumbers[]
367
+ * array can be used to map this back to the catalog information.
368
+ * argnumbers[k] is set to the proargtypes index of the k'th call argument.
369
+ *
370
+ * We search a single namespace if the function name is qualified, else
371
+ * all namespaces in the search path. In the multiple-namespace case,
372
+ * we arrange for entries in earlier namespaces to mask identical entries in
373
+ * later namespaces.
374
+ *
375
+ * When expanding variadics, we arrange for non-variadic functions to mask
376
+ * variadic ones if the expanded argument list is the same. It is still
377
+ * possible for there to be conflicts between different variadic functions,
378
+ * however.
379
+ *
380
+ * It is guaranteed that the return list will never contain multiple entries
381
+ * with identical argument lists. When expand_defaults is true, the entries
382
+ * could have more than nargs positions, but we still guarantee that they are
383
+ * distinct in the first nargs positions. However, if argnames isn't NIL or
384
+ * either expand_variadic or expand_defaults is true, there might be multiple
385
+ * candidate functions that expand to identical argument lists. Rather than
386
+ * throw error here, we report such situations by returning a single entry
387
+ * with oid = 0 that represents a set of such conflicting candidates.
388
+ * The caller might end up discarding such an entry anyway, but if it selects
389
+ * such an entry it should react as though the call were ambiguous.
390
+ *
391
+ * If missing_ok is true, an empty list (NULL) is returned if the name was
392
+ * schema- qualified with a schema that does not exist. Likewise if no
393
+ * candidate is found for other reasons.
394
+ */
395
+
396
+
397
+ /*
398
+ * MatchNamedCall
399
+ * Given a pg_proc heap tuple and a call's list of argument names,
400
+ * check whether the function could match the call.
401
+ *
402
+ * The call could match if all supplied argument names are accepted by
403
+ * the function, in positions after the last positional argument, and there
404
+ * are defaults for all unsupplied arguments.
405
+ *
406
+ * The number of positional arguments is nargs - list_length(argnames).
407
+ * Note caller has already done basic checks on argument count.
408
+ *
409
+ * On match, return true and fill *argnumbers with a palloc'd array showing
410
+ * the mapping from call argument positions to actual function argument
411
+ * numbers. Defaulted arguments are included in this map, at positions
412
+ * after the last supplied argument.
413
+ */
414
+
415
+
416
+ /*
417
+ * FunctionIsVisible
418
+ * Determine whether a function (identified by OID) is visible in the
419
+ * current search path. Visible means "would be found by searching
420
+ * for the unqualified function name with exact argument matches".
421
+ */
422
+
423
+
424
+
425
+ /*
426
+ * OpernameGetOprid
427
+ * Given a possibly-qualified operator name and exact input datatypes,
428
+ * look up the operator. Returns InvalidOid if not found.
429
+ *
430
+ * Pass oprleft = InvalidOid for a prefix op, oprright = InvalidOid for
431
+ * a postfix op.
432
+ *
433
+ * If the operator name is not schema-qualified, it is sought in the current
434
+ * namespace search path. If the name is schema-qualified and the given
435
+ * schema does not exist, InvalidOid is returned.
436
+ */
437
+
438
+
439
+ /*
440
+ * OpernameGetCandidates
441
+ * Given a possibly-qualified operator name and operator kind,
442
+ * retrieve a list of the possible matches.
443
+ *
444
+ * If oprkind is '\0', we return all operators matching the given name,
445
+ * regardless of arguments.
446
+ *
447
+ * We search a single namespace if the operator name is qualified, else
448
+ * all namespaces in the search path. The return list will never contain
449
+ * multiple entries with identical argument lists --- in the multiple-
450
+ * namespace case, we arrange for entries in earlier namespaces to mask
451
+ * identical entries in later namespaces.
452
+ *
453
+ * The returned items always have two args[] entries --- one or the other
454
+ * will be InvalidOid for a prefix or postfix oprkind. nargs is 2, too.
455
+ */
456
+ #define SPACE_PER_OP MAXALIGN(offsetof(struct _FuncCandidateList, args) + \
457
+ 2 * sizeof(Oid))
458
+
459
+ /*
460
+ * OperatorIsVisible
461
+ * Determine whether an operator (identified by OID) is visible in the
462
+ * current search path. Visible means "would be found by searching
463
+ * for the unqualified operator name with exact argument matches".
464
+ */
465
+
466
+
467
+
468
+ /*
469
+ * OpclassnameGetOpcid
470
+ * Try to resolve an unqualified index opclass name.
471
+ * Returns OID if opclass found in search path, else InvalidOid.
472
+ *
473
+ * This is essentially the same as TypenameGetTypid, but we have to have
474
+ * an extra argument for the index AM OID.
475
+ */
476
+
477
+
478
+ /*
479
+ * OpclassIsVisible
480
+ * Determine whether an opclass (identified by OID) is visible in the
481
+ * current search path. Visible means "would be found by searching
482
+ * for the unqualified opclass name".
483
+ */
484
+
485
+
486
+ /*
487
+ * OpfamilynameGetOpfid
488
+ * Try to resolve an unqualified index opfamily name.
489
+ * Returns OID if opfamily found in search path, else InvalidOid.
490
+ *
491
+ * This is essentially the same as TypenameGetTypid, but we have to have
492
+ * an extra argument for the index AM OID.
493
+ */
494
+
495
+
496
+ /*
497
+ * OpfamilyIsVisible
498
+ * Determine whether an opfamily (identified by OID) is visible in the
499
+ * current search path. Visible means "would be found by searching
500
+ * for the unqualified opfamily name".
501
+ */
502
+
503
+
504
+ /*
505
+ * lookup_collation
506
+ * If there's a collation of the given name/namespace, and it works
507
+ * with the given encoding, return its OID. Else return InvalidOid.
508
+ */
509
+
510
+
511
+ /*
512
+ * CollationGetCollid
513
+ * Try to resolve an unqualified collation name.
514
+ * Returns OID if collation found in search path, else InvalidOid.
515
+ *
516
+ * Note that this will only find collations that work with the current
517
+ * database's encoding.
518
+ */
519
+
520
+
521
+ /*
522
+ * CollationIsVisible
523
+ * Determine whether a collation (identified by OID) is visible in the
524
+ * current search path. Visible means "would be found by searching
525
+ * for the unqualified collation name".
526
+ *
527
+ * Note that only collations that work with the current database's encoding
528
+ * will be considered visible.
529
+ */
530
+
531
+
532
+
533
+ /*
534
+ * ConversionGetConid
535
+ * Try to resolve an unqualified conversion name.
536
+ * Returns OID if conversion found in search path, else InvalidOid.
537
+ *
538
+ * This is essentially the same as RelnameGetRelid.
539
+ */
540
+
541
+
542
+ /*
543
+ * ConversionIsVisible
544
+ * Determine whether a conversion (identified by OID) is visible in the
545
+ * current search path. Visible means "would be found by searching
546
+ * for the unqualified conversion name".
547
+ */
548
+
549
+
550
+ /*
551
+ * get_statistics_object_oid - find a statistics object by possibly qualified name
552
+ *
553
+ * If not found, returns InvalidOid if missing_ok, else throws error
554
+ */
555
+
556
+
557
+ /*
558
+ * StatisticsObjIsVisible
559
+ * Determine whether a statistics object (identified by OID) is visible in
560
+ * the current search path. Visible means "would be found by searching
561
+ * for the unqualified statistics object name".
562
+ */
563
+
564
+
565
+ /*
566
+ * get_ts_parser_oid - find a TS parser by possibly qualified name
567
+ *
568
+ * If not found, returns InvalidOid if missing_ok, else throws error
569
+ */
570
+
571
+
572
+ /*
573
+ * TSParserIsVisible
574
+ * Determine whether a parser (identified by OID) is visible in the
575
+ * current search path. Visible means "would be found by searching
576
+ * for the unqualified parser name".
577
+ */
578
+
579
+
580
+ /*
581
+ * get_ts_dict_oid - find a TS dictionary by possibly qualified name
582
+ *
583
+ * If not found, returns InvalidOid if missing_ok, else throws error
584
+ */
585
+
586
+
587
+ /*
588
+ * TSDictionaryIsVisible
589
+ * Determine whether a dictionary (identified by OID) is visible in the
590
+ * current search path. Visible means "would be found by searching
591
+ * for the unqualified dictionary name".
592
+ */
593
+
594
+
595
+ /*
596
+ * get_ts_template_oid - find a TS template by possibly qualified name
597
+ *
598
+ * If not found, returns InvalidOid if missing_ok, else throws error
599
+ */
600
+
601
+
602
+ /*
603
+ * TSTemplateIsVisible
604
+ * Determine whether a template (identified by OID) is visible in the
605
+ * current search path. Visible means "would be found by searching
606
+ * for the unqualified template name".
607
+ */
608
+
609
+
610
+ /*
611
+ * get_ts_config_oid - find a TS config by possibly qualified name
612
+ *
613
+ * If not found, returns InvalidOid if missing_ok, else throws error
614
+ */
615
+
616
+
617
+ /*
618
+ * TSConfigIsVisible
619
+ * Determine whether a text search configuration (identified by OID)
620
+ * is visible in the current search path. Visible means "would be found
621
+ * by searching for the unqualified text search configuration name".
622
+ */
623
+
624
+
625
+
626
+ /*
627
+ * DeconstructQualifiedName
628
+ * Given a possibly-qualified name expressed as a list of String nodes,
629
+ * extract the schema name and object name.
630
+ *
631
+ * *nspname_p is set to NULL if there is no explicit schema name.
632
+ */
633
+
634
+
635
+ /*
636
+ * LookupNamespaceNoError
637
+ * Look up a schema name.
638
+ *
639
+ * Returns the namespace OID, or InvalidOid if not found.
640
+ *
641
+ * Note this does NOT perform any permissions check --- callers are
642
+ * responsible for being sure that an appropriate check is made.
643
+ * In the majority of cases LookupExplicitNamespace is preferable.
644
+ */
645
+
646
+
647
+ /*
648
+ * LookupExplicitNamespace
649
+ * Process an explicitly-specified schema name: look up the schema
650
+ * and verify we have USAGE (lookup) rights in it.
651
+ *
652
+ * Returns the namespace OID
653
+ */
654
+
655
+
656
+ /*
657
+ * LookupCreationNamespace
658
+ * Look up the schema and verify we have CREATE rights on it.
659
+ *
660
+ * This is just like LookupExplicitNamespace except for the different
661
+ * permission check, and that we are willing to create pg_temp if needed.
662
+ *
663
+ * Note: calling this may result in a CommandCounterIncrement operation,
664
+ * if we have to create or clean out the temp namespace.
665
+ */
666
+
667
+
668
+ /*
669
+ * Common checks on switching namespaces.
670
+ *
671
+ * We complain if either the old or new namespaces is a temporary schema
672
+ * (or temporary toast schema), or if either the old or new namespaces is the
673
+ * TOAST schema.
674
+ */
675
+
676
+
677
+ /*
678
+ * QualifiedNameGetCreationNamespace
679
+ * Given a possibly-qualified name for an object (in List-of-Values
680
+ * format), determine what namespace the object should be created in.
681
+ * Also extract and return the object name (last component of list).
682
+ *
683
+ * Note: this does not apply any permissions check. Callers must check
684
+ * for CREATE rights on the selected namespace when appropriate.
685
+ *
686
+ * Note: calling this may result in a CommandCounterIncrement operation,
687
+ * if we have to create or clean out the temp namespace.
688
+ */
689
+
690
+
691
+ /*
692
+ * get_namespace_oid - given a namespace name, look up the OID
693
+ *
694
+ * If missing_ok is false, throw an error if namespace name not found. If
695
+ * true, just return InvalidOid.
696
+ */
697
+
698
+
699
+ /*
700
+ * makeRangeVarFromNameList
701
+ * Utility routine to convert a qualified-name list into RangeVar form.
702
+ */
703
+
704
+
705
+ /*
706
+ * NameListToString
707
+ * Utility routine to convert a qualified-name list into a string.
708
+ *
709
+ * This is used primarily to form error messages, and so we do not quote
710
+ * the list elements, for the sake of legibility.
711
+ *
712
+ * In most scenarios the list elements should always be Value strings,
713
+ * but we also allow A_Star for the convenience of ColumnRef processing.
714
+ */
715
+ char *
716
+ NameListToString(List *names)
717
+ {
718
+ StringInfoData string;
719
+ ListCell *l;
720
+
721
+ initStringInfo(&string);
722
+
723
+ foreach(l, names)
724
+ {
725
+ Node *name = (Node *) lfirst(l);
726
+
727
+ if (l != list_head(names))
728
+ appendStringInfoChar(&string, '.');
729
+
730
+ if (IsA(name, String))
731
+ appendStringInfoString(&string, strVal(name));
732
+ else if (IsA(name, A_Star))
733
+ appendStringInfoChar(&string, '*');
734
+ else
735
+ elog(ERROR, "unexpected node type in name list: %d",
736
+ (int) nodeTag(name));
737
+ }
738
+
739
+ return string.data;
740
+ }
741
+
742
+ /*
743
+ * NameListToQuotedString
744
+ * Utility routine to convert a qualified-name list into a string.
745
+ *
746
+ * Same as above except that names will be double-quoted where necessary,
747
+ * so the string could be re-parsed (eg, by textToQualifiedNameList).
748
+ */
749
+
750
+
751
+ /*
752
+ * isTempNamespace - is the given namespace my temporary-table namespace?
753
+ */
754
+
755
+
756
+ /*
757
+ * isTempToastNamespace - is the given namespace my temporary-toast-table
758
+ * namespace?
759
+ */
760
+
761
+
762
+ /*
763
+ * isTempOrTempToastNamespace - is the given namespace my temporary-table
764
+ * namespace or my temporary-toast-table namespace?
765
+ */
766
+
767
+
768
+ /*
769
+ * isAnyTempNamespace - is the given namespace a temporary-table namespace
770
+ * (either my own, or another backend's)? Temporary-toast-table namespaces
771
+ * are included, too.
772
+ */
773
+
774
+
775
+ /*
776
+ * isOtherTempNamespace - is the given namespace some other backend's
777
+ * temporary-table namespace (including temporary-toast-table namespaces)?
778
+ *
779
+ * Note: for most purposes in the C code, this function is obsolete. Use
780
+ * RELATION_IS_OTHER_TEMP() instead to detect non-local temp relations.
781
+ */
782
+
783
+
784
+ /*
785
+ * checkTempNamespaceStatus - is the given namespace owned and actively used
786
+ * by a backend?
787
+ *
788
+ * Note: this can be used while scanning relations in pg_class to detect
789
+ * orphaned temporary tables or namespaces with a backend connected to a
790
+ * given database. The result may be out of date quickly, so the caller
791
+ * must be careful how to handle this information.
792
+ */
793
+
794
+
795
+ /*
796
+ * GetTempNamespaceBackendId - if the given namespace is a temporary-table
797
+ * namespace (either my own, or another backend's), return the BackendId
798
+ * that owns it. Temporary-toast-table namespaces are included, too.
799
+ * If it isn't a temp namespace, return InvalidBackendId.
800
+ */
801
+
802
+
803
+ /*
804
+ * GetTempToastNamespace - get the OID of my temporary-toast-table namespace,
805
+ * which must already be assigned. (This is only used when creating a toast
806
+ * table for a temp table, so we must have already done InitTempTableNamespace)
807
+ */
808
+
809
+
810
+
811
+ /*
812
+ * GetTempNamespaceState - fetch status of session's temporary namespace
813
+ *
814
+ * This is used for conveying state to a parallel worker, and is not meant
815
+ * for general-purpose access.
816
+ */
817
+
818
+
819
+ /*
820
+ * SetTempNamespaceState - set status of session's temporary namespace
821
+ *
822
+ * This is used for conveying state to a parallel worker, and is not meant for
823
+ * general-purpose access. By transferring these namespace OIDs to workers,
824
+ * we ensure they will have the same notion of the search path as their leader
825
+ * does.
826
+ */
827
+
828
+
829
+
830
+ /*
831
+ * GetOverrideSearchPath - fetch current search path definition in form
832
+ * used by PushOverrideSearchPath.
833
+ *
834
+ * The result structure is allocated in the specified memory context
835
+ * (which might or might not be equal to CurrentMemoryContext); but any
836
+ * junk created by revalidation calculations will be in CurrentMemoryContext.
837
+ */
838
+
839
+
840
+ /*
841
+ * CopyOverrideSearchPath - copy the specified OverrideSearchPath.
842
+ *
843
+ * The result structure is allocated in CurrentMemoryContext.
844
+ */
845
+
846
+
847
+ /*
848
+ * OverrideSearchPathMatchesCurrent - does path match current setting?
849
+ *
850
+ * This is tested over and over in some common code paths, and in the typical
851
+ * scenario where the active search path seldom changes, it'll always succeed.
852
+ * We make that case fast by keeping a generation counter that is advanced
853
+ * whenever the active search path changes.
854
+ */
855
+
856
+
857
+ /*
858
+ * PushOverrideSearchPath - temporarily override the search path
859
+ *
860
+ * We allow nested overrides, hence the push/pop terminology. The GUC
861
+ * search_path variable is ignored while an override is active.
862
+ *
863
+ * It's possible that newpath->useTemp is set but there is no longer any
864
+ * active temp namespace, if the path was saved during a transaction that
865
+ * created a temp namespace and was later rolled back. In that case we just
866
+ * ignore useTemp. A plausible alternative would be to create a new temp
867
+ * namespace, but for existing callers that's not necessary because an empty
868
+ * temp namespace wouldn't affect their results anyway.
869
+ *
870
+ * It's also worth noting that other schemas listed in newpath might not
871
+ * exist anymore either. We don't worry about this because OIDs that match
872
+ * no existing namespace will simply not produce any hits during searches.
873
+ */
874
+
875
+
876
+ /*
877
+ * PopOverrideSearchPath - undo a previous PushOverrideSearchPath
878
+ *
879
+ * Any push during a (sub)transaction will be popped automatically at abort.
880
+ * But it's caller error if a push isn't popped in normal control flow.
881
+ */
882
+
883
+
884
+
885
+ /*
886
+ * get_collation_oid - find a collation by possibly qualified name
887
+ *
888
+ * Note that this will only find collations that work with the current
889
+ * database's encoding.
890
+ */
891
+ Oid get_collation_oid(List *name, bool missing_ok) { return -1; }
892
+
893
+
894
+ /*
895
+ * get_conversion_oid - find a conversion by possibly qualified name
896
+ */
897
+
898
+
899
+ /*
900
+ * FindDefaultConversionProc - find default encoding conversion proc
901
+ */
902
+
903
+
904
+ /*
905
+ * recomputeNamespacePath - recompute path derived variables if needed.
906
+ */
907
+
908
+
909
+ /*
910
+ * AccessTempTableNamespace
911
+ * Provide access to a temporary namespace, potentially creating it
912
+ * if not present yet. This routine registers if the namespace gets
913
+ * in use in this transaction. 'force' can be set to true to allow
914
+ * the caller to enforce the creation of the temporary namespace for
915
+ * use in this backend, which happens if its creation is pending.
916
+ */
917
+
918
+
919
+ /*
920
+ * InitTempTableNamespace
921
+ * Initialize temp table namespace on first use in a particular backend
922
+ */
923
+
924
+
925
+ /*
926
+ * End-of-transaction cleanup for namespaces.
927
+ */
928
+
929
+
930
+ /*
931
+ * AtEOSubXact_Namespace
932
+ *
933
+ * At subtransaction commit, propagate the temp-namespace-creation
934
+ * flag to the parent subtransaction.
935
+ *
936
+ * At subtransaction abort, forget the flag if we set it up.
937
+ */
938
+
939
+
940
+ /*
941
+ * Remove all relations in the specified temp namespace.
942
+ *
943
+ * This is called at backend shutdown (if we made any temp relations).
944
+ * It is also called when we begin using a pre-existing temp namespace,
945
+ * in order to clean out any relations that might have been created by
946
+ * a crashed backend.
947
+ */
948
+
949
+
950
+ /*
951
+ * Callback to remove temp relations at backend exit.
952
+ */
953
+
954
+
955
+ /*
956
+ * Remove all temp tables from the temporary namespace.
957
+ */
958
+
959
+
960
+
961
+ /*
962
+ * Routines for handling the GUC variable 'search_path'.
963
+ */
964
+
965
+ /* check_hook: validate new search_path value */
966
+
967
+
968
+ /* assign_hook: do extra actions as needed */
969
+
970
+
971
+ /*
972
+ * InitializeSearchPath: initialize module during InitPostgres.
973
+ *
974
+ * This is called after we are up enough to be able to do catalog lookups.
975
+ */
976
+
977
+
978
+ /*
979
+ * NamespaceCallback
980
+ * Syscache inval callback function
981
+ */
982
+
983
+
984
+ /*
985
+ * Fetch the active search path. The return value is a palloc'ed list
986
+ * of OIDs; the caller is responsible for freeing this storage as
987
+ * appropriate.
988
+ *
989
+ * The returned list includes the implicitly-prepended namespaces only if
990
+ * includeImplicit is true.
991
+ *
992
+ * Note: calling this may result in a CommandCounterIncrement operation,
993
+ * if we have to create or clean out the temp namespace.
994
+ */
995
+
996
+
997
+ /*
998
+ * Fetch the active search path into a caller-allocated array of OIDs.
999
+ * Returns the number of path entries. (If this is more than sarray_len,
1000
+ * then the data didn't fit and is not all stored.)
1001
+ *
1002
+ * The returned list always includes the implicitly-prepended namespaces,
1003
+ * but never includes the temp namespace. (This is suitable for existing
1004
+ * users, which would want to ignore the temp namespace anyway.) This
1005
+ * definition allows us to not worry about initializing the temp namespace.
1006
+ */
1007
+
1008
+
1009
+
1010
+ /*
1011
+ * Export the FooIsVisible functions as SQL-callable functions.
1012
+ *
1013
+ * Note: as of Postgres 8.4, these will silently return NULL if called on
1014
+ * a nonexistent object OID, rather than failing. This is to avoid race
1015
+ * condition errors when a query that's scanning a catalog using an MVCC
1016
+ * snapshot uses one of these functions. The underlying IsVisible functions
1017
+ * always use an up-to-date snapshot and so might see the object as already
1018
+ * gone when it's still visible to the transaction snapshot. (There is no race
1019
+ * condition in the current coding because we don't accept sinval messages
1020
+ * between the SearchSysCacheExists test and the subsequent lookup.)
1021
+ */
1022
+
1023
+
1024
+
1025
+
1026
+
1027
+
1028
+
1029
+
1030
+
1031
+
1032
+
1033
+
1034
+
1035
+
1036
+
1037
+
1038
+
1039
+
1040
+
1041
+
1042
+
1043
+
1044
+
1045
+
1046
+
1047
+
1048
+
1049
+
1050
+
1051
+