% psql -c 'create table t (x integer not null)'
CREATE TABLE
% psql -c 'insert into t (x) values (0)'
INSERT 0 1
% psql -c 'select * from t'
x
---
0
(1 row)
% cat 1.sql
begin;
select x from t for update;
delete from t;
select pg_sleep(10); -- perform some tasks
insert into t (x) values (1);
commit;
% psql -f 1.sql &
[1] 25215
BEGIN
x
---
0
(1 row)
DELETE 1
% psql -c 'select x from t for update'
pg_sleep
----------
(1 row)
INSERT 0 1
x
---
COMMIT
(0 rows)
[1] + done psql -f 1.sql
Last active
August 1, 2021 15:34
-
-
Save eagletmt/614a8eb7c53eb04f168a58edbf98d0fd to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment