39 #include "utils/fmgroids.h" 56 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
57 errmsg(
"\"%s\" is not a table",
59 errdetail(
"Only tables can be added to publications.")));
64 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
65 errmsg(
"\"%s\" is a system table",
67 errdetail(
"System tables cannot be added to publications.")));
72 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
73 errmsg(
"table \"%s\" cannot be replicated",
75 errdetail(
"Temporary and unlogged relations cannot be replicated.")));
100 return (reltuple->relkind == RELKIND_RELATION ||
101 reltuple->relkind == RELKIND_PARTITIONED_TABLE) &&
103 reltuple->relpersistence == RELPERSISTENCE_PERMANENT &&
150 bool nulls[Natts_pg_publication_rel];
174 errmsg(
"relation \"%s\" is already member of publication \"%s\"",
181 memset(values, 0,
sizeof(values));
182 memset(nulls,
false,
sizeof(nulls));
185 Anum_pg_publication_rel_oid);
187 values[Anum_pg_publication_rel_prpubid - 1] =
189 values[Anum_pg_publication_rel_prrelid - 1] =
228 for (i = 0; i < pubrellist->
n_members; i++)
260 Anum_pg_publication_rel_prpubid,
265 true, NULL, 1, &scankey);
286 foreach(lc, all_parts)
323 Anum_pg_publication_puballtables,
363 Anum_pg_class_relkind,
372 Oid relid = relForm->oid;
375 !(relForm->relispartition && pubviaroot))
384 Anum_pg_class_relkind,
393 Oid relid = relForm->oid;
396 !relForm->relispartition)
421 elog(
ERROR,
"cache lookup failed for publication %u", pubid);
469 (
errcode(ERRCODE_UNDEFINED_OBJECT),
470 errmsg(
"publication \"%s\" does not exist", pubname)));
492 elog(
ERROR,
"cache lookup failed for publication %u", pubid);
#define RelationIsPermanent(relation)
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
PublicationActions pubactions
bool IsCatalogRelation(Relation relation)
void table_close(Relation relation, LOCKMODE lockmode)
void systable_endscan(SysScanDesc sysscan)
TableScanDesc table_beginscan_catalog(Relation relation, int nkeys, struct ScanKeyData *key)
List * GetPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt)
#define RelationGetDescr(relation)
#define SRF_IS_FIRSTCALL()
#define GetSysCacheOid1(cacheId, oidcol, key1)
char get_rel_relkind(Oid relid)
char * pstrdup(const char *in)
#define RelationGetForm(relation)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
List * list_concat(List *list1, const List *list2)
int errcode(int sqlerrcode)
void recordDependencyOn(const ObjectAddress *depender, const ObjectAddress *referenced, DependencyType behavior)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
void heap_freetuple(HeapTuple htup)
#define PublicationRelObjectIndexId
List * lappend_oid(List *list, Oid datum)
#define OidIsValid(objectId)
#define SRF_PERCALL_SETUP()
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
Publication * GetPublicationByName(const char *pubname, bool missing_ok)
char * get_publication_name(Oid pubid, bool missing_ok)
#define FirstNormalObjectId
#define PG_GETARG_TEXT_PP(n)
static Oid list_nth_oid(const List *list, int n)
bool IsCatalogRelationOid(Oid relid)
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
#define SRF_RETURN_NEXT(_funcctx, _result)
List * GetRelationPublications(Oid relid)
HeapTuple systable_getnext(SysScanDesc sysscan)
Publication * GetPublication(Oid pubid)
#define ObjectIdGetDatum(X)
static void check_publication_add_relation(Relation targetrel)
HeapTuple heap_getnext(TableScanDesc sscan, ScanDirection direction)
bool is_publishable_relation(Relation rel)
int errdetail(const char *fmt,...)
Datum pg_relation_is_publishable(PG_FUNCTION_ARGS)
#define CStringGetDatum(X)
#define RelationGetRelationName(relation)
#define SearchSysCacheList1(cacheId, key1)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
#define ReleaseSysCacheList(x)
#define PG_RETURN_BOOL(x)
void ReleaseSysCache(HeapTuple tuple)
#define ereport(elevel,...)
#define HeapTupleIsValid(tuple)
#define Assert(condition)
#define PublicationRelPrrelidPrpubidIndexId
List * GetAllTablesPublications(void)
MemoryContext multi_call_memory_ctx
static int list_length(const List *l)
#define SearchSysCacheExists2(cacheId, key1, key2)
#define ObjectAddressSet(addr, class_id, object_id)
void CacheInvalidateRelcache(Relation relation)
static void table_endscan(TableScanDesc scan)
static Datum values[MAXATTR]
char * text_to_cstring(const text *t)
FormData_pg_class * Form_pg_class
List * find_all_inheritors(Oid parentrelId, LOCKMODE lockmode, List **numparents)
const ObjectAddress InvalidObjectAddress
Datum pg_get_publication_tables(PG_FUNCTION_ARGS)
int errmsg(const char *fmt,...)
FormData_pg_publication_rel * Form_pg_publication_rel
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
static bool is_publishable_class(Oid relid, Form_pg_class reltuple)
Oid get_publication_oid(const char *pubname, bool missing_ok)
ObjectAddress publication_add_relation(Oid pubid, Relation targetrel, bool if_not_exists)
List * GetAllTablesPublicationRelations(bool pubviaroot)
FormData_pg_publication * Form_pg_publication
Relation table_open(Oid relationId, LOCKMODE lockmode)
#define ERRCODE_DUPLICATE_OBJECT
#define RelationGetRelid(relation)
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
#define BTEqualStrategyNumber
#define SRF_RETURN_DONE(_funcctx)
#define SRF_FIRSTCALL_INIT()