|
|
3f1506 |
From c73d40c6e219621c4bdc1fe9cadd52b7f09e8560 Mon Sep 17 00:00:00 2001
|
|
|
3f1506 |
From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilmari@ilmari.org>
|
|
|
3f1506 |
Date: Mon, 31 Dec 2018 18:45:57 +0100
|
|
|
3f1506 |
Subject: [PATCH] Inline no-longer-conditional catalog query fragments
|
|
|
3f1506 |
MIME-Version: 1.0
|
|
|
3f1506 |
Content-Type: text/plain; charset=UTF-8
|
|
|
3f1506 |
Content-Transfer-Encoding: 8bit
|
|
|
3f1506 |
|
|
|
3f1506 |
Some bits of catalog queries needed version-specific variants, but when
|
|
|
3f1506 |
support for the versions that necessitated them was removed, the
|
|
|
3f1506 |
variables were left in place. This removes these now-unnecessary
|
|
|
3f1506 |
variables and puts the SQL fragments back in the query.
|
|
|
3f1506 |
|
|
|
3f1506 |
The pg_get_expr() call does not need to be conditional, it exists in 7.4
|
|
|
3f1506 |
too: https://www.postgresql.org/docs/7.4/functions-misc.html
|
|
|
3f1506 |
|
|
|
3f1506 |
Petr Písař: Ported to 3.7.4 from
|
|
|
3f1506 |
c7ea8fd90b5fc09f28e090e0e00cbb2708eda4cc.
|
|
|
3f1506 |
|
|
|
3f1506 |
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
3f1506 |
---
|
|
|
3f1506 |
Pg.pm | 14 +++-----------
|
|
|
3f1506 |
1 file changed, 3 insertions(+), 11 deletions(-)
|
|
|
3f1506 |
|
|
|
3f1506 |
diff --git a/Pg.pm b/Pg.pm
|
|
|
3f1506 |
index 9c664e9..5658d1b 100644
|
|
|
3f1506 |
--- a/Pg.pm
|
|
|
3f1506 |
+++ b/Pg.pm
|
|
|
3f1506 |
@@ -443,14 +443,6 @@ use 5.008001;
|
|
|
3f1506 |
|
|
|
3f1506 |
my $whereclause = join "\n\t\t\t\tAND ", '', @search;
|
|
|
3f1506 |
|
|
|
3f1506 |
- my $schemajoin = 'JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace)';
|
|
|
3f1506 |
-
|
|
|
3f1506 |
- my $remarks = 'pg_catalog.col_description(a.attrelid, a.attnum)';
|
|
|
3f1506 |
-
|
|
|
3f1506 |
- my $column_def = $dbh->{private_dbdpg}{version} >= 80000
|
|
|
3f1506 |
- ? 'pg_catalog.pg_get_expr(af.adbin, af.adrelid)'
|
|
|
3f1506 |
- : 'af.adsrc';
|
|
|
3f1506 |
-
|
|
|
3f1506 |
my $col_info_sql = qq!
|
|
|
3f1506 |
SELECT
|
|
|
3f1506 |
NULL::text AS "TABLE_CAT"
|
|
|
3f1506 |
@@ -464,8 +456,8 @@ use 5.008001;
|
|
|
3f1506 |
, NULL::text AS "DECIMAL_DIGITS"
|
|
|
3f1506 |
, NULL::text AS "NUM_PREC_RADIX"
|
|
|
3f1506 |
, CASE a.attnotnull WHEN 't' THEN 0 ELSE 1 END AS "NULLABLE"
|
|
|
3f1506 |
- , $remarks AS "REMARKS"
|
|
|
3f1506 |
- , $column_def AS "COLUMN_DEF"
|
|
|
3f1506 |
+ , pg_catalog.col_description(a.attrelid, a.attnum) AS "REMARKS"
|
|
|
3f1506 |
+ , pg_catalog.pg_get_expr(af.adbin, af.adrelid) AS "COLUMN_DEF"
|
|
|
3f1506 |
, NULL::text AS "SQL_DATA_TYPE"
|
|
|
3f1506 |
, NULL::text AS "SQL_DATETIME_SUB"
|
|
|
3f1506 |
, NULL::text AS "CHAR_OCTET_LENGTH"
|
|
|
3f1506 |
@@ -486,7 +478,7 @@ use 5.008001;
|
|
|
3f1506 |
JOIN pg_catalog.pg_attribute a ON (t.oid = a.atttypid)
|
|
|
3f1506 |
JOIN pg_catalog.pg_class c ON (a.attrelid = c.oid)
|
|
|
3f1506 |
LEFT JOIN pg_catalog.pg_attrdef af ON (a.attnum = af.adnum AND a.attrelid = af.adrelid)
|
|
|
3f1506 |
- $schemajoin
|
|
|
3f1506 |
+ JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace)
|
|
|
3f1506 |
WHERE
|
|
|
3f1506 |
a.attnum >= 0
|
|
|
3f1506 |
AND c.relkind IN ('r','v','m')
|
|
|
3f1506 |
--
|
|
|
3f1506 |
2.21.0
|
|
|
3f1506 |
|