diff --git a/cstore_fdw.c b/cstore_fdw.c index 94c7018..b0a3277 100644 --- a/cstore_fdw.c +++ b/cstore_fdw.c @@ -1878,6 +1878,12 @@ ColumnList(RelOptInfo *baserel, Oid foreignTableId) { ListCell *neededColumnCell = NULL; Var *column = NULL; + Form_pg_attribute attributeForm = TupleDescAttr(tupleDescriptor, columnIndex - 1); + + if (attributeForm->attisdropped) + { + continue; + } /* look for this column in the needed column list */ foreach(neededColumnCell, neededColumnList) @@ -1890,7 +1896,6 @@ ColumnList(RelOptInfo *baserel, Oid foreignTableId) } else if (neededColumn->varattno == wholeRow) { - Form_pg_attribute attributeForm = TupleDescAttr(tupleDescriptor, columnIndex - 1); Index tableId = neededColumn->varno; column = makeVar(tableId, columnIndex, attributeForm->atttypid, diff --git a/expected/alter.out b/expected/alter.out index 548fb9e..659e272 100644 --- a/expected/alter.out +++ b/expected/alter.out @@ -127,6 +127,18 @@ SELECT * from test_alter_table; 1 | 4 | ABCDEF (7 rows) +SELECT count(*) from test_alter_table; + count +------- + 7 +(1 row) + +SELECT count(t.*) from test_alter_table t; + count +------- + 7 +(1 row) + -- unsupported default values ALTER FOREIGN TABLE test_alter_table ADD COLUMN g boolean DEFAULT isfinite(current_date); ALTER FOREIGN TABLE test_alter_table ADD COLUMN h DATE DEFAULT current_date; diff --git a/sql/alter.sql b/sql/alter.sql index f03e58c..5ba3beb 100644 --- a/sql/alter.sql +++ b/sql/alter.sql @@ -53,6 +53,8 @@ ALTER FOREIGN TABLE test_alter_table DROP COLUMN c; ALTER FOREIGN TABLE test_alter_table DROP COLUMN e; ANALYZE test_alter_table; SELECT * from test_alter_table; +SELECT count(*) from test_alter_table; +SELECT count(t.*) from test_alter_table t; -- unsupported default values