appendStringInfo(buf, "pageno %d, oldestXid %u",
trunc->pageno, trunc->oldestXid);
}
- else if (info == COMMIT_TS_SETTS)
- {
- xl_commit_ts_set *xlrec = (xl_commit_ts_set *) rec;
- int nsubxids;
-
- appendStringInfo(buf, "set %s/%d for: %u",
- timestamptz_to_str(xlrec->timestamp),
- xlrec->nodeid,
- xlrec->mainxid);
- nsubxids = ((XLogRecGetDataLen(record) - SizeOfCommitTsSet) /
- sizeof(TransactionId));
- if (nsubxids > 0)
- {
- int i;
- TransactionId *subxids;
-
- subxids = palloc(sizeof(TransactionId) * nsubxids);
- memcpy(subxids,
- XLogRecGetData(record) + SizeOfCommitTsSet,
- sizeof(TransactionId) * nsubxids);
- for (i = 0; i < nsubxids; i++)
- appendStringInfo(buf, ", %u", subxids[i]);
- pfree(subxids);
- }
- }
}
const char *
return "ZEROPAGE";
case COMMIT_TS_TRUNCATE:
return "TRUNCATE";
- case COMMIT_TS_SETTS:
- return "SETTS";
default:
return NULL;
}
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXid);
-static void WriteSetTimestampXlogRec(TransactionId mainxid, int nsubxids,
- TransactionId *subxids, TimestampTz timestamp,
- RepOriginId nodeid);
/*
* TransactionTreeSetCommitTsData
* permanent) so we need to keep the information about them here. If the
* subtrans implementation changes in the future, we might want to revisit the
* decision of storing timestamp info for each subxid.
- *
- * The write_xlog parameter tells us whether to include an XLog record of this
- * or not. Normally, this is called from transaction commit routines (both
- * normal and prepared) and the information will be stored in the transaction
- * commit XLog record, and so they should pass "false" for this. The XLog redo
- * code should use "false" here as well. Other callers probably want to pass
- * true, so that the given values persist in case of crashes.
*/
void
TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz timestamp,
- RepOriginId nodeid, bool write_xlog)
+ RepOriginId nodeid)
{
int i;
TransactionId headxid;
if (!commitTsShared->commitTsActive)
return;
- /*
- * Comply with the WAL-before-data rule: if caller specified it wants this
- * value to be recorded in WAL, do so before touching the data.
- */
- if (write_xlog)
- WriteSetTimestampXlogRec(xid, nsubxids, subxids, timestamp, nodeid);
-
/*
* Figure out the latest Xid in this batch: either the last subxid if
* there's any, otherwise the parent xid.
(void) XLogInsert(RM_COMMIT_TS_ID, COMMIT_TS_TRUNCATE);
}
-/*
- * Write a SETTS xlog record
- */
-static void
-WriteSetTimestampXlogRec(TransactionId mainxid, int nsubxids,
- TransactionId *subxids, TimestampTz timestamp,
- RepOriginId nodeid)
-{
- xl_commit_ts_set record;
-
- record.timestamp = timestamp;
- record.nodeid = nodeid;
- record.mainxid = mainxid;
-
- XLogBeginInsert();
- XLogRegisterData((char *) &record,
- offsetof(xl_commit_ts_set, mainxid) +
- sizeof(TransactionId));
- XLogRegisterData((char *) subxids, nsubxids * sizeof(TransactionId));
- XLogInsert(RM_COMMIT_TS_ID, COMMIT_TS_SETTS);
-}
-
/*
* CommitTS resource manager's routines
*/
SimpleLruTruncate(CommitTsCtl, trunc->pageno);
}
- else if (info == COMMIT_TS_SETTS)
- {
- xl_commit_ts_set *setts = (xl_commit_ts_set *) XLogRecGetData(record);
- int nsubxids;
- TransactionId *subxids;
-
- nsubxids = ((XLogRecGetDataLen(record) - SizeOfCommitTsSet) /
- sizeof(TransactionId));
- if (nsubxids > 0)
- {
- subxids = palloc(sizeof(TransactionId) * nsubxids);
- memcpy(subxids,
- XLogRecGetData(record) + SizeOfCommitTsSet,
- sizeof(TransactionId) * nsubxids);
- }
- else
- subxids = NULL;
-
- TransactionTreeSetCommitTsData(setts->mainxid, nsubxids, subxids,
- setts->timestamp, setts->nodeid, false);
- if (subxids)
- pfree(subxids);
- }
else
elog(PANIC, "commit_ts_redo: unknown op code %u", info);
}
extern void TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz timestamp,
- RepOriginId nodeid, bool write_xlog);
+ RepOriginId nodeid);
extern bool TransactionIdGetCommitTsData(TransactionId xid,
TimestampTz *ts, RepOriginId *nodeid);
extern TransactionId GetLatestCommitTsData(TimestampTz *ts,
/* XLOG stuff */
#define COMMIT_TS_ZEROPAGE 0x00
#define COMMIT_TS_TRUNCATE 0x10
-#define COMMIT_TS_SETTS 0x20
typedef struct xl_commit_ts_set
{