From 3a6fdada111c1eb70d1f1d594d70af6a667cf601 Mon Sep 17 00:00:00 2001 From: gindibay Date: Sat, 14 Oct 2023 05:35:34 +0300 Subject: [PATCH] Changes if to switch statements --- .../distributed/deparser/citus_deparseutils.c | 62 ++++++++++--------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/src/backend/distributed/deparser/citus_deparseutils.c b/src/backend/distributed/deparser/citus_deparseutils.c index 52d96930e..f96244a27 100644 --- a/src/backend/distributed/deparser/citus_deparseutils.c +++ b/src/backend/distributed/deparser/citus_deparseutils.c @@ -31,36 +31,38 @@ optionToStatement(StringInfo buf, DefElem *option, const struct { if (strcmp(name, opt_formats[i].name) == 0) { - if (opt_formats[i].type == OPTION_FORMAT_STRING) - { - char *value = defGetString(option); - appendStringInfo(buf, opt_formats[i].format, quote_identifier(value)); - } - else if (opt_formats[i].type == OPTION_FORMAT_INTEGER) - { - int32 value = defGetInt32(option); - appendStringInfo(buf, opt_formats[i].format, value); - } - else if (opt_formats[i].type == OPTION_FORMAT_BOOLEAN) - { - bool value = defGetBoolean(option); - appendStringInfo(buf, opt_formats[i].format, value ? "true" : "false"); - } -#if PG_VERSION_NUM >= PG_VERSION_15 - else if (opt_formats[i].type == OPTION_FORMAT_OBJECT_ID) - { - Oid value = defGetObjectId(option); - appendStringInfo(buf, opt_formats[i].format, value); - } -#endif - else if (opt_formats[i].type == OPTION_FORMAT_LITERAL_CSTR) - { - char *value = defGetString(option); - appendStringInfo(buf, opt_formats[i].format, quote_literal_cstr(value)); - } - else - { - elog(ERROR, "unrecognized option type: %d", opt_formats[i].type); + switch (opt_formats[i].type) { + case OPTION_FORMAT_STRING: { + char *value = defGetString(option); + appendStringInfo(buf, opt_formats[i].format, quote_identifier(value)); + break; + } + case OPTION_FORMAT_INTEGER: { + int32 value = defGetInt32(option); + appendStringInfo(buf, opt_formats[i].format, value); + break; + } + case OPTION_FORMAT_BOOLEAN: { + bool value = defGetBoolean(option); + appendStringInfo(buf, opt_formats[i].format, value ? "true" : "false"); + break; + } + #if PG_VERSION_NUM >= PG_VERSION_15 + case OPTION_FORMAT_OBJECT_ID: { + Oid value = defGetObjectId(option); + appendStringInfo(buf, opt_formats[i].format, value); + break; + } + #endif + case OPTION_FORMAT_LITERAL_CSTR: { + char *value = defGetString(option); + appendStringInfo(buf, opt_formats[i].format, quote_literal_cstr(value)); + break; + } + default: { + elog(ERROR, "unrecognized option type: %d", opt_formats[i].type); + break; + } } break; }