diff options
Diffstat (limited to 'Frameworks/PostgresKit/Libs')
-rw-r--r-- | Frameworks/PostgresKit/Libs/libpq/include/libpq-fe.h | 576 | ||||
-rw-r--r-- | Frameworks/PostgresKit/Libs/libpq/include/postgres_ext.h | 59 | ||||
-rw-r--r-- | Frameworks/PostgresKit/Libs/libpq/lib/libpq.a | bin | 0 -> 687820 bytes | |||
-rw-r--r-- | Frameworks/PostgresKit/Libs/libpqtypes/include/libpqtypes.h | 468 | ||||
-rw-r--r-- | Frameworks/PostgresKit/Libs/libpqtypes/lib/libpqtypes.a | bin | 0 -> 515772 bytes |
5 files changed, 1103 insertions, 0 deletions
diff --git a/Frameworks/PostgresKit/Libs/libpq/include/libpq-fe.h b/Frameworks/PostgresKit/Libs/libpq/include/libpq-fe.h new file mode 100644 index 00000000..d7802753 --- /dev/null +++ b/Frameworks/PostgresKit/Libs/libpq/include/libpq-fe.h @@ -0,0 +1,576 @@ +/*------------------------------------------------------------------------- + * + * libpq-fe.h + * This file contains definitions for structures and + * externs for functions used by frontend postgres applications. + * + * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/interfaces/libpq/libpq-fe.h + * + *------------------------------------------------------------------------- + */ + +#ifndef LIBPQ_FE_H +#define LIBPQ_FE_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include <stdio.h> + +/* + * postgres_ext.h defines the backend's externally visible types, + * such as Oid. + */ +#include "postgres_ext.h" + +/* + * Option flags for PQcopyResult + */ +#define PG_COPYRES_ATTRS 0x01 +#define PG_COPYRES_TUPLES 0x02 /* Implies PG_COPYRES_ATTRS */ +#define PG_COPYRES_EVENTS 0x04 +#define PG_COPYRES_NOTICEHOOKS 0x08 + +/* Application-visible enum types */ + +typedef enum +{ + /* + * Although it is okay to add to this list, values which become unused + * should never be removed, nor should constants be redefined - that would + * break compatibility with existing code. + */ + CONNECTION_OK, + CONNECTION_BAD, + /* Non-blocking mode only below here */ + + /* + * The existence of these should never be relied upon - they should only + * be used for user feedback or similar purposes. + */ + CONNECTION_STARTED, /* Waiting for connection to be made. */ + CONNECTION_MADE, /* Connection OK; waiting to send. */ + CONNECTION_AWAITING_RESPONSE, /* Waiting for a response from the + * postmaster. */ + CONNECTION_AUTH_OK, /* Received authentication; waiting for + * backend startup. */ + CONNECTION_SETENV, /* Negotiating environment. */ + CONNECTION_SSL_STARTUP, /* Negotiating SSL. */ + CONNECTION_NEEDED /* Internal state: connect() needed */ +} ConnStatusType; + +typedef enum +{ + PGRES_POLLING_FAILED = 0, + PGRES_POLLING_READING, /* These two indicate that one may */ + PGRES_POLLING_WRITING, /* use select before polling again. */ + PGRES_POLLING_OK, + PGRES_POLLING_ACTIVE /* unused; keep for awhile for backwards + * compatibility */ +} PostgresPollingStatusType; + +typedef enum +{ + PGRES_EMPTY_QUERY = 0, /* empty query string was executed */ + 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, /* notice or warning message */ + PGRES_FATAL_ERROR, /* query failed */ + PGRES_COPY_BOTH /* Copy In/Out data transfer in progress */ +} ExecStatusType; + +typedef enum +{ + PQTRANS_IDLE, /* connection idle */ + PQTRANS_ACTIVE, /* command in progress */ + PQTRANS_INTRANS, /* idle, within transaction block */ + PQTRANS_INERROR, /* idle, within failed transaction */ + PQTRANS_UNKNOWN /* cannot determine status */ +} PGTransactionStatusType; + +typedef enum +{ + PQERRORS_TERSE, /* single-line error messages */ + PQERRORS_DEFAULT, /* recommended style */ + PQERRORS_VERBOSE /* all the facts, ma'am */ +} PGVerbosity; + +typedef enum +{ + PQPING_OK, /* server is accepting connections */ + PQPING_REJECT, /* server is alive but rejecting connections */ + PQPING_NO_RESPONSE, /* could not establish connection */ + PQPING_NO_ATTEMPT /* connection not attempted (bad params) */ +} PGPing; + +/* PGconn encapsulates a connection to the backend. + * The contents of this struct are not supposed to be known to applications. + */ +typedef struct pg_conn PGconn; + +/* 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. + */ +typedef struct pg_result PGresult; + +/* PGcancel encapsulates the information needed to cancel a running + * query on an existing connection. + * The contents of this struct are not supposed to be known to applications. + */ +typedef struct pg_cancel PGcancel; + +/* 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. + */ +typedef struct pgNotify +{ + char *relname; /* notification condition name */ + int be_pid; /* process ID of notifying server process */ + char *extra; /* notification parameter */ + /* Fields below here are private to libpq; apps should not use 'em */ + struct pgNotify *next; /* list link */ +} PGnotify; + +/* Function types for notice-handling callbacks */ +typedef void (*PQnoticeReceiver) (void *arg, const PGresult *res); +typedef void (*PQnoticeProcessor) (void *arg, const char *message); + +/* Print options for PQprint() */ +typedef char pqbool; + +typedef struct _PQprintOpt +{ + pqbool header; /* print output field headings and row count */ + pqbool align; /* fill align the fields */ + pqbool standard; /* old brain dead format */ + pqbool html3; /* output html tables */ + pqbool expanded; /* expand tables */ + pqbool pager; /* use pager for output if needed */ + char *fieldSep; /* field separator */ + char *tableOpt; /* insert to HTML <table ...> */ + char *caption; /* HTML <caption> */ + char **fieldName; /* null terminated array of replacement field + * names */ +} PQprintOpt; + +/* ---------------- + * Structure for the conninfo parameter definitions returned by PQconndefaults + * or PQconninfoParse. + * + * All fields except "val" point at static strings which must not be altered. + * "val" is either NULL or a malloc'd current-value string. PQconninfoFree() + * will release both the val strings and the PQconninfoOption array itself. + * ---------------- + */ +typedef struct _PQconninfoOption +{ + char *keyword; /* The keyword of the option */ + char *envvar; /* Fallback environment variable name */ + char *compiled; /* Fallback compiled in default value */ + char *val; /* Option's current value, or NULL */ + char *label; /* Label for field in connect dialog */ + char *dispchar; /* Indicates how to display this field in a + * connect dialog. Values are: "" Display + * entered value as is "*" Password field - + * hide value "D" Debug option - don't show + * by default */ + int dispsize; /* Field size in characters for dialog */ +} PQconninfoOption; + +/* ---------------- + * PQArgBlock -- structure for PQfn() arguments + * ---------------- + */ +typedef struct +{ + int len; + int isint; + union + { + int *ptr; /* can't use void (dec compiler barfs) */ + int integer; + } u; +} PQArgBlock; + +/* ---------------- + * PGresAttDesc -- Data about a single attribute (column) of a query result + * ---------------- + */ +typedef struct pgresAttDesc +{ + char *name; /* column name */ + Oid tableid; /* source table, if known */ + int columnid; /* source column, if known */ + int format; /* format code for value (text/binary) */ + Oid typid; /* type id */ + int typlen; /* type size */ + int atttypmod; /* type-specific modifier info */ +} PGresAttDesc; + +/* ---------------- + * Exported functions of libpq + * ---------------- + */ + +/* === in fe-connect.c === */ + +/* make a new client connection to the backend */ +/* Asynchronous (non-blocking) */ +extern PGconn *PQconnectStart(const char *conninfo); +extern PGconn *PQconnectStartParams(const char **keywords, + const char **values, int expand_dbname); +extern PostgresPollingStatusType PQconnectPoll(PGconn *conn); + +/* Synchronous (blocking) */ +extern PGconn *PQconnectdb(const char *conninfo); +extern PGconn *PQconnectdbParams(const char **keywords, + const char **values, int expand_dbname); +extern PGconn *PQsetdbLogin(const char *pghost, const char *pgport, + const char *pgoptions, const char *pgtty, + const char *dbName, + const char *login, const char *pwd); + +#define PQsetdb(M_PGHOST,M_PGPORT,M_PGOPT,M_PGTTY,M_DBNAME) \ + PQsetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, NULL, NULL) + +/* close the current connection and free the PGconn data structure */ +extern void PQfinish(PGconn *conn); + +/* get info about connection options known to PQconnectdb */ +extern PQconninfoOption *PQconndefaults(void); + +/* parse connection options in same way as PQconnectdb */ +extern PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); + +/* free the data structure returned by PQconndefaults() or PQconninfoParse() */ +extern void PQconninfoFree(PQconninfoOption *connOptions); + +/* + * close the current connection and restablish a new one with the same + * parameters + */ +/* Asynchronous (non-blocking) */ +extern int PQresetStart(PGconn *conn); +extern PostgresPollingStatusType PQresetPoll(PGconn *conn); + +/* Synchronous (blocking) */ +extern void PQreset(PGconn *conn); + +/* request a cancel structure */ +extern PGcancel *PQgetCancel(PGconn *conn); + +/* free a cancel structure */ +extern void PQfreeCancel(PGcancel *cancel); + +/* issue a cancel request */ +extern int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize); + +/* backwards compatible version of PQcancel; not thread-safe */ +extern int PQrequestCancel(PGconn *conn); + +/* Accessor functions for PGconn objects */ +extern char *PQdb(const PGconn *conn); +extern char *PQuser(const PGconn *conn); +extern char *PQpass(const PGconn *conn); +extern char *PQhost(const PGconn *conn); +extern char *PQport(const PGconn *conn); +extern char *PQtty(const PGconn *conn); +extern char *PQoptions(const PGconn *conn); +extern ConnStatusType PQstatus(const PGconn *conn); +extern PGTransactionStatusType PQtransactionStatus(const PGconn *conn); +extern const char *PQparameterStatus(const PGconn *conn, + const char *paramName); +extern int PQprotocolVersion(const PGconn *conn); +extern int PQserverVersion(const PGconn *conn); +extern char *PQerrorMessage(const PGconn *conn); +extern int PQsocket(const PGconn *conn); +extern int PQbackendPID(const PGconn *conn); +extern int PQconnectionNeedsPassword(const PGconn *conn); +extern int PQconnectionUsedPassword(const PGconn *conn); +extern int PQclientEncoding(const PGconn *conn); +extern int PQsetClientEncoding(PGconn *conn, const char *encoding); + +/* Get the OpenSSL structure associated with a connection. Returns NULL for + * unencrypted connections or if any other TLS library is in use. */ +extern void *PQgetssl(PGconn *conn); + +/* Tell libpq whether it needs to initialize OpenSSL */ +extern void PQinitSSL(int do_init); + +/* More detailed way to tell libpq whether it needs to initialize OpenSSL */ +extern void PQinitOpenSSL(int do_ssl, int do_crypto); + +/* Set verbosity for PQerrorMessage and PQresultErrorMessage */ +extern PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity); + +/* Enable/disable tracing */ +extern void PQtrace(PGconn *conn, FILE *debug_port); +extern void PQuntrace(PGconn *conn); + +/* Override default notice handling routines */ +extern PQnoticeReceiver PQsetNoticeReceiver(PGconn *conn, + PQnoticeReceiver proc, + void *arg); +extern PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn, + PQnoticeProcessor proc, + void *arg); + +/* + * Used to set callback that prevents concurrent access to + * non-thread safe functions that libpq needs. + * The default implementation uses a libpq internal mutex. + * Only required for multithreaded apps that use kerberos + * both within their app and for postgresql connections. + */ +typedef void (*pgthreadlock_t) (int acquire); + +extern pgthreadlock_t PQregisterThreadLock(pgthreadlock_t newhandler); + +/* === in fe-exec.c === */ + +/* Simple synchronous query */ +extern PGresult *PQexec(PGconn *conn, const char *query); +extern PGresult *PQexecParams(PGconn *conn, + const char *command, + int nParams, + const Oid *paramTypes, + const char *const * paramValues, + const int *paramLengths, + const int *paramFormats, + int resultFormat); +extern PGresult *PQprepare(PGconn *conn, const char *stmtName, + const char *query, int nParams, + const Oid *paramTypes); +extern PGresult *PQexecPrepared(PGconn *conn, + const char *stmtName, + int nParams, + const char *const * paramValues, + const int *paramLengths, + const int *paramFormats, + int resultFormat); + +/* Interface for multiple-result or asynchronous queries */ +extern int PQsendQuery(PGconn *conn, const char *query); +extern int PQsendQueryParams(PGconn *conn, + const char *command, + int nParams, + const Oid *paramTypes, + const char *const * paramValues, + const int *paramLengths, + const int *paramFormats, + int resultFormat); +extern int PQsendPrepare(PGconn *conn, const char *stmtName, + const char *query, int nParams, + const Oid *paramTypes); +extern int PQsendQueryPrepared(PGconn *conn, + const char *stmtName, + int nParams, + const char *const * paramValues, + const int *paramLengths, + const int *paramFormats, + int resultFormat); +extern PGresult *PQgetResult(PGconn *conn); + +/* Routines for managing an asynchronous query */ +extern int PQisBusy(PGconn *conn); +extern int PQconsumeInput(PGconn *conn); + +/* LISTEN/NOTIFY support */ +extern PGnotify *PQnotifies(PGconn *conn); + +/* Routines for copy in/out */ +extern int PQputCopyData(PGconn *conn, const char *buffer, int nbytes); +extern int PQputCopyEnd(PGconn *conn, const char *errormsg); +extern int PQgetCopyData(PGconn *conn, char **buffer, int async); + +/* Deprecated routines for copy in/out */ +extern int PQgetline(PGconn *conn, char *string, int length); +extern int PQputline(PGconn *conn, const char *string); +extern int PQgetlineAsync(PGconn *conn, char *buffer, int bufsize); +extern int PQputnbytes(PGconn *conn, const char *buffer, int nbytes); +extern int PQendcopy(PGconn *conn); + +/* Set blocking/nonblocking connection to the backend */ +extern int PQsetnonblocking(PGconn *conn, int arg); +extern int PQisnonblocking(const PGconn *conn); +extern int PQisthreadsafe(void); +extern PGPing PQping(const char *conninfo); +extern PGPing PQpingParams(const char **keywords, + const char **values, int expand_dbname); + +/* Force the write buffer to be written (or at least try) */ +extern int PQflush(PGconn *conn); + +/* + * "Fast path" interface --- not really recommended for application + * use + */ +extern PGresult *PQfn(PGconn *conn, + int fnid, + int *result_buf, + int *result_len, + int result_is_int, + const PQArgBlock *args, + int nargs); + +/* Accessor functions for PGresult objects */ +extern ExecStatusType PQresultStatus(const PGresult *res); +extern char *PQresStatus(ExecStatusType status); +extern char *PQresultErrorMessage(const PGresult *res); +extern char *PQresultErrorField(const PGresult *res, int fieldcode); +extern int PQntuples(const PGresult *res); +extern int PQnfields(const PGresult *res); +extern int PQbinaryTuples(const PGresult *res); +extern char *PQfname(const PGresult *res, int field_num); +extern int PQfnumber(const PGresult *res, const char *field_name); +extern Oid PQftable(const PGresult *res, int field_num); +extern int PQftablecol(const PGresult *res, int field_num); +extern int PQfformat(const PGresult *res, int field_num); +extern Oid PQftype(const PGresult *res, int field_num); +extern int PQfsize(const PGresult *res, int field_num); +extern int PQfmod(const PGresult *res, int field_num); +extern char *PQcmdStatus(PGresult *res); +extern char *PQoidStatus(const PGresult *res); /* old and ugly */ +extern Oid PQoidValue(const PGresult *res); /* new and improved */ +extern char *PQcmdTuples(PGresult *res); +extern char *PQgetvalue(const PGresult *res, int tup_num, int field_num); +extern int PQgetlength(const PGresult *res, int tup_num, int field_num); +extern int PQgetisnull(const PGresult *res, int tup_num, int field_num); +extern int PQnparams(const PGresult *res); +extern Oid PQparamtype(const PGresult *res, int param_num); + +/* Describe prepared statements and portals */ +extern PGresult *PQdescribePrepared(PGconn *conn, const char *stmt); +extern PGresult *PQdescribePortal(PGconn *conn, const char *portal); +extern int PQsendDescribePrepared(PGconn *conn, const char *stmt); +extern int PQsendDescribePortal(PGconn *conn, const char *portal); + +/* Delete a PGresult */ +extern void PQclear(PGresult *res); + +/* For freeing other alloc'd results, such as PGnotify structs */ +extern void PQfreemem(void *ptr); + +/* Exists for backward compatibility. bjm 2003-03-24 */ +#define PQfreeNotify(ptr) PQfreemem(ptr) + +/* Error when no password was given. */ +/* Note: depending on this is deprecated; use PQconnectionNeedsPassword(). */ +#define PQnoPasswordSupplied "fe_sendauth: no password supplied\n" + +/* Create and manipulate PGresults */ +extern PGresult *PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status); +extern PGresult *PQcopyResult(const PGresult *src, int flags); +extern int PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs); +extern void *PQresultAlloc(PGresult *res, size_t nBytes); +extern int PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len); + +/* Quoting strings before inclusion in queries. */ +extern size_t PQescapeStringConn(PGconn *conn, + char *to, const char *from, size_t length, + int *error); +extern char *PQescapeLiteral(PGconn *conn, const char *str, size_t len); +extern char *PQescapeIdentifier(PGconn *conn, const char *str, size_t len); +extern unsigned char *PQescapeByteaConn(PGconn *conn, + const unsigned char *from, size_t from_length, + size_t *to_length); +extern unsigned char *PQunescapeBytea(const unsigned char *strtext, + size_t *retbuflen); + +/* These forms are deprecated! */ +extern size_t PQescapeString(char *to, const char *from, size_t length); +extern unsigned char *PQescapeBytea(const unsigned char *from, size_t from_length, + size_t *to_length); + + + +/* === in fe-print.c === */ + +extern void +PQprint(FILE *fout, /* output stream */ + const PGresult *res, + const PQprintOpt *ps); /* option structure */ + +/* + * really old printing routines + */ +extern void +PQdisplayTuples(const PGresult *res, + FILE *fp, /* where to send the output */ + int fillAlign, /* pad the fields with spaces */ + const char *fieldSep, /* field separator */ + int printHeader, /* display headers? */ + int quiet); + +extern void +PQprintTuples(const PGresult *res, + FILE *fout, /* output stream */ + int printAttName, /* print attribute names */ + int terseOutput, /* delimiter bars */ + int width); /* width of column, if 0, use variable width */ + + +/* === in fe-lobj.c === */ + +/* Large-object access routines */ +extern int lo_open(PGconn *conn, Oid lobjId, int mode); +extern int lo_close(PGconn *conn, int fd); +extern int lo_read(PGconn *conn, int fd, char *buf, size_t len); +extern int lo_write(PGconn *conn, int fd, const char *buf, size_t len); +extern int lo_lseek(PGconn *conn, int fd, int offset, int whence); +extern Oid lo_creat(PGconn *conn, int mode); +extern Oid lo_create(PGconn *conn, Oid lobjId); +extern int lo_tell(PGconn *conn, int fd); +extern int lo_truncate(PGconn *conn, int fd, size_t len); +extern int lo_unlink(PGconn *conn, Oid lobjId); +extern Oid lo_import(PGconn *conn, const char *filename); +extern Oid lo_import_with_oid(PGconn *conn, const char *filename, Oid lobjId); +extern int lo_export(PGconn *conn, Oid lobjId, const char *filename); + +/* === in fe-misc.c === */ + +/* Get the version of the libpq library in use */ +extern int PQlibVersion(void); + +/* Determine length of multibyte encoded char at *s */ +extern int PQmblen(const char *s, int encoding); + +/* Determine display length of multibyte encoded char at *s */ +extern int PQdsplen(const char *s, int encoding); + +/* Get encoding id from environment variable PGCLIENTENCODING */ +extern int PQenv2encoding(void); + +/* === in fe-auth.c === */ + +extern char *PQencryptPassword(const char *passwd, const char *user); + +/* === in encnames.c === */ + +extern int pg_char_to_encoding(const char *name); +extern const char *pg_encoding_to_char(int encoding); +extern int pg_valid_server_encoding_id(int encoding); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBPQ_FE_H */ diff --git a/Frameworks/PostgresKit/Libs/libpq/include/postgres_ext.h b/Frameworks/PostgresKit/Libs/libpq/include/postgres_ext.h new file mode 100644 index 00000000..b6ebb7aa --- /dev/null +++ b/Frameworks/PostgresKit/Libs/libpq/include/postgres_ext.h @@ -0,0 +1,59 @@ +/*------------------------------------------------------------------------- + * + * postgres_ext.h + * + * This file contains declarations of things that are visible everywhere + * in PostgreSQL *and* are visible to clients of frontend interface libraries. + * For example, the Oid type is part of the API of libpq and other libraries. + * + * Declarations which are specific to a particular interface should + * go in the header file for that interface (such as libpq-fe.h). This + * file is only for fundamental Postgres declarations. + * + * User-written C functions don't count as "external to Postgres." + * Those function much as local modifications to the backend itself, and + * use header files that are otherwise internal to Postgres to interface + * with the backend. + * + * src/include/postgres_ext.h + * + *------------------------------------------------------------------------- + */ + +#ifndef POSTGRES_EXT_H +#define POSTGRES_EXT_H + +/* + * Object ID is a fundamental type in Postgres. + */ +typedef unsigned int Oid; + +#ifdef __cplusplus +#define InvalidOid (Oid(0)) +#else +#define InvalidOid ((Oid) 0) +#endif + +#define OID_MAX UINT_MAX +/* you will need to include <limits.h> to use the above #define */ + + +/* + * Identifiers of error message fields. Kept here to keep common + * between frontend and backend, and also to export them to libpq + * applications. + */ +#define PG_DIAG_SEVERITY 'S' +#define PG_DIAG_SQLSTATE 'C' +#define PG_DIAG_MESSAGE_PRIMARY 'M' +#define PG_DIAG_MESSAGE_DETAIL 'D' +#define PG_DIAG_MESSAGE_HINT 'H' +#define PG_DIAG_STATEMENT_POSITION 'P' +#define PG_DIAG_INTERNAL_POSITION 'p' +#define PG_DIAG_INTERNAL_QUERY 'q' +#define PG_DIAG_CONTEXT 'W' +#define PG_DIAG_SOURCE_FILE 'F' +#define PG_DIAG_SOURCE_LINE 'L' +#define PG_DIAG_SOURCE_FUNCTION 'R' + +#endif diff --git a/Frameworks/PostgresKit/Libs/libpq/lib/libpq.a b/Frameworks/PostgresKit/Libs/libpq/lib/libpq.a Binary files differnew file mode 100644 index 00000000..72502f0c --- /dev/null +++ b/Frameworks/PostgresKit/Libs/libpq/lib/libpq.a diff --git a/Frameworks/PostgresKit/Libs/libpqtypes/include/libpqtypes.h b/Frameworks/PostgresKit/Libs/libpqtypes/include/libpqtypes.h new file mode 100644 index 00000000..b41c9d70 --- /dev/null +++ b/Frameworks/PostgresKit/Libs/libpqtypes/include/libpqtypes.h @@ -0,0 +1,468 @@ + +/* + * libpqtypes.h + * Public header for libpqtypes. Contains the entire public API. + * + * Copyright (c) 2011 eSilo, LLC. All rights reserved. + * This is free software; see the source for copying conditions. There is + * NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +#ifndef LIBPQTYPES_H +#define LIBPQTYPES_H + +#include <libpq-fe.h> +#include <time.h> +#include <stdarg.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__) +# define PQT_EXPORT __declspec(dllexport) +#else +# define PQT_EXPORT extern +#endif + +/* MSVC 6 must use `i64', everything else uses `LL'. */ +#if !defined(_MSC_VER) || _MSC_VER > 1200 +# define PQT_INT64CONST(x) ((PGint8) x##LL) +#else +# define PQT_INT64CONST(x) ((PGint8) x##i64) +#endif + +enum +{ + PQT_SUBCLASS, + PQT_COMPOSITE, + PQT_USERDEFINED +}; + +typedef struct pg_param PGparam; +typedef struct pg_typeargs PGtypeArgs; +typedef int (*PGtypeProc)(PGtypeArgs *args); + +/* For use with a PQregisterXXX function */ +typedef struct +{ + const char *typname; + PGtypeProc typput; + PGtypeProc typget; +} PGregisterType; + +typedef struct +{ + int sversion; + int pversion; + char datestyle[48]; + int integer_datetimes; +} PGtypeFormatInfo; + +/* Record Attribute Description, its columns */ +typedef struct +{ + Oid attoid; + int attlen; + int atttypmod; + char attname[65]; +} PGrecordAttDesc; + +/* Type handler for putf and getf functions. The char fixed length buffers + * used to be allocated pointers. This was a performance problem when + * many type handlers are registered and one uses getf on a composite or + * an array. These types require generating a PGresult and duplicating + * the type handlers. Saved 40% by not having to deep copy the strings. + */ +typedef struct pg_typhandler +{ + int id; + char typschema[65]; + char typname[65]; + int typlen; + Oid typoid; + Oid typoid_array; + PGtypeProc typput; + PGtypeProc typget; + int base_id; + + /* For composites, contains each attribute of a composite */ + int nattrs; + int freeAttDescs; + PGrecordAttDesc attDescsBuf[16]; + PGrecordAttDesc *attDescs; +} PGtypeHandler; + +/* Values required during a type handler put ot get operation. */ +struct pg_typeargs +{ + int is_put; + const PGtypeFormatInfo *fmtinfo; + int is_ptr; + int format; + va_list ap; + int typpos; + PGtypeHandler *typhandler; + int (*errorf)(PGtypeArgs *args, const char *format, ...); + int (*super)(PGtypeArgs *args, ...); + + struct + { + PGparam *param; + char *out; + char *__allocated_out; /* leave me alone! */ + int outl; + int (*expandBuffer)(PGtypeArgs *args, int new_len); + } put; + + struct + { + PGresult *result; + int tup_num; + int field_num; + } get; +}; + + +/* ---------------- + * Variable Length types + * ---------------- + */ + +typedef char *PGtext; +typedef char *PGvarchar; +typedef char *PGbpchar; +typedef char *PGuuid; +typedef struct +{ + int len; + char *data; +} PGbytea; + +/* ---------------- + * Numeric types + * ---------------- + */ + +typedef signed char PGchar; +typedef int PGbool; +typedef short PGint2; +typedef int PGint4; +typedef float PGfloat4; +typedef double PGfloat8; +typedef char *PGnumeric; + +/* Defined by an end-user if the system is missing long long. */ +#ifdef PQT_LONG_LONG + typedef PQT_LONG_LONG PGint8; + typedef PQT_LONG_LONG PGmoney; + +/* MinGW and MSVC can use __int64 */ +#elif defined(__MINGW32__) || defined(_MSC_VER) + typedef __int64 PGint8; + typedef __int64 PGmoney; + +/* Cygwin and Unixes. */ +#else + typedef long long PGint8; + typedef long long PGmoney; +#endif + +/* ---------------- + * Geometric type structures + * ---------------- + */ + +typedef struct +{ + double x; + double y; +} PGpoint; + +typedef struct +{ + PGpoint pts[2]; +} PGlseg; + +typedef struct +{ + PGpoint high; + PGpoint low; +} PGbox; + +typedef struct +{ + PGpoint center; + double radius; +} PGcircle; + +typedef struct +{ + int npts; + int closed; + PGpoint *pts; /* for getf, only valid while PGresult is. */ +} PGpath; + +typedef struct +{ + int npts; + PGpoint *pts; /* for getf, only valid while PGresult is. */ +} PGpolygon; + +/* ---------------- + * Network type structures + * ---------------- + */ + +/* This struct works with CIDR as well. */ +typedef struct +{ + int mask; + int is_cidr; + int sa_buf_len; + + /* sockaddr buffer, can be casted to sockaddr, sockaddr_in, + * sockaddr_in6 or sockaddr_stroage. + */ + char sa_buf[128]; +} PGinet; + +typedef struct +{ + int a; + int b; + int c; + int d; + int e; + int f; +} PGmacaddr; + +/* ---------------- + * Date & Time structures + * ---------------- + */ + +typedef struct +{ + int years; + int mons; + int days; + int hours; + int mins; + int secs; + int usecs; +} PGinterval; + +typedef struct +{ + int isbc; + int year; + int mon; + int mday; + int jday; + int yday; + int wday; +} PGdate; + +typedef struct +{ + int hour; + int min; + int sec; + int usec; + int withtz; + int isdst; + int gmtoff; + char tzabbr[16]; +} PGtime; + +typedef struct +{ + PGint8 epoch; + PGdate date; + PGtime time; +} PGtimestamp; + +/* ---------------- + * Array structures + * ---------------- + */ + +#ifndef MAXDIM +# define MAXDIM 6 +#endif + +typedef struct +{ + int ndims; + int lbound[MAXDIM]; + int dims[MAXDIM]; + PGparam *param; + PGresult *res; +} PGarray; + +/* ---------------- + * Public API funcs + * ---------------- + */ + +/* === in events.c === */ + +/* Deprecated, see PQinitTypes */ +PQT_EXPORT int +PQtypesRegister(PGconn *conn); + +/* === in error.c === */ + +PQT_EXPORT char * +PQgeterror(void); + +/* PQseterror(NULL) will clear the error message */ +PQT_EXPORT void +PQseterror(const char *format, ...); + +/* Gets the error field for the last executed query. This only + * pertains to PQparamExec and PQparamExecPrepared. When using a + * standard libpq function like PQexec, PQresultErrorField should be used. + */ +PQT_EXPORT char * +PQgetErrorField(int fieldcode); + +/* === in spec.c === */ + +/* Set 'format' argument to NULL to clear a single prepared specifier. */ +PQT_EXPORT int +PQspecPrepare(PGconn *conn, const char *name, const char *format, int is_stmt); + +PQT_EXPORT int +PQclearSpecs(PGconn *conn); + +/* === in handler.c === */ + +/* Initialize type support on the given connection */ +PQT_EXPORT int +PQinitTypes(PGconn *conn); + +/* Deprecated, see PQregisterTypes */ +PQT_EXPORT int +PQregisterSubClasses(PGconn *conn, PGregisterType *types, int count); + +/* Deprecated, see PQregisterTypes */ +PQT_EXPORT int +PQregisterComposites(PGconn *conn, PGregisterType *types, int count); + +/* Deprecated, see PQregisterTypes */ +PQT_EXPORT int +PQregisterUserDefinedTypes(PGconn *conn, PGregisterType *types, int count); + +/* Registers PQT_SUBCLASS, PQT_COMPOSITE or PQT_USERDEFINED + * (the 'which' argument) for use with libpqtypes. + * + * For asynchronous type registration, set the 'async' argument to a + * non-zero value. This value is ignored when 'which' is PQT_SUBCLASS, + * since subclass registration does not execute any commands against the + * server. Use the standard PQconsumeInput, PQisBusy and PQgetResult + * to properly obtain a PGresult, which must be passed to PQregisterResult + * to complete the registration. + */ +PQT_EXPORT int +PQregisterTypes(PGconn *conn, int which, PGregisterType *types, + int count, int async); + +/* Registers a set of 'which' types found in the given PGresult. Caller + * is responsible for clearing the result 'res'. Useful for performing + * asynchronous type registration or for caching type result data to + * avoid lookups on a new connection. If PQregisterTypes is ran in async + * mode, the PGresult obtained via PGgetResult can be cached by an + * application and provided to this function for new connections. + * + * Types and count should be identical to what was originally supplied + * to PQregisterTypes. + * + * NOTE: although a PGconn is a required argument, it is never used + * to perform any network operation (non-blocking safe). + * + * PQT_SUBCLASS is not supported and will result in an error if supplied. + */ +PQT_EXPORT int +PQregisterResult(PGconn *conn, int which, PGregisterType *types, + int count, PGresult *res); + +/* Clears all type handlers registered on 'conn'. This is useful after a + * PQreset or PQresetPoll to optionally allow one to re-register types via + * PQregisterTypes. + */ +PQT_EXPORT int +PQclearTypes(PGconn *conn); + +/* === in param.c === */ + +PQT_EXPORT PGparam * +PQparamCreate(const PGconn *conn); + +PQT_EXPORT PGparam * +PQparamDup(PGparam *param); + +PQT_EXPORT int +PQparamCount(PGparam *param); + +PQT_EXPORT void +PQparamReset(PGparam *param); + +PQT_EXPORT void +PQparamClear(PGparam *param); + +PQT_EXPORT int +PQputf(PGparam *param, const char *format, ...); + +PQT_EXPORT int +PQputvf(PGparam *param, char *stmtBuf, size_t stmtBufLen, + const char *format, va_list ap); + +/* === in exec.c === */ + +PQT_EXPORT int +PQgetf(const PGresult *res, int tup_num, const char *format, ...); + +PQT_EXPORT int +PQgetvf(const PGresult *res, int tup_num, const char *format, va_list ap); + +PQT_EXPORT PGresult * +PQexecf(PGconn *conn, const char *cmdspec, ...); + +PQT_EXPORT PGresult * +PQexecvf(PGconn *conn, const char *cmdspec, va_list ap); + +PQT_EXPORT int +PQsendf(PGconn *conn, const char *cmdspec, ...); + +PQT_EXPORT int +PQsendvf(PGconn *conn, const char *cmdspec, va_list ap); + +PQT_EXPORT PGresult * +PQparamExec(PGconn *conn, PGparam *param, + const char *command, int resultFormat); + +PQT_EXPORT int +PQparamSendQuery(PGconn *conn, PGparam *param, + const char *command, int resultFormat); + +PQT_EXPORT PGresult * +PQparamExecPrepared(PGconn *conn, PGparam *param, + const char *stmtName, int resultFormat); + +PQT_EXPORT int +PQparamSendQueryPrepared(PGconn *conn, PGparam *param, + const char *stmtName, int resultFormat); + +/* === in datetime.c === */ + +PQT_EXPORT void +PQlocalTZInfo(time_t *t, int *gmtoff, int *isdst, char **tzabbrp); + +#ifdef __cplusplus +} +#endif +#endif /* !LIBPQTYPES_H */ + diff --git a/Frameworks/PostgresKit/Libs/libpqtypes/lib/libpqtypes.a b/Frameworks/PostgresKit/Libs/libpqtypes/lib/libpqtypes.a Binary files differnew file mode 100644 index 00000000..d95c9baf --- /dev/null +++ b/Frameworks/PostgresKit/Libs/libpqtypes/lib/libpqtypes.a |