DBZ-486 Replication message provides info about optionality
parent
88dfd7e594
commit
0718e99b7a
|
@ -32,6 +32,7 @@ message DatumMessage {
|
|||
|
||||
message TypeInfo {
|
||||
required string modifier = 1;
|
||||
required bool value_optional = 2;
|
||||
}
|
||||
|
||||
message RowMessage {
|
||||
|
|
|
@ -640,6 +640,7 @@ static void add_metadata_to_msg(Decoderbufs__TypeInfo **tmsg,
|
|||
Form_pg_attribute attr;
|
||||
char *typ_mod;
|
||||
Decoderbufs__TypeInfo typeinfo = DECODERBUFS__TYPE_INFO__INIT;
|
||||
bool not_null;
|
||||
|
||||
attr = tupdesc->attrs[natt];
|
||||
|
||||
|
@ -649,10 +650,12 @@ static void add_metadata_to_msg(Decoderbufs__TypeInfo **tmsg,
|
|||
continue;
|
||||
}
|
||||
|
||||
not_null = attr->attnotnull;
|
||||
typ_mod = TextDatumGetCString(DirectFunctionCall2(format_type, attr->atttypid, attr->atttypmod));
|
||||
elog(DEBUG1, "Adding typemodifier '%s' for column %d", typ_mod, natt);
|
||||
elog(DEBUG1, "Adding typemodifier '%s' for column %d, optional %s", typ_mod, natt, !not_null ? "true" : "false");
|
||||
|
||||
typeinfo.modifier = typ_mod;
|
||||
typeinfo.value_optional = !not_null;
|
||||
tmsg[valid_attr_cnt] = palloc(sizeof(typeinfo));
|
||||
memcpy(tmsg[valid_attr_cnt], &typeinfo, sizeof(typeinfo));
|
||||
|
||||
|
|
|
@ -385,7 +385,7 @@ const ProtobufCMessageDescriptor decoderbufs__datum_message__descriptor =
|
|||
(ProtobufCMessageInit) decoderbufs__datum_message__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
static const ProtobufCFieldDescriptor decoderbufs__type_info__field_descriptors[1] =
|
||||
static const ProtobufCFieldDescriptor decoderbufs__type_info__field_descriptors[2] =
|
||||
{
|
||||
{
|
||||
"modifier",
|
||||
|
@ -399,14 +399,27 @@ static const ProtobufCFieldDescriptor decoderbufs__type_info__field_descriptors[
|
|||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"value_optional",
|
||||
2,
|
||||
PROTOBUF_C_LABEL_REQUIRED,
|
||||
PROTOBUF_C_TYPE_BOOL,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(Decoderbufs__TypeInfo, value_optional),
|
||||
NULL,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
};
|
||||
static const unsigned decoderbufs__type_info__field_indices_by_name[] = {
|
||||
0, /* field[0] = modifier */
|
||||
1, /* field[1] = value_optional */
|
||||
};
|
||||
static const ProtobufCIntRange decoderbufs__type_info__number_ranges[1 + 1] =
|
||||
{
|
||||
{ 1, 0 },
|
||||
{ 0, 1 }
|
||||
{ 0, 2 }
|
||||
};
|
||||
const ProtobufCMessageDescriptor decoderbufs__type_info__descriptor =
|
||||
{
|
||||
|
@ -416,7 +429,7 @@ const ProtobufCMessageDescriptor decoderbufs__type_info__descriptor =
|
|||
"Decoderbufs__TypeInfo",
|
||||
"decoderbufs",
|
||||
sizeof(Decoderbufs__TypeInfo),
|
||||
1,
|
||||
2,
|
||||
decoderbufs__type_info__field_descriptors,
|
||||
decoderbufs__type_info__field_indices_by_name,
|
||||
1, decoderbufs__type_info__number_ranges,
|
||||
|
|
|
@ -82,10 +82,11 @@ struct _Decoderbufs__TypeInfo
|
|||
{
|
||||
ProtobufCMessage base;
|
||||
char *modifier;
|
||||
protobuf_c_boolean value_optional;
|
||||
};
|
||||
#define DECODERBUFS__TYPE_INFO__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&decoderbufs__type_info__descriptor) \
|
||||
, NULL }
|
||||
, NULL, 0 }
|
||||
|
||||
|
||||
struct _Decoderbufs__RowMessage
|
||||
|
|
Loading…
Reference in New Issue