Re: BUG #15998: query to return a table column list gives error on a missing foreign data wrapper library

From: Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com>
To: PG Bug reporting form <noreply(at)postgresql(dot)org>
Cc: PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>, zedaardv(at)drizzle(dot)com
Subject: Re: BUG #15998: query to return a table column list gives error on a missing foreign data wrapper library
Date: 2019-09-10 11:41:34
Message-ID: CAPmGK15Jx54cMyK2cjGs8mGiQwvDfqFgO7Nv5CnfZiYkf813iA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Sep 10, 2019 at 6:46 PM PG Bug reporting form
<noreply(at)postgresql(dot)org> wrote:
> 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

I'm now traveling, so I cannot try to reproduce this. Could you send
the EXPLAIN output for this query?

> 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.

Seems reasonable to me; the is_updatable reference would cause the
IsForeignRelUpdatable() call for postgres_fdw foreign tables IIUC, so
removing that would be a workaround for this issue if that works for
you.

Best regards,
Etsuro Fujita

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Sandeep Thakkar 2019-09-10 11:49:16 Re: BUG #15996: Unable to install any PosgresSQL version
Previous Message PG Bug reporting form 2019-09-10 09:55:06 BUG #15999: jsonb_populate_record fails with array column