Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 37fb017

Browse files
committed
In plpgsql, allow foreign tables to define row types.
This seems to have been just an oversight in previous foreign-table work. A quick grep didn't turn up any other places where RELKIND_FOREIGN_TABLE was obviously omitted. One change noted by Alexander Soudakov, the other by me. Back-patch to 9.1.
1 parent 07d5205 commit 37fb017

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/pl/plpgsql/src/pl_comp.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,12 +1721,13 @@ plpgsql_parse_cwordtype(List *idents)
17211721
classStruct = (Form_pg_class) GETSTRUCT(classtup);
17221722

17231723
/*
1724-
* It must be a relation, sequence, view, or type
1724+
* It must be a relation, sequence, view, composite type, or foreign table
17251725
*/
17261726
if (classStruct->relkind != RELKIND_RELATION &&
17271727
classStruct->relkind != RELKIND_SEQUENCE &&
17281728
classStruct->relkind != RELKIND_VIEW &&
1729-
classStruct->relkind != RELKIND_COMPOSITE_TYPE)
1729+
classStruct->relkind != RELKIND_COMPOSITE_TYPE &&
1730+
classStruct->relkind != RELKIND_FOREIGN_TABLE)
17301731
goto done;
17311732

17321733
/*
@@ -1947,11 +1948,12 @@ build_row_from_class(Oid classOid)
19471948
classStruct = RelationGetForm(rel);
19481949
relname = RelationGetRelationName(rel);
19491950

1950-
/* accept relation, sequence, view, or composite type entries */
1951+
/* accept relation, sequence, view, composite type, or foreign table */
19511952
if (classStruct->relkind != RELKIND_RELATION &&
19521953
classStruct->relkind != RELKIND_SEQUENCE &&
19531954
classStruct->relkind != RELKIND_VIEW &&
1954-
classStruct->relkind != RELKIND_COMPOSITE_TYPE)
1955+
classStruct->relkind != RELKIND_COMPOSITE_TYPE &&
1956+
classStruct->relkind != RELKIND_FOREIGN_TABLE)
19551957
ereport(ERROR,
19561958
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
19571959
errmsg("relation \"%s\" is not a table", relname)));

0 commit comments

Comments
 (0)