restore_name_timestamp_v1.patch

application/octet-stream

Filename: restore_name_timestamp_v1.patch
Type: application/octet-stream
Part: 0
Message: Re: Named restore points

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: context
Series: patch v1
File+
src/backend/access/transam/xlog.c 11 0
*** a/src/backend/access/transam/xlog.c
--- b/src/backend/access/transam/xlog.c
***************
*** 5228,5234 **** readRecoveryCommandFile(void)
  			if (strlen(recoveryTargetName) >= MAXFNAMELEN)
  				ereport(FATAL,
  						(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
! 						 errmsg("recovery_target_name is too long")));
  
  			ereport(DEBUG2,
  					(errmsg("recovery_target_name = '%s'",
--- 5228,5234 ----
  			if (strlen(recoveryTargetName) >= MAXFNAMELEN)
  				ereport(FATAL,
  						(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
! 						 errmsg("recovery_target_name is too long (max %d characters)", MAXFNAMELEN - 1)));
  
  			ereport(DEBUG2,
  					(errmsg("recovery_target_name = '%s'",
***************
*** 5448,5454 **** exitArchiveRecovery(TimeLineID endTLI, uint32 endLogId, uint32 endLogSeg)
   * Returns TRUE if we are stopping, FALSE otherwise.  On TRUE return,
   * *includeThis is set TRUE if we should apply this record before stopping.
   *
!  * We also track the timestamp of the latest applied COMMIT/ABORT/RESTORE POINT
   * record in XLogCtl->recoveryLastXTime, for logging purposes.
   * Also, some information is saved in recoveryStopXid et al for use in
   * annotating the new timeline's history file.
--- 5448,5454 ----
   * Returns TRUE if we are stopping, FALSE otherwise.  On TRUE return,
   * *includeThis is set TRUE if we should apply this record before stopping.
   *
!  * We also track the timestamp of the latest applied COMMIT/ABORT
   * record in XLogCtl->recoveryLastXTime, for logging purposes.
   * Also, some information is saved in recoveryStopXid et al for use in
   * annotating the new timeline's history file.
***************
*** 5493,5499 **** recoveryStopsHere(XLogRecord *record, bool *includeThis)
  	/* Do we have a PITR target at all? */
  	if (recoveryTarget == RECOVERY_TARGET_UNSET)
  	{
! 		SetLatestXTime(recordXtime);
  		return false;
  	}
  
--- 5493,5504 ----
  	/* Do we have a PITR target at all? */
  	if (recoveryTarget == RECOVERY_TARGET_UNSET)
  	{
! 		/*
! 		 * Save timestamp of latest transaction commit/abort if this is
! 		 * a transaction record
! 		 */
! 		if (record->xl_rmid == RM_XACT_ID)
! 			SetLatestXTime(recordXtime);
  		return false;
  	}
  
***************
*** 5583,5592 **** recoveryStopsHere(XLogRecord *record, bool *includeThis)
  								timestamptz_to_str(recoveryStopTime))));
  		}
  
! 		if (recoveryStopAfter)
  			SetLatestXTime(recordXtime);
  	}
! 	else
  		SetLatestXTime(recordXtime);
  
  	return stopsHere;
--- 5588,5597 ----
  								timestamptz_to_str(recoveryStopTime))));
  		}
  
! 		if (record->xl_rmid == RM_XACT_ID && recoveryStopAfter)
  			SetLatestXTime(recordXtime);
  	}
! 	else if (record->xl_rmid == RM_XACT_ID)
  		SetLatestXTime(recordXtime);
  
  	return stopsHere;
***************
*** 9220,9226 **** pg_create_restore_point(PG_FUNCTION_ARGS)
  	if (strlen(restore_name_str) >= MAXFNAMELEN)
  		ereport(ERROR,
  				(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
! 				 errmsg("value too long for restore point")));
  
  	restorepoint = XLogRestorePoint(restore_name_str);
  
--- 9225,9231 ----
  	if (strlen(restore_name_str) >= MAXFNAMELEN)
  		ereport(ERROR,
  				(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
! 				 errmsg("value too long for restore point (max %d characters)", MAXFNAMELEN - 1)));
  
  	restorepoint = XLogRestorePoint(restore_name_str);