summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/sepgsql/label.c33
1 files changed, 6 insertions, 27 deletions
diff --git a/contrib/sepgsql/label.c b/contrib/sepgsql/label.c
index 6e7c0d7cfff..440d9f0d507 100644
--- a/contrib/sepgsql/label.c
+++ b/contrib/sepgsql/label.c
@@ -646,45 +646,24 @@ sepgsql_mcstrans_out(PG_FUNCTION_ARGS)
/*
* quote_object_name
*
- * It tries to quote the supplied identifiers
+ * Concatenate as many of the given strings as aren't NULL, with dots between.
+ * Quote any of the strings that wouldn't be valid identifiers otherwise.
*/
static char *
quote_object_name(const char *src1, const char *src2,
const char *src3, const char *src4)
{
StringInfoData result;
- const char *temp;
initStringInfo(&result);
-
if (src1)
- {
- temp = quote_identifier(src1);
- appendStringInfoString(&result, temp);
- if (src1 != temp)
- pfree(temp);
- }
+ appendStringInfoString(&result, quote_identifier(src1));
if (src2)
- {
- temp = quote_identifier(src2);
- appendStringInfo(&result, ".%s", temp);
- if (src2 != temp)
- pfree(temp);
- }
+ appendStringInfo(&result, ".%s", quote_identifier(src2));
if (src3)
- {
- temp = quote_identifier(src3);
- appendStringInfo(&result, ".%s", temp);
- if (src3 != temp)
- pfree(temp);
- }
+ appendStringInfo(&result, ".%s", quote_identifier(src3));
if (src4)
- {
- temp = quote_identifier(src4);
- appendStringInfo(&result, ".%s", temp);
- if (src4 != temp)
- pfree(temp);
- }
+ appendStringInfo(&result, ".%s", quote_identifier(src4));
return result.data;
}