schema/spacewalk/postgres/procs/lookup_evr.sql
| 13 +-
schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/110-lookup_evr.sql.oracle
| 1
schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/110-lookup_evr.sql.postgresql
| 55 ++++++++++
3 files changed, 62 insertions(+), 7 deletions(-)
New commits:
commit d13b56bc04cb17f7f7cf2ca40b98602547f85adb
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Wed Jul 4 11:06:32 2012 +0200
We mustn't serialize object into string in lookup_evr, we need to only create it
once within the link.
Addressing
2012-07-04 04:51:53.605 EDT ERROR: column "'1.4 REV=2006.03.29'"
does not exist at character 114
2012-07-04 04:51:53.605 EDT STATEMENT: insert into rhnPackageEVR(id, epoch, version,
release, evr) values (1158, NULL, '1.4 REV=2006.03.29', '1',
(NULL,"'1.4 REV=2006.03.29'",'1'))
diff --git a/schema/spacewalk/postgres/procs/lookup_evr.sql
b/schema/spacewalk/postgres/procs/lookup_evr.sql
index af24ae7..a21c795 100644
--- a/schema/spacewalk/postgres/procs/lookup_evr.sql
+++ b/schema/spacewalk/postgres/procs/lookup_evr.sql
@@ -30,16 +30,15 @@ begin
if not found then
evr_id := nextval('rhn_pkg_evr_seq');
+ declare
+ e_text varchar = coalesce(quote_literal(e_in), 'NULL');
+ v_text varchar = coalesce(quote_literal(v_in), 'NULL');
+ r_text varchar = coalesce(quote_literal(r_in), 'NULL');
begin
perform pg_dblink_exec(
'insert into rhnPackageEVR(id, epoch, version, release, evr) values
(' ||
- evr_id || ', ' ||
- coalesce(quote_literal(e_in), 'NULL') || ', ' ||
- coalesce(quote_literal(v_in), 'NULL') || ', ' ||
- coalesce(quote_literal(r_in), 'NULL') || ', ' ||
- evr_t(coalesce(quote_literal(e_in), 'NULL'),
- coalesce(quote_literal(v_in), 'NULL'),
- coalesce(quote_literal(r_in), 'NULL')) || ')'
+ evr_id || ', ' || e_text || ', ' || v_text || ',
' || r_text
+ || ', evr_t(' || e_text || ', ' || v_text || ', ' || r_text ||
'))'
);
exception when unique_violation then
select id
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/110-lookup_evr.sql.oracle
b/schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/110-lookup_evr.sql.oracle
new file mode 100644
index 0000000..b7b00b1
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/110-lookup_evr.sql.oracle
@@ -0,0 +1 @@
+-- This file is intentionally left empty.
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/110-lookup_evr.sql.postgresql
b/schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/110-lookup_evr.sql.postgresql
new file mode 100644
index 0000000..9eb5055
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/110-lookup_evr.sql.postgresql
@@ -0,0 +1,55 @@
+-- oracle equivalent source sha1 b14267384bc104605623a41b755e68e0103b5aa8
+--
+-- Copyright (c) 2008--2012 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
+lookup_evr(e_in in varchar, v_in in varchar, r_in in varchar)
+returns numeric
+as
+$$
+declare
+ evr_id numeric;
+begin
+ select id
+ into evr_id
+ from rhnPackageEVR
+ where ((epoch is null and e_in is null) or (epoch = e_in)) and
+ version = v_in and
+ release = r_in;
+
+ if not found then
+ evr_id := nextval('rhn_pkg_evr_seq');
+ declare
+ e_text varchar = coalesce(quote_literal(e_in), 'NULL');
+ v_text varchar = coalesce(quote_literal(v_in), 'NULL');
+ r_text varchar = coalesce(quote_literal(r_in), 'NULL');
+ begin
+ perform pg_dblink_exec(
+ 'insert into rhnPackageEVR(id, epoch, version, release, evr) values
(' ||
+ evr_id || ', ' || e_text || ', ' || v_text || ',
' || r_text
+ || ', evr_t(' || e_text || ', ' || v_text || ', ' || r_text ||
'))'
+ );
+ exception when unique_violation then
+ select id
+ into strict evr_id
+ from rhnPackageEVR
+ where ((epoch is null and e_in is null) or (epoch = e_in)) and
+ version = v_in and
+ release = r_in;
+ end;
+ end if;
+
+ return evr_id;
+end;
+$$ language plpgsql immutable;