cockroachdb fix for macro (#1386)

This commit is contained in:
Altan Özlü 2021-08-17 22:20:08 +03:00 committed by GitHub
parent 38435ca647
commit 774880d17c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 6 deletions

View file

@ -399,13 +399,16 @@ SELECT oid FROM pg_catalog.pg_type WHERE typname ILIKE $1
.fetch_all(&mut *self)
.await?;
// patch up our null inference with data from EXPLAIN
let nullable_patch = self
.nullables_from_explain(stmt_id, meta.parameters.len())
.await?;
// if it's cockroachdb skip this step #1248
if !self.stream.parameter_statuses.contains_key("crdb_version") {
// patch up our null inference with data from EXPLAIN
let nullable_patch = self
.nullables_from_explain(stmt_id, meta.parameters.len())
.await?;
for (nullable, patch) in nullables.iter_mut().zip(nullable_patch) {
*nullable = patch.or(*nullable);
for (nullable, patch) in nullables.iter_mut().zip(nullable_patch) {
*nullable = patch.or(*nullable);
}
}
Ok(nullables)

View file

@ -47,3 +47,16 @@ fn bench_decode_parameter_status(b: &mut test::Bencher) {
ParameterStatus::decode(test::black_box(Bytes::from_static(DATA))).unwrap();
});
}
#[test]
fn test_decode_parameter_status_response() {
const PARAMETER_STATUS_RESPONSE: &[u8] = b"crdb_version\0CockroachDB CCL v21.1.0 (x86_64-unknown-linux-gnu, built 2021/05/17 13:49:40, go1.15.11)\0";
let message = ParameterStatus::decode(Bytes::from(PARAMETER_STATUS_RESPONSE)).unwrap();
assert_eq!(message.name, "crdb_version");
assert_eq!(
message.value,
"CockroachDB CCL v21.1.0 (x86_64-unknown-linux-gnu, built 2021/05/17 13:49:40, go1.15.11)"
);
}