Previous: Standard Introspection, Up: Introspection


15.2 Funky Introspection

The column definitions of an existing table can be discovered to some extent by the defs-from-psql, infer-defs and describe-table! procedures, the last one also displaying details on field/column innards.

[NOTE: docs missing for defs-from-psql]

[NOTE: docs missing for infer-defs]

[NOTE: docs missing for describe-table!]

Once you have a set of defs, you can verify that their types are supported by Guile-PG with the following procedures.

[NOTE: docs missing for check-type/elaborate]

[NOTE: docs missing for strictly-check-types/elaborate!]

Example

     (define DEFS (defs-from-psql #t "glug" "updok"))
     
     (car DEFS)
     ⇒ (time timestamp "without time zone not null")
     
     (map type-name DEFS)
     ⇒ (timestamp integer integer real integer real)
     
     (strictly-check-types/elaborate! "updok" (map type-name DEFS))
     -|
     ERROR: bad "updok" types: (real real)
     ABORT: (misc-error)

In this example, we use the external program psql to find out the defs for the table updok in database glug; use type-name to get the types (see Column Definitions); and finally check to see which ones, if any, are unknown to Guile-PG. The error output lists real twice because two of the DEFS have that type.