binary_minor.patch

text/plain

Filename: binary_minor.patch
Type: text/plain
Part: 0
Message: Add minor version to v3 protocol to allow changes without breaking backwards compatibility

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/utils/adt/version.c 1 0
src/backend/utils/misc/guc.c 27 0
src/include/utils/binaryminorversion.h 32 0
src/include/utils/builtins.h 2 0
commit d7ef5f1aef0941ec4b931f24745b65d77e7511e4
Author: Mikko Tiihonen <mikko.tiihonen@nitor.fi>
Date:   Sun Nov 27 14:12:59 2011 +0200

    Define binary_minor variable to control binary protocol minor version

diff --git a/src/backend/utils/adt/version.c b/src/backend/utils/adt/version.c
index 6ea5bd2..33ed4d3 100644
--- a/src/backend/utils/adt/version.c
+++ b/src/backend/utils/adt/version.c
@@ -16,6 +16,7 @@
 
 #include "utils/builtins.h"
 
+int binary_minor = 0;
 
 Datum
 pgsql_version(PG_FUNCTION_ARGS)
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index da7b6d4..67e80f1 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -64,6 +64,7 @@
 #include "storage/predicate.h"
 #include "tcop/tcopprot.h"
 #include "tsearch/ts_cache.h"
+#include "utils/binaryminorversion.h"
 #include "utils/builtins.h"
 #include "utils/bytea.h"
 #include "utils/guc_tables.h"
@@ -2053,6 +2054,18 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
+		{"binary_minor", PGC_USERSET, CLIENT_CONN_LOCALE,
+			gettext_noop("Sets the binary protocol minor version that controls enabling"
+						 "of newer features."),
+			gettext_noop("The default value is 0 which uses the binary protocol features"
+						 "as specified in postgres 9.1 release.")
+		},
+		&binary_minor,
+		0, 0, SUPPORTED_BINARY_MINOR_VERSION,
+		NULL, NULL, NULL
+	},
+
+	{
 		{"log_min_duration_statement", PGC_SUSET, LOGGING_WHEN,
 			gettext_noop("Sets the minimum execution time above which "
 						 "statements will be logged."),
diff --git a/src/include/utils/binaryminorversion.h b/src/include/utils/binaryminorversion.h
new file mode 100644
index 0000000..40ba970
--- /dev/null
+++ b/src/include/utils/binaryminorversion.h
@@ -0,0 +1,32 @@
+/*-------------------------------------------------------------------------
+ *
+ * binaryminorversion.h
+ *	  "Binary protocol encoding minor version number" for PostgreSQL.
+ *
+ * The catalog version number is used to flag incompatible changes in
+ * the PostgreSQL v3 binary protocol.  Whenever anyone changes the
+ * format of binary protocol, or modifies the standard types in such a
+ * way that an updated client wouldn't work with an old database
+ * (or vice versa), the binary protocol encoding version number
+ * should be changed.
+ *
+ * The point of this feature is to provide a way to allow introducing
+ * small new features to the binary encoding of types or the actual
+ * v3 protocol while still allowing full backward compatibility with
+ * old clients. The client can be an application using postgres,
+ * any tool using COPY BINARY or another postgres backend using 
+ * replication (TODO: does this affect replication?).
+ *
+ * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/include/util/binprotoversion.h
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef BINARYMINORVERSION_H
+#define BINARYMINORVERSION_H
+
+#define SUPPORTED_BINARY_MINOR_VERSION 1
+
+#endif
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 47a1412..c201d66 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -461,6 +461,8 @@ extern Datum pg_sleep(PG_FUNCTION_ARGS);
 extern Datum pg_get_keywords(PG_FUNCTION_ARGS);
 extern Datum pg_typeof(PG_FUNCTION_ARGS);
 
+extern PGDLLIMPORT int binary_minor;
+
 /* oid.c */
 extern Datum oidin(PG_FUNCTION_ARGS);
 extern Datum oidout(PG_FUNCTION_ARGS);
commit 06af85f130e2150f3ab5bcbd2c49dbecb69d98ec
Author: Mikko Tiihonen <mikko.tiihonen@nitor.fi>
Date:   Mon Nov 28 09:53:01 2011 +0200

    Add supported_binary_minor startup option

diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 67e80f1..6e5c908 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -477,6 +477,7 @@ static int	segment_size;
 static int	wal_block_size;
 static int	wal_segment_size;
 static bool integer_datetimes;
+static int  supported_binary_minor;
 static int	effective_io_concurrency;
 
 /* should be static, but commands/variable.c needs to get at this */
@@ -1976,6 +1977,19 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
+		{"supported_binary_minor", PGC_INTERNAL, PRESET_OPTIONS,
+			gettext_noop("Maximum supported binary minor version."),
+			NULL,
+			GUC_REPORT | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
+		},
+		&supported_binary_minor,
+		SUPPORTED_BINARY_MINOR_VERSION,
+		SUPPORTED_BINARY_MINOR_VERSION,
+		SUPPORTED_BINARY_MINOR_VERSION,
+		NULL, NULL, NULL
+	},
+
+	{
 		{"wal_buffers", PGC_POSTMASTER, WAL_SETTINGS,
 			gettext_noop("Sets the number of disk-page buffers in shared memory for WAL."),
 			NULL,