Skip to content

Commit

Permalink
Added 2 functions (column_size and column_mod) under pqxx::result file (
Browse files Browse the repository at this point in the history
#727)

Support `PQfsize()` and `PQfmod()`.
  • Loading branch information
TeamPlatform1 committed Sep 2, 2023
1 parent 66774c1 commit e079dbb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/pqxx/result.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,20 @@ public:
/// Name of column with this number (throws exception if it doesn't exist)
[[nodiscard]] char const *column_name(row_size_type number) const &;

/// Size in bytes of column with this number
/** This is the size of the server's internal representation of the data type.
* A negative value indicates the data type is variable-length.
*/
/// This is the size of the server's internal representation of the data type
[[nodiscard]] int column_storage(row_size_type number) const noexcept;

/// Type modifier of the column with this number
/** The interpretation of modifier values is type-specific; they typically indicate precision or size limits.
* The value -1 is used to indicate “no information available”.
* Most data types do not use modifiers, in which case the value is always -1.
*/
[[nodiscard]] int column_type_modifier(row_size_type number) const noexcept;

/// Return column's type, as an OID from the system catalogue.
[[nodiscard]] oid column_type(row_size_type col_num) const;

Expand Down
12 changes: 12 additions & 0 deletions src/result.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,18 @@ pqxx::row::size_type pqxx::result::columns() const noexcept
}


int pqxx::result::column_storage(pqxx::row::size_type number) const noexcept
{
return PQfsize(m_data.get(), number);
}


int pqxx::result::column_type_modifier(pqxx::row::size_type number) const noexcept
{
return PQfmod(m_data.get(), number);
}


// const_result_iterator

pqxx::const_result_iterator pqxx::const_result_iterator::operator++(int)
Expand Down

0 comments on commit e079dbb

Please sign in to comment.