]> granicus.if.org Git - postgresql/commitdiff
Forbid using pg_xlogfile_name() and pg_xlogfile_name_offset() during
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 7 Apr 2010 06:12:52 +0000 (06:12 +0000)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 7 Apr 2010 06:12:52 +0000 (06:12 +0000)
recovery. We might want to relax this in the future, but ThisTimeLineID
isn't currently correct in backends during recovery, so the filename
returned was wrong.

doc/src/sgml/func.sgml
src/backend/access/transam/xlog.c

index 4aa78728e3bd7555fa16a7516fb07c125e958745..7a18c92d312296b193672dee1c7d81b0d361be2f 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.512 2010/04/03 07:53:02 petere Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.513 2010/04/07 06:12:52 heikki Exp $ -->
 
  <chapter id="functions">
   <title>Functions and Operators</title>
@@ -13064,8 +13064,8 @@ SELECT set_config('log_statement_stats', 'off', false);
    <para>
     The functions shown in <xref
     linkend="functions-admin-backup-table"> assist in making on-line backups.
-    Use of the first three functions is restricted to superusers. The first
-    five functions cannot be executed during recovery.
+    These functions cannot be executed during recovery.
+    Use of the first three functions is restricted to superusers.
    </para>
 
    <table id="functions-admin-backup-table">
index ce6d561d5be36c7c265e15af128da83b68a776e0..592419d356741a1371d1c7ecf25129ba55a24e2d 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.389 2010/04/06 17:51:58 sriggs Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.390 2010/04/07 06:12:52 heikki Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -8410,6 +8410,12 @@ 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
         */
@@ -8479,6 +8485,12 @@ 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);
 
        if (sscanf(locationstr, "%X/%X", &uxlogid, &uxrecoff) != 2)