Skip to content

Commit 54c06ac

Browse files
authored
Fix/trg fire only altered masks (#89)
* checkpoint to pause this work and cherry pick out trigger fix. * cherry pick only trigger fix. * schema updates
1 parent 9ab96e1 commit 54c06ac

File tree

6 files changed

+43
-6
lines changed

6 files changed

+43
-6
lines changed

META.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "pgsodium",
33
"abstract": "Postgres extension for libsodium functions",
44
"description": "pgsodium is a PostgreSQL extension that exposes modern libsodium based cryptographic functions to SQL.",
5-
"version": "3.1.7",
5+
"version": "3.1.8",
66
"maintainer": [
77
"Michel Pelletier <pelletier.michel@gmail.com>"
88
],
@@ -13,7 +13,7 @@
1313
"abstract": "Postgres extension for libsodium functions",
1414
"file": "src/pgsodium.h",
1515
"docfile": "README.md",
16-
"version": "3.1.7"
16+
"version": "3.1.8"
1717
}
1818
},
1919
"prereqs": {

example/tce.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ CREATE SCHEMA "tce-example";
1010
SET search_path = "tce-example", pg_catalog;
1111

1212
CREATE TABLE test (
13-
secret text
13+
secret text,
14+
name text unique
1415
);
1516

1617
CREATE TABLE test2 (

pgsodium.control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# pgsodium extension
22
comment = 'Postgres extension for libsodium functions'
3-
default_version = '3.1.7'
3+
default_version = '3.1.8'
44
relocatable = false
55
schema = pgsodium

sql/pgsodium--3.1.7--3.1.8.sql

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
CREATE OR REPLACE FUNCTION pgsodium.trg_mask_update()
3+
RETURNS EVENT_TRIGGER AS
4+
$$
5+
DECLARE
6+
r record;
7+
BEGIN
8+
IF (SELECT bool_or(in_extension) FROM pg_event_trigger_ddl_commands()) THEN
9+
RAISE NOTICE 'skipping pgsodium mask regeneration in extension';
10+
RETURN;
11+
END IF;
12+
13+
FOR r IN
14+
SELECT e.*
15+
FROM pg_event_trigger_ddl_commands() e
16+
WHERE EXISTS (
17+
SELECT FROM pg_catalog.pg_class c
18+
JOIN pg_catalog.pg_seclabel s ON s.classoid = c.tableoid
19+
AND s.objoid = c.oid
20+
WHERE c.tableoid = e.classid
21+
AND e.objid = c.oid
22+
AND s.provider = 'pgsodium'
23+
)
24+
LOOP
25+
IF r.object_type in ('table', 'table column')
26+
THEN
27+
PERFORM pgsodium.update_mask(r.objid);
28+
END IF;
29+
END LOOP;
30+
END
31+
$$
32+
LANGUAGE plpgsql
33+
SET search_path=''
34+
;

test/pgsodium_schema.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ SELECT cmp_ok(current_setting('server_version_num')::int, '>=', 130000, format('
88

99

1010
---- EXTENSION VERSION
11-
SELECT results_eq('SELECT pgsodium.version()', $$VALUES ('3.1.7'::text)$$, 'Version of pgsodium is 3.1.7');
11+
SELECT results_eq('SELECT pgsodium.version()', $$VALUES ('3.1.8'::text)$$, 'Version of pgsodium is 3.1.8');
1212

1313

1414
---- EXTENSION OBJECTS
@@ -5604,7 +5604,7 @@ SELECT function_privs_are('pgsodium'::name, proname, proargtypes::regtype[]::tex
56045604
AND oidvectortypes(proargtypes) = 'bytea';
56055605

56065606
SELECT unnest(ARRAY[
5607-
is(md5(prosrc), '4db22ce073ebb842d305c906da664e72',
5607+
is(md5(prosrc), 'b8b02682e0138dc894512f55587db8d4',
56085608
format('Function pgsodium.%s(%s) body should match checksum',
56095609
proname, pg_get_function_identity_arguments(oid))
56105610
),

test/test.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ SELECT * FROM no_plan();
2727

2828
SET search_path = pgsodium, public;
2929

30+
select (current_setting('server_version_num')::int / 10000) = 15 pg15 \gset
31+
3032
\ir random.sql
3133
\ir secretbox.sql
3234
\ir secretstream.sql

0 commit comments

Comments
 (0)