@@ -29,98 +29,52 @@ Created 2007/5/9 Sunny Bains
2929
3030#include " fts0priv.h"
3131
32- /* *****************************************************************/ /* *
33- Callback function for fetching the config value.
34- @return always returns TRUE */
35- static
36- ibool
37- fts_config_fetch_value (
38- /* ===================*/
39- void * row, /* !< in: sel_node_t* */
40- void * user_arg) /* !< in: pointer to
41- ib_vector_t */
32+ /* * Callback function for fetching the config value. */
33+ void read_fts_config (const rec_t *rec, const rec_offs *offsets,
34+ void *user_arg)
4235{
43- sel_node_t * node = static_cast <sel_node_t *>(row);
44- fts_string_t * value = static_cast <fts_string_t *>(user_arg);
45-
46- dfield_t * dfield = que_node_get_val (node->select_list );
47- dtype_t * type = dfield_get_type (dfield);
48- ulint len = dfield_get_len (dfield);
49- void * data = dfield_get_data (dfield);
50-
51- ut_a (dtype_get_mtype (type) == DATA_VARCHAR);
52-
53- if (len != UNIV_SQL_NULL) {
54- ulint max_len = ut_min (value->f_len - 1 , len);
55-
56- memcpy (value->f_str , data, max_len);
57- value->f_len = max_len;
58- value->f_str [value->f_len ] = ' \0 ' ;
59- }
60-
61- return (TRUE );
36+ ulint len;
37+ fts_string_t *value= static_cast <fts_string_t *>(user_arg);
38+ const byte *data= rec_get_nth_field (rec, offsets, 3 , &len);
39+ if (len != UNIV_SQL_NULL)
40+ {
41+ ulint max_len= ut_min (value->f_len - 1 , len);
42+ memcpy (value->f_str , data, max_len);
43+ value->f_len = max_len;
44+ value->f_str [value->f_len ]= ' \0 ' ;
45+ }
6246}
6347
64- /* *****************************************************************/ /* *
65- Get value from the config table. The caller must ensure that enough
48+ /* * Get value from the config table. The caller must ensure that enough
6649space is allocated for value to hold the column contents.
50+ @param trx transaction
51+ @param fts_table indexed FTS table
52+ @param name get config value for this parameter name
53+ @param value Value read from config table
6754@return DB_SUCCESS or error code */
68- dberr_t
69- fts_config_get_value (
70- /* =================*/
71- trx_t * trx, /* !< transaction */
72- fts_table_t * fts_table, /* !< in: the indexed
73- FTS table */
74- const char * name, /* !< in: get config value for
75- this parameter name */
76- fts_string_t * value) /* !< out: value read from
77- config table */
55+ dberr_t fts_config_get_value (trx_t *trx, fts_table_t *fts_table,
56+ const char *name, fts_string_t *value)
7857{
79- pars_info_t * info;
80- que_t * graph;
81- dberr_t error;
82- ulint name_len = strlen (name);
83- char table_name[MAX_FULL_NAME_LEN];
84-
85- info = pars_info_create ();
86-
87- *value->f_str = ' \0 ' ;
88- ut_a (value->f_len > 0 );
89-
90- pars_info_bind_function (info, " my_func" , fts_config_fetch_value,
91- value);
92-
93- /* The len field of value must be set to the max bytes that
94- it can hold. On a successful read, the len field will be set
95- to the actual number of bytes copied to value. */
96- pars_info_bind_varchar_literal (info, " name" , (byte*) name, name_len);
97-
98- fts_table->suffix = " CONFIG" ;
99- fts_get_table_name (fts_table, table_name);
100- pars_info_bind_id (info, " table_name" , table_name);
101-
102- graph = fts_parse_sql (
103- fts_table,
104- info,
105- " DECLARE FUNCTION my_func;\n "
106- " DECLARE CURSOR c IS SELECT value FROM $table_name"
107- " WHERE key = :name;\n "
108- " BEGIN\n "
109- " "
110- " OPEN c;\n "
111- " WHILE 1 = 1 LOOP\n "
112- " FETCH c INTO my_func();\n "
113- " IF c % NOTFOUND THEN\n "
114- " EXIT;\n "
115- " END IF;\n "
116- " END LOOP;\n "
117- " CLOSE c;" );
118-
119- trx->op_info = " getting FTS config value" ;
120-
121- error = fts_eval_sql (trx, graph);
122- que_graph_free (graph);
123- return (error);
58+ FTSQueryExecutor executor (trx);
59+ fts_table->suffix = " CONFIG" ;
60+ dict_table_t *table= nullptr ;
61+ dberr_t err= executor.open_table (fts_table, &table);
62+ if (err == DB_SUCCESS)
63+ {
64+ err= executor.prepare_for_read (table);
65+ if (err == DB_SUCCESS)
66+ {
67+ executor.build_tuple (table, 1 , 1 );
68+ executor.assign_config_fields (name);
69+ *value->f_str = ' \0 ' ;
70+ ut_a (value->f_len > 0 );
71+ err= executor.search_tuple (table, &read_fts_config, value);
72+ if (err == DB_END_OF_INDEX || err == DB_RECORD_NOT_FOUND)
73+ err= DB_SUCCESS;
74+ }
75+ }
76+ if (table) table->release ();
77+ return err;
12478}
12579
12680/* ********************************************************************/ /* *
0 commit comments