BUG #15998: query to return a table column list gives error on a missing foreign data wrapper library - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #15998: query to return a table column list gives error on a missing foreign data wrapper library
Date
Msg-id 15998-8429a3984b1364ad@postgresql.org
Whole thread Raw
Responses Re: BUG #15998: query to return a table column list gives error on amissing foreign data wrapper library
List pgsql-bugs
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


pgsql-bugs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: BUG #15804: Assertion failure when using logging_collector withEXEC_BACKEND
Next
From: PG Bug reporting form
Date:
Subject: BUG #15999: jsonb_populate_record fails with array column