Commit 969eee02 authored by Eric Marsden's avatar Eric Marsden

Add a utility function PG-DESCRIBE-TABLE.

parent 83bcb58d
;;; meta-queries.lisp -- DBMS metainformation
;;; Author: Eric Marsden <>
;;; Time-stamp: <2004-03-05 emarsden>
;;; Author: Eric Marsden <>
;;; Time-stamp: <2005-12-19 emarsden>
;; Metainformation such as the list of databases present in the
......@@ -36,5 +36,15 @@
(let ((res (pg-exec conn "SELECT version()")))
(first (pg-result res :tuple 0))))
(defun pg-describe-table (conn table)
(flet ((oid-to-name (oid)
(maphash (lambda (key value)
(when (eql value oid)
(return-from oid-to-name key)))
(let ((res (pg-exec conn (format nil "SELECT * FROM ~S WHERE 0=1" table))))
(loop :for (name oid) :in (pg-result res :attributes)
:collect (list name (oid-to-name oid))))))
;; EOF
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment