drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
transaction_services.h
1/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 *
4 * Copyright (C) 2008 Sun Microsystems, Inc.
5 * Copyright (C) 2010 Jay Pipes <[email protected]>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
24
25#pragma once
26
27#include <drizzled/atomics.h>
28#include <drizzled/message/transaction.pb.h>
29#include <drizzled/identifier.h>
30#include <drizzled/message/schema.h>
31#include <drizzled/message/table.h>
32#include <drizzled/session.h>
33
34#include <drizzled/visibility.h>
35
36namespace drizzled {
37
43{
44public:
45 static const size_t DEFAULT_RECORD_SIZE= 100;
46
51 static bool shouldConstructMessages();
52
60 static void finalizeStatementMessage(message::Statement&, Session&);
61
72 static bool insertRecord(Session&, Table &in_table);
73
83 static void updateRecord(Session&,
84 Table&,
85 const unsigned char *old_record,
86 const unsigned char *new_record);
87
96 static void deleteRecord(Session&, Table&, bool use_update_record= false);
97
106 static void createSchema(Session&, const message::Schema &schema);
107
116 static void dropSchema(Session&,
117 const identifier::Schema& identifier,
118 message::schema::const_reference schema);
119
129 static void alterSchema(Session&,
130 const message::Schema &old_schema,
131 const message::Schema &new_schema);
132
141 static void createTable(Session&, const message::Table&);
142
152 static void dropTable(Session&,
153 const identifier::Table& identifier,
154 message::table::const_reference table,
155 bool if_exists);
156
165 static void truncateTable(Session&, Table&);
166
180 static void rawStatement(Session&, const std::string &query, const std::string &schema);
181
182 static void rawStatement(Session& session, const std::string& query)
183 {
184 rawStatement(session, query, "");
185 }
186
187 /* transactions: interface to plugin::StorageEngine functions */
188 static int rollbackTransaction(Session&, bool all);
189
203 static int commitTransaction(Session&, bool all);
204
216 static int autocommitOrRollback(Session&, int error);
217
218 /* savepoints */
219 static int rollbackToSavepoint(Session&, NamedSavepoint &sv);
220 static int setSavepoint(Session&, NamedSavepoint &sv);
221 static int releaseSavepoint(Session&, NamedSavepoint &sv);
222
242
265 plugin::XaResourceManager *resource_manager);
266
292
294
295 static void allocateNewTransactionId();
296
297 /**************
298 * Events API
299 **************/
300
309 static bool sendStartupEvent(Session&);
310
319 static bool sendShutdownEvent(Session&);
320
321private:
322
334 static message::Transaction *getActiveTransactionMessage(Session&, bool should_inc_trx_id= true);
335
346 static void initTransactionMessage(message::Transaction&, Session&, bool should_inc_trx_id);
347
355 static void initStatementMessage(message::Statement&, message::Statement::Type type, const Session&);
356
364 static void finalizeTransactionMessage(message::Transaction&, const Session&);
365
370 static void cleanupTransactionMessage(message::Transaction *transaction, Session&);
371
379 static message::Statement &getInsertStatement(Session&, Table&, uint32_t *next_segment_id);
380
389 static void setInsertHeader(message::Statement&,
390 const Session&,
391 Table&);
402 static message::Statement &getUpdateStatement(Session&,
403 Table&,
404 const unsigned char *old_record,
405 const unsigned char *new_record,
406 uint32_t *next_segment_id);
417 static void setUpdateHeader(message::Statement&,
418 const Session&,
419 Table&,
420 const unsigned char *old_record,
421 const unsigned char *new_record);
422
431 static message::Statement &getDeleteStatement(Session&, Table&, uint32_t *next_segment_id);
432
441 static void setDeleteHeader(message::Statement&, const Session&, Table&);
442
450
458
468 static void rollbackStatementMessage(Session&);
469
478 static bool isFieldUpdated(Field *current_field,
479 Table&,
480 const unsigned char *old_record,
481 const unsigned char *new_record);
482
497 static int sendEvent(Session&, const message::Event &event);
498
511 static message::Transaction *segmentTransactionMessage(Session&, message::Transaction*);
512
513 static int commitPhaseOne(Session&, bool all);
514
515 static uint64_t getCurrentTransactionId(Session&);
516};
517
518} /* namespace drizzled */
519
static bool insertRecord(Session &, Table &in_table)
static bool sendShutdownEvent(Session &)
static void rawStatement(Session &, const std::string &query, const std::string &schema)
static void finalizeStatementMessage(message::Statement &, Session &)
static void setUpdateHeader(message::Statement &, const Session &, Table &, const unsigned char *old_record, const unsigned char *new_record)
static int commitTransaction(Session &, bool all)
static void createTable(Session &, const message::Table &)
static message::Statement & getInsertStatement(Session &, Table &, uint32_t *next_segment_id)
static void registerResourceForStatement(Session &, plugin::MonitoredInTransaction *, plugin::TransactionalStorageEngine *)
static void initStatementMessage(message::Statement &, message::Statement::Type type, const Session &)
static message::Statement & getDeleteStatement(Session &, Table &, uint32_t *next_segment_id)
static message::Transaction * segmentTransactionMessage(Session &, message::Transaction *)
static bool isFieldUpdated(Field *current_field, Table &, const unsigned char *old_record, const unsigned char *new_record)
static int commitPhaseOne(Session &, bool all)
static void setDeleteHeader(message::Statement &, const Session &, Table &)
static int commitTransactionMessage(Session &)
static void rollbackStatementMessage(Session &)
static void registerResourceForTransaction(Session &, plugin::MonitoredInTransaction *, plugin::TransactionalStorageEngine *)
static void deleteRecord(Session &, Table &, bool use_update_record=false)
static void truncateTable(Session &, Table &)
static void alterSchema(Session &, const message::Schema &old_schema, const message::Schema &new_schema)
static void dropSchema(Session &, const identifier::Schema &identifier, message::schema::const_reference schema)
static void createSchema(Session &, const message::Schema &schema)
static void cleanupTransactionMessage(message::Transaction *transaction, Session &)
static void setInsertHeader(message::Statement &, const Session &, Table &)
static void rollbackTransactionMessage(Session &)
static void initTransactionMessage(message::Transaction &, Session &, bool should_inc_trx_id)
static int setSavepoint(Session &, NamedSavepoint &sv)
static bool sendStartupEvent(Session &)
static message::Transaction * getActiveTransactionMessage(Session &, bool should_inc_trx_id=true)
static message::Statement & getUpdateStatement(Session &, Table &, const unsigned char *old_record, const unsigned char *new_record, uint32_t *next_segment_id)
static void updateRecord(Session &, Table &, const unsigned char *old_record, const unsigned char *new_record)
static int autocommitOrRollback(Session &, int error)
static void dropTable(Session &, const identifier::Table &identifier, message::table::const_reference table, bool if_exists)
static int sendEvent(Session &, const message::Event &event)
static void finalizeTransactionMessage(message::Transaction &, const Session &)
Convert from decimal to binary representation.
Definition common_fwd.h:215
TODO: Rename this file - func.h is stupid.
Visibility Control Macros.
#define DRIZZLED_API
Definition visibility.h:38