~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/transaction_services.cc

  • Committer: Andrew Hutchings
  • Date: 2011-02-02 12:51:57 UTC
  • mto: (2157.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2158.
  • Revision ID: andrew@linuxjedi.co.uk-20110202125157-r6thh7ox4g9l90ec
Make transaction_message_threshold a read-only global variable instead of a per-session variable
Make replication_dictionary column lengths use transation_message_threshold

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
 * plugins can understand.
48
48
 */
49
49
 
50
 
#include <config.h>
51
 
#include <drizzled/current_session.h>
52
 
#include <drizzled/my_hash.h>
53
 
#include <drizzled/error.h>
54
 
#include <drizzled/gettext.h>
55
 
#include <drizzled/probes.h>
56
 
#include <drizzled/sql_parse.h>
57
 
#include <drizzled/session.h>
58
 
#include <drizzled/sql_base.h>
59
 
#include <drizzled/replication_services.h>
60
 
#include <drizzled/transaction_services.h>
61
 
#include <drizzled/transaction_context.h>
62
 
#include <drizzled/message/transaction.pb.h>
63
 
#include <drizzled/message/statement_transform.h>
64
 
#include <drizzled/resource_context.h>
65
 
#include <drizzled/lock.h>
66
 
#include <drizzled/item/int.h>
67
 
#include <drizzled/item/empty_string.h>
68
 
#include <drizzled/field/epoch.h>
69
 
#include <drizzled/plugin/client.h>
70
 
#include <drizzled/plugin/monitored_in_transaction.h>
71
 
#include <drizzled/plugin/transactional_storage_engine.h>
72
 
#include <drizzled/plugin/xa_resource_manager.h>
73
 
#include <drizzled/plugin/xa_storage_engine.h>
74
 
#include <drizzled/internal/my_sys.h>
 
50
#include "config.h"
 
51
#include "drizzled/my_hash.h"
 
52
#include "drizzled/error.h"
 
53
#include "drizzled/gettext.h"
 
54
#include "drizzled/probes.h"
 
55
#include "drizzled/sql_parse.h"
 
56
#include "drizzled/session.h"
 
57
#include "drizzled/sql_base.h"
 
58
#include "drizzled/replication_services.h"
 
59
#include "drizzled/transaction_services.h"
 
60
#include "drizzled/transaction_context.h"
 
61
#include "drizzled/message/transaction.pb.h"
 
62
#include "drizzled/message/statement_transform.h"
 
63
#include "drizzled/resource_context.h"
 
64
#include "drizzled/lock.h"
 
65
#include "drizzled/item/int.h"
 
66
#include "drizzled/item/empty_string.h"
 
67
#include "drizzled/field/epoch.h"
 
68
#include "drizzled/plugin/client.h"
 
69
#include "drizzled/plugin/monitored_in_transaction.h"
 
70
#include "drizzled/plugin/transactional_storage_engine.h"
 
71
#include "drizzled/plugin/xa_resource_manager.h"
 
72
#include "drizzled/plugin/xa_storage_engine.h"
 
73
#include "drizzled/internal/my_sys.h"
75
74
 
76
75
#include <vector>
77
76
#include <algorithm>
747
746
    {
748
747
      (void) rollbackTransaction(session, false);
749
748
      if (session.transaction_rollback_request)
750
 
      {
751
749
        (void) rollbackTransaction(session, true);
752
 
        session.server_status&= ~SERVER_STATUS_IN_TRANS;
753
 
      }
754
750
    }
755
751
 
756
752
    session.variables.tx_isolation= session.session_tx_isolation;
757
753
  }
758
 
 
759
754
  return error;
760
755
}
761
756
 
1385
1380
  if (! replication_services.isActive())
1386
1381
    return false;
1387
1382
 
1388
 
  if (not table.getShare()->replicate())
1389
 
    return false;
1390
 
 
1391
1383
  /**
1392
1384
   * We do this check here because we don't want to even create a 
1393
1385
   * statement if there isn't a primary key on the table...
1583
1575
    }
1584
1576
  }
1585
1577
}
1586
 
 
1587
1578
void TransactionServices::updateRecord(Session::reference session,
1588
1579
                                       Table &table, 
1589
1580
                                       const unsigned char *old_record, 
1593
1584
  if (! replication_services.isActive())
1594
1585
    return;
1595
1586
 
1596
 
  if (not table.getShare()->replicate())
1597
 
    return;
1598
 
 
1599
1587
  uint32_t next_segment_id= 1;
1600
1588
  message::Statement &statement= getUpdateStatement(session, table, old_record, new_record, &next_segment_id);
1601
1589
 
1855
1843
  if (! replication_services.isActive())
1856
1844
    return;
1857
1845
 
1858
 
  if (not table.getShare()->replicate())
1859
 
    return;
1860
 
 
1861
1846
  uint32_t next_segment_id= 1;
1862
1847
  message::Statement &statement= getDeleteStatement(session, table, &next_segment_id);
1863
1848
 
1913
1898
  ReplicationServices &replication_services= ReplicationServices::singleton();
1914
1899
  if (! replication_services.isActive())
1915
1900
    return;
1916
 
 
1917
 
  if (table.has_options() and table.options().has_dont_replicate() and table.options().dont_replicate())
1918
 
    return;
1919
 
 
 
1901
  
1920
1902
  message::Transaction *transaction= getActiveTransactionMessage(session);
1921
1903
  message::Statement *statement= transaction->add_statement();
1922
1904
 
1946
1928
  ReplicationServices &replication_services= ReplicationServices::singleton();
1947
1929
  if (! replication_services.isActive())
1948
1930
    return;
1949
 
 
1950
 
  if (schema.has_replication_options() and schema.replication_options().has_dont_replicate() and schema.replication_options().dont_replicate())
1951
 
    return;
1952
 
 
 
1931
  
1953
1932
  message::Transaction *transaction= getActiveTransactionMessage(session);
1954
1933
  message::Statement *statement= transaction->add_statement();
1955
1934
 
1974
1953
}
1975
1954
 
1976
1955
void TransactionServices::dropSchema(Session::reference session,
1977
 
                                     identifier::Schema::const_reference identifier,
1978
 
                                     message::schema::const_reference schema)
 
1956
                                     identifier::Schema::const_reference identifier)
1979
1957
{
1980
1958
  ReplicationServices &replication_services= ReplicationServices::singleton();
1981
1959
  if (! replication_services.isActive())
1982
1960
    return;
1983
 
 
1984
 
  if (schema.has_replication_options() and schema.replication_options().has_dont_replicate() and schema.replication_options().dont_replicate())
1985
 
    return;
1986
 
 
 
1961
  
1987
1962
  message::Transaction *transaction= getActiveTransactionMessage(session);
1988
1963
  message::Statement *statement= transaction->add_statement();
1989
1964
 
2007
1982
}
2008
1983
 
2009
1984
void TransactionServices::alterSchema(Session::reference session,
2010
 
                                      const message::Schema &old_schema,
 
1985
                                      const message::schema::shared_ptr &old_schema,
2011
1986
                                      const message::Schema &new_schema)
2012
1987
{
2013
1988
  ReplicationServices &replication_services= ReplicationServices::singleton();
2014
1989
  if (! replication_services.isActive())
2015
1990
    return;
2016
 
 
2017
 
  if (old_schema.has_replication_options() and old_schema.replication_options().has_dont_replicate() and old_schema.replication_options().dont_replicate())
2018
 
    return;
2019
 
 
 
1991
  
2020
1992
  message::Transaction *transaction= getActiveTransactionMessage(session);
2021
1993
  message::Statement *statement= transaction->add_statement();
2022
1994
 
2031
2003
  message::Schema *before= alter_schema_statement->mutable_before();
2032
2004
  message::Schema *after= alter_schema_statement->mutable_after();
2033
2005
 
2034
 
  *before= old_schema;
 
2006
  *before= *old_schema;
2035
2007
  *after= new_schema;
2036
2008
 
2037
2009
  finalizeStatementMessage(*statement, session);
2044
2016
}
2045
2017
 
2046
2018
void TransactionServices::dropTable(Session::reference session,
2047
 
                                    identifier::Table::const_reference identifier,
2048
 
                                    message::table::const_reference table,
 
2019
                                    const identifier::Table &table,
2049
2020
                                    bool if_exists)
2050
2021
{
2051
2022
  ReplicationServices &replication_services= ReplicationServices::singleton();
2052
2023
  if (! replication_services.isActive())
2053
2024
    return;
2054
 
 
2055
 
  if (table.has_options() and table.options().has_dont_replicate() and table.options().dont_replicate())
2056
 
    return;
2057
 
 
 
2025
  
2058
2026
  message::Transaction *transaction= getActiveTransactionMessage(session);
2059
2027
  message::Statement *statement= transaction->add_statement();
2060
2028
 
2070
2038
 
2071
2039
  message::TableMetadata *table_metadata= drop_table_statement->mutable_table_metadata();
2072
2040
 
2073
 
  table_metadata->set_schema_name(identifier.getSchemaName());
2074
 
  table_metadata->set_table_name(identifier.getTableName());
 
2041
  table_metadata->set_schema_name(table.getSchemaName());
 
2042
  table_metadata->set_table_name(table.getTableName());
2075
2043
 
2076
2044
  finalizeStatementMessage(*statement, session);
2077
2045
 
2088
2056
  ReplicationServices &replication_services= ReplicationServices::singleton();
2089
2057
  if (! replication_services.isActive())
2090
2058
    return;
2091
 
 
2092
 
  if (not table.getShare()->replicate())
2093
 
    return;
2094
 
 
 
2059
  
2095
2060
  message::Transaction *transaction= getActiveTransactionMessage(session);
2096
2061
  message::Statement *statement= transaction->add_statement();
2097
2062
 
2106
2071
 
2107
2072
  string schema_name;
2108
2073
  (void) table.getShare()->getSchemaName(schema_name);
2109
 
 
2110
2074
  string table_name;
2111
2075
  (void) table.getShare()->getTableName(table_name);
2112
2076