[PATCHES] SSL configure patch

2008-06-13 Thread pgsql
Here is the SSL patch we discussed previously for 8.3.1.

sslconfig.patch.8.3.1
Description: Binary data

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


Re: [PATCHES] Better formatting of functions in pg_dump

2008-06-13 Thread Tom Lane
Greg Sabino Mullane [EMAIL PROTECTED] writes:
 Why the random switching between newline-before and newline-after
 styles?  Please be consistent.

 I thought they were all after. On second glance, they still seem
 all after?

Oh, my mistake, I had failed to see that the patch was getting rid of
newline-before style in this function.  I think you might have gone
a bit overboard on adding whitespace, but the previous objection is
nonsense, sorry.

regards, tom lane

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


[PATCHES] page macros cleanup

2008-06-13 Thread Zdenek Kotala
I attached code cleanup which is related to in-place upgrade. I replace direct 
access to PageHeader structure with already existing macros and I removed also 
unnecessary retyping. There still lot of places which directly access to 
PageHeader structure which require new macros/fuction in page API. I will fix it 
in next patch.


Zdenek
diff -cr pgsql.orig.da8c485e0e2a/src/backend/access/gist/gistutil.c pgsql.orig/src/backend/access/gist/gistutil.c
*** pgsql.orig.da8c485e0e2a/src/backend/access/gist/gistutil.c	pá črn 13 18:00:35 2008
--- pgsql.orig/src/backend/access/gist/gistutil.c	pá črn 13 18:00:35 2008
***
*** 592,598 
  	/*
  	 * Additionally check that the special area looks sane.
  	 */
! 	if (((PageHeader) (page))-pd_special !=
  		(BLCKSZ - MAXALIGN(sizeof(GISTPageOpaqueData
  		ereport(ERROR,
  (errcode(ERRCODE_INDEX_CORRUPTED),
--- 592,598 
  	/*
  	 * Additionally check that the special area looks sane.
  	 */
! 	if ( PageGetSpecialPointer(page) - page !=
  		(BLCKSZ - MAXALIGN(sizeof(GISTPageOpaqueData
  		ereport(ERROR,
  (errcode(ERRCODE_INDEX_CORRUPTED),
diff -cr pgsql.orig.da8c485e0e2a/src/backend/access/hash/hashpage.c pgsql.orig/src/backend/access/hash/hashpage.c
*** pgsql.orig.da8c485e0e2a/src/backend/access/hash/hashpage.c	pá črn 13 18:00:35 2008
--- pgsql.orig/src/backend/access/hash/hashpage.c	pá črn 13 18:00:35 2008
***
*** 407,413 
  	for (i = _hash_log2(metap-hashm_bsize); i  0; --i)
  	{
  		if ((1  i) = (metap-hashm_bsize -
! 		 (MAXALIGN(sizeof(PageHeaderData)) +
  		  MAXALIGN(sizeof(HashPageOpaqueData)
  			break;
  	}
--- 407,413 
  	for (i = _hash_log2(metap-hashm_bsize); i  0; --i)
  	{
  		if ((1  i) = (metap-hashm_bsize -
! 		 (MAXALIGN(SizeOfPageHeaderData) +
  		  MAXALIGN(sizeof(HashPageOpaqueData)
  			break;
  	}
diff -cr pgsql.orig.da8c485e0e2a/src/backend/access/hash/hashutil.c pgsql.orig/src/backend/access/hash/hashutil.c
*** pgsql.orig.da8c485e0e2a/src/backend/access/hash/hashutil.c	pá črn 13 18:00:35 2008
--- pgsql.orig/src/backend/access/hash/hashutil.c	pá črn 13 18:00:35 2008
***
*** 164,170 
  	/*
  	 * Additionally check that the special area looks sane.
  	 */
! 	if (((PageHeader) (page))-pd_special !=
  		(BLCKSZ - MAXALIGN(sizeof(HashPageOpaqueData
  		ereport(ERROR,
  (errcode(ERRCODE_INDEX_CORRUPTED),
--- 164,170 
  	/*
  	 * Additionally check that the special area looks sane.
  	 */
! 	if ( PageGetSpecialPointer(page) - page !=
  		(BLCKSZ - MAXALIGN(sizeof(HashPageOpaqueData
  		ereport(ERROR,
  (errcode(ERRCODE_INDEX_CORRUPTED),
diff -cr pgsql.orig.da8c485e0e2a/src/backend/access/heap/heapam.c pgsql.orig/src/backend/access/heap/heapam.c
*** pgsql.orig.da8c485e0e2a/src/backend/access/heap/heapam.c	pá črn 13 18:00:35 2008
--- pgsql.orig/src/backend/access/heap/heapam.c	pá črn 13 18:00:35 2008
***
*** 1342,1348 
  	ItemPointer tid = (tuple-t_self);
  	ItemId		lp;
  	Buffer		buffer;
! 	PageHeader	dp;
  	OffsetNumber offnum;
  	bool		valid;
  
--- 1342,1348 
  	ItemPointer tid = (tuple-t_self);
  	ItemId		lp;
  	Buffer		buffer;
! 	Page		page;
  	OffsetNumber offnum;
  	bool		valid;
  
***
*** 1355,1361 
  	 * Need share lock on buffer to examine tuple commit status.
  	 */
  	LockBuffer(buffer, BUFFER_LOCK_SHARE);
! 	dp = (PageHeader) BufferGetPage(buffer);
  
  	/*
  	 * We'd better check for out-of-range offnum in case of VACUUM since the
--- 1355,1361 
  	 * Need share lock on buffer to examine tuple commit status.
  	 */
  	LockBuffer(buffer, BUFFER_LOCK_SHARE);
! 	page = BufferGetPage(buffer);
  
  	/*
  	 * We'd better check for out-of-range offnum in case of VACUUM since the
***
*** 1362,1368 
  	 * TID was obtained.
  	 */
  	offnum = ItemPointerGetOffsetNumber(tid);
! 	if (offnum  FirstOffsetNumber || offnum  PageGetMaxOffsetNumber(dp))
  	{
  		LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
  		if (keep_buf)
--- 1362,1368 
  	 * TID was obtained.
  	 */
  	offnum = ItemPointerGetOffsetNumber(tid);
! 	if (offnum  FirstOffsetNumber || offnum  PageGetMaxOffsetNumber(page))
  	{
  		LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
  		if (keep_buf)
***
*** 1379,1385 
  	/*
  	 * get the item line pointer corresponding to the requested tid
  	 */
! 	lp = PageGetItemId(dp, offnum);
  
  	/*
  	 * Must check for deleted tuple.
--- 1379,1385 
  	/*
  	 * get the item line pointer corresponding to the requested tid
  	 */
! 	lp = PageGetItemId(page, offnum);
  
  	/*
  	 * Must check for deleted tuple.
***
*** 1401,1407 
  	/*
  	 * fill in *tuple fields
  	 */
! 	tuple-t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
  	tuple-t_len = ItemIdGetLength(lp);
  	tuple-t_tableOid = RelationGetRelid(relation);
  
--- 1401,1407 
  	/*
  	 * fill in *tuple fields
  	 */
! 	tuple-t_data = (HeapTupleHeader) PageGetItem(page, 

Re: [PATCHES] Simplify formatting.c

2008-06-13 Thread Bruce Momjian
Tom Lane wrote:
 Euler Taveira de Oliveira [EMAIL PROTECTED] writes:
  Tom Lane wrote:
  Also, it seems a bit inconsistent to be relying on
  oracle_compat.c for upper/lower but not initcap.
  
  I saw this inconsistence while I'm doing the patch. What about moving 
  that upper/lower/initcap and wcs* code to another file. pg_locale.c? 
 
 That doesn't seem a particularly appropriate place for them.  pg_locale
 is about dealing with the locale state, not about doing actual
 operations based on the locale data.
 
 I was just thinking of having oracle_compat expose an initcap routine.

You mean like the attached?

I moved str_initcap() over into oracle_compat.c and then had initcap()
convert to/from TEXT to call it.  The code is a little weird because
str_initcap() needs to convert to text to use texttowcs(), so in
multibyte encodings initcap converts the string to text, then to char,
then to text to call texttowcs().  I didn't see a cleaner way to do
this.

-- 
  Bruce Momjian  [EMAIL PROTECTED]http://momjian.us
  EnterpriseDB http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: src/backend/utils/adt/formatting.c
===
RCS file: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v
retrieving revision 1.141
diff -c -c -r1.141 formatting.c
*** src/backend/utils/adt/formatting.c	20 May 2008 01:41:02 -	1.141
--- src/backend/utils/adt/formatting.c	13 Jun 2008 22:01:18 -
***
*** 927,933 
  static int	strdigits_len(char *str);
  static char *str_toupper(char *buff);
  static char *str_tolower(char *buff);
- static char *str_initcap(char *buff);
  
  static int	seq_search(char *name, char **array, int type, int max, int *len);
  static void do_to_timestamp(text *date_txt, text *fmt,
--- 927,932 
***
*** 1484,1549 
  }

  /* --
-  * wide-character-aware initcap function
-  * --
-  */
- static char *
- str_initcap(char *buff)
- {
- 	char		*result;
- 	bool		wasalnum = false;
- 
- 	if (!buff)
- 		return NULL;
- 
- #ifdef USE_WIDE_UPPER_LOWER
- 	if (pg_database_encoding_max_length()  1  !lc_ctype_is_c())
- 	{
- 		wchar_t		*workspace;
- 		text		*in_text;
- 		text		*out_text;
- 		int			i;
- 
- 		in_text = cstring_to_text(buff);
- 		workspace = texttowcs(in_text);
- 
- 		for (i = 0; workspace[i] != 0; i++)
- 		{
- 			if (wasalnum)
- workspace[i] = towlower(workspace[i]);
- 			else
- workspace[i] = towupper(workspace[i]);
- 			wasalnum = iswalnum(workspace[i]);
- 		}
- 
- 		out_text = wcstotext(workspace, i);
- 		result = text_to_cstring(out_text);
- 
- 		pfree(workspace);
- 		pfree(in_text);
- 		pfree(out_text);
- 	}
- 	else
- #endif		/* USE_WIDE_UPPER_LOWER */
- 	{
- 		char *p;
- 
- 		result = pstrdup(buff);
- 
- 		for (p = result; *p; p++)
- 		{
- 			if (wasalnum)
- *p = pg_tolower((unsigned char) *p);
- 			else
- *p = pg_toupper((unsigned char) *p);
- 			wasalnum = isalnum((unsigned char) *p);
- 		}
- 	}
- 
- 	return result;
- }
- 
- /* --
   * Sequential search with to upper/lower conversion
   * --
   */
--- 1483,1488 
Index: src/backend/utils/adt/oracle_compat.c
===
RCS file: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v
retrieving revision 1.79
diff -c -c -r1.79 oracle_compat.c
*** src/backend/utils/adt/oracle_compat.c	19 May 2008 18:08:16 -	1.79
--- src/backend/utils/adt/oracle_compat.c	13 Jun 2008 22:01:18 -
***
*** 471,478 
  Datum
  initcap(PG_FUNCTION_ARGS)
  {
! #ifdef USE_WIDE_UPPER_LOWER
  
  	/*
  	 * Use wide char code only when max encoding length  1 and ctype != C.
  	 * Some operating systems fail with multi-byte encodings and a C locale.
--- 471,496 
  Datum
  initcap(PG_FUNCTION_ARGS)
  {
! 	text	   *string = PG_GETARG_TEXT_PP(0);
! 	char	   *str2;
! 
! 	str2 = str_initcap(DatumGetCString(string));
! 	string = cstring_to_text(str2);
! 	pfree(str2);
! 	PG_RETURN_TEXT_P(string);
! }
! 
  
+ char *
+ str_initcap(char *str)
+ {
+ 	char		*result;
+ 	int			wasalnum = 0;
+ 
+ 	if (!str)
+ 		return NULL;
+ 
+ #ifdef USE_WIDE_UPPER_LOWER
  	/*
  	 * Use wide char code only when max encoding length  1 and ctype != C.
  	 * Some operating systems fail with multi-byte encodings and a C locale.
***
*** 480,492 
  	 */
  	if (pg_database_encoding_max_length()  1  !lc_ctype_is_c())
  	{
- 		text	   *string = PG_GETARG_TEXT_PP(0);
- 		text	   *result;
  		wchar_t*workspace;
! 		int			wasalnum = 0;
  		int			i;
  
! 		workspace = texttowcs(string);
  
  		for (i = 0; workspace[i] != 0; i++)
  		{
--- 498,510 
  	 */
  	if (pg_database_encoding_max_length()  1  !lc_ctype_is_c())
  	{
  		wchar_t*workspace;
! 		text		*in_text;
! 		text		*out_text;
  		int			i;
  
! 		in_text = cstring_to_text(str);
! 		workspace = texttowcs(in_text);
  
  		for (i = 0;