Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite16db75

Browse files
committed
Improve subscriber's error message for wrong publication relkind.
Pre-v13 versions only support logical replication from plain tables,while v13 and later also allow partitioned tables to be published.If you tried to subscribe an older server to such a publication,you got "table XXX not found on publisher", which is prettyunhelpful/confusing. Arrange to deliver a more on-point errormessage. As commitc314c14 did in v13, remove the relkind checkfrom the query WHERE clause altogether, so that "not there"is distinguishable from "wrong relkind".Per report from Radoslav Nedyalkov. Patch v10-v12.Discussion:https://postgr.es/m/2952568.1644876730@sss.pgh.pa.us
1 parentce349cf commite16db75

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

‎src/backend/replication/logical/tablesync.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -646,23 +646,23 @@ fetch_remote_table_info(char *nspname, char *relname,
646646
WalRcvExecResult*res;
647647
StringInfoDatacmd;
648648
TupleTableSlot*slot;
649-
OidtableRow[2]= {OIDOID,CHAROID};
649+
OidtableRow[3]= {OIDOID,CHAROID,CHAROID};
650650
OidattrRow[4]= {TEXTOID,OIDOID,INT4OID,BOOLOID};
651651
boolisnull;
652+
charrelkind;
652653
intnatt;
653654

654655
lrel->nspname=nspname;
655656
lrel->relname=relname;
656657

657658
/* First fetch Oid and replica identity. */
658659
initStringInfo(&cmd);
659-
appendStringInfo(&cmd,"SELECT c.oid, c.relreplident"
660+
appendStringInfo(&cmd,"SELECT c.oid, c.relreplident, c.relkind"
660661
" FROM pg_catalog.pg_class c"
661662
" INNER JOIN pg_catalog.pg_namespace n"
662663
" ON (c.relnamespace = n.oid)"
663664
" WHERE n.nspname = %s"
664-
" AND c.relname = %s"
665-
" AND c.relkind = 'r'",
665+
" AND c.relname = %s",
666666
quote_literal_cstr(nspname),
667667
quote_literal_cstr(relname));
668668
res=walrcv_exec(LogRepWorkerWalRcvConn,cmd.data,
@@ -683,6 +683,19 @@ fetch_remote_table_info(char *nspname, char *relname,
683683
Assert(!isnull);
684684
lrel->replident=DatumGetChar(slot_getattr(slot,2,&isnull));
685685
Assert(!isnull);
686+
relkind=DatumGetChar(slot_getattr(slot,3,&isnull));
687+
Assert(!isnull);
688+
689+
/*
690+
* Newer PG versions allow things that aren't plain tables to appear in
691+
* publications. We don't handle that in this version, but try to provide
692+
* a useful error message.
693+
*/
694+
if (relkind!=RELKIND_RELATION)
695+
ereport(ERROR,
696+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
697+
errmsg("logical replication source relation \"%s.%s\" is not a table",
698+
nspname,relname)));
686699

687700
ExecDropSingleTupleTableSlot(slot);
688701
walrcv_clear_result(res);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp