11use std:: ffi:: { c_char, CStr } ;
22
3- use pgrx:: {
4- datum:: TimeWithTimeZone ,
5- direct_function_call,
6- pg_sys:: {
7- copy_data_source_cb, AsPgCStr , List , Node , ParseState , QueryEnvironment , RawStmt , Relation ,
8- } ,
9- IntoDatum ,
10- } ;
11-
12- #[ cfg( any( feature = "pg14" , feature = "pg15" , feature = "pg16" , feature = "pg17" ) ) ]
13- use pgrx:: AnyNumeric ;
3+ use pgrx:: pg_sys:: { AsPgCStr , List , Node , QueryEnvironment , RawStmt } ;
144
155pub ( crate ) fn pg_analyze_and_rewrite (
166 raw_stmt : * mut RawStmt ,
177 query_string : * const c_char ,
188 query_env : * mut QueryEnvironment ,
199) -> * mut List {
20- #[ cfg( any ( feature = "pg13" , feature = " pg14") ) ]
10+ #[ cfg( feature = "pg14" ) ]
2111 unsafe {
2212 pgrx:: pg_sys:: pg_analyze_and_rewrite (
2313 raw_stmt,
@@ -42,7 +32,7 @@ pub(crate) fn pg_analyze_and_rewrite(
4232
4333#[ allow( non_snake_case) ]
4434pub ( crate ) fn strVal ( val : * mut Node ) -> String {
45- #[ cfg( any ( feature = "pg13" , feature = " pg14") ) ]
35+ #[ cfg( feature = "pg14" ) ]
4636 unsafe {
4737 let val = ( * ( val as * mut pgrx:: pg_sys:: Value ) ) . val . str_ ;
4838
@@ -63,88 +53,9 @@ pub(crate) fn strVal(val: *mut Node) -> String {
6353 }
6454}
6555
66- #[ cfg( feature = "pg13" ) ]
67- #[ allow( non_snake_case) ]
68- pub ( crate ) fn BeginCopyFrom (
69- pstate : * mut ParseState ,
70- relation : Relation ,
71- _where_clause : * mut Node ,
72- data_source_cb : copy_data_source_cb ,
73- attribute_list : * mut List ,
74- copy_options : * mut List ,
75- ) -> * mut pgrx:: pg_sys:: CopyStateData {
76- unsafe {
77- pgrx:: pg_sys:: BeginCopyFrom (
78- pstate,
79- relation,
80- std:: ptr:: null ( ) ,
81- false ,
82- data_source_cb,
83- attribute_list,
84- copy_options,
85- )
86- }
87- }
88-
89- #[ cfg( any( feature = "pg14" , feature = "pg15" , feature = "pg16" , feature = "pg17" ) ) ]
90- #[ allow( non_snake_case) ]
91- pub ( crate ) fn BeginCopyFrom (
92- pstate : * mut ParseState ,
93- relation : Relation ,
94- _where_clause : * mut Node ,
95- data_source_cb : copy_data_source_cb ,
96- attribute_list : * mut List ,
97- copy_options : * mut List ,
98- ) -> * mut pgrx:: pg_sys:: CopyFromStateData {
99- unsafe {
100- pgrx:: pg_sys:: BeginCopyFrom (
101- pstate,
102- relation,
103- _where_clause,
104- std:: ptr:: null ( ) ,
105- false ,
106- data_source_cb,
107- attribute_list,
108- copy_options,
109- )
110- }
111- }
112-
113- pub ( crate ) fn extract_timezone_from_timetz ( timetz : TimeWithTimeZone ) -> f64 {
114- #[ cfg( feature = "pg13" ) ]
115- {
116- let timezone_as_secs: f64 = unsafe {
117- direct_function_call (
118- pgrx:: pg_sys:: timetz_part,
119- & [ "timezone" . into_datum ( ) , timetz. into_datum ( ) ] ,
120- )
121- }
122- . expect ( "cannot extract timezone from timetz" ) ;
123-
124- timezone_as_secs
125- }
126-
127- #[ cfg( any( feature = "pg14" , feature = "pg15" , feature = "pg16" , feature = "pg17" ) ) ]
128- {
129- let timezone_as_secs: AnyNumeric = unsafe {
130- direct_function_call (
131- pgrx:: pg_sys:: extract_timetz,
132- & [ "timezone" . into_datum ( ) , timetz. into_datum ( ) ] ,
133- )
134- }
135- . expect ( "cannot extract timezone from timetz" ) ;
136-
137- let timezone_as_secs: f64 = timezone_as_secs
138- . try_into ( )
139- . unwrap_or_else ( |e| panic ! ( "{}" , e) ) ;
140-
141- timezone_as_secs
142- }
143- }
144-
14556#[ allow( non_snake_case) ]
14657pub ( crate ) fn MarkGUCPrefixReserved ( guc_prefix : & str ) {
147- #[ cfg( any ( feature = "pg13" , feature = " pg14") ) ]
58+ #[ cfg( feature = "pg14" ) ]
14859 unsafe {
14960 pgrx:: pg_sys:: EmitWarningsOnPlaceholders ( guc_prefix. as_pg_cstr ( ) )
15061 }
0 commit comments