~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/str/load_file.cc

[patch 109/129] Merge patch for revision 1921 from InnoDB SVN:
revno: 1921
revision-id: svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6160
parent: svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6159
committer: vasil
timestamp: Wed 2009-11-11 13:33:49 +0000
message:
  branches/zip: Merge r6152:6159 from branches/5.1:
  
  (r6158 was skipped as an equivallent change has already been merged from MySQL)
  
    ------------------------------------------------------------------------
    r6154 | calvin | 2009-11-11 02:51:17 +0200 (Wed, 11 Nov 2009) | 17 lines
    Changed paths:
       M /branches/5.1/include/os0file.h
       M /branches/5.1/os/os0file.c
    
    branches/5.1: fix bug#3139: Mysql crashes: 'windows error 995'
    after several selects on a large DB
    
    During stress environment, Windows AIO may fail with error code
    ERROR_OPERATION_ABORTED. InnoDB does not handle the error, rather
    crashes. The cause of the error is unknown, but likely due to
    faulty hardware or driver.
    
    This patch introduces a new error code OS_FILE_OPERATION_ABORTED,
    which maps to Windows ERROR_OPERATION_ABORTED (995). When the error
    is detected during AIO, the InnoDB will issue a synchronous retry
    (read/write).
    
    This patch has been extensively tested by MySQL support.
    
    Approved by: Marko
    rb://196
    ------------------------------------------------------------------------
    r6158 | vasil | 2009-11-11 14:52:14 +0200 (Wed, 11 Nov 2009) | 37 lines
    Changed paths:
       M /branches/5.1/handler/ha_innodb.cc
       M /branches/5.1/handler/ha_innodb.h
    
    branches/5.1:
    
    Merge a change from MySQL:
    (this has been reviewed by Calvin and Marko, and Calvin says Luis has
    incorporated Marko's suggestions)
    
      ------------------------------------------------------------
      revno: 3092.5.1
      committer: Luis Soares <luis.soares@sun.com>
      branch nick: mysql-5.1-bugteam
      timestamp: Thu 2009-09-24 15:52:52 +0100
      message:
        BUG#42829: binlogging enabled for all schemas regardless of
        binlog-db-db / binlog-ignore-db
              
        InnoDB will return an error if statement based replication is used
        along with transaction isolation level READ-COMMITTED (or weaker),
        even if the statement in question is filtered out according to the
        binlog-do-db rules set. In this case, an error should not be printed.
              
        This patch addresses this issue by extending the existing check in
        external_lock to take into account the filter rules before deciding to
        print an error. Furthermore, it also changes decide_logging_format to
        take into consideration whether the statement is filtered out from 
        binlog before decision is made.
      added:
        mysql-test/suite/binlog/r/binlog_stm_do_db.result
        mysql-test/suite/binlog/t/binlog_stm_do_db-master.opt
        mysql-test/suite/binlog/t/binlog_stm_do_db.test
      modified:
        sql/sql_base.cc
        sql/sql_class.cc
        storage/innobase/handler/ha_innodb.cc
        storage/innobase/handler/ha_innodb.h
        storage/innodb_plugin/handler/ha_innodb.cc
        storage/innodb_plugin/handler/ha_innodb.h
    
    ------------------------------------------------------------------------
modified:
  include/os0file.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fos0file.h
  os/os0file.c                   2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fos%2Fos0file.c
diff:
=== modified file 'include/os0file.h'

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <drizzled/session.h>
26
26
#include "drizzled/internal/my_sys.h"
27
27
 
28
 
#include <boost/filesystem.hpp>
29
 
 
30
28
#include <fcntl.h>
31
29
#include <sys/stat.h>
32
 
#include <iostream>
33
 
 
34
 
namespace fs=boost::filesystem;
35
 
using namespace std;
36
30
 
37
31
namespace drizzled
38
32
{
43
37
  String *file_name;
44
38
  int file;
45
39
  struct stat stat_info;
 
40
  char path[FN_REFLEN];
46
41
 
47
42
  if (!(file_name= args[0]->val_str(str)))
48
 
  {
49
 
    null_value = 1;
50
 
    return(0);
51
 
  }
 
43
    goto err;
52
44
 
53
 
  fs::path target_path(fs::system_complete(getDataHomeCatalog()));
54
 
  fs::path to_file(file_name->c_ptr());
55
 
  if (not to_file.has_root_directory())
56
 
  {
57
 
    target_path /= to_file;
58
 
  }
59
 
  else
60
 
  {
61
 
    target_path= to_file;
62
 
  }
 
45
  (void) internal::fn_format(path, file_name->c_ptr(), getDataHome().c_str(), "",
 
46
                   MY_RELATIVE_PATH | MY_UNPACK_FILENAME);
63
47
 
64
48
  /* Read only allowed from within dir specified by secure_file_priv */
65
 
  if (not secure_file_priv.string().empty())
66
 
  {
67
 
    fs::path secure_file_path(fs::system_complete(secure_file_priv));
68
 
    if (target_path.file_string().substr(0, secure_file_path.file_string().size()) != secure_file_path.file_string())
69
 
    {
70
 
      /* Read only allowed from within dir specified by secure_file_priv */
71
 
      my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv"); 
72
 
      null_value = 1;
73
 
      return 0;
74
 
    }
75
 
  }
 
49
  if (opt_secure_file_priv &&
 
50
      strncmp(opt_secure_file_priv, path, strlen(opt_secure_file_priv)))
 
51
    goto err;
76
52
 
77
 
  if (stat(target_path.file_string().c_str(), &stat_info))
78
 
  {
79
 
    my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), file_name->c_ptr());
 
53
  if (stat(path, &stat_info))
80
54
    goto err;
81
 
  }
82
55
 
83
56
  if (!(stat_info.st_mode & S_IROTH))
84
57
  {
85
 
    my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), file_name->c_ptr());
 
58
    /* my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), file_name->c_ptr()); */
86
59
    goto err;
87
60
  }
88
 
 
89
61
  if (stat_info.st_size > (long) session.variables.max_allowed_packet)
90
62
  {
91
63
    push_warning_printf(&session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
94
66
                        func_name(), session.variables.max_allowed_packet);
95
67
    goto err;
96
68
  }
97
 
 
98
 
  if (stat_info.st_size == 0)
99
 
  {
100
 
    goto err;
101
 
  }
102
 
 
103
69
  if (tmp_value.alloc((size_t)stat_info.st_size))
104
70
    goto err;
105
 
  if ((file = internal::my_open(target_path.file_string().c_str(), O_RDONLY, MYF(0))) < 0)
 
71
  if ((file = internal::my_open(file_name->c_ptr(), O_RDONLY, MYF(0))) < 0)
106
72
    goto err;
107
73
  if (internal::my_read(file, (unsigned char*) tmp_value.ptr(), (size_t)stat_info.st_size, MYF(MY_NABP)))
108
74
  {
109
75
    internal::my_close(file, MYF(0));
110
76
    goto err;
111
77
  }
112
 
  if (strlen(tmp_value.ptr()) == 0)
113
 
  {
114
 
    goto err;
115
 
  }
116
78
  tmp_value.length((size_t)stat_info.st_size);
117
79
  internal::my_close(file, MYF(0));
118
80
  null_value = 0;