* ALTER FOREIGN TABLE OPTIONS (...) */
| 19865 | * ALTER FOREIGN TABLE <name> OPTIONS (...) |
| 19866 | */ |
| 19867 | static void |
| 19868 | ATExecGenericOptions(Relation rel, List *options) |
| 19869 | { |
| 19870 | Relation ftrel; |
| 19871 | ForeignServer *server; |
| 19872 | ForeignDataWrapper *fdw; |
| 19873 | HeapTuple tuple; |
| 19874 | bool isnull; |
| 19875 | Datum repl_val[Natts_pg_foreign_table]; |
| 19876 | bool repl_null[Natts_pg_foreign_table]; |
| 19877 | bool repl_repl[Natts_pg_foreign_table]; |
| 19878 | Datum datum; |
| 19879 | Form_pg_foreign_table tableform; |
| 19880 | |
| 19881 | if (options == NIL) |
| 19882 | return; |
| 19883 | |
| 19884 | ftrel = table_open(ForeignTableRelationId, RowExclusiveLock); |
| 19885 | |
| 19886 | tuple = SearchSysCacheCopy1(FOREIGNTABLEREL, rel->rd_id); |
| 19887 | if (!HeapTupleIsValid(tuple)) |
| 19888 | ereport(ERROR, |
| 19889 | (errcode(ERRCODE_UNDEFINED_OBJECT), |
| 19890 | errmsg("foreign table \"%s\" does not exist", |
| 19891 | RelationGetRelationName(rel)))); |
| 19892 | tableform = (Form_pg_foreign_table) GETSTRUCT(tuple); |
| 19893 | server = GetForeignServer(tableform->ftserver); |
| 19894 | fdw = GetForeignDataWrapper(server->fdwid); |
| 19895 | |
| 19896 | memset(repl_val, 0, sizeof(repl_val)); |
| 19897 | memset(repl_null, false, sizeof(repl_null)); |
| 19898 | memset(repl_repl, false, sizeof(repl_repl)); |
| 19899 | |
| 19900 | /* Extract the current options */ |
| 19901 | datum = SysCacheGetAttr(FOREIGNTABLEREL, |
| 19902 | tuple, |
| 19903 | Anum_pg_foreign_table_ftoptions, |
| 19904 | &isnull); |
| 19905 | if (isnull) |
| 19906 | datum = PointerGetDatum(NULL); |
| 19907 | |
| 19908 | /* Transform the options */ |
| 19909 | datum = transformGenericOptions(ForeignTableRelationId, |
| 19910 | datum, |
| 19911 | options, |
| 19912 | fdw->fdwvalidator); |
| 19913 | |
| 19914 | if (PointerIsValid(DatumGetPointer(datum))) |
| 19915 | repl_val[Anum_pg_foreign_table_ftoptions - 1] = datum; |
| 19916 | else |
| 19917 | repl_null[Anum_pg_foreign_table_ftoptions - 1] = true; |
| 19918 | |
| 19919 | repl_repl[Anum_pg_foreign_table_ftoptions - 1] = true; |
| 19920 | |
| 19921 | /* Everything looks good - update the tuple */ |
| 19922 | |
| 19923 | tuple = heap_modify_tuple(tuple, RelationGetDescr(ftrel), |
| 19924 | repl_val, repl_null, repl_repl); |
no test coverage detected