Fix mysql_dump for MySQL 5.7 and MariaDB when using mysqldump 8

This commit is contained in:
Laurent Indermuehle 2023-01-09 17:00:41 +01:00
commit 9cb404b17b
No known key found for this signature in database
GPG key ID: 93FA944C9F34DD09
4 changed files with 189 additions and 7 deletions

View file

@ -36,7 +36,13 @@
command: "{{ mysql_command }} {{ db_latin1_name }} -e \"select * from testlatin1\""
register: output
- name: Dumping a table in Latin1 database
# With MySQL 8, new options have been added. For instance, when attempt to dump
# a MySQL 5.7 instance, mysqldump will throw "Unknown table 'COLUMN_STATISTICS'
# in information_schema (1109)".
# Unfortunatly, the mysql-client-5.7 is unavailable on Ubuntu for multiple
# major relase :( So I add --column-statistics=0 as a workaround...
# TODO : Remove this option in octobre 2023 when MySQL 5.7 will be End of Life.
- name: Encoding | Dumping a table in Latin1 database
mysql_db:
login_user: '{{ mysql_user }}'
login_password: '{{ mysql_password }}'
@ -46,6 +52,10 @@
encoding: latin1
target: "{{ latin1_file1 }}"
state: dump
dump_extra_args: >-
{% if db_engine == 'mysql' %}
--column-statistics=0
{% endif %}
register: result
- assert:

View file

@ -27,32 +27,72 @@
- "CREATE TABLE db1.t2 (id int)"
- "CREATE VIEW db2.v1 AS SELECT id from db1.t1"
# With MySQL 8, new options have been added. For instance, when attempt to dump
# a MySQL 5.7 instance, mysqldump will throw "Unknown table 'COLUMN_STATISTICS'
# in information_schema (1109)".
# Unfortunatly, the mysql-client-5.7 is unavailable on Ubuntu for multiple
# major relase :( So I add --column-statistics=0 as a workaround...
# TODO : Remove this option in octobre 2023 when MySQL 5.7 will be End of Life.
- name: Dumps errors | Full dump without compression
community.mysql.mysql_db:
state: dump
name: all
target: /tmp/full-dump.sql
dump_extra_args: >-
{% if db_engine == 'mysql' %}
--column-statistics=0
{% endif %}
register: full_dump
# With MySQL 8, new options have been added. For instance, when attempt to dump
# a MySQL 5.7 instance, mysqldump will throw "Unknown table 'COLUMN_STATISTICS'
# in information_schema (1109)".
# Unfortunatly, the mysql-client-5.7 is unavailable on Ubuntu for multiple
# major relase :( So I add --column-statistics=0 as a workaround...
# TODO : Remove this option in octobre 2023 when MySQL 5.7 will be End of Life.
- name: Dumps errors | Full dump with gunzip
community.mysql.mysql_db:
state: dump
name: all
target: /tmp/full-dump.sql.gz
dump_extra_args: >-
{% if db_engine == 'mysql' %}
--column-statistics=0
{% endif %}
register: full_dump_gz
# With MySQL 8, new options have been added. For instance, when attempt to dump
# a MySQL 5.7 instance, mysqldump will throw "Unknown table 'COLUMN_STATISTICS'
# in information_schema (1109)".
# Unfortunatly, the mysql-client-5.7 is unavailable on Ubuntu for multiple
# major relase :( So I add --column-statistics=0 as a workaround...
# TODO : Remove this option in octobre 2023 when MySQL 5.7 will be End of Life.
- name: Dumps errors | Distinct dump without compression
community.mysql.mysql_db:
state: dump
name: db2
target: /tmp/dump-db2.sql
dump_extra_args: >-
{% if db_engine == 'mysql' %}
--column-statistics=0
{% endif %}
register: dump_db2
# With MySQL 8, new options have been added. For instance, when attempt to dump
# a MySQL 5.7 instance, mysqldump will throw "Unknown table 'COLUMN_STATISTICS'
# in information_schema (1109)".
# Unfortunatly, the mysql-client-5.7 is unavailable on Ubuntu for multiple
# major relase :( So I add --column-statistics=0 as a workaround...
# TODO : Remove this option in octobre 2023 when MySQL 5.7 will be End of Life.
- name: Dumps errors | Distinct dump with gunzip
community.mysql.mysql_db:
state: dump
name: db2
target: /tmp/dump-db2.sql.gz
dump_extra_args: >-
{% if db_engine == 'mysql' %}
--column-statistics=0
{% endif %}
register: dump_db2_gz
- name: Dumps errors | Check distinct dumps are changed
@ -67,29 +107,60 @@
query:
- "DROP TABLE db1.t1"
# With MySQL 8, new options have been added. For instance, when attempt to dump
# a MySQL 5.7 instance, mysqldump will throw "Unknown table 'COLUMN_STATISTICS'
# in information_schema (1109)".
# Unfortunatly, the mysql-client-5.7 is unavailable on Ubuntu for multiple
# major relase :( So I add --column-statistics=0 as a workaround...
# TODO : Remove this option in octobre 2023 when MySQL 5.7 will be End of Life.
- name: Dumps errors | Full dump after drop t1 without compression
community.mysql.mysql_db:
state: dump
name: all
target: /tmp/full-dump-without-t1.sql
pipefail: true # This should do nothing
dump_extra_args: >-
{% if db_engine == 'mysql' %}
--column-statistics=0
{% endif %}
register: full_dump_without_t1
ignore_errors: true
# With MySQL 8, new options have been added. For instance, when attempt to dump
# a MySQL 5.7 instance, mysqldump will throw "Unknown table 'COLUMN_STATISTICS'
# in information_schema (1109)".
# Unfortunatly, the mysql-client-5.7 is unavailable on Ubuntu for multiple
# major relase :( So I add --column-statistics=0 as a workaround...
# TODO : Remove this option in octobre 2023 when MySQL 5.7 will be End of Life.
- name: Dumps errors | Full dump after drop t1 with gzip without the fix
community.mysql.mysql_db:
state: dump
name: all
target: /tmp/full-dump-without-t1.sql.gz
dump_extra_args: >-
{% if db_engine == 'mysql' %}
--column-statistics=0
{% endif %}
register: full_dump_without_t1_gz_without_fix
ignore_errors: true
# With MySQL 8, new options have been added. For instance, when attempt to dump
# a MySQL 5.7 instance, mysqldump will throw "Unknown table 'COLUMN_STATISTICS'
# in information_schema (1109)".
# Unfortunatly, the mysql-client-5.7 is unavailable on Ubuntu for multiple
# major relase :( So I add --column-statistics=0 as a workaround...
# TODO : Remove this option in octobre 2023 when MySQL 5.7 will be End of Life.
- name: Dumps errors | Full dump after drop t1 with gzip with the fix
community.mysql.mysql_db:
state: dump
name: all
target: /tmp/full-dump-without-t1.sql.gz
pipefail: true
dump_extra_args: >-
{% if db_engine == 'mysql' %}
--column-statistics=0
{% endif %}
register: full_dump_without_t1_gz_with_fix
ignore_errors: true
@ -104,29 +175,59 @@
- full_dump_without_t1_gz_with_fix.msg is search(
'references invalid table')
# With MySQL 8, new options have been added. For instance, when attempt to dump
# a MySQL 5.7 instance, mysqldump will throw "Unknown table 'COLUMN_STATISTICS'
# in information_schema (1109)".
# Unfortunatly, the mysql-client-5.7 is unavailable on Ubuntu for multiple
# major relase :( So I add --column-statistics=0 as a workaround...
# TODO : Remove this option in octobre 2023 when MySQL 5.7 will be End of Life.
- name: Dumps errors | Distinct dump after drop t1 without compression
community.mysql.mysql_db:
state: dump
name: db2
target: /tmp/dump-db2-without_t1.sql
pipefail: true # This should do nothing
dump_extra_args: >-
{% if db_engine == 'mysql' %}
--column-statistics=0
{% endif %}
register: dump_db2_without_t1
ignore_errors: true
# With MySQL 8, new options have been added. For instance, when attempt to dump
# a MySQL 5.7 instance, mysqldump will throw "Unknown table 'COLUMN_STATISTICS'
# in information_schema (1109)".
# Unfortunatly, the mysql-client-5.7 is unavailable on Ubuntu for multiple
# major relase :( So I add --column-statistics=0 as a workaround...
# TODO : Remove this option in octobre 2023 when MySQL 5.7 will be End of Life.
- name: Dumps errors | Distinct dump after drop t1 with gzip without the fix
community.mysql.mysql_db:
state: dump
name: db2
target: /tmp/dump-db2-without_t1.sql.gz
dump_extra_args: >-
{% if db_engine == 'mysql' %}
--column-statistics=0
{% endif %}
register: dump_db2_without_t1_gz_without_fix
ignore_errors: true
# With MySQL 8, new options have been added. For instance, when attempt to dump
# a MySQL 5.7 instance, mysqldump will throw "Unknown table 'COLUMN_STATISTICS'
# in information_schema (1109)".
# Unfortunatly, the mysql-client-5.7 is unavailable on Ubuntu for multiple
# major relase :( So I add --column-statistics=0 as a workaround...
# TODO : Remove this option in octobre 2023 when MySQL 5.7 will be End of Life.
- name: Dumps errors | Distinct dump after drop t1 with gzip with the fix
community.mysql.mysql_db:
state: dump
name: db2
target: /tmp/dump-db2-without_t1.sql.gz
pipefail: true
dump_extra_args: >-
{% if db_engine == 'mysql' %}
--column-statistics=0
{% endif %}
register: dump_db2_without_t1_gz_with_fix
ignore_errors: true

View file

@ -384,6 +384,13 @@
# ==========================================================================
# Dump existing databases
# With MySQL 8, new options have been added. For instance, when attempt to dump
# a MySQL 5.7 instance, mysqldump will throw "Unknown table 'COLUMN_STATISTICS'
# in information_schema (1109)".
# Unfortunatly, the mysql-client-5.7 is unavailable on Ubuntu for multiple
# major relase :( So I add --column-statistics=0 as a workaround...
# TODO : Remove this option in octobre 2023 when MySQL 5.7 will be End of Life.
- name: Dump existing databases
mysql_db:
login_user: '{{ mysql_user }}'
@ -396,6 +403,10 @@
- '{{ db3_name }}'
state: dump
target: '{{ dump1_file }}'
dump_extra_args: >-
{% if db_engine == 'mysql' %}
--column-statistics=0
{% endif %}
register: dump_result
- name: Assert successful completion of dump operation (existing database)
@ -437,6 +448,12 @@
name: '{{ dump2_file }}'
state: absent
# With MySQL 8, new options have been added. For instance, when attempt to dump
# a MySQL 5.7 instance, mysqldump will throw "Unknown table 'COLUMN_STATISTICS'
# in information_schema (1109)".
# Unfortunatly, the mysql-client-5.7 is unavailable on Ubuntu for multiple
# major relase :( So I add --column-statistics=0 as a workaround...
# TODO : Remove this option in octobre 2023 when MySQL 5.7 will be End of Life.
- name: Dump existing databases
mysql_db:
login_user: '{{ mysql_user }}'
@ -446,6 +463,10 @@
name: all
state: dump
target: '{{ dump2_file }}'
dump_extra_args: >-
{% if db_engine == 'mysql' %}
--column-statistics=0
{% endif %}
register: dump_result
- name: assert successful completion of dump operation

View file

@ -89,7 +89,13 @@
name: '{{ dump_file2 }}'
state: absent
- name: state dump without department table.
# With MySQL 8, new options have been added. For instance, when attempt to dump
# a MySQL 5.7 instance, mysqldump will throw "Unknown table 'COLUMN_STATISTICS'
# in information_schema (1109)".
# Unfortunatly, the mysql-client-5.7 is unavailable on Ubuntu for multiple
# major relase :( So I add --column-statistics=0 as a workaround...
# TODO : Remove this option in octobre 2023 when MySQL 5.7 will be End of Life.
- name: Dump and Import | State dump without department table.
mysql_db:
login_user: '{{ db_user }}'
login_password: '{{ db_user_unsafe_password }}'
@ -104,7 +110,11 @@
force: yes
master_data: 1
skip_lock_tables: yes
dump_extra_args: --skip-triggers
dump_extra_args: >-
--skip-triggers
{% if db_engine == 'mysql' %}
--column-statistics=0
{% endif %}
config_file: '{{ config_file }}'
restrict_config_file: yes
check_implicit_admin: no
@ -121,7 +131,13 @@
name: '{{ db_file_name }}'
state: file
- name: state dump with multiple databases in comma separated form.
# With MySQL 8, new options have been added. For instance, when attempt to dump
# a MySQL 5.7 instance, mysqldump will throw "Unknown table 'COLUMN_STATISTICS'
# in information_schema (1109)".
# Unfortunatly, the mysql-client-5.7 is unavailable on Ubuntu for multiple
# major relase :( So I add --column-statistics=0 as a workaround...
# TODO : Remove this option in octobre 2023 when MySQL 5.7 will be End of Life.
- name: Dump and Import | State dump with multiple databases in comma separated form for MySQL.
mysql_db:
login_user: '{{ mysql_user }}'
login_password: '{{ mysql_password }}'
@ -131,6 +147,10 @@
state: dump
target: '{{ dump_file1 }}'
check_implicit_admin: yes
dump_extra_args: >-
{% if db_engine == 'mysql' %}
--column-statistics=0
{% endif %}
register: dump_result1
- name: Dump and Import | Assert successful completion of dump operation (with multiple databases in comma separated form)
@ -144,7 +164,13 @@
name: '{{ dump_file1 }}'
state: file
- name: state dump with multiple databases in list form via check_mode
# With MySQL 8, new options have been added. For instance, when attempt to dump
# a MySQL 5.7 instance, mysqldump will throw "Unknown table 'COLUMN_STATISTICS'
# in information_schema (1109)".
# Unfortunatly, the mysql-client-5.7 is unavailable on Ubuntu for multiple
# major relase :( So I add --column-statistics=0 as a workaround...
# TODO : Remove this option in octobre 2023 when MySQL 5.7 will be End of Life.
- name: Dump and Import | State dump with multiple databases in list form via check_mode
mysql_db:
login_user: '{{ mysql_user }}'
login_password: '{{ mysql_password }}'
@ -155,6 +181,10 @@
- '{{ db_name2 }}'
state: dump
target: '{{ dump_file2 }}'
dump_extra_args: >-
{% if db_engine == 'mysql' %}
--column-statistics=0
{% endif %}
register: dump_result
check_mode: yes
@ -173,7 +203,13 @@
that:
- stat_result.stat.exists is defined and not stat_result.stat.exists
- name: state dump with multiple databases in list form.
# With MySQL 8, new options have been added. For instance, when attempt to dump
# a MySQL 5.7 instance, mysqldump will throw "Unknown table 'COLUMN_STATISTICS'
# in information_schema (1109)".
# Unfortunatly, the mysql-client-5.7 is unavailable on Ubuntu for multiple
# major relase :( So I add --column-statistics=0 as a workaround...
# TODO : Remove this option in octobre 2023 when MySQL 5.7 will be End of Life.
- name: Dump and Import | State dump with multiple databases in list form.
mysql_db:
login_user: '{{ mysql_user }}'
login_password: '{{ mysql_password }}'
@ -184,6 +220,10 @@
- '{{ db_name2 }}'
state: dump
target: '{{ dump_file2 }}'
dump_extra_args: >-
{% if db_engine == 'mysql' %}
--column-statistics=0
{% endif %}
register: dump_result2
- name: Dump and Import | Assert successful completion of dump operation (with multiple databases in list form)
@ -323,7 +363,13 @@
that:
- "'{{ db_name2 }}' in mysql_result.stdout"
- name: test state=dump to backup the database of type {{ format_type }} (expect changed=true)
# With MySQL 8, new options have been added. For instance, when attempt to dump
# a MySQL 5.7 instance, mysqldump will throw "Unknown table 'COLUMN_STATISTICS'
# in information_schema (1109)".
# Unfortunatly, the mysql-client-5.7 is unavailable on Ubuntu for multiple
# major relase :( So I add --column-statistics=0 as a workaround...
# TODO : Remove this option in octobre 2023 when MySQL 5.7 will be End of Life.
- name: Dump and Import | Test state=dump to backup the database of type {{ format_type }} (expect changed=true)
mysql_db:
login_user: '{{ mysql_user }}'
login_password: '{{ mysql_password }}'
@ -332,6 +378,10 @@
name: '{{ db_name }}'
state: dump
target: '{{ db_file_name }}'
dump_extra_args: >-
{% if db_engine == 'mysql' %}
--column-statistics=0
{% endif %}
register: result
- name: Dump and Import | Assert output message backup the database