init script or procedure

Started by Gauthier, Daveover 14 years ago8 messagesgeneral
Jump to latest
#1Gauthier, Dave
dave.gauthier@intel.com

Does PG support the use of an init script or procedure? I'm looking for something that'll run unconditionally every time someone makes a DB connection. This script will create a temp table and stuff some data in it for general use within that session.

Thanks in Advance for any help!

#2Andreas Kretschmer
andreas@a-kretschmer.de
In reply to: Gauthier, Dave (#1)
Re: init script or procedure

No, that's not possible.

Zitat von "Gauthier, Dave" <dave.gauthier@intel.com>:

Show quoted text

Does PG support the use of an init script or procedure? I'm looking
for something that'll run unconditionally every time someone makes a
DB connection. This script will create a temp table and stuff some
data in it for general use within that session.

Thanks in Advance for any help!

#3Pavel Stehule
pavel.stehule@gmail.com
In reply to: Gauthier, Dave (#1)
Re: init script or procedure

Hello

2011/8/24 Gauthier, Dave <dave.gauthier@intel.com>:

Does PG support the use of an init script or procedure?  I'm looking for
something that'll run unconditionally every time someone makes a DB
connection.  This script will create a temp table and stuff some data in it
for general use within that session.

no, there is nothing similar. You have to call a own procedure after
login explicitly

Regards

Pavel Stehule

Show quoted text

Thanks in Advance for any help!

#4Merlin Moncure
mmoncure@gmail.com
In reply to: Pavel Stehule (#3)
Re: init script or procedure

On Wed, Aug 24, 2011 at 9:30 AM, Pavel Stehule <pavel.stehule@gmail.com> wrote:

Hello

2011/8/24 Gauthier, Dave <dave.gauthier@intel.com>:

Does PG support the use of an init script or procedure?  I'm looking for
something that'll run unconditionally every time someone makes a DB
connection.  This script will create a temp table and stuff some data in it
for general use within that session.

no, there is nothing similar. You have to call a own procedure after
login explicitly

We could really use this. It's kinda sorta possible to script SQL on
connection close via C hook through dblink but not on session startup.
It's not always possible for the client know when a backend session is
fired up -- for example in connection pools.

merlin

#5Pavel Stehule
pavel.stehule@gmail.com
In reply to: Merlin Moncure (#4)
Re: init script or procedure

2011/8/24 Merlin Moncure <mmoncure@gmail.com>:

On Wed, Aug 24, 2011 at 9:30 AM, Pavel Stehule <pavel.stehule@gmail.com> wrote:

Hello

2011/8/24 Gauthier, Dave <dave.gauthier@intel.com>:

Does PG support the use of an init script or procedure?  I'm looking for
something that'll run unconditionally every time someone makes a DB
connection.  This script will create a temp table and stuff some data in it
for general use within that session.

no, there is nothing similar. You have to call a own procedure after
login explicitly

We could really use this.   It's kinda sorta possible to script SQL on
connection close via C hook through dblink but not on session startup.
It's not always possible for the client know when a backend session is
fired up -- for example in connection pools.

connection pooling is problem every time. This is not task for server,
but for connection pooling maintainer. Once we used a workaround - on
a start every function we tested if session is well initialized, and
if not, then we called a init function. But it has a problem with
pooling, so we changed to explicitly call a init function.

Regards

Pavel Stehule

Show quoted text

merlin

#6Merlin Moncure
mmoncure@gmail.com
In reply to: Pavel Stehule (#5)
Re: init script or procedure

On Wed, Aug 24, 2011 at 9:51 AM, Pavel Stehule <pavel.stehule@gmail.com> wrote:

2011/8/24 Merlin Moncure <mmoncure@gmail.com>:

On Wed, Aug 24, 2011 at 9:30 AM, Pavel Stehule <pavel.stehule@gmail.com> wrote:

Hello

2011/8/24 Gauthier, Dave <dave.gauthier@intel.com>:

Does PG support the use of an init script or procedure?  I'm looking for
something that'll run unconditionally every time someone makes a DB
connection.  This script will create a temp table and stuff some data in it
for general use within that session.

no, there is nothing similar. You have to call a own procedure after
login explicitly

We could really use this.   It's kinda sorta possible to script SQL on
connection close via C hook through dblink but not on session startup.
It's not always possible for the client know when a backend session is
fired up -- for example in connection pools.

[snip]

. This is not task for server,

I disagree. Other databases have them (see
http://msdn.microsoft.com/en-us/library/bb326598.aspx), and they are
highly used and useful.

merlin

#7Pavel Stehule
pavel.stehule@gmail.com
In reply to: Merlin Moncure (#6)
Re: init script or procedure

2011/8/24 Merlin Moncure <mmoncure@gmail.com>:

On Wed, Aug 24, 2011 at 9:51 AM, Pavel Stehule <pavel.stehule@gmail.com> wrote:

2011/8/24 Merlin Moncure <mmoncure@gmail.com>:

On Wed, Aug 24, 2011 at 9:30 AM, Pavel Stehule <pavel.stehule@gmail.com> wrote:

Hello

2011/8/24 Gauthier, Dave <dave.gauthier@intel.com>:

Does PG support the use of an init script or procedure?  I'm looking for
something that'll run unconditionally every time someone makes a DB
connection.  This script will create a temp table and stuff some data in it
for general use within that session.

no, there is nothing similar. You have to call a own procedure after
login explicitly

We could really use this.   It's kinda sorta possible to script SQL on
connection close via C hook through dblink but not on session startup.
It's not always possible for the client know when a backend session is
fired up -- for example in connection pools.

[snip]

. This is not task for server,

I disagree.  Other databases have them (see
http://msdn.microsoft.com/en-us/library/bb326598.aspx), and they are
highly used and useful.

other databases has own integrated connection pooling

I am not absolutely against - but we need a integrated pool before

Pavel

Show quoted text

merlin

#8Merlin Moncure
mmoncure@gmail.com
In reply to: Pavel Stehule (#7)
Re: init script or procedure

On Wed, Aug 24, 2011 at 10:06 AM, Pavel Stehule <pavel.stehule@gmail.com> wrote:

[snip]

. This is not task for server,

I disagree.  Other databases have them (see
http://msdn.microsoft.com/en-us/library/bb326598.aspx), and they are
highly used and useful.

other databases has own integrated connection pooling

I am not absolutely against - but we need a integrated pool before

not to argue the point, but connection pooling is only one reason of
many why you would want a logon trigger, and integrated connection
pooling is not a prerequisite for them being implemented IMO. Login
triggers are useful any time the client code is not completely under
your control, for example when logging in with psql/pgadmin or any
time really when the actionable item is required from the servers'
point of view.

merlin