-
Notifications
You must be signed in to change notification settings - Fork 0
/
pgbench_bf.sql
19 lines (17 loc) · 1.87 KB
/
pgbench_bf.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=bf'::text),'SQL_ASCII')::int + :delta)::text::bytea, $$secret$$::text,'compress-algo=1, compress-level=5, cipher-algo=bf'::text ) WHERE aid = :aid;
SELECT convert_from(pgp_sym_decrypt_bytea(abalance, $$secret$$::text,'compress-algo=1, compress-level=5, cipher-algo=bf'::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=bf'::text),'SQL_ASCII')::int + :delta)::text::bytea, $$secret$$::text,'compress-algo=1, compress-level=5, cipher-algo=bf'::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=bf'::text),'SQL_ASCII')::int + :delta)::text::bytea, $$secret$$::text,'compress-algo=1, compress-level=5, cipher-algo=bf'::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=bf'::text), pgp_sym_encrypt_bytea((CURRENT_TIMESTAMP)::text::bytea, $$secret$$::text,'compress-algo=1, compress-level=5, cipher-algo=bf'::text));
END;
-- WORKING !