Chapter 4: src/bin, one line for cargo-pgrx
The shortest chapter in the guide, because the folder holds one line of
code: ::pgrx::pgrx_embed!();.
Every pgrx extension has to answer a question at build time: what SQL does
this library declare? Under cargo, cargo pgrx schema finds out by building
and running a small binary from the extension's own crate, and this is that
binary. The macro expands into the program cargo-pgrx runs to turn the
#[pg_extern] functions and extension_sql! blocks into the install SQL.
buck does not use it. Under buck, tools/pgrx-schema (chapter 18) reads the
same entities straight out of the built .so, which needs no second binary.
The file exists only so that the generated Cargo workspace works with
cargo pgrx install for people who build without buck, and it is generated
along with that workspace.
Try it. Open pgrx_embed.rs. Its first line says who wrote it, and it was not a person.
For the people who maintain it
| File | What |
|---|---|
| pgrx_embed.rs | pgrx_embed!(), generated by tools/cargo-gen, named pgrx_embed_postjevsql in crates/postjevsql/Cargo.toml. |
← Previous: Chapter 3, postjevsql/src/ · Up: src · Next: Chapter 5, postjevsql-pg/ →