src/dbapi/driver/ftds64/freetds/dblib/bcp.c File Reference


Detailed Description

Implementation of db-lib bulk copy functions.

Definition in file bcp.c.

#include <stdio.h>
#include <assert.h>
#include "tds.h"
#include "tdsiconv.h"
#include "tdsconvert.h"
#include "replacements.h"
#include "sybfront.h"
#include "sybdb.h"
#include "syberror.h"
#include "dblib.h"

Include dependency graph for bcp.c:

Go to the source code of this file.

Classes

struct  _pbcb

Defines

#define HOST_COL_CONV_ERROR   1
#define HOST_COL_NULL_ERROR   2
#define BCP_REC_FETCH_DATA   1
#define BCP_REC_NOFETCH_DATA   0
#define MAX(a, b)   ( (a) > (b) ? (a) : (b) )
#define fseeko(f, o, w)   fseek(f,o,w)
#define ftello(f)   ftell(f)
#define SYBETDSVER   -100

Typedefs

typedef _pbcb TDS_PBCB
typedef long offset_type

Functions

 TDS_RCSID (var,"$Id: bcp.c 174668 2009-10-29 19:44:31Z ivanovp $")
static RETCODE _bcp_send_bcp_record (DBPROCESS *dbproc, int behaviour)
static RETCODE _bcp_build_bulk_insert_stmt (TDSSOCKET *tds, TDS_PBCB *clause, TDSCOLUMN *bcpcol, int first)
static RETCODE _bcp_free_storage (DBPROCESS *dbproc)
static void _bcp_free_columns (DBPROCESS *dbproc)
static RETCODE _bcp_get_col_data (DBPROCESS *dbproc, TDSCOLUMN *bindcol)
static RETCODE _bcp_send_colmetadata (DBPROCESS *dbproc)
static RETCODE _bcp_start_copy_in (DBPROCESS *dbproc)
static RETCODE _bcp_start_new_batch (DBPROCESS *dbproc)
static int rtrim (char *istr, int ilen)
static offset_type _bcp_measure_terminated_field (FILE *hostfile, BYTE *terminator, int term_len)
static RETCODE _bcp_read_hostfile (DBPROCESS *dbproc, FILE *hostfile, int *row_error)
static int _bcp_readfmt_colinfo (DBPROCESS *dbproc, char *buf, BCP_HOSTCOLINFO *ci)
static RETCODE _bcp_get_term_var (BYTE *pdata, BYTE *term, int term_len)
RETCODE bcp_init (DBPROCESS *dbproc, const char *tblname, const char *hfile, const char *errfile, int direction)
 Prepare for bulk copy operation on a table.
RETCODE bcp_collen (DBPROCESS *dbproc, DBINT varlen, int table_column)
 Set the length of a host variable to be written to a table.
RETCODE bcp_columns (DBPROCESS *dbproc, int host_colcount)
 Indicate how many columns are to be found in the datafile.
RETCODE bcp_colfmt (DBPROCESS *dbproc, int host_colnum, int host_type, int host_prefixlen, DBINT host_collen, const BYTE *host_term, int host_termlen, int table_colnum)
 Specify the format of a datafile prior to writing to a table.
RETCODE bcp_colfmt_ps (DBPROCESS *dbproc, int host_colnum, int host_type, int host_prefixlen, DBINT host_collen, BYTE *host_term, int host_termlen, int table_colnum, DBTYPEINFO *typeinfo)
 Specify the format of a host file for bulk copy purposes, with precision and scale support for numeric and decimal columns.
RETCODE bcp_control (DBPROCESS *dbproc, int field, DBINT value)
 Set BCP options for uploading a datafile.
RETCODE bcp_options (DBPROCESS *dbproc, int option, BYTE *value, int valuelen)
 Set "hints" for uploading a file.
RETCODE bcp_colptr (DBPROCESS *dbproc, BYTE *colptr, int table_column)
 Override bcp_bind() by pointing to a different host variable.
DBBOOL bcp_getl (LOGINREC *login)
 See if BCP_SETL() was used to set the LOGINREC for BCP work.
static RETCODE _bcp_exec_out (DBPROCESS *dbproc, DBINT *rows_copied)
static RETCODE _bcp_check_eof (DBPROCESS *dbproc, FILE *file, int icol)
static int _bcp_add_fixed_columns (DBPROCESS *dbproc, int behaviour, BYTE *rowbuffer, int start)
static int _bcp_add_variable_columns (DBPROCESS *dbproc, int behaviour, BYTE *rowbuffer, int start, int *var_cols)
RETCODE bcp_sendrow (DBPROCESS *dbproc)
 Write data in host variables to the table.
static RETCODE _bcp_exec_in (DBPROCESS *dbproc, DBINT *rows_copied)
RETCODE bcp_exec (DBPROCESS *dbproc, DBINT *rows_copied)
 Write a datafile to a table.
static char * _bcp_fgets (char *buffer, size_t size, FILE *f)
RETCODE bcp_readfmt (DBPROCESS *dbproc, char *filename)
 Read a format definition file.
RETCODE bcp_writefmt (DBPROCESS *dbproc, char *filename)
 Write a format definition file.
RETCODE bcp_moretext (DBPROCESS *dbproc, DBINT size, BYTE *text)
 Write some text or image data to the server.
DBINT bcp_batch (DBPROCESS *dbproc)
 Commit a set of rows to the table.
DBINT bcp_done (DBPROCESS *dbproc)
 Conclude the transfer of data from program variables.
RETCODE bcp_bind (DBPROCESS *dbproc, BYTE *varaddr, int prefixlen, DBINT varlen, BYTE *terminator, int termlen, int vartype, int table_column)
 Bind a program host variable to a database column.


Define Documentation

#define BCP_REC_FETCH_DATA   1
 

Definition at line 55 of file bcp.c.

Referenced by _bcp_add_fixed_columns(), _bcp_add_variable_columns(), _bcp_send_bcp_record(), and bcp_sendrow().

#define BCP_REC_NOFETCH_DATA   0
 

Definition at line 56 of file bcp.c.

#define fseeko f,
o,
 )     fseek(f,o,w)
 

Definition at line 75 of file bcp.c.

Referenced by _bcp_exec_in(), and _bcp_measure_terminated_field().

#define ftello  )     ftell(f)
 

Definition at line 76 of file bcp.c.

Referenced by _bcp_exec_in(), and _bcp_measure_terminated_field().

#define HOST_COL_CONV_ERROR   1
 

Definition at line 52 of file bcp.c.

Referenced by _bcp_exec_in().

#define HOST_COL_NULL_ERROR   2
 

Definition at line 53 of file bcp.c.

Referenced by _bcp_exec_in().

#define MAX a,
 )     ( (a) > (b) ? (a) : (b) )
 

Definition at line 59 of file bcp.c.

#define SYBETDSVER   -100
 

Referenced by bcp_init().


Typedef Documentation

typedef long offset_type
 

Definition at line 77 of file bcp.c.

typedef struct _pbcb TDS_PBCB
 


Function Documentation

static RETCODE _bcp_check_eof DBPROCESS dbproc,
FILE *  file,
int  icol
[static]
 

Definition at line 1068 of file bcp.c.

References dbperror(), errno, FAIL, NO_MORE_ROWS, SYBEBCRE, SYBEBEOF, TDS_DBG_FUNC, and tdsdump_log.

TDS_RCSID var  ,
"$Id: bcp.c 174668 2009-10-29 19:44:31Z ivanovp $" 
 


Generated on Wed Dec 9 07:44:22 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Wed Dec 09 08:18:17 2009 by modify_doxy.py rev. 173732