macro_rules! error {
() => { ... };
($msg:expr) => { ... };
($msg:expr,) => { ... };
($fmt:expr, $($arg:tt)+) => { ... };
}
Expand description
Log to Postgres’ error
log level. This will abort the current Postgres transaction.
This macro accepts arguments like the println
and format
macros.
See fmt
for information about options.
Given some function:
use pgx::*;
#[pg_extern]
fn sum_array(input: Array<i32>) -> i64 {
let mut sum = 0 as i64;
for i in input {
pgx::error!("i={index:?}, sum={}", sum, index = i);
sum += i.unwrap_or(-1) as i64;
}
sum
}
When run inside PostgreSQL would output:
arrays=# SELECT arrays.sum_array('{1,2,3}');
ERROR: i=Some(1), sum=0
CONTEXT: src/lib.rs:37:9