XLogRecPtrIsInvalid() only checks the xrecoff field, which is correct when
checking if a WAL record could legally begin at the given position, but WAL
sending can legally be paused at a page boundary, in which case xrecoff is
0. Use XLByteEQ(..., InvalidXLogRecPtr) instead, which checks that both
xlogid and xrecoff are 0.
9.3 doesn't have this problem because XLogRecPtr is now a single 64-bit
integer, so XLogRecPtrIsInvalid() does the right thing. Apply to 9.2, and
9.1 where pg_stat_replication view was introduced.
Kyotaro HORIGUCHI, reviewed by Fujii Masao.
 
 #include <unistd.h>
 
+#include "access/transam.h"
 #include "access/xact.h"
 #include "miscadmin.h"
 #include "replication/syncrep.h"
     */
    if (MyWalSnd->sync_standby_priority == 0 ||
        MyWalSnd->state < WALSNDSTATE_STREAMING ||
-       XLogRecPtrIsInvalid(MyWalSnd->flush))
+       XLByteEQ(MyWalSnd->flush, InvalidXLogRecPtr))
        return;
 
    /*
            walsnd->sync_standby_priority > 0 &&
            (priority == 0 ||
             priority > walsnd->sync_standby_priority) &&
-           !XLogRecPtrIsInvalid(walsnd->flush))
+           !XLByteEQ(walsnd->flush, InvalidXLogRecPtr))
        {
            priority = walsnd->sync_standby_priority;
            syncWalSnd = walsnd;
 
             * which always returns an invalid flush location, as an
             * asynchronous standby.
             */
-           sync_priority[i] = XLogRecPtrIsInvalid(walsnd->flush) ?
+           sync_priority[i] = XLByteEQ(walsnd->flush, InvalidXLogRecPtr) ?
                0 : walsnd->sync_standby_priority;
 
            if (walsnd->state == WALSNDSTATE_STREAMING &&
                walsnd->sync_standby_priority > 0 &&
                (priority == 0 ||
                 priority > walsnd->sync_standby_priority) &&
-               !XLogRecPtrIsInvalid(walsnd->flush))
+               !XLByteEQ(walsnd->flush, InvalidXLogRecPtr))
            {
                priority = walsnd->sync_standby_priority;
                sync_standby = i;