Re: [HACKERS] gSoC - ADD MERGE COMMAND - code patch submission

2010-07-10 Thread Andres Freund
On Fri, Jul 09, 2010 at 11:33:04PM -0400, Robert Haas wrote:
 On Fri, Jul 9, 2010 at 10:25 PM, Boxuan Zhai bxzhai2...@gmail.com wrote:
  Dear All,
 
  This is ZHAI BOXUAN, a student of gSoC 2010. My project is to add merge
  command in postgres.
  There is a more detailed instruction in readme.
I would find it helpfull to find a short recap of how you want to
handle the various problems (mostly around locking) in the readme.

  Any comments will be highly appreciated.
 Is there any chance you can submit this as a single patch file?  Or if
 not, can you at least use a zip or tar file instead of a RAR archive?
 Ideally the patch would be against CVS HEAD, not 8.4.3.

I would also suggest you base your patch either against the git tree
or CVS. Currently it does include patches agains generated files like
gram.y or kwlist.h which make it harder to see the real changes.

Thanks,
Andres

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


Re: [HACKERS] FYI: Ubuntu 10.04 lucid strange segfault

2010-07-10 Thread Yeb Havinga
On Fri, Jul 9, 2010 at 10:18 PM, Robert Haas robertmh...@gmail.com wrote:

 On Fri, Jul 9, 2010 at 4:10 PM, Yeb Havinga yebhavi...@gmail.com wrote:
  Joshua D. Drake wrote:
  On Fri, 2010-07-09 at 16:57 +0200, Yeb Havinga wrote:
  Hello list,
 
  Due to dependency requirements my development machine has ubuntu
  repositories jaunty, lucid and intrepid.
 
  I would not expect anything to work in an environment that is that
  misconfigured. I would suggest running VirtualBox for your different
  requirements.
 
 
  Thanks for your advice but my message was a FYI. The link I provided
  suggests it can happen at systems having only lucid as well.

 It sounds like it's an Ubuntu linker bug, though - not really anything
 to do with us.


I realize the pg lists are not the place to discuss particular distribution
bugs. However, because the bug occurred only in a particular pg source tree
and not another, I spent a lot of time looking in the wrong place. This
could happen to somebody else as well. Since searching for some keywords in
the pg lists returned 0 results I thought lets change that, to possibly safe
somebody else some time.

Sorry to cause confusion. I'll try to be more prudent in the future.

regards,
Yeb Havinga


Re: [PATCH] Re: [HACKERS] Issue: Deprecation of the XML2 module 'xml_is_well_formed' function

2010-07-10 Thread Mike Fowler

Robert Haas wrote:

On Fri, Jul 9, 2010 at 4:06 PM, Peter Eisentraut pete...@gmx.net wrote:
  

On ons, 2010-07-07 at 16:37 +0100, Mike Fowler wrote:


Here's the patch to add the 'xml_is_well_formed' function.
  

I suppose we should remove the function from contrib/xml2 at the same
time.



Yep


Revised patch deleting the contrib/xml2 version of the function attached.

Regards,

--
Mike Fowler
Registered Linux user: 379787

*** a/contrib/xml2/xpath.c
--- b/contrib/xml2/xpath.c
***
*** 27,33  PG_MODULE_MAGIC;
  
  /* externally accessible functions */
  
- Datum		xml_is_well_formed(PG_FUNCTION_ARGS);
  Datum		xml_encode_special_chars(PG_FUNCTION_ARGS);
  Datum		xpath_nodeset(PG_FUNCTION_ARGS);
  Datum		xpath_string(PG_FUNCTION_ARGS);
--- 27,32 
***
*** 70,97  pgxml_parser_init(void)
  	xmlLoadExtDtdDefaultValue = 1;
  }
  
- 
- /* Returns true if document is well-formed */
- 
- PG_FUNCTION_INFO_V1(xml_is_well_formed);
- 
- Datum
- xml_is_well_formed(PG_FUNCTION_ARGS)
- {
- 	text	   *t = PG_GETARG_TEXT_P(0);		/* document buffer */
- 	int32		docsize = VARSIZE(t) - VARHDRSZ;
- 	xmlDocPtr	doctree;
- 
- 	pgxml_parser_init();
- 
- 	doctree = xmlParseMemory((char *) VARDATA(t), docsize);
- 	if (doctree == NULL)
- 		PG_RETURN_BOOL(false);	/* i.e. not well-formed */
- 	xmlFreeDoc(doctree);
- 	PG_RETURN_BOOL(true);
- }
- 
- 
  /* Encodes special characters (, , ,  and \r) as XML entities */
  
  PG_FUNCTION_INFO_V1(xml_encode_special_chars);
--- 69,74 
*** a/doc/src/sgml/func.sgml
--- b/doc/src/sgml/func.sgml
***
*** 8554,8562  SELECT xmlagg(x) FROM (SELECT * FROM test ORDER BY y DESC) AS tab;
  ]]/screen
  /para
 /sect3
  
 sect3
! titleXML Predicates/title
  
  indexterm
   primaryIS DOCUMENT/primary
--- 8554,8566 
  ]]/screen
  /para
 /sect3
+   /sect2
+ 
+   sect2
+titleXML Predicates/title
  
 sect3
! titleIS DOCUMENT/title
  
  indexterm
   primaryIS DOCUMENT/primary
***
*** 8574,8579  SELECT xmlagg(x) FROM (SELECT * FROM test ORDER BY y DESC) AS tab;
--- 8578,8653 
   between documents and content fragments.
  /para
 /sect3
+ 
+sect3
+ titlexml_is_well_formed/title
+ 
+ indexterm
+  primaryxml_is_well_formed/primary
+  secondarywell formed/secondary
+ /indexterm
+ 
+ synopsis
+ functionxml_is_well_formed/function(replaceabletext/replaceable)
+ /synopsis
+ 
+ para
+  The function functionxml_is_well_formed/function evaluates whether
+  the replaceabletext/replaceable is well formed XML content, returning
+  a boolean.
+ /para
+ para
+ Example:
+ screen![CDATA[
+ SELECT xml_is_well_formed('foobar/foo');
+  xml_is_well_formed
+ 
+  t
+ (1 row)
+ 
+ SELECT xml_is_well_formed('foobar/foo');
+  xml_is_well_formed
+ 
+  f
+ (1 row)
+ ]]/screen
+ /para
+ para
+ This function can be combined with the IS DOCUMENT predicate to prevent
+ invalid XML content errors from occuring in queries. For example, given a
+ table that may have rows with invalid XML mixed in with rows of valid
+ XML, functionxml_is_well_formed/function can be used to filter out all
+ the invalid rows.
+ /para
+ para
+ Example:
+ screen![CDATA[
+ SELECT * FROM mixed;
+  data
+ --
+  foobar/foo
+  foobar/foo
+  foobar/foobarfoo/bar
+  foobar/foobarfoo/bar
+ (4 rows)
+ 
+ SELECT COUNT(data) FROM mixed WHERE data::xml IS DOCUMENT;
+ ERROR:  invalid XML content
+ DETAIL:  Entity: line 1: parser error : expected ''
+ foobar/foo
+  ^
+ Entity: line 1: parser error : chunk is not well balanced
+ foobar/foo
+  ^
+ 
+ SELECT COUNT(data) FROM mixed WHERE xml_is_well_formed(data) AND data::xml IS DOCUMENT;
+  count
+ ---
+  1
+ (1 row)
+ ]]/screen
+ /para
+/sect3
/sect2
  
sect2 id=functions-xml-processing
*** a/src/backend/utils/adt/xml.c
--- b/src/backend/utils/adt/xml.c
***
*** 3293,3298  xml_xmlnodetoxmltype(xmlNodePtr cur)
--- 3293,3365 
  }
  #endif
  
+ Datum
+ xml_is_well_formed(PG_FUNCTION_ARGS)
+ {
+ #ifdef USE_LIBXML
+ 	text*data = PG_GETARG_TEXT_P(0);
+ 	boolresult;
+ 	int	res_code;
+ 	int32len;
+ 	const xmlChar		*string;
+ 	xmlParserCtxtPtr	ctxt;
+ 	xmlDocPtr			doc = NULL;
+ 
+ 	len = VARSIZE(data) - VARHDRSZ;
+ 	string = xml_text2xmlChar(data);
+ 
+ 	/* Start up libxml and its parser (no-ops if already done) */
+ 	pg_xml_init();
+ 	xmlInitParser();
+ 
+ 	ctxt = xmlNewParserCtxt();
+ 	if (ctxt == NULL)
+ 		xml_ereport(ERROR, ERRCODE_OUT_OF_MEMORY,
+ 	could not allocate parser context);
+ 
+ 	PG_TRY();
+ 	{
+ 		size_t		count;
+ 		xmlChar*version = NULL;
+ 		int			standalone = -1;
+ 
+ 		res_code = parse_xml_decl(string, count, version, NULL, standalone);
+ 		if (res_code != 0)
+ 			xml_ereport_by_code(ERROR, 

Re: [HACKERS] gSoC - ADD MERGE COMMAND - code patch submission

2010-07-10 Thread David Fetter
On Sat, Jul 10, 2010 at 11:52:31AM +0200, Andres Freund wrote:
 On Fri, Jul 09, 2010 at 11:33:04PM -0400, Robert Haas wrote:
  On Fri, Jul 9, 2010 at 10:25 PM, Boxuan Zhai bxzhai2...@gmail.com wrote:
   Dear All,
  
   This is ZHAI BOXUAN, a student of gSoC 2010. My project is to add merge
   command in postgres.
   There is a more detailed instruction in readme.
 I would find it helpfull to find a short recap of how you want to
 handle the various problems (mostly around locking) in the readme.
 
   Any comments will be highly appreciated.
  Is there any chance you can submit this as a single patch file?  Or if
  not, can you at least use a zip or tar file instead of a RAR archive?
  Ideally the patch would be against CVS HEAD, not 8.4.3.
 
 I would also suggest you base your patch either against the git tree
 or CVS. Currently it does include patches agains generated files like
 gram.y or kwlist.h which make it harder to see the real changes.
 
 Thanks,
 Andres

Please find enclosed a patch against git master as of
7b2668159bb4d0f5177a23d05bf7c2ab00bc0d75.  It works up to make, but
fails on make check.

I'm thinking the docs for INSERT, UPDATE, and DELETE should link to
the docs for this, as they get written.

Cheers,
David.
-- 
David Fetter da...@fetter.org http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter  XMPP: david.fet...@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index e770e89..aad914c 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -2231,6 +2231,7 @@ _copyQuery(Query *from)
COPY_SCALAR_FIELD(querySource);
COPY_SCALAR_FIELD(canSetTag);
COPY_NODE_FIELD(utilityStmt);
+   COPY_NODE_FIELD(mergeActQry); //merge actions 
COPY_SCALAR_FIELD(resultRelation);
COPY_NODE_FIELD(intoClause);
COPY_SCALAR_FIELD(hasAggs);
@@ -2324,6 +2325,36 @@ _copySelectStmt(SelectStmt *from)
return newnode;
 }
 
+
+static MergeStmt *
+_copyMergeStmt(MergeStmt *from)
+{
+   MergeStmt *newnode = makeNode(MergeStmt);
+
+   COPY_NODE_FIELD(relation);
+   COPY_NODE_FIELD(source);
+   COPY_NODE_FIELD(matchCondition);
+   COPY_NODE_FIELD(actions);
+   
+   return newnode;
+   
+}
+
+
+static MergeConditionAction *
+_copyMergeConditionAction(MergeConditionAction *from)
+{
+   MergeConditionAction *newnode = makeNode(MergeConditionAction);
+
+   COPY_SCALAR_FIELD(match);
+   COPY_NODE_FIELD(condition);
+   COPY_NODE_FIELD(action);
+
+   return newnode;
+}
+
+
+
 static SetOperationStmt *
 _copySetOperationStmt(SetOperationStmt *from)
 {
@@ -4148,7 +4179,14 @@ copyObject(void *from)
case T_AlterTSConfigurationStmt:
retval = _copyAlterTSConfigurationStmt(from);
break;
+   case T_MergeStmt:
+   retval = _copyMergeStmt(from);
+   break;
 
+   
+   case T_MergeConditionAction:
+   retval = _copyMergeConditionAction(from);
+   break;
case T_A_Expr:
retval = _copyAExpr(from);
break;
@@ -4244,7 +4282,7 @@ copyObject(void *from)
break;
 
default:
-   elog(ERROR, unrecognized node type: %d, (int) 
nodeTag(from));
+   elog(ERROR, unrecognized node type: %d in copyObject() 
function, (int) nodeTag(from));
retval = from;  /* keep compiler quiet */
break;
}
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index 5d83727..8ab3247 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -855,6 +855,7 @@ _equalQuery(Query *a, Query *b)
COMPARE_SCALAR_FIELD(querySource);
COMPARE_SCALAR_FIELD(canSetTag);
COMPARE_NODE_FIELD(utilityStmt);
+   COMPARE_NODE_FIELD(mergeActQry);
COMPARE_SCALAR_FIELD(resultRelation);
COMPARE_NODE_FIELD(intoClause);
COMPARE_SCALAR_FIELD(hasAggs);
@@ -2933,7 +2934,7 @@ equal(void *a, void *b)
break;
 
default:
-   elog(ERROR, unrecognized node type: %d,
+   elog(ERROR, unrecognized node type: %d in equal() 
function,
 (int) nodeTag(a));
retval = false; /* keep compiler quiet */
break;
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index e7dae4b..357de31 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -1984,6 +1984,7 @@ 

Re: [HACKERS] gSoC - ADD MERGE COMMAND - code patch submission

2010-07-10 Thread Tom Lane
David Fetter da...@fetter.org writes:
 Please find enclosed a patch against git master as of
 7b2668159bb4d0f5177a23d05bf7c2ab00bc0d75.  It works up to make, but
 fails on make check.

There seem to be about four different comment styles used in this patch,
none of which match the project standard:
http://developer.postgresql.org/pgdocs/postgres/source-format.html

BTW, I notice that that page fails to mention anything about preferred
window width.  I believe the project standard is to make things readable
in an 80-column window --- anyone have an objection to stating that
explicitly?

regards, tom lane

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


Re: [HACKERS] gSoC - ADD MERGE COMMAND - code patch submission

2010-07-10 Thread Robert Haas
On Jul 10, 2010, at 11:45 AM, Tom Lane t...@sss.pgh.pa.us wrote:
 David Fetter da...@fetter.org writes:
 Please find enclosed a patch against git master as of
 7b2668159bb4d0f5177a23d05bf7c2ab00bc0d75.  It works up to make, but
 fails on make check.
 
 There seem to be about four different comment styles used in this patch,
 none of which match the project standard:
 http://developer.postgresql.org/pgdocs/postgres/source-format.html
 
 BTW, I notice that that page fails to mention anything about preferred
 window width.  I believe the project standard is to make things readable
 in an 80-column window --- anyone have an objection to stating that
 explicitly?

I certainly don't.

Though, if the worst problem with this patch is the formatting, we're doing 
*quite* well.

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


Re: [HACKERS] gSoC - ADD MERGE COMMAND - code patch submission

2010-07-10 Thread David Fetter
On Sat, Jul 10, 2010 at 09:26:38AM -0700, David Fetter wrote:
 On Sat, Jul 10, 2010 at 11:52:31AM +0200, Andres Freund wrote:
  On Fri, Jul 09, 2010 at 11:33:04PM -0400, Robert Haas wrote:
   On Fri, Jul 9, 2010 at 10:25 PM, Boxuan Zhai bxzhai2...@gmail.com wrote:
Dear All,
   
This is ZHAI BOXUAN, a student of gSoC 2010. My project is to add merge
command in postgres.
There is a more detailed instruction in readme.
  I would find it helpfull to find a short recap of how you want to
  handle the various problems (mostly around locking) in the readme.
  
Any comments will be highly appreciated.
   Is there any chance you can submit this as a single patch file?  Or if
   not, can you at least use a zip or tar file instead of a RAR archive?
   Ideally the patch would be against CVS HEAD, not 8.4.3.
  
  I would also suggest you base your patch either against the git tree
  or CVS. Currently it does include patches agains generated files like
  gram.y or kwlist.h which make it harder to see the real changes.
  
 Please find enclosed a patch against git master as of
 7b2668159bb4d0f5177a23d05bf7c2ab00bc0d75.  It works up to make, but
 fails on make check.
 
 I'm thinking the docs for INSERT, UPDATE, and DELETE should link to
 the docs for this, as they get written.
 
 Cheers,
 David.

Oops.  Just noticed that there were 56 lines' worth of C++ style
comments, which I've corrected in the enclosed patch, along with some
spelling mistakes, grammar, and gratuitous white space.

Cheers,
David.
-- 
David Fetter da...@fetter.org http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter  XMPP: david.fet...@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index e770e89..f72ebcf 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -2231,6 +2231,7 @@ _copyQuery(Query *from)
COPY_SCALAR_FIELD(querySource);
COPY_SCALAR_FIELD(canSetTag);
COPY_NODE_FIELD(utilityStmt);
+   COPY_NODE_FIELD(mergeActQry); /* merge actions */
COPY_SCALAR_FIELD(resultRelation);
COPY_NODE_FIELD(intoClause);
COPY_SCALAR_FIELD(hasAggs);
@@ -2324,6 +2325,36 @@ _copySelectStmt(SelectStmt *from)
return newnode;
 }
 
+
+static MergeStmt *
+_copyMergeStmt(MergeStmt *from)
+{
+   MergeStmt *newnode = makeNode(MergeStmt);
+
+   COPY_NODE_FIELD(relation);
+   COPY_NODE_FIELD(source);
+   COPY_NODE_FIELD(matchCondition);
+   COPY_NODE_FIELD(actions);
+
+   return newnode;
+
+}
+
+
+static MergeConditionAction *
+_copyMergeConditionAction(MergeConditionAction *from)
+{
+   MergeConditionAction *newnode = makeNode(MergeConditionAction);
+
+   COPY_SCALAR_FIELD(match);
+   COPY_NODE_FIELD(condition);
+   COPY_NODE_FIELD(action);
+
+   return newnode;
+}
+
+
+
 static SetOperationStmt *
 _copySetOperationStmt(SetOperationStmt *from)
 {
@@ -4148,7 +4179,14 @@ copyObject(void *from)
case T_AlterTSConfigurationStmt:
retval = _copyAlterTSConfigurationStmt(from);
break;
+   case T_MergeStmt:
+   retval = _copyMergeStmt(from);
+   break;
 
+
+   case T_MergeConditionAction:
+   retval = _copyMergeConditionAction(from);
+   break;
case T_A_Expr:
retval = _copyAExpr(from);
break;
@@ -4244,7 +4282,7 @@ copyObject(void *from)
break;
 
default:
-   elog(ERROR, unrecognized node type: %d, (int) 
nodeTag(from));
+   elog(ERROR, unrecognized node type: %d in copyObject() 
function, (int) nodeTag(from));
retval = from;  /* keep compiler quiet */
break;
}
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index 5d83727..8ab3247 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -855,6 +855,7 @@ _equalQuery(Query *a, Query *b)
COMPARE_SCALAR_FIELD(querySource);
COMPARE_SCALAR_FIELD(canSetTag);
COMPARE_NODE_FIELD(utilityStmt);
+   COMPARE_NODE_FIELD(mergeActQry);
COMPARE_SCALAR_FIELD(resultRelation);
COMPARE_NODE_FIELD(intoClause);
COMPARE_SCALAR_FIELD(hasAggs);
@@ -2933,7 +2934,7 @@ equal(void *a, void *b)
break;
 
default:
-   elog(ERROR, unrecognized node type: %d,
+   elog(ERROR, unrecognized node type: %d in equal() 
function,
 (int) nodeTag(a));
retval = false; /* keep compiler 

Re: [HACKERS] gSoC - ADD MERGE COMMAND - code patch submission

2010-07-10 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes:
 Though, if the worst problem with this patch is the formatting, we're doing 
 *quite* well.

Well, the worst problem with it is that it hasn't touched the
interesting part, ie, what happens at execution time.  I haven't
seen a design for that, which means it's impossible to evaluate
whether the code that is here is of any use.  We might need some
other representation entirely.

BTW, Fetter's version of the patch seems to be lacking any gram.y
changes, but surely those exist already?

regards, tom lane

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


Re: [HACKERS] gSoC - ADD MERGE COMMAND - code patch submission

2010-07-10 Thread David Fetter
On Sat, Jul 10, 2010 at 01:18:49PM -0400, Tom Lane wrote:
 Robert Haas robertmh...@gmail.com writes:
  Though, if the worst problem with this patch is the formatting, we're doing 
  *quite* well.
 
 Well, the worst problem with it is that it hasn't touched the
 interesting part, ie, what happens at execution time.  I haven't
 seen a design for that, which means it's impossible to evaluate
 whether the code that is here is of any use.  We might need some
 other representation entirely.
 
 BTW, Fetter's version of the patch seems to be lacking any gram.y
 changes, but surely those exist already?

Oops.

Fixed that now in attached patch.

Cheers,
David.
-- 
David Fetter da...@fetter.org http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter  XMPP: david.fet...@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index e770e89..f72ebcf 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -2231,6 +2231,7 @@ _copyQuery(Query *from)
COPY_SCALAR_FIELD(querySource);
COPY_SCALAR_FIELD(canSetTag);
COPY_NODE_FIELD(utilityStmt);
+   COPY_NODE_FIELD(mergeActQry); /* merge actions */
COPY_SCALAR_FIELD(resultRelation);
COPY_NODE_FIELD(intoClause);
COPY_SCALAR_FIELD(hasAggs);
@@ -2324,6 +2325,36 @@ _copySelectStmt(SelectStmt *from)
return newnode;
 }
 
+
+static MergeStmt *
+_copyMergeStmt(MergeStmt *from)
+{
+   MergeStmt *newnode = makeNode(MergeStmt);
+
+   COPY_NODE_FIELD(relation);
+   COPY_NODE_FIELD(source);
+   COPY_NODE_FIELD(matchCondition);
+   COPY_NODE_FIELD(actions);
+
+   return newnode;
+
+}
+
+
+static MergeConditionAction *
+_copyMergeConditionAction(MergeConditionAction *from)
+{
+   MergeConditionAction *newnode = makeNode(MergeConditionAction);
+
+   COPY_SCALAR_FIELD(match);
+   COPY_NODE_FIELD(condition);
+   COPY_NODE_FIELD(action);
+
+   return newnode;
+}
+
+
+
 static SetOperationStmt *
 _copySetOperationStmt(SetOperationStmt *from)
 {
@@ -4148,7 +4179,14 @@ copyObject(void *from)
case T_AlterTSConfigurationStmt:
retval = _copyAlterTSConfigurationStmt(from);
break;
+   case T_MergeStmt:
+   retval = _copyMergeStmt(from);
+   break;
 
+
+   case T_MergeConditionAction:
+   retval = _copyMergeConditionAction(from);
+   break;
case T_A_Expr:
retval = _copyAExpr(from);
break;
@@ -4244,7 +4282,7 @@ copyObject(void *from)
break;
 
default:
-   elog(ERROR, unrecognized node type: %d, (int) 
nodeTag(from));
+   elog(ERROR, unrecognized node type: %d in copyObject() 
function, (int) nodeTag(from));
retval = from;  /* keep compiler quiet */
break;
}
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index 5d83727..8ab3247 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -855,6 +855,7 @@ _equalQuery(Query *a, Query *b)
COMPARE_SCALAR_FIELD(querySource);
COMPARE_SCALAR_FIELD(canSetTag);
COMPARE_NODE_FIELD(utilityStmt);
+   COMPARE_NODE_FIELD(mergeActQry);
COMPARE_SCALAR_FIELD(resultRelation);
COMPARE_NODE_FIELD(intoClause);
COMPARE_SCALAR_FIELD(hasAggs);
@@ -2933,7 +2934,7 @@ equal(void *a, void *b)
break;
 
default:
-   elog(ERROR, unrecognized node type: %d,
+   elog(ERROR, unrecognized node type: %d in equal() 
function,
 (int) nodeTag(a));
retval = false; /* keep compiler quiet */
break;
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index e7dae4b..b65dc58 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -1984,6 +1984,7 @@ _outQuery(StringInfo str, Query *node)
else
appendStringInfo(str,  :utilityStmt );
 
+   WRITE_NODE_FIELD(mergeActQry);
WRITE_INT_FIELD(resultRelation);
WRITE_NODE_FIELD(intoClause);
WRITE_BOOL_FIELD(hasAggs);
@@ -2439,6 +2440,46 @@ _outConstraint(StringInfo str, Constraint *node)
 }
 
 
+
+
+static void
+_outMergeConditionAction(StringInfo str, MergeConditionAction *node)
+{
+   WRITE_NODE_TYPE(MERGECONDITIONACTION);
+
+   WRITE_BOOL_FIELD(match);
+
+   WRITE_NODE_FIELD(condition);
+   WRITE_NODE_FIELD(action);
+
+
+}
+
+static void
+_outMergeStmt(StringInfo 

Re: [HACKERS] gSoC - ADD MERGE COMMAND - code patch submission

2010-07-10 Thread David Fetter
On Sat, Jul 10, 2010 at 10:39:02AM -0700, David Fetter wrote:
 On Sat, Jul 10, 2010 at 01:18:49PM -0400, Tom Lane wrote:
  Robert Haas robertmh...@gmail.com writes:
   Though, if the worst problem with this patch is the formatting, we're 
   doing *quite* well.
  
  Well, the worst problem with it is that it hasn't touched the
  interesting part, ie, what happens at execution time.  I haven't
  seen a design for that, which means it's impossible to evaluate
  whether the code that is here is of any use.  We might need some
  other representation entirely.
  
  BTW, Fetter's version of the patch seems to be lacking any gram.y
  changes, but surely those exist already?
 
 Oops.
 
 Fixed that now in attached patch.

By the way, make check fails here with attached initdb.log:

./pg_regress --inputdir=. --dlpath=. --multibyte=SQL_ASCII  
--temp-install=./tmp_check --top-builddir=../../.. 
--schedule=./parallel_schedule  
== creating temporary installation==
== initializing database system   ==

pg_regress: initdb failed
Examine /home/shackle/pggit/postgresql/src/test/regress/log/initdb.log for the 
reason.
Command was: 
/home/shackle/pggit/postgresql/src/test/regress/./tmp_check/install//home/shackle/tip/bin/initdb
 -D /home/shackle/pggit/postgresql/src/test/regress/./tmp_check/data -L 
/home/shackle/pggit/postgresql/src/test/regress/./tmp_check/install//home/shackle/tip/share/postgresql
 --noclean  /home/shackle/pggit/postgresql/src/test/regress/log/initdb.log 
21
make[2]: *** [check] Error 2
make[2]: Leaving directory `/home/shackle/pggit/postgresql/src/test/regress'
make[1]: *** [check] Error 2
make[1]: Leaving directory `/home/shackle/pggit/postgresql/src/test'
make: *** [check] Error 2

Cheers,
David.
-- 
David Fetter da...@fetter.org http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter  XMPP: david.fet...@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate
Running in noclean mode.  Mistakes will not be cleaned up.
The files belonging to this database system will be owned by user shackle.
This user must also own the server process.

The database cluster will be initialized with locales
  COLLATE:  en_US.utf8
  CTYPE:en_US.utf8
  MESSAGES: C
  MONETARY: en_US.utf8
  NUMERIC:  en_US.utf8
  TIME: en_US.utf8
The default database encoding has accordingly been set to UTF8.
The default text search configuration will be set to english.

creating directory 
/home/shackle/pggit/postgresql/src/test/regress/./tmp_check/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
creating template1 database in 
/home/shackle/pggit/postgresql/src/test/regress/./tmp_check/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... FATAL:  unrecognized token: false
STATEMENT:  /*
 * PostgreSQL System Views
 *
 * Copyright (c) 1996-2010, PostgreSQL Global Development Group
 *
 * $PostgreSQL$
 */

CREATE VIEW pg_roles AS 
SELECT 
rolname,
rolsuper,
rolinherit,
rolcreaterole,
rolcreatedb,
rolcatupdate,
rolcanlogin,
rolconnlimit,
''::text as rolpassword,
rolvaliduntil,
setconfig as rolconfig,
pg_authid.oid
FROM pg_authid LEFT JOIN pg_db_role_setting s
ON (pg_authid.oid = setrole AND setdatabase = 0);

CREATE VIEW pg_shadow AS
SELECT
rolname AS usename,
pg_authid.oid AS usesysid,
rolcreatedb AS usecreatedb,
rolsuper AS usesuper,
rolcatupdate AS usecatupd,
rolpassword AS passwd,
rolvaliduntil::abstime AS valuntil,
setconfig AS useconfig
FROM pg_authid LEFT JOIN pg_db_role_setting s
ON (pg_authid.oid = setrole AND setdatabase = 0)
WHERE rolcanlogin;

REVOKE ALL on pg_shadow FROM public;

CREATE VIEW pg_group AS
SELECT
rolname AS groname,
oid AS grosysid,
ARRAY(SELECT member FROM pg_auth_members WHERE roleid = oid) AS 
grolist
FROM pg_authid
WHERE NOT rolcanlogin;

CREATE VIEW pg_user AS 
SELECT 
usename, 
usesysid, 
usecreatedb, 
usesuper, 
usecatupd, 
''::text as passwd, 
valuntil, 
useconfig 
   

Re: [HACKERS] gSoC - ADD MERGE COMMAND - code patch submission

2010-07-10 Thread Tom Lane
David Fetter da...@fetter.org writes:
 By the way, make check fails here with attached initdb.log:

 creating system views ... FATAL:  unrecognized token: false

Hm, I'd suspect something fouled up in keyword recognition.
Did you do a make clean and rebuild?

BTW, this patch is still a few bricks shy of a load, since there's no
kwlist.h change and so the new MERGE keyword couldn't possibly be
recognized.  More generally, I'm wondering why the original .rar
submission was 300k (presumably compressed) and your diff is only
about 35k ...

regards, tom lane

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


Re: [HACKERS] gSoC - ADD MERGE COMMAND - code patch submission

2010-07-10 Thread Peter Eisentraut
On lör, 2010-07-10 at 09:26 -0700, David Fetter wrote:
 Please find enclosed a patch against git master as of
 7b2668159bb4d0f5177a23d05bf7c2ab00bc0d75.  It works up to make, but
 fails on make check.

It looks like this implementation reaches about the same level of parser
support as the stuff that I had coded up a few months ago at the airport
within a couple of hours [0][1], and I had sent the student the code, so
he could have had that for free.

But as others had commented already, the meat of the problem is how
MERGE statement *execution* is supposed to work.

[0]
http://git.postgresql.org/gitweb?p=users/petere/postgresql.git;a=shortlog;h=refs/heads/merge-statement
[1] http://petereisentraut.blogspot.com/2010/05/merge-syntax.html


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


Re: [HACKERS] gSoC - ADD MERGE COMMAND - code patch submission

2010-07-10 Thread David Fetter
On Sat, Jul 10, 2010 at 01:53:53PM -0400, Tom Lane wrote:
 David Fetter da...@fetter.org writes:
  By the way, make check fails here with attached initdb.log:
 
  creating system views ... FATAL:  unrecognized token: false
 
 Hm, I'd suspect something fouled up in keyword recognition.  Did you
 do a make clean and rebuild?

I did make maintainer-clean.

 BTW, this patch is still a few bricks shy of a load, since there's
 no kwlist.h change and so the new MERGE keyword couldn't possibly be
 recognized.  More generally, I'm wondering why the original .rar
 submission was 300k (presumably compressed) and your diff is only
 about 35k ...

I'll look into that.  From what you can see, is it worth trying to
clean up, starting from base, or should we just wait for the next
revision of the patch?

Cheers,
David.
-- 
David Fetter da...@fetter.org http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter  XMPP: david.fet...@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

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

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


Re: [HACKERS] ALTER TABLE SET STATISTICS requires AccessExclusiveLock

2010-07-10 Thread Bruce Momjian
Robert Haas wrote:
 On Wed, Jul 7, 2010 at 9:04 PM, C?dric Villemain
 cedric.villemain.deb...@gmail.com wrote:
   I assume this did not get done for 9.0. ?Do we want a TODO item?
 
  Yes.
 
  Added:
 
  ? ? ? ?Reduce locking required for ALTER commands
 
  I just faced production issue where it is impossible to alter table to
  adjust autovacuum settings in a pg8.4. (5K tps, 260M rows table, lock
  too much)
 
  Can we add some mechanism to prevent that situation also in the TODO item ?
 
  (alternative is actualy to alter other tables and adjust the
  postgresql.conf for biggest tables, but not an ideal solution anyway)
 
 
  ? ? ? ? ? ?* 
  http://archives.postgresql.org/pgsql-hackers/2009-08/msg00533.php
  ? ? ? ? ? ?* 
  http://archives.postgresql.org/pgsql-hackers/2009-10/msg01083.php
  ? ? ? ? ? ?* 
  http://archives.postgresql.org/pgsql-hackers/2010-01/msg02349.php
 
 Bruce, that last link is about something else completely.  Here are
 some better ones:
 
 http://archives.postgresql.org/pgsql-hackers/2008-10/msg01248.php
 http://archives.postgresql.org/pgsql-hackers/2008-10/msg00242.php

Thanks, TODO updated.

-- 
  Bruce Momjian  br...@momjian.ushttp://momjian.us
  EnterpriseDB http://enterprisedb.com

  + None of us is going to be here forever. +

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


[HACKERS] Re: [COMMITTERS] pgsql: Add support for TCP keepalives on Windows, both for backend and

2010-07-10 Thread Bruce Momjian
Magnus Hagander wrote:
  An easy approximation would be to make the code #ifdef SIO_KEEPALIVE_VALS.
  That would fail if the mingw guys decide to provide the #define without
  adding the struct at the same time, but that seems moderately unlikely.
 
 Seems reasonable. I'll go do something along that line and verify that
 it actually works :-)
 
 That laves the questions of docs - right now the docs just say it
 works on windows. I guess we need to add some kind of disclaimer
 around that, but the fact is that for 99+% of our windows users it
 will work - since they use the binaries, and the binaries are built
 with the full api - so we shouldn't make it *too* prominent..

Wow, how would they know if the binaries are MinGW compiled?  Does it
show in version()?

-- 
  Bruce Momjian  br...@momjian.ushttp://momjian.us
  EnterpriseDB http://enterprisedb.com

  + None of us is going to be here forever. +

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


Re: [HACKERS] gSoC - ADD MERGE COMMAND - code patch submission

2010-07-10 Thread Tom Lane
David Fetter da...@fetter.org writes:
 On Sat, Jul 10, 2010 at 01:53:53PM -0400, Tom Lane wrote:
 BTW, this patch is still a few bricks shy of a load, since there's
 no kwlist.h change and so the new MERGE keyword couldn't possibly be
 recognized.  More generally, I'm wondering why the original .rar
 submission was 300k (presumably compressed) and your diff is only
 about 35k ...

 I'll look into that.  From what you can see, is it worth trying to
 clean up, starting from base, or should we just wait for the next
 revision of the patch?

Well, rebasing against HEAD will presumably help the submitter
(assuming that he takes the advice to work against HEAD not 8.4.x).
But really what we need to see is design documentation, not code.

regards, tom lane

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


Re: [HACKERS] Re: [COMMITTERS] pgsql: Add support for TCP keepalives on Windows, both for backend and

2010-07-10 Thread Tom Lane
Bruce Momjian br...@momjian.us writes:
 Magnus Hagander wrote:
 That laves the questions of docs - right now the docs just say it
 works on windows. I guess we need to add some kind of disclaimer
 around that, but the fact is that for 99+% of our windows users it
 will work - since they use the binaries, and the binaries are built
 with the full api - so we shouldn't make it *too* prominent..

 Wow, how would they know if the binaries are MinGW compiled?  Does it
 show in version()?

AFAIK there is nobody distributing mingw-built binaries.  If somebody
has one, they'd have built it themselves, and they'd know.

regards, tom lane

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


Re: [HACKERS] Re: [COMMITTERS] pgsql: Add support for TCP keepalives on Windows, both for backend and

2010-07-10 Thread Peter Eisentraut
On lör, 2010-07-10 at 16:23 -0400, Bruce Momjian wrote:
 Wow, how would they know if the binaries are MinGW compiled?  Does it
 show in version()?

Yes, I think so.


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


Re: [HACKERS] gSoC - ADD MERGE COMMAND - code patch submission

2010-07-10 Thread Andrew Dunstan



Tom Lane wrote:

BTW, I notice that that page fails to mention anything about preferred
window width.  I believe the project standard is to make things readable
in an 80-column window --- anyone have an objection to stating that
explicitly?


  


No, on the contrary, I'm in favor of stating it.

cheers

andrew

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


Re: [HACKERS] LLVM / clang

2010-07-10 Thread Peter Eisentraut
On fre, 2010-06-11 at 07:00 +0300, Peter Eisentraut wrote:
 The second problem is that the prototype check for accept() fails.
 This
 is because glibc defines the second argument to be a transparent
 union, apparently to make it look like a lot of things at once.
 clang
 apparently doesn't understand that.  One could address this by
 checking
 for the typedef that glibc uses explicitly in the configure check, but
 that would appear to defeat the point of the *transparent* union.  A
 workaround is to remove -D_GNU_SOURCE from src/template/linux.

For the record, there is already a bug report about this:
http://llvm.org/bugs/show_bug.cgi?id=5365


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


Re: [HACKERS] gSoC - ADD MERGE COMMAND - code patch submission

2010-07-10 Thread Peter Eisentraut
On lör, 2010-07-10 at 12:45 -0400, Tom Lane wrote:
 I believe the project standard is to make things readable
 in an 80-column window --- anyone have an objection to stating that
 explicitly?

Is that what pgindent reformats it to?


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


Re: [HACKERS] gSoC - ADD MERGE COMMAND - code patch submission

2010-07-10 Thread Tom Lane
Peter Eisentraut pete...@gmx.net writes:
 On lör, 2010-07-10 at 12:45 -0400, Tom Lane wrote:
 I believe the project standard is to make things readable
 in an 80-column window --- anyone have an objection to stating that
 explicitly?

 Is that what pgindent reformats it to?

pgindent tries to leave a character or two to spare, IIRC, so its target
is probably 78 or thereabouts.

regards, tom lane

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


Re: [HACKERS] patch (for 9.1) string functions

2010-07-10 Thread Erik Rijkers
contrib/stringfunc was missing this small change in contrib/Makefile, I think.  
With it, it
installs and runs make check cleanly.


Erik Rijkers



stringfunc_fix.diff
Description: Binary data

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