From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: zedaardv@drizzle.com
Subject: BUG #15998: query to return a table column list gives error on a missing foreign data wrapper library
Date: Tue, 10 Sep 2019 09:46:01 +0000
Message-ID: <15998-8429a3984b1364ad@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 15998
Logged by: reiner peterke
Email address: zedaardv@drizzle.com
PostgreSQL version: 11.5
Operating system: Centos 7.6.1810 x86
Description:
This is a very corner case situation.
Found originally with the oracle_fdw but can reproduce with the
postgres_fdw.
Happened on at a customers site when we changed the binaries from postgres
from community version to another version.
database server was started without the foreign data wrapper having been
installed (tested with oracle_fdw and postgres_fdw)
a query was run from a GUI tool to get the column list for a non-foreign
table. when the query was run the error was thrown
ERROR: could not access file "$libdir/oracle_fdw": No such file or
directory
Have been able to reproduce the behavior on postgres 10 and 11 with the
postgres_fdw on centos 7 on ppc64le.
Take a postgres database with foreign servers and foreign tables.
remove the fdw library.
i simulated this by
mv postgres_fdw.so postgres_fdw.so.xx
run the query below on a normal table
the query needs to be adjusted to to have a table oid (version runs in
postgres 11)
SELECT
typ.oid AS typoid, nspname, relname, attname, attrelid, attnum,
attnotnull,
attidentity != '' AS isidentity,
CASE WHEN typ.typtype = 'd' THEN typ.typtypmod ELSE atttypmod
END AS typmod,
CASE WHEN atthasdef THEN (SELECT pg_get_expr(adbin, cls.oid)
FROM pg_attrdef WHERE adrelid = cls.oid AND adnum = attr.attnum) ELSE NULL
END AS default,
CASE WHEN col.is_updatable = 'YES' THEN true ELSE false END AS
is_updatable,
EXISTS (
SELECT * FROM pg_index
WHERE pg_index.indrelid = cls.oid AND
pg_index.indisprimary AND
attnum = ANY (indkey)
) AS isprimarykey,
EXISTS (
SELECT * FROM pg_index
WHERE pg_index.indrelid = cls.oid AND
pg_index.indisunique AND
pg_index.indnkeyatts = 1 AND
attnum = pg_index.indkey[0]
) AS isunique
FROM pg_attribute AS attr
JOIN pg_type AS typ ON attr.atttypid = typ.oid
JOIN pg_class AS cls ON cls.oid = attr.attrelid
JOIN pg_namespace AS ns ON ns.oid = cls.relnamespace
LEFT OUTER JOIN information_schema.columns AS col ON
col.table_schema = nspname AND
col.table_name = relname AND
col.column_name = attname
WHERE
atttypid <> 0 AND
relkind IN ('r', 'v', 'm') AND
NOT attisdropped AND
nspname NOT IN ('pg_catalog', 'information_schema') AND
attnum > 0 AND
((attr.attrelid=1354075 AND attr.attnum=1))
ORDER BY attnum
throws error
ERROR: could not access file "$libdir/postgres_fdw": No such file or
directory
commenting out the case statement
CASE WHEN col.is_updatable = 'YES' THEN true ELSE false END AS
is_updatable,
causes the query to run without error.
It seems odd to me that this query generates such an error
running a query with just the case statement works fine.
select case when col.is_updatable = 'YES' then true else false end as
is_updatable from information_schema.columns col where table_name =
'batch';
I am not sure how to dig further into this at the moment
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, zedaardv@drizzle.com
Subject: Re: BUG #15998: query to return a table column list gives error on a missing foreign data wrapper library
In-Reply-To: <15998-8429a3984b1364ad@postgresql.org>
References: <15998-8429a3984b1364ad@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox