applyToBuffer method
void
applyToBuffer(
- PgByteDataWriter buffer
)
override
Implementation
@override
void applyToBuffer(PgByteDataWriter buffer) {
final databaseName = buffer.encodeString(_databaseName);
final timeZone = buffer.encodeString(_timeZone);
final username = _username == null ? null : buffer.encodeString(_username!);
final replication = buffer.encodeString(_replication);
var fixedLength = 44 + buffer.encodingName.bytesLength;
var variableLength = databaseName.bytesLength + timeZone.bytesLength + 2;
if (username != null) {
fixedLength += 5;
variableLength += username.bytesLength + 1;
}
if (_replication != ReplicationMode.none.value) {
fixedLength += UTF8ByteConstants.replication.length;
variableLength += replication.bytesLength + 1;
}
buffer.writeInt32(fixedLength + variableLength);
buffer.writeInt32(ClientMessage.ProtocolVersion);
if (username != null) {
buffer.write(UTF8ByteConstants.user);
buffer.writeEncodedString(username);
}
if (_replication != ReplicationMode.none.value) {
buffer.write(UTF8ByteConstants.replication);
buffer.writeEncodedString(replication);
}
buffer.write(UTF8ByteConstants.database);
buffer.writeEncodedString(databaseName);
buffer.write(UTF8ByteConstants.clientEncoding);
buffer.writeEncodedString(buffer.encodingName);
buffer.write(UTF8ByteConstants.timeZone);
buffer.writeEncodedString(timeZone);
buffer.writeInt8(0);
}