Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CREATE FOREIGN TABLE fails if the option "table_name" is not provided. #6642

Closed
emelsimsek opened this issue Jan 24, 2023 · 2 comments · Fixed by #6652
Closed

CREATE FOREIGN TABLE fails if the option "table_name" is not provided. #6642

emelsimsek opened this issue Jan 24, 2023 · 2 comments · Fixed by #6652

Comments

@emelsimsek
Copy link
Contributor

emelsimsek commented Jan 24, 2023

Env: tools/citus_dev/citus_dev make testCluster

psql -p 9700

CREATE EXTENSION postgres_fdw;

CREATE SERVER foreign_server
FOREIGN DATA WRAPPER postgres_fdw
OPTIONS (host 'localhost', port '9700', dbname 'regression');

CREATE USER MAPPING FOR CURRENT_USER
SERVER foreign_server
OPTIONS (user 'emel');

CREATE FOREIGN TABLE foreign_table (
id integer NOT NULL,
data text,
a bigserial
)
SERVER foreign_server
OPTIONS (schema_name 'foreign_tables_schema_mx');

ERROR: table_name option must be provided when using postgres_fdw with Citus
HINT: Provide the option "table_name" with value target table's name

Looking at the citus regression tests (foreign_tables_mx.sql) , this seems to be expected when
SET citus.use_citus_managed_tables TO ON;

However, the above commands fail even if there is no citus configuration and citus is only loaded.

Citus utility hook seems to interfere somehow.

This bug can be confirmed by running regression tests of the extension
postgresql-14.6/contrib/postgres_fdw
postgresql-15.1/contrib/postgres_fdw

by simply loading Citus during their regression runs.

@gokhangulbiz
Copy link
Contributor

gokhangulbiz commented Jan 25, 2023

It appears that the table_name option is a required field for foreign tables, by design. See #5461.

This is because Postgres uses the name of the shard when querying the fdw, not the name of the table. Since we only support foreign tables on citus local tables, we could move this check to the citus_add_local_table_to_metadata function. Let me know your thoughts on this approach.

@marcocitus
Copy link
Member

we should probably also make sure that ALTER FOREIGN TABLE is allowed for postgres tables, and maybe disallowed (or unsupported) for Citus local.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants