Permalink
Browse files

Handle NULL and boolean properly in gPGSql

  • Loading branch information...
1 parent edf46fe commit df76bda902517e655189717e4c1c8a3c9c34ca14 @cmouse cmouse committed with cmouse Sep 13, 2015
Showing with 10 additions and 2 deletions.
  1. +10 −2 modules/gpgsqlbackend/spgsql.cc
@@ -166,8 +166,16 @@ bool SPgSQL::getRow(row_t &row)
return false;
}
- for(int i=0;i<PQnfields(d_result);i++)
- row.push_back(PQgetvalue(d_result,d_count,i) ?: "");
+ for(int i=0;i<PQnfields(d_result);i++) {
+ if (PQgetisnull(d_result, d_count, i)) {
+ row.push_back("");
+ } else if (PQftype(d_result, i) == 16) { // BOOLEAN
+ char *val = PQgetvalue(d_result, d_count, i);
+ row.push_back(val[0] == 't' ? "1" : "0");
+ } else {
+ row.push_back(string(PQgetvalue(d_result, d_count, i)));
+ }
+ }
d_count++;
return true;
}

0 comments on commit df76bda

Please sign in to comment.