postmodern

API Reference

cl-postgres

Low-level client library for PostgreSQL

CL-POSTGRES-TRIVIAL-UTF-8

  • Function UTF-8-BYTE-LENGTH (string)
    Calculate the amount of bytes needed to encode a string.
  • Function STRING-TO-UTF-8-BYTES (string &key null-terminate)
    Convert a string into an array of unsigned bytes containing its utf-8 representation.
  • Function WRITE-UTF-8-BYTES (string output &key null-terminate)
    Write a string to a byte-stream, encoding it as utf-8.
  • Condition UTF-8-DECODING-ERROR  (SIMPLE-ERROR)
  • Function UTF-8-GROUP-SIZE (byte)
    Determine the amount of bytes that are part of the character starting with a given byte.
  • Function UTF-8-BYTES-TO-STRING (bytes-in &key (start 0) (end (length bytes-in)))
    Convert a byte array containing utf-8 encoded characters into the string it encodes.
  • Function READ-UTF-8-STRING (input &key null-terminated stop-at-eof (char-length -1) (byte-length -1))
    Read utf-8 encoded data from a byte stream and construct a string with the characters found. When null-terminated is given it will stop reading at a null character, stop-at-eof tells it to stop at the end of file without raising an error, and the char-length and byte-length parameters can be used to specify the max amount of characters or bytes to read.

CL-POSTGRES-IEEE-FLOATS

  • Macro MAKE-FLOAT-CONVERTERS (encoder-name decoder-name exponent-bits significand-bits support-nan-and-infinity-p)
    Writes an encoder and decoder function for floating point numbers with the given amount of exponent and significand bits (plus an extra sign bit). If support-nan-and-infinity-p is true, the decoders will also understand these special cases. NaN is represented as :not-a-number, and the infinities as :positive-infinity and :negative-infinity. Note that this means that the in- or output of these functions is not just floating point numbers anymore, but also keywords.
  • Function ENCODE-FLOAT32 (float)
  • Function DECODE-FLOAT32 (bits)
  • Function ENCODE-FLOAT64 (float)
  • Function DECODE-FLOAT64 (bits)

CL-POSTGRES.FEATURES

No exported symbols.

CL-POSTGRES

  • Variable *QUERY-LOG*
    nil
  • Variable *QUERY-CALLBACK*
    'cl-postgres:log-query
  • Function LOG-QUERY (query time-units)
  • Condition DATABASE-ERROR  (ERROR)
    This is the condition type that will be used to signal virtually all database-related errors (though in some cases socket errors may be raised when a connection fails on the IP level).
  • Function DATABASE-ERROR-CONSTRAINT-NAME (err)
    Given a database-error for an integrity violation, will attempt to extract the constraint name.
  • Condition DATABASE-CONNECTION-ERROR  (DATABASE-ERROR)
    Conditions of this type are signalled when an error occurs that breaks the connection socket. They offer a :reconnect restart.
  • Condition DATABASE-CONNECTION-LOST  (DATABASE-CONNECTION-ERROR)
    Raised when a query is initiated on a disconnected connection object.
  • Condition DATABASE-SOCKET-ERROR  (DATABASE-CONNECTION-ERROR)
    Used to wrap stream-errors and socket-errors, giving them a database-connection-error superclass.
  • Variable *SILENTLY-TRUNCATE-RATIONALS*
    t
  • Generic-Function TO-SQL-STRING (arg)
    Turn a lisp value into a string containing its SQL representation. Returns an optional second value that indicates whether the string should be escaped before being put into a query.
  • Method TO-SQL-STRING ((arg t))
  • Method TO-SQL-STRING ((arg t))
  • Method TO-SQL-STRING ((arg t))
  • Method TO-SQL-STRING ((arg (eql :null)))
    NULL
  • Method TO-SQL-STRING ((arg (eql :null)))
    NULL
  • Method TO-SQL-STRING ((arg (eql :null)))
    NULL
  • Method TO-SQL-STRING ((arg (eql nil)))
    false
  • Method TO-SQL-STRING ((arg (eql nil)))
    false
  • Method TO-SQL-STRING ((arg (eql nil)))
    false
  • Method TO-SQL-STRING ((arg (eql t)))
    true
  • Method TO-SQL-STRING ((arg (eql t)))
    true
  • Method TO-SQL-STRING ((arg (eql t)))
    true
  • Method TO-SQL-STRING ((arg ratio))
  • Method TO-SQL-STRING ((arg ratio))
  • Method TO-SQL-STRING ((arg ratio))
  • Method TO-SQL-STRING ((arg double-float))
  • Method TO-SQL-STRING ((arg double-float))
  • Method TO-SQL-STRING ((arg double-float))
  • Method TO-SQL-STRING ((arg float))
  • Method TO-SQL-STRING ((arg float))
  • Method TO-SQL-STRING ((arg float))
  • Method TO-SQL-STRING ((arg integer))
  • Method TO-SQL-STRING ((arg integer))
  • Method TO-SQL-STRING ((arg integer))
  • Method TO-SQL-STRING ((arg array))
  • Method TO-SQL-STRING ((arg array))
  • Method TO-SQL-STRING ((arg array))
  • Method TO-SQL-STRING ((arg vector))
  • Method TO-SQL-STRING ((arg vector))
  • Method TO-SQL-STRING ((arg vector))
  • Method TO-SQL-STRING ((arg string))
  • Method TO-SQL-STRING ((arg string))
  • Method TO-SQL-STRING ((arg string))
  • Generic-Function SERIALIZE-FOR-POSTGRES (arg)
    Conversion function used to turn a lisp value into a value that PostgreSQL understands when sent through its socket connection. May return a string or a (vector (unsigned-byte 8)).
  • Method SERIALIZE-FOR-POSTGRES (arg)
  • Method SERIALIZE-FOR-POSTGRES (arg)
  • Method SERIALIZE-FOR-POSTGRES (arg)
  • Variable *SQL-READTABLE*
    (make-hash-table)
    The exported special var holding the current read table, a hash mapping OIDs to instances of the type-interpreter class that contain functions for retreiving values from the database in text, and possible binary, form.
  • Function SET-SQL-READER (oid function &key (table *sql-readtable*) binary-p)
    Add an sql reader to a readtable. When the reader is not binary, it is wrapped by a function that will read the string from the socket.
  • Variable *READ-ROW-VALUES-AS-BINARY*
    nil
    Controls whether row values (as in select row(1, 'foo') ) should be received from the database in text or binary form. The default value is nil, specifying that the results be sent back as text. Set this to t to cause the results to be read as binary.
  • Macro WITH-BINARY-ROW-VALUES (&body body)
    Helper macro to locally set *read-row-values-as-binary* to t while executing body so that row values will be returned as binary.
  • Macro WITH-TEXT-ROW-VALUES (&body body)
    Helper macro to locally set *read-row-values-as-binary* to nil while executing body so that row values will be returned as t.
  • Function SET-SQL-DATETIME-READERS (&key date timestamp timestamp-with-timezone interval time (table *sql-readtable*))
  • Function COPY-SQL-READTABLE (&optional (table *sql-readtable*))
  • Function DEFAULT-SQL-READTABLE
  • Condition POSTGRESQL-NOTIFICATION  (SIMPLE-WARNING)
  • Condition POSTGRESQL-WARNING  (SIMPLE-WARNING)
  • Variable *SSL-CERTIFICATE-FILE*
    nil
    When set to a filename, this file will be used as client certificate for SSL connections.
  • Variable *SSL-KEY-FILE*
    nil
    When set to a filename, this file will be used as client key for SSL connections.
  • Macro ROW-READER ((fields) &body body)
    Create a row-reader, using the given name for the fields argument and the given body for reading the rows. A row reader is a function that is used to do something with the results of a query. It has two local functions: next-row and next-field, the first should be called once per row and will return a boolean indicating whether there are any more rows, the second should be called once for every element in the fields vector, with that field as argument, to read a single value in a row. See list-row-reader in public.lisp for an example.
  • Macro DEF-ROW-READER (name (fields) &body body)
    Create a row reader, as in the row-reader macro, and assign a name to it.
  • Class DATABASE-CONNECTION
    Representation of a database connection. Contains login information in order to be able to automatically re-establish a connection when it is somehow closed.
    HOST   Reader: CONNECTION-HOST
    PORT   Reader: CONNECTION-PORT
    DATABASE   Reader: CONNECTION-DB
    USER   Reader: CONNECTION-USER
    PASSWORD   Reader: CONNECTION-PASSWORD
    USE-SSL   Reader: CONNECTION-USE-SSL
    SERVICE   Accessor: CONNECTION-SERVICE
    SOCKET   Accessor: CONNECTION-SOCKET
    META
    AVAILABLE   Accessor: CONNECTION-AVAILABLE
    PARAMETERS   Accessor: CONNECTION-PARAMETERS
    TIMESTAMP-FORMAT   Accessor: CONNECTION-TIMESTAMP-FORMAT
  • Function CONNECTION-META (connection)
    Retrieves the meta field of a connection, the primary purpose of which is to store information about the prepared statements that exists for it.
  • Function DATABASE-OPEN-P (connection)
    Returns a boolean indicating whether the given connection is currently connected.
  • Function OPEN-DATABASE (database user password host &optional (port 5432) (use-ssl :no) (service "postgres"))
    Create and connect a database object. use-ssl may be :no, :yes, or :try.
  • Variable *UNIX-SOCKET-DIR*
    "/var/run/postgresql/"
    Directory where the Unix domain socket for PostgreSQL be found.
  • Function REOPEN-DATABASE (conn)
    Reconnect a disconnected database connection.
  • Function CLOSE-DATABASE (connection)
    Gracefully disconnect a database connection.
  • Function WAIT-FOR-NOTIFICATION (connection)
    Perform a blocking wait for asynchronous notification. Return the channel string, the payload and notifying pid as multiple values.
  • Function EXEC-QUERY (connection query &optional (row-reader 'ignore-row-reader))
    Execute a query string and apply the given row-reader to the result.
  • Function PREPARE-QUERY (connection name query)
    Prepare a query string and store it under the given name.
  • Function UNPREPARE-QUERY (connection name)
    Close the prepared query given by name.
  • Function EXEC-PREPARED (connection name parameters &optional (row-reader 'ignore-row-reader))
    Execute a previously prepared query with the given parameters, apply a row-reader to the result.
  • Function ALIST-ROW-READER (g900 fields)
  • Function LIST-ROW-READER (g939 fields)
  • Function VECTOR-ROW-READER (g978 fields)
  • Function IGNORE-ROW-READER (g1049 fields)
  • Function OPEN-DB-WRITER (db-spec table columns)
  • Function CLOSE-DB-WRITER (self &key (abort nil))
  • Function DB-WRITE-ROW (self row &optional (data (prepare-row self row)))

CL-POSTGRES-ERROR

  • Condition FEATURE-NOT-SUPPORTED  (DATABASE-ERROR)
  • Condition DATA-EXCEPTION  (DATABASE-ERROR)
  • Condition DB-DIVISION-BY-ZERO  (DATA-EXCEPTION)
  • Condition INVALID-DATETIME-FORMAT  (DATA-EXCEPTION)
  • Condition NUMERIC-VALUE-OUT-OF-RANGE  (DATA-EXCEPTION)
  • Condition FLOATING-POINT-EXCEPTION  (DATA-EXCEPTION)
  • Condition INTEGRITY-VIOLATION  (DATABASE-ERROR)
  • Condition RESTRICT-VIOLATION  (INTEGRITY-VIOLATION)
  • Condition NOT-NULL-VIOLATION  (INTEGRITY-VIOLATION)
  • Condition FOREIGN-KEY-VIOLATION  (INTEGRITY-VIOLATION)
  • Condition UNIQUE-VIOLATION  (INTEGRITY-VIOLATION)
  • Condition CHECK-VIOLATION  (INTEGRITY-VIOLATION)
  • Condition SYNTAX-ERROR-OR-ACCESS-VIOLATION  (DATABASE-ERROR)
  • Condition INSUFFICIENT-PRIVILEGE  (SYNTAX-ERROR-OR-ACCESS-VIOLATION)
  • Condition TRANSACTION-ROLLBACK  (DATABASE-ERROR)
  • Condition SERIALIZATION-FAILURE  (TRANSACTION-ROLLBACK)
  • Condition TRANSACTION-INTEGRITY-CONSTRAINT-VIOLATION  (TRANSACTION-ROLLBACK)
  • Condition STATEMENT-COMPLETION-UNKNOWN  (TRANSACTION-ROLLBACK)
  • Condition DEADLOCK-DETECTED  (TRANSACTION-ROLLBACK)
  • Condition INSUFFICIENT-RESOURCES  (DATABASE-ERROR)
  • Condition PROGRAM-LIMIT-EXCEEDED  (DATABASE-ERROR)
  • Condition OBJECT-STATE-ERROR  (DATABASE-ERROR)
  • Condition OBJECT-IN-USE  (OBJECT-STATE-ERROR)
  • Condition LOCK-NOT-AVAILABLE  (OBJECT-STATE-ERROR)
  • Condition OPERATOR-INTERVENTION  (DATABASE-ERROR)
  • Condition QUERY-CANCELED  (OPERATOR-INTERVENTION)
  • Condition SERVER-SHUTDOWN  (OPERATOR-INTERVENTION, DATABASE-CONNECTION-ERROR)
  • Condition ADMIN-SHUTDOWN  (SERVER-SHUTDOWN)
  • Condition CRASH-SHUTDOWN  (SERVER-SHUTDOWN)
  • Condition CANNOT-CONNECT-NOW  (OPERATOR-INTERVENTION)
  • Condition SYSTEM-ERROR  (DATABASE-ERROR)
  • Condition INTERNAL-ERROR  (DATABASE-ERROR)

CL-POSTGRES-OID

  • Variable +BOOL+
    16
  • Variable +BYTEA+
    17
  • Variable +CHAR+
    18
  • Variable +NAME+
    19
  • Variable +INT8+
    20
  • Variable +INT2+
    21
  • Variable +INT2VECTOR+
    22
  • Variable +INT4+
    23
  • Variable +REGPROC+
    24
  • Variable +TEXT+
    25
  • Variable +OID+
    26
  • Variable +TID+
    27
  • Variable +XID+
    28
  • Variable +CID+
    29
  • Variable +OID-VECTOR+
    30
  • Variable +JSON+
    114
  • Variable +XML+
    142
  • Variable +PGNODETREE+
    194
  • Variable +PGDDLCOMMAND+
    32
  • Variable +POINT+
    600
  • Variable +LSEG+
    601
  • Variable +PATH+
    602
  • Variable +BOX+
    603
  • Variable +POLYGON+
    604
  • Variable +LINE+
    628
  • Variable +FLOAT4+
    700
  • Variable +FLOAT8+
    701
  • Variable +ABSTIME+
    702
  • Variable +RELTIME+
    703
  • Variable +TINTERVAL+
    704
  • Variable +UNKNOWN+
    705
  • Variable +CIRCLE+
    718
  • Variable +CASH+
    790
  • Variable +MACADDR+
    829
  • Variable +INET+
    869
  • Variable +CIDR+
    650
  • Variable +BOOL-ARRAY+
    1000
  • Variable +BYTEA-ARRAY+
    1001
  • Variable +CHAR-ARRAY+
    1002
  • Variable +NAME-ARRAY+
    1003
  • Variable +INT2-ARRAY+
    1005
  • Variable +INT4-ARRAY+
    1007
  • Variable +TEXT-ARRAY+
    1009
  • Variable +BPCHAR-ARRAY+
    1014
  • Variable +VARCHAR-ARRAY+
    1015
  • Variable +INT8-ARRAY+
    1016
  • Variable +POINT-ARRAY+
    1017
  • Variable +LSEG-ARRAY+
    1018
  • Variable +BOX-ARRAY+
    1020
  • Variable +FLOAT4-ARRAY+
    1021
  • Variable +FLOAT8-ARRAY+
    1022
  • Variable +OID-ARRAY+
    1028
  • Variable +ACLITEM+
    1033
  • Variable +CSTRING-ARRAY+
    1263
  • Variable +BPCHAR+
    1042
  • Variable +VARCHAR+
    1043
  • Variable +DATE+
    1082
  • Variable +TIME+
    1083
  • Variable +TIMESTAMP+
    1114
  • Variable +TIMESTAMP-ARRAY+
    1115
  • Variable +DATE-ARRAY+
    1182
  • Variable +TIME-ARRAY+
    1183
  • Variable +TIMESTAMPTZ+
    1184
  • Variable +TIMESTAMPTZ-ARRAY+
    1185
  • Variable +INTERVAL+
    1186
  • Variable +INTERVAL-ARRAY+
    1187
  • Variable +TIMETZ+
    1266
  • Variable +BIT+
    1560
  • Variable +BIT-ARRAY+
    1561
  • Variable +VARBIT+
    1562
  • Variable +VARBIT-ARRAY+
    1563
  • Variable +NUMERIC+
    1700
  • Variable +NUMERIC-ARRAY+
    1231
  • Variable +REFCURSOR+
    1790
  • Variable +REGPROCEDURE+
    2202
  • Variable +REGOPER+
    2203
  • Variable +REGOPERATOR+
    2204
  • Variable +REGCLASS+
    2205
  • Variable +REGTYPE+
    2206
  • Variable +REGROLE+
    4096
  • Variable +REGNAMESPACE+
    4089
  • Variable +REGTYPE-ARRAY+
    2211
  • Variable +UUID+
    2950
  • Variable +LSN+
    3220
  • Variable +TSVECTOR+
    3614
  • Variable +GTSVECTOR+
    3642
  • Variable +TSQUERY+
    3615
  • Variable +REGCONFIG+
    3734
  • Variable +REGDICTIONARY+
    3769
  • Variable +JSONB+
    3802
  • Variable +INT4RANGE+
    3904
  • Variable +RECORD+
    2249
  • Variable +RECORD-ARRAY+
    2287
  • Variable +CSTRING+
    2275
  • Variable +ANY+
    2276
  • Variable +ANY-ARRAY+
    2277
  • Variable +V-OID+
    2278
  • Variable +TRIGGER+
    2279
  • Variable +EVTTRIGGER+
    3838
  • Variable +LANGUAGE-HANDLER+
    2280
  • Variable +INTERNAL+
    2281
  • Variable +OPAQUE+
    2282
  • Variable +ANYELEMENT+
    2283
  • Variable +ANYNON-ARRAY+
    2776
  • Variable +ANYENUM+
    3500
  • Variable +FDW-HANDLER+
    3115
  • Variable +INDEX-AM-HANDLER+
    325
  • Variable +TSM-HANDLER+
    3310
  • Variable +ANYRANGE+
    3831

postmodern

PostgreSQL programming API

POSTMODERN

  • Variable *DATABASE*
    nil
    Special holding the current database. Most functions and macros operating on a database assume this contains a connected database.
  • Variable *DEFAULT-USE-SSL*
    :no
  • Function CONNECT (database user password host &key (port 5432) pooled-p (use-ssl *default-use-ssl*) (service "postgres"))
    Create and return a database connection.
  • Function CONNECTED-P (database)
    Test whether a database connection is still connected.
  • Function CONNECT-TOPLEVEL (database user password host &key (port 5432) (use-ssl *default-use-ssl*))
    Set *database* to a new connection. Use this if you only need one connection, or if you want a connection for debugging from the REPL.
  • Generic-Function DISCONNECT (database)
    Close a database connection. Returns it to a pool if it is a pooled connection.
  • Generic-Function DISCONNECT (database)
    Close a database connection. Returns it to a pool if it is a pooled connection.
  • Method DISCONNECT ((connection database-connection))
  • Method DISCONNECT ((connection database-connection))
  • Method DISCONNECT ((connection database-connection))
  • Generic-Function RECONNECT (database)
    Reconnect a database connection.
  • Generic-Function RECONNECT (database)
    Reconnect a database connection.
  • Method RECONNECT ((connection pooled-database-connection))
  • Method RECONNECT ((connection pooled-database-connection))
  • Method RECONNECT ((connection pooled-database-connection))
  • Method RECONNECT ((database database-connection))
  • Method RECONNECT ((database database-connection))
  • Method RECONNECT ((database database-connection))
  • Function DISCONNECT-TOPLEVEL
    Disconnect *database*.
  • Function CALL-WITH-CONNECTION (spec thunk)
    Binds *database* to a new connection, as specified by the spec argument, which should be a list of arguments that can be passed to connect, and runs the function given as a second argument with that database.
  • Macro WITH-CONNECTION (spec &body body)
    Locally establish a database connection, and bind *database* to it.
  • Variable *MAX-POOL-SIZE*
    nil
    The maximum amount of connection that will be kept in a single pool, or NIL for no maximum.
  • Method DISCONNECT ((connection pooled-database-connection))
    Add the connection to the corresponding pool, or drop it when the pool is full.
  • Function CLEAR-CONNECTION-POOL
    Disconnect and remove all connections in the connection pool.
  • Macro QUERY (query &rest args/format)
    Execute a query, optionally with arguments to put in the place of $X elements. If one of the arguments is a known result style or a class name, it specifies the format in which the results should be returned.
  • Macro EXECUTE (query &rest args)
    Execute a query, ignore the results.
  • Macro DOQUERY (query (&rest names) &body body)
    Iterate over the rows in the result of a query, binding the given names to the results and executing body for every row. Query can be a string, an s-sql query, or a list starting with one of those, followed by the arguments to parameterize the query with.
  • Macro PREPARE (query &optional (format :rows))
    Wraps a query into a function that will prepare it once for a connection, and then execute it with the given parameters. The query should contain a placeholder ($1, $2, etc) for every parameter.
  • Macro DEFPREPARED (name query &optional (format :rows))
    Like perpare, but gives the function a name instead of returning it.
  • Macro DEFPREPARED-WITH-NAMES (name (&rest args) (query &rest query-args) &optional (format :rows))
    Like defprepared, but with lambda list for statement arguments.
  • Function SEQUENCE-NEXT (sequence)
    Shortcut for getting the next value from a sequence.
  • Function LIST-TABLES (&optional strings-p)
    Return a list of the tables in a database. Turn them into keywords if strings-p is not true.
  • Function TABLE-EXISTS-P (table)
    Check whether a table exists. Takes either a string or a symbol for the table name.
  • Function LIST-SEQUENCES (&optional strings-p)
    Return a list of the sequences in a database. Turn them into keywords if strings-p is not true.
  • Function SEQUENCE-EXISTS-P (sequence)
    Check whether a sequence exists. Takes either a string or a symbol for the sequence name.
  • Function LIST-VIEWS (&optional strings-p)
    Return a list of the views in a database. Turn them into keywords if strings-p is not true.
  • Function VIEW-EXISTS-P (view)
    Check whether a view exists. Takes either a string or a symbol for the view name.
  • Function TABLE-DESCRIPTION (table &optional schema-name)
    Return a list of (name type null-allowed) lists for the fields of a table. If SCHEMA-NAME is specified, only fields from that schema are returned.
  • Function COALESCE (&rest args)
  • Variable *CURRENT-LOGICAL-TRANSACTION*
    nil
  • Macro WITH-TRANSACTION ((&optional name) &body body)
    Execute the body within a database transaction, committing when the body exits normally, and aborting otherwise. An optional name can be given to the transaction, which can be used to force a commit or abort before the body unwinds.
  • Function ABORT-TRANSACTION (transaction)
    Immediately abort an open transaction.
  • Function COMMIT-TRANSACTION (transaction)
    Immediately commit an open transaction.
  • Macro WITH-SAVEPOINT (name &body body)
    Execute the body within a savepoint, releasing savepoint when the body exits normally, and rolling back otherwise. NAME is both the variable that can be used to release or rolled back before the body unwinds, and the SQL name of the savepoint.
  • Function ROLLBACK-SAVEPOINT (savepoint)
    Immediately roll back a savepoint, aborting it results.
  • Function RELEASE-SAVEPOINT (savepoint)
    Immediately release a savepoint, commiting its results.
  • Macro WITH-LOGICAL-TRANSACTION ((&optional (name nil name-p)) &body body)
    Executes the body within a with-transaction (if no transaction is already in progress) or a with-savepoint (if one is), binding the transaction or savepoint to NAME (if supplied)
  • Macro ENSURE-TRANSACTION (&body body)
    Executes body within a with-transaction form if and only if no transaction is already in progress.
  • Macro WITH-SCHEMA ((schema &key (strict t) (if-not-exist :create) (drop-after nil)) &body form)
    A macro to set the schema search path of the postgresql database to include as first entry a specified schema. calling with strict 't only the specified schema is set as current search path. All other schema are then not searched any more. calling with if-not-exist set to :create the schema is created if this schema did not exist. calling with drop-after set to 't the schema is removed after the execution of the body form. example : (with-schema (:schema-name :strict nil :drop-after nil :if-not-exist :error) (foo 1) (foo 2))
  • Function GET-SEARCH-PATH
  • Function SET-SEARCH-PATH (path)
  • Function LIST-SCHEMATA
    List all existing user defined schemata. Note: The query uses the portable information_schema relations instead of pg_tables relations SELECT schema_name FROM information_schema.schemata where schema_name !~ '(pg_*)|information_schema' ORDER BY schema_name ;
  • Function SCHEMA-EXIST-P (name)
    Predicate for schema existence
  • Function CREATE-SCHEMA (schema)
    Creating a non existing schema. If the schema exists an error is raised.
  • Function DROP-SCHEMA (schema &key (cascade nil))
    Drops an existing database schema 'schema'
  • Class DAO-CLASS  (STANDARD-CLASS)
    Metaclass for database-access-object classes.
    DIRECT-KEYS   Reader: DIRECT-KEYS
    EFFECTIVE-KEYS   Reader: DAO-KEYS
    TABLE-NAME
    COLUMN-MAP   Reader: DAO-COLUMN-MAP
  • Method DAO-KEYS ((class dao-class))
  • Method DAO-KEYS ((class-name symbol))
  • Method DAO-KEYS (dao)
  • Function DAO-TABLE-NAME (class)
  • Generic-Function DAO-EXISTS-P (dao)
    Return a boolean indicating whether the given dao exists in the database.
  • Generic-Function DAO-EXISTS-P (dao)
    Return a boolean indicating whether the given dao exists in the database.
  • Generic-Function INSERT-DAO (dao)
    Insert the given object into the database.
  • Generic-Function INSERT-DAO (dao)
    Insert the given object into the database.
  • Generic-Function UPDATE-DAO (dao)
    Update the object's representation in the database with the values in the given instance.
  • Generic-Function UPDATE-DAO (dao)
    Update the object's representation in the database with the values in the given instance.
  • Generic-Function DELETE-DAO (dao)
    Delete the given dao from the database.
  • Generic-Function DELETE-DAO (dao)
    Delete the given dao from the database.
  • Generic-Function UPSERT-DAO (dao)
    Update or insert the given dao. If its primary key is already in the database and all slots are bound, an update will occur. Otherwise it tries to insert it.
  • Generic-Function UPSERT-DAO (dao)
    Update or insert the given dao. If its primary key is already in the database and all slots are bound, an update will occur. Otherwise it tries to insert it.
  • Generic-Function GET-DAO (type &rest args)
    Get the object corresponding to the given primary key, or return nil if it does not exist.
  • Generic-Function GET-DAO (type &rest args)
    Get the object corresponding to the given primary key, or return nil if it does not exist.
  • Method GET-DAO ((class-name symbol) &rest args)
  • Method GET-DAO ((class-name symbol) &rest args)
  • Method GET-DAO ((class-name symbol) &rest args)
  • Generic-Function MAKE-DAO (type &rest args &key &allow-other-keys)
    Make the instance of the given class and insert it into the database
  • Generic-Function MAKE-DAO (type &rest args &key &allow-other-keys)
    Make the instance of the given class and insert it into the database
  • Method MAKE-DAO ((class dao-class) &rest args &key &allow-other-keys)
  • Method MAKE-DAO ((class dao-class) &rest args &key &allow-other-keys)
  • Method MAKE-DAO ((class dao-class) &rest args &key &allow-other-keys)
  • Method MAKE-DAO ((class-name symbol) &rest args &key &allow-other-keys)
  • Method MAKE-DAO ((class-name symbol) &rest args &key &allow-other-keys)
  • Method MAKE-DAO ((class-name symbol) &rest args &key &allow-other-keys)
  • Macro DEFINE-DAO-FINALIZATION (((dao-name class) &rest keyword-args) &body body)
  • Macro WITH-COLUMN-WRITERS ((&rest defs) &body body)
  • Variable *IGNORE-UNKNOWN-COLUMNS*
    nil
  • Function SAVE-DAO (dao)
    Try to insert the content of a DAO. If this leads to a unique key violation, update it instead.
  • Function SAVE-DAO/TRANSACTION (dao)
  • Macro QUERY-DAO (type query &rest args)
    Execute a query and return the result as daos of the given type. The fields returned by the query must match the slots of the dao, both by type and by name.
  • Macro DO-QUERY-DAO (((type type-var) query) &body body)
    Like query-dao, but rather than returning a list of results, executes BODY once for each result, with TYPE-VAR bound to the DAO representing that result.
  • Macro SELECT-DAO (type &optional (test t) &rest ordering)
    Select daos for the rows in its table for which the given test holds, order them by the given criteria.
  • Macro DO-SELECT-DAO (((type type-var) &optional (test t) &rest ordering) &body body)
    Like select-dao, but rather than returning a list of results, executes BODY once for each result, with TYPE-VAR bound to the DAO representing that result.
  • Function DAO-TABLE-DEFINITION (table)
    Generate the appropriate CREATE TABLE query for this class.
  • Variable *TABLE-NAME*
  • Variable *TABLE-SYMBOL*
  • Macro DEFTABLE (name &body definitions)
    Define a table. name can be either a symbol or a (symbol string) list. In the first case, the table name is derived from the symbol by S-SQL's rules, in the second case, the name is given explicitly. The body of definitions can contain anything that evaluates to a string, as well as S-SQL expressions. In this body, the variables *table-name* and *table-symbol* are bound to the relevant values.
  • Function CREATE-TABLE (name)
    Create a defined table.
  • Function CREATE-ALL-TABLES
    Create all defined tables.
  • Function CREATE-PACKAGE-TABLES (package)
    Create all tables whose identifying symbol is interned in the given package.
  • Function !INDEX (&rest fields)
    Used inside a deftable form. Define an index on the defined table.
  • Function !UNIQUE-INDEX (&rest fields)
    Used inside a deftable form. Define a unique index on the defined table.
  • Function !DAO-DEF
    Used inside a deftable form. Define this table using the corresponding DAO class' slots.
  • Function !FOREIGN (target fields &rest target-fields/on-delete/on-update/deferrable/initially-deferred)
    Used inside a deftable form. Define a foreign key on this table. Pass a table the index refers to, a list of fields or single field in *this* table, and, if the fields have different names in the table referred to, another field or list of fields for the target table, or :primary-key to indicate that the other table's primary key should be referenced.
  • Function !UNIQUE (target-fields &key deferrable initially-deferred)

Also exports

  • CL-POSTGRES:DATABASE-ERROR-DETAIL
  • S-SQL:VARCHAR
  • CL-POSTGRES:DATABASE-ERROR-MESSAGE
  • CL-POSTGRES:DATABASE-ERROR-QUERY
  • S-SQL:*ESCAPE-SQL-NAMES-P*
  • S-SQL:SQL-COMPILE
  • CL-POSTGRES:DATABASE-CONNECTION
  • S-SQL:SMALLINT
  • S-SQL:BYTEA
  • CL-POSTGRES:DATABASE-ERROR-CAUSE
  • S-SQL:SQL
  • S-SQL:TEXT
  • S-SQL:SQL-ERROR
  • S-SQL:DOUBLE-PRECISION
  • CL-POSTGRES:DATABASE-CONNECTION-ERROR
  • S-SQL:SQL-ESCAPE-STRING
  • CL-POSTGRES:DATABASE-ERROR
  • S-SQL:SQL-ESCAPE
  • S-SQL:REGISTER-SQL-OPERATORS
  • S-SQL:DB-NULL
  • S-SQL:NUMERIC
  • CL-POSTGRES:DATABASE-ERROR-CONSTRAINT-NAME
  • COMMON-LISP:REAL
  • CL-POSTGRES:DATABASE-ERROR-CODE
  • S-SQL:BIGINT

s-sql

S-SQL

  • Condition SQL-ERROR  (SIMPLE-ERROR)
  • Function SQL-ERROR (control &rest args)
  • Variable *ESCAPE-SQL-NAMES-P*
    :auto
    Setting this to T will make S-SQL add double quotes around identifiers in queries. Setting it :auto will turn on this behaviour only for reserved words.
  • Variable *DOWNCASE-SYMBOLS*
    t
  • Function TO-SQL-NAME (name &optional (escape-p *escape-sql-names-p*))
    Convert a symbol or string into a name that can be an sql table, column, or operation name. Add quotes when escape-p is true, or escape-p is :auto and the name contains reserved words.
  • Function FROM-SQL-NAME (str)
    Convert a string to something that might have been its original lisp name (does not work if this name contained non-alphanumeric characters other than #-)
  • Type SMALLINT
  • Type BIGINT
  • Type NUMERIC (&optional precision/scale scale)
  • Type DOUBLE-PRECISION
  • Type BYTEA
  • Type TEXT
  • Type VARCHAR (length)
  • Type DB-NULL
    Type for representing NULL values. Use like (or integer db-null) for declaring a type to be an integer that may be null.
  • Generic-Function SQL-TYPE-NAME (lisp-type &rest args)
    Transform a lisp type into a string containing something SQL understands. Default is to just use the type symbol's name.
  • Method SQL-TYPE-NAME ((lisp-type (eql 'db-null)) &rest args)
  • Method SQL-TYPE-NAME ((lisp-type (eql 'db-null)) &rest args)
  • Method SQL-TYPE-NAME ((lisp-type (eql 'db-null)) &rest args)
  • Method SQL-TYPE-NAME ((lisp-type (eql 'array)) &rest args)
  • Method SQL-TYPE-NAME ((lisp-type (eql 'array)) &rest args)
  • Method SQL-TYPE-NAME ((lisp-type (eql 'array)) &rest args)
  • Method SQL-TYPE-NAME ((lisp-type (eql 'serial8)) &rest args)
    SERIAL8
  • Method SQL-TYPE-NAME ((lisp-type (eql 'serial8)) &rest args)
    SERIAL8
  • Method SQL-TYPE-NAME ((lisp-type (eql 'serial8)) &rest args)
    SERIAL8
  • Method SQL-TYPE-NAME ((lisp-type (eql 'serial)) &rest args)
    SERIAL
  • Method SQL-TYPE-NAME ((lisp-type (eql 'serial)) &rest args)
    SERIAL
  • Method SQL-TYPE-NAME ((lisp-type (eql 'serial)) &rest args)
    SERIAL
  • Method SQL-TYPE-NAME ((lisp-type (eql 'double-precision)) &rest args)
    DOUBLE PRECISION
  • Method SQL-TYPE-NAME ((lisp-type (eql 'double-precision)) &rest args)
    DOUBLE PRECISION
  • Method SQL-TYPE-NAME ((lisp-type (eql 'double-precision)) &rest args)
    DOUBLE PRECISION
  • Method SQL-TYPE-NAME ((lisp-type (eql 'double-float)) &rest args)
    DOUBLE PRECISION
  • Method SQL-TYPE-NAME ((lisp-type (eql 'double-float)) &rest args)
    DOUBLE PRECISION
  • Method SQL-TYPE-NAME ((lisp-type (eql 'double-float)) &rest args)
    DOUBLE PRECISION
  • Method SQL-TYPE-NAME ((lisp-type (eql 'float)) &rest args)
    REAL
  • Method SQL-TYPE-NAME ((lisp-type (eql 'float)) &rest args)
    REAL
  • Method SQL-TYPE-NAME ((lisp-type (eql 'float)) &rest args)
    REAL
  • Method SQL-TYPE-NAME ((lisp-type (eql 'numeric)) &rest args)
  • Method SQL-TYPE-NAME ((lisp-type (eql 'numeric)) &rest args)
  • Method SQL-TYPE-NAME ((lisp-type (eql 'numeric)) &rest args)
  • Method SQL-TYPE-NAME ((lisp-type (eql 'varchar)) &rest args)
  • Method SQL-TYPE-NAME ((lisp-type (eql 'varchar)) &rest args)
  • Method SQL-TYPE-NAME ((lisp-type (eql 'varchar)) &rest args)
  • Method SQL-TYPE-NAME ((lisp-type (eql 'string)) &rest args)
  • Method SQL-TYPE-NAME ((lisp-type (eql 'string)) &rest args)
  • Method SQL-TYPE-NAME ((lisp-type (eql 'string)) &rest args)
  • Method SQL-TYPE-NAME ((lisp-type symbol) &rest args)
  • Method SQL-TYPE-NAME ((lisp-type symbol) &rest args)
  • Method SQL-TYPE-NAME ((lisp-type symbol) &rest args)
  • Variable *STANDARD-SQL-STRINGS*
    nil
    Indicate whether S-SQL will use standard SQL strings (just use '' for #'), or backslash-style escaping. Setting this to NIL is always safe, but when the server is configured to allow standard strings (parameter 'standard_conforming_strings' is 'on'), the noise in queries can be reduced by setting this to T.
  • Function SQL-ESCAPE-STRING (string &optional prefix)
    Escape string data so it can be used in a query.
  • Generic-Function SQL-ESCAPE (arg)
    Get the representation of a Lisp value so that it can be used in a query.
  • Method SQL-ESCAPE ((arg t))
  • Method SQL-ESCAPE ((arg t))
  • Method SQL-ESCAPE ((arg t))
  • Method SQL-ESCAPE ((arg vector))
  • Method SQL-ESCAPE ((arg vector))
  • Method SQL-ESCAPE ((arg vector))
  • Method SQL-ESCAPE ((arg symbol))
  • Method SQL-ESCAPE ((arg symbol))
  • Method SQL-ESCAPE ((arg symbol))
  • Macro SQL (form)
    Compile form to an sql expression as far as possible.
  • Function SQL-COMPILE (form)
  • Function SQL-TEMPLATE (form)
  • Function ENABLE-S-SQL-SYNTAX (&optional (char #\q))
    Enable a syntactic shortcut #Q(...) for (sql (...)). Optionally takes a character to use instead of #\Q.
  • Macro REGISTER-SQL-OPERATORS (arity &rest names)
    Define simple operators. Arity is one of :unary (like 'not'), :unary-postfix (the operator comes after the operand), :n-ary (like '+': the operator falls away when there is only one operand), :2+-ary (like '=', which is meaningless for one operand), or :n-or-unary (like '-', where the operator is kept in the unary case). After the arity follow any number of operators, either just a keyword, in which case the downcased symbol name is used as the operator, or a two-element list containing a keyword and a name string.

Also exports

  • COMMON-LISP:REAL

simple-date

SIMPLE-DATE

  • Class DATE
    This class is used to represent dates where the time of day is not important.
    DAYS   Accessor: DAYS
  • Function ENCODE-DATE (year month day)
    Create a date object.
  • Function DECODE-DATE (date)
    Get the date elements from a date object.
  • Function DAY-OF-WEEK (date)
    Returns the weekday of the given date as a number between 0 and 6, 0 being Sunday and 6 being Saturday.
  • Class TIME-OF-DAY
    This class is used to represent time of day in hours, minutes, seconds and microseconds.
    HOURS   Accessor: HOURS
    MINUTES   Accessor: MINUTES
    SECONDS   Accessor: SECONDS
    MICROSECONDS   Accessor: MICROSECONDS
  • Function ENCODE-TIME-OF-DAY (hour minute &optional (second 0) (microsecond 0))
    Create a timestamp object.
  • Function DECODE-TIME-OF-DAY (time)
  • Class TIMESTAMP  (DATE)
    A timestamp specifies a time with a precision up to milliseconds.
    MILLISECS   Accessor: MILLISECS
  • Function ENCODE-TIMESTAMP (year month day &optional (hour 0) (minute 0) (second 0) (millisecond 0))
    Create a timestamp object.
  • Function DECODE-TIMESTAMP (timestamp)
    Extract the date and time from a timestamp object.
  • Function TIMESTAMP-TO-UNIVERSAL-TIME (timestamp)
    Convert a timestamp to a Lisp universal time.
  • Function UNIVERSAL-TIME-TO-TIMESTAMP (utime)
    Convert a Lisp universal time to a timestamp.
  • Class INTERVAL
    Intervals can be added to date and timestamp units to get relative times. The amount of time added for the month part of a timestamp depends on the time it is being added to.
    MILLISECS   Accessor: MILLISECS
    MONTHS   Accessor: MONTHS
  • Function ENCODE-INTERVAL (&key (year 0) (month 0) (week 0) (day 0) (hour 0) (minute 0) (second 0) (millisecond 0))
    Create an interval object. Parameters may be negative.
  • Function DECODE-INTERVAL (interval)
  • Generic-Function TIME-ADD (a b)
    Generic function for combining datetime objects. Adding an interval to a date or timestamp will return a new date or timestamp, increased by the value of the interval. Adding two intervals returns a new interval with the sum of the two arguments. Integers can be used in place of intervals, and will be interpreted as an amount of milliseconds.
  • Method TIME-ADD ((stamp timestamp) (interval interval))
  • Method TIME-ADD ((interval interval) (stamp timestamp))
  • Method TIME-ADD ((date date) (interval interval))
  • Method TIME-ADD ((interval interval) (date date))
  • Method TIME-ADD ((a interval) (b interval))
  • Method TIME-ADD ((interval interval) (millisecs integer))
  • Method TIME-ADD ((millisecs integer) (interval interval))
  • Method TIME-ADD ((stamp timestamp) (millisecs integer))
  • Method TIME-ADD ((millisecs integer) (stamp timestamp))
  • Method TIME-ADD ((a integer) (b integer))
  • Generic-Function TIME-SUBTRACT (a b)
    Subtracts datetime objects from each other. Subtracting two dates or timestamps results in an interval that represents the difference between them. Similarly subtracting two intervals gives their difference.
  • Method TIME-SUBTRACT ((a date) (b date))
  • Method TIME-SUBTRACT ((a timestamp) (b date))
  • Method TIME-SUBTRACT ((a timestamp) (b timestamp))
  • Method TIME-SUBTRACT ((date date) (interval interval))
  • Method TIME-SUBTRACT ((stamp timestamp) (millisecs integer))
  • Method TIME-SUBTRACT ((a interval) (b interval))
  • Method TIME-SUBTRACT ((interval interval) (millisecs integer))
  • Method TIME-SUBTRACT ((millisecs integer) (interval interval))
  • Generic-Function TIME= (a b)
    Compare two time-related values, returns a boolean indicating whether they denote the same time or period.
  • Method TIME= ((a date) (b date))
  • Method TIME= ((a date) (b timestamp))
  • Method TIME= ((a timestamp) (b date))
  • Method TIME= ((a timestamp) (b timestamp))
  • Method TIME= ((a interval) (b interval))
  • Method TIME= ((a time-of-day) (b time-of-day))
  • Generic-Function TIME< (a b)
    Compare two time-related values, returns a boolean indicating whether the first is less than the second.
  • Method TIME< ((a date) (b date))
  • Method TIME< ((a date) (b timestamp))
  • Method TIME< ((a timestamp) (b date))
  • Method TIME< ((a timestamp) (b timestamp))
  • Method TIME< ((a interval) (b interval))
  • Generic-Function TIME> (a b)
    Compare two time-related values, returns a boolean indicating whether the first is greater than the second.
  • Method TIME> ((a date) (b date))
  • Method TIME> ((a date) (b timestamp))
  • Method TIME> ((a timestamp) (b date))
  • Method TIME> ((a timestamp) (b timestamp))
  • Method TIME> ((a interval) (b interval))
  • Function TIME<= (a b)
    Compare two time-related values, returns a boolean indicating whether the first is less or equal than the second.
  • Function TIME>= (a b)
    Compare two time-related values, returns a boolean indicating whether the first is greater or equal than the second.