pg_query 5.0.0 → 5.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 +9 -0
- data/Rakefile +3 -4
- data/ext/pg_query/extconf.rb +14 -4
- data/ext/pg_query/include/pg_query_fingerprint_defs.c +1 -1
- data/ext/pg_query/include/pg_query_outfuncs_defs.c +1 -1
- data/ext/pg_query/include/pg_query_readfuncs_defs.c +1 -1
- data/ext/pg_query/include/{miscadmin.h → postgres/miscadmin.h} +1 -1
- data/ext/pg_query/include/{nodes → postgres/nodes}/nodes.h +1 -1
- data/ext/pg_query/include/{parser → postgres/parser}/parser.h +3 -3
- data/ext/pg_query/include/{pg_config.h → postgres/pg_config.h} +136 -2
- data/ext/pg_query/include/postgres/pg_config_os.h +8 -0
- data/ext/pg_query/include/{pgstat.h → postgres/pgstat.h} +1 -1
- data/ext/pg_query/include/{pl_gram.h → postgres/pl_gram.h} +2 -2
- data/ext/pg_query/include/{plpgsql.h → postgres/plpgsql.h} +11 -11
- data/ext/pg_query/include/postgres/port/atomics/arch-hppa.h +17 -0
- data/ext/pg_query/include/postgres/port/atomics/generic-msvc.h +101 -0
- data/ext/pg_query/include/postgres/port/atomics/generic-sunpro.h +106 -0
- data/ext/pg_query/include/postgres/port/win32/arpa/inet.h +3 -0
- data/ext/pg_query/include/postgres/port/win32/dlfcn.h +1 -0
- data/ext/pg_query/include/postgres/port/win32/grp.h +1 -0
- data/ext/pg_query/include/postgres/port/win32/netdb.h +7 -0
- data/ext/pg_query/include/postgres/port/win32/netinet/in.h +3 -0
- data/ext/pg_query/include/postgres/port/win32/netinet/tcp.h +7 -0
- data/ext/pg_query/include/postgres/port/win32/pwd.h +3 -0
- data/ext/pg_query/include/postgres/port/win32/sys/resource.h +20 -0
- data/ext/pg_query/include/postgres/port/win32/sys/select.h +3 -0
- data/ext/pg_query/include/postgres/port/win32/sys/socket.h +26 -0
- data/ext/pg_query/include/postgres/port/win32/sys/un.h +17 -0
- data/ext/pg_query/include/postgres/port/win32/sys/wait.h +3 -0
- data/ext/pg_query/include/postgres/port/win32.h +59 -0
- data/ext/pg_query/include/postgres/port/win32_msvc/dirent.h +34 -0
- data/ext/pg_query/include/postgres/port/win32_msvc/sys/file.h +1 -0
- data/ext/pg_query/include/postgres/port/win32_msvc/sys/param.h +1 -0
- data/ext/pg_query/include/postgres/port/win32_msvc/sys/time.h +1 -0
- data/ext/pg_query/include/postgres/port/win32_msvc/unistd.h +9 -0
- data/ext/pg_query/include/postgres/port/win32_msvc/utime.h +3 -0
- data/ext/pg_query/include/postgres/port/win32_port.h +594 -0
- data/ext/pg_query/include/{postmaster → postgres/postmaster}/postmaster.h +1 -1
- data/ext/pg_query/include/{storage → postgres/storage}/ipc.h +1 -1
- data/ext/pg_query/include/{tcop → postgres/tcop}/tcopprot.h +2 -2
- data/ext/pg_query/include/{utils → postgres/utils}/builtins.h +1 -1
- data/ext/pg_query/include/{utils → postgres/utils}/elog.h +3 -3
- data/ext/pg_query/include/{utils → postgres/utils}/guc.h +4 -4
- data/ext/pg_query/include/{utils → postgres/utils}/memutils.h +2 -2
- data/ext/pg_query/include/{utils → postgres/utils}/palloc.h +1 -1
- data/ext/pg_query/pg_query.c +9 -0
- data/ext/pg_query/pg_query_fingerprint.c +4 -5
- data/ext/pg_query/pg_query_outfuncs_json.c +6 -0
- data/ext/pg_query/pg_query_outfuncs_protobuf.c +1 -0
- data/ext/pg_query/pg_query_parse.c +1 -1
- data/ext/pg_query/pg_query_parse_plpgsql.c +6 -4
- data/ext/pg_query/pg_query_readfuncs_protobuf.c +1 -0
- data/ext/pg_query/pg_query_ruby.c +5 -0
- data/ext/pg_query/pg_query_split.c +1 -1
- data/ext/pg_query/src_backend_nodes_nodes.c +38 -0
- data/ext/pg_query/src_backend_utils_error_elog.c +17 -152
- data/ext/pg_query/src_backend_utils_init_globals.c +1 -1
- data/ext/pg_query/src_backend_utils_mb_mbutils.c +8 -63
- data/ext/pg_query/src_backend_utils_misc_guc_tables.c +0 -2
- data/ext/pg_query/src_port_pg_bitutils.c +78 -4
- data/ext/pg_query/src_port_snprintf.c +3 -3
- data/ext/pg_query/src_port_strlcpy.c +79 -0
- data/lib/pg_query/fingerprint.rb +2 -3
- data/lib/pg_query/node.rb +16 -11
- data/lib/pg_query/parse.rb +1 -1
- data/lib/pg_query/pg_query_pb.rb +1 -1
- data/lib/pg_query/treewalker.rb +16 -3
- data/lib/pg_query/version.rb +1 -1
- metadata +424 -394
- data/ext/pg_query/guc-file.c +0 -0
- data/ext/pg_query/include/common/ip.h +0 -33
- data/ext/pg_query/include/pg_config_os.h +0 -8
- data/ext/pg_query/include/postmaster/auxprocess.h +0 -20
- data/ext/pg_query/include/postmaster/fork_process.h +0 -17
- data/ext/pg_query/include/src_backend_nodes_copyfuncs.funcs.c +0 -5321
- data/ext/pg_query/include/src_backend_nodes_equalfuncs.funcs.c +0 -3354
- data/ext/pg_query/include/utils/pidfile.h +0 -56
- data/ext/pg_query/src_backend_postmaster_postmaster.c +0 -2220
- data/ext/pg_query/src_port_strnlen.c +0 -39
- /data/ext/pg_query/include/{access → postgres/access}/amapi.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/attmap.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/attnum.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/clog.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/commit_ts.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/detoast.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/genam.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/gin.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/htup.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/htup_details.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/itup.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/parallel.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/printtup.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/relation.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/relscan.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/rmgr.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/rmgrlist.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/sdir.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/skey.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/stratnum.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/sysattr.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/table.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/tableam.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/toast_compression.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/transam.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/tsmapi.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/tupconvert.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/tupdesc.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/tupmacs.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/twophase.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/xact.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/xlog.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/xlog_internal.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/xlogbackup.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/xlogdefs.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/xlogprefetcher.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/xlogreader.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/xlogrecord.h +0 -0
- /data/ext/pg_query/include/{access → postgres/access}/xlogrecovery.h +0 -0
- /data/ext/pg_query/include/{archive → postgres/archive}/archive_module.h +0 -0
- /data/ext/pg_query/include/{c.h → postgres/c.h} +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/catalog.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/catversion.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/dependency.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/genbki.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/index.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/indexing.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/namespace.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/objectaccess.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/objectaddress.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_aggregate.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_aggregate_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_am.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_am_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_attribute.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_attribute_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_authid.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_authid_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_class.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_class_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_collation.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_collation_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_constraint.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_constraint_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_control.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_conversion.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_conversion_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_database.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_database_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_depend.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_depend_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_event_trigger.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_event_trigger_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_index.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_index_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_language.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_language_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_namespace.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_namespace_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_opclass.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_opclass_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_operator.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_operator_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_opfamily.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_opfamily_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_partitioned_table.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_partitioned_table_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_proc.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_proc_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_publication.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_publication_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_replication_origin.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_replication_origin_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_statistic.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_statistic_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_statistic_ext.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_statistic_ext_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_transform.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_transform_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_trigger.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_trigger_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_config.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_config_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_dict.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_dict_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_parser.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_parser_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_template.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_ts_template_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_type.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/pg_type_d.h +0 -0
- /data/ext/pg_query/include/{catalog → postgres/catalog}/storage.h +0 -0
- /data/ext/pg_query/include/{commands → postgres/commands}/async.h +0 -0
- /data/ext/pg_query/include/{commands → postgres/commands}/dbcommands.h +0 -0
- /data/ext/pg_query/include/{commands → postgres/commands}/defrem.h +0 -0
- /data/ext/pg_query/include/{commands → postgres/commands}/event_trigger.h +0 -0
- /data/ext/pg_query/include/{commands → postgres/commands}/explain.h +0 -0
- /data/ext/pg_query/include/{commands → postgres/commands}/prepare.h +0 -0
- /data/ext/pg_query/include/{commands → postgres/commands}/tablespace.h +0 -0
- /data/ext/pg_query/include/{commands → postgres/commands}/trigger.h +0 -0
- /data/ext/pg_query/include/{commands → postgres/commands}/user.h +0 -0
- /data/ext/pg_query/include/{commands → postgres/commands}/vacuum.h +0 -0
- /data/ext/pg_query/include/{common → postgres/common}/cryptohash.h +0 -0
- /data/ext/pg_query/include/{common → postgres/common}/file_perm.h +0 -0
- /data/ext/pg_query/include/{common → postgres/common}/hashfn.h +0 -0
- /data/ext/pg_query/include/{common → postgres/common}/int.h +0 -0
- /data/ext/pg_query/include/{common → postgres/common}/keywords.h +0 -0
- /data/ext/pg_query/include/{common → postgres/common}/kwlookup.h +0 -0
- /data/ext/pg_query/include/{common → postgres/common}/pg_prng.h +0 -0
- /data/ext/pg_query/include/{common → postgres/common}/relpath.h +0 -0
- /data/ext/pg_query/include/{common → postgres/common}/scram-common.h +0 -0
- /data/ext/pg_query/include/{common → postgres/common}/sha2.h +0 -0
- /data/ext/pg_query/include/{common → postgres/common}/string.h +0 -0
- /data/ext/pg_query/include/{common → postgres/common}/unicode_east_asian_fw_table.h +0 -0
- /data/ext/pg_query/include/{common → postgres/common}/unicode_nonspacing_table.h +0 -0
- /data/ext/pg_query/include/{copyfuncs.funcs.c → postgres/copyfuncs.funcs.c} +0 -0
- /data/ext/pg_query/include/{copyfuncs.switch.c → postgres/copyfuncs.switch.c} +0 -0
- /data/ext/pg_query/include/{datatype → postgres/datatype}/timestamp.h +0 -0
- /data/ext/pg_query/include/{equalfuncs.funcs.c → postgres/equalfuncs.funcs.c} +0 -0
- /data/ext/pg_query/include/{equalfuncs.switch.c → postgres/equalfuncs.switch.c} +0 -0
- /data/ext/pg_query/include/{executor → postgres/executor}/execdesc.h +0 -0
- /data/ext/pg_query/include/{executor → postgres/executor}/executor.h +0 -0
- /data/ext/pg_query/include/{executor → postgres/executor}/functions.h +0 -0
- /data/ext/pg_query/include/{executor → postgres/executor}/instrument.h +0 -0
- /data/ext/pg_query/include/{executor → postgres/executor}/spi.h +0 -0
- /data/ext/pg_query/include/{executor → postgres/executor}/tablefunc.h +0 -0
- /data/ext/pg_query/include/{executor → postgres/executor}/tuptable.h +0 -0
- /data/ext/pg_query/include/{fmgr.h → postgres/fmgr.h} +0 -0
- /data/ext/pg_query/include/{foreign → postgres/foreign}/fdwapi.h +0 -0
- /data/ext/pg_query/include/{funcapi.h → postgres/funcapi.h} +0 -0
- /data/ext/pg_query/include/{gram.h → postgres/gram.h} +0 -0
- /data/ext/pg_query/include/{gramparse.h → postgres/gramparse.h} +0 -0
- /data/ext/pg_query/include/{jit → postgres/jit}/jit.h +0 -0
- /data/ext/pg_query/include/{kwlist_d.h → postgres/kwlist_d.h} +0 -0
- /data/ext/pg_query/include/{lib → postgres/lib}/dshash.h +0 -0
- /data/ext/pg_query/include/{lib → postgres/lib}/ilist.h +0 -0
- /data/ext/pg_query/include/{lib → postgres/lib}/pairingheap.h +0 -0
- /data/ext/pg_query/include/{lib → postgres/lib}/simplehash.h +0 -0
- /data/ext/pg_query/include/{lib → postgres/lib}/sort_template.h +0 -0
- /data/ext/pg_query/include/{lib → postgres/lib}/stringinfo.h +0 -0
- /data/ext/pg_query/include/{libpq → postgres/libpq}/auth.h +0 -0
- /data/ext/pg_query/include/{libpq → postgres/libpq}/crypt.h +0 -0
- /data/ext/pg_query/include/{libpq → postgres/libpq}/hba.h +0 -0
- /data/ext/pg_query/include/{libpq → postgres/libpq}/libpq-be.h +0 -0
- /data/ext/pg_query/include/{libpq → postgres/libpq}/libpq.h +0 -0
- /data/ext/pg_query/include/{libpq → postgres/libpq}/pqcomm.h +0 -0
- /data/ext/pg_query/include/{libpq → postgres/libpq}/pqformat.h +0 -0
- /data/ext/pg_query/include/{libpq → postgres/libpq}/pqsignal.h +0 -0
- /data/ext/pg_query/include/{libpq → postgres/libpq}/sasl.h +0 -0
- /data/ext/pg_query/include/{libpq → postgres/libpq}/scram.h +0 -0
- /data/ext/pg_query/include/{mb → postgres/mb}/pg_wchar.h +0 -0
- /data/ext/pg_query/include/{mb → postgres/mb}/stringinfo_mb.h +0 -0
- /data/ext/pg_query/include/{nodes → postgres/nodes}/bitmapset.h +0 -0
- /data/ext/pg_query/include/{nodes → postgres/nodes}/execnodes.h +0 -0
- /data/ext/pg_query/include/{nodes → postgres/nodes}/extensible.h +0 -0
- /data/ext/pg_query/include/{nodes → postgres/nodes}/lockoptions.h +0 -0
- /data/ext/pg_query/include/{nodes → postgres/nodes}/makefuncs.h +0 -0
- /data/ext/pg_query/include/{nodes → postgres/nodes}/memnodes.h +0 -0
- /data/ext/pg_query/include/{nodes → postgres/nodes}/miscnodes.h +0 -0
- /data/ext/pg_query/include/{nodes → postgres/nodes}/nodeFuncs.h +0 -0
- /data/ext/pg_query/include/{nodes → postgres/nodes}/nodetags.h +0 -0
- /data/ext/pg_query/include/{nodes → postgres/nodes}/params.h +0 -0
- /data/ext/pg_query/include/{nodes → postgres/nodes}/parsenodes.h +0 -0
- /data/ext/pg_query/include/{nodes → postgres/nodes}/pathnodes.h +0 -0
- /data/ext/pg_query/include/{nodes → postgres/nodes}/pg_list.h +0 -0
- /data/ext/pg_query/include/{nodes → postgres/nodes}/plannodes.h +0 -0
- /data/ext/pg_query/include/{nodes → postgres/nodes}/primnodes.h +0 -0
- /data/ext/pg_query/include/{nodes → postgres/nodes}/print.h +0 -0
- /data/ext/pg_query/include/{nodes → postgres/nodes}/queryjumble.h +0 -0
- /data/ext/pg_query/include/{nodes → postgres/nodes}/replnodes.h +0 -0
- /data/ext/pg_query/include/{nodes → postgres/nodes}/supportnodes.h +0 -0
- /data/ext/pg_query/include/{nodes → postgres/nodes}/tidbitmap.h +0 -0
- /data/ext/pg_query/include/{nodes → postgres/nodes}/value.h +0 -0
- /data/ext/pg_query/include/{optimizer → postgres/optimizer}/cost.h +0 -0
- /data/ext/pg_query/include/{optimizer → postgres/optimizer}/geqo.h +0 -0
- /data/ext/pg_query/include/{optimizer → postgres/optimizer}/geqo_gene.h +0 -0
- /data/ext/pg_query/include/{optimizer → postgres/optimizer}/optimizer.h +0 -0
- /data/ext/pg_query/include/{optimizer → postgres/optimizer}/paths.h +0 -0
- /data/ext/pg_query/include/{optimizer → postgres/optimizer}/planmain.h +0 -0
- /data/ext/pg_query/include/{parser → postgres/parser}/analyze.h +0 -0
- /data/ext/pg_query/include/{parser → postgres/parser}/kwlist.h +0 -0
- /data/ext/pg_query/include/{parser → postgres/parser}/parse_agg.h +0 -0
- /data/ext/pg_query/include/{parser → postgres/parser}/parse_coerce.h +0 -0
- /data/ext/pg_query/include/{parser → postgres/parser}/parse_expr.h +0 -0
- /data/ext/pg_query/include/{parser → postgres/parser}/parse_func.h +0 -0
- /data/ext/pg_query/include/{parser → postgres/parser}/parse_node.h +0 -0
- /data/ext/pg_query/include/{parser → postgres/parser}/parse_oper.h +0 -0
- /data/ext/pg_query/include/{parser → postgres/parser}/parse_relation.h +0 -0
- /data/ext/pg_query/include/{parser → postgres/parser}/parse_type.h +0 -0
- /data/ext/pg_query/include/{parser → postgres/parser}/parsetree.h +0 -0
- /data/ext/pg_query/include/{parser → postgres/parser}/scanner.h +0 -0
- /data/ext/pg_query/include/{parser → postgres/parser}/scansup.h +0 -0
- /data/ext/pg_query/include/{partitioning → postgres/partitioning}/partdefs.h +0 -0
- /data/ext/pg_query/include/{pg_config_ext.h → postgres/pg_config_ext.h} +0 -0
- /data/ext/pg_query/include/{pg_config_manual.h → postgres/pg_config_manual.h} +0 -0
- /data/ext/pg_query/include/{pg_getopt.h → postgres/pg_getopt.h} +0 -0
- /data/ext/pg_query/include/{pg_trace.h → postgres/pg_trace.h} +0 -0
- /data/ext/pg_query/include/{pgtime.h → postgres/pgtime.h} +0 -0
- /data/ext/pg_query/include/{pl_reserved_kwlist.h → postgres/pl_reserved_kwlist.h} +0 -0
- /data/ext/pg_query/include/{pl_reserved_kwlist_d.h → postgres/pl_reserved_kwlist_d.h} +0 -0
- /data/ext/pg_query/include/{pl_unreserved_kwlist.h → postgres/pl_unreserved_kwlist.h} +0 -0
- /data/ext/pg_query/include/{pl_unreserved_kwlist_d.h → postgres/pl_unreserved_kwlist_d.h} +0 -0
- /data/ext/pg_query/include/{plerrcodes.h → postgres/plerrcodes.h} +0 -0
- /data/ext/pg_query/include/{port → postgres/port}/atomics/arch-arm.h +0 -0
- /data/ext/pg_query/include/{port → postgres/port}/atomics/arch-ppc.h +0 -0
- /data/ext/pg_query/include/{port → postgres/port}/atomics/arch-x86.h +0 -0
- /data/ext/pg_query/include/{port → postgres/port}/atomics/fallback.h +0 -0
- /data/ext/pg_query/include/{port → postgres/port}/atomics/generic-gcc.h +0 -0
- /data/ext/pg_query/include/{port → postgres/port}/atomics/generic.h +0 -0
- /data/ext/pg_query/include/{port → postgres/port}/atomics.h +0 -0
- /data/ext/pg_query/include/{port → postgres/port}/pg_bitutils.h +0 -0
- /data/ext/pg_query/include/{port → postgres/port}/pg_bswap.h +0 -0
- /data/ext/pg_query/include/{port → postgres/port}/pg_crc32c.h +0 -0
- /data/ext/pg_query/include/{port → postgres/port}/simd.h +0 -0
- /data/ext/pg_query/include/{port.h → postgres/port.h} +0 -0
- /data/ext/pg_query/include/{portability → postgres/portability}/instr_time.h +0 -0
- /data/ext/pg_query/include/{postgres.h → postgres/postgres.h} +0 -0
- /data/ext/pg_query/include/{postgres_ext.h → postgres/postgres_ext.h} +0 -0
- /data/ext/pg_query/include/{postmaster → postgres/postmaster}/autovacuum.h +0 -0
- /data/ext/pg_query/include/{postmaster → postgres/postmaster}/bgworker.h +0 -0
- /data/ext/pg_query/include/{postmaster → postgres/postmaster}/bgworker_internals.h +0 -0
- /data/ext/pg_query/include/{postmaster → postgres/postmaster}/bgwriter.h +0 -0
- /data/ext/pg_query/include/{postmaster → postgres/postmaster}/interrupt.h +0 -0
- /data/ext/pg_query/include/{postmaster → postgres/postmaster}/pgarch.h +0 -0
- /data/ext/pg_query/include/{postmaster → postgres/postmaster}/startup.h +0 -0
- /data/ext/pg_query/include/{postmaster → postgres/postmaster}/syslogger.h +0 -0
- /data/ext/pg_query/include/{postmaster → postgres/postmaster}/walwriter.h +0 -0
- /data/ext/pg_query/include/{regex → postgres/regex}/regex.h +0 -0
- /data/ext/pg_query/include/{replication → postgres/replication}/logicallauncher.h +0 -0
- /data/ext/pg_query/include/{replication → postgres/replication}/logicalproto.h +0 -0
- /data/ext/pg_query/include/{replication → postgres/replication}/logicalworker.h +0 -0
- /data/ext/pg_query/include/{replication → postgres/replication}/origin.h +0 -0
- /data/ext/pg_query/include/{replication → postgres/replication}/reorderbuffer.h +0 -0
- /data/ext/pg_query/include/{replication → postgres/replication}/slot.h +0 -0
- /data/ext/pg_query/include/{replication → postgres/replication}/syncrep.h +0 -0
- /data/ext/pg_query/include/{replication → postgres/replication}/walreceiver.h +0 -0
- /data/ext/pg_query/include/{replication → postgres/replication}/walsender.h +0 -0
- /data/ext/pg_query/include/{rewrite → postgres/rewrite}/prs2lock.h +0 -0
- /data/ext/pg_query/include/{rewrite → postgres/rewrite}/rewriteHandler.h +0 -0
- /data/ext/pg_query/include/{rewrite → postgres/rewrite}/rewriteManip.h +0 -0
- /data/ext/pg_query/include/{rewrite → postgres/rewrite}/rewriteSupport.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/backendid.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/block.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/buf.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/bufmgr.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/bufpage.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/condition_variable.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/dsm.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/dsm_impl.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/fd.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/fileset.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/item.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/itemid.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/itemptr.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/large_object.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/latch.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/lmgr.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/lock.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/lockdefs.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/lwlock.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/lwlocknames.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/off.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/pg_sema.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/pg_shmem.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/pmsignal.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/predicate.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/proc.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/procarray.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/proclist_types.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/procsignal.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/relfilelocator.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/s_lock.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/sharedfileset.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/shm_mq.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/shm_toc.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/shmem.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/sinval.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/sinvaladt.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/smgr.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/spin.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/standby.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/standbydefs.h +0 -0
- /data/ext/pg_query/include/{storage → postgres/storage}/sync.h +0 -0
- /data/ext/pg_query/include/{tcop → postgres/tcop}/cmdtag.h +0 -0
- /data/ext/pg_query/include/{tcop → postgres/tcop}/cmdtaglist.h +0 -0
- /data/ext/pg_query/include/{tcop → postgres/tcop}/deparse_utility.h +0 -0
- /data/ext/pg_query/include/{tcop → postgres/tcop}/dest.h +0 -0
- /data/ext/pg_query/include/{tcop → postgres/tcop}/fastpath.h +0 -0
- /data/ext/pg_query/include/{tcop → postgres/tcop}/pquery.h +0 -0
- /data/ext/pg_query/include/{tcop → postgres/tcop}/utility.h +0 -0
- /data/ext/pg_query/include/{tsearch → postgres/tsearch}/ts_cache.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/acl.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/aclchk_internal.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/array.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/backend_progress.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/backend_status.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/bytea.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/catcache.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/date.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/datetime.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/datum.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/dsa.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/errcodes.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/expandeddatum.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/expandedrecord.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/float.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/fmgroids.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/fmgrprotos.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/fmgrtab.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/guc_hooks.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/guc_tables.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/hsearch.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/inval.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/logtape.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/lsyscache.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/memdebug.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/memutils_internal.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/memutils_memorychunk.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/numeric.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/partcache.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/pg_locale.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/pgstat_internal.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/plancache.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/portal.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/probes.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/ps_status.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/queryenvironment.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/regproc.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/rel.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/relcache.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/reltrigger.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/resowner.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/ruleutils.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/sharedtuplestore.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/snapmgr.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/snapshot.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/sortsupport.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/syscache.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/timeout.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/timestamp.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/tuplesort.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/tuplestore.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/typcache.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/varlena.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/wait_event.h +0 -0
- /data/ext/pg_query/include/{utils → postgres/utils}/xml.h +0 -0
- /data/ext/pg_query/include/{varatt.h → postgres/varatt.h} +0 -0
|
@@ -56,7 +56,7 @@ typedef struct MemoryContextCallback
|
|
|
56
56
|
* Avoid accessing it directly! Instead, use MemoryContextSwitchTo()
|
|
57
57
|
* to change the setting.
|
|
58
58
|
*/
|
|
59
|
-
extern PGDLLIMPORT __thread
|
|
59
|
+
extern PGDLLIMPORT __thread MemoryContext CurrentMemoryContext;
|
|
60
60
|
|
|
61
61
|
/*
|
|
62
62
|
* Flags for MemoryContextAllocExtended.
|
data/ext/pg_query/pg_query.c
CHANGED
|
@@ -5,15 +5,20 @@
|
|
|
5
5
|
#include <utils/memutils.h>
|
|
6
6
|
#include <utils/memdebug.h>
|
|
7
7
|
|
|
8
|
+
#ifdef HAVE_PTHREAD
|
|
8
9
|
#include <pthread.h>
|
|
10
|
+
#endif
|
|
11
|
+
|
|
9
12
|
#include <signal.h>
|
|
10
13
|
|
|
11
14
|
const char* progname = "pg_query";
|
|
12
15
|
|
|
13
16
|
__thread sig_atomic_t pg_query_initialized = 0;
|
|
14
17
|
|
|
18
|
+
#ifdef HAVE_PTHREAD
|
|
15
19
|
static pthread_key_t pg_query_thread_exit_key;
|
|
16
20
|
static void pg_query_thread_exit(void *key);
|
|
21
|
+
#endif
|
|
17
22
|
|
|
18
23
|
void pg_query_init(void)
|
|
19
24
|
{
|
|
@@ -23,8 +28,10 @@ void pg_query_init(void)
|
|
|
23
28
|
MemoryContextInit();
|
|
24
29
|
SetDatabaseEncoding(PG_UTF8);
|
|
25
30
|
|
|
31
|
+
#ifdef HAVE_PTHREAD
|
|
26
32
|
pthread_key_create(&pg_query_thread_exit_key, pg_query_thread_exit);
|
|
27
33
|
pthread_setspecific(pg_query_thread_exit_key, TopMemoryContext);
|
|
34
|
+
#endif
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
void pg_query_free_top_memory_context(MemoryContext context)
|
|
@@ -55,11 +62,13 @@ void pg_query_free_top_memory_context(MemoryContext context)
|
|
|
55
62
|
ErrorContext = NULL;
|
|
56
63
|
}
|
|
57
64
|
|
|
65
|
+
#ifdef HAVE_PTHREAD
|
|
58
66
|
static void pg_query_thread_exit(void *key)
|
|
59
67
|
{
|
|
60
68
|
MemoryContext context = (MemoryContext) key;
|
|
61
69
|
pg_query_free_top_memory_context(context);
|
|
62
70
|
}
|
|
71
|
+
#endif
|
|
63
72
|
|
|
64
73
|
void pg_query_exit(void)
|
|
65
74
|
{
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// Ensure we have asprintf's definition on glibc-based platforms to avoid compiler warnings
|
|
2
|
-
#define _GNU_SOURCE
|
|
3
1
|
#include <stdio.h>
|
|
4
2
|
|
|
5
3
|
#include "pg_query.h"
|
|
@@ -369,12 +367,13 @@ PgQueryFingerprintResult pg_query_fingerprint_with_opts(const char* input, int p
|
|
|
369
367
|
_fingerprintFreeContext(&ctx);
|
|
370
368
|
|
|
371
369
|
XXH64_canonicalFromHash(&chash, result.fingerprint);
|
|
372
|
-
|
|
370
|
+
result.fingerprint_str = malloc(17 * sizeof(char));
|
|
371
|
+
int n = snprintf(result.fingerprint_str, 17, "%02x%02x%02x%02x%02x%02x%02x%02x",
|
|
373
372
|
chash.digest[0], chash.digest[1], chash.digest[2], chash.digest[3],
|
|
374
373
|
chash.digest[4], chash.digest[5], chash.digest[6], chash.digest[7]);
|
|
375
|
-
if (
|
|
374
|
+
if (n < 0 || n >= 17) {
|
|
376
375
|
PgQueryError* error = malloc(sizeof(PgQueryError));
|
|
377
|
-
error->message = strdup("Failed to output fingerprint string due to
|
|
376
|
+
error->message = strdup("Failed to output fingerprint string due to snprintf failure");
|
|
378
377
|
result.error = error;
|
|
379
378
|
}
|
|
380
379
|
}
|
|
@@ -36,6 +36,12 @@
|
|
|
36
36
|
appendStringInfo(out, "\"" CppAsString(outname_json) "\":%u,", node->fldname); \
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/* Write an unsigned integer field */
|
|
40
|
+
#define WRITE_UINT64_FIELD(outname, outname_json, fldname) \
|
|
41
|
+
if (node->fldname != 0) { \
|
|
42
|
+
appendStringInfo(out, "\"" CppAsString(outname_json) "\":" UINT64_FORMAT ",", node->fldname); \
|
|
43
|
+
}
|
|
44
|
+
|
|
39
45
|
/* Write a long-integer field */
|
|
40
46
|
#define WRITE_LONG_FIELD(outname, outname_json, fldname) \
|
|
41
47
|
if (node->fldname != 0) { \
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
#define WRITE_INT_FIELD(outname, outname_json, fldname) out->outname = node->fldname;
|
|
25
25
|
#define WRITE_UINT_FIELD(outname, outname_json, fldname) out->outname = node->fldname;
|
|
26
|
+
#define WRITE_UINT64_FIELD(outname, outname_json, fldname) out->outname = node->fldname;
|
|
26
27
|
#define WRITE_LONG_FIELD(outname, outname_json, fldname) out->outname = node->fldname;
|
|
27
28
|
#define WRITE_FLOAT_FIELD(outname, outname_json, fldname) out->outname = node->fldname;
|
|
28
29
|
#define WRITE_BOOL_FIELD(outname, outname_json, fldname) out->outname = node->fldname;
|
|
@@ -153,7 +153,7 @@ PgQueryProtobufParseResult pg_query_parse_protobuf_opts(const char* input, int p
|
|
|
153
153
|
{
|
|
154
154
|
MemoryContext ctx = NULL;
|
|
155
155
|
PgQueryInternalParsetreeAndError parsetree_and_error;
|
|
156
|
-
PgQueryProtobufParseResult result = {};
|
|
156
|
+
PgQueryProtobufParseResult result = {0};
|
|
157
157
|
|
|
158
158
|
ctx = pg_query_enter_memory_context();
|
|
159
159
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#define _GNU_SOURCE // Necessary to get asprintf (which is a GNU extension)
|
|
2
1
|
#include <stdio.h>
|
|
3
2
|
|
|
4
3
|
#include "pg_query.h"
|
|
@@ -486,14 +485,17 @@ PgQueryPlpgsqlParseResult pg_query_parse_plpgsql(const char* input)
|
|
|
486
485
|
if (func_and_error.func != NULL) {
|
|
487
486
|
char *func_json;
|
|
488
487
|
char *new_out;
|
|
488
|
+
size_t new_out_len;
|
|
489
489
|
|
|
490
490
|
func_json = plpgsqlToJSON(func_and_error.func);
|
|
491
491
|
plpgsql_free_function_memory(func_and_error.func);
|
|
492
492
|
|
|
493
|
-
|
|
494
|
-
|
|
493
|
+
new_out_len = strlen(result.plpgsql_funcs) + strlen(func_json) + 3;
|
|
494
|
+
new_out = malloc(new_out_len);
|
|
495
|
+
int n = snprintf(new_out, new_out_len, "%s%s,\n", result.plpgsql_funcs, func_json);
|
|
496
|
+
if (n < 0 || n >= new_out_len) {
|
|
495
497
|
PgQueryError* error = malloc(sizeof(PgQueryError));
|
|
496
|
-
error->message = strdup("Failed to output PL/pgSQL functions due to
|
|
498
|
+
error->message = strdup("Failed to output PL/pgSQL functions due to snprintf failure");
|
|
497
499
|
result.error = error;
|
|
498
500
|
} else {
|
|
499
501
|
free(result.plpgsql_funcs);
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
#define READ_INT_FIELD(outname, outname_json, fldname) node->fldname = msg->outname;
|
|
16
16
|
#define READ_UINT_FIELD(outname, outname_json, fldname) node->fldname = msg->outname;
|
|
17
|
+
#define READ_UINT64_FIELD(outname, outname_json, fldname) node->fldname = msg->outname;
|
|
17
18
|
#define READ_LONG_FIELD(outname, outname_json, fldname) node->fldname = msg->outname;
|
|
18
19
|
#define READ_FLOAT_FIELD(outname, outname_json, fldname) node->fldname = msg->outname;
|
|
19
20
|
#define READ_BOOL_FIELD(outname, outname_json, fldname) node->fldname = msg->outname;
|
|
@@ -221,5 +221,10 @@ VALUE pg_query_ruby_hash_xxh3_64(VALUE self, VALUE input, VALUE seed)
|
|
|
221
221
|
Check_Type(input, T_STRING);
|
|
222
222
|
Check_Type(seed, T_FIXNUM);
|
|
223
223
|
|
|
224
|
+
#ifdef HAVE_LONG_LONG
|
|
225
|
+
return ULL2NUM(XXH3_64bits_withSeed(StringValuePtr(input), RSTRING_LEN(input), NUM2ULONG(seed)));
|
|
226
|
+
#else
|
|
224
227
|
return ULONG2NUM(XXH3_64bits_withSeed(StringValuePtr(input), RSTRING_LEN(input), NUM2ULONG(seed)));
|
|
228
|
+
#endif
|
|
229
|
+
|
|
225
230
|
}
|
|
@@ -166,7 +166,7 @@ PgQuerySplitResult pg_query_split_with_parser(const char* input)
|
|
|
166
166
|
{
|
|
167
167
|
MemoryContext ctx = NULL;
|
|
168
168
|
PgQueryInternalParsetreeAndError parsetree_and_error;
|
|
169
|
-
PgQuerySplitResult result = {};
|
|
169
|
+
PgQuerySplitResult result = {0};
|
|
170
170
|
|
|
171
171
|
ctx = pg_query_enter_memory_context();
|
|
172
172
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*--------------------------------------------------------------------
|
|
2
|
+
* Symbols referenced in this file:
|
|
3
|
+
* - newNodeMacroHolder
|
|
4
|
+
*--------------------------------------------------------------------
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/*-------------------------------------------------------------------------
|
|
8
|
+
*
|
|
9
|
+
* nodes.c
|
|
10
|
+
* support code for nodes (now that we have removed the home-brew
|
|
11
|
+
* inheritance system, our support code for nodes is much simpler)
|
|
12
|
+
*
|
|
13
|
+
* Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
|
|
14
|
+
* Portions Copyright (c) 1994, Regents of the University of California
|
|
15
|
+
*
|
|
16
|
+
*
|
|
17
|
+
* IDENTIFICATION
|
|
18
|
+
* src/backend/nodes/nodes.c
|
|
19
|
+
*
|
|
20
|
+
* HISTORY
|
|
21
|
+
* Andrew Yu Oct 20, 1994 file creation
|
|
22
|
+
*
|
|
23
|
+
*-------------------------------------------------------------------------
|
|
24
|
+
*/
|
|
25
|
+
#include "postgres.h"
|
|
26
|
+
|
|
27
|
+
#include "nodes/nodes.h"
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
* Support for newNode() macro
|
|
31
|
+
*
|
|
32
|
+
* In a GCC build there is no need for the global variable newNodeMacroHolder.
|
|
33
|
+
* However, we create it anyway, to support the case of a non-GCC-built
|
|
34
|
+
* loadable module being loaded into a GCC-built backend.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
__thread Node *newNodeMacroHolder;
|
|
38
|
+
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* - errstart
|
|
5
5
|
* - PG_exception_stack
|
|
6
6
|
* - write_stderr
|
|
7
|
-
* - err_gettext
|
|
8
7
|
* - in_error_recursion_trouble
|
|
9
8
|
* - error_context_stack
|
|
10
9
|
* - errordata_stack_depth
|
|
@@ -27,6 +26,7 @@
|
|
|
27
26
|
* - emit_log_hook
|
|
28
27
|
* - send_message_to_server_log
|
|
29
28
|
* - send_message_to_frontend
|
|
29
|
+
* - pgwin32_dispatch_queued_signals
|
|
30
30
|
* - set_stack_entry_location
|
|
31
31
|
* - matches_backtrace_functions
|
|
32
32
|
* - backtrace_symbol_list
|
|
@@ -45,6 +45,9 @@
|
|
|
45
45
|
* - errcontext_msg
|
|
46
46
|
* - CopyErrorData
|
|
47
47
|
* - FlushErrorState
|
|
48
|
+
* - pg_signal_queue
|
|
49
|
+
* - pg_signal_mask
|
|
50
|
+
* - pgwin32_dispatch_queued_signals
|
|
48
51
|
*--------------------------------------------------------------------
|
|
49
52
|
*/
|
|
50
53
|
|
|
@@ -302,24 +305,8 @@ should_output_to_server(int elevel)
|
|
|
302
305
|
/*
|
|
303
306
|
* should_output_to_client --- should message of given elevel go to the client?
|
|
304
307
|
*/
|
|
305
|
-
static inline bool
|
|
306
|
-
|
|
307
|
-
{
|
|
308
|
-
if (whereToSendOutput == DestRemote && elevel != LOG_SERVER_ONLY)
|
|
309
|
-
{
|
|
310
|
-
/*
|
|
311
|
-
* client_min_messages is honored only after we complete the
|
|
312
|
-
* authentication handshake. This is required both for security
|
|
313
|
-
* reasons and because many clients can't handle NOTICE messages
|
|
314
|
-
* during authentication.
|
|
315
|
-
*/
|
|
316
|
-
if (ClientAuthInProgress)
|
|
317
|
-
return (elevel >= ERROR);
|
|
318
|
-
else
|
|
319
|
-
return (elevel >= client_min_messages || elevel == INFO);
|
|
320
|
-
}
|
|
321
|
-
return false;
|
|
322
|
-
}
|
|
308
|
+
static inline bool should_output_to_client(int elevel) { return false; }
|
|
309
|
+
|
|
323
310
|
|
|
324
311
|
|
|
325
312
|
/*
|
|
@@ -352,18 +339,9 @@ in_error_recursion_trouble(void)
|
|
|
352
339
|
* message, since there's a significant probability that that's exactly
|
|
353
340
|
* what's causing the recursion.
|
|
354
341
|
*/
|
|
355
|
-
static inline const char *
|
|
356
|
-
err_gettext(const char *str)
|
|
357
|
-
{
|
|
358
342
|
#ifdef ENABLE_NLS
|
|
359
|
-
if (in_error_recursion_trouble())
|
|
360
|
-
return str;
|
|
361
|
-
else
|
|
362
|
-
return gettext(str);
|
|
363
343
|
#else
|
|
364
|
-
return str;
|
|
365
344
|
#endif
|
|
366
|
-
}
|
|
367
345
|
|
|
368
346
|
/*
|
|
369
347
|
* errstart_cold
|
|
@@ -1766,108 +1744,12 @@ pg_re_throw(void)
|
|
|
1766
1744
|
* interfaces (e.g. CreateFileA()) expect string arguments in this encoding.
|
|
1767
1745
|
* Every process in a given system will find the same value at all times.
|
|
1768
1746
|
*/
|
|
1769
|
-
static int
|
|
1770
|
-
GetACPEncoding(void)
|
|
1771
|
-
{
|
|
1772
|
-
static int encoding = -2;
|
|
1773
|
-
|
|
1774
|
-
if (encoding == -2)
|
|
1775
|
-
encoding = pg_codepage_to_encoding(GetACP());
|
|
1776
1747
|
|
|
1777
|
-
return encoding;
|
|
1778
|
-
}
|
|
1779
1748
|
|
|
1780
1749
|
/*
|
|
1781
1750
|
* Write a message line to the windows event log
|
|
1782
1751
|
*/
|
|
1783
|
-
static void
|
|
1784
|
-
write_eventlog(int level, const char *line, int len)
|
|
1785
|
-
{
|
|
1786
|
-
WCHAR *utf16;
|
|
1787
|
-
int eventlevel = EVENTLOG_ERROR_TYPE;
|
|
1788
|
-
static HANDLE evtHandle = INVALID_HANDLE_VALUE;
|
|
1789
|
-
|
|
1790
|
-
if (evtHandle == INVALID_HANDLE_VALUE)
|
|
1791
|
-
{
|
|
1792
|
-
evtHandle = RegisterEventSource(NULL,
|
|
1793
|
-
event_source ? event_source : DEFAULT_EVENT_SOURCE);
|
|
1794
|
-
if (evtHandle == NULL)
|
|
1795
|
-
{
|
|
1796
|
-
evtHandle = INVALID_HANDLE_VALUE;
|
|
1797
|
-
return;
|
|
1798
|
-
}
|
|
1799
|
-
}
|
|
1800
1752
|
|
|
1801
|
-
switch (level)
|
|
1802
|
-
{
|
|
1803
|
-
case DEBUG5:
|
|
1804
|
-
case DEBUG4:
|
|
1805
|
-
case DEBUG3:
|
|
1806
|
-
case DEBUG2:
|
|
1807
|
-
case DEBUG1:
|
|
1808
|
-
case LOG:
|
|
1809
|
-
case LOG_SERVER_ONLY:
|
|
1810
|
-
case INFO:
|
|
1811
|
-
case NOTICE:
|
|
1812
|
-
eventlevel = EVENTLOG_INFORMATION_TYPE;
|
|
1813
|
-
break;
|
|
1814
|
-
case WARNING:
|
|
1815
|
-
case WARNING_CLIENT_ONLY:
|
|
1816
|
-
eventlevel = EVENTLOG_WARNING_TYPE;
|
|
1817
|
-
break;
|
|
1818
|
-
case ERROR:
|
|
1819
|
-
case FATAL:
|
|
1820
|
-
case PANIC:
|
|
1821
|
-
default:
|
|
1822
|
-
eventlevel = EVENTLOG_ERROR_TYPE;
|
|
1823
|
-
break;
|
|
1824
|
-
}
|
|
1825
|
-
|
|
1826
|
-
/*
|
|
1827
|
-
* If message character encoding matches the encoding expected by
|
|
1828
|
-
* ReportEventA(), call it to avoid the hazards of conversion. Otherwise,
|
|
1829
|
-
* try to convert the message to UTF16 and write it with ReportEventW().
|
|
1830
|
-
* Fall back on ReportEventA() if conversion failed.
|
|
1831
|
-
*
|
|
1832
|
-
* Since we palloc the structure required for conversion, also fall
|
|
1833
|
-
* through to writing unconverted if we have not yet set up
|
|
1834
|
-
* CurrentMemoryContext.
|
|
1835
|
-
*
|
|
1836
|
-
* Also verify that we are not on our way into error recursion trouble due
|
|
1837
|
-
* to error messages thrown deep inside pgwin32_message_to_UTF16().
|
|
1838
|
-
*/
|
|
1839
|
-
if (!in_error_recursion_trouble() &&
|
|
1840
|
-
CurrentMemoryContext != NULL &&
|
|
1841
|
-
GetMessageEncoding() != GetACPEncoding())
|
|
1842
|
-
{
|
|
1843
|
-
utf16 = pgwin32_message_to_UTF16(line, len, NULL);
|
|
1844
|
-
if (utf16)
|
|
1845
|
-
{
|
|
1846
|
-
ReportEventW(evtHandle,
|
|
1847
|
-
eventlevel,
|
|
1848
|
-
0,
|
|
1849
|
-
0, /* All events are Id 0 */
|
|
1850
|
-
NULL,
|
|
1851
|
-
1,
|
|
1852
|
-
0,
|
|
1853
|
-
(LPCWSTR *) &utf16,
|
|
1854
|
-
NULL);
|
|
1855
|
-
/* XXX Try ReportEventA() when ReportEventW() fails? */
|
|
1856
|
-
|
|
1857
|
-
pfree(utf16);
|
|
1858
|
-
return;
|
|
1859
|
-
}
|
|
1860
|
-
}
|
|
1861
|
-
ReportEventA(evtHandle,
|
|
1862
|
-
eventlevel,
|
|
1863
|
-
0,
|
|
1864
|
-
0, /* All events are Id 0 */
|
|
1865
|
-
NULL,
|
|
1866
|
-
1,
|
|
1867
|
-
0,
|
|
1868
|
-
&line,
|
|
1869
|
-
NULL);
|
|
1870
|
-
}
|
|
1871
1753
|
#endif /* WIN32 */
|
|
1872
1754
|
|
|
1873
1755
|
#ifdef WIN32
|
|
@@ -2012,44 +1894,20 @@ static void send_message_to_frontend(ErrorData *edata) {}
|
|
|
2012
1894
|
* not available). Used before ereport/elog can be used
|
|
2013
1895
|
* safely (memory context, GUC load etc)
|
|
2014
1896
|
*/
|
|
1897
|
+
|
|
2015
1898
|
void
|
|
2016
1899
|
write_stderr(const char *fmt,...)
|
|
2017
1900
|
{
|
|
2018
|
-
va_list
|
|
2019
|
-
|
|
2020
|
-
#ifdef WIN32
|
|
2021
|
-
char errbuf[2048]; /* Arbitrary size? */
|
|
2022
|
-
#endif
|
|
2023
|
-
|
|
2024
|
-
fmt = _(fmt);
|
|
2025
|
-
|
|
1901
|
+
va_list ap;
|
|
2026
1902
|
va_start(ap, fmt);
|
|
2027
|
-
#ifndef WIN32
|
|
2028
|
-
/* On Unix, we just fprintf to stderr */
|
|
2029
1903
|
vfprintf(stderr, fmt, ap);
|
|
2030
1904
|
fflush(stderr);
|
|
2031
|
-
#else
|
|
2032
|
-
vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
|
|
2033
|
-
|
|
2034
|
-
/*
|
|
2035
|
-
* On Win32, we print to stderr if running on a console, or write to
|
|
2036
|
-
* eventlog if running as a service
|
|
2037
|
-
*/
|
|
2038
|
-
if (pgwin32_is_service()) /* Running as a service */
|
|
2039
|
-
{
|
|
2040
|
-
write_eventlog(ERROR, errbuf, strlen(errbuf));
|
|
2041
|
-
}
|
|
2042
|
-
else
|
|
2043
|
-
{
|
|
2044
|
-
/* Not running as service, write to stderr */
|
|
2045
|
-
write_console(errbuf, strlen(errbuf));
|
|
2046
|
-
fflush(stderr);
|
|
2047
|
-
}
|
|
2048
|
-
#endif
|
|
2049
1905
|
va_end(ap);
|
|
2050
1906
|
}
|
|
2051
1907
|
|
|
2052
1908
|
|
|
1909
|
+
|
|
1910
|
+
|
|
2053
1911
|
/*
|
|
2054
1912
|
* Write a message to STDERR using only async-signal-safe functions. This can
|
|
2055
1913
|
* be used to safely emit a message from a signal handler.
|
|
@@ -2076,3 +1934,10 @@ write_stderr(const char *fmt,...)
|
|
|
2076
1934
|
* hard-to-explain kluge.
|
|
2077
1935
|
*/
|
|
2078
1936
|
|
|
1937
|
+
#ifdef WIN32
|
|
1938
|
+
__thread volatile int pg_signal_queue;
|
|
1939
|
+
|
|
1940
|
+
__thread int pg_signal_mask;
|
|
1941
|
+
|
|
1942
|
+
void pgwin32_dispatch_queued_signals(void) {}
|
|
1943
|
+
#endif
|
|
@@ -91,7 +91,7 @@ __thread volatile uint32 CritSectionCount = 0;
|
|
|
91
91
|
/* full path to lib directory */
|
|
92
92
|
|
|
93
93
|
#ifdef EXEC_BACKEND
|
|
94
|
-
|
|
94
|
+
/* full path to backend */
|
|
95
95
|
|
|
96
96
|
/* note: currently this is not valid in backend processes */
|
|
97
97
|
#endif
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
* - pg_mbstrlen_with_len
|
|
18
18
|
* - pg_mblen
|
|
19
19
|
* - SetDatabaseEncoding
|
|
20
|
+
* - GetMessageEncoding
|
|
21
|
+
* - MessageEncoding
|
|
20
22
|
*--------------------------------------------------------------------
|
|
21
23
|
*/
|
|
22
24
|
|
|
@@ -105,6 +107,7 @@ static __thread const pg_enc2name *ClientEncoding = &pg_enc2name_tbl[PG_SQL_ASCI
|
|
|
105
107
|
|
|
106
108
|
static __thread const pg_enc2name *DatabaseEncoding = &pg_enc2name_tbl[PG_SQL_ASCII];
|
|
107
109
|
|
|
110
|
+
static __thread const pg_enc2name *MessageEncoding = &pg_enc2name_tbl[PG_SQL_ASCII];
|
|
108
111
|
|
|
109
112
|
|
|
110
113
|
/*
|
|
@@ -595,7 +598,11 @@ GetDatabaseEncodingName(void)
|
|
|
595
598
|
* not attached to a database, and under a database encoding lacking iconv
|
|
596
599
|
* support (MULE_INTERNAL).
|
|
597
600
|
*/
|
|
598
|
-
|
|
601
|
+
int
|
|
602
|
+
GetMessageEncoding(void)
|
|
603
|
+
{
|
|
604
|
+
return MessageEncoding->encoding;
|
|
605
|
+
}
|
|
599
606
|
|
|
600
607
|
|
|
601
608
|
/*
|
|
@@ -770,68 +777,6 @@ report_invalid_encoding(int encoding, const char *mbstr, int len)
|
|
|
770
777
|
* null. Returns NULL iff failed. Before MessageEncoding initialization, "str"
|
|
771
778
|
* should be ASCII-only; this will function as though MessageEncoding is UTF8.
|
|
772
779
|
*/
|
|
773
|
-
WCHAR *
|
|
774
|
-
pgwin32_message_to_UTF16(const char *str, int len, int *utf16len)
|
|
775
|
-
{
|
|
776
|
-
int msgenc = GetMessageEncoding();
|
|
777
|
-
WCHAR *utf16;
|
|
778
|
-
int dstlen;
|
|
779
|
-
UINT codepage;
|
|
780
|
-
|
|
781
|
-
if (msgenc == PG_SQL_ASCII)
|
|
782
|
-
/* No conversion is possible, and SQL_ASCII is never utf16. */
|
|
783
|
-
return NULL;
|
|
784
780
|
|
|
785
|
-
codepage = pg_enc2name_tbl[msgenc].codepage;
|
|
786
|
-
|
|
787
|
-
/*
|
|
788
|
-
* Use MultiByteToWideChar directly if there is a corresponding codepage,
|
|
789
|
-
* or double conversion through UTF8 if not. Double conversion is needed,
|
|
790
|
-
* for example, in an ENCODING=LATIN8, LC_CTYPE=C database.
|
|
791
|
-
*/
|
|
792
|
-
if (codepage != 0)
|
|
793
|
-
{
|
|
794
|
-
utf16 = (WCHAR *) palloc(sizeof(WCHAR) * (len + 1));
|
|
795
|
-
dstlen = MultiByteToWideChar(codepage, 0, str, len, utf16, len);
|
|
796
|
-
utf16[dstlen] = (WCHAR) 0;
|
|
797
|
-
}
|
|
798
|
-
else
|
|
799
|
-
{
|
|
800
|
-
char *utf8;
|
|
801
|
-
|
|
802
|
-
/*
|
|
803
|
-
* XXX pg_do_encoding_conversion() requires a transaction. In the
|
|
804
|
-
* absence of one, hope for the input to be valid UTF8.
|
|
805
|
-
*/
|
|
806
|
-
if (IsTransactionState())
|
|
807
|
-
{
|
|
808
|
-
utf8 = (char *) pg_do_encoding_conversion((unsigned char *) str,
|
|
809
|
-
len,
|
|
810
|
-
msgenc,
|
|
811
|
-
PG_UTF8);
|
|
812
|
-
if (utf8 != str)
|
|
813
|
-
len = strlen(utf8);
|
|
814
|
-
}
|
|
815
|
-
else
|
|
816
|
-
utf8 = (char *) str;
|
|
817
|
-
|
|
818
|
-
utf16 = (WCHAR *) palloc(sizeof(WCHAR) * (len + 1));
|
|
819
|
-
dstlen = MultiByteToWideChar(CP_UTF8, 0, utf8, len, utf16, len);
|
|
820
|
-
utf16[dstlen] = (WCHAR) 0;
|
|
821
|
-
|
|
822
|
-
if (utf8 != str)
|
|
823
|
-
pfree(utf8);
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
if (dstlen == 0 && len > 0)
|
|
827
|
-
{
|
|
828
|
-
pfree(utf16);
|
|
829
|
-
return NULL; /* error */
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
if (utf16len)
|
|
833
|
-
*utf16len = dstlen;
|
|
834
|
-
return utf16;
|
|
835
|
-
}
|
|
836
781
|
|
|
837
782
|
#endif /* WIN32 */
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/*--------------------------------------------------------------------
|
|
2
2
|
* Symbols referenced in this file:
|
|
3
3
|
* - log_min_messages
|
|
4
|
-
* - client_min_messages
|
|
5
4
|
* - backtrace_functions
|
|
6
5
|
* - check_function_bodies
|
|
7
6
|
*--------------------------------------------------------------------
|
|
@@ -285,7 +284,6 @@ __thread bool check_function_bodies = true;
|
|
|
285
284
|
|
|
286
285
|
__thread int log_min_messages = WARNING;
|
|
287
286
|
|
|
288
|
-
__thread int client_min_messages = NOTICE;
|
|
289
287
|
|
|
290
288
|
|
|
291
289
|
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
* Symbols referenced in this file:
|
|
3
3
|
* - pg_popcount64
|
|
4
4
|
* - pg_popcount64_slow
|
|
5
|
+
* - pg_popcount32
|
|
6
|
+
* - pg_popcount32_slow
|
|
7
|
+
* - pg_leftmost_one_pos
|
|
8
|
+
* - pg_rightmost_one_pos
|
|
9
|
+
* - pg_number_of_ones
|
|
5
10
|
*--------------------------------------------------------------------
|
|
6
11
|
*/
|
|
7
12
|
|
|
@@ -38,7 +43,24 @@
|
|
|
38
43
|
* HAVE__BUILTIN_CLZ is defined, but we provide it anyway, so that
|
|
39
44
|
* extensions possibly compiled with a different compiler can use it.
|
|
40
45
|
*/
|
|
41
|
-
|
|
46
|
+
const uint8 pg_leftmost_one_pos[256] = {
|
|
47
|
+
0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
|
|
48
|
+
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
|
49
|
+
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
|
50
|
+
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
|
51
|
+
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
|
52
|
+
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
|
53
|
+
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
|
54
|
+
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
|
55
|
+
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
|
56
|
+
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
|
57
|
+
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
|
58
|
+
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
|
59
|
+
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
|
60
|
+
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
|
61
|
+
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
|
62
|
+
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
|
|
63
|
+
};
|
|
42
64
|
|
|
43
65
|
/*
|
|
44
66
|
* Array giving the position of the right-most set bit for each possible
|
|
@@ -49,7 +71,24 @@
|
|
|
49
71
|
* HAVE__BUILTIN_CTZ is defined, but we provide it anyway, so that
|
|
50
72
|
* extensions possibly compiled with a different compiler can use it.
|
|
51
73
|
*/
|
|
52
|
-
|
|
74
|
+
const uint8 pg_rightmost_one_pos[256] = {
|
|
75
|
+
0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
76
|
+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
77
|
+
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
78
|
+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
79
|
+
6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
80
|
+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
81
|
+
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
82
|
+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
83
|
+
7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
84
|
+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
85
|
+
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
86
|
+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
87
|
+
6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
88
|
+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
89
|
+
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
90
|
+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
|
|
91
|
+
};
|
|
53
92
|
|
|
54
93
|
/*
|
|
55
94
|
* Array giving the number of 1-bits in each possible byte value.
|
|
@@ -57,7 +96,24 @@
|
|
|
57
96
|
* Note: we export this for use by functions in which explicit use
|
|
58
97
|
* of the popcount functions seems unlikely to be a win.
|
|
59
98
|
*/
|
|
60
|
-
|
|
99
|
+
const uint8 pg_number_of_ones[256] = {
|
|
100
|
+
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
|
|
101
|
+
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
|
102
|
+
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
|
103
|
+
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
|
104
|
+
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
|
105
|
+
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
|
106
|
+
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
|
107
|
+
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
|
108
|
+
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
|
109
|
+
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
|
110
|
+
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
|
111
|
+
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
|
112
|
+
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
|
113
|
+
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
|
114
|
+
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
|
115
|
+
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
|
|
116
|
+
};
|
|
61
117
|
|
|
62
118
|
static int pg_popcount32_slow(uint32 word);
|
|
63
119
|
static int pg_popcount64_slow(uint64 word);
|
|
@@ -175,9 +231,23 @@ __asm__ __volatile__(" popcntq %1,%0\n":"=q"(res):"rm"(word):"cc");
|
|
|
175
231
|
* pg_popcount32_slow
|
|
176
232
|
* Return the number of 1 bits set in word
|
|
177
233
|
*/
|
|
234
|
+
static int
|
|
235
|
+
pg_popcount32_slow(uint32 word)
|
|
236
|
+
{
|
|
178
237
|
#ifdef HAVE__BUILTIN_POPCOUNT
|
|
238
|
+
return __builtin_popcount(word);
|
|
179
239
|
#else /* !HAVE__BUILTIN_POPCOUNT */
|
|
240
|
+
int result = 0;
|
|
241
|
+
|
|
242
|
+
while (word != 0)
|
|
243
|
+
{
|
|
244
|
+
result += pg_number_of_ones[word & 255];
|
|
245
|
+
word >>= 8;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return result;
|
|
180
249
|
#endif /* HAVE__BUILTIN_POPCOUNT */
|
|
250
|
+
}
|
|
181
251
|
|
|
182
252
|
/*
|
|
183
253
|
* pg_popcount64_slow
|
|
@@ -216,7 +286,11 @@ pg_popcount64_slow(uint64 word)
|
|
|
216
286
|
* TRY_POPCNT_FAST is not defined. The compiler should be able to inline
|
|
217
287
|
* the slow versions here.
|
|
218
288
|
*/
|
|
219
|
-
|
|
289
|
+
int
|
|
290
|
+
pg_popcount32(uint32 word)
|
|
291
|
+
{
|
|
292
|
+
return pg_popcount32_slow(word);
|
|
293
|
+
}
|
|
220
294
|
|
|
221
295
|
int
|
|
222
296
|
pg_popcount64(uint64 word)
|