Skip to content

Commit

Permalink
[feat] Mark exposed functions parallel safe (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuri0sh committed Apr 4, 2024
1 parent b5a9dba commit 6dfbfe3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib.rs
Expand Up @@ -2,17 +2,17 @@ use pgrx::*;

pg_module_magic!();

#[pg_extern(immutable, strict)]
#[pg_extern(immutable, strict, parallel_safe)]
fn json_matches_schema(schema: Json, instance: Json) -> bool {
jsonschema::is_valid(&schema.0, &instance.0)
}

#[pg_extern(immutable, strict)]
#[pg_extern(immutable, strict, parallel_safe)]
fn jsonb_matches_schema(schema: Json, instance: JsonB) -> bool {
jsonschema::is_valid(&schema.0, &instance.0)
}

#[pg_extern(immutable, strict)]
#[pg_extern(immutable, strict, parallel_safe)]
fn jsonschema_is_valid(schema: Json) -> bool {
match jsonschema::JSONSchema::compile(&schema.0) {
Ok(_) => true,
Expand All @@ -29,7 +29,7 @@ fn jsonschema_is_valid(schema: Json) -> bool {
}
}

#[pg_extern(immutable, strict)]
#[pg_extern(immutable, strict, parallel_safe)]
fn jsonschema_validation_errors(schema: Json, instance: Json) -> Vec<String> {
let schema = match jsonschema::JSONSchema::compile(&schema.0) {
Ok(s) => s,
Expand Down

0 comments on commit 6dfbfe3

Please sign in to comment.