diff --git a/src/backend/access/gin/ginxlog.c b/src/backend/access/gin/ginxlog.c
index 01297c3..21b5af9 100644
--- a/src/backend/access/gin/ginxlog.c
+++ b/src/backend/access/gin/ginxlog.c
@@ -719,7 +719,7 @@ desc_node(StringInfo buf, RelFileNode node, BlockNumber blkno)
 }
 
 void
-gin_desc(StringInfo buf, uint8 xl_info, char *rec)
+gin_desc(StringInfo buf, uint8 xl_info, const char *rec)
 {
 	uint8		info = xl_info & ~XLR_INFO_MASK;
 
@@ -727,49 +727,49 @@ gin_desc(StringInfo buf, uint8 xl_info, char *rec)
 	{
 		case XLOG_GIN_CREATE_INDEX:
 			appendStringInfo(buf, "Create index, ");
-			desc_node(buf, *(RelFileNode *) rec, GIN_ROOT_BLKNO);
+			desc_node(buf, *(const RelFileNode *) rec, GIN_ROOT_BLKNO);
 			break;
 		case XLOG_GIN_CREATE_PTREE:
 			appendStringInfo(buf, "Create posting tree, ");
-			desc_node(buf, ((ginxlogCreatePostingTree *) rec)->node, ((ginxlogCreatePostingTree *) rec)->blkno);
+			desc_node(buf, ((const ginxlogCreatePostingTree *) rec)->node, ((const ginxlogCreatePostingTree *) rec)->blkno);
 			break;
 		case XLOG_GIN_INSERT:
 			appendStringInfo(buf, "Insert item, ");
-			desc_node(buf, ((ginxlogInsert *) rec)->node, ((ginxlogInsert *) rec)->blkno);
+			desc_node(buf, ((const ginxlogInsert *) rec)->node, ((const ginxlogInsert *) rec)->blkno);
 			appendStringInfo(buf, " offset: %u nitem: %u isdata: %c isleaf %c isdelete %c updateBlkno:%u",
-							 ((ginxlogInsert *) rec)->offset,
-							 ((ginxlogInsert *) rec)->nitem,
-							 (((ginxlogInsert *) rec)->isData) ? 'T' : 'F',
-							 (((ginxlogInsert *) rec)->isLeaf) ? 'T' : 'F',
-							 (((ginxlogInsert *) rec)->isDelete) ? 'T' : 'F',
-							 ((ginxlogInsert *) rec)->updateBlkno
+							 ((const ginxlogInsert *) rec)->offset,
+							 ((const ginxlogInsert *) rec)->nitem,
+							 (((const ginxlogInsert *) rec)->isData) ? 'T' : 'F',
+							 (((const ginxlogInsert *) rec)->isLeaf) ? 'T' : 'F',
+							 (((const ginxlogInsert *) rec)->isDelete) ? 'T' : 'F',
+							 ((const ginxlogInsert *) rec)->updateBlkno
 				);
 
 			break;
 		case XLOG_GIN_SPLIT:
 			appendStringInfo(buf, "Page split, ");
-			desc_node(buf, ((ginxlogSplit *) rec)->node, ((ginxlogSplit *) rec)->lblkno);
-			appendStringInfo(buf, " isrootsplit: %c", (((ginxlogSplit *) rec)->isRootSplit) ? 'T' : 'F');
+			desc_node(buf, ((const ginxlogSplit *) rec)->node, ((const ginxlogSplit *) rec)->lblkno);
+			appendStringInfo(buf, " isrootsplit: %c", (((const ginxlogSplit *) rec)->isRootSplit) ? 'T' : 'F');
 			break;
 		case XLOG_GIN_VACUUM_PAGE:
 			appendStringInfo(buf, "Vacuum page, ");
-			desc_node(buf, ((ginxlogVacuumPage *) rec)->node, ((ginxlogVacuumPage *) rec)->blkno);
+			desc_node(buf, ((const ginxlogVacuumPage *) rec)->node, ((const ginxlogVacuumPage *) rec)->blkno);
 			break;
 		case XLOG_GIN_DELETE_PAGE:
 			appendStringInfo(buf, "Delete page, ");
-			desc_node(buf, ((ginxlogDeletePage *) rec)->node, ((ginxlogDeletePage *) rec)->blkno);
+			desc_node(buf, ((const ginxlogDeletePage *) rec)->node, ((const ginxlogDeletePage *) rec)->blkno);
 			break;
 		case XLOG_GIN_UPDATE_META_PAGE:
 			appendStringInfo(buf, "Update metapage, ");
-			desc_node(buf, ((ginxlogUpdateMeta *) rec)->node, ((ginxlogUpdateMeta *) rec)->metadata.tail);
+			desc_node(buf, ((const ginxlogUpdateMeta *) rec)->node, ((const ginxlogUpdateMeta *) rec)->metadata.tail);
 			break;
 		case XLOG_GIN_INSERT_LISTPAGE:
 			appendStringInfo(buf, "Insert new list page, ");
-			desc_node(buf, ((ginxlogInsertListPage *) rec)->node, ((ginxlogInsertListPage *) rec)->blkno);
+			desc_node(buf, ((const ginxlogInsertListPage *) rec)->node, ((const ginxlogInsertListPage *) rec)->blkno);
 			break;
 		case XLOG_GIN_DELETE_LISTPAGE:
-			appendStringInfo(buf, "Delete list pages (%d), ", ((ginxlogDeleteListPages *) rec)->ndeleted);
-			desc_node(buf, ((ginxlogDeleteListPages *) rec)->node, ((ginxlogDeleteListPages *) rec)->metadata.head);
+			appendStringInfo(buf, "Delete list pages (%d), ", ((const ginxlogDeleteListPages *) rec)->ndeleted);
+			desc_node(buf, ((const ginxlogDeleteListPages *) rec)->node, ((const ginxlogDeleteListPages *) rec)->metadata.head);
 			break;
 		default:
 			elog(PANIC, "gin_desc: unknown op code %u", info);
diff --git a/src/backend/access/gist/gistxlog.c b/src/backend/access/gist/gistxlog.c
index 8c32646..b78865b 100644
--- a/src/backend/access/gist/gistxlog.c
+++ b/src/backend/access/gist/gistxlog.c
@@ -341,14 +341,14 @@ out_target(StringInfo buf, RelFileNode node)
 }
 
 static void
-out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
+out_gistxlogPageUpdate(StringInfo buf, const gistxlogPageUpdate *xlrec)
 {
 	out_target(buf, xlrec->node);
 	appendStringInfo(buf, "; block number %u", xlrec->blkno);
 }
 
 static void
-out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
+out_gistxlogPageDelete(StringInfo buf, const gistxlogPageDelete *xlrec)
 {
 	appendStringInfo(buf, "page_delete: rel %u/%u/%u; blkno %u",
 				xlrec->node.spcNode, xlrec->node.dbNode, xlrec->node.relNode,
@@ -356,7 +356,7 @@ out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
 }
 
 static void
-out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
+out_gistxlogPageSplit(StringInfo buf, const gistxlogPageSplit *xlrec)
 {
 	appendStringInfo(buf, "page_split: ");
 	out_target(buf, xlrec->node);
@@ -365,7 +365,7 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
 }
 
 void
-gist_desc(StringInfo buf, uint8 xl_info, char *rec)
+gist_desc(StringInfo buf, uint8 xl_info, const char *rec)
 {
 	uint8		info = xl_info & ~XLR_INFO_MASK;
 
@@ -373,19 +373,19 @@ gist_desc(StringInfo buf, uint8 xl_info, char *rec)
 	{
 		case XLOG_GIST_PAGE_UPDATE:
 			appendStringInfo(buf, "page_update: ");
-			out_gistxlogPageUpdate(buf, (gistxlogPageUpdate *) rec);
+			out_gistxlogPageUpdate(buf, (const gistxlogPageUpdate *) rec);
 			break;
 		case XLOG_GIST_PAGE_DELETE:
-			out_gistxlogPageDelete(buf, (gistxlogPageDelete *) rec);
+			out_gistxlogPageDelete(buf, (const gistxlogPageDelete *) rec);
 			break;
 		case XLOG_GIST_PAGE_SPLIT:
-			out_gistxlogPageSplit(buf, (gistxlogPageSplit *) rec);
+			out_gistxlogPageSplit(buf, (const gistxlogPageSplit *) rec);
 			break;
 		case XLOG_GIST_CREATE_INDEX:
 			appendStringInfo(buf, "create_index: rel %u/%u/%u",
-							 ((RelFileNode *) rec)->spcNode,
-							 ((RelFileNode *) rec)->dbNode,
-							 ((RelFileNode *) rec)->relNode);
+							 ((const RelFileNode *) rec)->spcNode,
+							 ((const RelFileNode *) rec)->dbNode,
+							 ((const RelFileNode *) rec)->relNode);
 			break;
 		default:
 			appendStringInfo(buf, "unknown gist op code %u", info);
diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c
index 770b3ef..91f1195 100644
--- a/src/backend/access/hash/hash.c
+++ b/src/backend/access/hash/hash.c
@@ -714,6 +714,6 @@ hash_redo(XLogRecPtr lsn, XLogRecord *record)
 }
 
 void
-hash_desc(StringInfo buf, uint8 xl_info, char *rec)
+hash_desc(StringInfo buf, uint8 xl_info, const char *rec)
 {
 }
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index b2d1901..a4067c9 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5132,7 +5132,7 @@ heap2_redo(XLogRecPtr lsn, XLogRecord *record)
 }
 
 static void
-out_target(StringInfo buf, xl_heaptid *target)
+out_target(StringInfo buf, const xl_heaptid *target)
 {
 	appendStringInfo(buf, "rel %u/%u/%u; tid %u/%u",
 			 target->node.spcNode, target->node.dbNode, target->node.relNode,
@@ -5141,14 +5141,14 @@ out_target(StringInfo buf, xl_heaptid *target)
 }
 
 void
-heap_desc(StringInfo buf, uint8 xl_info, char *rec)
+heap_desc(StringInfo buf, uint8 xl_info, const char *rec)
 {
 	uint8		info = xl_info & ~XLR_INFO_MASK;
 
 	info &= XLOG_HEAP_OPMASK;
 	if (info == XLOG_HEAP_INSERT)
 	{
-		xl_heap_insert *xlrec = (xl_heap_insert *) rec;
+		const xl_heap_insert *xlrec = (const xl_heap_insert *) rec;
 
 		if (xl_info & XLOG_HEAP_INIT_PAGE)
 			appendStringInfo(buf, "insert(init): ");
@@ -5158,14 +5158,14 @@ heap_desc(StringInfo buf, uint8 xl_info, char *rec)
 	}
 	else if (info == XLOG_HEAP_DELETE)
 	{
-		xl_heap_delete *xlrec = (xl_heap_delete *) rec;
+		const xl_heap_delete *xlrec = (const xl_heap_delete *) rec;
 
 		appendStringInfo(buf, "delete: ");
 		out_target(buf, &(xlrec->target));
 	}
 	else if (info == XLOG_HEAP_UPDATE)
 	{
-		xl_heap_update *xlrec = (xl_heap_update *) rec;
+		const xl_heap_update *xlrec = (const xl_heap_update *) rec;
 
 		if (xl_info & XLOG_HEAP_INIT_PAGE)
 			appendStringInfo(buf, "update(init): ");
@@ -5178,7 +5178,7 @@ heap_desc(StringInfo buf, uint8 xl_info, char *rec)
 	}
 	else if (info == XLOG_HEAP_HOT_UPDATE)
 	{
-		xl_heap_update *xlrec = (xl_heap_update *) rec;
+		const xl_heap_update *xlrec = (const xl_heap_update *) rec;
 
 		if (xl_info & XLOG_HEAP_INIT_PAGE)		/* can this case happen? */
 			appendStringInfo(buf, "hot_update(init): ");
@@ -5191,7 +5191,7 @@ heap_desc(StringInfo buf, uint8 xl_info, char *rec)
 	}
 	else if (info == XLOG_HEAP_NEWPAGE)
 	{
-		xl_heap_newpage *xlrec = (xl_heap_newpage *) rec;
+		const xl_heap_newpage *xlrec = (const xl_heap_newpage *) rec;
 
 		appendStringInfo(buf, "newpage: rel %u/%u/%u; fork %u, blk %u",
 						 xlrec->node.spcNode, xlrec->node.dbNode,
@@ -5200,7 +5200,7 @@ heap_desc(StringInfo buf, uint8 xl_info, char *rec)
 	}
 	else if (info == XLOG_HEAP_LOCK)
 	{
-		xl_heap_lock *xlrec = (xl_heap_lock *) rec;
+		const xl_heap_lock *xlrec = (const xl_heap_lock *) rec;
 
 		if (xlrec->shared_lock)
 			appendStringInfo(buf, "shared_lock: ");
@@ -5215,7 +5215,7 @@ heap_desc(StringInfo buf, uint8 xl_info, char *rec)
 	}
 	else if (info == XLOG_HEAP_INPLACE)
 	{
-		xl_heap_inplace *xlrec = (xl_heap_inplace *) rec;
+		const xl_heap_inplace *xlrec = (const xl_heap_inplace *) rec;
 
 		appendStringInfo(buf, "inplace: ");
 		out_target(buf, &(xlrec->target));
@@ -5225,14 +5225,14 @@ heap_desc(StringInfo buf, uint8 xl_info, char *rec)
 }
 
 void
-heap2_desc(StringInfo buf, uint8 xl_info, char *rec)
+heap2_desc(StringInfo buf, uint8 xl_info, const char *rec)
 {
 	uint8		info = xl_info & ~XLR_INFO_MASK;
 
 	info &= XLOG_HEAP_OPMASK;
 	if (info == XLOG_HEAP2_FREEZE)
 	{
-		xl_heap_freeze *xlrec = (xl_heap_freeze *) rec;
+		const xl_heap_freeze *xlrec = (const xl_heap_freeze *) rec;
 
 		appendStringInfo(buf, "freeze: rel %u/%u/%u; blk %u; cutoff %u",
 						 xlrec->node.spcNode, xlrec->node.dbNode,
@@ -5241,7 +5241,7 @@ heap2_desc(StringInfo buf, uint8 xl_info, char *rec)
 	}
 	else if (info == XLOG_HEAP2_CLEAN)
 	{
-		xl_heap_clean *xlrec = (xl_heap_clean *) rec;
+		const xl_heap_clean *xlrec = (const xl_heap_clean *) rec;
 
 		appendStringInfo(buf, "clean: rel %u/%u/%u; blk %u remxid %u",
 						 xlrec->node.spcNode, xlrec->node.dbNode,
@@ -5250,14 +5250,14 @@ heap2_desc(StringInfo buf, uint8 xl_info, char *rec)
 	}
 	else if (info == XLOG_HEAP2_CLEANUP_INFO)
 	{
-		xl_heap_cleanup_info *xlrec = (xl_heap_cleanup_info *) rec;
+		const xl_heap_cleanup_info *xlrec = (const xl_heap_cleanup_info *) rec;
 
 		appendStringInfo(buf, "cleanup info: remxid %u",
 						 xlrec->latestRemovedXid);
 	}
 	else if (info == XLOG_HEAP2_VISIBLE)
 	{
-		xl_heap_visible *xlrec = (xl_heap_visible *) rec;
+		const xl_heap_visible *xlrec = (const xl_heap_visible *) rec;
 
 		appendStringInfo(buf, "visible: rel %u/%u/%u; blk %u",
 						 xlrec->node.spcNode, xlrec->node.dbNode,
diff --git a/src/backend/access/nbtree/nbtxlog.c b/src/backend/access/nbtree/nbtxlog.c
index e2ed50f..73393d7 100644
--- a/src/backend/access/nbtree/nbtxlog.c
+++ b/src/backend/access/nbtree/nbtxlog.c
@@ -1034,7 +1034,7 @@ btree_redo(XLogRecPtr lsn, XLogRecord *record)
 }
 
 static void
-out_target(StringInfo buf, xl_btreetid *target)
+out_target(StringInfo buf, const xl_btreetid *target)
 {
 	appendStringInfo(buf, "rel %u/%u/%u; tid %u/%u",
 			 target->node.spcNode, target->node.dbNode, target->node.relNode,
@@ -1043,7 +1043,7 @@ out_target(StringInfo buf, xl_btreetid *target)
 }
 
 void
-btree_desc(StringInfo buf, uint8 xl_info, char *rec)
+btree_desc(StringInfo buf, uint8 xl_info, const char *rec)
 {
 	uint8		info = xl_info & ~XLR_INFO_MASK;
 
@@ -1051,7 +1051,7 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
 	{
 		case XLOG_BTREE_INSERT_LEAF:
 			{
-				xl_btree_insert *xlrec = (xl_btree_insert *) rec;
+				const xl_btree_insert *xlrec = (const xl_btree_insert *) rec;
 
 				appendStringInfo(buf, "insert: ");
 				out_target(buf, &(xlrec->target));
@@ -1059,7 +1059,7 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
 			}
 		case XLOG_BTREE_INSERT_UPPER:
 			{
-				xl_btree_insert *xlrec = (xl_btree_insert *) rec;
+				const xl_btree_insert *xlrec = (const xl_btree_insert *) rec;
 
 				appendStringInfo(buf, "insert_upper: ");
 				out_target(buf, &(xlrec->target));
@@ -1067,7 +1067,7 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
 			}
 		case XLOG_BTREE_INSERT_META:
 			{
-				xl_btree_insert *xlrec = (xl_btree_insert *) rec;
+				const xl_btree_insert *xlrec = (const xl_btree_insert *) rec;
 
 				appendStringInfo(buf, "insert_meta: ");
 				out_target(buf, &(xlrec->target));
@@ -1075,7 +1075,7 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
 			}
 		case XLOG_BTREE_SPLIT_L:
 			{
-				xl_btree_split *xlrec = (xl_btree_split *) rec;
+				const xl_btree_split *xlrec = (const xl_btree_split *) rec;
 
 				appendStringInfo(buf, "split_l: rel %u/%u/%u ",
 								 xlrec->node.spcNode, xlrec->node.dbNode,
@@ -1087,7 +1087,7 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
 			}
 		case XLOG_BTREE_SPLIT_R:
 			{
-				xl_btree_split *xlrec = (xl_btree_split *) rec;
+				const xl_btree_split *xlrec = (const xl_btree_split *) rec;
 
 				appendStringInfo(buf, "split_r: rel %u/%u/%u ",
 								 xlrec->node.spcNode, xlrec->node.dbNode,
@@ -1099,7 +1099,7 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
 			}
 		case XLOG_BTREE_SPLIT_L_ROOT:
 			{
-				xl_btree_split *xlrec = (xl_btree_split *) rec;
+				const xl_btree_split *xlrec = (const xl_btree_split *) rec;
 
 				appendStringInfo(buf, "split_l_root: rel %u/%u/%u ",
 								 xlrec->node.spcNode, xlrec->node.dbNode,
@@ -1111,7 +1111,7 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
 			}
 		case XLOG_BTREE_SPLIT_R_ROOT:
 			{
-				xl_btree_split *xlrec = (xl_btree_split *) rec;
+				const xl_btree_split *xlrec = (const xl_btree_split *) rec;
 
 				appendStringInfo(buf, "split_r_root: rel %u/%u/%u ",
 								 xlrec->node.spcNode, xlrec->node.dbNode,
@@ -1123,7 +1123,7 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
 			}
 		case XLOG_BTREE_VACUUM:
 			{
-				xl_btree_vacuum *xlrec = (xl_btree_vacuum *) rec;
+				const xl_btree_vacuum *xlrec = (const xl_btree_vacuum *) rec;
 
 				appendStringInfo(buf, "vacuum: rel %u/%u/%u; blk %u, lastBlockVacuumed %u",
 								 xlrec->node.spcNode, xlrec->node.dbNode,
@@ -1133,7 +1133,7 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
 			}
 		case XLOG_BTREE_DELETE:
 			{
-				xl_btree_delete *xlrec = (xl_btree_delete *) rec;
+				const xl_btree_delete *xlrec = (const xl_btree_delete *) rec;
 
 				appendStringInfo(buf, "delete: index %u/%u/%u; iblk %u, heap %u/%u/%u;",
 				xlrec->node.spcNode, xlrec->node.dbNode, xlrec->node.relNode,
@@ -1145,7 +1145,7 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
 		case XLOG_BTREE_DELETE_PAGE_META:
 		case XLOG_BTREE_DELETE_PAGE_HALF:
 			{
-				xl_btree_delete_page *xlrec = (xl_btree_delete_page *) rec;
+				const xl_btree_delete_page *xlrec = (const xl_btree_delete_page *) rec;
 
 				appendStringInfo(buf, "delete_page: ");
 				out_target(buf, &(xlrec->target));
@@ -1155,7 +1155,7 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
 			}
 		case XLOG_BTREE_NEWROOT:
 			{
-				xl_btree_newroot *xlrec = (xl_btree_newroot *) rec;
+				const xl_btree_newroot *xlrec = (const xl_btree_newroot *) rec;
 
 				appendStringInfo(buf, "newroot: rel %u/%u/%u; root %u lev %u",
 								 xlrec->node.spcNode, xlrec->node.dbNode,
@@ -1165,7 +1165,7 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
 			}
 		case XLOG_BTREE_REUSE_PAGE:
 			{
-				xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
+				const xl_btree_reuse_page *xlrec = (const xl_btree_reuse_page *) rec;
 
 				appendStringInfo(buf, "reuse_page: rel %u/%u/%u; latestRemovedXid %u",
 								 xlrec->node.spcNode, xlrec->node.dbNode,
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index ee645f7..0d2f93a 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -721,7 +721,7 @@ clog_redo(XLogRecPtr lsn, XLogRecord *record)
 }
 
 void
-clog_desc(StringInfo buf, uint8 xl_info, char *rec)
+clog_desc(StringInfo buf, uint8 xl_info, const char *rec)
 {
 	uint8		info = xl_info & ~XLR_INFO_MASK;
 
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 1d159bc..50b612c 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -2049,7 +2049,7 @@ multixact_redo(XLogRecPtr lsn, XLogRecord *record)
 }
 
 void
-multixact_desc(StringInfo buf, uint8 xl_info, char *rec)
+multixact_desc(StringInfo buf, uint8 xl_info, const char *rec)
 {
 	uint8		info = xl_info & ~XLR_INFO_MASK;
 
@@ -2069,7 +2069,7 @@ multixact_desc(StringInfo buf, uint8 xl_info, char *rec)
 	}
 	else if (info == XLOG_MULTIXACT_CREATE_ID)
 	{
-		xl_multixact_create *xlrec = (xl_multixact_create *) rec;
+		const xl_multixact_create *xlrec = (const xl_multixact_create *) rec;
 		int			i;
 
 		appendStringInfo(buf, "create multixact %u offset %u:",
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index c151d3b..b7c36fb 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -4807,12 +4807,12 @@ xact_redo(XLogRecPtr lsn, XLogRecord *record)
 }
 
 static void
-xact_desc_commit(StringInfo buf, xl_xact_commit *xlrec)
+xact_desc_commit(StringInfo buf, const xl_xact_commit *xlrec)
 {
 	int			i;
-	TransactionId *subxacts;
+	const TransactionId *subxacts;
 
-	subxacts = (TransactionId *) &xlrec->xnodes[xlrec->nrels];
+	subxacts = (const TransactionId *) &xlrec->xnodes[xlrec->nrels];
 
 	appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
 
@@ -4835,9 +4835,9 @@ xact_desc_commit(StringInfo buf, xl_xact_commit *xlrec)
 	}
 	if (xlrec->nmsgs > 0)
 	{
-		SharedInvalidationMessage *msgs;
+		const SharedInvalidationMessage *msgs;
 
-		msgs = (SharedInvalidationMessage *) &subxacts[xlrec->nsubxacts];
+		msgs = (const SharedInvalidationMessage *) &subxacts[xlrec->nsubxacts];
 
 		if (XactCompletionRelcacheInitFileInval(xlrec->xinfo))
 			appendStringInfo(buf, "; relcache init file inval dbid %u tsid %u",
@@ -4846,7 +4846,7 @@ xact_desc_commit(StringInfo buf, xl_xact_commit *xlrec)
 		appendStringInfo(buf, "; inval msgs:");
 		for (i = 0; i < xlrec->nmsgs; i++)
 		{
-			SharedInvalidationMessage *msg = &msgs[i];
+			const SharedInvalidationMessage *msg = &msgs[i];
 
 			if (msg->id >= 0)
 				appendStringInfo(buf, " catcache %d", msg->id);
@@ -4866,7 +4866,7 @@ xact_desc_commit(StringInfo buf, xl_xact_commit *xlrec)
 }
 
 static void
-xact_desc_commit_compact(StringInfo buf, xl_xact_commit_compact *xlrec)
+xact_desc_commit_compact(StringInfo buf, const xl_xact_commit_compact *xlrec)
 {
 	int			i;
 
@@ -4881,7 +4881,7 @@ xact_desc_commit_compact(StringInfo buf, xl_xact_commit_compact *xlrec)
 }
 
 static void
-xact_desc_abort(StringInfo buf, xl_xact_abort *xlrec)
+xact_desc_abort(StringInfo buf, const xl_xact_abort *xlrec)
 {
 	int			i;
 
@@ -4899,7 +4899,7 @@ xact_desc_abort(StringInfo buf, xl_xact_abort *xlrec)
 	}
 	if (xlrec->nsubxacts > 0)
 	{
-		TransactionId *xacts = (TransactionId *)
+		const TransactionId *xacts = (const TransactionId *)
 		&xlrec->xnodes[xlrec->nrels];
 
 		appendStringInfo(buf, "; subxacts:");
@@ -4909,7 +4909,7 @@ xact_desc_abort(StringInfo buf, xl_xact_abort *xlrec)
 }
 
 static void
-xact_desc_assignment(StringInfo buf, xl_xact_assignment *xlrec)
+xact_desc_assignment(StringInfo buf, const xl_xact_assignment *xlrec)
 {
 	int			i;
 
@@ -4920,27 +4920,27 @@ xact_desc_assignment(StringInfo buf, xl_xact_assignment *xlrec)
 }
 
 void
-xact_desc(StringInfo buf, uint8 xl_info, char *rec)
+xact_desc(StringInfo buf, uint8 xl_info, const char *rec)
 {
 	uint8		info = xl_info & ~XLR_INFO_MASK;
 
 	if (info == XLOG_XACT_COMMIT_COMPACT)
 	{
-		xl_xact_commit_compact *xlrec = (xl_xact_commit_compact *) rec;
+		const xl_xact_commit_compact *xlrec = (const xl_xact_commit_compact *) rec;
 
 		appendStringInfo(buf, "commit: ");
 		xact_desc_commit_compact(buf, xlrec);
 	}
 	else if (info == XLOG_XACT_COMMIT)
 	{
-		xl_xact_commit *xlrec = (xl_xact_commit *) rec;
+		const xl_xact_commit *xlrec = (const xl_xact_commit *) rec;
 
 		appendStringInfo(buf, "commit: ");
 		xact_desc_commit(buf, xlrec);
 	}
 	else if (info == XLOG_XACT_ABORT)
 	{
-		xl_xact_abort *xlrec = (xl_xact_abort *) rec;
+		const xl_xact_abort *xlrec = (const xl_xact_abort *) rec;
 
 		appendStringInfo(buf, "abort: ");
 		xact_desc_abort(buf, xlrec);
@@ -4951,21 +4951,21 @@ xact_desc(StringInfo buf, uint8 xl_info, char *rec)
 	}
 	else if (info == XLOG_XACT_COMMIT_PREPARED)
 	{
-		xl_xact_commit_prepared *xlrec = (xl_xact_commit_prepared *) rec;
+		const xl_xact_commit_prepared *xlrec = (const xl_xact_commit_prepared *) rec;
 
 		appendStringInfo(buf, "commit prepared %u: ", xlrec->xid);
 		xact_desc_commit(buf, &xlrec->crec);
 	}
 	else if (info == XLOG_XACT_ABORT_PREPARED)
 	{
-		xl_xact_abort_prepared *xlrec = (xl_xact_abort_prepared *) rec;
+		const xl_xact_abort_prepared *xlrec = (const xl_xact_abort_prepared *) rec;
 
 		appendStringInfo(buf, "abort prepared %u: ", xlrec->xid);
 		xact_desc_abort(buf, &xlrec->arec);
 	}
 	else if (info == XLOG_XACT_ASSIGNMENT)
 	{
-		xl_xact_assignment *xlrec = (xl_xact_assignment *) rec;
+		const xl_xact_assignment *xlrec = (const xl_xact_assignment *) rec;
 
 		/*
 		 * Note that we ignore the WAL record's xid, since we're more
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 5fec886..2023e19 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -666,7 +666,7 @@ static void xlog_outrec(StringInfo buf, XLogRecord *record);
 static void pg_start_backup_callback(int code, Datum arg);
 static bool read_backup_label(XLogRecPtr *checkPointLoc,
 				  bool *backupEndRequired);
-static void rm_redo_error_callback(void *arg);
+static void rm_redo_error_callback(const void *arg);
 static int	get_sync_bit(int method);
 
 
@@ -8597,14 +8597,14 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
 }
 
 void
-xlog_desc(StringInfo buf, uint8 xl_info, char *rec)
+xlog_desc(StringInfo buf, uint8 xl_info, const char *rec)
 {
 	uint8		info = xl_info & ~XLR_INFO_MASK;
 
 	if (info == XLOG_CHECKPOINT_SHUTDOWN ||
 		info == XLOG_CHECKPOINT_ONLINE)
 	{
-		CheckPoint *checkpoint = (CheckPoint *) rec;
+		const CheckPoint *checkpoint = (const CheckPoint *) rec;
 
 		appendStringInfo(buf, "checkpoint: redo %X/%X; "
 						 "tli %u; xid %u/%u; oid %u; multi %u; offset %u; "
@@ -8637,7 +8637,7 @@ xlog_desc(StringInfo buf, uint8 xl_info, char *rec)
 	}
 	else if (info == XLOG_RESTORE_POINT)
 	{
-		xl_restore_point *xlrec = (xl_restore_point *) rec;
+		const xl_restore_point *xlrec = (const xl_restore_point *) rec;
 
 		appendStringInfo(buf, "restore point: %s", xlrec->rp_name);
 
@@ -9865,15 +9865,15 @@ read_backup_label(XLogRecPtr *checkPointLoc, bool *backupEndRequired)
  * Error context callback for errors occurring during rm_redo().
  */
 static void
-rm_redo_error_callback(void *arg)
+rm_redo_error_callback(const void *arg)
 {
-	XLogRecord *record = (XLogRecord *) arg;
+	const XLogRecord *record = (const XLogRecord *) arg;
 	StringInfoData buf;
 
 	initStringInfo(&buf);
 	RmgrTable[record->xl_rmid].rm_desc(&buf,
 									   record->xl_info,
-									   XLogRecGetData(record));
+									   XLogRecGetConstData(record));
 
 	/* don't bother emitting empty description */
 	if (buf.len > 0)
diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c
index 5f7d7f6..3cf65cf 100644
--- a/src/backend/catalog/pg_proc.c
+++ b/src/backend/catalog/pg_proc.c
@@ -48,7 +48,7 @@ typedef struct
 	char	   *prosrc;
 } parse_error_callback_arg;
 
-static void sql_function_parse_error_callback(void *arg);
+static void sql_function_parse_error_callback(const void *arg);
 static int match_prosrc_to_query(const char *prosrc, const char *queryText,
 					  int cursorpos);
 static bool match_prosrc_to_literal(const char *prosrc, const char *literal,
@@ -881,9 +881,9 @@ fmgr_sql_validator(PG_FUNCTION_ARGS)
  * Error context callback for handling errors in SQL function definitions
  */
 static void
-sql_function_parse_error_callback(void *arg)
+sql_function_parse_error_callback(const void *arg)
 {
-	parse_error_callback_arg *callback_arg = (parse_error_callback_arg *) arg;
+	const parse_error_callback_arg *callback_arg = (const parse_error_callback_arg *) arg;
 
 	/* See if it's a syntax error; if so, transpose to CREATE FUNCTION */
 	if (!function_parse_error_transpose(callback_arg->prosrc))
diff --git a/src/backend/catalog/storage.c b/src/backend/catalog/storage.c
index d027361..c023802 100644
--- a/src/backend/catalog/storage.c
+++ b/src/backend/catalog/storage.c
@@ -530,13 +530,13 @@ smgr_redo(XLogRecPtr lsn, XLogRecord *record)
 }
 
 void
-smgr_desc(StringInfo buf, uint8 xl_info, char *rec)
+smgr_desc(StringInfo buf, uint8 xl_info, const char *rec)
 {
 	uint8		info = xl_info & ~XLR_INFO_MASK;
 
 	if (info == XLOG_SMGR_CREATE)
 	{
-		xl_smgr_create *xlrec = (xl_smgr_create *) rec;
+		const xl_smgr_create *xlrec = (const xl_smgr_create *) rec;
 		char	   *path = relpathperm(xlrec->rnode, xlrec->forkNum);
 
 		appendStringInfo(buf, "file create: %s", path);
@@ -544,7 +544,7 @@ smgr_desc(StringInfo buf, uint8 xl_info, char *rec)
 	}
 	else if (info == XLOG_SMGR_TRUNCATE)
 	{
-		xl_smgr_truncate *xlrec = (xl_smgr_truncate *) rec;
+		const xl_smgr_truncate *xlrec = (const xl_smgr_truncate *) rec;
 		char	   *path = relpathperm(xlrec->rnode, MAIN_FORKNUM);
 
 		appendStringInfo(buf, "file truncate: %s to %u blocks", path,
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index e0c72d9..3e61dae 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -1728,9 +1728,9 @@ CopyOneRowTo(CopyState cstate, Oid tupleOid, Datum *values, bool *nulls)
  * The argument for the error context must be CopyState.
  */
 void
-CopyFromErrorCallback(void *arg)
+CopyFromErrorCallback(const void *arg)
 {
-	CopyState	cstate = (CopyState) arg;
+	const CopyStateData *cstate = (const CopyStateData *) arg;
 
 	if (cstate->binary)
 	{
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 2c05814..6bf7250 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -1978,13 +1978,13 @@ dbase_redo(XLogRecPtr lsn, XLogRecord *record)
 }
 
 void
-dbase_desc(StringInfo buf, uint8 xl_info, char *rec)
+dbase_desc(StringInfo buf, uint8 xl_info, const char *rec)
 {
 	uint8		info = xl_info & ~XLR_INFO_MASK;
 
 	if (info == XLOG_DBASE_CREATE)
 	{
-		xl_dbase_create_rec *xlrec = (xl_dbase_create_rec *) rec;
+		const xl_dbase_create_rec *xlrec = (const xl_dbase_create_rec *) rec;
 
 		appendStringInfo(buf, "create db: copy dir %u/%u to %u/%u",
 						 xlrec->src_db_id, xlrec->src_tablespace_id,
@@ -1992,7 +1992,7 @@ dbase_desc(StringInfo buf, uint8 xl_info, char *rec)
 	}
 	else if (info == XLOG_DBASE_DROP)
 	{
-		xl_dbase_drop_rec *xlrec = (xl_dbase_drop_rec *) rec;
+		const xl_dbase_drop_rec *xlrec = (const xl_dbase_drop_rec *) rec;
 
 		appendStringInfo(buf, "drop db: dir %u/%u",
 						 xlrec->db_id, xlrec->tablespace_id);
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index 54660f4..23df6e1 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -1548,10 +1548,10 @@ seq_redo(XLogRecPtr lsn, XLogRecord *record)
 }
 
 void
-seq_desc(StringInfo buf, uint8 xl_info, char *rec)
+seq_desc(StringInfo buf, uint8 xl_info, const char *rec)
 {
 	uint8		info = xl_info & ~XLR_INFO_MASK;
-	xl_seq_rec *xlrec = (xl_seq_rec *) rec;
+	const xl_seq_rec *xlrec = (const xl_seq_rec *) rec;
 
 	if (info == XLOG_SEQ_LOG)
 		appendStringInfo(buf, "log: ");
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index d223f8c..565e576 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -1453,20 +1453,20 @@ tblspc_redo(XLogRecPtr lsn, XLogRecord *record)
 }
 
 void
-tblspc_desc(StringInfo buf, uint8 xl_info, char *rec)
+tblspc_desc(StringInfo buf, uint8 xl_info, const char *rec)
 {
 	uint8		info = xl_info & ~XLR_INFO_MASK;
 
 	if (info == XLOG_TBLSPC_CREATE)
 	{
-		xl_tblspc_create_rec *xlrec = (xl_tblspc_create_rec *) rec;
+		const xl_tblspc_create_rec *xlrec = (const xl_tblspc_create_rec *) rec;
 
 		appendStringInfo(buf, "create ts: %u \"%s\"",
 						 xlrec->ts_id, xlrec->ts_path);
 	}
 	else if (info == XLOG_TBLSPC_DROP)
 	{
-		xl_tblspc_drop_rec *xlrec = (xl_tblspc_drop_rec *) rec;
+		const xl_tblspc_drop_rec *xlrec = (const xl_tblspc_drop_rec *) rec;
 
 		appendStringInfo(buf, "drop ts: %u", xlrec->ts_id);
 	}
diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c
index 398bc40..a7b23ce 100644
--- a/src/backend/executor/functions.c
+++ b/src/backend/executor/functions.c
@@ -136,7 +136,7 @@ static Datum postquel_get_single_result(TupleTableSlot *slot,
 						   FunctionCallInfo fcinfo,
 						   SQLFunctionCachePtr fcache,
 						   MemoryContext resultcontext);
-static void sql_exec_error_callback(void *arg);
+static void sql_exec_error_callback(const void *arg);
 static void ShutdownSQLFunction(Datum arg);
 static void sqlfunction_startup(DestReceiver *self, int operation, TupleDesc typeinfo);
 static void sqlfunction_receive(TupleTableSlot *slot, DestReceiver *self);
@@ -1096,9 +1096,9 @@ fmgr_sql(PG_FUNCTION_ARGS)
  * error context callback to let us supply a call-stack traceback
  */
 static void
-sql_exec_error_callback(void *arg)
+sql_exec_error_callback(const void *arg)
 {
-	FmgrInfo   *flinfo = (FmgrInfo *) arg;
+	const FmgrInfo *flinfo = (const FmgrInfo *) arg;
 	SQLFunctionCachePtr fcache = (SQLFunctionCachePtr) flinfo->fn_extra;
 	int			syntaxerrposition;
 
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index 688279c..ad03e36 100644
--- a/src/backend/executor/spi.c
+++ b/src/backend/executor/spi.c
@@ -60,7 +60,7 @@ static ParamListInfo _SPI_convert_params(int nargs, Oid *argtypes,
 
 static int	_SPI_pquery(QueryDesc *queryDesc, bool fire_triggers, long tcount);
 
-static void _SPI_error_callback(void *arg);
+static void _SPI_error_callback(const void *arg);
 
 static void _SPI_cursor_operation(Portal portal,
 					  FetchDirection direction, long count,
@@ -1668,7 +1668,7 @@ _SPI_prepare_plan(const char *src, SPIPlanPtr plan, ParamListInfo boundParams)
 	 * Setup error traceback support for ereport()
 	 */
 	spierrcontext.callback = _SPI_error_callback;
-	spierrcontext.arg = (void *) src;
+	spierrcontext.arg = src;
 	spierrcontext.previous = error_context_stack;
 	error_context_stack = &spierrcontext;
 
@@ -1813,7 +1813,7 @@ _SPI_execute_plan(SPIPlanPtr plan, ParamListInfo paramLI,
 		List	   *stmt_list;
 		ListCell   *lc2;
 
-		spierrcontext.arg = (void *) plansource->query_string;
+		spierrcontext.arg = plansource->query_string;
 
 		/*
 		 * Replan if needed, and increment plan refcount.  If it's a saved
@@ -2121,7 +2121,7 @@ _SPI_pquery(QueryDesc *queryDesc, bool fire_triggers, long tcount)
  * Add context information when a query invoked via SPI fails
  */
 static void
-_SPI_error_callback(void *arg)
+_SPI_error_callback(const void *arg)
 {
 	const char *query = (const char *) arg;
 	int			syntaxerrposition;
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c
index baa90fa..1ad93e4 100644
--- a/src/backend/optimizer/util/clauses.c
+++ b/src/backend/optimizer/util/clauses.c
@@ -132,7 +132,7 @@ static Node *substitute_actual_parameters(Node *expr, int nargs, List *args,
 							 int *usecounts);
 static Node *substitute_actual_parameters_mutator(Node *node,
 							  substitute_actual_parameters_context *context);
-static void sql_inline_error_callback(void *arg);
+static void sql_inline_error_callback(const void *arg);
 static Expr *evaluate_expr(Expr *expr, Oid result_type, int32 result_typmod,
 			  Oid result_collation);
 static Query *substitute_actual_srf_parameters(Query *expr,
@@ -4188,9 +4188,9 @@ substitute_actual_parameters_mutator(Node *node,
  * error context callback to let us supply a call-stack traceback
  */
 static void
-sql_inline_error_callback(void *arg)
+sql_inline_error_callback(const void *arg)
 {
-	inline_error_callback_arg *callback_arg = (inline_error_callback_arg *) arg;
+	const inline_error_callback_arg *callback_arg = (const inline_error_callback_arg *) arg;
 	int			syntaxerrposition;
 
 	/* If it's a syntax error, convert to internal syntax error report */
diff --git a/src/backend/parser/parse_node.c b/src/backend/parser/parse_node.c
index 7b5c040..613b643 100644
--- a/src/backend/parser/parse_node.c
+++ b/src/backend/parser/parse_node.c
@@ -30,7 +30,7 @@
 #include "utils/varbit.h"
 
 
-static void pcb_error_callback(void *arg);
+static void pcb_error_callback(const void *arg);
 
 
 /*
@@ -168,9 +168,9 @@ cancel_parser_errposition_callback(ParseCallbackState *pcbstate)
  * if the error is a query cancel --- are there any other important cases?
  */
 static void
-pcb_error_callback(void *arg)
+pcb_error_callback(const void *arg)
 {
-	ParseCallbackState *pcbstate = (ParseCallbackState *) arg;
+	const ParseCallbackState *pcbstate = (const ParseCallbackState *) arg;
 
 	if (geterrcode() != ERRCODE_QUERY_CANCELED)
 		(void) parser_errposition(pcbstate->pstate, pcbstate->location);
diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c
index 2122032..b9acc35 100644
--- a/src/backend/parser/parse_type.c
+++ b/src/backend/parser/parse_type.c
@@ -640,7 +640,7 @@ typeidTypeRelid(Oid type_id)
  * error context callback for parse failure during parseTypeString()
  */
 static void
-pts_error_callback(void *arg)
+pts_error_callback(const void *arg)
 {
 	const char *str = (const char *) arg;
 
@@ -681,7 +681,7 @@ parseTypeString(const char *str, Oid *typeid_p, int32 *typmod_p)
 	 * Setup error traceback support in case of ereport() during parse
 	 */
 	ptserrcontext.callback = pts_error_callback;
-	ptserrcontext.arg = (void *) str;
+	ptserrcontext.arg = str;
 	ptserrcontext.previous = error_context_stack;
 	error_context_stack = &ptserrcontext;
 
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index f47f1b6..de90bf3 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -96,8 +96,8 @@ static void WaitIO(volatile BufferDesc *buf);
 static bool StartBufferIO(volatile BufferDesc *buf, bool forInput);
 static void TerminateBufferIO(volatile BufferDesc *buf, bool clear_dirty,
 				  int set_flag_bits);
-static void shared_buffer_write_error_callback(void *arg);
-static void local_buffer_write_error_callback(void *arg);
+static void shared_buffer_write_error_callback(const void *arg);
+static void local_buffer_write_error_callback(const void *arg);
 static volatile BufferDesc *BufferAlloc(SMgrRelation smgr,
 			char relpersistence,
 			ForkNumber forkNum,
@@ -2776,7 +2776,7 @@ AbortBufferIO(void)
  * Error context callback for errors occurring during shared buffer writes.
  */
 static void
-shared_buffer_write_error_callback(void *arg)
+shared_buffer_write_error_callback(const void *arg)
 {
 	volatile BufferDesc *bufHdr = (volatile BufferDesc *) arg;
 
@@ -2795,7 +2795,7 @@ shared_buffer_write_error_callback(void *arg)
  * Error context callback for errors occurring during local buffer writes.
  */
 static void
-local_buffer_write_error_callback(void *arg)
+local_buffer_write_error_callback(const void *arg)
 {
 	volatile BufferDesc *bufHdr = (volatile BufferDesc *) arg;
 
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 72c6b97..70d12d3 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -718,7 +718,7 @@ standby_redo(XLogRecPtr lsn, XLogRecord *record)
 }
 
 static void
-standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
+standby_desc_running_xacts(StringInfo buf, const xl_running_xacts *xlrec)
 {
 	int			i;
 
@@ -738,13 +738,13 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
 }
 
 void
-standby_desc(StringInfo buf, uint8 xl_info, char *rec)
+standby_desc(StringInfo buf, uint8 xl_info, const char *rec)
 {
 	uint8		info = xl_info & ~XLR_INFO_MASK;
 
 	if (info == XLOG_STANDBY_LOCK)
 	{
-		xl_standby_locks *xlrec = (xl_standby_locks *) rec;
+		const xl_standby_locks *xlrec = (const xl_standby_locks *) rec;
 		int			i;
 
 		appendStringInfo(buf, "AccessExclusive locks:");
@@ -756,7 +756,7 @@ standby_desc(StringInfo buf, uint8 xl_info, char *rec)
 	}
 	else if (info == XLOG_RUNNING_XACTS)
 	{
-		xl_running_xacts *xlrec = (xl_running_xacts *) rec;
+		const xl_running_xacts *xlrec = (const xl_running_xacts *) rec;
 
 		appendStringInfo(buf, " running xacts:");
 		standby_desc_running_xacts(buf, xlrec);
diff --git a/src/backend/tsearch/ts_locale.c b/src/backend/tsearch/ts_locale.c
index 93b550a..26a9246 100644
--- a/src/backend/tsearch/ts_locale.c
+++ b/src/backend/tsearch/ts_locale.c
@@ -18,7 +18,7 @@
 #include "tsearch/ts_locale.h"
 #include "tsearch/ts_public.h"
 
-static void tsearch_readline_callback(void *arg);
+static void tsearch_readline_callback(const void *arg);
 
 
 #ifdef USE_WIDE_UPPER_LOWER
@@ -162,9 +162,9 @@ tsearch_readline_end(tsearch_readline_state *stp)
  * configuration file.
  */
 static void
-tsearch_readline_callback(void *arg)
+tsearch_readline_callback(const void *arg)
 {
-	tsearch_readline_state *stp = (tsearch_readline_state *) arg;
+	const tsearch_readline_state *stp = (const tsearch_readline_state *) arg;
 
 	/*
 	 * We can't include the text of the config line for errors that occur
diff --git a/src/backend/utils/cache/relmapper.c b/src/backend/utils/cache/relmapper.c
index b33a846..f646235 100644
--- a/src/backend/utils/cache/relmapper.c
+++ b/src/backend/utils/cache/relmapper.c
@@ -895,13 +895,13 @@ relmap_redo(XLogRecPtr lsn, XLogRecord *record)
 }
 
 void
-relmap_desc(StringInfo buf, uint8 xl_info, char *rec)
+relmap_desc(StringInfo buf, uint8 xl_info, const char *rec)
 {
 	uint8		info = xl_info & ~XLR_INFO_MASK;
 
 	if (info == XLOG_RELMAP_UPDATE)
 	{
-		xl_relmap_update *xlrec = (xl_relmap_update *) rec;
+		const xl_relmap_update *xlrec = (const xl_relmap_update *) rec;
 
 		appendStringInfo(buf, "update relmap: database %u tablespace %u size %u",
 						 xlrec->dbid, xlrec->tsid, xlrec->nbytes);
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index 7a8918e..03393b5 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -50,6 +50,6 @@ extern void TruncateCLOG(TransactionId oldestXact);
 #define CLOG_TRUNCATE		0x10
 
 extern void clog_redo(XLogRecPtr lsn, XLogRecord *record);
-extern void clog_desc(StringInfo buf, uint8 xl_info, char *rec);
+extern void clog_desc(StringInfo buf, uint8 xl_info, const char *rec);
 
 #endif   /* CLOG_H */
diff --git a/src/include/access/gin.h b/src/include/access/gin.h
index 31e9733..1cb4cb8 100644
--- a/src/include/access/gin.h
+++ b/src/include/access/gin.h
@@ -55,7 +55,7 @@ extern void ginUpdateStats(Relation index, const GinStatsData *stats);
 
 /* ginxlog.c */
 extern void gin_redo(XLogRecPtr lsn, XLogRecord *record);
-extern void gin_desc(StringInfo buf, uint8 xl_info, char *rec);
+extern void gin_desc(StringInfo buf, uint8 xl_info, const char *rec);
 extern void gin_xlog_startup(void);
 extern void gin_xlog_cleanup(void);
 extern bool gin_safe_restartpoint(void);
diff --git a/src/include/access/gist_private.h b/src/include/access/gist_private.h
index e988382..26b8a55 100644
--- a/src/include/access/gist_private.h
+++ b/src/include/access/gist_private.h
@@ -457,7 +457,7 @@ extern SplitedPageLayout *gistSplit(Relation r, Page page, IndexTuple *itup,
 
 /* gistxlog.c */
 extern void gist_redo(XLogRecPtr lsn, XLogRecord *record);
-extern void gist_desc(StringInfo buf, uint8 xl_info, char *rec);
+extern void gist_desc(StringInfo buf, uint8 xl_info, const char *rec);
 extern void gist_xlog_startup(void);
 extern void gist_xlog_cleanup(void);
 
diff --git a/src/include/access/hash.h b/src/include/access/hash.h
index d9a23ae..0e0f83f 100644
--- a/src/include/access/hash.h
+++ b/src/include/access/hash.h
@@ -355,6 +355,6 @@ extern OffsetNumber _hash_binsearch_last(Page page, uint32 hash_value);
 
 /* hash.c */
 extern void hash_redo(XLogRecPtr lsn, XLogRecord *record);
-extern void hash_desc(StringInfo buf, uint8 xl_info, char *rec);
+extern void hash_desc(StringInfo buf, uint8 xl_info, const char *rec);
 
 #endif   /* HASH_H */
diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h
index 776ea5c..94ba534 100644
--- a/src/include/access/heapam.h
+++ b/src/include/access/heapam.h
@@ -123,9 +123,9 @@ extern void heap_restrpos(HeapScanDesc scan);
 extern void heap_sync(Relation relation);
 
 extern void heap_redo(XLogRecPtr lsn, XLogRecord *rptr);
-extern void heap_desc(StringInfo buf, uint8 xl_info, char *rec);
+extern void heap_desc(StringInfo buf, uint8 xl_info, const char *rec);
 extern void heap2_redo(XLogRecPtr lsn, XLogRecord *rptr);
-extern void heap2_desc(StringInfo buf, uint8 xl_info, char *rec);
+extern void heap2_desc(StringInfo buf, uint8 xl_info, const char *rec);
 
 extern XLogRecPtr log_heap_cleanup_info(RelFileNode rnode,
 					  TransactionId latestRemovedXid);
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index c3ec763..f070b6c 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -77,6 +77,6 @@ extern void multixact_twophase_postabort(TransactionId xid, uint16 info,
 							 void *recdata, uint32 len);
 
 extern void multixact_redo(XLogRecPtr lsn, XLogRecord *record);
-extern void multixact_desc(StringInfo buf, uint8 xl_info, char *rec);
+extern void multixact_desc(StringInfo buf, uint8 xl_info, const char *rec);
 
 #endif   /* MULTIXACT_H */
diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h
index 347d942..65555fd 100644
--- a/src/include/access/nbtree.h
+++ b/src/include/access/nbtree.h
@@ -684,7 +684,7 @@ extern void _bt_leafbuild(BTSpool *btspool, BTSpool *spool2);
  * prototypes for functions in nbtxlog.c
  */
 extern void btree_redo(XLogRecPtr lsn, XLogRecord *record);
-extern void btree_desc(StringInfo buf, uint8 xl_info, char *rec);
+extern void btree_desc(StringInfo buf, uint8 xl_info, const char *rec);
 extern void btree_xlog_startup(void);
 extern void btree_xlog_cleanup(void);
 extern bool btree_safe_restartpoint(void);
diff --git a/src/include/access/xact.h b/src/include/access/xact.h
index aaa6204..42287f0 100644
--- a/src/include/access/xact.h
+++ b/src/include/access/xact.h
@@ -247,6 +247,6 @@ extern void UnregisterSubXactCallback(SubXactCallback callback, void *arg);
 extern int	xactGetCommittedChildren(TransactionId **ptr);
 
 extern void xact_redo(XLogRecPtr lsn, XLogRecord *record);
-extern void xact_desc(StringInfo buf, uint8 xl_info, char *rec);
+extern void xact_desc(StringInfo buf, uint8 xl_info, const char *rec);
 
 #endif   /* XACT_H */
diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h
index e4a13a1..cc0f442 100644
--- a/src/include/access/xlog.h
+++ b/src/include/access/xlog.h
@@ -57,6 +57,7 @@ typedef struct XLogRecord
 #define SizeOfXLogRecord	MAXALIGN(sizeof(XLogRecord))
 
 #define XLogRecGetData(record)	((char*) (record) + SizeOfXLogRecord)
+#define XLogRecGetConstData(record)	((const char*) (record) + SizeOfXLogRecord)
 
 /*
  * XLOG uses only low 4 bits of xl_info.  High 4 bits may be used by rmgr.
@@ -283,7 +284,7 @@ extern void XLogSetAsyncXactLSN(XLogRecPtr record);
 extern void RestoreBkpBlocks(XLogRecPtr lsn, XLogRecord *record, bool cleanup);
 
 extern void xlog_redo(XLogRecPtr lsn, XLogRecord *record);
-extern void xlog_desc(StringInfo buf, uint8 xl_info, char *rec);
+extern void xlog_desc(StringInfo buf, uint8 xl_info, const char *rec);
 
 extern void issue_xlog_fsync(int fd, uint32 log, uint32 seg);
 
diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h
index 4eaa243..07abb08 100644
--- a/src/include/access/xlog_internal.h
+++ b/src/include/access/xlog_internal.h
@@ -247,7 +247,7 @@ typedef struct RmgrData
 {
 	const char *rm_name;
 	void		(*rm_redo) (XLogRecPtr lsn, XLogRecord *rptr);
-	void		(*rm_desc) (StringInfo buf, uint8 xl_info, char *rec);
+	void		(*rm_desc) (StringInfo buf, uint8 xl_info, const char *rec);
 	void		(*rm_startup) (void);
 	void		(*rm_cleanup) (void);
 	bool		(*rm_safe_restartpoint) (void);
diff --git a/src/include/catalog/storage.h b/src/include/catalog/storage.h
index 8769bfd..3e06642 100644
--- a/src/include/catalog/storage.h
+++ b/src/include/catalog/storage.h
@@ -37,6 +37,6 @@ extern void PostPrepare_smgr(void);
 extern void log_smgrcreate(RelFileNode *rnode, ForkNumber forkNum);
 
 extern void smgr_redo(XLogRecPtr lsn, XLogRecord *record);
-extern void smgr_desc(StringInfo buf, uint8 xl_info, char *rec);
+extern void smgr_desc(StringInfo buf, uint8 xl_info, const char *rec);
 
 #endif   /* STORAGE_H */
diff --git a/src/include/commands/copy.h b/src/include/commands/copy.h
index a31479d..e885dd4 100644
--- a/src/include/commands/copy.h
+++ b/src/include/commands/copy.h
@@ -31,7 +31,7 @@ extern bool NextCopyFrom(CopyState cstate, ExprContext *econtext,
 			 Datum *values, bool *nulls, Oid *tupleOid);
 extern bool NextCopyFromRawFields(CopyState cstate,
 					  char ***fields, int *nfields);
-extern void CopyFromErrorCallback(void *arg);
+extern void CopyFromErrorCallback(const void *arg);
 
 extern DestReceiver *CreateCopyDestReceiver(void);
 
diff --git a/src/include/commands/dbcommands.h b/src/include/commands/dbcommands.h
index 21dacff..5644bd6 100644
--- a/src/include/commands/dbcommands.h
+++ b/src/include/commands/dbcommands.h
@@ -63,7 +63,7 @@ extern Oid	get_database_oid(const char *dbname, bool missingok);
 extern char *get_database_name(Oid dbid);
 
 extern void dbase_redo(XLogRecPtr lsn, XLogRecord *rptr);
-extern void dbase_desc(StringInfo buf, uint8 xl_info, char *rec);
+extern void dbase_desc(StringInfo buf, uint8 xl_info, const char *rec);
 
 extern void check_encoding_locale_matches(int encoding, const char *collate, const char *ctype);
 
diff --git a/src/include/commands/sequence.h b/src/include/commands/sequence.h
index 4177bc2..2f1c07c 100644
--- a/src/include/commands/sequence.h
+++ b/src/include/commands/sequence.h
@@ -76,6 +76,6 @@ extern void AlterSequence(AlterSeqStmt *stmt);
 extern void ResetSequence(Oid seq_relid);
 
 extern void seq_redo(XLogRecPtr lsn, XLogRecord *rptr);
-extern void seq_desc(StringInfo buf, uint8 xl_info, char *rec);
+extern void seq_desc(StringInfo buf, uint8 xl_info, const char *rec);
 
 #endif   /* SEQUENCE_H */
diff --git a/src/include/commands/tablespace.h b/src/include/commands/tablespace.h
index 4692098..251264e 100644
--- a/src/include/commands/tablespace.h
+++ b/src/include/commands/tablespace.h
@@ -57,6 +57,6 @@ extern char *get_tablespace_name(Oid spc_oid);
 extern bool directory_is_empty(const char *path);
 
 extern void tblspc_redo(XLogRecPtr lsn, XLogRecord *rptr);
-extern void tblspc_desc(StringInfo buf, uint8 xl_info, char *rec);
+extern void tblspc_desc(StringInfo buf, uint8 xl_info, const char *rec);
 
 #endif   /* TABLESPACE_H */
diff --git a/src/include/storage/standby.h b/src/include/storage/standby.h
index 6ebac62..9f92bf9 100644
--- a/src/include/storage/standby.h
+++ b/src/include/storage/standby.h
@@ -81,7 +81,7 @@ typedef struct xl_running_xacts
 
 /* Recovery handlers for the Standby Rmgr (RM_STANDBY_ID) */
 extern void standby_redo(XLogRecPtr lsn, XLogRecord *record);
-extern void standby_desc(StringInfo buf, uint8 xl_info, char *rec);
+extern void standby_desc(StringInfo buf, uint8 xl_info, const char *rec);
 
 /*
  * Declarations for GetRunningTransactionData(). Similar to Snapshots, but
diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h
index 93b141d..859b57b 100644
--- a/src/include/utils/elog.h
+++ b/src/include/utils/elog.h
@@ -221,8 +221,8 @@ __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
 typedef struct ErrorContextCallback
 {
 	struct ErrorContextCallback *previous;
-	void		(*callback) (void *arg);
-	void	   *arg;
+	void		(*callback) (const void *arg);
+	const void   *arg;
 } ErrorContextCallback;
 
 extern PGDLLIMPORT ErrorContextCallback *error_context_stack;
diff --git a/src/include/utils/plancache.h b/src/include/utils/plancache.h
index c8c27bb..d9b42fa 100644
--- a/src/include/utils/plancache.h
+++ b/src/include/utils/plancache.h
@@ -69,7 +69,7 @@ typedef struct CachedPlanSource
 {
 	int			magic;			/* should equal CACHEDPLANSOURCE_MAGIC */
 	Node	   *raw_parse_tree; /* output of raw_parser() */
-	char	   *query_string;	/* source text of query */
+	const char *query_string;	/* source text of query */
 	const char *commandTag;		/* command tag (a constant!), or NULL */
 	Oid		   *param_types;	/* array of parameter type OIDs, or NULL */
 	int			num_params;		/* length of param_types array */
diff --git a/src/include/utils/relmapper.h b/src/include/utils/relmapper.h
index e81b027..8f03657 100644
--- a/src/include/utils/relmapper.h
+++ b/src/include/utils/relmapper.h
@@ -57,6 +57,6 @@ extern void RelationMapInitializePhase2(void);
 extern void RelationMapInitializePhase3(void);
 
 extern void relmap_redo(XLogRecPtr lsn, XLogRecord *record);
-extern void relmap_desc(StringInfo buf, uint8 xl_info, char *rec);
+extern void relmap_desc(StringInfo buf, uint8 xl_info, const char *rec);
 
 #endif   /* RELMAPPER_H */
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index fb23ae2..94d4ff2 100644
--- a/src/pl/plperl/plperl.c
+++ b/src/pl/plperl/plperl.c
@@ -265,9 +265,9 @@ static SV **hv_fetch_string(HV *hv, const char *key);
 static void plperl_create_sub(plperl_proc_desc *desc, char *s, Oid fn_oid);
 static SV  *plperl_call_perl_func(plperl_proc_desc *desc,
 					  FunctionCallInfo fcinfo);
-static void plperl_compile_callback(void *arg);
-static void plperl_exec_callback(void *arg);
-static void plperl_inline_callback(void *arg);
+static void plperl_compile_callback(const void *arg);
+static void plperl_exec_callback(const void *arg);
+static void plperl_inline_callback(const void *arg);
 static char *strip_trailing_ws(const char *msg);
 static OP  *pp_require_safe(pTHX);
 static void activate_interpreter(plperl_interp_desc *interp_desc);
@@ -3644,9 +3644,9 @@ hv_fetch_string(HV *hv, const char *key)
  * Provide function name for PL/Perl execution errors
  */
 static void
-plperl_exec_callback(void *arg)
+plperl_exec_callback(const void *arg)
 {
-	char	   *procname = (char *) arg;
+	const char *procname = (const char *) arg;
 
 	if (procname)
 		errcontext("PL/Perl function \"%s\"", procname);
@@ -3656,9 +3656,9 @@ plperl_exec_callback(void *arg)
  * Provide function name for PL/Perl compilation errors
  */
 static void
-plperl_compile_callback(void *arg)
+plperl_compile_callback(const void *arg)
 {
-	char	   *procname = (char *) arg;
+	const char *procname = (const char *) arg;
 
 	if (procname)
 		errcontext("compilation of PL/Perl function \"%s\"", procname);
@@ -3668,7 +3668,7 @@ plperl_compile_callback(void *arg)
  * Provide error context for the inline handler
  */
 static void
-plperl_inline_callback(void *arg)
+plperl_inline_callback(const void *arg)
 {
 	errcontext("PL/Perl anonymous code block");
 }
diff --git a/src/pl/plpgsql/src/gram.y b/src/pl/plpgsql/src/gram.y
index fb3a546..76f9c38 100644
--- a/src/pl/plpgsql/src/gram.y
+++ b/src/pl/plpgsql/src/gram.y
@@ -97,7 +97,7 @@ static	PLpgSQL_row		*make_scalar_list1(char *initial_name,
 										   int lineno, int location);
 static	void			 check_sql_expr(const char *stmt, int location,
 										int leaderlen);
-static	void			 plpgsql_sql_error_callback(void *arg);
+static	void			 plpgsql_sql_error_callback(const void *arg);
 static	PLpgSQL_type	*parse_datatype(const char *string, int location);
 static	void			 check_labels(const char *start_label,
 									  const char *end_label,
@@ -3282,9 +3282,9 @@ check_sql_expr(const char *stmt, int location, int leaderlen)
 }
 
 static void
-plpgsql_sql_error_callback(void *arg)
+plpgsql_sql_error_callback(const void *arg)
 {
-	sql_error_callback_arg *cbarg = (sql_error_callback_arg *) arg;
+	const sql_error_callback_arg *cbarg = (const sql_error_callback_arg *) arg;
 	int			errpos;
 
 	/*
diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c
index 578cae5..75ca6c4 100644
--- a/src/pl/plpgsql/src/pl_comp.c
+++ b/src/pl/plpgsql/src/pl_comp.c
@@ -91,7 +91,7 @@ static PLpgSQL_function *do_compile(FunctionCallInfo fcinfo,
 		   PLpgSQL_function *function,
 		   PLpgSQL_func_hashkey *hashkey,
 		   bool forValidator);
-static void plpgsql_compile_error_callback(void *arg);
+static void plpgsql_compile_error_callback(const void *arg);
 static void add_parameter_name(int itemtype, int itemno, const char *name);
 static void add_dummy_return(PLpgSQL_function *function);
 static Node *plpgsql_pre_column_ref(ParseState *pstate, ColumnRef *cref);
@@ -888,7 +888,7 @@ plpgsql_compile_inline(char *proc_source)
  * source text is passed as an argument.
  */
 static void
-plpgsql_compile_error_callback(void *arg)
+plpgsql_compile_error_callback(const void *arg)
 {
 	if (arg)
 	{
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index 387362a..c97e76d 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -79,7 +79,7 @@ static SimpleEcontextStackEntry *simple_econtext_stack = NULL;
 /************************************************************
  * Local function forward declarations
  ************************************************************/
-static void plpgsql_exec_error_callback(void *arg);
+static void plpgsql_exec_error_callback(const void *arg);
 static PLpgSQL_datum *copy_plpgsql_datum(PLpgSQL_datum *datum);
 
 static int exec_stmt_block(PLpgSQL_execstate *estate,
@@ -771,9 +771,9 @@ plpgsql_exec_trigger(PLpgSQL_function *func,
  * error context callback to let us supply a call-stack traceback
  */
 static void
-plpgsql_exec_error_callback(void *arg)
+plpgsql_exec_error_callback(const void *arg)
 {
-	PLpgSQL_execstate *estate = (PLpgSQL_execstate *) arg;
+	const PLpgSQL_execstate *estate = (const PLpgSQL_execstate *) arg;
 
 	/* if we are doing RAISE, don't report its location */
 	if (estate->err_text == raise_skip_msg)
diff --git a/src/pl/plpgsql/src/plpgsql.h b/src/pl/plpgsql/src/plpgsql.h
index c638f43..dddc90e 100644
--- a/src/pl/plpgsql/src/plpgsql.h
+++ b/src/pl/plpgsql/src/plpgsql.h
@@ -809,7 +809,7 @@ typedef struct
 	void		(*stmt_end) (PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt);
 
 	/* Function pointers set by PL/pgSQL itself */
-	void		(*error_callback) (void *arg);
+	void		(*error_callback) (const void *arg);
 	void		(*assign_expr) (PLpgSQL_execstate *estate, PLpgSQL_datum *target,
 											PLpgSQL_expr *expr);
 } PLpgSQL_plugin;
diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c
index 93e8043..73dab64 100644
--- a/src/pl/plpython/plpython.c
+++ b/src/pl/plpython/plpython.c
@@ -509,7 +509,7 @@ perm_fmgr_info(Oid functionId, FmgrInfo *finfo)
 }
 
 static void
-plpython_error_callback(void *arg)
+plpython_error_callback(const void *arg)
 {
 	if (PLy_curr_procedure)
 		errcontext("PL/Python function \"%s\"",
@@ -517,20 +517,20 @@ plpython_error_callback(void *arg)
 }
 
 static void
-plpython_inline_error_callback(void *arg)
+plpython_inline_error_callback(const void *arg)
 {
 	errcontext("PL/Python anonymous code block");
 }
 
 static void
-plpython_trigger_error_callback(void *arg)
+plpython_trigger_error_callback(const void *arg)
 {
 	if (PLy_curr_procedure)
 		errcontext("while modifying trigger row");
 }
 
 static void
-plpython_return_error_callback(void *arg)
+plpython_return_error_callback(const void *arg)
 {
 	if (PLy_curr_procedure)
 		errcontext("while creating return value");
