wolfgangbrandl / db2_fdw

PostgreSQL DB2 Data Wrapper
Other
20 stars 13 forks source link

Querying imported foreign schema with hidden fields causes segfault. #32

Open Dracyr opened 3 years ago

Dracyr commented 3 years ago

Creating tables with hidden fields, importing them using IMPORT FOREIGN SCHEMA, and then querying them causes a segfault in the postgres server.

I also created the table using CREATE TABLE, where including the hidden fields only caused a segfault if the key 'true' option was also set on the column. This option seems to be set for all columns always, which I'm not sure is the intended effect?

DB2

CREATE SCHEMA "TEST";
CREATE TABLE "TEST"."TEST_HIDDEN"  ( 
    "FIELD" INTEGER NOT NULL, 
    "HIDDEN_FIELD" INTEGER NOT NULL IMPLICITLY HIDDEN
);

Postgres

postgres=# IMPORT FOREIGN SCHEMA "TEST" FROM SERVER test INTO public OPTIONS (readonly 'true');
IMPORT FOREIGN SCHEMA
postgres=# \d test_hidden
                   Foreign table "public.test_hidden"
    Column    |  Type   | Collation | Nullable | Default | FDW options
--------------+---------+-----------+----------+---------+--------------
 field        | integer |           | not null |         | (key 'true')
 hidden_field | integer |           | not null |         | (key 'true')
Server: test
FDW options: (schema 'TEST', "table" 'TEST_HIDDEN', readonly 'true')

postgres=# SELECT * FROM test_hidden;
server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!>

Postgres Logs

2021-05-13 07:58:51.028 UTC [290] LOG:  server process (PID 334) was terminated by signal 11: Segmentation fault
2021-05-13 07:58:51.028 UTC [290] DETAIL:  Failed process was running: SELECT * FROM test_hidden;
2021-05-13 07:58:51.028 UTC [290] LOG:  terminating any other active server processes
2021-05-13 07:58:51.029 UTC [314] WARNING:  terminating connection because of crash of another server process
2021-05-13 07:58:51.029 UTC [314] DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2021-05-13 07:58:51.029 UTC [314] HINT:  In a moment you should be able to reconnect to the database and repeat your command.
2021-05-13 07:58:51.032 UTC [337] FATAL:  the database system is in recovery mode