Skip to content

Commit

Permalink
update to pgx 2.6; update dependencies; testing on postgres 14
Browse files Browse the repository at this point in the history
  • Loading branch information
jefbarn committed Dec 15, 2021
1 parent 5a57c45 commit 3775d3d
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 16 deletions.
19 changes: 16 additions & 3 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
[build]
# Postgres symbols won't ve available until runtime
rustflags = ["-C", "link-args=-Wl,-undefined,dynamic_lookup"]
# Auto-generated by pgx. You may edit this, or delete it to have a new one created.

[target.x86_64-unknown-linux-gnu]
linker = "./.cargo/pgx-linker-script.sh"

[target.aarch64-unknown-linux-gnu]
linker = "./.cargo/pgx-linker-script.sh"

[target.x86_64-apple-darwin]
linker = "./.cargo/pgx-linker-script.sh"

[target.aarch64-apple-darwin]
linker = "./.cargo/pgx-linker-script.sh"

[target.x86_64-unknown-freebsd]
linker = "./.cargo/pgx-linker-script.sh"
19 changes: 19 additions & 0 deletions .cargo/pgx-linker-script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#! /usr/bin/env bash
# Auto-generated by pgx. You may edit this, or delete it to have a new one created.

if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then
UNAME=$(uname)
if [[ $UNAME == "Darwin" ]]; then
TEMP=$(mktemp pgx-XXX)
echo "*_pgx_internals_*" > ${TEMP}
gcc -exported_symbols_list ${TEMP} $@
rm -rf ${TEMP}
else
TEMP=$(mktemp pgx-XXX)
echo "{ __pgx_internals_*; };" > ${TEMP}
gcc -Wl,-dynamic-list=${TEMP} $@
rm -rf ${TEMP}
fi
else
gcc -Wl,-undefined,dynamic_lookup $@
fi
22 changes: 12 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
[package]
name = "pgx_json_schema"
version = "0.2.0"
edition = "2018"
version = "0.2.1"
edition = "2021"

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

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

[dependencies]
pgx = "0.1.20"
pgx-macros = "0.1.20"
serde_json = "1.0.59"
jsonschema = "0.12.0"
jtd = "0.3"
pgx = "0.2.6"
pgx-macros = "0.2.6"
serde_json = "1.0.73"
jsonschema = "0.13.3"
jtd = "0.3.1"
avro-rs = "0.13.0"

[dev-dependencies]
pgx-tests = "0.1.20"
pgx-tests = "0.2.6"

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

[profile.release]
panic = "unwind"
Expand Down
3 changes: 0 additions & 3 deletions sql/load-order.txt

This file was deleted.

64 changes: 64 additions & 0 deletions sql/pgx_json_schema-1.0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
This file is auto generated by pgx.
The ordering of items is not stable, it is driven by a dependency graph.
*/

-- src/json_type_def.rs:4
-- pgx_json_schema::json_type_def::jtd_is_valid
CREATE OR REPLACE FUNCTION "jtd_is_valid"(
"schema" jsonb, /* pgx::datum::json::JsonB */
"instance" jsonb /* pgx::datum::json::JsonB */
) RETURNS bool /* bool */
STRICT
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'jtd_is_valid_wrapper';

-- src/json_type_def.rs:13
-- pgx_json_schema::json_type_def::jtd_get_errors
CREATE OR REPLACE FUNCTION "jtd_get_errors"(
"schema" jsonb, /* pgx::datum::json::JsonB */
"instance" jsonb /* pgx::datum::json::JsonB */
) RETURNS TABLE (
"instance_path" text, /* alloc::string::String */
"schema_path" text /* alloc::string::String */
)
STRICT
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'jtd_get_errors_wrapper';

-- src/json_schema.rs:4
-- pgx_json_schema::json_schema::json_schema_is_valid
CREATE OR REPLACE FUNCTION "json_schema_is_valid"(
"schema" jsonb, /* pgx::datum::json::JsonB */
"instance" jsonb /* pgx::datum::json::JsonB */
) RETURNS bool /* bool */
STRICT
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'json_schema_is_valid_wrapper';

-- src/json_schema.rs:9
-- pgx_json_schema::json_schema::json_schema_get_errors
CREATE OR REPLACE FUNCTION "json_schema_get_errors"(
"schema" jsonb, /* pgx::datum::json::JsonB */
"instance" jsonb /* pgx::datum::json::JsonB */
) RETURNS TABLE (
"error_value" jsonb, /* pgx::datum::json::JsonB */
"description" text, /* alloc::string::String */
"details" text, /* alloc::string::String */
"instance_path" text, /* alloc::string::String */
"schema_path" text /* alloc::string::String */
)
STRICT
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'json_schema_get_errors_wrapper';

-- src/avro.rs:5
-- pgx_json_schema::avro::avro_is_valid
CREATE OR REPLACE FUNCTION "avro_is_valid"(
"schema" jsonb, /* pgx::datum::json::JsonB */
"instance" jsonb /* pgx::datum::json::JsonB */
) RETURNS bool /* bool */
STRICT
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'avro_is_valid_wrapper';
1 change: 1 addition & 0 deletions src/avro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fn avro_is_valid(schema: JsonB, instance: JsonB) -> bool {
}

#[cfg(any(test, feature = "pg_test"))]
#[pg_schema]
mod tests {
use pgx::*;
use std::panic;
Expand Down
2 changes: 2 additions & 0 deletions src/bin/sql-generator.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* Auto-generated by pgx. You may edit this, or delete it to have a new one created. */
pgx::pg_binary_magic!(pgx_json_schema);
1 change: 1 addition & 0 deletions src/json_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ fn json_schema_get_errors(
}

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

Expand Down
1 change: 1 addition & 0 deletions src/json_type_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ fn jtd_get_errors(
}

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

Expand Down

0 comments on commit 3775d3d

Please sign in to comment.