[PATCHES] SQL/XML publishing function experimental patch

2005-09-12 Thread Pavel Stehule

Hello

This patch contains SQL/XML public function XMLFOREST, XMLELEMENT, ... based 
on CString type. This patch hasn't high quality, but can be usefull for 
testing funcionality, and maybe for some people. Patch needs initdb and 
following registration:


CREATE AGGREGATE pg_catalog.fast_cstring_concat (
BASETYPE = cstring,
SFUNC = xmlagg_trans,
STYPE = text,
FINALFUNC = xmlagg_final);

I invite all notes, ..

Best regards
Pavel Stehule

_
Chcete sdilet sve obrazky a hudbu s prateli? http://messenger.msn.cz/
diff -c -r pgsql.clean/src/backend/executor/execQual.c pgsql2/src/backend/executor/execQual.c
*** pgsql.clean/src/backend/executor/execQual.c	2005-06-27 00:05:36.0 +0200
--- pgsql2/src/backend/executor/execQual.c	2005-09-05 17:41:48.0 +0200
***
*** 53,59 
  #include utils/lsyscache.h
  #include utils/memutils.h
  #include utils/typcache.h
! 
  
  /* static function decls */
  static Datum ExecEvalArrayRef(ArrayRefExprState *astate,
--- 53,60 
  #include utils/lsyscache.h
  #include utils/memutils.h
  #include utils/typcache.h
! #include lib/stringinfo.h 
! #include string.h
  
  /* static function decls */
  static Datum ExecEvalArrayRef(ArrayRefExprState *astate,
***
*** 111,116 
--- 112,119 
  static Datum ExecEvalNullIf(FuncExprState *nullIfExpr,
  			   ExprContext *econtext,
  			   bool *isNull, ExprDoneCond *isDone);
+ static Datum ExecEvalXml(XmlExprState *xmlExpr, ExprContext *econtext,
+ 			bool *isNull, ExprDoneCond *isDone);
  static Datum ExecEvalNullTest(GenericExprState *nstate,
   ExprContext *econtext,
   bool *isNull, ExprDoneCond *isDone);
***
*** 218,223 
--- 221,228 
   * have to know the difference (that's what they need refattrlength for).
   *--
   */
+  
+ 
  static Datum
  ExecEvalArrayRef(ArrayRefExprState *astate,
   ExprContext *econtext,
***
*** 2304,2312 
  		}
  	}
  
! 	return result;
  }
  
  /* 
   *		ExecEvalNullIf
   *
--- 2309,2498 
  		}
  	}
  
!  	return result;
! }
! 
! /* 
!  *		ExecEvalXml
!  * 
!  */
!  
! static char *
! getXmlParam(XmlParams *params, XmlParamOp op)
! {
! 	if (params == NULL)
! 		return NULL;
! 	switch (op)
! 	{
! 		case IS_XMLNAME:
! 			return params-name;
! 		case IS_XMLVERSION:
! 			return params-version;
! 		case IS_XMLENCODING:
! 			return params-encoding;
! 		case IS_XMLSTANDALONE:
! 			return params-standalone;
! 	}
! 	return NULL;
! }
! 
! static Datum ExecEvalXml(XmlExprState *xmlExpr, ExprContext *econtext,
! 			bool *isNull, ExprDoneCond *isDone)
! {
! 	StringInfoData buf;
! 	bool isnull;
! 	ListCell *arg;
! 	
! 	initStringInfo(buf);
! 	
! 	*isNull = false;
! 	
! 	if (isDone)
! 		*isDone = ExprSingleResult;
! 
! 
! 	switch (xmlExpr-op)
! 	{
! 		case IS_XMLCONCAT:
! 			{
! *isNull = true;
! foreach(arg, xmlExpr-xml_args)
! {
! 	ExprState  *e = (ExprState *) lfirst(arg);
! 	Datum value = ExecEvalExpr(e, econtext, isnull, NULL);
! 	if (!isnull)
! 	{
! 		appendStringInfo(buf, %s,  (char *)value);
! 		*isNull = false;
! 	}
! }
! 			}
! 			break;
! 		case IS_XMLELEMENT:
! 			{
! appendStringInfo(buf, %s,  getXmlParam(xmlExpr-params, IS_XMLNAME));
! int state = 0;
! int i = 0;
! foreach(arg, xmlExpr-nargs)
! {
! 		GenericExprState *gstate = (GenericExprState *) lfirst(arg);
! 		Datum value = ExecEvalExpr(gstate-arg, econtext, isnull, NULL);
! 		if (!isnull)
! 		{
! 			char *outstr = DatumGetCString(OidFunctionCall1(xmlExpr-nargs_tcache[i], value));
! 			appendStringInfo(buf,  %s=\%s\, xmlExpr-nargs_ncache[i], outstr);
! 			pfree(outstr);
! 		}
! 		i += 1;		
! }
! foreach(arg, xmlExpr-xml_args)
! {
! 	ExprState  *e = (ExprState *) lfirst(arg);
! 	Datum value = ExecEvalExpr(e, econtext, isnull, NULL);
! 	if (!isnull)
! 	{
! 		if (state == 0)
! 		{
! 			appendStringInfo(buf, );
! 			state = 1;
! 		}	
! 		appendStringInfo(buf, %s,  (char *)value);
! 	}
! }
! if (xmlExpr-args)
! {
! 	ExprState *expr = linitial(xmlExpr-args);
! 	Datum value = ExecEvalExpr(expr, econtext, isnull, NULL);
! 
! 	if (!isnull)
! 	{
! 		char *outstr = DatumGetCString(OidFunctionCall1(xmlExpr-arg_typeId, value));
! 		if (state == 0)
! 		{
! 			appendStringInfoChar(buf, '');
! 			state = 1;
! 		}
! 		

Re: [PATCHES] [INTERFACES] [HACKERS] ECPG ignores SAVEPOINT if first statement of a transaction

2005-09-12 Thread Michael Meskes
On Sat, Aug 13, 2005 at 09:01:45AM -0600, Michael Fuhr wrote:
 If no statements have been executed in this transaction then committed
 is true, so ECPGtrans() ignores the current statement.  It looks
 like the code should make an extra consideration for SAVEPOINT in
 case it's the first statement.

I rearranged the whole code as it seemed to have more holes. This code
really was old. :-)

So could you please check with the lates CVS, either HEAD or 8.0?

 I'm also wondering if the check for a NULL return value from PQexec()
 is sufficient.  Shouldn't it also check for a non-NULL result that's
 anything other than PGRES_COMMAND_OK?

Yes, it should. I changed this as well.

Michael
-- 
Michael Meskes
Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: [EMAIL PROTECTED]
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!

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

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


Re: [PATCHES] SQL/XML publishing function experimental patch

2005-09-12 Thread Tom Lane
Pavel Stehule [EMAIL PROTECTED] writes:
 This patch contains SQL/XML public function XMLFOREST, XMLELEMENT, ... based 
 on CString type. This patch hasn't high quality, but can be usefull for 
 testing funcionality, and maybe for some people.

1. Why did you base the datatype on cstring?  That's inappropriate for
anything except guaranteed-short strings, because it's not toastable.

2. Is it really necessary to hack up the grammar for this?  Seems like
you should create ordinary functions to manipulate the datatype(s).
If every datatype thought it could do this sort of thing, we'd have
a completely unmanageable grammar.

regards, tom lane

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

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


Re: [PATCHES] SQL/XML publishing function experimental patch

2005-09-12 Thread Peter Eisentraut
Am Montag, 12. September 2005 16:05 schrieb Tom Lane:
 2. Is it really necessary to hack up the grammar for this?

Yes, because the syntax defined in the SQL standard is completely weird.

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/

---(end of broadcast)---
TIP 4: Have you searched our list archives?

   http://archives.postgresql.org


[PATCHES] Autovacuum docs

2005-09-12 Thread Alvaro Herrera
Hackers,

I have prepared some docs for autovacuum.  I attach the patch.  Comments
on grammar, style etc. are welcome.

I will not apply it yet because it conflicts with Neil's runtime-config
restructuring, so I'll wait until he applies his patch.

-- 
Alvaro Herrera -- Valdivia, Chile Architect, www.EnterpriseDB.com
www.google.com: interfaz de lĂ­nea de comando para la web.
Index: catalogs.sgml
===
RCS file: /home/alvherre/cvs/pgsql/doc/src/sgml/catalogs.sgml,v
retrieving revision 2.113
diff -c -r2.113 catalogs.sgml
*** catalogs.sgml   8 Sep 2005 20:07:41 -   2.113
--- catalogs.sgml   12 Sep 2005 13:56:35 -
***
*** 1137,1145 
 primarypg_autovacuum/primary
/indexterm
  
para
 The catalog structnamepg_autovacuum/structname stores optional
!per-relation configuration parameters for quoteautovacuum/.
 If there is an entry here for a particular relation, the given
 parameters will be used for autovacuuming that table.  If no entry
 is present, the system-wide defaults will be used.
--- 1137,1150 
 primarypg_autovacuum/primary
/indexterm
  
+   indexterm zone=catalog-pg-autovacuum
+primaryautovacuum/primary
+secondarytable-specific configuration/secondary
+   /indexterm
+ 
para
 The catalog structnamepg_autovacuum/structname stores optional
!per-relation configuration parameters for xref linkend=autovacuum 
endterm=autovacuum-title.
 If there is an entry here for a particular relation, the given
 parameters will be used for autovacuuming that table.  If no entry
 is present, the system-wide defaults will be used.
Index: maintenance.sgml
===
RCS file: /home/alvherre/cvs/pgsql/doc/src/sgml/maintenance.sgml,v
retrieving revision 1.45
diff -c -r1.45 maintenance.sgml
*** maintenance.sgml22 Jun 2005 21:14:28 -  1.45
--- maintenance.sgml12 Sep 2005 14:10:17 -
***
*** 99,104 
--- 99,110 
 xref linkend=runtime-config-resource-vacuum-cost.
/para
  
+   para
+An automated mechanism for performing the necessary commandVACUUM/
+operations has been added in productnamePostgreSQL/productname 8.1.
+See xref linkend=autovacuum endterm=autovacuum-title.
+   /para
+ 
sect2 id=vacuum-for-space-recovery
 titleRecovering disk space/title
  
***
*** 177,189 
  the program filenamevacuumdb/ may be helpful.
 /para
  
-tip
- para
-  The filenamecontrib/pg_autovacuum/ program can be useful for
-  automating high-frequency vacuuming operations.
- /para
-/tip
- 
 para
  commandVACUUM FULL/ is recommended for cases where you know
  you have deleted the majority of rows in a table, so that the
--- 183,188 
***
*** 456,461 
--- 455,551 
  /para
 /warning
/sect2
+ 
+   sect2 id=autovacuum
+title id=autovacuum-titleThe Auto-Vacuum Daemon/title
+ 
+indexterm
+ primaryautovacuum/primary
+ secondarygeneral information/secondary
+/indexterm
+para
+ Beginning in productnamePostgreSQL /productname 8.1, there is a
+ separate optional server process called the firsttermautovacuum
+ daemon/firstterm, whose purpose is to automate the issuance of
+ commandVACUUM/command and commandANALYZE /command commands.
+ When enabled, the autovacuum daemon runs periodically and checks for
+ tables that have had a large number of inserted, updated or deleted
+ tuples.  These checks use the row-level statistics collection facility;
+ therefore, the autovacuum daemon cannot be used unless xref
+ linkend=guc-stats-start-collector and xref
+ linkend=guc-stats-row-level are set literaltrue/literal.  Also, 
it's
+ important to allow a slot for the autovacuum process when choosing the
+ value of xref linkend=guc-superuser-reserved-connections.
+/para
+ 
+para
+ The autovacuum daemon, when enabled, runs every xref
+ linkend=guc-autovacuum-naptime seconds and determines which database
+ to process.  Any database which is close to transaction ID wraparound
+ is immediately processed.  In this case, autovacuum issues a
+ database-wide commandVACUUM/command call, or commandVACUUM
+ FREEZE/command if it's a template database, and then terminates.  If
+ no database fulfills this criterion, the one that was least recently
+ processed by autovacuum itself is chosen.  In this mode, each table in
+ the database is checked for new and obsolete tuples, according to the
+ applicable autovacuum parameters.  If a link 
linkend=catalog-pg-autovacuum
+ structnamepg_autovacuum/structname/link tuple is found for this
+ table, these settings are applied; otherwise the global values in
+ filenamepostgresql.conf/filename are used.  See xref 

Re: [PATCHES] Autovacuum docs

2005-09-12 Thread Peter Eisentraut
Alvaro Herrera wrote:
 I have prepared some docs for autovacuum.  I attach the patch. 
 Comments on grammar, style etc. are welcome.

Looks very good to me.

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/

---(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


Re: [PATCHES] SQL/XML publishing function experimental patch

2005-09-12 Thread Pavel Stehule

1. Why did you base the datatype on cstring?  That's inappropriate for
anything except guaranteed-short strings, because it's not toastable.



It's only my laziness. I can adapt patch for TEXT. It's only temporary 
solution. The goal is true xml type.



2. Is it really necessary to hack up the grammar for this?  Seems like
you should create ordinary functions to manipulate the datatype(s).
If every datatype thought it could do this sort of thing, we'd have
a completely unmanageable grammar.

regards, tom lane


I prefere any general solution. But there isn't. I hope SQL/XML syntax is 
exception and the solution SQL/XML function is relative clean. There was 
ideas about pretranslators from different syntaxs. Is this idea dead?


regards
Pavel Stehule

_
Emotikony a pozadi programu MSN Messenger ozivi vasi konverzaci. 
http://messenger.msn.cz/



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


Re: [PATCHES] docs: config chapter

2005-09-12 Thread Neil Conway

Peter Eisentraut wrote:

Moreover, I don't agree with the premise.


This patch is blocking other work. If you still object to it, can you 
elaborate why?


Otherwise I'll apply it this evening (EST).

-Neil

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

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


Re: [PATCHES] pg_dump feature patch to allow selection of rows to

2005-09-12 Thread Neil Conway

Seth Robertson wrote:

In order to support some automation, I needed the ability to pull out
subsets of postgres tables in a format which could be loaded into
other postgres databases.


One alternative would be using CREATE TABLE AS to create a separate 
table containing the desired subset, and then using pg_dump to dump that 
table.



Instead of writing a utility to replicate the functionality in
pg_dump, I created a new flag, --where, which allows you to postpend
where (or order or limit or whatever) sql fragments at the end of the
select done by pg_dump.


Neat, but IMHO too much of a kludge for mainline.

-Neil

---(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


Re: [PATCHES] SPI_getbinval() documentation correction

2005-09-12 Thread Neil Conway

Michael Fuhr wrote:

The synopsis for SPI_getbinval() shows the third argument being
colnumber but in the Arguments section it appears as rownumber.
This patch corrects that.


Thanks for the patch -- applied to HEAD, 8.0, and 7.4

-Neil

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


Re: [PATCHES] pg_dump feature patch to allow selection of rows to

2005-09-12 Thread Tom Lane
Neil Conway [EMAIL PROTECTED] writes:
 Seth Robertson wrote:
 Instead of writing a utility to replicate the functionality in
 pg_dump, I created a new flag, --where, which allows you to postpend
 where (or order or limit or whatever) sql fragments at the end of the
 select done by pg_dump.

 Neat, but IMHO too much of a kludge for mainline.

Yeah, I felt the same --- the fact that it doesn't work for the normal
COPY case renders it a bit too ugly.

regards, tom lane

---(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


Re: [PATCHES] Autovacuum docs

2005-09-12 Thread Tom Lane
Alvaro Herrera [EMAIL PROTECTED] writes:
 I have prepared some docs for autovacuum.  I attach the patch.  Comments
 on grammar, style etc. are welcome.

A few piddling suggestions:

 +See xref linkend=autovacuum endterm=autovacuum-title.

I think we mostly don't use endterm on cross-references to sections.
Not sure if that's a project standard, or just laziness, though.
(Peter?)

 +   sect2 id=autovacuum
 +title id=autovacuum-titleThe Auto-Vacuum Daemon/title

The other sect2 titles in this chapter capitalize only the first word.
Again, I'm not sure how fully that convention is followed, but I think
this would look better as The auto-vacuum daemon.

 + for more details on the global settings.  Note that the autovacuum
 + daemon can be instructed to skip particular tables, by setting the
 + structnamepg_autovacuum/.structfieldenabled/ field to 
 literalfalse/literal.
 +/para

This note seems a bit awkwardly placed.  I'd drop it and instead add
enabled to the list of additional pg_autovacuum parameters here:

 + Additionally to the base threshold values and scale factors, there are
 + two parameters that can be set for each table in 
 structnamepg_autovacuum/structname: 

Additionally to is not good style ... maybe Besides?
  
   variablelist
 ***
 *** 3470,3477 
   commandVACUUM/ operations.  If -1 is specified (which is the
   default), the regular
   xref linkend=guc-vacuum-cost-delay value will be used.
 - This setting can be overridden for individual tables by entries in
 - structnamepg_autovacuum/.
  /para
 /listitem
/varlistentry
 --- 3467,3472 
 ***
 *** 3487,3494 
   commandVACUUM/ operations.  If -1 is specified (which is the
   default), the regular
   xref linkend=guc-vacuum-cost-limit value will be used.
 - This setting can be overridden for individual tables by entries in
 - structnamepg_autovacuum/.
  /para
 /listitem
/varlistentry
 --- 3482,3487 

I don't think you should remove those sentences.  The information about
GUC variables is intentionally somewhat redundant with discussions
elsewhere, and in this case it's important as a cross-reference.

Otherwise looks great.

regards, tom lane

---(end of broadcast)---
TIP 4: Have you searched our list archives?

   http://archives.postgresql.org


Re: [PATCHES] docs: config chapter

2005-09-12 Thread Neil Conway

Neil Conway wrote:

This patch is blocking other work [...]
Otherwise I'll apply it this evening (EST).


Applied.

-Neil

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


Re: [PATCHES] Autovacuum docs

2005-09-12 Thread Matthew T. O'Connor

Tom Lane wrote:


+ Additionally to the base threshold values and scale factors, there are
+ two parameters that can be set for each table in structnamepg_autovacuum/structname: 
   



Additionally to is not good style ... maybe Besides?
 



I think In addition to was what Alvaro meant, which works. 


I just gave the patch a quick eye-balling and it looks good to me.

Alvaro, thanks for doing this, I know I said I would get to it, but I 
just don't seem to be able to find time for Postgres work these days.  
If fact I can barely find enough time to keep up with the lists these 
days.  Anyway, it looks good and thanks!


Matt



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


Re: [PATCHES] Autovacuum docs

2005-09-12 Thread Alvaro Herrera
On Mon, Sep 12, 2005 at 04:17:29PM -0400, Tom Lane wrote:
 Alvaro Herrera [EMAIL PROTECTED] writes:
  I have prepared some docs for autovacuum.  I attach the patch.  Comments
  on grammar, style etc. are welcome.

Applied, updated per your comments.

  +See xref linkend=autovacuum endterm=autovacuum-title.
 
 I think we mostly don't use endterm on cross-references to sections.
 Not sure if that's a project standard, or just laziness, though.
 (Peter?)

I removed it, but personally I think it's better to put it where it
makes the text read naturally.  For example, that text reads
See _The auto-vacuum daemon_, instead of See _Section 21.1.4_ -- I
think the former is better.  There are instances where it doesn't read 
so good, for example in the runtime configuration chapter, the text is

These settings control the default behavior for the autovacuum daemon.
Please refer to _Section 22.1.4_ for more information.

I don't see how to cleanly fit The auto-vacuum daemon in that sentence
in a way that looks like a reference.

So, in short, if there is a policy on this, I propose to update it to
use endterm wherever the surrounding text allows it.


Please check the new version.  Bruce's site is already up to date:

http://candle.pha.pa.us/main/writings/pgsql/sgml/maintenance.html#AUTOVACUUM

-- 
Alvaro Herrera -- Valdivia, Chile Architect, www.EnterpriseDB.com
One man's impedance mismatch is another man's layer of abstraction.
(Lincoln Yeoh)

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