backend/server/rhnSQL/sql_row.py | 7 -
backend/server/rhnSQL/sql_table.py | 8 -
schema/spacewalk/postgres/packages/rhn_entitlements.pkb | 73 +++++++---------
schema/spacewalk/postgres/packages/rhn_server.pkb | 17 ---
4 files changed, 38 insertions(+), 67 deletions(-)
New commits:
commit 90c15eb1ce50d3892026ce43715ac1357db2334d
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Fri Oct 29 17:27:15 2010 +0200
The Oracle version and use of find_compatible_sg was changed in
b6832310938382e6f4e0f3c2d26807f4594ae96d, the comment no longer true.
diff --git a/schema/spacewalk/postgres/packages/rhn_entitlements.pkb
b/schema/spacewalk/postgres/packages/rhn_entitlements.pkb
index 699c3aa..a11b4fa 100644
--- a/schema/spacewalk/postgres/packages/rhn_entitlements.pkb
+++ b/schema/spacewalk/postgres/packages/rhn_entitlements.pkb
@@ -26,7 +26,6 @@
-- setup search_path so that these functions are created in appropriate schema.
update pg_settings set setting = 'rhn_entitlements,' || setting where name =
'search_path';
- -- returns NULL if no match found; this is different from the Oracle coding
create or replace function find_compatible_sg (
server_id_in in numeric,
type_label_in in varchar
commit 78b9966e3fd23e3703650832acfa0d60bb68bab8
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Fri Oct 29 17:26:20 2010 +0200
Move the source of find_compatible_sg up in the file, to match the position of the
Oracle code.
diff --git a/schema/spacewalk/postgres/packages/rhn_entitlements.pkb
b/schema/spacewalk/postgres/packages/rhn_entitlements.pkb
index 98d4a2a..699c3aa 100644
--- a/schema/spacewalk/postgres/packages/rhn_entitlements.pkb
+++ b/schema/spacewalk/postgres/packages/rhn_entitlements.pkb
@@ -26,6 +26,43 @@
-- setup search_path so that these functions are created in appropriate schema.
update pg_settings set setting = 'rhn_entitlements,' || setting where name =
'search_path';
+ -- returns NULL if no match found; this is different from the Oracle coding
+ create or replace function find_compatible_sg (
+ server_id_in in numeric,
+ type_label_in in varchar
+ )
+ returns numeric
+as $$
+ declare
+ servergroups cursor for
+ select sg.id
+ from rhnServerGroupType sgt,
+ rhnServerGroup sg,
+ rhnServer s,
+ rhnServerServerGroupArchCompat ssgac
+ where s.id = server_id_in
+ and s.org_id = sg.org_id
+ and sgt.label = type_label_in
+ and sg.group_type = sgt.id
+ and ssgac.server_group_type = sgt.id
+ and ssgac.server_arch_id = s.server_arch_id
+ and not exists (
+ select 1
+ from rhnServerGroupMembers sgm
+ where sgm.server_group_id = sg.id
+ and sgm.server_id = s.id);
+
+
+ begin
+ for servergroup in servergroups loop
+ return servergroup.id;
+ end loop;
+
+ --no servergroup found
+ return NULL;
+ end$$
+language plpgsql;
+
-- *******************************************************************
-- PROCEDURE: remove_org_entitlements
--
@@ -290,43 +327,6 @@ as $$
end$$
language plpgsql;
- -- returns NULL if no match found; this is different from the Oracle coding
- create or replace function find_compatible_sg (
- server_id_in in numeric,
- type_label_in in varchar
- )
- returns numeric
-as $$
- declare
- servergroups cursor for
- select sg.id
- from rhnServerGroupType sgt,
- rhnServerGroup sg,
- rhnServer s,
- rhnServerServerGroupArchCompat ssgac
- where s.id = server_id_in
- and s.org_id = sg.org_id
- and sgt.label = type_label_in
- and sg.group_type = sgt.id
- and ssgac.server_group_type = sgt.id
- and ssgac.server_arch_id = s.server_arch_id
- and not exists (
- select 1
- from rhnServerGroupMembers sgm
- where sgm.server_group_id = sg.id
- and sgm.server_id = s.id);
-
-
- begin
- for servergroup in servergroups loop
- return servergroup.id;
- end loop;
-
- --no servergroup found
- return NULL;
- end$$
-language plpgsql;
-
create or replace function entitle_server (
server_id_in in numeric,
type_label_in in varchar default 'sw_mgr_entitled'
commit 59f67aa807e05e365512c68eb11f13c0c9901e24
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Fri Oct 29 17:00:39 2010 +0200
Removing select with rownum. It seems not that useful anyway.
We cannot use rownum in PostgreSQL, and besides, if the table
does not exist, the code will fail later. We will save one select
here and there.
diff --git a/backend/server/rhnSQL/sql_row.py b/backend/server/rhnSQL/sql_row.py
index c10788c..856d799 100644
--- a/backend/server/rhnSQL/sql_row.py
+++ b/backend/server/rhnSQL/sql_row.py
@@ -37,13 +37,6 @@ class Row(UserDictCase):
self.db = db
self.table = table
self.hashname = string.lower(hashname)
- # see if the table exists
- sql = "select %s from %s where rownum = 0" % (self.hashname, self.table)
- try:
- h = self.db.prepare(sql)
- except:
- raise ValueError, "Invalid table or column"
- del h
# and the data dictionary
self.data = {}
diff --git a/backend/server/rhnSQL/sql_table.py b/backend/server/rhnSQL/sql_table.py
index 4acdba5..923bff5 100644
--- a/backend/server/rhnSQL/sql_table.py
+++ b/backend/server/rhnSQL/sql_table.py
@@ -71,14 +71,6 @@ class Table:
if cache:
self.__cache = {}
- # see if the table exists
- sql = "select %s from %s where rownum = 0" % (self.__hashid, self.__table)
- try:
- h = self.__db.prepare(sql)
- except:
- raise ValueError,"Invalid table or column"
- del h
-
def set_cache(self, value):
if not value:
self.__cache = None
commit 7d8eb3ac88d8ebb17f3eab066dfa0c9554340ef3
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Fri Oct 29 16:27:46 2010 +0200
Apply change 15c8aa97447223934e3e9c991b76deef466b0b9b to PostgreSQL code.
diff --git a/schema/spacewalk/postgres/packages/rhn_server.pkb
b/schema/spacewalk/postgres/packages/rhn_server.pkb
index fc630b2..7052210 100644
--- a/schema/spacewalk/postgres/packages/rhn_server.pkb
+++ b/schema/spacewalk/postgres/packages/rhn_server.pkb
@@ -488,10 +488,6 @@ update pg_settings set setting = 'rhn_server,' || setting
where name = 'search_p
) returns void
as $$
declare
- sg_users cursor is
- select user_id id
- from rhnUserServerGroupPerms
- where server_group_id = server_group_id_in;
used_slots numeric;
max_slots numeric;
org_id numeric;
@@ -529,9 +525,7 @@ update pg_settings set setting = 'rhn_server,' || setting
where name = 'search_p
set current_members = current_members + 1
where id = server_group_id_in;
- for u in sg_users loop
- perform rhn_cache.update_perms_for_user(u.id);
- end loop;
+ perform rhn_cache.update_perms_for_server_group(server_group_id_in);
return;
end if;
@@ -637,11 +631,6 @@ update pg_settings set setting = 'rhn_server,' || setting
where name = 'search_p
) returns void
as $$
declare
- sg_users cursor is
- select user_id id
- from rhnUserServerGroupPerms
- where server_group_id = server_group_id_in;
-
server_virt_groups cursor is
select 1
from rhnServerEntitlementVirtual sev
@@ -674,9 +663,7 @@ update pg_settings set setting = 'rhn_server,' || setting
where name = 'search_p
update rhnServerGroup
set current_members = current_members - 1
where id = server_group_id_in;
- for u in sg_users loop
- perform rhn_cache.update_perms_for_user(u.id);
- end loop;
+ perform rhn_cache.update_perms_for_server_group(server_group_id_in);
return;
end if;