DBZ-7599 Write toast placeholder instead of null for binary types when "hex" mode configured
This commit is contained in:
parent
edaea2f3fc
commit
69efa7e218
@ -593,3 +593,4 @@ Clifford Cheefoon
|
||||
Fr0z3Nn
|
||||
Xianming Zhou
|
||||
Akula
|
||||
Nick Golubev
|
@ -1162,6 +1162,9 @@ protected Object convertBinaryToBase64UrlSafe(Column column, Field fieldDefn, Ob
|
||||
|
||||
@Override
|
||||
protected Object convertBinaryToHex(Column column, Field fieldDefn, Object data) {
|
||||
if (data == UnchangedToastedReplicationMessageColumn.UNCHANGED_TOAST_VALUE) {
|
||||
return unchangedToastedPlaceholder.getToastPlaceholderString();
|
||||
}
|
||||
return super.convertBinaryToHex(column, fieldDefn, (data instanceof PGobject) ? ((PGobject) data).getValue() : data);
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalTime;
|
||||
import java.time.OffsetDateTime;
|
||||
@ -103,6 +104,7 @@
|
||||
import io.debezium.time.MicroTimestamp;
|
||||
import io.debezium.time.ZonedTime;
|
||||
import io.debezium.time.ZonedTimestamp;
|
||||
import io.debezium.util.HexConverter;
|
||||
import io.debezium.util.Stopwatch;
|
||||
import io.debezium.util.Testing;
|
||||
|
||||
@ -1801,6 +1803,33 @@ final var record = consumer.remove();
|
||||
.isEqualTo(SchemaBuilder.array(Schema.OPTIONAL_BYTES_SCHEMA).optional().build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldHandleToastedByteaColumnInHexMode() throws Exception {
|
||||
TestHelper.execute(
|
||||
"DROP TABLE IF EXISTS test_toast_table;",
|
||||
"CREATE TABLE test_toast_table (id SERIAL PRIMARY KEY);");
|
||||
|
||||
startConnector(config -> config.with(CommonConnectorConfig.BINARY_HANDLING_MODE, BinaryHandlingMode.HEX), false);
|
||||
final String toastedValue = RandomStringUtils.randomNumeric(10000);
|
||||
|
||||
String statement = "ALTER TABLE test_toast_table ADD COLUMN not_toast integer;"
|
||||
+ "ALTER TABLE test_toast_table ADD COLUMN bytea_ bytea;"
|
||||
+ "ALTER TABLE test_toast_table ALTER COLUMN bytea_ SET STORAGE EXTENDED;"
|
||||
+ "INSERT INTO test_toast_table (not_toast, bytea_) values (10, '" + toastedValue + "'::bytea);";
|
||||
consumer = testConsumer(1);
|
||||
executeAndWait(statement);
|
||||
|
||||
// after record should contain the toasted value
|
||||
assertValueField(consumer.remove(), "after/bytea_", HexConverter.convertToHexString(toastedValue.getBytes(StandardCharsets.UTF_8)));
|
||||
|
||||
statement = "UPDATE test_toast_table SET not_toast = 2;";
|
||||
|
||||
consumer.expects(1);
|
||||
executeAndWait(statement);
|
||||
// after update of toasted value record should contain the placeholder
|
||||
assertValueField(consumer.remove(), "after/bytea_", DecoderDifferences.mandatoryToastedValuePlaceholder());
|
||||
}
|
||||
|
||||
@Test
|
||||
@FixFor("DBZ-5936")
|
||||
public void shouldHandleToastedIntegerArrayColumn() throws Exception {
|
||||
|
@ -259,3 +259,4 @@ nrkeli,Emil Lindström
|
||||
akulapid,Akula
|
||||
ArthurLR,Arthur Le Ray
|
||||
Lars M Johansson,Lars M. Johansson
|
||||
nivolg,Nick Golubev
|
||||
|
Loading…
Reference in New Issue
Block a user