From b84e8937ffb04bf0d136d4647625da9c0f7aba6b Mon Sep 17 00:00:00 2001
From: Julia Eskew <jeskew@edx.org>
Date: Fri, 4 Jun 2021 10:46:10 -0400
Subject: [PATCH] fix: Disable column-statistics during mysqldump command. This
 option was recently enabled by default in mysqldump, but the generation of
 histogram statistics fails in devstack during this script's mysqldump
 commands. The SQL statement and output of the failure:

mysql> SELECT \
COLUMN_NAME, JSON_EXTRACT(HISTOGRAM, '$."number-of-buckets-specified"') \
FROM information_schema.COLUMN_STATISTICS \
WHERE \
SCHEMA_NAME = 'edxtest' AND \
TABLE_NAME = 'agreements_integritysignature';
ERROR 1109 (42S02): Unknown table 'COLUMN_STATISTICS' in information_schema
---
 scripts/reset-test-db.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/reset-test-db.sh b/scripts/reset-test-db.sh
index 75fa576c451..0a41b31277b 100755
--- a/scripts/reset-test-db.sh
+++ b/scripts/reset-test-db.sh
@@ -89,11 +89,11 @@ rebuild_cache_for_db() {
     echo "Using the dumpdata command to save the $db fixture data to the filesystem."
     ./manage.py lms --settings $SETTINGS dumpdata --database $db > $DB_CACHE_DIR/bok_choy_data_$db.json --exclude=api_admin.Catalog
     echo "Saving the schema of the $db bok_choy DB to the filesystem."
-    mysqldump $MYSQL_HOST -u root --no-data --skip-comments --skip-dump-date "${databases[$db]}" > $DB_CACHE_DIR/bok_choy_schema_$db.sql
+    mysqldump --column_statistics=0 $MYSQL_HOST -u root --no-data --skip-comments --skip-dump-date "${databases[$db]}" > $DB_CACHE_DIR/bok_choy_schema_$db.sql
 
     # dump_data does not dump the django_migrations table so we do it separately.
     echo "Saving the django_migrations table of the $db bok_choy DB to the filesystem."
-    mysqldump $MYSQL_HOST -u root --no-create-info --skip-comments --skip-dump-date "${databases["$db"]}" django_migrations > $DB_CACHE_DIR/bok_choy_migrations_data_$db.sql
+    mysqldump --column_statistics=0 $MYSQL_HOST -u root --no-create-info --skip-comments --skip-dump-date "${databases["$db"]}" django_migrations > $DB_CACHE_DIR/bok_choy_migrations_data_$db.sql
 }
 
 for db in "${database_order[@]}"; do
-- 
GitLab