Re: [HACKERS] Add function for quote_qualified_identifier?

Lists: pgsql-hackerspgsql-patches
From: "Brendan Jurd" <direvus(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Add function for quote_qualified_identifier?
Date: 2007-09-12 03:15:29
Message-ID: 37ed240d0709112015g6746be2bp91fcf5aeee1e92f1@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Hi hackers,

I note that we currently expose the usefulness of the quote_identifier
function to the user with quote_ident(text).

Is there any reason we shouldn't do the same with quote_qualified_identifier?

We could just add a quote_qualified_ident(text, text) ... it would
make forming dynamic queries more convenient in databases that use
multiple schemas.

Clearly a DBA could just create this function himself in SQL (and it
wouldn't be difficult), but is that a good reason not to have it in
our standard set of functions?

Would be happy to cook up a patch for this.

Cheers,
BJ


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Brendan Jurd <direvus(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Add function for quote_qualified_identifier?
Date: 2007-09-14 17:43:10
Message-ID: 200709141743.l8EHhA418806@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches


This has been saved for the 8.4 release:

http://momjian.postgresql.org/cgi-bin/pgpatches_hold

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

Brendan Jurd wrote:
> Hi hackers,
>
> I note that we currently expose the usefulness of the quote_identifier
> function to the user with quote_ident(text).
>
> Is there any reason we shouldn't do the same with quote_qualified_identifier?
>
> We could just add a quote_qualified_ident(text, text) ... it would
> make forming dynamic queries more convenient in databases that use
> multiple schemas.
>
> Clearly a DBA could just create this function himself in SQL (and it
> wouldn't be difficult), but is that a good reason not to have it in
> our standard set of functions?
>
> Would be happy to cook up a patch for this.
>
> Cheers,
> BJ
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: "Brendan Jurd" <direvus(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Add function for quote_qualified_identifier?
Date: 2007-09-22 20:54:52
Message-ID: 37ed240d0709221354j739bcbb8t714508a66863870c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

I had some spare cycles so I went ahead and patched this.

Patch includes documentation and new regression tests. While I was in
there I also added regression tests for quote_ident(), which appeared
to be absent.

quote_literal doesn't seem to have any regression tests either, but I
decided to leave that for another patch.

With thanks to Neil Conway for his assistance on IRC.

Cheers
BJ

On 9/15/07, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> This has been saved for the 8.4 release:
> Brendan Jurd wrote:
> > Hi hackers,
> >
> > I note that we currently expose the usefulness of the quote_identifier
> > function to the user with quote_ident(text).
> >
> > Is there any reason we shouldn't do the same with quote_qualified_identifier?
> >
> > We could just add a quote_qualified_ident(text, text) ... it would
> > make forming dynamic queries more convenient in databases that use
> > multiple schemas.
> >
> > Clearly a DBA could just create this function himself in SQL (and it
> > wouldn't be difficult), but is that a good reason not to have it in
> > our standard set of functions?
> >
> > Would be happy to cook up a patch for this.
> >
> > Cheers,
> > BJ
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 9: In versions below 8.0, the planner will ignore your desire to
> > choose an index scan if your joining column's datatypes do not
> > match
>
> --
> Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
> EnterpriseDB http://www.enterprisedb.com
>
> + If your life is a hard drive, Christ can be your backup. +
>

Attachment Content-Type Size
quote_qualified.diff text/plain 8.1 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Brendan Jurd" <direvus(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Add function for quote_qualified_identifier?
Date: 2007-09-22 21:41:19
Message-ID: 5114.1190497279@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

"Brendan Jurd" <direvus(at)gmail(dot)com> writes:
> Patch includes documentation and new regression tests. While I was in
> there I also added regression tests for quote_ident(), which appeared
> to be absent.

This seems rather pointless, since it's equivalent to
quote_ident(schemaname) || '.' || quote_ident(relname).

regards, tom lane


From: "Brendan Jurd" <direvus(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Add function for quote_qualified_identifier?
Date: 2007-09-22 22:11:08
Message-ID: 37ed240d0709221511x44237f64n7d417b4d06579620@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On 9/23/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> This seems rather pointless, since it's equivalent to
> quote_ident(schemaname) || '.' || quote_ident(relname).

Yes it is, and I brought that up in the OP:

I wrote:
> Clearly a DBA could just create this function himself in SQL (and it
> wouldn't be difficult), but is that a good reason not to have it in
> our standard set of functions?

But since nobody arced up about it I thought I might as well move
things along and produce a patch.

Many of the functions provided by postgres are easy to write yourself.
That doesn't mean they shouldn't be there. After all, there is
*exactly* one way to do quote_qualified_ident. Why require every DBA
who needs this functionality to go through the motions?

I'll admit that it's a minor improvement, but that seems reasonable
given it has a miniscule cost.


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Brendan Jurd <direvus(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Add function for quote_qualified_identifier?
Date: 2007-09-28 22:24:42
Message-ID: 200709282224.l8SMOgp06240@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
> "Brendan Jurd" <direvus(at)gmail(dot)com> writes:
> > Patch includes documentation and new regression tests. While I was in
> > there I also added regression tests for quote_ident(), which appeared
> > to be absent.
>
> This seems rather pointless, since it's equivalent to
> quote_ident(schemaname) || '.' || quote_ident(relname).

Has anyone every asked for this functionality?

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://postgres.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: "Brendan Jurd" <direvus(at)gmail(dot)com>
To: "Bruce Momjian" <bruce(at)momjian(dot)us>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Add function for quote_qualified_identifier?
Date: 2007-09-29 03:02:10
Message-ID: 37ed240d0709282002k73a225a7lcfec96f589e31030@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On 9/29/07, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> Has anyone every asked for this functionality?

I searched the list archives for previous mentions of the topic, and
didn't find any. So the answer to your question is "yes", but so far
it seems to be just me.

Cheers,
BJ


From: "Brendan Jurd" <direvus(at)gmail(dot)com>
To: "Bruce Momjian" <bruce(at)momjian(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: [HACKERS] Add function for quote_qualified_identifier?
Date: 2007-09-30 18:14:44
Message-ID: 37ed240d0709301114r78d63fa3we81f45394f13935f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On 9/29/07, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> I think we need more than one person's request to add this function.

Well, I don't expect it would get requested. Most DBAs would likely
look for the function in the docs, see it's not there and then just
implement it themselves. Obviously it's not critical. But
anticipating those little requirements and providing for them is one
of the things that makes a piece of software a pleasure to use.
"Batteries included" and all that.

Anyway, I seem to be flogging a horse which, if not dead, is surely
mortally wounded. If quote_qualified_ident isn't desired, perhaps you
can still use the regression test I included for quote_ident in the
patch. The test is functional as a standalone item, and seems to fill
a gap.

Thanks for your time,
BJ


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Brendan Jurd <direvus(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: [HACKERS] Add function for quote_qualified_identifier?
Date: 2007-10-08 18:33:53
Message-ID: 200710081833.l98IXru16653@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Brendan Jurd wrote:
> On 9/29/07, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> > I think we need more than one person's request to add this function.
>
> Well, I don't expect it would get requested. Most DBAs would likely
> look for the function in the docs, see it's not there and then just
> implement it themselves. Obviously it's not critical. But
> anticipating those little requirements and providing for them is one
> of the things that makes a piece of software a pleasure to use.
> "Batteries included" and all that.

I was just looking for someone else to say "Yea, I would like that too".

> Anyway, I seem to be flogging a horse which, if not dead, is surely
> mortally wounded. If quote_qualified_ident isn't desired, perhaps you
> can still use the regression test I included for quote_ident in the
> patch. The test is functional as a standalone item, and seems to fill
> a gap.

Well, we don't test everything and I don't remember problems in quoting
in the past, at least not enough to add another test.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://postgres.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Brendan Jurd <direvus(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: [HACKERS] Add function for quote_qualified_identifier?
Date: 2007-10-08 20:53:20
Message-ID: 20071008205320.GG6000@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Bruce Momjian escribió:
> Brendan Jurd wrote:
> > On 9/29/07, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> > > I think we need more than one person's request to add this function.
> >
> > Well, I don't expect it would get requested. Most DBAs would likely
> > look for the function in the docs, see it's not there and then just
> > implement it themselves. Obviously it's not critical. But
> > anticipating those little requirements and providing for them is one
> > of the things that makes a piece of software a pleasure to use.
> > "Batteries included" and all that.
>
> I was just looking for someone else to say "Yea, I would like that too".

Probably pgsql-hackers is not the best place to ask.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Brendan Jurd <direvus(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: [PATCHES] Add function for quote_qualified_identifier?
Date: 2008-03-26 02:49:14
Message-ID: 200803260249.m2Q2nEW01599@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Brendan Jurd wrote:
> On 9/29/07, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> > I think we need more than one person's request to add this function.
>
> Well, I don't expect it would get requested. Most DBAs would likely
> look for the function in the docs, see it's not there and then just
> implement it themselves. Obviously it's not critical. But
> anticipating those little requirements and providing for them is one
> of the things that makes a piece of software a pleasure to use.
> "Batteries included" and all that.
>
> Anyway, I seem to be flogging a horse which, if not dead, is surely
> mortally wounded. If quote_qualified_ident isn't desired, perhaps you
> can still use the regression test I included for quote_ident in the
> patch. The test is functional as a standalone item, and seems to fill
> a gap.

I think we did our best to find requests for this feature. If they ever
pop up in the future we can always recover this patch from the archives.
Sorry.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://postgres.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +