{********************************************************} { } { Zeos Database Objects } { Plain interface to libpq.dll } { } { Copyright (c) 1999-2001 Sergey Seroukhov } { } {********************************************************} unit ZLibPgSql; interface uses {$IFNDEF LINUX}Windows,{$ELSE} Libc, {$ENDIF} Classes, ZSqlTypes; {$IFNDEF LINUX} {$INCLUDE ..\Zeos.inc} {$ELSE} {$INCLUDE ../Zeos.inc} {$ENDIF} {***************** Plain API Constants definition ****************} const {$IFNDEF LINUX} DEFAULT_DLL_LOCATION = 'libpq.dll'; {$ELSE} DEFAULT_DLL_LOCATION = 'libpq.so'; {$ENDIF} { Type Lengths } NAMEDATALEN = 32; { OIDNAMELEN should be set to NAMEDATALEN + sizeof(Oid) } OIDNAMELEN = 36; INV_WRITE = $00020000; INV_READ = $00040000; SEEK_SET = 0; SEEK_CUR = 1; SEEK_END = 2; {****************** Plain API Types definition *****************} type Oid = Integer; { Application-visible enum types } ConnStatusType = ( CONNECTION_OK, CONNECTION_BAD ); ExecStatusType = ( PGRES_EMPTY_QUERY, PGRES_COMMAND_OK, { a query command that doesn't return anything was executed properly by the backend } PGRES_TUPLES_OK, { a query command that returns tuples was executed properly by the backend, PGresult contains the result tuples } PGRES_COPY_OUT, { Copy Out data transfer in progress } PGRES_COPY_IN, { Copy In data transfer in progress } PGRES_BAD_RESPONSE, { an unexpected response was recv'd from the backend } PGRES_NONFATAL_ERROR, PGRES_FATAL_ERROR ); { String descriptions of the ExecStatusTypes } pgresStatus = array[$00..$ff] of PChar; { PGconn encapsulates a connection to the backend. The contents of this struct are not supposed to be known to applications. } PGconn = Pointer; PPGconn = Pointer; { PGresult encapsulates the result of a query (or more precisely, of a single SQL command --- a query string given to PQsendQuery can contain multiple commands and thus return multiple PGresult objects). The contents of this struct are not supposed to be known to applications. } PGresult = Pointer; PPGresult = Pointer; { PGnotify represents the occurrence of a NOTIFY message. Ideally this would be an opaque typedef, but it's so simple that it's unlikely to change. NOTE: in Postgres 6.4 and later, the be_pid is the notifying backend's, whereas in earlier versions it was always your own backend's PID. } PGnotify = packed record relname: array [0..NAMEDATALEN-1] of Char; { name of relation containing data } be_pid: Integer; { process id of backend } end; PPGnotify = ^PGnotify; { PQnoticeProcessor is the function type for the notice-message callback. } PQnoticeProcessor = procedure(arg: Pointer; message: PChar); cdecl; { Print options for PQprint() } { We can't use the conventional "bool", because we are designed to be included in a user's program, and user may already have that type defined. Pqbool, on the other hand, is unlikely to be used. } PPChar = array[00..$ff] of PChar; PQprintOpt = packed record header: TBool; { print output field headings and row count } align: TBool; { fill align the fields } standard: TBool; { old brain dead format } html3: TBool; { output html tables } expanded: TBool; { expand tables } pager: TBool; { use pager for output if needed } fieldSep: PChar; { field separator } tableOpt: PChar; { insert to HTML