📄 connection.h
字号:
char database[MEDIUM_REGISTRY_LEN]; char username[MEDIUM_REGISTRY_LEN]; char password[MEDIUM_REGISTRY_LEN]; char conn_settings[LARGE_REGISTRY_LEN]; char protocol[SMALL_REGISTRY_LEN]; char port[SMALL_REGISTRY_LEN]; char sslmode[SMALL_REGISTRY_LEN]; char onlyread[SMALL_REGISTRY_LEN]; char fake_oid_index[SMALL_REGISTRY_LEN]; char show_oid_column[SMALL_REGISTRY_LEN]; char row_versioning[SMALL_REGISTRY_LEN]; char show_system_tables[SMALL_REGISTRY_LEN]; char translation_dll[MEDIUM_REGISTRY_LEN]; char translation_option[SMALL_REGISTRY_LEN]; char focus_password; signed char disallow_premature; signed char allow_keyset; signed char updatable_cursors; signed char lf_conversion; signed char true_is_minus1; signed char int8_as; signed char bytea_as_longvarbinary; signed char use_server_side_prepare; signed char lower_case_identifier; signed char rollback_on_error; signed char force_abbrev_connstr; signed char bde_environment; signed char fake_mss; signed char cvt_null_date_string; signed char autocommit_public; signed char accessible_only;#ifdef _HANDLE_ENLIST_IN_DTC_ signed char xa_opt;#endif /* _HANDLE_ENLIST_IN_DTC_ */ GLOBAL_VALUES drivers; /* moved from driver's option */} ConnInfo;/* Macro to determine is the connection using 6.2 protocol? */#define PROTOCOL_62(conninfo_) (strncmp((conninfo_)->protocol, PG62, strlen(PG62)) == 0)/* Macro to determine is the connection using 6.3 protocol? */#define PROTOCOL_63(conninfo_) (strncmp((conninfo_)->protocol, PG63, strlen(PG63)) == 0)/* Macro to determine is the connection using 6.4 protocol? */#define PROTOCOL_64(conninfo_) (strncmp((conninfo_)->protocol, PG64, strlen(PG64)) == 0)/* Macro to determine is the connection using 7.4 protocol? */#define PROTOCOL_74(conninfo_) (strncmp((conninfo_)->protocol, PG74, strlen(PG74)) == 0)#define SUPPORT_DESCRIBE_PARAM(conninfo_) (PROTOCOL_74(conninfo_) && conninfo_->use_server_side_prepare)/* * Macros to compare the server's version with a specified version * 1st parameter: pointer to a ConnectionClass object * 2nd parameter: major version number * 3rd parameter: minor version number */#define SERVER_VERSION_GT(conn, major, minor) \ ((conn)->pg_version_major > major || \ ((conn)->pg_version_major == major && (conn)->pg_version_minor > minor))#define SERVER_VERSION_GE(conn, major, minor) \ ((conn)->pg_version_major > major || \ ((conn)->pg_version_major == major && (conn)->pg_version_minor >= minor))#define SERVER_VERSION_EQ(conn, major, minor) \ ((conn)->pg_version_major == major && (conn)->pg_version_minor == minor)#define SERVER_VERSION_LE(conn, major, minor) (! SERVER_VERSION_GT(conn, major, minor))#define SERVER_VERSION_LT(conn, major, minor) (! SERVER_VERSION_GE(conn, major, minor))/*#if ! defined(HAVE_CONFIG_H) || defined(HAVE_STRINGIZE)*/#define STRING_AFTER_DOT(string) (strchr(#string, '.') + 1)/*#else#define STRING_AFTER_DOT(str) (strchr("str", '.') + 1)#endif*//* * Simplified macros to compare the server's version with a * specified version * Note: Never pass a variable as the second parameter. * It must be a decimal constant of the form %d.%d . */#define PG_VERSION_GT(conn, ver) \ (SERVER_VERSION_GT(conn, (int) ver, atoi(STRING_AFTER_DOT(ver))))#define PG_VERSION_GE(conn, ver) \ (SERVER_VERSION_GE(conn, (int) ver, atoi(STRING_AFTER_DOT(ver))))#define PG_VERSION_EQ(conn, ver) \ (SERVER_VERSION_EQ(conn, (int) ver, atoi(STRING_AFTER_DOT(ver))))#define PG_VERSION_LE(conn, ver) (! PG_VERSION_GT(conn, ver))#define PG_VERSION_LT(conn, ver) (! PG_VERSION_GE(conn, ver))/* This is used to store cached table information in the connection */struct col_info{ Int2 num_reserved_cols; QResultClass *result; pgNAME schema_name; pgNAME table_name; OID table_oid;};#define col_info_initialize(coli) (memset(coli, 0, sizeof(COL_INFO))) /* Translation DLL entry points */#ifdef WIN32#define DLLHANDLE HINSTANCE#else#define WINAPI CALLBACK#define DLLHANDLE void *#define HINSTANCE void *#endiftypedef BOOL (FAR WINAPI * DataSourceToDriverProc) (UDWORD, SWORD, PTR, SDWORD, PTR, SDWORD, SDWORD FAR *, UCHAR FAR *, SWORD, SWORD FAR *); typedef BOOL (FAR WINAPI * DriverToDataSourceProc) (UDWORD, SWORD, PTR, SDWORD, PTR, SDWORD, SDWORD FAR *, UCHAR FAR *, SWORD, SWORD FAR *);/******* The Connection handle ************/struct ConnectionClass_{ HENV henv; /* environment this connection was * created on */ SQLUINTEGER login_timeout; StatementOptions stmtOptions; ARDFields ardOptions; APDFields apdOptions; char *__error_message; int __error_number; char sqlstate[8]; CONN_Status status; ConnInfo connInfo; StatementClass **stmts; Int2 num_stmts; Int2 ncursors; SocketClass *sock; Int4 lobj_type; Int2 coli_allocated; Int2 ntables; COL_INFO **col_info; long translation_option; HINSTANCE translation_handle; DataSourceToDriverProc DataSourceToDriver; DriverToDataSourceProc DriverToDataSource; Int2 driver_version; /* prepared for ODBC3.0 */ char transact_status; /* Is a transaction is currently * in progress */ char errormsg_created; /* has an informative error msg * been created ? */ char pg_version[MAX_INFO_STRING]; /* Version of PostgreSQL * we're connected to - * DJP 25-1-2001 */ float pg_version_number; Int2 pg_version_major; Int2 pg_version_minor; char ms_jet; char unicode; char result_uncommitted; char schema_support; char lo_is_domain; char escape_in_literal; char *original_client_encoding; char *current_client_encoding; char *server_encoding; Int2 ccsc; Int2 mb_maxbyte_per_char; int be_pid; /* pid returned by backend */ int be_key; /* auth code needed to send cancel */ UInt4 isolation; char *current_schema; Int2 max_identifier_length; Int2 num_discardp; char **discardp;#if (ODBCVER >= 0x0300) int num_descs; DescriptorClass **descs;#endif /* ODBCVER */ pgNAME schemaIns; pgNAME tableIns;#if defined(WIN_MULTITHREAD_SUPPORT) CRITICAL_SECTION cs; CRITICAL_SECTION slock;#elif defined(POSIX_THREADMUTEX_SUPPORT) pthread_mutex_t cs; pthread_mutex_t slock;#endif /* WIN_MULTITHREAD_SUPPORT */#ifdef _HANDLE_ENLIST_IN_DTC_ void *asdum;#endif /* _HANDLE_ENLIST_IN_DTC_ */};/* Accessor functions */#define CC_get_socket(x) (x->sock)#define CC_get_database(x) (x->connInfo.database)#define CC_get_server(x) (x->connInfo.server)#define CC_get_DSN(x) (x->connInfo.dsn)#define CC_get_username(x) (x->connInfo.username)#define CC_is_onlyread(x) (x->connInfo.onlyread[0] == '1')#define CC_get_escape(x) (x->escape_in_literal)#define CC_fake_mss(x) (/* 0 != (x)->ms_jet && */ 0 < (x)->connInfo.fake_mss)#define CC_accessible_only(x) (0 < (x)->connInfo.accessible_only && PG_VERSION_GE((x), 7.2))#define CC_default_is_c(x) (CC_is_in_ansi_app(x) || x->ms_jet /* not only */ || TRUE /* but for any other ? */)/* for CC_DSN_info */#define CONN_DONT_OVERWRITE 0#define CONN_OVERWRITE 1/* prototypes */ConnectionClass *CC_Constructor(void);void CC_conninfo_init(ConnInfo *conninfo);char CC_Destructor(ConnectionClass *self);int CC_cursor_count(ConnectionClass *self);char CC_cleanup(ConnectionClass *self);char CC_begin(ConnectionClass *self);char CC_commit(ConnectionClass *self);char CC_abort(ConnectionClass *self);char CC_set_autocommit(ConnectionClass *self, BOOL on);int CC_set_translation(ConnectionClass *self);char CC_connect(ConnectionClass *self, char password_req, char *salt);char CC_add_statement(ConnectionClass *self, StatementClass *stmt);char CC_remove_statement(ConnectionClass *self, StatementClass *stmt);#if (ODBCVER >= 0x0300)char CC_add_descriptor(ConnectionClass *self, DescriptorClass *desc);char CC_remove_descriptor(ConnectionClass *self, DescriptorClass *desc);#endif /* ODBCVER */void CC_set_error(ConnectionClass *self, int number, const char *message, const char *func);void CC_set_errormsg(ConnectionClass *self, const char *message);char CC_get_error(ConnectionClass *self, int *number, char **message);QResultClass *CC_send_query_append(ConnectionClass *self, const char *query, QueryInfo *qi, UDWORD flag, StatementClass *stmt, const char *appendq);#define CC_send_query(self, query, qi, flag, stmt) CC_send_query_append(self, query, qi, flag, stmt, NULL)void CC_clear_error(ConnectionClass *self);int CC_send_function(ConnectionClass *conn, int fnid, void *result_buf, int *actual_result_len, int result_is_int, LO_ARG *argv, int nargs);char CC_send_settings(ConnectionClass *self);/*char *CC_create_errormsg(ConnectionClass *self);void CC_lookup_lo(ConnectionClass *conn);void CC_lookup_pg_version(ConnectionClass *conn);*/void CC_initialize_pg_version(ConnectionClass *conn);void CC_log_error(const char *func, const char *desc, const ConnectionClass *self);int CC_get_max_query_len(const ConnectionClass *self);int CC_send_cancel_request(const ConnectionClass *conn);void CC_on_commit(ConnectionClass *conn);void CC_on_abort(ConnectionClass *conn, UDWORD opt);void CC_on_abort_partial(ConnectionClass *conn);void ProcessRollback(ConnectionClass *conn, BOOL undo, BOOL partial);const char *CC_get_current_schema(ConnectionClass *conn);int CC_mark_a_object_to_discard(ConnectionClass *conn, int type, const char *plan);int CC_discard_marked_objects(ConnectionClass *conn);int handle_error_message(ConnectionClass *self, char *msgbuf, size_t buflen, char *sqlstate, const char *comment, QResultClass *res);int handle_notice_message(ConnectionClass *self, char *msgbuf, size_t buflen, char *sqlstate, const char *comment, QResultClass *res);int EatReadyForQuery(ConnectionClass *self);void getParameterValues(ConnectionClass *self);int CC_get_max_idlen(ConnectionClass *self);BOOL SendSyncRequest(ConnectionClass *self);const char *CurrCat(const ConnectionClass *self);const char *CurrCatString(const ConnectionClass *self);/* CC_send_query options */enum { IGNORE_ABORT_ON_CONN = 1L /* not set the error result even when */ ,CREATE_KEYSET = (1L << 1) /* create keyset for updatable curosrs */ ,GO_INTO_TRANSACTION = (1L << 2) /* issue begin in advance */ ,ROLLBACK_ON_ERROR = (1L << 3) /* rollback the query when an error occurs */ ,END_WITH_COMMIT = (1L << 4) /* the query ends with COMMMIT command */};/* CC_on_abort options */#define NO_TRANS 1L#define CONN_DEAD (1L << 1) /* connection is no longer valid */#ifdef __cplusplus}#endif#endif /* __CONNECTION_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -