-
Notifications
You must be signed in to change notification settings - Fork 0
/
pgbench_aes128.sql
19 lines (17 loc) · 1.91 KB
/
pgbench_aes128.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
\set nbranches :scale
\set ntellers 10 * :scale
\set naccounts 100000 * :scale
\setrandom aid 1 :naccounts
\setrandom bid 1 :nbranches
\setrandom tid 1 :ntellers
\setrandom delta -5000 5000
BEGIN;
-- UPDATE pgbench_accounts
-- SET abalance = pgp_sym_encrypt_bytea( ( convert_from(pgp_sym_decrypt_bytea(abalance, $$secret$$::text), 'SQL_ASCII')::int + 2)::text::bytea, $$secret$$::text ) WHERE aid = 1;
UPDATE pgbench_accounts SET abalance = pgp_sym_encrypt_bytea( ( convert_from(pgp_sym_decrypt_bytea(abalance, $$secret$$::text,'compress-algo=1, compress-level=5, cipher-algo=aes128'::text),'SQL_ASCII')::int + :delta)::text::bytea, $$secret$$::text,'compress-algo=1, compress-level=5, cipher-algo=aes128'::text ) WHERE aid = :aid;
SELECT convert_from(pgp_sym_decrypt_bytea(abalance, $$secret$$::text,'compress-algo=1, compress-level=5, cipher-algo=aes128'::text),'SQL_ASCII')::int FROM pgbench_accounts WHERE aid = :aid;
UPDATE pgbench_tellers SET tbalance = pgp_sym_encrypt_bytea( ( convert_from(pgp_sym_decrypt_bytea(tbalance, $$secret$$::text,'compress-algo=1, compress-level=5, cipher-algo=aes128'::text),'SQL_ASCII')::int + :delta)::text::bytea, $$secret$$::text ,'compress-algo=1, compress-level=5, cipher-algo=aes128'::text) WHERE tid = :tid;
UPDATE pgbench_branches SET bbalance = pgp_sym_encrypt_bytea( ( convert_from(pgp_sym_decrypt_bytea(bbalance, $$secret$$::text,'compress-algo=1, compress-level=5, cipher-algo=aes128'::text),'SQL_ASCII')::int + :delta)::text::bytea, $$secret$$::text,'compress-algo=1, compress-level=5, cipher-algo=aes128'::text ) WHERE bid = :bid;
INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, pgp_sym_encrypt_bytea((:delta)::text::bytea, $$secret$$::text,'compress-algo=1, compress-level=5, cipher-algo=aes128'::text), pgp_sym_encrypt_bytea((CURRENT_TIMESTAMP)::text::bytea, $$secret$$::text,'compress-algo=1, compress-level=5, cipher-algo=aes128'::text));
END;
-- WORKING !