/*********************************************************************** Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. 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 St, Fifth Floor, Boston, MA 02110-1301 USA ***********************************************************************/ /**************************************************/ /** @file innodb_api.h Created 03/15/2011 Jimmy Yang *******************************************************/ #ifndef innodb_api_h #define innodb_api_h #include "api0api.h" #include "assert.h" #include "handler_api.h" #include "innodb_engine.h" /** Macros to lock/unlock the engine connection mutex */ #define LOCK_CONN_IF_NOT_LOCKED(has_lock, engine) \ if (!(has_lock)) { \ pthread_mutex_lock(&(engine)->conn_mutex); \ } #define UNLOCK_CONN_IF_NOT_LOCKED(has_lock, engine) \ if (!(has_lock)) { \ pthread_mutex_unlock(&(engine)->conn_mutex); \ } /** Macros to lock/unlock the connection mutex, used for any connection specific operations */ #define LOCK_CURRENT_CONN_IF_NOT_LOCKED(has_lock, conn) \ if (!(has_lock)) { \ pthread_mutex_lock(&(conn)->curr_conn_mutex); \ } #define LOCK_CURRENT_CONN_TRYLOCK(conn) \ pthread_mutex_trylock(&(conn)->curr_conn_mutex); #define UNLOCK_CURRENT_CONN_IF_NOT_LOCKED(has_lock, conn) \ if (!(has_lock)) { \ pthread_mutex_unlock(&(conn)->curr_conn_mutex); \ } /** We would need to fetch 5 column values from each key value rows if they are available. They are the "key", "value", "cas", "exp" and "flag" */ #define MCI_COL_TO_GET 5 typedef enum mci_col { MCI_COL_KEY, /*!< key */ MCI_COL_VALUE, /*!< value */ MCI_COL_FLAG, /*!< flag */ MCI_COL_CAS, /*!< check and set value */ MCI_COL_EXP /*!< expiration */ } mci_col_t; /** mci_column is the structure that stores and describes a column info in InnoDB Memcached. The supported column types are either character type or integer type (see above "enum mci_col" for columns supporting memcached) */ typedef struct mci_column { char *value_str; /*!< char value of the column */ int value_len; /*!< char value length in bytes */ uint64_t value_int; /*!< integer value */ bool is_str; /*!< whether the value is char or int */ bool is_unsigned; /*!< whether the value is signed or not */ bool is_valid; /*!< this structure contains valid or stale column value */ bool is_null; /*!< whether it is a NULL value */ bool allocated; /*!< whether memory allocated to store the value */ } mci_column_t; /** "mci_item_t" represents values we read from a table row, and enough to assemble to an memcached response. As described in above mci_col, we must have "MCI_COL_TO_GET" (5) column values to read. In addition, the user table could have multiple "value" columns, and it is possible to map such multiple "value" columns to a single memcached key, such value is separated by "separator" as defined in the "config_option" table. And we will assemble and disassemble the memcached value from these column values. And "extra_col_value" and "n_extra_col" is used to support multiple value columns */ typedef struct mci_item { mci_column_t col_value[MCI_COL_TO_GET]; /*!< columns in a row */ mci_column_t *extra_col_value; /*!< whether there will be additional/multiple "values" to be stored */ int n_extra_col; /*!< number of additional "value" columns */ } mci_item_t; /*************************************************************/ /** Register InnoDB Callback functions */ void register_innodb_cb( /*===============*/ void *p); /*!