From 15efb4a323e4943589ae52587c49188a9c7fefa5 Mon Sep 17 00:00:00 2001 From: Vladimir Nadvornik Date: Tue, 15 Oct 2024 15:21:45 +0200 Subject: [PATCH] Do not use postgres extensions dblink and pgcrypto --- schema/reportdb/postgres/start.sql | 1 - schema/sm-specific-schema-patches/scopy.sh | 2 +- .../2014-pg_dblink_exec.sql.postgresql.dif | 24 ------------ .../postgres/procs/pg_dblink_exec.sql | 35 ------------------ schema/spacewalk/postgres/procs/procs.deps | 37 ++++++++----------- schema/spacewalk/postgres/start.sql | 2 - ...nager-schema.changes.nadvornik.drop_pg_ext | 1 + 7 files changed, 17 insertions(+), 85 deletions(-) delete mode 100644 schema/sm-specific-schema-patches/template/2014-pg_dblink_exec.sql.postgresql.dif delete mode 100644 schema/spacewalk/postgres/procs/pg_dblink_exec.sql create mode 100644 schema/spacewalk/susemanager-schema.changes.nadvornik.drop_pg_ext diff --git a/schema/reportdb/postgres/start.sql b/schema/reportdb/postgres/start.sql index 51d9b0311fa0..5830dcf41a6b 100644 --- a/schema/reportdb/postgres/start.sql +++ b/schema/reportdb/postgres/start.sql @@ -10,5 +10,4 @@ -- in this software or its documentation. -- -create extension dblink; diff --git a/schema/sm-specific-schema-patches/scopy.sh b/schema/sm-specific-schema-patches/scopy.sh index 0d082359497d..57585dd52a62 100755 --- a/schema/sm-specific-schema-patches/scopy.sh +++ b/schema/sm-specific-schema-patches/scopy.sh @@ -27,7 +27,7 @@ function find_source () { local db="" local imp_packages=(rhn_entitlements.pkb rhn_channel.pks rhn_channel.pkb rhn_server.pkb) - local imp_procs=(pg_dblink_exec create_first_org create_new_org) + local imp_procs=(create_first_org create_new_org) if [[ "$s" == *oracle ]]; then db="oracle" diff --git a/schema/sm-specific-schema-patches/template/2014-pg_dblink_exec.sql.postgresql.dif b/schema/sm-specific-schema-patches/template/2014-pg_dblink_exec.sql.postgresql.dif deleted file mode 100644 index 31a5b2b893e8..000000000000 --- a/schema/sm-specific-schema-patches/template/2014-pg_dblink_exec.sql.postgresql.dif +++ /dev/null @@ -1,24 +0,0 @@ -@@ -15,18 +15,21 @@ - - create or replace function pg_dblink_exec(in_sql in varchar) returns void as - $$ -+declare -+ conn text[]; - begin - if in_sql is null then - raise 'pg_dblink_exec in_sql is null'; - end if; -+ conn := dblink_get_connections(); -+ if conn is NULL or NOT(conn @> '{at_conn}') then - perform dblink_connect('at_conn', 'dbname=' || current_database() || ' port=' || coalesce(inet_server_port(), '5432')); -+ end if; - begin - perform dblink_exec('at_conn', in_sql, true); - exception when others then -- perform dblink_disconnect('at_conn'); - raise; - end; -- perform dblink_disconnect('at_conn'); - end; - $$ - language plpgsql; diff --git a/schema/spacewalk/postgres/procs/pg_dblink_exec.sql b/schema/spacewalk/postgres/procs/pg_dblink_exec.sql deleted file mode 100644 index 7f815eb71b3a..000000000000 --- a/schema/spacewalk/postgres/procs/pg_dblink_exec.sql +++ /dev/null @@ -1,35 +0,0 @@ --- oracle equivalent source none --- --- Copyright (c) 2012 - 2013 Red Hat, Inc. --- --- This software is licensed to you under the GNU General Public License, --- version 2 (GPLv2). There is NO WARRANTY for this software, express or --- implied, including the implied warranties of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 --- along with this software; if not, see --- http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. --- --- Red Hat trademarks are not licensed under GPLv2. No permission is --- granted to use or replicate Red Hat trademarks that are incorporated --- in this software or its documentation. - -create or replace function pg_dblink_exec(in_sql in varchar) returns void as -$$ -declare - conn text[]; -begin - if in_sql is null then - raise 'pg_dblink_exec in_sql is null'; - end if; - conn := dblink_get_connections(); - if conn is NULL or NOT(conn @> '{at_conn}') then - perform dblink_connect('at_conn', 'dbname=' || current_database() || ' port=' || coalesce(inet_server_port(), '5432')); - end if; - begin - perform dblink_exec('at_conn', in_sql, true); - exception when others then - raise; - end; -end; -$$ -language plpgsql; diff --git a/schema/spacewalk/postgres/procs/procs.deps b/schema/spacewalk/postgres/procs/procs.deps index 60a56ac1cc8c..4c8f307082a2 100644 --- a/schema/spacewalk/postgres/procs/procs.deps +++ b/schema/spacewalk/postgres/procs/procs.deps @@ -21,8 +21,7 @@ create_new_org :: web_customer rhnUserGroupType rhnUserGroup create_new_user :: web_contact web_user_contact_permission \ web_user_personal_info web_user_site_info \ rhnUserInfo -create_pxt_session :: pg_dblink_exec \ - PXTSessions +create_pxt_session :: PXTSessions delete_server :: rhn_channel.pks rhn_config.pks \ rhn_config.pks rhn_server.pks rhn_entitlements.pks \ rhn_server.pks \ @@ -58,13 +57,11 @@ does_user_have_role :: rhnUserGroup rhnUserGroupMembers rhnUserGroup lookup_arch_type :: data/rhnArchType rhn_exception.pks lookup_channel_arch :: rhn_exception.pks data/rhnException rhnChannelArch \ data/rhnChannelArch -lookup_client_capability :: rhnClientCapabilityName pg_dblink_exec +lookup_client_capability :: rhnClientCapabilityName lookup_cf_state :: rhnConfigFileState -lookup_config_filename :: pg_dblink_exec -lookup_config_info :: pg_dblink_exec -lookup_cve :: rhnCVE pg_dblink_exec +lookup_cve :: rhnCVE lookup_erratafile_type :: rhnErrataFileType data/rhnErrataFileType -lookup_evr :: rhnPackageEVR pg_dblink_exec +lookup_evr :: rhnPackageEVR lookup_feature_type :: rhnFeature lookup_first_matching_cf :: rhnConfigFile rhnConfigChannel \ rhnServerConfigChannel lookup_cf_state \ @@ -78,34 +75,30 @@ lookup_functions :: lookup_evr lookup_package_name \ lookup_snapshot_invalid_reason \ lookup_tag_name lookup_sg_type \ lookup_tag lookup_arch_type -lookup_checksum :: pg_dblink_exec -lookup_md_keyword :: pg_dblink_exec suseMdKeyword +lookup_md_keyword :: suseMdKeyword lookup_package_arch :: rhn_exception.pks data/rhnException rhnPackageArch \ data/rhnPackageArch lookup_package_capability :: rhnPackageCapability lookup_package_delta :: rhnPackageDelta -lookup_package_name :: rhnPackageName pg_dblink_exec +lookup_package_name :: rhnPackageName lookup_package_provider :: rhnPackageProvider lookup_package_key_type :: rhnPackageKeyType -lookup_package_nevra :: rhnPackageNEVRA pg_dblink_exec -lookup_package_group :: rhnPackageGroup pg_dblink_exec +lookup_package_nevra :: rhnPackageNEVRA +lookup_package_group :: rhnPackageGroup lookup_server_arch :: rhn_exception.pks data/rhnException rhnServerArch \ data/rhnServerArch lookup_sg_type :: rhnServerGroupType lookup_snapshot_invalid_reason :: rhnSnapshotInvalidReason -lookup_source_name :: rhnSourceRPM pg_dblink_exec -lookup_tag :: rhnTag lookup_tag_name pg_dblink_exec -lookup_tag_name :: rhnTagName pg_dblink_exec +lookup_source_name :: rhnSourceRPM +lookup_tag :: rhnTag lookup_tag_name +lookup_tag_name :: rhnTagName lookup_transaction_package :: rhnTransactionOperation lookup_package_name \ lookup_evr lookup_package_arch \ - rhnTransactionPackage rhn_exception.pks \ - pg_dblink_exec -lookup_xccdf_benchmark :: rhnXccdfBenchmark pg_dblink_exec + rhnTransactionPackage rhn_exception.pks +lookup_xccdf_benchmark :: rhnXccdfBenchmark lookup_xccdf_ident :: rhnXccdfIdentSystem \ - rhnXccdfIdent \ - pg_dblink_exec -lookup_xccdf_profile :: rhnXccdfProfile \ - pg_dblink_exec + rhnXccdfIdent +lookup_xccdf_profile :: rhnXccdfProfile queue_server :: rhnTaskQueue rhnServer \ rhn_server.update_needed_cache queue_image :: rhnTaskQueue suseImageInfo \ diff --git a/schema/spacewalk/postgres/start.sql b/schema/spacewalk/postgres/start.sql index a6364c948271..c1199626a560 100644 --- a/schema/spacewalk/postgres/start.sql +++ b/schema/spacewalk/postgres/start.sql @@ -13,5 +13,3 @@ -- in this software or its documentation. -- -create extension dblink; -CREATE EXTENSION pgcrypto; diff --git a/schema/spacewalk/susemanager-schema.changes.nadvornik.drop_pg_ext b/schema/spacewalk/susemanager-schema.changes.nadvornik.drop_pg_ext new file mode 100644 index 000000000000..c64f2de90cbd --- /dev/null +++ b/schema/spacewalk/susemanager-schema.changes.nadvornik.drop_pg_ext @@ -0,0 +1 @@ +- Do not use postgres extensions dblink and pgcrypto