Re: Restrict number of connections to specific table - Mailing list pgsql-novice

From Thomas Kellerer
Subject Re: Restrict number of connections to specific table
Date
Msg-id lksvn0$khv$1@ger.gmane.org
Whole thread Raw
In response to Restrict number of connections to specific table  ("Sam Franklin" <Sam.Franklin@senergyworld.com>)
Responses Re: Restrict number of connections to specific table  (Keith <keith@keithf4.com>)
List pgsql-novice
Sam Franklin, 13.05.2014 12:50:
> Hi – apologies if this question has a painfully obvious answer.  I
> put the N in novice regarding postgresql.
>
> I use postgres with the spatial extension, postgis.
>
> I have some licenced geospatial data. The licence terms state that
> only “one user can access the data at one time”.
>
> I want to add this data to the collection of spatially-enabled
> postgis tables that I serve to my enterprise, where users access and
> consume postgis data tables via GIS clients.
>
>
> Can I put a constraint on a specific table to restrict the number of
> concurrent connections to 1, which will allow me to adhere to the
> data licencing terms?
>
> If not, is there an alternative solution to serve up the data via a
> PostgreSQL table and still keep within the data licence terms?

There is no configuration option if you mean that.

One thing I can think of is to allow access to that table only through a function. Inside that function lock the table
exclusivelyso that no other session can access it.  

The question then is: _when_ do you release this lock?

If you release the lock after the select has finished, two users could query the data one after the other. But if the
firstuser doesn't clear the results within the tool that is used to display the data you would still wind up with two
users"accessing" the data at the same time. 

Thomas


pgsql-novice by date:

Previous
From: "Sam Franklin"
Date:
Subject: Restrict number of connections to specific table
Next
From: Keith
Date:
Subject: Re: Restrict number of connections to specific table