mirror of
https://github.com/postgres/postgres.git
synced 2025-06-25 01:02:05 +03:00
Don't try to print data type names in slot_store_error_callback().
The existing code tried to do syscache lookups in an already-failed transaction, which is problematic to say the least. After some consideration of alternatives, the best fix seems to be to just drop type names from the error message altogether. The table and column names seem like sufficient localization. If the user is unsure what types are involved, she can check the local and remote table definitions. Having done that, we can also discard the LogicalRepTypMap hash table, which had no other use. Arguably, LOGICAL_REP_MSG_TYPE replication messages are now obsolete as well; but we should probably keep them in case some other use emerges. (The complexity of removing something from the replication protocol would likely outweigh any savings anyhow.) Masahiko Sawada and Bharath Rupireddy, per complaint from Andres Freund. Back-patch to v10 where this code originated. Discussion: https://postgr.es/m/20210106020229.ne5xnuu6wlondjpe@alap3.anarazel.de
This commit is contained in:
@ -105,7 +105,6 @@ static dlist_head lsn_mapping = DLIST_STATIC_INIT(lsn_mapping);
|
||||
typedef struct SlotErrCallbackArg
|
||||
{
|
||||
LogicalRepRelMapEntry *rel;
|
||||
int local_attnum;
|
||||
int remote_attnum;
|
||||
} SlotErrCallbackArg;
|
||||
|
||||
@ -307,36 +306,23 @@ slot_fill_defaults(LogicalRepRelMapEntry *rel, EState *estate,
|
||||
}
|
||||
|
||||
/*
|
||||
* Error callback to give more context info about type conversion failure.
|
||||
* Error callback to give more context info about data conversion failures
|
||||
* while reading data from the remote server.
|
||||
*/
|
||||
static void
|
||||
slot_store_error_callback(void *arg)
|
||||
{
|
||||
SlotErrCallbackArg *errarg = (SlotErrCallbackArg *) arg;
|
||||
LogicalRepRelMapEntry *rel;
|
||||
char *remotetypname;
|
||||
Oid remotetypoid,
|
||||
localtypoid;
|
||||
|
||||
/* Nothing to do if remote attribute number is not set */
|
||||
if (errarg->remote_attnum < 0)
|
||||
return;
|
||||
|
||||
rel = errarg->rel;
|
||||
remotetypoid = rel->remoterel.atttyps[errarg->remote_attnum];
|
||||
|
||||
/* Fetch remote type name from the LogicalRepTypMap cache */
|
||||
remotetypname = logicalrep_typmap_gettypname(remotetypoid);
|
||||
|
||||
/* Fetch local type OID from the local sys cache */
|
||||
localtypoid = get_atttype(rel->localreloid, errarg->local_attnum + 1);
|
||||
|
||||
errcontext("processing remote data for replication target relation \"%s.%s\" column \"%s\", "
|
||||
"remote type %s, local type %s",
|
||||
errcontext("processing remote data for replication target relation \"%s.%s\" column \"%s\"",
|
||||
rel->remoterel.nspname, rel->remoterel.relname,
|
||||
rel->remoterel.attnames[errarg->remote_attnum],
|
||||
remotetypname,
|
||||
format_type_be(localtypoid));
|
||||
rel->remoterel.attnames[errarg->remote_attnum]);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -357,7 +343,6 @@ slot_store_cstrings(TupleTableSlot *slot, LogicalRepRelMapEntry *rel,
|
||||
|
||||
/* Push callback + info on the error context stack */
|
||||
errarg.rel = rel;
|
||||
errarg.local_attnum = -1;
|
||||
errarg.remote_attnum = -1;
|
||||
errcallback.callback = slot_store_error_callback;
|
||||
errcallback.arg = (void *) &errarg;
|
||||
@ -376,7 +361,6 @@ slot_store_cstrings(TupleTableSlot *slot, LogicalRepRelMapEntry *rel,
|
||||
Oid typinput;
|
||||
Oid typioparam;
|
||||
|
||||
errarg.local_attnum = i;
|
||||
errarg.remote_attnum = remoteattnum;
|
||||
|
||||
getTypeInputInfo(att->atttypid, &typinput, &typioparam);
|
||||
@ -385,7 +369,6 @@ slot_store_cstrings(TupleTableSlot *slot, LogicalRepRelMapEntry *rel,
|
||||
typioparam, att->atttypmod);
|
||||
slot->tts_isnull[i] = false;
|
||||
|
||||
errarg.local_attnum = -1;
|
||||
errarg.remote_attnum = -1;
|
||||
}
|
||||
else
|
||||
@ -441,7 +424,6 @@ slot_modify_cstrings(TupleTableSlot *slot, TupleTableSlot *srcslot,
|
||||
|
||||
/* For error reporting, push callback + info on the error context stack */
|
||||
errarg.rel = rel;
|
||||
errarg.local_attnum = -1;
|
||||
errarg.remote_attnum = -1;
|
||||
errcallback.callback = slot_store_error_callback;
|
||||
errcallback.arg = (void *) &errarg;
|
||||
@ -465,7 +447,6 @@ slot_modify_cstrings(TupleTableSlot *slot, TupleTableSlot *srcslot,
|
||||
Oid typinput;
|
||||
Oid typioparam;
|
||||
|
||||
errarg.local_attnum = i;
|
||||
errarg.remote_attnum = remoteattnum;
|
||||
|
||||
getTypeInputInfo(att->atttypid, &typinput, &typioparam);
|
||||
@ -474,7 +455,6 @@ slot_modify_cstrings(TupleTableSlot *slot, TupleTableSlot *srcslot,
|
||||
typioparam, att->atttypmod);
|
||||
slot->tts_isnull[i] = false;
|
||||
|
||||
errarg.local_attnum = -1;
|
||||
errarg.remote_attnum = -1;
|
||||
}
|
||||
else
|
||||
@ -598,8 +578,7 @@ apply_handle_relation(StringInfo s)
|
||||
/*
|
||||
* Handle TYPE message.
|
||||
*
|
||||
* Note we don't do local mapping here, that's done when the type is
|
||||
* actually used.
|
||||
* This is now vestigial; we read the info and discard it.
|
||||
*/
|
||||
static void
|
||||
apply_handle_type(StringInfo s)
|
||||
@ -607,7 +586,6 @@ apply_handle_type(StringInfo s)
|
||||
LogicalRepTyp typ;
|
||||
|
||||
logicalrep_read_typ(s, &typ);
|
||||
logicalrep_typmap_update(&typ);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user