NCBI C++ ToolKit
Classes | Typedefs | Functions | Variables
dblib.c File Reference

Main implementation file for db-lib. More...

#include <config.h>
#include <stdarg.h>
#include <freetds/time.h>
#include <assert.h>
#include <stdio.h>
#include <freetds/tds.h>
#include <freetds/thread.h>
#include <freetds/convert.h>
#include <freetds/utils/string.h>
#include <freetds/data.h>
#include <freetds/replacements.h>
#include <sybfront.h>
#include <sybdb.h>
#include <syberror.h>
#include <dblib.h>
#include "buffering.h"
+ Include dependency graph for dblib.c:

Go to the source code of this file.

Go to the SVN repository for this file.

Classes

struct  dblib_context
 
struct  _dblib_error_message
 

Typedefs

typedef struct dblib_context DBLIBCONTEXT
 
typedef struct _dblib_error_message DBLIB_ERROR_MESSAGE
 

Functions

static RETCODE _dbresults (DBPROCESS *dbproc)
 
static BYTE_dbcoldata (TDSCOLUMN *colinfo)
 
static int _get_printable_size (TDSCOLUMN *colinfo)
 
static char * _dbprdate (char *timestr)
 
static int _dbnullable (DBPROCESS *dbproc, int column)
 
static const char * tds_prdatatype (int datatype_token)
 Returns type in string. More...
 
static int default_err_handler (DBPROCESS *dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr)
 
void copy_data_to_host_var (DBPROCESS *, TDS_SERVER_TYPE, const BYTE *, int, BYTE *, DBINT, int, DBINT *)
 
RETCODE dbgetnull (DBPROCESS *dbproc, int bindtype, int varlen, BYTE *varaddr)
 
static int dblib_add_connection (DBLIBCONTEXT *ctx, TDSSOCKET *tds)
 
static void dblib_del_connection (DBLIBCONTEXT *ctx, TDSSOCKET *tds)
 
static TDSCONTEXTdblib_get_tds_ctx (void)
 
static void dblib_release_tds_ctx (int count)
 
static void db_env_chg (TDSSOCKET *tds, int type, char *oldval, char *newval)
 
static TDSCOLUMNdbcolptr (DBPROCESS *dbproc, int column)
 
static TDSCOLUMNdbacolptr (DBPROCESS *dbproc, int computeid, int column, int is_bind)
 
static int dbbindtype (int datatype)
 
RETCODE dbinit (void)
 Initialize db-lib. More...
 
LOGINRECdblogin (void)
 Allocate a LOGINREC structure. More...
 
void dbloginfree (LOGINREC *login)
 free the LOGINREC More...
 
RETCODE dbsetlname (LOGINREC *login, const char *value, int which)
 
RETCODE dbsetllong (LOGINREC *login, long value, int which)
 
RETCODE dbsetlbool (LOGINREC *login, int value, int which)
 
RETCODE dbsetlversion (LOGINREC *login, BYTE version)
 Set TDS version for future connections. More...
 
static void dbstring_free (DBSTRING **dbstrp)
 
static RETCODE dbstring_concat (DBSTRING **dbstrp, const char *p)
 
static RETCODE dbstring_assign (DBSTRING **dbstrp, const char *p)
 
static DBINT dbstring_length (DBSTRING *dbstr)
 
static int dbstring_getchar (DBSTRING *dbstr, ssize_t i)
 
static char * dbstring_get (DBSTRING *dbstr)
 
static DBOPTIONinit_dboptions (void)
 
DBPROCESStdsdbopen (LOGINREC *login, const char *server, int msdblib)
 
RETCODE dbfcmd (DBPROCESS *dbproc, const char *fmt,...)
 printf-like way to form SQL to send to the server. More...
 
RETCODE dbcmd (DBPROCESS *dbproc, const char cmdstring[])
 Append SQL to the command buffer. More...
 
RETCODE dbsqlexec (DBPROCESS *dbproc)
 send the SQL command to the server and wait for an answer. More...
 
RETCODE dbuse (DBPROCESS *dbproc, const char *name)
 Change current database. More...
 
void dbclose (DBPROCESS *dbproc)
 Close a connection to the server and free associated resources. More...
 
void dbexit ()
 Close server connections and free all related structures. More...
 
static const char * prdbresults_state (int retcode)
 
static const char * prdbretcode (RETCODE retcode)
 
static const char * prretcode (int retcode)
 
static const char * prresult_type (int result_type)
 
RETCODE dbresults (DBPROCESS *dbproc)
 Set up query results. More...
 
int dbnumcols (DBPROCESS *dbproc)
 Return number of regular columns in a result set. More...
 
char * dbcolname (DBPROCESS *dbproc, int column)
 Return name of a regular result column. More...
 
const char * dbacolname (DBPROCESS *dbproc, int computeid, int column)
 Return name of a computed result column. More...
 
RETCODE dbgetrow (DBPROCESS *dbproc, DBINT row)
 Read a row from the row buffer. More...
 
RETCODE dbsetnull (DBPROCESS *dbproc, int bindtype, int bindlen, BYTE *bindval)
 Define substitution values to be used when binding null values. More...
 
STATUS dbsetrow (DBPROCESS *dbproc, DBINT row)
 Make a buffered row "current" without fetching it into bound variables. More...
 
STATUS dbnextrow (DBPROCESS *dbproc)
 
static TDS_SERVER_TYPE dblib_bound_type (int bindtype)
 
DBINT dbconvert_ps (DBPROCESS *dbproc, int db_srctype, const BYTE *src, DBINT srclen, int db_desttype, BYTE *dest, DBINT destlen, DBTYPEINFO *typeinfo)
 Convert one datatype to another. More...
 
DBINT dbconvert (DBPROCESS *dbproc, int srctype, const BYTE *src, DBINT srclen, int desttype, BYTE *dest, DBINT destlen)
 cf. More...
 
RETCODE dbbind (DBPROCESS *dbproc, int column, int vartype, DBINT varlen, BYTE *varaddr)
 Tie a host variable to a resultset column. More...
 
void dbsetifile (char *filename)
 set name and location of the interfaces file FreeTDS should use to look up a servername. More...
 
RETCODE dbnullbind (DBPROCESS *dbproc, int column, DBINT *indicator)
 Tie a null-indicator to a regular result column. More...
 
RETCODE dbanullbind (DBPROCESS *dbproc, int computeid, int column, DBINT *indicator)
 Tie a null-indicator to a compute result column. More...
 
BOOL dbiscount (DBPROCESS *dbproc)
 Indicates whether or not the count returned by dbcount is real (Microsoft-compatibility feature). More...
 
DBINT dbcount (DBPROCESS *dbproc)
 Get count of rows processed. More...
 
void dbclrbuf (DBPROCESS *dbproc, DBINT n)
 Clear n rows from the row buffer. More...
 
DBBOOL dbwillconvert (int srctype, int desttype)
 Test whether or not a datatype can be converted to another datatype. More...
 
static int dblib_coltype (TDSCOLUMN *colinfo)
 
int dbcoltype (DBPROCESS *dbproc, int column)
 Get the datatype of a regular result set column. More...
 
int dbcolutype (DBPROCESS *dbproc, int column)
 Get user-defined datatype of a regular result column. More...
 
DBTYPEINFOdbcoltypeinfo (DBPROCESS *dbproc, int column)
 Get precision and scale information for a regular result column. More...
 
RETCODE dbcolinfo (DBPROCESS *dbproc, CI_TYPE type, DBINT column, DBINT computeid, DBCOL *pdbcol)
 Get a bunch of column attributes with a single call (Microsoft-compatibility feature). More...
 
char * dbcolsource (DBPROCESS *dbproc, int column)
 Get base database column name for a result set column. More...
 
DBINT dbcollen (DBPROCESS *dbproc, int column)
 Get size of a regular result column. More...
 
DBINT dbprcollen (DBPROCESS *dbproc, int column)
 Get size of a result column needed to print column. More...
 
DBINT dbvarylen (DBPROCESS *dbproc, int column)
 Determine whether a column can vary in size. More...
 
DBINT dbdatlen (DBPROCESS *dbproc, int column)
 Get size of current row's data in a regular result column. More...
 
BYTEdbdata (DBPROCESS *dbproc, int column)
 Get address of data in a regular result column. More...
 
RETCODE dbcancel (DBPROCESS *dbproc)
 Cancel the current command batch. More...
 
DBINT dbspr1rowlen (DBPROCESS *dbproc)
 Determine size buffer required to hold the results returned by dbsprhead(), dbsprline(), and dbspr1row(). More...
 
RETCODE dbspr1row (DBPROCESS *dbproc, char *buffer, DBINT buf_len)
 Print a regular result row to a buffer. More...
 
RETCODE dbprrow (DBPROCESS *dbproc)
 Print a result set to stdout. More...
 
RETCODE dbsprline (DBPROCESS *dbproc, char *buffer, DBINT buf_len, DBCHAR line_char)
 Get formatted string for underlining dbsprhead() column names. More...
 
RETCODE dbsprhead (DBPROCESS *dbproc, char *buffer, DBINT buf_len)
 Print result set headings to a buffer. More...
 
void dbprhead (DBPROCESS *dbproc)
 Print result set headings to stdout. More...
 
RETCODE dbrows (DBPROCESS *dbproc)
 
int dbgetpacket (DBPROCESS *dbproc)
 Get TDS packet size for the connection. More...
 
RETCODE dbsetmaxprocs (int maxprocs)
 Set maximum simultaneous connections db-lib will open to the server. More...
 
int dbgetmaxprocs (void)
 get maximum simultaneous connections db-lib will open to the server. More...
 
RETCODE dbsettime (int seconds)
 Set maximum seconds db-lib waits for a server response to query. More...
 
int dbgettime (void)
 Get maximum seconds db-lib waits for a server response to query. More...
 
RETCODE dbsetlogintime (int seconds)
 Set maximum seconds db-lib waits for a server response to a login attempt. More...
 
RETCODE dbcmdrow (DBPROCESS *dbproc)
 
int dbaltcolid (DBPROCESS *dbproc, int computeid, int column)
 Get column ID of a compute column. More...
 
DBINT dbadlen (DBPROCESS *dbproc, int computeid, int column)
 Get size of data in a compute column. More...
 
int dbalttype (DBPROCESS *dbproc, int computeid, int column)
 Get datatype for a compute column. More...
 
RETCODE dbaltbind (DBPROCESS *dbproc, int computeid, int column, int vartype, DBINT varlen, BYTE *varaddr)
 Bind a compute column to a program variable. More...
 
BYTEdbadata (DBPROCESS *dbproc, int computeid, int column)
 Get address of compute column data. More...
 
int dbaltop (DBPROCESS *dbproc, int computeid, int column)
 Get aggregation operator for a compute column. More...
 
RETCODE dbsetopt (DBPROCESS *dbproc, int option, const char *char_param, int int_param)
 Set db-lib or server option. More...
 
void dbsetinterrupt (DBPROCESS *dbproc, DB_DBCHKINTR_FUNC chkintr, DB_DBHNDLINTR_FUNC hndlintr)
 Set interrupt handler for db-lib to use while blocked against a read from the server. More...
 
DBBOOL dbhasretstat (DBPROCESS *dbproc)
 Determine if query generated a return status number. More...
 
DBINT dbretstatus (DBPROCESS *dbproc)
 Fetch status value returned by query or remote procedure call. More...
 
int dbnumrets (DBPROCESS *dbproc)
 Get count of output parameters filled by a stored procedure. More...
 
char * dbretname (DBPROCESS *dbproc, int retnum)
 Get name of an output parameter filled by a stored procedure. More...
 
BYTEdbretdata (DBPROCESS *dbproc, int retnum)
 Get value of an output parameter filled by a stored procedure. More...
 
int dbretlen (DBPROCESS *dbproc, int retnum)
 Get size of an output parameter filled by a stored procedure. More...
 
RETCODE dbsqlok (DBPROCESS *dbproc)
 Wait for results of a query from the server. More...
 
int dbnumalts (DBPROCESS *dbproc, int computeid)
 Get count of columns in a compute row. More...
 
int dbnumcompute (DBPROCESS *dbproc)
 Get count of COMPUTE clauses for a result set. More...
 
BYTEdbbylist (DBPROCESS *dbproc, int computeid, int *size)
 Get bylist for a compute row. More...
 
DBBOOL dbdead (DBPROCESS *dbproc)
 
EHANDLEFUNC dberrhandle (EHANDLEFUNC handler)
 Set an error handler, for messages from db-lib. More...
 
MHANDLEFUNC dbmsghandle (MHANDLEFUNC handler)
 Set a message handler, for messages from the server. More...
 
int dbmnycmp (DBPROCESS *dbproc, DBMONEY *m1, DBMONEY *m2)
 Compare two DBMONEY values. More...
 
RETCODE dbmnyzero (DBPROCESS *dbproc, DBMONEY *dest)
 Set a DBMONEY value to zero. More...
 
RETCODE dbmnymaxpos (DBPROCESS *dbproc, DBMONEY *amount)
 Get maximum positive DBMONEY value supported. More...
 
RETCODE dbmnymaxneg (DBPROCESS *dbproc, DBMONEY *amount)
 Get maximum negative DBMONEY value supported. More...
 
RETCODE dbmnyinc (DBPROCESS *dbproc, DBMONEY *amount)
 Add $0.0001 to a DBMONEY value. More...
 
RETCODE dbmnydec (DBPROCESS *dbproc, DBMONEY *amount)
 Subtract $0.0001 from a DBMONEY value. More...
 
RETCODE dbmnyminus (DBPROCESS *dbproc, DBMONEY *src, DBMONEY *dest)
 Negate a DBMONEY value. More...
 
RETCODE dbmny4minus (DBPROCESS *dbproc, DBMONEY4 *src, DBMONEY4 *dest)
 Negate a DBMONEY4 value. More...
 
RETCODE dbmny4zero (DBPROCESS *dbproc, DBMONEY4 *dest)
 Zero a DBMONEY4 value. More...
 
RETCODE dbmny4add (DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2, DBMONEY4 *sum)
 Add two DBMONEY4 values. More...
 
RETCODE dbmny4sub (DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2, DBMONEY4 *diff)
 Subtract two DBMONEY4 values. More...
 
int dbmny4cmp (DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2)
 Compare two DBMONEY4 values. More...
 
RETCODE dbmny4copy (DBPROCESS *dbproc, DBMONEY4 *src, DBMONEY4 *dest)
 Copy a DBMONEY4 value. More...
 
int dbdatecmp (DBPROCESS *dbproc, DBDATETIME *d1, DBDATETIME *d2)
 Compare DBDATETIME values, similar to strcmp(3). More...
 
static RETCODE dblib_datecrack (DBPROCESS *dbproc, BOOL nano_precision, DBDATEREC *output, int type, const void *data)
 
RETCODE dbdatecrack (DBPROCESS *dbproc, DBDATEREC *di, DBDATETIME *datetime)
 Break a DBDATETIME value into useful pieces. More...
 
RETCODE dbanydatecrack (DBPROCESS *dbproc, DBDATEREC2 *di, int type, const void *data)
 Break any kind of date or time value into useful pieces. More...
 
int dbspid (DBPROCESS *dbproc)
 Get server process ID for a DBPROCESS. More...
 
void dbsetuserdata (DBPROCESS *dbproc, BYTE *ptr)
 Associate client-allocated (and defined) data with a DBPROCESS. More...
 
BYTEdbgetuserdata (DBPROCESS *dbproc)
 Get address of user-allocated data from a DBPROCESS. More...
 
RETCODE dbsetversion (DBINT version)
 Specify a db-lib version level. More...
 
RETCODE dbmnycopy (DBPROCESS *dbproc, DBMONEY *src, DBMONEY *dest)
 Copy a DBMONEY value. More...
 
RETCODE dbcanquery (DBPROCESS *dbproc)
 Cancel the query currently being retrieved, discarding all pending rows. More...
 
void dbfreebuf (DBPROCESS *dbproc)
 Erase the command buffer, in case DBNOAUTOFREE was set with dbsetopt(). More...
 
RETCODE dbclropt (DBPROCESS *dbproc, int option, const char param[])
 Reset an option. More...
 
DBBOOL dbisopt (DBPROCESS *dbproc, int option, const char param[])
 Get value of an option. More...
 
DBINT dbcurrow (DBPROCESS *dbproc)
 
STATUS dbrowtype (DBPROCESS *dbproc)
 
int dbcurcmd (DBPROCESS *dbproc)
 
RETCODE dbmorecmds (DBPROCESS *dbproc)
 See if more commands are to be processed. More...
 
int dbrettype (DBPROCESS *dbproc, int retnum)
 Get datatype of a stored procedure's return parameter. More...
 
int dbstrlen (DBPROCESS *dbproc)
 Get size of the command buffer, in bytes. More...
 
char * dbgetchar (DBPROCESS *dbproc, int pos)
 Get address of a position in the command buffer. More...
 
RETCODE dbstrcpy (DBPROCESS *dbproc, int start, int numbytes, char *dest)
 Get a copy of a chunk of the command buffer. More...
 
RETCODE dbsafestr (DBPROCESS *dbproc, const char *src, DBINT srclen, char *dest, DBINT destlen, int quotetype)
 safely quotes character values in SQL text. More...
 
const char * dbprtype (int token)
 Print a token value's name to a buffer. More...
 
RETCODE dbtablecolinfo (DBPROCESS *dbproc, DBINT column, DBCOL *pdbcol)
 describe table column attributes with a single call (Freetds-only API function modelled on dbcolinfo) More...
 
DBBINARYdbtxtimestamp (DBPROCESS *dbproc, int column)
 Get text timestamp for a column in the current row. More...
 
DBBINARYdbtxptr (DBPROCESS *dbproc, int column)
 Get text pointer for a column in the current row. More...
 
RETCODE dbwritetext (DBPROCESS *dbproc, char *objname, DBBINARY *textptr, DBTINYINT textptrlen, DBBINARY *timestamp, DBBOOL log, DBINT size, BYTE *text)
 Send text or image data to the server. More...
 
STATUS dbreadtext (DBPROCESS *dbproc, void *buf, DBINT bufsize)
 Fetch part of a text or image value from the server. More...
 
RETCODE dbmoretext (DBPROCESS *dbproc, DBINT size, const BYTE text[])
 Send chunk of a text/image value to the server. More...
 
void dbrecftos (const char filename[])
 Record to a file all SQL commands sent to the server. More...
 
int dbtds (DBPROCESS *dbproc)
 
const char * dbversion ()
 See which version of db-lib is in use. More...
 
const char * dbmonthname (DBPROCESS *dbproc, char *language, int monthnum, DBBOOL shortform)
 Get name of a month, in some human language. More...
 
char * dbchange (DBPROCESS *dbproc)
 See if a command caused the current database to change. More...
 
char * dbname (DBPROCESS *dbproc)
 Get name of current database. More...
 
char * dbservcharset (DBPROCESS *dbproc)
 Get syscharset name of the server character set. More...
 
RETCODE dbsqlsend (DBPROCESS *dbproc)
 Transmit the command buffer to the server. More...
 
DBINT dbaltutype (DBPROCESS *dbproc, int computeid, int column)
 Get user-defined datatype of a compute column. More...
 
DBINT dbaltlen (DBPROCESS *dbproc, int computeid, int column)
 Get size of data in compute column. More...
 
DBINT dbfirstrow (DBPROCESS *dbproc)
 See if a server response has arrived. More...
 
DBINT dblastrow (DBPROCESS *dbproc)
 
int dbiordesc (DBPROCESS *dbproc)
 
int dbiowdesc (DBPROCESS *dbproc)
 
DBBOOL dbisavail (DBPROCESS *dbproc)
 
void dbsetavail (DBPROCESS *dbproc)
 
RETCODE dbstrbuild (DBPROCESS *dbproc, char *charbuf, int bufsize, char *text, char *formats,...)
 Build a printable string from text containing placeholders for variables. More...
 
void copy_data_to_host_var (DBPROCESS *dbproc, TDS_SERVER_TYPE srctype, const BYTE *src, DBINT srclen, BYTE *dest, DBINT destlen, int bindtype, DBINT *indicator)
 
int dbperror (DBPROCESS *dbproc, DBINT msgno, long errnum,...)
 

Variables

MHANDLEFUNC _dblib_msg_handler = NULL
 
EHANDLEFUNC _dblib_err_handler = default_err_handler
 
static DBLIBCONTEXT g_dblib_ctx
 
static tds_mutex dblib_mutex = TDS_MUTEX_INITIALIZER
 
static int g_dblib_version
 
static const DBBIT null_BIT = 0
 
static const DBTINYINT null_TINYINT = 0
 
static const DBSMALLINT null_SMALLINT = 0
 
static const DBINT null_INT = 0
 
static const DBBIGINT null_BIGINT = 0
 
static const DBFLT8 null_FLT8 = 0
 
static const DBREAL null_REAL = 0
 
static const DBCHAR null_CHAR = '\0'
 
static const DBVARYCHAR null_VARYCHAR = { 0, {0} }
 
static const DBDATETIME null_DATETIME = { 0, 0 }
 
static const DBDATETIME4 null_SMALLDATETIME = { 0, 0 }
 
static const DBMONEY null_MONEY = { 0, 0 }
 
static const DBMONEY4 null_SMALLMONEY = {0}
 
static const DBNUMERIC null_NUMERIC = { 0, 0, {0} }
 
static const TDS_DATETIMEALL null_DATETIMEALL = { 0, 0, 0, 0 }
 
static NULLREP default_null_representations [MAXBINDTYPES]
 
static const char *const opttext [DBNUMOPTIONS]
 
static const DBLIB_ERROR_MESSAGE dblib_error_messages []
 

Detailed Description

Main implementation file for db-lib.

Definition in file dblib.c.

Typedef Documentation

◆ DBLIB_ERROR_MESSAGE

◆ DBLIBCONTEXT

typedef struct dblib_context DBLIBCONTEXT

Function Documentation

◆ _dbcoldata()

static BYTE * _dbcoldata ( TDSCOLUMN colinfo)
static

◆ _dbnullable()

static DBINT _dbnullable ( DBPROCESS dbproc,
int  column 
)
static

◆ _dbprdate()

static char * _dbprdate ( char *  timestr)
static

Definition at line 7369 of file dblib.c.

References assert, and NULL.

Referenced by tdsdbopen().

◆ _dbresults()

static RETCODE _dbresults ( DBPROCESS dbproc)
static

◆ _get_printable_size()

static int _get_printable_size ( TDSCOLUMN colinfo)
static

◆ copy_data_to_host_var() [1/2]

void copy_data_to_host_var ( DBPROCESS ,
TDS_SERVER_TYPE  ,
const BYTE ,
int  ,
BYTE ,
DBINT  ,
int  ,
DBINT  
)

◆ copy_data_to_host_var() [2/2]

void copy_data_to_host_var ( DBPROCESS dbproc,
TDS_SERVER_TYPE  srctype,
const BYTE src,
DBINT  srclen,
BYTE dest,
DBINT  destlen,
int  bindtype,
DBINT indicator 
)

◆ db_env_chg()

static void db_env_chg ( TDSSOCKET tds,
int  type,
char *  oldval,
char *  newval 
)
static

◆ dbacolptr()

static TDSCOLUMN* dbacolptr ( DBPROCESS dbproc,
int  computeid,
int  column,
int  is_bind 
)
static

◆ dbbindtype()

static int dbbindtype ( int  datatype)
static

◆ dbcmdrow()

RETCODE dbcmdrow ( DBPROCESS dbproc)

◆ dbcolinfo()

RETCODE dbcolinfo ( DBPROCESS dbproc,
CI_TYPE  type,
DBINT  column,
DBINT  computeid,
DBCOL pdbcol 
)

Get a bunch of column attributes with a single call (Microsoft-compatibility feature).

Parameters
dbproccontains all information needed by db-lib to manage communications with the server.
typemust be CI_REGULAR or CI_ALTERNATE (CI_CURSOR is defined by the vendor, but is not yet implemented).
columnNth in the result set, starting from 1.
computeid(ignored)
pdbcoladdress of structure to be populated by this function.
Returns
SUCCEED or FAIL.
See also
dbcolbrowse(), dbqual(), dbtabbrowse(), dbtabcount(), dbtabname(), dbtabsource(), dbtsnewlen(), dbtsnewval(), dbtsput().

Definition at line 3054 of file dblib.c.

References _dbnullable(), DBCOL::ActualName, CHECK_NULP, CI_ALTERNATE, CI_REGULAR, column, tds_column::column_identity, tds_column::column_name, tds_column::column_nullable, tds_column::column_prec, tds_column::column_scale, tds_column::column_type, tds_column::column_writeable, tds_socket::comp_info, dbaltlen(), dbalttype(), dbaltutype(), dbcollen(), dbcolname(), dbcolptr(), dbcoltype(), dbcoltypeinfo(), dbcolutype(), dbproc, dbvarylen(), FAIL, FALSE, i, DBCOL::Identity, info, is_nullable_type, DBCOL::MaxLength, DBCOL::Name, DBCOL::Null, tds_socket::num_comp_info, dbtypeinfo::precision, DBCOL::Precision, dbtypeinfo::scale, DBCOL::Scale, strlcpy, SUCCEED, tds_column::table_name, DBCOL::TableName, TDS_DBG_FUNC, tds_dstr_cstr(), tds_dblib_dbprocess::tds_socket, tdsdump_log, TRUE, DBCOL::Type, DBCOL::Updatable, DBCOL::UserType, and DBCOL::VarLength.

◆ dbcolptr()

static TDSCOLUMN* dbcolptr ( DBPROCESS dbproc,
int  column 
)
static

◆ dbcurcmd()

int dbcurcmd ( DBPROCESS dbproc)

Definition at line 6263 of file dblib.c.

References CHECK_PARAMETER, dbproc, SYBENULL, TDS_DBG_FUNC, and tdsdump_log.

◆ dbcurrow()

DBINT dbcurrow ( DBPROCESS dbproc)

Definition at line 6229 of file dblib.c.

References CHECK_PARAMETER, dbproc, SYBENULL, TDS_DBG_FUNC, and tdsdump_log.

◆ dbdead()

DBBOOL dbdead ( DBPROCESS dbproc)

◆ dbgetnull()

RETCODE dbgetnull ( DBPROCESS dbproc,
int  bindtype,
int  varlen,
BYTE varaddr 
)

◆ dbiordesc()

int dbiordesc ( DBPROCESS dbproc)

◆ dbiowdesc()

int dbiowdesc ( DBPROCESS dbproc)

◆ dbisavail()

DBBOOL dbisavail ( DBPROCESS dbproc)

◆ dblastrow()

DBINT dblastrow ( DBPROCESS dbproc)

◆ dblib_add_connection()

static int dblib_add_connection ( DBLIBCONTEXT ctx,
TDSSOCKET tds 
)
static

Definition at line 212 of file dblib.c.

References ctx, dbperror(), i, tds, TDS_DBG_FUNC, tds_get_parent, and tdsdump_log.

Referenced by tdsdbopen().

◆ dblib_bound_type()

static TDS_SERVER_TYPE dblib_bound_type ( int  bindtype)
static

◆ dblib_coltype()

static int dblib_coltype ( TDSCOLUMN colinfo)
static

◆ dblib_datecrack()

static RETCODE dblib_datecrack ( DBPROCESS dbproc,
BOOL  nano_precision,
DBDATEREC output,
int  type,
const void *  data 
)
static

◆ dblib_del_connection()

static void dblib_del_connection ( DBLIBCONTEXT ctx,
TDSSOCKET tds 
)
static

Definition at line 231 of file dblib.c.

References ctx, i, NULL, tds, TDS_DBG_FUNC, and tdsdump_log.

◆ dblib_get_tds_ctx()

static TDSCONTEXT* dblib_get_tds_ctx ( void  )
static

◆ dblib_release_tds_ctx()

static void dblib_release_tds_ctx ( int  count)
static

◆ dbnextrow()

STATUS dbnextrow ( DBPROCESS dbproc)

◆ dbperror()

int dbperror ( DBPROCESS dbproc,
DBINT  msgno,
long  errnum,
  ... 
)

◆ dbrows()

RETCODE dbrows ( DBPROCESS dbproc)

◆ dbrowtype()

STATUS dbrowtype ( DBPROCESS dbproc)

◆ dbsetavail()

void dbsetavail ( DBPROCESS dbproc)

◆ dbsetlbool()

RETCODE dbsetlbool ( LOGINREC login,
int  value,
int  which 
)

◆ dbsetllong()

RETCODE dbsetllong ( LOGINREC login,
long  value,
int  which 
)

◆ dbsetlname()

RETCODE dbsetlname ( LOGINREC login,
const char *  value,
int  which 
)

◆ dbstring_assign()

static RETCODE dbstring_assign ( DBSTRING **  dbstrp,
const char *  p 
)
static

Definition at line 1033 of file dblib.c.

References dbstring_concat(), and dbstring_free().

Referenced by init_dboptions().

◆ dbstring_concat()

static RETCODE dbstring_concat ( DBSTRING **  dbstrp,
const char *  p 
)
static

Definition at line 1008 of file dblib.c.

References dbperror(), FAIL, NULL, SUCCEED, SYBEMEM, tds_new, and TDS_ZERO_FREE.

Referenced by dbstring_assign().

◆ dbstring_free()

static void dbstring_free ( DBSTRING **  dbstrp)
static

Definition at line 989 of file dblib.c.

References free(), next(), NULL, dbstring::strnext, and dbstring::strtext.

Referenced by dbstring_assign().

◆ dbstring_get()

static char* dbstring_get ( DBSTRING dbstr)
static

Definition at line 1074 of file dblib.c.

References dbperror(), dbstring_length(), len, next(), NULL, SYBEMEM, and tds_new.

◆ dbstring_getchar()

static int dbstring_getchar ( DBSTRING dbstr,
ssize_t  i 
)
static

Definition at line 1056 of file dblib.c.

References i, NULL, dbstring::strnext, dbstring::strtext, and dbstring::strtotlen.

◆ dbstring_length()

static DBINT dbstring_length ( DBSTRING dbstr)
static

Definition at line 1042 of file dblib.c.

References len, next(), and NULL.

Referenced by dbstring_get().

◆ dbtds()

int dbtds ( DBPROCESS dbproc)

◆ default_err_handler()

static int default_err_handler ( DBPROCESS dbproc,
int  severity,
int  dberr,
int  oserr,
char *  dberrstr,
char *  oserrstr 
)
static

◆ init_dboptions()

static DBOPTION* init_dboptions ( void  )
static

◆ prdbresults_state()

static const char* prdbresults_state ( int  retcode)
static

◆ prdbretcode()

static const char* prdbretcode ( RETCODE  retcode)
static

Definition at line 1611 of file dblib.c.

References BUF_FULL, FAIL, NO_MORE_RESULTS, NO_MORE_ROWS, REG_ROW, and SUCCEED.

Referenced by dbnextrow().

◆ prresult_type()

static const char* prresult_type ( int  result_type)
static

◆ prretcode()

static const char* prretcode ( int  retcode)
static

Definition at line 1626 of file dblib.c.

References TDS_CANCELLED, TDS_FAIL, TDS_NO_MORE_RESULTS, and TDS_SUCCESS.

Referenced by _dbresults().

◆ tds_prdatatype()

static const char * tds_prdatatype ( int  datatype_token)
static

◆ tdsdbopen()

DBPROCESS* tdsdbopen ( LOGINREC login,
const char *  server,
int  msdblib 
)

Variable Documentation

◆ _dblib_err_handler

EHANDLEFUNC _dblib_err_handler = default_err_handler

Definition at line 165 of file dblib.c.

◆ _dblib_msg_handler

MHANDLEFUNC _dblib_msg_handler = NULL

Definition at line 164 of file dblib.c.

◆ dblib_error_messages

const DBLIB_ERROR_MESSAGE dblib_error_messages[]
static

Definition at line 7800 of file dblib.c.

Referenced by dbperror().

◆ dblib_mutex

tds_mutex dblib_mutex = TDS_MUTEX_INITIALIZER
static

◆ default_null_representations

NULLREP default_null_representations[MAXBINDTYPES]
static

Definition at line 429 of file dblib.c.

Referenced by dbgetnull(), and tdsdbopen().

◆ g_dblib_ctx

DBLIBCONTEXT g_dblib_ctx
static

◆ g_dblib_version

int g_dblib_version
static
Initial value:
=
#define DBVERSION_UNKNOWN
DBVERSION_xxx are used with dbsetversion()
Definition: sybdb.h:72

Definition at line 195 of file dblib.c.

◆ null_BIGINT

const DBBIGINT null_BIGINT = 0
static

Definition at line 415 of file dblib.c.

◆ null_BIT

const DBBIT null_BIT = 0
static

Definition at line 411 of file dblib.c.

◆ null_CHAR

const DBCHAR null_CHAR = '\0'
static

Definition at line 419 of file dblib.c.

◆ null_DATETIME

const DBDATETIME null_DATETIME = { 0, 0 }
static

Definition at line 422 of file dblib.c.

◆ null_DATETIMEALL

const TDS_DATETIMEALL null_DATETIMEALL = { 0, 0, 0, 0 }
static

Definition at line 427 of file dblib.c.

◆ null_FLT8

const DBFLT8 null_FLT8 = 0
static

Definition at line 416 of file dblib.c.

◆ null_INT

const DBINT null_INT = 0
static

Definition at line 414 of file dblib.c.

◆ null_MONEY

const DBMONEY null_MONEY = { 0, 0 }
static

Definition at line 424 of file dblib.c.

◆ null_NUMERIC

const DBNUMERIC null_NUMERIC = { 0, 0, {0} }
static

Definition at line 426 of file dblib.c.

◆ null_REAL

const DBREAL null_REAL = 0
static

Definition at line 417 of file dblib.c.

◆ null_SMALLDATETIME

const DBDATETIME4 null_SMALLDATETIME = { 0, 0 }
static

Definition at line 423 of file dblib.c.

◆ null_SMALLINT

const DBSMALLINT null_SMALLINT = 0
static

Definition at line 413 of file dblib.c.

◆ null_SMALLMONEY

const DBMONEY4 null_SMALLMONEY = {0}
static

Definition at line 425 of file dblib.c.

◆ null_TINYINT

const DBTINYINT null_TINYINT = 0
static

Definition at line 412 of file dblib.c.

◆ null_VARYCHAR

const DBVARYCHAR null_VARYCHAR = { 0, {0} }
static

Definition at line 420 of file dblib.c.

◆ opttext

const char* const opttext[DBNUMOPTIONS]
static

Definition at line 1100 of file dblib.c.

Referenced by init_dboptions().

Modified on Sat Jun 08 14:24:18 2024 by modify_doxy.py rev. 669887