current_database()

Lists: Postg스포츠 토토 베트맨SQL
From: Rod Taylor <rbt(at)zort(dot)ca>
To: pgsql-patches(at)postgresql(dot)org
Subject: current_database()
Date: 2002-08-07 01:15:03
Message-ID: 1028682904.93791.5.camel@jester
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: Postg스포츠 토토 베트맨SQL

Quick system function to pull out the current database.

I've used this a number of times to allow stored procedures to find out
where they are. Especially useful for those that do logging or hit a
remote server.

It's called current_database() to match with current_user().

Attachment Content-Type Size
current_database.patch text/x-patch 2.2 KB

From: Rod Taylor <rbt(at)zort(dot)ca>
To: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: current_database()
Date: 2002-08-07 01:19:07
Message-ID: 1028683148.93791.11.camel@jester
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

On Tue, 2002-08-06 at 21:15, Rod Taylor wrote:
> Quick system function to pull out the current database.
>
> I've used this a number of times to allow stored procedures to find out
> where they are. Especially useful for those that do logging or hit a
> remote server.
>
> It's called current_database() to match with current_user().

It's also a necessity for an informational schema. The catalog
(database) name is required in a number of places.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rod Taylor <rbt(at)zort(dot)ca>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: current_database()
Date: 2002-08-07 04:10:12
Message-ID: 12420.1028693412@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Rod Taylor <rbt(at)zort(dot)ca> writes:
> + Datum
> + current_database(PG_FUNCTION_ARGS)
> + {
> + PG_RETURN_NAME(DatabaseName);
> }

DatabaseName is not actually a NAME, only a C string. You need a palloc
and a namestrcpy in there.

regards, tom lane


From: Rod Taylor <rbt(at)zort(dot)ca>
To:
Cc: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: current_database()
Date: 2002-08-07 13:15:41
Message-ID: 1028726143.12474.0.camel@jester
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

On Wed, 2002-08-07 at 00:10, Tom Lane wrote:
> Rod Taylor <rbt(at)zort(dot)ca> writes:
> > + Datum
> > + current_database(PG_FUNCTION_ARGS)
> > + {
> > + PG_RETURN_NAME(DatabaseName);
> > }
>
> DatabaseName is not actually a NAME, only a C string. You need a palloc
> and a namestrcpy in there.

Hmm.. Oops.

Attachment Content-Type Size
current_database.patch text/plain 2.4 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rod Taylor <rbt(at)zort(dot)ca>
Cc: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: current_database()
Date: 2002-08-07 13:59:33
Message-ID: 15332.1028728773@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Rod Taylor <rbt(at)zort(dot)ca> writes:
>> DatabaseName is not actually a NAME, only a C string. You need a palloc
>> and a namestrcpy in there.

> Hmm.. Oops.

That's better ... but we also need a patch to the SGML documentation
(probably it belongs in misc/session information functions).

regards, tom lane


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Rod Taylor <rbt(at)zort(dot)ca>
Cc: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: current_database()
Date: 2002-08-14 05:10:43
Message-ID: 200208140510.g7E5AhA00482@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


Your patch has been added to the PostgreSQL unapplied patches list at:

http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------

Rod Taylor wrote:
> On Wed, 2002-08-07 at 00:10, Tom Lane wrote:
> > Rod Taylor <rbt(at)zort(dot)ca> writes:
> > > + Datum
> > > + current_database(PG_FUNCTION_ARGS)
> > > + {
> > > + PG_RETURN_NAME(DatabaseName);
> > > }
> >
> > DatabaseName is not actually a NAME, only a C string. You need a palloc
> > and a namestrcpy in there.
>
> Hmm.. Oops.

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Rod Taylor <rbt(at)zort(dot)ca>
Cc: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: current_database()
Date: 2002-08-20 04:46:04
Message-ID: 200208200446.g7K4k4f21967@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


Patch applied with docs. Thanks.

---------------------------------------------------------------------------

Rod Taylor wrote:
> On Tue, 2002-08-06 at 21:15, Rod Taylor wrote:
> > Quick system function to pull out the current database.
> >
> > I've used this a number of times to allow stored procedures to find out
> > where they are. Especially useful for those that do logging or hit a
> > remote server.
> >
> > It's called current_database() to match with current_user().
>
> It's also a necessity for an informational schema. The catalog
> (database) name is required in a number of places.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073