deparse: fix SECURITY LABEL ... IS NULL
authorAndres Freund <andres@anarazel.de>
Sun, 2 Nov 2014 13:52:13 +0000 (14:52 +0100)
committerAndres Freund <andres@anarazel.de>
Sun, 2 Nov 2014 13:52:13 +0000 (14:52 +0100)
src/backend/tcop/deparse_utility.c

index 91ad80809282dec443651003c6567a5daafa4138..94955f28091d7d70ca4c3979bd4c989808a2ed22 100644 (file)
@@ -3946,11 +3946,21 @@ deparse_SecLabelStmt(Oid objectId, Oid objectSubId, Node *parsetree)
    char       *fmt;
    char       *command;
 
-   fmt = psprintf("SECURITY LABEL FOR %%{provider}s ON %s %%{identity}s IS %%{label}L",
+   if (node->label)
+   {
+       fmt = psprintf("SECURITY LABEL FOR %%{provider}s ON %s %%{identity}s IS %%{label}L",
                   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);
+   }
 
-   append_string_object(label, "label", node->label);
    append_string_object(label, "provider", node->provider);
 
    addr.classId = get_objtype_catalog_oid(node->objtype);