403Webshell
Server IP : 104.21.38.3  /  Your IP : 172.71.124.156
Web Server : Apache
System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /www/server/mysql/src/storage/innobase/include/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/server/mysql/src/storage/innobase/include/btr0sea.ic
/*****************************************************************************

Copyright (c) 1996, 2023, Oracle and/or its affiliates.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
as published by the Free Software Foundation.

This program is also distributed with certain software (including
but not limited to OpenSSL) that is licensed under separate terms,
as designated in a particular file or component or in included license
documentation.  The authors of MySQL hereby grant you an additional
permission to link the program and your derivative works with the
separately licensed software that they have included with MySQL.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License, version 2.0, for more details.

You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA

*****************************************************************************/

/********************************************************************//**
@file include/btr0sea.ic
The index tree adaptive search

Created 2/17/1996 Heikki Tuuri
*************************************************************************/

#include "dict0mem.h"
#include "btr0cur.h"
#include "buf0buf.h"

/*********************************************************************//**
Updates the search info. */
void
btr_search_info_update_slow(
/*========================*/
	btr_search_t*	info,	/*!< in/out: search info */
	btr_cur_t*	cursor);/*!< in: cursor which was just positioned */

/********************************************************************//**
Returns search info for an index.
@return search info; search mutex reserved */
UNIV_INLINE
btr_search_t*
btr_search_get_info(
/*================*/
	dict_index_t*	index)	/*!< in: index */
{
	return(index->search_info);
}

/*********************************************************************//**
Updates the search info. */
UNIV_INLINE
void
btr_search_info_update(
/*===================*/
	dict_index_t*	index,	/*!< in: index of the cursor */
	btr_cur_t*	cursor)	/*!< in: cursor which was just positioned */
{
	ut_ad(!rw_lock_own(btr_get_search_latch(index), RW_LOCK_S));
	ut_ad(!rw_lock_own(btr_get_search_latch(index), RW_LOCK_X));

	if (dict_index_is_spatial(index) || !btr_search_enabled) {
		return;
	}

	btr_search_t*	info;
	info = btr_search_get_info(index);

	info->hash_analysis++;

	if (info->hash_analysis < BTR_SEARCH_HASH_ANALYSIS) {

		/* Do nothing */

		return;

	}

	ut_ad(cursor->flag != BTR_CUR_HASH);

	btr_search_info_update_slow(info, cursor);
}

/** X-Lock the search latch (corresponding to given index)
@param[in]	index	index handler */
UNIV_INLINE
void
btr_search_x_lock(const dict_index_t* index)
{
	rw_lock_x_lock(btr_get_search_latch(index));
}

/** X-Unlock the search latch (corresponding to given index)
@param[in]	index	index handler */
UNIV_INLINE
void
btr_search_x_unlock(const dict_index_t* index)
{
	rw_lock_x_unlock(btr_get_search_latch(index));
}

/** Lock all search latches in exclusive mode. */
UNIV_INLINE
void
btr_search_x_lock_all()
{
	for (ulint i = 0; i < btr_ahi_parts; ++i) {
		rw_lock_x_lock(btr_search_latches[i]);
	}
}

/** Unlock all search latches from exclusive mode. */
UNIV_INLINE
void
btr_search_x_unlock_all()
{
	for (ulint i = 0; i < btr_ahi_parts; ++i) {
		rw_lock_x_unlock(btr_search_latches[i]);
	}
}

/** S-Lock the search latch (corresponding to given index)
@param[in]	index	index handler */
UNIV_INLINE
void
btr_search_s_lock(const dict_index_t* index)
{
	rw_lock_s_lock(btr_get_search_latch(index));
}

/** S-Unlock the search latch (corresponding to given index)
@param[in]	index	index handler */
UNIV_INLINE
void
btr_search_s_unlock(const dict_index_t* index)
{
	rw_lock_s_unlock(btr_get_search_latch(index));
}

/** Lock all search latches in shared mode. */
UNIV_INLINE
void
btr_search_s_lock_all()
{
	for (ulint i = 0; i < btr_ahi_parts; ++i) {
		rw_lock_s_lock(btr_search_latches[i]);
	}
}

/** Unlock all search latches from shared mode. */
UNIV_INLINE
void
btr_search_s_unlock_all()
{
	for (ulint i = 0; i < btr_ahi_parts; ++i) {
		rw_lock_s_unlock(btr_search_latches[i]);
	}
}

#ifdef UNIV_DEBUG
/** Check if thread owns all the search latches.
@param[in]	mode	lock mode check
@retval true if owns all of them
@retval false if does not own some of them */
UNIV_INLINE
bool
btr_search_own_all(ulint mode)
{
	for (ulint i = 0; i < btr_ahi_parts; ++i) {
		if (!rw_lock_own(btr_search_latches[i], mode)) {
			return(false);
		}
	}
	return(true);
}

/** Check if thread owns any of the search latches.
@param[in]	mode	lock mode check
@retval true if owns any of them
@retval false if owns no search latch */
UNIV_INLINE
bool
btr_search_own_any(ulint mode)
{
	for (ulint i = 0; i < btr_ahi_parts; ++i) {
		if (rw_lock_own(btr_search_latches[i], mode)) {
			return(true);
		}
	}
	return(false);
}
#endif /* UNIV_DEBUG */

/** Get the adaptive hash search index latch for a b-tree.
@param[in]	index	b-tree index
@return latch */
UNIV_INLINE
rw_lock_t*
btr_get_search_latch(const dict_index_t* index)
{
	ut_ad(index != NULL);

	ulint	ifold = ut_fold_ulint_pair(static_cast<ulint>(index->id),
					   static_cast<ulint>(index->space));

	return(btr_search_latches[ifold % btr_ahi_parts]);
}

/** Get the hash-table based on index attributes.
A table is selected from an array of tables using pair of index-id, space-id.
@param[in]	index	index handler
@return hash table */
UNIV_INLINE
hash_table_t*
btr_get_search_table(const dict_index_t* index)
{
	ut_ad(index != NULL);

	ulint	ifold = ut_fold_ulint_pair(static_cast<ulint>(index->id),
					   static_cast<ulint>(index->space));

	return(btr_search_sys->hash_tables[ifold % btr_ahi_parts]);
}

Youez - 2016 - github.com/yon3zu
LinuXploit