A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/ftds14_2freetds_2tds_2bulk_8c_source.html below:

NCBI C++ ToolKit: src/dbapi/driver/ftds14/freetds/tds/bulk.c Source File

43 #include <freetds/tds.h> 44 #include <freetds/checks.h> 45 #include <freetds/bytes.h> 46 #include <freetds/iconv.h> 47 #include <freetds/stream.h> 48 #include <freetds/convert.h> 50 #include <freetds/replacements.h> 54 #define MAX(a,b) ( (a) > (b) ? (a) : (b) ) 58 #define MIN(a,b) ( (a) < (b) ? (a) : (b) ) 78  int offset

,

unsigned char

* rowbuffer,

int

start);

110

fmt =

"SET FMTONLY ON select * from %s SET FMTONLY OFF"

;

112

fmt =

"SET FMTONLY ON %s SET FMTONLY OFF"

;

235  char

column_type[40];

246  if

(clause->

cb

< strlen(clause->

pb

)

248

+ strlen(column_type)

249

+ ((

first

) ? 2u : 4u)) {

250  char

*temp =

tds_new

(

char

, 2 * clause->

cb

);

256

strcpy(temp, clause->

pb

);

274 static const char

*

uc_str

(

const char

* s)

277  size_t n

= strcspn(s,

"abcdefghijklmnopqrstuvwxyz"

);

278  if

(s[

n

] ==

'\0'

) {

283  for

(

i

= 0;

i

<

n

;

i

++) {

302  int i

, firstcol, erc;

306  char

clause_buffer[4096] = { 0 };

307  bool

triggers_checked = !bcpinfo->

hint

;

309

colclause.

pb

= clause_buffer;

310

colclause.

cb

=

sizeof

(clause_buffer);

325  if

( !triggers_checked ) {

328  if

(strstr(uc_hint,

"FIRE_TRIGGERS"

)) {

331  if

(uc_hint != bcpinfo->

hint

) {

332  free

((

char

*)uc_hint);

334

triggers_checked =

true

;

344  if

(bcpinfo->

hint

) {

345  if

(

asprintf

(&hint,

" with (%s)"

, bcpinfo->

hint

) < 0)

383  if

(start_col == 0) {

389  unsigned char

*save_data;

393  bool

has_text =

false

;

410

rc = get_col_data(bcpinfo, bindcol,

offset

);

428

null_error(bcpinfo,

i

,

offset

);

433

}

else if

(has_text) {

438

memset(&blob, 0,

sizeof

(blob));

467  int

var_cols_written = 0;

471

memset(record,

'\0'

, old_record_size);

482

row_sz_pos = row_pos;

491  if

(var_cols_written) {

493

record[0] = var_cols_written;

509  if

(start_col == 0) {

582  int

start_col = bcpinfo->

next_col

;

585  tds

, bcpinfo, get_col_data, null_error,

offset

);

634 #ifdef WORDS_BIGENDIAN 651  int offset

,

unsigned char

* rowbuffer,

int

start)

657  int

bitleft = 0, bitpos = 0;

663

bcpinfo, get_col_data, null_error,

offset

, rowbuffer, start);

692

null_error(bcpinfo,

i

,

offset

);

699

memcpy(&rowbuffer[row_pos], num->

array

, cpbytes);

705

rowbuffer[bitpos] = 0;

708

rowbuffer[bitpos] |= 256 >> bitleft;

720

memset(rowbuffer + row_pos + cpbytes,

' '

, column_size - cpbytes);

723

row_pos += column_size;

746  unsigned int i

, row_pos;

747  unsigned int

ncols = 0;

773  for

(

i

= bcpinfo->

next_col

; i < bcpinfo->bindinfo->num_cols;

i

++) {

774  unsigned int

cpbytes = 0;

805

null_error(bcpinfo,

i

,

offset

);

817

memcpy(&rowbuffer[row_pos], num->

array

, cpbytes);

822

rowbuffer[row_pos] =

' '

;

863  unsigned int

pfx_top =

offsets

[ncols] / 256;

872  unsigned int

n_pfx = 1;

874  for

(

i

= 0;

i

<= ncols ; ++

i

)

875  if

((

offsets

[

i

] / 256u) < pfx_top)

883  for

(

i

=0;

i

<= ncols;

i

++)

884

*poff++ =

offsets

[ncols-

i

] & 0xFF;

885

row_pos = (

unsigned int

)(poff - rowbuffer);

893  return

ncols == 0? start : row_pos;

936  size_t

converted_len;

937  const char

*converted_name;

971  if

(!converted_name) {

986  if

(!converted_name) {

1094 #define BULKCOL(n) do {\ 1095  if (strcmp(name, #n) == 0) \ 1096  return BULKCOL_ ## n; \ 1129  for

(

i

= 0;

i

< res_info->

num_cols

; ++

i

, ++syb_info) {

1134

src = (

unsigned char

*) ((

TDSBLOB

*)src)->textvalue;

1136  while

( !syb_info->

dflt

) {

1152  bool

row_match =

false

;

1173  for

(icol = 0; icol < res_info->

num_cols

; ++icol) {

1178

cols_pos[scol] = icol;

1179

col_flags |= 1 << scol;

1189 #if ENABLE_EXTRA_CHECKS 1206

col_flags |= 1 << icol;

1207

cols_values[icol] = dres.

i

;

1237  if

(colinfo->

dflt

) {

1270

ret = get_col_data(bulk, bcpcol,

offset

);

1279  if

((nullind !=

NULL

&& nullind[

offset

] == -1)

1280

|| !syb_info->

dflt

) {

1321  int

fixed_col_len_tot = 0;

1322  int

variable_col_len_tot = 0;

1323  int

column_bcp_data_size = 0;

1324  int

bcp_record_size = 0;

1358

column_bcp_data_size = 16;

1371

variable_col_len_tot += column_bcp_data_size;

1374

fixed_col_len_tot += column_bcp_data_size;

1380

bcp_record_size = 4 +

1382

variable_col_len_tot +

1383

( (

int

)(variable_col_len_tot / 256 ) + 1 ) +

1421 #if defined(_WIN32) && defined(HAVE__LOCK_FILE) && defined(HAVE__UNLOCK_FILE) 1422 #define TDS_HAVE_STDIO_LOCKED 1 1423 #define flockfile(s) _lock_file(s) 1424 #define funlockfile(s) _unlock_file(s) 1425 #define getc_unlocked(s) _getc_nolock(s) 1426 #define feof_unlocked(s) _feof_nolock(s) 1429 #ifndef TDS_HAVE_STDIO_LOCKED 1430 #undef getc_unlocked 1431 #undef feof_unlocked 1434 #define getc_unlocked(s) getc(s) 1435 #define feof_unlocked(s) feof(s) 1436 #define flockfile(s) do { } while(0) 1437 #define funlockfile(s) do { } while(0) 1452  char

*p = (

char

*) ptr;

1456  return

p - (

char

*) ptr;

1458

c = getc_unlocked(s->

f

);

1468  return

p - (

char

*) ptr;

1488  r

.term_len = term_len;

1489  r

.left =

tds_new0

(

char

, term_len*3);

1494

memcpy(

r

.left + term_len,

terminator

, term_len);

1495

memcpy(

r

.left + term_len*2u,

terminator

, term_len);

1496  r

.terminator =

r

.left + term_len*2u;

1499

readed = fread(

r

.left, 1, term_len, stream);

1500  if

(readed != term_len) {

1502  if

(readed == 0 && feof(stream))

1515  if

(char_conv ==

NULL

)

1519

funlockfile(stream);

1525

*outbytes = w.

size

;

1554  "writetext bulk %s 0x%s timestamp = 0x%s%s"

,

1555

objname, textptr, timestamp, with_log ?

" with log"

:

""

);

1616  return

(bcpinfo && colinfo &&

static void cleanup(void)

#define TDS_PUT_UA2LE(ptr, val)

#define CHECK_TDS_EXTRA(tds)

static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)

#define TDS7_RESULT_TOKEN

#define is_numeric_type(x)

#define TDS_DONEPROC_RESULT

#define TDS_ROWFMT_RESULT

tds_sysdep_int32_type TDS_INT

#define TDS_PUT_BYTE(tds, v)

#define TDS_NO_MORE_RESULTS

void(* tds_bcp_null_error)(TDSBCPINFO *bulk, int index, int offset)

@ TDS_PENDING

cilent is waiting for data

@ TDS_SENDING

client would send data

@ TDS_WRITING

client is writing data

tds_sysdep_int16_type TDS_SMALLINT

#define tds_convert_string_free(original, converted)

TDSRET(* tds_bcp_get_col_data)(TDSBCPINFO *bulk, TDSCOLUMN *bcpcol, int offset)

#define tds_new0(type, n)

#define is_nullable_type(x)

@ TDS_DONE_ERROR

error occurred

tds_sysdep_uint16_type TDS_USMALLINT

#define TDS_RESIZE(p, n_elem)

tds_sysdep_uint32_type TDS_UINT

#define TDS_PUT_SMALLINT(tds, v)

#define TDS_DONEINPROC_RESULT

TDSRET tds_bcp_start_copy_in(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)

Start bulk copy to server \tds.

TDSRET tds_writetext_start(TDSSOCKET *tds, const char *objname, const char *textptr, const char *timestamp, int with_log, TDS_UINT size)

Start writing writetext request.

TDSRET tds_bcp_start(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)

Start sending BCP data to server.

TDSRET tds_bcp_fread(TDSSOCKET *tds, TDSICONV *char_conv, FILE *stream, const char *terminator, size_t term_len, char **outbuf, size_t *outbytes)

Read a data file, passing the data through iconv().

TDSRET tds_writetext_continue(TDSSOCKET *tds, const TDS_UCHAR *text, TDS_UINT size)

Send some data in the writetext request started by tds_writetext_start.

TDSRET tds_writetext_end(TDSSOCKET *tds)

Finish sending writetext data.

struct tds_file_stream TDSFILESTREAM

input stream to read a file

TDSRET tds_bcp_init(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)

Initialize BCP information.

TDSRET tds_bcp_send_record(TDSSOCKET *tds, TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset)

Send one row of data to server \tds.

TDSRET tds_bcp_done(TDSSOCKET *tds, int *rows_copied)

Tell we finished sending BCP data to server \tds.

struct tds_pbcb TDSPBCB

Holds clause buffer.

#define tds_alloc_results

#define tds_convert_stream

#define tds_connection_close

#define tds_dynamic_stream_init

#define tds_process_simple_query

#define tds_get_column_declaration

#define tds_convert_string

#define tds_numeric_bytes_per_prec

#define tds_alloc_bcp_column_data

#define tds_submit_queryf

#define tds_get_conversion_type

#define tds_process_tokens

#define TDS_PROPAGATE(rc)

static int tds5_bulk_insert_column(const char *name)

static void tds5_swap_data(const TDSCOLUMN *col, void *p)

static TDSRET tds5_send_record(TDSSOCKET *tds, TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset, int start_col)

static int tds_file_stream_read(TDSINSTREAM *stream, void *ptr, size_t len)

Reads a chunk of data from file stream checking for terminator.

static TDSRET tds7_build_bulk_insert_stmt(TDSSOCKET *tds, TDSPBCB *clause, TDSCOLUMN *bcpcol, int first)

Help to build query to be sent to server.

static TDSRET tds7_bcp_send_colmetadata(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)

Send BCP metadata to server.

static int tds5_bcp_add_variable_columns(TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset, TDS_UCHAR *rowbuffer, int start, int *pncols)

Add variable size columns to the row.

static void tds_bcp_row_free(TDSRESULTINFO *result, unsigned char *row)

Free row data allocated in the result set.

static TDSRET tds5_send_non_blobs(TDSSOCKET *tds, TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset)

static const char * uc_str(const char *s)

static int tds_bcp_is_bound(TDSBCPINFO *bcpinfo, TDSCOLUMN *colinfo)

static void tds5_read_bulk_defaults(TDSRESULTINFO *res_info, TDSBCPINFO *bcpinfo)

static int tds5_bcp_add_fixed_columns(TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset, unsigned char *rowbuffer, int start)

Add fixed size columns to the row.

static TDSRET tds5_get_col_data_or_dflt(tds_bcp_get_col_data get_col_data, TDSBCPINFO *bulk, TDSCOLUMN *bcpcol, int offset, int colnum)

static TDSRET tds5_process_insert_bulk_reply(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)

static TDSRET tds_bcp_start_insert_stmt(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)

Prepare the query to be sent to server to request BCP information \tds.

static TDSRET tds7_send_record(TDSSOCKET *tds, TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset, int start_col)

static const char * tds_dstr_cstr(DSTR *s)

Returns a C version (NUL terminated string) of dstr.

DSTR * tds_dstr_dup(DSTR *s, const DSTR *src) TDS_WUR

Duplicate a string from another dynamic string.

static size_t tds_dstr_len(DSTR *s)

Returns the length of the string in bytes.

unsigned int

A callback function used to compare two keys in a database.

static void text(MDB_val *v)

const struct ncbi::grid::netcache::search::fields::SIZE size

#define MIN(a, b)

returns smaller of a and b.

#define MAX(a, b)

returns larger of a and b.

double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)

static PCRE2_SIZE * offsets

#define row(bind, expected)

TDS_INT identity_insert_on

TDS5COLINFO * sybase_colinfo

Information about blobs (e.g.

tds_func_put_info * put_info

Send metadata column information to server.

tds_func_put_data * put_data

Send column data to server.

Metadata about columns in regular and compute rows.

TDS_TINYINT column_varint_size

size of length when reading from wire (0, 1, 2 or 4)

TDS_INT column_size

maximun size of data.

TDS_SMALLINT * column_nullbind

unsigned int column_timestamp

BCPCOLDATA * bcp_column_data

TDS_UCHAR column_collation[5]

const TDSCOLUMNFUNCS * funcs

unsigned char column_computed

TDS_TINYINT column_prec

precision for decimal/numeric

TDS_SERVER_TYPE column_type

This type can be different from wire type because conversion (e.g.

unsigned int column_identity

TDSICONV * char_conv

refers to previously allocated iconv information

unsigned int column_nullable

TDS_TINYINT column_scale

scale for decimal/numeric

unsigned char * column_data

struct tds_column::@124 on_server

TDS_CHAR * column_varaddr

TDS_INT column_cur_size

size written in variable (ie: char, text, binary).

output stream to write data to a dynamic buffer

size_t size

size of data inside buffer

input stream to read a file

const char * terminator

terminator

FILE * f

file to read from

size_t term_len

terminator length in bytes

TDSINSTREAM stream

common fields, must be the first field

char * left

buffer for store bytes readed that could be the terminator

define a stream of data used for input

int(* write)(struct tds_output_stream *stream, size_t len)

write len bytes from buffer, return <0 if error or len

char * buffer

write buffer.

unsigned int from_malloc

true is buffer came from malloc

unsigned int cb

buffer length

Hold information for any results.

unsigned char * current_row

void(* row_free)(struct tds_result_info *result, unsigned char *row)

Information for a server connection.

TDS_INT8 rows_affected

rows updated/deleted/inserted/selected, TDS_NO_COUNT if not valid

TDS_TINYINT bulk_query

true is query sent was a bulk query so we need to switch state to QUERYING

unsigned char out_flag

output buffer type

TDSRESULTINFO * current_results

Current query information.

uchar outbuf[(1000000+1000000)]

voidp calloc(uInt items, uInt size)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4