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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +217 -99
- data/README.md +92 -69
- data/Rakefile +85 -5
- data/ext/pg_query/extconf.rb +3 -40
- data/ext/pg_query/guc-file.c +0 -0
- data/ext/pg_query/include/access/amapi.h +246 -0
- data/ext/pg_query/include/access/attmap.h +52 -0
- data/ext/pg_query/include/access/attnum.h +64 -0
- data/ext/pg_query/include/access/clog.h +61 -0
- data/ext/pg_query/include/access/commit_ts.h +77 -0
- data/ext/pg_query/include/access/detoast.h +92 -0
- data/ext/pg_query/include/access/genam.h +228 -0
- data/ext/pg_query/include/access/gin.h +78 -0
- data/ext/pg_query/include/access/htup.h +89 -0
- data/ext/pg_query/include/access/htup_details.h +819 -0
- data/ext/pg_query/include/access/itup.h +161 -0
- data/ext/pg_query/include/access/parallel.h +82 -0
- data/ext/pg_query/include/access/printtup.h +35 -0
- data/ext/pg_query/include/access/relation.h +28 -0
- data/ext/pg_query/include/access/relscan.h +176 -0
- data/ext/pg_query/include/access/rmgr.h +35 -0
- data/ext/pg_query/include/access/rmgrlist.h +49 -0
- data/ext/pg_query/include/access/sdir.h +58 -0
- data/ext/pg_query/include/access/skey.h +151 -0
- data/ext/pg_query/include/access/stratnum.h +83 -0
- data/ext/pg_query/include/access/sysattr.h +29 -0
- data/ext/pg_query/include/access/table.h +27 -0
- data/ext/pg_query/include/access/tableam.h +1825 -0
- data/ext/pg_query/include/access/transam.h +265 -0
- data/ext/pg_query/include/access/tupconvert.h +51 -0
- data/ext/pg_query/include/access/tupdesc.h +154 -0
- data/ext/pg_query/include/access/tupmacs.h +247 -0
- data/ext/pg_query/include/access/twophase.h +61 -0
- data/ext/pg_query/include/access/xact.h +463 -0
- data/ext/pg_query/include/access/xlog.h +398 -0
- data/ext/pg_query/include/access/xlog_internal.h +330 -0
- data/ext/pg_query/include/access/xlogdefs.h +109 -0
- data/ext/pg_query/include/access/xloginsert.h +64 -0
- data/ext/pg_query/include/access/xlogreader.h +327 -0
- data/ext/pg_query/include/access/xlogrecord.h +227 -0
- data/ext/pg_query/include/bootstrap/bootstrap.h +62 -0
- data/ext/pg_query/include/c.h +1322 -0
- data/ext/pg_query/include/catalog/catalog.h +42 -0
- data/ext/pg_query/include/catalog/catversion.h +58 -0
- data/ext/pg_query/include/catalog/dependency.h +275 -0
- data/ext/pg_query/include/catalog/genbki.h +64 -0
- data/ext/pg_query/include/catalog/index.h +199 -0
- data/ext/pg_query/include/catalog/indexing.h +366 -0
- data/ext/pg_query/include/catalog/namespace.h +188 -0
- data/ext/pg_query/include/catalog/objectaccess.h +197 -0
- data/ext/pg_query/include/catalog/objectaddress.h +84 -0
- data/ext/pg_query/include/catalog/pg_aggregate.h +176 -0
- data/ext/pg_query/include/catalog/pg_aggregate_d.h +77 -0
- data/ext/pg_query/include/catalog/pg_am.h +60 -0
- data/ext/pg_query/include/catalog/pg_am_d.h +45 -0
- data/ext/pg_query/include/catalog/pg_attribute.h +204 -0
- data/ext/pg_query/include/catalog/pg_attribute_d.h +59 -0
- data/ext/pg_query/include/catalog/pg_authid.h +58 -0
- data/ext/pg_query/include/catalog/pg_authid_d.h +49 -0
- data/ext/pg_query/include/catalog/pg_class.h +200 -0
- data/ext/pg_query/include/catalog/pg_class_d.h +103 -0
- data/ext/pg_query/include/catalog/pg_collation.h +73 -0
- data/ext/pg_query/include/catalog/pg_collation_d.h +45 -0
- data/ext/pg_query/include/catalog/pg_constraint.h +247 -0
- data/ext/pg_query/include/catalog/pg_constraint_d.h +67 -0
- data/ext/pg_query/include/catalog/pg_control.h +250 -0
- data/ext/pg_query/include/catalog/pg_conversion.h +72 -0
- data/ext/pg_query/include/catalog/pg_conversion_d.h +35 -0
- data/ext/pg_query/include/catalog/pg_depend.h +73 -0
- data/ext/pg_query/include/catalog/pg_depend_d.h +34 -0
- data/ext/pg_query/include/catalog/pg_event_trigger.h +51 -0
- data/ext/pg_query/include/catalog/pg_event_trigger_d.h +34 -0
- data/ext/pg_query/include/catalog/pg_index.h +80 -0
- data/ext/pg_query/include/catalog/pg_index_d.h +56 -0
- data/ext/pg_query/include/catalog/pg_language.h +67 -0
- data/ext/pg_query/include/catalog/pg_language_d.h +39 -0
- data/ext/pg_query/include/catalog/pg_namespace.h +59 -0
- data/ext/pg_query/include/catalog/pg_namespace_d.h +34 -0
- data/ext/pg_query/include/catalog/pg_opclass.h +85 -0
- data/ext/pg_query/include/catalog/pg_opclass_d.h +49 -0
- data/ext/pg_query/include/catalog/pg_operator.h +102 -0
- data/ext/pg_query/include/catalog/pg_operator_d.h +106 -0
- data/ext/pg_query/include/catalog/pg_opfamily.h +60 -0
- data/ext/pg_query/include/catalog/pg_opfamily_d.h +47 -0
- data/ext/pg_query/include/catalog/pg_partitioned_table.h +63 -0
- data/ext/pg_query/include/catalog/pg_partitioned_table_d.h +35 -0
- data/ext/pg_query/include/catalog/pg_proc.h +211 -0
- data/ext/pg_query/include/catalog/pg_proc_d.h +99 -0
- data/ext/pg_query/include/catalog/pg_publication.h +115 -0
- data/ext/pg_query/include/catalog/pg_publication_d.h +36 -0
- data/ext/pg_query/include/catalog/pg_replication_origin.h +57 -0
- data/ext/pg_query/include/catalog/pg_replication_origin_d.h +29 -0
- data/ext/pg_query/include/catalog/pg_statistic.h +275 -0
- data/ext/pg_query/include/catalog/pg_statistic_d.h +194 -0
- data/ext/pg_query/include/catalog/pg_statistic_ext.h +74 -0
- data/ext/pg_query/include/catalog/pg_statistic_ext_d.h +40 -0
- data/ext/pg_query/include/catalog/pg_transform.h +45 -0
- data/ext/pg_query/include/catalog/pg_transform_d.h +32 -0
- data/ext/pg_query/include/catalog/pg_trigger.h +137 -0
- data/ext/pg_query/include/catalog/pg_trigger_d.h +106 -0
- data/ext/pg_query/include/catalog/pg_ts_config.h +50 -0
- data/ext/pg_query/include/catalog/pg_ts_config_d.h +32 -0
- data/ext/pg_query/include/catalog/pg_ts_dict.h +54 -0
- data/ext/pg_query/include/catalog/pg_ts_dict_d.h +33 -0
- data/ext/pg_query/include/catalog/pg_ts_parser.h +57 -0
- data/ext/pg_query/include/catalog/pg_ts_parser_d.h +35 -0
- data/ext/pg_query/include/catalog/pg_ts_template.h +48 -0
- data/ext/pg_query/include/catalog/pg_ts_template_d.h +32 -0
- data/ext/pg_query/include/catalog/pg_type.h +372 -0
- data/ext/pg_query/include/catalog/pg_type_d.h +285 -0
- data/ext/pg_query/include/catalog/storage.h +48 -0
- data/ext/pg_query/include/commands/async.h +54 -0
- data/ext/pg_query/include/commands/dbcommands.h +35 -0
- data/ext/pg_query/include/commands/defrem.h +173 -0
- data/ext/pg_query/include/commands/event_trigger.h +88 -0
- data/ext/pg_query/include/commands/explain.h +127 -0
- data/ext/pg_query/include/commands/prepare.h +61 -0
- data/ext/pg_query/include/commands/tablespace.h +67 -0
- data/ext/pg_query/include/commands/trigger.h +277 -0
- data/ext/pg_query/include/commands/user.h +37 -0
- data/ext/pg_query/include/commands/vacuum.h +293 -0
- data/ext/pg_query/include/commands/variable.h +38 -0
- data/ext/pg_query/include/common/file_perm.h +56 -0
- data/ext/pg_query/include/common/hashfn.h +104 -0
- data/ext/pg_query/include/common/ip.h +37 -0
- data/ext/pg_query/include/common/keywords.h +33 -0
- data/ext/pg_query/include/common/kwlookup.h +44 -0
- data/ext/pg_query/include/common/relpath.h +90 -0
- data/ext/pg_query/include/common/string.h +19 -0
- data/ext/pg_query/include/common/unicode_combining_table.h +196 -0
- data/ext/pg_query/include/datatype/timestamp.h +197 -0
- data/ext/pg_query/include/executor/execdesc.h +70 -0
- data/ext/pg_query/include/executor/executor.h +614 -0
- data/ext/pg_query/include/executor/functions.h +41 -0
- data/ext/pg_query/include/executor/instrument.h +101 -0
- data/ext/pg_query/include/executor/spi.h +175 -0
- data/ext/pg_query/include/executor/tablefunc.h +67 -0
- data/ext/pg_query/include/executor/tuptable.h +487 -0
- data/ext/pg_query/include/fmgr.h +775 -0
- data/ext/pg_query/include/funcapi.h +348 -0
- data/ext/pg_query/include/getaddrinfo.h +162 -0
- data/ext/pg_query/include/jit/jit.h +105 -0
- data/ext/pg_query/include/kwlist_d.h +1072 -0
- data/ext/pg_query/include/lib/ilist.h +727 -0
- data/ext/pg_query/include/lib/pairingheap.h +102 -0
- data/ext/pg_query/include/lib/simplehash.h +1059 -0
- data/ext/pg_query/include/lib/stringinfo.h +161 -0
- data/ext/pg_query/include/libpq/auth.h +29 -0
- data/ext/pg_query/include/libpq/crypt.h +46 -0
- data/ext/pg_query/include/libpq/hba.h +140 -0
- data/ext/pg_query/include/libpq/libpq-be.h +326 -0
- data/ext/pg_query/include/libpq/libpq.h +133 -0
- data/ext/pg_query/include/libpq/pqcomm.h +208 -0
- data/ext/pg_query/include/libpq/pqformat.h +210 -0
- data/ext/pg_query/include/libpq/pqsignal.h +42 -0
- data/ext/pg_query/include/mb/pg_wchar.h +672 -0
- data/ext/pg_query/include/mb/stringinfo_mb.h +24 -0
- data/ext/pg_query/include/miscadmin.h +476 -0
- data/ext/pg_query/include/nodes/bitmapset.h +122 -0
- data/ext/pg_query/include/nodes/execnodes.h +2520 -0
- data/ext/pg_query/include/nodes/extensible.h +160 -0
- data/ext/pg_query/include/nodes/lockoptions.h +61 -0
- data/ext/pg_query/include/nodes/makefuncs.h +108 -0
- data/ext/pg_query/include/nodes/memnodes.h +108 -0
- data/ext/pg_query/include/nodes/nodeFuncs.h +162 -0
- data/ext/pg_query/include/nodes/nodes.h +842 -0
- data/ext/pg_query/include/nodes/params.h +170 -0
- data/ext/pg_query/include/nodes/parsenodes.h +3579 -0
- data/ext/pg_query/include/nodes/pathnodes.h +2556 -0
- data/ext/pg_query/include/nodes/pg_list.h +605 -0
- data/ext/pg_query/include/nodes/plannodes.h +1251 -0
- data/ext/pg_query/include/nodes/primnodes.h +1541 -0
- data/ext/pg_query/include/nodes/print.h +34 -0
- data/ext/pg_query/include/nodes/tidbitmap.h +75 -0
- data/ext/pg_query/include/nodes/value.h +61 -0
- data/ext/pg_query/include/optimizer/cost.h +206 -0
- data/ext/pg_query/include/optimizer/geqo.h +88 -0
- data/ext/pg_query/include/optimizer/geqo_gene.h +45 -0
- data/ext/pg_query/include/optimizer/optimizer.h +199 -0
- data/ext/pg_query/include/optimizer/paths.h +249 -0
- data/ext/pg_query/include/optimizer/planmain.h +119 -0
- data/ext/pg_query/include/parser/analyze.h +49 -0
- data/ext/pg_query/include/parser/gram.h +1067 -0
- data/ext/pg_query/include/parser/gramparse.h +75 -0
- data/ext/pg_query/include/parser/kwlist.h +477 -0
- data/ext/pg_query/include/parser/parse_agg.h +68 -0
- data/ext/pg_query/include/parser/parse_clause.h +54 -0
- data/ext/pg_query/include/parser/parse_coerce.h +97 -0
- data/ext/pg_query/include/parser/parse_collate.h +27 -0
- data/ext/pg_query/include/parser/parse_expr.h +26 -0
- data/ext/pg_query/include/parser/parse_func.h +73 -0
- data/ext/pg_query/include/parser/parse_node.h +327 -0
- data/ext/pg_query/include/parser/parse_oper.h +67 -0
- data/ext/pg_query/include/parser/parse_relation.h +123 -0
- data/ext/pg_query/include/parser/parse_target.h +46 -0
- data/ext/pg_query/include/parser/parse_type.h +60 -0
- data/ext/pg_query/include/parser/parser.h +41 -0
- data/ext/pg_query/include/parser/parsetree.h +61 -0
- data/ext/pg_query/include/parser/scanner.h +152 -0
- data/ext/pg_query/include/parser/scansup.h +30 -0
- data/ext/pg_query/include/partitioning/partdefs.h +26 -0
- data/ext/pg_query/include/pg_config.h +989 -0
- data/ext/pg_query/include/pg_config_ext.h +8 -0
- data/ext/pg_query/include/pg_config_manual.h +350 -0
- data/ext/pg_query/include/pg_config_os.h +8 -0
- data/ext/pg_query/include/pg_getopt.h +56 -0
- data/ext/pg_query/include/pg_query.h +121 -0
- data/ext/pg_query/include/pg_query_enum_defs.c +2454 -0
- data/ext/pg_query/include/pg_query_fingerprint_conds.c +875 -0
- data/ext/pg_query/include/pg_query_fingerprint_defs.c +12413 -0
- data/ext/pg_query/include/pg_query_json_helper.c +61 -0
- data/ext/pg_query/include/pg_query_outfuncs_conds.c +686 -0
- data/ext/pg_query/include/pg_query_outfuncs_defs.c +2437 -0
- data/ext/pg_query/include/pg_query_readfuncs_conds.c +222 -0
- data/ext/pg_query/include/pg_query_readfuncs_defs.c +2878 -0
- data/ext/pg_query/include/pg_trace.h +17 -0
- data/ext/pg_query/include/pgstat.h +1487 -0
- data/ext/pg_query/include/pgtime.h +84 -0
- data/ext/pg_query/include/pl_gram.h +385 -0
- data/ext/pg_query/include/pl_reserved_kwlist.h +52 -0
- data/ext/pg_query/include/pl_reserved_kwlist_d.h +114 -0
- data/ext/pg_query/include/pl_unreserved_kwlist.h +112 -0
- data/ext/pg_query/include/pl_unreserved_kwlist_d.h +246 -0
- data/ext/pg_query/include/plerrcodes.h +990 -0
- data/ext/pg_query/include/plpgsql.h +1347 -0
- data/ext/pg_query/include/port.h +524 -0
- data/ext/pg_query/include/port/atomics.h +524 -0
- data/ext/pg_query/include/port/atomics/arch-arm.h +26 -0
- data/ext/pg_query/include/port/atomics/arch-ppc.h +254 -0
- data/ext/pg_query/include/port/atomics/arch-x86.h +252 -0
- data/ext/pg_query/include/port/atomics/fallback.h +170 -0
- data/ext/pg_query/include/port/atomics/generic-gcc.h +286 -0
- data/ext/pg_query/include/port/atomics/generic.h +401 -0
- data/ext/pg_query/include/port/pg_bitutils.h +226 -0
- data/ext/pg_query/include/port/pg_bswap.h +161 -0
- data/ext/pg_query/include/port/pg_crc32c.h +101 -0
- data/ext/pg_query/include/portability/instr_time.h +256 -0
- data/ext/pg_query/include/postgres.h +764 -0
- data/ext/pg_query/include/postgres_ext.h +74 -0
- data/ext/pg_query/include/postmaster/autovacuum.h +83 -0
- data/ext/pg_query/include/postmaster/bgworker.h +161 -0
- data/ext/pg_query/include/postmaster/bgworker_internals.h +64 -0
- data/ext/pg_query/include/postmaster/bgwriter.h +45 -0
- data/ext/pg_query/include/postmaster/fork_process.h +17 -0
- data/ext/pg_query/include/postmaster/interrupt.h +32 -0
- data/ext/pg_query/include/postmaster/pgarch.h +39 -0
- data/ext/pg_query/include/postmaster/postmaster.h +77 -0
- data/ext/pg_query/include/postmaster/syslogger.h +98 -0
- data/ext/pg_query/include/postmaster/walwriter.h +21 -0
- data/ext/pg_query/include/protobuf-c.h +1106 -0
- data/ext/pg_query/include/protobuf-c/protobuf-c.h +1106 -0
- data/ext/pg_query/include/protobuf/pg_query.pb-c.h +10846 -0
- data/ext/pg_query/include/protobuf/pg_query.pb.h +124718 -0
- data/ext/pg_query/include/regex/regex.h +184 -0
- data/ext/pg_query/include/replication/logicallauncher.h +31 -0
- data/ext/pg_query/include/replication/logicalproto.h +110 -0
- data/ext/pg_query/include/replication/logicalworker.h +19 -0
- data/ext/pg_query/include/replication/origin.h +73 -0
- data/ext/pg_query/include/replication/reorderbuffer.h +467 -0
- data/ext/pg_query/include/replication/slot.h +219 -0
- data/ext/pg_query/include/replication/syncrep.h +115 -0
- data/ext/pg_query/include/replication/walreceiver.h +340 -0
- data/ext/pg_query/include/replication/walsender.h +74 -0
- data/ext/pg_query/include/rewrite/prs2lock.h +46 -0
- data/ext/pg_query/include/rewrite/rewriteHandler.h +40 -0
- data/ext/pg_query/include/rewrite/rewriteManip.h +87 -0
- data/ext/pg_query/include/rewrite/rewriteSupport.h +26 -0
- data/ext/pg_query/include/storage/backendid.h +37 -0
- data/ext/pg_query/include/storage/block.h +121 -0
- data/ext/pg_query/include/storage/buf.h +46 -0
- data/ext/pg_query/include/storage/bufmgr.h +292 -0
- data/ext/pg_query/include/storage/bufpage.h +459 -0
- data/ext/pg_query/include/storage/condition_variable.h +62 -0
- data/ext/pg_query/include/storage/dsm.h +61 -0
- data/ext/pg_query/include/storage/dsm_impl.h +75 -0
- data/ext/pg_query/include/storage/fd.h +168 -0
- data/ext/pg_query/include/storage/ipc.h +81 -0
- data/ext/pg_query/include/storage/item.h +19 -0
- data/ext/pg_query/include/storage/itemid.h +184 -0
- data/ext/pg_query/include/storage/itemptr.h +206 -0
- data/ext/pg_query/include/storage/large_object.h +100 -0
- data/ext/pg_query/include/storage/latch.h +190 -0
- data/ext/pg_query/include/storage/lmgr.h +114 -0
- data/ext/pg_query/include/storage/lock.h +612 -0
- data/ext/pg_query/include/storage/lockdefs.h +59 -0
- data/ext/pg_query/include/storage/lwlock.h +232 -0
- data/ext/pg_query/include/storage/lwlocknames.h +51 -0
- data/ext/pg_query/include/storage/off.h +57 -0
- data/ext/pg_query/include/storage/pg_sema.h +61 -0
- data/ext/pg_query/include/storage/pg_shmem.h +90 -0
- data/ext/pg_query/include/storage/pmsignal.h +94 -0
- data/ext/pg_query/include/storage/predicate.h +87 -0
- data/ext/pg_query/include/storage/proc.h +333 -0
- data/ext/pg_query/include/storage/proclist_types.h +51 -0
- data/ext/pg_query/include/storage/procsignal.h +75 -0
- data/ext/pg_query/include/storage/relfilenode.h +99 -0
- data/ext/pg_query/include/storage/s_lock.h +1047 -0
- data/ext/pg_query/include/storage/sharedfileset.h +45 -0
- data/ext/pg_query/include/storage/shm_mq.h +85 -0
- data/ext/pg_query/include/storage/shm_toc.h +58 -0
- data/ext/pg_query/include/storage/shmem.h +81 -0
- data/ext/pg_query/include/storage/sinval.h +153 -0
- data/ext/pg_query/include/storage/sinvaladt.h +43 -0
- data/ext/pg_query/include/storage/smgr.h +109 -0
- data/ext/pg_query/include/storage/spin.h +77 -0
- data/ext/pg_query/include/storage/standby.h +91 -0
- data/ext/pg_query/include/storage/standbydefs.h +74 -0
- data/ext/pg_query/include/storage/sync.h +62 -0
- data/ext/pg_query/include/tcop/cmdtag.h +58 -0
- data/ext/pg_query/include/tcop/cmdtaglist.h +217 -0
- data/ext/pg_query/include/tcop/deparse_utility.h +108 -0
- data/ext/pg_query/include/tcop/dest.h +149 -0
- data/ext/pg_query/include/tcop/fastpath.h +21 -0
- data/ext/pg_query/include/tcop/pquery.h +45 -0
- data/ext/pg_query/include/tcop/tcopprot.h +89 -0
- data/ext/pg_query/include/tcop/utility.h +108 -0
- data/ext/pg_query/include/tsearch/ts_cache.h +98 -0
- data/ext/pg_query/include/utils/acl.h +312 -0
- data/ext/pg_query/include/utils/aclchk_internal.h +45 -0
- data/ext/pg_query/include/utils/array.h +458 -0
- data/ext/pg_query/include/utils/builtins.h +127 -0
- data/ext/pg_query/include/utils/bytea.h +27 -0
- data/ext/pg_query/include/utils/catcache.h +231 -0
- data/ext/pg_query/include/utils/date.h +90 -0
- data/ext/pg_query/include/utils/datetime.h +343 -0
- data/ext/pg_query/include/utils/datum.h +68 -0
- data/ext/pg_query/include/utils/dsa.h +123 -0
- data/ext/pg_query/include/utils/dynahash.h +19 -0
- data/ext/pg_query/include/utils/elog.h +439 -0
- data/ext/pg_query/include/utils/errcodes.h +352 -0
- data/ext/pg_query/include/utils/expandeddatum.h +159 -0
- data/ext/pg_query/include/utils/expandedrecord.h +231 -0
- data/ext/pg_query/include/utils/float.h +356 -0
- data/ext/pg_query/include/utils/fmgroids.h +2657 -0
- data/ext/pg_query/include/utils/fmgrprotos.h +2646 -0
- data/ext/pg_query/include/utils/fmgrtab.h +48 -0
- data/ext/pg_query/include/utils/guc.h +443 -0
- data/ext/pg_query/include/utils/guc_tables.h +272 -0
- data/ext/pg_query/include/utils/hsearch.h +149 -0
- data/ext/pg_query/include/utils/inval.h +64 -0
- data/ext/pg_query/include/utils/lsyscache.h +197 -0
- data/ext/pg_query/include/utils/memdebug.h +82 -0
- data/ext/pg_query/include/utils/memutils.h +225 -0
- data/ext/pg_query/include/utils/numeric.h +76 -0
- data/ext/pg_query/include/utils/palloc.h +136 -0
- data/ext/pg_query/include/utils/partcache.h +102 -0
- data/ext/pg_query/include/utils/pg_locale.h +119 -0
- data/ext/pg_query/include/utils/pg_lsn.h +29 -0
- data/ext/pg_query/include/utils/pidfile.h +56 -0
- data/ext/pg_query/include/utils/plancache.h +235 -0
- data/ext/pg_query/include/utils/portal.h +241 -0
- data/ext/pg_query/include/utils/probes.h +114 -0
- data/ext/pg_query/include/utils/ps_status.h +25 -0
- data/ext/pg_query/include/utils/queryenvironment.h +74 -0
- data/ext/pg_query/include/utils/regproc.h +28 -0
- data/ext/pg_query/include/utils/rel.h +644 -0
- data/ext/pg_query/include/utils/relcache.h +151 -0
- data/ext/pg_query/include/utils/reltrigger.h +81 -0
- data/ext/pg_query/include/utils/resowner.h +86 -0
- data/ext/pg_query/include/utils/rls.h +50 -0
- data/ext/pg_query/include/utils/ruleutils.h +44 -0
- data/ext/pg_query/include/utils/sharedtuplestore.h +61 -0
- data/ext/pg_query/include/utils/snapmgr.h +158 -0
- data/ext/pg_query/include/utils/snapshot.h +206 -0
- data/ext/pg_query/include/utils/sortsupport.h +276 -0
- data/ext/pg_query/include/utils/syscache.h +219 -0
- data/ext/pg_query/include/utils/timeout.h +88 -0
- data/ext/pg_query/include/utils/timestamp.h +116 -0
- data/ext/pg_query/include/utils/tuplesort.h +277 -0
- data/ext/pg_query/include/utils/tuplestore.h +91 -0
- data/ext/pg_query/include/utils/typcache.h +202 -0
- data/ext/pg_query/include/utils/tzparser.h +39 -0
- data/ext/pg_query/include/utils/varlena.h +39 -0
- data/ext/pg_query/include/utils/xml.h +84 -0
- data/ext/pg_query/include/xxhash.h +5445 -0
- data/ext/pg_query/include/xxhash/xxhash.h +5445 -0
- data/ext/pg_query/pg_query.c +104 -0
- data/ext/pg_query/pg_query.pb-c.c +37628 -0
- data/ext/pg_query/pg_query_deparse.c +9959 -0
- data/ext/pg_query/pg_query_fingerprint.c +295 -0
- data/ext/pg_query/pg_query_fingerprint.h +8 -0
- data/ext/pg_query/pg_query_internal.h +24 -0
- data/ext/pg_query/pg_query_json_plpgsql.c +738 -0
- data/ext/pg_query/pg_query_json_plpgsql.h +9 -0
- data/ext/pg_query/pg_query_normalize.c +439 -0
- data/ext/pg_query/pg_query_outfuncs.h +10 -0
- data/ext/pg_query/pg_query_outfuncs_json.c +297 -0
- data/ext/pg_query/pg_query_outfuncs_protobuf.c +237 -0
- data/ext/pg_query/pg_query_parse.c +148 -0
- data/ext/pg_query/pg_query_parse_plpgsql.c +460 -0
- data/ext/pg_query/pg_query_readfuncs.h +11 -0
- data/ext/pg_query/pg_query_readfuncs_protobuf.c +142 -0
- data/ext/pg_query/pg_query_ruby.c +108 -12
- data/ext/pg_query/pg_query_scan.c +173 -0
- data/ext/pg_query/pg_query_split.c +221 -0
- data/ext/pg_query/protobuf-c.c +3660 -0
- data/ext/pg_query/src_backend_catalog_namespace.c +1051 -0
- data/ext/pg_query/src_backend_catalog_pg_proc.c +142 -0
- data/ext/pg_query/src_backend_commands_define.c +117 -0
- data/ext/pg_query/src_backend_libpq_pqcomm.c +651 -0
- data/ext/pg_query/src_backend_nodes_bitmapset.c +513 -0
- data/ext/pg_query/src_backend_nodes_copyfuncs.c +6013 -0
- data/ext/pg_query/src_backend_nodes_equalfuncs.c +4003 -0
- data/ext/pg_query/src_backend_nodes_extensible.c +99 -0
- data/ext/pg_query/src_backend_nodes_list.c +922 -0
- data/ext/pg_query/src_backend_nodes_makefuncs.c +417 -0
- data/ext/pg_query/src_backend_nodes_nodeFuncs.c +1363 -0
- data/ext/pg_query/src_backend_nodes_value.c +84 -0
- data/ext/pg_query/src_backend_parser_gram.c +47456 -0
- data/ext/pg_query/src_backend_parser_parse_expr.c +313 -0
- data/ext/pg_query/src_backend_parser_parser.c +497 -0
- data/ext/pg_query/src_backend_parser_scan.c +7091 -0
- data/ext/pg_query/src_backend_parser_scansup.c +160 -0
- data/ext/pg_query/src_backend_postmaster_postmaster.c +2230 -0
- data/ext/pg_query/src_backend_storage_ipc_ipc.c +192 -0
- data/ext/pg_query/src_backend_storage_lmgr_s_lock.c +370 -0
- data/ext/pg_query/src_backend_tcop_postgres.c +776 -0
- data/ext/pg_query/src_backend_utils_adt_datum.c +326 -0
- data/ext/pg_query/src_backend_utils_adt_expandeddatum.c +98 -0
- data/ext/pg_query/src_backend_utils_adt_format_type.c +136 -0
- data/ext/pg_query/src_backend_utils_adt_ruleutils.c +1683 -0
- data/ext/pg_query/src_backend_utils_error_assert.c +74 -0
- data/ext/pg_query/src_backend_utils_error_elog.c +1748 -0
- data/ext/pg_query/src_backend_utils_fmgr_fmgr.c +570 -0
- data/ext/pg_query/src_backend_utils_hash_dynahash.c +1086 -0
- data/ext/pg_query/src_backend_utils_init_globals.c +168 -0
- data/ext/pg_query/src_backend_utils_mb_mbutils.c +839 -0
- data/ext/pg_query/src_backend_utils_misc_guc.c +1831 -0
- data/ext/pg_query/src_backend_utils_mmgr_aset.c +1560 -0
- data/ext/pg_query/src_backend_utils_mmgr_mcxt.c +1006 -0
- data/ext/pg_query/src_common_encnames.c +158 -0
- data/ext/pg_query/src_common_keywords.c +39 -0
- data/ext/pg_query/src_common_kwlist_d.h +1081 -0
- data/ext/pg_query/src_common_kwlookup.c +91 -0
- data/ext/pg_query/src_common_psprintf.c +158 -0
- data/ext/pg_query/src_common_string.c +86 -0
- data/ext/pg_query/src_common_stringinfo.c +336 -0
- data/ext/pg_query/src_common_wchar.c +1651 -0
- data/ext/pg_query/src_pl_plpgsql_src_pl_comp.c +1133 -0
- data/ext/pg_query/src_pl_plpgsql_src_pl_funcs.c +877 -0
- data/ext/pg_query/src_pl_plpgsql_src_pl_gram.c +6533 -0
- data/ext/pg_query/src_pl_plpgsql_src_pl_handler.c +107 -0
- data/ext/pg_query/src_pl_plpgsql_src_pl_reserved_kwlist_d.h +123 -0
- data/ext/pg_query/src_pl_plpgsql_src_pl_scanner.c +671 -0
- data/ext/pg_query/src_pl_plpgsql_src_pl_unreserved_kwlist_d.h +255 -0
- data/ext/pg_query/src_port_erand48.c +127 -0
- data/ext/pg_query/src_port_pg_bitutils.c +246 -0
- data/ext/pg_query/src_port_pgsleep.c +69 -0
- data/ext/pg_query/src_port_pgstrcasecmp.c +83 -0
- data/ext/pg_query/src_port_qsort.c +240 -0
- data/ext/pg_query/src_port_random.c +31 -0
- data/ext/pg_query/src_port_snprintf.c +1449 -0
- data/ext/pg_query/src_port_strerror.c +324 -0
- data/ext/pg_query/src_port_strnlen.c +39 -0
- data/ext/pg_query/xxhash.c +43 -0
- data/lib/pg_query.rb +7 -4
- data/lib/pg_query/constants.rb +21 -0
- data/lib/pg_query/deparse.rb +15 -1581
- data/lib/pg_query/filter_columns.rb +88 -85
- data/lib/pg_query/fingerprint.rb +122 -87
- data/lib/pg_query/json_field_names.rb +1402 -0
- data/lib/pg_query/node.rb +31 -0
- data/lib/pg_query/param_refs.rb +42 -37
- data/lib/pg_query/parse.rb +220 -203
- data/lib/pg_query/parse_error.rb +1 -1
- data/lib/pg_query/pg_query_pb.rb +3211 -0
- data/lib/pg_query/scan.rb +23 -0
- data/lib/pg_query/treewalker.rb +24 -40
- data/lib/pg_query/truncate.rb +71 -42
- data/lib/pg_query/version.rb +2 -2
- metadata +472 -11
- data/ext/pg_query/pg_query_ruby.h +0 -10
- data/lib/pg_query/deep_dup.rb +0 -16
- data/lib/pg_query/deparse/alter_table.rb +0 -42
- data/lib/pg_query/deparse/interval.rb +0 -105
- data/lib/pg_query/deparse/keywords.rb +0 -159
- data/lib/pg_query/deparse/rename.rb +0 -41
- data/lib/pg_query/legacy_parsetree.rb +0 -109
- data/lib/pg_query/node_types.rb +0 -296
@@ -0,0 +1,417 @@
|
|
1
|
+
/*--------------------------------------------------------------------
|
2
|
+
* Symbols referenced in this file:
|
3
|
+
* - makeDefElem
|
4
|
+
* - makeTypeNameFromNameList
|
5
|
+
* - makeDefElemExtended
|
6
|
+
* - makeVacuumRelation
|
7
|
+
* - makeAlias
|
8
|
+
* - makeSimpleA_Expr
|
9
|
+
* - makeGroupingSet
|
10
|
+
* - makeTypeName
|
11
|
+
* - makeFuncCall
|
12
|
+
* - makeA_Expr
|
13
|
+
* - makeRangeVar
|
14
|
+
* - makeBoolExpr
|
15
|
+
*--------------------------------------------------------------------
|
16
|
+
*/
|
17
|
+
|
18
|
+
/*-------------------------------------------------------------------------
|
19
|
+
*
|
20
|
+
* makefuncs.c
|
21
|
+
* creator functions for various nodes. The functions here are for the
|
22
|
+
* most frequently created nodes.
|
23
|
+
*
|
24
|
+
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
|
25
|
+
* Portions Copyright (c) 1994, Regents of the University of California
|
26
|
+
*
|
27
|
+
*
|
28
|
+
* IDENTIFICATION
|
29
|
+
* src/backend/nodes/makefuncs.c
|
30
|
+
*
|
31
|
+
*-------------------------------------------------------------------------
|
32
|
+
*/
|
33
|
+
#include "postgres.h"
|
34
|
+
|
35
|
+
#include "catalog/pg_class.h"
|
36
|
+
#include "catalog/pg_type.h"
|
37
|
+
#include "nodes/makefuncs.h"
|
38
|
+
#include "nodes/nodeFuncs.h"
|
39
|
+
#include "utils/lsyscache.h"
|
40
|
+
|
41
|
+
|
42
|
+
/*
|
43
|
+
* makeA_Expr -
|
44
|
+
* makes an A_Expr node
|
45
|
+
*/
|
46
|
+
A_Expr *
|
47
|
+
makeA_Expr(A_Expr_Kind kind, List *name,
|
48
|
+
Node *lexpr, Node *rexpr, int location)
|
49
|
+
{
|
50
|
+
A_Expr *a = makeNode(A_Expr);
|
51
|
+
|
52
|
+
a->kind = kind;
|
53
|
+
a->name = name;
|
54
|
+
a->lexpr = lexpr;
|
55
|
+
a->rexpr = rexpr;
|
56
|
+
a->location = location;
|
57
|
+
return a;
|
58
|
+
}
|
59
|
+
|
60
|
+
/*
|
61
|
+
* makeSimpleA_Expr -
|
62
|
+
* As above, given a simple (unqualified) operator name
|
63
|
+
*/
|
64
|
+
A_Expr *
|
65
|
+
makeSimpleA_Expr(A_Expr_Kind kind, char *name,
|
66
|
+
Node *lexpr, Node *rexpr, int location)
|
67
|
+
{
|
68
|
+
A_Expr *a = makeNode(A_Expr);
|
69
|
+
|
70
|
+
a->kind = kind;
|
71
|
+
a->name = list_make1(makeString((char *) name));
|
72
|
+
a->lexpr = lexpr;
|
73
|
+
a->rexpr = rexpr;
|
74
|
+
a->location = location;
|
75
|
+
return a;
|
76
|
+
}
|
77
|
+
|
78
|
+
/*
|
79
|
+
* makeVar -
|
80
|
+
* creates a Var node
|
81
|
+
*/
|
82
|
+
|
83
|
+
|
84
|
+
/*
|
85
|
+
* makeVarFromTargetEntry -
|
86
|
+
* convenience function to create a same-level Var node from a
|
87
|
+
* TargetEntry
|
88
|
+
*/
|
89
|
+
|
90
|
+
|
91
|
+
/*
|
92
|
+
* makeWholeRowVar -
|
93
|
+
* creates a Var node representing a whole row of the specified RTE
|
94
|
+
*
|
95
|
+
* A whole-row reference is a Var with varno set to the correct range
|
96
|
+
* table entry, and varattno == 0 to signal that it references the whole
|
97
|
+
* tuple. (Use of zero here is unclean, since it could easily be confused
|
98
|
+
* with error cases, but it's not worth changing now.) The vartype indicates
|
99
|
+
* a rowtype; either a named composite type, or a domain over a named
|
100
|
+
* composite type (only possible if the RTE is a function returning that),
|
101
|
+
* or RECORD. This function encapsulates the logic for determining the
|
102
|
+
* correct rowtype OID to use.
|
103
|
+
*
|
104
|
+
* If allowScalar is true, then for the case where the RTE is a single function
|
105
|
+
* returning a non-composite result type, we produce a normal Var referencing
|
106
|
+
* the function's result directly, instead of the single-column composite
|
107
|
+
* value that the whole-row notation might otherwise suggest.
|
108
|
+
*/
|
109
|
+
|
110
|
+
|
111
|
+
/*
|
112
|
+
* makeTargetEntry -
|
113
|
+
* creates a TargetEntry node
|
114
|
+
*/
|
115
|
+
|
116
|
+
|
117
|
+
/*
|
118
|
+
* flatCopyTargetEntry -
|
119
|
+
* duplicate a TargetEntry, but don't copy substructure
|
120
|
+
*
|
121
|
+
* This is commonly used when we just want to modify the resno or substitute
|
122
|
+
* a new expression.
|
123
|
+
*/
|
124
|
+
|
125
|
+
|
126
|
+
/*
|
127
|
+
* makeFromExpr -
|
128
|
+
* creates a FromExpr node
|
129
|
+
*/
|
130
|
+
|
131
|
+
|
132
|
+
/*
|
133
|
+
* makeConst -
|
134
|
+
* creates a Const node
|
135
|
+
*/
|
136
|
+
|
137
|
+
|
138
|
+
/*
|
139
|
+
* makeNullConst -
|
140
|
+
* creates a Const node representing a NULL of the specified type/typmod
|
141
|
+
*
|
142
|
+
* This is a convenience routine that just saves a lookup of the type's
|
143
|
+
* storage properties.
|
144
|
+
*/
|
145
|
+
|
146
|
+
|
147
|
+
/*
|
148
|
+
* makeBoolConst -
|
149
|
+
* creates a Const node representing a boolean value (can be NULL too)
|
150
|
+
*/
|
151
|
+
|
152
|
+
|
153
|
+
/*
|
154
|
+
* makeBoolExpr -
|
155
|
+
* creates a BoolExpr node
|
156
|
+
*/
|
157
|
+
Expr *
|
158
|
+
makeBoolExpr(BoolExprType boolop, List *args, int location)
|
159
|
+
{
|
160
|
+
BoolExpr *b = makeNode(BoolExpr);
|
161
|
+
|
162
|
+
b->boolop = boolop;
|
163
|
+
b->args = args;
|
164
|
+
b->location = location;
|
165
|
+
|
166
|
+
return (Expr *) b;
|
167
|
+
}
|
168
|
+
|
169
|
+
/*
|
170
|
+
* makeAlias -
|
171
|
+
* creates an Alias node
|
172
|
+
*
|
173
|
+
* NOTE: the given name is copied, but the colnames list (if any) isn't.
|
174
|
+
*/
|
175
|
+
Alias *
|
176
|
+
makeAlias(const char *aliasname, List *colnames)
|
177
|
+
{
|
178
|
+
Alias *a = makeNode(Alias);
|
179
|
+
|
180
|
+
a->aliasname = pstrdup(aliasname);
|
181
|
+
a->colnames = colnames;
|
182
|
+
|
183
|
+
return a;
|
184
|
+
}
|
185
|
+
|
186
|
+
/*
|
187
|
+
* makeRelabelType -
|
188
|
+
* creates a RelabelType node
|
189
|
+
*/
|
190
|
+
|
191
|
+
|
192
|
+
/*
|
193
|
+
* makeRangeVar -
|
194
|
+
* creates a RangeVar node (rather oversimplified case)
|
195
|
+
*/
|
196
|
+
RangeVar *
|
197
|
+
makeRangeVar(char *schemaname, char *relname, int location)
|
198
|
+
{
|
199
|
+
RangeVar *r = makeNode(RangeVar);
|
200
|
+
|
201
|
+
r->catalogname = NULL;
|
202
|
+
r->schemaname = schemaname;
|
203
|
+
r->relname = relname;
|
204
|
+
r->inh = true;
|
205
|
+
r->relpersistence = RELPERSISTENCE_PERMANENT;
|
206
|
+
r->alias = NULL;
|
207
|
+
r->location = location;
|
208
|
+
|
209
|
+
return r;
|
210
|
+
}
|
211
|
+
|
212
|
+
/*
|
213
|
+
* makeTypeName -
|
214
|
+
* build a TypeName node for an unqualified name.
|
215
|
+
*
|
216
|
+
* typmod is defaulted, but can be changed later by caller.
|
217
|
+
*/
|
218
|
+
TypeName *
|
219
|
+
makeTypeName(char *typnam)
|
220
|
+
{
|
221
|
+
return makeTypeNameFromNameList(list_make1(makeString(typnam)));
|
222
|
+
}
|
223
|
+
|
224
|
+
/*
|
225
|
+
* makeTypeNameFromNameList -
|
226
|
+
* build a TypeName node for a String list representing a qualified name.
|
227
|
+
*
|
228
|
+
* typmod is defaulted, but can be changed later by caller.
|
229
|
+
*/
|
230
|
+
TypeName *
|
231
|
+
makeTypeNameFromNameList(List *names)
|
232
|
+
{
|
233
|
+
TypeName *n = makeNode(TypeName);
|
234
|
+
|
235
|
+
n->names = names;
|
236
|
+
n->typmods = NIL;
|
237
|
+
n->typemod = -1;
|
238
|
+
n->location = -1;
|
239
|
+
return n;
|
240
|
+
}
|
241
|
+
|
242
|
+
/*
|
243
|
+
* makeTypeNameFromOid -
|
244
|
+
* build a TypeName node to represent a type already known by OID/typmod.
|
245
|
+
*/
|
246
|
+
|
247
|
+
|
248
|
+
/*
|
249
|
+
* makeColumnDef -
|
250
|
+
* build a ColumnDef node to represent a simple column definition.
|
251
|
+
*
|
252
|
+
* Type and collation are specified by OID.
|
253
|
+
* Other properties are all basic to start with.
|
254
|
+
*/
|
255
|
+
|
256
|
+
|
257
|
+
/*
|
258
|
+
* makeFuncExpr -
|
259
|
+
* build an expression tree representing a function call.
|
260
|
+
*
|
261
|
+
* The argument expressions must have been transformed already.
|
262
|
+
*/
|
263
|
+
|
264
|
+
|
265
|
+
/*
|
266
|
+
* makeDefElem -
|
267
|
+
* build a DefElem node
|
268
|
+
*
|
269
|
+
* This is sufficient for the "typical" case with an unqualified option name
|
270
|
+
* and no special action.
|
271
|
+
*/
|
272
|
+
DefElem *
|
273
|
+
makeDefElem(char *name, Node *arg, int location)
|
274
|
+
{
|
275
|
+
DefElem *res = makeNode(DefElem);
|
276
|
+
|
277
|
+
res->defnamespace = NULL;
|
278
|
+
res->defname = name;
|
279
|
+
res->arg = arg;
|
280
|
+
res->defaction = DEFELEM_UNSPEC;
|
281
|
+
res->location = location;
|
282
|
+
|
283
|
+
return res;
|
284
|
+
}
|
285
|
+
|
286
|
+
/*
|
287
|
+
* makeDefElemExtended -
|
288
|
+
* build a DefElem node with all fields available to be specified
|
289
|
+
*/
|
290
|
+
DefElem *
|
291
|
+
makeDefElemExtended(char *nameSpace, char *name, Node *arg,
|
292
|
+
DefElemAction defaction, int location)
|
293
|
+
{
|
294
|
+
DefElem *res = makeNode(DefElem);
|
295
|
+
|
296
|
+
res->defnamespace = nameSpace;
|
297
|
+
res->defname = name;
|
298
|
+
res->arg = arg;
|
299
|
+
res->defaction = defaction;
|
300
|
+
res->location = location;
|
301
|
+
|
302
|
+
return res;
|
303
|
+
}
|
304
|
+
|
305
|
+
/*
|
306
|
+
* makeFuncCall -
|
307
|
+
*
|
308
|
+
* Initialize a FuncCall struct with the information every caller must
|
309
|
+
* supply. Any non-default parameters have to be inserted by the caller.
|
310
|
+
*/
|
311
|
+
FuncCall *
|
312
|
+
makeFuncCall(List *name, List *args, int location)
|
313
|
+
{
|
314
|
+
FuncCall *n = makeNode(FuncCall);
|
315
|
+
|
316
|
+
n->funcname = name;
|
317
|
+
n->args = args;
|
318
|
+
n->agg_order = NIL;
|
319
|
+
n->agg_filter = NULL;
|
320
|
+
n->agg_within_group = false;
|
321
|
+
n->agg_star = false;
|
322
|
+
n->agg_distinct = false;
|
323
|
+
n->func_variadic = false;
|
324
|
+
n->over = NULL;
|
325
|
+
n->location = location;
|
326
|
+
return n;
|
327
|
+
}
|
328
|
+
|
329
|
+
/*
|
330
|
+
* make_opclause
|
331
|
+
* Creates an operator clause given its operator info, left operand
|
332
|
+
* and right operand (pass NULL to create single-operand clause),
|
333
|
+
* and collation info.
|
334
|
+
*/
|
335
|
+
|
336
|
+
|
337
|
+
/*
|
338
|
+
* make_andclause
|
339
|
+
*
|
340
|
+
* Creates an 'and' clause given a list of its subclauses.
|
341
|
+
*/
|
342
|
+
|
343
|
+
|
344
|
+
/*
|
345
|
+
* make_orclause
|
346
|
+
*
|
347
|
+
* Creates an 'or' clause given a list of its subclauses.
|
348
|
+
*/
|
349
|
+
|
350
|
+
|
351
|
+
/*
|
352
|
+
* make_notclause
|
353
|
+
*
|
354
|
+
* Create a 'not' clause given the expression to be negated.
|
355
|
+
*/
|
356
|
+
|
357
|
+
|
358
|
+
/*
|
359
|
+
* make_and_qual
|
360
|
+
*
|
361
|
+
* Variant of make_andclause for ANDing two qual conditions together.
|
362
|
+
* Qual conditions have the property that a NULL nodetree is interpreted
|
363
|
+
* as 'true'.
|
364
|
+
*
|
365
|
+
* NB: this makes no attempt to preserve AND/OR flatness; so it should not
|
366
|
+
* be used on a qual that has already been run through prepqual.c.
|
367
|
+
*/
|
368
|
+
|
369
|
+
|
370
|
+
/*
|
371
|
+
* The planner and executor usually represent qualification expressions
|
372
|
+
* as lists of boolean expressions with implicit AND semantics.
|
373
|
+
*
|
374
|
+
* These functions convert between an AND-semantics expression list and the
|
375
|
+
* ordinary representation of a boolean expression.
|
376
|
+
*
|
377
|
+
* Note that an empty list is considered equivalent to TRUE.
|
378
|
+
*/
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
/*
|
384
|
+
* makeIndexInfo
|
385
|
+
* create an IndexInfo node
|
386
|
+
*/
|
387
|
+
|
388
|
+
|
389
|
+
/*
|
390
|
+
* makeGroupingSet
|
391
|
+
*
|
392
|
+
*/
|
393
|
+
GroupingSet *
|
394
|
+
makeGroupingSet(GroupingSetKind kind, List *content, int location)
|
395
|
+
{
|
396
|
+
GroupingSet *n = makeNode(GroupingSet);
|
397
|
+
|
398
|
+
n->kind = kind;
|
399
|
+
n->content = content;
|
400
|
+
n->location = location;
|
401
|
+
return n;
|
402
|
+
}
|
403
|
+
|
404
|
+
/*
|
405
|
+
* makeVacuumRelation -
|
406
|
+
* create a VacuumRelation node
|
407
|
+
*/
|
408
|
+
VacuumRelation *
|
409
|
+
makeVacuumRelation(RangeVar *relation, Oid oid, List *va_cols)
|
410
|
+
{
|
411
|
+
VacuumRelation *v = makeNode(VacuumRelation);
|
412
|
+
|
413
|
+
v->relation = relation;
|
414
|
+
v->oid = oid;
|
415
|
+
v->va_cols = va_cols;
|
416
|
+
return v;
|
417
|
+
}
|
@@ -0,0 +1,1363 @@
|
|
1
|
+
/*--------------------------------------------------------------------
|
2
|
+
* Symbols referenced in this file:
|
3
|
+
* - exprLocation
|
4
|
+
* - leftmostLoc
|
5
|
+
* - raw_expression_tree_walker
|
6
|
+
*--------------------------------------------------------------------
|
7
|
+
*/
|
8
|
+
|
9
|
+
/*-------------------------------------------------------------------------
|
10
|
+
*
|
11
|
+
* nodeFuncs.c
|
12
|
+
* Various general-purpose manipulations of Node trees
|
13
|
+
*
|
14
|
+
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
|
15
|
+
* Portions Copyright (c) 1994, Regents of the University of California
|
16
|
+
*
|
17
|
+
*
|
18
|
+
* IDENTIFICATION
|
19
|
+
* src/backend/nodes/nodeFuncs.c
|
20
|
+
*
|
21
|
+
*-------------------------------------------------------------------------
|
22
|
+
*/
|
23
|
+
#include "postgres.h"
|
24
|
+
|
25
|
+
#include "catalog/pg_collation.h"
|
26
|
+
#include "catalog/pg_type.h"
|
27
|
+
#include "miscadmin.h"
|
28
|
+
#include "nodes/execnodes.h"
|
29
|
+
#include "nodes/makefuncs.h"
|
30
|
+
#include "nodes/nodeFuncs.h"
|
31
|
+
#include "nodes/pathnodes.h"
|
32
|
+
#include "utils/builtins.h"
|
33
|
+
#include "utils/lsyscache.h"
|
34
|
+
|
35
|
+
static bool expression_returns_set_walker(Node *node, void *context);
|
36
|
+
static int leftmostLoc(int loc1, int loc2);
|
37
|
+
static bool fix_opfuncids_walker(Node *node, void *context);
|
38
|
+
static bool planstate_walk_subplans(List *plans, bool (*walker) (),
|
39
|
+
void *context);
|
40
|
+
static bool planstate_walk_members(PlanState **planstates, int nplans,
|
41
|
+
bool (*walker) (), void *context);
|
42
|
+
|
43
|
+
|
44
|
+
/*
|
45
|
+
* exprType -
|
46
|
+
* returns the Oid of the type of the expression's result.
|
47
|
+
*/
|
48
|
+
|
49
|
+
|
50
|
+
/*
|
51
|
+
* exprTypmod -
|
52
|
+
* returns the type-specific modifier of the expression's result type,
|
53
|
+
* if it can be determined. In many cases, it can't and we return -1.
|
54
|
+
*/
|
55
|
+
|
56
|
+
|
57
|
+
/*
|
58
|
+
* exprIsLengthCoercion
|
59
|
+
* Detect whether an expression tree is an application of a datatype's
|
60
|
+
* typmod-coercion function. Optionally extract the result's typmod.
|
61
|
+
*
|
62
|
+
* If coercedTypmod is not NULL, the typmod is stored there if the expression
|
63
|
+
* is a length-coercion function, else -1 is stored there.
|
64
|
+
*
|
65
|
+
* Note that a combined type-and-length coercion will be treated as a
|
66
|
+
* length coercion by this routine.
|
67
|
+
*/
|
68
|
+
|
69
|
+
|
70
|
+
/*
|
71
|
+
* applyRelabelType
|
72
|
+
* Add a RelabelType node if needed to make the expression expose
|
73
|
+
* the specified type, typmod, and collation.
|
74
|
+
*
|
75
|
+
* This is primarily intended to be used during planning. Therefore, it must
|
76
|
+
* maintain the post-eval_const_expressions invariants that there are not
|
77
|
+
* adjacent RelabelTypes, and that the tree is fully const-folded (hence,
|
78
|
+
* we mustn't return a RelabelType atop a Const). If we do find a Const,
|
79
|
+
* we'll modify it in-place if "overwrite_ok" is true; that should only be
|
80
|
+
* passed as true if caller knows the Const is newly generated.
|
81
|
+
*/
|
82
|
+
|
83
|
+
|
84
|
+
/*
|
85
|
+
* relabel_to_typmod
|
86
|
+
* Add a RelabelType node that changes just the typmod of the expression.
|
87
|
+
*
|
88
|
+
* Convenience function for a common usage of applyRelabelType.
|
89
|
+
*/
|
90
|
+
|
91
|
+
|
92
|
+
/*
|
93
|
+
* strip_implicit_coercions: remove implicit coercions at top level of tree
|
94
|
+
*
|
95
|
+
* This doesn't modify or copy the input expression tree, just return a
|
96
|
+
* pointer to a suitable place within it.
|
97
|
+
*
|
98
|
+
* Note: there isn't any useful thing we can do with a RowExpr here, so
|
99
|
+
* just return it unchanged, even if it's marked as an implicit coercion.
|
100
|
+
*/
|
101
|
+
|
102
|
+
|
103
|
+
/*
|
104
|
+
* expression_returns_set
|
105
|
+
* Test whether an expression returns a set result.
|
106
|
+
*
|
107
|
+
* Because we use expression_tree_walker(), this can also be applied to
|
108
|
+
* whole targetlists; it'll produce true if any one of the tlist items
|
109
|
+
* returns a set.
|
110
|
+
*/
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
/*
|
117
|
+
* exprCollation -
|
118
|
+
* returns the Oid of the collation of the expression's result.
|
119
|
+
*
|
120
|
+
* Note: expression nodes that can invoke functions generally have an
|
121
|
+
* "inputcollid" field, which is what the function should use as collation.
|
122
|
+
* That is the resolved common collation of the node's inputs. It is often
|
123
|
+
* but not always the same as the result collation; in particular, if the
|
124
|
+
* function produces a non-collatable result type from collatable inputs
|
125
|
+
* or vice versa, the two are different.
|
126
|
+
*/
|
127
|
+
|
128
|
+
|
129
|
+
/*
|
130
|
+
* exprInputCollation -
|
131
|
+
* returns the Oid of the collation a function should use, if available.
|
132
|
+
*
|
133
|
+
* Result is InvalidOid if the node type doesn't store this information.
|
134
|
+
*/
|
135
|
+
|
136
|
+
|
137
|
+
/*
|
138
|
+
* exprSetCollation -
|
139
|
+
* Assign collation information to an expression tree node.
|
140
|
+
*
|
141
|
+
* Note: since this is only used during parse analysis, we don't need to
|
142
|
+
* worry about subplans or PlaceHolderVars.
|
143
|
+
*/
|
144
|
+
#ifdef USE_ASSERT_CHECKING
|
145
|
+
#endif /* USE_ASSERT_CHECKING */
|
146
|
+
|
147
|
+
/*
|
148
|
+
* exprSetInputCollation -
|
149
|
+
* Assign input-collation information to an expression tree node.
|
150
|
+
*
|
151
|
+
* This is a no-op for node types that don't store their input collation.
|
152
|
+
* Note we omit RowCompareExpr, which needs special treatment since it
|
153
|
+
* contains multiple input collation OIDs.
|
154
|
+
*/
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
/*
|
159
|
+
* exprLocation -
|
160
|
+
* returns the parse location of an expression tree, for error reports
|
161
|
+
*
|
162
|
+
* -1 is returned if the location can't be determined.
|
163
|
+
*
|
164
|
+
* For expressions larger than a single token, the intent here is to
|
165
|
+
* return the location of the expression's leftmost token, not necessarily
|
166
|
+
* the topmost Node's location field. For example, an OpExpr's location
|
167
|
+
* field will point at the operator name, but if it is not a prefix operator
|
168
|
+
* then we should return the location of the left-hand operand instead.
|
169
|
+
* The reason is that we want to reference the entire expression not just
|
170
|
+
* that operator, and pointing to its start seems to be the most natural way.
|
171
|
+
*
|
172
|
+
* The location is not perfect --- for example, since the grammar doesn't
|
173
|
+
* explicitly represent parentheses in the parsetree, given something that
|
174
|
+
* had been written "(a + b) * c" we are going to point at "a" not "(".
|
175
|
+
* But it should be plenty good enough for error reporting purposes.
|
176
|
+
*
|
177
|
+
* You might think that this code is overly general, for instance why check
|
178
|
+
* the operands of a FuncExpr node, when the function name can be expected
|
179
|
+
* to be to the left of them? There are a couple of reasons. The grammar
|
180
|
+
* sometimes builds expressions that aren't quite what the user wrote;
|
181
|
+
* for instance x IS NOT BETWEEN ... becomes a NOT-expression whose keyword
|
182
|
+
* pointer is to the right of its leftmost argument. Also, nodes that were
|
183
|
+
* inserted implicitly by parse analysis (such as FuncExprs for implicit
|
184
|
+
* coercions) will have location -1, and so we can have odd combinations of
|
185
|
+
* known and unknown locations in a tree.
|
186
|
+
*/
|
187
|
+
int
|
188
|
+
exprLocation(const Node *expr)
|
189
|
+
{
|
190
|
+
int loc;
|
191
|
+
|
192
|
+
if (expr == NULL)
|
193
|
+
return -1;
|
194
|
+
switch (nodeTag(expr))
|
195
|
+
{
|
196
|
+
case T_RangeVar:
|
197
|
+
loc = ((const RangeVar *) expr)->location;
|
198
|
+
break;
|
199
|
+
case T_TableFunc:
|
200
|
+
loc = ((const TableFunc *) expr)->location;
|
201
|
+
break;
|
202
|
+
case T_Var:
|
203
|
+
loc = ((const Var *) expr)->location;
|
204
|
+
break;
|
205
|
+
case T_Const:
|
206
|
+
loc = ((const Const *) expr)->location;
|
207
|
+
break;
|
208
|
+
case T_Param:
|
209
|
+
loc = ((const Param *) expr)->location;
|
210
|
+
break;
|
211
|
+
case T_Aggref:
|
212
|
+
/* function name should always be the first thing */
|
213
|
+
loc = ((const Aggref *) expr)->location;
|
214
|
+
break;
|
215
|
+
case T_GroupingFunc:
|
216
|
+
loc = ((const GroupingFunc *) expr)->location;
|
217
|
+
break;
|
218
|
+
case T_WindowFunc:
|
219
|
+
/* function name should always be the first thing */
|
220
|
+
loc = ((const WindowFunc *) expr)->location;
|
221
|
+
break;
|
222
|
+
case T_SubscriptingRef:
|
223
|
+
/* just use container argument's location */
|
224
|
+
loc = exprLocation((Node *) ((const SubscriptingRef *) expr)->refexpr);
|
225
|
+
break;
|
226
|
+
case T_FuncExpr:
|
227
|
+
{
|
228
|
+
const FuncExpr *fexpr = (const FuncExpr *) expr;
|
229
|
+
|
230
|
+
/* consider both function name and leftmost arg */
|
231
|
+
loc = leftmostLoc(fexpr->location,
|
232
|
+
exprLocation((Node *) fexpr->args));
|
233
|
+
}
|
234
|
+
break;
|
235
|
+
case T_NamedArgExpr:
|
236
|
+
{
|
237
|
+
const NamedArgExpr *na = (const NamedArgExpr *) expr;
|
238
|
+
|
239
|
+
/* consider both argument name and value */
|
240
|
+
loc = leftmostLoc(na->location,
|
241
|
+
exprLocation((Node *) na->arg));
|
242
|
+
}
|
243
|
+
break;
|
244
|
+
case T_OpExpr:
|
245
|
+
case T_DistinctExpr: /* struct-equivalent to OpExpr */
|
246
|
+
case T_NullIfExpr: /* struct-equivalent to OpExpr */
|
247
|
+
{
|
248
|
+
const OpExpr *opexpr = (const OpExpr *) expr;
|
249
|
+
|
250
|
+
/* consider both operator name and leftmost arg */
|
251
|
+
loc = leftmostLoc(opexpr->location,
|
252
|
+
exprLocation((Node *) opexpr->args));
|
253
|
+
}
|
254
|
+
break;
|
255
|
+
case T_ScalarArrayOpExpr:
|
256
|
+
{
|
257
|
+
const ScalarArrayOpExpr *saopexpr = (const ScalarArrayOpExpr *) expr;
|
258
|
+
|
259
|
+
/* consider both operator name and leftmost arg */
|
260
|
+
loc = leftmostLoc(saopexpr->location,
|
261
|
+
exprLocation((Node *) saopexpr->args));
|
262
|
+
}
|
263
|
+
break;
|
264
|
+
case T_BoolExpr:
|
265
|
+
{
|
266
|
+
const BoolExpr *bexpr = (const BoolExpr *) expr;
|
267
|
+
|
268
|
+
/*
|
269
|
+
* Same as above, to handle either NOT or AND/OR. We can't
|
270
|
+
* special-case NOT because of the way that it's used for
|
271
|
+
* things like IS NOT BETWEEN.
|
272
|
+
*/
|
273
|
+
loc = leftmostLoc(bexpr->location,
|
274
|
+
exprLocation((Node *) bexpr->args));
|
275
|
+
}
|
276
|
+
break;
|
277
|
+
case T_SubLink:
|
278
|
+
{
|
279
|
+
const SubLink *sublink = (const SubLink *) expr;
|
280
|
+
|
281
|
+
/* check the testexpr, if any, and the operator/keyword */
|
282
|
+
loc = leftmostLoc(exprLocation(sublink->testexpr),
|
283
|
+
sublink->location);
|
284
|
+
}
|
285
|
+
break;
|
286
|
+
case T_FieldSelect:
|
287
|
+
/* just use argument's location */
|
288
|
+
loc = exprLocation((Node *) ((const FieldSelect *) expr)->arg);
|
289
|
+
break;
|
290
|
+
case T_FieldStore:
|
291
|
+
/* just use argument's location */
|
292
|
+
loc = exprLocation((Node *) ((const FieldStore *) expr)->arg);
|
293
|
+
break;
|
294
|
+
case T_RelabelType:
|
295
|
+
{
|
296
|
+
const RelabelType *rexpr = (const RelabelType *) expr;
|
297
|
+
|
298
|
+
/* Much as above */
|
299
|
+
loc = leftmostLoc(rexpr->location,
|
300
|
+
exprLocation((Node *) rexpr->arg));
|
301
|
+
}
|
302
|
+
break;
|
303
|
+
case T_CoerceViaIO:
|
304
|
+
{
|
305
|
+
const CoerceViaIO *cexpr = (const CoerceViaIO *) expr;
|
306
|
+
|
307
|
+
/* Much as above */
|
308
|
+
loc = leftmostLoc(cexpr->location,
|
309
|
+
exprLocation((Node *) cexpr->arg));
|
310
|
+
}
|
311
|
+
break;
|
312
|
+
case T_ArrayCoerceExpr:
|
313
|
+
{
|
314
|
+
const ArrayCoerceExpr *cexpr = (const ArrayCoerceExpr *) expr;
|
315
|
+
|
316
|
+
/* Much as above */
|
317
|
+
loc = leftmostLoc(cexpr->location,
|
318
|
+
exprLocation((Node *) cexpr->arg));
|
319
|
+
}
|
320
|
+
break;
|
321
|
+
case T_ConvertRowtypeExpr:
|
322
|
+
{
|
323
|
+
const ConvertRowtypeExpr *cexpr = (const ConvertRowtypeExpr *) expr;
|
324
|
+
|
325
|
+
/* Much as above */
|
326
|
+
loc = leftmostLoc(cexpr->location,
|
327
|
+
exprLocation((Node *) cexpr->arg));
|
328
|
+
}
|
329
|
+
break;
|
330
|
+
case T_CollateExpr:
|
331
|
+
/* just use argument's location */
|
332
|
+
loc = exprLocation((Node *) ((const CollateExpr *) expr)->arg);
|
333
|
+
break;
|
334
|
+
case T_CaseExpr:
|
335
|
+
/* CASE keyword should always be the first thing */
|
336
|
+
loc = ((const CaseExpr *) expr)->location;
|
337
|
+
break;
|
338
|
+
case T_CaseWhen:
|
339
|
+
/* WHEN keyword should always be the first thing */
|
340
|
+
loc = ((const CaseWhen *) expr)->location;
|
341
|
+
break;
|
342
|
+
case T_ArrayExpr:
|
343
|
+
/* the location points at ARRAY or [, which must be leftmost */
|
344
|
+
loc = ((const ArrayExpr *) expr)->location;
|
345
|
+
break;
|
346
|
+
case T_RowExpr:
|
347
|
+
/* the location points at ROW or (, which must be leftmost */
|
348
|
+
loc = ((const RowExpr *) expr)->location;
|
349
|
+
break;
|
350
|
+
case T_RowCompareExpr:
|
351
|
+
/* just use leftmost argument's location */
|
352
|
+
loc = exprLocation((Node *) ((const RowCompareExpr *) expr)->largs);
|
353
|
+
break;
|
354
|
+
case T_CoalesceExpr:
|
355
|
+
/* COALESCE keyword should always be the first thing */
|
356
|
+
loc = ((const CoalesceExpr *) expr)->location;
|
357
|
+
break;
|
358
|
+
case T_MinMaxExpr:
|
359
|
+
/* GREATEST/LEAST keyword should always be the first thing */
|
360
|
+
loc = ((const MinMaxExpr *) expr)->location;
|
361
|
+
break;
|
362
|
+
case T_SQLValueFunction:
|
363
|
+
/* function keyword should always be the first thing */
|
364
|
+
loc = ((const SQLValueFunction *) expr)->location;
|
365
|
+
break;
|
366
|
+
case T_XmlExpr:
|
367
|
+
{
|
368
|
+
const XmlExpr *xexpr = (const XmlExpr *) expr;
|
369
|
+
|
370
|
+
/* consider both function name and leftmost arg */
|
371
|
+
loc = leftmostLoc(xexpr->location,
|
372
|
+
exprLocation((Node *) xexpr->args));
|
373
|
+
}
|
374
|
+
break;
|
375
|
+
case T_NullTest:
|
376
|
+
{
|
377
|
+
const NullTest *nexpr = (const NullTest *) expr;
|
378
|
+
|
379
|
+
/* Much as above */
|
380
|
+
loc = leftmostLoc(nexpr->location,
|
381
|
+
exprLocation((Node *) nexpr->arg));
|
382
|
+
}
|
383
|
+
break;
|
384
|
+
case T_BooleanTest:
|
385
|
+
{
|
386
|
+
const BooleanTest *bexpr = (const BooleanTest *) expr;
|
387
|
+
|
388
|
+
/* Much as above */
|
389
|
+
loc = leftmostLoc(bexpr->location,
|
390
|
+
exprLocation((Node *) bexpr->arg));
|
391
|
+
}
|
392
|
+
break;
|
393
|
+
case T_CoerceToDomain:
|
394
|
+
{
|
395
|
+
const CoerceToDomain *cexpr = (const CoerceToDomain *) expr;
|
396
|
+
|
397
|
+
/* Much as above */
|
398
|
+
loc = leftmostLoc(cexpr->location,
|
399
|
+
exprLocation((Node *) cexpr->arg));
|
400
|
+
}
|
401
|
+
break;
|
402
|
+
case T_CoerceToDomainValue:
|
403
|
+
loc = ((const CoerceToDomainValue *) expr)->location;
|
404
|
+
break;
|
405
|
+
case T_SetToDefault:
|
406
|
+
loc = ((const SetToDefault *) expr)->location;
|
407
|
+
break;
|
408
|
+
case T_TargetEntry:
|
409
|
+
/* just use argument's location */
|
410
|
+
loc = exprLocation((Node *) ((const TargetEntry *) expr)->expr);
|
411
|
+
break;
|
412
|
+
case T_IntoClause:
|
413
|
+
/* use the contained RangeVar's location --- close enough */
|
414
|
+
loc = exprLocation((Node *) ((const IntoClause *) expr)->rel);
|
415
|
+
break;
|
416
|
+
case T_List:
|
417
|
+
{
|
418
|
+
/* report location of first list member that has a location */
|
419
|
+
ListCell *lc;
|
420
|
+
|
421
|
+
loc = -1; /* just to suppress compiler warning */
|
422
|
+
foreach(lc, (const List *) expr)
|
423
|
+
{
|
424
|
+
loc = exprLocation((Node *) lfirst(lc));
|
425
|
+
if (loc >= 0)
|
426
|
+
break;
|
427
|
+
}
|
428
|
+
}
|
429
|
+
break;
|
430
|
+
case T_A_Expr:
|
431
|
+
{
|
432
|
+
const A_Expr *aexpr = (const A_Expr *) expr;
|
433
|
+
|
434
|
+
/* use leftmost of operator or left operand (if any) */
|
435
|
+
/* we assume right operand can't be to left of operator */
|
436
|
+
loc = leftmostLoc(aexpr->location,
|
437
|
+
exprLocation(aexpr->lexpr));
|
438
|
+
}
|
439
|
+
break;
|
440
|
+
case T_ColumnRef:
|
441
|
+
loc = ((const ColumnRef *) expr)->location;
|
442
|
+
break;
|
443
|
+
case T_ParamRef:
|
444
|
+
loc = ((const ParamRef *) expr)->location;
|
445
|
+
break;
|
446
|
+
case T_A_Const:
|
447
|
+
loc = ((const A_Const *) expr)->location;
|
448
|
+
break;
|
449
|
+
case T_FuncCall:
|
450
|
+
{
|
451
|
+
const FuncCall *fc = (const FuncCall *) expr;
|
452
|
+
|
453
|
+
/* consider both function name and leftmost arg */
|
454
|
+
/* (we assume any ORDER BY nodes must be to right of name) */
|
455
|
+
loc = leftmostLoc(fc->location,
|
456
|
+
exprLocation((Node *) fc->args));
|
457
|
+
}
|
458
|
+
break;
|
459
|
+
case T_A_ArrayExpr:
|
460
|
+
/* the location points at ARRAY or [, which must be leftmost */
|
461
|
+
loc = ((const A_ArrayExpr *) expr)->location;
|
462
|
+
break;
|
463
|
+
case T_ResTarget:
|
464
|
+
/* we need not examine the contained expression (if any) */
|
465
|
+
loc = ((const ResTarget *) expr)->location;
|
466
|
+
break;
|
467
|
+
case T_MultiAssignRef:
|
468
|
+
loc = exprLocation(((const MultiAssignRef *) expr)->source);
|
469
|
+
break;
|
470
|
+
case T_TypeCast:
|
471
|
+
{
|
472
|
+
const TypeCast *tc = (const TypeCast *) expr;
|
473
|
+
|
474
|
+
/*
|
475
|
+
* This could represent CAST(), ::, or TypeName 'literal', so
|
476
|
+
* any of the components might be leftmost.
|
477
|
+
*/
|
478
|
+
loc = exprLocation(tc->arg);
|
479
|
+
loc = leftmostLoc(loc, tc->typeName->location);
|
480
|
+
loc = leftmostLoc(loc, tc->location);
|
481
|
+
}
|
482
|
+
break;
|
483
|
+
case T_CollateClause:
|
484
|
+
/* just use argument's location */
|
485
|
+
loc = exprLocation(((const CollateClause *) expr)->arg);
|
486
|
+
break;
|
487
|
+
case T_SortBy:
|
488
|
+
/* just use argument's location (ignore operator, if any) */
|
489
|
+
loc = exprLocation(((const SortBy *) expr)->node);
|
490
|
+
break;
|
491
|
+
case T_WindowDef:
|
492
|
+
loc = ((const WindowDef *) expr)->location;
|
493
|
+
break;
|
494
|
+
case T_RangeTableSample:
|
495
|
+
loc = ((const RangeTableSample *) expr)->location;
|
496
|
+
break;
|
497
|
+
case T_TypeName:
|
498
|
+
loc = ((const TypeName *) expr)->location;
|
499
|
+
break;
|
500
|
+
case T_ColumnDef:
|
501
|
+
loc = ((const ColumnDef *) expr)->location;
|
502
|
+
break;
|
503
|
+
case T_Constraint:
|
504
|
+
loc = ((const Constraint *) expr)->location;
|
505
|
+
break;
|
506
|
+
case T_FunctionParameter:
|
507
|
+
/* just use typename's location */
|
508
|
+
loc = exprLocation((Node *) ((const FunctionParameter *) expr)->argType);
|
509
|
+
break;
|
510
|
+
case T_XmlSerialize:
|
511
|
+
/* XMLSERIALIZE keyword should always be the first thing */
|
512
|
+
loc = ((const XmlSerialize *) expr)->location;
|
513
|
+
break;
|
514
|
+
case T_GroupingSet:
|
515
|
+
loc = ((const GroupingSet *) expr)->location;
|
516
|
+
break;
|
517
|
+
case T_WithClause:
|
518
|
+
loc = ((const WithClause *) expr)->location;
|
519
|
+
break;
|
520
|
+
case T_InferClause:
|
521
|
+
loc = ((const InferClause *) expr)->location;
|
522
|
+
break;
|
523
|
+
case T_OnConflictClause:
|
524
|
+
loc = ((const OnConflictClause *) expr)->location;
|
525
|
+
break;
|
526
|
+
case T_CommonTableExpr:
|
527
|
+
loc = ((const CommonTableExpr *) expr)->location;
|
528
|
+
break;
|
529
|
+
case T_PlaceHolderVar:
|
530
|
+
/* just use argument's location */
|
531
|
+
loc = exprLocation((Node *) ((const PlaceHolderVar *) expr)->phexpr);
|
532
|
+
break;
|
533
|
+
case T_InferenceElem:
|
534
|
+
/* just use nested expr's location */
|
535
|
+
loc = exprLocation((Node *) ((const InferenceElem *) expr)->expr);
|
536
|
+
break;
|
537
|
+
case T_PartitionElem:
|
538
|
+
loc = ((const PartitionElem *) expr)->location;
|
539
|
+
break;
|
540
|
+
case T_PartitionSpec:
|
541
|
+
loc = ((const PartitionSpec *) expr)->location;
|
542
|
+
break;
|
543
|
+
case T_PartitionBoundSpec:
|
544
|
+
loc = ((const PartitionBoundSpec *) expr)->location;
|
545
|
+
break;
|
546
|
+
case T_PartitionRangeDatum:
|
547
|
+
loc = ((const PartitionRangeDatum *) expr)->location;
|
548
|
+
break;
|
549
|
+
default:
|
550
|
+
/* for any other node type it's just unknown... */
|
551
|
+
loc = -1;
|
552
|
+
break;
|
553
|
+
}
|
554
|
+
return loc;
|
555
|
+
}
|
556
|
+
|
557
|
+
/*
|
558
|
+
* leftmostLoc - support for exprLocation
|
559
|
+
*
|
560
|
+
* Take the minimum of two parse location values, but ignore unknowns
|
561
|
+
*/
|
562
|
+
static int
|
563
|
+
leftmostLoc(int loc1, int loc2)
|
564
|
+
{
|
565
|
+
if (loc1 < 0)
|
566
|
+
return loc2;
|
567
|
+
else if (loc2 < 0)
|
568
|
+
return loc1;
|
569
|
+
else
|
570
|
+
return Min(loc1, loc2);
|
571
|
+
}
|
572
|
+
|
573
|
+
|
574
|
+
/*
|
575
|
+
* fix_opfuncids
|
576
|
+
* Calculate opfuncid field from opno for each OpExpr node in given tree.
|
577
|
+
* The given tree can be anything expression_tree_walker handles.
|
578
|
+
*
|
579
|
+
* The argument is modified in-place. (This is OK since we'd want the
|
580
|
+
* same change for any node, even if it gets visited more than once due to
|
581
|
+
* shared structure.)
|
582
|
+
*/
|
583
|
+
|
584
|
+
|
585
|
+
|
586
|
+
|
587
|
+
/*
|
588
|
+
* set_opfuncid
|
589
|
+
* Set the opfuncid (procedure OID) in an OpExpr node,
|
590
|
+
* if it hasn't been set already.
|
591
|
+
*
|
592
|
+
* Because of struct equivalence, this can also be used for
|
593
|
+
* DistinctExpr and NullIfExpr nodes.
|
594
|
+
*/
|
595
|
+
|
596
|
+
|
597
|
+
/*
|
598
|
+
* set_sa_opfuncid
|
599
|
+
* As above, for ScalarArrayOpExpr nodes.
|
600
|
+
*/
|
601
|
+
|
602
|
+
|
603
|
+
|
604
|
+
/*
|
605
|
+
* check_functions_in_node -
|
606
|
+
* apply checker() to each function OID contained in given expression node
|
607
|
+
*
|
608
|
+
* Returns true if the checker() function does; for nodes representing more
|
609
|
+
* than one function call, returns true if the checker() function does so
|
610
|
+
* for any of those functions. Returns false if node does not invoke any
|
611
|
+
* SQL-visible function. Caller must not pass node == NULL.
|
612
|
+
*
|
613
|
+
* This function examines only the given node; it does not recurse into any
|
614
|
+
* sub-expressions. Callers typically prefer to keep control of the recursion
|
615
|
+
* for themselves, in case additional checks should be made, or because they
|
616
|
+
* have special rules about which parts of the tree need to be visited.
|
617
|
+
*
|
618
|
+
* Note: we ignore MinMaxExpr, SQLValueFunction, XmlExpr, CoerceToDomain,
|
619
|
+
* and NextValueExpr nodes, because they do not contain SQL function OIDs.
|
620
|
+
* However, they can invoke SQL-visible functions, so callers should take
|
621
|
+
* thought about how to treat them.
|
622
|
+
*/
|
623
|
+
|
624
|
+
|
625
|
+
|
626
|
+
/*
|
627
|
+
* Standard expression-tree walking support
|
628
|
+
*
|
629
|
+
* We used to have near-duplicate code in many different routines that
|
630
|
+
* understood how to recurse through an expression node tree. That was
|
631
|
+
* a pain to maintain, and we frequently had bugs due to some particular
|
632
|
+
* routine neglecting to support a particular node type. In most cases,
|
633
|
+
* these routines only actually care about certain node types, and don't
|
634
|
+
* care about other types except insofar as they have to recurse through
|
635
|
+
* non-primitive node types. Therefore, we now provide generic tree-walking
|
636
|
+
* logic to consolidate the redundant "boilerplate" code. There are
|
637
|
+
* two versions: expression_tree_walker() and expression_tree_mutator().
|
638
|
+
*/
|
639
|
+
|
640
|
+
/*
|
641
|
+
* expression_tree_walker() is designed to support routines that traverse
|
642
|
+
* a tree in a read-only fashion (although it will also work for routines
|
643
|
+
* that modify nodes in-place but never add/delete/replace nodes).
|
644
|
+
* A walker routine should look like this:
|
645
|
+
*
|
646
|
+
* bool my_walker (Node *node, my_struct *context)
|
647
|
+
* {
|
648
|
+
* if (node == NULL)
|
649
|
+
* return false;
|
650
|
+
* // check for nodes that special work is required for, eg:
|
651
|
+
* if (IsA(node, Var))
|
652
|
+
* {
|
653
|
+
* ... do special actions for Var nodes
|
654
|
+
* }
|
655
|
+
* else if (IsA(node, ...))
|
656
|
+
* {
|
657
|
+
* ... do special actions for other node types
|
658
|
+
* }
|
659
|
+
* // for any node type not specially processed, do:
|
660
|
+
* return expression_tree_walker(node, my_walker, (void *) context);
|
661
|
+
* }
|
662
|
+
*
|
663
|
+
* The "context" argument points to a struct that holds whatever context
|
664
|
+
* information the walker routine needs --- it can be used to return data
|
665
|
+
* gathered by the walker, too. This argument is not touched by
|
666
|
+
* expression_tree_walker, but it is passed down to recursive sub-invocations
|
667
|
+
* of my_walker. The tree walk is started from a setup routine that
|
668
|
+
* fills in the appropriate context struct, calls my_walker with the top-level
|
669
|
+
* node of the tree, and then examines the results.
|
670
|
+
*
|
671
|
+
* The walker routine should return "false" to continue the tree walk, or
|
672
|
+
* "true" to abort the walk and immediately return "true" to the top-level
|
673
|
+
* caller. This can be used to short-circuit the traversal if the walker
|
674
|
+
* has found what it came for. "false" is returned to the top-level caller
|
675
|
+
* iff no invocation of the walker returned "true".
|
676
|
+
*
|
677
|
+
* The node types handled by expression_tree_walker include all those
|
678
|
+
* normally found in target lists and qualifier clauses during the planning
|
679
|
+
* stage. In particular, it handles List nodes since a cnf-ified qual clause
|
680
|
+
* will have List structure at the top level, and it handles TargetEntry nodes
|
681
|
+
* so that a scan of a target list can be handled without additional code.
|
682
|
+
* Also, RangeTblRef, FromExpr, JoinExpr, and SetOperationStmt nodes are
|
683
|
+
* handled, so that query jointrees and setOperation trees can be processed
|
684
|
+
* without additional code.
|
685
|
+
*
|
686
|
+
* expression_tree_walker will handle SubLink nodes by recursing normally
|
687
|
+
* into the "testexpr" subtree (which is an expression belonging to the outer
|
688
|
+
* plan). It will also call the walker on the sub-Query node; however, when
|
689
|
+
* expression_tree_walker itself is called on a Query node, it does nothing
|
690
|
+
* and returns "false". The net effect is that unless the walker does
|
691
|
+
* something special at a Query node, sub-selects will not be visited during
|
692
|
+
* an expression tree walk. This is exactly the behavior wanted in many cases
|
693
|
+
* --- and for those walkers that do want to recurse into sub-selects, special
|
694
|
+
* behavior is typically needed anyway at the entry to a sub-select (such as
|
695
|
+
* incrementing a depth counter). A walker that wants to examine sub-selects
|
696
|
+
* should include code along the lines of:
|
697
|
+
*
|
698
|
+
* if (IsA(node, Query))
|
699
|
+
* {
|
700
|
+
* adjust context for subquery;
|
701
|
+
* result = query_tree_walker((Query *) node, my_walker, context,
|
702
|
+
* 0); // adjust flags as needed
|
703
|
+
* restore context if needed;
|
704
|
+
* return result;
|
705
|
+
* }
|
706
|
+
*
|
707
|
+
* query_tree_walker is a convenience routine (see below) that calls the
|
708
|
+
* walker on all the expression subtrees of the given Query node.
|
709
|
+
*
|
710
|
+
* expression_tree_walker will handle SubPlan nodes by recursing normally
|
711
|
+
* into the "testexpr" and the "args" list (which are expressions belonging to
|
712
|
+
* the outer plan). It will not touch the completed subplan, however. Since
|
713
|
+
* there is no link to the original Query, it is not possible to recurse into
|
714
|
+
* subselects of an already-planned expression tree. This is OK for current
|
715
|
+
* uses, but may need to be revisited in future.
|
716
|
+
*/
|
717
|
+
|
718
|
+
|
719
|
+
|
720
|
+
/*
|
721
|
+
* query_tree_walker --- initiate a walk of a Query's expressions
|
722
|
+
*
|
723
|
+
* This routine exists just to reduce the number of places that need to know
|
724
|
+
* where all the expression subtrees of a Query are. Note it can be used
|
725
|
+
* for starting a walk at top level of a Query regardless of whether the
|
726
|
+
* walker intends to descend into subqueries. It is also useful for
|
727
|
+
* descending into subqueries within a walker.
|
728
|
+
*
|
729
|
+
* Some callers want to suppress visitation of certain items in the sub-Query,
|
730
|
+
* typically because they need to process them specially, or don't actually
|
731
|
+
* want to recurse into subqueries. This is supported by the flags argument,
|
732
|
+
* which is the bitwise OR of flag values to add or suppress visitation of
|
733
|
+
* indicated items. (More flag bits may be added as needed.)
|
734
|
+
*/
|
735
|
+
|
736
|
+
|
737
|
+
/*
|
738
|
+
* range_table_walker is just the part of query_tree_walker that scans
|
739
|
+
* a query's rangetable. This is split out since it can be useful on
|
740
|
+
* its own.
|
741
|
+
*/
|
742
|
+
|
743
|
+
|
744
|
+
/*
|
745
|
+
* Some callers even want to scan the expressions in individual RTEs.
|
746
|
+
*/
|
747
|
+
|
748
|
+
|
749
|
+
|
750
|
+
/*
|
751
|
+
* expression_tree_mutator() is designed to support routines that make a
|
752
|
+
* modified copy of an expression tree, with some nodes being added,
|
753
|
+
* removed, or replaced by new subtrees. The original tree is (normally)
|
754
|
+
* not changed. Each recursion level is responsible for returning a copy of
|
755
|
+
* (or appropriately modified substitute for) the subtree it is handed.
|
756
|
+
* A mutator routine should look like this:
|
757
|
+
*
|
758
|
+
* Node * my_mutator (Node *node, my_struct *context)
|
759
|
+
* {
|
760
|
+
* if (node == NULL)
|
761
|
+
* return NULL;
|
762
|
+
* // check for nodes that special work is required for, eg:
|
763
|
+
* if (IsA(node, Var))
|
764
|
+
* {
|
765
|
+
* ... create and return modified copy of Var node
|
766
|
+
* }
|
767
|
+
* else if (IsA(node, ...))
|
768
|
+
* {
|
769
|
+
* ... do special transformations of other node types
|
770
|
+
* }
|
771
|
+
* // for any node type not specially processed, do:
|
772
|
+
* return expression_tree_mutator(node, my_mutator, (void *) context);
|
773
|
+
* }
|
774
|
+
*
|
775
|
+
* The "context" argument points to a struct that holds whatever context
|
776
|
+
* information the mutator routine needs --- it can be used to return extra
|
777
|
+
* data gathered by the mutator, too. This argument is not touched by
|
778
|
+
* expression_tree_mutator, but it is passed down to recursive sub-invocations
|
779
|
+
* of my_mutator. The tree walk is started from a setup routine that
|
780
|
+
* fills in the appropriate context struct, calls my_mutator with the
|
781
|
+
* top-level node of the tree, and does any required post-processing.
|
782
|
+
*
|
783
|
+
* Each level of recursion must return an appropriately modified Node.
|
784
|
+
* If expression_tree_mutator() is called, it will make an exact copy
|
785
|
+
* of the given Node, but invoke my_mutator() to copy the sub-node(s)
|
786
|
+
* of that Node. In this way, my_mutator() has full control over the
|
787
|
+
* copying process but need not directly deal with expression trees
|
788
|
+
* that it has no interest in.
|
789
|
+
*
|
790
|
+
* Just as for expression_tree_walker, the node types handled by
|
791
|
+
* expression_tree_mutator include all those normally found in target lists
|
792
|
+
* and qualifier clauses during the planning stage.
|
793
|
+
*
|
794
|
+
* expression_tree_mutator will handle SubLink nodes by recursing normally
|
795
|
+
* into the "testexpr" subtree (which is an expression belonging to the outer
|
796
|
+
* plan). It will also call the mutator on the sub-Query node; however, when
|
797
|
+
* expression_tree_mutator itself is called on a Query node, it does nothing
|
798
|
+
* and returns the unmodified Query node. The net effect is that unless the
|
799
|
+
* mutator does something special at a Query node, sub-selects will not be
|
800
|
+
* visited or modified; the original sub-select will be linked to by the new
|
801
|
+
* SubLink node. Mutators that want to descend into sub-selects will usually
|
802
|
+
* do so by recognizing Query nodes and calling query_tree_mutator (below).
|
803
|
+
*
|
804
|
+
* expression_tree_mutator will handle a SubPlan node by recursing into the
|
805
|
+
* "testexpr" and the "args" list (which belong to the outer plan), but it
|
806
|
+
* will simply copy the link to the inner plan, since that's typically what
|
807
|
+
* expression tree mutators want. A mutator that wants to modify the subplan
|
808
|
+
* can force appropriate behavior by recognizing SubPlan expression nodes
|
809
|
+
* and doing the right thing.
|
810
|
+
*/
|
811
|
+
|
812
|
+
#define FLATCOPY(newnode, node, nodetype) \
|
813
|
+
( (newnode) = (nodetype *) palloc(sizeof(nodetype)), \
|
814
|
+
memcpy((newnode), (node), sizeof(nodetype)) )
|
815
|
+
#define CHECKFLATCOPY(newnode, node, nodetype) \
|
816
|
+
( AssertMacro(IsA((node), nodetype)), \
|
817
|
+
(newnode) = (nodetype *) palloc(sizeof(nodetype)), \
|
818
|
+
memcpy((newnode), (node), sizeof(nodetype)) )
|
819
|
+
#define MUTATE(newfield, oldfield, fieldtype) \
|
820
|
+
( (newfield) = (fieldtype) mutator((Node *) (oldfield), context) )
|
821
|
+
|
822
|
+
|
823
|
+
/*
|
824
|
+
* query_tree_mutator --- initiate modification of a Query's expressions
|
825
|
+
*
|
826
|
+
* This routine exists just to reduce the number of places that need to know
|
827
|
+
* where all the expression subtrees of a Query are. Note it can be used
|
828
|
+
* for starting a walk at top level of a Query regardless of whether the
|
829
|
+
* mutator intends to descend into subqueries. It is also useful for
|
830
|
+
* descending into subqueries within a mutator.
|
831
|
+
*
|
832
|
+
* Some callers want to suppress mutating of certain items in the Query,
|
833
|
+
* typically because they need to process them specially, or don't actually
|
834
|
+
* want to recurse into subqueries. This is supported by the flags argument,
|
835
|
+
* which is the bitwise OR of flag values to suppress mutating of
|
836
|
+
* indicated items. (More flag bits may be added as needed.)
|
837
|
+
*
|
838
|
+
* Normally the Query node itself is copied, but some callers want it to be
|
839
|
+
* modified in-place; they must pass QTW_DONT_COPY_QUERY in flags. All
|
840
|
+
* modified substructure is safely copied in any case.
|
841
|
+
*/
|
842
|
+
|
843
|
+
|
844
|
+
/*
|
845
|
+
* range_table_mutator is just the part of query_tree_mutator that processes
|
846
|
+
* a query's rangetable. This is split out since it can be useful on
|
847
|
+
* its own.
|
848
|
+
*/
|
849
|
+
|
850
|
+
|
851
|
+
/*
|
852
|
+
* query_or_expression_tree_walker --- hybrid form
|
853
|
+
*
|
854
|
+
* This routine will invoke query_tree_walker if called on a Query node,
|
855
|
+
* else will invoke the walker directly. This is a useful way of starting
|
856
|
+
* the recursion when the walker's normal change of state is not appropriate
|
857
|
+
* for the outermost Query node.
|
858
|
+
*/
|
859
|
+
|
860
|
+
|
861
|
+
/*
|
862
|
+
* query_or_expression_tree_mutator --- hybrid form
|
863
|
+
*
|
864
|
+
* This routine will invoke query_tree_mutator if called on a Query node,
|
865
|
+
* else will invoke the mutator directly. This is a useful way of starting
|
866
|
+
* the recursion when the mutator's normal change of state is not appropriate
|
867
|
+
* for the outermost Query node.
|
868
|
+
*/
|
869
|
+
|
870
|
+
|
871
|
+
|
872
|
+
/*
|
873
|
+
* raw_expression_tree_walker --- walk raw parse trees
|
874
|
+
*
|
875
|
+
* This has exactly the same API as expression_tree_walker, but instead of
|
876
|
+
* walking post-analysis parse trees, it knows how to walk the node types
|
877
|
+
* found in raw grammar output. (There is not currently any need for a
|
878
|
+
* combined walker, so we keep them separate in the name of efficiency.)
|
879
|
+
* Unlike expression_tree_walker, there is no special rule about query
|
880
|
+
* boundaries: we descend to everything that's possibly interesting.
|
881
|
+
*
|
882
|
+
* Currently, the node type coverage here extends only to DML statements
|
883
|
+
* (SELECT/INSERT/UPDATE/DELETE) and nodes that can appear in them, because
|
884
|
+
* this is used mainly during analysis of CTEs, and only DML statements can
|
885
|
+
* appear in CTEs.
|
886
|
+
*/
|
887
|
+
bool
|
888
|
+
raw_expression_tree_walker(Node *node,
|
889
|
+
bool (*walker) (),
|
890
|
+
void *context)
|
891
|
+
{
|
892
|
+
ListCell *temp;
|
893
|
+
|
894
|
+
/*
|
895
|
+
* The walker has already visited the current node, and so we need only
|
896
|
+
* recurse into any sub-nodes it has.
|
897
|
+
*/
|
898
|
+
if (node == NULL)
|
899
|
+
return false;
|
900
|
+
|
901
|
+
/* Guard against stack overflow due to overly complex expressions */
|
902
|
+
check_stack_depth();
|
903
|
+
|
904
|
+
switch (nodeTag(node))
|
905
|
+
{
|
906
|
+
case T_SetToDefault:
|
907
|
+
case T_CurrentOfExpr:
|
908
|
+
case T_SQLValueFunction:
|
909
|
+
case T_Integer:
|
910
|
+
case T_Float:
|
911
|
+
case T_String:
|
912
|
+
case T_BitString:
|
913
|
+
case T_Null:
|
914
|
+
case T_ParamRef:
|
915
|
+
case T_A_Const:
|
916
|
+
case T_A_Star:
|
917
|
+
/* primitive node types with no subnodes */
|
918
|
+
break;
|
919
|
+
case T_Alias:
|
920
|
+
/* we assume the colnames list isn't interesting */
|
921
|
+
break;
|
922
|
+
case T_RangeVar:
|
923
|
+
return walker(((RangeVar *) node)->alias, context);
|
924
|
+
case T_GroupingFunc:
|
925
|
+
return walker(((GroupingFunc *) node)->args, context);
|
926
|
+
case T_SubLink:
|
927
|
+
{
|
928
|
+
SubLink *sublink = (SubLink *) node;
|
929
|
+
|
930
|
+
if (walker(sublink->testexpr, context))
|
931
|
+
return true;
|
932
|
+
/* we assume the operName is not interesting */
|
933
|
+
if (walker(sublink->subselect, context))
|
934
|
+
return true;
|
935
|
+
}
|
936
|
+
break;
|
937
|
+
case T_CaseExpr:
|
938
|
+
{
|
939
|
+
CaseExpr *caseexpr = (CaseExpr *) node;
|
940
|
+
|
941
|
+
if (walker(caseexpr->arg, context))
|
942
|
+
return true;
|
943
|
+
/* we assume walker doesn't care about CaseWhens, either */
|
944
|
+
foreach(temp, caseexpr->args)
|
945
|
+
{
|
946
|
+
CaseWhen *when = lfirst_node(CaseWhen, temp);
|
947
|
+
|
948
|
+
if (walker(when->expr, context))
|
949
|
+
return true;
|
950
|
+
if (walker(when->result, context))
|
951
|
+
return true;
|
952
|
+
}
|
953
|
+
if (walker(caseexpr->defresult, context))
|
954
|
+
return true;
|
955
|
+
}
|
956
|
+
break;
|
957
|
+
case T_RowExpr:
|
958
|
+
/* Assume colnames isn't interesting */
|
959
|
+
return walker(((RowExpr *) node)->args, context);
|
960
|
+
case T_CoalesceExpr:
|
961
|
+
return walker(((CoalesceExpr *) node)->args, context);
|
962
|
+
case T_MinMaxExpr:
|
963
|
+
return walker(((MinMaxExpr *) node)->args, context);
|
964
|
+
case T_XmlExpr:
|
965
|
+
{
|
966
|
+
XmlExpr *xexpr = (XmlExpr *) node;
|
967
|
+
|
968
|
+
if (walker(xexpr->named_args, context))
|
969
|
+
return true;
|
970
|
+
/* we assume walker doesn't care about arg_names */
|
971
|
+
if (walker(xexpr->args, context))
|
972
|
+
return true;
|
973
|
+
}
|
974
|
+
break;
|
975
|
+
case T_NullTest:
|
976
|
+
return walker(((NullTest *) node)->arg, context);
|
977
|
+
case T_BooleanTest:
|
978
|
+
return walker(((BooleanTest *) node)->arg, context);
|
979
|
+
case T_JoinExpr:
|
980
|
+
{
|
981
|
+
JoinExpr *join = (JoinExpr *) node;
|
982
|
+
|
983
|
+
if (walker(join->larg, context))
|
984
|
+
return true;
|
985
|
+
if (walker(join->rarg, context))
|
986
|
+
return true;
|
987
|
+
if (walker(join->quals, context))
|
988
|
+
return true;
|
989
|
+
if (walker(join->alias, context))
|
990
|
+
return true;
|
991
|
+
/* using list is deemed uninteresting */
|
992
|
+
}
|
993
|
+
break;
|
994
|
+
case T_IntoClause:
|
995
|
+
{
|
996
|
+
IntoClause *into = (IntoClause *) node;
|
997
|
+
|
998
|
+
if (walker(into->rel, context))
|
999
|
+
return true;
|
1000
|
+
/* colNames, options are deemed uninteresting */
|
1001
|
+
/* viewQuery should be null in raw parsetree, but check it */
|
1002
|
+
if (walker(into->viewQuery, context))
|
1003
|
+
return true;
|
1004
|
+
}
|
1005
|
+
break;
|
1006
|
+
case T_List:
|
1007
|
+
foreach(temp, (List *) node)
|
1008
|
+
{
|
1009
|
+
if (walker((Node *) lfirst(temp), context))
|
1010
|
+
return true;
|
1011
|
+
}
|
1012
|
+
break;
|
1013
|
+
case T_InsertStmt:
|
1014
|
+
{
|
1015
|
+
InsertStmt *stmt = (InsertStmt *) node;
|
1016
|
+
|
1017
|
+
if (walker(stmt->relation, context))
|
1018
|
+
return true;
|
1019
|
+
if (walker(stmt->cols, context))
|
1020
|
+
return true;
|
1021
|
+
if (walker(stmt->selectStmt, context))
|
1022
|
+
return true;
|
1023
|
+
if (walker(stmt->onConflictClause, context))
|
1024
|
+
return true;
|
1025
|
+
if (walker(stmt->returningList, context))
|
1026
|
+
return true;
|
1027
|
+
if (walker(stmt->withClause, context))
|
1028
|
+
return true;
|
1029
|
+
}
|
1030
|
+
break;
|
1031
|
+
case T_DeleteStmt:
|
1032
|
+
{
|
1033
|
+
DeleteStmt *stmt = (DeleteStmt *) node;
|
1034
|
+
|
1035
|
+
if (walker(stmt->relation, context))
|
1036
|
+
return true;
|
1037
|
+
if (walker(stmt->usingClause, context))
|
1038
|
+
return true;
|
1039
|
+
if (walker(stmt->whereClause, context))
|
1040
|
+
return true;
|
1041
|
+
if (walker(stmt->returningList, context))
|
1042
|
+
return true;
|
1043
|
+
if (walker(stmt->withClause, context))
|
1044
|
+
return true;
|
1045
|
+
}
|
1046
|
+
break;
|
1047
|
+
case T_UpdateStmt:
|
1048
|
+
{
|
1049
|
+
UpdateStmt *stmt = (UpdateStmt *) node;
|
1050
|
+
|
1051
|
+
if (walker(stmt->relation, context))
|
1052
|
+
return true;
|
1053
|
+
if (walker(stmt->targetList, context))
|
1054
|
+
return true;
|
1055
|
+
if (walker(stmt->whereClause, context))
|
1056
|
+
return true;
|
1057
|
+
if (walker(stmt->fromClause, context))
|
1058
|
+
return true;
|
1059
|
+
if (walker(stmt->returningList, context))
|
1060
|
+
return true;
|
1061
|
+
if (walker(stmt->withClause, context))
|
1062
|
+
return true;
|
1063
|
+
}
|
1064
|
+
break;
|
1065
|
+
case T_SelectStmt:
|
1066
|
+
{
|
1067
|
+
SelectStmt *stmt = (SelectStmt *) node;
|
1068
|
+
|
1069
|
+
if (walker(stmt->distinctClause, context))
|
1070
|
+
return true;
|
1071
|
+
if (walker(stmt->intoClause, context))
|
1072
|
+
return true;
|
1073
|
+
if (walker(stmt->targetList, context))
|
1074
|
+
return true;
|
1075
|
+
if (walker(stmt->fromClause, context))
|
1076
|
+
return true;
|
1077
|
+
if (walker(stmt->whereClause, context))
|
1078
|
+
return true;
|
1079
|
+
if (walker(stmt->groupClause, context))
|
1080
|
+
return true;
|
1081
|
+
if (walker(stmt->havingClause, context))
|
1082
|
+
return true;
|
1083
|
+
if (walker(stmt->windowClause, context))
|
1084
|
+
return true;
|
1085
|
+
if (walker(stmt->valuesLists, context))
|
1086
|
+
return true;
|
1087
|
+
if (walker(stmt->sortClause, context))
|
1088
|
+
return true;
|
1089
|
+
if (walker(stmt->limitOffset, context))
|
1090
|
+
return true;
|
1091
|
+
if (walker(stmt->limitCount, context))
|
1092
|
+
return true;
|
1093
|
+
if (walker(stmt->lockingClause, context))
|
1094
|
+
return true;
|
1095
|
+
if (walker(stmt->withClause, context))
|
1096
|
+
return true;
|
1097
|
+
if (walker(stmt->larg, context))
|
1098
|
+
return true;
|
1099
|
+
if (walker(stmt->rarg, context))
|
1100
|
+
return true;
|
1101
|
+
}
|
1102
|
+
break;
|
1103
|
+
case T_A_Expr:
|
1104
|
+
{
|
1105
|
+
A_Expr *expr = (A_Expr *) node;
|
1106
|
+
|
1107
|
+
if (walker(expr->lexpr, context))
|
1108
|
+
return true;
|
1109
|
+
if (walker(expr->rexpr, context))
|
1110
|
+
return true;
|
1111
|
+
/* operator name is deemed uninteresting */
|
1112
|
+
}
|
1113
|
+
break;
|
1114
|
+
case T_BoolExpr:
|
1115
|
+
{
|
1116
|
+
BoolExpr *expr = (BoolExpr *) node;
|
1117
|
+
|
1118
|
+
if (walker(expr->args, context))
|
1119
|
+
return true;
|
1120
|
+
}
|
1121
|
+
break;
|
1122
|
+
case T_ColumnRef:
|
1123
|
+
/* we assume the fields contain nothing interesting */
|
1124
|
+
break;
|
1125
|
+
case T_FuncCall:
|
1126
|
+
{
|
1127
|
+
FuncCall *fcall = (FuncCall *) node;
|
1128
|
+
|
1129
|
+
if (walker(fcall->args, context))
|
1130
|
+
return true;
|
1131
|
+
if (walker(fcall->agg_order, context))
|
1132
|
+
return true;
|
1133
|
+
if (walker(fcall->agg_filter, context))
|
1134
|
+
return true;
|
1135
|
+
if (walker(fcall->over, context))
|
1136
|
+
return true;
|
1137
|
+
/* function name is deemed uninteresting */
|
1138
|
+
}
|
1139
|
+
break;
|
1140
|
+
case T_NamedArgExpr:
|
1141
|
+
return walker(((NamedArgExpr *) node)->arg, context);
|
1142
|
+
case T_A_Indices:
|
1143
|
+
{
|
1144
|
+
A_Indices *indices = (A_Indices *) node;
|
1145
|
+
|
1146
|
+
if (walker(indices->lidx, context))
|
1147
|
+
return true;
|
1148
|
+
if (walker(indices->uidx, context))
|
1149
|
+
return true;
|
1150
|
+
}
|
1151
|
+
break;
|
1152
|
+
case T_A_Indirection:
|
1153
|
+
{
|
1154
|
+
A_Indirection *indir = (A_Indirection *) node;
|
1155
|
+
|
1156
|
+
if (walker(indir->arg, context))
|
1157
|
+
return true;
|
1158
|
+
if (walker(indir->indirection, context))
|
1159
|
+
return true;
|
1160
|
+
}
|
1161
|
+
break;
|
1162
|
+
case T_A_ArrayExpr:
|
1163
|
+
return walker(((A_ArrayExpr *) node)->elements, context);
|
1164
|
+
case T_ResTarget:
|
1165
|
+
{
|
1166
|
+
ResTarget *rt = (ResTarget *) node;
|
1167
|
+
|
1168
|
+
if (walker(rt->indirection, context))
|
1169
|
+
return true;
|
1170
|
+
if (walker(rt->val, context))
|
1171
|
+
return true;
|
1172
|
+
}
|
1173
|
+
break;
|
1174
|
+
case T_MultiAssignRef:
|
1175
|
+
return walker(((MultiAssignRef *) node)->source, context);
|
1176
|
+
case T_TypeCast:
|
1177
|
+
{
|
1178
|
+
TypeCast *tc = (TypeCast *) node;
|
1179
|
+
|
1180
|
+
if (walker(tc->arg, context))
|
1181
|
+
return true;
|
1182
|
+
if (walker(tc->typeName, context))
|
1183
|
+
return true;
|
1184
|
+
}
|
1185
|
+
break;
|
1186
|
+
case T_CollateClause:
|
1187
|
+
return walker(((CollateClause *) node)->arg, context);
|
1188
|
+
case T_SortBy:
|
1189
|
+
return walker(((SortBy *) node)->node, context);
|
1190
|
+
case T_WindowDef:
|
1191
|
+
{
|
1192
|
+
WindowDef *wd = (WindowDef *) node;
|
1193
|
+
|
1194
|
+
if (walker(wd->partitionClause, context))
|
1195
|
+
return true;
|
1196
|
+
if (walker(wd->orderClause, context))
|
1197
|
+
return true;
|
1198
|
+
if (walker(wd->startOffset, context))
|
1199
|
+
return true;
|
1200
|
+
if (walker(wd->endOffset, context))
|
1201
|
+
return true;
|
1202
|
+
}
|
1203
|
+
break;
|
1204
|
+
case T_RangeSubselect:
|
1205
|
+
{
|
1206
|
+
RangeSubselect *rs = (RangeSubselect *) node;
|
1207
|
+
|
1208
|
+
if (walker(rs->subquery, context))
|
1209
|
+
return true;
|
1210
|
+
if (walker(rs->alias, context))
|
1211
|
+
return true;
|
1212
|
+
}
|
1213
|
+
break;
|
1214
|
+
case T_RangeFunction:
|
1215
|
+
{
|
1216
|
+
RangeFunction *rf = (RangeFunction *) node;
|
1217
|
+
|
1218
|
+
if (walker(rf->functions, context))
|
1219
|
+
return true;
|
1220
|
+
if (walker(rf->alias, context))
|
1221
|
+
return true;
|
1222
|
+
if (walker(rf->coldeflist, context))
|
1223
|
+
return true;
|
1224
|
+
}
|
1225
|
+
break;
|
1226
|
+
case T_RangeTableSample:
|
1227
|
+
{
|
1228
|
+
RangeTableSample *rts = (RangeTableSample *) node;
|
1229
|
+
|
1230
|
+
if (walker(rts->relation, context))
|
1231
|
+
return true;
|
1232
|
+
/* method name is deemed uninteresting */
|
1233
|
+
if (walker(rts->args, context))
|
1234
|
+
return true;
|
1235
|
+
if (walker(rts->repeatable, context))
|
1236
|
+
return true;
|
1237
|
+
}
|
1238
|
+
break;
|
1239
|
+
case T_RangeTableFunc:
|
1240
|
+
{
|
1241
|
+
RangeTableFunc *rtf = (RangeTableFunc *) node;
|
1242
|
+
|
1243
|
+
if (walker(rtf->docexpr, context))
|
1244
|
+
return true;
|
1245
|
+
if (walker(rtf->rowexpr, context))
|
1246
|
+
return true;
|
1247
|
+
if (walker(rtf->namespaces, context))
|
1248
|
+
return true;
|
1249
|
+
if (walker(rtf->columns, context))
|
1250
|
+
return true;
|
1251
|
+
if (walker(rtf->alias, context))
|
1252
|
+
return true;
|
1253
|
+
}
|
1254
|
+
break;
|
1255
|
+
case T_RangeTableFuncCol:
|
1256
|
+
{
|
1257
|
+
RangeTableFuncCol *rtfc = (RangeTableFuncCol *) node;
|
1258
|
+
|
1259
|
+
if (walker(rtfc->colexpr, context))
|
1260
|
+
return true;
|
1261
|
+
if (walker(rtfc->coldefexpr, context))
|
1262
|
+
return true;
|
1263
|
+
}
|
1264
|
+
break;
|
1265
|
+
case T_TypeName:
|
1266
|
+
{
|
1267
|
+
TypeName *tn = (TypeName *) node;
|
1268
|
+
|
1269
|
+
if (walker(tn->typmods, context))
|
1270
|
+
return true;
|
1271
|
+
if (walker(tn->arrayBounds, context))
|
1272
|
+
return true;
|
1273
|
+
/* type name itself is deemed uninteresting */
|
1274
|
+
}
|
1275
|
+
break;
|
1276
|
+
case T_ColumnDef:
|
1277
|
+
{
|
1278
|
+
ColumnDef *coldef = (ColumnDef *) node;
|
1279
|
+
|
1280
|
+
if (walker(coldef->typeName, context))
|
1281
|
+
return true;
|
1282
|
+
if (walker(coldef->raw_default, context))
|
1283
|
+
return true;
|
1284
|
+
if (walker(coldef->collClause, context))
|
1285
|
+
return true;
|
1286
|
+
/* for now, constraints are ignored */
|
1287
|
+
}
|
1288
|
+
break;
|
1289
|
+
case T_IndexElem:
|
1290
|
+
{
|
1291
|
+
IndexElem *indelem = (IndexElem *) node;
|
1292
|
+
|
1293
|
+
if (walker(indelem->expr, context))
|
1294
|
+
return true;
|
1295
|
+
/* collation and opclass names are deemed uninteresting */
|
1296
|
+
}
|
1297
|
+
break;
|
1298
|
+
case T_GroupingSet:
|
1299
|
+
return walker(((GroupingSet *) node)->content, context);
|
1300
|
+
case T_LockingClause:
|
1301
|
+
return walker(((LockingClause *) node)->lockedRels, context);
|
1302
|
+
case T_XmlSerialize:
|
1303
|
+
{
|
1304
|
+
XmlSerialize *xs = (XmlSerialize *) node;
|
1305
|
+
|
1306
|
+
if (walker(xs->expr, context))
|
1307
|
+
return true;
|
1308
|
+
if (walker(xs->typeName, context))
|
1309
|
+
return true;
|
1310
|
+
}
|
1311
|
+
break;
|
1312
|
+
case T_WithClause:
|
1313
|
+
return walker(((WithClause *) node)->ctes, context);
|
1314
|
+
case T_InferClause:
|
1315
|
+
{
|
1316
|
+
InferClause *stmt = (InferClause *) node;
|
1317
|
+
|
1318
|
+
if (walker(stmt->indexElems, context))
|
1319
|
+
return true;
|
1320
|
+
if (walker(stmt->whereClause, context))
|
1321
|
+
return true;
|
1322
|
+
}
|
1323
|
+
break;
|
1324
|
+
case T_OnConflictClause:
|
1325
|
+
{
|
1326
|
+
OnConflictClause *stmt = (OnConflictClause *) node;
|
1327
|
+
|
1328
|
+
if (walker(stmt->infer, context))
|
1329
|
+
return true;
|
1330
|
+
if (walker(stmt->targetList, context))
|
1331
|
+
return true;
|
1332
|
+
if (walker(stmt->whereClause, context))
|
1333
|
+
return true;
|
1334
|
+
}
|
1335
|
+
break;
|
1336
|
+
case T_CommonTableExpr:
|
1337
|
+
return walker(((CommonTableExpr *) node)->ctequery, context);
|
1338
|
+
default:
|
1339
|
+
elog(ERROR, "unrecognized node type: %d",
|
1340
|
+
(int) nodeTag(node));
|
1341
|
+
break;
|
1342
|
+
}
|
1343
|
+
return false;
|
1344
|
+
}
|
1345
|
+
|
1346
|
+
/*
|
1347
|
+
* planstate_tree_walker --- walk plan state trees
|
1348
|
+
*
|
1349
|
+
* The walker has already visited the current node, and so we need only
|
1350
|
+
* recurse into any sub-nodes it has.
|
1351
|
+
*/
|
1352
|
+
|
1353
|
+
|
1354
|
+
/*
|
1355
|
+
* Walk a list of SubPlans (or initPlans, which also use SubPlan nodes).
|
1356
|
+
*/
|
1357
|
+
|
1358
|
+
|
1359
|
+
/*
|
1360
|
+
* Walk the constituent plans of a ModifyTable, Append, MergeAppend,
|
1361
|
+
* BitmapAnd, or BitmapOr node.
|
1362
|
+
*/
|
1363
|
+
|