本文整理汇总了C++中DBUG_PRINT函数的典型用法代码示例。如果您正苦于以下问题:C++ DBUG_PRINT函数的具体用法?C++ DBUG_PRINT怎么用?C++ DBUG_PRINT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DBUG_PRINT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: my_fwrite
size_t my_fwrite(FILE *stream, const uchar *Buffer, size_t Count, myf MyFlags)
{
size_t writtenbytes =0;
my_off_t seekptr;
#if !defined(NO_BACKGROUND) && defined(USE_MY_STREAM)
uint errors;
#endif
DBUG_ENTER("my_fwrite");
DBUG_PRINT("my",("stream: 0x%lx Buffer: 0x%lx Count: %u MyFlags: %d",
(long) stream, (long) Buffer, (uint) Count, MyFlags));
#if !defined(NO_BACKGROUND) && defined(USE_MY_STREAM)
errors=0;
#endif
seekptr= ftell(stream);
for (;;)
{
size_t written;
if ((written = (size_t) fwrite((char*) Buffer,sizeof(char),
Count, stream)) != Count)
{
DBUG_PRINT("error",("Write only %d bytes", (int) writtenbytes));
my_errno=errno;
if (written != (size_t) -1)
{
seekptr+=written;
Buffer+=written;
writtenbytes+=written;
Count-=written;
}
#ifdef EINTR
if (errno == EINTR)
{
(void) my_fseek(stream,seekptr,MY_SEEK_SET,MYF(0));
continue;
}
#endif
#if !defined(NO_BACKGROUND) && defined(USE_MY_STREAM)
if (my_thread_var->abort)
MyFlags&= ~ MY_WAIT_IF_FULL; /* End if aborted by user */
if ((errno == ENOSPC || errno == EDQUOT) &&
(MyFlags & MY_WAIT_IF_FULL))
{
wait_for_free_space("[stream]", errors);
errors++;
(void) my_fseek(stream,seekptr,MY_SEEK_SET,MYF(0));
continue;
}
#endif
if (ferror(stream) || (MyFlags & (MY_NABP | MY_FNABP)))
{
if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))
{
my_error(EE_WRITE, MYF(ME_BELL+ME_WAITTANG),
my_filename(my_fileno(stream)),errno);
}
writtenbytes= (size_t) -1; /* Return that we got error */
break;
}
}
if (MyFlags & (MY_NABP | MY_FNABP))
writtenbytes= 0; /* Everything OK */
else
writtenbytes+= written;
break;
}
DBUG_RETURN(writtenbytes);
} /* my_fwrite */
示例2: mrn_get_partition_info
void mrn_get_partition_info(const char *table_name, uint table_name_length,
const TABLE *table, partition_element **part_elem,
partition_element **sub_elem)
{
char tmp_name[FN_LEN];
partition_info *part_info = table->part_info;
partition_element *tmp_part_elem = NULL, *tmp_sub_elem = NULL;
bool tmp_flg = FALSE, tmp_find_flg = FALSE;
MRN_DBUG_ENTER_FUNCTION();
*part_elem = NULL;
*sub_elem = NULL;
if (!part_info)
DBUG_VOID_RETURN;
if (table_name && !memcmp(table_name + table_name_length - 5, "#TMP#", 5))
tmp_flg = TRUE;
DBUG_PRINT("info", ("mroonga table_name=%s", table_name));
List_iterator<partition_element> part_it(part_info->partitions);
while ((*part_elem = part_it++))
{
if ((*part_elem)->subpartitions.elements)
{
List_iterator<partition_element> sub_it((*part_elem)->subpartitions);
while ((*sub_elem = sub_it++))
{
create_subpartition_name(tmp_name, table->s->path.str,
(*part_elem)->partition_name, (*sub_elem)->partition_name,
NORMAL_PART_NAME);
DBUG_PRINT("info", ("mroonga tmp_name=%s", tmp_name));
if (table_name && !memcmp(table_name, tmp_name, table_name_length + 1))
DBUG_VOID_RETURN;
if (
tmp_flg &&
table_name &&
*(tmp_name + table_name_length - 5) == '\0' &&
!memcmp(table_name, tmp_name, table_name_length - 5)
) {
tmp_part_elem = *part_elem;
tmp_sub_elem = *sub_elem;
tmp_flg = FALSE;
tmp_find_flg = TRUE;
}
}
} else {
create_partition_name(tmp_name, table->s->path.str,
(*part_elem)->partition_name, NORMAL_PART_NAME, TRUE);
DBUG_PRINT("info", ("mroonga tmp_name=%s", tmp_name));
if (table_name && !memcmp(table_name, tmp_name, table_name_length + 1))
DBUG_VOID_RETURN;
if (
tmp_flg &&
table_name &&
*(tmp_name + table_name_length - 5) == '\0' &&
!memcmp(table_name, tmp_name, table_name_length - 5)
) {
tmp_part_elem = *part_elem;
tmp_flg = FALSE;
tmp_find_flg = TRUE;
}
}
}
if (tmp_find_flg)
{
*part_elem = tmp_part_elem;
*sub_elem = tmp_sub_elem;
DBUG_PRINT("info", ("mroonga tmp find"));
DBUG_VOID_RETURN;
}
*part_elem = NULL;
*sub_elem = NULL;
DBUG_PRINT("info", ("mroonga no hit"));
DBUG_VOID_RETURN;
}
示例3: mrn_add_index_param
int mrn_add_index_param(MRN_SHARE *share, KEY *key_info, int i)
{
int error;
char *param_string = NULL;
#if MYSQL_VERSION_ID >= 50500
int title_length;
char *sprit_ptr[2];
char *tmp_ptr, *start_ptr;
#endif
THD *thd = current_thd;
MRN_DBUG_ENTER_FUNCTION();
#if MYSQL_VERSION_ID >= 50500
if (key_info->comment.length == 0)
{
if (share->key_tokenizer[i]) {
my_free(share->key_tokenizer[i]);
}
share->key_tokenizer[i] = mrn_my_strdup(mrn_default_tokenizer, MYF(MY_WME));
if (!share->key_tokenizer[i]) {
error = HA_ERR_OUT_OF_MEM;
goto error;
}
share->key_tokenizer_length[i] = strlen(share->key_tokenizer[i]);
DBUG_RETURN(0);
}
DBUG_PRINT("info", ("mroonga create comment string"));
if (
!(param_string = mrn_my_strndup(key_info->comment.str,
key_info->comment.length,
MYF(MY_WME)))
) {
error = HA_ERR_OUT_OF_MEM;
goto error_alloc_param_string;
}
DBUG_PRINT("info", ("mroonga comment string=%s", param_string));
sprit_ptr[0] = param_string;
while (sprit_ptr[0])
{
if ((sprit_ptr[1] = strchr(sprit_ptr[0], ',')))
{
*sprit_ptr[1] = '\0';
sprit_ptr[1]++;
}
tmp_ptr = sprit_ptr[0];
sprit_ptr[0] = sprit_ptr[1];
while (*tmp_ptr == ' ' || *tmp_ptr == '\r' ||
*tmp_ptr == '\n' || *tmp_ptr == '\t')
tmp_ptr++;
if (*tmp_ptr == '\0')
continue;
title_length = 0;
start_ptr = tmp_ptr;
while (*start_ptr != ' ' && *start_ptr != '\'' &&
*start_ptr != '"' && *start_ptr != '\0' &&
*start_ptr != '\r' && *start_ptr != '\n' &&
*start_ptr != '\t')
{
title_length++;
start_ptr++;
}
switch (title_length)
{
case 5:
MRN_PARAM_STR_LIST("table", index_table, i);
break;
case 6:
push_warning_printf(thd, MRN_SEVERITY_WARNING,
ER_WARN_DEPRECATED_SYNTAX,
ER(ER_WARN_DEPRECATED_SYNTAX),
"parser", "tokenizer");
MRN_PARAM_STR_LIST("parser", key_tokenizer, i);
break;
case 9:
MRN_PARAM_STR_LIST("tokenizer", key_tokenizer, i);
break;
default:
break;
}
}
#endif
if (!share->key_tokenizer[i]) {
share->key_tokenizer[i] = mrn_my_strdup(mrn_default_tokenizer, MYF(MY_WME));
if (!share->key_tokenizer[i]) {
error = HA_ERR_OUT_OF_MEM;
goto error;
}
share->key_tokenizer_length[i] = strlen(share->key_tokenizer[i]);
}
if (param_string)
my_free(param_string);
DBUG_RETURN(0);
error:
//.........这里部分代码省略.........
示例4: new_VioSSLAcceptorFd
/*
TODO:
Add option --verify to mysqld to be able to change verification mode
*/
struct st_VioSSLAcceptorFd*
new_VioSSLAcceptorFd(const char *key_file,
const char *cert_file,
const char *ca_file,
const char *ca_path,
const char *cipher)
{
int verify = (SSL_VERIFY_PEER |
SSL_VERIFY_CLIENT_ONCE);
struct st_VioSSLAcceptorFd* ptr;
int result;
DH *dh=NULL;
DBUG_ENTER("new_VioSSLAcceptorFd");
DBUG_PRINT("enter",
("key_file=%s, cert_file=%s, ca_path=%s, ca_file=%s, cipher=%s",
key_file, cert_file, ca_path, ca_file, cipher));
ptr= ((struct st_VioSSLAcceptorFd*)
my_malloc(sizeof(struct st_VioSSLAcceptorFd),MYF(0)));
ptr->ssl_context=0;
ptr->ssl_method=0;
/* FIXME: constants! */
ptr->session_id_context= ptr;
if (!ssl_algorithms_added)
{
DBUG_PRINT("info", ("todo: OpenSSL_add_all_algorithms()"));
ssl_algorithms_added = TRUE;
OpenSSL_add_all_algorithms();
}
if (!ssl_error_strings_loaded)
{
DBUG_PRINT("info", ("todo: SSL_load_error_strings()"));
ssl_error_strings_loaded = TRUE;
SSL_load_error_strings();
}
ptr->ssl_method= TLSv1_server_method();
ptr->ssl_context= SSL_CTX_new(ptr->ssl_method);
if (ptr->ssl_context == 0)
{
DBUG_PRINT("error", ("SSL_CTX_new failed"));
report_errors();
goto ctor_failure;
}
if (cipher)
{
result=SSL_CTX_set_cipher_list(ptr->ssl_context, cipher);
DBUG_PRINT("info",("SSL_set_cipher_list() returned %d",result));
}
/* SSL_CTX_set_quiet_shutdown(ctx,1); */
SSL_CTX_sess_set_cache_size(ptr->ssl_context,128);
/* DH? */
SSL_CTX_set_verify(ptr->ssl_context, verify, vio_verify_callback);
SSL_CTX_set_session_id_context(ptr->ssl_context,
(const uchar*) &(ptr->session_id_context),
sizeof(ptr->session_id_context));
/*
SSL_CTX_set_client_CA_list(ctx,SSL_load_client_CA_file(CAfile));
*/
if (vio_set_cert_stuff(ptr->ssl_context, cert_file, key_file) == -1)
{
DBUG_PRINT("error", ("vio_set_cert_stuff failed"));
report_errors();
goto ctor_failure;
}
if (SSL_CTX_load_verify_locations( ptr->ssl_context, ca_file, ca_path) == 0)
{
DBUG_PRINT("warning", ("SSL_CTX_load_verify_locations failed"));
if (SSL_CTX_set_default_verify_paths(ptr->ssl_context)==0)
{
DBUG_PRINT("error", ("SSL_CTX_set_default_verify_paths failed"));
report_errors();
goto ctor_failure;
}
}
/* DH stuff */
dh=get_dh512();
SSL_CTX_set_tmp_dh(ptr->ssl_context,dh);
DH_free(dh);
DBUG_RETURN(ptr);
ctor_failure:
DBUG_PRINT("exit", ("there was an error"));
my_free((gptr) ptr,MYF(0));
DBUG_RETURN(0);
}
示例5: DBUG_ENTER
MY_DIR *my_dir(const char *path, myf MyFlags)
{
char *buffer;
MY_DIR *result= 0;
FILEINFO finfo;
DYNAMIC_ARRAY *dir_entries_storage;
MEM_ROOT *names_storage;
#ifdef __BORLANDC__
struct ffblk find;
#else
struct _finddata_t find;
#endif
ushort mode;
char tmp_path[FN_REFLEN],*tmp_file,attrib;
#ifdef _WIN64
__int64 handle;
#else
long handle;
#endif
DBUG_ENTER("my_dir");
DBUG_PRINT("my",("path: '%s' stat: %d MyFlags: %d",path,MyFlags));
/* Put LIB-CHAR as last path-character if not there */
tmp_file=tmp_path;
if (!*path)
*tmp_file++ ='.'; /* From current dir */
tmp_file= strnmov(tmp_file, path, FN_REFLEN-5);
if (tmp_file[-1] == FN_DEVCHAR)
*tmp_file++= '.'; /* From current dev-dir */
if (tmp_file[-1] != FN_LIBCHAR)
*tmp_file++ =FN_LIBCHAR;
tmp_file[0]='*'; /* Windows needs this !??? */
tmp_file[1]='.';
tmp_file[2]='*';
tmp_file[3]='\0';
if (!(buffer= my_malloc(ALIGN_SIZE(sizeof(MY_DIR)) +
ALIGN_SIZE(sizeof(DYNAMIC_ARRAY)) +
sizeof(MEM_ROOT), MyFlags)))
goto error;
dir_entries_storage= (DYNAMIC_ARRAY*)(buffer + ALIGN_SIZE(sizeof(MY_DIR)));
names_storage= (MEM_ROOT*)(buffer + ALIGN_SIZE(sizeof(MY_DIR)) +
ALIGN_SIZE(sizeof(DYNAMIC_ARRAY)));
if (my_init_dynamic_array(dir_entries_storage, sizeof(FILEINFO),
ENTRIES_START_SIZE, ENTRIES_INCREMENT))
{
my_free(buffer);
goto error;
}
init_alloc_root(names_storage, NAMES_START_SIZE, NAMES_START_SIZE);
/* MY_DIR structure is allocated and completly initialized at this point */
result= (MY_DIR*)buffer;
#ifdef __BORLANDC__
if ((handle= findfirst(tmp_path,&find,0)) == -1L)
#else
if ((handle=_findfirst(tmp_path,&find)) == -1L)
#endif
{
DBUG_PRINT("info", ("findfirst returned error, errno: %d", errno));
if (errno != EINVAL)
goto error;
/*
Could not read the directory, no read access.
Probably because by "chmod -r".
continue and return zero files in dir
*/
}
else
{
do
{
#ifdef __BORLANDC__
attrib= find.ff_attrib;
#else
attrib= find.attrib;
/*
Do not show hidden and system files which Windows sometimes create.
Note. Because Borland's findfirst() is called with the third
argument = 0 hidden/system files are excluded from the search.
*/
if (attrib & (_A_HIDDEN | _A_SYSTEM))
continue;
#endif
#ifdef __BORLANDC__
if (!(finfo.name= strdup_root(names_storage, find.ff_name)))
goto error;
#else
if (!(finfo.name= strdup_root(names_storage, find.name)))
goto error;
#endif
if (MyFlags & MY_WANT_STAT)
{
if (!(finfo.mystat= (MY_STAT*)alloc_root(names_storage,
sizeof(MY_STAT))))
goto error;
//.........这里部分代码省略.........
示例6: hp_hashnr
ulong hp_hashnr(register HP_KEYDEF *keydef, register const uchar *key)
{
/*register*/
ulong nr=1, nr2=4;
HA_KEYSEG *seg,*endseg;
for (seg=keydef->seg,endseg=seg+keydef->keysegs ; seg < endseg ; seg++)
{
uchar *pos=(uchar*) key;
key+=seg->length;
if (seg->null_bit)
{
key++; /* Skip null byte */
if (*pos) /* Found null */
{
nr^= (nr << 1) | 1;
/* Add key pack length (2) to key for VARCHAR segments */
if (seg->type == HA_KEYTYPE_VARTEXT1)
key+= 2;
continue;
}
pos++;
}
if (seg->type == HA_KEYTYPE_TEXT)
{
const CHARSET_INFO *cs= seg->charset;
uint length= seg->length;
if (cs->mbmaxlen > 1)
{
uint char_length;
char_length= my_charpos(cs, pos, pos + length, length/cs->mbmaxlen);
set_if_smaller(length, char_length);
}
cs->coll->hash_sort(cs, pos, length, &nr, &nr2);
}
else if (seg->type == HA_KEYTYPE_VARTEXT1) /* Any VARCHAR segments */
{
const CHARSET_INFO *cs= seg->charset;
uint pack_length= 2; /* Key packing is constant */
uint length= uint2korr(pos);
if (cs->mbmaxlen > 1)
{
uint char_length;
char_length= my_charpos(cs, pos +pack_length,
pos +pack_length + length,
seg->length/cs->mbmaxlen);
set_if_smaller(length, char_length);
}
cs->coll->hash_sort(cs, pos+pack_length, length, &nr, &nr2);
key+= pack_length;
}
else
{
for (; pos < (uchar*) key ; pos++)
{
nr^=(ulong) ((((uint) nr & 63)+nr2)*((uint) *pos)) + (nr << 8);
nr2+=3;
}
}
}
DBUG_PRINT("exit", ("hash: 0x%lx", nr));
return((ulong) nr);
}
示例7: DBUG_ENTER
uchar *hp_search(HP_INFO *info, HP_KEYDEF *keyinfo, const uchar *key,
uint nextflag)
{
reg1 HASH_INFO *pos,*prev_ptr;
int flag;
uint old_nextflag;
HP_SHARE *share=info->s;
DBUG_ENTER("hp_search");
old_nextflag=nextflag;
flag=1;
prev_ptr=0;
if (share->records)
{
pos=hp_find_hash(&keyinfo->block, hp_mask(hp_hashnr(keyinfo, key),
share->blength, share->records));
do
{
if (!hp_key_cmp(keyinfo, pos->ptr_to_rec, key))
{
switch (nextflag) {
case 0: /* Search after key */
DBUG_PRINT("exit", ("found key at 0x%lx", (long) pos->ptr_to_rec));
info->current_hash_ptr=pos;
DBUG_RETURN(info->current_ptr= pos->ptr_to_rec);
case 1: /* Search next */
if (pos->ptr_to_rec == info->current_ptr)
nextflag=0;
break;
case 2: /* Search previous */
if (pos->ptr_to_rec == info->current_ptr)
{
my_errno=HA_ERR_KEY_NOT_FOUND; /* If gpos == 0 */
info->current_hash_ptr=prev_ptr;
DBUG_RETURN(info->current_ptr=prev_ptr ? prev_ptr->ptr_to_rec : 0);
}
prev_ptr=pos; /* Prev. record found */
break;
case 3: /* Search same */
if (pos->ptr_to_rec == info->current_ptr)
{
info->current_hash_ptr=pos;
DBUG_RETURN(info->current_ptr);
}
}
}
if (flag)
{
flag=0; /* Reset flag */
if (hp_find_hash(&keyinfo->block,
hp_mask(hp_rec_hashnr(keyinfo, pos->ptr_to_rec),
share->blength, share->records)) != pos)
break; /* Wrong link */
}
}
while ((pos=pos->next_key));
}
my_errno=HA_ERR_KEY_NOT_FOUND;
if (nextflag == 2 && ! info->current_ptr)
{
/* Do a previous from end */
info->current_hash_ptr=prev_ptr;
DBUG_RETURN(info->current_ptr=prev_ptr ? prev_ptr->ptr_to_rec : 0);
}
if (old_nextflag && nextflag)
my_errno=HA_ERR_RECORD_CHANGED; /* Didn't find old record */
DBUG_PRINT("exit",("Error: %d",my_errno));
info->current_hash_ptr=0;
DBUG_RETURN((info->current_ptr= 0));
}
示例8: program
/*
Delete file.
The function also makes best effort to minimize number of errors,
where another program (or thread in the current program) has the the same file
open.
We're using 2 tricks to prevent the errors.
1. A usual Win32's DeleteFile() can with ERROR_SHARED_VIOLATION,
because the file is opened in another application (often, antivirus or backup)
We avoid the error by using CreateFile() with FILE_FLAG_DELETE_ON_CLOSE, instead
of DeleteFile()
2. If file which is deleted (delete on close) but has not entirely gone,
because it is still opened by some app, an attempt to trcreate file with the
same name would result in yet another error. The workaround here is renaming
a file to unique name.
Symbolic link are deleted without renaming. Directories are not deleted.
*/
static int my_win_unlink(const char *name)
{
HANDLE handle= INVALID_HANDLE_VALUE;
DWORD attributes;
DWORD last_error;
char unique_filename[MAX_PATH + 35];
unsigned long long tsc; /* time stamp counter, for unique filename*/
DBUG_ENTER("my_win_unlink");
attributes= GetFileAttributes(name);
if (attributes == INVALID_FILE_ATTRIBUTES)
{
last_error= GetLastError();
DBUG_PRINT("error",("GetFileAttributes(%s) failed with %u\n", name, last_error));
goto error;
}
if (attributes & FILE_ATTRIBUTE_DIRECTORY)
{
DBUG_PRINT("error",("can't remove %s - it is a directory\n", name));
errno= EINVAL;
DBUG_RETURN(-1);
}
if (attributes & FILE_ATTRIBUTE_REPARSE_POINT)
{
/* Symbolic link. Delete link, the not target */
if (!DeleteFile(name))
{
last_error= GetLastError();
DBUG_PRINT("error",("DeleteFile(%s) failed with %u\n", name,last_error));
goto error;
}
DBUG_RETURN(0);
}
handle= CreateFile(name, DELETE, 0, NULL, OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, NULL);
if (handle != INVALID_HANDLE_VALUE)
{
/*
We opened file without sharing flags (exclusive), no one else has this file
opened, thus it is save to close handle to remove it. No renaming is
necessary.
*/
CloseHandle(handle);
DBUG_RETURN(0);
}
/*
Can't open file exclusively, hence the file must be already opened by
someone else. Open it for delete (with all FILE_SHARE flags set),
rename to unique name, close.
*/
handle= CreateFile(name, DELETE, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
NULL, OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, NULL);
if (handle == INVALID_HANDLE_VALUE)
{
last_error= GetLastError();
DBUG_PRINT("error",
("CreateFile(%s) with FILE_FLAG_DELETE_ON_CLOSE failed with %u\n",
name,last_error));
goto error;
}
tsc= __rdtsc();
my_snprintf(unique_filename,sizeof(unique_filename),"%s.%llx.deleted",
name, tsc);
if (!MoveFile(name, unique_filename))
{
DBUG_PRINT("warning", ("moving %s to unique filename failed, error %u\n",
name,GetLastError()));
}
CloseHandle(handle);
DBUG_RETURN(0);
error:
my_osmaperr(last_error);
//.........这里部分代码省略.........
示例9: myrg_rrnd
int myrg_rrnd(MYRG_INFO *info,uchar *buf,ulonglong filepos)
{
int error;
MI_INFO *isam_info;
DBUG_ENTER("myrg_rrnd");
DBUG_PRINT("info",("offset: %lu", (ulong) filepos));
if (filepos == HA_OFFSET_ERROR)
{
if (!info->current_table)
{
if (info->open_tables == info->end_table)
{ /* No tables */
DBUG_RETURN(my_errno=HA_ERR_END_OF_FILE);
}
isam_info=(info->current_table=info->open_tables)->table;
if (info->cache_in_use)
mi_extra(isam_info,HA_EXTRA_CACHE,(uchar*) &info->cache_size);
filepos=isam_info->s->pack.header_length;
isam_info->lastinx= (uint) -1; /* Can't forward or backward */
}
else
{
isam_info=info->current_table->table;
filepos= isam_info->nextpos;
}
for (;;)
{
isam_info->update&= HA_STATE_CHANGED;
if ((error=(*isam_info->s->read_rnd)(isam_info,(uchar*) buf,
(my_off_t) filepos,1)) !=
HA_ERR_END_OF_FILE)
DBUG_RETURN(error);
if (info->cache_in_use)
mi_extra(info->current_table->table, HA_EXTRA_NO_CACHE,
(uchar*) &info->cache_size);
if (info->current_table+1 == info->end_table)
DBUG_RETURN(HA_ERR_END_OF_FILE);
info->current_table++;
info->last_used_table=info->current_table;
if (info->cache_in_use)
mi_extra(info->current_table->table, HA_EXTRA_CACHE,
(uchar*) &info->cache_size);
info->current_table->file_offset=
info->current_table[-1].file_offset+
info->current_table[-1].table->state->data_file_length;
isam_info=info->current_table->table;
filepos=isam_info->s->pack.header_length;
isam_info->lastinx= (uint) -1;
}
}
info->current_table=find_table(info->open_tables,
info->end_table-1,filepos);
isam_info=info->current_table->table;
isam_info->update&= HA_STATE_CHANGED;
DBUG_RETURN((*isam_info->s->read_rnd)
(isam_info, (uchar*) buf,
(my_off_t) (filepos - info->current_table->file_offset),
0));
}
示例10: while
bool SCI_Transporter::doSend() {
#ifdef DEBUG_TRANSPORTER
NDB_TICKS startSec=0, stopSec=0;
Uint32 startMicro=0, stopMicro=0, totalMicro=0;
#endif
sci_error_t err;
Uint32 retry=0;
if (!fetch_send_iovec_data())
return false;
Uint32 used = m_send_iovec_used;
if (used == 0)
return true; // Nothing to send
#ifdef DEBUG_TRANSPORTER
Uint32 sizeToSend = 0;
for (Uint32 i = 0; i < used; i++)
sizeToSend += m_send_iovec[i].iov_len;
if(sizeToSend < 1024 )
i1024++;
if(sizeToSend > 1024 && sizeToSend < 2048 )
i10242048++;
if(sizeToSend==2048)
i2048++;
if(sizeToSend>2048 && sizeToSend < 4096)
i20484096++;
if(sizeToSend==4096)
i4096++;
if(sizeToSend==4097)
i4097++;
#endif
bool status = true;
Uint32 curr = 0;
Uint32 total = 0;
while (curr < used)
{
tryagain:
if (retry > 3) {
DBUG_PRINT("error", ("SCI Transfer failed"));
report_error(TE_SCI_UNRECOVERABLE_DATA_TFX_ERROR);
status = false;
break;
}
Uint32 segSize = m_send_iovec[curr].iov_len;
Uint32 * insertPtr = (Uint32 *)
(m_TargetSegm[m_ActiveAdapterId].writer)->getWritePtr(segSize);
if(insertPtr != 0) {
const Uint32 remoteOffset=(Uint32)
((char*)insertPtr -
(char*)(m_TargetSegm[m_ActiveAdapterId].mappedMemory));
SCIMemCpy(m_TargetSegm[m_ActiveAdapterId].sequence,
(void*)m_send_iovec[curr].iov_base,
m_TargetSegm[m_ActiveAdapterId].rhm[m_ActiveAdapterId].map,
remoteOffset,
segSize,
SCI_FLAG_ERROR_CHECK,
&err);
if (err != SCI_ERR_OK) {
if (err == SCI_ERR_OUT_OF_RANGE ||
err == SCI_ERR_SIZE_ALIGNMENT ||
err == SCI_ERR_OFFSET_ALIGNMENT) {
DBUG_PRINT("error", ("Data transfer error = %d", err));
report_error(TE_SCI_UNRECOVERABLE_DATA_TFX_ERROR);
status = false;
break;
}
if(err == SCI_ERR_TRANSFER_FAILED) {
if(getLinkStatus(m_ActiveAdapterId))
{
retry++;
goto tryagain;
}
if (m_adapters == 1) {
DBUG_PRINT("error", ("SCI Transfer failed"));
report_error(TE_SCI_UNRECOVERABLE_DATA_TFX_ERROR);
status = false;
break;
}
m_failCounter++;
Uint32 temp=m_ActiveAdapterId;
if (getLinkStatus(m_StandbyAdapterId)) {
failoverShmWriter();
SCIStoreBarrier(m_TargetSegm[m_StandbyAdapterId].sequence,0);
m_ActiveAdapterId=m_StandbyAdapterId;
m_StandbyAdapterId=temp;
DBUG_PRINT("error", ("Swapping from adapter %u to %u",
m_StandbyAdapterId, m_ActiveAdapterId));
} else {
report_error(TE_SCI_UNRECOVERABLE_DATA_TFX_ERROR);
DBUG_PRINT("error", ("SCI Transfer failed"));
}
}
break;
//.........这里部分代码省略.........
示例11: DBUG_ENTER
void SCI_Transporter::setupRemoteSegment()
{
DBUG_ENTER("SCI_Transporter::setupRemoteSegment");
Uint32 sharedSize = 0;
sharedSize =4096; //start of the buffer is page aligned
Uint32 sizeOfBuffer = m_BufferSize;
const Uint32 slack = MAX_MESSAGE_SIZE;
sizeOfBuffer -= sharedSize;
Uint32 *segPtr = (Uint32*) m_TargetSegm[m_ActiveAdapterId].mappedMemory ;
Uint32 * remoteReadIndex = (Uint32*)segPtr;
Uint32 * remoteWriteIndex = (Uint32*)(segPtr + 1);
m_remoteStatusFlag = (Uint32*)(segPtr + 3);
char * remoteStartOfBuf = ( char*)((char*)segPtr+(sharedSize));
writer = new SHM_Writer(remoteStartOfBuf,
sizeOfBuffer,
slack,
remoteReadIndex,
remoteWriteIndex);
writer->clear();
m_TargetSegm[0].writer=writer;
if(createSequence(m_ActiveAdapterId)!=SCI_ERR_OK) {
report_error(TE_SCI_UNABLE_TO_CREATE_SEQUENCE);
DBUG_PRINT("error", ("Unable to create sequence on active"));
doDisconnect();
}
if (m_adapters > 1) {
segPtr = (Uint32*) m_TargetSegm[m_StandbyAdapterId].mappedMemory ;
Uint32 * remoteReadIndex2 = (Uint32*)segPtr;
Uint32 * remoteWriteIndex2 = (Uint32*) (segPtr + 1);
m_remoteStatusFlag2 = (Uint32*)(segPtr + 3);
char * remoteStartOfBuf2 = ( char*)((char *)segPtr+sharedSize);
/**
* setup a writer. writer2 is used to mirror the changes of
* writer on the standby
* segment, so that in the case of a failover, we can switch
* to the stdby seg. quickly.*
*/
writer2 = new SHM_Writer(remoteStartOfBuf2,
sizeOfBuffer,
slack,
remoteReadIndex2,
remoteWriteIndex2);
* remoteReadIndex = 0;
* remoteWriteIndex = 0;
writer2->clear();
m_TargetSegm[1].writer=writer2;
if(createSequence(m_StandbyAdapterId)!=SCI_ERR_OK) {
report_error(TE_SCI_UNABLE_TO_CREATE_SEQUENCE);
DBUG_PRINT("error", ("Unable to create sequence on standby"));
doDisconnect();
}
}
DBUG_VOID_RETURN;
} //setupRemoteSegment
示例12: my_copy
int my_copy(const char *from, const char *to, myf MyFlags)
{
size_t Count;
my_bool new_file_stat= 0; /* 1 if we could stat "to" */
int create_flag;
File from_file,to_file;
uchar buff[IO_SIZE];
MY_STAT stat_buff,new_stat_buff;
DBUG_ENTER("my_copy");
DBUG_PRINT("my",("from %s to %s MyFlags %d", from, to, MyFlags));
from_file=to_file= -1;
DBUG_ASSERT(!(MyFlags & (MY_FNABP | MY_NABP))); /* for my_read/my_write */
if (MyFlags & MY_HOLD_ORIGINAL_MODES) /* Copy stat if possible */
new_file_stat= test(my_stat((char*) to, &new_stat_buff, MYF(0)));
if ((from_file=my_open(from,O_RDONLY | O_SHARE,MyFlags)) >= 0)
{
if (!my_stat(from, &stat_buff, MyFlags))
{
my_errno=errno;
goto err;
}
if (MyFlags & MY_HOLD_ORIGINAL_MODES && new_file_stat)
stat_buff=new_stat_buff;
create_flag= (MyFlags & MY_DONT_OVERWRITE_FILE) ? O_EXCL : O_TRUNC;
if ((to_file= my_create(to,(int) stat_buff.st_mode,
O_WRONLY | create_flag | O_BINARY | O_SHARE,
MyFlags)) < 0)
goto err;
while ((Count=my_read(from_file, buff, sizeof(buff), MyFlags)) != 0)
{
if (Count == (uint) -1 ||
my_write(to_file,buff,Count,MYF(MyFlags | MY_NABP)))
goto err;
}
/* sync the destination file */
if (MyFlags & MY_SYNC)
{
if (my_sync(to_file, MyFlags))
goto err;
}
if (my_close(from_file,MyFlags) | my_close(to_file,MyFlags))
DBUG_RETURN(-1); /* Error on close */
/* Copy modes if possible */
if (MyFlags & MY_HOLD_ORIGINAL_MODES && !new_file_stat)
DBUG_RETURN(0); /* File copyed but not stat */
/* Copy modes */
if (chmod(to, stat_buff.st_mode & 07777))
{
my_errno= errno;
if (MyFlags & (MY_FAE+MY_WME))
my_error(EE_CHANGE_PERMISSIONS, MYF(ME_BELL+ME_WAITTANG), from, errno);
goto err;
}
#if !defined(__WIN__)
/* Copy ownership */
if (chown(to, stat_buff.st_uid, stat_buff.st_gid))
{
my_errno= errno;
if (MyFlags & (MY_FAE+MY_WME))
my_error(EE_CHANGE_OWNERSHIP, MYF(ME_BELL+ME_WAITTANG), from, errno);
goto err;
}
#endif
if (MyFlags & MY_COPYTIME)
{
struct utimbuf timep;
timep.actime = stat_buff.st_atime;
timep.modtime = stat_buff.st_mtime;
(void) utime((char*) to, &timep); /* last accessed and modified times */
}
DBUG_RETURN(0);
}
err:
if (from_file >= 0) (void) my_close(from_file,MyFlags);
if (to_file >= 0)
{
(void) my_close(to_file, MyFlags);
/* attempt to delete the to-file we've partially written */
(void) my_delete(to, MyFlags);
}
DBUG_RETURN(-1);
} /* my_copy */
示例13: create_temp_file
File create_temp_file(char *to, const char *dir, const char *prefix,
int mode, myf MyFlags)
{
File file= -1;
#ifdef _WIN32
TCHAR path_buf[MAX_PATH-14];
#endif
DBUG_ENTER("create_temp_file");
DBUG_PRINT("enter", ("dir: %s, prefix: %s", dir, prefix));
#if defined(_WIN32)
/*
Use GetTempPath to determine path for temporary files.
This is because the documentation for GetTempFileName
has the following to say about this parameter:
"If this parameter is NULL, the function fails."
*/
if (!dir)
{
if(GetTempPath(sizeof(path_buf), path_buf) > 0)
dir = path_buf;
}
/*
Use GetTempFileName to generate a unique filename, create
the file and release it's handle
- uses up to the first three letters from prefix
*/
if (GetTempFileName(dir, prefix, 0, to) == 0)
DBUG_RETURN(-1);
DBUG_PRINT("info", ("name: %s", to));
/*
Open the file without the "open only if file doesn't already exist"
since the file has already been created by GetTempFileName
*/
if ((file= my_open(to, (mode & ~O_EXCL), MyFlags)) < 0)
{
/* Open failed, remove the file created by GetTempFileName */
int tmp= my_errno();
(void) my_delete(to, MYF(0));
set_my_errno(tmp);
}
#else /* mkstemp() is available on all non-Windows supported platforms. */
{
char prefix_buff[30];
uint pfx_len;
File org_file;
pfx_len= (uint) (my_stpcpy(my_stpnmov(prefix_buff,
prefix ? prefix : "tmp.",
sizeof(prefix_buff)-7),"XXXXXX") -
prefix_buff);
if (!dir && ! (dir =getenv("TMPDIR")))
dir= DEFAULT_TMPDIR;
if (strlen(dir)+ pfx_len > FN_REFLEN-2)
{
errno=ENAMETOOLONG;
set_my_errno(ENAMETOOLONG);
DBUG_RETURN(file);
}
my_stpcpy(convert_dirname(to,dir,NullS),prefix_buff);
org_file=mkstemp(to);
if (mode & O_TEMPORARY)
(void) my_delete(to, MYF(MY_WME));
file=my_register_filename(org_file, to, FILE_BY_MKSTEMP,
EE_CANTCREATEFILE, MyFlags);
/* If we didn't manage to register the name, remove the temp file */
if (org_file >= 0 && file < 0)
{
int tmp=my_errno();
close(org_file);
(void) my_delete(to, MYF(MY_WME));
set_my_errno(tmp);
}
}
#endif
if (file >= 0)
{
mysql_mutex_lock(&THR_LOCK_open);
my_tmp_file_created++;
mysql_mutex_unlock(&THR_LOCK_open);
}
DBUG_RETURN(file);
}
示例14: nisam_update
int nisam_update(register N_INFO *info, const byte *oldrec, const byte *newrec)
{
int flag,key_changed,save_errno;
reg3 ulong pos;
uint i,length;
uchar old_key[N_MAX_KEY_BUFF],*new_key;
DBUG_ENTER("nisam_update");
LINT_INIT(save_errno);
if (!(info->update & HA_STATE_AKTIV))
{
my_errno=HA_ERR_KEY_NOT_FOUND;
DBUG_RETURN(-1);
}
if (info->s->base.options & HA_OPTION_READ_ONLY_DATA)
{
my_errno=EACCES;
DBUG_RETURN(-1);
}
pos=info->lastpos;
#ifndef NO_LOCKING
if (_nisam_readinfo(info,F_WRLCK,1)) DBUG_RETURN(-1);
#endif
if ((*info->s->compare_record)(info,oldrec))
{
save_errno=my_errno;
goto err_end; /* Record has changed */
}
if (info->s->state.key_file_length >=
info->s->base.max_key_file_length -
info->s->blocksize* INDEX_BLOCK_MARGIN *info->s->state.keys)
{
save_errno=HA_ERR_INDEX_FILE_FULL;
goto err_end;
}
/* Flyttar de element i isamfilen som m}ste flyttas */
new_key=info->lastkey+info->s->base.max_key_length;
key_changed=HA_STATE_KEY_CHANGED; /* We changed current database */
/* Remove key that didn't change */
for (i=0 ; i < info->s->state.keys ; i++)
{
length=_nisam_make_key(info,i,new_key,newrec,pos);
if (length != _nisam_make_key(info,i,old_key,oldrec,pos) ||
memcmp((byte*) old_key,(byte*) new_key,length))
{
if ((int) i == info->lastinx)
key_changed|=HA_STATE_WRITTEN; /* Mark that keyfile changed */
if (_nisam_ck_delete(info,i,old_key)) goto err;
if (_nisam_ck_write(info,i,new_key)) goto err;
}
}
if ((*info->s->update_record)(info,pos,newrec))
goto err;
info->update= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED | HA_STATE_AKTIV |
key_changed);
nisam_log_record(LOG_UPDATE,info,newrec,info->lastpos,0);
VOID(_nisam_writeinfo(info,test(key_changed)));
allow_break(); /* Allow SIGHUP & SIGINT */
DBUG_RETURN(0);
err:
DBUG_PRINT("error",("key: %d errno: %d",i,my_errno));
save_errno=my_errno;
if (my_errno == HA_ERR_FOUND_DUPP_KEY || my_errno == HA_ERR_RECORD_FILE_FULL)
{
info->errkey= (int) i;
flag=0;
do
{
length=_nisam_make_key(info,i,new_key,newrec,pos);
if (length != _nisam_make_key(info,i,old_key,oldrec,pos) ||
memcmp((byte*) old_key,(byte*) new_key,length))
{
if ((flag++ && _nisam_ck_delete(info,i,new_key)) ||
_nisam_ck_write(info,i,old_key))
break;
}
} while (i-- != 0);
}
info->update= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED | HA_STATE_AKTIV |
key_changed);
err_end:
nisam_log_record(LOG_UPDATE,info,newrec,info->lastpos,save_errno);
VOID(_nisam_writeinfo(info,1));
allow_break(); /* Allow SIGHUP & SIGINT */
my_errno=(save_errno == HA_ERR_KEY_NOT_FOUND) ? HA_ERR_CRASHED : save_errno;
DBUG_RETURN(-1);
} /* nisam_update */
示例15: my_end
void my_end(int infoflag)
{
/*
this code is suboptimal to workaround a bug in
Sun CC: Sun C++ 5.6 2004/06/02 for x86, and should not be
optimized until this compiler is not in use anymore
*/
FILE *info_file= DBUG_FILE;
my_bool print_info= (info_file != stderr);
DBUG_ENTER("my_end");
if (!info_file)
{
info_file= stderr;
print_info= 0;
}
DBUG_PRINT("info",("Shutting down: print_info: %d", print_info));
if ((infoflag & MY_CHECK_ERROR) || print_info)
{ /* Test if some file is left open */
if (my_file_opened | my_stream_opened)
{
sprintf(errbuff[0],EE(EE_OPEN_WARNING),my_file_opened,my_stream_opened);
(void) my_message_no_curses(EE_OPEN_WARNING,errbuff[0],ME_BELL);
DBUG_PRINT("error",("%s",errbuff[0]));
}
}
free_charsets();
my_once_free();
if ((infoflag & MY_GIVE_INFO) || print_info)
{
#ifdef HAVE_GETRUSAGE
struct rusage rus;
#ifdef HAVE_purify
/* Purify assumes that rus is uninitialized after getrusage call */
bzero((char*) &rus, sizeof(rus));
#endif
if (!getrusage(RUSAGE_SELF, &rus))
fprintf(info_file,"\n\
User time %.2f, System time %.2f\n\
Maximum resident set size %ld, Integral resident set size %ld\n\
Non-physical pagefaults %ld, Physical pagefaults %ld, Swaps %ld\n\
Blocks in %ld out %ld, Messages in %ld out %ld, Signals %ld\n\
Voluntary context switches %ld, Involuntary context switches %ld\n",
(rus.ru_utime.tv_sec * SCALE_SEC +
rus.ru_utime.tv_usec / SCALE_USEC) / 100.0,
(rus.ru_stime.tv_sec * SCALE_SEC +
rus.ru_stime.tv_usec / SCALE_USEC) / 100.0,
rus.ru_maxrss, rus.ru_idrss,
rus.ru_minflt, rus.ru_majflt,
rus.ru_nswap, rus.ru_inblock, rus.ru_oublock,
rus.ru_msgsnd, rus.ru_msgrcv, rus.ru_nsignals,
rus.ru_nvcsw, rus.ru_nivcsw);
#endif
#if ( defined(MSDOS) || defined(__NETWARE__) ) && !defined(__WIN__)
fprintf(info_file,"\nRun time: %.1f\n",(double) clock()/CLOCKS_PER_SEC);
#endif
#if defined(SAFEMALLOC)
TERMINATE(stderr); /* Give statistic on screen */
#elif defined(__WIN__) && defined(_MSC_VER)
_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );
_CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR );
_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
_CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDERR );
_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
_CrtCheckMemory();
_CrtDumpMemoryLeaks();
#endif
}
#ifdef THREAD
DBUG_POP(); /* Must be done before my_thread_end */
my_thread_end();
my_thread_global_end();
#if defined(SAFE_MUTEX)
/*
Check on destroying of mutexes. A few may be left that will get cleaned
up by C++ destructors
*/
safe_mutex_end(infoflag & MY_GIVE_INFO ? stderr : (FILE *) 0);
#endif /* defined(SAFE_MUTEX) */
#endif /* THREAD */
#ifdef __WIN__
if (have_tcpip)
WSACleanup();
#endif /* __WIN__ */
my_init_done=0;
} /* my_end */