Skip site navigation (1) Skip section navigation (2)

Re: Small code clean-up

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: Small code clean-up
Date: 2007-03-29 22:46:51
Message-ID: 200703292246.l2TMkpw21498@momjian.us (view raw or flat)
Thread:
Lists: pgsql-patches
I have applied the initdb part of this patch, and Magnus did the
win32_shmem part.  Thanks.

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

ITAGAKI Takahiro wrote:
> Here are two small code clean-up in initdb and win32_shmem.
> 
> pg_char_to_encoding() was redundant in initdb because
> pg_valid_server_encoding() returns the same result if the encoding is valid,
> 
> Changes in win32_shmem suppress the following warnings.
> | pg_shmem.c: In function `PGSharedMemoryCreate':
> | pg_shmem.c:137: warning: long unsigned int format, Size arg (arg 2)
> | pg_shmem.c:159: warning: long unsigned int format, Size arg (arg 2)
> 
> 
> *** initdb.c.orig	Mon Mar 19 01:50:43 2007
> --- initdb.c	Wed Mar 28 10:02:42 2007
> *************** get_encoding_id(char *encoding_name)
> *** 709,716 ****
>   
>   	if (encoding_name && *encoding_name)
>   	{
> ! 		if ((enc = pg_char_to_encoding(encoding_name)) >= 0 &&
> ! 			pg_valid_server_encoding(encoding_name) >= 0)
>   			return encodingid_to_string(enc);
>   	}
>   	fprintf(stderr, _("%s: \"%s\" is not a valid server encoding name\n"),
> --- 709,715 ----
>   
>   	if (encoding_name && *encoding_name)
>   	{
> ! 		if ((enc = pg_valid_server_encoding(encoding_name)) >= 0)
>   			return encodingid_to_string(enc);
>   	}
>   	fprintf(stderr, _("%s: \"%s\" is not a valid server encoding name\n"),
> 
> 
> *** win32_shmem.c.orig	Wed Mar 28 10:17:14 2007
> --- win32_shmem.c	Wed Mar 28 10:16:36 2007
> *************** PGSharedMemoryCreate(Size size, bool mak
> *** 136,142 ****
>   	if (!hmap)
>   		ereport(FATAL,
>   				(errmsg("could not create shared memory segment: %lu", GetLastError()),
> ! 				 errdetail("Failed system call was CreateFileMapping(size=%lu, name=%s)", size, szShareMem)));
>   
>   	/*
>   	 * If the segment already existed, CreateFileMapping() will return a
> --- 136,142 ----
>   	if (!hmap)
>   		ereport(FATAL,
>   				(errmsg("could not create shared memory segment: %lu", GetLastError()),
> ! 				 errdetail("Failed system call was CreateFileMapping(size=%lu, name=%s)", (unsigned long) size, szShareMem)));
>   
>   	/*
>   	 * If the segment already existed, CreateFileMapping() will return a
> *************** PGSharedMemoryCreate(Size size, bool mak
> *** 158,164 ****
>   		if (!hmap)
>   			ereport(FATAL,
>   					(errmsg("could not create shared memory segment: %lu", GetLastError()),
> ! 					 errdetail("Failed system call was CreateFileMapping(size=%lu, name=%s)", size, szShareMem)));
>   
>   		if (GetLastError() == ERROR_ALREADY_EXISTS)
>   			ereport(FATAL,
> --- 158,164 ----
>   		if (!hmap)
>   			ereport(FATAL,
>   					(errmsg("could not create shared memory segment: %lu", GetLastError()),
> ! 					 errdetail("Failed system call was CreateFileMapping(size=%lu, name=%s)", (unsigned long) size, szShareMem)));
>   
>   		if (GetLastError() == ERROR_ALREADY_EXISTS)
>   			ereport(FATAL,
> 
> 
> Regards,
> ---
> ITAGAKI Takahiro
> NTT Open Source Software Center
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 7: You can help support the PostgreSQL project by donating at
> 
>                 http://www.postgresql.org/about/donate

-- 
  Bruce Momjian  <bruce(at)momjian(dot)us>          http://momjian.us
  EnterpriseDB                               http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

In response to

pgsql-patches by date

Next:From: Bruce MomjianDate: 2007-03-29 22:50:30
Subject: Re: Patch for circular buffer in tuplestore to optimize merge joins (v1)
Previous:From: Neil ConwayDate: 2007-03-29 22:39:08
Subject: Re: DEALLOCATE ALL

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group