Commit f939a6b6 authored by unknown's avatar unknown

Removed compiler warnings.

Added new operators to be used with gcc 3.0.x
Update of query cache code.
Added semaphores for Windows (not yet in use)
Added pthread_mutex_trylock for windows.


Docs/manual.texi:
  Update of query cache info.
Docs/section.Comparisons.texi:
  Added indexing.
client/mysqlbinlog.cc:
  Removed compiler warnings.
client/mysqltest.c:
  Added enable_result_log/disable_result_log
include/config-win.h:
  Added support of semaphores on Windows.
include/my_pthread.h:
  Added pthread_mutex_trylock for windows.
include/my_sys.h:
  Cleanup
libmysql/libmysql.c:
  Fixed bug in mysql_use_result() (When reusing connections).
myisam/ft_boolean_search.c:
  Removed compiler warnings
myisam/ft_nlq_search.c:
  Removed compiler warnings
myisam/ft_update.c:
  Removed compiler warnings
mysql-test/r/query_cache.result:
  New tests
mysql-test/t/query_cache-master.opt:
  New tests
mysql-test/t/query_cache.test:
  New tests
mysys/Makefile.am:
  Added new operators to be used with gcc 3.0.x
sql/filesort.cc:
  Removed compiler warnings
sql/item_func.cc:
  Removed compiler warnings
sql/mysql_priv.h:
  Removed compiler warnings
sql/mysqld.cc:
  Update of query cache code.
sql/slave.cc:
  Removed compiler warnings.
  Code cleanup (Indentation)
sql/sql_cache.cc:
  Updated code
sql/sql_cache.h:
  Updated code
sql/sql_repl.cc:
  Removed compiler warnings
sql/sql_yacc.yy:
  Updated query cache
parent b0552052
......@@ -18506,9 +18506,12 @@ If this is 0, the query cache is disabled (default).
@item @code{query_cache_startup_type}
This may be set (only numeric) to
0 (OFF, don't cache or retrieve results),
1 (ON, cache all results except @code{SELECT SQL_NO_CACHE ...} queries) or
2 (DEMAND, cache only @code{SELECT SQL_CACHE ...} queries).
@multitable @columnfractions .1 .2 .7
@item @strong{Value} @tab @strong{Alias} @tab @strong{Comment}
@item 0 @tab OFF @tab Don't cache or retrieve results.
@item 1 @tab ON @tab Cache all results except @code{SELECT SQL_NO_CACHE ...} queries.
@item 2 @tab DEMAND @tab Cache only @code{SELECT SQL_CACHE ...} queries.
@end multitable
@item @code{safe_show_databases}
Don't show databases for which the user doesn't have any database or
......@@ -34,6 +34,7 @@ see the @code{crash-me} web page at
@node Compare mSQL, Compare PostgreSQL, Comparisons, Comparisons
@subsection How MySQL Compares to @code{mSQL}
@cindex mSQL, MySQL vs mSQL, overview
@table @strong
@item Performance
......@@ -301,7 +302,7 @@ multiple connections to the server from the same process.
@subsubsection How @code{mSQL} and MySQL Client/Server Communications Protocols Differ
@cindex communications protocols
@cindex mSQL vs. MySQL
@cindex mSQL vs. MySQL, protocol
There are enough differences that it is impossible (or at least not easy)
to support both.
......@@ -557,7 +558,6 @@ satisfies your application. If you need raw speed, MySQL is probably your
best choice. If you need some of the extra features that only PostgreSQL
can offer, you should use @code{PostgreSQL}.
@cindex PostgreSQL/MySQL, strategies
@menu
* MySQL-PostgreSQL goals:: MySQL and PostgreSQL development strategies
* MySQL-PostgreSQL features:: Featurewise Comparison of MySQL and PostgreSQL
......@@ -568,6 +568,7 @@ can offer, you should use @code{PostgreSQL}.
@node MySQL-PostgreSQL goals, MySQL-PostgreSQL features, Compare PostgreSQL, Compare PostgreSQL
@subsubsection MySQL and PostgreSQL development strategies
@cindex PostgreSQL vs. MySQL, strategies
When adding things to MySQL we take pride to do an optimal, definite
solution. The code should be so good that we shouldn't have any need to
change it in the foreseeable future. We also do not like to sacrifice
......@@ -609,7 +610,7 @@ code, we are better able to coordinate new features and releases.
@node MySQL-PostgreSQL features, MySQL-PostgreSQL benchmarks, MySQL-PostgreSQL goals, Compare PostgreSQL
@subsubsection Featurewise Comparison of MySQL and PostgreSQL
@cindex PostgreSQL/MySQL, features
@cindex PostgreSQL vs. MySQL, features
On the crash-me page
(@uref{http://www.mysql.com/information/crash-me.php})
......
......@@ -385,9 +385,9 @@ static void dump_remote_log_entries(const char* logname)
}
}
static int check_header (IO_CACHE* file)
static int check_header(IO_CACHE* file)
{
char buf[PROBE_HEADER_LEN];
byte buf[PROBE_HEADER_LEN];
int old_format;
my_off_t pos = my_b_tell(file);
......
......@@ -43,7 +43,7 @@
**********************************************************************/
#define MTEST_VERSION "1.11"
#define MTEST_VERSION "1.12"
#include <my_global.h>
#include <mysql_embed.h>
......@@ -138,16 +138,16 @@ MYSQL_RES *last_result=0;
PARSER parser;
MASTER_POS master_pos;
int* block_ok; /* set to 0 if the current block should not be executed */
int *block_ok; /* set to 0 if the current block should not be executed */
int false_block_depth = 0;
const char* result_file = 0; /* if set, all results are concated and
compared against this file*/
/* if set, all results are concated and compared against this file */
const char *result_file = 0;
typedef struct
{
char* name;
char *name;
int name_len;
char* str_val;
char *str_val;
int str_val_len;
int int_val;
int alloced_len;
......@@ -158,7 +158,7 @@ typedef struct
VAR var_reg[10];
/*Perl/shell-like variable registers */
HASH var_hash;
int disable_query_log=0;
int disable_query_log=0, disable_result_log=0;
struct connection cons[MAX_CONS];
struct connection* cur_con, *next_con, *cons_end;
......@@ -181,6 +181,7 @@ Q_PING, Q_EVAL,
Q_RPL_PROBE, Q_ENABLE_RPL_PARSE,
Q_DISABLE_RPL_PARSE, Q_EVAL_RESULT,
Q_ENABLE_QUERY_LOG, Q_DISABLE_QUERY_LOG,
Q_ENABLE_RESULT_LOG, Q_DISABLE_RESULT_LOG,
Q_SERVER_START, Q_SERVER_STOP,Q_REQUIRE_MANAGER,
Q_UNKNOWN, /* Unknown command. */
Q_COMMENT, /* Comments, ignored. */
......@@ -215,6 +216,7 @@ const char *command_names[] = {
"rpl_probe", "enable_rpl_parse",
"disable_rpl_parse", "eval_result",
"enable_query_log", "disable_query_log",
"enable_result_log", "disable_result_log",
"server_start", "server_stop",
"require_manager",
0
......@@ -224,22 +226,22 @@ TYPELIB command_typelib= {array_elements(command_names),"",
command_names};
DYNAMIC_STRING ds_res;
static void die(const char* fmt, ...);
static void die(const char *fmt, ...);
static void init_var_hash();
static byte* get_var_key(const byte* rec, uint* len,
my_bool __attribute__((unused)) t);
static VAR* var_init(VAR* v, const char* name, int name_len, const char* val,
static VAR* var_init(VAR* v, const char *name, int name_len, const char *val,
int val_len);
static void var_free(void* v);
int dyn_string_cmp(DYNAMIC_STRING* ds, const char* fname);
void reject_dump(const char* record_file, char* buf, int size);
int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname);
void reject_dump(const char *record_file, char *buf, int size);
int close_connection(struct st_query* q);
VAR* var_get(const char* var_name, const char** var_name_end, int raw);
int eval_expr(VAR* v, const char* p, const char** p_end);
static int read_server_arguments(const char* name);
VAR* var_get(const char *var_name, const char** var_name_end, int raw);
int eval_expr(VAR* v, const char *p, const char** p_end);
static int read_server_arguments(const char *name);
/* Definitions for replace */
......@@ -259,9 +261,9 @@ static int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name);
void free_pointer_array(POINTER_ARRAY *pa);
static int initialize_replace_buffer(void);
static void free_replace_buffer(void);
static void do_eval(DYNAMIC_STRING* query_eval, const char* query);
void str_to_file(const char* fname, char* str, int size);
int do_server_op(struct st_query* q,const char* op);
static void do_eval(DYNAMIC_STRING* query_eval, const char *query);
void str_to_file(const char *fname, char *str, int size);
int do_server_op(struct st_query* q,const char *op);
struct st_replace *glob_replace;
static char *out_buff;
......@@ -1960,20 +1962,20 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
int query_len;
DBUG_ENTER("run_query");
if(q->type != Q_EVAL)
{
query = q->query;
query_len = strlen(query);
}
if (q->type != Q_EVAL)
{
query = q->query;
query_len = strlen(query);
}
else
{
init_dynamic_string(&eval_query, "", 16384, 65536);
do_eval(&eval_query, q->query);
query = eval_query.str;
query_len = eval_query.length;
}
{
init_dynamic_string(&eval_query, "", 16384, 65536);
do_eval(&eval_query, q->query);
query = eval_query.str;
query_len = eval_query.length;
}
if ( q->record_file[0])
if (q->record_file[0])
{
init_dynamic_string(&ds_tmp, "", 16384, 65536);
ds = &ds_tmp;
......@@ -2060,44 +2062,45 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
goto end;
}
if (!res) goto end;
fields = mysql_fetch_fields(res);
num_fields = mysql_num_fields(res);
for( i = 0; i < num_fields; i++)
{
if (i)
dynstr_append_mem(ds, "\t", 1);
dynstr_append(ds, fields[i].name);
}
dynstr_append_mem(ds, "\n", 1);
if (!res)
goto end;
while((row = mysql_fetch_row(res)))
if (!disable_result_log)
{
lengths = mysql_fetch_lengths(res);
for(i = 0; i < num_fields; i++)
fields = mysql_fetch_fields(res);
num_fields = mysql_num_fields(res);
for (i = 0; i < num_fields; i++)
{
val = (char*)row[i];
len = lengths[i];
if (!val)
{
val = (char*)"NULL";
len = 4;
}
if (i)
dynstr_append_mem(ds, "\t", 1);
replace_dynstr_append_mem(ds, val, len);
dynstr_append(ds, fields[i].name);
}
dynstr_append_mem(ds, "\n", 1);
}
if (glob_replace)
free_replace();
while ((row = mysql_fetch_row(res)))
{
lengths = mysql_fetch_lengths(res);
for(i = 0; i < num_fields; i++)
{
val = (char*)row[i];
len = lengths[i];
if (!val)
{
val = (char*)"NULL";
len = 4;
}
if (i)
dynstr_append_mem(ds, "\t", 1);
replace_dynstr_append_mem(ds, val, len);
}
dynstr_append_mem(ds, "\n", 1);
}
if (glob_replace)
free_replace();
}
if (record)
{
if (!q->record_file[0] && !result_file)
......@@ -2111,7 +2114,8 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
}
end:
if (res) mysql_free_result(res);
if (res)
mysql_free_result(res);
last_result=0;
if (ds == &ds_tmp)
dynstr_free(&ds_tmp);
......@@ -2288,10 +2292,12 @@ int main(int argc, char** argv)
case Q_DIRTY_CLOSE:
close_connection(q); break;
case Q_RPL_PROBE: do_rpl_probe(q); break;
case Q_ENABLE_RPL_PARSE: do_enable_rpl_parse(q); break;
case Q_DISABLE_RPL_PARSE: do_disable_rpl_parse(q); break;
case Q_ENABLE_QUERY_LOG: disable_query_log=0; break;
case Q_DISABLE_QUERY_LOG: disable_query_log=1; break;
case Q_ENABLE_RPL_PARSE: do_enable_rpl_parse(q); break;
case Q_DISABLE_RPL_PARSE: do_disable_rpl_parse(q); break;
case Q_ENABLE_QUERY_LOG: disable_query_log=0; break;
case Q_DISABLE_QUERY_LOG: disable_query_log=1; break;
case Q_ENABLE_RESULT_LOG: disable_result_log=0; break;
case Q_DISABLE_RESULT_LOG: disable_result_log=1; break;
case Q_SOURCE: do_source(q); break;
case Q_SLEEP: do_sleep(q); break;
case Q_REQUIRE_MANAGER: do_require_manager(q); break;
......
......@@ -253,6 +253,7 @@ inline double ulonglong2double(ulonglong value)
#define HAVE_STRPBRK
#define HAVE_STRSTR
#define HAVE_COMPRESS
#define HAVE_CREATESEMAPHORE
#ifdef NOT_USED
#define HAVE_SNPRINTF /* Gave link error */
......
......@@ -132,16 +132,17 @@ void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/
#define pthread_equal(A,B) ((A) == (B))
#ifdef OS2
int pthread_mutex_init (pthread_mutex_t *, const pthread_mutexattr_t *);
int pthread_mutex_lock (pthread_mutex_t *);
int pthread_mutex_unlock (pthread_mutex_t *);
int pthread_mutex_destroy (pthread_mutex_t *);
extern int pthread_mutex_init (pthread_mutex_t *, const pthread_mutexattr_t *);
extern int pthread_mutex_lock (pthread_mutex_t *);
extern int pthread_mutex_unlock (pthread_mutex_t *);
extern int pthread_mutex_destroy (pthread_mutex_t *);
#define my_pthread_setprio(A,B) DosSetPriority(PRTYS_THREAD,PRTYC_NOCHANGE, B, A)
#define pthread_kill(A,B) raise(B)
#define pthread_exit(A) pthread_dummy()
#else
#define pthread_mutex_init(A,B) InitializeCriticalSection(A)
#define pthread_mutex_lock(A) (EnterCriticalSection(A),0)
#define pthread_mutex_trylock(A) (WaitForSingleObject((A), 0) == WAIT_TIMEOUT)
#define pthread_mutex_unlock(A) LeaveCriticalSection(A)
#define pthread_mutex_destroy(A) DeleteCriticalSection(A)
#define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B))
......
/*
* Module: semaphore.h
*
* Purpose:
* Semaphores aren't actually part of the PThreads standard.
* They are defined by the POSIX Standard:
*
* POSIX 1003.1b-1993 (POSIX.1b)
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright (C) 1998
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA
*/
/* This is hacked by Monty to be included in mysys library */
#ifndef _my_semaphore_h_
#define _my_semaphore_h_
#ifndef __WIN__
#include <semaphore.h>
#else
C_MODE_START
typedef HANDLE sem_t;
int sem_init (sem_t * sem, int pshared, unsigned int value);
int sem_destroy (sem_t * sem);
int sem_trywait (sem_t * sem);
int sem_wait (sem_t * sem);
int sem_post (sem_t * sem);
int sem_post_multiple (sem_t * sem,int count);
int sem_getvalue (sem_t * sem, int * sval);
C_MODE_END
#endif /* __WIN__ */
#endif /* !_my_semaphore_h_ */
......@@ -16,9 +16,7 @@
#ifndef _my_sys_h
#define _my_sys_h
#ifdef __cplusplus
extern "C" {
#endif
C_MODE_START
#ifdef HAVE_AIOWAIT
#include <sys/asynch.h> /* Used by record-cache */
......@@ -649,8 +647,6 @@ extern void sleep(int sec);
extern my_bool have_tcpip; /* Is set if tcpip is used */
#endif
#ifdef __cplusplus
}
#endif
C_MODE_END
#include "raid.h"
#endif /* _my_sys_h */
......@@ -2397,6 +2397,8 @@ mysql_fetch_row(MYSQL_RES *res)
DBUG_PRINT("info",("end of data"));
res->eof=1;
res->handle->status=MYSQL_STATUS_READY;
/* Don't clear handle in mysql_free_results */
res->handle=0;
}
}
DBUG_RETURN((MYSQL_ROW) NULL);
......
......@@ -112,11 +112,13 @@ void _ftb_parse_query(FTB *ftb, byte **start, byte *end,
while ((res=ft_get_word(start,end,&w,&param)))
{
byte r=param.plusminus;
float weight=(param.pmsign ? nwghts : wghts)[(r>5)?5:((r<-5)?-5:r)];
float weight= (float) (param.pmsign ? nwghts : wghts)[(r>5)?5:((r<-5)?-5:r)];
switch (res) {
case 1: /* word found */
ftbw=(FTB_WORD *)alloc_root(&ftb->mem_root,
sizeof(FTB_WORD) + (param.trunc ? MI_MAX_KEY_BUFF : w.len+extra));
sizeof(FTB_WORD) +
(param.trunc ? MI_MAX_KEY_BUFF :
w.len+extra));
ftbw->len=w.len+1;
ftbw->yesno=param.yesno;
ftbw->trunc=param.trunc; /* 0 or 1 */
......@@ -216,7 +218,8 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, byte *query,
ftb->queue.root=(byte **)alloc_root(&ftb->mem_root, (res+1)*sizeof(void*));
reinit_queue(& ftb->queue, res, 0, 0, FTB_WORD_cmp, ftb);
ftbe=(FTB_EXPR *)alloc_root(&ftb->mem_root, sizeof(FTB_EXPR));
ftbe->weight=ftbe->yesno=ftbe->nos=1;
ftbe->weight=1;
ftbe->yesno=ftbe->nos=1;
ftbe->up=0;
ftbe->ythresh=0;
ftbe->docid=HA_POS_ERROR;
......@@ -236,7 +239,8 @@ void _ftb_climb_the_tree(FTB_WORD *ftbw, my_off_t curdoc)
{
if (ftbe->docid != curdoc)
{
ftbe->cur_weight=ftbe->yesses=ftbe->nos=0;
ftbe->cur_weight=0;
ftbe->yesses=ftbe->nos=0;
ftbe->docid=curdoc;
}
if (ftbe->nos)
......@@ -373,7 +377,8 @@ float ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length)
{
if (ftbe->docid != HA_POS_ERROR)
{
ftbe->cur_weight=ftbe->yesses=ftbe->nos=0;
ftbe->cur_weight=0;
ftbe->yesses=ftbe->nos=0;
ftbe->docid=HA_POS_ERROR;
}
else
......
......@@ -248,7 +248,8 @@ int ft_nlq_read_next(FT_INFO *handler, char *record)
}
float ft_nlq_find_relevance(FT_INFO *handler,
byte *record __attribute__((unused)), uint length __attribute__((unused)))
byte *record __attribute__((unused)),
uint length __attribute__((unused)))
{
int a,b,c;
FT_DOC *docs=handler->doc;
......@@ -267,7 +268,7 @@ float ft_nlq_find_relevance(FT_INFO *handler,
a=c;
}
if (docs[a].dpos == docid)
return docs[a].weight;
return (float) docs[a].weight;
else
return 0.0;
}
......@@ -279,7 +280,7 @@ void ft_nlq_close_search(FT_INFO *handler)
float ft_nlq_get_relevance(FT_INFO *handler)
{
return handler->doc[handler->curdoc].weight;
return (float) handler->doc[handler->curdoc].weight;
}
void ft_nlq_reinit_search(FT_INFO *handler)
......
......@@ -19,6 +19,7 @@
/* functions to work with full-text indices */
#include "ftdefs.h"
#include <math.h>
/**************************************************************
This is to make ft-code to ignore keyseg.length at all *
......@@ -186,7 +187,7 @@ int _mi_ft_update(MI_INFO *info, uint keynr, byte *keybuf,
cmp=_mi_compare_text(default_charset_info,
(uchar*) old_word->pos,old_word->len,
(uchar*) new_word->pos,new_word->len,0);
cmp2= cmp ? 0 : (abs(old_word->weight - new_word->weight) > 1.e-5);
cmp2= cmp ? 0 : (fabs(old_word->weight - new_word->weight) > 1.e-5);
if (cmp < 0 || cmp2)
{
......
reset query cache;
flush status;
drop table if exists t1;
drop table if exists t1,t2,t3;
create table t1 (a int not null);
insert into t1 values (1),(2),(3);
select * from t1;
......@@ -36,3 +36,265 @@ drop table t1;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
create table t1 (a int not null);
insert into t1 values (1),(2),(3);
create table t2 (a int not null);
insert into t2 values (4),(5),(6);
create table t3 (a int not null) type=MERGE UNION=(t1,t2) INSERT_METHOD=FIRST;
select * from t3;
a
1
2
3
4
5
6
select * from t3;
a
1
2
3
4
5
6
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 2
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
insert into t2 values (7);
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
select * from t1;
a
1
2
3
select * from t1;
a
1
2
3
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 3
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
insert into t3 values (8);
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
select * from t3;
a
1
2
3
8
4
5
6
7
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
update t2 set a=9 where a=7;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
select * from t1;
a
1
2
3
8
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
update t3 set a=10 where a=1;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
select * from t3;
a
10
2
3
8
4
5
6
9
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
delete from t2 where a=9;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
select * from t1;
a
10
2
3
8
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
delete from t3 where a=10;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
drop table t1, t2, t3;
set autocommit=0;
create table t1 (a int not null) type=innodb;
insert into t1 values (1),(2),(3);
select * from t1;
a
1
2
3
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
drop table t1;
commit;
set autocommit=1;
create table t1 (a int not null);
insert into t1 values (1),(2),(3);
create table t2 (a int not null);
insert into t2 values (1),(2),(3);
select * from t1;
a
1
2
3
select * from t2;
a
1
2
3
insert into t1 values (4);
show status like "Qcache_free_blocks";
Variable_name Value
Qcache_free_blocks 2
flush query cache;
show status like "Qcache_free_blocks";
Variable_name Value
Qcache_free_blocks 1
drop table t1, t2;
set sql_query_cache_type=demand;
create table t1 (a int not null);
insert into t1 values (1),(2),(3);
select * from t1;
a
1
2
3
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
select sql_cache * from t1;
a
1
2
3
set sql_query_cache_type=2;
select sql_cache * from t1;
a
1
2
3
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 4
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
set sql_query_cache_type=on;
reset query cache;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
select sql_no_cache * from t1;
a
1
2
3
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
drop table t1;
create table t1 (a text not null);
select CONNECTION_ID() from t1;
CONNECTION_ID()
select FOUND_ROWS();
FOUND_ROWS()
0
select NOW() from t1;
NOW()
select CURDATE() from t1;
CURDATE()
select CURTIME() from t1;
CURTIME()
select DATABASE() from t1;
DATABASE()
select ENCRYPT("test") from t1;
ENCRYPT("test")
select LAST_INSERT_ID() from t1;
last_insert_id()
select RAND() from t1;
RAND()
select UNIX_TIMESTAMP() from t1;
UNIX_TIMESTAMP()
select USER() from t1;
USER()
select benchmark(1,1) from t1;
benchmark(1,1)
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
create table t2 (a text not null);
insert into t1 values("1111111111111111111111111111111111111111111111111111");
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
insert into t2 select * from t1;
insert into t1 select * from t2;
drop table t2;
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 4
select a as a1, a as a2 from t1;
select a as a2, a as a3 from t1;
select a as a3, a as a4 from t1;
select a as a1, a as a2 from t1;
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 4
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 2
reset query cache;
show variables like "query_cache_size";
Variable_name Value
query_cache_size 1039700
show status like "Qcache_free_memory";
Variable_name Value
Qcache_free_memory 1039700
drop table t1;
--set-variable=query_cache_size=2M
--set-variable=query_cache_size=1M
-- source include/have_innodb.inc
#
# Tests with query cache
#
......@@ -6,7 +8,12 @@
reset query cache;
flush status;
drop table if exists t1;
drop table if exists t1,t2,t3;
#
# First simple test
#
create table t1 (a int not null);
insert into t1 values (1),(2),(3);
select * from t1;
......@@ -24,3 +31,153 @@ show status like "Qcache_hits";
drop table t1;
show status like "Qcache_queries_in_cache";
#
# MERGE TABLES with INSERT/UPDATE and DELETE
#
create table t1 (a int not null);
insert into t1 values (1),(2),(3);
create table t2 (a int not null);
insert into t2 values (4),(5),(6);
create table t3 (a int not null) type=MERGE UNION=(t1,t2) INSERT_METHOD=FIRST;
# insert
select * from t3;
select * from t3;
show status like "Qcache_hits";
show status like "Qcache_queries_in_cache";
insert into t2 values (7);
show status like "Qcache_queries_in_cache";
select * from t1;
select * from t1;
show status like "Qcache_hits";
show status like "Qcache_queries_in_cache";
insert into t3 values (8);
show status like "Qcache_queries_in_cache";
# update
select * from t3;
show status like "Qcache_queries_in_cache";
update t2 set a=9 where a=7;
show status like "Qcache_queries_in_cache";
select * from t1;
show status like "Qcache_queries_in_cache";
update t3 set a=10 where a=1;
show status like "Qcache_queries_in_cache";
#delete
select * from t3;
show status like "Qcache_queries_in_cache";
delete from t2 where a=9;
show status like "Qcache_queries_in_cache";
select * from t1;
show status like "Qcache_queries_in_cache";
delete from t3 where a=10;
show status like "Qcache_queries_in_cache";
drop table t1, t2, t3;
#
# Without auto_commit.
#
set autocommit=0;
create table t1 (a int not null) type=innodb;
insert into t1 values (1),(2),(3);
select * from t1;
show status like "Qcache_queries_in_cache";
drop table t1;
commit;
set autocommit=1;
#
# FLUSH QUERY CACHE
#
create table t1 (a int not null);
insert into t1 values (1),(2),(3);
create table t2 (a int not null);
insert into t2 values (1),(2),(3);
select * from t1;
select * from t2;
insert into t1 values (4);
show status like "Qcache_free_blocks";
flush query cache;
show status like "Qcache_free_blocks";
drop table t1, t2;
#
# SELECT SQL_CACHE ...
#
set sql_query_cache_type=demand;
create table t1 (a int not null);
insert into t1 values (1),(2),(3);
select * from t1;
show status like "Qcache_queries_in_cache";
select sql_cache * from t1;
set sql_query_cache_type=2;
select sql_cache * from t1;
show status like "Qcache_hits";
show status like "Qcache_queries_in_cache";
set sql_query_cache_type=on;
#
# RESET QUERY CACHE
#
reset query cache;
show status like "Qcache_queries_in_cache";
#
# SELECT SQL_NO_CACHE
#
select sql_no_cache * from t1;
show status like "Qcache_queries_in_cache";
drop table t1;
#
# Check that queries that uses NOW(), LAST_INSERT_ID()... are not cached.
#
create table t1 (a text not null);
select CONNECTION_ID() from t1;
#GET_LOCK
#RELEASE_LOCK
#LOAD_FILE
select FOUND_ROWS();
select NOW() from t1;
select CURDATE() from t1;
select CURTIME() from t1;
select DATABASE() from t1;
select ENCRYPT("test") from t1;
select LAST_INSERT_ID() from t1;
select RAND() from t1;
select UNIX_TIMESTAMP() from t1;
select USER() from t1;
select benchmark(1,1) from t1;
show status like "Qcache_queries_in_cache";
#
# Tests when the cache is filled
#
create table t2 (a text not null);
insert into t1 values("1111111111111111111111111111111111111111111111111111");
insert into t2 select * from t1;
insert into t1 select * from t2; # 2
insert into t2 select * from t1; # 3
insert into t1 select * from t2; # 5
insert into t2 select * from t1; # 8
insert into t1 select * from t2; # 13
insert into t2 select * from t1; # 21
insert into t1 select * from t2; # 34
insert into t2 select * from t1; # 55
insert into t1 select * from t2; # 89
insert into t2 select * from t1; # 144
insert into t1 select * from t2; # 233
insert into t2 select * from t1; # 357
insert into t1 select * from t2; # 610
insert into t2 select * from t1; # 987
insert into t1 select * from t2; # 1597
insert into t2 select * from t1; # 2584
insert into t1 select * from t2; # 4181
drop table t2;
show status like "Qcache_hits";
disable_result_log;
select a as a1, a as a2 from t1;
select a as a2, a as a3 from t1;
select a as a3, a as a4 from t1;
# next query must be out of 1Mb cache
select a as a1, a as a2 from t1;
enable_result_log;
show status like "Qcache_hits";
show status like "Qcache_queries_in_cache";
reset query cache;
show variables like "query_cache_size";
show status like "Qcache_free_memory";
drop table t1;
......@@ -30,7 +30,8 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c\
mf_iocache.c mf_iocache2.c mf_cache.c mf_tempfile.c \
my_lock.c mf_brkhant.c my_alarm.c \
my_malloc.c my_realloc.c my_once.c mulalloc.c \
my_alloc.c safemalloc.c my_fopen.c my_fstream.c \
my_alloc.c safemalloc.c my_new.cc \
my_fopen.c my_fstream.c \
my_error.c errors.c my_div.c my_messnc.c \
mf_format.c mf_same.c mf_dirname.c mf_fn_ext.c \
my_symlink.c my_symlink2.c \
......
/* Copyright (C) 2000 MySQL AB
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; either version 2 of the License, or
(at your option) any later version.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
This is a replacement of new/delete operators to be used when compiling
with gcc 3.0.x to avoid including libstdc++
*/
#include "mysys_priv.h"
#ifdef USE_MYSYS_NEW
void *operator new (size_t sz)
{
return (void *) malloc (sz ? sz+1 : sz);
}
void *operator new[] (size_t sz)
{
return (void *) malloc (sz ? sz+1 : sz);
}
void operator delete (void *ptr)
{
if (ptr)
free(ptr);
}
void operator delete[] (void *ptr) throw ()
{
if (ptr)
free(ptr);
}
#endif /* USE_MYSYS_NEW */
This diff is collapsed.
......@@ -69,7 +69,7 @@ ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length,
{
int error;
ulong memavl;
uint maxbuffer,skr;
uint maxbuffer;
BUFFPEK *buffpek;
ha_rows records;
uchar **sort_keys;
......@@ -163,7 +163,7 @@ ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length,
&tempfile, selected_records_file)) ==
HA_POS_ERROR)
goto err;
maxbuffer= my_b_tell(&buffpek_pointers)/sizeof(*buffpek);
maxbuffer= (uint) (my_b_tell(&buffpek_pointers)/sizeof(*buffpek));
if (maxbuffer == 0) // The whole set is in memory
{
......@@ -267,7 +267,7 @@ static BUFFPEK *read_buffpek_from_file(IO_CACHE *buffpek_pointers, uint count)
if (tmp)
{
if (reinit_io_cache(buffpek_pointers,READ_CACHE,0L,0,0) ||
my_b_read(buffpek_pointers, (char*) tmp, length))
my_b_read(buffpek_pointers, (byte*) tmp, length))
{
my_free((char*) tmp, MYF(0));
tmp=0;
......@@ -398,10 +398,12 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
/* Skriver en buffert med nycklar till filen */
static int write_keys(SORTPARAM *param, register uchar **sort_keys, uint count,
IO_CACHE *buffpek_pointers, IO_CACHE *tempfile)
static int
write_keys(SORTPARAM *param, register uchar **sort_keys, uint count,
IO_CACHE *buffpek_pointers, IO_CACHE *tempfile)
{
uint sort_length;
uchar **end;
BUFFPEK buffpek;
DBUG_ENTER("write_keys");
......@@ -419,10 +421,10 @@ static int write_keys(SORTPARAM *param, register uchar **sort_keys, uint count,
if ((ha_rows) count > param->max_rows)
count=(uint) param->max_rows; /* purecov: inspected */
buffpek.count=(ha_rows) count;
for (uchar **end=sort_keys+count ; sort_keys != end ; sort_keys++)
for (end=sort_keys+count ; sort_keys != end ; sort_keys++)
if (my_b_write(tempfile,(byte*) *sort_keys,(uint) sort_length))
goto err;
if (my_b_write(buffpek_pointers, (char*) &buffpek, sizeof(buffpek)))
if (my_b_write(buffpek_pointers, (byte*) &buffpek, sizeof(buffpek)))
goto err;
DBUG_RETURN(0);
......
......@@ -2019,7 +2019,9 @@ void Item_func_match::init_search(bool no_order)
}
ft_handler=table->file->ft_init_ext(mode, key,
ft_tmp->ptr(), ft_tmp->length(), join_key && !no_order);
(byte*) ft_tmp->ptr(),
ft_tmp->length(),
join_key && !no_order);
if (join_key)
{
......
......@@ -149,7 +149,7 @@ char* query_table_status(THD *thd,const char *db,const char *table_name);
#define SELECT_SMALL_RESULT 8
#define SELECT_BIG_RESULT 16
#define OPTION_FOUND_ROWS 32
#define SELECT_HIGH_PRIORITY 64 /* Intern */
#define OPTION_TO_QUERY_CACHE 64
#define SELECT_NO_JOIN_CACHE 256 /* Intern */
#define OPTION_BIG_TABLES 512 /* for SQL OPTION */
......@@ -179,7 +179,6 @@ char* query_table_status(THD *thd,const char *db,const char *table_name);
#define SELECT_NO_UNLOCK (QUERY_NO_GOOD_INDEX_USED*2)
#define TMP_TABLE_ALL_COLUMNS (SELECT_NO_UNLOCK*2)
#define OPTION_TO_QUERY_CACHE (TMP_TABLE_ALL_COLUMNS*2)
#define MODE_REAL_AS_FLOAT 1
......
......@@ -3157,12 +3157,16 @@ struct show_var_st status_vars[]= {
{"Open_streams", (char*) &my_stream_opened, SHOW_INT_CONST},
{"Opened_tables", (char*) &opened_tables, SHOW_LONG},
{"Questions", (char*) 0, SHOW_QUESTION},
{"Qcache_queries_in_cache", (char*) &query_cache.queries_in_cache,
SHOW_LONG},
{"Qcache_queries_in_cache", (char*) &query_cache.queries_in_cache, SHOW_LONG_CONST},
{"Qcache_inserts", (char*) &query_cache.inserts, SHOW_LONG},
{"Qcache_hits", (char*) &query_cache.hits, SHOW_LONG},
{"Qcache_not_cached", (char*) &query_cache.refused, SHOW_LONG},
{"Qcache_free_memory", (char*) &query_cache.free_memory,SHOW_LONG},
{"Qcache_free_memory", (char*) &query_cache.free_memory,
SHOW_LONG_CONST},
{"Qcache_free_blocks", (char*) &query_cache.free_memory_blocks,
SHOW_LONG_CONST},
{"Qcache_total_blocks", (char*) &query_cache.total_blocks,
SHOW_LONG_CONST},
{"Rpl_status", (char*) 0, SHOW_RPL_STATUS},
{"Select_full_join", (char*) &select_full_join_count, SHOW_LONG},
{"Select_full_range_join", (char*) &select_full_range_join_count, SHOW_LONG},
......
This diff is collapsed.
This diff is collapsed.
......@@ -17,8 +17,6 @@
#ifndef _SQL_CACHE_H
#define _SQL_CACHE_H
#include <semaphore.h>
/* Query cache */
/*
......@@ -105,7 +103,7 @@ struct Query_cache_query
Query_cache_block *res;
NET *wri;
ulong len;
sem_t lock; // R/W lock of block
pthread_cond_t lock; // R/W lock of block
pthread_mutex_t clients_guard;
uint clients;
......@@ -220,7 +218,8 @@ public:
/* Info */
ulong query_cache_size, query_cache_limit;
/* statistics */
ulong free_memory, queries_in_cache, hits, inserts, refused;
ulong free_memory, queries_in_cache, hits, inserts, refused,
free_memory_blocks, total_blocks;
protected:
/*
......
......@@ -1023,11 +1023,11 @@ err:
int log_loaded_block(IO_CACHE* file)
{
LOAD_FILE_INFO* lf_info;
uint block_len ;
ulong block_len ;
/* file->request_pos contains position where we started last read */
char* buffer = (char*) file->request_pos;
if (!(block_len = file->read_end - buffer))
byte *buffer = file->request_pos;
if (!(block_len = (ulong) (file->read_end - buffer)))
return 0;
lf_info = (LOAD_FILE_INFO*)file->arg;
if (lf_info->last_pos_in_file != HA_POS_ERROR &&
......@@ -1036,14 +1036,14 @@ int log_loaded_block(IO_CACHE* file)
lf_info->last_pos_in_file = file->pos_in_file;
if (lf_info->wrote_create_file)
{
Append_block_log_event a(lf_info->thd, buffer, block_len);
Append_block_log_event a(lf_info->thd, (char*) buffer, block_len);
mysql_bin_log.write(&a);
}
else
{
Create_file_log_event c(lf_info->thd,lf_info->ex,lf_info->db,
lf_info->table_name, *lf_info->fields,
lf_info->handle_dup, buffer,
lf_info->handle_dup, (char*) buffer,
block_len);
mysql_bin_log.write(&c);
lf_info->wrote_create_file = 1;
......
......@@ -3172,11 +3172,9 @@ option_value:
}
query_cache_type:
'0' { current_thd->query_cache_type = 0; }
NUM { current_thd->query_cache_type = set_zone(atoi($1.str),0,3); }
| OFF { current_thd->query_cache_type = 0; }
| '1' { current_thd->query_cache_type = 1; }
| ON { current_thd->query_cache_type = 1; }
| '2' { current_thd->query_cache_type = 2; }
| DEMAND_SYM { current_thd->query_cache_type = 2; }
text_or_password:
......
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