schema/spacewalk/postgres/procs/lookup_tag.sql
| 8 ++++---
schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/015-lookup_tag.sql.postgresql
| 8 ++++---
web/modules/rhn/RHN/DB/Tag.pm
| 11 +---------
3 files changed, 12 insertions(+), 15 deletions(-)
New commits:
commit b6dc4c1de89c2092c5a5fe70472595d78c0b1ca9
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Wed Jun 6 16:48:52 2012 +0200
803370 - call to rhn_server.tag_delete db agnostic
diff --git a/web/modules/rhn/RHN/DB/Tag.pm b/web/modules/rhn/RHN/DB/Tag.pm
index 5ca102c..2d02775 100644
--- a/web/modules/rhn/RHN/DB/Tag.pm
+++ b/web/modules/rhn/RHN/DB/Tag.pm
@@ -105,16 +105,9 @@ sub remove_tags_from_system {
my $sid = shift;
my $dbh = $params{transaction} || RHN::DB->connect();
- my $query = <<EOQ;
-BEGIN
- rhn_server.tag_delete(:server_id, :tag_id);
-END;
-EOQ
-
- my $sth = $dbh->prepare($query);
-
+
for my $tag (@tags) {
- $sth->execute_h(tag_id => $tag, server_id => $sid);
+ $dbh->call_procedure('rhn_server.tag_delete', $sid, $tag);
}
$dbh->commit;
}
commit 09267c86b26ca550c1bdfac1ca21d26ea11b1899
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Wed Jun 6 16:47:18 2012 +0200
803370 - lookup_tag: schema upgrade
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/015-lookup_tag.sql.postgresql
b/schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/015-lookup_tag.sql.postgresql
index ae714b4..0a8d4a3 100644
---
a/schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/015-lookup_tag.sql.postgresql
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/015-lookup_tag.sql.postgresql
@@ -6,20 +6,22 @@ returns numeric
as $$
declare
tag_id numeric;
+ tag_name_id numeric;
begin
+ tag_name_id := lookup_tag_name(name_in);
+
select id
into tag_id
from rhnTag
where org_id = org_id_in and
- name_id = lookup_tag_name(name_in);
+ name_id = tag_name_id;
if not found then
tag_id := nextval('rhn_tag_id_seq');
begin
perform pg_dblink_exec(
'insert into rhnTag(id, org_id, name_id) values (' ||
- tag_id || ', ' || org_id_in || ', ' ||
- coalesce(quote_literal(lookup_tag_name(name_in)), 'NULL') ||
')');
+ tag_id || ', ' || org_id_in || ', ' || tag_name_id ||
')');
exception when unique_violation then
select id
into strict tag_id
commit 6cd7d4d03d1e0a29c320619a80e6b8bb80507b6c
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Wed Jun 6 16:41:51 2012 +0200
803370 - lookup_tag: don't call lookup_tag_name twice
Second call to lookup_tag_name would still see the uncomitted transaction
and try to insert the same data for the second time, resulting in
the following error:
ERROR: duplicate key value violates unique constraint "rhn_tn_name_uq"
STATEMENT: insert into rhnTagName(id, name) values (4, 'snap02')
ERROR: query returned no rows
CONTEXT: PL/pgSQL function "lookup_tag_name" line 16 at SQL statement
SQL statement "SELECT pg_dblink_exec( 'insert into rhnTag(id,
org_id, name_id) values (' || $1 || ', ' || $2 || ', ' ||
coalesce(quote_literal(lookup_tag_name( $3 )), 'NULL') || ')')"
PL/pgSQL function "lookup_tag" line 13 at PERFORM
diff --git a/schema/spacewalk/postgres/procs/lookup_tag.sql
b/schema/spacewalk/postgres/procs/lookup_tag.sql
index 935cf0b..4e4ad3c 100644
--- a/schema/spacewalk/postgres/procs/lookup_tag.sql
+++ b/schema/spacewalk/postgres/procs/lookup_tag.sql
@@ -19,20 +19,22 @@ returns numeric
as $$
declare
tag_id numeric;
+ tag_name_id numeric;
begin
+ tag_name_id := lookup_tag_name(name_in);
+
select id
into tag_id
from rhnTag
where org_id = org_id_in and
- name_id = lookup_tag_name(name_in);
+ name_id = tag_name_id;
if not found then
tag_id := nextval('rhn_tag_id_seq');
begin
perform pg_dblink_exec(
'insert into rhnTag(id, org_id, name_id) values (' ||
- tag_id || ', ' || org_id_in || ', ' ||
- coalesce(quote_literal(lookup_tag_name(name_in)), 'NULL') ||
')');
+ tag_id || ', ' || org_id_in || ', ' || tag_name_id ||
')');
exception when unique_violation then
select id
into strict tag_id
Show replies by date