From 083600343771cac59267ab266d4a1d120a65fdb0 Mon Sep 17 00:00:00 2001 From: Fantix King Date: Mon, 25 Nov 2024 10:12:51 -0500 Subject: [PATCH] Replace headers with annotations in Parse/Execute --- edb/server/protocol/binary.pxd | 2 ++ edb/server/protocol/binary.pyx | 35 ++++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/edb/server/protocol/binary.pxd b/edb/server/protocol/binary.pxd index d6d480834d6..8a6cde986ae 100644 --- a/edb/server/protocol/binary.pxd +++ b/edb/server/protocol/binary.pxd @@ -97,6 +97,8 @@ cdef class EdgeConnection(frontend.FrontendConnection): cdef inline reject_headers(self) cdef inline ignore_headers(self) cdef dict parse_headers(self) + cdef dict parse_annotations(self) + cdef inline ignore_annotations(self) cdef write_status(self, bytes name, bytes value) cdef write_edgedb_error(self, exc) diff --git a/edb/server/protocol/binary.pyx b/edb/server/protocol/binary.pyx index 6f23400bdeb..f9b60b9af99 100644 --- a/edb/server/protocol/binary.pyx +++ b/edb/server/protocol/binary.pyx @@ -637,6 +637,31 @@ cdef class EdgeConnection(frontend.FrontendConnection): self.buffer.read_len_prefixed_bytes() num_fields -= 1 + cdef dict parse_annotations(self): + cdef: + dict annos + uint16_t num_annos + str name, value + + annos = {} + num_annos = self.buffer.read_int16() + while num_annos: + name = self.buffer.read_len_prefixed_utf8() + value = self.buffer.read_len_prefixed_utf8() + annos[name] = value + num_annos -= 1 + return annos + + cdef inline ignore_annotations(self): + cdef: + uint16_t num_annos + + num_annos = self.buffer.read_int16() + while num_annos: + self.buffer.read_len_prefixed_bytes() + self.buffer.read_len_prefixed_bytes() + num_annos -= 1 + ############# cdef WriteBuffer make_negotiate_protocol_version_msg( @@ -883,7 +908,10 @@ cdef class EdgeConnection(frontend.FrontendConnection): self._last_anon_compiled = None - self.ignore_headers() + if self.protocol_version >= (3, 0): + self.ignore_annotations() + else: + self.ignore_headers() _dbview = self.get_dbview() if _dbview.get_state_serializer() is None: @@ -913,7 +941,10 @@ cdef class EdgeConnection(frontend.FrontendConnection): bytes args uint64_t allow_capabilities - self.ignore_headers() + if self.protocol_version >= (3, 0): + self.ignore_annotations() + else: + self.ignore_headers() _dbview = self.get_dbview() if _dbview.get_state_serializer() is None: