0

MySQL バージョン 5.5.27

更新 2:これはかなり大きいと確信しており、同じ動作でゼロからテストを行いました。MySQL サイトのバグを開き、結果を更新します。

更新: ストアド プロシージャの一時テーブルから列を削除すると、正常に動作します。この問題は、列を手で落とした場合にのみ発生します。

次の行はストアド プロシージャで失敗し、エラーが発生します。

mysql> insert into player_record_week select * from pr_temp;

mysql> call insert_agg_week('2013-02-26');
ERROR 1054 (42S22): Unknown column 'prod_gamestats.pr_temp.total_battles' in 'field list'

手で実行すると動作します。

mysql>  insert into player_record_week select * from pr_temp;
Query OK, 211708 rows affected (2.23 sec)
Records: 211708  Duplicates: 0  Warnings: 0

一時テーブルに total_battles 列を残すと、列数の不一致に関するエラーで失敗します。テーブル pr_temp は、player_record_week テーブルを複製することによって作成されます。

| insert_agg_week |          | CREATE PROCEDURE     `insert_agg_week`(insert_week date)
begin
delete from player_record_week where stat_week = insert_week;
delete from player_tank_record_week where stat_week = insert_week;
delete from player_ratings_week_agg where stat_week = insert_week;
delete from player_ratings_week_per where stat_week = insert_week;
delete from global_week where stat_week = insert_week;
delete from global_tank_week where stat_week = insert_week;
insert into player_record_week select * from pr_temp;
insert into player_tank_record_week select * from ptr_temp;
insert into player_ratings_week_agg select * from pratings_temp_agg;
insert into player_ratings_week_per select * from pratings_temp_per;
insert into global_week select * from global_week_temp;
insert into global_tank_week select * from global_tank_week_temp;
end | utf8                 | utf8_general_ci      | latin1_swedish_ci  |

余分な列を保持すると、ストアド プロシージャは列数の不一致でエラーになります。

余分な列を削除すると、削除した列への参照でストアド プロシージャがエラーになります。

mysql> call insert_agg_week('2013-02-26');
ERROR 1054 (42S22): Unknown column 'prod_gamestats.pr_temp.total_battles' in 'field list'

コマンドを手動で実行すると、問題なく実行されます。

mysql> delete from player_record_week where stat_week = '2013-02-26';
Query OK, 0 rows affected (0.00 sec)

mysql> delete from player_tank_record_week where stat_week = '2013-02-26';
Query OK, 0 rows affected (0.00 sec)

mysql> delete from player_ratings_week_agg where stat_week = '2013-02-26';
Query OK, 0 rows affected (0.52 sec)

mysql> delete from player_ratings_week_per where stat_week = '2013-02-26';
Query OK, 0 rows affected (0.09 sec)

mysql> delete from global_week where stat_week = '2013-02-26';
Query OK, 0 rows affected (0.00 sec)

mysql> delete from global_tank_week where stat_week = '2013-02-26';
Query OK, 0 rows affected (0.00 sec)

mysql>  insert into player_record_week select * from pr_temp;
Query OK, 211708 rows affected (2.23 sec)
Records: 211708  Duplicates: 0  Warnings: 0

mysql>  insert into player_tank_record_week select * from ptr_temp;
Query OK, 1618240 rows affected (25.61 sec)
Records: 1618240  Duplicates: 0  Warnings: 0

mysql>  insert into player_ratings_week_agg select * from pratings_temp_agg;
Query OK, 211708 rows affected (1.86 sec)
Records: 211708  Duplicates: 0  Warnings: 0

mysql>  insert into player_ratings_week_per select * from pratings_temp_per;
Query OK, 41648 rows affected (0.39 sec)
Records: 41648  Duplicates: 0  Warnings: 0

mysql>  insert into global_week select * from global_week_temp;
Query OK, 21 rows affected (0.00 sec)
Records: 21  Duplicates: 0  Warnings: 0

mysql>  insert into global_tank_week select * from global_tank_week_temp;
Query OK, 257 rows affected (0.00 sec)
Records: 257  Duplicates: 0  Warnings: 0

以下に 2 つのテーブルを示します。

mysql> describe pr_temp;
+------------------------+-----------------------+------+-----+---------+-------+
| Field                  | Type                  | Null | Key | Default | Extra |
+------------------------+-----------------------+------+-----+---------+-------+
| player_id              | int(10) unsigned      | NO   | PRI | NULL    |       |
| stat_week              | date                  | NO   | PRI | NULL    |       |
| insert_date            | date                  | NO   |     | NULL    |       |
| tier_weight            | float                 | YES  |     | 0       |       |
| tier_weight_adj        | float                 | YES  |     | 0       |       |
| battles_count          | int(10) unsigned      | YES  |     | NULL    |       |
| wins                   | mediumint(8) unsigned | YES  |     | NULL    |       |
| losses                 | mediumint(8) unsigned | YES  |     | NULL    |       |
| survived_battles       | mediumint(8) unsigned | YES  |     | NULL    |       |
| spotted                | mediumint(8) unsigned | YES  |     | NULL    |       |
| hits_percents          | tinyint(3) unsigned   | YES  |     | NULL    |       |
| capture_points         | mediumint(8) unsigned | YES  |     | NULL    |       |
| damage_dealt           | int(10) unsigned      | YES  |     | NULL    |       |
| frags                  | mediumint(8) unsigned | YES  |     | NULL    |       |
| dropped_capture_points | mediumint(8) unsigned | YES  |     | NULL    |       |
| max_xp                 | smallint(5) unsigned  | YES  |     | NULL    |       |
| battle_avg_xp          | smallint(5) unsigned  | YES  |     | NULL    |       |
| xp                     | int(10) unsigned      | YES  |     | NULL    |       |
| integrated_rating      | smallint(5) unsigned  | YES  |     | NULL    |       |
| efficiency             | smallint(6)           | YES  |     | NULL    |       |
| efficiency_adj         | smallint(6)           | YES  |     | NULL    |       |
| wn7                    | smallint(6)           | YES  |     | NULL    |       |
| wn7_adj                | smallint(6)           | YES  |     | NULL    |       |
+------------------------+-----------------------+------+-----+---------+-------+
23 rows in set (0.00 sec)

mysql> describe player_record_week;
+------------------------+-----------------------+------+-----+---------+-------+
| Field                  | Type                  | Null | Key | Default | Extra |
+------------------------+-----------------------+------+-----+---------+-------+
| player_id              | int(10) unsigned      | NO   | PRI | NULL    |       |
| stat_week              | date                  | NO   | PRI | NULL    |       |
| insert_date            | date                  | NO   |     | NULL    |       |
| tier_weight            | float                 | YES  |     | 0       |       |
| tier_weight_adj        | float                 | YES  |     | 0       |       |
| battles_count          | int(10) unsigned      | YES  |     | NULL    |       |
| wins                   | mediumint(8) unsigned | YES  |     | NULL    |       |
| losses                 | mediumint(8) unsigned | YES  |     | NULL    |       |
| survived_battles       | mediumint(8) unsigned | YES  |     | NULL    |       |
| spotted                | mediumint(8) unsigned | YES  |     | NULL    |       |
| hits_percents          | tinyint(3) unsigned   | YES  |     | NULL    |       |
| capture_points         | mediumint(8) unsigned | YES  |     | NULL    |       |
| damage_dealt           | int(10) unsigned      | YES  |     | NULL    |       |
| frags                  | mediumint(8) unsigned | YES  |     | NULL    |       |
| dropped_capture_points | mediumint(8) unsigned | YES  |     | NULL    |       |
| max_xp                 | smallint(5) unsigned  | YES  |     | NULL    |       |
| battle_avg_xp          | smallint(5) unsigned  | YES  |     | NULL    |       |
| xp                     | int(10) unsigned      | YES  |     | NULL    |       | 
| integrated_rating      | smallint(5) unsigned  | YES  |     | NULL    |       |
| efficiency             | smallint(6)           | YES  |     | NULL    |       |
| efficiency_adj         | smallint(6)           | YES  |     | NULL    |       |
| wn7                    | smallint(6)           | YES  |     | NULL    |       |
| wn7_adj                | smallint(6)           | YES  |     | NULL    |       |
+------------------------+-----------------------+------+-----+---------+-------+
23 rows in set (0.00 sec)
4

1 に答える 1

1

MySQL のバグは 5.6.6 で修正されました。最初の手順の実行後、メタデータは更新されません。

http://bugs.mysql.com/bug.php?id=32868

バグ レポートからの回避策は、キャッシュをフラッシュすることです: CREATE OR REPLACE VIEW tmpviewAS SELECT 1;

于 2013-03-19T22:57:45.783 に答える