NCBI C++ ToolKit
|
#include <config.h>
#include <stdarg.h>
#include <stdio.h>
#include <sql.h>
#include <sqlext.h>
#include <sqlucode.h>
#include <freetds/sysdep_private.h>
#include <freetds/tds.h>
Go to the source code of this file.
Go to the SVN repository for this file.
Classes | |
struct | odbc_buf |
Typedefs | |
typedef struct odbc_buf | ODBC_BUF |
Variables | |
HENV | odbc_env |
HDBC | odbc_conn |
HSTMT | odbc_stmt |
int | odbc_use_version3 |
void(* | odbc_set_conn_attr )(void) |
char | odbc_err [512] |
char | odbc_sqlstate [6] |
char | odbc_user [512] |
char | odbc_server [512] |
char | odbc_password [512] |
char | odbc_database [512] |
char | odbc_driver [1024] |
ODBC_BUF * | odbc_buf |
#define CHKAllocConnect | ( | a, | |
res | |||
) | CHKR2(SQLAllocConnect, (odbc_env,a), SQL_HANDLE_ENV, odbc_env, res) |
#define CHKAllocEnv | ( | a, | |
res | |||
) | CHKR2(SQLAllocEnv, (a), 0, 0, res) |
#define CHKAllocHandle | ( | a, | |
b, | |||
c, | |||
res | |||
) | CHKR2(SQLAllocHandle, (a,b,c), odbc_alloc_handle_err_type(a), b, res) |
#define CHKAllocStmt | ( | a, | |
res | |||
) | CHKR2(SQLAllocStmt, (odbc_conn,a), SQL_HANDLE_DBC, odbc_conn, res) |
#define CHKBindCol | ( | a, | |
b, | |||
c, | |||
d, | |||
e, | |||
res | |||
) | CHKR2(SQLBindCol, (odbc_stmt,a,b,c,d,e), SQL_HANDLE_STMT, odbc_stmt, res) |
#define CHKCancel | ( | res | ) | CHKR2(SQLCancel, (odbc_stmt), SQL_HANDLE_STMT, odbc_stmt, res) |
#define CHKCloseCursor | ( | res | ) | CHKR2(SQLCloseCursor, (odbc_stmt), SQL_HANDLE_STMT, odbc_stmt, res) |
#define CHKExecDirect | ( | a, | |
b, | |||
res | |||
) | CHKR2(SQLExecDirect, (odbc_stmt,a,b), SQL_HANDLE_STMT, odbc_stmt, res) |
#define CHKExecute | ( | res | ) | CHKR2(SQLExecute, (odbc_stmt), SQL_HANDLE_STMT, odbc_stmt, res) |
#define CHKExtendedFetch | ( | a, | |
b, | |||
c, | |||
d, | |||
res | |||
) | CHKR2(SQLExtendedFetch, (odbc_stmt,a,b,c,d), SQL_HANDLE_STMT, odbc_stmt, res) |
#define CHKFetch | ( | res | ) | CHKR2(SQLFetch, (odbc_stmt), SQL_HANDLE_STMT, odbc_stmt, res) |
#define CHKFetchScroll | ( | a, | |
b, | |||
res | |||
) | CHKR2(SQLFetchScroll, (odbc_stmt,a,b), SQL_HANDLE_STMT, odbc_stmt, res) |
#define CHKFreeStmt | ( | a, | |
res | |||
) | CHKR2(SQLFreeStmt, (odbc_stmt,a), SQL_HANDLE_STMT, odbc_stmt, res) |
#define CHKGetConnectAttr | ( | a, | |
b, | |||
c, | |||
d, | |||
res | |||
) | CHKR2(SQLGetConnectAttr, (odbc_conn,a,b,c,d), SQL_HANDLE_DBC, odbc_conn, res) |
#define CHKGetData | ( | a, | |
b, | |||
c, | |||
d, | |||
e, | |||
res | |||
) | CHKR2(SQLGetData, (odbc_stmt,a,b,c,d,e), SQL_HANDLE_STMT, odbc_stmt, res) |
#define CHKGetStmtAttr | ( | a, | |
b, | |||
c, | |||
d, | |||
res | |||
) | CHKR2(SQLGetStmtAttr, (odbc_stmt,a,b,c,d), SQL_HANDLE_STMT, odbc_stmt, res) |
#define CHKGetTypeInfo | ( | a, | |
res | |||
) | CHKR2(SQLGetTypeInfo, (odbc_stmt,a), SQL_HANDLE_STMT, odbc_stmt, res) |
#define CHKMoreResults | ( | res | ) | CHKR2(SQLMoreResults, (odbc_stmt), SQL_HANDLE_STMT, odbc_stmt, res) |
#define CHKNumResultCols | ( | a, | |
res | |||
) | CHKR2(SQLNumResultCols, (odbc_stmt,a), SQL_HANDLE_STMT, odbc_stmt, res) |
#define CHKParamData | ( | a, | |
res | |||
) | CHKR2(SQLParamData, (odbc_stmt,a), SQL_HANDLE_STMT, odbc_stmt, res) |
#define CHKParamOptions | ( | a, | |
b, | |||
res | |||
) | CHKR2(SQLParamOptions, (odbc_stmt,a,b), SQL_HANDLE_STMT, odbc_stmt, res) |
#define CHKPrepare | ( | a, | |
b, | |||
res | |||
) | CHKR2(SQLPrepare, (odbc_stmt,a,b), SQL_HANDLE_STMT, odbc_stmt, res) |
#define CHKPutData | ( | a, | |
b, | |||
res | |||
) | CHKR2(SQLPutData, (odbc_stmt,a,b), SQL_HANDLE_STMT, odbc_stmt, res) |
#define CHKR | ( | func, | |
params, | |||
res | |||
) | odbc_check_res(__FILE__, __LINE__, (func params), 0, 0, #func, res) |
#define CHKR2 | ( | func, | |
params, | |||
type, | |||
handle, | |||
res | |||
) | odbc_check_res(__FILE__, __LINE__, (func params), type, handle, #func, res) |
#define CHKRowCount | ( | a, | |
res | |||
) | CHKR2(SQLRowCount, (odbc_stmt,a), SQL_HANDLE_STMT, odbc_stmt, res) |
#define CHKSetConnectAttr | ( | a, | |
b, | |||
c, | |||
res | |||
) | CHKR2(SQLSetConnectAttr, (odbc_conn,a,b,c), SQL_HANDLE_DBC, odbc_conn, res) |
#define CHKSetCursorName | ( | a, | |
b, | |||
res | |||
) | CHKR2(SQLSetCursorName, (odbc_stmt,a,b), SQL_HANDLE_STMT, odbc_stmt, res) |
#define CHKSetStmtAttr | ( | a, | |
b, | |||
c, | |||
res | |||
) | CHKR2(SQLSetStmtAttr, (odbc_stmt,a,b,c), SQL_HANDLE_STMT, odbc_stmt, res) |
#define CHKSetStmtOption | ( | a, | |
b, | |||
res | |||
) | CHKR2(SQLSetStmtOption, (odbc_stmt,a,b), SQL_HANDLE_STMT, odbc_stmt, res) |
#define int2ptr | ( | i | ) | ((void*)(((char*)0)+((tds_sysdep_intptr_type)(i)))) |
#define ODBC_CHECK_COLS | ( | n | ) | odbc_check_cols(n, __LINE__, __FILE__) |
#define ODBC_CHECK_ROWS | ( | n | ) | odbc_check_rows(n, __LINE__, __FILE__) |
#define odbc_command | ( | cmd | ) | odbc_command_proc(odbc_stmt, cmd, __FILE__, __LINE__, "SNo") |
#define odbc_command2 | ( | cmd, | |
res | |||
) | odbc_command_proc(odbc_stmt, cmd, __FILE__, __LINE__, res) |
#define ODBC_FREE | ( | ) | odbc_buf_free(&odbc_buf) |
#define ODBC_GET | ( | s | ) | odbc_buf_get(&odbc_buf, s) |
#define ODBC_REPORT_ERROR | ( | msg | ) | odbc_report_error(msg, __LINE__, __FILE__) |
#define odbc_reset_statement | ( | ) | odbc_reset_statement_proc(&odbc_stmt, __FILE__, __LINE__) |
#define setenv odbc_setenv |
#define SQLLEN SQLINTEGER |
#define SQLULEN SQLUINTEGER |
#define T | ( | s | ) | ((SQLCHAR*)(s)) |
SQLSMALLINT odbc_alloc_handle_err_type | ( | SQLSMALLINT | type | ) |
Definition at line 609 of file common.c.
References SQL_HANDLE_DBC, SQL_HANDLE_DESC, SQL_HANDLE_ENV, and SQL_HANDLE_STMT.
void odbc_buf_free | ( | ODBC_BUF ** | buf | ) |
Definition at line 693 of file common.c.
References buf, odbc_buf::buf, free(), next(), odbc_buf::next, and NULL.
void* odbc_buf_get | ( | ODBC_BUF ** | buf, |
size_t | s | ||
) |
Definition at line 681 of file common.c.
References assert, buf, odbc_buf::buf, calloc(), malloc(), and odbc_buf::next.
Referenced by odbc_get_sqlchar(), and odbc_get_sqlwchar().
void odbc_c2string | ( | char * | out, |
SQLSMALLINT | out_c_type, | ||
const void * | in, | ||
size_t | in_len | ||
) |
Converts an ODBC result into a string.
There is no check on destination length, use a buffer big enough.
Definition at line 26 of file c2string.c.
References add_char(), assert, i, IN, int, out(), tagSQL_NUMERIC_STRUCT::precision, PRId64, tagSQL_NUMERIC_STRUCT::scale, si, tagSQL_NUMERIC_STRUCT::sign, SQL_C_BINARY, SQL_C_CHAR, SQL_C_LONG, SQL_C_NUMERIC, SQL_C_SBIGINT, SQL_C_SHORT, SQL_C_TIMESTAMP, SQL_C_WCHAR, SQL_MAX_NUMERIC_LEN, tds_sysdep_int64_type, and tagSQL_NUMERIC_STRUCT::val.
Referenced by Test(), and TestOutput().
Definition at line 496 of file common.c.
References CHKNumResultCols, exit(), file, n, and odbc_disconnect().
void odbc_check_cursor | ( | void | ) |
Definition at line 548 of file common.c.
References C, CHKGetDiagRec, NULL, odbc_disconnect(), ODBC_FREE, odbc_reset_statement, odbc_stmt, odbc_test_skipped(), ODBC_VECTOR_SIZE, output, ReportODBCError(), SQL_ATTR_CONCURRENCY, SQL_CONCUR_ROWVER, SQL_HANDLE_STMT, SQL_SUCCESS, SQLSetStmtAttr(), and util::strcmp().
Referenced by main().
void odbc_check_no_row | ( | const char * | query | ) |
Definition at line 883 of file common.c.
References CHKExecDirect, CHKMoreResults, CHKNumResultCols, exit(), odbc_disconnect(), query, SQL_NO_DATA, SQL_NTS, SQL_SUCCESS, and T.
Referenced by check_dbname(), main(), Test0(), and TestBinding().
SQLRETURN odbc_check_res | ( | const char * | file, |
int | line, | ||
SQLRETURN | rc, | ||
SQLSMALLINT | handle_type, | ||
SQLHANDLE | handle, | ||
const char * | func, | ||
const char * | res | ||
) |
Definition at line 573 of file common.c.
References file, odbc_report_error(), ReportODBCError(), SQL_ERROR, SQL_NEED_DATA, SQL_NO_DATA, SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, and util::strncmp().
Referenced by odbc_command_proc(), and odbc_reset_statement_proc().
Definition at line 513 of file common.c.
References CHKRowCount, exit(), file, n, odbc_disconnect(), and SQLLEN.
SQLRETURN odbc_command_proc | ( | HSTMT | stmt, |
const char * | command, | ||
const char * | file, | ||
int | line, | ||
const char * | res | ||
) |
Definition at line 623 of file common.c.
References command, file, NULL, odbc_check_res(), ODBC_FREE, SQL_HANDLE_STMT, SQL_NTS, SQLExecDirect(), stmt, and T.
Definition at line 312 of file common.c.
References command, NULL, ODBC_FREE, SQL_NTS, SQLExecDirect(), stmt, and T.
Referenced by DoTest(), main(), query_test(), Test(), and TestRawODBCGuid().
int odbc_connect | ( | void | ) |
Definition at line 244 of file common.c.
References CHKAllocConnect, CHKAllocEnv, CHKAllocHandle, CHKAllocStmt, CHKConnect, CHKExecDirect, command, exit(), NULL, odbc_conn, odbc_database, odbc_env, ODBC_FREE, odbc_password, odbc_read_login_info(), odbc_server, odbc_set_conn_attr, odbc_stmt, odbc_use_version3, odbc_user, SQL_ATTR_ODBC_VERSION, SQL_HANDLE_DBC, SQL_HANDLE_ENV, SQL_IS_UINTEGER, SQL_NTS, SQL_NULL_HANDLE, SQL_OV_ODBC3, SQLMoreResults(), SQLSetConnectAttr, SQLSetEnvAttr(), and T.
int odbc_db_is_microsoft | ( | void | ) |
Definition at line 325 of file common.c.
References buf, C, i, len, ms_db, NULL, odbc_conn, ODBC_FREE, SQL_DBMS_NAME, SQLGetInfo(), and tolower().
Referenced by AllTests(), DoTest(), main(), NullInput(), odbc_init_bools(), Test(), Test2(), TestName(), and TestRawODBCGuid().
const char* odbc_db_version | ( | void | ) |
Definition at line 468 of file common.c.
References buf, C, CHKR, db_str_version, NULL, odbc_conn, ODBC_FREE, SQL_DBMS_VER, and SQLGetInfo().
Referenced by AllTests(), DoTest(), and odbc_db_version_int().
unsigned int odbc_db_version_int | ( | void | ) |
Definition at line 483 of file common.c.
References exit(), odbc_db_version(), and odbc_disconnect().
Referenced by AllTests(), DoTest(), and main().
int odbc_disconnect | ( | void | ) |
Definition at line 290 of file common.c.
References odbc_conn, odbc_env, ODBC_FREE, odbc_stmt, SQL_DROP, SQL_NULL_HDBC, SQL_NULL_HENV, SQL_NULL_HSTMT, SQLDisconnect(), SQLFreeConnect(), SQLFreeEnv(), and SQLFreeStmt().
Referenced by CheckType(), clean_up(), DoTest(), main(), odbc_check_cols(), odbc_check_cursor(), odbc_check_no_row(), odbc_check_rows(), odbc_db_version_int(), odbc_report_error(), odbc_tds_version_long(), ReportODBCError(), Test(), test(), test_err(), TestProc(), TestRawODBCDirectQuery(), TestRawODBCGuid(), TestRawODBCPreparedQuery(), and TestTable().
int odbc_driver_is_freetds | ( | void | ) |
Definition at line 345 of file common.c.
References buf, C, freetds_driver, i, len, NULL, odbc_conn, ODBC_FREE, SQL_DRIVER_NAME, SQLGetInfo(), and tolower().
Referenced by AllTests(), DoTest(), main(), odbc_init_bools(), odbc_tds_version(), Test(), and TestOutput().
TDS_SYS_SOCKET odbc_find_last_socket | ( | void | ) |
Definition at line 802 of file common.c.
References fd_is_socket(), FOR_ALL_SOCKETS, i, in(), INADDR_LOOPBACK, info, INVALID_SOCKET, mark_fd(), memmove, n, odbc_conn, long_sockaddr::sa, long_sockaddr::sin, tds_get_s, tds_getpeername, and tds_getsockname.
SQLINTEGER odbc_from_sqlwchar | ( | char * | dst, |
const SQLWCHAR * | src, | ||
SQLINTEGER | n | ||
) |
Definition at line 663 of file common.c.
References assert, i, n, and SQLLEN.
Referenced by odbc_get_sqlchar(), and readBlobAsChar().
Definition at line 719 of file common.c.
References buf, n, odbc_buf_get(), odbc_from_sqlwchar(), and out().
Referenced by extract_error().
Definition at line 706 of file common.c.
References buf, buffer, NULL, odbc_buf_get(), and odbc_to_sqlwchar().
Referenced by main().
void odbc_mark_sockets_opened | ( | void | ) |
Definition at line 790 of file common.c.
References fd_bitmask, fd_is_socket(), FOR_ALL_SOCKETS, i, and mark_fd().
void odbc_read_error | ( | void | ) |
Definition at line 638 of file common.c.
References C, CHKGetDiagRec, NULL, odbc_err, ODBC_FREE, ODBC_GET, odbc_sqlstate, odbc_stmt, and SQL_HANDLE_STMT.
Referenced by main(), query_test(), test(), and test_err().
int odbc_read_login_info | ( | void | ) |
Definition at line 88 of file common.c.
References check_lib(), in(), len, NULL, odbc_database, odbc_driver, odbc_password, odbc_server, odbc_user, ODBC_USER_DSN, PWD, search_driver, setenv, SQLGetConfigMode(), SQLSetConfigMode(), SQLWritePrivateProfileString(), strcasecmp, and util::strcmp().
Referenced by main(), and odbc_connect().
Definition at line 188 of file common.c.
References C, exit(), file, NULL, odbc_conn, odbc_disconnect(), odbc_env, ODBC_FREE, odbc_stmt, ODBC_VECTOR_SIZE, SQL_HANDLE_DBC, SQL_HANDLE_ENV, SQL_HANDLE_STMT, SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, and SQLGetDiagRec().
Referenced by odbc_check_res(), and report_bcp_error().
Definition at line 531 of file common.c.
References file, odbc_check_res(), odbc_conn, SQL_DROP, SQL_HANDLE_DBC, SQL_NULL_HSTMT, SQLAllocStmt(), SQLFreeStmt(), and stmt.
int odbc_tds_version | ( | void | ) |
Definition at line 444 of file common.c.
References len, NULL, odbc_conn, odbc_driver_is_freetds(), ODBC_FREE, odbc_tds_version_long(), SQLGetInfo(), tds_version, and version.
Referenced by AllTests(), DoTest(), main(), odbc_get_cmd_line(), and odbc_init_parser().
void odbc_test_skipped | ( | void | ) |
Definition at line 539 of file common.c.
References exit().
Referenced by main(), and odbc_check_cursor().
SQLINTEGER odbc_to_sqlwchar | ( | SQLWCHAR * | dst, |
const char * | src, | ||
SQLINTEGER | n | ||
) |
|
extern |
Definition at line 32 of file common.c.
Referenced by EndTransaction(), exec_direct(), init_connect(), insert_test_man(), main(), my_attrs(), normal_inserts(), odbc_connect(), odbc_db_is_microsoft(), odbc_db_version(), odbc_disconnect(), odbc_driver_is_freetds(), odbc_find_last_socket(), odbc_report_error(), odbc_reset_statement_proc(), odbc_tds_version(), ReadErrorConn(), set_attr(), special_inserts(), Test(), test_insert(), and test_select().
|
extern |
Definition at line 40 of file common.c.
Referenced by main(), odbc_connect(), and odbc_read_login_info().
|
extern |
Definition at line 41 of file common.c.
Referenced by main(), and odbc_read_login_info().
|
extern |
Definition at line 31 of file common.c.
Referenced by init_connect(), main(), odbc_connect(), odbc_disconnect(), odbc_report_error(), test_insert(), and test_select().
|
extern |
Definition at line 634 of file common.c.
Referenced by main(), odbc_read_error(), query_test(), ReadErrorConn(), and test().
|
extern |
Definition at line 39 of file common.c.
Referenced by main(), my_attrs(), normal_connect(), odbc_connect(), and odbc_read_login_info().
|
extern |
Definition at line 38 of file common.c.
Referenced by main(), normal_connect(), odbc_connect(), and odbc_read_login_info().
|
extern |
Definition at line 35 of file common.c.
Referenced by ConnectWithTxn(), main(), and odbc_connect().
|
extern |
Definition at line 635 of file common.c.
Referenced by main(), odbc_read_error(), query_test(), ReadErrorConn(), and test_err().
|
extern |
Definition at line 33 of file common.c.
Referenced by AllTests(), check_attr_ard(), check_attr_ird(), check_dbname(), CheckDirtyRead(), CheckNonrepeatableRead(), CheckPhantom(), CheckType(), DoTest(), exec_direct(), get_attr_stmt(), main(), odbc_check_cursor(), odbc_connect(), odbc_disconnect(), odbc_read_error(), odbc_report_error(), query_test(), report_bcp_error(), Test(), Test0(), test_err(), test_insert(), test_params(), test_rows(), test_select(), TestInput(), TestOutput(), TestRawODBCDirectQuery(), TestRawODBCGuid(), TestRawODBCPreparedQuery(), and TestResult().
|
extern |
|
extern |
Definition at line 37 of file common.c.
Referenced by main(), normal_connect(), odbc_connect(), and odbc_read_login_info().