pgsql 8.0 beta1 patch for token and timezone

Started by Zhong Xubinover 21 years ago6 messagesbugs
Jump to latest
#1Zhong Xubin
jackyzhongxp@msn.com

Hi pgsql-bugs,

I'm a Chinese and I am using WinXp Chs to compile pgsql 8.0 beta 1
in the MinGW environment. I found 2 bugs and fix them, maybe you can
merge the patch into the offical release, thanks.

Part A) Below is the two bugs occur when we run initdb under WinXp Chs.

1) FATAL: syntax error in file "E:/Unix/Sys/Pgsql/data/postgresql.conf"

line 261, near token "s"

Reason: the string 'Chinese_People's Republic of China.936' should be
'Chinese_People\'s Republic of China.936', otherwise token mismatch. Plese
remember the regular expression like sed and awk under Unix.

Patch: I wrote a function to detect ' in string and insert a \ symbol

2) WARNING: could not find a match for Windows timezone "锟叫癸拷锟斤拷准时锟斤拷"

Reason: "锟叫癸拷锟斤拷准时锟斤拷" is the string stands for "China Standard
Time",
which shows in Chinese language.

Patch: use a scanzone() function to find and convert timezone to the
English string in win32_tzmap[]. I can fix only Chinese because I only have
WinXp Chs operating system, people can fix others in similar way.

Part B) You can visit these 2 websites for more detail and get patch.
1) http://blog.csdn.net/chaoyuebetter/archive/2004/08/13/73785.aspx
2) http://www.smth.edu.cn/bbsgcon.php?board=NewSoftware&num=2548

Part C) The patch is based on snap0812, but can work on snap0825, etc.

Regards,
Jacky

_________________________________________________________________
锟斤拷锟斤拷锟斤拷锟� MSN Explorer: http://explorer.msn.com/lccn/

#2Bruce Momjian
bruce@momjian.us
In reply to: Zhong Xubin (#1)
Re: pgsql 8.0 beta1 patch for token and timezone

I do not see a patch. Did you forget to attach it?

---------------------------------------------------------------------------

Zhong Jacky wrote:

Hi pgsql-bugs,

I'm a Chinese and I am using WinXp Chs to compile pgsql 8.0 beta 1
in the MinGW environment. I found 2 bugs and fix them, maybe you can
merge the patch into the offical release, thanks.

Part A) Below is the two bugs occur when we run initdb under WinXp Chs.

1) FATAL: syntax error in file "E:/Unix/Sys/Pgsql/data/postgresql.conf"

line 261, near token "s"

Reason: the string 'Chinese_People's Republic of China.936' should be
'Chinese_People\'s Republic of China.936', otherwise token mismatch. Plese
remember the regular expression like sed and awk under Unix.

Patch: I wrote a function to detect ' in string and insert a \ symbol

2) WARNING: could not find a match for Windows timezone "??????"

Reason: "??????" is the string stands for "China Standard
Time",
which shows in Chinese language.

Patch: use a scanzone() function to find and convert timezone to the
English string in win32_tzmap[]. I can fix only Chinese because I only have
WinXp Chs operating system, people can fix others in similar way.

Part B) You can visit these 2 websites for more detail and get patch.
1) http://blog.csdn.net/chaoyuebetter/archive/2004/08/13/73785.aspx
2) http://www.smth.edu.cn/bbsgcon.php?board=NewSoftware&num=2548

Part C) The patch is based on snap0812, but can work on snap0825, etc.

Regards,
Jacky

_________________________________________________________________
???? MSN Explorer: http://explorer.msn.com/lccn/

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

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#3Bruce Momjian
bruce@momjian.us
In reply to: Zhong Xubin (#1)
Re: pgsql 8.0 beta1 patch for token and timezone

I have reviewed your patch. I found that the first patch was definitely
needed. Your code adds escapes for single quotes in locale names placed
in postgresql.conf. I also added code to escape a literal backslash as
well. I re-factored your code and applied the attached patch.

Your second patch to pgtz.c is not needed anymore because we have a more
general solution added on September 1:

/*
* Localized Windows versions return localized names for the
* timezone. Scan the registry to find the English name,
* and then try matching against our table again.
*/
memset(localtzname, 0, sizeof(localtzname));
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
0,
KEY_READ,
&rootKey) != ERROR_SUCCESS)

Thanks.

---------------------------------------------------------------------------

Zhong Jacky wrote:

Hi pgsql-bugs,

I'm a Chinese and I am using WinXp Chs to compile pgsql 8.0 beta 1
in the MinGW environment. I found 2 bugs and fix them, maybe you can
merge the patch into the offical release, thanks.

Part A) Below is the two bugs occur when we run initdb under WinXp Chs.

1) FATAL: syntax error in file "E:/Unix/Sys/Pgsql/data/postgresql.conf"

line 261, near token "s"

Reason: the string 'Chinese_People's Republic of China.936' should be
'Chinese_People\'s Republic of China.936', otherwise token mismatch. Plese
remember the regular expression like sed and awk under Unix.

Patch: I wrote a function to detect ' in string and insert a \ symbol

2) WARNING: could not find a match for Windows timezone "??????"

Reason: "??????" is the string stands for "China Standard
Time",
which shows in Chinese language.

Patch: use a scanzone() function to find and convert timezone to the
English string in win32_tzmap[]. I can fix only Chinese because I only have
WinXp Chs operating system, people can fix others in similar way.

Part B) You can visit these 2 websites for more detail and get patch.
1) http://blog.csdn.net/chaoyuebetter/archive/2004/08/13/73785.aspx
2) http://www.smth.edu.cn/bbsgcon.php?board=NewSoftware&num=2548

Part C) The patch is based on snap0812, but can work on snap0825, etc.

Regards,
Jacky

_________________________________________________________________
???? MSN Explorer: http://explorer.msn.com/lccn/

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

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Attachments:

/bjm/difftext/plainDownload+24-3
#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#3)
Re: pgsql 8.0 beta1 patch for token and timezone

Bruce Momjian <pgman@candle.pha.pa.us> writes:

+ /*
+  * Escape any single quotes or backslashes in locale
+  */
+ static void
+ escape_locale(char **locale)
+ {
+ 	int			len = strlen(*locale),
+ 				i, j;
+ 	char		*loc_temp = xmalloc(len * 2);
+ 	
+ 	for (i = 0, j = 0; i < len; i++)
+ 	{
+ 		if ((*locale)[i] == '\'' || (*locale)[i] == '\\')
+ 			loc_temp[j++] = '\\';
+ 		loc_temp[j++] = (*locale)[i];
+ 	}
+ 	*locale = loc_temp;
+ }

Surely this is quite broken. You need to xmalloc one more byte and
add a '\0'.

regards, tom lane

#5Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#4)
Re: pgsql 8.0 beta1 patch for token and timezone

OK, fixed.

---------------------------------------------------------------------------

Tom Lane wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

+ /*
+  * Escape any single quotes or backslashes in locale
+  */
+ static void
+ escape_locale(char **locale)
+ {
+ 	int			len = strlen(*locale),
+ 				i, j;
+ 	char		*loc_temp = xmalloc(len * 2);
+ 	
+ 	for (i = 0, j = 0; i < len; i++)
+ 	{
+ 		if ((*locale)[i] == '\'' || (*locale)[i] == '\\')
+ 			loc_temp[j++] = '\\';
+ 		loc_temp[j++] = (*locale)[i];
+ 	}
+ 	*locale = loc_temp;
+ }

Surely this is quite broken. You need to xmalloc one more byte and
add a '\0'.

regards, tom lane

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

http://www.postgresql.org/docs/faqs/FAQ.html

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#6Zhong Xubin
jackyzhongxp@msn.com
In reply to: Bruce Momjian (#5)
Re: pgsql 8.0 beta1 patch for token and timezone

Hi All,

Great thanks for your kindness and quick reply. Fixing those bugs
will help many people in China who plan to study Pgsql.

Regards,
Jacky

From: Bruce Momjian <pgman@candle.pha.pa.us>
To: Tom Lane <tgl@sss.pgh.pa.us>
CC: Zhong Jacky <jackyzhongxp@msn.com>, pgsql-bugs@postgresql.org
Subject: Re: [BUGS] pgsql 8.0 beta1 patch for token and timezone
Date: Thu, 7 Oct 2004 13:29:11 -0400 (EDT)

OK, fixed.

---------------------------------------------------------------------------

Tom Lane wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

+ /*
+  * Escape any single quotes or backslashes in locale
+  */
+ static void
+ escape_locale(char **locale)
+ {
+ 	int			len = strlen(*locale),
+ 				i, j;
+ 	char		*loc_temp = xmalloc(len * 2);
+
+ 	for (i = 0, j = 0; i < len; i++)
+ 	{
+ 		if ((*locale)[i] == '\'' || (*locale)[i] == '\\')
+ 			loc_temp[j++] = '\\';
+ 		loc_temp[j++] = (*locale)[i];
+ 	}
+ 	*locale = loc_temp;
+ }

Surely this is quite broken. You need to xmalloc one more byte and
add a '\0'.

regards, tom lane

---------------------------(end of

broadcast)---------------------------

TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

--
Bruce Momjian                        |  http://candle.pha.pa.us
pgman@candle.pha.pa.us               |  (610) 359-1001
+  If your life is a hard drive,     |  13 Roberts Road
+  Christ can be your backup.        |  Newtown Square, Pennsylvania 

19073

_________________________________________________________________
锟斤拷锟斤拷锟斤拷锟� MSN Explorer: http://explorer.msn.com/lccn