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