@@ -7,6 +7,7 @@ mod typesystem;
77pub use self :: errors:: PostgresSourceError ;
88use cidr_02:: IpInet ;
99pub use connection:: rewrite_tls_args;
10+ use pgvector:: { Bit , HalfVector , SparseVector , Vector } ;
1011pub use typesystem:: { PostgresTypePairs , PostgresTypeSystem } ;
1112
1213use crate :: constants:: DB_BUFFER_SIZE ;
@@ -52,6 +53,47 @@ pub enum SimpleProtocol {}
5253type PgManager < C > = PostgresConnectionManager < C > ;
5354type PgConn < C > = PooledConnection < PgManager < C > > ;
5455
56+ macro_rules! impl_produce_unimplemented {
57+ ( $( ( $protocol: ty, $t: ty, $msg: expr) , ) +) => {
58+ $(
59+ impl <' r> Produce <' r, $t> for $protocol {
60+ type Error = PostgresSourceError ;
61+
62+ #[ throws( PostgresSourceError ) ]
63+ fn produce( & ' r mut self ) -> $t {
64+ unimplemented!( $msg) ;
65+ }
66+ }
67+
68+ impl <' r> Produce <' r, Option <$t>> for $protocol {
69+ type Error = PostgresSourceError ;
70+
71+ #[ throws( PostgresSourceError ) ]
72+ fn produce( & ' r mut self ) -> Option <$t> {
73+ unimplemented!( $msg) ;
74+ }
75+ }
76+ ) +
77+ } ;
78+ }
79+
80+ impl_produce_unimplemented ! (
81+ ( PostgresCSVSourceParser <' _>, HashMap <String , Option <String >>, "Please use `cursor` protocol for hstore type" ) ,
82+ ( PostgresCSVSourceParser <' _>, Vector , "Please use `binary` protocol for vector type" ) ,
83+ ( PostgresCSVSourceParser <' _>, HalfVector , "Please use `binary` protocol for halfvector type" ) ,
84+ ( PostgresCSVSourceParser <' _>, Bit , "Please use `binary` protocol for bit type" ) ,
85+ ( PostgresCSVSourceParser <' _>, SparseVector , "Please use `binary` protocol for sparsevector type" ) ,
86+
87+
88+ ( PostgresSimpleSourceParser , HashMap <String , Option <String >>, "unimplemented" ) ,
89+ ( PostgresSimpleSourceParser , Value , "unimplemented" ) ,
90+ ( PostgresSimpleSourceParser , Vector , "Please use `binary` protocol for vector type" ) ,
91+ ( PostgresSimpleSourceParser , HalfVector , "Please use `binary` protocol for halfvector type" ) ,
92+ ( PostgresSimpleSourceParser , Bit , "Please use `binary` protocol for bit type" ) ,
93+ ( PostgresSimpleSourceParser , SparseVector , "Please use `binary` protocol for sparsevector type" ) ,
94+
95+ ) ;
96+
5597// take a row and unwrap the interior field from column 0
5698fn convert_row < ' b , R : TryFrom < usize > + postgres:: types:: FromSql < ' b > + Clone > ( row : & ' b Row ) -> R {
5799 let nrows: Option < R > = row. get ( 0 ) ;
@@ -482,6 +524,10 @@ impl_produce!(
482524 Uuid ,
483525 Value ,
484526 IpInet ,
527+ Vector ,
528+ HalfVector ,
529+ Bit ,
530+ SparseVector ,
485531 Vec <Option <bool >>,
486532 Vec <Option <i16 >>,
487533 Vec <Option <i32 >>,
@@ -773,22 +819,6 @@ macro_rules! impl_csv_vec_produce {
773819
774820impl_csv_vec_produce ! ( i8 , i16 , i32 , i64 , f32 , f64 , Decimal , String , ) ;
775821
776- impl Produce < ' _ , HashMap < String , Option < String > > > for PostgresCSVSourceParser < ' _ > {
777- type Error = PostgresSourceError ;
778- #[ throws( PostgresSourceError ) ]
779- fn produce ( & mut self ) -> HashMap < String , Option < String > > {
780- unimplemented ! ( "Please use `cursor` protocol for hstore type" ) ;
781- }
782- }
783-
784- impl Produce < ' _ , Option < HashMap < String , Option < String > > > > for PostgresCSVSourceParser < ' _ > {
785- type Error = PostgresSourceError ;
786- #[ throws( PostgresSourceError ) ]
787- fn produce ( & mut self ) -> Option < HashMap < String , Option < String > > > {
788- unimplemented ! ( "Please use `cursor` protocol for hstore type" ) ;
789- }
790- }
791-
792822impl Produce < ' _ , bool > for PostgresCSVSourceParser < ' _ > {
793823 type Error = PostgresSourceError ;
794824
@@ -1219,6 +1249,10 @@ impl_produce!(
12191249 Uuid ,
12201250 Value ,
12211251 IpInet ,
1252+ Vector ,
1253+ HalfVector ,
1254+ Bit ,
1255+ SparseVector ,
12221256 HashMap <String , Option <String >>,
12231257 Vec <Option <bool >>,
12241258 Vec <Option <String >>,
@@ -1403,30 +1437,6 @@ impl PartitionParser<'_> for PostgresSimpleSourceParser {
14031437 }
14041438}
14051439
1406- macro_rules! impl_simple_produce_unimplemented {
1407- ( $( $t: ty, ) +) => {
1408- $(
1409- impl <' r, ' a> Produce <' r, $t> for PostgresSimpleSourceParser {
1410- type Error = PostgresSourceError ;
1411-
1412- #[ throws( PostgresSourceError ) ]
1413- fn produce( & ' r mut self ) -> $t {
1414- unimplemented!( "not implemented!" ) ;
1415- }
1416- }
1417-
1418- impl <' r, ' a> Produce <' r, Option <$t>> for PostgresSimpleSourceParser {
1419- type Error = PostgresSourceError ;
1420-
1421- #[ throws( PostgresSourceError ) ]
1422- fn produce( & ' r mut self ) -> Option <$t> {
1423- unimplemented!( "not implemented!" ) ;
1424- }
1425- }
1426- ) +
1427- } ;
1428- }
1429-
14301440macro_rules! impl_simple_produce {
14311441 ( $( $t: ty, ) +) => {
14321442 $(
@@ -1591,10 +1601,6 @@ impl<'r> Produce<'r, Option<Decimal>> for PostgresSimpleSourceParser {
15911601 }
15921602}
15931603
1594- impl_simple_produce_unimplemented ! (
1595- Value ,
1596- HashMap <String , Option <String >>, ) ;
1597-
15981604impl < ' r > Produce < ' r , & ' r str > for PostgresSimpleSourceParser {
15991605 type Error = PostgresSourceError ;
16001606
0 commit comments