Re: [HACKERS] PL/pgSQL support to define multi variables once

2014-06-13 Thread Quan Zongliang

On 06/13/2014 03:42 PM, Ian Barwick wrote:

Hi

On 14/06/13 16:20, Quan Zongliang wrote:

Hi all,

Please find the attachment.

By my friend asking, for convenience,
support to define multi variables in single PL/pgSQL line.

Like this:

CREATE OR REPLACE FUNCTION try_mutlivardef() RETURNS text AS $$
DECLARE
local_a, local_b, local_c text := 'a1';
BEGIN
return local_a || local_b || local_c;
end;
$$ LANGUAGE plpgsql;


Please submit this patch to the current commitfest:

   https://commitfest.postgresql.org/action/commitfest_view?id=22


Regards

Ian Barwick



submitted
https://commitfest.postgresql.org/action/patch_view?id=1475


---
此电子邮件没有病毒和恶意软件,因为 avast! 防病毒保护处于活动状态。
http://www.avast.com



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


[HACKERS] PL/pgSQL support to define multi variables once

2014-06-13 Thread Quan Zongliang

Hi all,

Please find the attachment.

By my friend asking, for convenience,
support to define multi variables in single PL/pgSQL line.

Like this:

CREATE OR REPLACE FUNCTION try_mutlivardef() RETURNS text AS $$
DECLARE
local_a, local_b, local_c text := 'a1';
BEGIN
return local_a || local_b || local_c;
end;
$$ LANGUAGE plpgsql;


Regards,
Quan Zongliang


---
此电子邮件没有病毒和恶意软件,因为 avast! 防病毒保护处于活动状态。
http://www.avast.com
diff --git a/src/pl/plpgsql/src/pl_gram.y b/src/pl/plpgsql/src/pl_gram.y
index e3a992c..2737a3a 100644
--- a/src/pl/plpgsql/src/pl_gram.y
+++ b/src/pl/plpgsql/src/pl_gram.y
@@ -167,6 +167,7 @@ static	List			*read_raise_options(void);
 
 %type  decl_sect
 %type  decl_varname
+%type 	decl_varnames
 %type 	decl_const decl_notnull exit_type
 %type 	decl_defval decl_cursor_query
 %type 	decl_datatype
@@ -471,9 +472,10 @@ decl_stmt		: decl_statement
 	}
 ;
 
-decl_statement	: decl_varname decl_const decl_datatype decl_collate decl_notnull decl_defval
+decl_statement	: decl_varnames decl_const decl_datatype decl_collate decl_notnull decl_defval
 	{
 		PLpgSQL_variable	*var;
+		ListCell *lc;
 
 		/*
 		 * If a collation is supplied, insert it into the
@@ -492,38 +494,44 @@ decl_statement	: decl_varname decl_const decl_datatype decl_collate decl_notnull
 			$3->collation = $4;
 		}
 
-		var = plpgsql_build_variable($1.name, $1.lineno,
-	 $3, true);
-		if ($2)
-		{
-			if (var->dtype == PLPGSQL_DTYPE_VAR)
-((PLpgSQL_var *) var)->isconst = $2;
-			else
-ereport(ERROR,
-		(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-		 errmsg("row or record variable cannot be CONSTANT"),
-		 parser_errposition(@2)));
-		}
-		if ($5)
-		{
-			if (var->dtype == PLPGSQL_DTYPE_VAR)
-((PLpgSQL_var *) var)->notnull = $5;
-			else
-ereport(ERROR,
-		(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-		 errmsg("row or record variable cannot be NOT NULL"),
-		 parser_errposition(@4)));
 
-		}
-		if ($6 != NULL)
+		foreach(lc, $1)
 		{
-			if (var->dtype == PLPGSQL_DTYPE_VAR)
-((PLpgSQL_var *) var)->default_val = $6;
-			else
-ereport(ERROR,
-		(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-		 errmsg("default value for row or record variable is not supported"),
-		 parser_errposition(@5)));
+			YYSTYPE *v = (YYSTYPE *) lfirst(lc);
+
+			var = plpgsql_build_variable(v->varname.name, v->varname.lineno,
+	 	$3, true);
+			if ($2)
+			{
+if (var->dtype == PLPGSQL_DTYPE_VAR)
+	((PLpgSQL_var *) var)->isconst = $2;
+else
+	ereport(ERROR,
+			(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+			 errmsg("row or record variable cannot be CONSTANT"),
+			 parser_errposition(@2)));
+			}
+			if ($5)
+			{
+if (var->dtype == PLPGSQL_DTYPE_VAR)
+	((PLpgSQL_var *) var)->notnull = $5;
+else
+	ereport(ERROR,
+			(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+			 errmsg("row or record variable cannot be NOT NULL"),
+			 parser_errposition(@4)));
+
+			}
+			if ($6 != NULL)
+			{
+if (var->dtype == PLPGSQL_DTYPE_VAR)
+	((PLpgSQL_var *) var)->default_val = $6;
+else
+	ereport(ERROR,
+			(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+			 errmsg("default value for row or record variable is not supported"),
+			 parser_errposition(@5)));
+			}
 		}
 	}
 | decl_varname K_ALIAS K_FOR decl_aliasitem ';'
@@ -773,6 +781,22 @@ decl_varname	: T_WORD
 	}
 ;
 
+decl_varnames : decl_varname
+	{
+		YYSTYPE *v = palloc(sizeof(YYSTYPE));
+		v->varname.name = pstrdup($1.name);
+		v->varname.lineno = $1.lineno;
+		$$ = list_make1(v);
+	}
+| decl_varnames ',' decl_varname
+	{
+		YYSTYPE *v = palloc(sizeof(YYSTYPE));
+		v->varname.name = pstrdup($3.name);
+		v->varname.lineno = $3.lineno;
+		$$ = lappend($1, v);
+	}
+;
+
 decl_const		:
 	{ $$ = false; }
 | K_CONSTANT

-- 
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] improve Chinese locale performance

2013-09-09 Thread Quan Zongliang

On 09/06/2013 01:02 AM, Robert Haas wrote:

On Wed, Sep 4, 2013 at 11:02 PM, Quan Zongliang  wrote:

I think of a new idea.
Add a compare method column to pg_collation.
Every collation has its own compare function or null.
When function varstr_cmp is called, if specified collation
has compare function, call it instead of strcoll().


I think we're going to need to have two kinds of collations:
OS-derived collations (which get all of their smarts from the OS), and
PG-internal collations (which use PG-aware code for everything).
Which I suspect is a bit more involved than what you're imagining, but
mixing and matching doesn't seem likely to end well.

However, what you're proposing might serve as a useful demonstration
of how much performance there is to be gained here.


Understood.

I just try to speed up text compare, not redesign locale.

Do you have a plan to do this?

Thank you.

Quan Zongliang



--
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] improve Chinese locale performance

2013-09-04 Thread Quan Zongliang

On 07/23/2013 09:42 PM, Craig Ringer wrote:

(Replying on phone, please forgive bad quoting)

Isn't this pretty much what adopting ICU is supposed to give us? OS-independent 
collations?

I'd be interested in seeing the rest data for this performance report, partly 
as I'd like to see how ICU collations would compare when ICU is crudely hacked 
into place for testing.


I think of a new idea.
Add a compare method column to pg_collation.
Every collation has its own compare function or null.
When function varstr_cmp is called, if specified collation
has compare function, call it instead of strcoll().

How about this?

Regards.

Quan Zongliang



--
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] improve Chinese locale performance

2013-07-23 Thread Quan Zongliang

On 07/23/2013 09:42 PM, Craig Ringer wrote:

(Replying on phone, please forgive bad quoting)

Isn't this pretty much what adopting ICU is supposed to give us? OS-independent 
collations?


Yes, we need OS-independent collations.


I'd be interested in seeing the rest data for this performance report, partly 
as I'd like to see how ICU collations would compare when ICU is crudely hacked 
into place for testing.





--
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] improve Chinese locale performance

2013-07-22 Thread Quan Zongliang

On 07/22/2013 03:54 PM, Craig Ringer wrote:

On 07/22/2013 12:17 PM, Quan Zongliang wrote:

Hi hackers,

I tried to improve performance when database is Chinese.

Under openSUSE, create index on table with 54996 rows
locale=C, 140ms
locale=zh_CN, 985ms

I think the function strcoll() of Linux is too slow.
So, I made a new utf8 to GB18030 map, store Chinese order in it.
Do not call strcoll().
On my modified code, same operation, locale=zh_CN, 203ms.


It might be worth looking at gcc's strcoll() implementation. See if it
performs better when you use the latest gcc, and if not try to improve
gcc's strcoll() .

I'd be interested in seeing a test case for this that shows that the
results of your new collation are exactly the same as the original
strcoll() based approach.


Do not same exactly.
I found some errors in gcc's strcoll() when order by Chinese character.
Because there are lots of special characters in Chinese.
gcc's strcoll() do not consider this or missed at part of them.

Yes, the best way is to impove gcc's strcoll().
But I don't know how to do.


Thanks,
Quan Zongliang



--
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] compare lower case and upper case when encoding is utf-8

2012-06-17 Thread Quan Zongliang

On 2012/6/18 7:13, Peter Eisentraut wrote:

On lör, 2012-06-16 at 16:21 +0800, Quan Zongliang wrote:

I found that lower case is less than upper case when the db is
created
with utf8.
I tried below
  locale   en_US.utf8   'A'<'a' false
  locale   ja_JP.utf8   'A'<'a' true
  locale   zh_CN.utf8   'A'<'a' false
Under Windows
  locale   Chinese_China   'A'<'a' false

I am not sure it is normal or not.
But in Chinese, the lower case should be greater than upper, same as
locale C.

The operating system locale determines that, so you need to look there
if you don't agree with the result.

http://wiki.postgresql.org/wiki/FAQ#Why_do_my_strings_sort_incorrectly.3F



I see, thank you.

Quan Zongliang



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


[HACKERS] compare lower case and upper case when encoding is utf-8

2012-06-16 Thread Quan Zongliang

Hi hackers,

I found that lower case is less than upper case when the db is created 
with utf8.

I tried below
locale   en_US.utf8   'A'<'a' false
locale   ja_JP.utf8   'A'<'a' true
locale   zh_CN.utf8   'A'<'a' false
Under Windows
locale   Chinese_China   'A'<'a' false

I am not sure it is normal or not.
But in Chinese, the lower case should be greater than upper, same as 
locale C.


I made some code try to fix it.
It seems to work fine.

Quan Zongliang


--
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 BUG #5103: "pg_ctl -w (re)start" fails with custom unix_socket_directory

2010-12-23 Thread Quan Zongliang
On Wed, 22 Dec 2010 21:02:35 -0500 (EST)
Bruce Momjian  wrote:

> Alvaro Herrera wrote:
> > Excerpts from Quan Zongliang's message of mar dic 21 18:36:11 -0300 2010:
> > > On Mon, 29 Nov 2010 10:29:17 -0300
> > > Alvaro Herrera  wrote:
> > > 
> > 
> > > > I think the way this should work is that you call postmaster with a new
> > > > switch and it prints out its configuration, after reading the
> > > > appropriate config file(s).  That way it handles all the little details
> > > > such as figuring out the correct config file, hadle include files, etc.
> > > > This output would be presumably easier to parse and more trustworthy.
> > > 
> > > Sorry for my late reply.
> > > 
> > > I will check the source of postmaster.
> > 
> > Actually Bruce Momjian is now working on a different fix:
> > unix_socket_directory would be added to postmaster.pid, allowing pg_ctl
> > to find it.
> 
> Yes, I will apply this patch tomorrow and it will be in 9.1.  Thanks for
> the report.
> 
Nice work.


-- 
Quan Zongliang 

-- 
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 BUG #5103: "pg_ctl -w (re)start" fails with custom unix_socket_directory

2010-12-21 Thread Quan Zongliang
On Mon, 29 Nov 2010 10:29:17 -0300
Alvaro Herrera  wrote:

> Excerpts from Quan Zongliang's message of sáb nov 27 06:03:12 -0300 2010:
> > Hi, all
> > 
> > I created a pg_ctl patch to fix:
> > * BUG #5103: "pg_ctl -w (re)start" fails with custom unix_socket_directory 
> > Allow pg_ctl to work properly with configuration files located outside the 
> > PGDATA directory
> 
> I think the way this should work is that you call postmaster with a new
> switch and it prints out its configuration, after reading the
> appropriate config file(s).  That way it handles all the little details
> such as figuring out the correct config file, hadle include files, etc.
> This output would be presumably easier to parse and more trustworthy.
> 
> Right now we have --describe-config, which is missing the values for
> each config option.
> 

Sorry for my late reply.

I will check the source of postmaster.


-- 
Quan Zongliang 

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


[HACKERS] Patch BUG #5103: "pg_ctl -w (re)start" fails with custom unix_socket_directory

2010-11-27 Thread Quan Zongliang
Hi, all

I created a pg_ctl patch to fix:
* BUG #5103: "pg_ctl -w (re)start" fails with custom unix_socket_directory 
Allow pg_ctl to work properly with configuration files located outside the 
PGDATA directory

I tested it under Windows XP sp3.
All of configuration files(postgresql.conf pg_hba.conf pg_ident.conf) are in 
c:\data,
and data_dir is in C:\Program Files\PostgreSQL\9.0\data

Check the attchment, please.

Another question, after clone source with git I can not compile them:
Bad format filename 'src\bin\scripts\submake-libpq'
Former makefile like "createdb: createdb.o ... keywords.o"
Now it is "createdb: createdb.o ... keywords.o | submake-libpq"
How to do this?

--
SEARCHING JOB. I can work on C/C++.

Quan Zongliang 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
old mode 100644
new mode 100755
index 14d36b5..c708ba8
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -89,6 +89,8 @@ static char *register_username = NULL;
 static char *register_password = NULL;
 static char *argv0 = NULL;
 static bool allow_core_files = false;
+static char *pgconf_portstr = NULL;
+static char *pgconf_datadir = NULL;
 
 static void
 write_stderr(const char *fmt,...)
@@ -455,41 +457,7 @@ test_postmaster_connection(bool do_checkpoint)
 * for valid port settings.
 */
if (!*portstr)
-   {
-   char  **optlines;
-
-   optlines = readfile(conf_file);
-   if (optlines != NULL)
-   {
-   for (; *optlines != NULL; optlines++)
-   {
-   p = *optlines;
-
-   while (isspace((unsigned char) *p))
-   p++;
-   if (strncmp(p, "port", 4) != 0)
-   continue;
-   p += 4;
-   while (isspace((unsigned char) *p))
-   p++;
-   if (*p != '=')
-   continue;
-   p++;
-   /* advance past any whitespace/quoting */
-   while (isspace((unsigned char) *p) || *p == 
'\'' || *p == '"')
-   p++;
-   /* find end of value (not including any ending 
quote/comment!) */
-   q = p;
-   while (*q &&
-  !(isspace((unsigned char) *q) ||
-*q == '\'' || *q == '"' || *q 
== '#'))
-   q++;
-   /* and save the argument value */
-   strlcpy(portstr, p, Min((q - p) + 1, 
sizeof(portstr)));
-   /* keep looking, maybe there is another */
-   }
-   }
-   }
+   strlcpy(portstr, pgconf_portstr, Min(sizeof(pgconf_portstr)+1, 
sizeof(portstr)));
 
/* Check environment */
if (!*portstr && getenv("PGPORT") != NULL)
@@ -547,6 +515,75 @@ test_postmaster_connection(bool do_checkpoint)
 }
 
 
+static void
+read_conf_file(void)
+{
+   char**optlines;
+   char *p, *q;
+   bool isportnum, isdatadir, isquoted;
+
+   optlines = readfile(conf_file);
+   if (optlines == NULL)
+   return;
+
+   for (; *optlines != NULL; optlines++)
+   {
+   p = *optlines;
+
+   while (isspace((unsigned char) *p))
+   p++;
+
+   if (strncmp(p, "port", 4) == 0)
+   {
+   isportnum = true;
+   p += 4;
+   }
+   else if (strncmp(p, "data_directory", 14) == 0)
+   {
+   isdatadir = true;
+   p += 14;
+   }
+   else
+   continue;
+
+   while (isspace((unsigned char) *p))
+   p++;
+   if (*p != '=')
+   continue;
+   p++;
+   isquoted = false;
+   /* advance past any whitespace/quoting */
+   while (isspace((unsigned char) *p) || *p == '\'' || *p == '"')
+   {
+   if (*p == '\'' || *p == '"')
+   isquoted = true;
+   p++;
+   }
+   /* find end of value (not including any ending quote/comment!) 
*/
+   q = p;

Re: [HACKERS] Fw: patch for pg_ctl.c to add windows service start-type

2010-08-24 Thread Quan Zongliang
Which files need be modified?
sgml, html, and man-page or only sgml?
I am not familiar with this.

On Sun, 22 Aug 2010 08:25:59 -0700
David Fetter  wrote:

> On Sun, Aug 22, 2010 at 10:03:32PM +0800, Quan Zongliang wrote:
> > Sure, I agree.
> > New patch attached. How about this?
> 
> Docs re-added.  Please not to leave these out in future patches. :)
> 
> Cheers,
> David.
> -- 
> David Fetter  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


-- 
Quan Zongliang 

-- 
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] Fw: patch for pg_ctl.c to add windows service start-type

2010-08-22 Thread Quan Zongliang
Sure, I agree.
New patch attached. How about this?

On Fri, 20 Aug 2010 11:21:18 +0200
Magnus Hagander  wrote:

> On Fri, Aug 20, 2010 at 01:01, Quan Zongliang  wrote:
> > Because Windows's CreateService has serial start-type:
> > SERVICE_AUTO_START
> > SERVICE_BOOT_START
> > SERVICE_DEMAND_START
> > SERVICE_DISABLED
> > SERVICE_SYSTEM_START
> >
> > Although all of them are not useful for pg service.
> > I think it is better to use enum.
> 
> I don't see us ever using anything other than auto or demand. The
> others aren't for "regular services", except for "disabled". And
> adding a disabled service makes no sense :-) So I'm with Alvaro, I
> think it's a good idea to simplify that.
> 
> 
> -- 
>  Magnus Hagander
>  Me: http://www.hagander.net/
>  Work: http://www.redpill-linpro.com/


-- 
Quan Zongliang 
*** pg_ctl.c.bak2010-04-07 11:48:51.0 +0800
--- pg_ctl.c2010-08-22 20:15:53.37500 +0800
***
*** 121,126 
--- 121,127 
  static void pgwin32_doRunAsService(void);
  static intCreateRestrictedProcess(char *cmd, PROCESS_INFORMATION 
*processInfo, bool as_service);
  
+ static DWORD pgctl_start_type = SERVICE_AUTO_START;
  static SERVICE_STATUS status;
  static SERVICE_STATUS_HANDLE hStatus = (SERVICE_STATUS_HANDLE) 0;
  static HANDLE shutdownHandles[2];
***
*** 1147,1153 
  
if ((hService = CreateService(hSCM, register_servicename, 
register_servicename,
   SERVICE_ALL_ACCESS, 
SERVICE_WIN32_OWN_PROCESS,
! 
SERVICE_AUTO_START, SERVICE_ERROR_NORMAL,
  
pgwin32_CommandLine(true),
   NULL, NULL, "RPCSS\0", register_username, register_password)) == 
NULL)
{
--- 1148,1154 
  
if ((hService = CreateService(hSCM, register_servicename, 
register_servicename,
   SERVICE_ALL_ACCESS, 
SERVICE_WIN32_OWN_PROCESS,
! 
pgctl_start_type, SERVICE_ERROR_NORMAL,
  
pgwin32_CommandLine(true),
   NULL, NULL, "RPCSS\0", register_username, register_password)) == 
NULL)
{
***
*** 1586,1592 
printf(_("  %s killSIGNALNAME PID\n"), progname);
  #if defined(WIN32) || defined(__CYGWIN__)
printf(_("  %s register   [-N SERVICENAME] [-U USERNAME] [-P PASSWORD] 
[-D DATADIR]\n"
!"[-w] [-t SECS] [-o \"OPTIONS\"]\n"), 
progname);
printf(_("  %s unregister [-N SERVICENAME]\n"), progname);
  #endif
  
--- 1587,1593 
printf(_("  %s killSIGNALNAME PID\n"), progname);
  #if defined(WIN32) || defined(__CYGWIN__)
printf(_("  %s register   [-N SERVICENAME] [-U USERNAME] [-P PASSWORD] 
[-D DATADIR]\n"
!"[-S START-TYPE] [-w] [-t SECS] [-o 
\"OPTIONS\"]\n"), progname);
printf(_("  %s unregister [-N SERVICENAME]\n"), progname);
  #endif
  
***
*** 1627,1632 
--- 1628,1640 
printf(_("  -N SERVICENAME  service name with which to register 
PostgreSQL server\n"));
printf(_("  -P PASSWORD password of account to register PostgreSQL 
server\n"));
printf(_("  -U USERNAME user name of account to register PostgreSQL 
server\n"));
+   printf(_("  -S START-TYPE   service start type to register PostgreSQL 
server,\n"
+   "  can be auto or demand\n"));
+ 
+   printf(_("\nStart types are:\n"));
+   printf(_("  auto   service start automatically during system 
startup\n"));
+   printf(_("  demand service start on demand\n"));
+ 
  #endif
  
printf(_("\nReport bugs to .\n"));
***
*** 1696,1701 
--- 1704,1728 
  
  
  
+ #if defined(WIN32) || defined(__CYGWIN__)
+ static void
+ set_starttype(char *starttypeopt)
+ {
+   if (strcmp(starttypeopt, "a") == 0 || strcmp(starttypeopt, "auto") == 0)
+   pgctl_start_type = SERVICE_AUTO_START;
+   else if (strcmp(starttypeopt, "d") == 0 || strcmp(starttypeopt, 
"demand") == 0)
+   pgctl_start_type = SERVICE_DEMAND_START;
+   else
+   {
+   write_stderr(_("%s: unrecognized start type \"%s\"\n"), 
progname, starttypeopt);
+   do_advice();
+   exit(1);
+   }
+ }
+ #endif
+ 
+ 
+ 
  int
  main(int argc, 

Re: [HACKERS] Fw: patch for pg_ctl.c to add windows service start-type

2010-08-19 Thread Quan Zongliang
I don't know how to edit documents exactly before.

Thanks.

On Thu, 19 Aug 2010 08:48:53 -0700
David Fetter  wrote:

> On Thu, Aug 19, 2010 at 10:24:54PM +0800, Quan Zongliang wrote:
> > documents attached. html and man-page
> 
> Thanks!
> 
> For future reference, the way to patch docs is by patching the SGML
> source.  Please find enclosed a patch which incorporates the code
> patch you sent with these docs.
> 
> Cheers,
> David.
> -- 
> David Fetter  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


-- 
Quan Zongliang 

-- 
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] Fw: patch for pg_ctl.c to add windows service start-type

2010-08-19 Thread Quan Zongliang
Because Windows's CreateService has serial start-type:
SERVICE_AUTO_START
SERVICE_BOOT_START
SERVICE_DEMAND_START
SERVICE_DISABLED
SERVICE_SYSTEM_START

Although all of them are not useful for pg service.
I think it is better to use enum.

On Thu, 19 Aug 2010 16:48:53 -0400
Alvaro Herrera  wrote:

> Excerpts from David Fetter's message of jue ago 19 16:40:18 -0400 2010:
> > On Thu, Aug 19, 2010 at 03:47:43PM -0400, Alvaro Herrera wrote:
> > > Excerpts from David Fetter's message of jue ago 19 11:48:53 -0400 2010:
> > > 
> > > > +
> > > > + -S  > > > class="parameter">
> > > 
> > > You omitted the start-type inside the  tag.  Also, the "a"
> > > and "d" values seem to be accepted but not documented.
> > 
> > D'oh!  Changed patch enclosed.  Now in context format :)
> 
> Thanks.
> 
> Another thing -- why is there an enum at all?  Seems it'd be
> simpler to assign the right value to the variable in the getopt() code
> to start with.
> 
> -- 
> Álvaro Herrera 
> The PostgreSQL Company - Command Prompt, Inc.
> PostgreSQL Replication, Consulting, Custom Development, 24x7 support


-- 
Quan Zongliang 

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


[HACKERS] Fw: patch for pg_ctl.c to add windows service start-type

2010-08-17 Thread Quan Zongliang

Sorry.
I forget to attach the patch file.

Begin forwarded message:

Date: Mon, 16 Aug 2010 19:49:20 +0800
From: Quan Zongliang 
To: pgsql-hackers@postgresql.org
Subject: patch for pg_ctl.c to add windows service start-type


Hi, all

I modified pg_ctl.c to add a new option for Windows service start-type.
new option is -S [auto|demand]

For example, the command can be used under Windows:
pg_ctl register -N "s-name" -S auto
or
pg_ctl register -N "s-name" -S demand

The created service will be SERVICE_AUTO_START or SERVICE_DEMAND_START 
respectively.

regards

-- 
Quan Zongliang 


-- 
Quan Zongliang 


pg_ctl.patch
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


[HACKERS] patch for pg_ctl.c to add windows service start-type

2010-08-16 Thread Quan Zongliang
Hi, all

I modified pg_ctl.c to add a new option for Windows service start-type.
new option is -S [auto|demand]

For example, the command can be used under Windows:
pg_ctl register -N "s-name" -S auto
or
pg_ctl register -N "s-name" -S demand

The created service will be SERVICE_AUTO_START or SERVICE_DEMAND_START 
respectively.

regards

-- 
Quan Zongliang 

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