summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorndbdev@dl145c.mysql.com <>2005-05-20 06:25:02 +0200
committerndbdev@dl145c.mysql.com <>2005-05-20 06:25:02 +0200
commitf0f8b0a97bcccf5d082d802f0766222d78ffc6b7 (patch)
tree57c3e1e510646f339bdaeadb1d430a67bcf5e402 /sql
parent4b47828478963effbfacc064aedef1ce2bc30ed0 (diff)
parented674271d46fdc0f0ea2bde408d00c45e74fe72a (diff)
downloadmariadb-git-f0f8b0a97bcccf5d082d802f0766222d78ffc6b7.tar.gz
Merge tulin@bk-internal.mysql.com:/home/bk/mysql-5.0
into dl145c.mysql.com:/home/ndbdev/tomas/mysql-5.1
Diffstat (limited to 'sql')
-rw-r--r--sql/gen_lex_hash.cc4
-rw-r--r--sql/ha_ndbcluster.cc22
-rw-r--r--sql/item_func.cc22
-rw-r--r--sql/item_strfunc.cc1
-rw-r--r--sql/mysql_priv.h1
-rw-r--r--sql/spatial.cc47
-rw-r--r--sql/sql_list.h48
-rw-r--r--sql/sql_udf.cc10
-rw-r--r--sql/unireg.cc1
9 files changed, 100 insertions, 56 deletions
diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc
index c3206de3cd4..7e0b178f7af 100644
--- a/sql/gen_lex_hash.cc
+++ b/sql/gen_lex_hash.cc
@@ -459,8 +459,8 @@ int main(int argc,char **argv)
generate_find_structs();
print_find_structs();
- printf("\static unsigned int sql_functions_max_len=%d;\n",max_len);
- printf("\static unsigned int symbols_max_len=%d;\n\n",max_len2);
+ printf("\nstatic unsigned int sql_functions_max_len=%d;\n", max_len);
+ printf("\nstatic unsigned int symbols_max_len=%d;\n\n", max_len2);
printf("\
static inline SYMBOL *get_hash_symbol(const char *s,\n\
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index c16113e61d1..3a21258cf70 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -984,16 +984,13 @@ static int fix_unique_index_attr_order(NDB_INDEX_DATA &data,
for (unsigned i= 0; key_part != end; key_part++, i++)
{
const char *field_name= key_part->field->field_name;
- unsigned name_sz= strlen(field_name);
- if (name_sz >= NDB_MAX_ATTR_NAME_SIZE)
- name_sz= NDB_MAX_ATTR_NAME_SIZE-1;
#ifndef DBUG_OFF
data.unique_index_attrid_map[i]= 255;
#endif
for (unsigned j= 0; j < sz; j++)
{
const NDBCOL *c= index->getColumn(j);
- if (strncmp(field_name, c->getName(), name_sz) == 0)
+ if (strcmp(field_name, c->getName()) == 0)
{
data.unique_index_attrid_map[i]= j;
break;
@@ -3449,12 +3446,7 @@ static int create_ndb_column(NDBCOL &col,
HA_CREATE_INFO *info)
{
// Set name
- {
- char truncated_field_name[NDB_MAX_ATTR_NAME_SIZE];
- strnmov(truncated_field_name,field->field_name,sizeof(truncated_field_name));
- truncated_field_name[sizeof(truncated_field_name)-1]= '\0';
- col.setName(truncated_field_name);
- }
+ col.setName(field->field_name);
// Get char set
CHARSET_INFO *cs= field->charset();
// Set type and sizes
@@ -3944,12 +3936,7 @@ int ha_ndbcluster::create_index(const char *name,
{
Field *field= key_part->field;
DBUG_PRINT("info", ("attr: %s", field->field_name));
- {
- char truncated_field_name[NDB_MAX_ATTR_NAME_SIZE];
- strnmov(truncated_field_name,field->field_name,sizeof(truncated_field_name));
- truncated_field_name[sizeof(truncated_field_name)-1]= '\0';
- ndb_index.addColumnName(truncated_field_name);
- }
+ ndb_index.addColumnName(field->field_name);
}
if (dict->createIndex(ndb_index))
@@ -5409,7 +5396,8 @@ ndb_get_table_statistics(Ndb* ndb, const char * table,
DBUG_RETURN(0);
} while(0);
- ndb->closeTransaction(pTrans);
+ if (pTrans)
+ ndb->closeTransaction(pTrans);
DBUG_PRINT("exit", ("failed"));
DBUG_RETURN(-1);
}
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 89f9111101a..db2aa735b0e 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -1880,22 +1880,16 @@ void Item_func_round::fix_length_and_dec()
}
}
-double Item_func_round::real_op()
+double my_double_round(double value, int dec, bool truncate)
{
- double value= args[0]->val_real();
- int dec=(int) args[1]->val_int();
- if (dec > 0)
- decimals= dec; // to get correct output
- uint abs_dec=abs(dec);
double tmp;
+ uint abs_dec= abs(dec);
/*
tmp2 is here to avoid return the value with 80 bit precision
This will fix that the test round(0.1,1) = round(0.1,1) is true
*/
volatile double tmp2;
- if ((null_value=args[0]->null_value || args[1]->null_value))
- return 0.0;
tmp=(abs_dec < array_elements(log_10) ?
log_10[abs_dec] : pow(10.0,(double) abs_dec));
@@ -1912,6 +1906,18 @@ double Item_func_round::real_op()
}
+double Item_func_round::real_op()
+{
+ double value= args[0]->val_real();
+ int dec= (int) args[1]->val_int();
+
+ if (!(null_value= args[0]->null_value || args[1]->null_value))
+ return my_double_round(value, dec, truncate);
+
+ return 0.0;
+}
+
+
longlong Item_func_round::int_op()
{
longlong value= args[0]->val_int();
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 52449f6d91c..857140dba8f 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1673,6 +1673,7 @@ String *Item_func_format::val_str(String *str)
int diff;
if ((null_value=args[0]->null_value))
return 0; /* purecov: inspected */
+ nr= my_double_round(nr, decimals, FALSE);
dec= decimals ? decimals+1 : 0;
/* Here default_charset() is right as this is not an automatic conversion */
str->set(nr,decimals, default_charset());
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 6ff5bc34721..9ee1f5ca7ce 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -1254,6 +1254,7 @@ ha_rows filesort(THD *thd, TABLE *form,struct st_sort_field *sortorder,
ha_rows max_rows, ha_rows *examined_rows);
void filesort_free_buffers(TABLE *table);
void change_double_for_sort(double nr,byte *to);
+double my_double_round(double value, int dec, bool truncate);
int get_quick_record(SQL_SELECT *select);
int calc_weekday(long daynr,bool sunday_first_day_of_week);
uint calc_week(TIME *l_time, uint week_behaviour, uint *year);
diff --git a/sql/spatial.cc b/sql/spatial.cc
index 427648850e4..176f1f2fbfe 100644
--- a/sql/spatial.cc
+++ b/sql/spatial.cc
@@ -98,6 +98,12 @@ static Geometry::Class_info
geometrycollection_class("GEOMETRYCOLLECTION",Geometry::wkb_geometrycollection,
create_geometrycollection);
+static void get_point(double *x, double *y, const char *data)
+{
+ float8get(*x, data);
+ float8get(*y, data + SIZEOF_STORED_DOUBLE);
+}
+
/***************************** Geometry *******************************/
Geometry::Class_info *Geometry::find_class(const char *name, uint32 len)
@@ -268,14 +274,13 @@ const char *Geometry::append_points(String *txt, uint32 n_points,
{
while (n_points--)
{
- double d;
+ double x,y;
data+= offset;
- float8get(d, data);
- txt->qs_append(d);
- txt->qs_append(' ');
- float8get(d, data + SIZEOF_STORED_DOUBLE);
+ get_point(&x, &y, data);
data+= SIZEOF_STORED_DOUBLE * 2;
- txt->qs_append(d);
+ txt->qs_append(x);
+ txt->qs_append(' ');
+ txt->qs_append(y);
txt->qs_append(',');
}
return data;
@@ -428,8 +433,7 @@ bool Gis_line_string::get_data_as_wkt(String *txt, const char **end) const
while (n_points--)
{
double x, y;
- float8get(x, data);
- float8get(y, data + SIZEOF_STORED_DOUBLE);
+ get_point(&x, &y, data);
data+= SIZEOF_STORED_DOUBLE * 2;
txt->qs_append(x);
txt->qs_append(' ');
@@ -462,15 +466,13 @@ int Gis_line_string::length(double *len) const
if (n_points < 1 || no_data(data, SIZEOF_STORED_DOUBLE * 2 * n_points))
return 1;
- float8get(prev_x, data);
- float8get(prev_y, data + SIZEOF_STORED_DOUBLE);
+ get_point(&prev_x, &prev_y, data);
data+= SIZEOF_STORED_DOUBLE*2;
while (--n_points)
{
double x, y;
- float8get(x, data);
- float8get(y, data + SIZEOF_STORED_DOUBLE);
+ get_point(&x, &y, data);
data+= SIZEOF_STORED_DOUBLE * 2;
*len+= sqrt(pow(prev_x-x,2)+pow(prev_y-y,2));
prev_x= x;
@@ -499,13 +501,11 @@ int Gis_line_string::is_closed(int *closed) const
return 1;
/* Get first point */
- float8get(x1, data);
- float8get(y1, data + SIZEOF_STORED_DOUBLE);
+ get_point(&x1, &y1, data);
/* get last point */
data+= SIZEOF_STORED_DOUBLE*2 + (n_points-2)*POINT_DATA_SIZE;
- float8get(x2, data);
- float8get(y2, data + SIZEOF_STORED_DOUBLE);
+ get_point(&x2, &y2, data);
*closed= (x1==x2) && (y1==y2);
return 0;
@@ -683,15 +683,13 @@ int Gis_polygon::area(double *ar, const char **end_of_data) const
n_points= uint4korr(data);
if (no_data(data, (SIZEOF_STORED_DOUBLE*2) * n_points))
return 1;
- float8get(prev_x, data+4);
- float8get(prev_y, data+(4+SIZEOF_STORED_DOUBLE));
+ get_point(&prev_x, &prev_y, data+4);
data+= (4+SIZEOF_STORED_DOUBLE*2);
while (--n_points) // One point is already read
{
double x, y;
- float8get(x, data);
- float8get(y, data + SIZEOF_STORED_DOUBLE);
+ get_point(&x, &y, data);
data+= (SIZEOF_STORED_DOUBLE*2);
/* QQ: Is the following prev_x+x right ? */
lr_area+= (prev_x + x)* (prev_y - y);
@@ -781,7 +779,8 @@ int Gis_polygon::interior_ring_n(uint32 num, String *result) const
int Gis_polygon::centroid_xy(double *x, double *y) const
{
uint32 n_linear_rings;
- double res_area, res_cx, res_cy;
+ double res_area;
+ double res_cx, res_cy;
const char *data= m_data;
bool first_loop= 1;
LINT_INIT(res_area);
@@ -807,15 +806,13 @@ int Gis_polygon::centroid_xy(double *x, double *y) const
data+= 4;
if (no_data(data, (SIZEOF_STORED_DOUBLE*2) * n_points))
return 1;
- float8get(prev_x, data);
- float8get(prev_y, data+SIZEOF_STORED_DOUBLE);
+ get_point(&prev_x, &prev_y, data);
data+= (SIZEOF_STORED_DOUBLE*2);
while (--n_points) // One point is already read
{
double x, y;
- float8get(x, data);
- float8get(y, data + SIZEOF_STORED_DOUBLE);
+ get_point(&x, &y, data);
data+= (SIZEOF_STORED_DOUBLE*2);
/* QQ: Is the following prev_x+x right ? */
cur_area+= (prev_x + x) * (prev_y - y);
diff --git a/sql/sql_list.h b/sql/sql_list.h
index ac0f7f7012a..09c01931c38 100644
--- a/sql/sql_list.h
+++ b/sql/sql_list.h
@@ -192,6 +192,54 @@ public:
friend class error_list;
friend class error_list_iterator;
+#ifdef LIST_EXTRA_DEBUG
+ /*
+ Check list invariants and print results into trace. Invariants are:
+ - (*last) points to end_of_list
+ - There are no NULLs in the list.
+ - base_list::elements is the number of elements in the list.
+
+ SYNOPSIS
+ check_list()
+ name Name to print to trace file
+
+ RETURN
+ 1 The list is Ok.
+ 0 List invariants are not met.
+ */
+
+ bool check_list(const char *name)
+ {
+ base_list *list= this;
+ list_node *node= first;
+ uint cnt= 0;
+
+ while (node->next != &end_of_list)
+ {
+ if (!node->info)
+ {
+ DBUG_PRINT("list_invariants",("%s: error: NULL element in the list",
+ name));
+ return FALSE;
+ }
+ node= node->next;
+ cnt++;
+ }
+ if (last != &(node->next))
+ {
+ DBUG_PRINT("list_invariants", ("%s: error: wrong last pointer", name));
+ return FALSE;
+ }
+ if (cnt+1 != elements)
+ {
+ DBUG_PRINT("list_invariants", ("%s: error: wrong element count", name));
+ return FALSE;
+ }
+ DBUG_PRINT("list_invariants", ("%s: list is ok", name));
+ return TRUE;
+ }
+#endif // LIST_EXTRA_DEBUG
+
protected:
void after(void *info,list_node *node)
{
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index dc6e8380cfe..575d75380eb 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -194,7 +194,9 @@ void udf_init()
This is done to ensure that only approved dll from the system
directories are used (to make this even remotely secure).
*/
- if (strchr(dl_name, '/') || name.length > NAME_LEN)
+ if (strchr(dl_name, '/') ||
+ IF_WIN(strchr(dl_name, '\\'),0) ||
+ strlen(name.str) > NAME_LEN)
{
sql_print_error("Invalid row in mysql.func table for function '%.64s'",
name.str);
@@ -223,7 +225,7 @@ void udf_init()
}
tmp->dlhandle = dl;
{
- char buf[MAX_FIELD_NAME+16], *missing;
+ char buf[NAME_LEN+16], *missing;
if ((missing= init_syms(tmp, buf)))
{
sql_print_error(ER(ER_CANT_FIND_DL_ENTRY), missing);
@@ -410,7 +412,7 @@ int mysql_create_function(THD *thd,udf_func *udf)
This is done to ensure that only approved dll from the system
directories are used (to make this even remotely secure).
*/
- if (strchr(udf->dl, '/'))
+ if (strchr(udf->dl, '/') || IF_WIN(strchr(dl_name, '\\'),0))
{
my_message(ER_UDF_NO_PATHS, ER(ER_UDF_NO_PATHS), MYF(0));
DBUG_RETURN(1);
@@ -441,7 +443,7 @@ int mysql_create_function(THD *thd,udf_func *udf)
}
udf->dlhandle=dl;
{
- char buf[MAX_FIELD_NAME+16], *missing;
+ char buf[NAME_LEN+16], *missing;
if ((missing= init_syms(udf, buf)))
{
my_error(ER_CANT_FIND_DL_ENTRY, MYF(0), missing);
diff --git a/sql/unireg.cc b/sql/unireg.cc
index 629fb20f9dd..4c647fcb07c 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -27,6 +27,7 @@
#define USES_TYPES
#include "mysql_priv.h"
#include <m_ctype.h>
+#include <assert.h>
#define FCOMP 17 /* Bytes for a packed field */