Skip to content

Commit e268122

Browse files
authored
Remove remaining v0 protocol bits (#511)
This removes the last traces of v0. We now return an error from gel-tokio's connection methods if we get this in a server version. gel-tokio and gel-protocol get a minor verison bump to help end-users who might possibly need the older server support.
1 parent d6cbd41 commit e268122

File tree

7 files changed

+15
-189
lines changed

7 files changed

+15
-189
lines changed

gel-db-protocol/src/protocol.rs

Lines changed: 0 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ message_group!(
3232
Parse,
3333
Execute,
3434
Sync,
35-
Flush,
3635
Terminate,
3736
Dump,
3837
Restore,
@@ -85,18 +84,6 @@ struct LogMessage<'a>: Message {
8584
annotations: Array<'a, i16, Annotation<'a>>,
8685
}
8786

88-
/// The `ReadyForCommand` struct represents a message indicating the server is ready for a new command.
89-
struct ReadyForCommand0<'a>: Message {
90-
/// Identifies the message as ready for command.
91-
mtype: u8 = 'Z',
92-
/// Length of message contents in bytes, including self.
93-
mlen: len,
94-
/// Message headers.
95-
headers: Array<'a, i16, KeyValue<'a>>,
96-
/// Transaction state.
97-
transaction_state: TransactionState,
98-
}
99-
10087
/// The `ReadyForCommand` struct represents a message indicating the server is ready for a new command.
10188
struct ReadyForCommand<'a>: Message {
10289
/// Identifies the message as ready for command.
@@ -347,14 +334,6 @@ struct Sync<'a>: Message {
347334
mlen: len,
348335
}
349336

350-
/// The `Flush` struct represents a flush message from the client.
351-
struct Flush<'a>: Message {
352-
/// Identifies the message as flush.
353-
mtype: u8 = 'H',
354-
/// Length of message contents in bytes, including self.
355-
mlen: len,
356-
}
357-
358337
/// The `Restore` struct represents a restore message from the client.
359338
struct Restore<'a>: Message {
360339
/// Identifies the message as restore.
@@ -441,18 +420,6 @@ struct Parse<'a>: Message {
441420
state_data: Array<'a, u32, u8>,
442421
}
443422

444-
/// The `ParseComplete` struct represents the response to a `Parse` request from the client.
445-
struct ParseComplete<'a>: Message {
446-
/// The headers
447-
headers: Array<'a, i16, KeyValue<'a>>,
448-
/// Cardinality
449-
cardinality: u8,
450-
/// Input descriptor ID.
451-
input_typedesc_id: Uuid,
452-
/// Output descriptor ID.
453-
output_typedesc_id: Uuid,
454-
}
455-
456423
/// The `Execute` struct represents an execute message from the client.
457424
struct Execute<'a>: Message {
458425
/// Identifies the message as execute.
@@ -591,74 +558,6 @@ struct ConnectionParam<'a> {
591558
value: LString<'a>,
592559
}
593560

594-
/// Legacy response of [`Prepare0`].
595-
struct PrepareComplete0<'a>: Message {
596-
mtype: u8 = '1',
597-
mlen: len,
598-
headers: Array<'a, i16, KeyValue<'a>>,
599-
cardinality: u8,
600-
input_typedesc_id: Uuid,
601-
output_typedesc_id: Uuid,
602-
}
603-
604-
/// Legacy request.
605-
struct ExecuteScript0<'a>: Message {
606-
mtype: u8 = 'Q',
607-
mlen: len,
608-
headers: Array<'a, i16, KeyValue<'a>>,
609-
script_text: LString<'a>,
610-
}
611-
612-
/// Legacy equivalent of [`Parse`].
613-
struct Prepare0<'a>: Message {
614-
mtype: u8 = 'P',
615-
mlen: len,
616-
headers: Array<'a, i16, KeyValue<'a>>,
617-
io_format: IoFormat,
618-
expected_cardinality: u8,
619-
statement_name: Array<'a, u32, u8>,
620-
command_text: LString<'a>,
621-
}
622-
623-
/// Legacy equivalent of [`Parse`].
624-
struct DescribeStatement0<'a>: Message {
625-
mtype: u8 = 'D',
626-
mlen: len,
627-
headers: Array<'a, i16, KeyValue<'a>>,
628-
aspect: DescribeAspect,
629-
statement_name: Array<'a, u32, u8>,
630-
}
631-
632-
/// Legacy version of [`CommandComplete`].
633-
struct CommandComplete0<'a>: Message {
634-
mtype: u8 = 'C',
635-
mlen: len,
636-
headers: Array<'a, i16, KeyValue<'a>>,
637-
status_data: Array<'a, u32, u8>,
638-
}
639-
640-
/// Legacy version of [`CommandDataDescription`].
641-
struct CommandDataDescription0<'a>: Message {
642-
mtype: u8 = 'T',
643-
mlen: len,
644-
headers: Array<'a, i16, KeyValue<'a>>,
645-
result_cardinality: u8,
646-
input_typedesc_id: Uuid,
647-
input_typedesc: Array<'a, u32, u8>,
648-
output_typedesc_id: Uuid,
649-
output_typedesc: Array<'a, u32, u8>,
650-
}
651-
652-
/// Legacy version of [`Execute`].
653-
struct Execute0<'a>: Message {
654-
mtype: u8 = 'E',
655-
mlen: len,
656-
headers: Array<'a, i16, KeyValue<'a>>,
657-
statement_name: Array<'a, u32, u8>,
658-
arguments: Array<'a, u32, u8>,
659-
}
660-
661-
662561
/// Legacy version of [`Execute`] without `input_language`.
663562
struct Execute2<'a>: Message {
664563
/// Identifies the message as execute.
@@ -691,19 +590,6 @@ struct Execute2<'a>: Message {
691590
arguments: Array<'a, u32, u8>,
692591
}
693592

694-
/// Legacy version of [`Execute`].
695-
struct OptimisticExecute0<'a>: Message {
696-
mtype: u8 = 'O',
697-
mlen: len,
698-
headers: Array<'a, i16, KeyValue<'a>>,
699-
io_format: IoFormat,
700-
expected_cardinality: u8,
701-
command_text: LString<'a>,
702-
input_typedesc_id: Uuid,
703-
output_typedesc_id: Uuid,
704-
arguments: Array<'a, u32, u8>,
705-
}
706-
707593
#[repr(u8)]
708594
/// Data format.
709595
enum IoFormat {

gel-protocol/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "gel-protocol"
33
license = "MIT/Apache-2.0"
4-
version = "0.8.5"
4+
version = "0.9.0"
55
authors = ["MagicStack Inc. <hello@magic.io>"]
66
edition = "2018"
77
description = """

gel-protocol/src/descriptors.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -698,13 +698,8 @@ impl Decode for ObjectShapeDescriptor {
698698
impl Decode for ShapeElement {
699699
fn decode(buf: &mut Input) -> Result<Self, DecodeError> {
700700
ensure!(buf.remaining() >= 7, errors::Underflow);
701-
let (flags, cardinality) = if buf.proto().is_at_least(0, 11) {
702-
let flags = buf.get_u32();
703-
let cardinality = TryFrom::try_from(buf.get_u8())?;
704-
(flags, Some(cardinality))
705-
} else {
706-
(buf.get_u8() as u32, None)
707-
};
701+
let flags = buf.get_u32();
702+
let cardinality = Some(Cardinality::try_from(buf.get_u8())?);
708703
let name = String::decode(buf)?;
709704
let type_pos = TypePos::decode(buf)?;
710705
let source_type_pos = if buf.proto().is_2() {

gel-protocol/tests/type_descriptors.rs

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ fn decode_1_0(bytes: &[u8]) -> Result<Vec<Descriptor>, DecodeError> {
3333
decode(ProtocolVersion::new(1, 0), bytes)
3434
}
3535

36-
fn decode_0_10(bytes: &[u8]) -> Result<Vec<Descriptor>, DecodeError> {
37-
decode(ProtocolVersion::new(0, 10), bytes)
38-
}
39-
4036
#[test]
4137
fn empty_tuple() -> Result<(), Box<dyn Error>> {
4238
// `SELECT ()`
@@ -168,67 +164,6 @@ fn duration() -> Result<(), Box<dyn Error>> {
168164
Ok(())
169165
}
170166

171-
#[test]
172-
fn object_0_10() -> Result<(), Box<dyn Error>> {
173-
assert_eq!(
174-
decode_0_10(bconcat!(
175-
b"\x02\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\0\x02"
176-
b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\x01\x01n"
177-
b"\xbb\xbe\xda\0P\x14\xfe\x84\xbc\x82\x15@\xb1"
178-
b"R\xcd\0\x03\x01\0\0\0\x07__tid__\0\0\x01"
179-
b"\0\0\0\x02id\0\0\0\0\0\0\x05title\0\x01"))?,
180-
vec![
181-
Descriptor::BaseScalar(BaseScalarTypeDescriptor {
182-
id: "00000000-0000-0000-0000-000000000100"
183-
.parse::<Uuid>()?
184-
.into(),
185-
}),
186-
Descriptor::BaseScalar(BaseScalarTypeDescriptor {
187-
id: "00000000-0000-0000-0000-000000000101"
188-
.parse::<Uuid>()?
189-
.into(),
190-
}),
191-
Descriptor::ObjectShape(ObjectShapeDescriptor {
192-
id: "6ebbbeda-0050-14fe-84bc-821540b152cd"
193-
.parse::<Uuid>()?
194-
.into(),
195-
ephemeral_free_shape: false,
196-
type_pos: None,
197-
elements: vec![
198-
ShapeElement {
199-
flag_implicit: true,
200-
flag_link_property: false,
201-
flag_link: false,
202-
cardinality: None,
203-
name: String::from("__tid__"),
204-
type_pos: TypePos(0),
205-
source_type_pos: None,
206-
},
207-
ShapeElement {
208-
flag_implicit: true,
209-
flag_link_property: false,
210-
flag_link: false,
211-
cardinality: None,
212-
name: String::from("id"),
213-
type_pos: TypePos(0),
214-
source_type_pos: None,
215-
},
216-
ShapeElement {
217-
flag_implicit: false,
218-
flag_link_property: false,
219-
flag_link: false,
220-
cardinality: None,
221-
name: String::from("title"),
222-
type_pos: TypePos(1),
223-
source_type_pos: None,
224-
}
225-
]
226-
})
227-
]
228-
);
229-
Ok(())
230-
}
231-
232167
#[test]
233168
fn object_1_0() -> Result<(), Box<dyn Error>> {
234169
use gel_protocol::common::Cardinality::*;

gel-tokio/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "gel-tokio"
33
license = "MIT/Apache-2.0"
4-
version = "0.10.16"
4+
version = "0.11.0"
55
authors = ["MagicStack Inc. <hello@magic.io>"]
66
edition = "2021"
77
description = """
@@ -12,7 +12,7 @@ readme = "README.md"
1212
rust-version.workspace = true
1313

1414
[dependencies]
15-
gel-protocol = { path = "../gel-protocol", version = "^0.8.5", features = [
15+
gel-protocol = { path = "../gel-protocol", version = "^0.9.0", features = [
1616
"with-serde",
1717
] }
1818
gel-errors = { path = "../gel-errors", version = "^0.5.4" }

gel-tokio/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ async fn main() -> anyhow::Result<()> {
3737

3838
More [examples on github](https://github.com/edgedb/edgedb-rust/tree/master/gel-tokio/examples)
3939

40+
Version Support
41+
===============
42+
43+
Gel protocol version 0 support was removed in 0.11.x.
44+
4045

4146
License
4247
=======

gel-tokio/src/raw/connection.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,11 @@ async fn connect4(cfg: &Config, mut stream: gel_stream::RawStream, cert_check: O
371371
params.insert(String::from("secret_key"), secret_key.to_string());
372372
}
373373
let (major_ver, minor_ver) = proto.version_tuple();
374+
if major_ver < 1 {
375+
return Err(ProtocolError::with_message(format!(
376+
"EdgeDB protocol version {major_ver}.{minor_ver} is not supported"
377+
)));
378+
}
374379
send_messages(
375380
&mut stream,
376381
&mut out_buf,

0 commit comments

Comments
 (0)