pg_query 5.1.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/README.md +1 -1
- data/Rakefile +4 -4
- data/ext/pg_query/ext_symbols_freebsd.sym +1 -0
- data/ext/pg_query/ext_symbols_freebsd_with_ruby_abi_version.sym +2 -0
- data/ext/pg_query/ext_symbols_openbsd.sym +1 -0
- data/ext/pg_query/ext_symbols_openbsd_with_ruby_abi_version.sym +2 -0
- data/ext/pg_query/ext_symbols_with_ruby_abi_version.sym +2 -0
- data/ext/pg_query/extconf.rb +20 -6
- data/ext/pg_query/include/pg_query.h +4 -3
- data/ext/pg_query/include/pg_query_enum_defs.c +424 -154
- data/ext/pg_query/include/pg_query_fingerprint_conds.c +68 -4
- data/ext/pg_query/include/pg_query_fingerprint_defs.c +2952 -1845
- data/ext/pg_query/include/pg_query_outfuncs_conds.c +51 -3
- data/ext/pg_query/include/pg_query_outfuncs_defs.c +210 -23
- data/ext/pg_query/include/pg_query_readfuncs_conds.c +17 -1
- data/ext/pg_query/include/pg_query_readfuncs_defs.c +271 -52
- data/ext/pg_query/include/postgres/access/amapi.h +14 -3
- data/ext/pg_query/include/postgres/access/attmap.h +1 -1
- data/ext/pg_query/include/postgres/access/attnum.h +1 -1
- data/ext/pg_query/include/postgres/access/brin_internal.h +116 -0
- data/ext/pg_query/include/postgres/access/brin_tuple.h +112 -0
- data/ext/pg_query/include/postgres/access/clog.h +2 -3
- data/ext/pg_query/include/postgres/access/commit_ts.h +2 -3
- data/ext/pg_query/include/postgres/access/detoast.h +1 -1
- data/ext/pg_query/include/postgres/access/genam.h +17 -4
- data/ext/pg_query/include/postgres/access/gin.h +1 -1
- data/ext/pg_query/include/postgres/access/htup.h +1 -1
- data/ext/pg_query/include/postgres/access/htup_details.h +11 -11
- data/ext/pg_query/include/postgres/access/itup.h +3 -3
- data/ext/pg_query/include/postgres/access/parallel.h +1 -2
- data/ext/pg_query/include/postgres/access/printtup.h +1 -1
- data/ext/pg_query/include/postgres/access/relation.h +1 -1
- data/ext/pg_query/include/postgres/access/relscan.h +1 -1
- data/ext/pg_query/include/postgres/access/rmgrlist.h +1 -1
- data/ext/pg_query/include/postgres/access/sdir.h +1 -1
- data/ext/pg_query/include/postgres/access/skey.h +1 -1
- data/ext/pg_query/include/postgres/access/slru.h +218 -0
- data/ext/pg_query/include/postgres/access/stratnum.h +1 -1
- data/ext/pg_query/include/postgres/access/sysattr.h +1 -1
- data/ext/pg_query/include/postgres/access/table.h +1 -1
- data/ext/pg_query/include/postgres/access/tableam.h +35 -25
- data/ext/pg_query/include/postgres/access/tidstore.h +50 -0
- data/ext/pg_query/include/postgres/access/toast_compression.h +2 -2
- data/ext/pg_query/include/postgres/access/transam.h +50 -7
- data/ext/pg_query/include/postgres/access/tsmapi.h +1 -1
- data/ext/pg_query/include/postgres/access/tupconvert.h +1 -1
- data/ext/pg_query/include/postgres/access/tupdesc.h +5 -5
- data/ext/pg_query/include/postgres/access/tupmacs.h +1 -1
- data/ext/pg_query/include/postgres/access/twophase.h +2 -2
- data/ext/pg_query/include/postgres/access/xact.h +5 -5
- data/ext/pg_query/include/postgres/access/xlog.h +20 -12
- data/ext/pg_query/include/postgres/access/xlog_internal.h +4 -3
- data/ext/pg_query/include/postgres/access/xlogbackup.h +3 -1
- data/ext/pg_query/include/postgres/access/xlogdefs.h +5 -5
- data/ext/pg_query/include/postgres/access/xlogprefetcher.h +2 -2
- data/ext/pg_query/include/postgres/access/xlogreader.h +2 -2
- data/ext/pg_query/include/postgres/access/xlogrecord.h +3 -3
- data/ext/pg_query/include/postgres/access/xlogrecovery.h +4 -4
- data/ext/pg_query/include/postgres/archive/archive_module.h +9 -1
- data/ext/pg_query/include/postgres/c.h +32 -37
- data/ext/pg_query/include/postgres/catalog/catalog.h +3 -1
- data/ext/pg_query/include/postgres/catalog/catversion.h +2 -2
- data/ext/pg_query/include/postgres/catalog/dependency.h +17 -59
- data/ext/pg_query/include/postgres/catalog/genbki.h +12 -6
- data/ext/pg_query/include/postgres/catalog/index.h +22 -18
- data/ext/pg_query/include/postgres/catalog/indexing.h +1 -1
- data/ext/pg_query/include/postgres/catalog/namespace.h +18 -19
- data/ext/pg_query/include/postgres/catalog/objectaccess.h +2 -2
- data/ext/pg_query/include/postgres/catalog/objectaddress.h +5 -1
- data/ext/pg_query/include/postgres/catalog/pg_aggregate.h +4 -2
- data/ext/pg_query/include/postgres/catalog/pg_aggregate_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_am.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_am_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_attribute.h +31 -14
- data/ext/pg_query/include/postgres/catalog/pg_attribute_d.h +3 -3
- data/ext/pg_query/include/postgres/catalog/pg_authid.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_authid_d.h +2 -1
- data/ext/pg_query/include/postgres/catalog/pg_class.h +10 -5
- data/ext/pg_query/include/postgres/catalog/pg_class_d.h +4 -2
- data/ext/pg_query/include/postgres/catalog/pg_collation.h +11 -5
- data/ext/pg_query/include/postgres/catalog/pg_collation_d.h +5 -2
- data/ext/pg_query/include/postgres/catalog/pg_constraint.h +15 -10
- data/ext/pg_query/include/postgres/catalog/pg_constraint_d.h +2 -1
- data/ext/pg_query/include/postgres/catalog/pg_control.h +5 -3
- data/ext/pg_query/include/postgres/catalog/pg_conversion.h +8 -4
- data/ext/pg_query/include/postgres/catalog/pg_conversion_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_database.h +9 -4
- data/ext/pg_query/include/postgres/catalog/pg_database_d.h +13 -12
- data/ext/pg_query/include/postgres/catalog/pg_depend.h +3 -3
- data/ext/pg_query/include/postgres/catalog/pg_depend_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_event_trigger.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_event_trigger_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_index.h +5 -3
- data/ext/pg_query/include/postgres/catalog/pg_index_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_language.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_language_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_namespace.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_namespace_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_opclass.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_opclass_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_operator.h +20 -3
- data/ext/pg_query/include/postgres/catalog/pg_operator_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_opfamily.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_opfamily_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_partitioned_table.h +4 -2
- data/ext/pg_query/include/postgres/catalog/pg_partitioned_table_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_proc.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_proc_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_publication.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_publication_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_replication_origin.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_replication_origin_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_statistic.h +10 -4
- data/ext/pg_query/include/postgres/catalog/pg_statistic_d.h +7 -3
- data/ext/pg_query/include/postgres/catalog/pg_statistic_ext.h +10 -7
- data/ext/pg_query/include/postgres/catalog/pg_statistic_ext_d.h +3 -3
- data/ext/pg_query/include/postgres/catalog/pg_transform.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_transform_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_trigger.h +4 -4
- data/ext/pg_query/include/postgres/catalog/pg_trigger_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_ts_config.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_ts_config_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_ts_dict.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_ts_dict_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_ts_parser.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_ts_parser_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_ts_template.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_ts_template_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/pg_type.h +6 -3
- data/ext/pg_query/include/postgres/catalog/pg_type_d.h +1 -1
- data/ext/pg_query/include/postgres/catalog/storage.h +1 -1
- data/ext/pg_query/include/postgres/catalog/syscache_ids.h +104 -0
- data/ext/pg_query/include/postgres/commands/async.h +2 -6
- data/ext/pg_query/include/postgres/commands/dbcommands.h +1 -1
- data/ext/pg_query/include/postgres/commands/defrem.h +6 -6
- data/ext/pg_query/include/postgres/commands/event_trigger.h +11 -2
- data/ext/pg_query/include/postgres/commands/explain.h +19 -3
- data/ext/pg_query/include/postgres/commands/prepare.h +1 -1
- data/ext/pg_query/include/postgres/commands/tablespace.h +1 -1
- data/ext/pg_query/include/postgres/commands/trigger.h +1 -1
- data/ext/pg_query/include/postgres/commands/vacuum.h +28 -26
- data/ext/pg_query/include/postgres/common/cryptohash.h +2 -2
- data/ext/pg_query/include/postgres/common/file_perm.h +1 -1
- data/ext/pg_query/include/postgres/common/file_utils.h +65 -0
- data/ext/pg_query/include/postgres/common/hashfn.h +16 -1
- data/ext/pg_query/include/postgres/common/hashfn_unstable.h +407 -0
- data/ext/pg_query/include/postgres/common/int.h +79 -4
- data/ext/pg_query/include/postgres/common/keywords.h +1 -1
- data/ext/pg_query/include/postgres/common/kwlookup.h +1 -1
- data/ext/pg_query/include/postgres/common/pg_prng.h +2 -1
- data/ext/pg_query/include/postgres/common/relpath.h +4 -4
- data/ext/pg_query/include/postgres/common/scram-common.h +1 -1
- data/ext/pg_query/include/postgres/common/sha2.h +1 -1
- data/ext/pg_query/include/postgres/common/string.h +1 -1
- data/ext/pg_query/include/postgres/common/unicode_east_asian_fw_table.h +2 -3
- data/ext/pg_query/include/postgres/copyfuncs.funcs.c +278 -30
- data/ext/pg_query/include/postgres/copyfuncs.switch.c +55 -4
- data/ext/pg_query/include/postgres/datatype/timestamp.h +29 -3
- data/ext/pg_query/include/postgres/equalfuncs.funcs.c +239 -26
- data/ext/pg_query/include/postgres/equalfuncs.switch.c +55 -4
- data/ext/pg_query/include/postgres/executor/execdesc.h +2 -2
- data/ext/pg_query/include/postgres/executor/executor.h +6 -5
- data/ext/pg_query/include/postgres/executor/functions.h +2 -1
- data/ext/pg_query/include/postgres/executor/instrument.h +5 -3
- data/ext/pg_query/include/postgres/executor/spi.h +2 -8
- data/ext/pg_query/include/postgres/executor/tablefunc.h +1 -1
- data/ext/pg_query/include/postgres/executor/tuptable.h +31 -2
- data/ext/pg_query/include/postgres/fmgr.h +2 -2
- data/ext/pg_query/include/postgres/foreign/fdwapi.h +1 -1
- data/ext/pg_query/include/postgres/funcapi.h +2 -2
- data/ext/pg_query/include/postgres/gram.h +871 -830
- data/ext/pg_query/include/postgres/gramparse.h +1 -1
- data/ext/pg_query/include/postgres/jit/jit.h +4 -3
- data/ext/pg_query/include/postgres/kwlist_d.h +511 -466
- data/ext/pg_query/include/postgres/lib/dshash.h +25 -10
- data/ext/pg_query/include/postgres/lib/ilist.h +1 -1
- data/ext/pg_query/include/postgres/lib/pairingheap.h +1 -1
- data/ext/pg_query/include/postgres/lib/simplehash.h +40 -18
- data/ext/pg_query/include/postgres/lib/sort_template.h +14 -1
- data/ext/pg_query/include/postgres/lib/stringinfo.h +93 -11
- data/ext/pg_query/include/postgres/libpq/auth.h +1 -1
- data/ext/pg_query/include/postgres/libpq/crypt.h +2 -2
- data/ext/pg_query/include/postgres/libpq/hba.h +4 -4
- data/ext/pg_query/include/postgres/libpq/libpq-be.h +35 -28
- data/ext/pg_query/include/postgres/libpq/libpq.h +6 -7
- data/ext/pg_query/include/postgres/libpq/pqcomm.h +26 -20
- data/ext/pg_query/include/postgres/libpq/pqformat.h +2 -3
- data/ext/pg_query/include/postgres/libpq/pqsignal.h +1 -1
- data/ext/pg_query/include/postgres/libpq/protocol.h +89 -0
- data/ext/pg_query/include/postgres/libpq/sasl.h +1 -1
- data/ext/pg_query/include/postgres/libpq/scram.h +1 -1
- data/ext/pg_query/include/postgres/mb/pg_wchar.h +103 -82
- data/ext/pg_query/include/postgres/mb/stringinfo_mb.h +1 -1
- data/ext/pg_query/include/postgres/miscadmin.h +72 -52
- data/ext/pg_query/include/postgres/nodes/bitmapset.h +17 -3
- data/ext/pg_query/include/postgres/nodes/execnodes.h +112 -25
- data/ext/pg_query/include/postgres/nodes/extensible.h +1 -1
- data/ext/pg_query/include/postgres/nodes/lockoptions.h +4 -4
- data/ext/pg_query/include/postgres/nodes/makefuncs.h +8 -2
- data/ext/pg_query/include/postgres/nodes/memnodes.h +43 -4
- data/ext/pg_query/include/postgres/nodes/miscnodes.h +1 -1
- data/ext/pg_query/include/postgres/nodes/nodeFuncs.h +1 -1
- data/ext/pg_query/include/postgres/nodes/nodes.h +30 -41
- data/ext/pg_query/include/postgres/nodes/nodetags.h +464 -444
- data/ext/pg_query/include/postgres/nodes/params.h +1 -1
- data/ext/pg_query/include/postgres/nodes/parsenodes.h +358 -175
- data/ext/pg_query/include/postgres/nodes/pathnodes.h +64 -10
- data/ext/pg_query/include/postgres/nodes/pg_list.h +62 -11
- data/ext/pg_query/include/postgres/nodes/plannodes.h +11 -10
- data/ext/pg_query/include/postgres/nodes/primnodes.h +352 -54
- data/ext/pg_query/include/postgres/nodes/print.h +1 -1
- data/ext/pg_query/include/postgres/nodes/queryjumble.h +2 -2
- data/ext/pg_query/include/postgres/nodes/replnodes.h +23 -2
- data/ext/pg_query/include/postgres/nodes/supportnodes.h +1 -1
- data/ext/pg_query/include/postgres/nodes/tidbitmap.h +1 -1
- data/ext/pg_query/include/postgres/nodes/value.h +1 -1
- data/ext/pg_query/include/postgres/optimizer/cost.h +5 -4
- data/ext/pg_query/include/postgres/optimizer/geqo.h +1 -1
- data/ext/pg_query/include/postgres/optimizer/geqo_gene.h +1 -1
- data/ext/pg_query/include/postgres/optimizer/optimizer.h +5 -2
- data/ext/pg_query/include/postgres/optimizer/paths.h +13 -8
- data/ext/pg_query/include/postgres/optimizer/planmain.h +7 -1
- data/ext/pg_query/include/postgres/parser/analyze.h +3 -1
- data/ext/pg_query/include/postgres/parser/kwlist.h +22 -2
- data/ext/pg_query/include/postgres/parser/parse_agg.h +1 -1
- data/ext/pg_query/include/postgres/parser/parse_coerce.h +5 -2
- data/ext/pg_query/include/postgres/parser/parse_expr.h +1 -1
- data/ext/pg_query/include/postgres/parser/parse_func.h +2 -2
- data/ext/pg_query/include/postgres/parser/parse_node.h +3 -2
- data/ext/pg_query/include/postgres/parser/parse_oper.h +4 -1
- data/ext/pg_query/include/postgres/parser/parse_relation.h +1 -1
- data/ext/pg_query/include/postgres/parser/parse_type.h +2 -2
- data/ext/pg_query/include/postgres/parser/parser.h +3 -3
- data/ext/pg_query/include/postgres/parser/parsetree.h +1 -1
- data/ext/pg_query/include/postgres/parser/scanner.h +1 -1
- data/ext/pg_query/include/postgres/parser/scansup.h +1 -1
- data/ext/pg_query/include/postgres/partitioning/partdefs.h +1 -1
- data/ext/pg_query/include/postgres/pg_config.h +53 -45
- data/ext/pg_query/include/postgres/pg_config_manual.h +21 -8
- data/ext/pg_query/include/postgres/pg_getopt.h +1 -1
- data/ext/pg_query/include/postgres/pg_trace.h +1 -1
- data/ext/pg_query/include/postgres/pgstat.h +13 -11
- data/ext/pg_query/include/postgres/pgtime.h +1 -1
- data/ext/pg_query/include/postgres/pl_reserved_kwlist.h +1 -1
- data/ext/pg_query/include/postgres/pl_reserved_kwlist_d.h +1 -1
- data/ext/pg_query/include/postgres/pl_unreserved_kwlist.h +1 -1
- data/ext/pg_query/include/postgres/pl_unreserved_kwlist_d.h +1 -1
- data/ext/pg_query/include/postgres/plerrcodes.h +4 -4
- data/ext/pg_query/include/postgres/plpgsql.h +15 -13
- data/ext/pg_query/include/postgres/port/atomics/arch-arm.h +1 -1
- data/ext/pg_query/include/postgres/port/atomics/arch-hppa.h +1 -1
- data/ext/pg_query/include/postgres/port/atomics/arch-ppc.h +3 -1
- data/ext/pg_query/include/postgres/port/atomics/arch-x86.h +3 -1
- data/ext/pg_query/include/postgres/port/atomics/fallback.h +1 -1
- data/ext/pg_query/include/postgres/port/atomics/generic-gcc.h +38 -1
- data/ext/pg_query/include/postgres/port/atomics/generic-msvc.h +19 -1
- data/ext/pg_query/include/postgres/port/atomics/generic-sunpro.h +16 -1
- data/ext/pg_query/include/postgres/port/atomics/generic.h +38 -2
- data/ext/pg_query/include/postgres/port/atomics.h +93 -6
- data/ext/pg_query/include/postgres/port/pg_bitutils.h +91 -9
- data/ext/pg_query/include/postgres/port/pg_bswap.h +1 -1
- data/ext/pg_query/include/postgres/port/pg_crc32c.h +10 -1
- data/ext/pg_query/include/postgres/port/pg_iovec.h +117 -0
- data/ext/pg_query/include/postgres/port/simd.h +48 -1
- data/ext/pg_query/include/postgres/port/win32/sys/socket.h +8 -0
- data/ext/pg_query/include/postgres/port/win32_port.h +1 -13
- data/ext/pg_query/include/postgres/port.h +39 -4
- data/ext/pg_query/include/postgres/portability/instr_time.h +1 -1
- data/ext/pg_query/include/postgres/postgres.h +1 -1
- data/ext/pg_query/include/postgres/postmaster/autovacuum.h +5 -16
- data/ext/pg_query/include/postgres/postmaster/bgworker.h +8 -6
- data/ext/pg_query/include/postgres/postmaster/bgworker_internals.h +3 -7
- data/ext/pg_query/include/postgres/postmaster/bgwriter.h +3 -3
- data/ext/pg_query/include/postgres/postmaster/interrupt.h +1 -1
- data/ext/pg_query/include/postgres/postmaster/pgarch.h +2 -2
- data/ext/pg_query/include/postgres/postmaster/postmaster.h +25 -5
- data/ext/pg_query/include/postgres/postmaster/startup.h +2 -2
- data/ext/pg_query/include/postgres/postmaster/syslogger.h +2 -4
- data/ext/pg_query/include/postgres/postmaster/walsummarizer.h +35 -0
- data/ext/pg_query/include/postgres/postmaster/walwriter.h +2 -2
- data/ext/pg_query/include/postgres/regex/regex.h +92 -9
- data/ext/pg_query/include/postgres/replication/logicallauncher.h +1 -1
- data/ext/pg_query/include/postgres/replication/logicalproto.h +2 -2
- data/ext/pg_query/include/postgres/replication/logicalworker.h +2 -1
- data/ext/pg_query/include/postgres/replication/origin.h +1 -1
- data/ext/pg_query/include/postgres/replication/reorderbuffer.h +27 -46
- data/ext/pg_query/include/postgres/replication/slot.h +45 -5
- data/ext/pg_query/include/postgres/replication/slotsync.h +38 -0
- data/ext/pg_query/include/postgres/replication/syncrep.h +1 -1
- data/ext/pg_query/include/postgres/replication/walreceiver.h +37 -11
- data/ext/pg_query/include/postgres/replication/walsender.h +5 -3
- data/ext/pg_query/include/postgres/rewrite/prs2lock.h +1 -1
- data/ext/pg_query/include/postgres/rewrite/rewriteHandler.h +7 -1
- data/ext/pg_query/include/postgres/rewrite/rewriteManip.h +2 -2
- data/ext/pg_query/include/postgres/rewrite/rewriteSupport.h +1 -1
- data/ext/pg_query/include/postgres/storage/block.h +1 -1
- data/ext/pg_query/include/postgres/storage/buf.h +1 -1
- data/ext/pg_query/include/postgres/storage/bufmgr.h +59 -41
- data/ext/pg_query/include/postgres/storage/bufpage.h +1 -1
- data/ext/pg_query/include/postgres/storage/condition_variable.h +1 -1
- data/ext/pg_query/include/postgres/storage/dsm.h +1 -1
- data/ext/pg_query/include/postgres/storage/dsm_impl.h +2 -2
- data/ext/pg_query/include/postgres/storage/fd.h +30 -13
- data/ext/pg_query/include/postgres/storage/fileset.h +1 -1
- data/ext/pg_query/include/postgres/storage/ipc.h +4 -1
- data/ext/pg_query/include/postgres/storage/item.h +1 -1
- data/ext/pg_query/include/postgres/storage/itemid.h +1 -1
- data/ext/pg_query/include/postgres/storage/itemptr.h +1 -1
- data/ext/pg_query/include/postgres/storage/large_object.h +1 -1
- data/ext/pg_query/include/postgres/storage/latch.h +4 -2
- data/ext/pg_query/include/postgres/storage/lmgr.h +8 -2
- data/ext/pg_query/include/postgres/storage/lock.h +19 -19
- data/ext/pg_query/include/postgres/storage/lockdefs.h +3 -1
- data/ext/pg_query/include/postgres/storage/lwlock.h +17 -9
- data/ext/pg_query/include/postgres/storage/lwlocknames.h +7 -10
- data/ext/pg_query/include/postgres/storage/off.h +1 -1
- data/ext/pg_query/include/postgres/storage/pg_sema.h +1 -1
- data/ext/pg_query/include/postgres/storage/pg_shmem.h +5 -4
- data/ext/pg_query/include/postgres/storage/pmsignal.h +2 -2
- data/ext/pg_query/include/postgres/storage/predicate.h +1 -5
- data/ext/pg_query/include/postgres/storage/proc.h +48 -26
- data/ext/pg_query/include/postgres/storage/procarray.h +5 -1
- data/ext/pg_query/include/postgres/storage/proclist_types.h +11 -9
- data/ext/pg_query/include/postgres/storage/procnumber.h +43 -0
- data/ext/pg_query/include/postgres/storage/procsignal.h +8 -6
- data/ext/pg_query/include/postgres/storage/read_stream.h +65 -0
- data/ext/pg_query/include/postgres/storage/relfilelocator.h +16 -15
- data/ext/pg_query/include/postgres/storage/s_lock.h +7 -27
- data/ext/pg_query/include/postgres/storage/sharedfileset.h +1 -1
- data/ext/pg_query/include/postgres/storage/shm_mq.h +2 -2
- data/ext/pg_query/include/postgres/storage/shm_toc.h +1 -1
- data/ext/pg_query/include/postgres/storage/shmem.h +1 -1
- data/ext/pg_query/include/postgres/storage/sinval.h +3 -3
- data/ext/pg_query/include/postgres/storage/smgr.h +46 -29
- data/ext/pg_query/include/postgres/storage/spin.h +1 -1
- data/ext/pg_query/include/postgres/storage/standby.h +13 -3
- data/ext/pg_query/include/postgres/storage/standbydefs.h +2 -2
- data/ext/pg_query/include/postgres/storage/sync.h +4 -4
- data/ext/pg_query/include/postgres/tcop/cmdtag.h +1 -2
- data/ext/pg_query/include/postgres/tcop/cmdtaglist.h +3 -2
- data/ext/pg_query/include/postgres/tcop/deparse_utility.h +2 -2
- data/ext/pg_query/include/postgres/tcop/dest.h +3 -2
- data/ext/pg_query/include/postgres/tcop/fastpath.h +1 -1
- data/ext/pg_query/include/postgres/tcop/pquery.h +1 -1
- data/ext/pg_query/include/postgres/tcop/tcopprot.h +9 -5
- data/ext/pg_query/include/postgres/tcop/utility.h +2 -2
- data/ext/pg_query/include/postgres/tsearch/ts_cache.h +1 -1
- data/ext/pg_query/include/postgres/utils/acl.h +19 -7
- data/ext/pg_query/include/postgres/utils/aclchk_internal.h +1 -1
- data/ext/pg_query/include/postgres/utils/array.h +1 -2
- data/ext/pg_query/include/postgres/utils/ascii.h +84 -0
- data/ext/pg_query/include/postgres/utils/backend_progress.h +3 -2
- data/ext/pg_query/include/postgres/utils/backend_status.h +8 -10
- data/ext/pg_query/include/postgres/utils/builtins.h +4 -1
- data/ext/pg_query/include/postgres/utils/bytea.h +2 -2
- data/ext/pg_query/include/postgres/utils/catcache.h +6 -6
- data/ext/pg_query/include/postgres/utils/date.h +1 -1
- data/ext/pg_query/include/postgres/utils/datetime.h +4 -1
- data/ext/pg_query/include/postgres/utils/datum.h +1 -1
- data/ext/pg_query/include/postgres/utils/dsa.h +44 -5
- data/ext/pg_query/include/postgres/utils/elog.h +3 -8
- data/ext/pg_query/include/postgres/utils/errcodes.h +1 -3
- data/ext/pg_query/include/postgres/utils/expandeddatum.h +1 -1
- data/ext/pg_query/include/postgres/utils/expandedrecord.h +1 -1
- data/ext/pg_query/include/postgres/utils/float.h +1 -1
- data/ext/pg_query/include/postgres/utils/fmgroids.h +49 -16
- data/ext/pg_query/include/postgres/utils/fmgrprotos.h +47 -14
- data/ext/pg_query/include/postgres/utils/fmgrtab.h +1 -1
- data/ext/pg_query/include/postgres/utils/guc.h +20 -6
- data/ext/pg_query/include/postgres/utils/guc_hooks.h +23 -2
- data/ext/pg_query/include/postgres/utils/guc_tables.h +6 -5
- data/ext/pg_query/include/postgres/utils/hsearch.h +2 -2
- data/ext/pg_query/include/postgres/utils/injection_point.h +44 -0
- data/ext/pg_query/include/postgres/utils/inval.h +1 -1
- data/ext/pg_query/include/postgres/utils/logtape.h +5 -5
- data/ext/pg_query/include/postgres/utils/lsyscache.h +6 -3
- data/ext/pg_query/include/postgres/utils/memdebug.h +1 -1
- data/ext/pg_query/include/postgres/utils/memutils.h +12 -5
- data/ext/pg_query/include/postgres/utils/memutils_internal.h +53 -13
- data/ext/pg_query/include/postgres/utils/memutils_memorychunk.h +25 -9
- data/ext/pg_query/include/postgres/utils/numeric.h +6 -1
- data/ext/pg_query/include/postgres/utils/palloc.h +1 -15
- data/ext/pg_query/include/postgres/utils/partcache.h +1 -1
- data/ext/pg_query/include/postgres/utils/pg_locale.h +8 -7
- data/ext/pg_query/include/postgres/utils/pgstat_internal.h +30 -17
- data/ext/pg_query/include/postgres/utils/plancache.h +5 -3
- data/ext/pg_query/include/postgres/utils/portal.h +10 -10
- data/ext/pg_query/include/postgres/utils/queryenvironment.h +2 -2
- data/ext/pg_query/include/postgres/utils/regproc.h +1 -1
- data/ext/pg_query/include/postgres/utils/rel.h +14 -15
- data/ext/pg_query/include/postgres/utils/relcache.h +2 -5
- data/ext/pg_query/include/postgres/utils/reltrigger.h +1 -1
- data/ext/pg_query/include/postgres/utils/resowner.h +90 -9
- data/ext/pg_query/include/postgres/utils/ruleutils.h +1 -1
- data/ext/pg_query/include/postgres/utils/sharedtuplestore.h +1 -1
- data/ext/pg_query/include/postgres/utils/snapmgr.h +1 -52
- data/ext/pg_query/include/postgres/utils/snapshot.h +2 -2
- data/ext/pg_query/include/postgres/utils/sortsupport.h +1 -1
- data/ext/pg_query/include/postgres/utils/syscache.h +7 -98
- data/ext/pg_query/include/postgres/utils/timeout.h +3 -2
- data/ext/pg_query/include/postgres/utils/timestamp.h +1 -1
- data/ext/pg_query/include/postgres/utils/tuplesort.h +36 -9
- data/ext/pg_query/include/postgres/utils/tuplestore.h +2 -5
- data/ext/pg_query/include/postgres/utils/typcache.h +2 -1
- data/ext/pg_query/include/postgres/utils/varlena.h +1 -1
- data/ext/pg_query/include/postgres/utils/wait_event.h +28 -214
- data/ext/pg_query/include/postgres/utils/wait_event_types.h +218 -0
- data/ext/pg_query/include/postgres/utils/xml.h +4 -4
- data/ext/pg_query/include/postgres/varatt.h +1 -1
- data/ext/pg_query/include/protobuf/pg_query.pb-c.h +1546 -792
- data/ext/pg_query/include/protobuf/pg_query.pb.h +58365 -46595
- data/ext/pg_query/pg_query.pb-c.c +6598 -3739
- data/ext/pg_query/pg_query_normalize.c +42 -1
- data/ext/pg_query/pg_query_outfuncs_json.c +3 -1
- data/ext/pg_query/pg_query_parse_plpgsql.c +12 -13
- data/ext/pg_query/pg_query_readfuncs_protobuf.c +2 -2
- data/ext/pg_query/pg_query_scan.c +1 -1
- data/ext/pg_query/postgres_deparse.c +601 -172
- data/ext/pg_query/src_backend_catalog_namespace.c +241 -66
- data/ext/pg_query/src_backend_catalog_pg_proc.c +1 -3
- data/ext/pg_query/src_backend_commands_define.c +2 -3
- data/ext/pg_query/src_backend_nodes_bitmapset.c +137 -94
- data/ext/pg_query/src_backend_nodes_copyfuncs.c +1 -1
- data/ext/pg_query/src_backend_nodes_equalfuncs.c +1 -1
- data/ext/pg_query/src_backend_nodes_extensible.c +1 -1
- data/ext/pg_query/src_backend_nodes_list.c +3 -7
- data/ext/pg_query/src_backend_nodes_makefuncs.c +59 -20
- data/ext/pg_query/src_backend_nodes_nodeFuncs.c +109 -2
- data/ext/pg_query/src_backend_nodes_value.c +1 -1
- data/ext/pg_query/src_backend_parser_gram.c +34491 -32136
- data/ext/pg_query/src_backend_parser_parser.c +8 -8
- data/ext/pg_query/src_backend_parser_scan.c +5637 -3028
- data/ext/pg_query/src_backend_parser_scansup.c +2 -1
- data/ext/pg_query/src_backend_storage_ipc_ipc.c +1 -1
- data/ext/pg_query/src_backend_tcop_postgres.c +34 -10
- data/ext/pg_query/src_backend_utils_activity_pgstat_database.c +2 -2
- data/ext/pg_query/src_backend_utils_adt_datum.c +8 -6
- data/ext/pg_query/src_backend_utils_adt_expandeddatum.c +1 -1
- data/ext/pg_query/src_backend_utils_adt_format_type.c +1 -1
- data/ext/pg_query/src_backend_utils_adt_numutils.c +4 -5
- data/ext/pg_query/src_backend_utils_adt_ruleutils.c +101 -28
- data/ext/pg_query/src_backend_utils_error_assert.c +1 -1
- data/ext/pg_query/src_backend_utils_error_elog.c +47 -42
- data/ext/pg_query/src_backend_utils_fmgr_fmgr.c +4 -2
- data/ext/pg_query/src_backend_utils_init_globals.c +15 -3
- data/ext/pg_query/src_backend_utils_mb_mbutils.c +11 -18
- data/ext/pg_query/src_backend_utils_misc_guc_tables.c +16 -6
- data/ext/pg_query/src_backend_utils_mmgr_alignedalloc.c +8 -5
- data/ext/pg_query/src_backend_utils_mmgr_aset.c +308 -238
- data/ext/pg_query/src_backend_utils_mmgr_bump.c +728 -0
- data/ext/pg_query/src_backend_utils_mmgr_generation.c +273 -197
- data/ext/pg_query/src_backend_utils_mmgr_mcxt.c +270 -215
- data/ext/pg_query/src_backend_utils_mmgr_slab.c +154 -96
- data/ext/pg_query/src_common_encnames.c +43 -44
- data/ext/pg_query/src_common_hashfn.c +1 -1
- data/ext/pg_query/src_common_keywords.c +1 -1
- data/ext/pg_query/src_common_kwlist_d.h +511 -466
- data/ext/pg_query/src_common_kwlookup.c +1 -1
- data/ext/pg_query/src_common_psprintf.c +3 -3
- data/ext/pg_query/src_common_stringinfo.c +18 -1
- data/ext/pg_query/src_common_wchar.c +92 -109
- data/ext/pg_query/src_pl_plpgsql_src_pl_comp.c +99 -5
- data/ext/pg_query/src_pl_plpgsql_src_pl_funcs.c +1 -1
- data/ext/pg_query/src_pl_plpgsql_src_pl_gram.c +242 -143
- data/ext/pg_query/src_pl_plpgsql_src_pl_handler.c +1 -1
- data/ext/pg_query/src_pl_plpgsql_src_pl_reserved_kwlist_d.h +1 -1
- data/ext/pg_query/src_pl_plpgsql_src_pl_scanner.c +19 -1
- data/ext/pg_query/src_pl_plpgsql_src_pl_unreserved_kwlist_d.h +1 -1
- data/ext/pg_query/src_port_pg_bitutils.c +173 -28
- data/ext/pg_query/src_port_pgstrcasecmp.c +29 -1
- data/ext/pg_query/src_port_snprintf.c +15 -18
- data/ext/pg_query/src_port_strerror.c +1 -3
- data/ext/pg_query/src_port_strlcpy.c +1 -1
- data/lib/pg_query/fingerprint.rb +3 -5
- data/lib/pg_query/param_refs.rb +2 -2
- data/lib/pg_query/parse.rb +5 -7
- data/lib/pg_query/parse_error.rb +1 -0
- data/lib/pg_query/pg_query_pb.rb +27 -25
- data/lib/pg_query/scan.rb +1 -0
- data/lib/pg_query/treewalker.rb +38 -15
- data/lib/pg_query/truncate.rb +18 -20
- data/lib/pg_query/version.rb +1 -1
- metadata +31 -82
- data/ext/pg_query/include/postgres/storage/backendid.h +0 -37
- data/ext/pg_query/include/postgres/storage/sinvaladt.h +0 -45
- data/ext/pg_query/pg_query_ruby_freebsd.sym +0 -2
- data/ext/pg_query/src_backend_nodes_nodes.c +0 -38
- /data/ext/pg_query/{pg_query_ruby.sym → ext_symbols.sym} +0 -0
@@ -20,12 +20,7 @@ typedef enum DeparseNodeContext {
|
|
20
20
|
DEPARSE_NODE_CONTEXT_NONE,
|
21
21
|
// Parent node type (and sometimes field)
|
22
22
|
DEPARSE_NODE_CONTEXT_INSERT_RELATION,
|
23
|
-
DEPARSE_NODE_CONTEXT_INSERT_ON_CONFLICT,
|
24
|
-
DEPARSE_NODE_CONTEXT_UPDATE,
|
25
|
-
DEPARSE_NODE_CONTEXT_RETURNING,
|
26
23
|
DEPARSE_NODE_CONTEXT_A_EXPR,
|
27
|
-
DEPARSE_NODE_CONTEXT_XMLATTRIBUTES,
|
28
|
-
DEPARSE_NODE_CONTEXT_XMLNAMESPACES,
|
29
24
|
DEPARSE_NODE_CONTEXT_CREATE_TYPE,
|
30
25
|
DEPARSE_NODE_CONTEXT_ALTER_TYPE,
|
31
26
|
DEPARSE_NODE_CONTEXT_SET_STATEMENT,
|
@@ -186,9 +181,9 @@ static void deparseReplicaIdentityStmt(StringInfo str, ReplicaIdentityStmt *repl
|
|
186
181
|
static void deparseRangeTableSample(StringInfo str, RangeTableSample *range_table_sample);
|
187
182
|
static void deparseRangeTableFunc(StringInfo str, RangeTableFunc* range_table_func);
|
188
183
|
static void deparseGroupingSet(StringInfo str, GroupingSet *grouping_set);
|
189
|
-
static void deparseFuncCall(StringInfo str, FuncCall *func_call);
|
184
|
+
static void deparseFuncCall(StringInfo str, FuncCall *func_call, DeparseNodeContext context);
|
190
185
|
static void deparseMinMaxExpr(StringInfo str, MinMaxExpr *min_max_expr);
|
191
|
-
static void deparseXmlExpr(StringInfo str, XmlExpr* xml_expr);
|
186
|
+
static void deparseXmlExpr(StringInfo str, XmlExpr* xml_expr, DeparseNodeContext context);
|
192
187
|
static void deparseXmlSerialize(StringInfo str, XmlSerialize *xml_serialize);
|
193
188
|
static void deparseJsonIsPredicate(StringInfo str, JsonIsPredicate *json_is_predicate);
|
194
189
|
static void deparseJsonObjectAgg(StringInfo str, JsonObjectAgg *json_object_agg);
|
@@ -196,6 +191,20 @@ static void deparseJsonArrayAgg(StringInfo str, JsonArrayAgg *json_array_agg);
|
|
196
191
|
static void deparseJsonObjectConstructor(StringInfo str, JsonObjectConstructor *json_object_constructor);
|
197
192
|
static void deparseJsonArrayConstructor(StringInfo str, JsonArrayConstructor *json_array_constructor);
|
198
193
|
static void deparseJsonArrayQueryConstructor(StringInfo str, JsonArrayQueryConstructor *json_array_query_constructor);
|
194
|
+
static void deparseJsonValueExpr(StringInfo str, JsonValueExpr *json_value_expr);
|
195
|
+
static void deparseJsonOutput(StringInfo str, JsonOutput *json_output);
|
196
|
+
static void deparseJsonParseExpr(StringInfo str, JsonParseExpr *json_parse_expr);
|
197
|
+
static void deparseJsonScalarExpr(StringInfo str, JsonScalarExpr *json_scalar_expr);
|
198
|
+
static void deparseJsonSerializeExpr(StringInfo str, JsonSerializeExpr *json_serialize_expr);
|
199
|
+
static void deparseJsonTable(StringInfo str, JsonTable *json_table);
|
200
|
+
static void deparseJsonTableColumn(StringInfo str, JsonTableColumn *json_table_column);
|
201
|
+
static void deparseJsonTableColumns(StringInfo str, List *json_table_columns);
|
202
|
+
static void deparseJsonTablePathSpec(StringInfo str, JsonTablePathSpec *json_table_path_spec);
|
203
|
+
static void deparseJsonBehavior(StringInfo str, JsonBehavior *json_behavior);
|
204
|
+
static void deparseJsonFuncExpr(StringInfo str, JsonFuncExpr *json_func_expr);
|
205
|
+
static void deparseJsonQuotesClauseOpt(StringInfo str, JsonQuotes quotes);
|
206
|
+
static void deparseJsonOnErrorClauseOpt(StringInfo str, JsonBehavior *behavior);
|
207
|
+
static void deparseJsonOnEmptyClauseOpt(StringInfo str, JsonBehavior *behavior);
|
199
208
|
static void deparseConstraint(StringInfo str, Constraint *constraint);
|
200
209
|
static void deparseSchemaStmt(StringInfo str, Node *node);
|
201
210
|
static void deparseExecuteStmt(StringInfo str, ExecuteStmt *execute_stmt);
|
@@ -252,12 +261,12 @@ static void deparseAnyNameSkipLast(StringInfo str, List *parts)
|
|
252
261
|
}
|
253
262
|
|
254
263
|
// "func_expr" in gram.y
|
255
|
-
static void deparseFuncExpr(StringInfo str, Node *node)
|
264
|
+
static void deparseFuncExpr(StringInfo str, Node *node, DeparseNodeContext context)
|
256
265
|
{
|
257
266
|
switch (nodeTag(node))
|
258
267
|
{
|
259
268
|
case T_FuncCall:
|
260
|
-
deparseFuncCall(str, castNode(FuncCall, node));
|
269
|
+
deparseFuncCall(str, castNode(FuncCall, node), context);
|
261
270
|
break;
|
262
271
|
case T_SQLValueFunction:
|
263
272
|
deparseSQLValueFunction(str, castNode(SQLValueFunction, node));
|
@@ -269,7 +278,7 @@ static void deparseFuncExpr(StringInfo str, Node *node)
|
|
269
278
|
deparseCoalesceExpr(str, castNode(CoalesceExpr, node));
|
270
279
|
break;
|
271
280
|
case T_XmlExpr:
|
272
|
-
deparseXmlExpr(str, castNode(XmlExpr, node));
|
281
|
+
deparseXmlExpr(str, castNode(XmlExpr, node), context);
|
273
282
|
break;
|
274
283
|
case T_XmlSerialize:
|
275
284
|
deparseXmlSerialize(str, castNode(XmlSerialize, node));
|
@@ -299,7 +308,7 @@ static void deparseFuncExpr(StringInfo str, Node *node)
|
|
299
308
|
static void deparseCExpr(StringInfo str, Node *node);
|
300
309
|
|
301
310
|
// "a_expr" in gram.y
|
302
|
-
static void deparseExpr(StringInfo str, Node *node)
|
311
|
+
static void deparseExpr(StringInfo str, Node *node, DeparseNodeContext context)
|
303
312
|
{
|
304
313
|
if (node == NULL)
|
305
314
|
return;
|
@@ -323,7 +332,7 @@ static void deparseExpr(StringInfo str, Node *node)
|
|
323
332
|
deparseCollateClause(str, castNode(CollateClause, node));
|
324
333
|
break;
|
325
334
|
case T_A_Expr:
|
326
|
-
deparseAExpr(str, castNode(A_Expr, node),
|
335
|
+
deparseAExpr(str, castNode(A_Expr, node), DEPARSE_NODE_CONTEXT_A_EXPR);
|
327
336
|
break;
|
328
337
|
case T_BoolExpr:
|
329
338
|
deparseBoolExpr(str, castNode(BoolExpr, node));
|
@@ -340,6 +349,21 @@ static void deparseExpr(StringInfo str, Node *node)
|
|
340
349
|
case T_SetToDefault:
|
341
350
|
deparseSetToDefault(str, castNode(SetToDefault, node));
|
342
351
|
break;
|
352
|
+
case T_MergeSupportFunc:
|
353
|
+
appendStringInfoString(str, "merge_action() ");
|
354
|
+
break;
|
355
|
+
case T_JsonParseExpr:
|
356
|
+
deparseJsonParseExpr(str, castNode(JsonParseExpr, node));
|
357
|
+
break;
|
358
|
+
case T_JsonScalarExpr:
|
359
|
+
deparseJsonScalarExpr(str, castNode(JsonScalarExpr, node));
|
360
|
+
break;
|
361
|
+
case T_JsonSerializeExpr:
|
362
|
+
deparseJsonSerializeExpr(str, castNode(JsonSerializeExpr, node));
|
363
|
+
break;
|
364
|
+
case T_JsonFuncExpr:
|
365
|
+
deparseJsonFuncExpr(str, castNode(JsonFuncExpr, node));
|
366
|
+
break;
|
343
367
|
case T_FuncCall:
|
344
368
|
case T_SQLValueFunction:
|
345
369
|
case T_MinMaxExpr:
|
@@ -351,7 +375,7 @@ static void deparseExpr(StringInfo str, Node *node)
|
|
351
375
|
case T_JsonObjectConstructor:
|
352
376
|
case T_JsonArrayConstructor:
|
353
377
|
case T_JsonArrayQueryConstructor:
|
354
|
-
deparseFuncExpr(str, node);
|
378
|
+
deparseFuncExpr(str, node, context);
|
355
379
|
break;
|
356
380
|
default:
|
357
381
|
// Note that this is also the fallthrough for deparseBExpr and deparseCExpr
|
@@ -365,7 +389,7 @@ static void deparseExpr(StringInfo str, Node *node)
|
|
365
389
|
static void deparseBExpr(StringInfo str, Node *node)
|
366
390
|
{
|
367
391
|
if (IsA(node, XmlExpr)) {
|
368
|
-
deparseXmlExpr(str, castNode(XmlExpr, node));
|
392
|
+
deparseXmlExpr(str, castNode(XmlExpr, node), DEPARSE_NODE_CONTEXT_NONE);
|
369
393
|
return;
|
370
394
|
}
|
371
395
|
|
@@ -389,6 +413,24 @@ static void deparseBExpr(StringInfo str, Node *node)
|
|
389
413
|
deparseCExpr(str, node);
|
390
414
|
}
|
391
415
|
|
416
|
+
// "AexprConst" in gram.y
|
417
|
+
static void deparseAexprConst(StringInfo str, Node *node)
|
418
|
+
{
|
419
|
+
switch (nodeTag(node))
|
420
|
+
{
|
421
|
+
case T_A_Const:
|
422
|
+
deparseAConst(str, castNode(A_Const, node));
|
423
|
+
break;
|
424
|
+
case T_TypeCast:
|
425
|
+
deparseTypeCast(str, castNode(TypeCast, node), DEPARSE_NODE_CONTEXT_NONE);
|
426
|
+
break;
|
427
|
+
default:
|
428
|
+
elog(ERROR, "deparse: unpermitted node type in AexprConst: %d",
|
429
|
+
(int) nodeTag(node));
|
430
|
+
break;
|
431
|
+
}
|
432
|
+
}
|
433
|
+
|
392
434
|
// "c_expr" in gram.y
|
393
435
|
static void deparseCExpr(StringInfo str, Node *node)
|
394
436
|
{
|
@@ -432,11 +474,12 @@ static void deparseCExpr(StringInfo str, Node *node)
|
|
432
474
|
case T_JsonObjectConstructor:
|
433
475
|
case T_JsonArrayConstructor:
|
434
476
|
case T_JsonArrayQueryConstructor:
|
435
|
-
deparseFuncExpr(str, node);
|
477
|
+
deparseFuncExpr(str, node, DEPARSE_NODE_CONTEXT_NONE);
|
436
478
|
break;
|
437
479
|
default:
|
438
480
|
appendStringInfoChar(str, '(');
|
439
|
-
|
481
|
+
// Because we wrap this in parenthesis, the expression inside follows "a_expr" parser rules
|
482
|
+
deparseExpr(str, node, DEPARSE_NODE_CONTEXT_A_EXPR);
|
440
483
|
appendStringInfoChar(str, ')');
|
441
484
|
break;
|
442
485
|
}
|
@@ -448,7 +491,7 @@ static void deparseExprList(StringInfo str, List *exprs)
|
|
448
491
|
ListCell *lc;
|
449
492
|
foreach(lc, exprs)
|
450
493
|
{
|
451
|
-
deparseExpr(str, lfirst(lc));
|
494
|
+
deparseExpr(str, lfirst(lc), DEPARSE_NODE_CONTEXT_A_EXPR);
|
452
495
|
if (lnext(exprs, lc))
|
453
496
|
appendStringInfoString(str, ", ");
|
454
497
|
}
|
@@ -1554,7 +1597,7 @@ static void deparseTargetList(StringInfo str, List *l)
|
|
1554
1597
|
else if (IsA(res_target->val, ColumnRef))
|
1555
1598
|
deparseColumnRef(str, castNode(ColumnRef, res_target->val));
|
1556
1599
|
else
|
1557
|
-
deparseExpr(str, res_target->val);
|
1600
|
+
deparseExpr(str, res_target->val, DEPARSE_NODE_CONTEXT_A_EXPR);
|
1558
1601
|
|
1559
1602
|
if (res_target->name != NULL) {
|
1560
1603
|
appendStringInfoString(str, " AS ");
|
@@ -1592,7 +1635,7 @@ static void deparseXmlAttributeList(StringInfo str, List *l)
|
|
1592
1635
|
ResTarget *res_target = castNode(ResTarget, lfirst(lc));
|
1593
1636
|
Assert(res_target->val != NULL);
|
1594
1637
|
|
1595
|
-
deparseExpr(str, res_target->val);
|
1638
|
+
deparseExpr(str, res_target->val, DEPARSE_NODE_CONTEXT_A_EXPR);
|
1596
1639
|
|
1597
1640
|
if (res_target->name != NULL)
|
1598
1641
|
{
|
@@ -1618,7 +1661,7 @@ static void deparseXmlNamespaceList(StringInfo str, List *l)
|
|
1618
1661
|
if (res_target->name == NULL)
|
1619
1662
|
appendStringInfoString(str, "DEFAULT ");
|
1620
1663
|
|
1621
|
-
deparseExpr(str, res_target->val);
|
1664
|
+
deparseExpr(str, res_target->val, DEPARSE_NODE_CONTEXT_NONE /* b_expr */);
|
1622
1665
|
|
1623
1666
|
if (res_target->name != NULL)
|
1624
1667
|
{
|
@@ -1654,6 +1697,9 @@ static void deparseTableRef(StringInfo str, Node *node)
|
|
1654
1697
|
case T_JoinExpr:
|
1655
1698
|
deparseJoinExpr(str, castNode(JoinExpr, node));
|
1656
1699
|
break;
|
1700
|
+
case T_JsonTable:
|
1701
|
+
deparseJsonTable(str, castNode(JsonTable, node));
|
1702
|
+
break;
|
1657
1703
|
default:
|
1658
1704
|
Assert(false);
|
1659
1705
|
}
|
@@ -1693,7 +1739,7 @@ static void deparseWhereClause(StringInfo str, Node *node)
|
|
1693
1739
|
if (node != NULL)
|
1694
1740
|
{
|
1695
1741
|
appendStringInfoString(str, "WHERE ");
|
1696
|
-
deparseExpr(str, node);
|
1742
|
+
deparseExpr(str, node, DEPARSE_NODE_CONTEXT_A_EXPR);
|
1697
1743
|
appendStringInfoChar(str, ' ');
|
1698
1744
|
}
|
1699
1745
|
}
|
@@ -1713,7 +1759,7 @@ static void deparseWhereOrCurrentClause(StringInfo str, Node *node)
|
|
1713
1759
|
appendStringInfoString(str, "CURRENT OF ");
|
1714
1760
|
appendStringInfoString(str, quote_identifier(current_of_expr->cursor_name));
|
1715
1761
|
} else {
|
1716
|
-
deparseExpr(str, node);
|
1762
|
+
deparseExpr(str, node, DEPARSE_NODE_CONTEXT_A_EXPR);
|
1717
1763
|
}
|
1718
1764
|
|
1719
1765
|
appendStringInfoChar(str, ' ');
|
@@ -1729,7 +1775,7 @@ static void deparseGroupByList(StringInfo str, List *l)
|
|
1729
1775
|
if (IsA(lfirst(lc), GroupingSet))
|
1730
1776
|
deparseGroupingSet(str, castNode(GroupingSet, lfirst(lc)));
|
1731
1777
|
else
|
1732
|
-
deparseExpr(str, lfirst(lc));
|
1778
|
+
deparseExpr(str, lfirst(lc), DEPARSE_NODE_CONTEXT_A_EXPR);
|
1733
1779
|
|
1734
1780
|
if (lnext(l, lc))
|
1735
1781
|
appendStringInfoString(str, ", ");
|
@@ -1799,11 +1845,11 @@ static void deparseFuncArgExpr(StringInfo str, Node *node)
|
|
1799
1845
|
NamedArgExpr *named_arg_expr = castNode(NamedArgExpr, node);
|
1800
1846
|
appendStringInfoString(str, named_arg_expr->name);
|
1801
1847
|
appendStringInfoString(str, " := ");
|
1802
|
-
deparseExpr(str, (Node *) named_arg_expr->arg);
|
1848
|
+
deparseExpr(str, (Node *) named_arg_expr->arg, DEPARSE_NODE_CONTEXT_A_EXPR);
|
1803
1849
|
}
|
1804
1850
|
else
|
1805
1851
|
{
|
1806
|
-
deparseExpr(str, node);
|
1852
|
+
deparseExpr(str, node, DEPARSE_NODE_CONTEXT_A_EXPR);
|
1807
1853
|
}
|
1808
1854
|
}
|
1809
1855
|
|
@@ -1843,14 +1889,14 @@ static void deparseSetClauseList(StringInfo str, List *target_list)
|
|
1843
1889
|
appendStringInfoString(str, ", ");
|
1844
1890
|
}
|
1845
1891
|
appendStringInfoString(str, ") = ");
|
1846
|
-
deparseExpr(str, r->source);
|
1892
|
+
deparseExpr(str, r->source, DEPARSE_NODE_CONTEXT_A_EXPR);
|
1847
1893
|
skip_next_n_elems = r->ncolumns - 1;
|
1848
1894
|
}
|
1849
1895
|
else
|
1850
1896
|
{
|
1851
1897
|
deparseSetTarget(str, res_target);
|
1852
1898
|
appendStringInfoString(str, " = ");
|
1853
|
-
deparseExpr(str, res_target->val);
|
1899
|
+
deparseExpr(str, res_target->val, DEPARSE_NODE_CONTEXT_A_EXPR);
|
1854
1900
|
}
|
1855
1901
|
}
|
1856
1902
|
}
|
@@ -1861,7 +1907,7 @@ static void deparseFuncExprWindowless(StringInfo str, Node* node)
|
|
1861
1907
|
switch (nodeTag(node))
|
1862
1908
|
{
|
1863
1909
|
case T_FuncCall:
|
1864
|
-
deparseFuncCall(str, castNode(FuncCall, node));
|
1910
|
+
deparseFuncCall(str, castNode(FuncCall, node), DEPARSE_NODE_CONTEXT_NONE /* we don't know which kind of expression */);
|
1865
1911
|
break;
|
1866
1912
|
case T_SQLValueFunction:
|
1867
1913
|
deparseSQLValueFunction(str, castNode(SQLValueFunction, node));
|
@@ -1876,7 +1922,7 @@ static void deparseFuncExprWindowless(StringInfo str, Node* node)
|
|
1876
1922
|
deparseMinMaxExpr(str, castNode(MinMaxExpr, node));
|
1877
1923
|
break;
|
1878
1924
|
case T_XmlExpr:
|
1879
|
-
deparseXmlExpr(str, castNode(XmlExpr, node));
|
1925
|
+
deparseXmlExpr(str, castNode(XmlExpr, node), DEPARSE_NODE_CONTEXT_NONE /* we don't know which kind of expression */);
|
1880
1926
|
break;
|
1881
1927
|
case T_XmlSerialize:
|
1882
1928
|
deparseXmlSerialize(str, castNode(XmlSerialize, node));
|
@@ -1923,7 +1969,7 @@ static void deparseIndexElem(StringInfo str, IndexElem* index_elem)
|
|
1923
1969
|
break;
|
1924
1970
|
default:
|
1925
1971
|
appendStringInfoChar(str, '(');
|
1926
|
-
deparseExpr(str, index_elem->expr);
|
1972
|
+
deparseExpr(str, index_elem->expr, DEPARSE_NODE_CONTEXT_A_EXPR);
|
1927
1973
|
appendStringInfoString(str, ") ");
|
1928
1974
|
}
|
1929
1975
|
}
|
@@ -2273,7 +2319,7 @@ static void deparseSelectStmt(StringInfo str, SelectStmt *stmt)
|
|
2273
2319
|
if (stmt->havingClause != NULL)
|
2274
2320
|
{
|
2275
2321
|
appendStringInfoString(str, "HAVING ");
|
2276
|
-
deparseExpr(str, stmt->havingClause);
|
2322
|
+
deparseExpr(str, stmt->havingClause, DEPARSE_NODE_CONTEXT_A_EXPR);
|
2277
2323
|
appendStringInfoChar(str, ' ');
|
2278
2324
|
}
|
2279
2325
|
|
@@ -2356,7 +2402,7 @@ static void deparseSelectStmt(StringInfo str, SelectStmt *stmt)
|
|
2356
2402
|
else if (stmt->limitOption == LIMIT_OPTION_WITH_TIES)
|
2357
2403
|
deparseCExpr(str, stmt->limitCount);
|
2358
2404
|
else
|
2359
|
-
deparseExpr(str, stmt->limitCount);
|
2405
|
+
deparseExpr(str, stmt->limitCount, DEPARSE_NODE_CONTEXT_NONE /* c_expr */);
|
2360
2406
|
|
2361
2407
|
appendStringInfoChar(str, ' ');
|
2362
2408
|
|
@@ -2367,7 +2413,7 @@ static void deparseSelectStmt(StringInfo str, SelectStmt *stmt)
|
|
2367
2413
|
if (stmt->limitOffset != NULL)
|
2368
2414
|
{
|
2369
2415
|
appendStringInfoString(str, "OFFSET ");
|
2370
|
-
deparseExpr(str, stmt->limitOffset);
|
2416
|
+
deparseExpr(str, stmt->limitOffset, DEPARSE_NODE_CONTEXT_A_EXPR);
|
2371
2417
|
appendStringInfoChar(str, ' ');
|
2372
2418
|
}
|
2373
2419
|
|
@@ -2493,7 +2539,7 @@ static void deparseAConst(StringInfo str, A_Const *a_const)
|
|
2493
2539
|
deparseValue(str, val, DEPARSE_NODE_CONTEXT_CONSTANT);
|
2494
2540
|
}
|
2495
2541
|
|
2496
|
-
static void deparseFuncCall(StringInfo str, FuncCall *func_call)
|
2542
|
+
static void deparseFuncCall(StringInfo str, FuncCall *func_call, DeparseNodeContext context)
|
2497
2543
|
{
|
2498
2544
|
const ListCell *lc = NULL;
|
2499
2545
|
|
@@ -2509,13 +2555,13 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call)
|
|
2509
2555
|
* keyword parameter style when its called as a keyword, not as a regular function (i.e. pg_catalog.overlay)
|
2510
2556
|
*/
|
2511
2557
|
appendStringInfoString(str, "OVERLAY(");
|
2512
|
-
deparseExpr(str, linitial(func_call->args));
|
2558
|
+
deparseExpr(str, linitial(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
2513
2559
|
appendStringInfoString(str, " PLACING ");
|
2514
|
-
deparseExpr(str, lsecond(func_call->args));
|
2560
|
+
deparseExpr(str, lsecond(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
2515
2561
|
appendStringInfoString(str, " FROM ");
|
2516
|
-
deparseExpr(str, lthird(func_call->args));
|
2562
|
+
deparseExpr(str, lthird(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
2517
2563
|
appendStringInfoString(str, " FOR ");
|
2518
|
-
deparseExpr(str, lfourth(func_call->args));
|
2564
|
+
deparseExpr(str, lfourth(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
2519
2565
|
appendStringInfoChar(str, ')');
|
2520
2566
|
return;
|
2521
2567
|
} else if (func_call->funcformat == COERCE_SQL_SYNTAX &&
|
@@ -2529,13 +2575,13 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call)
|
|
2529
2575
|
*/
|
2530
2576
|
Assert(list_length(func_call->args) == 2 || list_length(func_call->args) == 3);
|
2531
2577
|
appendStringInfoString(str, "SUBSTRING(");
|
2532
|
-
deparseExpr(str, linitial(func_call->args));
|
2578
|
+
deparseExpr(str, linitial(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
2533
2579
|
appendStringInfoString(str, " FROM ");
|
2534
|
-
deparseExpr(str, lsecond(func_call->args));
|
2580
|
+
deparseExpr(str, lsecond(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
2535
2581
|
if (list_length(func_call->args) == 3)
|
2536
2582
|
{
|
2537
2583
|
appendStringInfoString(str, " FOR ");
|
2538
|
-
deparseExpr(str, lthird(func_call->args));
|
2584
|
+
deparseExpr(str, lthird(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
2539
2585
|
}
|
2540
2586
|
appendStringInfoChar(str, ')');
|
2541
2587
|
return;
|
@@ -2567,11 +2613,11 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call)
|
|
2567
2613
|
* keyword parameter style when its called as a keyword, not as a regular function (i.e. pg_catalog.overlay)
|
2568
2614
|
*/
|
2569
2615
|
appendStringInfoString(str, "overlay(");
|
2570
|
-
deparseExpr(str, linitial(func_call->args));
|
2616
|
+
deparseExpr(str, linitial(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
2571
2617
|
appendStringInfoString(str, " placing ");
|
2572
|
-
deparseExpr(str, lsecond(func_call->args));
|
2618
|
+
deparseExpr(str, lsecond(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
2573
2619
|
appendStringInfoString(str, " from ");
|
2574
|
-
deparseExpr(str, lthird(func_call->args));
|
2620
|
+
deparseExpr(str, lthird(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
2575
2621
|
appendStringInfoChar(str, ')');
|
2576
2622
|
return;
|
2577
2623
|
} else if (func_call->funcformat == COERCE_SQL_SYNTAX &&
|
@@ -2585,7 +2631,7 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call)
|
|
2585
2631
|
* keyword parameter style when its called as a keyword, not as a regular function (i.e. pg_catalog.overlay)
|
2586
2632
|
*/
|
2587
2633
|
appendStringInfoString(str, "collation for (");
|
2588
|
-
deparseExpr(str, linitial(func_call->args));
|
2634
|
+
deparseExpr(str, linitial(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
2589
2635
|
appendStringInfoChar(str, ')');
|
2590
2636
|
return;
|
2591
2637
|
} else if (func_call->funcformat == COERCE_SQL_SYNTAX &&
|
@@ -2599,9 +2645,9 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call)
|
|
2599
2645
|
* keyword parameter style when its called as a keyword, not as a regular function (i.e. pg_catalog.extract)
|
2600
2646
|
*/
|
2601
2647
|
appendStringInfoString(str, "extract (");
|
2602
|
-
deparseExpr(str, linitial(func_call->args));
|
2648
|
+
deparseExpr(str, linitial(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
2603
2649
|
appendStringInfoString(str, " FROM ");
|
2604
|
-
deparseExpr(str, lsecond(func_call->args));
|
2650
|
+
deparseExpr(str, lsecond(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
2605
2651
|
appendStringInfoChar(str, ')');
|
2606
2652
|
return;
|
2607
2653
|
} else if (func_call->funcformat == COERCE_SQL_SYNTAX &&
|
@@ -2616,16 +2662,16 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call)
|
|
2616
2662
|
* format: (start_1, end_1) overlaps (start_2, end_2)
|
2617
2663
|
*/
|
2618
2664
|
appendStringInfoChar(str, '(');
|
2619
|
-
deparseExpr(str, linitial(func_call->args));
|
2665
|
+
deparseExpr(str, linitial(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
2620
2666
|
appendStringInfoString(str, ", ");
|
2621
|
-
deparseExpr(str, lsecond(func_call->args));
|
2667
|
+
deparseExpr(str, lsecond(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
2622
2668
|
appendStringInfoString(str, ") ");
|
2623
2669
|
|
2624
2670
|
appendStringInfoString(str, "overlaps ");
|
2625
2671
|
appendStringInfoChar(str, '(');
|
2626
|
-
deparseExpr(str, lthird(func_call->args));
|
2672
|
+
deparseExpr(str, lthird(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
2627
2673
|
appendStringInfoString(str, ", ");
|
2628
|
-
deparseExpr(str, lfourth(func_call->args));
|
2674
|
+
deparseExpr(str, lfourth(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
2629
2675
|
appendStringInfoString(str, ") ");
|
2630
2676
|
return;
|
2631
2677
|
} else if (func_call->funcformat == COERCE_SQL_SYNTAX &&
|
@@ -2652,36 +2698,57 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call)
|
|
2652
2698
|
appendStringInfoString(str, "TRAILING ");
|
2653
2699
|
|
2654
2700
|
if (list_length(func_call->args) == 2)
|
2655
|
-
deparseExpr(str, lsecond(func_call->args));
|
2701
|
+
deparseExpr(str, lsecond(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
2656
2702
|
appendStringInfoString(str, " FROM ");
|
2657
|
-
deparseExpr(str, linitial(func_call->args));
|
2703
|
+
deparseExpr(str, linitial(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
2658
2704
|
appendStringInfoChar(str, ')');
|
2659
2705
|
return;
|
2660
2706
|
} else if (func_call->funcformat == COERCE_SQL_SYNTAX &&
|
2661
2707
|
list_length(func_call->funcname) == 2 &&
|
2662
2708
|
strcmp(strVal(linitial(func_call->funcname)), "pg_catalog") == 0 &&
|
2663
2709
|
strcmp(strVal(lsecond(func_call->funcname)), "timezone") == 0 &&
|
2664
|
-
list_length(func_call->args)
|
2710
|
+
list_length(func_call->args) > 0 &&
|
2711
|
+
list_length(func_call->args) <= 2)
|
2665
2712
|
{
|
2666
2713
|
/*
|
2667
2714
|
* "AT TIME ZONE" is a keyword on its own merit, and only accepts the
|
2668
2715
|
* keyword parameter style when its called as a keyword, not as a regular function (i.e. pg_catalog.timezone)
|
2669
2716
|
* Note that the arguments are swapped in this case
|
2670
2717
|
*/
|
2671
|
-
Expr* e
|
2718
|
+
Expr* e;
|
2719
|
+
bool isLocal = list_length(func_call->args) == 1;
|
2720
|
+
|
2721
|
+
if (isLocal)
|
2722
|
+
e = linitial(func_call->args);
|
2723
|
+
else
|
2724
|
+
e = lsecond(func_call->args);
|
2725
|
+
|
2726
|
+
// If we're not inside an a_expr context, we must add wrapping parenthesis around the AT ... syntax
|
2727
|
+
if (context != DEPARSE_NODE_CONTEXT_A_EXPR) {
|
2728
|
+
appendStringInfoChar(str, '(');
|
2729
|
+
}
|
2672
2730
|
|
2673
2731
|
if (IsA(e, A_Expr)) {
|
2674
2732
|
appendStringInfoChar(str, '(');
|
2675
2733
|
}
|
2676
2734
|
|
2677
|
-
deparseExpr(str, (Node*) e);
|
2735
|
+
deparseExpr(str, (Node*) e, DEPARSE_NODE_CONTEXT_A_EXPR);
|
2678
2736
|
|
2679
2737
|
if (IsA(e, A_Expr)) {
|
2680
2738
|
appendStringInfoChar(str, ')');
|
2681
2739
|
}
|
2682
2740
|
|
2683
|
-
|
2684
|
-
|
2741
|
+
if (isLocal)
|
2742
|
+
appendStringInfoString(str, " AT LOCAL");
|
2743
|
+
else {
|
2744
|
+
appendStringInfoString(str, " AT TIME ZONE ");
|
2745
|
+
deparseExpr(str, linitial(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
2746
|
+
}
|
2747
|
+
|
2748
|
+
if (context != DEPARSE_NODE_CONTEXT_A_EXPR) {
|
2749
|
+
appendStringInfoChar(str, ')');
|
2750
|
+
}
|
2751
|
+
|
2685
2752
|
return;
|
2686
2753
|
} else if (func_call->funcformat == COERCE_SQL_SYNTAX &&
|
2687
2754
|
list_length(func_call->funcname) == 2 &&
|
@@ -2695,7 +2762,7 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call)
|
|
2695
2762
|
Assert(list_length(func_call->args) == 1 || list_length(func_call->args) == 2);
|
2696
2763
|
appendStringInfoString(str, "normalize (");
|
2697
2764
|
|
2698
|
-
deparseExpr(str, linitial(func_call->args));
|
2765
|
+
deparseExpr(str, linitial(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
2699
2766
|
if (list_length(func_call->args) == 2)
|
2700
2767
|
{
|
2701
2768
|
appendStringInfoString(str, ", ");
|
@@ -2716,7 +2783,7 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call)
|
|
2716
2783
|
*/
|
2717
2784
|
Assert(list_length(func_call->args) == 1 || list_length(func_call->args) == 2);
|
2718
2785
|
|
2719
|
-
deparseExpr(str, linitial(func_call->args));
|
2786
|
+
deparseExpr(str, linitial(func_call->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
2720
2787
|
appendStringInfoString(str, " IS ");
|
2721
2788
|
if (list_length(func_call->args) == 2)
|
2722
2789
|
{
|
@@ -2733,9 +2800,9 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call)
|
|
2733
2800
|
list_length(func_call->args) == 2)
|
2734
2801
|
{
|
2735
2802
|
appendStringInfoString(str, "xmlexists (");
|
2736
|
-
deparseExpr(str, linitial(func_call->args));
|
2803
|
+
deparseExpr(str, linitial(func_call->args), DEPARSE_NODE_CONTEXT_NONE /* c_expr */);
|
2737
2804
|
appendStringInfoString(str, " PASSING ");
|
2738
|
-
deparseExpr(str, lsecond(func_call->args));
|
2805
|
+
deparseExpr(str, lsecond(func_call->args), DEPARSE_NODE_CONTEXT_NONE /* c_expr */);
|
2739
2806
|
appendStringInfoChar(str, ')');
|
2740
2807
|
return;
|
2741
2808
|
} else if (func_call->funcformat == COERCE_SQL_SYNTAX &&
|
@@ -2789,7 +2856,7 @@ static void deparseFuncCall(StringInfo str, FuncCall *func_call)
|
|
2789
2856
|
if (func_call->agg_filter)
|
2790
2857
|
{
|
2791
2858
|
appendStringInfoString(str, "FILTER (WHERE ");
|
2792
|
-
deparseExpr(str, func_call->agg_filter);
|
2859
|
+
deparseExpr(str, func_call->agg_filter, DEPARSE_NODE_CONTEXT_A_EXPR);
|
2793
2860
|
appendStringInfoString(str, ") ");
|
2794
2861
|
}
|
2795
2862
|
|
@@ -2856,13 +2923,13 @@ static void deparseWindowDef(StringInfo str, WindowDef* window_def)
|
|
2856
2923
|
else if (window_def->frameOptions & FRAMEOPTION_START_OFFSET_PRECEDING)
|
2857
2924
|
{
|
2858
2925
|
Assert(window_def->startOffset != NULL);
|
2859
|
-
deparseExpr(str, window_def->startOffset);
|
2926
|
+
deparseExpr(str, window_def->startOffset, DEPARSE_NODE_CONTEXT_A_EXPR);
|
2860
2927
|
appendStringInfoString(str, " PRECEDING ");
|
2861
2928
|
}
|
2862
2929
|
else if (window_def->frameOptions & FRAMEOPTION_START_OFFSET_FOLLOWING)
|
2863
2930
|
{
|
2864
2931
|
Assert(window_def->startOffset != NULL);
|
2865
|
-
deparseExpr(str, window_def->startOffset);
|
2932
|
+
deparseExpr(str, window_def->startOffset, DEPARSE_NODE_CONTEXT_A_EXPR);
|
2866
2933
|
appendStringInfoString(str, " FOLLOWING ");
|
2867
2934
|
}
|
2868
2935
|
|
@@ -2886,13 +2953,13 @@ static void deparseWindowDef(StringInfo str, WindowDef* window_def)
|
|
2886
2953
|
else if (window_def->frameOptions & FRAMEOPTION_END_OFFSET_PRECEDING)
|
2887
2954
|
{
|
2888
2955
|
Assert(window_def->endOffset != NULL);
|
2889
|
-
deparseExpr(str, window_def->endOffset);
|
2956
|
+
deparseExpr(str, window_def->endOffset, DEPARSE_NODE_CONTEXT_A_EXPR);
|
2890
2957
|
appendStringInfoString(str, " PRECEDING ");
|
2891
2958
|
}
|
2892
2959
|
else if (window_def->frameOptions & FRAMEOPTION_END_OFFSET_FOLLOWING)
|
2893
2960
|
{
|
2894
2961
|
Assert(window_def->endOffset != NULL);
|
2895
|
-
deparseExpr(str, window_def->endOffset);
|
2962
|
+
deparseExpr(str, window_def->endOffset, DEPARSE_NODE_CONTEXT_A_EXPR);
|
2896
2963
|
appendStringInfoString(str, " FOLLOWING ");
|
2897
2964
|
}
|
2898
2965
|
}
|
@@ -2930,7 +2997,7 @@ static void deparseSubLink(StringInfo str, SubLink* sub_link)
|
|
2930
2997
|
appendStringInfoChar(str, ')');
|
2931
2998
|
return;
|
2932
2999
|
case ALL_SUBLINK:
|
2933
|
-
deparseExpr(str, sub_link->testexpr);
|
3000
|
+
deparseExpr(str, sub_link->testexpr, DEPARSE_NODE_CONTEXT_A_EXPR);
|
2934
3001
|
appendStringInfoChar(str, ' ');
|
2935
3002
|
deparseSubqueryOp(str, sub_link->operName);
|
2936
3003
|
appendStringInfoString(str, " ALL (");
|
@@ -2938,7 +3005,7 @@ static void deparseSubLink(StringInfo str, SubLink* sub_link)
|
|
2938
3005
|
appendStringInfoChar(str, ')');
|
2939
3006
|
return;
|
2940
3007
|
case ANY_SUBLINK:
|
2941
|
-
deparseExpr(str, sub_link->testexpr);
|
3008
|
+
deparseExpr(str, sub_link->testexpr, DEPARSE_NODE_CONTEXT_A_EXPR);
|
2942
3009
|
if (list_length(sub_link->operName) > 0)
|
2943
3010
|
{
|
2944
3011
|
appendStringInfoChar(str, ' ');
|
@@ -2978,6 +3045,7 @@ static void deparseSubLink(StringInfo str, SubLink* sub_link)
|
|
2978
3045
|
}
|
2979
3046
|
}
|
2980
3047
|
|
3048
|
+
// This handles "A_Expr" parse tree objects, which are a subset of the rules in "a_expr" (handled by deparseExpr)
|
2981
3049
|
static void deparseAExpr(StringInfo str, A_Expr* a_expr, DeparseNodeContext context)
|
2982
3050
|
{
|
2983
3051
|
ListCell *lc;
|
@@ -2989,15 +3057,11 @@ static void deparseAExpr(StringInfo str, A_Expr* a_expr, DeparseNodeContext cont
|
|
2989
3057
|
switch (a_expr->kind) {
|
2990
3058
|
case AEXPR_OP: /* normal operator */
|
2991
3059
|
{
|
2992
|
-
bool need_outer_parens = context == DEPARSE_NODE_CONTEXT_A_EXPR;
|
2993
|
-
|
2994
|
-
if (need_outer_parens)
|
2995
|
-
appendStringInfoChar(str, '(');
|
2996
3060
|
if (a_expr->lexpr != NULL)
|
2997
3061
|
{
|
2998
3062
|
if (need_lexpr_parens)
|
2999
3063
|
appendStringInfoChar(str, '(');
|
3000
|
-
deparseExpr(str, a_expr->lexpr);
|
3064
|
+
deparseExpr(str, a_expr->lexpr, context);
|
3001
3065
|
if (need_lexpr_parens)
|
3002
3066
|
appendStringInfoChar(str, ')');
|
3003
3067
|
appendStringInfoChar(str, ' ');
|
@@ -3008,29 +3072,26 @@ static void deparseAExpr(StringInfo str, A_Expr* a_expr, DeparseNodeContext cont
|
|
3008
3072
|
appendStringInfoChar(str, ' ');
|
3009
3073
|
if (need_rexpr_parens)
|
3010
3074
|
appendStringInfoChar(str, '(');
|
3011
|
-
deparseExpr(str, a_expr->rexpr);
|
3075
|
+
deparseExpr(str, a_expr->rexpr, context);
|
3012
3076
|
if (need_rexpr_parens)
|
3013
3077
|
appendStringInfoChar(str, ')');
|
3014
3078
|
}
|
3015
|
-
|
3016
|
-
if (need_outer_parens)
|
3017
|
-
appendStringInfoChar(str, ')');
|
3018
3079
|
}
|
3019
3080
|
return;
|
3020
3081
|
case AEXPR_OP_ANY: /* scalar op ANY (array) */
|
3021
|
-
deparseExpr(str, a_expr->lexpr);
|
3082
|
+
deparseExpr(str, a_expr->lexpr, context);
|
3022
3083
|
appendStringInfoChar(str, ' ');
|
3023
3084
|
deparseSubqueryOp(str, a_expr->name);
|
3024
3085
|
appendStringInfoString(str, " ANY(");
|
3025
|
-
deparseExpr(str, a_expr->rexpr);
|
3086
|
+
deparseExpr(str, a_expr->rexpr, context);
|
3026
3087
|
appendStringInfoChar(str, ')');
|
3027
3088
|
return;
|
3028
3089
|
case AEXPR_OP_ALL: /* scalar op ALL (array) */
|
3029
|
-
deparseExpr(str, a_expr->lexpr);
|
3090
|
+
deparseExpr(str, a_expr->lexpr, context);
|
3030
3091
|
appendStringInfoChar(str, ' ');
|
3031
3092
|
deparseSubqueryOp(str, a_expr->name);
|
3032
3093
|
appendStringInfoString(str, " ALL(");
|
3033
|
-
deparseExpr(str, a_expr->rexpr);
|
3094
|
+
deparseExpr(str, a_expr->rexpr, context);
|
3034
3095
|
appendStringInfoChar(str, ')');
|
3035
3096
|
return;
|
3036
3097
|
case AEXPR_DISTINCT: /* IS DISTINCT FROM - name must be "=" */
|
@@ -3040,13 +3101,13 @@ static void deparseAExpr(StringInfo str, A_Expr* a_expr, DeparseNodeContext cont
|
|
3040
3101
|
|
3041
3102
|
if (need_lexpr_parens)
|
3042
3103
|
appendStringInfoChar(str, '(');
|
3043
|
-
deparseExpr(str, a_expr->lexpr);
|
3104
|
+
deparseExpr(str, a_expr->lexpr, context);
|
3044
3105
|
if (need_lexpr_parens)
|
3045
3106
|
appendStringInfoChar(str, ')');
|
3046
3107
|
appendStringInfoString(str, " IS DISTINCT FROM ");
|
3047
3108
|
if (need_rexpr_parens)
|
3048
3109
|
appendStringInfoChar(str, '(');
|
3049
|
-
deparseExpr(str, a_expr->rexpr);
|
3110
|
+
deparseExpr(str, a_expr->rexpr, context);
|
3050
3111
|
if (need_rexpr_parens)
|
3051
3112
|
appendStringInfoChar(str, ')');
|
3052
3113
|
return;
|
@@ -3055,9 +3116,9 @@ static void deparseAExpr(StringInfo str, A_Expr* a_expr, DeparseNodeContext cont
|
|
3055
3116
|
Assert(IsA(linitial(a_expr->name), String));
|
3056
3117
|
Assert(strcmp(strVal(linitial(a_expr->name)), "=") == 0);
|
3057
3118
|
|
3058
|
-
deparseExpr(str, a_expr->lexpr);
|
3119
|
+
deparseExpr(str, a_expr->lexpr, context);
|
3059
3120
|
appendStringInfoString(str, " IS NOT DISTINCT FROM ");
|
3060
|
-
deparseExpr(str, a_expr->rexpr);
|
3121
|
+
deparseExpr(str, a_expr->rexpr, context);
|
3061
3122
|
return;
|
3062
3123
|
case AEXPR_NULLIF: /* NULLIF - name must be "=" */
|
3063
3124
|
Assert(list_length(a_expr->name) == 1);
|
@@ -3065,16 +3126,16 @@ static void deparseAExpr(StringInfo str, A_Expr* a_expr, DeparseNodeContext cont
|
|
3065
3126
|
Assert(strcmp(strVal(linitial(a_expr->name)), "=") == 0);
|
3066
3127
|
|
3067
3128
|
appendStringInfoString(str, "NULLIF(");
|
3068
|
-
deparseExpr(str, a_expr->lexpr);
|
3129
|
+
deparseExpr(str, a_expr->lexpr, context);
|
3069
3130
|
appendStringInfoString(str, ", ");
|
3070
|
-
deparseExpr(str, a_expr->rexpr);
|
3131
|
+
deparseExpr(str, a_expr->rexpr, context);
|
3071
3132
|
appendStringInfoChar(str, ')');
|
3072
3133
|
return;
|
3073
3134
|
case AEXPR_IN: /* [NOT] IN - name must be "=" or "<>" */
|
3074
3135
|
Assert(list_length(a_expr->name) == 1);
|
3075
3136
|
Assert(IsA(linitial(a_expr->name), String));
|
3076
3137
|
Assert(IsA(a_expr->rexpr, List));
|
3077
|
-
deparseExpr(str, a_expr->lexpr);
|
3138
|
+
deparseExpr(str, a_expr->lexpr, context);
|
3078
3139
|
appendStringInfoChar(str, ' ');
|
3079
3140
|
name = ((union ValUnion *) linitial(a_expr->name))->sval.sval;
|
3080
3141
|
if (strcmp(name, "=") == 0) {
|
@@ -3094,7 +3155,7 @@ static void deparseAExpr(StringInfo str, A_Expr* a_expr, DeparseNodeContext cont
|
|
3094
3155
|
case AEXPR_LIKE: /* [NOT] LIKE - name must be "~~" or "!~~" */
|
3095
3156
|
Assert(list_length(a_expr->name) == 1);
|
3096
3157
|
Assert(IsA(linitial(a_expr->name), String));
|
3097
|
-
deparseExpr(str, a_expr->lexpr);
|
3158
|
+
deparseExpr(str, a_expr->lexpr, context);
|
3098
3159
|
appendStringInfoChar(str, ' ');
|
3099
3160
|
|
3100
3161
|
name = ((union ValUnion *) linitial(a_expr->name))->sval.sval;
|
@@ -3106,12 +3167,12 @@ static void deparseAExpr(StringInfo str, A_Expr* a_expr, DeparseNodeContext cont
|
|
3106
3167
|
Assert(false);
|
3107
3168
|
}
|
3108
3169
|
|
3109
|
-
deparseExpr(str, a_expr->rexpr);
|
3170
|
+
deparseExpr(str, a_expr->rexpr, context);
|
3110
3171
|
return;
|
3111
3172
|
case AEXPR_ILIKE: /* [NOT] ILIKE - name must be "~~*" or "!~~*" */
|
3112
3173
|
Assert(list_length(a_expr->name) == 1);
|
3113
3174
|
Assert(IsA(linitial(a_expr->name), String));
|
3114
|
-
deparseExpr(str, a_expr->lexpr);
|
3175
|
+
deparseExpr(str, a_expr->lexpr, context);
|
3115
3176
|
appendStringInfoChar(str, ' ');
|
3116
3177
|
|
3117
3178
|
name = ((union ValUnion *) linitial(a_expr->name))->sval.sval;
|
@@ -3123,12 +3184,12 @@ static void deparseAExpr(StringInfo str, A_Expr* a_expr, DeparseNodeContext cont
|
|
3123
3184
|
Assert(false);
|
3124
3185
|
}
|
3125
3186
|
|
3126
|
-
deparseExpr(str, a_expr->rexpr);
|
3187
|
+
deparseExpr(str, a_expr->rexpr, context);
|
3127
3188
|
return;
|
3128
3189
|
case AEXPR_SIMILAR: /* [NOT] SIMILAR - name must be "~" or "!~" */
|
3129
3190
|
Assert(list_length(a_expr->name) == 1);
|
3130
3191
|
Assert(IsA(linitial(a_expr->name), String));
|
3131
|
-
deparseExpr(str, a_expr->lexpr);
|
3192
|
+
deparseExpr(str, a_expr->lexpr, context);
|
3132
3193
|
appendStringInfoChar(str, ' ');
|
3133
3194
|
|
3134
3195
|
name = ((union ValUnion *) linitial(a_expr->name))->sval.sval;
|
@@ -3146,11 +3207,11 @@ static void deparseAExpr(StringInfo str, A_Expr* a_expr, DeparseNodeContext cont
|
|
3146
3207
|
Assert(strcmp(strVal(lsecond(n->funcname)), "similar_to_escape") == 0);
|
3147
3208
|
Assert(list_length(n->args) == 1 || list_length(n->args) == 2);
|
3148
3209
|
|
3149
|
-
deparseExpr(str, linitial(n->args));
|
3210
|
+
deparseExpr(str, linitial(n->args), context);
|
3150
3211
|
if (list_length(n->args) == 2)
|
3151
3212
|
{
|
3152
3213
|
appendStringInfoString(str, " ESCAPE ");
|
3153
|
-
deparseExpr(str, lsecond(n->args));
|
3214
|
+
deparseExpr(str, lsecond(n->args), context);
|
3154
3215
|
}
|
3155
3216
|
|
3156
3217
|
return;
|
@@ -3162,13 +3223,13 @@ static void deparseAExpr(StringInfo str, A_Expr* a_expr, DeparseNodeContext cont
|
|
3162
3223
|
Assert(IsA(linitial(a_expr->name), String));
|
3163
3224
|
Assert(IsA(a_expr->rexpr, List));
|
3164
3225
|
|
3165
|
-
deparseExpr(str, a_expr->lexpr);
|
3226
|
+
deparseExpr(str, a_expr->lexpr, context);
|
3166
3227
|
appendStringInfoChar(str, ' ');
|
3167
3228
|
appendStringInfoString(str, strVal(linitial(a_expr->name)));
|
3168
3229
|
appendStringInfoChar(str, ' ');
|
3169
3230
|
|
3170
3231
|
foreach(lc, castNode(List, a_expr->rexpr)) {
|
3171
|
-
deparseExpr(str, lfirst(lc));
|
3232
|
+
deparseExpr(str, lfirst(lc), context);
|
3172
3233
|
if (lnext(castNode(List, a_expr->rexpr), lc))
|
3173
3234
|
appendStringInfoString(str, " AND ");
|
3174
3235
|
}
|
@@ -3190,7 +3251,7 @@ static void deparseBoolExpr(StringInfo str, BoolExpr *bool_expr)
|
|
3190
3251
|
if (need_parens)
|
3191
3252
|
appendStringInfoChar(str, '(');
|
3192
3253
|
|
3193
|
-
deparseExpr(str, lfirst(lc));
|
3254
|
+
deparseExpr(str, lfirst(lc), DEPARSE_NODE_CONTEXT_A_EXPR);
|
3194
3255
|
|
3195
3256
|
if (need_parens)
|
3196
3257
|
appendStringInfoChar(str, ')');
|
@@ -3208,7 +3269,7 @@ static void deparseBoolExpr(StringInfo str, BoolExpr *bool_expr)
|
|
3208
3269
|
if (need_parens)
|
3209
3270
|
appendStringInfoChar(str, '(');
|
3210
3271
|
|
3211
|
-
deparseExpr(str, lfirst(lc));
|
3272
|
+
deparseExpr(str, lfirst(lc), DEPARSE_NODE_CONTEXT_A_EXPR);
|
3212
3273
|
|
3213
3274
|
if (need_parens)
|
3214
3275
|
appendStringInfoChar(str, ')');
|
@@ -3223,7 +3284,7 @@ static void deparseBoolExpr(StringInfo str, BoolExpr *bool_expr)
|
|
3223
3284
|
appendStringInfoString(str, "NOT ");
|
3224
3285
|
if (need_parens)
|
3225
3286
|
appendStringInfoChar(str, '(');
|
3226
|
-
deparseExpr(str, linitial(bool_expr->args));
|
3287
|
+
deparseExpr(str, linitial(bool_expr->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
3227
3288
|
if (need_parens)
|
3228
3289
|
appendStringInfoChar(str, ')');
|
3229
3290
|
return;
|
@@ -3243,7 +3304,7 @@ static void deparseCollateClause(StringInfo str, CollateClause* collate_clause)
|
|
3243
3304
|
bool need_parens = IsA(collate_clause->arg, A_Expr);
|
3244
3305
|
if (need_parens)
|
3245
3306
|
appendStringInfoChar(str, '(');
|
3246
|
-
deparseExpr(str, collate_clause->arg);
|
3307
|
+
deparseExpr(str, collate_clause->arg, DEPARSE_NODE_CONTEXT_A_EXPR);
|
3247
3308
|
if (need_parens)
|
3248
3309
|
appendStringInfoChar(str, ')');
|
3249
3310
|
appendStringInfoChar(str, ' ');
|
@@ -3252,9 +3313,10 @@ static void deparseCollateClause(StringInfo str, CollateClause* collate_clause)
|
|
3252
3313
|
deparseAnyName(str, collate_clause->collname);
|
3253
3314
|
}
|
3254
3315
|
|
3316
|
+
// "sortby" in gram.y
|
3255
3317
|
static void deparseSortBy(StringInfo str, SortBy* sort_by)
|
3256
3318
|
{
|
3257
|
-
deparseExpr(str, sort_by->node);
|
3319
|
+
deparseExpr(str, sort_by->node, DEPARSE_NODE_CONTEXT_A_EXPR);
|
3258
3320
|
appendStringInfoChar(str, ' ');
|
3259
3321
|
|
3260
3322
|
switch (sort_by->sortby_dir)
|
@@ -3371,6 +3433,7 @@ static void deparseWithClause(StringInfo str, WithClause *with_clause)
|
|
3371
3433
|
removeTrailingSpace(str);
|
3372
3434
|
}
|
3373
3435
|
|
3436
|
+
// "joined_table" in gram.y
|
3374
3437
|
static void deparseJoinExpr(StringInfo str, JoinExpr *join_expr)
|
3375
3438
|
{
|
3376
3439
|
ListCell *lc;
|
@@ -3424,7 +3487,7 @@ static void deparseJoinExpr(StringInfo str, JoinExpr *join_expr)
|
|
3424
3487
|
if (join_expr->quals != NULL)
|
3425
3488
|
{
|
3426
3489
|
appendStringInfoString(str, "ON ");
|
3427
|
-
deparseExpr(str, join_expr->quals);
|
3490
|
+
deparseExpr(str, join_expr->quals, DEPARSE_NODE_CONTEXT_A_EXPR);
|
3428
3491
|
appendStringInfoChar(str, ' ');
|
3429
3492
|
}
|
3430
3493
|
|
@@ -3467,6 +3530,7 @@ static void deparseCTESearchClause(StringInfo str, CTESearchClause *search_claus
|
|
3467
3530
|
appendStringInfoString(str, quote_identifier(search_clause->search_seq_column));
|
3468
3531
|
}
|
3469
3532
|
|
3533
|
+
// "opt_cycle_clause" in gram.y
|
3470
3534
|
static void deparseCTECycleClause(StringInfo str, CTECycleClause *cycle_clause)
|
3471
3535
|
{
|
3472
3536
|
appendStringInfoString(str, " CYCLE ");
|
@@ -3480,15 +3544,15 @@ static void deparseCTECycleClause(StringInfo str, CTECycleClause *cycle_clause)
|
|
3480
3544
|
if (cycle_clause->cycle_mark_value)
|
3481
3545
|
{
|
3482
3546
|
appendStringInfoString(str, " TO ");
|
3483
|
-
|
3547
|
+
deparseAexprConst(str, cycle_clause->cycle_mark_value);
|
3484
3548
|
}
|
3485
|
-
|
3549
|
+
|
3486
3550
|
if (cycle_clause->cycle_mark_default)
|
3487
3551
|
{
|
3488
3552
|
appendStringInfoString(str, " DEFAULT ");
|
3489
|
-
|
3553
|
+
deparseAexprConst(str, cycle_clause->cycle_mark_default);
|
3490
3554
|
}
|
3491
|
-
|
3555
|
+
|
3492
3556
|
appendStringInfoString(str, " USING ");
|
3493
3557
|
appendStringInfoString(str, quote_identifier(cycle_clause->cycle_path_column));
|
3494
3558
|
}
|
@@ -3653,7 +3717,7 @@ static void deparseTypeCast(StringInfo str, TypeCast *type_cast, DeparseNodeCont
|
|
3653
3717
|
if (IsA(type_cast->arg, A_Expr) || context == DEPARSE_NODE_CONTEXT_FUNC_EXPR)
|
3654
3718
|
{
|
3655
3719
|
appendStringInfoString(str, "CAST(");
|
3656
|
-
deparseExpr(str, type_cast->arg);
|
3720
|
+
deparseExpr(str, type_cast->arg, DEPARSE_NODE_CONTEXT_A_EXPR);
|
3657
3721
|
appendStringInfoString(str, " AS ");
|
3658
3722
|
deparseTypeName(str, type_cast->typeName);
|
3659
3723
|
appendStringInfoChar(str, ')');
|
@@ -3720,7 +3784,7 @@ static void deparseTypeCast(StringInfo str, TypeCast *type_cast, DeparseNodeCont
|
|
3720
3784
|
|
3721
3785
|
if (need_parens)
|
3722
3786
|
appendStringInfoChar(str, '(');
|
3723
|
-
deparseExpr(str, type_cast->arg);
|
3787
|
+
deparseExpr(str, type_cast->arg, DEPARSE_NODE_CONTEXT_NONE /* could be either a_expr or b_expr (we could pass this down, but that'd require two kinds of contexts most likely) */);
|
3724
3788
|
if (need_parens)
|
3725
3789
|
appendStringInfoChar(str, ')');
|
3726
3790
|
|
@@ -3949,7 +4013,7 @@ static void deparseNullTest(StringInfo str, NullTest *null_test)
|
|
3949
4013
|
// argisrow is always false in raw parser output
|
3950
4014
|
Assert(null_test->argisrow == false);
|
3951
4015
|
|
3952
|
-
deparseExpr(str, (Node *) null_test->arg);
|
4016
|
+
deparseExpr(str, (Node *) null_test->arg, DEPARSE_NODE_CONTEXT_A_EXPR);
|
3953
4017
|
switch (null_test->nulltesttype)
|
3954
4018
|
{
|
3955
4019
|
case IS_NULL:
|
@@ -3961,6 +4025,7 @@ static void deparseNullTest(StringInfo str, NullTest *null_test)
|
|
3961
4025
|
}
|
3962
4026
|
}
|
3963
4027
|
|
4028
|
+
// "case_expr" in gram.y
|
3964
4029
|
static void deparseCaseExpr(StringInfo str, CaseExpr *case_expr)
|
3965
4030
|
{
|
3966
4031
|
ListCell *lc;
|
@@ -3969,7 +4034,7 @@ static void deparseCaseExpr(StringInfo str, CaseExpr *case_expr)
|
|
3969
4034
|
|
3970
4035
|
if (case_expr->arg != NULL)
|
3971
4036
|
{
|
3972
|
-
deparseExpr(str, (Node *) case_expr->arg);
|
4037
|
+
deparseExpr(str, (Node *) case_expr->arg, DEPARSE_NODE_CONTEXT_A_EXPR);
|
3973
4038
|
appendStringInfoChar(str, ' ');
|
3974
4039
|
}
|
3975
4040
|
|
@@ -3982,19 +4047,20 @@ static void deparseCaseExpr(StringInfo str, CaseExpr *case_expr)
|
|
3982
4047
|
if (case_expr->defresult != NULL)
|
3983
4048
|
{
|
3984
4049
|
appendStringInfoString(str, "ELSE ");
|
3985
|
-
deparseExpr(str, (Node *) case_expr->defresult);
|
4050
|
+
deparseExpr(str, (Node *) case_expr->defresult, DEPARSE_NODE_CONTEXT_A_EXPR);
|
3986
4051
|
appendStringInfoChar(str, ' ');
|
3987
4052
|
}
|
3988
4053
|
|
3989
4054
|
appendStringInfoString(str, "END");
|
3990
4055
|
}
|
3991
4056
|
|
4057
|
+
// "when_clause" in gram.y
|
3992
4058
|
static void deparseCaseWhen(StringInfo str, CaseWhen *case_when)
|
3993
4059
|
{
|
3994
4060
|
appendStringInfoString(str, "WHEN ");
|
3995
|
-
deparseExpr(str, (Node *) case_when->expr);
|
4061
|
+
deparseExpr(str, (Node *) case_when->expr, DEPARSE_NODE_CONTEXT_A_EXPR);
|
3996
4062
|
appendStringInfoString(str, " THEN ");
|
3997
|
-
deparseExpr(str, (Node *) case_when->result);
|
4063
|
+
deparseExpr(str, (Node *) case_when->result, DEPARSE_NODE_CONTEXT_A_EXPR);
|
3998
4064
|
}
|
3999
4065
|
|
4000
4066
|
static void deparseAIndirection(StringInfo str, A_Indirection *a_indirection)
|
@@ -4006,12 +4072,13 @@ static void deparseAIndirection(StringInfo str, A_Indirection *a_indirection)
|
|
4006
4072
|
IsA(a_indirection->arg, A_Expr) ||
|
4007
4073
|
IsA(a_indirection->arg, TypeCast) ||
|
4008
4074
|
IsA(a_indirection->arg, RowExpr) ||
|
4009
|
-
(IsA(a_indirection->arg, ColumnRef) && !IsA(linitial(a_indirection->indirection), A_Indices))
|
4075
|
+
(IsA(a_indirection->arg, ColumnRef) && !IsA(linitial(a_indirection->indirection), A_Indices)) ||
|
4076
|
+
IsA(a_indirection->arg, JsonFuncExpr);
|
4010
4077
|
|
4011
4078
|
if (need_parens)
|
4012
4079
|
appendStringInfoChar(str, '(');
|
4013
4080
|
|
4014
|
-
deparseExpr(str, a_indirection->arg);
|
4081
|
+
deparseExpr(str, a_indirection->arg, need_parens ? DEPARSE_NODE_CONTEXT_A_EXPR : DEPARSE_NODE_CONTEXT_NONE);
|
4015
4082
|
|
4016
4083
|
if (need_parens)
|
4017
4084
|
appendStringInfoChar(str, ')');
|
@@ -4023,11 +4090,11 @@ static void deparseAIndices(StringInfo str, A_Indices *a_indices)
|
|
4023
4090
|
{
|
4024
4091
|
appendStringInfoChar(str, '[');
|
4025
4092
|
if (a_indices->lidx != NULL)
|
4026
|
-
deparseExpr(str, a_indices->lidx);
|
4093
|
+
deparseExpr(str, a_indices->lidx, DEPARSE_NODE_CONTEXT_A_EXPR);
|
4027
4094
|
if (a_indices->is_slice)
|
4028
4095
|
appendStringInfoChar(str, ':');
|
4029
4096
|
if (a_indices->uidx != NULL)
|
4030
|
-
deparseExpr(str, a_indices->uidx);
|
4097
|
+
deparseExpr(str, a_indices->uidx, DEPARSE_NODE_CONTEXT_A_EXPR);
|
4031
4098
|
appendStringInfoChar(str, ']');
|
4032
4099
|
}
|
4033
4100
|
|
@@ -4060,7 +4127,7 @@ static void deparseBooleanTest(StringInfo str, BooleanTest *boolean_test)
|
|
4060
4127
|
if (need_parens)
|
4061
4128
|
appendStringInfoChar(str, '(');
|
4062
4129
|
|
4063
|
-
deparseExpr(str, (Node *) boolean_test->arg);
|
4130
|
+
deparseExpr(str, (Node *) boolean_test->arg, DEPARSE_NODE_CONTEXT_A_EXPR);
|
4064
4131
|
|
4065
4132
|
if (need_parens)
|
4066
4133
|
appendStringInfoChar(str, ')');
|
@@ -4090,6 +4157,7 @@ static void deparseBooleanTest(StringInfo str, BooleanTest *boolean_test)
|
|
4090
4157
|
}
|
4091
4158
|
}
|
4092
4159
|
|
4160
|
+
// "columnDef" and "alter_table_cmd" in gram.y
|
4093
4161
|
static void deparseColumnDef(StringInfo str, ColumnDef *column_def)
|
4094
4162
|
{
|
4095
4163
|
ListCell *lc;
|
@@ -4116,7 +4184,7 @@ static void deparseColumnDef(StringInfo str, ColumnDef *column_def)
|
|
4116
4184
|
if (column_def->raw_default != NULL)
|
4117
4185
|
{
|
4118
4186
|
appendStringInfoString(str, "USING ");
|
4119
|
-
deparseExpr(str, column_def->raw_default);
|
4187
|
+
deparseExpr(str, column_def->raw_default, DEPARSE_NODE_CONTEXT_A_EXPR);
|
4120
4188
|
appendStringInfoChar(str, ' ');
|
4121
4189
|
}
|
4122
4190
|
|
@@ -4312,6 +4380,7 @@ static void deparseUpdateStmt(StringInfo str, UpdateStmt *update_stmt)
|
|
4312
4380
|
removeTrailingSpace(str);
|
4313
4381
|
}
|
4314
4382
|
|
4383
|
+
// "MergeStmt" in gram.y
|
4315
4384
|
static void deparseMergeStmt(StringInfo str, MergeStmt *merge_stmt)
|
4316
4385
|
{
|
4317
4386
|
if (merge_stmt->withClause != NULL)
|
@@ -4329,27 +4398,33 @@ static void deparseMergeStmt(StringInfo str, MergeStmt *merge_stmt)
|
|
4329
4398
|
appendStringInfoChar(str, ' ');
|
4330
4399
|
|
4331
4400
|
appendStringInfoString(str, "ON ");
|
4332
|
-
deparseExpr(str, merge_stmt->joinCondition);
|
4401
|
+
deparseExpr(str, merge_stmt->joinCondition, DEPARSE_NODE_CONTEXT_A_EXPR);
|
4333
4402
|
appendStringInfoChar(str, ' ');
|
4334
4403
|
|
4335
|
-
ListCell *lc
|
4404
|
+
ListCell *lc;
|
4336
4405
|
foreach (lc, merge_stmt->mergeWhenClauses)
|
4337
4406
|
{
|
4338
4407
|
MergeWhenClause *clause = castNode(MergeWhenClause, lfirst(lc));
|
4339
4408
|
|
4340
4409
|
appendStringInfoString(str, "WHEN ");
|
4341
4410
|
|
4342
|
-
|
4411
|
+
switch (clause->matchKind)
|
4343
4412
|
{
|
4344
|
-
|
4413
|
+
case MERGE_WHEN_MATCHED:
|
4414
|
+
appendStringInfoString(str, "MATCHED ");
|
4415
|
+
break;
|
4416
|
+
case MERGE_WHEN_NOT_MATCHED_BY_SOURCE:
|
4417
|
+
appendStringInfoString(str, "NOT MATCHED BY SOURCE ");
|
4418
|
+
break;
|
4419
|
+
case MERGE_WHEN_NOT_MATCHED_BY_TARGET:
|
4420
|
+
appendStringInfoString(str, "NOT MATCHED ");
|
4421
|
+
break;
|
4345
4422
|
}
|
4346
4423
|
|
4347
|
-
appendStringInfoString(str, "MATCHED ");
|
4348
|
-
|
4349
4424
|
if (clause->condition)
|
4350
4425
|
{
|
4351
4426
|
appendStringInfoString(str, "AND ");
|
4352
|
-
deparseExpr(str, clause->condition);
|
4427
|
+
deparseExpr(str, clause->condition, DEPARSE_NODE_CONTEXT_A_EXPR);
|
4353
4428
|
appendStringInfoChar(str, ' ');
|
4354
4429
|
}
|
4355
4430
|
|
@@ -4394,6 +4469,12 @@ static void deparseMergeStmt(StringInfo str, MergeStmt *merge_stmt)
|
|
4394
4469
|
if (lfirst(lc) != llast(merge_stmt->mergeWhenClauses))
|
4395
4470
|
appendStringInfoChar(str, ' ');
|
4396
4471
|
}
|
4472
|
+
|
4473
|
+
if (merge_stmt->returningList)
|
4474
|
+
{
|
4475
|
+
appendStringInfoString(str, " RETURNING ");
|
4476
|
+
deparseTargetList(str, merge_stmt->returningList);
|
4477
|
+
}
|
4397
4478
|
}
|
4398
4479
|
|
4399
4480
|
static void deparseDeleteStmt(StringInfo str, DeleteStmt *delete_stmt)
|
@@ -4719,6 +4800,7 @@ static void deparseCreateExtensionStmt(StringInfo str, CreateExtensionStmt *crea
|
|
4719
4800
|
removeTrailingSpace(str);
|
4720
4801
|
}
|
4721
4802
|
|
4803
|
+
// "ColConstraintElem" and "ConstraintElem" in gram.y
|
4722
4804
|
static void deparseConstraint(StringInfo str, Constraint *constraint)
|
4723
4805
|
{
|
4724
4806
|
ListCell *lc;
|
@@ -4760,12 +4842,12 @@ static void deparseConstraint(StringInfo str, Constraint *constraint)
|
|
4760
4842
|
case CONSTR_GENERATED:
|
4761
4843
|
Assert(constraint->generated_when == ATTRIBUTE_IDENTITY_ALWAYS);
|
4762
4844
|
appendStringInfoString(str, "GENERATED ALWAYS AS (");
|
4763
|
-
deparseExpr(str, constraint->raw_expr);
|
4845
|
+
deparseExpr(str, constraint->raw_expr, DEPARSE_NODE_CONTEXT_A_EXPR);
|
4764
4846
|
appendStringInfoString(str, ") STORED ");
|
4765
4847
|
break;
|
4766
4848
|
case CONSTR_CHECK:
|
4767
4849
|
appendStringInfoString(str, "CHECK (");
|
4768
|
-
deparseExpr(str, constraint->raw_expr);
|
4850
|
+
deparseExpr(str, constraint->raw_expr, DEPARSE_NODE_CONTEXT_A_EXPR);
|
4769
4851
|
appendStringInfoString(str, ") ");
|
4770
4852
|
break;
|
4771
4853
|
case CONSTR_PRIMARY:
|
@@ -4799,7 +4881,7 @@ static void deparseConstraint(StringInfo str, Constraint *constraint)
|
|
4799
4881
|
if (constraint->where_clause != NULL)
|
4800
4882
|
{
|
4801
4883
|
appendStringInfoString(str, "WHERE (");
|
4802
|
-
deparseExpr(str, constraint->where_clause);
|
4884
|
+
deparseExpr(str, constraint->where_clause, DEPARSE_NODE_CONTEXT_A_EXPR);
|
4803
4885
|
appendStringInfoString(str, ") ");
|
4804
4886
|
}
|
4805
4887
|
break;
|
@@ -4823,9 +4905,18 @@ static void deparseConstraint(StringInfo str, Constraint *constraint)
|
|
4823
4905
|
|
4824
4906
|
if (list_length(constraint->keys) > 0)
|
4825
4907
|
{
|
4826
|
-
|
4827
|
-
|
4828
|
-
|
4908
|
+
bool valueOnly = false;
|
4909
|
+
|
4910
|
+
if (list_length(constraint->keys) == 1) {
|
4911
|
+
Node* firstKey = constraint->keys->elements[0].ptr_value;
|
4912
|
+
valueOnly = IsA(firstKey, String) && !strcmp("value", ((String*)firstKey)->sval);
|
4913
|
+
}
|
4914
|
+
|
4915
|
+
if (!valueOnly) {
|
4916
|
+
appendStringInfoChar(str, '(');
|
4917
|
+
deparseColumnList(str, constraint->keys);
|
4918
|
+
appendStringInfoString(str, ") ");
|
4919
|
+
}
|
4829
4920
|
}
|
4830
4921
|
|
4831
4922
|
if (list_length(constraint->fk_attrs) > 0)
|
@@ -4962,10 +5053,11 @@ static void deparseConstraint(StringInfo str, Constraint *constraint)
|
|
4962
5053
|
removeTrailingSpace(str);
|
4963
5054
|
}
|
4964
5055
|
|
5056
|
+
// "ReturnStmt" in gram.y
|
4965
5057
|
static void deparseReturnStmt(StringInfo str, ReturnStmt *return_stmt)
|
4966
5058
|
{
|
4967
5059
|
appendStringInfoString(str, "RETURN ");
|
4968
|
-
deparseExpr(str, return_stmt->returnval);
|
5060
|
+
deparseExpr(str, return_stmt->returnval, DEPARSE_NODE_CONTEXT_A_EXPR);
|
4969
5061
|
}
|
4970
5062
|
|
4971
5063
|
static void deparseCreateFunctionStmt(StringInfo str, CreateFunctionStmt *create_function_stmt)
|
@@ -5064,6 +5156,7 @@ static void deparseCreateFunctionStmt(StringInfo str, CreateFunctionStmt *create
|
|
5064
5156
|
removeTrailingSpace(str);
|
5065
5157
|
}
|
5066
5158
|
|
5159
|
+
// "func_arg", "func_arg_with_default" and other places in gram.y
|
5067
5160
|
static void deparseFunctionParameter(StringInfo str, FunctionParameter *function_parameter)
|
5068
5161
|
{
|
5069
5162
|
switch (function_parameter->mode)
|
@@ -5104,7 +5197,7 @@ static void deparseFunctionParameter(StringInfo str, FunctionParameter *function
|
|
5104
5197
|
if (function_parameter->defexpr != NULL)
|
5105
5198
|
{
|
5106
5199
|
appendStringInfoString(str, "= ");
|
5107
|
-
deparseExpr(str, function_parameter->defexpr);
|
5200
|
+
deparseExpr(str, function_parameter->defexpr, DEPARSE_NODE_CONTEXT_A_EXPR);
|
5108
5201
|
}
|
5109
5202
|
|
5110
5203
|
removeTrailingSpace(str);
|
@@ -5225,7 +5318,7 @@ static void deparsePartitionElem(StringInfo str, PartitionElem *partition_elem)
|
|
5225
5318
|
else if (partition_elem->expr != NULL)
|
5226
5319
|
{
|
5227
5320
|
appendStringInfoChar(str, '(');
|
5228
|
-
deparseExpr(str, partition_elem->expr);
|
5321
|
+
deparseExpr(str, partition_elem->expr, DEPARSE_NODE_CONTEXT_A_EXPR);
|
5229
5322
|
appendStringInfoString(str, ") ");
|
5230
5323
|
}
|
5231
5324
|
|
@@ -6287,6 +6380,7 @@ static void deparseAlterObjectSchemaStmt(StringInfo str, AlterObjectSchemaStmt *
|
|
6287
6380
|
appendStringInfoString(str, quote_identifier(alter_object_schema_stmt->newschema));
|
6288
6381
|
}
|
6289
6382
|
|
6383
|
+
// "alter_table_cmd" in gram.y
|
6290
6384
|
static void deparseAlterTableCmd(StringInfo str, AlterTableCmd *alter_table_cmd, DeparseNodeContext context)
|
6291
6385
|
{
|
6292
6386
|
ListCell *lc = NULL;
|
@@ -6525,6 +6619,9 @@ static void deparseAlterTableCmd(StringInfo str, AlterTableCmd *alter_table_cmd,
|
|
6525
6619
|
options = "DROP IDENTITY";
|
6526
6620
|
trailing_missing_ok = true;
|
6527
6621
|
break;
|
6622
|
+
case AT_SetExpression:
|
6623
|
+
appendStringInfoString(str, "ALTER COLUMN ");
|
6624
|
+
break;
|
6528
6625
|
}
|
6529
6626
|
|
6530
6627
|
if (alter_table_cmd->missing_ok && !trailing_missing_ok)
|
@@ -6539,6 +6636,9 @@ static void deparseAlterTableCmd(StringInfo str, AlterTableCmd *alter_table_cmd,
|
|
6539
6636
|
{
|
6540
6637
|
appendStringInfoString(str, quote_identifier(alter_table_cmd->name));
|
6541
6638
|
appendStringInfoChar(str, ' ');
|
6639
|
+
} else if (alter_table_cmd->subtype == AT_SetAccessMethod)
|
6640
|
+
{
|
6641
|
+
appendStringInfoString(str, " DEFAULT");
|
6542
6642
|
}
|
6543
6643
|
|
6544
6644
|
if (alter_table_cmd->num > 0)
|
@@ -6572,7 +6672,7 @@ static void deparseAlterTableCmd(StringInfo str, AlterTableCmd *alter_table_cmd,
|
|
6572
6672
|
case AT_ColumnDefault:
|
6573
6673
|
if (alter_table_cmd->def != NULL)
|
6574
6674
|
{
|
6575
|
-
deparseExpr(str, alter_table_cmd->def);
|
6675
|
+
deparseExpr(str, alter_table_cmd->def, DEPARSE_NODE_CONTEXT_A_EXPR);
|
6576
6676
|
appendStringInfoChar(str, ' ');
|
6577
6677
|
}
|
6578
6678
|
break;
|
@@ -6626,6 +6726,11 @@ static void deparseAlterTableCmd(StringInfo str, AlterTableCmd *alter_table_cmd,
|
|
6626
6726
|
deparseReplicaIdentityStmt(str, castNode(ReplicaIdentityStmt, alter_table_cmd->def));
|
6627
6727
|
appendStringInfoChar(str, ' ');
|
6628
6728
|
break;
|
6729
|
+
case AT_SetExpression:
|
6730
|
+
appendStringInfoString(str, "SET EXPRESSION AS (");
|
6731
|
+
deparseExpr(str, alter_table_cmd->def, DEPARSE_NODE_CONTEXT_A_EXPR);
|
6732
|
+
appendStringInfoChar(str, ')');
|
6733
|
+
break;
|
6629
6734
|
default:
|
6630
6735
|
Assert(alter_table_cmd->def == NULL);
|
6631
6736
|
break;
|
@@ -6731,6 +6836,7 @@ static void deparseAlterTableSpaceOptionsStmt(StringInfo str, AlterTableSpaceOpt
|
|
6731
6836
|
deparseRelOptions(str, alter_table_space_options_stmt->options);
|
6732
6837
|
}
|
6733
6838
|
|
6839
|
+
// "AlterDomainStmt" in gram.y
|
6734
6840
|
static void deparseAlterDomainStmt(StringInfo str, AlterDomainStmt *alter_domain_stmt)
|
6735
6841
|
{
|
6736
6842
|
appendStringInfoString(str, "ALTER DOMAIN ");
|
@@ -6743,7 +6849,7 @@ static void deparseAlterDomainStmt(StringInfo str, AlterDomainStmt *alter_domain
|
|
6743
6849
|
if (alter_domain_stmt->def != NULL)
|
6744
6850
|
{
|
6745
6851
|
appendStringInfoString(str, "SET DEFAULT ");
|
6746
|
-
deparseExpr(str, alter_domain_stmt->def);
|
6852
|
+
deparseExpr(str, alter_domain_stmt->def, DEPARSE_NODE_CONTEXT_A_EXPR);
|
6747
6853
|
}
|
6748
6854
|
else
|
6749
6855
|
{
|
@@ -7509,15 +7615,29 @@ static void deparseCopyStmt(StringInfo str, CopyStmt *copy_stmt)
|
|
7509
7615
|
}
|
7510
7616
|
else if (strcmp(def_elem->defname, "force_not_null") == 0)
|
7511
7617
|
{
|
7512
|
-
appendStringInfoString(str, "FORCE_NOT_NULL
|
7513
|
-
|
7514
|
-
|
7618
|
+
appendStringInfoString(str, "FORCE_NOT_NULL ");
|
7619
|
+
|
7620
|
+
if (IsA(def_elem->arg, A_Star))
|
7621
|
+
deparseAStar(str, castNode(A_Star, def_elem->arg));
|
7622
|
+
else
|
7623
|
+
{
|
7624
|
+
appendStringInfoChar(str, '(');
|
7625
|
+
deparseColumnList(str, castNode(List, def_elem->arg));
|
7626
|
+
appendStringInfoChar(str, ')');
|
7627
|
+
}
|
7515
7628
|
}
|
7516
7629
|
else if (strcmp(def_elem->defname, "force_null") == 0)
|
7517
7630
|
{
|
7518
|
-
appendStringInfoString(str, "FORCE_NULL
|
7519
|
-
|
7520
|
-
|
7631
|
+
appendStringInfoString(str, "FORCE_NULL ");
|
7632
|
+
|
7633
|
+
if (IsA(def_elem->arg, A_Star))
|
7634
|
+
deparseAStar(str, castNode(A_Star, def_elem->arg));
|
7635
|
+
else
|
7636
|
+
{
|
7637
|
+
appendStringInfoChar(str, '(');
|
7638
|
+
deparseColumnList(str, castNode(List, def_elem->arg));
|
7639
|
+
appendStringInfoChar(str, ')');
|
7640
|
+
}
|
7521
7641
|
}
|
7522
7642
|
else if (strcmp(def_elem->defname, "encoding") == 0)
|
7523
7643
|
{
|
@@ -8617,7 +8737,7 @@ static void deparseFetchStmt(StringInfo str, FetchStmt *fetch_stmt)
|
|
8617
8737
|
appendStringInfo(str, "RELATIVE %ld ", fetch_stmt->howMany);
|
8618
8738
|
}
|
8619
8739
|
|
8620
|
-
appendStringInfoString(str, fetch_stmt->portalname);
|
8740
|
+
appendStringInfoString(str, quote_identifier(fetch_stmt->portalname));
|
8621
8741
|
}
|
8622
8742
|
|
8623
8743
|
static void deparseAlterDefaultPrivilegesStmt(StringInfo str, AlterDefaultPrivilegesStmt *alter_default_privileges_stmt)
|
@@ -8955,6 +9075,7 @@ static void deparseReplicaIdentityStmt(StringInfo str, ReplicaIdentityStmt *repl
|
|
8955
9075
|
}
|
8956
9076
|
}
|
8957
9077
|
|
9078
|
+
// "CreatePolicyStmt" in gram.y
|
8958
9079
|
static void deparseCreatePolicyStmt(StringInfo str, CreatePolicyStmt *create_policy_stmt)
|
8959
9080
|
{
|
8960
9081
|
ListCell *lc = NULL;
|
@@ -8988,18 +9109,19 @@ static void deparseCreatePolicyStmt(StringInfo str, CreatePolicyStmt *create_pol
|
|
8988
9109
|
if (create_policy_stmt->qual != NULL)
|
8989
9110
|
{
|
8990
9111
|
appendStringInfoString(str, "USING (");
|
8991
|
-
deparseExpr(str, create_policy_stmt->qual);
|
9112
|
+
deparseExpr(str, create_policy_stmt->qual, DEPARSE_NODE_CONTEXT_A_EXPR);
|
8992
9113
|
appendStringInfoString(str, ") ");
|
8993
9114
|
}
|
8994
9115
|
|
8995
9116
|
if (create_policy_stmt->with_check != NULL)
|
8996
9117
|
{
|
8997
9118
|
appendStringInfoString(str, "WITH CHECK (");
|
8998
|
-
deparseExpr(str, create_policy_stmt->with_check);
|
9119
|
+
deparseExpr(str, create_policy_stmt->with_check, DEPARSE_NODE_CONTEXT_A_EXPR);
|
8999
9120
|
appendStringInfoString(str, ") ");
|
9000
9121
|
}
|
9001
9122
|
}
|
9002
9123
|
|
9124
|
+
// "AlterPolicyStmt" in gram.y
|
9003
9125
|
static void deparseAlterPolicyStmt(StringInfo str, AlterPolicyStmt *alter_policy_stmt)
|
9004
9126
|
{
|
9005
9127
|
appendStringInfoString(str, "ALTER POLICY ");
|
@@ -9018,14 +9140,14 @@ static void deparseAlterPolicyStmt(StringInfo str, AlterPolicyStmt *alter_policy
|
|
9018
9140
|
if (alter_policy_stmt->qual != NULL)
|
9019
9141
|
{
|
9020
9142
|
appendStringInfoString(str, "USING (");
|
9021
|
-
deparseExpr(str, alter_policy_stmt->qual);
|
9143
|
+
deparseExpr(str, alter_policy_stmt->qual, DEPARSE_NODE_CONTEXT_A_EXPR);
|
9022
9144
|
appendStringInfoString(str, ") ");
|
9023
9145
|
}
|
9024
9146
|
|
9025
9147
|
if (alter_policy_stmt->with_check != NULL)
|
9026
9148
|
{
|
9027
9149
|
appendStringInfoString(str, "WITH CHECK (");
|
9028
|
-
deparseExpr(str, alter_policy_stmt->with_check);
|
9150
|
+
deparseExpr(str, alter_policy_stmt->with_check, DEPARSE_NODE_CONTEXT_A_EXPR);
|
9029
9151
|
appendStringInfoString(str, ") ");
|
9030
9152
|
}
|
9031
9153
|
}
|
@@ -9112,6 +9234,7 @@ static void deparseCreateAmStmt(StringInfo str, CreateAmStmt *create_am_stmt)
|
|
9112
9234
|
deparseHandlerName(str, create_am_stmt->handler_name);
|
9113
9235
|
}
|
9114
9236
|
|
9237
|
+
// "pub_obj_list" in gram.y
|
9115
9238
|
static void deparsePublicationObjectList(StringInfo str, List *pubobjects) {
|
9116
9239
|
const ListCell *lc;
|
9117
9240
|
foreach(lc, pubobjects) {
|
@@ -9132,7 +9255,7 @@ static void deparsePublicationObjectList(StringInfo str, List *pubobjects) {
|
|
9132
9255
|
if (obj->pubtable->whereClause)
|
9133
9256
|
{
|
9134
9257
|
appendStringInfoString(str, " WHERE (");
|
9135
|
-
deparseExpr(str, obj->pubtable->whereClause);
|
9258
|
+
deparseExpr(str, obj->pubtable->whereClause, DEPARSE_NODE_CONTEXT_A_EXPR);
|
9136
9259
|
appendStringInfoString(str, ")");
|
9137
9260
|
}
|
9138
9261
|
|
@@ -9481,6 +9604,7 @@ static void deparseCommentStmt(StringInfo str, CommentStmt *comment_stmt)
|
|
9481
9604
|
appendStringInfoString(str, "NULL");
|
9482
9605
|
}
|
9483
9606
|
|
9607
|
+
// "stats_param" in gram.y
|
9484
9608
|
static void deparseStatsElem(StringInfo str, StatsElem *stats_elem)
|
9485
9609
|
{
|
9486
9610
|
// only one of stats_elem->name or stats_elem->expr can be non-null
|
@@ -9489,7 +9613,7 @@ static void deparseStatsElem(StringInfo str, StatsElem *stats_elem)
|
|
9489
9613
|
else if (stats_elem->expr)
|
9490
9614
|
{
|
9491
9615
|
appendStringInfoChar(str, '(');
|
9492
|
-
deparseExpr(str, stats_elem->expr);
|
9616
|
+
deparseExpr(str, stats_elem->expr, DEPARSE_NODE_CONTEXT_A_EXPR);
|
9493
9617
|
appendStringInfoChar(str, ')');
|
9494
9618
|
}
|
9495
9619
|
}
|
@@ -9559,7 +9683,10 @@ static void deparseAlterStatsStmt(StringInfo str, AlterStatsStmt *alter_stats_st
|
|
9559
9683
|
deparseAnyName(str, alter_stats_stmt->defnames);
|
9560
9684
|
appendStringInfoChar(str, ' ');
|
9561
9685
|
|
9562
|
-
|
9686
|
+
if (alter_stats_stmt->stxstattarget)
|
9687
|
+
appendStringInfo(str, "SET STATISTICS %d", castNode(Integer, alter_stats_stmt->stxstattarget)->ival);
|
9688
|
+
else
|
9689
|
+
appendStringInfo(str, "SET STATISTICS DEFAULT");
|
9563
9690
|
}
|
9564
9691
|
|
9565
9692
|
static void deparseAlterTSDictionaryStmt(StringInfo str, AlterTSDictionaryStmt *alter_ts_dictionary_stmt)
|
@@ -9634,6 +9761,7 @@ static void deparseVariableShowStmt(StringInfo str, VariableShowStmt *variable_s
|
|
9634
9761
|
appendStringInfoString(str, quote_identifier(variable_show_stmt->name));
|
9635
9762
|
}
|
9636
9763
|
|
9764
|
+
// "tablesample_clause" in gram.y
|
9637
9765
|
static void deparseRangeTableSample(StringInfo str, RangeTableSample *range_table_sample)
|
9638
9766
|
{
|
9639
9767
|
deparseRangeVar(str, castNode(RangeVar, range_table_sample->relation), DEPARSE_NODE_CONTEXT_NONE);
|
@@ -9648,7 +9776,7 @@ static void deparseRangeTableSample(StringInfo str, RangeTableSample *range_tabl
|
|
9648
9776
|
if (range_table_sample->repeatable != NULL)
|
9649
9777
|
{
|
9650
9778
|
appendStringInfoString(str, "REPEATABLE (");
|
9651
|
-
deparseExpr(str, range_table_sample->repeatable);
|
9779
|
+
deparseExpr(str, range_table_sample->repeatable, DEPARSE_NODE_CONTEXT_A_EXPR);
|
9652
9780
|
appendStringInfoString(str, ") ");
|
9653
9781
|
}
|
9654
9782
|
|
@@ -9773,7 +9901,7 @@ static void deparseDropSubscriptionStmt(StringInfo str, DropSubscriptionStmt *dr
|
|
9773
9901
|
static void deparseCallStmt(StringInfo str, CallStmt *call_stmt)
|
9774
9902
|
{
|
9775
9903
|
appendStringInfoString(str, "CALL ");
|
9776
|
-
deparseFuncCall(str, call_stmt->funccall);
|
9904
|
+
deparseFuncCall(str, call_stmt->funccall, DEPARSE_NODE_CONTEXT_NONE);
|
9777
9905
|
}
|
9778
9906
|
|
9779
9907
|
static void deparseAlterOwnerStmt(StringInfo str, AlterOwnerStmt *alter_owner_stmt)
|
@@ -9965,6 +10093,7 @@ static void deparseClosePortalStmt(StringInfo str, ClosePortalStmt *close_portal
|
|
9965
10093
|
}
|
9966
10094
|
}
|
9967
10095
|
|
10096
|
+
// "CreateTrigStmt" in gram.y
|
9968
10097
|
static void deparseCreateTrigStmt(StringInfo str, CreateTrigStmt *create_trig_stmt)
|
9969
10098
|
{
|
9970
10099
|
ListCell *lc;
|
@@ -10060,7 +10189,7 @@ static void deparseCreateTrigStmt(StringInfo str, CreateTrigStmt *create_trig_st
|
|
10060
10189
|
if (create_trig_stmt->whenClause)
|
10061
10190
|
{
|
10062
10191
|
appendStringInfoString(str, "WHEN (");
|
10063
|
-
deparseExpr(str, create_trig_stmt->whenClause);
|
10192
|
+
deparseExpr(str, create_trig_stmt->whenClause, DEPARSE_NODE_CONTEXT_A_EXPR);
|
10064
10193
|
appendStringInfoString(str, ") ");
|
10065
10194
|
}
|
10066
10195
|
|
@@ -10091,7 +10220,7 @@ static void deparseTriggerTransition(StringInfo str, TriggerTransition *trigger_
|
|
10091
10220
|
appendStringInfoString(str, quote_identifier(trigger_transition->name));
|
10092
10221
|
}
|
10093
10222
|
|
10094
|
-
static void deparseXmlExpr(StringInfo str, XmlExpr* xml_expr)
|
10223
|
+
static void deparseXmlExpr(StringInfo str, XmlExpr* xml_expr, DeparseNodeContext context)
|
10095
10224
|
{
|
10096
10225
|
switch (xml_expr->op)
|
10097
10226
|
{
|
@@ -10135,7 +10264,7 @@ static void deparseXmlExpr(StringInfo str, XmlExpr* xml_expr)
|
|
10135
10264
|
default:
|
10136
10265
|
Assert(false);
|
10137
10266
|
}
|
10138
|
-
deparseExpr(str, linitial(xml_expr->args));
|
10267
|
+
deparseExpr(str, linitial(xml_expr->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
10139
10268
|
appendStringInfoChar(str, ')');
|
10140
10269
|
break;
|
10141
10270
|
case IS_XMLPI: /* XMLPI(name [, args]) */
|
@@ -10144,18 +10273,18 @@ static void deparseXmlExpr(StringInfo str, XmlExpr* xml_expr)
|
|
10144
10273
|
if (xml_expr->args != NULL)
|
10145
10274
|
{
|
10146
10275
|
appendStringInfoString(str, ", ");
|
10147
|
-
deparseExpr(str, linitial(xml_expr->args));
|
10276
|
+
deparseExpr(str, linitial(xml_expr->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
10148
10277
|
}
|
10149
10278
|
appendStringInfoChar(str, ')');
|
10150
10279
|
break;
|
10151
10280
|
case IS_XMLROOT: /* XMLROOT(xml, version, standalone) */
|
10152
10281
|
appendStringInfoString(str, "xmlroot(");
|
10153
|
-
deparseExpr(str, linitial(xml_expr->args));
|
10282
|
+
deparseExpr(str, linitial(xml_expr->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
10154
10283
|
appendStringInfoString(str, ", version ");
|
10155
10284
|
if (castNode(A_Const, lsecond(xml_expr->args))->isnull)
|
10156
10285
|
appendStringInfoString(str, "NO VALUE");
|
10157
10286
|
else
|
10158
|
-
deparseExpr(str, lsecond(xml_expr->args));
|
10287
|
+
deparseExpr(str, lsecond(xml_expr->args), DEPARSE_NODE_CONTEXT_A_EXPR);
|
10159
10288
|
if (intVal(&castNode(A_Const, lthird(xml_expr->args))->val) == XML_STANDALONE_YES)
|
10160
10289
|
appendStringInfoString(str, ", STANDALONE YES");
|
10161
10290
|
else if (intVal(&castNode(A_Const, lthird(xml_expr->args))->val) == XML_STANDALONE_NO)
|
@@ -10170,12 +10299,13 @@ static void deparseXmlExpr(StringInfo str, XmlExpr* xml_expr)
|
|
10170
10299
|
break;
|
10171
10300
|
case IS_DOCUMENT: /* xmlval IS DOCUMENT */
|
10172
10301
|
Assert(list_length(xml_expr->args) == 1);
|
10173
|
-
deparseExpr(str, linitial(xml_expr->args));
|
10302
|
+
deparseExpr(str, linitial(xml_expr->args), context);
|
10174
10303
|
appendStringInfoString(str, " IS DOCUMENT");
|
10175
10304
|
break;
|
10176
10305
|
}
|
10177
10306
|
}
|
10178
10307
|
|
10308
|
+
// "xmltable_column_el" in gram.y
|
10179
10309
|
static void deparseRangeTableFuncCol(StringInfo str, RangeTableFuncCol* range_table_func_col)
|
10180
10310
|
{
|
10181
10311
|
appendStringInfoString(str, quote_identifier(range_table_func_col->colname));
|
@@ -10193,14 +10323,14 @@ static void deparseRangeTableFuncCol(StringInfo str, RangeTableFuncCol* range_ta
|
|
10193
10323
|
if (range_table_func_col->colexpr)
|
10194
10324
|
{
|
10195
10325
|
appendStringInfoString(str, "PATH ");
|
10196
|
-
deparseExpr(str, range_table_func_col->colexpr);
|
10326
|
+
deparseExpr(str, range_table_func_col->colexpr, DEPARSE_NODE_CONTEXT_NONE /* b_expr */);
|
10197
10327
|
appendStringInfoChar(str, ' ');
|
10198
10328
|
}
|
10199
10329
|
|
10200
10330
|
if (range_table_func_col->coldefexpr)
|
10201
10331
|
{
|
10202
10332
|
appendStringInfoString(str, "DEFAULT ");
|
10203
|
-
deparseExpr(str, range_table_func_col->coldefexpr);
|
10333
|
+
deparseExpr(str, range_table_func_col->coldefexpr, DEPARSE_NODE_CONTEXT_NONE /* b_expr */);
|
10204
10334
|
appendStringInfoChar(str, ' ');
|
10205
10335
|
}
|
10206
10336
|
|
@@ -10211,6 +10341,7 @@ static void deparseRangeTableFuncCol(StringInfo str, RangeTableFuncCol* range_ta
|
|
10211
10341
|
removeTrailingSpace(str);
|
10212
10342
|
}
|
10213
10343
|
|
10344
|
+
// "table_ref" and "xmltable" in gram.y
|
10214
10345
|
static void deparseRangeTableFunc(StringInfo str, RangeTableFunc* range_table_func)
|
10215
10346
|
{
|
10216
10347
|
ListCell *lc;
|
@@ -10227,11 +10358,11 @@ static void deparseRangeTableFunc(StringInfo str, RangeTableFunc* range_table_fu
|
|
10227
10358
|
}
|
10228
10359
|
|
10229
10360
|
appendStringInfoChar(str, '(');
|
10230
|
-
deparseExpr(str, range_table_func->rowexpr);
|
10361
|
+
deparseExpr(str, range_table_func->rowexpr, DEPARSE_NODE_CONTEXT_NONE /* c_expr */);
|
10231
10362
|
appendStringInfoChar(str, ')');
|
10232
10363
|
|
10233
10364
|
appendStringInfoString(str, " PASSING ");
|
10234
|
-
deparseExpr(str, range_table_func->docexpr);
|
10365
|
+
deparseExpr(str, range_table_func->docexpr, DEPARSE_NODE_CONTEXT_NONE /* c_expr */);
|
10235
10366
|
|
10236
10367
|
appendStringInfoString(str, " COLUMNS ");
|
10237
10368
|
foreach(lc, range_table_func->columns)
|
@@ -10266,7 +10397,7 @@ static void deparseXmlSerialize(StringInfo str, XmlSerialize *xml_serialize)
|
|
10266
10397
|
default:
|
10267
10398
|
Assert(false);
|
10268
10399
|
}
|
10269
|
-
deparseExpr(str, xml_serialize->expr);
|
10400
|
+
deparseExpr(str, xml_serialize->expr, DEPARSE_NODE_CONTEXT_A_EXPR);
|
10270
10401
|
appendStringInfoString(str, " AS ");
|
10271
10402
|
deparseTypeName(str, xml_serialize->typeName);
|
10272
10403
|
|
@@ -10303,7 +10434,7 @@ static void deparseJsonFormat(StringInfo str, JsonFormat *json_format)
|
|
10303
10434
|
|
10304
10435
|
static void deparseJsonIsPredicate(StringInfo str, JsonIsPredicate *j)
|
10305
10436
|
{
|
10306
|
-
deparseExpr(str, j->expr);
|
10437
|
+
deparseExpr(str, j->expr, DEPARSE_NODE_CONTEXT_A_EXPR);
|
10307
10438
|
appendStringInfoChar(str, ' ');
|
10308
10439
|
|
10309
10440
|
deparseJsonFormat(str, castNode(JsonFormat, j->format));
|
@@ -10335,7 +10466,7 @@ static void deparseJsonIsPredicate(StringInfo str, JsonIsPredicate *j)
|
|
10335
10466
|
// "json_value_expr" in gram.y
|
10336
10467
|
static void deparseJsonValueExpr(StringInfo str, JsonValueExpr *json_value_expr)
|
10337
10468
|
{
|
10338
|
-
deparseExpr(str, (Node *) json_value_expr->raw_expr);
|
10469
|
+
deparseExpr(str, (Node *) json_value_expr->raw_expr, DEPARSE_NODE_CONTEXT_A_EXPR);
|
10339
10470
|
appendStringInfoChar(str, ' ');
|
10340
10471
|
deparseJsonFormat(str, json_value_expr->format);
|
10341
10472
|
}
|
@@ -10357,7 +10488,7 @@ static void deparseJsonValueExprList(StringInfo str, List *exprs)
|
|
10357
10488
|
// "json_name_and_value" in gram.y
|
10358
10489
|
static void deparseJsonKeyValue(StringInfo str, JsonKeyValue *json_key_value)
|
10359
10490
|
{
|
10360
|
-
deparseExpr(str, (Node *) json_key_value->key);
|
10491
|
+
deparseExpr(str, (Node *) json_key_value->key, DEPARSE_NODE_CONTEXT_A_EXPR);
|
10361
10492
|
appendStringInfoString(str, ": ");
|
10362
10493
|
deparseJsonValueExpr(str, json_key_value->value);
|
10363
10494
|
}
|
@@ -10389,6 +10520,7 @@ static void deparseJsonOutput(StringInfo str, JsonOutput *json_output)
|
|
10389
10520
|
deparseJsonFormat(str, json_output->returning->format);
|
10390
10521
|
}
|
10391
10522
|
|
10523
|
+
// "json_aggregate_func" and "func_expr" in gram.y
|
10392
10524
|
static void deparseJsonObjectAgg(StringInfo str, JsonObjectAgg *json_object_agg)
|
10393
10525
|
{
|
10394
10526
|
Assert(json_object_agg->constructor != NULL);
|
@@ -10410,7 +10542,7 @@ static void deparseJsonObjectAgg(StringInfo str, JsonObjectAgg *json_object_agg)
|
|
10410
10542
|
if (json_object_agg->constructor->agg_filter)
|
10411
10543
|
{
|
10412
10544
|
appendStringInfoString(str, "FILTER (WHERE ");
|
10413
|
-
deparseExpr(str, json_object_agg->constructor->agg_filter);
|
10545
|
+
deparseExpr(str, json_object_agg->constructor->agg_filter, DEPARSE_NODE_CONTEXT_A_EXPR);
|
10414
10546
|
appendStringInfoString(str, ") ");
|
10415
10547
|
}
|
10416
10548
|
|
@@ -10427,6 +10559,7 @@ static void deparseJsonObjectAgg(StringInfo str, JsonObjectAgg *json_object_agg)
|
|
10427
10559
|
removeTrailingSpace(str);
|
10428
10560
|
}
|
10429
10561
|
|
10562
|
+
// "json_aggregate_func" and "func_expr" in gram.y
|
10430
10563
|
static void deparseJsonArrayAgg(StringInfo str, JsonArrayAgg *json_array_agg)
|
10431
10564
|
{
|
10432
10565
|
Assert(json_array_agg->constructor != NULL);
|
@@ -10446,7 +10579,7 @@ static void deparseJsonArrayAgg(StringInfo str, JsonArrayAgg *json_array_agg)
|
|
10446
10579
|
if (json_array_agg->constructor->agg_filter)
|
10447
10580
|
{
|
10448
10581
|
appendStringInfoString(str, "FILTER (WHERE ");
|
10449
|
-
deparseExpr(str, json_array_agg->constructor->agg_filter);
|
10582
|
+
deparseExpr(str, json_array_agg->constructor->agg_filter, DEPARSE_NODE_CONTEXT_A_EXPR);
|
10450
10583
|
appendStringInfoString(str, ") ");
|
10451
10584
|
}
|
10452
10585
|
|
@@ -10506,6 +10639,302 @@ static void deparseJsonArrayQueryConstructor(StringInfo str, JsonArrayQueryConst
|
|
10506
10639
|
appendStringInfoChar(str, ')');
|
10507
10640
|
}
|
10508
10641
|
|
10642
|
+
static void deparseJsonParseExpr(StringInfo str, JsonParseExpr *json_parse_expr)
|
10643
|
+
{
|
10644
|
+
appendStringInfoString(str, "JSON(");
|
10645
|
+
|
10646
|
+
deparseJsonValueExpr(str, json_parse_expr->expr);
|
10647
|
+
|
10648
|
+
if (json_parse_expr->unique_keys)
|
10649
|
+
appendStringInfoString(str, " WITH UNIQUE KEYS");
|
10650
|
+
|
10651
|
+
appendStringInfoString(str, ")");
|
10652
|
+
}
|
10653
|
+
|
10654
|
+
static void deparseJsonScalarExpr(StringInfo str, JsonScalarExpr *json_scalar_expr)
|
10655
|
+
{
|
10656
|
+
appendStringInfoString(str, "JSON_SCALAR(");
|
10657
|
+
deparseExpr(str, (Node*) json_scalar_expr->expr, DEPARSE_NODE_CONTEXT_A_EXPR);
|
10658
|
+
appendStringInfoString(str, ")");
|
10659
|
+
}
|
10660
|
+
|
10661
|
+
static void deparseJsonSerializeExpr(StringInfo str, JsonSerializeExpr *json_serialize_expr)
|
10662
|
+
{
|
10663
|
+
appendStringInfoString(str, "JSON_SERIALIZE(");
|
10664
|
+
|
10665
|
+
deparseJsonValueExpr(str, json_serialize_expr->expr);
|
10666
|
+
|
10667
|
+
if (json_serialize_expr->output)
|
10668
|
+
deparseJsonOutput(str, json_serialize_expr->output);
|
10669
|
+
|
10670
|
+
appendStringInfoString(str, ")");
|
10671
|
+
}
|
10672
|
+
|
10673
|
+
static void deparseJsonQuotesClauseOpt(StringInfo str, JsonQuotes quotes)
|
10674
|
+
{
|
10675
|
+
switch (quotes)
|
10676
|
+
{
|
10677
|
+
case JS_QUOTES_UNSPEC:
|
10678
|
+
break;
|
10679
|
+
case JS_QUOTES_KEEP:
|
10680
|
+
appendStringInfoString(str, " KEEP QUOTES");
|
10681
|
+
break;
|
10682
|
+
case JS_QUOTES_OMIT:
|
10683
|
+
appendStringInfoString(str, " OMIT QUOTES");
|
10684
|
+
break;
|
10685
|
+
}
|
10686
|
+
}
|
10687
|
+
|
10688
|
+
static void deparseJsonOnErrorClauseOpt(StringInfo str, JsonBehavior *behavior)
|
10689
|
+
{
|
10690
|
+
if (!behavior)
|
10691
|
+
return;
|
10692
|
+
|
10693
|
+
appendStringInfoChar(str, ' ');
|
10694
|
+
deparseJsonBehavior(str, behavior);
|
10695
|
+
appendStringInfoString(str, " ON ERROR");
|
10696
|
+
}
|
10697
|
+
|
10698
|
+
static void deparseJsonOnEmptyClauseOpt(StringInfo str, JsonBehavior *behavior)
|
10699
|
+
{
|
10700
|
+
if (behavior)
|
10701
|
+
{
|
10702
|
+
appendStringInfoChar(str, ' ');
|
10703
|
+
deparseJsonBehavior(str, behavior);
|
10704
|
+
appendStringInfoString(str, " ON EMPTY");
|
10705
|
+
}
|
10706
|
+
}
|
10707
|
+
|
10708
|
+
static void deparseJsonFuncExpr(StringInfo str, JsonFuncExpr *json_func_expr)
|
10709
|
+
{
|
10710
|
+
switch (json_func_expr->op)
|
10711
|
+
{
|
10712
|
+
case JSON_EXISTS_OP:
|
10713
|
+
appendStringInfoString(str, "JSON_EXISTS(");
|
10714
|
+
break;
|
10715
|
+
case JSON_QUERY_OP:
|
10716
|
+
appendStringInfoString(str, "JSON_QUERY(");
|
10717
|
+
break;
|
10718
|
+
case JSON_VALUE_OP:
|
10719
|
+
appendStringInfoString(str, "JSON_VALUE(");
|
10720
|
+
break;
|
10721
|
+
case JSON_TABLE_OP:
|
10722
|
+
appendStringInfoString(str, "JSON_TABLE(");
|
10723
|
+
break;
|
10724
|
+
}
|
10725
|
+
|
10726
|
+
deparseJsonValueExpr(str, json_func_expr->context_item);
|
10727
|
+
appendStringInfoString(str, ", ");
|
10728
|
+
deparseExpr(str, json_func_expr->pathspec, DEPARSE_NODE_CONTEXT_A_EXPR);
|
10729
|
+
|
10730
|
+
if (json_func_expr->passing)
|
10731
|
+
appendStringInfoString(str, " PASSING ");
|
10732
|
+
|
10733
|
+
ListCell *lc = NULL;
|
10734
|
+
foreach (lc, json_func_expr->passing)
|
10735
|
+
{
|
10736
|
+
JsonArgument *json_argument = castNode(JsonArgument, lfirst(lc));
|
10737
|
+
deparseJsonValueExpr(str, json_argument->val);
|
10738
|
+
appendStringInfoString(str, " AS ");
|
10739
|
+
deparseColLabel(str, json_argument->name);
|
10740
|
+
|
10741
|
+
if (lnext(json_func_expr->passing, lc))
|
10742
|
+
appendStringInfoString(str, ", ");
|
10743
|
+
}
|
10744
|
+
|
10745
|
+
if (json_func_expr->output)
|
10746
|
+
{
|
10747
|
+
appendStringInfoChar(str, ' ');
|
10748
|
+
deparseJsonOutput(str, json_func_expr->output);
|
10749
|
+
}
|
10750
|
+
|
10751
|
+
switch (json_func_expr->wrapper)
|
10752
|
+
{
|
10753
|
+
case JSW_UNSPEC:
|
10754
|
+
break;
|
10755
|
+
case JSW_NONE:
|
10756
|
+
appendStringInfoString(str, " WITHOUT WRAPPER");
|
10757
|
+
break;
|
10758
|
+
case JSW_CONDITIONAL:
|
10759
|
+
appendStringInfoString(str, " WITH CONDITIONAL WRAPPER");
|
10760
|
+
break;
|
10761
|
+
case JSW_UNCONDITIONAL:
|
10762
|
+
appendStringInfoString(str, " WITH UNCONDITIONAL WRAPPER");
|
10763
|
+
break;
|
10764
|
+
}
|
10765
|
+
|
10766
|
+
deparseJsonQuotesClauseOpt(str, json_func_expr->quotes);
|
10767
|
+
deparseJsonOnEmptyClauseOpt(str, json_func_expr->on_empty);
|
10768
|
+
deparseJsonOnErrorClauseOpt(str, json_func_expr->on_error);
|
10769
|
+
|
10770
|
+
appendStringInfoChar(str, ')');
|
10771
|
+
}
|
10772
|
+
|
10773
|
+
static void deparseJsonTablePathSpec(StringInfo str, JsonTablePathSpec *json_table_path_spec)
|
10774
|
+
{
|
10775
|
+
deparseStringLiteral(str, castNode(A_Const, json_table_path_spec->string)->val.sval.sval);
|
10776
|
+
|
10777
|
+
if (json_table_path_spec->name)
|
10778
|
+
{
|
10779
|
+
appendStringInfoString(str, " AS ");
|
10780
|
+
deparseColLabel(str, json_table_path_spec->name);
|
10781
|
+
}
|
10782
|
+
}
|
10783
|
+
|
10784
|
+
// "json_behavior" in gram.y
|
10785
|
+
static void deparseJsonBehavior(StringInfo str, JsonBehavior *json_behavior)
|
10786
|
+
{
|
10787
|
+
switch (json_behavior->btype)
|
10788
|
+
{
|
10789
|
+
case JSON_BEHAVIOR_NULL:
|
10790
|
+
appendStringInfoString(str, "NULL");
|
10791
|
+
break;
|
10792
|
+
case JSON_BEHAVIOR_ERROR:
|
10793
|
+
appendStringInfoString(str, "ERROR");
|
10794
|
+
break;
|
10795
|
+
case JSON_BEHAVIOR_EMPTY:
|
10796
|
+
appendStringInfoString(str, "EMPTY");
|
10797
|
+
break;
|
10798
|
+
case JSON_BEHAVIOR_TRUE:
|
10799
|
+
appendStringInfoString(str, "TRUE");
|
10800
|
+
break;
|
10801
|
+
case JSON_BEHAVIOR_FALSE:
|
10802
|
+
appendStringInfoString(str, "FALSE");
|
10803
|
+
break;
|
10804
|
+
case JSON_BEHAVIOR_EMPTY_ARRAY:
|
10805
|
+
appendStringInfoString(str, "EMPTY ARRAY");
|
10806
|
+
break;
|
10807
|
+
case JSON_BEHAVIOR_EMPTY_OBJECT:
|
10808
|
+
appendStringInfoString(str, "EMPTY OBJECT");
|
10809
|
+
break;
|
10810
|
+
case JSON_BEHAVIOR_DEFAULT:
|
10811
|
+
appendStringInfoString(str, "DEFAULT ");
|
10812
|
+
deparseExpr(str, (Node*) json_behavior->expr, DEPARSE_NODE_CONTEXT_A_EXPR);
|
10813
|
+
break;
|
10814
|
+
case JSON_BEHAVIOR_UNKNOWN:
|
10815
|
+
appendStringInfoString(str, "UNKNOWN");
|
10816
|
+
break;
|
10817
|
+
}
|
10818
|
+
}
|
10819
|
+
|
10820
|
+
static void deparseJsonTableColumn(StringInfo str, JsonTableColumn *json_table_column)
|
10821
|
+
{
|
10822
|
+
if (json_table_column->coltype == JTC_NESTED)
|
10823
|
+
{
|
10824
|
+
appendStringInfoString(str, "NESTED PATH ");
|
10825
|
+
deparseJsonTablePathSpec(str, json_table_column->pathspec);
|
10826
|
+
deparseJsonTableColumns(str, json_table_column->columns);
|
10827
|
+
return;
|
10828
|
+
}
|
10829
|
+
|
10830
|
+
deparseColLabel(str, json_table_column->name);
|
10831
|
+
appendStringInfoChar(str, ' ');
|
10832
|
+
|
10833
|
+
switch (json_table_column->coltype)
|
10834
|
+
{
|
10835
|
+
case JTC_FOR_ORDINALITY:
|
10836
|
+
appendStringInfoString(str, " FOR ORDINALITY");
|
10837
|
+
break;
|
10838
|
+
case JTC_EXISTS:
|
10839
|
+
case JTC_FORMATTED:
|
10840
|
+
case JTC_REGULAR:
|
10841
|
+
deparseTypeName(str, json_table_column->typeName);
|
10842
|
+
|
10843
|
+
if (json_table_column->coltype == JTC_EXISTS)
|
10844
|
+
appendStringInfoString(str, " EXISTS ");
|
10845
|
+
else
|
10846
|
+
appendStringInfoChar(str, ' ');
|
10847
|
+
|
10848
|
+
if (json_table_column->format)
|
10849
|
+
deparseJsonFormat(str, json_table_column->format);
|
10850
|
+
|
10851
|
+
if (json_table_column->pathspec)
|
10852
|
+
{
|
10853
|
+
appendStringInfoString(str, "PATH ");
|
10854
|
+
deparseJsonTablePathSpec(str, json_table_column->pathspec);
|
10855
|
+
}
|
10856
|
+
break;
|
10857
|
+
case JTC_NESTED:
|
10858
|
+
Assert(false);
|
10859
|
+
}
|
10860
|
+
|
10861
|
+
switch (json_table_column->wrapper)
|
10862
|
+
{
|
10863
|
+
case JSW_UNSPEC:
|
10864
|
+
break;
|
10865
|
+
case JSW_NONE:
|
10866
|
+
if (json_table_column->coltype == JTC_REGULAR || json_table_column->coltype == JTC_FORMATTED)
|
10867
|
+
appendStringInfoString(str, " WITHOUT WRAPPER");
|
10868
|
+
break;
|
10869
|
+
case JSW_CONDITIONAL:
|
10870
|
+
appendStringInfoString(str, " WITH CONDITIONAL WRAPPER");
|
10871
|
+
break;
|
10872
|
+
case JSW_UNCONDITIONAL:
|
10873
|
+
appendStringInfoString(str, " WITH UNCONDITIONAL WRAPPER");
|
10874
|
+
break;
|
10875
|
+
}
|
10876
|
+
|
10877
|
+
deparseJsonQuotesClauseOpt(str, json_table_column->quotes);
|
10878
|
+
deparseJsonOnEmptyClauseOpt(str, json_table_column->on_empty);
|
10879
|
+
deparseJsonOnErrorClauseOpt(str, json_table_column->on_error);
|
10880
|
+
}
|
10881
|
+
|
10882
|
+
static void deparseJsonTableColumns(StringInfo str, List *json_table_columns)
|
10883
|
+
{
|
10884
|
+
appendStringInfoString(str, " COLUMNS (");
|
10885
|
+
|
10886
|
+
ListCell *lc = NULL;
|
10887
|
+
foreach(lc, json_table_columns)
|
10888
|
+
{
|
10889
|
+
deparseJsonTableColumn(str, castNode(JsonTableColumn, lfirst(lc)));
|
10890
|
+
|
10891
|
+
if (lnext(json_table_columns, lc))
|
10892
|
+
appendStringInfoString(str, ", ");
|
10893
|
+
}
|
10894
|
+
|
10895
|
+
appendStringInfoChar(str, ')');
|
10896
|
+
}
|
10897
|
+
|
10898
|
+
static void deparseJsonTable(StringInfo str, JsonTable *json_table)
|
10899
|
+
{
|
10900
|
+
appendStringInfoString(str, "JSON_TABLE(");
|
10901
|
+
|
10902
|
+
deparseJsonValueExpr(str, json_table->context_item);
|
10903
|
+
appendStringInfoString(str, ", ");
|
10904
|
+
deparseJsonTablePathSpec(str, json_table->pathspec);
|
10905
|
+
|
10906
|
+
if (json_table->passing)
|
10907
|
+
appendStringInfoString(str, " PASSING ");
|
10908
|
+
|
10909
|
+
ListCell *lc = NULL;
|
10910
|
+
foreach (lc, json_table->passing)
|
10911
|
+
{
|
10912
|
+
JsonArgument *json_argument = castNode(JsonArgument, lfirst(lc));
|
10913
|
+
deparseJsonValueExpr(str, json_argument->val);
|
10914
|
+
appendStringInfoString(str, " AS ");
|
10915
|
+
deparseColLabel(str, json_argument->name);
|
10916
|
+
|
10917
|
+
if (lnext(json_table->passing, lc))
|
10918
|
+
appendStringInfoString(str, ", ");
|
10919
|
+
}
|
10920
|
+
|
10921
|
+
deparseJsonTableColumns(str, json_table->columns);
|
10922
|
+
|
10923
|
+
if (json_table->on_error)
|
10924
|
+
{
|
10925
|
+
deparseJsonBehavior(str, json_table->on_error);
|
10926
|
+
appendStringInfoString(str, " ON ERROR");
|
10927
|
+
}
|
10928
|
+
|
10929
|
+
appendStringInfoChar(str, ')');
|
10930
|
+
|
10931
|
+
if (json_table->alias)
|
10932
|
+
{
|
10933
|
+
appendStringInfoChar(str, ' ');
|
10934
|
+
deparseAlias(str, json_table->alias);
|
10935
|
+
}
|
10936
|
+
}
|
10937
|
+
|
10509
10938
|
static void deparseGroupingFunc(StringInfo str, GroupingFunc *grouping_func)
|
10510
10939
|
{
|
10511
10940
|
appendStringInfoString(str, "GROUPING(");
|