Skip to content

Commit

Permalink
Refactor ifs into switch/case
Browse files Browse the repository at this point in the history
  • Loading branch information
jgoizueta committed Aug 2, 2016
1 parent f903e6a commit cb4a4c2
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions odbc_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1535,25 +1535,29 @@ odbcIterateForeignScan(ForeignScanState *node)
buf = pg_any_to_server(buf, strlen(buf), festate->encoding);
}
initStringInfo(&col_data);
if (conversion == HEX_CONVERSION)
switch (conversion)
{
appendStringInfoString (&col_data, "\\x");
case TEXT_CONVERSION :
appendStringInfoString (&col_data, buf);
break;
case HEX_CONVERSION :
appendStringInfoString (&col_data, "\\x");
appendStringInfoString (&col_data, buf);
break;
case BOOL_CONVERSION :
if (buf[0] == 0)
strcpy(buf, "F");
else if (buf[0] == 1)
strcpy(buf, "T");
appendStringInfoString (&col_data, buf);
break;
case BIN_CONVERSION :
ereport(ERROR,
(errcode(ERRCODE_FDW_INVALID_DATA_TYPE),
errmsg("Bit string columns are not supported")
));
break;
}
if (conversion == BOOL_CONVERSION)
{
if (buf[0] == 0)
strcpy(buf, "F");
else if (buf[0] == 1)
strcpy(buf, "T");
}
if (conversion == BIN_CONVERSION)
{
ereport(ERROR,
(errcode(ERRCODE_FDW_INVALID_DATA_TYPE),
errmsg("Bit string columns are not supported")
));
}
appendStringInfoString (&col_data, buf);

values[mapped_pos] = col_data.data;
}
Expand Down

0 comments on commit cb4a4c2

Please sign in to comment.