Commit d2aa1fb8 authored by peter@mysql.com's avatar peter@mysql.com

Merge mysql.com:/home/pz/mysql/mysql-4.1-root

into mysql.com:/home/pz/mysql/mysql-4.1
parents 925155cf 39c73021
...@@ -57,6 +57,9 @@ typedef int my_socket; ...@@ -57,6 +57,9 @@ typedef int my_socket;
#include "mysql_com.h" #include "mysql_com.h"
#include "mysql_version.h" #include "mysql_version.h"
#include "typelib.h" #include "typelib.h"
#ifndef DBUG_OFF
#define CHECK_EXTRA_ARGUMENTS
#endif
extern unsigned int mysql_port; extern unsigned int mysql_port;
extern char *mysql_unix_port; extern char *mysql_unix_port;
...@@ -424,7 +427,7 @@ int STDCALL mysql_manager_fetch_line(MYSQL_MANAGER* con, ...@@ -424,7 +427,7 @@ int STDCALL mysql_manager_fetch_line(MYSQL_MANAGER* con,
*/ */
/* statement state */ /* statement state */
enum MY_STMT_STATE { MY_ST_UNKNOWN, MY_ST_PREPARE, MY_ST_EXECUTE }; enum PREP_STMT_STATE { MY_ST_UNKNOWN, MY_ST_PREPARE, MY_ST_EXECUTE };
/* bind structure */ /* bind structure */
typedef struct st_mysql_bind typedef struct st_mysql_bind
...@@ -442,7 +445,7 @@ typedef struct st_mysql_bind ...@@ -442,7 +445,7 @@ typedef struct st_mysql_bind
my_bool long_ended; /* All data supplied for long */ my_bool long_ended; /* All data supplied for long */
unsigned int param_number; /* For null count and error messages */ unsigned int param_number; /* For null count and error messages */
void (*store_param_func)(NET *net, struct st_mysql_bind *param); void (*store_param_func)(NET *net, struct st_mysql_bind *param);
char *(*fetch_result)(struct st_mysql_bind *, const char *row); void (*fetch_result)(struct st_mysql_bind *, unsigned char **row);
} MYSQL_BIND; } MYSQL_BIND;
...@@ -462,10 +465,12 @@ typedef struct st_mysql_stmt ...@@ -462,10 +465,12 @@ typedef struct st_mysql_stmt
unsigned long long_length; /* long buffer alloced length */ unsigned long long_length; /* long buffer alloced length */
unsigned long stmt_id; /* Id for prepared statement */ unsigned long stmt_id; /* Id for prepared statement */
unsigned int last_errno; /* error code */ unsigned int last_errno; /* error code */
enum MY_STMT_STATE state; /* statement state */ enum PREP_STMT_STATE state; /* statement state */
char last_error[MYSQL_ERRMSG_SIZE]; /* error message */ char last_error[MYSQL_ERRMSG_SIZE]; /* error message */
my_bool long_alloced; /* flag to indicate long alloced */ my_bool long_alloced; /* flag to indicate long alloced */
my_bool types_supplied; /* to indicate types supply */ my_bool send_types_to_server; /* to indicate types supply to server */
my_bool param_buffers; /* to indicate the param bound buffers */
my_bool res_buffers; /* to indicate the result bound buffers */
} MYSQL_STMT; } MYSQL_STMT;
......
...@@ -312,6 +312,7 @@ void my_thread_end(void); ...@@ -312,6 +312,7 @@ void my_thread_end(void);
#endif #endif
#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */ #define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
#define MYSQL_STMT_HEADER 4
#define MYSQL_LONG_DATA_HEADER 8 #define MYSQL_LONG_DATA_HEADER 8
#endif #endif
...@@ -261,4 +261,5 @@ ...@@ -261,4 +261,5 @@
#define ER_CORRUPT_HELP_DB 1242 #define ER_CORRUPT_HELP_DB 1242
#define ER_CYCLIC_REFERENCE 1243 #define ER_CYCLIC_REFERENCE 1243
#define ER_AUTO_CONVERT 1244 #define ER_AUTO_CONVERT 1244
#define ER_ERROR_MESSAGES 245 #define ER_ILLEGAL_REFERENCE 1245
#define ER_ERROR_MESSAGES 246
...@@ -59,7 +59,7 @@ const char *client_errors[]= ...@@ -59,7 +59,7 @@ const char *client_errors[]=
"No parameters exists in the statement", "No parameters exists in the statement",
"Invalid parameter number", "Invalid parameter number",
"Can't send long data for non string or binary data types (parameter: %d)", "Can't send long data for non string or binary data types (parameter: %d)",
"Using not supported parameter type: %d (parameter: %d)" "Using un supported parameter type: %d (parameter: %d)"
"Shared memory (%lu)", "Shared memory (%lu)",
"Can't open shared memory. Request event don't create (%lu)", "Can't open shared memory. Request event don't create (%lu)",
"Can't open shared memory. Answer event don't create (%lu)", "Can't open shared memory. Answer event don't create (%lu)",
...@@ -113,7 +113,7 @@ const char *client_errors[]= ...@@ -113,7 +113,7 @@ const char *client_errors[]=
"No parameters exists in the statement", "No parameters exists in the statement",
"Invalid parameter number", "Invalid parameter number",
"Can't send long data for non string or binary data types (parameter: %d)", "Can't send long data for non string or binary data types (parameter: %d)",
"Using not supported parameter type: %d (parameter: %d)" "Using un supported parameter type: %d (parameter: %d)"
"Shared memory (%lu)", "Shared memory (%lu)",
"Can't open shared memory. Request event don't create (%lu)", "Can't open shared memory. Request event don't create (%lu)",
"Can't open shared memory. Answer event don't create (%lu)", "Can't open shared memory. Answer event don't create (%lu)",
...@@ -165,7 +165,7 @@ const char *client_errors[]= ...@@ -165,7 +165,7 @@ const char *client_errors[]=
"No parameters exists in the statement", "No parameters exists in the statement",
"Invalid parameter number", "Invalid parameter number",
"Can't send long data for non string or binary data types (parameter: %d)", "Can't send long data for non string or binary data types (parameter: %d)",
"Using not supported parameter type: %d (parameter: %d)" "Using un supported parameter type: %d (parameter: %d)"
"Shared memory (%lu)", "Shared memory (%lu)",
"Can't open shared memory. Request event don't create (%lu)", "Can't open shared memory. Request event don't create (%lu)",
"Can't open shared memory. Answer event don't create (%lu)", "Can't open shared memory. Answer event don't create (%lu)",
......
This diff is collapsed.
...@@ -102,6 +102,22 @@ EXPORTS ...@@ -102,6 +102,22 @@ EXPORTS
mysql_add_slave mysql_add_slave
mysql_warning_count mysql_warning_count
mysql_warnings mysql_warnings
mysql_prepare
mysql_execute
mysql_param_count
mysql_bind_param
mysql_bind_result
mysql_prepare_result
mysql_stmt_close
mysql_stmt_error
mysql_stmt_errno
mysql_fetch
mysql_send_long_data
mysql_multi_query
mysql_next_result
mysql_commit
mysql_rollback
mysql_autocommit
......
...@@ -9,9 +9,14 @@ SELECT (SELECT (SELECT 0 UNION SELECT 0)); ...@@ -9,9 +9,14 @@ SELECT (SELECT (SELECT 0 UNION SELECT 0));
(SELECT (SELECT 0 UNION SELECT 0)) (SELECT (SELECT 0 UNION SELECT 0))
0 0
SELECT (SELECT 1 FROM (SELECT 1) HAVING a=1) as a; SELECT (SELECT 1 FROM (SELECT 1) HAVING a=1) as a;
Cyclic reference on subqueries Reference 'a' not supported (forward reference in item list)
SELECT (SELECT 1 FROM (SELECT 1) HAVING b=1) as a,(SELECT 1 FROM (SELECT 1) HAVING a=1) as b; SELECT (SELECT 1 FROM (SELECT 1) HAVING b=1) as a,(SELECT 1 FROM (SELECT 1) HAVING a=1) as b;
Cyclic reference on subqueries Reference 'b' not supported (forward reference in item list)
SELECT (SELECT 1),MAX(1) FROM (SELECT 1);
(SELECT 1) MAX(1)
1 1
SELECT (SELECT a) as a;
Reference 'a' not supported (forward reference in item list)
drop table if exists t1,t2,t3,t4,t5,attend,clinic,inscrit; drop table if exists t1,t2,t3,t4,t5,attend,clinic,inscrit;
create table t1 (a int); create table t1 (a int);
create table t2 (a int, b int); create table t2 (a int, b int);
...@@ -20,6 +25,8 @@ create table t4 (a int, b int); ...@@ -20,6 +25,8 @@ create table t4 (a int, b int);
insert into t1 values (2); insert into t1 values (2);
insert into t2 values (1,7),(2,7); insert into t2 values (1,7),(2,7);
insert into t4 values (4,8),(3,8),(5,9); insert into t4 values (4,8),(3,8),(5,9);
select (select a from t1 where t1.a = a1) as a2, (select b from t2 where t2.b=a2) as a1;
Reference 'a1' not supported (forward reference in item list)
select (select a from t1 where t1.a=t2.a), a from t2; select (select a from t1 where t1.a=t2.a), a from t2;
(select a from t1 where t1.a=t2.a) a (select a from t1 where t1.a=t2.a) a
NULL 1 NULL 1
...@@ -278,6 +285,12 @@ PRIMARY KEY (`numeropost`,`numreponse`), ...@@ -278,6 +285,12 @@ PRIMARY KEY (`numeropost`,`numreponse`),
UNIQUE KEY `numreponse` (`numreponse`), UNIQUE KEY `numreponse` (`numreponse`),
KEY `pseudo` (`pseudo`,`numeropost`) KEY `pseudo` (`pseudo`,`numeropost`)
) TYPE=MyISAM; ) TYPE=MyISAM;
SELECT (SELECT numeropost FROM threadhardwarefr7 HAVING numreponse=a),numreponse FROM (SELECT * FROM threadhardwarefr7) as a;
Reference 'numreponse' not supported (forward reference in item list)
SELECT numreponse, (SELECT numeropost FROM threadhardwarefr7 HAVING numreponse=a) FROM (SELECT * FROM threadhardwarefr7) as a;
Unknown column 'a' in 'having clause'
SELECT numreponse, (SELECT numeropost FROM threadhardwarefr7 HAVING numreponse=1) FROM (SELECT * FROM threadhardwarefr7) as a;
numreponse (SELECT numeropost FROM threadhardwarefr7 HAVING numreponse=1)
INSERT INTO threadhardwarefr7 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test'); INSERT INTO threadhardwarefr7 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test');
EXPLAIN SELECT numreponse FROM threadhardwarefr7 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM threadhardwarefr7 WHERE numeropost='1'); EXPLAIN SELECT numreponse FROM threadhardwarefr7 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM threadhardwarefr7 WHERE numeropost='1');
Subselect returns more than 1 record Subselect returns more than 1 record
......
select (select 2); select (select 2);
SELECT (SELECT 1) UNION SELECT (SELECT 2); SELECT (SELECT 1) UNION SELECT (SELECT 2);
SELECT (SELECT (SELECT 0 UNION SELECT 0)); SELECT (SELECT (SELECT 0 UNION SELECT 0));
-- error 1243 -- error 1245
SELECT (SELECT 1 FROM (SELECT 1) HAVING a=1) as a; SELECT (SELECT 1 FROM (SELECT 1) HAVING a=1) as a;
-- error 1243 -- error 1245
SELECT (SELECT 1 FROM (SELECT 1) HAVING b=1) as a,(SELECT 1 FROM (SELECT 1) HAVING a=1) as b; SELECT (SELECT 1 FROM (SELECT 1) HAVING b=1) as a,(SELECT 1 FROM (SELECT 1) HAVING a=1) as b;
SELECT (SELECT 1),MAX(1) FROM (SELECT 1);
-- error 1245
SELECT (SELECT a) as a;
drop table if exists t1,t2,t3,t4,t5,attend,clinic,inscrit; drop table if exists t1,t2,t3,t4,t5,attend,clinic,inscrit;
create table t1 (a int); create table t1 (a int);
create table t2 (a int, b int); create table t2 (a int, b int);
...@@ -13,6 +16,8 @@ create table t4 (a int, b int); ...@@ -13,6 +16,8 @@ create table t4 (a int, b int);
insert into t1 values (2); insert into t1 values (2);
insert into t2 values (1,7),(2,7); insert into t2 values (1,7),(2,7);
insert into t4 values (4,8),(3,8),(5,9); insert into t4 values (4,8),(3,8),(5,9);
-- error 1245
select (select a from t1 where t1.a = a1) as a2, (select b from t2 where t2.b=a2) as a1;
select (select a from t1 where t1.a=t2.a), a from t2; select (select a from t1 where t1.a=t2.a), a from t2;
select (select a from t1 where t1.a=t2.b), a from t2; select (select a from t1 where t1.a=t2.b), a from t2;
select (select a from t1), a from t2; select (select a from t1), a from t2;
...@@ -176,6 +181,11 @@ CREATE TABLE `threadhardwarefr7` ( ...@@ -176,6 +181,11 @@ CREATE TABLE `threadhardwarefr7` (
UNIQUE KEY `numreponse` (`numreponse`), UNIQUE KEY `numreponse` (`numreponse`),
KEY `pseudo` (`pseudo`,`numeropost`) KEY `pseudo` (`pseudo`,`numeropost`)
) TYPE=MyISAM; ) TYPE=MyISAM;
-- error 1245
SELECT (SELECT numeropost FROM threadhardwarefr7 HAVING numreponse=a),numreponse FROM (SELECT * FROM threadhardwarefr7) as a;
-- error 1054
SELECT numreponse, (SELECT numeropost FROM threadhardwarefr7 HAVING numreponse=a) FROM (SELECT * FROM threadhardwarefr7) as a;
SELECT numreponse, (SELECT numeropost FROM threadhardwarefr7 HAVING numreponse=1) FROM (SELECT * FROM threadhardwarefr7) as a;
INSERT INTO threadhardwarefr7 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test'); INSERT INTO threadhardwarefr7 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test');
-- error 1240 -- error 1240
EXPLAIN SELECT numreponse FROM threadhardwarefr7 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM threadhardwarefr7 WHERE numeropost='1'); EXPLAIN SELECT numreponse FROM threadhardwarefr7 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM threadhardwarefr7 WHERE numeropost='1');
......
...@@ -34,7 +34,8 @@ void item_init(void) ...@@ -34,7 +34,8 @@ void item_init(void)
item_user_lock_init(); item_user_lock_init();
} }
Item::Item() Item::Item():
fixed(0)
{ {
marker=0; marker=0;
maybe_null=null_value=with_sum_func=unsigned_flag=0; maybe_null=null_value=with_sum_func=unsigned_flag=0;
...@@ -139,6 +140,7 @@ CHARSET_INFO * Item::thd_charset() const ...@@ -139,6 +140,7 @@ CHARSET_INFO * Item::thd_charset() const
Item_field::Item_field(Field *f) :Item_ident(NullS,f->table_name,f->field_name) Item_field::Item_field(Field *f) :Item_ident(NullS,f->table_name,f->field_name)
{ {
set_field(f); set_field(f);
fixed= 1; // This item is not needed in fix_fields
} }
...@@ -315,32 +317,27 @@ void Item_param::set_null() ...@@ -315,32 +317,27 @@ void Item_param::set_null()
void Item_param::set_int(longlong i) void Item_param::set_int(longlong i)
{ {
int_value=(longlong)i; int_value=(longlong)i;
item_result_type = INT_RESULT;
item_type = INT_ITEM; item_type = INT_ITEM;
} }
void Item_param::set_double(double value) void Item_param::set_double(double value)
{ {
real_value=value; real_value=value;
item_result_type = REAL_RESULT;
item_type = REAL_ITEM; item_type = REAL_ITEM;
} }
void Item_param::set_value(const char *str, uint length, CHARSET_INFO *cs) void Item_param::set_value(const char *str, uint length)
{ {
str_value.set(str,length,cs); str_value.set(str,length,thd_charset());
item_result_type = STRING_RESULT;
item_type = STRING_ITEM; item_type = STRING_ITEM;
} }
void Item_param::set_longdata(const char *str, ulong length, CHARSET_INFO *cs) void Item_param::set_longdata(const char *str, ulong length)
{ {
/* TODO: Fix this for binary handling by making use of
buffer_type..
*/
str_value.append(str,length); str_value.append(str,length);
long_data_supplied= 1;
} }
...@@ -438,6 +435,7 @@ bool Item::fix_fields(THD *thd, ...@@ -438,6 +435,7 @@ bool Item::fix_fields(THD *thd,
struct st_table_list *list, struct st_table_list *list,
Item ** ref) Item ** ref)
{ {
fixed= 1;
return 0; return 0;
} }
...@@ -459,23 +457,48 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -459,23 +457,48 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
*/ */
SELECT_LEX *last= 0; SELECT_LEX *last= 0;
Item **refer= (Item **)not_found_item;
// Prevent using outer fields in subselects, that is not supported now // Prevent using outer fields in subselects, that is not supported now
if (thd->lex.current_select->linkage != DERIVED_TABLE_TYPE) if (thd->lex.current_select->linkage != DERIVED_TABLE_TYPE)
for (SELECT_LEX *sl= thd->lex.current_select->outer_select(); for (SELECT_LEX *sl= thd->lex.current_select->outer_select();
sl; sl;
sl= sl->outer_select()) sl= sl->outer_select())
{
if ((tmp= find_field_in_tables(thd, this, if ((tmp= find_field_in_tables(thd, this,
(last= sl)->get_table_list(), (last= sl)->get_table_list(),
0)) != not_found_field) 0)) != not_found_field)
break; break;
if((refer= find_item_in_list(this, (last= sl)->item_list,
REPORT_EXCEPT_NOT_FOUND)) !=
(Item **)not_found_item)
break;
}
if (!tmp) if (!tmp)
return -1; return -1;
else if (tmp == not_found_field) else if (!refer)
return 1;
else if (tmp == not_found_field && refer == (Item **)not_found_item)
{ {
// call to return error code // call to return error code
find_field_in_tables(thd, this, tables, 1); find_field_in_tables(thd, this, tables, 1);
return -1; return -1;
} }
else if (refer != (Item **)not_found_item)
{
Item_ref *r;
*ref= r= new Item_ref((char *)db_name, (char *)table_name,
(char *)field_name);
if (!r)
return 1;
int res;
if ((res= r->fix_fields(thd, tables, ref)))
return res;
r->depended_from= last;
thd->lex.current_select->mark_as_dependent(last);
thd->add_possible_loop(r);
return 0;
}
else else
{ {
depended_from= last; depended_from= last;
...@@ -507,6 +530,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -507,6 +530,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
return 1; return 1;
return (*ref)->fix_fields(thd, tables, ref); return (*ref)->fix_fields(thd, tables, ref);
} }
fixed= 1;
return 0; return 0;
} }
...@@ -885,6 +909,19 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference) ...@@ -885,6 +909,19 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
maybe_null= (*ref)->maybe_null; maybe_null= (*ref)->maybe_null;
decimals= (*ref)->decimals; decimals= (*ref)->decimals;
} }
if (((*ref)->with_sum_func &&
(depended_from ||
!(thd->lex.current_select->linkage != GLOBAL_OPTIONS_TYPE &&
thd->lex.current_select->select_lex()->having_fix_field))) ||
!(*ref)->fixed)
{
my_error(ER_ILLEGAL_REFERENCE, MYF(0), name,
((*ref)->with_sum_func?
"reference on group function":
"forward reference in item list"));
return 1;
}
fixed= 1;
return 0; return 0;
} }
......
...@@ -46,6 +46,7 @@ public: ...@@ -46,6 +46,7 @@ public:
my_bool null_value; /* if item is null */ my_bool null_value; /* if item is null */
my_bool unsigned_flag; my_bool unsigned_flag;
my_bool with_sum_func; my_bool with_sum_func;
my_bool fixed; /* If item fixed with fix_fields */
// alloc & destruct is done as start of select using sql_alloc // alloc & destruct is done as start of select using sql_alloc
Item(); Item();
...@@ -186,8 +187,8 @@ public: ...@@ -186,8 +187,8 @@ public:
Item_param(char *name_par=0) Item_param(char *name_par=0)
{ {
name= name_par ? name_par : (char*) "?"; name= name_par ? name_par : (char*) "?";
long_data_supplied = false; long_data_supplied= false;
item_type = STRING_ITEM; item_type= STRING_ITEM;
item_result_type = STRING_RESULT; item_result_type = STRING_RESULT;
} }
enum Type type() const { return item_type; } enum Type type() const { return item_type; }
...@@ -199,12 +200,13 @@ public: ...@@ -199,12 +200,13 @@ public:
void set_null(); void set_null();
void set_int(longlong i); void set_int(longlong i);
void set_double(double i); void set_double(double i);
void set_value(const char *str, uint length, CHARSET_INFO *cs); void set_value(const char *str, uint length);
void set_long_str(const char *str, ulong length, CHARSET_INFO *cs); void set_long_str(const char *str, ulong length);
void set_long_binary(const char *str, ulong length, CHARSET_INFO *cs); void set_long_binary(const char *str, ulong length);
void set_longdata(const char *str, ulong length, CHARSET_INFO *cs); void set_longdata(const char *str, ulong length);
void set_long_end(); void set_long_end();
void reset() {} void reset() {}
void (*setup_param_func)(Item_param *param, uchar **pos);
enum Item_result result_type () const enum Item_result result_type () const
{ return item_result_type; } { return item_result_type; }
Item *new_item() { return new Item_param(name); } Item *new_item() { return new Item_param(name); }
...@@ -401,8 +403,8 @@ public: ...@@ -401,8 +403,8 @@ public:
:Item_ident(NullS,table_name_par,field_name_par),ref(item) {} :Item_ident(NullS,table_name_par,field_name_par),ref(item) {}
enum Type type() const { return REF_ITEM; } enum Type type() const { return REF_ITEM; }
bool eq(const Item *item, bool binary_cmp) const bool eq(const Item *item, bool binary_cmp) const
{ return (*ref)->eq(item, binary_cmp); } { return ref && (*ref)->eq(item, binary_cmp); }
~Item_ref() { if (ref) delete *ref; } ~Item_ref() { if (ref && (*ref) != this) delete *ref; }
double val() double val()
{ {
double tmp=(*ref)->val_result(); double tmp=(*ref)->val_result();
......
...@@ -1160,6 +1160,7 @@ Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -1160,6 +1160,7 @@ Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
if (thd) if (thd)
thd->cond_count+=list.elements; thd->cond_count+=list.elements;
fix_length_and_dec(); fix_length_and_dec();
fixed= 1;
return 0; return 0;
} }
...@@ -1485,6 +1486,7 @@ Item_func_regex::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -1485,6 +1486,7 @@ Item_func_regex::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
} }
else else
maybe_null=1; maybe_null=1;
fixed= 1;
return 0; return 0;
} }
......
...@@ -123,6 +123,7 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -123,6 +123,7 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
} }
} }
fix_length_and_dec(); fix_length_and_dec();
fixed= 1;
return 0; return 0;
} }
......
...@@ -754,6 +754,7 @@ public: ...@@ -754,6 +754,7 @@ public:
bool res= udf.fix_fields(thd, tables, this, arg_count, args); bool res= udf.fix_fields(thd, tables, this, arg_count, args);
used_tables_cache= udf.used_tables_cache; used_tables_cache= udf.used_tables_cache;
const_item_cache= udf.const_item_cache; const_item_cache= udf.const_item_cache;
fixed= 1;
return res; return res;
} }
Item_result result_type () const { return udf.result_type(); } Item_result result_type () const { return udf.result_type(); }
......
...@@ -2079,6 +2079,7 @@ bool Item_func_conv_charset::fix_fields(THD *thd,struct st_table_list *tables, I ...@@ -2079,6 +2079,7 @@ bool Item_func_conv_charset::fix_fields(THD *thd,struct st_table_list *tables, I
const_item_cache=args[0]->const_item(); const_item_cache=args[0]->const_item();
set_charset(conv_charset); set_charset(conv_charset);
fix_length_and_dec(); fix_length_and_dec();
fixed= 1;
return 0; return 0;
} }
...@@ -2113,6 +2114,7 @@ bool Item_func_set_collation::fix_fields(THD *thd,struct st_table_list *tables, ...@@ -2113,6 +2114,7 @@ bool Item_func_set_collation::fix_fields(THD *thd,struct st_table_list *tables,
used_tables_cache=args[0]->used_tables(); used_tables_cache=args[0]->used_tables();
const_item_cache=args[0]->const_item(); const_item_cache=args[0]->const_item();
fix_length_and_dec(); fix_length_and_dec();
fixed= 1;
return 0; return 0;
} }
......
...@@ -92,6 +92,7 @@ bool Item_subselect::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -92,6 +92,7 @@ bool Item_subselect::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
} }
fix_length_and_dec(); fix_length_and_dec();
} }
fixed= 1;
return res; return res;
} }
......
...@@ -135,6 +135,7 @@ Item_sum_num::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -135,6 +135,7 @@ Item_sum_num::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
null_value=1; null_value=1;
fix_length_and_dec(); fix_length_and_dec();
thd->allow_sum_func=1; // Allow group functions thd->allow_sum_func=1; // Allow group functions
fixed= 1;
return 0; return 0;
} }
...@@ -165,6 +166,7 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -165,6 +166,7 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
null_value=1; null_value=1;
fix_length_and_dec(); fix_length_and_dec();
thd->allow_sum_func=1; // Allow group functions thd->allow_sum_func=1; // Allow group functions
fixed= 1;
return 0; return 0;
} }
......
...@@ -384,6 +384,7 @@ public: ...@@ -384,6 +384,7 @@ public:
const char *func_name() const { return udf.name(); } const char *func_name() const { return udf.name(); }
bool fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) bool fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
{ {
fixed= 1;
return udf.fix_fields(thd,tables,this,this->arg_count,this->args); return udf.fix_fields(thd,tables,this,this->arg_count,this->args);
} }
enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; } enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
......
...@@ -43,5 +43,9 @@ public: ...@@ -43,5 +43,9 @@ public:
bool add() { return 0; } bool add() { return 0; }
void reset_field() {} void reset_field() {}
void update_field(int offset) {} void update_field(int offset) {}
bool fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref) { return 0;} bool fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref)
{
fixed= 1;
return 0;
}
}; };
...@@ -513,7 +513,7 @@ int mysqld_show_column_types(THD *thd); ...@@ -513,7 +513,7 @@ int mysqld_show_column_types(THD *thd);
int mysqld_help (THD *thd, const char *text); int mysqld_help (THD *thd, const char *text);
/* sql_prepare.cc */ /* sql_prepare.cc */
int compare_prep_stmt(PREP_STMT *a, PREP_STMT *b, void *not_used); int compare_prep_stmt(void *not_used, PREP_STMT *stmt, ulong *key);
void free_prep_stmt(PREP_STMT *stmt, TREE_FREE mode, void *not_used); void free_prep_stmt(PREP_STMT *stmt, TREE_FREE mode, void *not_used);
bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length); bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length);
void mysql_stmt_execute(THD *thd, char *packet); void mysql_stmt_execute(THD *thd, char *packet);
......
...@@ -254,4 +254,5 @@ ...@@ -254,4 +254,5 @@
"Unknown prepared statement handler (%ld) given to %s", "Unknown prepared statement handler (%ld) given to %s",
"Help database is corrupt or does not exist", "Help database is corrupt or does not exist",
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s" "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
...@@ -248,4 +248,5 @@ ...@@ -248,4 +248,5 @@
"Unknown prepared statement handler (%ld) given to %s", "Unknown prepared statement handler (%ld) given to %s",
"Help database is corrupt or does not exist", "Help database is corrupt or does not exist",
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s" "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
...@@ -256,4 +256,5 @@ ...@@ -256,4 +256,5 @@
"Unknown prepared statement handler (%ld) given to %s", "Unknown prepared statement handler (%ld) given to %s",
"Help database is corrupt or does not exist", "Help database is corrupt or does not exist",
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s" "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
...@@ -245,4 +245,5 @@ ...@@ -245,4 +245,5 @@
"Unknown prepared statement handler (%ld) given to %s", "Unknown prepared statement handler (%ld) given to %s",
"Help database is corrupt or does not exist", "Help database is corrupt or does not exist",
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s" "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
...@@ -250,4 +250,5 @@ ...@@ -250,4 +250,5 @@
"Unknown prepared statement handler (%ld) given to %s", "Unknown prepared statement handler (%ld) given to %s",
"Help database is corrupt or does not exist", "Help database is corrupt or does not exist",
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s" "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
...@@ -245,4 +245,5 @@ ...@@ -245,4 +245,5 @@
"Unknown prepared statement handler (%ld) given to %s", "Unknown prepared statement handler (%ld) given to %s",
"Help database is corrupt or does not exist", "Help database is corrupt or does not exist",
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s" "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
...@@ -248,4 +248,5 @@ ...@@ -248,4 +248,5 @@
"Unknown prepared statement handler (%ld) given to %s", "Unknown prepared statement handler (%ld) given to %s",
"Help database is corrupt or does not exist", "Help database is corrupt or does not exist",
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s" "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
...@@ -245,4 +245,5 @@ ...@@ -245,4 +245,5 @@
"Unknown prepared statement handler (%ld) given to %s", "Unknown prepared statement handler (%ld) given to %s",
"Help database is corrupt or does not exist", "Help database is corrupt or does not exist",
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s" "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
...@@ -247,4 +247,5 @@ ...@@ -247,4 +247,5 @@
"Unknown prepared statement handler (%ld) given to %s", "Unknown prepared statement handler (%ld) given to %s",
"Help database is corrupt or does not exist", "Help database is corrupt or does not exist",
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s" "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
...@@ -245,4 +245,5 @@ ...@@ -245,4 +245,5 @@
"Unknown prepared statement handler (%ld) given to %s", "Unknown prepared statement handler (%ld) given to %s",
"Help database is corrupt or does not exist", "Help database is corrupt or does not exist",
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s" "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
...@@ -247,4 +247,5 @@ ...@@ -247,4 +247,5 @@
"Unknown prepared statement handler (%ld) given to %s", "Unknown prepared statement handler (%ld) given to %s",
"Help database is corrupt or does not exist", "Help database is corrupt or does not exist",
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s" "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
...@@ -245,4 +245,5 @@ ...@@ -245,4 +245,5 @@
"Unknown prepared statement handler (%ld) given to %s", "Unknown prepared statement handler (%ld) given to %s",
"Help database is corrupt or does not exist", "Help database is corrupt or does not exist",
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s" "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
...@@ -247,4 +247,5 @@ ...@@ -247,4 +247,5 @@
"Unknown prepared statement handler (%ld) given to %s", "Unknown prepared statement handler (%ld) given to %s",
"Help database is corrupt or does not exist", "Help database is corrupt or does not exist",
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s" "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
...@@ -247,4 +247,5 @@ ...@@ -247,4 +247,5 @@
"Unknown prepared statement handler (%ld) given to %s", "Unknown prepared statement handler (%ld) given to %s",
"Help database is corrupt or does not exist", "Help database is corrupt or does not exist",
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s" "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
...@@ -249,4 +249,5 @@ ...@@ -249,4 +249,5 @@
"Unknown prepared statement handler (%ld) given to %s", "Unknown prepared statement handler (%ld) given to %s",
"Help database is corrupt or does not exist", "Help database is corrupt or does not exist",
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s" "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
...@@ -245,4 +245,5 @@ ...@@ -245,4 +245,5 @@
"Unknown prepared statement handler (%ld) given to %s", "Unknown prepared statement handler (%ld) given to %s",
"Help database is corrupt or does not exist", "Help database is corrupt or does not exist",
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s" "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
...@@ -250,3 +250,4 @@ ...@@ -250,3 +250,4 @@
"Help database is corrupt or does not exist", "Help database is corrupt or does not exist",
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s" "Converting column '%s' from %s to %s"
"Reference '%-.64s' not supported (%s)",
...@@ -248,4 +248,5 @@ ...@@ -248,4 +248,5 @@
"Unknown prepared statement handler (%ld) given to %s", "Unknown prepared statement handler (%ld) given to %s",
"Help database is corrupt or does not exist", "Help database is corrupt or does not exist",
" ", " ",
"Converting column '%s' from %s to %s" " '%s' %s %s",
" '%-.64s' (%s)",
...@@ -241,4 +241,5 @@ ...@@ -241,4 +241,5 @@
"Unknown prepared statement handler (%ld) given to %s", "Unknown prepared statement handler (%ld) given to %s",
"Help database is corrupt or does not exist", "Help database is corrupt or does not exist",
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s" "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
...@@ -253,4 +253,5 @@ ...@@ -253,4 +253,5 @@
"Unknown prepared statement handler (%ld) given to %s", "Unknown prepared statement handler (%ld) given to %s",
"Help database is corrupt or does not exist", "Help database is corrupt or does not exist",
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s" "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
...@@ -246,4 +246,5 @@ ...@@ -246,4 +246,5 @@
"Unknown prepared statement handler (%ld) given to %s", "Unknown prepared statement handler (%ld) given to %s",
"Help database is corrupt or does not exist", "Help database is corrupt or does not exist",
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s" "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
...@@ -245,4 +245,5 @@ ...@@ -245,4 +245,5 @@
"Okänd PREPARED STATEMENT id (%ld) var given till %s", "Okänd PREPARED STATEMENT id (%ld) var given till %s",
"Hjälp databasen finns inte eller är skadad", "Hjälp databasen finns inte eller är skadad",
"Syklisk referens i subselect", "Syklisk referens i subselect",
"Konvertar kolumn '%s' från %s till %s" "Konvertar kolumn '%s' från %s till %s",
"Reference '%-.64s' not supported (%s)",
...@@ -250,4 +250,5 @@ ...@@ -250,4 +250,5 @@
"Unknown prepared statement handler (%ld) given to %s", "Unknown prepared statement handler (%ld) given to %s",
"Help database is corrupt or does not exist", "Help database is corrupt or does not exist",
"i i", "i i",
"Converting column '%s' from %s to %s" " '%s' %s %s",
" '%-.64s' i (%s)",
...@@ -2225,8 +2225,10 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) ...@@ -2225,8 +2225,10 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
{ {
DBUG_ENTER("setup_conds"); DBUG_ENTER("setup_conds");
thd->set_query_id=1; thd->set_query_id=1;
thd->cond_count=0;
thd->allow_sum_func=0; thd->cond_count= 0;
bool save_allow_sum_func= thd->allow_sum_func;
thd->allow_sum_func= 0;
if (*conds) if (*conds)
{ {
thd->where="where clause"; thd->where="where clause";
...@@ -2299,6 +2301,7 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) ...@@ -2299,6 +2301,7 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
table->on_expr=and_conds(table->on_expr,cond_and); table->on_expr=and_conds(table->on_expr,cond_and);
} }
} }
thd->allow_sum_func= save_allow_sum_func;
DBUG_RETURN(test(thd->fatal_error)); DBUG_RETURN(test(thd->fatal_error));
} }
......
...@@ -325,7 +325,7 @@ typedef struct st_prep_stmt ...@@ -325,7 +325,7 @@ typedef struct st_prep_stmt
uint param_count; uint param_count;
uint last_errno; uint last_errno;
char last_error[MYSQL_ERRMSG_SIZE]; char last_error[MYSQL_ERRMSG_SIZE];
bool error_in_prepare, long_data_used; bool error_in_prepare, long_data_used, param_inited;
} PREP_STMT; } PREP_STMT;
...@@ -510,7 +510,6 @@ public: ...@@ -510,7 +510,6 @@ public:
bool safe_to_cache_query; bool safe_to_cache_query;
bool volatile killed; bool volatile killed;
bool prepare_command; bool prepare_command;
Item_param *params; // Pointer to array of params
/* /*
If we do a purge of binary logs, log index info of the threads If we do a purge of binary logs, log index info of the threads
......
...@@ -127,7 +127,7 @@ static const char *warning_level_names[]= {"Note", "Warning", "Error", "?"}; ...@@ -127,7 +127,7 @@ static const char *warning_level_names[]= {"Note", "Warning", "Error", "?"};
my_bool mysqld_show_warnings(THD *thd, ulong levels_to_show) my_bool mysqld_show_warnings(THD *thd, ulong levels_to_show)
{ {
List<Item> field_list; List<Item> field_list;
DBUG_ENTER("mysqld_show_errors"); DBUG_ENTER("mysqld_show_warnings");
field_list.push_back(new Item_empty_string("Level", 7)); field_list.push_back(new Item_empty_string("Level", 7));
field_list.push_back(new Item_int("Code",0,4)); field_list.push_back(new Item_int("Code",0,4));
......
This diff is collapsed.
This diff is collapsed.
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