Make-xlog-filename-formatters-usable-while-in-recovery-v1.patch
application/octet-stream
Filename: Make-xlog-filename-formatters-usable-while-in-recovery-v1.patch
Type: application/octet-stream
Part: 0
From 7703e840bb4606da87ed62385eabeb2e177cfdeb Mon Sep 17 00:00:00 2001
From: Daniel Farina <daniel@heroku.com>
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 <daniel@heroku.com>
---
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);
<primary>pg_switch_xlog</primary>
</indexterm>
<indexterm>
- <primary>pg_xlogfile_name</primary>
- </indexterm>
- <indexterm>
- <primary>pg_xlogfile_name_offset</primary>
- </indexterm>
- <indexterm>
<primary>pg_xlog_location_diff</primary>
</indexterm>
--- 14469,14474 ----
***************
*** 14551,14577 **** SELECT set_config('log_statement_stats', 'off', false);
<entry><type>text</type></entry>
<entry>Force switch to a new transaction log file (restricted to superusers)</entry>
</row>
- <row>
- <entry>
- <literal><function>pg_xlogfile_name(<parameter>location</> <type>text</>)</function></literal>
- </entry>
- <entry><type>text</type></entry>
- <entry>Convert transaction log location string to file name</entry>
- </row>
- <row>
- <entry>
- <literal><function>pg_xlogfile_name_offset(<parameter>location</> <type>text</>)</function></literal>
- </entry>
- <entry><type>text</>, <type>integer</></entry>
- <entry>Convert transaction log location string to file name and decimal byte offset within file</entry>
- </row>
- <row>
- <entry>
- <literal><function>pg_xlog_location_diff(<parameter>location</> <type>text</>, <parameter>location</> <type>text</>)</function></literal>
- </entry>
- <entry><type>numeric</></entry>
- <entry>Calculate the difference between two transaction log locations</entry>
- </row>
</tbody>
</tgroup>
</table>
--- 14545,14550 ----
***************
*** 14693,14698 **** postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
--- 14666,14677 ----
<indexterm>
<primary>pg_last_xact_replay_timestamp</primary>
</indexterm>
+ <indexterm>
+ <primary>pg_xlogfile_name</primary>
+ </indexterm>
+ <indexterm>
+ <primary>pg_xlogfile_name_offset</primary>
+ </indexterm>
<para>
The functions shown in <xref
***************
*** 14761,14766 **** postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
--- 14740,14769 ----
the function returns NULL.
</entry>
</row>
+ <row>
+ <entry>
+ <literal><function>pg_xlogfile_name(<parameter>location</> <type>text</>)</function></literal>
+ </entry>
+ <entry><type>text</type></entry>
+ <entry>Convert transaction log location string to file
+ name</entry>
+ </row>
+ <row>
+ <entry>
+ <literal><function>pg_xlogfile_name_offset(<parameter>location</> <type>text</>)</function></literal>
+ </entry>
+ <entry><type>text</>, <type>integer</></entry>
+ <entry>Convert transaction log location string to file name and
+ decimal byte offset within file</entry>
+ </row>
+ <row>
+ <entry>
+ <literal><function>pg_xlog_location_diff(<parameter>location</> <type>text</>, <parameter>location</> <type>text</>)</function></literal>
+ </entry>
+ <entry><type>numeric</></entry>
+ <entry>Calculate the difference between two transaction log
+ locations</entry>
+ </row>
</tbody>
</tgroup>
</table>
*** 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 ----