Skip to content

Commit df76bda

Browse files
committed
Handle NULL and boolean properly in gPGSql
1 parent edf46fe commit df76bda

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

modules/gpgsqlbackend/spgsql.cc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,16 @@ bool SPgSQL::getRow(row_t &row)
166166
return false;
167167
}
168168

169-
for(int i=0;i<PQnfields(d_result);i++)
170-
row.push_back(PQgetvalue(d_result,d_count,i) ?: "");
169+
for(int i=0;i<PQnfields(d_result);i++) {
170+
if (PQgetisnull(d_result, d_count, i)) {
171+
row.push_back("");
172+
} else if (PQftype(d_result, i) == 16) { // BOOLEAN
173+
char *val = PQgetvalue(d_result, d_count, i);
174+
row.push_back(val[0] == 't' ? "1" : "0");
175+
} else {
176+
row.push_back(string(PQgetvalue(d_result, d_count, i)));
177+
}
178+
}
171179
d_count++;
172180
return true;
173181
}

0 commit comments

Comments
 (0)