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
@@ -397,7 +397,7 @@
|
|
397
397
|
*
|
398
398
|
* pl_gram.y - Parser for the PL/pgSQL procedural language
|
399
399
|
*
|
400
|
-
* Portions Copyright (c) 1996-
|
400
|
+
* Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
|
401
401
|
* Portions Copyright (c) 1994, Regents of the University of California
|
402
402
|
*
|
403
403
|
*
|
@@ -460,7 +460,6 @@ static PLpgSQL_expr *read_sql_construct(int until,
|
|
460
460
|
RawParseMode parsemode,
|
461
461
|
bool isexpression,
|
462
462
|
bool valid_sql,
|
463
|
-
bool trim,
|
464
463
|
int *startloc,
|
465
464
|
int *endtoken);
|
466
465
|
static PLpgSQL_expr *read_sql_expression(int until,
|
@@ -470,7 +469,8 @@ static PLpgSQL_expr *read_sql_expression2(int until, int until2,
|
|
470
469
|
int *endtoken);
|
471
470
|
static PLpgSQL_expr *read_sql_stmt(void);
|
472
471
|
static PLpgSQL_type *read_datatype(int tok);
|
473
|
-
static PLpgSQL_stmt *make_execsql_stmt(int firsttoken, int location
|
472
|
+
static PLpgSQL_stmt *make_execsql_stmt(int firsttoken, int location,
|
473
|
+
PLword *word);
|
474
474
|
static PLpgSQL_stmt_fetch *read_fetch_direction(void);
|
475
475
|
static void complete_direction(PLpgSQL_stmt_fetch *fetch,
|
476
476
|
bool *check_FROM);
|
@@ -986,14 +986,14 @@ static const yytype_uint16 yyrline[] =
|
|
986
986
|
397, 401, 406, 407, 410, 433, 441, 448, 457, 469,
|
987
987
|
470, 473, 474, 478, 491, 529, 535, 534, 561, 564,
|
988
988
|
568, 575, 581, 584, 615, 619, 625, 633, 634, 636,
|
989
|
-
651, 666, 694, 722, 753, 754, 759,
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
989
|
+
651, 666, 694, 722, 753, 754, 759, 771, 772, 777,
|
990
|
+
782, 789, 790, 794, 796, 802, 803, 811, 812, 816,
|
991
|
+
817, 827, 829, 831, 833, 835, 837, 839, 841, 843,
|
992
|
+
845, 847, 849, 851, 853, 855, 857, 859, 861, 863,
|
993
|
+
865, 867, 869, 871, 873, 877, 913, 931, 952, 991,
|
994
|
+
1055, 1058, 1062, 1068, 1072, 1078, 1091, 1138, 1156, 1161,
|
995
|
+
1168, 1186, 1189, 1203, 1206, 1212, 1219, 1233, 1237, 1243,
|
996
|
+
1255, 1258, 1273, 1291, 1310, 1344, 1602, 1628, 1642, 1649,
|
997
997
|
1688, 1691, 1697, 1750, 1754, 1760, 1786, 1931, 1955, 1973,
|
998
998
|
1977, 1981, 1985, 1996, 2009, 2073, 2151, 2181, 2194, 2199,
|
999
999
|
2213, 2220, 2234, 2249, 2250, 2251, 2255, 2277, 2282, 2290,
|
@@ -2877,8 +2877,9 @@ yyreduce:
|
|
2877
2877
|
#line 759 "pl_gram.y"
|
2878
2878
|
{
|
2879
2879
|
/*
|
2880
|
-
* If there's a lookahead token, read_datatype
|
2881
|
-
*
|
2880
|
+
* If there's a lookahead token, read_datatype() will
|
2881
|
+
* consume it, and then we must tell bison to forget
|
2882
|
+
* it.
|
2882
2883
|
*/
|
2883
2884
|
(yyval.dtype) = read_datatype(yychar);
|
2884
2885
|
yyclearin;
|
@@ -2886,12 +2887,12 @@ yyreduce:
|
|
2886
2887
|
break;
|
2887
2888
|
|
2888
2889
|
case 47:
|
2889
|
-
#line
|
2890
|
+
#line 771 "pl_gram.y"
|
2890
2891
|
{ (yyval.oid) = InvalidOid; ;}
|
2891
2892
|
break;
|
2892
2893
|
|
2893
2894
|
case 48:
|
2894
|
-
#line
|
2895
|
+
#line 773 "pl_gram.y"
|
2895
2896
|
{
|
2896
2897
|
(yyval.oid) = get_collation_oid(list_make1(makeString((yyvsp[(2) - (2)].word).ident)),
|
2897
2898
|
false);
|
@@ -2899,7 +2900,7 @@ yyreduce:
|
|
2899
2900
|
break;
|
2900
2901
|
|
2901
2902
|
case 49:
|
2902
|
-
#line
|
2903
|
+
#line 778 "pl_gram.y"
|
2903
2904
|
{
|
2904
2905
|
(yyval.oid) = get_collation_oid(list_make1(makeString(pstrdup((yyvsp[(2) - (2)].keyword)))),
|
2905
2906
|
false);
|
@@ -2907,41 +2908,41 @@ yyreduce:
|
|
2907
2908
|
break;
|
2908
2909
|
|
2909
2910
|
case 50:
|
2910
|
-
#line
|
2911
|
+
#line 783 "pl_gram.y"
|
2911
2912
|
{
|
2912
2913
|
(yyval.oid) = get_collation_oid((yyvsp[(2) - (2)].cword).idents, false);
|
2913
2914
|
;}
|
2914
2915
|
break;
|
2915
2916
|
|
2916
2917
|
case 51:
|
2917
|
-
#line
|
2918
|
+
#line 789 "pl_gram.y"
|
2918
2919
|
{ (yyval.boolean) = false; ;}
|
2919
2920
|
break;
|
2920
2921
|
|
2921
2922
|
case 52:
|
2922
|
-
#line
|
2923
|
+
#line 791 "pl_gram.y"
|
2923
2924
|
{ (yyval.boolean) = true; ;}
|
2924
2925
|
break;
|
2925
2926
|
|
2926
2927
|
case 53:
|
2927
|
-
#line
|
2928
|
+
#line 795 "pl_gram.y"
|
2928
2929
|
{ (yyval.expr) = NULL; ;}
|
2929
2930
|
break;
|
2930
2931
|
|
2931
2932
|
case 54:
|
2932
|
-
#line
|
2933
|
+
#line 797 "pl_gram.y"
|
2933
2934
|
{
|
2934
2935
|
(yyval.expr) = read_sql_expression(';', ";");
|
2935
2936
|
;}
|
2936
2937
|
break;
|
2937
2938
|
|
2938
2939
|
case 59:
|
2939
|
-
#line
|
2940
|
+
#line 816 "pl_gram.y"
|
2940
2941
|
{ (yyval.list) = NIL; ;}
|
2941
2942
|
break;
|
2942
2943
|
|
2943
2944
|
case 60:
|
2944
|
-
#line
|
2945
|
+
#line 818 "pl_gram.y"
|
2945
2946
|
{
|
2946
2947
|
/* don't bother linking null statements into list */
|
2947
2948
|
if ((yyvsp[(2) - (2)].stmt) == NULL)
|
@@ -2952,127 +2953,127 @@ yyreduce:
|
|
2952
2953
|
break;
|
2953
2954
|
|
2954
2955
|
case 61:
|
2955
|
-
#line
|
2956
|
+
#line 828 "pl_gram.y"
|
2956
2957
|
{ (yyval.stmt) = (yyvsp[(1) - (2)].stmt); ;}
|
2957
2958
|
break;
|
2958
2959
|
|
2959
2960
|
case 62:
|
2960
|
-
#line
|
2961
|
+
#line 830 "pl_gram.y"
|
2961
2962
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
2962
2963
|
break;
|
2963
2964
|
|
2964
2965
|
case 63:
|
2965
|
-
#line
|
2966
|
+
#line 832 "pl_gram.y"
|
2966
2967
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
2967
2968
|
break;
|
2968
2969
|
|
2969
2970
|
case 64:
|
2970
|
-
#line
|
2971
|
+
#line 834 "pl_gram.y"
|
2971
2972
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
2972
2973
|
break;
|
2973
2974
|
|
2974
2975
|
case 65:
|
2975
|
-
#line
|
2976
|
+
#line 836 "pl_gram.y"
|
2976
2977
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
2977
2978
|
break;
|
2978
2979
|
|
2979
2980
|
case 66:
|
2980
|
-
#line
|
2981
|
+
#line 838 "pl_gram.y"
|
2981
2982
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
2982
2983
|
break;
|
2983
2984
|
|
2984
2985
|
case 67:
|
2985
|
-
#line
|
2986
|
+
#line 840 "pl_gram.y"
|
2986
2987
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
2987
2988
|
break;
|
2988
2989
|
|
2989
2990
|
case 68:
|
2990
|
-
#line
|
2991
|
+
#line 842 "pl_gram.y"
|
2991
2992
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
2992
2993
|
break;
|
2993
2994
|
|
2994
2995
|
case 69:
|
2995
|
-
#line
|
2996
|
+
#line 844 "pl_gram.y"
|
2996
2997
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
2997
2998
|
break;
|
2998
2999
|
|
2999
3000
|
case 70:
|
3000
|
-
#line
|
3001
|
+
#line 846 "pl_gram.y"
|
3001
3002
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
3002
3003
|
break;
|
3003
3004
|
|
3004
3005
|
case 71:
|
3005
|
-
#line
|
3006
|
+
#line 848 "pl_gram.y"
|
3006
3007
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
3007
3008
|
break;
|
3008
3009
|
|
3009
3010
|
case 72:
|
3010
|
-
#line
|
3011
|
+
#line 850 "pl_gram.y"
|
3011
3012
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
3012
3013
|
break;
|
3013
3014
|
|
3014
3015
|
case 73:
|
3015
|
-
#line
|
3016
|
+
#line 852 "pl_gram.y"
|
3016
3017
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
3017
3018
|
break;
|
3018
3019
|
|
3019
3020
|
case 74:
|
3020
|
-
#line
|
3021
|
+
#line 854 "pl_gram.y"
|
3021
3022
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
3022
3023
|
break;
|
3023
3024
|
|
3024
3025
|
case 75:
|
3025
|
-
#line
|
3026
|
+
#line 856 "pl_gram.y"
|
3026
3027
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
3027
3028
|
break;
|
3028
3029
|
|
3029
3030
|
case 76:
|
3030
|
-
#line
|
3031
|
+
#line 858 "pl_gram.y"
|
3031
3032
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
3032
3033
|
break;
|
3033
3034
|
|
3034
3035
|
case 77:
|
3035
|
-
#line
|
3036
|
+
#line 860 "pl_gram.y"
|
3036
3037
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
3037
3038
|
break;
|
3038
3039
|
|
3039
3040
|
case 78:
|
3040
|
-
#line
|
3041
|
+
#line 862 "pl_gram.y"
|
3041
3042
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
3042
3043
|
break;
|
3043
3044
|
|
3044
3045
|
case 79:
|
3045
|
-
#line
|
3046
|
+
#line 864 "pl_gram.y"
|
3046
3047
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
3047
3048
|
break;
|
3048
3049
|
|
3049
3050
|
case 80:
|
3050
|
-
#line
|
3051
|
+
#line 866 "pl_gram.y"
|
3051
3052
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
3052
3053
|
break;
|
3053
3054
|
|
3054
3055
|
case 81:
|
3055
|
-
#line
|
3056
|
+
#line 868 "pl_gram.y"
|
3056
3057
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
3057
3058
|
break;
|
3058
3059
|
|
3059
3060
|
case 82:
|
3060
|
-
#line
|
3061
|
+
#line 870 "pl_gram.y"
|
3061
3062
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
3062
3063
|
break;
|
3063
3064
|
|
3064
3065
|
case 83:
|
3065
|
-
#line
|
3066
|
+
#line 872 "pl_gram.y"
|
3066
3067
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
3067
3068
|
break;
|
3068
3069
|
|
3069
3070
|
case 84:
|
3070
|
-
#line
|
3071
|
+
#line 874 "pl_gram.y"
|
3071
3072
|
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
|
3072
3073
|
break;
|
3073
3074
|
|
3074
3075
|
case 85:
|
3075
|
-
#line
|
3076
|
+
#line 878 "pl_gram.y"
|
3076
3077
|
{
|
3077
3078
|
PLpgSQL_stmt_perform *new;
|
3078
3079
|
int startloc;
|
@@ -3093,7 +3094,7 @@ yyreduce:
|
|
3093
3094
|
*/
|
3094
3095
|
new->expr = read_sql_construct(';', 0, 0, ";",
|
3095
3096
|
RAW_PARSE_DEFAULT,
|
3096
|
-
false, false,
|
3097
|
+
false, false,
|
3097
3098
|
&startloc, NULL);
|
3098
3099
|
/* overwrite "perform" ... */
|
3099
3100
|
memcpy(new->expr->query, " SELECT", 7);
|
@@ -3109,7 +3110,7 @@ yyreduce:
|
|
3109
3110
|
break;
|
3110
3111
|
|
3111
3112
|
case 86:
|
3112
|
-
#line
|
3113
|
+
#line 914 "pl_gram.y"
|
3113
3114
|
{
|
3114
3115
|
PLpgSQL_stmt_call *new;
|
3115
3116
|
|
@@ -3130,7 +3131,7 @@ yyreduce:
|
|
3130
3131
|
break;
|
3131
3132
|
|
3132
3133
|
case 87:
|
3133
|
-
#line
|
3134
|
+
#line 932 "pl_gram.y"
|
3134
3135
|
{
|
3135
3136
|
/* use the same structures as for CALL, for simplicity */
|
3136
3137
|
PLpgSQL_stmt_call *new;
|
@@ -3152,7 +3153,7 @@ yyreduce:
|
|
3152
3153
|
break;
|
3153
3154
|
|
3154
3155
|
case 88:
|
3155
|
-
#line
|
3156
|
+
#line 953 "pl_gram.y"
|
3156
3157
|
{
|
3157
3158
|
PLpgSQL_stmt_assign *new;
|
3158
3159
|
RawParseMode pmode;
|
@@ -3184,7 +3185,7 @@ yyreduce:
|
|
3184
3185
|
plpgsql_push_back_token(T_DATUM);
|
3185
3186
|
new->expr = read_sql_construct(';', 0, 0, ";",
|
3186
3187
|
pmode,
|
3187
|
-
false, true,
|
3188
|
+
false, true,
|
3188
3189
|
NULL, NULL);
|
3189
3190
|
|
3190
3191
|
(yyval.stmt) = (PLpgSQL_stmt *) new;
|
@@ -3192,7 +3193,7 @@ yyreduce:
|
|
3192
3193
|
break;
|
3193
3194
|
|
3194
3195
|
case 89:
|
3195
|
-
#line
|
3196
|
+
#line 992 "pl_gram.y"
|
3196
3197
|
{
|
3197
3198
|
PLpgSQL_stmt_getdiag *new;
|
3198
3199
|
ListCell *lc;
|
@@ -3256,42 +3257,42 @@ yyreduce:
|
|
3256
3257
|
break;
|
3257
3258
|
|
3258
3259
|
case 90:
|
3259
|
-
#line
|
3260
|
+
#line 1055 "pl_gram.y"
|
3260
3261
|
{
|
3261
3262
|
(yyval.boolean) = false;
|
3262
3263
|
;}
|
3263
3264
|
break;
|
3264
3265
|
|
3265
3266
|
case 91:
|
3266
|
-
#line
|
3267
|
+
#line 1059 "pl_gram.y"
|
3267
3268
|
{
|
3268
3269
|
(yyval.boolean) = false;
|
3269
3270
|
;}
|
3270
3271
|
break;
|
3271
3272
|
|
3272
3273
|
case 92:
|
3273
|
-
#line
|
3274
|
+
#line 1063 "pl_gram.y"
|
3274
3275
|
{
|
3275
3276
|
(yyval.boolean) = true;
|
3276
3277
|
;}
|
3277
3278
|
break;
|
3278
3279
|
|
3279
3280
|
case 93:
|
3280
|
-
#line
|
3281
|
+
#line 1069 "pl_gram.y"
|
3281
3282
|
{
|
3282
3283
|
(yyval.list) = lappend((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].diagitem));
|
3283
3284
|
;}
|
3284
3285
|
break;
|
3285
3286
|
|
3286
3287
|
case 94:
|
3287
|
-
#line
|
3288
|
+
#line 1073 "pl_gram.y"
|
3288
3289
|
{
|
3289
3290
|
(yyval.list) = list_make1((yyvsp[(1) - (1)].diagitem));
|
3290
3291
|
;}
|
3291
3292
|
break;
|
3292
3293
|
|
3293
3294
|
case 95:
|
3294
|
-
#line
|
3295
|
+
#line 1079 "pl_gram.y"
|
3295
3296
|
{
|
3296
3297
|
PLpgSQL_diag_item *new;
|
3297
3298
|
|
@@ -3304,7 +3305,7 @@ yyreduce:
|
|
3304
3305
|
break;
|
3305
3306
|
|
3306
3307
|
case 96:
|
3307
|
-
#line
|
3308
|
+
#line 1091 "pl_gram.y"
|
3308
3309
|
{
|
3309
3310
|
int tok = yylex();
|
3310
3311
|
|
@@ -3353,7 +3354,7 @@ yyreduce:
|
|
3353
3354
|
break;
|
3354
3355
|
|
3355
3356
|
case 97:
|
3356
|
-
#line
|
3357
|
+
#line 1139 "pl_gram.y"
|
3357
3358
|
{
|
3358
3359
|
/*
|
3359
3360
|
* In principle we should support a getdiag_target
|
@@ -3374,7 +3375,7 @@ yyreduce:
|
|
3374
3375
|
break;
|
3375
3376
|
|
3376
3377
|
case 98:
|
3377
|
-
#line
|
3378
|
+
#line 1157 "pl_gram.y"
|
3378
3379
|
{
|
3379
3380
|
/* just to give a better message than "syntax error" */
|
3380
3381
|
word_is_not_variable(&((yyvsp[(1) - (1)].word)), (yylsp[(1) - (1)]));
|
@@ -3382,7 +3383,7 @@ yyreduce:
|
|
3382
3383
|
break;
|
3383
3384
|
|
3384
3385
|
case 99:
|
3385
|
-
#line
|
3386
|
+
#line 1162 "pl_gram.y"
|
3386
3387
|
{
|
3387
3388
|
/* just to give a better message than "syntax error" */
|
3388
3389
|
cword_is_not_variable(&((yyvsp[(1) - (1)].cword)), (yylsp[(1) - (1)]));
|
@@ -3390,7 +3391,7 @@ yyreduce:
|
|
3390
3391
|
break;
|
3391
3392
|
|
3392
3393
|
case 100:
|
3393
|
-
#line
|
3394
|
+
#line 1169 "pl_gram.y"
|
3394
3395
|
{
|
3395
3396
|
PLpgSQL_stmt_if *new;
|
3396
3397
|
|
@@ -3408,14 +3409,14 @@ yyreduce:
|
|
3408
3409
|
break;
|
3409
3410
|
|
3410
3411
|
case 101:
|
3411
|
-
#line
|
3412
|
+
#line 1186 "pl_gram.y"
|
3412
3413
|
{
|
3413
3414
|
(yyval.list) = NIL;
|
3414
3415
|
;}
|
3415
3416
|
break;
|
3416
3417
|
|
3417
3418
|
case 102:
|
3418
|
-
#line
|
3419
|
+
#line 1190 "pl_gram.y"
|
3419
3420
|
{
|
3420
3421
|
PLpgSQL_if_elsif *new;
|
3421
3422
|
|
@@ -3429,28 +3430,28 @@ yyreduce:
|
|
3429
3430
|
break;
|
3430
3431
|
|
3431
3432
|
case 103:
|
3432
|
-
#line
|
3433
|
+
#line 1203 "pl_gram.y"
|
3433
3434
|
{
|
3434
3435
|
(yyval.list) = NIL;
|
3435
3436
|
;}
|
3436
3437
|
break;
|
3437
3438
|
|
3438
3439
|
case 104:
|
3439
|
-
#line
|
3440
|
+
#line 1207 "pl_gram.y"
|
3440
3441
|
{
|
3441
3442
|
(yyval.list) = (yyvsp[(2) - (2)].list);
|
3442
3443
|
;}
|
3443
3444
|
break;
|
3444
3445
|
|
3445
3446
|
case 105:
|
3446
|
-
#line
|
3447
|
+
#line 1213 "pl_gram.y"
|
3447
3448
|
{
|
3448
3449
|
(yyval.stmt) = make_case((yylsp[(1) - (7)]), (yyvsp[(2) - (7)].expr), (yyvsp[(3) - (7)].list), (yyvsp[(4) - (7)].list));
|
3449
3450
|
;}
|
3450
3451
|
break;
|
3451
3452
|
|
3452
3453
|
case 106:
|
3453
|
-
#line
|
3454
|
+
#line 1219 "pl_gram.y"
|
3454
3455
|
{
|
3455
3456
|
PLpgSQL_expr *expr = NULL;
|
3456
3457
|
int tok = yylex();
|
@@ -3466,21 +3467,21 @@ yyreduce:
|
|
3466
3467
|
break;
|
3467
3468
|
|
3468
3469
|
case 107:
|
3469
|
-
#line
|
3470
|
+
#line 1234 "pl_gram.y"
|
3470
3471
|
{
|
3471
3472
|
(yyval.list) = lappend((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].casewhen));
|
3472
3473
|
;}
|
3473
3474
|
break;
|
3474
3475
|
|
3475
3476
|
case 108:
|
3476
|
-
#line
|
3477
|
+
#line 1238 "pl_gram.y"
|
3477
3478
|
{
|
3478
3479
|
(yyval.list) = list_make1((yyvsp[(1) - (1)].casewhen));
|
3479
3480
|
;}
|
3480
3481
|
break;
|
3481
3482
|
|
3482
3483
|
case 109:
|
3483
|
-
#line
|
3484
|
+
#line 1244 "pl_gram.y"
|
3484
3485
|
{
|
3485
3486
|
PLpgSQL_case_when *new = palloc(sizeof(PLpgSQL_case_when));
|
3486
3487
|
|
@@ -3492,14 +3493,14 @@ yyreduce:
|
|
3492
3493
|
break;
|
3493
3494
|
|
3494
3495
|
case 110:
|
3495
|
-
#line
|
3496
|
+
#line 1255 "pl_gram.y"
|
3496
3497
|
{
|
3497
3498
|
(yyval.list) = NIL;
|
3498
3499
|
;}
|
3499
3500
|
break;
|
3500
3501
|
|
3501
3502
|
case 111:
|
3502
|
-
#line
|
3503
|
+
#line 1259 "pl_gram.y"
|
3503
3504
|
{
|
3504
3505
|
/*
|
3505
3506
|
* proc_sect could return an empty list, but we
|
@@ -3515,7 +3516,7 @@ yyreduce:
|
|
3515
3516
|
break;
|
3516
3517
|
|
3517
3518
|
case 112:
|
3518
|
-
#line
|
3519
|
+
#line 1274 "pl_gram.y"
|
3519
3520
|
{
|
3520
3521
|
PLpgSQL_stmt_loop *new;
|
3521
3522
|
|
@@ -3534,7 +3535,7 @@ yyreduce:
|
|
3534
3535
|
break;
|
3535
3536
|
|
3536
3537
|
case 113:
|
3537
|
-
#line
|
3538
|
+
#line 1292 "pl_gram.y"
|
3538
3539
|
{
|
3539
3540
|
PLpgSQL_stmt_while *new;
|
3540
3541
|
|
@@ -3554,7 +3555,7 @@ yyreduce:
|
|
3554
3555
|
break;
|
3555
3556
|
|
3556
3557
|
case 114:
|
3557
|
-
#line
|
3558
|
+
#line 1311 "pl_gram.y"
|
3558
3559
|
{
|
3559
3560
|
/* This runs after we've scanned the loop body */
|
3560
3561
|
if ((yyvsp[(3) - (4)].stmt)->cmd_type == PLPGSQL_STMT_FORI)
|
@@ -3589,7 +3590,7 @@ yyreduce:
|
|
3589
3590
|
break;
|
3590
3591
|
|
3591
3592
|
case 115:
|
3592
|
-
#line
|
3593
|
+
#line 1345 "pl_gram.y"
|
3593
3594
|
{
|
3594
3595
|
int tok = yylex();
|
3595
3596
|
int tokloc = yylloc;
|
@@ -3722,7 +3723,6 @@ yyreduce:
|
|
3722
3723
|
RAW_PARSE_DEFAULT,
|
3723
3724
|
true,
|
3724
3725
|
false,
|
3725
|
-
true,
|
3726
3726
|
&expr1loc,
|
3727
3727
|
&tok);
|
3728
3728
|
|
@@ -4128,7 +4128,7 @@ yyreduce:
|
|
4128
4128
|
expr = read_sql_construct(',', ';', K_USING,
|
4129
4129
|
", or ; or USING",
|
4130
4130
|
RAW_PARSE_PLPGSQL_EXPR,
|
4131
|
-
true, true,
|
4131
|
+
true, true,
|
4132
4132
|
NULL, &tok);
|
4133
4133
|
new->params = lappend(new->params, expr);
|
4134
4134
|
}
|
@@ -4215,21 +4215,21 @@ yyreduce:
|
|
4215
4215
|
case 129:
|
4216
4216
|
#line 1974 "pl_gram.y"
|
4217
4217
|
{
|
4218
|
-
(yyval.stmt) = make_execsql_stmt(K_IMPORT, (yylsp[(1) - (1)]));
|
4218
|
+
(yyval.stmt) = make_execsql_stmt(K_IMPORT, (yylsp[(1) - (1)]), NULL);
|
4219
4219
|
;}
|
4220
4220
|
break;
|
4221
4221
|
|
4222
4222
|
case 130:
|
4223
4223
|
#line 1978 "pl_gram.y"
|
4224
4224
|
{
|
4225
|
-
(yyval.stmt) = make_execsql_stmt(K_INSERT, (yylsp[(1) - (1)]));
|
4225
|
+
(yyval.stmt) = make_execsql_stmt(K_INSERT, (yylsp[(1) - (1)]), NULL);
|
4226
4226
|
;}
|
4227
4227
|
break;
|
4228
4228
|
|
4229
4229
|
case 131:
|
4230
4230
|
#line 1982 "pl_gram.y"
|
4231
4231
|
{
|
4232
|
-
(yyval.stmt) = make_execsql_stmt(K_MERGE, (yylsp[(1) - (1)]));
|
4232
|
+
(yyval.stmt) = make_execsql_stmt(K_MERGE, (yylsp[(1) - (1)]), NULL);
|
4233
4233
|
;}
|
4234
4234
|
break;
|
4235
4235
|
|
@@ -4243,7 +4243,7 @@ yyreduce:
|
|
4243
4243
|
if (tok == '=' || tok == COLON_EQUALS ||
|
4244
4244
|
tok == '[' || tok == '.')
|
4245
4245
|
word_is_not_variable(&((yyvsp[(1) - (1)].word)), (yylsp[(1) - (1)]));
|
4246
|
-
(yyval.stmt) = make_execsql_stmt(T_WORD, (yylsp[(1) - (1)]));
|
4246
|
+
(yyval.stmt) = make_execsql_stmt(T_WORD, (yylsp[(1) - (1)]), &((yyvsp[(1) - (1)].word)));
|
4247
4247
|
;}
|
4248
4248
|
break;
|
4249
4249
|
|
@@ -4257,7 +4257,7 @@ yyreduce:
|
|
4257
4257
|
if (tok == '=' || tok == COLON_EQUALS ||
|
4258
4258
|
tok == '[' || tok == '.')
|
4259
4259
|
cword_is_not_variable(&((yyvsp[(1) - (1)].cword)), (yylsp[(1) - (1)]));
|
4260
|
-
(yyval.stmt) = make_execsql_stmt(T_CWORD, (yylsp[(1) - (1)]));
|
4260
|
+
(yyval.stmt) = make_execsql_stmt(T_CWORD, (yylsp[(1) - (1)]), NULL);
|
4261
4261
|
;}
|
4262
4262
|
break;
|
4263
4263
|
|
@@ -4271,7 +4271,7 @@ yyreduce:
|
|
4271
4271
|
expr = read_sql_construct(K_INTO, K_USING, ';',
|
4272
4272
|
"INTO or USING or ;",
|
4273
4273
|
RAW_PARSE_PLPGSQL_EXPR,
|
4274
|
-
true, true,
|
4274
|
+
true, true,
|
4275
4275
|
NULL, &endtoken);
|
4276
4276
|
|
4277
4277
|
new = palloc(sizeof(PLpgSQL_stmt_dynexecute));
|
@@ -4310,7 +4310,7 @@ yyreduce:
|
|
4310
4310
|
expr = read_sql_construct(',', ';', K_INTO,
|
4311
4311
|
", or ; or INTO",
|
4312
4312
|
RAW_PARSE_PLPGSQL_EXPR,
|
4313
|
-
true, true,
|
4313
|
+
true, true,
|
4314
4314
|
NULL, &endtoken);
|
4315
4315
|
new->params = lappend(new->params, expr);
|
4316
4316
|
} while (endtoken == ',');
|
@@ -5095,7 +5095,7 @@ read_sql_expression(int until, const char *expected)
|
|
5095
5095
|
{
|
5096
5096
|
return read_sql_construct(until, 0, 0, expected,
|
5097
5097
|
RAW_PARSE_PLPGSQL_EXPR,
|
5098
|
-
true, true,
|
5098
|
+
true, true, NULL, NULL);
|
5099
5099
|
}
|
5100
5100
|
|
5101
5101
|
/* Convenience routine to read an expression with two possible terminators */
|
@@ -5105,7 +5105,7 @@ read_sql_expression2(int until, int until2, const char *expected,
|
|
5105
5105
|
{
|
5106
5106
|
return read_sql_construct(until, until2, 0, expected,
|
5107
5107
|
RAW_PARSE_PLPGSQL_EXPR,
|
5108
|
-
true, true,
|
5108
|
+
true, true, NULL, endtoken);
|
5109
5109
|
}
|
5110
5110
|
|
5111
5111
|
/* Convenience routine to read a SQL statement that must end with ';' */
|
@@ -5114,7 +5114,7 @@ read_sql_stmt(void)
|
|
5114
5114
|
{
|
5115
5115
|
return read_sql_construct(';', 0, 0, ";",
|
5116
5116
|
RAW_PARSE_DEFAULT,
|
5117
|
-
false, true,
|
5117
|
+
false, true, NULL, NULL);
|
5118
5118
|
}
|
5119
5119
|
|
5120
5120
|
/*
|
@@ -5127,7 +5127,6 @@ read_sql_stmt(void)
|
|
5127
5127
|
* parsemode: raw_parser() mode to use
|
5128
5128
|
* isexpression: whether to say we're reading an "expression" or a "statement"
|
5129
5129
|
* valid_sql: whether to check the syntax of the expr
|
5130
|
-
* trim: trim trailing whitespace
|
5131
5130
|
* startloc: if not NULL, location of first token is stored at *startloc
|
5132
5131
|
* endtoken: if not NULL, ending token is stored at *endtoken
|
5133
5132
|
* (this is only interesting if until2 or until3 isn't zero)
|
@@ -5140,7 +5139,6 @@ read_sql_construct(int until,
|
|
5140
5139
|
RawParseMode parsemode,
|
5141
5140
|
bool isexpression,
|
5142
5141
|
bool valid_sql,
|
5143
|
-
bool trim,
|
5144
5142
|
int *startloc,
|
5145
5143
|
int *endtoken)
|
5146
5144
|
{
|
@@ -5148,6 +5146,7 @@ read_sql_construct(int until,
|
|
5148
5146
|
StringInfoData ds;
|
5149
5147
|
IdentifierLookup save_IdentifierLookup;
|
5150
5148
|
int startlocation = -1;
|
5149
|
+
int endlocation = -1;
|
5151
5150
|
int parenlevel = 0;
|
5152
5151
|
PLpgSQL_expr *expr;
|
5153
5152
|
|
@@ -5198,6 +5197,8 @@ read_sql_construct(int until,
|
|
5198
5197
|
expected),
|
5199
5198
|
parser_errposition(yylloc)));
|
5200
5199
|
}
|
5200
|
+
/* Remember end+1 location of last accepted token */
|
5201
|
+
endlocation = yylloc + plpgsql_token_length();
|
5201
5202
|
}
|
5202
5203
|
|
5203
5204
|
plpgsql_IdentifierLookup = save_IdentifierLookup;
|
@@ -5208,7 +5209,7 @@ read_sql_construct(int until,
|
|
5208
5209
|
*endtoken = tok;
|
5209
5210
|
|
5210
5211
|
/* give helpful complaint about empty input */
|
5211
|
-
if (startlocation >=
|
5212
|
+
if (startlocation >= endlocation)
|
5212
5213
|
{
|
5213
5214
|
if (isexpression)
|
5214
5215
|
yyerror("missing expression");
|
@@ -5216,14 +5217,14 @@ read_sql_construct(int until,
|
|
5216
5217
|
yyerror("missing SQL statement");
|
5217
5218
|
}
|
5218
5219
|
|
5219
|
-
|
5220
|
-
|
5221
|
-
|
5222
|
-
|
5223
|
-
|
5224
|
-
|
5225
|
-
|
5226
|
-
|
5220
|
+
/*
|
5221
|
+
* We save only the text from startlocation to endlocation-1. This
|
5222
|
+
* suppresses the "until" token as well as any whitespace or comments
|
5223
|
+
* following the last accepted token. (We used to strip such trailing
|
5224
|
+
* whitespace by hand, but that causes problems if there's a "-- comment"
|
5225
|
+
* in front of said whitespace.)
|
5226
|
+
*/
|
5227
|
+
plpgsql_append_source_text(&ds, startlocation, endlocation);
|
5227
5228
|
|
5228
5229
|
expr = palloc0(sizeof(PLpgSQL_expr));
|
5229
5230
|
expr->query = pstrdup(ds.data);
|
@@ -5240,13 +5241,17 @@ read_sql_construct(int until,
|
|
5240
5241
|
return expr;
|
5241
5242
|
}
|
5242
5243
|
|
5244
|
+
/*
|
5245
|
+
* Read a datatype declaration, consuming the current lookahead token if any.
|
5246
|
+
* Returns a PLpgSQL_type struct.
|
5247
|
+
*/
|
5243
5248
|
static PLpgSQL_type *
|
5244
5249
|
read_datatype(int tok)
|
5245
5250
|
{
|
5246
5251
|
StringInfoData ds;
|
5247
5252
|
char *type_name;
|
5248
5253
|
int startlocation;
|
5249
|
-
PLpgSQL_type *result;
|
5254
|
+
PLpgSQL_type *result = NULL;
|
5250
5255
|
int parenlevel = 0;
|
5251
5256
|
|
5252
5257
|
/* Should only be called while parsing DECLARE sections */
|
@@ -5256,11 +5261,12 @@ read_datatype(int tok)
|
|
5256
5261
|
if (tok == YYEMPTY)
|
5257
5262
|
tok = yylex();
|
5258
5263
|
|
5264
|
+
/* The current token is the start of what we'll pass to parse_datatype */
|
5259
5265
|
startlocation = yylloc;
|
5260
5266
|
|
5261
5267
|
/*
|
5262
|
-
* If we have a simple or composite identifier, check for %TYPE
|
5263
|
-
*
|
5268
|
+
* If we have a simple or composite identifier, check for %TYPE and
|
5269
|
+
* %ROWTYPE constructs.
|
5264
5270
|
*/
|
5265
5271
|
if (tok == T_WORD)
|
5266
5272
|
{
|
@@ -5272,18 +5278,10 @@ read_datatype(int tok)
|
|
5272
5278
|
tok = yylex();
|
5273
5279
|
if (tok_is_keyword(tok, &yylval,
|
5274
5280
|
K_TYPE, "type"))
|
5275
|
-
{
|
5276
5281
|
result = plpgsql_parse_wordtype(dtname);
|
5277
|
-
if (result)
|
5278
|
-
return result;
|
5279
|
-
}
|
5280
5282
|
else if (tok_is_keyword(tok, &yylval,
|
5281
5283
|
K_ROWTYPE, "rowtype"))
|
5282
|
-
{
|
5283
5284
|
result = plpgsql_parse_wordrowtype(dtname);
|
5284
|
-
if (result)
|
5285
|
-
return result;
|
5286
|
-
}
|
5287
5285
|
}
|
5288
5286
|
}
|
5289
5287
|
else if (plpgsql_token_is_unreserved_keyword(tok))
|
@@ -5296,18 +5294,10 @@ read_datatype(int tok)
|
|
5296
5294
|
tok = yylex();
|
5297
5295
|
if (tok_is_keyword(tok, &yylval,
|
5298
5296
|
K_TYPE, "type"))
|
5299
|
-
{
|
5300
5297
|
result = plpgsql_parse_wordtype(dtname);
|
5301
|
-
if (result)
|
5302
|
-
return result;
|
5303
|
-
}
|
5304
5298
|
else if (tok_is_keyword(tok, &yylval,
|
5305
5299
|
K_ROWTYPE, "rowtype"))
|
5306
|
-
{
|
5307
5300
|
result = plpgsql_parse_wordrowtype(dtname);
|
5308
|
-
if (result)
|
5309
|
-
return result;
|
5310
|
-
}
|
5311
5301
|
}
|
5312
5302
|
}
|
5313
5303
|
else if (tok == T_CWORD)
|
@@ -5320,21 +5310,56 @@ read_datatype(int tok)
|
|
5320
5310
|
tok = yylex();
|
5321
5311
|
if (tok_is_keyword(tok, &yylval,
|
5322
5312
|
K_TYPE, "type"))
|
5323
|
-
{
|
5324
5313
|
result = plpgsql_parse_cwordtype(dtnames);
|
5325
|
-
if (result)
|
5326
|
-
return result;
|
5327
|
-
}
|
5328
5314
|
else if (tok_is_keyword(tok, &yylval,
|
5329
5315
|
K_ROWTYPE, "rowtype"))
|
5330
|
-
{
|
5331
5316
|
result = plpgsql_parse_cwordrowtype(dtnames);
|
5332
|
-
if (result)
|
5333
|
-
return result;
|
5334
|
-
}
|
5335
5317
|
}
|
5336
5318
|
}
|
5337
5319
|
|
5320
|
+
/*
|
5321
|
+
* If we recognized a %TYPE or %ROWTYPE construct, see if it is followed
|
5322
|
+
* by array decoration: [ ARRAY ] [ '[' [ iconst ] ']' [ ... ] ]
|
5323
|
+
*
|
5324
|
+
* Like the core parser, we ignore the specific numbers and sizes of
|
5325
|
+
* dimensions; arrays of different dimensionality are still the same type
|
5326
|
+
* in Postgres.
|
5327
|
+
*/
|
5328
|
+
if (result)
|
5329
|
+
{
|
5330
|
+
bool is_array = false;
|
5331
|
+
|
5332
|
+
tok = yylex();
|
5333
|
+
if (tok_is_keyword(tok, &yylval,
|
5334
|
+
K_ARRAY, "array"))
|
5335
|
+
{
|
5336
|
+
is_array = true;
|
5337
|
+
tok = yylex();
|
5338
|
+
}
|
5339
|
+
while (tok == '[')
|
5340
|
+
{
|
5341
|
+
is_array = true;
|
5342
|
+
tok = yylex();
|
5343
|
+
if (tok == ICONST)
|
5344
|
+
tok = yylex();
|
5345
|
+
if (tok != ']')
|
5346
|
+
yyerror("syntax error, expected \"]\"");
|
5347
|
+
tok = yylex();
|
5348
|
+
}
|
5349
|
+
plpgsql_push_back_token(tok);
|
5350
|
+
|
5351
|
+
if (is_array)
|
5352
|
+
result = plpgsql_build_datatype_arrayof(result);
|
5353
|
+
|
5354
|
+
return result;
|
5355
|
+
}
|
5356
|
+
|
5357
|
+
/*
|
5358
|
+
* Not %TYPE or %ROWTYPE, so scan to the end of the datatype declaration,
|
5359
|
+
* which could include typmod or array decoration. We are not very picky
|
5360
|
+
* here, instead relying on parse_datatype to complain about garbage. But
|
5361
|
+
* we must count parens to handle typmods within cursor_arg correctly.
|
5362
|
+
*/
|
5338
5363
|
while (tok != ';')
|
5339
5364
|
{
|
5340
5365
|
if (tok == 0)
|
@@ -5376,8 +5401,13 @@ read_datatype(int tok)
|
|
5376
5401
|
return result;
|
5377
5402
|
}
|
5378
5403
|
|
5404
|
+
/*
|
5405
|
+
* Read a generic SQL statement. We have already read its first token;
|
5406
|
+
* firsttoken is that token's code and location its starting location.
|
5407
|
+
* If firsttoken == T_WORD, pass its yylval value as "word", else pass NULL.
|
5408
|
+
*/
|
5379
5409
|
static PLpgSQL_stmt *
|
5380
|
-
make_execsql_stmt(int firsttoken, int location)
|
5410
|
+
make_execsql_stmt(int firsttoken, int location, PLword *word)
|
5381
5411
|
{
|
5382
5412
|
StringInfoData ds;
|
5383
5413
|
IdentifierLookup save_IdentifierLookup;
|
@@ -5390,9 +5420,16 @@ make_execsql_stmt(int firsttoken, int location)
|
|
5390
5420
|
bool have_strict = false;
|
5391
5421
|
int into_start_loc = -1;
|
5392
5422
|
int into_end_loc = -1;
|
5423
|
+
int paren_depth = 0;
|
5424
|
+
int begin_depth = 0;
|
5425
|
+
bool in_routine_definition = false;
|
5426
|
+
int token_count = 0;
|
5427
|
+
char tokens[4]; /* records the first few tokens */
|
5393
5428
|
|
5394
5429
|
initStringInfo(&ds);
|
5395
5430
|
|
5431
|
+
memset(tokens, 0, sizeof(tokens));
|
5432
|
+
|
5396
5433
|
/* special lookup mode for identifiers within the SQL text */
|
5397
5434
|
save_IdentifierLookup = plpgsql_IdentifierLookup;
|
5398
5435
|
plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_EXPR;
|
@@ -5401,6 +5438,12 @@ make_execsql_stmt(int firsttoken, int location)
|
|
5401
5438
|
* Scan to the end of the SQL command. Identify any INTO-variables
|
5402
5439
|
* clause lurking within it, and parse that via read_into_target().
|
5403
5440
|
*
|
5441
|
+
* The end of the statement is defined by a semicolon ... except that
|
5442
|
+
* semicolons within parentheses or BEGIN/END blocks don't terminate a
|
5443
|
+
* statement. We follow psql's lead in not recognizing BEGIN/END except
|
5444
|
+
* after CREATE [OR REPLACE] {FUNCTION|PROCEDURE}. END can also appear
|
5445
|
+
* within a CASE construct, so we treat CASE/END like BEGIN/END.
|
5446
|
+
*
|
5404
5447
|
* Because INTO is sometimes used in the main SQL grammar, we have to be
|
5405
5448
|
* careful not to take any such usage of INTO as a PL/pgSQL INTO clause.
|
5406
5449
|
* There are currently three such cases:
|
@@ -5426,13 +5469,50 @@ make_execsql_stmt(int firsttoken, int location)
|
|
5426
5469
|
* break this logic again ... beware!
|
5427
5470
|
*/
|
5428
5471
|
tok = firsttoken;
|
5472
|
+
if (tok == T_WORD && strcmp(word->ident, "create") == 0)
|
5473
|
+
tokens[token_count] = 'c';
|
5474
|
+
token_count++;
|
5475
|
+
|
5429
5476
|
for (;;)
|
5430
5477
|
{
|
5431
5478
|
prev_tok = tok;
|
5432
5479
|
tok = yylex();
|
5433
5480
|
if (have_into && into_end_loc < 0)
|
5434
5481
|
into_end_loc = yylloc; /* token after the INTO part */
|
5435
|
-
|
5482
|
+
/* Detect CREATE [OR REPLACE] {FUNCTION|PROCEDURE} */
|
5483
|
+
if (tokens[0] == 'c' && token_count < sizeof(tokens))
|
5484
|
+
{
|
5485
|
+
if (tok == K_OR)
|
5486
|
+
tokens[token_count] = 'o';
|
5487
|
+
else if (tok == T_WORD &&
|
5488
|
+
strcmp(yylval.word.ident, "replace") == 0)
|
5489
|
+
tokens[token_count] = 'r';
|
5490
|
+
else if (tok == T_WORD &&
|
5491
|
+
strcmp(yylval.word.ident, "function") == 0)
|
5492
|
+
tokens[token_count] = 'f';
|
5493
|
+
else if (tok == T_WORD &&
|
5494
|
+
strcmp(yylval.word.ident, "procedure") == 0)
|
5495
|
+
tokens[token_count] = 'f'; /* treat same as "function" */
|
5496
|
+
if (tokens[1] == 'f' ||
|
5497
|
+
(tokens[1] == 'o' && tokens[2] == 'r' && tokens[3] == 'f'))
|
5498
|
+
in_routine_definition = true;
|
5499
|
+
token_count++;
|
5500
|
+
}
|
5501
|
+
/* Track paren nesting (needed for CREATE RULE syntax) */
|
5502
|
+
if (tok == '(')
|
5503
|
+
paren_depth++;
|
5504
|
+
else if (tok == ')' && paren_depth > 0)
|
5505
|
+
paren_depth--;
|
5506
|
+
/* We need track BEGIN/END nesting only in a routine definition */
|
5507
|
+
if (in_routine_definition && paren_depth == 0)
|
5508
|
+
{
|
5509
|
+
if (tok == K_BEGIN || tok == K_CASE)
|
5510
|
+
begin_depth++;
|
5511
|
+
else if (tok == K_END && begin_depth > 0)
|
5512
|
+
begin_depth--;
|
5513
|
+
}
|
5514
|
+
/* Command-ending semicolon? */
|
5515
|
+
if (tok == ';' && paren_depth == 0 && begin_depth == 0)
|
5436
5516
|
break;
|
5437
5517
|
if (tok == 0)
|
5438
5518
|
yyerror("unexpected end of function definition");
|
@@ -5596,11 +5676,11 @@ read_fetch_direction(void)
|
|
5596
5676
|
{
|
5597
5677
|
/*
|
5598
5678
|
* Assume it's a count expression with no preceding keyword.
|
5599
|
-
* Note: we allow this syntax because core SQL does, but
|
5600
|
-
*
|
5601
|
-
*
|
5602
|
-
* Perhaps this can be improved
|
5603
|
-
* lot of work.
|
5679
|
+
* Note: we allow this syntax because core SQL does, but it's
|
5680
|
+
* ambiguous with the case of an omitted direction clause; for
|
5681
|
+
* instance, "MOVE n IN c" will fail if n is a variable, because the
|
5682
|
+
* preceding else-arm will trigger. Perhaps this can be improved
|
5683
|
+
* someday, but it hardly seems worth a lot of work.
|
5604
5684
|
*/
|
5605
5685
|
plpgsql_push_back_token(tok);
|
5606
5686
|
fetch->expr = read_sql_expression2(K_FROM, K_IN,
|
@@ -6090,7 +6170,30 @@ plpgsql_sql_error_callback(void *arg)
|
|
6090
6170
|
* This is handled the same as in check_sql_expr(), and we likewise
|
6091
6171
|
* expect that the given string is a copy from the source text.
|
6092
6172
|
*/
|
6093
|
-
|
6173
|
+
|
6174
|
+
#include "catalog/pg_collation_d.h"
|
6175
|
+
static PLpgSQL_type * parse_datatype(const char *string, int location) {
|
6176
|
+
PLpgSQL_type *typ;
|
6177
|
+
|
6178
|
+
/* Ignore trailing spaces */
|
6179
|
+
size_t len = strlen(string);
|
6180
|
+
while (len > 0 && scanner_isspace(string[len - 1])) --len;
|
6181
|
+
|
6182
|
+
typ = (PLpgSQL_type *) palloc0(sizeof(PLpgSQL_type));
|
6183
|
+
typ->typname = pstrdup(string);
|
6184
|
+
typ->ttype = pg_strncasecmp(string, "RECORD", len) == 0 ? PLPGSQL_TTYPE_REC : PLPGSQL_TTYPE_SCALAR;
|
6185
|
+
if (pg_strncasecmp(string, "REFCURSOR", len) == 0 || pg_strncasecmp(string, "CURSOR", len) == 0)
|
6186
|
+
{
|
6187
|
+
typ->typoid = REFCURSOROID;
|
6188
|
+
}
|
6189
|
+
else if (pg_strncasecmp(string, "TEXT", len) == 0)
|
6190
|
+
{
|
6191
|
+
typ->typoid = TEXTOID;
|
6192
|
+
typ->collation = DEFAULT_COLLATION_OID;
|
6193
|
+
}
|
6194
|
+
return typ;
|
6195
|
+
}
|
6196
|
+
|
6094
6197
|
|
6095
6198
|
|
6096
6199
|
/*
|
@@ -6229,16 +6332,12 @@ read_cursor_args(PLpgSQL_var *cursor, int until)
|
|
6229
6332
|
* Read the value expression. To provide the user with meaningful
|
6230
6333
|
* parse error positions, we check the syntax immediately, instead of
|
6231
6334
|
* checking the final expression that may have the arguments
|
6232
|
-
* reordered.
|
6233
|
-
* otherwise input of the form (param -- comment\n, param) would be
|
6234
|
-
* translated into a form where the second parameter is commented
|
6235
|
-
* out.
|
6335
|
+
* reordered.
|
6236
6336
|
*/
|
6237
6337
|
item = read_sql_construct(',', ')', 0,
|
6238
6338
|
",\" or \")",
|
6239
6339
|
RAW_PARSE_PLPGSQL_EXPR,
|
6240
6340
|
true, true,
|
6241
|
-
false, /* do not trim */
|
6242
6341
|
NULL, &endtoken);
|
6243
6342
|
|
6244
6343
|
argv[argpos] = item->query;
|