File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ use pgrx::prelude::*;
99
1010:: pgrx:: pg_module_magic!( name, version) ;
1111
12+ fn knock_knock ( ) {
13+ todo ! ( )
14+ }
15+
1216fn delete_must_have_a_where ( query : PgBox < pg_sys:: Query > ) {
1317 if query. commandType != pg_sys:: CmdType :: CMD_DELETE {
1418 return ( ) ;
@@ -33,6 +37,25 @@ fn only_superusers_can_truncate(pstmt: PgBox<pg_sys::PlannedStmt>) {
3337}
3438
3539unsafe fn register_hooks ( ) {
40+
41+ //
42+ // Client Authentication hook
43+ //
44+ static mut PREV_CLIENTAUTHENTICATION_HOOK : pg_sys:: libpq:: ClientAuthentication_hook_type = None ;
45+ PREV_CLIENTAUTHENTICATION_HOOK = pg_sys:: libpq:: ClientAuthentication_hook ;
46+ pg_sys:: libpq:: ClientAuthentication_hook = Some ( client_authentication_hook) ;
47+
48+ #[ pg_guard]
49+ unsafe extern "C-unwind" fn client_authentication_hook (
50+ port : * mut pg_sys:: libpq:: be:: Port ,
51+ status : i32 ,
52+ ) {
53+ knock_knock ( ) ;
54+ if let Some ( prev_hook) = PREV_CLIENTAUTHENTICATION_HOOK {
55+ pg_guard_ffi_boundary ( || prev_hook ( port, status) ) ;
56+ }
57+ }
58+
3659 //
3760 // Post Parse Analyze hook
3861 //
Original file line number Diff line number Diff line change @@ -203,3 +203,13 @@ pub mod be {
203203 raw_buf_remaining : isize ,
204204 }
205205}
206+
207+ // The ClientAuthentication Hook cannot be implemented simply with bindgen
208+ /// Hook type to get control in ClientAuthentication()
209+ pub type ClientAuthentication_hook_type =
210+ Option < unsafe extern "C-unwind" fn ( port : * mut be:: Port , status : i32 ) > ;
211+
212+ #[ pgrx_macros:: pg_guard]
213+ unsafe extern "C-unwind" {
214+ pub static mut ClientAuthentication_hook : ClientAuthentication_hook_type ;
215+ }
You can’t perform that action at this time.
0 commit comments