| 1 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::errorrust-analyzer cargo sqlx-postgres 0.8.3 error/::Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#; |
| 2 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::extrust-analyzer cargo sqlx-core 0.8.3 ext/::ustrrust-analyzer cargo sqlx-core 0.8.3 ext/ustr/::UStrrust-analyzer cargo sqlx-core 0.8.3 ext/ustr/UStr#; |
| 3 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::iorust-analyzer cargo sqlx-postgres 0.8.3 io/::StatementIdrust-analyzer cargo sqlx-postgres 0.8.3 io/StatementId#; |
| 4 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::messagerust-analyzer cargo sqlx-postgres 0.8.3 message/::{ParameterDescriptionrust-analyzer cargo sqlx-postgres 0.8.3 message/parameter_description/ParameterDescription#, RowDescriptionrust-analyzer cargo sqlx-postgres 0.8.3 message/row_description/RowDescription#}; |
| 5 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::query_asrust-analyzer cargo sqlx-core 0.8.3 query_as/::query_asrust-analyzer cargo sqlx-core 0.8.3 query_as/query_as().; |
| 6 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::query_scalarrust-analyzer cargo sqlx-core 0.8.3 query_scalar/::query_scalarrust-analyzer cargo sqlx-core 0.8.3 query_scalar/query_scalar().; |
| 7 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::statementrust-analyzer cargo sqlx-postgres 0.8.3 statement/::PgStatementMetadatarust-analyzer cargo sqlx-postgres 0.8.3 statement/PgStatementMetadata#; |
| 8 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::type_inforust-analyzer cargo sqlx-postgres 0.8.3 type_info/::{PgArrayOfrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgArrayOf#, PgCustomTyperust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType#, PgTyperust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgType#, PgTypeKindrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeKind#}; |
| 9 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::typesrust-analyzer cargo sqlx-postgres 0.8.3 types/::Jsonrust-analyzer cargo sqlx-core 0.8.3 types/json/Json#; |
| 10 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::typesrust-analyzer cargo sqlx-postgres 0.8.3 types/::Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#; |
| 11 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::HashMaprust-analyzer cargo hashbrown 0.15.5 map/HashMap#; |
| 12 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::{PgColumnrust-analyzer cargo sqlx-postgres 0.8.3 column/PgColumn#, PgConnectionrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#, PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#}; |
| 13 | use smallvecrust-analyzer cargo smallvec 1.15.2 crate/::SmallVecrust-analyzer cargo smallvec 1.15.2 SmallVec#; |
| 14 | use sqlx_corerust-analyzer cargo sqlx-core 0.8.3 crate/::query_builderrust-analyzer cargo sqlx-core 0.8.3 query_builder/::QueryBuilderrust-analyzer cargo sqlx-core 0.8.3 query_builder/QueryBuilder#; |
| 15 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#; |
| 16 | |
| 17 | /// Describes the type of the `pg_type.typtype` column |
| 18 | /// |
| 19 | /// See <https://www.postgresql.org/docs/13/catalog-pg-type.html> |
| 20 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 21 | enum TypTyperust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType# { |
| 22 | Baserust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#Base#, |
| 23 | Compositerust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#Composite#, |
| 24 | Domainrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#Domain#, |
| 25 | Enumrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#Enum#, |
| 26 | Pseudorust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#Pseudo#, |
| 27 | Rangerust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#Range#, |
| 28 | } |
| 29 | |
| 30 | impl TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#<i8> for TypTyperust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType# { |
| 31 | type Errorrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypType][`TryFrom<i8>`]Error# = (); |
| 32 | |
| 33 | fn try_fromrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypType][`TryFrom<i8>`]try_from().(t: i8) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypType][`TryFrom<i8>`], Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypType][`TryFrom<i8>`]::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#Error#> { |
| 34 | let t = u8::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u8][`TryFrom<i8>`]try_from().(t).orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]or().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(()))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 35 | |
| 36 | let t = match t { |
| 37 | b'b' => Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypType][`TryFrom<i8>`]::Baserust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#Base#, |
| 38 | b'c' => Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypType][`TryFrom<i8>`]::Compositerust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#Composite#, |
| 39 | b'd' => Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypType][`TryFrom<i8>`]::Domainrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#Domain#, |
| 40 | b'e' => Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypType][`TryFrom<i8>`]::Enumrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#Enum#, |
| 41 | b'p' => Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypType][`TryFrom<i8>`]::Pseudorust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#Pseudo#, |
| 42 | b'r' => Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypType][`TryFrom<i8>`]::Rangerust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#Range#, |
| 43 | _ => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(()), |
| 44 | }; |
| 45 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(t) |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | /// Describes the type of the `pg_type.typcategory` column |
| 50 | /// |
| 51 | /// See <https://www.postgresql.org/docs/13/catalog-pg-type.html#CATALOG-TYPCATEGORY-TABLE> |
| 52 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 53 | enum TypCategoryrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory# { |
| 54 | Arrayrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Array#, |
| 55 | Booleanrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Boolean#, |
| 56 | Compositerust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Composite#, |
| 57 | DateTimerust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#DateTime#, |
| 58 | Enumrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Enum#, |
| 59 | Geometricrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Geometric#, |
| 60 | Networkrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Network#, |
| 61 | Numericrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Numeric#, |
| 62 | Pseudorust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Pseudo#, |
| 63 | Rangerust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Range#, |
| 64 | Stringrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#String#, |
| 65 | Timespanrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Timespan#, |
| 66 | Userrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#User#, |
| 67 | BitStringrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#BitString#, |
| 68 | Unknownrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Unknown#, |
| 69 | } |
| 70 | |
| 71 | impl TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#<i8> for TypCategoryrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory# { |
| 72 | type Errorrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypCategory][`TryFrom<i8>`]Error# = (); |
| 73 | |
| 74 | fn try_fromrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypCategory][`TryFrom<i8>`]try_from().(c: i8) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypCategory][`TryFrom<i8>`], Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypCategory][`TryFrom<i8>`]::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#Error#> { |
| 75 | let c = u8::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u8][`TryFrom<i8>`]try_from().(c).orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]or().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(()))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 76 | |
| 77 | let c = match c { |
| 78 | b'A' => Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypCategory][`TryFrom<i8>`]::Arrayrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Array#, |
| 79 | b'B' => Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypCategory][`TryFrom<i8>`]::Booleanrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Boolean#, |
| 80 | b'C' => Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypCategory][`TryFrom<i8>`]::Compositerust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Composite#, |
| 81 | b'D' => Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypCategory][`TryFrom<i8>`]::DateTimerust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#DateTime#, |
| 82 | b'E' => Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypCategory][`TryFrom<i8>`]::Enumrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Enum#, |
| 83 | b'G' => Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypCategory][`TryFrom<i8>`]::Geometricrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Geometric#, |
| 84 | b'I' => Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypCategory][`TryFrom<i8>`]::Networkrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Network#, |
| 85 | b'N' => Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypCategory][`TryFrom<i8>`]::Numericrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Numeric#, |
| 86 | b'P' => Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypCategory][`TryFrom<i8>`]::Pseudorust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Pseudo#, |
| 87 | b'R' => Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypCategory][`TryFrom<i8>`]::Rangerust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Range#, |
| 88 | b'S' => Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypCategory][`TryFrom<i8>`]::Stringrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#String#, |
| 89 | b'T' => Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypCategory][`TryFrom<i8>`]::Timespanrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Timespan#, |
| 90 | b'U' => Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypCategory][`TryFrom<i8>`]::Userrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#User#, |
| 91 | b'V' => Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypCategory][`TryFrom<i8>`]::BitStringrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#BitString#, |
| 92 | b'X' => Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypCategory][`TryFrom<i8>`]::Unknownrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Unknown#, |
| 93 | _ => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(()), |
| 94 | }; |
| 95 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(c) |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | impl PgConnectionrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection# { |
| 100 | pub(superrust-analyzer cargo sqlx-postgres 0.8.3 connection/) async fn handle_row_descriptionrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]handle_row_description().( |
| 101 | &mut self, |
| 102 | desc: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<RowDescriptionrust-analyzer cargo sqlx-postgres 0.8.3 message/row_description/RowDescription#>, |
| 103 | should_fetch: bool, |
| 104 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<PgColumnrust-analyzer cargo sqlx-postgres 0.8.3 column/PgColumn#>, HashMaprust-analyzer cargo hashbrown 0.15.5 map/HashMap#<UStrrust-analyzer cargo sqlx-core 0.8.3 ext/ustr/UStr#, usize>), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 105 | let mut columns = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 106 | let mut column_names = HashMaprust-analyzer cargo hashbrown 0.15.5 map/HashMap#::newrust-analyzer cargo hashbrown 0.15.5 map/impl#[`HashMap<K, V>`]new().(); |
| 107 | |
| 108 | let desc = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(desc) = desc { |
| 109 | desc |
| 110 | } else { |
| 111 | // no rows |
| 112 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((columns, column_names)); |
| 113 | }; |
| 114 | |
| 115 | columns.reserverust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]reserve().(desc.fieldsrust-analyzer cargo sqlx-postgres 0.8.3 message/row_description/RowDescription#fields..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()); |
| 116 | column_names.reserverust-analyzer cargo hashbrown 0.15.5 map/impl#[`HashMap<K, V, S, A>`]reserve().(desc.fieldsrust-analyzer cargo sqlx-postgres 0.8.3 message/row_description/RowDescription#fields..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()); |
| 117 | |
| 118 | for (index, field) in desc.fieldsrust-analyzer cargo sqlx-postgres 0.8.3 message/row_description/RowDescription#fields..into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 119 | let name = UStrrust-analyzer cargo sqlx-core 0.8.3 ext/ustr/UStr#::fromrust-analyzer cargo sqlx-core 0.8.3 ext/ustr/impl#[UStr][`From<String>`]from().(field.namerust-analyzer cargo sqlx-postgres 0.8.3 message/row_description/Field#name.); |
| 120 | |
| 121 | let type_info = self |
| 122 | .maybe_fetch_type_info_by_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]maybe_fetch_type_info_by_oid().(field.data_type_idrust-analyzer cargo sqlx-postgres 0.8.3 message/row_description/Field#data_type_id., should_fetch) |
| 123 | .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 124 | |
| 125 | let column = PgColumnrust-analyzer cargo sqlx-postgres 0.8.3 column/PgColumn# { |
| 126 | ordinalrust-analyzer cargo sqlx-postgres 0.8.3 column/PgColumn#ordinal.: index, |
| 127 | namerust-analyzer cargo sqlx-postgres 0.8.3 column/PgColumn#name.: name.clonerust-analyzer cargo sqlx-core 0.8.3 ext/ustr/impl#[UStr][Clone]clone().(), |
| 128 | type_inforust-analyzer cargo sqlx-postgres 0.8.3 column/PgColumn#type_info., |
| 129 | relation_idrust-analyzer cargo sqlx-postgres 0.8.3 column/PgColumn#relation_id.: field.relation_idrust-analyzer cargo sqlx-postgres 0.8.3 message/row_description/Field#relation_id., |
| 130 | relation_attribute_norust-analyzer cargo sqlx-postgres 0.8.3 column/PgColumn#relation_attribute_no.: field.relation_attribute_norust-analyzer cargo sqlx-postgres 0.8.3 message/row_description/Field#relation_attribute_no., |
| 131 | }; |
| 132 | |
| 133 | columns.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(column); |
| 134 | column_names.insertrust-analyzer cargo hashbrown 0.15.5 map/impl#[`HashMap<K, V, S, A>`]insert().(name, index); |
| 135 | } |
| 136 | |
| 137 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((columns, column_names)) |
| 138 | } |
| 139 | |
| 140 | pub(superrust-analyzer cargo sqlx-postgres 0.8.3 connection/) async fn handle_parameter_descriptionrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]handle_parameter_description().( |
| 141 | &mut self, |
| 142 | desc: ParameterDescriptionrust-analyzer cargo sqlx-postgres 0.8.3 message/parameter_description/ParameterDescription#, |
| 143 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#>, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 144 | let mut params = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(desc.typesrust-analyzer cargo sqlx-postgres 0.8.3 message/parameter_description/ParameterDescription#types..lenrust-analyzer cargo smallvec 1.15.2 impl#[`SmallVec<A>`]len().()); |
| 145 | |
| 146 | for ty in desc.typesrust-analyzer cargo sqlx-postgres 0.8.3 message/parameter_description/ParameterDescription#types. { |
| 147 | params.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(self.maybe_fetch_type_info_by_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]maybe_fetch_type_info_by_oid().(ty, true).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().); |
| 148 | } |
| 149 | |
| 150 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(params) |
| 151 | } |
| 152 | |
| 153 | async fn maybe_fetch_type_info_by_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]maybe_fetch_type_info_by_oid().( |
| 154 | &mut self, |
| 155 | oid: Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#, |
| 156 | should_fetch: bool, |
| 157 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 158 | // first we check if this is a built-in type |
| 159 | // in the average application, the vast majority of checks should flow through this |
| 160 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(info) = PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#::try_from_oidrust-analyzer cargo sqlx-postgres 0.8.3 type_info/impl#[PgTypeInfo]try_from_oid().(oid) { |
| 161 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(info); |
| 162 | } |
| 163 | |
| 164 | // next we check a local cache for user-defined type names <-> object id |
| 165 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(info) = self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..cache_type_inforust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#cache_type_info..getrust-analyzer cargo hashbrown 0.15.5 map/impl#[`HashMap<K, V, S, A>`]get().(&oid) { |
| 166 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(info.clonerust-analyzer cargo sqlx-postgres 0.8.3 type_info/impl#[PgTypeInfo][Clone]clone().()); |
| 167 | } |
| 168 | |
| 169 | // fallback to asking the database directly for a type name |
| 170 | if should_fetch { |
| 171 | // we're boxing this future here so we can use async recursion |
| 172 | let info = Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::pinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]pin().(async { self.fetch_type_by_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]fetch_type_by_oid().(oid).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll(). }).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 173 | |
| 174 | // cache the type name <-> oid relationship in a paired hashmap |
| 175 | // so we don't come down this road again |
| 176 | self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..cache_type_inforust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#cache_type_info..insertrust-analyzer cargo hashbrown 0.15.5 map/impl#[`HashMap<K, V, S, A>`]insert().(oid, info.clonerust-analyzer cargo sqlx-postgres 0.8.3 type_info/impl#[PgTypeInfo][Clone]clone().()); |
| 177 | self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner. |
| 178 | .cache_type_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#cache_type_oid. |
| 179 | .insertrust-analyzer cargo hashbrown 0.15.5 map/impl#[`HashMap<K, V, S, A>`]insert().(info.0rust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#0..namerust-analyzer cargo sqlx-postgres 0.8.3 type_info/impl#[PgType]name().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), oid); |
| 180 | |
| 181 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(info) |
| 182 | } else { |
| 183 | // we are not in a place that *can* run a query |
| 184 | // this generally means we are in the middle of another query |
| 185 | // this _should_ only happen for complex types sent through the TEXT protocol |
| 186 | // we're open to ideas to correct this.. but it'd probably be more efficient to figure |
| 187 | // out a way to "prime" the type cache for connections rather than make this |
| 188 | // fallback work correctly for complex user-defined types for the TEXT protocol |
| 189 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#(PgTyperust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgType#::DeclareWithOidrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgType#DeclareWithOid#(oid))) |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | async fn fetch_type_by_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]fetch_type_by_oid().(&mut self, oid: Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 194 | let (name, typ_type, category, relation_id, element, base_type): ( |
| 195 | Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 196 | i8, |
| 197 | i8, |
| 198 | Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#, |
| 199 | Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#, |
| 200 | Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#, |
| 201 | ) = query_asrust-analyzer cargo sqlx-core 0.8.3 query_as/query_as().( |
| 202 | // Converting the OID to `regtype` and then `text` will give us the name that |
| 203 | // the type will need to be found at by search_path. |
| 204 | "SELECT oid::regtype::text, \ |
| 205 | typtype, \ |
| 206 | typcategory, \ |
| 207 | typrelid, \ |
| 208 | typelem, \ |
| 209 | typbasetype \ |
| 210 | FROM pg_catalog.pg_type \ |
| 211 | WHERE oid = $1", |
| 212 | ) |
| 213 | .bindrust-analyzer cargo sqlx-core 0.8.3 query_as/impl#[`QueryAs<'q, DB, O, <DB as Database>::Arguments<'q>>`]bind().(oid) |
| 214 | .fetch_onerust-analyzer cargo sqlx-core 0.8.3 query_as/impl#[`QueryAs<'q, DB, O, A>`]fetch_one().(&mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self) |
| 215 | .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 216 | |
| 217 | let typ_type = TypTyperust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#::try_fromrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypType][`TryFrom<i8>`]try_from().(typ_type); |
| 218 | let category = TypCategoryrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#::try_fromrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[TypCategory][`TryFrom<i8>`]try_from().(category); |
| 219 | |
| 220 | match (typ_type, category) { |
| 221 | (Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(TypTyperust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#::Domainrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#Domain#), _) => self.fetch_domain_by_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]fetch_domain_by_oid().(oid, base_type, name).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()., |
| 222 | |
| 223 | (Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(TypTyperust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#::Baserust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#Base#), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(TypCategoryrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#::Arrayrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Array#)) => { |
| 224 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#(PgTyperust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgType#::Customrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgType#Custom#(Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(PgCustomTyperust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType# { |
| 225 | kindrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType#kind.: PgTypeKindrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeKind#::Arrayrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeKind#Array#( |
| 226 | self.maybe_fetch_type_info_by_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]maybe_fetch_type_info_by_oid().(element, true).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 227 | ), |
| 228 | namerust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType#name.: name.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 229 | oidrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType#oid., |
| 230 | })))) |
| 231 | } |
| 232 | |
| 233 | (Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(TypTyperust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#::Pseudorust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#Pseudo#), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(TypCategoryrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#::Pseudorust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Pseudo#)) => { |
| 234 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#(PgTyperust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgType#::Customrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgType#Custom#(Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(PgCustomTyperust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType# { |
| 235 | kindrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType#kind.: PgTypeKindrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeKind#::Pseudorust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeKind#Pseudo#, |
| 236 | namerust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType#name.: name.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 237 | oidrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType#oid., |
| 238 | })))) |
| 239 | } |
| 240 | |
| 241 | (Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(TypTyperust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#::Rangerust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#Range#), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(TypCategoryrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#::Rangerust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Range#)) => { |
| 242 | self.fetch_range_by_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]fetch_range_by_oid().(oid, name).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll(). |
| 243 | } |
| 244 | |
| 245 | (Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(TypTyperust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#::Enumrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#Enum#), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(TypCategoryrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#::Enumrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Enum#)) => self.fetch_enum_by_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]fetch_enum_by_oid().(oid, name).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()., |
| 246 | |
| 247 | (Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(TypTyperust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#::Compositerust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypType#Composite#), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(TypCategoryrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#::Compositerust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/TypCategory#Composite#)) => { |
| 248 | self.fetch_composite_by_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]fetch_composite_by_oid().(oid, relation_id, name).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll(). |
| 249 | } |
| 250 | |
| 251 | _ => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#(PgTyperust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgType#::Customrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgType#Custom#(Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(PgCustomTyperust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType# { |
| 252 | kindrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType#kind.: PgTypeKindrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeKind#::Simplerust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeKind#Simple#, |
| 253 | namerust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType#name.: name.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 254 | oidrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType#oid., |
| 255 | })))), |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | async fn fetch_enum_by_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]fetch_enum_by_oid().(&mut self, oid: Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#, name: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 260 | let variants: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> = query_scalarrust-analyzer cargo sqlx-core 0.8.3 query_scalar/query_scalar().( |
| 261 | r#" |
| 262 | SELECT enumlabel |
| 263 | FROM pg_catalog.pg_enum |
| 264 | WHERE enumtypid = $1 |
| 265 | ORDER BY enumsortorder |
| 266 | "#, |
| 267 | ) |
| 268 | .bindrust-analyzer cargo sqlx-core 0.8.3 query_scalar/impl#[`QueryScalar<'q, DB, O, <DB as Database>::Arguments<'q>>`]bind().(oid) |
| 269 | .fetch_allrust-analyzer cargo sqlx-core 0.8.3 query_scalar/impl#[`QueryScalar<'q, DB, O, A>`]fetch_all().(self) |
| 270 | .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 271 | |
| 272 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#(PgTyperust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgType#::Customrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgType#Custom#(Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(PgCustomTyperust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType# { |
| 273 | oidrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType#oid., |
| 274 | namerust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType#name.: name.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 275 | kindrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType#kind.: PgTypeKindrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeKind#::Enumrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeKind#Enum#(Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<[T], A>`][`From<Vec<T, A>>`]from().(variants)), |
| 276 | })))) |
| 277 | } |
| 278 | |
| 279 | async fn fetch_composite_by_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]fetch_composite_by_oid().( |
| 280 | &mut self, |
| 281 | oid: Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#, |
| 282 | relation_id: Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#, |
| 283 | name: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 284 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 285 | let raw_fields: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#)> = query_asrust-analyzer cargo sqlx-core 0.8.3 query_as/query_as().( |
| 286 | r#" |
| 287 | SELECT attname, atttypid |
| 288 | FROM pg_catalog.pg_attribute |
| 289 | WHERE attrelid = $1 |
| 290 | AND NOT attisdropped |
| 291 | AND attnum > 0 |
| 292 | ORDER BY attnum |
| 293 | "#, |
| 294 | ) |
| 295 | .bindrust-analyzer cargo sqlx-core 0.8.3 query_as/impl#[`QueryAs<'q, DB, O, <DB as Database>::Arguments<'q>>`]bind().(relation_id) |
| 296 | .fetch_allrust-analyzer cargo sqlx-core 0.8.3 query_as/impl#[`QueryAs<'q, DB, O, A>`]fetch_all().(&mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self) |
| 297 | .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 298 | |
| 299 | let mut fields = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 300 | |
| 301 | for (field_name, field_oid) in raw_fields.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() { |
| 302 | let field_type = self.maybe_fetch_type_info_by_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]maybe_fetch_type_info_by_oid().(field_oid, true).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 303 | |
| 304 | fields.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((field_name, field_type)); |
| 305 | } |
| 306 | |
| 307 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#(PgTyperust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgType#::Customrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgType#Custom#(Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(PgCustomTyperust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType# { |
| 308 | oidrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType#oid., |
| 309 | namerust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType#name.: name.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 310 | kindrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType#kind.: PgTypeKindrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeKind#::Compositerust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeKind#Composite#(Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<[T], A>`][`From<Vec<T, A>>`]from().(fields)), |
| 311 | })))) |
| 312 | } |
| 313 | |
| 314 | async fn fetch_domain_by_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]fetch_domain_by_oid().( |
| 315 | &mut self, |
| 316 | oid: Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#, |
| 317 | base_type: Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#, |
| 318 | name: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 319 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 320 | let base_type = self.maybe_fetch_type_info_by_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]maybe_fetch_type_info_by_oid().(base_type, true).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 321 | |
| 322 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#(PgTyperust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgType#::Customrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgType#Custom#(Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(PgCustomTyperust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType# { |
| 323 | oidrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType#oid., |
| 324 | namerust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType#name.: name.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 325 | kindrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType#kind.: PgTypeKindrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeKind#::Domainrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeKind#Domain#(base_type), |
| 326 | })))) |
| 327 | } |
| 328 | |
| 329 | async fn fetch_range_by_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]fetch_range_by_oid().(&mut self, oid: Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#, name: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 330 | let element_oid: Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid# = query_scalarrust-analyzer cargo sqlx-core 0.8.3 query_scalar/query_scalar().( |
| 331 | r#" |
| 332 | SELECT rngsubtype |
| 333 | FROM pg_catalog.pg_range |
| 334 | WHERE rngtypid = $1 |
| 335 | "#, |
| 336 | ) |
| 337 | .bindrust-analyzer cargo sqlx-core 0.8.3 query_scalar/impl#[`QueryScalar<'q, DB, O, <DB as Database>::Arguments<'q>>`]bind().(oid) |
| 338 | .fetch_onerust-analyzer cargo sqlx-core 0.8.3 query_scalar/impl#[`QueryScalar<'q, DB, O, A>`]fetch_one().(&mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self) |
| 339 | .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 340 | |
| 341 | let element = self.maybe_fetch_type_info_by_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]maybe_fetch_type_info_by_oid().(element_oid, true).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 342 | |
| 343 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#(PgTyperust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgType#::Customrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgType#Custom#(Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(PgCustomTyperust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType# { |
| 344 | kindrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType#kind.: PgTypeKindrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeKind#::Rangerust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeKind#Range#(element), |
| 345 | namerust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType#name.: name.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 346 | oidrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgCustomType#oid., |
| 347 | })))) |
| 348 | } |
| 349 | |
| 350 | pub(craterust-analyzer cargo sqlx-postgres 0.8.3 crate/) async fn resolve_type_idrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]resolve_type_id().(&mut self, ty: &PgTyperust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgType#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 351 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(oid) = ty.try_oidrust-analyzer cargo sqlx-postgres 0.8.3 type_info/impl#[PgType]try_oid().() { |
| 352 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(oid); |
| 353 | } |
| 354 | |
| 355 | match ty { |
| 356 | PgTyperust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgType#::DeclareWithNamerust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgType#DeclareWithName#(name) => self.fetch_type_id_by_namerust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]fetch_type_id_by_name().(name).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()., |
| 357 | PgTyperust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgType#::DeclareArrayOfrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgType#DeclareArrayOf#(array) => self.fetch_array_type_idrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]fetch_array_type_id().(array).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()., |
| 358 | // `.try_oid()` should return `Some()` or it should be covered here |
| 359 | _ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!("(bug) OID should be resolvable for type {ty:?}"), |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | pub(craterust-analyzer cargo sqlx-postgres 0.8.3 crate/) async fn fetch_type_id_by_namerust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]fetch_type_id_by_name().(&mut self, name: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 364 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(oid) = self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..cache_type_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#cache_type_oid..getrust-analyzer cargo hashbrown 0.15.5 map/impl#[`HashMap<K, V, S, A>`]get().(name) { |
| 365 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().oid); |
| 366 | } |
| 367 | |
| 368 | // language=SQL |
| 369 | let (oid,): (Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#,) = query_asrust-analyzer cargo sqlx-core 0.8.3 query_as/query_as().("SELECT $1::regtype::oid") |
| 370 | .bindrust-analyzer cargo sqlx-core 0.8.3 query_as/impl#[`QueryAs<'q, DB, O, <DB as Database>::Arguments<'q>>`]bind().(name) |
| 371 | .fetch_optionalrust-analyzer cargo sqlx-core 0.8.3 query_as/impl#[`QueryAs<'q, DB, O, A>`]fetch_optional().(&mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self) |
| 372 | .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 373 | .ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::TypeNotFoundrust-analyzer cargo sqlx-core 0.8.3 error/Error#TypeNotFound# { |
| 374 | type_namerust-analyzer cargo sqlx-core 0.8.3 error/Error#TypeNotFound#type_name.: name.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 375 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 376 | |
| 377 | self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner. |
| 378 | .cache_type_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#cache_type_oid. |
| 379 | .insertrust-analyzer cargo hashbrown 0.15.5 map/impl#[`HashMap<K, V, S, A>`]insert().(name.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), oid); |
| 380 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(oid) |
| 381 | } |
| 382 | |
| 383 | pub(craterust-analyzer cargo sqlx-postgres 0.8.3 crate/) async fn fetch_array_type_idrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]fetch_array_type_id().(&mut self, array: &PgArrayOfrust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgArrayOf#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 384 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(oid) = self |
| 385 | .innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner. |
| 386 | .cache_type_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#cache_type_oid. |
| 387 | .getrust-analyzer cargo hashbrown 0.15.5 map/impl#[`HashMap<K, V, S, A>`]get().(&array.elem_namerust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgArrayOf#elem_name.) |
| 388 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|elem_oid| self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..cache_elem_type_to_arrayrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#cache_elem_type_to_array..getrust-analyzer cargo hashbrown 0.15.5 map/impl#[`HashMap<K, V, S, A>`]get().(elem_oid)) |
| 389 | { |
| 390 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().oid); |
| 391 | } |
| 392 | |
| 393 | // language=SQL |
| 394 | let (elem_oid, array_oid): (Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#, Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#) = |
| 395 | query_asrust-analyzer cargo sqlx-core 0.8.3 query_as/query_as().("SELECT oid, typarray FROM pg_catalog.pg_type WHERE oid = $1::regtype::oid") |
| 396 | .bindrust-analyzer cargo sqlx-core 0.8.3 query_as/impl#[`QueryAs<'q, DB, O, <DB as Database>::Arguments<'q>>`]bind().(&*rust-analyzer cargo sqlx-core 0.8.3 ext/ustr/impl#[UStr][Deref]deref().array.elem_namerust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgArrayOf#elem_name.) |
| 397 | .fetch_optionalrust-analyzer cargo sqlx-core 0.8.3 query_as/impl#[`QueryAs<'q, DB, O, A>`]fetch_optional().(&mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self) |
| 398 | .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 399 | .ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::TypeNotFoundrust-analyzer cargo sqlx-core 0.8.3 error/Error#TypeNotFound# { |
| 400 | type_namerust-analyzer cargo sqlx-core 0.8.3 error/Error#TypeNotFound#type_name.: array.namerust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgArrayOf#name..to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 401 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 402 | |
| 403 | // Avoids copying `elem_name` until necessary |
| 404 | self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner. |
| 405 | .cache_type_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#cache_type_oid. |
| 406 | .entry_refrust-analyzer cargo hashbrown 0.15.5 map/impl#[`HashMap<K, V, S, A>`]entry_ref().(&array.elem_namerust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgArrayOf#elem_name.) |
| 407 | .insertrust-analyzer cargo hashbrown 0.15.5 map/impl#[`EntryRef<'a, 'b, K, Q, V, S, A>`]insert().(elem_oid); |
| 408 | self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner. |
| 409 | .cache_elem_type_to_arrayrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#cache_elem_type_to_array. |
| 410 | .insertrust-analyzer cargo hashbrown 0.15.5 map/impl#[`HashMap<K, V, S, A>`]insert().(elem_oid, array_oid); |
| 411 | |
| 412 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(array_oid) |
| 413 | } |
| 414 | |
| 415 | /// Check whether EXPLAIN statements are supported by the current connection |
| 416 | fn is_explain_availablerust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]is_explain_available().(&self) -> bool { |
| 417 | let parameter_statuses = &self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..streamrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#stream..parameter_statusesrust-analyzer cargo sqlx-postgres 0.8.3 connection/stream/PgStream#parameter_statuses.; |
| 418 | let is_cockroachdb = parameter_statuses.contains_keyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]contains_key().("crdb_version"); |
| 419 | let is_materialize = parameter_statuses.contains_keyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]contains_key().("mz_version"); |
| 420 | let is_questdb = parameter_statuses.contains_keyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]contains_key().("questdb_version"); |
| 421 | !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_cockroachdb && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_materialize && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_questdb |
| 422 | } |
| 423 | |
| 424 | pub(craterust-analyzer cargo sqlx-postgres 0.8.3 crate/) async fn get_nullable_for_columnsrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]get_nullable_for_columns().( |
| 425 | &mut self, |
| 426 | stmt_id: StatementIdrust-analyzer cargo sqlx-postgres 0.8.3 io/StatementId#, |
| 427 | meta: &PgStatementMetadatarust-analyzer cargo sqlx-postgres 0.8.3 statement/PgStatementMetadata#, |
| 428 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<bool>>, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 429 | if meta.columnsrust-analyzer cargo sqlx-postgres 0.8.3 statement/PgStatementMetadata#columns..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 430 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]); |
| 431 | } |
| 432 | |
| 433 | if meta.columnsrust-analyzer cargo sqlx-postgres 0.8.3 statement/PgStatementMetadata#columns..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().3 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().65535 { |
| 434 | tracingrust-analyzer cargo tracing 0.1.44 crate/::debugrust-analyzer cargo tracing 0.1.44 macros/debug!!( |
| 435 | ?stmt_id, |
| 436 | num_columns = meta.columnsrust-analyzer cargo sqlx-postgres 0.8.3 statement/PgStatementMetadata#columns..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), |
| 437 | "number of columns in query is too large to pull nullability for" |
| 438 | ); |
| 439 | } |
| 440 | |
| 441 | // Query for NOT NULL constraints for each column in the query. |
| 442 | // |
| 443 | // This will include columns that don't have a `relation_id` (are not from a table); |
| 444 | // assuming those are a minority of columns, it's less code to _not_ work around it |
| 445 | // and just let Postgres return `NULL`. |
| 446 | // |
| 447 | // Use `UNION ALL` syntax instead of `VALUES` due to frequent lack of |
| 448 | // support for `VALUES` in pgwire supported databases. |
| 449 | let mut nullable_query = QueryBuilderrust-analyzer cargo sqlx-core 0.8.3 query_builder/QueryBuilder#::newrust-analyzer cargo sqlx-core 0.8.3 query_builder/impl#[`QueryBuilder<'args, DB>`]new().("SELECT NOT attnotnull FROM ( "); |
| 450 | let mut separated = nullable_query.separatedrust-analyzer cargo sqlx-core 0.8.3 query_builder/impl#[`QueryBuilder<'args, DB>`]separated().("UNION ALL "); |
| 451 | |
| 452 | let mut column_iter = meta.columnsrust-analyzer cargo sqlx-postgres 0.8.3 statement/PgStatementMetadata#columns..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(0i32..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#); |
| 453 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((column, i)) = column_iter.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/zip/impl#[`Zip<A, B>`][Iterator]next().() { |
| 454 | separated.pushrust-analyzer cargo sqlx-core 0.8.3 query_builder/impl#[`Separated<'qb, 'args, DB, Sep>`]push().("( SELECT "); |
| 455 | separated |
| 456 | .push_bind_unseparatedrust-analyzer cargo sqlx-core 0.8.3 query_builder/impl#[`Separated<'qb, 'args, DB, Sep>`]push_bind_unseparated().(i) |
| 457 | .push_unseparatedrust-analyzer cargo sqlx-core 0.8.3 query_builder/impl#[`Separated<'qb, 'args, DB, Sep>`]push_unseparated().("::int4 AS idx, "); |
| 458 | separated |
| 459 | .push_bind_unseparatedrust-analyzer cargo sqlx-core 0.8.3 query_builder/impl#[`Separated<'qb, 'args, DB, Sep>`]push_bind_unseparated().(column.relation_idrust-analyzer cargo sqlx-postgres 0.8.3 column/PgColumn#relation_id.) |
| 460 | .push_unseparatedrust-analyzer cargo sqlx-core 0.8.3 query_builder/impl#[`Separated<'qb, 'args, DB, Sep>`]push_unseparated().("::int4 AS table_id, "); |
| 461 | separated |
| 462 | .push_bind_unseparatedrust-analyzer cargo sqlx-core 0.8.3 query_builder/impl#[`Separated<'qb, 'args, DB, Sep>`]push_bind_unseparated().(column.relation_attribute_norust-analyzer cargo sqlx-postgres 0.8.3 column/PgColumn#relation_attribute_no.) |
| 463 | .push_unseparatedrust-analyzer cargo sqlx-core 0.8.3 query_builder/impl#[`Separated<'qb, 'args, DB, Sep>`]push_unseparated().("::int2 AS col_idx ) "); |
| 464 | } |
| 465 | |
| 466 | for (column, i) in column_iter { |
| 467 | separated.pushrust-analyzer cargo sqlx-core 0.8.3 query_builder/impl#[`Separated<'qb, 'args, DB, Sep>`]push().("( SELECT "); |
| 468 | separated |
| 469 | .push_bind_unseparatedrust-analyzer cargo sqlx-core 0.8.3 query_builder/impl#[`Separated<'qb, 'args, DB, Sep>`]push_bind_unseparated().(i) |
| 470 | .push_unseparatedrust-analyzer cargo sqlx-core 0.8.3 query_builder/impl#[`Separated<'qb, 'args, DB, Sep>`]push_unseparated().("::int4, "); |
| 471 | separated |
| 472 | .push_bind_unseparatedrust-analyzer cargo sqlx-core 0.8.3 query_builder/impl#[`Separated<'qb, 'args, DB, Sep>`]push_bind_unseparated().(column.relation_idrust-analyzer cargo sqlx-postgres 0.8.3 column/PgColumn#relation_id.) |
| 473 | .push_unseparatedrust-analyzer cargo sqlx-core 0.8.3 query_builder/impl#[`Separated<'qb, 'args, DB, Sep>`]push_unseparated().("::int4, "); |
| 474 | separated |
| 475 | .push_bind_unseparatedrust-analyzer cargo sqlx-core 0.8.3 query_builder/impl#[`Separated<'qb, 'args, DB, Sep>`]push_bind_unseparated().(column.relation_attribute_norust-analyzer cargo sqlx-postgres 0.8.3 column/PgColumn#relation_attribute_no.) |
| 476 | .push_unseparatedrust-analyzer cargo sqlx-core 0.8.3 query_builder/impl#[`Separated<'qb, 'args, DB, Sep>`]push_unseparated().("::int2 ) "); |
| 477 | } |
| 478 | |
| 479 | nullable_query.pushrust-analyzer cargo sqlx-core 0.8.3 query_builder/impl#[`QueryBuilder<'args, DB>`]push().( |
| 480 | ") AS col LEFT JOIN pg_catalog.pg_attribute \ |
| 481 | ON table_id IS NOT NULL \ |
| 482 | AND attrelid = table_id \ |
| 483 | AND attnum = col_idx \ |
| 484 | ORDER BY idx", |
| 485 | ); |
| 486 | |
| 487 | let mut nullables: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<bool>> = nullable_query |
| 488 | .build_query_scalarrust-analyzer cargo sqlx-core 0.8.3 query_builder/impl#[`QueryBuilder<'args, DB>`]build_query_scalar().() |
| 489 | .fetch_allrust-analyzer cargo sqlx-core 0.8.3 query_scalar/impl#[`QueryScalar<'q, DB, O, A>`]fetch_all().(&mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self) |
| 490 | .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll(). |
| 491 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| { |
| 492 | err_protocolrust-analyzer cargo sqlx-core 0.8.3 error/err_protocol!!( |
| 493 | "error from nullables query: {e}; query: {:?}", |
| 494 | nullable_query.sqlrust-analyzer cargo sqlx-core 0.8.3 query_builder/impl#[`QueryBuilder<'args, DB>`]sql().() |
| 495 | ) |
| 496 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 497 | |
| 498 | // If the server doesn't support EXPLAIN statements, skip this step (#1248). |
| 499 | if self.is_explain_availablerust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]is_explain_available().() { |
| 500 | // patch up our null inference with data from EXPLAIN |
| 501 | let nullable_patch = self |
| 502 | .nullables_from_explainrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]nullables_from_explain().(stmt_id, meta.parametersrust-analyzer cargo sqlx-postgres 0.8.3 statement/PgStatementMetadata#parameters..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()) |
| 503 | .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 504 | |
| 505 | for (nullable, patch) in nullables.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(nullable_patch) { |
| 506 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().nullable = patch.orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]or().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().nullable); |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(nullables) |
| 511 | } |
| 512 | |
| 513 | /// Infer nullability for columns of this statement using EXPLAIN VERBOSE. |
| 514 | /// |
| 515 | /// This currently only marks columns that are on the inner half of an outer join |
| 516 | /// and returns `None` for all others. |
| 517 | async fn nullables_from_explainrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/impl#[PgConnection]nullables_from_explain().( |
| 518 | &mut self, |
| 519 | stmt_id: StatementIdrust-analyzer cargo sqlx-postgres 0.8.3 io/StatementId#, |
| 520 | params_len: usize, |
| 521 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<bool>>, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 522 | let stmt_id_display = stmt_id |
| 523 | .displayrust-analyzer cargo sqlx-postgres 0.8.3 io/impl#[StatementId]display().() |
| 524 | .ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| err_protocolrust-analyzer cargo sqlx-core 0.8.3 error/err_protocol!!("cannot EXPLAIN unnamed statement: {stmt_id:?}"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 525 | |
| 526 | let mut explain = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("EXPLAIN (VERBOSE, FORMAT JSON) EXECUTE {stmt_id_display}"); |
| 527 | let mut comma = false; |
| 528 | |
| 529 | if params_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 { |
| 530 | explain rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`AddAssign<&str>`]add_assign().+=rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`AddAssign<&str>`]add_assign(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`AddAssign<&str>`]add_assign()."("; |
| 531 | |
| 532 | // fill the arguments list with NULL, which should theoretically be valid |
| 533 | for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#params_len { |
| 534 | if comma { |
| 535 | explain rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`AddAssign<&str>`]add_assign().+=rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`AddAssign<&str>`]add_assign(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`AddAssign<&str>`]add_assign().", "; |
| 536 | } |
| 537 | |
| 538 | explain rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`AddAssign<&str>`]add_assign().+=rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`AddAssign<&str>`]add_assign(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`AddAssign<&str>`]add_assign()."NULL"; |
| 539 | comma = true; |
| 540 | } |
| 541 | |
| 542 | explain rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`AddAssign<&str>`]add_assign().+=rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`AddAssign<&str>`]add_assign(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`AddAssign<&str>`]add_assign().")"; |
| 543 | } |
| 544 | |
| 545 | let (Jsonrust-analyzer cargo sqlx-core 0.8.3 types/json/Json#(explains),): (Jsonrust-analyzer cargo sqlx-core 0.8.3 types/json/Json#<SmallVecrust-analyzer cargo smallvec 1.15.2 SmallVec#<[Explainrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Explain#; 1]>>,) = |
| 546 | query_asrust-analyzer cargo sqlx-core 0.8.3 query_as/query_as().(&explain).fetch_onerust-analyzer cargo sqlx-core 0.8.3 query_as/impl#[`QueryAs<'q, DB, O, A>`]fetch_one().(self).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 547 | |
| 548 | let mut nullables = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 549 | |
| 550 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Explainrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Explain#::Planrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Explain#Plan# { |
| 551 | planrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Explain#Plan#plan.: |
| 552 | plan @ Planrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Plan# { |
| 553 | outputrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Plan#output.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref outputs), |
| 554 | .. |
| 555 | }, |
| 556 | }) = explains.firstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]first().() |
| 557 | { |
| 558 | nullables.resizerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]resize().(outputs.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 559 | visit_planrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/visit_plan().(plan, outputs, &mut nullables); |
| 560 | } |
| 561 | |
| 562 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(nullables) |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | fn visit_planrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/visit_plan().(plan: &Planrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Plan#, outputs: &[Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#], nullables: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<bool>>) { |
| 567 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(plan_outputs) = &plan.outputrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Plan#output. { |
| 568 | // all outputs of a Full Join must be marked nullable |
| 569 | // otherwise, all outputs of the inner half of an outer join must be marked nullable |
| 570 | if plan.join_typerust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Plan#join_type..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Full") |
| 571 | || plan.parent_relationrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Plan#parent_relation..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Inner") |
| 572 | { |
| 573 | for output in plan_outputs { |
| 574 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(i) = outputs.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().positionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]position().(|o| o rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().output) { |
| 575 | // N.B. this may produce false positives but those don't cause runtime errors |
| 576 | nullables[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(true); |
| 577 | } |
| 578 | } |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(plans) = &plan.plansrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Plan#plans. { |
| 583 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Left") | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Right") = plan.join_typerust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Plan#join_type..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().() { |
| 584 | for plan in plans { |
| 585 | visit_planrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/visit_plan().(plan, outputs, nullables); |
| 586 | } |
| 587 | } |
| 588 | } |
| 589 | } |
| 590 | |
| 591 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(serderust-analyzer cargo serde 1.0.229 crate/::Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 592 | #[serde(untagged)] |
| 593 | enum Explainrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Explain# { |
| 594 | // NOTE: the returned JSON may not contain a `plan` field, for example, with `CALL` statements: |
| 595 | // https://github.com/launchbadge/sqlx/issues/1449 |
| 596 | // |
| 597 | // In this case, we should just fall back to assuming all is nullable. |
| 598 | // |
| 599 | // It may also contain additional fields we don't care about, which should not break parsing: |
| 600 | // https://github.com/launchbadge/sqlx/issues/2587 |
| 601 | // https://github.com/launchbadge/sqlx/issues/2622 |
| 602 | Planrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Explain#Plan# { |
| 603 | #[serde(rename = "Plan")] |
| 604 | planrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Explain#Plan#plan.: Planrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Plan#, |
| 605 | }, |
| 606 | |
| 607 | // This ensures that parsing never technically fails. |
| 608 | // |
| 609 | // We don't want to specifically expect `"Utility Statement"` because there might be other cases |
| 610 | // and we don't care unless it contains a query plan anyway. |
| 611 | Otherrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Explain#Other#(serderust-analyzer cargo serde 1.0.229 crate/::derust-analyzer cargo serde_core 1.0.229 de/::IgnoredAnyrust-analyzer cargo serde_core 1.0.229 de/ignored_any/IgnoredAny#), |
| 612 | } |
| 613 | |
| 614 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(serderust-analyzer cargo serde 1.0.229 crate/::Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 615 | struct Planrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Plan# { |
| 616 | #[serderust-analyzer cargo serde_derive 1.0.229 serde:(rename = "Join Type")] |
| 617 | join_typerust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Plan#join_type.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 618 | #[serderust-analyzer cargo serde_derive 1.0.229 serde:(rename = "Parent Relationship")] |
| 619 | parent_relationrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Plan#parent_relation.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 620 | #[serderust-analyzer cargo serde_derive 1.0.229 serde:(rename = "Output")] |
| 621 | outputrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Plan#output.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>, |
| 622 | #[serderust-analyzer cargo serde_derive 1.0.229 serde:(rename = "Plans")] |
| 623 | plansrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Plan#plans.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Planrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Plan#>>, |
| 624 | } |
| 625 | |
| 626 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 627 | fn explain_parsingrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/explain_parsing().() { |
| 628 | let normal_plan = r#"[ |
| 629 | { |
| 630 | "Plan": { |
| 631 | "Node Type": "Result", |
| 632 | "Parallel Aware": false, |
| 633 | "Async Capable": false, |
| 634 | "Startup Cost": 0.00, |
| 635 | "Total Cost": 0.01, |
| 636 | "Plan Rows": 1, |
| 637 | "Plan Width": 4, |
| 638 | "Output": ["1"] |
| 639 | } |
| 640 | } |
| 641 | ]"#; |
| 642 | |
| 643 | // https://github.com/launchbadge/sqlx/issues/2622 |
| 644 | let extra_field = r#"[ |
| 645 | { |
| 646 | "Plan": { |
| 647 | "Node Type": "Result", |
| 648 | "Parallel Aware": false, |
| 649 | "Async Capable": false, |
| 650 | "Startup Cost": 0.00, |
| 651 | "Total Cost": 0.01, |
| 652 | "Plan Rows": 1, |
| 653 | "Plan Width": 4, |
| 654 | "Output": ["1"] |
| 655 | }, |
| 656 | "Query Identifier": 1147616880456321454 |
| 657 | } |
| 658 | ]"#; |
| 659 | |
| 660 | // https://github.com/launchbadge/sqlx/issues/1449 |
| 661 | let utility_statement = r#"["Utility Statement"]"#; |
| 662 | |
| 663 | let normal_plan_parsed = serde_jsonrust-analyzer cargo serde_json 1.0.151 crate/::from_strrust-analyzer cargo serde_json 1.0.151 de/from_str().::<[Explainrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Explain#; 1]>(normal_plan).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 664 | let extra_field_parsed = serde_jsonrust-analyzer cargo serde_json 1.0.151 crate/::from_strrust-analyzer cargo serde_json 1.0.151 de/from_str().::<[Explainrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Explain#; 1]>(extra_field).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 665 | let utility_statement_parsed = serde_jsonrust-analyzer cargo serde_json 1.0.151 crate/::from_strrust-analyzer cargo serde_json 1.0.151 de/from_str().::<[Explainrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Explain#; 1]>(utility_statement).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 666 | |
| 667 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!( |
| 668 | matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(normal_plan_parsed, [Explainrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Explain#::Planrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Explain#Plan# { planrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Explain#Plan#plan.: Planrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Plan# { .. } }]), |
| 669 | "unexpected parse from {normal_plan:?}: {normal_plan_parsed:?}" |
| 670 | ); |
| 671 | |
| 672 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!( |
| 673 | matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(extra_field_parsed, [Explainrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Explain#::Planrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Explain#Plan# { planrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Explain#Plan#plan.: Planrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Plan# { .. } }]), |
| 674 | "unexpected parse from {extra_field:?}: {extra_field_parsed:?}" |
| 675 | ); |
| 676 | |
| 677 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!( |
| 678 | matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(utility_statement_parsed, [Explainrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Explain#::Otherrust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/Explain#Other#(_)]), |
| 679 | "unexpected parse from {utility_statement:?}: {utility_statement_parsed:?}" |
| 680 | ) |
| 681 | } |