ifsnop / mysqldump-php

PHP version of mysqldump cli that comes with MySQL
https://github.com/ifsnop/mysqldump-php
GNU General Public License v3.0
1.25k stars 300 forks source link

Reading Issue for Partitioned Tables #282

Closed dev-quentin closed 2 months ago

dev-quentin commented 3 months ago

Problem Description

https://github.com/ifsnop/mysqldump-php/blob/2d3a43fc0c49f23bf7dee392b0dd1f8c799f89d3/src/Ifsnop/Mysqldump/Mysqldump.php#L302

This line does not work correctly with partitions in MySQL databases.

Example

If the SQL file contains a partitioned table like the one below:

CREATE TABLE my_table (
  id mediumint(8) NOT NULL DEFAULT 0,
  field_code int(3) NOT NULL DEFAULT 0,
  field_subcode int(3) NOT NULL DEFAULT 0,
  value text NOT NULL,
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci
 PARTITION BY KEY (field_code, field_subcode)
PARTITIONS 50;

The current mechanism produces an incorrect line such as

COLLATE=utf8mb3_unicode_ciPARTITION

Solution

Remove the trim function.