1
by brian
clean slate |
1 |
/* Copyright (C) 2000-2004 MySQL AB
|
2 |
||
3 |
This program is free software; you can redistribute it and/or modify
|
|
4 |
it under the terms of the GNU General Public License as published by
|
|
5 |
the Free Software Foundation; version 2 of the License.
|
|
6 |
||
7 |
This program is distributed in the hope that it will be useful,
|
|
8 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
10 |
GNU General Public License for more details.
|
|
11 |
||
12 |
You should have received a copy of the GNU General Public License
|
|
13 |
along with this program; if not, write to the Free Software
|
|
14 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
15 |
||
16 |
/**
|
|
17 |
@file
|
|
18 |
||
19 |
@details
|
|
20 |
Caching of files with only does (sequential) read or writes of fixed-
|
|
21 |
length records. A read isn't allowed to go over file-length. A read is ok
|
|
22 |
if it ends at file-length and next read can try to read after file-length
|
|
23 |
(and get a EOF-error).
|
|
24 |
Possibly use of asyncronic io.
|
|
25 |
macros for read and writes for faster io.
|
|
26 |
Used instead of FILE when reading or writing whole files.
|
|
27 |
This will make mf_rec_cache obsolete.
|
|
28 |
One can change info->pos_in_file to a higher value to skip bytes in file if
|
|
29 |
also info->rc_pos is set to info->rc_end.
|
|
30 |
If called through open_cached_file(), then the temporary file will
|
|
31 |
only be created if a write exeeds the file buffer or if one calls
|
|
32 |
flush_io_cache().
|
|
33 |
*/
|
|
243.1.17
by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.) |
34 |
#include <drizzled/server_includes.h> |
1
by brian
clean slate |
35 |
|
36 |
extern "C" { |
|
37 |
||
38 |
/**
|
|
39 |
Read buffered from the net.
|
|
40 |
||
41 |
@retval
|
|
42 |
1 if can't read requested characters
|
|
43 |
@retval
|
|
44 |
0 if record read
|
|
45 |
*/
|
|
481
by Brian Aker
Remove all of uchar. |
46 |
int _my_b_net_read(register IO_CACHE *info, unsigned char *Buffer, |
1
by brian
clean slate |
47 |
size_t Count __attribute__((unused))) |
48 |
{
|
|
49 |
ulong read_length; |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
50 |
NET *net= &(current_session)->net; |
1
by brian
clean slate |
51 |
|
52 |
if (!info->end_of_file) |
|
51.1.32
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
53 |
return(1); /* because my_b_get (no _) takes 1 byte at a time */ |
1
by brian
clean slate |
54 |
read_length=my_net_read(net); |
55 |
if (read_length == packet_error) |
|
56 |
{
|
|
57 |
info->error= -1; |
|
51.1.32
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
58 |
return(1); |
1
by brian
clean slate |
59 |
}
|
60 |
if (read_length == 0) |
|
61 |
{
|
|
62 |
info->end_of_file= 0; /* End of file from client */ |
|
51.1.32
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
63 |
return(1); |
1
by brian
clean slate |
64 |
}
|
65 |
/* to set up stuff for my_b_get (no _) */
|
|
481
by Brian Aker
Remove all of uchar. |
66 |
info->read_end = (info->read_pos = (unsigned char*) net->read_pos) + read_length; |
1
by brian
clean slate |
67 |
Buffer[0] = info->read_pos[0]; /* length is always 1 */ |
68 |
||
69 |
/*
|
|
70 |
info->request_pos is used by log_loaded_block() to know the size
|
|
71 |
of the current block.
|
|
72 |
info->pos_in_file is used by log_loaded_block() too.
|
|
73 |
*/
|
|
74 |
info->pos_in_file+= read_length; |
|
75 |
info->request_pos=info->read_pos; |
|
76 |
||
77 |
info->read_pos++; |
|
78 |
||
51.1.32
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
79 |
return(0); |
1
by brian
clean slate |
80 |
}
|
81 |
||
82 |
} /* extern "C" */ |