Skip to content

Commit

Permalink
Initialize pgx demo project
Browse files Browse the repository at this point in the history
  • Loading branch information
laurenceisla committed Sep 23, 2022
0 parents commit 6d4b316
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build]
# Postgres symbols won't be available until runtime
rustflags = ["-C", "link-args=-Wl,-undefined,dynamic_lookup"]
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.DS_Store
.idea/
/target
*.iml
**/*.rs.bk
Cargo.lock
32 changes: 32 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[package]
name = "pgx_demo"
version = "0.0.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[features]
default = ["pg13"]
pg10 = ["pgx/pg10", "pgx-tests/pg10" ]
pg11 = ["pgx/pg11", "pgx-tests/pg11" ]
pg12 = ["pgx/pg12", "pgx-tests/pg12" ]
pg13 = ["pgx/pg13", "pgx-tests/pg13" ]
pg14 = ["pgx/pg14", "pgx-tests/pg14" ]
pg_test = []

[dependencies]
pgx = "=0.4.5"

[dev-dependencies]
pgx-tests = "=0.4.5"

[profile.dev]
panic = "unwind"
lto = "thin"

[profile.release]
panic = "unwind"
opt-level = 3
lto = "fat"
codegen-units = 1
5 changes: 5 additions & 0 deletions pgx_demo.control
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
comment = 'pgx_demo: Created by pgx'
default_version = '@CARGO_VERSION@'
module_pathname = '$libdir/pgx_demo'
relocatable = false
superuser = false
32 changes: 32 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use pgx::*;

pg_module_magic!();

#[pg_extern]
fn hello_pgx_demo() -> &'static str {
"Hello, pgx_demo"
}

#[cfg(any(test, feature = "pg_test"))]
#[pg_schema]
mod tests {
use pgx::*;

#[pg_test]
fn test_hello_pgx_demo() {
assert_eq!("Hello, pgx_demo", crate::hello_pgx_demo());
}

}

#[cfg(test)]
pub mod pg_test {
pub fn setup(_options: Vec<&str>) {
// perform one-off initialization when the pg_test framework starts
}

pub fn postgresql_conf_options() -> Vec<&'static str> {
// return any postgresql.conf settings that are required for your tests
vec![]
}
}

0 comments on commit 6d4b316

Please sign in to comment.