NCBI C++ ToolKit
Classes | Macros | Typedefs | Functions | Variables
bcp.c File Reference
#include "common.h"
#include <odbcss.h>
#include <freetds/test_assert.h>
+ Include dependency graph for bcp.c:

Go to the source code of this file.

Go to the SVN repository for this file.

Classes

struct  prefixed_int
 
struct  prefixed_str
 

Macros

#define TDSODBC_BCP
 
#define VARCHAR_BIND(x)
 
#define INT_BIND(x)    bcp_bind( odbc_conn, (unsigned char *) (prefixlen == 0 ? (void*)&x.value : &x), prefixlen, SQL_VARLEN_DATA, NULL, termlen, BCP_TYPE_SQLINT4, col++ )
 
#define NULL_BIND(x, type)    bcp_bind( odbc_conn, (unsigned char *) (prefixlen == 0 ? (void*)&x.value : &null_prefix), prefixlen, prefixlen == 0 ? SQL_NULL_DATA : SQL_VARLEN_DATA, NULL, termlen, type, col++ )
 

Typedefs

typedef char bcp_init_char_t
 

Functions

static void cleanup (void)
 
static void init (void)
 
static void test_bind (int prefixlen)
 
static void set_attr (void)
 
static void report_bcp_error (const char *errmsg, int line, const char *file)
 
static void normal_inserts (int prefixlen)
 
static void normal_select (void)
 
static void special_inserts (void)
 
static void special_select (void)
 
int main (int argc, char *argv[])
 

Variables

static struct prefixed_int not_null_bit = {4, 1}
 
static struct prefixed_str not_null_char = {64, "a char"}
 
static struct prefixed_str not_null_varchar = {64, "a varchar"}
 
static struct prefixed_str not_null_datetime = {64, "2003-12-17 15:44:00.000"}
 
static struct prefixed_str not_null_smalldatetime = {64, "2003-12-17 15:44:00"}
 
static struct prefixed_str not_null_money = {64, "12.341"}
 
static struct prefixed_str not_null_smallmoney = {64, "12.34"}
 
static struct prefixed_str not_null_float = {64, "12.34"}
 
static struct prefixed_str not_null_real = {64, "12.34"}
 
static struct prefixed_str not_null_decimal = {64, "12.34"}
 
static struct prefixed_str not_null_numeric = {64, "12.34"}
 
static struct prefixed_int not_null_int = {4, 1234}
 
static struct prefixed_int not_null_smallint = {4, 1234}
 
static struct prefixed_int not_null_tinyint = {4, 123}
 
static struct prefixed_str not_null_nvarchar = {64, "a wide var"}
 
static ODBCINT64 null_prefix = -1
 
static const char * expected []
 
static const int total_cols = 29
 
static const char * expected_special []
 
static int tds_version
 
static const char table_name [] = "all_types_bcp_unittest"
 

Macro Definition Documentation

◆ INT_BIND

#define INT_BIND (   x)     bcp_bind( odbc_conn, (unsigned char *) (prefixlen == 0 ? (void*)&x.value : &x), prefixlen, SQL_VARLEN_DATA, NULL, termlen, BCP_TYPE_SQLINT4, col++ )

Definition at line 147 of file bcp.c.

◆ NULL_BIND

#define NULL_BIND (   x,
  type 
)     bcp_bind( odbc_conn, (unsigned char *) (prefixlen == 0 ? (void*)&x.value : &null_prefix), prefixlen, prefixlen == 0 ? SQL_NULL_DATA : SQL_VARLEN_DATA, NULL, termlen, type, col++ )

Definition at line 150 of file bcp.c.

◆ TDSODBC_BCP

#define TDSODBC_BCP

Definition at line 2 of file bcp.c.

◆ VARCHAR_BIND

#define VARCHAR_BIND (   x)
Value:
(unsigned char *) (prefixlen == 0 ? (void*)&x.value : &x), \
prefixlen, (SQLINTEGER) strlen(x.value), NULL, termlen, \
BCP_TYPE_SQLVARCHAR, col++ )
HDBC odbc_conn
Definition: common.c:32
#define NULL
Definition: ncbistd.hpp:225
RETCODE bcp_bind(DBPROCESS *dbproc, BYTE *varaddr, int prefixlen, DBINT varlen, BYTE *terminator, int termlen, int db_vartype, int table_column)
Bind a program host variable to a database column.
Definition: bcp.c:2032
long SQLINTEGER
Definition: sqltypes.h:176

Definition at line 141 of file bcp.c.

Typedef Documentation

◆ bcp_init_char_t

typedef char bcp_init_char_t

Definition at line 10 of file bcp.c.

Function Documentation

◆ cleanup()

static void cleanup ( void  )
static

Definition at line 62 of file bcp.c.

References odbc_command.

Referenced by init(), and main().

◆ init()

static void init ( void  )
static

Definition at line 69 of file bcp.c.

References cleanup(), odbc_command, and tds_version.

Referenced by main().

◆ main()

int main ( int  argc,
char *  argv[] 
)

◆ normal_inserts()

static void normal_inserts ( int  prefixlen)
static

Definition at line 297 of file bcp.c.

References bcp_batch(), bcp_done(), bcp_init(), bcp_sendrow(), FAIL, i, NULL, odbc_conn, report_bcp_error(), T, table_name, and test_bind().

Referenced by main().

◆ normal_select()

static void normal_select ( void  )
static

◆ report_bcp_error()

static void report_bcp_error ( const char *  errmsg,
int  line,
const char *  file 
)
static

Definition at line 244 of file bcp.c.

References file, NULL, odbc_report_error(), and odbc_stmt.

Referenced by normal_inserts(), and special_inserts().

◆ set_attr()

static void set_attr ( void  )
static

Definition at line 238 of file bcp.c.

References odbc_conn, and SQLSetConnectAttr.

Referenced by main().

◆ special_inserts()

static void special_inserts ( void  )
static

◆ special_select()

static void special_select ( void  )
static

◆ test_bind()

static void test_bind ( int  prefixlen)
static

Variable Documentation

◆ expected

const char* expected[]
static
Initial value:
= {
"1",
"a char ","a varchar","2003-12-17 15:44:00.000","2003-12-17 15:44:00",
"12.3410","12.3400","12.34","12.3400002","12.34","12.34",
"1234","1234","123",
"a wide var",
}

Definition at line 42 of file bcp.c.

Referenced by normal_select().

◆ expected_special

const char* expected_special[]
static
Initial value:
= {
"2015-03-14 15:26:53.000",
"2015-03-14 15:26:53.589793",
"3.141593000",
"3.141593",
"",
}

Definition at line 51 of file bcp.c.

Referenced by special_select().

◆ not_null_bit

struct prefixed_int not_null_bit = {4, 1}
static

Definition at line 10 of file bcp.c.

Referenced by special_inserts(), and test_bind().

◆ not_null_char

struct prefixed_str not_null_char = {64, "a char"}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_datetime

struct prefixed_str not_null_datetime = {64, "2003-12-17 15:44:00.000"}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_decimal

struct prefixed_str not_null_decimal = {64, "12.34"}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_float

struct prefixed_str not_null_float = {64, "12.34"}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_int

struct prefixed_int not_null_int = {4, 1234}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_money

struct prefixed_str not_null_money = {64, "12.341"}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_numeric

struct prefixed_str not_null_numeric = {64, "12.34"}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_nvarchar

struct prefixed_str not_null_nvarchar = {64, "a wide var"}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_real

struct prefixed_str not_null_real = {64, "12.34"}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_smalldatetime

struct prefixed_str not_null_smalldatetime = {64, "2003-12-17 15:44:00"}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_smallint

struct prefixed_int not_null_smallint = {4, 1234}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_smallmoney

struct prefixed_str not_null_smallmoney = {64, "12.34"}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_tinyint

struct prefixed_int not_null_tinyint = {4, 123}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_varchar

struct prefixed_str not_null_varchar = {64, "a varchar"}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ null_prefix

ODBCINT64 null_prefix = -1
static

Definition at line 40 of file bcp.c.

◆ table_name

const char table_name[] = "all_types_bcp_unittest"
static

Definition at line 255 of file bcp.c.

Referenced by main(), and normal_inserts().

◆ tds_version

int tds_version
static

Definition at line 59 of file bcp.c.

Referenced by init(), and main().

◆ total_cols

const int total_cols = 29
static

Definition at line 49 of file bcp.c.

Referenced by normal_select().

Modified on Sun Jun 23 05:20:06 2024 by modify_doxy.py rev. 669887