Skip to content

Commit

Permalink
Support lock directory table.
Browse files Browse the repository at this point in the history
Support lock directory table grammar in this commit, such as:
LOCK TABLE dir_table IN ACCESS SHARE MODE;

Authored-by: Zhang Wenchao [email protected]
  • Loading branch information
wenchaozhang-123 committed Aug 16, 2024
1 parent b9aec75 commit c6320f6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/backend/commands/lockcmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ RangeVarCallbackForLockTable(const RangeVar *rv, Oid relid, Oid oldrelid,

/* Currently, we only allow plain tables or views to be locked */
if (relkind != RELKIND_RELATION && relkind != RELKIND_PARTITIONED_TABLE &&
relkind != RELKIND_VIEW)
relkind != RELKIND_VIEW && relkind != RELKIND_DIRECTORY_TABLE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not a table or view",
errmsg("\"%s\" is not a table, directory table or view",
rv->relname)));

#if 0 /* Upstream code not applicable to GPDB */
Expand Down
11 changes: 11 additions & 0 deletions src/test/regress/input/directory_table.source
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,17 @@ SELECT count(*) FROM pg_directory_table;
SELECT relname, relisshared, relpersistence, relkind FROM pg_class WHERE relname like '%dir_table%' ORDER BY 1;
\c regression

--Test Lock directory table
BEGIN;
LOCK TABLE dir_table1 IN ACCESS SHARE MODE;
LOCK TABLE dir_table1 IN ACCESS EXCLUSIVE MODE;
COMMIT;

BEGIN;
LOCK TABLE dir_table1 IN ACCESS SHARE MODE;
LOCK TABLE dir_table1 IN ACCESS EXCLUSIVE MODE;
ROLLBACK;

-- Test CREATE/DROP/REINDEX on DIRECTORY SCHEMA TABLE
-- Test CREATE INDEX on DIRECTORY SCHEMA TABLE
CREATE INDEX dirtable1_relative_path_idx on dir_table1(relative_path);
Expand Down
9 changes: 9 additions & 0 deletions src/test/regress/output/directory_table.source
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,15 @@ SELECT relname, relisshared, relpersistence, relkind FROM pg_class WHERE relname
(0 rows)

\c regression
--Test Lock directory table
BEGIN;
LOCK TABLE dir_table1 IN ACCESS SHARE MODE;
LOCK TABLE dir_table1 IN ACCESS EXCLUSIVE MODE;
COMMIT;
BEGIN;
LOCK TABLE dir_table1 IN ACCESS SHARE MODE;
LOCK TABLE dir_table1 IN ACCESS EXCLUSIVE MODE;
ROLLBACK;
-- Test CREATE/DROP/REINDEX on DIRECTORY SCHEMA TABLE
-- Test CREATE INDEX on DIRECTORY SCHEMA TABLE
CREATE INDEX dirtable1_relative_path_idx on dir_table1(relative_path);
Expand Down

0 comments on commit c6320f6

Please sign in to comment.