From 7703e840bb4606da87ed62385eabeb2e177cfdeb Mon Sep 17 00:00:00 2001 From: Daniel Farina Date: Tue, 3 Jul 2012 00:59:59 -0700 Subject: [PATCH] Make xlog filename formatters usable while in recovery Previously, these reporting functions were unusable with pg_last_xlog_receive_location and pg_last_xlog_replay_location. Signed-off-by: Daniel Farina --- doc/src/sgml/func.sgml | 57 +++++++++++++++++--------------- src/backend/access/transam/xlogfuncs.c | 12 ------- 2 files changed, 30 insertions(+), 39 deletions(-) *** a/doc/src/sgml/func.sgml --- b/doc/src/sgml/func.sgml *************** *** 14469,14480 **** SELECT set_config('log_statement_stats', 'off', false); pg_switch_xlog - pg_xlogfile_name - - - pg_xlogfile_name_offset - - pg_xlog_location_diff --- 14469,14474 ---- *************** *** 14551,14577 **** SELECT set_config('log_statement_stats', 'off', false); text Force switch to a new transaction log file (restricted to superusers) - - - pg_xlogfile_name(location text) - - text - Convert transaction log location string to file name - - - - pg_xlogfile_name_offset(location text) - - text, integer - Convert transaction log location string to file name and decimal byte offset within file - - - - pg_xlog_location_diff(location text, location text) - - numeric - Calculate the difference between two transaction log locations - --- 14545,14550 ---- *************** *** 14693,14698 **** postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup()); --- 14666,14677 ---- pg_last_xact_replay_timestamp + + pg_xlogfile_name + + + pg_xlogfile_name_offset + The functions shown in + + + pg_xlogfile_name(location text) + + text + Convert transaction log location string to file + name + + + + pg_xlogfile_name_offset(location text) + + text, integer + Convert transaction log location string to file name and + decimal byte offset within file + + + + pg_xlog_location_diff(location text, location text) + + numeric + Calculate the difference between two transaction log + locations + *** a/src/backend/access/transam/xlogfuncs.c --- b/src/backend/access/transam/xlogfuncs.c *************** *** 281,292 **** pg_xlogfile_name_offset(PG_FUNCTION_ARGS) HeapTuple resultHeapTuple; Datum result; - if (RecoveryInProgress()) - ereport(ERROR, - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("recovery is in progress"), - errhint("pg_xlogfile_name_offset() cannot be executed during recovery."))); - /* * Read input and parse */ --- 281,286 ---- *************** *** 355,366 **** pg_xlogfile_name(PG_FUNCTION_ARGS) XLogRecPtr locationpoint; char xlogfilename[MAXFNAMELEN]; - if (RecoveryInProgress()) - ereport(ERROR, - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("recovery is in progress"), - errhint("pg_xlogfile_name() cannot be executed during recovery."))); - locationstr = text_to_cstring(location); validate_xlog_location(locationstr); --- 349,354 ----