summaryrefslogtreecommitdiff
path: root/storage/innobase/fts/fts0config.cc
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/fts/fts0config.cc')
-rw-r--r--storage/innobase/fts/fts0config.cc84
1 files changed, 38 insertions, 46 deletions
diff --git a/storage/innobase/fts/fts0config.cc b/storage/innobase/fts/fts0config.cc
index 5b4ae5c39f7..740ee87fe01 100644
--- a/storage/innobase/fts/fts0config.cc
+++ b/storage/innobase/fts/fts0config.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 2007, 2013, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2007, 2014, 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 as published by the Free Software
@@ -28,7 +28,7 @@ Created 2007/5/9 Sunny Bains
#include "fts0priv.h"
-#ifndef UNIV_NONINL
+#ifdef UNIV_NONINL
#include "fts0types.ic"
#include "fts0vlc.ic"
#endif
@@ -69,7 +69,6 @@ fts_config_fetch_value(
Get value from the config table. The caller must ensure that enough
space is allocated for value to hold the column contents.
@return DB_SUCCESS or error code */
-UNIV_INTERN
dberr_t
fts_config_get_value(
/*=================*/
@@ -85,6 +84,7 @@ fts_config_get_value(
que_t* graph;
dberr_t error;
ulint name_len = strlen(name);
+ char table_name[MAX_FULL_NAME_LEN];
info = pars_info_create();
@@ -100,12 +100,14 @@ fts_config_get_value(
pars_info_bind_varchar_literal(info, "name", (byte*) name, name_len);
fts_table->suffix = "CONFIG";
+ fts_get_table_name(fts_table, table_name);
+ pars_info_bind_id(info, true, "table_name", table_name);
graph = fts_parse_sql(
fts_table,
info,
"DECLARE FUNCTION my_func;\n"
- "DECLARE CURSOR c IS SELECT value FROM \"%s\""
+ "DECLARE CURSOR c IS SELECT value FROM $table_name"
" WHERE key = :name;\n"
"BEGIN\n"
""
@@ -132,7 +134,6 @@ fts_config_get_value(
/*********************************************************************//**
Create the config table name for retrieving index specific value.
@return index config parameter name */
-UNIV_INTERN
char*
fts_config_create_index_param_name(
/*===============================*/
@@ -146,9 +147,9 @@ fts_config_create_index_param_name(
len = strlen(param);
/* Caller is responsible for deleting name. */
- name = static_cast<char*>(ut_malloc(
+ name = static_cast<char*>(ut_malloc_nokey(
len + FTS_AUX_MIN_TABLE_ID_LENGTH + 2));
- strcpy(name, param);
+ ::strcpy(name, param);
name[len] = '_';
fts_write_object_id(index->id, name + len + 1,
@@ -163,7 +164,6 @@ Get value specific to an FTS index from the config table. The caller
must ensure that enough space is allocated for value to hold the
column contents.
@return DB_SUCCESS or error code */
-UNIV_INTERN
dberr_t
fts_config_get_index_value(
/*=======================*/
@@ -194,7 +194,6 @@ fts_config_get_index_value(
/******************************************************************//**
Set the value in the config table for name.
@return DB_SUCCESS or error code */
-UNIV_INTERN
dberr_t
fts_config_set_value(
/*=================*/
@@ -212,6 +211,7 @@ fts_config_set_value(
undo_no_t undo_no;
undo_no_t n_rows_updated;
ulint name_len = strlen(name);
+ char table_name[MAX_FULL_NAME_LEN];
info = pars_info_create();
@@ -220,10 +220,13 @@ fts_config_set_value(
value->f_str, value->f_len);
fts_table->suffix = "CONFIG";
+ fts_get_table_name(fts_table, table_name);
+ pars_info_bind_id(info, true, "table_name", table_name);
graph = fts_parse_sql(
fts_table, info,
- "BEGIN UPDATE \"%s\" SET value = :value WHERE key = :name;");
+ "BEGIN UPDATE $table_name SET value = :value"
+ " WHERE key = :name;");
trx->op_info = "setting FTS config value";
@@ -245,10 +248,13 @@ fts_config_set_value(
pars_info_bind_varchar_literal(
info, "value", value->f_str, value->f_len);
+ fts_get_table_name(fts_table, table_name);
+ pars_info_bind_id(info, true, "table_name", table_name);
+
graph = fts_parse_sql(
fts_table, info,
"BEGIN\n"
- "INSERT INTO \"%s\" VALUES(:name, :value);");
+ "INSERT INTO $table_name VALUES(:name, :value);");
trx->op_info = "inserting FTS config value";
@@ -263,7 +269,6 @@ fts_config_set_value(
/******************************************************************//**
Set the value specific to an FTS index in the config table.
@return DB_SUCCESS or error code */
-UNIV_INTERN
dberr_t
fts_config_set_index_value(
/*=======================*/
@@ -294,7 +299,6 @@ fts_config_set_index_value(
/******************************************************************//**
Get an ulint value from the config table.
@return DB_SUCCESS if all OK else error code */
-UNIV_INTERN
dberr_t
fts_config_get_index_ulint(
/*=======================*/
@@ -309,15 +313,14 @@ fts_config_get_index_ulint(
/* We set the length of value to the max bytes it can hold. This
information is used by the callback that reads the value.*/
value.f_len = FTS_MAX_CONFIG_VALUE_LEN;
- value.f_str = static_cast<byte*>(ut_malloc(value.f_len + 1));
+ value.f_str = static_cast<byte*>(ut_malloc_nokey(value.f_len + 1));
error = fts_config_get_index_value(trx, index, name, &value);
if (UNIV_UNLIKELY(error != DB_SUCCESS)) {
- ut_print_timestamp(stderr);
- fprintf(stderr, " InnoDB: Error: (%s) reading `%s'\n",
- ut_strerr(error), name);
+ ib::error() << "(" << ut_strerr(error) << ") reading `"
+ << name << "'";
} else {
*int_value = strtoul((char*) value.f_str, NULL, 10);
}
@@ -330,7 +333,6 @@ fts_config_get_index_ulint(
/******************************************************************//**
Set an ulint value in the config table.
@return DB_SUCCESS if all OK else error code */
-UNIV_INTERN
dberr_t
fts_config_set_index_ulint(
/*=======================*/
@@ -345,7 +347,7 @@ fts_config_set_index_ulint(
/* We set the length of value to the max bytes it can hold. This
information is used by the callback that reads the value.*/
value.f_len = FTS_MAX_CONFIG_VALUE_LEN;
- value.f_str = static_cast<byte*>(ut_malloc(value.f_len + 1));
+ value.f_str = static_cast<byte*>(ut_malloc_nokey(value.f_len + 1));
// FIXME: Get rid of snprintf
ut_a(FTS_MAX_INT_LEN < FTS_MAX_CONFIG_VALUE_LEN);
@@ -356,10 +358,9 @@ fts_config_set_index_ulint(
error = fts_config_set_index_value(trx, index, name, &value);
if (UNIV_UNLIKELY(error != DB_SUCCESS)) {
- ut_print_timestamp(stderr);
- fprintf(stderr, " InnoDB: Error: (%s) writing `%s'\n",
- ut_strerr(error), name);
+ ib::error() << "(" << ut_strerr(error) << ") writing `"
+ << name << "'";
}
ut_free(value.f_str);
@@ -370,7 +371,6 @@ fts_config_set_index_ulint(
/******************************************************************//**
Get an ulint value from the config table.
@return DB_SUCCESS if all OK else error code */
-UNIV_INTERN
dberr_t
fts_config_get_ulint(
/*=================*/
@@ -386,15 +386,13 @@ fts_config_get_ulint(
/* We set the length of value to the max bytes it can hold. This
information is used by the callback that reads the value.*/
value.f_len = FTS_MAX_CONFIG_VALUE_LEN;
- value.f_str = static_cast<byte*>(ut_malloc(value.f_len + 1));
+ value.f_str = static_cast<byte*>(ut_malloc_nokey(value.f_len + 1));
error = fts_config_get_value(trx, fts_table, name, &value);
if (UNIV_UNLIKELY(error != DB_SUCCESS)) {
- ut_print_timestamp(stderr);
-
- fprintf(stderr, " InnoDB: Error: (%s) reading `%s'\n",
- ut_strerr(error), name);
+ ib::error() << "(" << ut_strerr(error) << ") reading `"
+ << name << "'";
} else {
*int_value = strtoul((char*) value.f_str, NULL, 10);
}
@@ -407,7 +405,6 @@ fts_config_get_ulint(
/******************************************************************//**
Set an ulint value in the config table.
@return DB_SUCCESS if all OK else error code */
-UNIV_INTERN
dberr_t
fts_config_set_ulint(
/*=================*/
@@ -423,21 +420,18 @@ fts_config_set_ulint(
/* We set the length of value to the max bytes it can hold. This
information is used by the callback that reads the value.*/
value.f_len = FTS_MAX_CONFIG_VALUE_LEN;
- value.f_str = static_cast<byte*>(ut_malloc(value.f_len + 1));
+ value.f_str = static_cast<byte*>(ut_malloc_nokey(value.f_len + 1));
- // FIXME: Get rid of snprintf
ut_a(FTS_MAX_INT_LEN < FTS_MAX_CONFIG_VALUE_LEN);
- value.f_len = snprintf(
+ value.f_len = my_snprintf(
(char*) value.f_str, FTS_MAX_INT_LEN, "%lu", int_value);
error = fts_config_set_value(trx, fts_table, name, &value);
if (UNIV_UNLIKELY(error != DB_SUCCESS)) {
- ut_print_timestamp(stderr);
-
- fprintf(stderr, " InnoDB: Error: (%s) writing `%s'\n",
- ut_strerr(error), name);
+ ib::error() << "(" << ut_strerr(error) << ") writing `"
+ << name << "'";
}
ut_free(value.f_str);
@@ -448,7 +442,6 @@ fts_config_set_ulint(
/******************************************************************//**
Increment the value in the config table for column name.
@return DB_SUCCESS or error code */
-UNIV_INTERN
dberr_t
fts_config_increment_value(
/*=======================*/
@@ -465,11 +458,12 @@ fts_config_increment_value(
que_t* graph = NULL;
ulint name_len = strlen(name);
pars_info_t* info = pars_info_create();
+ char table_name[MAX_FULL_NAME_LEN];
/* We set the length of value to the max bytes it can hold. This
information is used by the callback that reads the value.*/
value.f_len = FTS_MAX_CONFIG_VALUE_LEN;
- value.f_str = static_cast<byte*>(ut_malloc(value.f_len + 1));
+ value.f_str = static_cast<byte*>(ut_malloc_nokey(value.f_len + 1));
*value.f_str = '\0';
@@ -479,11 +473,13 @@ fts_config_increment_value(
info, "my_func", fts_config_fetch_value, &value);
fts_table->suffix = "CONFIG";
+ fts_get_table_name(fts_table, table_name);
+ pars_info_bind_id(info, true, "config_table", table_name);
graph = fts_parse_sql(
fts_table, info,
"DECLARE FUNCTION my_func;\n"
- "DECLARE CURSOR c IS SELECT value FROM \"%s\""
+ "DECLARE CURSOR c IS SELECT value FROM $config_table"
" WHERE key = :name FOR UPDATE;\n"
"BEGIN\n"
""
@@ -511,8 +507,7 @@ fts_config_increment_value(
ut_a(FTS_MAX_CONFIG_VALUE_LEN > FTS_MAX_INT_LEN);
- // FIXME: Get rid of snprintf
- value.f_len = snprintf(
+ value.f_len = my_snprintf(
(char*) value.f_str, FTS_MAX_INT_LEN, "%lu", int_value);
fts_config_set_value(trx, fts_table, name, &value);
@@ -520,10 +515,8 @@ fts_config_increment_value(
if (UNIV_UNLIKELY(error != DB_SUCCESS)) {
- ut_print_timestamp(stderr);
-
- fprintf(stderr, " InnoDB: Error: (%s) "
- "while incrementing %s.\n", ut_strerr(error), name);
+ ib::error() << "(" << ut_strerr(error) << ") while"
+ " incrementing " << name << ".";
}
ut_free(value.f_str);
@@ -534,7 +527,6 @@ fts_config_increment_value(
/******************************************************************//**
Increment the per index value in the config table for column name.
@return DB_SUCCESS or error code */
-UNIV_INTERN
dberr_t
fts_config_increment_index_value(
/*=============================*/