summaryrefslogtreecommitdiff
path: root/storage/innobase/eval/eval0eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/eval/eval0eval.c')
-rw-r--r--storage/innobase/eval/eval0eval.c120
1 files changed, 68 insertions, 52 deletions
diff --git a/storage/innobase/eval/eval0eval.c b/storage/innobase/eval/eval0eval.c
index 52e9923fc05..fc34ce83a0f 100644
--- a/storage/innobase/eval/eval0eval.c
+++ b/storage/innobase/eval/eval0eval.c
@@ -1,9 +1,26 @@
-/******************************************************
+/*****************************************************************************
+
+Copyright (c) 1997, 2009, Innobase Oy. 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
+Foundation; version 2 of the License.
+
+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 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 eval/eval0eval.c
SQL evaluator: evaluates simple data structures, like expressions, in
a query graph
-(c) 1997 Innobase Oy
-
Created 12/29/1997 Heikki Tuuri
*******************************************************/
@@ -16,29 +33,29 @@ Created 12/29/1997 Heikki Tuuri
#include "data0data.h"
#include "row0sel.h"
-/* The RND function seed */
-ulint eval_rnd = 128367121;
+/** The RND function seed */
+static ulint eval_rnd = 128367121;
-/* Dummy adress used when we should allocate a buffer of size 0 in
-the function below */
+/** Dummy adress used when we should allocate a buffer of size 0 in
+eval_node_alloc_val_buf */
-byte eval_dummy;
+static byte eval_dummy;
-/*********************************************************************
+/*****************************************************************//**
Allocate a buffer from global dynamic memory for a value of a que_node.
NOTE that this memory must be explicitly freed when the query graph is
freed. If the node already has an allocated buffer, that buffer is freed
here. NOTE that this is the only function where dynamic memory should be
-allocated for a query node val field. */
-
+allocated for a query node val field.
+@return pointer to allocated buffer */
+UNIV_INTERN
byte*
eval_node_alloc_val_buf(
/*====================*/
- /* out: pointer to allocated buffer */
- que_node_t* node, /* in: query graph node; sets the val field
+ que_node_t* node, /*!< in: query graph node; sets the val field
data field to point to the new buffer, and
len field equal to size */
- ulint size) /* in: buffer size */
+ ulint size) /*!< in: buffer size */
{
dfield_t* dfield;
byte* data;
@@ -67,15 +84,15 @@ eval_node_alloc_val_buf(
return(data);
}
-/*********************************************************************
+/*****************************************************************//**
Free the buffer from global dynamic memory for a value of a que_node,
if it has been allocated in the above function. The freeing for pushed
column values is done in sel_col_prefetch_buf_free. */
-
+UNIV_INTERN
void
eval_node_free_val_buf(
/*===================*/
- que_node_t* node) /* in: query graph node */
+ que_node_t* node) /*!< in: query graph node */
{
dfield_t* dfield;
byte* data;
@@ -94,14 +111,14 @@ eval_node_free_val_buf(
}
}
-/*********************************************************************
-Evaluates a comparison node. */
-
+/*****************************************************************//**
+Evaluates a comparison node.
+@return the result of the comparison */
+UNIV_INTERN
ibool
eval_cmp(
/*=====*/
- /* out: the result of the comparison */
- func_node_t* cmp_node) /* in: comparison node */
+ func_node_t* cmp_node) /*!< in: comparison node */
{
que_node_t* arg1;
que_node_t* arg2;
@@ -153,13 +170,13 @@ eval_cmp(
return(val);
}
-/*********************************************************************
+/*****************************************************************//**
Evaluates a logical operation node. */
UNIV_INLINE
void
eval_logical(
/*=========*/
- func_node_t* logical_node) /* in: logical operation node */
+ func_node_t* logical_node) /*!< in: logical operation node */
{
que_node_t* arg1;
que_node_t* arg2;
@@ -194,13 +211,13 @@ eval_logical(
eval_node_set_ibool_val(logical_node, val);
}
-/*********************************************************************
+/*****************************************************************//**
Evaluates an arithmetic operation node. */
UNIV_INLINE
void
eval_arith(
/*=======*/
- func_node_t* arith_node) /* in: arithmetic operation node */
+ func_node_t* arith_node) /*!< in: arithmetic operation node */
{
que_node_t* arg1;
que_node_t* arg2;
@@ -238,13 +255,13 @@ eval_arith(
eval_node_set_int_val(arith_node, val);
}
-/*********************************************************************
+/*****************************************************************//**
Evaluates an aggregate operation node. */
UNIV_INLINE
void
eval_aggregate(
/*===========*/
- func_node_t* node) /* in: aggregate operation node */
+ func_node_t* node) /*!< in: aggregate operation node */
{
que_node_t* arg;
lint val;
@@ -272,14 +289,14 @@ eval_aggregate(
eval_node_set_int_val(node, val);
}
-/*********************************************************************
+/*****************************************************************//**
Evaluates a predefined function node where the function is not relevant
in benchmarks. */
static
void
eval_predefined_2(
/*==============*/
- func_node_t* func_node) /* in: predefined function node */
+ func_node_t* func_node) /*!< in: predefined function node */
{
que_node_t* arg;
que_node_t* arg1;
@@ -359,13 +376,13 @@ eval_predefined_2(
}
}
-/*********************************************************************
+/*****************************************************************//**
Evaluates a notfound-function node. */
UNIV_INLINE
void
eval_notfound(
/*==========*/
- func_node_t* func_node) /* in: function node */
+ func_node_t* func_node) /*!< in: function node */
{
sym_node_t* cursor;
sel_node_t* sel_node;
@@ -396,13 +413,13 @@ eval_notfound(
eval_node_set_ibool_val(func_node, ibool_val);
}
-/*********************************************************************
+/*****************************************************************//**
Evaluates a substr-function node. */
UNIV_INLINE
void
eval_substr(
/*========*/
- func_node_t* func_node) /* in: function node */
+ func_node_t* func_node) /*!< in: function node */
{
que_node_t* arg1;
que_node_t* arg2;
@@ -429,13 +446,13 @@ eval_substr(
dfield_set_data(dfield, str1 + len1, len2);
}
-/*********************************************************************
+/*****************************************************************//**
Evaluates a replstr-procedure node. */
static
void
eval_replstr(
/*=========*/
- func_node_t* func_node) /* in: function node */
+ func_node_t* func_node) /*!< in: function node */
{
que_node_t* arg1;
que_node_t* arg2;
@@ -469,13 +486,13 @@ eval_replstr(
ut_memcpy(str1 + len1, str2, len2);
}
-/*********************************************************************
+/*****************************************************************//**
Evaluates an instr-function node. */
static
void
eval_instr(
/*=======*/
- func_node_t* func_node) /* in: function node */
+ func_node_t* func_node) /*!< in: function node */
{
que_node_t* arg1;
que_node_t* arg2;
@@ -541,13 +558,13 @@ match_found:
eval_node_set_int_val(func_node, int_val);
}
-/*********************************************************************
+/*****************************************************************//**
Evaluates a predefined function node. */
UNIV_INLINE
void
eval_binary_to_number(
/*==================*/
- func_node_t* func_node) /* in: function node */
+ func_node_t* func_node) /*!< in: function node */
{
que_node_t* arg1;
dfield_t* dfield;
@@ -579,13 +596,13 @@ eval_binary_to_number(
eval_node_copy_and_alloc_val(func_node, str2, 4);
}
-/*********************************************************************
+/*****************************************************************//**
Evaluates a predefined function node. */
static
void
eval_concat(
/*========*/
- func_node_t* func_node) /* in: function node */
+ func_node_t* func_node) /*!< in: function node */
{
que_node_t* arg;
dfield_t* dfield;
@@ -621,7 +638,7 @@ eval_concat(
}
}
-/*********************************************************************
+/*****************************************************************//**
Evaluates a predefined function node. If the first argument is an integer,
this function looks at the second argument which is the integer length in
bytes, and converts the integer to a VARCHAR.
@@ -631,7 +648,7 @@ UNIV_INLINE
void
eval_to_binary(
/*===========*/
- func_node_t* func_node) /* in: function node */
+ func_node_t* func_node) /*!< in: function node */
{
que_node_t* arg1;
que_node_t* arg2;
@@ -669,13 +686,13 @@ eval_to_binary(
dfield_set_data(dfield, str1 + (4 - len1), len1);
}
-/*********************************************************************
+/*****************************************************************//**
Evaluates a predefined function node. */
UNIV_INLINE
void
eval_predefined(
/*============*/
- func_node_t* func_node) /* in: function node */
+ func_node_t* func_node) /*!< in: function node */
{
que_node_t* arg1;
lint int_val;
@@ -741,8 +758,7 @@ eval_predefined(
}
}
- dfield_set_len((dfield_t*) que_node_get_val(func_node),
- int_len);
+ dfield_set_len(que_node_get_val(func_node), int_len);
return;
@@ -762,13 +778,13 @@ eval_predefined(
eval_node_set_int_val(func_node, int_val);
}
-/*********************************************************************
+/*****************************************************************//**
Evaluates a function node. */
-
+UNIV_INTERN
void
eval_func(
/*======*/
- func_node_t* func_node) /* in: function node */
+ func_node_t* func_node) /*!< in: function node */
{
que_node_t* arg;
ulint class;
@@ -788,7 +804,7 @@ eval_func(
/* The functions are not defined for SQL null argument
values, except for eval_cmp and notfound */
- if ((dfield_get_len(que_node_get_val(arg)) == UNIV_SQL_NULL)
+ if (dfield_is_null(que_node_get_val(arg))
&& (class != PARS_FUNC_CMP)
&& (func != PARS_NOTFOUND_TOKEN)
&& (func != PARS_PRINTF_TOKEN)) {