1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-27 07:42:10 +03:00

Let compiler handle size calculation of bool types.

Back in the day this did not work, but modern compilers should handle it themselves.
This commit is contained in:
Michael Meskes
2015-09-17 15:41:04 +02:00
parent 22f519c92a
commit 293fd7c77e
2 changed files with 4 additions and 27 deletions

View File

@@ -423,27 +423,13 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case ECPGt_bool:
if (pval[0] == 'f' && pval[1] == '\0')
{
if (offset == sizeof(char))
*((char *) (var + offset * act_tuple)) = false;
else if (offset == sizeof(int))
*((int *) (var + offset * act_tuple)) = false;
else
ecpg_raise(lineno, ECPG_CONVERT_BOOL,
ECPG_SQLSTATE_DATATYPE_MISMATCH,
NULL);
*((bool *) (var + offset * act_tuple)) = false;
pval++;
break;
}
else if (pval[0] == 't' && pval[1] == '\0')
{
if (offset == sizeof(char))
*((char *) (var + offset * act_tuple)) = true;
else if (offset == sizeof(int))
*((int *) (var + offset * act_tuple)) = true;
else
ecpg_raise(lineno, ECPG_CONVERT_BOOL,
ECPG_SQLSTATE_DATATYPE_MISMATCH,
NULL);
*((bool *) (var + offset * act_tuple)) = true;
pval++;
break;
}