Skip to content

Commit e375003

Browse files
jpechanegunnarmorling
authored andcommitted
DBZ-486 Replication message provides info about optionality
1 parent 2f3179e commit e375003

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

proto/pg_logicaldec.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ message DatumMessage {
3232

3333
message TypeInfo {
3434
required string modifier = 1;
35+
required bool value_optional = 2;
3536
}
3637

3738
message RowMessage {

src/decoderbufs.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ static void add_metadata_to_msg(Decoderbufs__TypeInfo **tmsg,
640640
Form_pg_attribute attr;
641641
char *typ_mod;
642642
Decoderbufs__TypeInfo typeinfo = DECODERBUFS__TYPE_INFO__INIT;
643+
bool not_null;
643644

644645
attr = tupdesc->attrs[natt];
645646

@@ -649,10 +650,12 @@ static void add_metadata_to_msg(Decoderbufs__TypeInfo **tmsg,
649650
continue;
650651
}
651652

653+
not_null = attr->attnotnull;
652654
typ_mod = TextDatumGetCString(DirectFunctionCall2(format_type, attr->atttypid, attr->atttypmod));
653-
elog(DEBUG1, "Adding typemodifier '%s' for column %d", typ_mod, natt);
655+
elog(DEBUG1, "Adding typemodifier '%s' for column %d, optional %s", typ_mod, natt, !not_null ? "true" : "false");
654656

655657
typeinfo.modifier = typ_mod;
658+
typeinfo.value_optional = !not_null;
656659
tmsg[valid_attr_cnt] = palloc(sizeof(typeinfo));
657660
memcpy(tmsg[valid_attr_cnt], &typeinfo, sizeof(typeinfo));
658661

src/proto/pg_logicaldec.pb-c.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ const ProtobufCMessageDescriptor decoderbufs__datum_message__descriptor =
385385
(ProtobufCMessageInit) decoderbufs__datum_message__init,
386386
NULL,NULL,NULL /* reserved[123] */
387387
};
388-
static const ProtobufCFieldDescriptor decoderbufs__type_info__field_descriptors[1] =
388+
static const ProtobufCFieldDescriptor decoderbufs__type_info__field_descriptors[2] =
389389
{
390390
{
391391
"modifier",
@@ -399,14 +399,27 @@ static const ProtobufCFieldDescriptor decoderbufs__type_info__field_descriptors[
399399
0, /* flags */
400400
0,NULL,NULL /* reserved1,reserved2, etc */
401401
},
402+
{
403+
"value_optional",
404+
2,
405+
PROTOBUF_C_LABEL_REQUIRED,
406+
PROTOBUF_C_TYPE_BOOL,
407+
0, /* quantifier_offset */
408+
offsetof(Decoderbufs__TypeInfo, value_optional),
409+
NULL,
410+
NULL,
411+
0, /* flags */
412+
0,NULL,NULL /* reserved1,reserved2, etc */
413+
},
402414
};
403415
static const unsigned decoderbufs__type_info__field_indices_by_name[] = {
404416
0, /* field[0] = modifier */
417+
1, /* field[1] = value_optional */
405418
};
406419
static const ProtobufCIntRange decoderbufs__type_info__number_ranges[1 + 1] =
407420
{
408421
{ 1, 0 },
409-
{ 0, 1 }
422+
{ 0, 2 }
410423
};
411424
const ProtobufCMessageDescriptor decoderbufs__type_info__descriptor =
412425
{
@@ -416,7 +429,7 @@ const ProtobufCMessageDescriptor decoderbufs__type_info__descriptor =
416429
"Decoderbufs__TypeInfo",
417430
"decoderbufs",
418431
sizeof(Decoderbufs__TypeInfo),
419-
1,
432+
2,
420433
decoderbufs__type_info__field_descriptors,
421434
decoderbufs__type_info__field_indices_by_name,
422435
1, decoderbufs__type_info__number_ranges,

src/proto/pg_logicaldec.pb-c.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)