finished postgres fetch

This commit is contained in:
2023-11-26 20:09:48 +01:00
parent 825e530a8d
commit 640dcfadb6
9 changed files with 194 additions and 99 deletions
@@ -24,7 +24,7 @@ size_t postgres_result_reader::column_count() const
const char *postgres_result_reader::column(size_t index) const
{
return nullptr;
return PQgetvalue(result_, static_cast<int>(row_index_), static_cast<int>(index));
}
bool postgres_result_reader::fetch()
@@ -99,22 +99,39 @@ void postgres_result_reader::read_value(const char *id, size_t index, double &va
void postgres_result_reader::read_value(const char *id, size_t index, char *value, size_t s)
{
auto *val = PQgetvalue(result_, static_cast<int>(row_index_), static_cast<int>(index));
size_t len = strlen(value);
if (len > (size_t)s) {
#ifdef _MSC_VER
strncpy_s(val, s, value, s);
#else
strncpy(val, value, s);
#endif
val[s-1] = '\n';
} else {
#ifdef _MSC_VER
strcpy_s(val, s, value);
#else
strcpy(val, value);
#endif
}
}
void postgres_result_reader::read_value(const char *id, size_t index, std::string &value)
{
auto *val = PQgetvalue(result_, static_cast<int>(row_index_), static_cast<int>(index));
if (strlen(val) != 0) {
value.assign(val);
}
}
void postgres_result_reader::read_value(const char *id, size_t index, std::string &value, size_t s)
{
auto *val = PQgetvalue(result_, static_cast<int>(row_index_), static_cast<int>(index));
if (strlen(val) != 0) {
value.assign(val);
}
}
void postgres_result_reader::read_value(const char *id, size_t index, sql::any_type &value, sql::data_type_t type,
size_t size)
{
}
}