Skip to content

Commit 846ca31

Browse files
committed
the pgx way
1 parent 1be827f commit 846ca31

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pgml-extension/src/bindings/venv.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
33
use once_cell::sync::Lazy;
44
use pgrx::*;
5+
use pgrx_pg_sys::AsPgCStr;
56
use pyo3::prelude::*;
67
use pyo3::types::PyTuple;
7-
use std::ffi::{c_char, CString};
8+
use std::ffi::CStr;
89

910
static PY_MODULE: Lazy<Py<PyModule>> = Lazy::new(|| {
1011
Python::with_gil(|py| -> Py<PyModule> {
@@ -27,13 +28,12 @@ pub fn activate_venv(venv: &str) -> bool {
2728

2829
pub fn activate() -> bool {
2930
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);
3333
if option.is_null() {
3434
false
3535
} else {
36-
let venv = std::ffi::CStr::from_ptr(option).to_str().unwrap();
36+
let venv = CStr::from_ptr(option).to_str().unwrap();
3737
activate_venv(venv)
3838
}
3939
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy