dbTalk Databases Forums  

[BUGS] pgsql 8.0 beta1 patch for token and timezone

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] pgsql 8.0 beta1 patch for token and timezone in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Zhong Xubin
 
Posts: n/a

Default [BUGS] pgsql 8.0 beta1 patch for token and timezone - 08-27-2004 , 06:17 PM






Hi pgsql-bugs-owner,

I want to join the bug mailing list cauz I found 2 bugs and fixed them.

Regards,
Jacky

------------------------------------->

Quote:
From: pgsql-bugs-owner (AT) postgresql (DOT) org
To: "Zhong Jacky" <jackyzhongxp (AT) msn (DOT) com
Subject: Stalled post to pgsql-bugs
Date: Wed, 25 Aug 2004 23:43:48 -0300

Your message to pgsql-bugs has been delayed, and requires the approval
of the moderators, for the following reason(s):

The author ("Zhong Jacky" <jackyzhongxp (AT) msn (DOT) com>)
is not a member of any of the restrict_post groups.

If you do not wish the message to be posted, or have other concerns,
please send a message to the list owners at the following address:
pgsql-bugs-owner (AT) postgresql (DOT) org
------------------------------------->

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/a.../13/73785.aspx
2) http://www.smth.edu.cn/bbsgcon.php?b...tware&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 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match


Reply With Quote
  #2  
Old   
Bruce Momjian
 
Posts: n/a

Default Re: [BUGS] pgsql 8.0 beta1 patch for token and timezone - 08-28-2004 , 10:14 PM







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

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

Zhong Jacky wrote:
Quote:
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/a.../13/73785.aspx
2) http://www.smth.edu.cn/bbsgcon.php?b...tware&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 (AT) candle (DOT) 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

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match


Reply With Quote
  #3  
Old   
Bruce Momjian
 
Posts: n/a

Default Re: [BUGS] pgsql 8.0 beta1 patch for token and timezone - 10-07-2004 , 11:54 AM



--ELM1097167957-27467-0_
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII


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:
Quote:
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/a.../13/73785.aspx
2) http://www.smth.edu.cn/bbsgcon.php?b...tware&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 (AT) candle (DOT) 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

--ELM1097167957-27467-0_
Content-Transfer-Encoding: 7bit
Content-Type: text/plain
Content-Disposition: inline; filename="/bjm/diff"

Index: src/bin/initdb/initdb.c
================================================== =================
RCS file: /cvsroot/pgsql-server/src/bin/initdb/initdb.c,v
retrieving revision 1.56
diff -c -c -r1.56 initdb.c
*** src/bin/initdb/initdb.c 6 Oct 2004 09:13:10 -0000 1.56
--- src/bin/initdb/initdb.c 7 Oct 2004 16:45:32 -0000
***************
*** 181,186 ****
--- 181,187 ----
static void make_template0(void);
static void trapsig(int signum);
static void check_ok(void);
+ static void escape_locale(char **locale);
static bool chklocale(const char *locale);
static void setlocales(void);
static void usage(const char *progname);
***************
*** 1099,1114 ****
snprintf(repltok, sizeof(repltok), "shared_buffers = %d", n_buffers);
conflines = replace_token(conflines, "#shared_buffers = 1000", repltok);

snprintf(repltok, sizeof(repltok), "lc_messages = '%s'", lc_messages);
conflines = replace_token(conflines, "#lc_messages = 'C'", repltok);

snprintf(repltok, sizeof(repltok), "lc_monetary = '%s'", lc_monetary);
conflines = replace_token(conflines, "#lc_monetary = 'C'", repltok);

snprintf(repltok, sizeof(repltok), "lc_numeric = '%s'", lc_numeric);
-
conflines = replace_token(conflines, "#lc_numeric = 'C'", repltok);

snprintf(repltok, sizeof(repltok), "lc_time = '%s'", lc_time);
conflines = replace_token(conflines, "#lc_time = 'C'", repltok);

--- 1100,1119 ----
snprintf(repltok, sizeof(repltok), "shared_buffers = %d", n_buffers);
conflines = replace_token(conflines, "#shared_buffers = 1000", repltok);

+
+ escape_locale(&lc_messages);
snprintf(repltok, sizeof(repltok), "lc_messages = '%s'", lc_messages);
conflines = replace_token(conflines, "#lc_messages = 'C'", repltok);

+ escape_locale(&lc_monetary);
snprintf(repltok, sizeof(repltok), "lc_monetary = '%s'", lc_monetary);
conflines = replace_token(conflines, "#lc_monetary = 'C'", repltok);

+ escape_locale(&lc_numeric);
snprintf(repltok, sizeof(repltok), "lc_numeric = '%s'", lc_numeric);
conflines = replace_token(conflines, "#lc_numeric = 'C'", repltok);

+ escape_locale(&lc_time);
snprintf(repltok, sizeof(repltok), "lc_time = '%s'", lc_time);
conflines = replace_token(conflines, "#lc_time = 'C'", repltok);

***************
*** 1896,1906 ****
}
}


/*
* check if given string is a valid locale specifier
- * based on some code given to me by Peter Eisentraut
- * (but I take responsibility for it :-)
*/
static bool
chklocale(const char *locale)
--- 1901,1927 ----
}
}

+ /*
+ * 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;
+ }

/*
* check if given string is a valid locale specifier
*/
static bool
chklocale(const char *locale)

--ELM1097167957-27467-0_
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0


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

--ELM1097167957-27467-0_--


Reply With Quote
  #4  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] pgsql 8.0 beta1 patch for token and timezone - 10-07-2004 , 12:19 PM



Bruce Momjian <pgman (AT) candle (DOT) pha.pa.us> writes:
Quote:
+ /*
+ * 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


Reply With Quote
  #5  
Old   
Bruce Momjian
 
Posts: n/a

Default Re: [BUGS] pgsql 8.0 beta1 patch for token and timezone - 10-07-2004 , 12:30 PM




OK, fixed.

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

Tom Lane wrote:
Quote:
Bruce Momjian <pgman (AT) candle (DOT) 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 (AT) candle (DOT) 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

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

http://archives.postgresql.org


Reply With Quote
  #6  
Old   
Zhong Xubin
 
Posts: n/a

Default Re: [BUGS] pgsql 8.0 beta1 patch for token and timezone - 10-10-2004 , 01:48 PM



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

Quote:
From: Bruce Momjian <pgman (AT) candle (DOT) pha.pa.us
To: Tom Lane <tgl (AT) sss (DOT) pgh.pa.us
CC: Zhong Jacky <jackyzhongxp (AT) msn (DOT) com>, pgsql-bugs (AT) postgresql (DOT) 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 (AT) candle (DOT) 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 (AT) candle (DOT) 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


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

http://archives.postgresql.org


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.