File tree Expand file tree Collapse file tree 5 files changed +61
-1
lines changed
pgrx-pg-sys/src/submodules Expand file tree Collapse file tree 5 files changed +61
-1
lines changed Original file line number Diff line number Diff line change @@ -257,6 +257,7 @@ cargo pgrx init
257257| ` anyarray ` | ` pgrx::AnyArray ` |
258258| ` anyelement ` | ` pgrx::AnyElement ` |
259259| ` box ` | ` pgrx::pg_sys::BOX ` |
260+ | ` circle ` | ` pgrx::pg_sys::CIRCLE ` |
260261| ` point ` | ` pgrx::pg_sys::Point ` |
261262| ` tid ` | ` pgrx::pg_sys::ItemPointerData ` |
262263| ` cstring ` | ` &core::ffi::CStr ` |
Original file line number Diff line number Diff line change 1- use crate :: { BOX , Point } ;
1+ use crate :: { BOX , CIRCLE , Point } ;
22
33impl PartialEq for Point {
44 #[ inline]
@@ -15,3 +15,11 @@ impl PartialEq for BOX {
1515 }
1616}
1717impl Eq for BOX { }
18+
19+ impl PartialEq for CIRCLE {
20+ #[ inline]
21+ fn eq ( & self , other : & Self ) -> bool {
22+ self . center == other. center && self . radius == other. radius
23+ }
24+ }
25+ impl Eq for CIRCLE { }
Original file line number Diff line number Diff line change @@ -65,6 +65,15 @@ unsafe impl SqlTranslatable for crate::BOX {
6565 }
6666}
6767
68+ unsafe impl SqlTranslatable for crate :: CIRCLE {
69+ fn argument_sql ( ) -> Result < SqlMapping , ArgumentError > {
70+ Ok ( SqlMapping :: literal ( "circle" ) )
71+ }
72+ fn return_sql ( ) -> Result < Returns , ReturnsError > {
73+ Ok ( Returns :: One ( SqlMapping :: literal ( "circle" ) ) )
74+ }
75+ }
76+
6877unsafe impl SqlTranslatable for crate :: Point {
6978 fn argument_sql ( ) -> Result < SqlMapping , ArgumentError > {
7079 Ok ( SqlMapping :: literal ( "point" ) )
Original file line number Diff line number Diff line change @@ -33,4 +33,14 @@ mod tests {
3333 assert_eq ! ( b. low. y, 2.0 ) ;
3434 Ok ( ( ) )
3535 }
36+
37+ #[ pg_test]
38+ fn test_circle_into_datum ( ) -> spi:: Result < ( ) > {
39+ let c =
40+ Spi :: get_one :: < pg_sys:: CIRCLE > ( "SELECT '1,2,3'::circle" ) ?. expect ( "SPI result was null" ) ;
41+ assert_eq ! ( c. center. x, 1.0 ) ;
42+ assert_eq ! ( c. center. y, 2.0 ) ;
43+ assert_eq ! ( c. radius, 3.0 ) ;
44+ Ok ( ( ) )
45+ }
3646}
Original file line number Diff line number Diff line change @@ -72,3 +72,35 @@ impl IntoDatum for pg_sys::Point {
7272 pg_sys:: POINTOID
7373 }
7474}
75+
76+ impl FromDatum for pg_sys:: CIRCLE {
77+ unsafe fn from_polymorphic_datum (
78+ datum : pg_sys:: Datum ,
79+ is_null : bool ,
80+ _: pg_sys:: Oid ,
81+ ) -> Option < Self >
82+ where
83+ Self : Sized ,
84+ {
85+ if is_null {
86+ None
87+ } else {
88+ let the_box = datum. cast_mut_ptr :: < pg_sys:: CIRCLE > ( ) ;
89+ Some ( the_box. read ( ) )
90+ }
91+ }
92+ }
93+
94+ impl IntoDatum for pg_sys:: CIRCLE {
95+ fn into_datum ( mut self ) -> Option < pg_sys:: Datum > {
96+ unsafe {
97+ let ptr = PgMemoryContexts :: CurrentMemoryContext
98+ . copy_ptr_into ( & mut self , std:: mem:: size_of :: < pg_sys:: CIRCLE > ( ) ) ;
99+ Some ( ptr. into ( ) )
100+ }
101+ }
102+
103+ fn type_oid ( ) -> pg_sys:: Oid {
104+ pg_sys:: CIRCLEOID
105+ }
106+ }
You can’t perform that action at this time.
0 commit comments