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

2007-10-08 Thread Bruce Momjian
Brendan Jurd wrote:
 On 9/29/07, Bruce Momjian [EMAIL PROTECTED] 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  [EMAIL PROTECTED]http://momjian.us
  EnterpriseDB http://postgres.enterprisedb.com

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

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


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

2007-10-08 Thread Alvaro Herrera
Bruce Momjian escribió:
 Brendan Jurd wrote:
  On 9/29/07, Bruce Momjian [EMAIL PROTECTED] 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 Herrerahttp://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


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

2007-09-30 Thread Brendan Jurd
On 9/29/07, Bruce Momjian [EMAIL PROTECTED] 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

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


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

2007-09-28 Thread Bruce Momjian
Tom Lane wrote:
 Brendan Jurd [EMAIL PROTECTED] 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  [EMAIL PROTECTED]http://momjian.us
  EnterpriseDB http://postgres.enterprisedb.com

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

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


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

2007-09-28 Thread Brendan Jurd
On 9/29/07, Bruce Momjian [EMAIL PROTECTED] 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

---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster


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

2007-09-22 Thread Brendan Jurd
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 [EMAIL PROTECTED] 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  [EMAIL PROTECTED]  http://momjian.us
   EnterpriseDB   http://www.enterprisedb.com

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

Index: doc/src/sgml/func.sgml
===
RCS file: /projects/cvsroot/pgsql/doc/src/sgml/func.sgml,v
retrieving revision 1.397
diff -c -r1.397 func.sgml
*** doc/src/sgml/func.sgml  19 Sep 2007 03:13:57 -  1.397
--- doc/src/sgml/func.sgml  22 Sep 2007 03:07:26 -
***
*** 1276,1281 
--- 1276,1284 
  primaryquote_ident/primary
 /indexterm
 indexterm
+ primaryquote_qualified_ident/primary
+/indexterm
+indexterm
  primaryquote_literal/primary
 /indexterm
 indexterm
***
*** 1541,1546 
--- 1544,1563 
/row
  
row
+
entryliteralfunctionquote_qualified_ident/function(parameterschema/parameter
 typetext/type, parameteridentifier/parameter 
typetext/type)/literal/entry
+entrytypetext/type/entry
+entry
+   Return the given schema and identifier suitably quoted to be 
used as a
+   fully qualified identifier in an acronymSQL/acronym 
statement
+   string.  Quoting is performed as for 
functionquote_ident/function,
+   but parameterschema/parameter and 
parameteridentifier/parameter
+   are quoted separately.
+/entry
+entryliteralquote_ident('Some schema','A table')/literal/entry
+entryliteralSome schema.A table/literal/entry
+   /row
+ 
+   row
 
entryliteralfunctionquote_literal/function(parameterstring/parameter)/literal/entry
 entrytypetext/type/entry
 entry
Index: src/backend/utils/adt/quote.c
===
RCS file: /projects/cvsroot/pgsql/src/backend/utils/adt/quote.c,v
retrieving revision 1.22
diff -c -r1.22 quote.c
*** src/backend/utils/adt/quote.c   27 Feb 2007 23:48:08 -  1.22
--- src/backend/utils/adt/quote.c   22 Sep 2007 03:07:26 -
***
*** 46,51 
--- 46,77 
  }
  
  /*
+  * quote_qualified_ident -
+  *returns a properly quoted, schema-qualified identifier
+  */
+ Datum
+ quote_qualified_ident(PG_FUNCTION_ARGS)
+ {
+   text*schema = PG_GETARG_TEXT_P(0);
+   text*ident = PG_GETARG_TEXT_P(1);
+   text*result;
+   const char  *quoted;
+   char*schema_s;
+   char*ident_s;
+ 
+   schema_s = DatumGetCString(DirectFunctionCall1(textout, 
+   
   PointerGetDatum(schema)));
+   ident_s = DatumGetCString(DirectFunctionCall1(textout, 
+   
  PointerGetDatum(ident)));
+ 
+   quoted = quote_qualified_identifier(schema_s, ident_s);
+ 
+   result = DatumGetTextP(DirectFunctionCall1(textin, 
+   
   CStringGetDatum(quoted)));
+   PG_RETURN_TEXT_P(result);
+ }
+ 
+ /*
   * quote_literal -
   *  returns a properly quoted literal
   *
Index: src/include/catalog/pg_proc.h
===
RCS file: /projects/cvsroot/pgsql/src/include/catalog/pg_proc.h,v
retrieving revision 1.471
diff -c -r1.471 pg_proc.h
*** src/include/catalog/pg_proc.h   20 Sep 2007 17:56:32 

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

2007-09-22 Thread Tom Lane
Brendan Jurd [EMAIL PROTECTED] 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

---(end of broadcast)---
TIP 6: explain analyze is your friend


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

2007-09-22 Thread Brendan Jurd
On 9/23/07, Tom Lane [EMAIL PROTECTED] 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.

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq