4 ms·
Build Postgres Functions in Rust on Amazon RDS
- kiwicopple 3y agoLooks like AWS announced[0] plrust support for Postgres today, but this one has a few more details, comparing a plv8 function and a plrust function. the tldr is that you can write a function like this: CREATE OR REPLACE FUNCTION public.array_sum(x float8[]) RETURNS float8 LANGUAGE plrust IMMUTABLE PARALLEL SAFE STRICT AS $$ let sum: f64 = x.iter() .map(|&xi| (xi.unwrap())) .sum(); Ok(Some(sum)) $$; and everythign between the $$ is Rust code. This is obviously a bit more approachable for developers who don't like SQL, and doesn't have the performance penalty of something like plv8 (for computational-heavy functions at least) [0] https://aws.amazon.com/about-aws/whats-new/2023/05/amazon-rds-postgresql-rust/ https://aws.amazon.com/about-aws/whats-new/2023/05/amazon-rd...