~drizzle-developers/ubuntu/karmic/drizzle/ppa

« back to all changes in this revision

Viewing changes to plugin/innobase/trx/trx0i_s.c

  • Committer: Monty Taylor
  • Date: 2010-11-24 18:44:57 UTC
  • mfrom: (1308.1.31 trunk)
  • Revision ID: mordred@inaugust.com-20101124184457-qd6jvoe2wgnvl3yq
Tags: 2010.11.04-0ubuntu1~karmic1
* New upstream release.
* Turn off -Werror for packaging builds. (Closes: #602662)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (c) 2007, 2009, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 2007, 2010, Innobase Oy. All Rights Reserved.
4
4
 
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
29
29
*******************************************************/
30
30
 
31
31
#include "config.h"
 
32
/* Found during the build of 5.5.3 on Linux 2.4 and early 2.6 kernels:
 
33
   The includes "univ.i" -> "my_global.h" cause a different path
 
34
   to be taken further down with pthread functions and types,
 
35
   so they must come first.
 
36
   From the symptoms, this is related to bug#46587 in the MySQL bug DB.
 
37
*/
 
38
#include "univ.i"
32
39
 
33
40
#if !defined(BUILD_DRIZZLE)
34
41
# include <mysql/plugin.h>
36
43
 
37
44
#include "mysql_addons.h"
38
45
 
39
 
#include "univ.i"
40
46
#include "buf0buf.h"
41
47
#include "dict0dict.h"
42
48
#include "ha0storage.h"
426
432
                                                which to copy volatile
427
433
                                                strings */
428
434
{
 
435
        const char*     stmt;
 
436
        size_t          stmt_len;
 
437
 
429
438
        row->trx_id = trx_get_id(trx);
430
439
        row->trx_started = (ib_time_t) trx->start_time;
431
440
        row->trx_state = trx_get_que_state_str(trx);
446
455
 
447
456
        row->trx_weight = (ullint) ut_conv_dulint_to_longlong(TRX_WEIGHT(trx));
448
457
 
449
 
        if (trx->mysql_thd != NULL) {
450
 
                row->trx_mysql_thread_id
451
 
#if defined(BUILD_DRIZZLE)
452
 
                        = session_get_thread_id(trx->mysql_thd);
453
 
#else
454
 
                        = thd_get_thread_id(trx->mysql_thd);
455
 
#endif
456
 
        } else {
 
458
        if (trx->mysql_thd == NULL) {
457
459
                /* For internal transactions e.g., purge and transactions
458
460
                being recovered at startup there is no associated MySQL
459
461
                thread data structure. */
460
462
                row->trx_mysql_thread_id = 0;
 
463
                row->trx_query = NULL;
 
464
                return(TRUE);
461
465
        }
462
466
 
463
 
        if (trx->mysql_query_str != NULL) {
464
 
 
465
 
                if (strlen(trx->mysql_query_str)
466
 
                    > TRX_I_S_TRX_QUERY_MAX_LEN) {
467
 
 
468
 
                        char    query[TRX_I_S_TRX_QUERY_MAX_LEN + 1];
469
 
 
470
 
                        memcpy(query, trx->mysql_query_str,
471
 
                               TRX_I_S_TRX_QUERY_MAX_LEN);
472
 
                        query[TRX_I_S_TRX_QUERY_MAX_LEN] = '\0';
473
 
 
474
 
                        row->trx_query = ha_storage_put_memlim(
475
 
                                cache->storage, query,
476
 
                                TRX_I_S_TRX_QUERY_MAX_LEN + 1,
477
 
                                MAX_ALLOWED_FOR_STORAGE(cache));
478
 
                } else {
479
 
 
480
 
                        row->trx_query = ha_storage_put_str_memlim(
481
 
                                cache->storage, trx->mysql_query_str,
482
 
                                MAX_ALLOWED_FOR_STORAGE(cache));
 
467
        row->trx_mysql_thread_id = session_get_thread_id(trx->mysql_thd);
 
468
        stmt = innobase_get_stmt(trx->mysql_thd, &stmt_len);
 
469
 
 
470
        if (stmt != NULL) {
 
471
 
 
472
                char    query[TRX_I_S_TRX_QUERY_MAX_LEN + 1];
 
473
 
 
474
                if (stmt_len > TRX_I_S_TRX_QUERY_MAX_LEN) {
 
475
                        stmt_len = TRX_I_S_TRX_QUERY_MAX_LEN;
483
476
                }
484
477
 
 
478
                memcpy(query, stmt, stmt_len);
 
479
                query[stmt_len] = '\0';
 
480
 
 
481
                row->trx_query = ha_storage_put_memlim(
 
482
                        cache->storage, stmt, stmt_len + 1,
 
483
                        MAX_ALLOWED_FOR_STORAGE(cache));
 
484
 
485
485
                if (row->trx_query == NULL) {
486
486
 
487
487
                        return(FALSE);
1213
1213
                return(1);
1214
1214
        }
1215
1215
 
1216
 
        /* We are going to access trx->query in all transactions */
1217
 
        innobase_mysql_prepare_print_arbitrary_thd();
1218
 
 
1219
1216
        /* We need to read trx_sys and record/table lock queues */
1220
1217
        mutex_enter(&kernel_mutex);
1221
1218
 
1223
1220
 
1224
1221
        mutex_exit(&kernel_mutex);
1225
1222
 
1226
 
        innobase_mysql_end_print_arbitrary_thd();
1227
 
 
1228
1223
        return(0);
1229
1224
}
1230
1225