Commit 346d7cd7 authored by Heikki Linnakangas's avatar Heikki Linnakangas

Return NULL instead of 0/0 in pg_last_xlog_receive_location() and

pg_last_xlog_replay_location(). Per Robert Haas's suggestion, after
Itagaki Takahiro pointed out an issue in the docs. Also, some wording
changes in the docs by me.
parent 4ddf151c
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.517 2010/06/05 14:56:36 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.518 2010/06/10 07:00:25 heikki Exp $ -->
<chapter id="functions"> <chapter id="functions">
<title>Functions and Operators</title> <title>Functions and Operators</title>
...@@ -13280,13 +13280,12 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup()); ...@@ -13280,13 +13280,12 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
<literal><function>pg_last_xlog_receive_location</function>()</literal> <literal><function>pg_last_xlog_receive_location</function>()</literal>
</entry> </entry>
<entry><type>text</type></entry> <entry><type>text</type></entry>
<entry>Get last transaction log location received and synced to disk during <entry>Get last transaction log location received and synced to disk by
streaming recovery. If streaming recovery is still in progress streaming replication. While streaming replication is in progress
this will increase monotonically. If streaming recovery has completed this will increase monotonically. If recovevery has completed
then this value will remain static at the value of the last WAL record this will remain static at the value of the last WAL record
received and synced to disk during that recovery. When the server has received and synced to disk during recovery. If streaming replication
been started without a streaming recovery then the return value will be is disabled, or it has not yet started, the function returns NULL.
InvalidXLogRecPtr (0/0).
</entry> </entry>
</row> </row>
<row> <row>
...@@ -13298,8 +13297,8 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup()); ...@@ -13298,8 +13297,8 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
If recovery is still in progress this will increase monotonically. If recovery is still in progress this will increase monotonically.
If recovery has completed then this value will remain static at If recovery has completed then this value will remain static at
the value of the last WAL record applied during that recovery. the value of the last WAL record applied during that recovery.
When the server has been started normally without a recovery When the server has been started normally without recovery
then the return value will be InvalidXLogRecPtr (0/0). the function returns NULL.
</entry> </entry>
</row> </row>
</tbody> </tbody>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.419 2010/06/09 15:04:06 heikki Exp $ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.420 2010/06/10 07:00:27 heikki Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -8757,6 +8757,9 @@ pg_last_xlog_receive_location(PG_FUNCTION_ARGS) ...@@ -8757,6 +8757,9 @@ pg_last_xlog_receive_location(PG_FUNCTION_ARGS)
recptr = GetWalRcvWriteRecPtr(); recptr = GetWalRcvWriteRecPtr();
if (recptr.xlogid == 0 && recptr.xrecoff == 0)
PG_RETURN_NULL();
snprintf(location, sizeof(location), "%X/%X", snprintf(location, sizeof(location), "%X/%X",
recptr.xlogid, recptr.xrecoff); recptr.xlogid, recptr.xrecoff);
PG_RETURN_TEXT_P(cstring_to_text(location)); PG_RETURN_TEXT_P(cstring_to_text(location));
...@@ -8780,6 +8783,9 @@ pg_last_xlog_replay_location(PG_FUNCTION_ARGS) ...@@ -8780,6 +8783,9 @@ pg_last_xlog_replay_location(PG_FUNCTION_ARGS)
recptr = xlogctl->recoveryLastRecPtr; recptr = xlogctl->recoveryLastRecPtr;
SpinLockRelease(&xlogctl->info_lck); SpinLockRelease(&xlogctl->info_lck);
if (recptr.xlogid == 0 && recptr.xrecoff == 0)
PG_RETURN_NULL();
snprintf(location, sizeof(location), "%X/%X", snprintf(location, sizeof(location), "%X/%X",
recptr.xlogid, recptr.xrecoff); recptr.xlogid, recptr.xrecoff);
PG_RETURN_TEXT_P(cstring_to_text(location)); PG_RETURN_TEXT_P(cstring_to_text(location));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment