~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_binlog.cc

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
RemoveĀ uint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
16
#include <drizzled/server_includes.h>
17
 
#include <drizzled/rpl_rli.h>
 
17
#include "rpl_rli.h"
18
18
#include <mysys/base64.h>
19
 
#include <drizzled/error.h>
20
19
 
21
20
/**
22
21
  Execute a BINLOG statement
29
28
  rli->description_event_for_exec.
30
29
*/
31
30
 
32
 
void mysql_client_binlog_statement(Session* session)
 
31
void mysql_client_binlog_statement(THD* thd)
33
32
{
34
 
  size_t coded_len= session->lex->comment.length + 1;
 
33
  size_t coded_len= thd->lex->comment.length + 1;
35
34
  size_t decoded_len= base64_needed_decoded_length(coded_len);
36
35
  assert(coded_len > 0);
37
36
 
45
44
    Format_description_event.
46
45
  */
47
46
  bool have_fd_event= true;
48
 
  if (!session->rli_fake)
 
47
  if (!thd->rli_fake)
49
48
  {
50
 
    session->rli_fake= new Relay_log_info;
 
49
    thd->rli_fake= new Relay_log_info;
51
50
#ifdef HAVE_purify
52
 
    session->rli_fake->is_fake= true;
 
51
    thd->rli_fake->is_fake= true;
53
52
#endif
54
53
    have_fd_event= false;
55
54
  }
56
 
  if (session->rli_fake && !session->rli_fake->relay_log.description_event_for_exec)
 
55
  if (thd->rli_fake && !thd->rli_fake->relay_log.description_event_for_exec)
57
56
  {
58
 
    session->rli_fake->relay_log.description_event_for_exec=
 
57
    thd->rli_fake->relay_log.description_event_for_exec=
59
58
      new Format_description_log_event(4);
60
59
    have_fd_event= false;
61
60
  }
67
66
  /*
68
67
    Out of memory check
69
68
  */
70
 
  if (!(session->rli_fake &&
71
 
        session->rli_fake->relay_log.description_event_for_exec &&
 
69
  if (!(thd->rli_fake &&
 
70
        thd->rli_fake->relay_log.description_event_for_exec &&
72
71
        buf))
73
72
  {
74
73
    my_error(ER_OUTOFMEMORY, MYF(0), 1);  /* needed 1 bytes */
75
74
    goto end;
76
75
  }
77
76
 
78
 
  session->rli_fake->sql_session= session;
79
 
  session->rli_fake->no_storage= true;
 
77
  thd->rli_fake->sql_thd= thd;
 
78
  thd->rli_fake->no_storage= true;
80
79
 
81
 
  for (char const *strptr= session->lex->comment.str ;
82
 
       strptr < session->lex->comment.str + session->lex->comment.length ; )
 
80
  for (char const *strptr= thd->lex->comment.str ;
 
81
       strptr < thd->lex->comment.str + thd->lex->comment.length ; )
83
82
  {
84
83
    char const *endptr= 0;
85
84
    int bytes_decoded= base64_decode(strptr, coded_len, buf, &endptr);
143
142
      }
144
143
 
145
144
      ev= Log_event::read_log_event(bufptr, event_len, &error,
146
 
                                    session->rli_fake->relay_log.
 
145
                                    thd->rli_fake->relay_log.
147
146
                                      description_event_for_exec);
148
147
 
149
148
      if (!ev)
159
158
      bytes_decoded -= event_len;
160
159
      bufptr += event_len;
161
160
 
162
 
      ev->session= session;
 
161
      ev->thd= thd;
163
162
      /*
164
163
        We go directly to the application phase, since we don't need
165
164
        to check if the event shall be skipped or not.
168
167
        not used at all: the rli_fake instance is used only for error
169
168
        reporting.
170
169
      */
171
 
      if (apply_event_and_update_pos(ev, session, session->rli_fake, false))
 
170
      if (apply_event_and_update_pos(ev, thd, thd->rli_fake, false))
172
171
      {
173
172
        /*
174
173
          TODO: Maybe a better error message since the BINLOG statement
190
189
    }
191
190
  }
192
191
 
193
 
  my_ok(session);
 
192
  my_ok(thd);
194
193
 
195
194
end:
196
 
  session->rli_fake->clear_tables_to_lock();
 
195
  thd->rli_fake->clear_tables_to_lock();
197
196
  free(buf);
198
197
  return;
199
198
}