Thread: Re: [HACKERS] Add function for quote_qualified_identifier?

Re: [HACKERS] Add function for quote_qualified_identifier?

From
"Brendan Jurd"
Date:
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@momjian.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@momjian.us>          http://momjian.us
>   EnterpriseDB                               http://www.enterprisedb.com
>
>   + If your life is a hard drive, Christ can be your backup. +
>

Attachment

Re: [HACKERS] Add function for quote_qualified_identifier?

From
Tom Lane
Date:
"Brendan Jurd" <direvus@gmail.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

Re: [HACKERS] Add function for quote_qualified_identifier?

From
"Brendan Jurd"
Date:
On 9/23/07, Tom Lane <tgl@sss.pgh.pa.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.

Re: [HACKERS] Add function for quote_qualified_identifier?

From
Bruce Momjian
Date:
Tom Lane wrote:
> "Brendan Jurd" <direvus@gmail.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@momjian.us>        http://momjian.us
  EnterpriseDB                             http://postgres.enterprisedb.com

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

Re: [HACKERS] Add function for quote_qualified_identifier?

From
"Brendan Jurd"
Date:
On 9/29/07, Bruce Momjian <bruce@momjian.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

Re: [HACKERS] Add function for quote_qualified_identifier?

From
"Brendan Jurd"
Date:
On 9/29/07, Bruce Momjian <bruce@momjian.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

Re: [HACKERS] Add function for quote_qualified_identifier?

From
Bruce Momjian
Date:
Brendan Jurd wrote:
> On 9/29/07, Bruce Momjian <bruce@momjian.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@momjian.us>        http://momjian.us
  EnterpriseDB                             http://postgres.enterprisedb.com

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

Re: [HACKERS] Add function for quote_qualified_identifier?

From
Alvaro Herrera
Date:
Bruce Momjian escribió:
> Brendan Jurd wrote:
> > On 9/29/07, Bruce Momjian <bruce@momjian.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.

Re: Add function for quote_qualified_identifier?

From
Bruce Momjian
Date:
Brendan Jurd wrote:
> On 9/29/07, Bruce Momjian <bruce@momjian.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@momjian.us>        http://momjian.us
  EnterpriseDB                             http://postgres.enterprisedb.com

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