File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
pgml-extension/src/bindings Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 2
2
3
3
use once_cell:: sync:: Lazy ;
4
4
use pgrx:: * ;
5
+ use pgrx_pg_sys:: AsPgCStr ;
5
6
use pyo3:: prelude:: * ;
6
7
use pyo3:: types:: PyTuple ;
7
- use std:: ffi:: { c_char , CString } ;
8
+ use std:: ffi:: CStr ;
8
9
9
10
static PY_MODULE : Lazy < Py < PyModule > > = Lazy :: new ( || {
10
11
Python :: with_gil ( |py| -> Py < PyModule > {
@@ -27,13 +28,12 @@ pub fn activate_venv(venv: &str) -> bool {
27
28
28
29
pub fn activate ( ) -> bool {
29
30
unsafe {
30
- let config_name = CString :: new ( "pgml.venv" ) . unwrap ( ) ;
31
- let option =
32
- pgrx_pg_sys:: GetConfigOption ( config_name. as_ptr ( ) as * const c_char , true , false ) ;
31
+ let config_name = "pgml.venv" . to_string ( ) ;
32
+ let option = pgrx_pg_sys:: GetConfigOption ( config_name. as_pg_cstr ( ) , true , false ) ;
33
33
if option. is_null ( ) {
34
34
false
35
35
} else {
36
- let venv = std :: ffi :: CStr :: from_ptr ( option) . to_str ( ) . unwrap ( ) ;
36
+ let venv = CStr :: from_ptr ( option) . to_str ( ) . unwrap ( ) ;
37
37
activate_venv ( venv)
38
38
}
39
39
}
You can’t perform that action at this time.
0 commit comments