Commit d7883045 authored by monty@mashka.mysql.fi's avatar monty@mashka.mysql.fi

Fix that -integer works as in 4.0

parent a5cf27b6
...@@ -746,7 +746,7 @@ AC_DEFUN(MYSQL_FIND_OPENSSL, [ ...@@ -746,7 +746,7 @@ AC_DEFUN(MYSQL_FIND_OPENSSL, [
/usr/include/ssl /opt/ssl/include /opt/openssl/include \ /usr/include/ssl /opt/ssl/include /opt/openssl/include \
/usr/local/ssl/include /usr/local/include ; do /usr/local/ssl/include /usr/local/include ; do
if test -f $d/openssl/ssl.h ; then if test -f $d/openssl/ssl.h ; then
OPENSSL_INCLUDE=$d OPENSSL_INCLUDE=-I$d
fi fi
done done
...@@ -757,6 +757,15 @@ AC_DEFUN(MYSQL_FIND_OPENSSL, [ ...@@ -757,6 +757,15 @@ AC_DEFUN(MYSQL_FIND_OPENSSL, [
fi fi
done done
# On RedHat 9 we need kerberos to compile openssl
for d in /usr/kerberos/include
do
if test -f $d/krb5.h ; then
OPENSSL_INCLUDE="$OPENSSL_INCLUDE -I$d"
fi
done
if test -z "$OPENSSL_LIB" -o -z "$OPENSSL_INCLUDE" ; then if test -z "$OPENSSL_LIB" -o -z "$OPENSSL_INCLUDE" ; then
echo "Could not find an installation of OpenSSL" echo "Could not find an installation of OpenSSL"
if test -n "$OPENSSL_LIB" ; then if test -n "$OPENSSL_LIB" ; then
...@@ -789,9 +798,9 @@ AC_MSG_CHECKING(for OpenSSL) ...@@ -789,9 +798,9 @@ AC_MSG_CHECKING(for OpenSSL)
openssl_libs="-L$OPENSSL_LIB -lssl -lcrypto" openssl_libs="-L$OPENSSL_LIB -lssl -lcrypto"
# Don't set openssl_includes to /usr/include as this gives us a lot of # Don't set openssl_includes to /usr/include as this gives us a lot of
# compiler warnings when using gcc 3.x # compiler warnings when using gcc 3.x
if test "$OPENSSL_INCLUDE" != "/usr/include" if test "$OPENSSL_INCLUDE" != "-I/usr/include"
then then
openssl_includes="-I$OPENSSL_INCLUDE" openssl_includes="$OPENSSL_INCLUDE"
fi fi
AC_DEFINE(HAVE_OPENSSL) AC_DEFINE(HAVE_OPENSSL)
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#endif #endif
#include "mysql_priv.h" #include "mysql_priv.h"
#include "slave.h" // for wait_for_master_pos #include "slave.h" // for wait_for_master_pos
#include <m_ctype.h> #include <m_ctype.h>
#include <hash.h> #include <hash.h>
#include <time.h> #include <time.h>
...@@ -31,7 +31,9 @@ ...@@ -31,7 +31,9 @@
#include <zlib.h> #include <zlib.h>
#endif #endif
static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fname)
static void my_coll_agg_error(DTCollation &c1, DTCollation &c2,
const char *fname)
{ {
my_error(ER_CANT_AGGREGATE_2COLLATIONS,MYF(0), my_error(ER_CANT_AGGREGATE_2COLLATIONS,MYF(0),
c1.collation->name,c1.derivation_name(), c1.collation->name,c1.derivation_name(),
...@@ -39,6 +41,7 @@ static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fnam ...@@ -39,6 +41,7 @@ static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fnam
fname); fname);
} }
static void my_coll_agg_error(DTCollation &c1, static void my_coll_agg_error(DTCollation &c1,
DTCollation &c2, DTCollation &c2,
DTCollation &c3, DTCollation &c3,
...@@ -51,11 +54,12 @@ static void my_coll_agg_error(DTCollation &c1, ...@@ -51,11 +54,12 @@ static void my_coll_agg_error(DTCollation &c1,
fname); fname);
} }
static void my_coll_agg_error(Item** args, uint ac, const char *fname)
static void my_coll_agg_error(Item** args, uint count, const char *fname)
{ {
if (2 == ac) if (count == 2)
my_coll_agg_error(args[0]->collation, args[1]->collation, fname); my_coll_agg_error(args[0]->collation, args[1]->collation, fname);
else if (3 == ac) else if (count == 3)
my_coll_agg_error(args[0]->collation, my_coll_agg_error(args[0]->collation,
args[1]->collation, args[1]->collation,
args[2]->collation, args[2]->collation,
...@@ -64,30 +68,32 @@ static void my_coll_agg_error(Item** args, uint ac, const char *fname) ...@@ -64,30 +68,32 @@ static void my_coll_agg_error(Item** args, uint ac, const char *fname)
my_error(ER_CANT_AGGREGATE_NCOLLATIONS,MYF(0),fname); my_error(ER_CANT_AGGREGATE_NCOLLATIONS,MYF(0),fname);
} }
bool Item_func::agg_arg_collations(DTCollation &c, Item **av, uint ac)
bool Item_func::agg_arg_collations(DTCollation &c, Item **av, uint count)
{ {
uint i; uint i;
c.set(av[0]->collation); c.set(av[0]->collation);
for (i= 1; i < ac; i++) for (i= 1; i < count; i++)
{ {
if (c.aggregate(av[i]->collation)) if (c.aggregate(av[i]->collation))
{ {
my_coll_agg_error(av, ac, func_name()); my_coll_agg_error(av, count, func_name());
return TRUE; return TRUE;
} }
} }
return FALSE; return FALSE;
} }
bool Item_func::agg_arg_collations_for_comparison(DTCollation &c, bool Item_func::agg_arg_collations_for_comparison(DTCollation &c,
Item **av, uint ac) Item **av, uint count)
{ {
if (agg_arg_collations(c, av, ac)) if (agg_arg_collations(c, av, count))
return TRUE; return TRUE;
if (c.derivation == DERIVATION_NONE) if (c.derivation == DERIVATION_NONE)
{ {
my_coll_agg_error(av, ac, func_name()); my_coll_agg_error(av, count, func_name());
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
...@@ -102,6 +108,7 @@ eval_const_cond(COND *cond) ...@@ -102,6 +108,7 @@ eval_const_cond(COND *cond)
return ((Item_func*) cond)->val_int() ? TRUE : FALSE; return ((Item_func*) cond)->val_int() ? TRUE : FALSE;
} }
void Item_func::set_arguments(List<Item> &list) void Item_func::set_arguments(List<Item> &list)
{ {
allowed_arg_cols= 1; allowed_arg_cols= 1;
...@@ -586,6 +593,7 @@ double Item_func_neg::val() ...@@ -586,6 +593,7 @@ double Item_func_neg::val()
return -value; return -value;
} }
longlong Item_func_neg::val_int() longlong Item_func_neg::val_int()
{ {
longlong value=args[0]->val_int(); longlong value=args[0]->val_int();
...@@ -593,14 +601,32 @@ longlong Item_func_neg::val_int() ...@@ -593,14 +601,32 @@ longlong Item_func_neg::val_int()
return -value; return -value;
} }
void Item_func_neg::fix_length_and_dec() void Item_func_neg::fix_length_and_dec()
{ {
decimals=args[0]->decimals; decimals=args[0]->decimals;
max_length=args[0]->max_length; max_length=args[0]->max_length;
hybrid_type= args[0]->result_type() == INT_RESULT && !args[0]->unsigned_flag ? hybrid_type= REAL_RESULT;
INT_RESULT : REAL_RESULT; if (args[0]->result_type() == INT_RESULT)
{
/*
If this is in integer context keep the context as integer
(This is how multiplication and other integer functions works)
We must however do a special case in the case where the argument
is a unsigned bigint constant as in this case the only safe
number to convert in integer context is 9223372036854775808.
(This is needed because the lex parser doesn't anymore handle
signed integers)
*/
if (args[0]->type() != INT_ITEM ||
((ulonglong) ((Item_uint*) args[0])->value <=
(ulonglong) LONGLONG_MIN))
hybrid_type= INT_RESULT;
}
} }
double Item_func_abs::val() double Item_func_abs::val()
{ {
double value=args[0]->val(); double value=args[0]->val();
...@@ -608,6 +634,7 @@ double Item_func_abs::val() ...@@ -608,6 +634,7 @@ double Item_func_abs::val()
return fabs(value); return fabs(value);
} }
longlong Item_func_abs::val_int() longlong Item_func_abs::val_int()
{ {
longlong value=args[0]->val_int(); longlong value=args[0]->val_int();
...@@ -615,13 +642,20 @@ longlong Item_func_abs::val_int() ...@@ -615,13 +642,20 @@ longlong Item_func_abs::val_int()
return value >= 0 ? value : -value; return value >= 0 ? value : -value;
} }
void Item_func_abs::fix_length_and_dec() void Item_func_abs::fix_length_and_dec()
{ {
decimals=args[0]->decimals; decimals=args[0]->decimals;
max_length=args[0]->max_length; max_length=args[0]->max_length;
hybrid_type= args[0]->result_type() == INT_RESULT ? INT_RESULT : REAL_RESULT; hybrid_type= REAL_RESULT;
if (args[0]->result_type() == INT_RESULT)
{
hybrid_type= INT_RESULT;
unsigned_flag= 1;
}
} }
/* Gateway to natural LOG function */ /* Gateway to natural LOG function */
double Item_func_ln::val() double Item_func_ln::val()
{ {
...@@ -1051,6 +1085,7 @@ longlong Item_func_crc32::val_int() ...@@ -1051,6 +1085,7 @@ longlong Item_func_crc32::val_int()
return (longlong) crc32(0L, (Bytef*)res->ptr(), res->length()); return (longlong) crc32(0L, (Bytef*)res->ptr(), res->length());
} }
longlong Item_func_uncompressed_length::val_int() longlong Item_func_uncompressed_length::val_int()
{ {
String *res= args[0]->val_str(&value); String *res= args[0]->val_str(&value);
...@@ -1063,9 +1098,9 @@ longlong Item_func_uncompressed_length::val_int() ...@@ -1063,9 +1098,9 @@ longlong Item_func_uncompressed_length::val_int()
if (res->is_empty()) return 0; if (res->is_empty()) return 0;
return uint4korr(res->c_ptr()) & 0x3FFFFFFF; return uint4korr(res->c_ptr()) & 0x3FFFFFFF;
} }
#endif /* HAVE_COMPRESS */ #endif /* HAVE_COMPRESS */
longlong Item_func_length::val_int() longlong Item_func_length::val_int()
{ {
String *res=args[0]->val_str(&value); String *res=args[0]->val_str(&value);
...@@ -1078,6 +1113,7 @@ longlong Item_func_length::val_int() ...@@ -1078,6 +1113,7 @@ longlong Item_func_length::val_int()
return (longlong) res->length(); return (longlong) res->length();
} }
longlong Item_func_char_length::val_int() longlong Item_func_char_length::val_int()
{ {
String *res=args[0]->val_str(&value); String *res=args[0]->val_str(&value);
...@@ -1090,6 +1126,7 @@ longlong Item_func_char_length::val_int() ...@@ -1090,6 +1126,7 @@ longlong Item_func_char_length::val_int()
return (longlong) res->numchars(); return (longlong) res->numchars();
} }
longlong Item_func_coercibility::val_int() longlong Item_func_coercibility::val_int()
{ {
if (args[0]->null_value) if (args[0]->null_value)
...@@ -1101,12 +1138,14 @@ longlong Item_func_coercibility::val_int() ...@@ -1101,12 +1138,14 @@ longlong Item_func_coercibility::val_int()
return (longlong) args[0]->derivation(); return (longlong) args[0]->derivation();
} }
void Item_func_locate::fix_length_and_dec() void Item_func_locate::fix_length_and_dec()
{ {
maybe_null=0; max_length=11; maybe_null=0; max_length=11;
agg_arg_collations_for_comparison(cmp_collation, args, 2); agg_arg_collations_for_comparison(cmp_collation, args, 2);
} }
longlong Item_func_locate::val_int() longlong Item_func_locate::val_int()
{ {
String *a=args[0]->val_str(&value1); String *a=args[0]->val_str(&value1);
...@@ -1207,6 +1246,7 @@ longlong Item_func_field::val_int() ...@@ -1207,6 +1246,7 @@ longlong Item_func_field::val_int()
return 0; return 0;
} }
void Item_func_field::fix_length_and_dec() void Item_func_field::fix_length_and_dec()
{ {
maybe_null=0; max_length=3; maybe_null=0; max_length=3;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment