applyToBuffer method
void
applyToBuffer(
- ByteDataWriter buffer
)
override
Implementation
@override
void applyToBuffer(ByteDataWriter buffer) {
buffer.writeUint8(ClientMessage.BindIdentifier);
buffer.writeUint32(length - 1);
// Name of portal.
_portalName.applyToBuffer(buffer);
// Name of prepared statement.
_statementName.applyToBuffer(buffer);
// OK, if we have no specified types at all, we can use 0. If we have all specified types, we can use 1. If we have a mix, we have to individually
// call out each type.
if (_typeSpecCount == _parameters.length) {
buffer.writeUint16(1);
// Apply following format code for all parameters by indicating 1
buffer.writeUint16(ClientMessage.FormatBinary);
} else if (_typeSpecCount == 0) {
buffer.writeUint16(1);
// Apply following format code for all parameters by indicating 1
buffer.writeUint16(ClientMessage.FormatText);
} else {
// Well, we have some text and some binary, so we have to be explicit about each one
buffer.writeUint16(_parameters.length);
for (final p in _parameters) {
buffer.writeUint16(
p.isBinary ? ClientMessage.FormatBinary : ClientMessage.FormatText);
}
}
// This must be the number of $n's in the query.
buffer.writeUint16(_parameters.length);
for (final p in _parameters) {
if (p.bytes == null) {
buffer.writeInt32(-1);
} else {
buffer.writeInt32(p.length);
buffer.write(p.bytes!);
}
}
// Result columns - we always want binary for all of them, so specify 1:1.
buffer.writeUint16(1);
buffer.writeUint16(1);
}