发布订阅支持冲突处理
This commit is contained in:
@ -199,87 +199,7 @@ static bool pg_decode_filter(LogicalDecodingContext* ctx, RepOriginId origin_id)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
static void tuple_to_stringinfo(Relation relation, StringInfo s, TupleDesc tupdesc, HeapTuple tuple, bool isOld)
|
||||
{
|
||||
if ((tuple->tupTableType == HEAP_TUPLE) && (HEAP_TUPLE_IS_COMPRESSED(tuple->t_data) ||
|
||||
(int)HeapTupleHeaderGetNatts(tuple->t_data, tupdesc) > tupdesc->natts)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Oid oid;
|
||||
|
||||
/* print oid of tuple, it's not included in the TupleDesc */
|
||||
if ((oid = HeapTupleHeaderGetOid(tuple->t_data)) != InvalidOid) {
|
||||
appendStringInfo(s, " oid[oid]:%u", oid);
|
||||
}
|
||||
|
||||
/* print all columns individually */
|
||||
for (int natt = 0; natt < tupdesc->natts; natt++) {
|
||||
Form_pg_attribute attr; /* the attribute itself */
|
||||
Oid typoutput; /* output function */
|
||||
bool typisvarlena = false;
|
||||
Datum origval; /* possibly toasted Datum */
|
||||
bool isnull = true; /* column is null? */
|
||||
|
||||
attr = &tupdesc->attrs[natt];
|
||||
|
||||
/*
|
||||
* don't print dropped columns, we can't be sure everything is
|
||||
* available for them
|
||||
*/
|
||||
if (attr->attisdropped)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Don't print system columns, oid will already have been printed if
|
||||
* present.
|
||||
*/
|
||||
if (attr->attnum < 0 || (isOld && !IsRelationReplidentKey(relation, attr->attnum)))
|
||||
continue;
|
||||
|
||||
Oid typid = attr->atttypid; /* type of current attribute */
|
||||
|
||||
/* get Datum from tuple */
|
||||
if (tuple->tupTableType == HEAP_TUPLE) {
|
||||
origval = heap_getattr(tuple, natt + 1, tupdesc, &isnull);
|
||||
} else {
|
||||
origval = uheap_getattr((UHeapTuple)tuple, natt + 1, tupdesc, &isnull);
|
||||
}
|
||||
|
||||
/* print attribute name */
|
||||
appendStringInfoChar(s, ' ');
|
||||
appendStringInfoString(s, quote_identifier(NameStr(attr->attname)));
|
||||
|
||||
/* print attribute type */
|
||||
appendStringInfoChar(s, '[');
|
||||
char* type_name = format_type_be(typid);
|
||||
if (strlen(type_name) == strlen("clob") && strncmp(type_name, "clob", strlen("clob")) == 0) {
|
||||
errno_t rc = strcpy_s(type_name, sizeof("clob"), "text");
|
||||
securec_check_c(rc, "\0", "\0");
|
||||
}
|
||||
appendStringInfoString(s, type_name);
|
||||
appendStringInfoChar(s, ']');
|
||||
|
||||
/* query output function */
|
||||
getTypeOutputInfo(typid, &typoutput, &typisvarlena);
|
||||
|
||||
/* print separator */
|
||||
appendStringInfoChar(s, ':');
|
||||
|
||||
/* print data */
|
||||
if (isnull)
|
||||
appendStringInfoString(s, "null");
|
||||
else if (typisvarlena && VARATT_IS_EXTERNAL_ONDISK_B(origval))
|
||||
appendStringInfoString(s, "unchanged-toast-datum");
|
||||
else if (!typisvarlena)
|
||||
PrintLiteral(s, typid, OidOutputFunctionCall(typoutput, origval));
|
||||
else {
|
||||
Datum val; /* definitely detoasted Datum */
|
||||
val = PointerGetDatum(PG_DETOAST_DATUM(origval));
|
||||
PrintLiteral(s, typid, OidOutputFunctionCall(typoutput, val));
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* callback for individual changed tuples
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user