Re: [PATCHES] Exposing keywords to clients

2008-07-02 Thread Nikhils
Hi,

> > Attached is an updated patch, giving the following output.
> >
> > Oh, one other thing: dropping externs into random modules unrelated to
> > their source module is completely awful programming style, because there
> > is nothing preventing incompatible declarations.  Put those externs in
> > keywords.h instead.
>
> OK.
>
> > I suspect you have ignored a compiler warning
> > about not declaring pg_get_keywords itself, too --- it should be
> > extern'd in builtins.h.
>
> No, no warning (I'm using VC++ today) - but fixed anyway.
>
> Update attached, including corrected docs. Note to self - proof read
> docs *after* putting the kids to bed in future.
>

Here are some comments from me:

* doc/src/sgml/func.sgml

a) Changed "localised" to "localized" to be consistent with the references
elsewhere in the same file.

* src/backend/utils/adt/misc.c

b) I wonder if we need the default case in the switch statement at all,
since we are scanning the statically populated ScanKeywords array with
proper category values for each entry.

c) There was a warning during compilation since we were assigning a const
pointer to a char pointer
 values[0] = ScanKeywords[funcctx->call_cntr].name;

* src/include/catalog/pg_proc.h

d) oid 2700 has been claimed by another function in the meanwhile. Modified
it to 2701.
DATA(insert OID = 2701 ( pg_get_keywordsPGNSP PGUID 12 10 400 f f t t s
0 2249

e) I was wondering why pronargs is set to 0 above. But I see other functions
doing the same, so its ok I guess for such kinds of usages.

PFA, version 4 of this patch with a,c and d taken care of.

Regards,
Nikhils
-- 
EnterpriseDB http://www.enterprisedb.com
Index: doc/src/sgml/func.sgml
===
RCS file: /repositories/postgreshome/cvs/pgsql/doc/src/sgml/func.sgml,v
retrieving revision 1.437
diff -c -w -r1.437 func.sgml
*** doc/src/sgml/func.sgml	19 May 2008 18:08:15 -	1.437
--- doc/src/sgml/func.sgml	3 Jul 2008 07:01:47 -
***
*** 10903,10908 
--- 10903,10914 

  

+pg_get_keywords()
+setof record
+list of keywords and their categories
+   
+ 
+   
 pg_my_temp_schema()
 oid
 OID of session's temporary schema, or 0 if none
***
*** 11044,11049 
--- 11050,11068 
 

 
+ pg_get_keywords
+
+
+
+ pg_get_keywords returns a set of records describing
+ the keywords recognized by the server. The word column
+ contains the keyword and the catcode column contains a
+ category code of 'U' for unreserved, 'C' for column name, 'T' for type
+ or function name or 'R' for reserved. The catdesc
+ column contains a localized string describing the category.
+
+
+
  pg_my_temp_schema
 

Index: src/backend/parser/keywords.c
===
RCS file: /repositories/postgreshome/cvs/pgsql/src/backend/parser/keywords.c,v
retrieving revision 1.197
diff -c -w -r1.197 keywords.c
*** src/backend/parser/keywords.c	21 May 2008 19:51:01 -	1.197
--- src/backend/parser/keywords.c	3 Jul 2008 07:01:47 -
***
*** 41,47 
   * !!WARNING!!: This list must be sorted by ASCII name, because binary
   *		 search is used to locate entries.
   */
! static const ScanKeyword ScanKeywords[] = {
  	/* name, value, category */
  	{"abort", ABORT_P, UNRESERVED_KEYWORD},
  	{"absolute", ABSOLUTE_P, UNRESERVED_KEYWORD},
--- 41,47 
   * !!WARNING!!: This list must be sorted by ASCII name, because binary
   *		 search is used to locate entries.
   */
! const ScanKeyword ScanKeywords[] = {
  	/* name, value, category */
  	{"abort", ABORT_P, UNRESERVED_KEYWORD},
  	{"absolute", ABSOLUTE_P, UNRESERVED_KEYWORD},
***
*** 428,433 
--- 428,436 
  	{"zone", ZONE, UNRESERVED_KEYWORD},
  };

+ /* End of ScanKeywords, for use elsewhere */
+ const ScanKeyword *LastScanKeyword = endof(ScanKeywords);
+
  /*
   * ScanKeywordLookup - see if a given word is a keyword
   *
Index: src/backend/utils/adt/misc.c
===
RCS file: /repositories/postgreshome/cvs/pgsql/src/backend/utils/adt/misc.c,v
retrieving revision 1.62
diff -c -w -r1.62 misc.c
*** src/backend/utils/adt/misc.c	17 Apr 2008 20:56:41 -	1.62
--- src/backend/utils/adt/misc.c	3 Jul 2008 07:01:47 -
***
*** 20,29 
--- 20,31 
  #include 

  #include "access/xact.h"
+ #include "catalog/pg_type.h"
  #include "catalog/pg_tablespace.h"
  #include "commands/dbcommands.h"
  #include "funcapi.h"
  #include "miscadmin.h"
+ #include "parser/keywords.h"
  #include "postmaster/syslogger.h"
  #include "storage/fd.h"
  #include "storage/pmsignal.h"
***
*** 322,324 
--- 324,393 

  	PG_RETURN_VOID();
  }
+
+ /* Function to return the keywords list */
+ Datum
+ pg_get_keywords(PG_FUNCTION_ARGS)
+ {
+ 	FuncCallCon

Re: [PATCHES] Re: [BUGS] BUG #4203: perform dblink() in begin/exception returns wrong SQLSTATE code

2008-07-02 Thread Joe Conway

Joe Conway wrote:

Tom Lane wrote:

Joe Conway <[EMAIL PROTECTED]> writes:

[ improved patch ]


Still a couple quibbles:


[ more good feedback ]

All valid complaints, and noticeably improved/simplified code as a 
result. Third patch attached.


Patch applied to HEAD.

Joe


--
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches


Re: [PATCHES] Patch to change psql default banner v6

2008-07-02 Thread Tom Lane
Guillaume Lelarge <[EMAIL PROTECTED]> writes:
> Attached is a new version of the patch. It fixes a few issues when one 
> adds a pattern to metacommands.

Applied with some editorialization.  There were some places you
evidently hadn't tested against all supported server versions ...

regards, tom lane

-- 
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches


[PATCHES] WITH RECURSIVE updated to CVS TIP

2008-07-02 Thread David Fetter
Folks,

Please find patch enclosed, including some documentation.

Can we see about getting this in this commitfest?

Cheers,
David.
-- 
David Fetter <[EMAIL PROTECTED]> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter  XMPP: [EMAIL PROTECTED]

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate


recursive_query-7.patch.bz2
Description: BZip2 compressed data

-- 
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches


Re: [PATCHES] Explain XML patch v2

2008-07-02 Thread Tom Raney

Peter Eisentraut wrote:

Am Mittwoch, 2. Juli 2008 schrieb Tom Raney:
  

This is an update to my EXPLAIN XML patch submitted a few days ago.



Could you explain how you came up with the XML schema design?  I suppose you 
just made something up that went along with the existing XML output.
  
Yes, it is based on the existing output. 
I would like to see more integration with the spirit of the existing XML 
functionality.  For example, instead of things like


"\n"

we ought to be using XML Schema data types for time intervals and so on.
  
The DTD provides only rudimentary document validation but it has no 
support for type checking.   So, it may make sense to move to the more 
rigorous XML Schema.  There is a 'duration' data type that could be used 
for the instance listed above.  Or, we could define our own.

We might also want to use an XML namespace.
  
Taking the 'ms' field listed above:  
xmlns="http://www.postgresql.org/v8.4/ms"; or something like this?  
Table and index names should be escaped using the existing escape mechanism 
for identifiers.  There might also be encoding issues.
  

That's a good point.  Or, wrap them with CDATA.
It would also be interesting if EXPLAIN could optionally be a function that 
returns a datum of type XML, to allow further processing.


Any thoughts on these issues?
  
I am in the process of writing a parser of this XML output for the Red 
Hat Visual Explain tool.  I want to see what surprises come up during 
implementation. 




--
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches


Re: [PATCHES] Explain XML patch v2

2008-07-02 Thread daveg
On Wed, Jul 02, 2008 at 09:01:18AM -0700, David Fetter wrote:
> On Wed, Jul 02, 2008 at 05:57:29PM +0200, Peter Eisentraut wrote:
> > It would also be interesting if EXPLAIN could optionally be a
> > function that returns a datum of type XML, to allow further
> > processing.
> 
> It would be better to have a function which allows people to plug in
> their own serialization.  A JSON or YAML one, for example, would be
> much lighter weight on both ends.

+1 for either of these.

-dg 

-- 
David Gould   [EMAIL PROTECTED]  510 536 1443510 282 0869
If simplicity worked, the world would be overrun with insects.

-- 
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches


Re: [PATCHES] GIN improvements

2008-07-02 Thread Teodor Sigaev
Sync with current CVS HEAD and post in hackers- too because patches- close to 
the closing.


http://www.sigaev.ru/misc/fast_insert_gin-0.7.gz
http://www.sigaev.ru/misc/multicolumn_gin-0.3.gz

--
Teodor Sigaev   E-mail: [EMAIL PROTECTED]
   WWW: http://www.sigaev.ru/

--
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches


Re: [PATCHES] Explain XML patch v2

2008-07-02 Thread Dave Page
On Wed, Jul 2, 2008 at 4:57 PM, Peter Eisentraut <[EMAIL PROTECTED]> wrote:
> Am Mittwoch, 2. Juli 2008 schrieb Tom Raney:
>> This is an update to my EXPLAIN XML patch submitted a few days ago.
>
> Could you explain how you came up with the XML schema design?  I suppose you
> just made something up that went along with the existing XML output.

Speaking of schema - I haven't had time to review the patch myself
yet, but does it include schema names for all relations? The current
text output does not (and adding it has been rejected due to
verbosity), but that makes any kind of query tuning or information
gathering tool more or less impossible to write.


-- 
Dave Page
EnterpriseDB UK: http://www.enterprisedb.com

-- 
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches


Re: [PATCHES] Explain XML patch v2

2008-07-02 Thread David Fetter
On Wed, Jul 02, 2008 at 05:57:29PM +0200, Peter Eisentraut wrote:
> It would also be interesting if EXPLAIN could optionally be a
> function that returns a datum of type XML, to allow further
> processing.

It would be better to have a function which allows people to plug in
their own serialization.  A JSON or YAML one, for example, would be
much lighter weight on both ends.

Cheers,
David.
-- 
David Fetter <[EMAIL PROTECTED]> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter  XMPP: [EMAIL PROTECTED]

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

-- 
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches


Re: [PATCHES] Explain XML patch v2

2008-07-02 Thread Peter Eisentraut
Am Mittwoch, 2. Juli 2008 schrieb Tom Raney:
> This is an update to my EXPLAIN XML patch submitted a few days ago.

Could you explain how you came up with the XML schema design?  I suppose you 
just made something up that went along with the existing XML output.

I would like to see more integration with the spirit of the existing XML 
functionality.  For example, instead of things like

"\n"

we ought to be using XML Schema data types for time intervals and so on.

We might also want to use an XML namespace.

Table and index names should be escaped using the existing escape mechanism 
for identifiers.  There might also be encoding issues.

It would also be interesting if EXPLAIN could optionally be a function that 
returns a datum of type XML, to allow further processing.

Any thoughts on these issues?

-- 
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches


Re: [PATCHES] pg_dump lock timeout

2008-07-02 Thread David Fetter
On Sun, May 11, 2008 at 06:00:35AM -0700, David Gould wrote:
> On Sun, May 11, 2008 at 04:30:47AM -0700, daveg wrote:
> > 
> > Attached is a patch to add a commandline option to pg_dump to
> > limit how long pg_dump will wait for locks during startup.
> 
> Ooops, really attached this time. 

Can we see about getting this into the July commitfest?  Dave has
presented a use case complete with logs where having this could have
prevented a failed backup and consequent data loss.

Cheers,
David.
-- 
David Fetter <[EMAIL PROTECTED]> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter  XMPP: [EMAIL PROTECTED]

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

-- 
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches


Re: [PATCHES] Regression test database name

2008-07-02 Thread Magnus Hagander
Peter Eisentraut wrote:
> For some experiments I wanted to run the regression tests using a different 
> database (possibly using pg_regress --dbname=), but the name "regression" is 
> hardcoded in a few places.  It's trivial to fix, see attached patch.  Quick 
> explanation: The fact that psql's \z prints the database name has always been 
> an inconsistency, so it's good to get rid of anyway.  The majority of the 
> diff in prepare.out is whitespace differences.  Objections?

Seems like a good idea to me. +1.

//Magnus


-- 
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches


[PATCHES] Regression test database name

2008-07-02 Thread Peter Eisentraut
For some experiments I wanted to run the regression tests using a different 
database (possibly using pg_regress --dbname=), but the name "regression" is 
hardcoded in a few places.  It's trivial to fix, see attached patch.  Quick 
explanation: The fact that psql's \z prints the database name has always been 
an inconsistency, so it's good to get rid of anyway.  The majority of the 
diff in prepare.out is whitespace differences.  Objections?
diff -ur ../cvs-pgsql/doc/src/sgml/ref/grant.sgml ./doc/src/sgml/ref/grant.sgml
--- ../cvs-pgsql/doc/src/sgml/ref/grant.sgml	2008-06-08 10:31:25.0 +0200
+++ ./doc/src/sgml/ref/grant.sgml	2008-07-01 16:06:32.0 +0200
@@ -419,7 +419,7 @@
 to obtain information about existing privileges, for example:
 
 => \z mytable
-   Access privileges for database "lusitania"
+Access privileges
  Schema |  Name   | Type  |  Access privileges   
 +-+---+--
  public | mytable | table | miriam=arwdxt/miriam
diff -ur ../cvs-pgsql/src/bin/psql/describe.c ./src/bin/psql/describe.c
--- ../cvs-pgsql/src/bin/psql/describe.c	2008-06-08 10:31:43.0 +0200
+++ ./src/bin/psql/describe.c	2008-07-01 16:05:32.0 +0200
@@ -515,8 +515,7 @@
 	}
 
 	myopt.nullPrint = NULL;
-	printfPQExpBuffer(&buf, _("Access privileges for database \"%s\""),
-	  PQdb(pset.db));
+	printfPQExpBuffer(&buf, _("Access privileges"));
 	myopt.title = buf.data;
 	myopt.trans_headers = true;
 	myopt.trans_columns = trans_columns;
diff -ur ../cvs-pgsql/src/test/regress/expected/dependency.out ./src/test/regress/expected/dependency.out
--- ../cvs-pgsql/src/test/regress/expected/dependency.out	2008-06-08 10:32:04.0 +0200
+++ ./src/test/regress/expected/dependency.out	2008-07-01 16:12:04.0 +0200
@@ -68,7 +68,7 @@
 GRANT ALL ON deptest1 TO regression_user2;
 RESET SESSION AUTHORIZATION;
 \z deptest1
-Access privileges for database "regression"
+ Access privileges
  Schema |   Name   | Type  |   Access privileges
 +--+---+
  public | deptest1 | table | regression_user0=arwdxt/regression_user0
@@ -79,7 +79,7 @@
 DROP OWNED BY regression_user1;
 -- all grants revoked
 \z deptest1
- Access privileges for database "regression"
+  Access privileges
  Schema |   Name   | Type  |Access privileges 
 +--+---+--
  public | deptest1 | table | regression_user0=arwdxt/regression_user0
diff -ur ../cvs-pgsql/src/test/regress/expected/prepare.out ./src/test/regress/expected/prepare.out
--- ../cvs-pgsql/src/test/regress/expected/prepare.out	2008-06-08 10:32:05.0 +0200
+++ ./src/test/regress/expected/prepare.out	2008-07-01 16:14:37.0 +0200
@@ -16,7 +16,7 @@
 SELECT name, statement, parameter_types FROM pg_prepared_statements;
  name |  statement   | parameter_types 
 --+--+-
- q1   | PREPARE q1 AS SELECT 1 AS a; | {} 
+ q1   | PREPARE q1 AS SELECT 1 AS a; | {}
 (1 row)
 
 -- should fail
@@ -35,8 +35,8 @@
 SELECT name, statement, parameter_types FROM pg_prepared_statements;
  name |  statement   | parameter_types 
 --+--+-
- q1   | PREPARE q1 AS SELECT 2;  | {} 
- q2   | PREPARE q2 AS SELECT 2 AS b; | {} 
+ q1   | PREPARE q1 AS SELECT 2;  | {}
+ q2   | PREPARE q2 AS SELECT 2 AS b; | {}
 (2 rows)
 
 -- sql92 syntax
@@ -44,7 +44,7 @@
 SELECT name, statement, parameter_types FROM pg_prepared_statements;
  name |  statement   | parameter_types 
 --+--+-
- q2   | PREPARE q2 AS SELECT 2 AS b; | {} 
+ q2   | PREPARE q2 AS SELECT 2 AS b; | {}
 (1 row)
 
 DEALLOCATE PREPARE q2;
@@ -58,10 +58,10 @@
 PREPARE q2(text) AS
 	SELECT datname, datistemplate, datallowconn
 	FROM pg_database WHERE datname = $1;
-EXECUTE q2('regression');
-  datname   | datistemplate | datallowconn 
-+---+--
- regression | f | t   
+EXECUTE q2('postgres');
+ datname  | datistemplate | datallowconn 
+--+---+--
+ postgres | f | t
 (1 row)
 
 PREPARE q3(text, int, float, boolean, oid, smallint) AS
@@ -71,35 +71,35 @@
 EXECUTE q3('xx', 5::smallint, 10.5::float, false, 500::oid, 4::bigint);
  unique1 | unique2 | two | four | ten | twenty | hundred | thousand | twothousand | fivethous | tenthous | odd | even | stringu1 | stringu2 | string4 
 -+-+-+--+-++-+--+-+---+--+-+--+--+--+-
-   2 |2716 |   0 |2 |   2 |  2 |   2 |2 |   2 |  

Re: [PATCHES] Explain XML patch v2

2008-07-02 Thread Gregory Stark
"Tom Raney" <[EMAIL PROTECTED]> writes:

> This is an update to my EXPLAIN XML patch submitted a few days ago.
>
> I've added a documentation patch and modified some of the code per  comments 
> by
> Gregory Stark.

You should update the wiki at

http://wiki.postgresql.org/wiki/CommitFest:2008-07

so any reviewers look at the updated patch.

(I certainly don't see any reason to wait two months for the next commit fest)

-- 
  Gregory Stark
  EnterpriseDB  http://www.enterprisedb.com
  Ask me about EnterpriseDB's PostGIS support!

-- 
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches