schema/spacewalk/postgres/procs/pg_dblink_exec.sql
| 3
schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/112-pg_dblink_exec.sql.postgresql
| 32 ++++++++++
2 files changed, 35 insertions(+)
New commits:
commit f4af386a910057b802bf27c323cba13aa255e551
Author: Tomas Kasparek <tkasparek(a)redhat.com>
Date: Mon Jul 23 10:42:12 2012 +0200
If by accident pg_dblink_exec is given NULL string (e.g concatenation of string and
NULL in pgsql) it raises an error.
diff --git a/schema/spacewalk/postgres/procs/pg_dblink_exec.sql
b/schema/spacewalk/postgres/procs/pg_dblink_exec.sql
index f0e8751..67279eb 100644
--- a/schema/spacewalk/postgres/procs/pg_dblink_exec.sql
+++ b/schema/spacewalk/postgres/procs/pg_dblink_exec.sql
@@ -16,6 +16,9 @@
create or replace function pg_dblink_exec(in_sql in varchar) returns void as
$$
begin
+ if in_sql is null then
+ raise 'pg_dblink_exec in_sql is null';
+ end if;
perform dblink_connect('at_conn', 'dbname=' || current_database());
begin
perform dblink_exec('at_conn', in_sql, true);
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/112-pg_dblink_exec.sql.postgresql
b/schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/112-pg_dblink_exec.sql.postgresql
new file mode 100644
index 0000000..67279eb
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/112-pg_dblink_exec.sql.postgresql
@@ -0,0 +1,32 @@
+-- oracle equivalent source none
+--
+-- Copyright (c) 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 pg_dblink_exec(in_sql in varchar) returns void as
+$$
+begin
+ if in_sql is null then
+ raise 'pg_dblink_exec in_sql is null';
+ end if;
+ perform dblink_connect('at_conn', 'dbname=' || current_database());
+ 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;