Re: Restrict number of connections to specific table

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Restrict number of connections to specific table
Date: 2014-05-13 11:29:36
Message-ID: lksvn0$khv$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 exclusively so 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 first user 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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Keith 2014-05-13 14:01:16 Re: Restrict number of connections to specific table
Previous Message Sam Franklin 2014-05-13 10:50:18 Restrict number of connections to specific table