1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
|
#
# When developing new tests, consider using a specific SELECT from ndbinfo
# tables (including the wl#11968 tables: dictionary_tables, dictionary_columns,
# blobs, index_columns, foreign_keys, events) to get brief and clear results.
#
# This file is meant to replace some uses of ndb_desc_print.inc with faster
# and more compact queries of ndbinfo tables.
#
# Set $ndb_describe_table to table name
# Set $ndb_describe_db to database name
#
# With $ndb_describe_indexes=1, include index info (like ndb_desc -i)
# With $ndb_describe_blobs=1, include blob info (like ndb_desc -b)
#
# The basic table description is almost perfectly backward-compatible with
# ndb_desc. The index and blob descriptions, however, differ substantial ways,
# since "ndb_desc -i" prints details of hidden index tables that are not
# generally available in NDB API.
#
# "ndb_desc -p" is not emulated at all here. It computes data distribution
# in a way that is not yet available anywhere else.
assert($ndb_describe_table);
if(! $ndb_describe_db)
{
let $ndb_describe_db=test;
}
disable_query_log ONCE;
disable_result_log ONCE;
eval SELECT table_id into @describe_table_id from ndbinfo.dictionary_tables
WHERE table_name = "$ndb_describe_table"
AND database_name = "$ndb_describe_db";
disable_query_log ONCE;
eval SELECT CONCAT(
"Version: Any",
"\nFragment type: ", fragment_type,
"\nK Value: 6",
"\nMin load factor: 78",
"\nMax load factor: 80",
"\nTemporary table: ", IF(logging, "no", "yes"),
"\nNumber of attributes: ", attributes,
"\nNumber of primary keys: ", primary_key_cols,
"\nLength of frm data: XXX",
"\nMax Rows: ", max_rows,
"\nRow Checksum: ", checksum,
"\nRow GCI: ", contains_GCI,
"\nSingleUserMode: ", single_user_mode-1,
"\nForceVarPart: ", force_var_part,
"\nPartitionCount: ", partitions,
"\nFragmentCount: ", fragments,
"\nPartitionBalance: ", partition_balance,
"\nExtraRowGciBits: ", GCI_bits,
"\nExtraRowAuthorBits: ", author_bits,
"\nTableStatus: ", status,
"\nTable options:", IF(read_backup, " readbackup", ""),
IF(read_backup AND fully_replicated, ", ", ""),
IF(fully_replicated, "fullyreplicated", ""),
IF(CHAR_LENGTH(hash_map), CONCAT("\nHashMap: ", hash_map), "")
) AS "-- $ndb_describe_table --"
FROM ndbinfo.dictionary_tables
WHERE table_id = @describe_table_id;
let $tablespace=`SELECT tablespace FROM ndbinfo.dictionary_tables
WHERE table_id = @describe_table_id`;
if($tablespace)
{
disable_query_log ONCE;
eval SELECT CONCAT("Tablespace: ", fq_name) AS "Tablespace id: XX"
FROM ndbinfo.dict_obj_info where id=$tablespace and type=20;
}
disable_query_log ONCE;
replace_regex /NDB\$BLOB_[0-9]*_/NDB$BLOB_XX_/;
SELECT CONCAT(
name, " ", column_type, " ",
IF(c.primary_key, "PRIMARY KEY", nullable),
IF(c.partition_key, " DISTRIBUTION KEY", ""),
" AT=", array_type,
" ST=", storage_type,
IF(c.auto_inc, " AUTO_INCR", ""),
IF(ISNULL(blob_table_name), "", concat(" BV=2 BT=", blob_table_name)),
IF(c.dynamic, " DYNAMIC", ""),
IF(CHAR_LENGTH(c.default_value), CONCAT(" DEFAULT ", c.default_value), "")
)
AS "-- Attributes --"
FROM ndbinfo.dictionary_columns c
JOIN ndbinfo.dictionary_tables t USING (table_id)
LEFT OUTER JOIN ndbinfo.blobs b USING (table_id, column_id)
WHERE table_id = @describe_table_id;
echo -- Indexes -- ;
disable_query_log ONCE;
disable_result_log ONCE;
SELECT
CONCAT("PRIMARY KEY(", REPLACE(primary_key,",",", "), ") - UniqueHashIndex")
INTO @pkdescriptor FROM ndbinfo.dictionary_tables
WHERE table_id = @describe_table_id;
let $pk_descriptor=`SELECT @pkdescriptor`;
disable_query_log ONCE;
EVAL SELECT
CONCAT(index_name,
"(", REPLACE(columns,",",", "), ") - ",
REPLACE(REPLACE(type_name," hash","Hash")," index","Index"))
AS "$pk_descriptor"
FROM ndbinfo.index_columns
JOIN ndbinfo.dict_obj_types ON index_type = type_id
WHERE table_id = @describe_table_id
ORDER BY index_object_id;
if($ndb_describe_indexes)
{
disable_query_log ONCE;
SELECT
CONCAT("-- ", table_name, "/", index_name, " --\n",
"Attributes: ", columns, "\n",
"Index Type: ", type_name, "\n",
"Index Status: ", status, "\n",
"Partitions: ", tab_partitions, "\n",
"Fragments: ", tab_fragments) AS ""
FROM ndbinfo.index_columns t1
JOIN ndbinfo.dict_obj_types ON t1.index_type = type_id
JOIN ndbinfo.table_distribution_status t3 ON index_object_id = t3.table_id
WHERE t1.table_id = @describe_table_id
ORDER BY index_object_id;
}
if($ndb_describe_blobs)
{
echo;
disable_query_log ONCE;
replace_regex /NDB\$BLOB_[0-9]*_/NDB$BLOB_XX_/;
SELECT CONCAT(
"Column name: ", column_name,
"\nInline size: ", inline_size,
"\nPart size: ", part_size,
"\nStipe size: ", stripe_size,
"\nBlob Table Name: ", blob_table_name,
"\nFragment type: ", fragment_type,
"\nTemporary table: ", IF(logging, "no", "yes"),
"\nNumber of attributes: ", attributes,
"\nPrimary key: ", primary_key,
"\nMax Rows: ", max_rows,
"\nRow Checksum: ", checksum,
"\nRow GCI: ", contains_GCI,
"\nSingleUserMode: ", single_user_mode-1,
"\nDynamic: ", dynamic,
"\nPartitionCount: ", partitions,
"\nFragmentCount: ", fragments,
"\nPartitionBalance: ", partition_balance,
"\nExtraRowGciBits: ", GCI_bits,
"\nExtraRowAuthorBits: ", author_bits,
"\nTableStatus: ", status,
"\nTable options:", IF(read_backup, " readbackup", ""),
IF(read_backup AND fully_replicated, ", ", ""),
IF(fully_replicated, "fullyreplicated", ""),
"\nHashMap: ", hash_map,
"\n") AS "-- Blob Tables --"
FROM ndbinfo.dictionary_tables t1
JOIN ndbinfo.blobs on t1.table_name = blob_table_name
WHERE blobs.table_id = @describe_table_id;
}
# Reset argument variable in order to detect missing assignment
let $ndb_describe_table=;
let $ndb_describe_db=;
let $ndb_describe_indexes=0;
let $ndb_describe_blobs=0;
|