~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/csv/transparent_file.cc

  • Committer: Jay Pipes
  • Date: 2009-01-30 04:01:12 UTC
  • mto: This revision was merged to the branch mainline in revision 830.
  • Revision ID: jpipes@serialcoder-20090130040112-svbn774guj98pwi4
To remain in compatibility with MySQL, added ability to interpret
decimal arguments as datetime strings for temporal functions.

Fixed YEAR(), MONTH(), DAYOFMONTH(), DAYOFYEAR(), HOUR(), MINUTE(), SECOND(), and MICROSECOND()
to accept decimal parameters and interpret them the same way as MySQL.

Fixed an issue with the TemporalFormat::matches() method which was 
incorrectly assuming all microsecond arguments were specified as 6 digits.
Added power of 10 multiplier to usecond calculation. This fixes issues with
failures in type_date and func_sapdb test cases.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
  You should have received a copy of the GNU General Public License
13
13
  along with this program; if not, write to the Free Software
14
 
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
 
 
16
 
 
17
 
#include "config.h"
18
 
#include <cstdlib>
19
 
#include "drizzled/internal/my_sys.h"
 
14
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
 
 
17
#include <drizzled/server_includes.h>
20
18
#include "transparent_file.h"
21
19
 
22
 
using namespace drizzled;
23
 
 
24
20
Transparent_file::Transparent_file() : lower_bound(0), buff_size(IO_SIZE)
25
21
{
26
 
  buff= static_cast<unsigned char *>(malloc(buff_size*sizeof(unsigned char)));
 
22
  buff= (unsigned char *) malloc(buff_size*sizeof(unsigned char));
27
23
}
28
24
 
29
25
Transparent_file::~Transparent_file()
30
26
{
31
 
  free(buff);
 
27
  free((unsigned char*)buff);
32
28
}
33
29
 
34
 
void Transparent_file::init_buff(int filedes_arg)
 
30
void Transparent_file::init_buff(File filedes_arg)
35
31
{
36
32
  filedes= filedes_arg;
37
33
  /* read the beginning of the file */
38
34
  lower_bound= 0;
39
35
  lseek(filedes, 0, SEEK_SET);
40
36
  if (filedes && buff)
41
 
    upper_bound= internal::my_read(filedes, buff, buff_size, MYF(0));
 
37
    upper_bound= my_read(filedes, buff, buff_size, MYF(0));
42
38
}
43
39
 
44
40
unsigned char *Transparent_file::ptr()
64
60
     No need to seek here, as the file managed by Transparent_file class
65
61
     always points to upper_bound byte
66
62
  */
67
 
  if ((bytes_read= internal::my_read(filedes, buff, buff_size, MYF(0))) == MY_FILE_ERROR)
 
63
  if ((bytes_read= my_read(filedes, buff, buff_size, MYF(0))) == MY_FILE_ERROR)
68
64
    return (off_t) -1;
69
65
 
70
66
  /* end of file */
88
84
 
89
85
  lseek(filedes, offset, SEEK_SET);
90
86
  /* read appropriate portion of the file */
91
 
  if ((bytes_read= internal::my_read(filedes, buff, buff_size,
 
87
  if ((bytes_read= my_read(filedes, buff, buff_size,
92
88
                           MYF(0))) == MY_FILE_ERROR)
93
89
    return 0;
94
90