@@ -56,6 +56,7 @@ Created July 18, 2007 Vasil Dimov
5656#include " fts0priv.h"
5757#include " btr0btr.h"
5858#include " page0zip.h"
59+ #include " trx0rseg.h"
5960
6061/* * structure associates a name string with a file page type and/or buffer
6162page state. */
@@ -620,14 +621,13 @@ fill_innodb_trx_from_cache(
620621 /* trx_requested_lock_id */
621622 /* trx_wait_started */
622623 if (row->trx_wait_started != 0 ) {
623-
624624 OK (field_store_string (
625625 fields[IDX_TRX_REQUESTED_LOCK_ID],
626626 trx_i_s_create_lock_id (
627627 row->requested_lock_row ,
628628 lock_id, sizeof (lock_id))));
629- /* field_store_string() sets it no notnull */
630629
630+ /* field_store_string() sets it no notnull */
631631 OK (field_store_time_t (
632632 fields[IDX_TRX_WAIT_STARTED],
633633 (time_t ) row->trx_wait_started ));
@@ -756,6 +756,181 @@ static struct st_mysql_information_schema i_s_info =
756756 MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION
757757};
758758
759+ /* Fields of the dynamic table information_schema.innodb_rseg. */
760+ static ST_FIELD_INFO i_s_innodb_rseg_fields_info[] =
761+ {
762+ {STRUCT_FLD (field_name, " rseg_id" ),
763+ STRUCT_FLD (field_length, MY_INT64_NUM_DECIMAL_DIGITS),
764+ STRUCT_FLD (field_type, MYSQL_TYPE_LONGLONG),
765+ STRUCT_FLD (value, 0 ),
766+ STRUCT_FLD (field_flags, MY_I_S_UNSIGNED),
767+ STRUCT_FLD (old_name, " " ),
768+ STRUCT_FLD (open_method, SKIP_OPEN_TABLE)},
769+
770+ {STRUCT_FLD (field_name, " space_id" ),
771+ STRUCT_FLD (field_length, MY_INT64_NUM_DECIMAL_DIGITS),
772+ STRUCT_FLD (field_type, MYSQL_TYPE_LONGLONG),
773+ STRUCT_FLD (value, 0 ),
774+ STRUCT_FLD (field_flags, MY_I_S_UNSIGNED),
775+ STRUCT_FLD (old_name, " " ),
776+ STRUCT_FLD (open_method, SKIP_OPEN_TABLE)},
777+
778+ {STRUCT_FLD (field_name, " zip_size" ),
779+ STRUCT_FLD (field_length, MY_INT64_NUM_DECIMAL_DIGITS),
780+ STRUCT_FLD (field_type, MYSQL_TYPE_LONGLONG),
781+ STRUCT_FLD (value, 0 ),
782+ STRUCT_FLD (field_flags, MY_I_S_UNSIGNED),
783+ STRUCT_FLD (old_name, " " ),
784+ STRUCT_FLD (open_method, SKIP_OPEN_TABLE)},
785+
786+ {STRUCT_FLD (field_name, " page_no" ),
787+ STRUCT_FLD (field_length, MY_INT64_NUM_DECIMAL_DIGITS),
788+ STRUCT_FLD (field_type, MYSQL_TYPE_LONGLONG),
789+ STRUCT_FLD (value, 0 ),
790+ STRUCT_FLD (field_flags, MY_I_S_UNSIGNED),
791+ STRUCT_FLD (old_name, " " ),
792+ STRUCT_FLD (open_method, SKIP_OPEN_TABLE)},
793+
794+ {STRUCT_FLD (field_name, " max_size" ),
795+ STRUCT_FLD (field_length, MY_INT64_NUM_DECIMAL_DIGITS),
796+ STRUCT_FLD (field_type, MYSQL_TYPE_LONGLONG),
797+ STRUCT_FLD (value, 0 ),
798+ STRUCT_FLD (field_flags, MY_I_S_UNSIGNED),
799+ STRUCT_FLD (old_name, " " ),
800+ STRUCT_FLD (open_method, SKIP_OPEN_TABLE)},
801+
802+ {STRUCT_FLD (field_name, " curr_size" ),
803+ STRUCT_FLD (field_length, MY_INT64_NUM_DECIMAL_DIGITS),
804+ STRUCT_FLD (field_type, MYSQL_TYPE_LONGLONG),
805+ STRUCT_FLD (value, 0 ),
806+ STRUCT_FLD (field_flags, MY_I_S_UNSIGNED),
807+ STRUCT_FLD (old_name, " " ),
808+ STRUCT_FLD (open_method, SKIP_OPEN_TABLE)},
809+
810+ END_OF_ST_FIELD_INFO
811+ };
812+
813+ /* ******************************************************************/ /* *
814+ Fill the dynamic table INFORMATION_SCHEMA.innodb_rseg
815+ @return 0 on success */
816+ static
817+ int
818+ i_s_innodb_rseg_fill (
819+ /* =================*/
820+ THD* thd, /* !< in: thread */
821+ TABLE_LIST* tables, /* !< in/out: tables to fill */
822+ Item* cond)
823+ {
824+ TABLE *table;
825+ int status;
826+
827+ status = 0 ;
828+ table = (TABLE *) tables->table ;
829+ DBUG_ENTER (" i_s_innodb_rseg_fill" );
830+
831+ /* Deny access to user without PROCESS_ACL privilege */
832+ if (check_global_access (thd, PROCESS_ACL)) {
833+ DBUG_RETURN (0 );
834+ }
835+
836+ RETURN_IF_INNODB_NOT_STARTED (tables->schema_table_name );
837+ /* Since rseg_array is a static array, so we don't need trx_sys->mutex.
838+ And we only estimate the size of rseg, also avoid rseg->mutex contention.
839+ */
840+ for (ulint i = 0 ; i < TRX_SYS_N_RSEGS; ++i) {
841+ const trx_rseg_t * rseg = trx_sys->rseg_array [i];
842+
843+ if (rseg != NULL ) {
844+ table->field [0 ]->store (rseg->id );
845+ table->field [1 ]->store (rseg->space );
846+ table->field [2 ]->store (rseg->zip_size );
847+ table->field [3 ]->store (rseg->page_no );
848+ table->field [4 ]->store (rseg->max_size );
849+ table->field [5 ]->store (rseg->curr_size );
850+
851+ if (schema_table_store_record (thd, table)) {
852+ status = 1 ; // no cover line.
853+ break ;
854+ }
855+ }
856+ }
857+
858+ DBUG_RETURN (status);
859+ }
860+
861+
862+ /* ******************************************************************/ /* *
863+ Bind the dynamic table INFORMATION_SCHEMA.innodb_rseg
864+ @return 0 on success */
865+ static
866+ int
867+ innodb_rseg_init (
868+ /* =============*/
869+ void * p) /* !< in/out: table schema object */
870+ {
871+ ST_SCHEMA_TABLE* schema;
872+ DBUG_ENTER (" innodb_rseg_init" );
873+
874+ schema= (ST_SCHEMA_TABLE*) p;
875+
876+ schema->fields_info = i_s_innodb_rseg_fields_info;
877+ schema->fill_table = i_s_innodb_rseg_fill;
878+
879+ DBUG_RETURN (0 );
880+ }
881+
882+ UNIV_INTERN struct st_mysql_plugin i_s_innodb_rseg =
883+ {
884+ /* the plugin type (a MYSQL_XXX_PLUGIN value) */
885+ /* int */
886+ STRUCT_FLD (type, MYSQL_INFORMATION_SCHEMA_PLUGIN),
887+
888+ /* pointer to type-specific plugin descriptor */
889+ /* void* */
890+ STRUCT_FLD (info, &i_s_info),
891+
892+ /* plugin name */
893+ /* const char* */
894+ STRUCT_FLD (name, " INNODB_RSEG" ),
895+
896+ /* plugin author (for SHOW PLUGINS) */
897+ /* const char* */
898+ STRUCT_FLD (author, " Aliyun" ),
899+
900+ /* general descriptive text (for SHOW PLUGINS) */
901+ /* const char* */
902+ STRUCT_FLD (descr, " InnoDB rollback segment information" ),
903+
904+ /* the plugin license (PLUGIN_LICENSE_XXX) */
905+ /* int */
906+ STRUCT_FLD (license, PLUGIN_LICENSE_GPL),
907+
908+ /* the function to invoke when plugin is loaded */
909+ /* int (*)(void*); */
910+ STRUCT_FLD (init, innodb_rseg_init),
911+
912+ /* the function to invoke when plugin is unloaded */
913+ /* int (*)(void*); */
914+ STRUCT_FLD (deinit, i_s_common_deinit),
915+
916+ /* plugin version (for SHOW PLUGINS) */
917+ /* unsigned int */
918+ STRUCT_FLD (version, INNODB_VERSION_SHORT),
919+
920+ /* struct st_mysql_show_var* */
921+ STRUCT_FLD (status_vars, NULL ),
922+
923+ /* struct st_mysql_sys_var** */
924+ STRUCT_FLD (system_vars, NULL ),
925+
926+ /* reserved for dependency checking */
927+ STRUCT_FLD (__reserved1, NULL ),
928+
929+ /* plugin flags */
930+ /* unsigned long */
931+ STRUCT_FLD (flags, 0UL ),
932+ };
933+
759934UNIV_INTERN struct st_mysql_plugin i_s_innodb_trx =
760935{
761936 /* the plugin type (a MYSQL_XXX_PLUGIN value) */
0 commit comments