MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / decode_bind

Function decode_bind

src/pgwire/src/codec.rs:854–890  ·  view source on GitHub ↗
(mut buf: Cursor)

Source from the content-addressed store, hash-verified

852}
853
854fn decode_bind(mut buf: Cursor) -> Result<FrontendMessage, io::Error> {
855 let portal_name = buf.read_cstr()?.to_string();
856 let statement_name = buf.read_cstr()?.to_string();
857
858 let mut param_formats = Vec::new();
859 for _ in 0..buf.read_i16()? {
860 param_formats.push(buf.read_format()?);
861 }
862
863 let mut raw_params = Vec::new();
864 for _ in 0..buf.read_i16()? {
865 let len = buf.read_i32()?;
866 if len == -1 {
867 raw_params.push(None); // NULL
868 } else {
869 // TODO(benesch): this should use bytes::Bytes to avoid the copy.
870 let mut value = Vec::new();
871 for _ in 0..len {
872 value.push(buf.read_byte()?);
873 }
874 raw_params.push(Some(value));
875 }
876 }
877
878 let mut result_formats = Vec::new();
879 for _ in 0..buf.read_i16()? {
880 result_formats.push(buf.read_format()?);
881 }
882
883 Ok(FrontendMessage::Bind {
884 portal_name,
885 statement_name,
886 param_formats,
887 raw_params,
888 result_formats,
889 })
890}
891
892fn decode_execute(mut buf: Cursor) -> Result<FrontendMessage, io::Error> {
893 let portal_name = buf.read_cstr()?.to_string();

Callers 1

decodeMethod · 0.85

Calls 7

read_cstrMethod · 0.80
read_i16Method · 0.80
read_formatMethod · 0.80
read_i32Method · 0.80
read_byteMethod · 0.80
to_stringMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected