[WIP] The shared dependency patch - Mailing list pgsql-patches

From Alvaro Herrera
Subject [WIP] The shared dependency patch
Date
Msg-id 20041216015755.GB1492@dcc.uchile.cl
Whole thread Raw
Responses Re: [WIP] The shared dependency patch
List pgsql-patches
Hackers,

Here is the current shared dependency patch I promised.  (The new files
are src/include/catalog/pg_shdepend.h and
src/backend/catalog/pg_shdepend.c).

The big problem with the current patch is this:

-- session 1
BEGIN;
DROP USER foo;
-- checks dependencies, all is OK
                -- session 2
                ALTER TABLE foo OWNER TO foo;
COMMIT;

Everything works, a dependency on user foo is recorded, but now it's
useless (it will be never checked).

Of course, there needs to be a lock to protect this from happening.  But
I'm not sure what should be locked.  The whole pg_shadow relation?  That
might be overkill.

I was trying to find out if I could lock the user (and have the ALTER
TABLE get a shared lock on the user before checking its existance, and
the DROP USER get an exclusive lock which would be release at
transaction end.  So everything would remain consistant.)  However the
LOCKTAG does not have provisions to lock arbitrary objects, only
relations (I could end up locking some completely unrelated table, I
guess).

Any ideas on how to handle this?

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Aprende a avergonzarte más ante ti que ante los demás" (Demócrito)

Attachment

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Threading fix for AIX
Next
From: Aleksander Kmetec
Date:
Subject: sl translations of .po files