From 33d3329613a55cd4148ac54a7b4717fb44a14c01 Mon Sep 17 00:00:00 2001
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: Tue, 24 Feb 2015 13:21:35 -0300
Subject: [PATCH 41/44] fixup! deparse: support SECURITY LABEL

use append_literal_or_null from COMMENT
---
 src/backend/tcop/deparse_utility.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/backend/tcop/deparse_utility.c b/src/backend/tcop/deparse_utility.c
index dda0f2f..3e2b98b 100644
--- a/src/backend/tcop/deparse_utility.c
+++ b/src/backend/tcop/deparse_utility.c
@@ -4594,23 +4594,17 @@ deparse_SecLabelStmt(ObjectAddress address, Node *parsetree)
 
 	Assert(node->provider);
 
-	if (node->label)
-	{
-		fmt = psprintf("SECURITY LABEL FOR %%{provider}s ON %s %%{identity}s IS %%{label}L",
+	fmt = psprintf("SECURITY LABEL FOR %%{provider}s ON %s %%{identity}s IS %%{label}s",
 				   stringify_objtype(node->objtype));
-		label = new_objtree_VA(fmt, 0);
+	label = new_objtree_VA(fmt, 0);
 
-		append_string_object(label, "label", node->label);
-	}
-	else
-	{
-		fmt = psprintf("SECURITY LABEL FOR %%{provider}s ON %s %%{identity}s IS NULL",
-				   stringify_objtype(node->objtype));
-		label = new_objtree_VA(fmt, 0);
-	}
+	/* Add the label clause; can be either NULL or a quoted literal. */
+	append_literal_or_null(label, "label", node->label);
 
+	/* Add the security provider clause */
 	append_string_object(label, "provider", node->provider);
 
+	/* Add the object identity clause */
 	append_string_object(label, "identity",
 						 getObjectIdentity(&address));
 
-- 
2.1.4

