~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/handler/i_s.cc

  • Committer: Brian Aker
  • Date: 2009-11-30 19:13:19 UTC
  • mfrom: (1225.1.39 figure)
  • Revision ID: brian@gaz-20091130191319-zyt51fidacic3brf
Merge Padraig

Show diffs side-by-side

added added

removed removed

Lines of Context:
112
112
*/
113
113
 
114
114
/* XXX these are defined in mysql_priv.h inside #ifdef DRIZZLE_SERVER */
115
 
bool schema_table_store_record(Session *session, Table *table);
116
115
void localtime_to_TIME(DRIZZLE_TIME *to, struct tm *from);
117
116
 
118
117
/*******************************************************************//**
205
204
                  DRIZZLE_TYPE_VARCHAR,
206
205
                  0,
207
206
                  0,
208
 
                  "",
209
 
                  SKIP_OPEN_TABLE),
 
207
                  ""),
210
208
 
211
209
#define IDX_TRX_STATE           1
212
210
        drizzled::plugin::ColumnInfo("trx_state",
214
212
                  DRIZZLE_TYPE_VARCHAR,
215
213
                  0,
216
214
                  0,
217
 
                  "",
218
 
                  SKIP_OPEN_TABLE),
 
215
                  ""),
219
216
 
220
217
#define IDX_TRX_STARTED         2
221
218
        drizzled::plugin::ColumnInfo("trx_started",
223
220
                  DRIZZLE_TYPE_DATETIME,
224
221
                  0,
225
222
                  0,
226
 
                  "",
227
 
                  SKIP_OPEN_TABLE),
 
223
                  ""),
228
224
 
229
225
#define IDX_TRX_REQUESTED_LOCK_ID       3
230
226
        drizzled::plugin::ColumnInfo("trx_requested_lock_id",
232
228
                  DRIZZLE_TYPE_VARCHAR,
233
229
                  0,
234
230
                  MY_I_S_MAYBE_NULL,
235
 
                  "",
236
 
                  SKIP_OPEN_TABLE),
 
231
                  ""),
237
232
 
238
233
#define IDX_TRX_WAIT_STARTED    4
239
234
        drizzled::plugin::ColumnInfo("trx_wait_started",
241
236
                  DRIZZLE_TYPE_DATETIME,
242
237
                  0,
243
238
                  MY_I_S_MAYBE_NULL,
244
 
                  "",
245
 
                  SKIP_OPEN_TABLE),
 
239
                  ""),
246
240
 
247
241
#define IDX_TRX_WEIGHT          5
248
242
        drizzled::plugin::ColumnInfo("trx_weight",
250
244
                  DRIZZLE_TYPE_LONGLONG,
251
245
                  0,
252
246
                  MY_I_S_UNSIGNED,
253
 
                  "",
254
 
                  SKIP_OPEN_TABLE),
 
247
                  ""),
255
248
 
256
249
#define IDX_TRX_DRIZZLE_THREAD_ID       6
257
250
        drizzled::plugin::ColumnInfo("trx_mysql_thread_id",
259
252
                  DRIZZLE_TYPE_LONGLONG,
260
253
                  0,
261
254
                  MY_I_S_UNSIGNED,
262
 
                  "",
263
 
                  SKIP_OPEN_TABLE),
 
255
                  ""),
264
256
 
265
257
#define IDX_TRX_QUERY           7
266
258
        drizzled::plugin::ColumnInfo("trx_query",
268
260
                  DRIZZLE_TYPE_VARCHAR,
269
261
                  0,
270
262
                  MY_I_S_MAYBE_NULL,
271
 
                  "",
272
 
                  SKIP_OPEN_TABLE),
 
263
                  ""),
273
264
 
274
265
        drizzled::plugin::ColumnInfo()
275
266
};
283
274
fill_innodb_trx_from_cache(
284
275
/*=======================*/
285
276
        trx_i_s_cache_t*        cache,  /*!< in: cache to read from */
286
 
        Session*                session,/*!< in: used to call
287
 
                                        schema_table_store_record() */
288
 
        Table*                  table)  /*!< in/out: fill this table */
 
277
        Table*                  table,  /*!< in/out: fill this table */
 
278
        drizzled::plugin::InfoSchemaTable *schema_table)
289
279
{
290
280
        Field** fields;
291
281
        ulint   rows_num;
351
341
                OK(field_store_string(fields[IDX_TRX_QUERY],
352
342
                                      row->trx_query));
353
343
 
354
 
                OK(schema_table_store_record(session, table));
 
344
                schema_table->addRow(table->record[0],
 
345
                                     table->s->reclength);
355
346
        }
356
347
 
357
348
        return(0);
383
374
                  DRIZZLE_TYPE_VARCHAR,
384
375
                  0,
385
376
                  0,
386
 
                  "",
387
 
                  SKIP_OPEN_TABLE),
 
377
                  ""),
388
378
 
389
379
#define IDX_LOCK_TRX_ID         1
390
380
        drizzled::plugin::ColumnInfo("lock_trx_id",
392
382
                  DRIZZLE_TYPE_VARCHAR,
393
383
                  0,
394
384
                  0,
395
 
                  "",
396
 
                  SKIP_OPEN_TABLE),
 
385
                  ""),
397
386
 
398
387
#define IDX_LOCK_MODE           2
399
388
        drizzled::plugin::ColumnInfo("lock_mode",
402
391
                  DRIZZLE_TYPE_VARCHAR,
403
392
                  0,
404
393
                  0,
405
 
                  "",
406
 
                  SKIP_OPEN_TABLE),
 
394
                  ""),
407
395
 
408
396
#define IDX_LOCK_TYPE           3
409
397
        drizzled::plugin::ColumnInfo("lock_type",
411
399
                  DRIZZLE_TYPE_VARCHAR,
412
400
                  0,
413
401
                  0,
414
 
                  "",
415
 
                  SKIP_OPEN_TABLE),
 
402
                  ""),
416
403
 
417
404
#define IDX_LOCK_TABLE          4
418
405
        drizzled::plugin::ColumnInfo("lock_table",
420
407
                  DRIZZLE_TYPE_VARCHAR,
421
408
                  0,
422
409
                  0,
423
 
                  "",
424
 
                  SKIP_OPEN_TABLE),
 
410
                  ""),
425
411
 
426
412
#define IDX_LOCK_INDEX          5
427
413
        drizzled::plugin::ColumnInfo("lock_index",
429
415
                  DRIZZLE_TYPE_VARCHAR,
430
416
                  0,
431
417
                  MY_I_S_MAYBE_NULL,
432
 
                  "",
433
 
                  SKIP_OPEN_TABLE),
 
418
                  ""),
434
419
 
435
420
#define IDX_LOCK_SPACE          6
436
421
        drizzled::plugin::ColumnInfo("lock_space",
438
423
                  DRIZZLE_TYPE_LONGLONG,
439
424
                  0,
440
425
                  MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL,
441
 
                  "",
442
 
                  SKIP_OPEN_TABLE),
 
426
                  ""),
443
427
 
444
428
#define IDX_LOCK_PAGE           7
445
429
        drizzled::plugin::ColumnInfo("lock_page",
447
431
                  DRIZZLE_TYPE_LONGLONG,
448
432
                  0,
449
433
                  MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL,
450
 
                  "",
451
 
                  SKIP_OPEN_TABLE),
 
434
                  ""),
452
435
 
453
436
#define IDX_LOCK_REC            8
454
437
        drizzled::plugin::ColumnInfo("lock_rec",
456
439
                  DRIZZLE_TYPE_LONGLONG,
457
440
                  0,
458
441
                  MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL,
459
 
                  "",
460
 
                  SKIP_OPEN_TABLE),
 
442
                  ""),
461
443
 
462
444
#define IDX_LOCK_DATA           9
463
445
        drizzled::plugin::ColumnInfo("lock_data",
465
447
                  DRIZZLE_TYPE_VARCHAR,
466
448
                  0,
467
449
                  MY_I_S_MAYBE_NULL,
468
 
                  "",
469
 
                  SKIP_OPEN_TABLE),
 
450
                  ""),
470
451
 
471
452
        drizzled::plugin::ColumnInfo()
472
453
};
481
462
/*=========================*/
482
463
        trx_i_s_cache_t*        cache,  /*!< in: cache to read from */
483
464
        Session*                session,/*!< in: MySQL client connection */
484
 
        Table*                  table)  /*!< in/out: fill this table */
 
465
        Table*                  table,  /*!< in/out: fill this table */
 
466
        drizzled::plugin::InfoSchemaTable *schema_table)
485
467
{
486
468
        Field** fields;
487
469
        ulint   rows_num;
571
553
                OK(field_store_string(fields[IDX_LOCK_DATA],
572
554
                                      row->lock_data));
573
555
 
574
 
                OK(schema_table_store_record(session, table));
 
556
                schema_table->addRow(table->record[0],
 
557
                                     table->s->reclength);
575
558
        }
576
559
 
577
560
        return(0);
603
586
                  DRIZZLE_TYPE_VARCHAR,
604
587
                  0,
605
588
                  0,
606
 
                  "",
607
 
                  SKIP_OPEN_TABLE),
 
589
                  ""),
608
590
 
609
591
#define IDX_REQUESTED_LOCK_ID   1
610
592
        drizzled::plugin::ColumnInfo("requested_lock_id",
612
594
                  DRIZZLE_TYPE_VARCHAR,
613
595
                  0,
614
596
                  0,
615
 
                  "",
616
 
                  SKIP_OPEN_TABLE),
 
597
                  ""),
617
598
 
618
599
#define IDX_BLOCKING_TRX_ID     2
619
600
        drizzled::plugin::ColumnInfo("blocking_trx_id",
621
602
                  DRIZZLE_TYPE_VARCHAR,
622
603
                  0,
623
604
                  0,
624
 
                  "",
625
 
                  SKIP_OPEN_TABLE),
 
605
                  ""),
626
606
 
627
607
#define IDX_BLOCKING_LOCK_ID    3
628
608
        drizzled::plugin::ColumnInfo("blocking_lock_id",
630
610
                  DRIZZLE_TYPE_VARCHAR,
631
611
                  0,
632
612
                  0,
633
 
                  "",
634
 
                  SKIP_OPEN_TABLE),
 
613
                  ""),
635
614
 
636
615
        drizzled::plugin::ColumnInfo()
637
616
};
645
624
fill_innodb_lock_waits_from_cache(
646
625
/*==============================*/
647
626
        trx_i_s_cache_t*        cache,  /*!< in: cache to read from */
648
 
        Session*                session,/*!< in: used to call
649
 
                                        schema_table_store_record() */
650
 
        Table*                  table)  /*!< in/out: fill this table */
 
627
        Table*                  table,  /*!< in/out: fill this table */
 
628
        drizzled::plugin::InfoSchemaTable *schema_table)
651
629
{
652
630
        Field** fields;
653
631
        ulint   rows_num;
699
677
                                   blocking_lock_id,
700
678
                                   sizeof(blocking_lock_id))));
701
679
 
702
 
                OK(schema_table_store_record(session, table));
 
680
                schema_table->addRow(table->record[0],
 
681
                                     table->s->reclength);
703
682
        }
704
683
 
705
684
        return(0);
734
713
TrxISMethods::fillTable(
735
714
/*======================*/
736
715
        Session*        session,/*!< in: thread */
737
 
        TableList*      tables) /*!< in/out: tables to fill */
 
716
        Table*  table,  /*!< in/out: tables to fill */
 
717
        drizzled::plugin::InfoSchemaTable *schema_table)
738
718
{
739
719
        const char*             table_name;
740
720
        int                     ret;
745
725
        cache = trx_i_s_cache;
746
726
 
747
727
        /* which table we have to fill? */
748
 
        table_name = tables->schema_table_name;
 
728
        table_name = schema_table->getName().c_str();
749
729
        /* or table_name = tables->schema_table->table_name; */
750
730
 
751
731
        RETURN_IF_INNODB_NOT_STARTED(table_name);
770
750
        if (innobase_strcasecmp(table_name, "innodb_trx") == 0) {
771
751
 
772
752
                if (fill_innodb_trx_from_cache(
773
 
                        cache, session, tables->table) != 0) {
 
753
                        cache, table, schema_table) != 0) {
774
754
 
775
755
                        ret = 1;
776
756
                }
778
758
        } else if (innobase_strcasecmp(table_name, "innodb_locks") == 0) {
779
759
 
780
760
                if (fill_innodb_locks_from_cache(
781
 
                        cache, session, tables->table) != 0) {
 
761
                        cache, session, table, schema_table) != 0) {
782
762
 
783
763
                        ret = 1;
784
764
                }
786
766
        } else if (innobase_strcasecmp(table_name, "innodb_lock_waits") == 0) {
787
767
 
788
768
                if (fill_innodb_lock_waits_from_cache(
789
 
                        cache, session, tables->table) != 0) {
 
769
                        cache, table, schema_table) != 0) {
790
770
 
791
771
                        ret = 1;
792
772
                }
825
805
                  DRIZZLE_TYPE_LONG,
826
806
                  0,
827
807
                  0,
828
 
                  "Compressed Page Size",
829
 
                  SKIP_OPEN_TABLE),
 
808
                  "Compressed Page Size"),
830
809
 
831
810
        drizzled::plugin::ColumnInfo("compress_ops",
832
811
                  MY_INT32_NUM_DECIMAL_DIGITS,
833
812
                  DRIZZLE_TYPE_LONG,
834
813
                  0,
835
814
                  0,
836
 
                  "Total Number of Compressions",
837
 
                  SKIP_OPEN_TABLE),
 
815
                  "Total Number of Compressions"),
838
816
 
839
817
        drizzled::plugin::ColumnInfo("compress_ops_ok",
840
818
                  MY_INT32_NUM_DECIMAL_DIGITS,
841
819
                  DRIZZLE_TYPE_LONG,
842
820
                  0,
843
821
                  0,
844
 
                  "Total Number of Successful Compressions",
845
 
                  SKIP_OPEN_TABLE),
 
822
                  "Total Number of Successful Compressions"),
846
823
 
847
824
        drizzled::plugin::ColumnInfo("compress_time",
848
825
                  MY_INT32_NUM_DECIMAL_DIGITS,
849
826
                  DRIZZLE_TYPE_LONG,
850
827
                  0,
851
828
                  0,
852
 
                  "Total Duration of Compressions in Seconds",
853
 
                  SKIP_OPEN_TABLE),
 
829
                  "Total Duration of Compressions in Seconds"),
854
830
 
855
831
        drizzled::plugin::ColumnInfo("uncompress_ops",
856
832
                  MY_INT32_NUM_DECIMAL_DIGITS,
857
833
                  DRIZZLE_TYPE_LONG,
858
834
                  0,
859
835
                  0,
860
 
                  "Total Number of Decompressions",
861
 
                  SKIP_OPEN_TABLE),
 
836
                  "Total Number of Decompressions"),
862
837
 
863
838
        drizzled::plugin::ColumnInfo("uncompress_time",
864
839
                  MY_INT32_NUM_DECIMAL_DIGITS,
865
840
                  DRIZZLE_TYPE_LONG,
866
841
                  0,
867
842
                  0,
868
 
                  "Total Duration of Decompressions in Seconds",
869
 
                  SKIP_OPEN_TABLE),
 
843
                  "Total Duration of Decompressions in Seconds"),
870
844
 
871
845
        drizzled::plugin::ColumnInfo()
872
846
};
881
855
i_s_cmp_fill_low(
882
856
/*=============*/
883
857
        Session*        session,/*!< in: thread */
884
 
        TableList*      tables, /*!< in/out: tables to fill */
 
858
        Table*  table,  /*!< in/out: tables to fill */
 
859
        drizzled::plugin::InfoSchemaTable *schema_table,
885
860
        ibool           reset)  /*!< in: TRUE=reset cumulated counts */
886
861
{
887
 
        Table*  table   = (Table *) tables->table;
888
862
        int     status  = 0;
889
863
 
890
864
 
891
 
        RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name);
 
865
        RETURN_IF_INNODB_NOT_STARTED(schema_table->getName().c_str());
892
866
 
893
867
        for (uint i = 0; i < PAGE_ZIP_NUM_SSIZE - 1; i++) {
894
868
                page_zip_stat_t*        zip_stat = &page_zip_stat[i];
913
887
                        memset(zip_stat, 0, sizeof *zip_stat);
914
888
                }
915
889
 
916
 
                if (schema_table_store_record(session, table)) {
917
 
                        status = 1;
918
 
                        break;
919
 
                }
 
890
                schema_table->addRow(table->record[0],
 
891
                                     table->s->reclength);
920
892
        }
921
893
 
922
894
        return(status);
929
901
CmpISMethods::fillTable(
930
902
/*=========*/
931
903
        Session*        session,/*!< in: thread */
932
 
        TableList*      tables) /*!< in/out: tables to fill */
 
904
        Table*  table,  /*!< in/out: tables to fill */
 
905
        drizzled::plugin::InfoSchemaTable *schema_table)
933
906
{
934
 
        return(i_s_cmp_fill_low(session, tables, FALSE));
 
907
        return(i_s_cmp_fill_low(session, table, schema_table, FALSE));
935
908
}
936
909
 
937
910
/*******************************************************************//**
941
914
CmpResetISMethods::fillTable(
942
915
/*===============*/
943
916
        Session*        session,/*!< in: thread */
944
 
        TableList*      tables) /*!< in/out: tables to fill */
 
917
        Table*  table,  /*!< in/out: tables to fill */
 
918
        drizzled::plugin::InfoSchemaTable *schema_table)
945
919
{
946
 
        return(i_s_cmp_fill_low(session, tables, TRUE));
 
920
        return(i_s_cmp_fill_low(session, table, schema_table, TRUE));
947
921
}
948
922
 
949
923
/*******************************************************************//**
990
964
                  DRIZZLE_TYPE_LONG,
991
965
                  0,
992
966
                  0,
993
 
                  "Buddy Block Size",
994
 
                  SKIP_OPEN_TABLE),
 
967
                  "Buddy Block Size"),
995
968
 
996
969
        drizzled::plugin::ColumnInfo("pages_used",
997
970
                  MY_INT32_NUM_DECIMAL_DIGITS,
998
971
                  DRIZZLE_TYPE_LONG,
999
972
                  0,
1000
973
                  0,
1001
 
                  "Currently in Use",
1002
 
                  SKIP_OPEN_TABLE),
 
974
                  "Currently in Use"),
1003
975
 
1004
976
        drizzled::plugin::ColumnInfo("pages_free",
1005
977
                  MY_INT32_NUM_DECIMAL_DIGITS,
1006
978
                  DRIZZLE_TYPE_LONG,
1007
979
                  0,
1008
980
                  0,
1009
 
                  "Currently Available",
1010
 
                  SKIP_OPEN_TABLE),
 
981
                  "Currently Available"),
1011
982
 
1012
983
        drizzled::plugin::ColumnInfo("relocation_ops",
1013
984
                  MY_INT64_NUM_DECIMAL_DIGITS,
1014
985
                  DRIZZLE_TYPE_LONGLONG,
1015
986
                  0,
1016
987
                  0,
1017
 
                  "Total Number of Relocations",
1018
 
                  SKIP_OPEN_TABLE),
 
988
                  "Total Number of Relocations"),
1019
989
 
1020
990
        drizzled::plugin::ColumnInfo("relocation_time",
1021
991
                  MY_INT32_NUM_DECIMAL_DIGITS,
1022
992
                  DRIZZLE_TYPE_LONG,
1023
993
                  0,
1024
994
                  0,
1025
 
                  "Total Duration of Relocations, in Seconds",
1026
 
                  SKIP_OPEN_TABLE),
 
995
                  "Total Duration of Relocations, in Seconds"),
1027
996
 
1028
997
        drizzled::plugin::ColumnInfo()
1029
998
};
1037
1006
i_s_cmpmem_fill_low(
1038
1007
/*================*/
1039
1008
        Session*        session,/*!< in: thread */
1040
 
        TableList*      tables, /*!< in/out: tables to fill */
 
1009
        Table*  table,  /*!< in/out: tables to fill */
 
1010
        drizzled::plugin::InfoSchemaTable *schema_table,
1041
1011
        ibool           reset)  /*!< in: TRUE=reset cumulated counts */
1042
1012
{
1043
 
        Table*  table   = (Table *) tables->table;
1044
1013
        int     status  = 0;
1045
1014
 
1046
 
        RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name);
 
1015
        RETURN_IF_INNODB_NOT_STARTED(schema_table->getName().c_str());
1047
1016
 
1048
1017
        buf_pool_mutex_enter();
1049
1018
 
1065
1034
                        buddy_stat->relocated_usec = 0;
1066
1035
                }
1067
1036
 
1068
 
                if (schema_table_store_record(session, table)) {
1069
 
                        status = 1;
1070
 
                        break;
1071
 
                }
 
1037
                schema_table->addRow(table->record[0],
 
1038
                                     table->s->reclength);
1072
1039
        }
1073
1040
 
1074
1041
        buf_pool_mutex_exit();
1082
1049
CmpmemISMethods::fillTable(
1083
1050
/*============*/
1084
1051
        Session*        session,/*!< in: thread */
1085
 
        TableList*      tables) /*!< in/out: tables to fill */
 
1052
        Table*  table, /*!< in/out: tables to fill */
 
1053
        drizzled::plugin::InfoSchemaTable *schema_table)        
1086
1054
{
1087
 
        return(i_s_cmpmem_fill_low(session, tables, FALSE));
 
1055
        return(i_s_cmpmem_fill_low(session, table, schema_table, FALSE));
1088
1056
}
1089
1057
 
1090
1058
/*******************************************************************//**
1094
1062
CmpmemResetISMethods::fillTable(
1095
1063
/*==================*/
1096
1064
        Session*        session,/*!< in: thread */
1097
 
        TableList*      tables) /*!< in/out: tables to fill */
 
1065
        Table*  table,  /*!< in/out: tables to fill */
 
1066
        drizzled::plugin::InfoSchemaTable *schema_table)
1098
1067
{
1099
 
        return(i_s_cmpmem_fill_low(session, tables, TRUE));
 
1068
        return(i_s_cmpmem_fill_low(session, table, schema_table, TRUE));
1100
1069
}
1101
1070
 
1102
1071
/*******************************************************************//**