# grant_lock_modes.spec
# Illustrates difference between AccessShareLock and ShareUpdateExclusiveLock
# when GRANT/REVOKE looks up relations via get_object_address().

setup
{
    CREATE TABLE t (id int);
    CREATE ROLE r1;
}

teardown
{
    DROP TABLE t;
    DROP ROLE r1;
}

session "s1"
step "begin1"   { BEGIN; }
step "lock_as"  { LOCK TABLE t IN ACCESS SHARE MODE; }
step "lock_sue" { LOCK TABLE t IN SHARE UPDATE EXCLUSIVE MODE; }
step "commit1"  { COMMIT; }

session "s2"
step "grant"    { GRANT SELECT ON t TO r1; }

session "s3"
step "select"   { SELECT count(*) FROM t; }

permutation "aslock"
    "begin1" "lock_as" "grant" "select" "commit1"

permutation "suelock"
    "begin1" "lock_sue" "grant" "select" "commit1"
