schema/spacewalk/schema-source-sanity-check.pl
| 31 +-
schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/004-rhn_channel-body.sql.postgresql
| 25 +
schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/005-rhn_package-drop.sql.postgresql
| 4
schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/006-rhn_org.sql.postgresql
| 11
schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/007-rhn_org-body.sql.postgresql
| 138 ++++++++++
schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/008-channel_name_join-drop.sql.postgresql
| 3
schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/009-channel_name_t-drop.sql.postgresql
| 3
schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/010-rpm.sql.postgresql
| 3
schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/011-rpm-body.sql.postgresql
| 35 ++
schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/012-rhn_user.sql.postgresql
| 12
schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/013-rhn_user-body.sql.postgresql
| 3
schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/014-rhn_entitlement_pkb.sql.postgresql
| 81 +++++
12 files changed, 338 insertions(+), 11 deletions(-)
New commits:
commit ce4e235db8e3801a96490b519297572b38083cfa
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 25 16:33:27 2011 +0100
Update schema-source-sanity-check.pl to process schema upgrades as well.
diff --git a/schema/spacewalk/schema-source-sanity-check.pl
b/schema/spacewalk/schema-source-sanity-check.pl
index bcc4ff7..e4bbbe5 100644
--- a/schema/spacewalk/schema-source-sanity-check.pl
+++ b/schema/spacewalk/schema-source-sanity-check.pl
@@ -11,7 +11,7 @@ my %files;
my $show_ignored = 0;
Getopt::Long::GetOptions('I' => \$show_ignored) or exit 9;
-for my $dir (qw( common oracle postgres )) {
+for my $dir (qw( common oracle postgres upgrade )) {
File::Find::find(sub {
my $name = $File::Find::name;
if ($name eq $dir) {
@@ -23,8 +23,17 @@ for my $dir (qw( common oracle postgres )) {
if (substr($name, 0, length($dir) + 1) ne "$dir/") {
die "In dir [$dir] we got [$name]\n";
}
- my $rname = substr($name, length($dir) + 1);
- $files{$dir}{$rname} = $_;
+ if ($dir eq 'upgrade') {
+ my $generic = $name;
+ if ($generic =~ s/\.(oracle|postgresql)$//) {
+ my $db = $1;
+ $db = 'postgres' if $db eq 'postgresql';
+ $files{$db}{$generic} = $name;
+ }
+ } else {
+ my $rname = substr($name, length($dir) + 1);
+ $files{$dir}{$rname} = $name;
+ }
}, $dir);
}
@@ -50,15 +59,15 @@ for my $c (sort keys %{ $files{oracle} }) {
for my $c (sort keys %{ $files{postgres} }) {
next unless $c =~ /\.(sql|pks|pkb)$/;
local *FILE;
- open FILE, "postgres/$c" or do {
- print "Error reading postgres/$c: $!\n";
+ open FILE, '<', $files{postgres}{$c} or do {
+ print "Error reading [$files{postgres}{$c}]: $!\n";
$error = 1;
next;
};
my $first_line = <FILE>;
close FILE;
- if (not $first_line =~ /^-- oracle equivalent source (?:(none)|sha1 ([0-9a-f]{40}))$/)
{
- print "File postgres/$c does not specify SHA1 of Oracle source nor none\n" if
$show_ignored;
+ if (not defined $first_line or not $first_line =~ /^-- oracle equivalent source
(?:(none)|sha1 ([0-9a-f]{40}))$/) {
+ print "PostgreSQL file [$c] does not specify SHA1 of Oracle source nor
none\n" if $show_ignored;
# $error = 1;
next;
}
@@ -76,8 +85,8 @@ for my $c (sort keys %{ $files{postgres} }) {
$error = 1;
next;
}
- open FILE, "oracle/$c" or do {
- print "Error reading oracle/$c to verify SHA1: $!\n";
+ open FILE, '<', $files{oracle}{$c} or do {
+ print "Error reading Oracle [$files{oracle}{$c}] to verify SHA1: $!\n";
$error = 1;
next;
};
@@ -86,7 +95,7 @@ for my $c (sort keys %{ $files{postgres} }) {
my $sha1_hex = $sha1->hexdigest();
close FILE;
if ($oracle_sha1 ne $sha1_hex) {
- print "File postgres/$c says SHA1 of Oracle source should be [$oracle_sha1] but it
is [$sha1_hex]\n";
+ print "PostgreSQL file [$c] says SHA1 of Oracle source should be [$oracle_sha1]
but it is [$sha1_hex]\n";
$error = 1;
}
}
commit 9af02e5c93bbb0a3d8cbf6f1be5327f8bc14fae6
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 25 17:28:26 2011 +0100
Fixing next if which was on bad place.
diff --git a/schema/spacewalk/schema-source-sanity-check.pl
b/schema/spacewalk/schema-source-sanity-check.pl
index 252eab0..bcc4ff7 100644
--- a/schema/spacewalk/schema-source-sanity-check.pl
+++ b/schema/spacewalk/schema-source-sanity-check.pl
@@ -30,8 +30,8 @@ for my $dir (qw( common oracle postgres )) {
my $error = 0;
for my $c (sort keys %{ $files{common} }) {
+ next unless $c =~ /\.(sql|pks|pkb)$/;
for my $o (qw( oracle postgres )) {
- next unless $o =~ /\.(sql|pks|pkb)$/;
if (exists $files{$o}{$c}) {
print "Common file [$c] is also in $o\n";
$error = 1;
commit 696e48a49d84f1d69c4f8b5ae068462bd3781381
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 25 16:18:45 2011 +0100
Empty schema upgrade on PostgreSQL for channel_name_t and channel_name_join.
They did not exist on PostgreSQL, so no schema upgrade needed, just
putting it in here to make counterpart for the .oracle files.
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/008-channel_name_join-drop.sql.postgresql
b/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/008-channel_name_join-drop.sql.postgresql
new file mode 100644
index 0000000..cae4024
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/008-channel_name_join-drop.sql.postgresql
@@ -0,0 +1,3 @@
+-- oracle equivalent source sha1 412e8302446320f3117deeb7415ad18e91be1191
+--
+-- This file is intentionally left empty.
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/009-channel_name_t-drop.sql.postgresql
b/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/009-channel_name_t-drop.sql.postgresql
new file mode 100644
index 0000000..0fc465f
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/009-channel_name_t-drop.sql.postgresql
@@ -0,0 +1,3 @@
+-- oracle equivalent source sha1 1e792602606d4063c6f684c0100b241aeaf34165
+--
+-- This file is intentionally left empty.
commit 347b391b630e3e5ff927941aef69207a477bb880
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 25 16:13:49 2011 +0100
Adding rpm (vercmp) PostgreSQL schema upgrade script.
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/010-rpm.sql.postgresql
b/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/010-rpm.sql.postgresql
new file mode 100644
index 0000000..d58038c
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/010-rpm.sql.postgresql
@@ -0,0 +1,3 @@
+-- oracle equivalent source sha1 1f8b5508a1d7ce29135f848b78b6564d005747b8
+--
+-- This file is intentionally left empty.
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/011-rpm-body.sql.postgresql
b/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/011-rpm-body.sql.postgresql
new file mode 100644
index 0000000..de5041d
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/011-rpm-body.sql.postgresql
@@ -0,0 +1,35 @@
+-- oracle equivalent source sha1 625d2c9b448240a736f369e7b53a386ce9c1f28a
+
+--update pg_setting
+update pg_settings set setting = 'rpm,' || setting where name =
'search_path';
+
+ create or replace FUNCTION vercmp(
+ e1 VARCHAR, v1 VARCHAR, r1 VARCHAR,
+ e2 VARCHAR, v2 VARCHAR, r2 VARCHAR)
+ RETURNS INTEGER as $$
+ declare
+ rc INTEGER;
+ ep1 INTEGER;
+ ep2 INTEGER;
+ BEGIN
+ if e1 is null or e1 = '' then
+ ep1 := 0;
+ else
+ ep1 := e1::integer;
+ end if;
+ if e2 is null or e2 = '' then
+ ep2 := 0;
+ else
+ ep2 := e2::integer;
+ end if;
+ -- Epochs are non-null; compare them
+ if ep1 < ep2 then return -1; end if;
+ if ep1 > ep2 then return 1; end if;
+ rc := rpm.rpmstrcmp(v1, v2);
+ if rc != 0 then return rc; end if;
+ return rpm.rpmstrcmp(r1, r2);
+ END;
+ $$ language 'plpgsql';
+
+-- restore the original setting
+update pg_settings set setting = overlay( setting placing '' from 1 for
(length('rpm')+1) ) where name = 'search_path';
commit cc92b73777ec6b64609ee9b48b25100c154cd953
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 25 16:09:41 2011 +0100
Adding rhn_entitlement PostgreSQL schema upgrade script.
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/014-rhn_entitlement_pkb.sql.postgresql
b/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/014-rhn_entitlement_pkb.sql.postgresql
new file mode 100644
index 0000000..7102902
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/014-rhn_entitlement_pkb.sql.postgresql
@@ -0,0 +1,81 @@
+-- oracle equivalent source sha1 16f4e58f383e0a61bf752b1a99a31a86780659dd
+--
+-- Copyright (c) 2011 Red Hat, Inc.
+
+-- setup search_path so that these functions are created in appropriate schema.
+update pg_settings set setting = 'rhn_entitlements,' || setting where name =
'search_path';
+
+ create or replace function set_customer_enterprise (
+ customer_id_in in numeric
+ ) returns void
+as $$
+ begin
+ perform rhn_entitlements.modify_org_service(customer_id_in, 'enterprise',
'Y');
+ end$$
+language plpgsql;
+
+ create or replace function set_customer_provisioning (
+ customer_id_in in numeric
+ ) returns void
+as $$
+ begin
+ perform rhn_entitlements.modify_org_service(customer_id_in,
'provisioning', 'Y');
+ end$$
+language plpgsql;
+
+ create or replace function set_customer_monitoring (
+ customer_id_in in numeric
+ ) returns void
+as $$
+ begin
+ perform rhn_entitlements.modify_org_service(customer_id_in, 'monitoring',
'Y');
+ end$$
+language plpgsql;
+
+ create or replace function set_customer_nonlinux (
+ customer_id_in in numeric
+ ) returns void
+as $$
+ begin
+ perform rhn_entitlements.modify_org_service(customer_id_in, 'nonlinux',
'Y');
+ end$$
+language plpgsql;
+
+ create or replace function unset_customer_enterprise (
+ customer_id_in in numeric
+ ) returns void
+as $$
+ begin
+ perform rhn_entitlements.modify_org_service(customer_id_in, 'enterprise',
'N');
+ end$$
+language plpgsql;
+
+ create or replace function unset_customer_provisioning (
+ customer_id_in in numeric
+ ) returns void
+as $$
+ begin
+ perform rhn_entitlements.modify_org_service(customer_id_in,
'provisioning', 'N');
+ end$$
+language plpgsql;
+
+ create or replace function unset_customer_monitoring (
+ customer_id_in in numeric
+ ) returns void
+as $$
+ begin
+ perform rhn_entitlements.modify_org_service(customer_id_in, 'monitoring',
'N');
+ end$$
+language plpgsql;
+
+ create or replace function unset_customer_nonlinux (
+ customer_id_in in numeric
+ ) returns void
+as $$
+ begin
+ perform rhn_entitlements.modify_org_service(customer_id_in, 'nonlinux',
'N');
+ end$$
+language plpgsql;
+
+-- restore the original setting
+update pg_settings set setting = overlay( setting placing '' from 1 for
(length('rhn_entitlements')+1) ) where name = 'search_path';
commit f0a84995f13e82af5fc74ea02baf67ffd319c55f
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 25 16:02:53 2011 +0100
Adding rhn_channel PostgreSQL schema upgrade script.
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/004-rhn_channel-body.sql.postgresql
b/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/004-rhn_channel-body.sql.postgresql
new file mode 100644
index 0000000..eb387bc
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/004-rhn_channel-body.sql.postgresql
@@ -0,0 +1,25 @@
+-- oracle equivalent source sha1 9d36eb7011645e0a66b8e357f196393b63c1024e
+--
+-- Copyright (c) 2011 Red Hat, Inc.
+
+--update pg_setting
+update pg_settings set setting = 'rhn_channel,' || setting where name =
'search_path';
+
+ create or replace function can_server_consume_fve(server_id_in in numeric) returns
numeric
+ as $$
+ declare
+ vi_entries cursor for
+ SELECT 1
+ FROM rhnVirtualInstance vi
+ WHERE vi.virtual_system_id = server_id_in;
+ vi_count numeric;
+
+ begin
+ FOR vi_entry IN VI_ENTRIES LOOP
+ return 1;
+ END LOOP;
+ RETURN 0;
+ end$$ language plpgsql;
+
+-- restore the original setting
+update pg_settings set setting = overlay( setting placing '' from 1 for
(length('rhn_channel')+1) ) where name = 'search_path';
commit 97235a402afbc30b7e34d6c65951e8a53c558b08
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 25 14:29:01 2011 +0100
Adding rhn_user PostgreSQL schema upgrade scripts.
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/012-rhn_user.sql.postgresql
b/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/012-rhn_user.sql.postgresql
new file mode 100644
index 0000000..b80bb06
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/012-rhn_user.sql.postgresql
@@ -0,0 +1,12 @@
+-- oracle equivalent source sha1 054658f16439e0bb3772d52b90edd7a1e7b4feff
+--
+-- Copyright (c) 2011 Red Hat, Inc.
+
+-- setup search_path so that these functions are created in appropriate schema.
+update pg_settings set setting = 'rhn_user,' || setting where name =
'search_path';
+
+drop function add_users_to_usergroups(user_id_in in numeric);
+drop function remove_users_from_servergroups(user_id_in in numeric);
+
+-- restore the original setting
+update pg_settings set setting = overlay( setting placing '' from 1 for
(length('rhn_user')+1) ) where name = 'search_path';
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/013-rhn_user-body.sql.postgresql
b/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/013-rhn_user-body.sql.postgresql
new file mode 100644
index 0000000..61f2d7b
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/013-rhn_user-body.sql.postgresql
@@ -0,0 +1,3 @@
+-- oracle equivalent source sha1 2e392775c7d2f4fda07a71107958ce84c38c874c
+
+-- This file is intentionally left empty.
commit fde90b97b97e3141048f326c7f6fa95303838ed3
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 25 14:28:25 2011 +0100
Adding rhn_package PostgreSQL schema upgrade script (dropping the schema).
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/005-rhn_package-drop.sql.postgresql
b/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/005-rhn_package-drop.sql.postgresql
new file mode 100644
index 0000000..888e3b6
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/005-rhn_package-drop.sql.postgresql
@@ -0,0 +1,4 @@
+-- oracle equivalent source sha1 a89010cda37aa555d62ea4cb5e543cf25134b21a
+
+drop schema rhn_package cascade;
+
commit 8dbbe1aae49d875b4b05bb5dac6ca1c2176deeab
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 25 14:26:05 2011 +0100
Adding rhn_org PostgreSQL schema upgrade scripts.
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/006-rhn_org.sql.postgresql
b/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/006-rhn_org.sql.postgresql
new file mode 100644
index 0000000..272d83d
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/006-rhn_org.sql.postgresql
@@ -0,0 +1,11 @@
+-- oracle equivalent source sha1 f19b747e0d9e2f2db3745679cdb0397e2be64650
+--
+-- Copyright (c) 2011 Red Hat, Inc.
+
+-- setup search_path so that these functions are created in appropriate schema.
+update pg_settings set setting = 'rhn_org,' || setting where name =
'search_path';
+
+drop function find_server_group_by_type(org_id_in NUMERIC, group_label_in VARCHAR);
+
+-- restore the original setting
+update pg_settings set setting = overlay( setting placing '' from 1 for
(length('rhn_org')+1) ) where name = 'search_path';
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/007-rhn_org-body.sql.postgresql
b/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/007-rhn_org-body.sql.postgresql
new file mode 100644
index 0000000..4ac7858
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.2-to-spacewalk-schema-1.3/007-rhn_org-body.sql.postgresql
@@ -0,0 +1,138 @@
+-- oracle equivalent source sha1 78ceb7a44befb2120e46a7d40ac1cd32f1227f06
+--
+-- Copyright (c) 2011 Red Hat, Inc.
+
+-- setup search_path so that these functions are created in appropriate schema.
+update pg_settings set setting = 'rhn_org,' || setting where name =
'search_path';
+
+create or replace function delete_user(user_id_in in numeric, deleting_org in numeric
default 0) returns void
+ as
+ $$
+ declare
+ servergroups_needing_admins cursor for
+ select usgp.server_group_id server_group_id
+ from rhnUserServerGroupPerms usgp
+ where 1=1
+ and usgp.user_id = user_id_in
+ and not exists (
+ select 1
+ from rhnUserServerGroupPerms sq_usgp
+ where 1=1
+ and sq_usgp.server_group_id = usgp.server_group_id
+ and sq_usgp.user_id != user_id_in
+ );
+ users numeric;
+ our_org_id numeric;
+ other_users numeric;
+ other_org_admin numeric;
+ other_user_id numeric;
+ is_admin numeric;
+ begin
+ select wc.org_id
+ into our_org_id
+ from web_contact wc
+ where id = user_id_in;
+
+ -- find any other users
+ begin
+ select id, 1
+ into other_user_id, other_users
+ from web_contact
+ where 1=1
+ and org_id = our_org_id
+ and id != user_id_in
+ limit 1;
+ exception
+ when no_data_found then
+ other_users := 0;
+ end;
+
+ -- now do org admin stuff
+ if other_users != 0 then
+ -- is user admin?
+ select count(1)
+ into is_admin
+ from rhnUserGroupType ugt,
+ rhnUserGroup ug,
+ rhnUserGroupMembers ugm
+ where ugm.user_id = user_id_in
+ and ugm.user_group_id = ug.id
+ and ug.group_type = ugt.id
+ and ugt.label = 'org_admin';
+ if is_admin > 0 then
+ begin
+ select new_ugm.user_id
+ into other_org_admin
+ from rhnUserGroupMembers new_ugm,
+ rhnUserGroupType ugt,
+ rhnUserGroup ug,
+ rhnUserGroupMembers ugm
+ where ugm.user_id = user_id_in
+ and ugm.user_group_id = ug.id
+ and ug.group_type = ugt.id
+ and ugt.label = 'org_admin'
+ and ug.id = new_ugm.user_group_id
+ and new_ugm.user_id != user_id_in
+ limit 1;
+ exception
+ when no_data_found then
+ -- If we're deleting the org, we don't want to raise
+ -- the exception.
+ if deleting_org = 0 then
+ perform
rhn_exception.raise_exception('cannot_delete_user');
+ end if;
+ end;
+
+ for sg in servergroups_needing_admins loop
+ perform rhn_user.add_servergroup_perm(other_org_admin,
+ sg.server_group_id);
+ end loop;
+ end if;
+ end if;
+
+ -- and now things for every user
+ delete from rhn_command_queue_sessions where contact_id = user_id_in;
+ delete from rhn_contact_groups
+ where recid in (
+ select contact_group_id
+ from rhn_contact_group_members
+ where member_contact_method_id in (
+ select recid from rhn_contact_methods
+ where contact_id = user_id_in
+ )
+ )
+ and not exists (
+ select 1
+ from rhn_contact_group_members, rhn_contact_methods
+ where rhn_contact_groups.recid =
rhn_contact_group_members.contact_group_id
+ and rhn_contact_group_members.member_contact_method_id =
rhn_contact_methods.recid
+ and rhn_contact_methods.contact_id <> user_id_in
+ );
+ delete from rhn_contact_methods where contact_id = user_id_in;
+ delete from rhn_redirects where contact_id = user_id_in;
+ delete from rhnUserServerPerms where user_id = user_id_in;
+ delete from rhnAppInstallSession where user_id = user_id_in;
+ update rhnConfigRevision
+ set changed_by_id = NULL
+ where changed_by_id = user_id_in;
+ if other_users != 0 then
+ update rhnRegToken
+ set user_id = coalesce(other_org_admin, other_user_id)
+ where org_id = our_org_id
+ and user_id = user_id_in;
+ end if;
+
+ begin
+ delete from web_contact where id = user_id_in;
+ exception
+ when others then
+ perform rhn_exception.raise_exception('cannot_delete_user');
+ end;
+ return;
+
+ end;
+ $$
+ language plpgsql;
+
+-- restore the original setting
+update pg_settings set setting = overlay( setting placing '' from 1 for
(length('rhn_org')+1) ) where name = 'search_path';