readonlycluster.diff

text/plain

Filename: readonlycluster.diff
Type: text/plain
Part: 0
Message: Re: read-only database

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
File+
src/backend/executor/execMain.c 2 1
src/backend/postmaster/postmaster.c 6 1
src/backend/tcop/utility.c 2 1
src/backend/utils/misc/guc.c 9 0
src/include/postmaster/postmaster.h 1 0
diff -ru postgresql-8.0.1.orig/src/backend/executor/execMain.c postgresql-8.0.1/src/backend/executor/execMain.c
--- postgresql-8.0.1.orig/src/backend/executor/execMain.c	2005-01-15 02:53:33.000000000 +0900
+++ postgresql-8.0.1/src/backend/executor/execMain.c	2005-03-21 13:12:22.000000000 +0900
@@ -43,6 +43,7 @@
 #include "optimizer/clauses.h"
 #include "optimizer/var.h"
 #include "parser/parsetree.h"
+#include "postmaster/postmaster.h"
 #include "utils/acl.h"
 #include "utils/guc.h"
 #include "utils/lsyscache.h"
@@ -127,7 +128,7 @@
 	 * If the transaction is read-only, we need to check if any writes are
 	 * planned to non-temporary tables.
 	 */
-	if (XactReadOnly && !explainOnly)
+	if ( (XactReadOnly || ReadOnlyCluster) && !explainOnly)
 		ExecCheckXactReadOnly(queryDesc->parsetree);
 
 	/*
diff -ru postgresql-8.0.1.orig/src/backend/postmaster/postmaster.c postgresql-8.0.1/src/backend/postmaster/postmaster.c
--- postgresql-8.0.1.orig/src/backend/postmaster/postmaster.c	2005-01-13 01:38:17.000000000 +0900
+++ postgresql-8.0.1/src/backend/postmaster/postmaster.c	2005-03-21 13:21:17.000000000 +0900
@@ -236,6 +236,8 @@
 extern int	optreset;
 #endif
 
+bool		ReadOnlyCluster = false;
+
 /*
  * postmaster.c - function prototypes
  */
@@ -440,7 +442,7 @@
 
 	opterr = 1;
 
-	while ((opt = getopt(argc, argv, "A:a:B:b:c:D:d:Fh:ik:lm:MN:no:p:Ss-:")) != -1)
+	while ((opt = getopt(argc, argv, "A:a:B:b:c:D:d:Fh:ik:lm:MN:no:p:rSs-:")) != -1)
 	{
 		switch (opt)
 		{
@@ -515,6 +517,9 @@
 			case 'p':
 				SetConfigOption("port", optarg, PGC_POSTMASTER, PGC_S_ARGV);
 				break;
+			case 'r':
+				SetConfigOption("readonly_cluster", "true", PGC_POSTMASTER, PGC_S_ARGV);
+				break;
 			case 'S':
 
 				/*
diff -ru postgresql-8.0.1.orig/src/backend/tcop/utility.c postgresql-8.0.1/src/backend/tcop/utility.c
--- postgresql-8.0.1.orig/src/backend/tcop/utility.c	2005-01-25 02:46:29.000000000 +0900
+++ postgresql-8.0.1/src/backend/tcop/utility.c	2005-03-21 13:13:45.000000000 +0900
@@ -47,6 +47,7 @@
 #include "parser/parse_expr.h"
 #include "parser/parse_type.h"
 #include "postmaster/bgwriter.h"
+#include "postmaster/postmaster.h"
 #include "rewrite/rewriteDefine.h"
 #include "rewrite/rewriteRemove.h"
 #include "storage/fd.h"
@@ -265,7 +266,7 @@
 static void
 check_xact_readonly(Node *parsetree)
 {
-	if (!XactReadOnly)
+	if (!XactReadOnly && !ReadOnlyCluster)
 		return;
 
 	/*
diff -ru postgresql-8.0.1.orig/src/backend/utils/misc/guc.c postgresql-8.0.1/src/backend/utils/misc/guc.c
--- postgresql-8.0.1.orig/src/backend/utils/misc/guc.c	2005-01-01 14:43:08.000000000 +0900
+++ postgresql-8.0.1/src/backend/utils/misc/guc.c	2005-03-21 13:06:42.000000000 +0900
@@ -851,6 +851,15 @@
 #endif
 	},
 
+	{
+		{"readonly_cluster", PGC_POSTMASTER, UNGROUPED,
+			gettext_noop("Enables the postmaster read-only."),
+			NULL
+		},
+		&ReadOnlyCluster,
+		false, NULL, NULL
+	},
+
 	/* End-of-list marker */
 	{
 		{NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL
diff -ru postgresql-8.0.1.orig/src/include/postmaster/postmaster.h postgresql-8.0.1/src/include/postmaster/postmaster.h
--- postgresql-8.0.1.orig/src/include/postmaster/postmaster.h	2005-01-01 07:03:39.000000000 +0900
+++ postgresql-8.0.1/src/include/postmaster/postmaster.h	2005-03-21 13:03:16.000000000 +0900
@@ -34,6 +34,7 @@
 extern HANDLE PostmasterHandle;
 #endif
 
+extern bool ReadOnlyCluster;
 
 extern int	PostmasterMain(int argc, char *argv[]);
 extern void ClosePostmasterPorts(bool am_syslogger);