Re: SQL access to database attributes - Mailing list pgsql-hackers

From Jim Nasby
Subject Re: SQL access to database attributes
Date
Msg-id 5380DCCF.3040608@nasby.net
Whole thread Raw
In response to Re: SQL access to database attributes  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: SQL access to database attributes  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 5/24/14, 8:14 AM, Tom Lane wrote:
> Vik Fearing<vik.fearing@dalibo.com>  writes:
>> >On 05/24/2014 12:03 AM, Jaime Casanova wrote:
>>> >>Which lead us to the question: you need to connect to the database to
>>> >>modify it, don't you? then, how do you change ALLOW CONNECTIONS to
>>> >>true?
>> >You can ALTER DATABASE from anywhere.
> Perhaps it'd be wise to have a safety check to disallow turning off
> datallowconn for the last connectable database?  Although it couldn't be
> bulletproof due to race conditions, so maybe that'd just be nannyism.
> (If you do shoot yourself in the foot that way, I think we ignore
> datallowconn in standalone mode.)

I think this is nannyism that would be well placed. Most people don't know about standalone, and I don't think we want
tochange that.
 

BTW, I think the race condition could be eliminated if we did something like (forgive the user-space semantics):

SELECT datallowconn FROM pg_database WHERE datallowconn AND datname <> $$database we're disallowing connections on$$
LIMIT1 FOR UPDATE;
 

If you don't get a record back from that you abort; meanwhile no one else can disallow connections on that database
untilyou commit or rollback.
 
-- 
Jim C. Nasby, Data Architect                       jim@nasby.net
512.569.9461 (cell)                         http://jim.nasby.net



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Allowing join removals for more join types
Next
From: Jim Nasby
Date:
Subject: Re: Priority table or Cache table