Skip to content

Commit 1d26537

Browse files
author
monty@hundin.mysql.fi
committed
Query cache.
Remove some warnings
1 parent 8a86170 commit 1d26537

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3363
-292
lines changed

Docs/manual.texi

+8
Original file line numberDiff line numberDiff line change
@@ -8528,6 +8528,14 @@ libc internal error: _rmutex_unlock: rmutex not held
85288528

85298529
Add @code{-mt} to @code{CFLAGS} and @code{CXXFLAGS} and try again.
85308530

8531+
If you are using the SFW version of gcc (which comes with Solaris 8),
8532+
you must add @file{/opt/sfw/lib} to the environment variable
8533+
@code{LD_LIBRARY_PATH} before running configure.
8534+
8535+
If you are using the gcc available from @code{sunfreeware.com}, you may
8536+
have many problems. You should recompile gcc and GNU binutils on the
8537+
machine you will be running them from to avoid any problems.
8538+
85318539
If you get the following error when compiling MySQL with @code{gcc},
85328540
it means that your @code{gcc} is not configured for your version of Solaris:
85338541

include/ft_global.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ extern const char *ft_precompiled_stopwords[];
4949
extern ulong ft_min_word_len;
5050
extern ulong ft_max_word_len;
5151
extern ulong ft_max_word_len_for_sort;
52-
extern char *ft_boolean_syntax;
52+
extern const char *ft_boolean_syntax;
5353

5454
int ft_init_stopwords(const char **);
5555
void ft_free_stopwords(void);

include/myisam.h

+2
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ typedef struct st_columndef /* column information */
191191
#endif
192192
} MI_COLUMNDEF;
193193

194+
/* invalidator function reference for Query Cache */
195+
typedef void (* invalidator_by_filename) (char * filename);
194196

195197
extern my_string myisam_log_filename; /* Name of logfile */
196198
extern uint myisam_block_size;

include/myisammrg.h

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ extern int myrg_lock_database(MYRG_INFO *file,int lock_type);
9595
extern int myrg_create(const char *name, const char **table_names,
9696
uint insert_method, my_bool fix_names);
9797
extern int myrg_extra(MYRG_INFO *file,enum ha_extra_function function);
98+
extern void myrg_extrafunc(MYRG_INFO *info,invalidator_by_filename inv);
9899
extern ha_rows myrg_records_in_range(MYRG_INFO *info,int inx,
99100
const byte *start_key,uint start_key_len,
100101
enum ha_rkey_function start_search_flag,

include/mysql_com.h

+4
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
7878
#define REFRESH_READ_LOCK 16384 /* Lock tables for read */
7979
#define REFRESH_FAST 32768 /* Intern flag */
8080

81+
#define REFRESH_QUERY_CACHE 65536 /* flush query cache */
82+
#define REFRESH_QUERY_CACHE_FREE 0x10000L /* pack query cache */
83+
8184
#define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
8285
#define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
8386
#define CLIENT_LONG_FLAG 4 /* Get all column flags */
@@ -126,6 +129,7 @@ typedef struct st_net {
126129
unsigned char reading_or_writing;
127130
char save_char;
128131
my_bool no_send_ok;
132+
gptr query_cache_query;
129133
} NET;
130134

131135
#define packet_error (~(unsigned long) 0)

libmysqld/lib_sql.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
460460
umask(((~my_umask) & 0666));
461461
table_cache_init();
462462
hostname_cache_init();
463-
sql_cache_init();
463+
/*sql_cache_init();*/
464464
randominit(&sql_rand,(ulong) start_time,(ulong) start_time/2);
465465
reset_floating_point_exceptions();
466466
init_thr_lock();

myisam/ft_boolean_search.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ typedef struct st_ft_info {
8686
MEM_ROOT mem_root;
8787
} FTB;
8888

89-
int FTB_WORD_cmp(void *v, byte *a, byte *b)
89+
int FTB_WORD_cmp(void *v __attribute__((unused)), byte *a, byte *b)
9090
{
9191
/* ORDER BY docid, ndepth DESC */
9292
int i=CMP_NUM(((FTB_WORD *)a)->docid, ((FTB_WORD *)b)->docid);
@@ -109,7 +109,7 @@ void _ftb_parse_query(FTB *ftb, byte **start, byte *end,
109109
return;
110110

111111
param.prev=' ';
112-
while (res=ft_get_word(start,end,&w,&param))
112+
while ((res=ft_get_word(start,end,&w,&param)))
113113
{
114114
byte r=param.plusminus;
115115
float weight=(param.pmsign ? nwghts : wghts)[(r>5)?5:((r<-5)?-5:r)];
@@ -280,7 +280,7 @@ void _ftb_climb_the_tree(FTB_WORD *ftbw, my_off_t curdoc)
280280

281281
int ft_boolean_read_next(FT_INFO *ftb, char *record)
282282
{
283-
FTB_EXPR *ftbe, *up;
283+
FTB_EXPR *ftbe;
284284
FTB_WORD *ftbw;
285285
MI_INFO *info=ftb->info;
286286
MI_KEYDEF *keyinfo=info->s->keyinfo+ftb->keynr;

myisam/ft_dump.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,14 @@ static void get_options(int argc, char *argv[])
184184

185185
static void usage(char *argv[])
186186
{
187-
printf("
188-
Use: %s [-%s] <table_name> <index_no>
189-
190-
-d dump index (incl. data offsets and word weights)
191-
-s report global stats
192-
-c calculate per-word stats (counts and global weights)
193-
-v be verbose
194-
-h this text\n
187+
printf("\n\
188+
Use: %s [-%s] <table_name> <index_no>\n\
189+
\n\
190+
-d dump index (incl. data offsets and word weights)\n\
191+
-s report global stats\n\
192+
-c calculate per-word stats (counts and global weights)\n\
193+
-v be verbose\n\
194+
-h this text\n\
195195
", *argv, options);
196196
exit(1);
197197
}

myisam/ft_parser.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ typedef struct st_ft_docstat {
3838
static int FT_WORD_cmp(void* cmp_arg, FT_WORD *w1, FT_WORD *w2)
3939
{
4040
return _mi_compare_text(default_charset_info,
41-
(uchar*) w1->pos,w1->len,
42-
(uchar*) w2->pos, w2->len,(my_bool)cmp_arg);
41+
(uchar*) w1->pos, w1->len,
42+
(uchar*) w2->pos, w2->len,
43+
(my_bool) (cmp_arg != 0));
4344
}
4445

4546
static int walk_and_copy(FT_WORD *word,uint32 count,FT_DOCSTAT *docstat)

myisam/ft_static.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
ulong ft_min_word_len=4;
2222
ulong ft_max_word_len=HA_FT_MAXLEN;
2323
ulong ft_max_word_len_for_sort=20;
24-
char *ft_boolean_syntax="+ -><()~*";
24+
const char *ft_boolean_syntax="+ -><()~*";
2525

2626
const MI_KEYSEG ft_keysegs[FT_SEGS]={
2727
{

myisam/ft_update.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ uint _mi_ft_parse(TREE *parsed, MI_INFO *info, uint keynr, const byte *record)
6767
return 0;
6868
}
6969

70-
FT_WORD * _mi_ft_parserecord(MI_INFO *info, uint keynr, byte *keybuf,
71-
const byte *record)
70+
FT_WORD * _mi_ft_parserecord(MI_INFO *info, uint keynr,
71+
byte *keybuf __attribute__((unused)),
72+
const byte *record)
7273
{
7374
TREE ptree;
7475

myisam/ftdefs.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ byte ft_simple_get_word(byte **, byte *, FT_WORD *);
123123
int ft_parse(TREE *, byte *, int);
124124
FT_WORD * ft_linearize(/*MI_INFO *, uint, byte *, */TREE *);
125125
FT_WORD * _mi_ft_parserecord(MI_INFO *, uint, byte *, const byte *);
126+
uint _mi_ft_parse(TREE *parsed, MI_INFO *info, uint keynr, const byte *record);
126127

127128
const struct _ft_vft _ft_vft_nlq;
128129
FT_INFO *ft_init_nlq_search(MI_INFO *, uint, byte *, uint, my_bool);
@@ -141,4 +142,3 @@ void ft_boolean_close_search(FT_INFO *);
141142
float ft_boolean_get_relevance(FT_INFO *);
142143
my_off_t ft_boolean_get_docid(FT_INFO *);
143144
void ft_boolean_reinit_search(FT_INFO *);
144-

myisam/mi_delete.c

+6
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ int mi_delete(MI_INFO *info,const byte *record)
9797
myisam_log_command(MI_LOG_DELETE,info,(byte*) lastpos,sizeof(lastpos),0);
9898
VOID(_mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE));
9999
allow_break(); /* Allow SIGHUP & SIGINT */
100+
if (info->invalidator != 0)
101+
{
102+
DBUG_PRINT("info", ("invalidator... '%s' (delete)", info->filename));
103+
(*info->invalidator)(info->filename);
104+
info->invalidator=0;
105+
}
100106
DBUG_RETURN(0);
101107

102108
err:

myisam/mi_locking.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ int mi_lock_database(MI_INFO *info, int lock_type)
4343
pthread_mutex_lock(&share->intern_lock);
4444
if (share->kfile >= 0) /* May only be false on windows */
4545
{
46-
switch (lock_type)
47-
{
46+
switch (lock_type) {
4847
case F_UNLCK:
4948
if (info->lock_type == F_RDLCK)
5049
count= --share->r_locks;
@@ -201,6 +200,7 @@ int mi_lock_database(MI_INFO *info, int lock_type)
201200
}
202201
VOID(_mi_test_if_changed(info));
203202
info->lock_type=lock_type;
203+
info->invalidator=info->s->invalidator;
204204
share->w_locks++;
205205
share->tot_locks++;
206206
break;
@@ -319,6 +319,7 @@ int _mi_readinfo(register MI_INFO *info, int lock_type, int check_keybuffer)
319319
}
320320
if (check_keybuffer)
321321
VOID(_mi_test_if_changed(info));
322+
info->invalidator=info->s->invalidator;
322323
}
323324
else if (lock_type == F_WRLCK && info->lock_type == F_RDLCK)
324325
{

myisam/mi_update.c

+6
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ int mi_update(register MI_INFO *info, const byte *oldrec, byte *newrec)
136136
myisam_log_record(MI_LOG_UPDATE,info,newrec,info->lastpos,0);
137137
VOID(_mi_writeinfo(info,key_changed ? WRITEINFO_UPDATE_KEYFILE : 0));
138138
allow_break(); /* Allow SIGHUP & SIGINT */
139+
if (info->invalidator != 0)
140+
{
141+
DBUG_PRINT("info", ("invalidator... '%s' (update)", info->filename));
142+
(*info->invalidator)(info->filename);
143+
info->invalidator=0;
144+
}
139145
DBUG_RETURN(0);
140146

141147
err:

myisam/myisamdef.h

+41-39
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ typedef struct st_mi_state_info
6666
ulong unique; /* Unique number for this process */
6767
ulong update_count; /* Updated for each write lock */
6868
ulong status;
69+
ulong *rec_per_key_part;
6970
my_off_t *key_root; /* Start of key trees */
7071
my_off_t *key_del; /* delete links for trees */
72+
my_off_t rec_per_key_rows; /* Rows when calculating rec_per_key */
7173

7274
ulong sec_index_changed; /* Updated when new sec_index */
7375
ulong sec_index_used; /* which extra index are in use */
@@ -80,8 +82,6 @@ typedef struct st_mi_state_info
8082
uint sortkey; /* sorted by this key (not used) */
8183
uint open_count;
8284
uint8 changed; /* Changed since myisamchk */
83-
my_off_t rec_per_key_rows; /* Rows when calculating rec_per_key */
84-
ulong *rec_per_key_part;
8585

8686
/* the following isn't saved on disk */
8787
uint state_diff_length; /* Should be 0 */
@@ -164,40 +164,41 @@ typedef struct st_mi_isam_share { /* Shared between opens */
164164
char *data_file_name, /* Resolved path names from symlinks */
165165
*index_file_name;
166166
byte *file_map; /* mem-map of file if possible */
167+
MI_DECODE_TREE *decode_trees;
168+
uint16 *decode_tables;
169+
int (*read_record)(struct st_myisam_info*, my_off_t, byte*);
170+
int (*write_record)(struct st_myisam_info*, const byte*);
171+
int (*update_record)(struct st_myisam_info*, my_off_t, const byte*);
172+
int (*delete_record)(struct st_myisam_info*);
173+
int (*read_rnd)(struct st_myisam_info*, byte*, my_off_t, my_bool);
174+
int (*compare_record)(struct st_myisam_info*, const byte *);
175+
ha_checksum (*calc_checksum)(struct st_myisam_info*, const byte *);
176+
int (*compare_unique)(struct st_myisam_info*, MI_UNIQUEDEF *,
177+
const byte *record, my_off_t pos);
178+
invalidator_by_filename invalidator; /* query cache invalidator */
167179
ulong this_process; /* processid */
168180
ulong last_process; /* For table-change-check */
169181
ulong last_version; /* Version on start */
170182
ulong options; /* Options used */
183+
ulong min_pack_length; /* Theese are used by packed data */
184+
ulong max_pack_length;
185+
ulong state_diff_length;
171186
uint rec_reflength; /* rec_reflength in use now */
172187
File kfile; /* Shared keyfile */
173188
File data_file; /* Shared data file */
174189
int mode; /* mode of file on open */
175190
uint reopen; /* How many times reopened */
176191
uint w_locks,r_locks,tot_locks; /* Number of read/write locks */
177192
uint blocksize; /* blocksize of keyfile */
178-
ulong min_pack_length; /* Theese are used by packed data */
179-
ulong max_pack_length;
180-
ulong state_diff_length;
193+
myf write_flag;
194+
int rnd; /* rnd-counter */
195+
enum data_file_type data_file_type;
181196
my_bool changed, /* If changed since lock */
182197
global_changed, /* If changed since open */
183198
not_flushed,
184199
temporary,delay_key_write,
185200
concurrent_insert,
186201
fulltext_index;
187-
myf write_flag;
188-
int rnd; /* rnd-counter */
189-
MI_DECODE_TREE *decode_trees;
190-
uint16 *decode_tables;
191-
enum data_file_type data_file_type;
192-
int (*read_record)(struct st_myisam_info*, my_off_t, byte*);
193-
int (*write_record)(struct st_myisam_info*, const byte*);
194-
int (*update_record)(struct st_myisam_info*, my_off_t, const byte*);
195-
int (*delete_record)(struct st_myisam_info*);
196-
int (*read_rnd)(struct st_myisam_info*, byte*, my_off_t, my_bool);
197-
int (*compare_record)(struct st_myisam_info*, const byte *);
198-
ha_checksum (*calc_checksum)(struct st_myisam_info*, const byte *);
199-
int (*compare_unique)(struct st_myisam_info*, MI_UNIQUEDEF *,
200-
const byte *record, my_off_t pos);
201202
#ifdef THREAD
202203
THR_LOCK lock;
203204
pthread_mutex_t intern_lock; /* Locking for use with _locking */
@@ -215,16 +216,22 @@ typedef struct st_mi_bit_buff { /* Used for packing of record */
215216
uint error;
216217
} MI_BIT_BUFF;
217218

218-
219219
struct st_myisam_info {
220220
MYISAM_SHARE *s; /* Shared between open:s */
221221
MI_STATUS_INFO *state,save_state;
222222
MI_BLOB *blobs; /* Pointer to blobs */
223-
int dfile; /* The datafile */
224-
MI_BIT_BUFF bit_buff;
225-
uint opt_flag; /* Optim. for space/speed */
226-
uint update; /* If file changed since open */
223+
MI_BIT_BUFF bit_buff;
224+
/* accumulate indexfile changes between write's */
225+
TREE *bulk_insert;
227226
char *filename; /* parameter to open filename */
227+
uchar *buff, /* Temp area for key */
228+
*lastkey,*lastkey2; /* Last used search key */
229+
byte *rec_buff, /* Tempbuff for recordpack */
230+
*rec_alloc; /* Malloced area for record */
231+
uchar *int_keypos, /* Save position for next/previous */
232+
*int_maxpos; /* -""- */
233+
int (*read_record)(struct st_myisam_info*, my_off_t, byte*);
234+
invalidator_by_filename invalidator; /* query cache invalidator */
228235
ulong this_unique; /* uniq filenumber or thread */
229236
ulong last_unique; /* last unique number */
230237
ulong this_loop; /* counter for this open */
@@ -233,20 +240,16 @@ struct st_myisam_info {
233240
nextpos; /* Position to next record */
234241
my_off_t save_lastpos;
235242
my_off_t pos; /* Intern variable */
243+
my_off_t last_keypage; /* Last key page read */
244+
my_off_t last_search_keypage; /* Last keypage when searching */
245+
my_off_t dupp_key_pos;
236246
ha_checksum checksum;
237247
ulong packed_length,blob_length; /* Length of found, packed record */
248+
int dfile; /* The datafile */
249+
uint opt_flag; /* Optim. for space/speed */
250+
uint update; /* If file changed since open */
238251
uint alloced_rec_buff_length; /* Max recordlength malloced */
239-
uchar *buff, /* Temp area for key */
240-
*lastkey,*lastkey2; /* Last used search key */
241-
byte *rec_buff, /* Tempbuff for recordpack */
242-
*rec_alloc; /* Malloced area for record */
243-
uchar *int_keypos, /* Save position for next/previous */
244-
*int_maxpos; /* -""- */
245-
uint32 int_keytree_version; /* -""- */
246252
uint int_nod_flag; /* -""- */
247-
my_off_t last_keypage; /* Last key page read */
248-
my_off_t last_search_keypage; /* Last keypage when searching */
249-
my_off_t dupp_key_pos;
250253
int lastinx; /* Last used index */
251254
uint lastkey_length; /* Length of key in lastkey */
252255
uint last_rkey_length; /* Last length in mi_rkey() */
@@ -257,16 +260,15 @@ struct st_myisam_info {
257260
uint data_changed; /* Somebody has changed data */
258261
uint save_update; /* When using KEY_READ */
259262
int save_lastinx;
263+
uint32 int_keytree_version; /* -""- */
264+
LIST open_list;
265+
IO_CACHE rec_cache; /* When cacheing records */
266+
myf lock_wait; /* is 0 or MY_DONT_WAIT */
260267
my_bool was_locked; /* Was locked in panic */
261268
my_bool quick_mode;
262269
my_bool page_changed; /* If info->buff can't be used for rnext */
263270
my_bool buff_used; /* If info->buff has to be reread for rnext */
264271
my_bool use_packed_key; /* For MYISAMMRG */
265-
TREE *bulk_insert; /* accumulate indexfile changes between mi_write's */
266-
myf lock_wait; /* is 0 or MY_DONT_WAIT */
267-
int (*read_record)(struct st_myisam_info*, my_off_t, byte*);
268-
LIST open_list;
269-
IO_CACHE rec_cache; /* When cacheing records */
270272
#ifdef THREAD
271273
THR_LOCK_DATA lock;
272274
#endif

myisammrg/myrg_extra.c

+10
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,13 @@ int myrg_extra(MYRG_INFO *info,enum ha_extra_function function)
4646
}
4747
DBUG_RETURN(save_error);
4848
}
49+
50+
void myrg_extrafunc(MYRG_INFO *info, invalidator_by_filename inv)
51+
{
52+
MYRG_TABLE *file;
53+
54+
DBUG_ENTER("myrg_extrafunc");
55+
for (file=info->open_tables ; file != info->end_table ; file++)
56+
file->table->s->invalidator = inv;
57+
DBUG_VOID_RETURN;
58+
}

0 commit comments

Comments
 (0)