~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/transaction_services.h

  • Committer: lbieber
  • Date: 2010-08-29 05:45:49 UTC
  • mfrom: (1734.2.1 staging)
  • Revision ID: lbieber@orisndriz03-20100829054549-9ruuvwr16egf1hq2
Merge Lee - fix bug 624974 - second pass on changing error numbers to enum values
Merge Shrews - fix bug 600795 - LOAD DATA INFILE INSERT not registered by the transaction log

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
  /**
81
81
   * Method which returns the active Transaction message
82
82
   * for the supplied Session.  If one is not found, a new Transaction
83
 
   * message is allocated, initialized, and returned.
 
83
   * message is allocated, initialized, and returned. It is possible that
 
84
   * we may want to NOT increment the transaction id for a new Transaction
 
85
   * object (e.g., splitting up Transactions into smaller chunks). The
 
86
   * should_inc_trx_id flag controls if we do this.
84
87
   *
85
 
   * @param The session processing the transaction
 
88
   * @param in_session The session processing the transaction
 
89
   * @param should_inc_trx_id If true, increments the transaction id for a new trx
86
90
   */
87
 
  message::Transaction *getActiveTransactionMessage(Session *in_session);
 
91
  message::Transaction *getActiveTransactionMessage(Session *in_session,
 
92
                                                    bool should_inc_trx_id= true);
88
93
  /** 
89
94
   * Method which attaches a transaction context
90
95
   * the supplied transaction based on the supplied Session's
91
96
   * transaction information.  This method also ensure the
92
97
   * transaction message is attached properly to the Session object
93
98
   *
94
 
   * @param The transaction message to initialize
95
 
   * @param The Session processing this transaction
 
99
   * @param in_transaction The transaction message to initialize
 
100
   * @param in_session The Session processing this transaction
 
101
   * @param should_inc_trx_id If true, increments the transaction id for a new trx
96
102
   */
97
 
  void initTransactionMessage(message::Transaction &in_transaction, Session *in_session);
 
103
  void initTransactionMessage(message::Transaction &in_transaction,
 
104
                              Session *in_session,
 
105
                              bool should_inc_trx_id);
98
106
  /** 
99
107
   * Helper method which finalizes data members for the 
100
108
   * supplied transaction's context.
101
109
   *
102
 
   * @param The transaction message to finalize 
103
 
   * @param The Session processing this transaction
 
110
   * @param in_transaction The transaction message to finalize 
 
111
   * @param in_session The Session processing this transaction
104
112
   */
105
113
  void finalizeTransactionMessage(message::Transaction &in_transaction, Session *in_session);
106
114
  /**
112
120
  /**
113
121
   * Helper method which initializes a Statement message
114
122
   *
115
 
   * @param The statement to initialize
116
 
   * @param The type of the statement
117
 
   * @param The session processing this statement
 
123
   * @param statement The statement to initialize
 
124
   * @param in_type The type of the statement
 
125
   * @param in_session The session processing this statement
118
126
   */
119
127
  void initStatementMessage(message::Statement &statement,
120
128
                            message::Statement::Type in_type,
123
131
   * Finalizes a Statement message and sets the Session's statement
124
132
   * message to NULL.
125
133
   *
126
 
   * @param The statement to initialize
127
 
   * @param The session processing this statement
 
134
   * @param statement The statement to initialize
 
135
   * @param in_session The session processing this statement
128
136
   */
129
137
  void finalizeStatementMessage(message::Statement &statement,
130
138
                                Session *in_session);
131
139
  /** Helper method which returns an initialized Statement message for methods
132
140
   * doing insertion of data.
133
141
   *
134
 
   * @param[in] Pointer to the Session doing the processing
135
 
   * @param[in] Pointer to the Table object being inserted into
 
142
   * @param[in] in_session Pointer to the Session doing the processing
 
143
   * @param[in] in_table Pointer to the Table object being inserted into
 
144
   * @param[out] next_segment_id The next Statement segment id to be used
136
145
   */
137
146
  message::Statement &getInsertStatement(Session *in_session,
138
 
                                         Table *in_table);
 
147
                                         Table *in_table,
 
148
                                         uint32_t *next_segment_id);
139
149
 
140
150
  /**
141
151
   * Helper method which initializes the header message for
142
152
   * insert operations.
143
153
   *
144
 
   * @param[inout] Statement message container to modify
145
 
   * @param[in] Pointer to the Session doing the processing
146
 
   * @param[in] Pointer to the Table being inserted into
 
154
   * @param[in,out] statement Statement message container to modify
 
155
   * @param[in] in_session Pointer to the Session doing the processing
 
156
   * @param[in] in_table Pointer to the Table being inserted into
147
157
   */
148
158
  void setInsertHeader(message::Statement &statement,
149
159
                       Session *in_session,
152
162
   * Helper method which returns an initialized Statement
153
163
   * message for methods doing updates of data.
154
164
   *
155
 
   * @param[in] Pointer to the Session doing the processing
156
 
   * @param[in] Pointer to the Table object being updated
157
 
   * @param[in] Pointer to the old data in the record
158
 
   * @param[in] Pointer to the new data in the record
 
165
   * @param[in] in_session Pointer to the Session doing the processing
 
166
   * @param[in] in_table Pointer to the Table object being updated
 
167
   * @param[in] old_record Pointer to the old data in the record
 
168
   * @param[in] new_record Pointer to the new data in the record
 
169
   * @param[out] next_segment_id The next Statement segment id to be used
159
170
   */
160
171
  message::Statement &getUpdateStatement(Session *in_session,
161
172
                                         Table *in_table,
162
173
                                         const unsigned char *old_record, 
163
 
                                         const unsigned char *new_record);
 
174
                                         const unsigned char *new_record,
 
175
                                         uint32_t *next_segment_id);
164
176
  /**
165
177
   * Helper method which initializes the header message for
166
178
   * update operations.
167
179
   *
168
 
   * @param[inout] Statement message container to modify
169
 
   * @param[in] Pointer to the Session doing the processing
170
 
   * @param[in] Pointer to the Table being updated
171
 
   * @param[in] Pointer to the old data in the record
172
 
   * @param[in] Pointer to the new data in the record
 
180
   * @param[in,out] statement Statement message container to modify
 
181
   * @param[in] in_session Pointer to the Session doing the processing
 
182
   * @param[in] in_table Pointer to the Table being updated
 
183
   * @param[in] old_record Pointer to the old data in the record
 
184
   * @param[in] new_record Pointer to the new data in the record
173
185
   */
174
186
  void setUpdateHeader(message::Statement &statement,
175
187
                       Session *in_session,
180
192
   * Helper method which returns an initialized Statement
181
193
   * message for methods doing deletion of data.
182
194
   *
183
 
   * @param[in] Pointer to the Session doing the processing
184
 
   * @param[in] Pointer to the Table object being deleted from
 
195
   * @param[in] in_session Pointer to the Session doing the processing
 
196
   * @param[in] in_table Pointer to the Table object being deleted from
 
197
   * @param[out] next_segment_id The next Statement segment id to be used
185
198
   */
186
199
  message::Statement &getDeleteStatement(Session *in_session,
187
 
                                         Table *in_table);
 
200
                                         Table *in_table,
 
201
                                         uint32_t *next_segment_id);
188
202
 
189
203
  /**
190
204
   * Helper method which initializes the header message for
191
205
   * insert operations.
192
206
   *
193
 
   * @param[inout] Statement message container to modify
194
 
   * @param[in] Pointer to the Session doing the processing
195
 
   * @param[in] Pointer to the Table being deleted from
 
207
   * @param[in,out] statement Statement message container to modify
 
208
   * @param[in] in_session Pointer to the Session doing the processing
 
209
   * @param[in] in_table Pointer to the Table being deleted from
196
210
   */
197
211
  void setDeleteHeader(message::Statement &statement,
198
212
                       Session *in_session,
201
215
   * Commits a normal transaction (see above) and pushes the transaction
202
216
   * message out to the replicators.
203
217
   *
204
 
   * @param Pointer to the Session committing the transaction
 
218
   * @param in_session Pointer to the Session committing the transaction
205
219
   */
206
220
  int commitTransactionMessage(Session *in_session);
207
221
  /** 
208
222
   * Marks the current active transaction message as being rolled back and
209
223
   * pushes the transaction message out to replicators.
210
224
   *
211
 
   * @param Pointer to the Session committing the transaction
 
225
   * @param in_session Pointer to the Session committing the transaction
212
226
   */
213
227
  void rollbackTransactionMessage(Session *in_session);
214
228
  /**
215
229
   * Creates a new InsertRecord GPB message and pushes it to
216
230
   * replicators.
217
231
   *
218
 
   * @param Pointer to the Session which has inserted a record
219
 
   * @param Pointer to the Table containing insert information
 
232
   * @param in_session Pointer to the Session which has inserted a record
 
233
   * @param in_table Pointer to the Table containing insert information
220
234
   *
221
235
   * Grr, returning "true" here on error because of the cursor
222
236
   * reversed bool return crap...fix that.
226
240
   * Creates a new UpdateRecord GPB message and pushes it to
227
241
   * replicators.
228
242
   *
229
 
   * @param Pointer to the Session which has updated a record
230
 
   * @param Pointer to the Table containing update information
231
 
   * @param Pointer to the raw bytes representing the old record/row
232
 
   * @param Pointer to the raw bytes representing the new record/row 
 
243
   * @param in_session Pointer to the Session which has updated a record
 
244
   * @param in_table Pointer to the Table containing update information
 
245
   * @param old_record Pointer to the raw bytes representing the old record/row
 
246
   * @param new_record Pointer to the raw bytes representing the new record/row 
233
247
   */
234
248
  void updateRecord(Session *in_session, 
235
249
                    Table *in_table, 
249
263
   * to the Session's active Transaction GPB message for pushing
250
264
   * out to the replicator streams.
251
265
   *
252
 
   * @param[in] Pointer to the Session which issued the statement
253
 
   * @param[in] message::Schema message describing new schema
 
266
   * @param[in] in_session Pointer to the Session which issued the statement
 
267
   * @param[in] schema message::Schema message describing new schema
254
268
   */
255
269
  void createSchema(Session *in_session, const message::Schema &schema);
256
270
  /**
258
272
   * to the Session's active Transaction GPB message for pushing
259
273
   * out to the replicator streams.
260
274
   *
261
 
   * @param[in] Pointer to the Session which issued the statement
262
 
   * @param[in] message::Schema message describing new schema
 
275
   * @param[in] in_session Pointer to the Session which issued the statement
 
276
   * @param[in] schema_name message::Schema message describing new schema
263
277
   */
264
278
  void dropSchema(Session *in_session, const std::string &schema_name);
265
279
  /**
267
281
   * to the Session's active Transaction GPB message for pushing
268
282
   * out to the replicator streams.
269
283
   *
270
 
   * @param[in] Pointer to the Session which issued the statement
271
 
   * @param[in] message::Table message describing new schema
 
284
   * @param[in] in_session Pointer to the Session which issued the statement
 
285
   * @param[in] table message::Table message describing new schema
272
286
   */
273
287
  void createTable(Session *in_session, const message::Table &table);
274
288
  /**
276
290
   * to the Session's active Transaction GPB message for pushing
277
291
   * out to the replicator streams.
278
292
   *
279
 
   * @param[in] Pointer to the Session which issued the statement
280
 
   * @param[in] The schema of the table being dropped
281
 
   * @param[in] The table name of the table being dropped
282
 
   * @param[in] Did the user specify an IF EXISTS clause?
 
293
   * @param[in] in_session Pointer to the Session which issued the statement
 
294
   * @param[in] schema_name The schema of the table being dropped
 
295
   * @param[in] table_name The table name of the table being dropped
 
296
   * @param[in] if_exists Did the user specify an IF EXISTS clause?
283
297
   */
284
298
  void dropTable(Session *in_session,
285
299
                     const std::string &schema_name,
290
304
   * to the Session's active Transaction GPB message for pushing
291
305
   * out to the replicator streams.
292
306
   *
293
 
   * @param[in] Pointer to the Session which issued the statement
294
 
   * @param[in] The Table being truncated
 
307
   * @param[in] in_session Pointer to the Session which issued the statement
 
308
   * @param[in] in_table The Table being truncated
295
309
   */
296
310
  void truncateTable(Session *in_session, Table *in_table);
297
311
  /**
303
317
   * on the I_S, etc.  Not sure what to do with administrative
304
318
   * commands like CHECK TABLE, though..
305
319
   *
306
 
   * @param Pointer to the Session which issued the statement
307
 
   * @param Query string
 
320
   * @param in_session Pointer to the Session which issued the statement
 
321
   * @param query Query string
308
322
   */
309
323
  void rawStatement(Session *in_session, const std::string &query);
310
324
  /* transactions: interface to plugin::StorageEngine functions */
334
348
   * per statement, and therefore should not need to be idempotent.
335
349
   * Put in assert()s to test this.
336
350
   *
337
 
   * @param[in] Session pointer
338
 
   * @param[in] Descriptor for the resource which will be participating
339
 
   * @param[in] Pointer to the TransactionalStorageEngine resource
 
351
   * @param[in] session Session pointer
 
352
   * @param[in] monitored Descriptor for the resource which will be participating
 
353
   * @param[in] engine Pointer to the TransactionalStorageEngine resource
340
354
   */
341
355
  void registerResourceForStatement(Session *session,
342
356
                                    plugin::MonitoredInTransaction *monitored,
356
370
   * per statement, and therefore should not need to be idempotent.
357
371
   * Put in assert()s to test this.
358
372
   *
359
 
   * @param[in] Session pointer
360
 
   * @param[in] Descriptor for the resource which will be participating
361
 
   * @param[in] Pointer to the TransactionalStorageEngine resource
362
 
   * @param[in] Pointer to the XaResourceManager resource manager
 
373
   * @param[in] session Session pointer
 
374
   * @param[in] monitored Descriptor for the resource which will be participating
 
375
   * @param[in] engine Pointer to the TransactionalStorageEngine resource
 
376
   * @param[in] resource_manager Pointer to the XaResourceManager resource manager
363
377
   */
364
378
  void registerResourceForStatement(Session *session,
365
379
                                    plugin::MonitoredInTransaction *monitored,