Home Explore Blog CI



postgresql

62th chunk of `doc/src/sgml/libpq.sgml`
c80813f5b830bdae043c096a50459e378be59081a62a95d80000000100000fc9
 <term><function>PQftable</function><indexterm><primary>PQftable</primary></indexterm></term>

     <listitem>
      <para>
       Returns the OID of the table from which the given column was
       fetched.  Column numbers start at 0.
<synopsis>
Oid PQftable(const PGresult *res,
             int column_number);
</synopsis>
      </para>

      <para>
       <literal>InvalidOid</literal> is returned if the column number is out of range,
       or if the specified column is not a simple reference to a table column.
       You can query the system table <literal>pg_class</literal> to determine
       exactly which table is referenced.
      </para>

      <para>
       The type <type>Oid</type> and the constant
       <literal>InvalidOid</literal> will be defined when you include
       the <application>libpq</application> header file. They will both
       be some integer type.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry id="libpq-PQftablecol">
     <term><function>PQftablecol</function><indexterm><primary>PQftablecol</primary></indexterm></term>

     <listitem>
      <para>
       Returns the column number (within its table) of the column making
       up the specified query result column.  Query-result column numbers
       start at 0, but table columns have nonzero numbers.
<synopsis>
int PQftablecol(const PGresult *res,
                int column_number);
</synopsis>
      </para>

      <para>
       Zero is returned if the column number is out of range, or if the
       specified column is not a simple reference to a table column.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry id="libpq-PQfformat">
     <term><function>PQfformat</function><indexterm><primary>PQfformat</primary></indexterm></term>

     <listitem>
      <para>
       Returns the format code indicating the format of the given
       column.  Column numbers start at 0.
<synopsis>
int PQfformat(const PGresult *res,
              int column_number);
</synopsis>
      </para>

      <para>
       Format code zero indicates textual data representation, while format
       code one indicates binary representation.  (Other codes are reserved
       for future definition.)
      </para>
     </listitem>
    </varlistentry>

    <varlistentry id="libpq-PQftype">
     <term><function>PQftype</function><indexterm><primary>PQftype</primary></indexterm></term>

     <listitem>
      <para>
       Returns the data type associated with the given  column number.
       The  integer  returned is the internal OID number of the type.
       Column numbers start at 0.
<synopsis>
Oid PQftype(const PGresult *res,
            int column_number);
</synopsis>
      </para>

      <para>
       You can query the system table <literal>pg_type</literal> to
       obtain the names and properties of the various data types. The
       <acronym>OID</acronym>s of the built-in data types are defined
       in the file <filename>catalog/pg_type_d.h</filename>
       in the <productname>PostgreSQL</productname>
       installation's <filename>include</filename> directory.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry id="libpq-PQfmod">
     <term><function>PQfmod</function><indexterm><primary>PQfmod</primary></indexterm></term>

     <listitem>
      <para>
       Returns  the type modifier of the column associated with the
       given column number.  Column numbers start at 0.
<synopsis>
int PQfmod(const PGresult *res,
           int column_number);
</synopsis>
      </para>

      <para>
       The interpretation of modifier values is type-specific; they
       typically indicate precision or size limits.  The value -1 is
       used to indicate <quote>no information available</quote>.  Most data
       types do not use modifiers, in which case the value is always
       -1.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry id="libpq-PQfsize">
     <term><function>PQfsize</function><indexterm><primary>PQfsize</primary></indexterm></term>

Title: More Functions for Extracting Column Information from Query Results in libpq
Summary
This section details additional libpq functions for retrieving column-specific information from a query result. It covers `PQftablecol` (to get the column number within its table), `PQfformat` (to get the column's format code, text or binary), `PQftype` (to get the column's data type OID), and `PQfmod` (to get the column's type modifier). It describes what each function returns, including special values indicating errors or unavailable information, and how to interpret the results.