Index: libpq.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql/doc/src/sgml/libpq.sgml,v
retrieving revision 1.72
diff -c -p -r1.72 libpq.sgml
*** libpq.sgml 2001/09/13 15:55:23 1.72
--- libpq.sgml 2001/11/07 19:06:52
*************** PGresult *PQexec(PGconn *conn,
*** 728,733 ****
--- 728,748 ----
PQerrorMessage to get more information about the error.
+
+
+
+ PQexecIncludeMetadata
+ Submit a query to the server and wait for the result;
+ include extra metadata about the result fields.
+ This makes available information such as the type name,
+ precision and scale for each field in the result.
+
+ PGresult *PQexecIncludeMetadata(PGconn *conn,
+ const char *query);
+
+ Used the same way as PQexec().
+
+
*************** You can query the system table
*** 964,969 ****
--- 979,986 ----
the name and properties of the various data types. The OIDs
of the built-in data types are defined in src/include/catalog/pg_type.h
in the source tree.
+ The function PQftypename can be used to retrieve the
+ type name if the result was obtained via PQexecIncludeMetadata.
*************** extracts data from a BINARY
+
+
+ The following functions only produce meaningful results if
+ PQexecIncludeMetadata was used
+ (as opposed to PQexec).
+
+
+
+
+
+
+ PQftypename
+ Returns the name of the column type as a string.
+ Field indices start at 0.
+
+ char *PQftypename(const PGresult *res,
+ int field_index);
+
+ Returns the name of the column type as a string.
+ Copy the string if needed -- do not modify, free()
+ or assume its persistence. The internal type name is
+ returned; use PQtypeint2ext() to convert to a more SQL-ish style.
+ NULL is returned if the field type name is not availble.
+
+
+
+
+
+ PQfprecision
+ Returns the precision of the field
+ associated with the given field index.
+ Field indices start at 0.
+
+ int PQfprecision(const PGresult *res,
+ int field_index);
+
+ Returns the precision of the field
+ associated with the given field index.
+ For numeric types (INTEGER, FLOAT, etc.), PQfprecision returns the
+ number of decimal digits in the specified field. For character and bit
+ string types, such as VARCHAR and BIT, PQfprecision returns the
+ maximum number of characters/bits allowed in the specified field.
+ PQfprecision returns 0 if precision information is not available and
+ -1 if precision is not applicable to the field in question. The latter
+ will be the case if the type of the field is POINT, for example.
+
+
+
+
+
+ PQfscale
+ Returns the scale of the field
+ associated with the given field index.
+ Field indices start at 0.
+
+ int PQfscale(const PGresult *res,
+ int field_index);
+
+ Returns the scale of the field
+ associated with the given field index.
+ PQfscale returns the scale of the field associated with the given
+ field index. Scale is the number of digits after the decimal point,
+ so this function is useful only with fields that are of a numeric
+ type (INTEGER, FLOAT, NUMERIC, etc.). -1 is returned if scale is not
+ applicable to the field type. 0 is returned if scale information is
+ not available.
+
+
+
+
+
+ Use the function below to convert internal type names (like the
+ ones returned by PQftypename) into something
+ more user-friendly.
+
+
+
+
+
+ PQtypeint2ext
+ Converts an internal type name into a SQL-ish
+ type name.
+
+ char *PQtypeint2ext(const char **intname);
+
+ Converts an internal type name into a SQL-ish
+ type name.
+ NULL is returned if the internal type is not recognized
+ (which will be the case if the type is a UDT).
+
+
+
+
+