v2-0002-Support-parenthesized-syntax-for-ANALYZE-in-vacuu.patch

application/octet-stream

Filename: v2-0002-Support-parenthesized-syntax-for-ANALYZE-in-vacuu.patch
Type: application/octet-stream
Part: 2
Message: Re: A few new options for vacuumdb

Patch

Format: format-patch
Series: patch v2-0002
Subject: Support parenthesized syntax for ANALYZE in vacuumdb.
File+
src/bin/scripts/vacuumdb.c 37 41
From a263b0e325d52f86cbf125318e33df9c5cefeead Mon Sep 17 00:00:00 2001
From: Nathan Bossart <bossartn@amazon.com>
Date: Fri, 4 Jan 2019 20:48:13 +0000
Subject: [PATCH v2 2/6] Support parenthesized syntax for ANALYZE in vacuumdb.

---
 src/bin/scripts/vacuumdb.c | 78 ++++++++++++++++++++++------------------------
 1 file changed, 37 insertions(+), 41 deletions(-)

diff --git a/src/bin/scripts/vacuumdb.c b/src/bin/scripts/vacuumdb.c
index 7aa5980b51..4e2bf713ae 100644
--- a/src/bin/scripts/vacuumdb.c
+++ b/src/bin/scripts/vacuumdb.c
@@ -639,54 +639,50 @@ prepare_vacuum_command(PQExpBuffer sql, PGconn *conn,
 	resetPQExpBuffer(sql);
 
 	if (vacopts->analyze_only)
-	{
 		appendPQExpBufferStr(sql, "ANALYZE");
-		if (vacopts->verbose)
-			appendPQExpBufferStr(sql, " VERBOSE");
-	}
 	else
-	{
 		appendPQExpBufferStr(sql, "VACUUM");
-		if (PQserverVersion(conn) >= 90000)
-		{
-			const char *paren = " (";
-			const char *comma = ", ";
-			const char *sep = paren;
 
-			if (vacopts->full)
-			{
-				appendPQExpBuffer(sql, "%sFULL", sep);
-				sep = comma;
-			}
-			if (vacopts->freeze)
-			{
-				appendPQExpBuffer(sql, "%sFREEZE", sep);
-				sep = comma;
-			}
-			if (vacopts->verbose)
-			{
-				appendPQExpBuffer(sql, "%sVERBOSE", sep);
-				sep = comma;
-			}
-			if (vacopts->and_analyze)
-			{
-				appendPQExpBuffer(sql, "%sANALYZE", sep);
-				sep = comma;
-			}
-			if (sep != paren)
-				appendPQExpBufferChar(sql, ')');
+	if ((vacopts->analyze_only && PQserverVersion(conn) >= 110000) ||
+		PQserverVersion(conn) >= 90000)
+	{
+		const char *paren = " (";
+		const char *comma = ", ";
+		const char *sep = paren;
+
+		if (vacopts->full)
+		{
+			appendPQExpBuffer(sql, "%sFULL", sep);
+			sep = comma;
 		}
-		else
+		if (vacopts->freeze)
+		{
+			appendPQExpBuffer(sql, "%sFREEZE", sep);
+			sep = comma;
+		}
+		if (vacopts->verbose)
 		{
-			if (vacopts->full)
-				appendPQExpBufferStr(sql, " FULL");
-			if (vacopts->freeze)
-				appendPQExpBufferStr(sql, " FREEZE");
-			if (vacopts->verbose)
-				appendPQExpBufferStr(sql, " VERBOSE");
-			if (vacopts->and_analyze)
-				appendPQExpBufferStr(sql, " ANALYZE");
+			appendPQExpBuffer(sql, "%sVERBOSE", sep);
+			sep = comma;
 		}
+		if (vacopts->and_analyze && !vacopts->analyze_only)
+		{
+			appendPQExpBuffer(sql, "%sANALYZE", sep);
+			sep = comma;
+		}
+		if (sep != paren)
+			appendPQExpBufferChar(sql, ')');
+	}
+	else
+	{
+		if (vacopts->full)
+			appendPQExpBufferStr(sql, " FULL");
+		if (vacopts->freeze)
+			appendPQExpBufferStr(sql, " FREEZE");
+		if (vacopts->verbose)
+			appendPQExpBufferStr(sql, " VERBOSE");
+		if (vacopts->and_analyze && !vacopts->analyze_only)
+			appendPQExpBufferStr(sql, " ANALYZE");
 	}
 
 	if (table)
-- 
2.16.5