Index: doc/src/sgml/runtime.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v
retrieving revision 1.335
diff -c -c -r1.335 runtime.sgml
*** doc/src/sgml/runtime.sgml	2 Jul 2005 19:16:36 -0000	1.335
--- doc/src/sgml/runtime.sgml	5 Jul 2005 23:15:33 -0000
***************
*** 1660,1666 ****
  
         
          This option can only be set at server start or in the
!         postgresql.conf file.
         
        
       
--- 1660,1668 ----
  
         
          This option can only be set at server start or in the
!         postgresql.conf file.  If this option
!         is off>, consider also turning off 
!         guc-full-page-writes>.
         
        
       
***************
*** 1687,1692 ****
--- 1689,1725 ----
        
       
       
+      
+       
+        full_page_writes> configuration parameter
+       
+       full_page_writes (boolean)
+       
+        
+         A page write in process during an operating system crash might
+         be only partially written to disk, leading to an on-disk page
+         that contains a mix of old and new data. During recovery, the
+         row changes stored in WAL are not enough to completely restore
+         the page.
+        
+ 
+        
+         When this option is on, the PostgreSQL> server
+         writes full pages to WAL when they first modified after a checkpoint
+         so full recovery is possible. Turning this option off might lead
+         to a corrupt system after an operating system crash because
+         uncorrected partial pages might contain inconsistent or corrupt
+         data. The risks are less but similar to fsync>.
+        
+ 
+        
+         This option can only be set at server start or in the
+         postgresql.conf file.  The default is
+         on>.
+        
+       
+      
+      
       
        wal_buffers (integer)
        
Index: src/backend/access/transam/xlog.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v
retrieving revision 1.206
diff -c -c -r1.206 xlog.c
*** src/backend/access/transam/xlog.c	4 Jul 2005 04:51:44 -0000	1.206
--- src/backend/access/transam/xlog.c	5 Jul 2005 23:15:36 -0000
***************
*** 103,108 ****
--- 103,109 ----
  char	   *XLogArchiveCommand = NULL;
  char	   *XLOG_sync_method = NULL;
  const char	XLOG_sync_method_default[] = DEFAULT_SYNC_METHOD_STR;
+ bool		fullPageWrites = true;
  
  #ifdef WAL_DEBUG
  bool		XLOG_DEBUG = false;
***************
*** 594,600 ****
  				{
  					/* OK, put it in this slot */
  					dtbuf[i] = rdt->buffer;
! 					if (XLogCheckBuffer(rdt, &(dtbuf_lsn[i]), &(dtbuf_xlg[i])))
  					{
  						dtbuf_bkp[i] = true;
  						rdt->data = NULL;
--- 595,603 ----
  				{
  					/* OK, put it in this slot */
  					dtbuf[i] = rdt->buffer;
! 					/* If fsync is off, no need to backup pages. */
! 					if (fullPageWrites &&
! 						XLogCheckBuffer(rdt, &(dtbuf_lsn[i]), &(dtbuf_xlg[i])))
  					{
  						dtbuf_bkp[i] = true;
  						rdt->data = NULL;
Index: src/backend/utils/misc/guc.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v
retrieving revision 1.272
diff -c -c -r1.272 guc.c
*** src/backend/utils/misc/guc.c	4 Jul 2005 04:51:51 -0000	1.272
--- src/backend/utils/misc/guc.c	5 Jul 2005 23:15:39 -0000
***************
*** 83,88 ****
--- 83,89 ----
  extern int	CommitDelay;
  extern int	CommitSiblings;
  extern char *default_tablespace;
+ extern bool	fullPageWrites;
  
  static const char *assign_log_destination(const char *value,
  					   bool doit, GucSource source);
***************
*** 483,488 ****
--- 484,501 ----
  		false, NULL, NULL
  	},
  	{
+ 		{"full_page_writes", PGC_SIGHUP, WAL_SETTINGS,
+ 			gettext_noop("Writes full pages to WAL when first modified after a checkpoint."),
+ 			gettext_noop("A page write in process during an operating system crash might be "
+ 						 "only partially written to disk.  During recovery, the row changes"
+ 						 "stored in WAL are not enough to recover.  This option writes "
+ 						 "pages when first modified after a checkpoint to WAL so full recovery "
+ 						 "is possible.")
+ 		},
+ 		&fullPageWrites,
+ 		true, NULL, NULL
+ 	},
+ 	{
  		{"silent_mode", PGC_POSTMASTER, LOGGING_WHEN,
  			gettext_noop("Runs the server silently."),
  			gettext_noop("If this parameter is set, the server will automatically run in the "
Index: src/backend/utils/misc/postgresql.conf.sample
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/misc/postgresql.conf.sample,v
retrieving revision 1.151
diff -c -c -r1.151 postgresql.conf.sample
*** src/backend/utils/misc/postgresql.conf.sample	2 Jul 2005 18:46:45 -0000	1.151
--- src/backend/utils/misc/postgresql.conf.sample	5 Jul 2005 23:15:39 -0000
***************
*** 121,126 ****
--- 121,127 ----
  #wal_sync_method = fsync	# the default varies across platforms:
  				# fsync, fdatasync, fsync_writethrough,
  				# open_sync, open_datasync
+ #full_page_writes = on		# recover from partial page writes
  #wal_buffers = 8		# min 4, 8KB each
  #commit_delay = 0		# range 0-100000, in microseconds
  #commit_siblings = 5		# range 1-1000