-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PL/Rust integration and usage #190
Comments
I am... not entirely sure about how to parse this question? There are two interpretations, one is "directly, using PL/Rust to put tokio into the DB" and one is "using the typical web server + DB setup".
It depends on what you mean exactly but the answer is probably "not nearly enough", we're looking to improve that. |
I meant two processes (web server + DB) but the thought (although impractical) of running a web server inside Postgres is really interesting haha. What is the timeline on the docs for IPC being ready? And do you have any advice/guidance in the meantime? What I mean by compile-time checked is that it’s validated that the PL/Rust functions do indeed exist and have the same parameters as the spi:: r#”SELECT …” call. Unsure if this is the case yet or isn’t. Thank you for the detailed answer, I really appreciate it! |
@workingjubilee @rustprooflabs Looking forward to hearing your insight on this. |
Hi @farazfazli Using PL/Rust functions from any kind of application will be similar to using PL/pgSQL functions from the same application. You'll connect to PostgreSQL and run SQL queries that call the PL/Rust functions. Connections between the app and database will be done using standard connections to PostgreSQL. If webapp/db are on the same host you can connect using sockets described here. More commonly, the app and the database are not on the same host and connect over the network using a connection string like The PL/Rust documentation is starting to come together with examples of creating functions, using logging, and triggers. The SPI section has a simple example, that should be expanded soon. Hopefully this helps answer some of your questions. Beyond these topics I am not sure exactly what you are asking for. If you can elaborate on what you're trying to accomplish we'll do our best to address that. |
Hey @rustprooflabs, Thanks for the detailed response, I really appreciate it. What I'm trying to do is create database functions in Rust which use SQL transactions. Do you have any example of this? |
Hi @rustprooflabs, Is SPI the recommended way to communicate with the database from PL/Rust? Also from my understanding of https://tcdi.github.io/plrust/functions/return-type.html#why-result-boxdyn-stderrorerror--send--sync--static it seems that the default behavior for PL/Rust is to treat each function as a transaction, is that right? Thank you. |
Hi PL/Rust Team,
Thanks for making such an awesome project! My experience is in using PL/pgSQL. My 2 main issues with PL/pgSQL are that it's interpreted rather than compiled, and the syntax is a bit esoteric. PL/Rust looks to solve both of these and that makes me very excited. My intention is to call Postgres functions written in PL/Rust from Rust web server code.
The idea here is to use PL/Rust to handle transactions and avoid multiple round-trips to the DB. I started reading through the tests.rs file which has given me some insight into how to use PL/Rust but want to learn more about how to integrate it into a project with actix-web and tokio.
Also - I'm curious, are spi:: r#"" function calls checked at compile-time?
Thank you!
The text was updated successfully, but these errors were encountered: