pgspider / sqlite_fdw

SQLite Foreign Data Wrapper for PostgreSQL
Other
219 stars 37 forks source link

Error when SELECT foreign table which specifies non-existent column name #15

Closed thongpvn closed 5 years ago

thongpvn commented 5 years ago

I have a scenario as below:


-- In SQLite
DROP TABLE IF EXISTS "T001";
CREATE TABLE "T001" (
    c1 int NOT NULL,
    c2 int NOT NULL,
    c3 text,
    CONSTRAINT t1_pkey PRIMARY KEY (c1)
);

-- In SQLite FDW
-- Add data for table T001
CREATE SCHEMA "S001";
IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO "S001";
INSERT INTO "S001"."T001" 
    SELECT id,
           id % 10,
           to_char(id, 'FM00000')
    FROM generate_series(1, 10) id;
-- Scenario
CREATE FOREIGN TABLE ft002 (
    c1 int OPTIONS (key 'true'),
    c2 int NOT NULL,
    c3 text
) SERVER sqlite_svr OPTIONS (table 'T001');
ALTER FOREIGN TABLE ft002 ALTER COLUMN c1 OPTIONS (column_name 'c0');  <-- c0 not exist
SELECT * FROM "S001"."T001";
 c1 | c2 |  c3   
----+----+-------
  1 |  1 | 00001
  2 |  2 | 00002
  3 |  3 | 00003
  4 |  4 | 00004
  5 |  5 | 00005
  6 |  6 | 00006
  7 |  7 | 00007
  8 |  8 | 00008
  9 |  9 | 00009
 10 |  0 | 00010
(10 rows)

SELECT * FROM ft002; <-- Error
 c1 | c2 |  c3   
----+----+-------
  0 |  1 | 00001
  0 |  2 | 00002
  0 |  3 | 00003
  0 |  4 | 00004
  0 |  5 | 00005
  0 |  6 | 00006
  0 |  7 | 00007
  0 |  8 | 00008
  0 |  9 | 00009
  0 |  0 | 00010
(10 rows)

Could you help me to resolve this issue?

mochizk commented 5 years ago

Thanks for the report. I fixed the issue. Please confirm.

thongpvn commented 5 years ago

Thanks for your update. The issue is fixed.