Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Disable Column Statistics for php artisan schema:dump on MariaDB #43027

Merged
merged 1 commit into from
Jul 1, 2022

Conversation

BrandonSurowiec
Copy link
Contributor

The php artisan schema:dump command fails on v10.x MariaDB. This is a resubmission of the fix by @domainregistrar in #40832. (Feel free to merge that one instead to give him credit.)

The previous PR was closed as Taylor was awaiting feedback to confirm the fix. I just ran into this issue myself. The proposed fix solves it and was verified by a few others before me:


Screenshot 2022-02-08 at 16 36 18

@taylorotwell can confirm that this problem exists.

EDIT: Using Laravel 9.x but should also happen in 8.x

Originally posted by @Jubeki in #40832 (comment)


Can confirm this fix works for me πŸ‘πŸΌ

I'm using Laravel version: 8.83.1 and Sail with image: 'mariadb:10'
mysqldump version: Ver 10.19 Distrib 10.6.5-MariaDB, for debian-linux-gnu (x86_64)

Before applying this fix:

sail artisan schema:dump
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqldump: Couldn't execute 'SELECT COLUMN_NAME,                       JSON_EXTRACT(HISTOGRAM, '$."number-of-buckets-specified"')                FROM information_schema.COLUMN_STATISTICS                WHERE SCHEMA_NAME = 'intranet' AND TABLE_NAME = 'attendance_reasons';': Unknown table 'COLUMN_STATISTICS' in information_schema (1109)

   Symfony\Component\Process\Exception\ProcessFailedException 

  The command "mysqldump  --user="${:LARAVEL_LOAD_USER}" --password="${:LARAVEL_LOAD_PASSWORD}" --host="${:LARAVEL_LOAD_HOST}" --port="${:LARAVEL_LOAD_PORT}" --no-tablespaces --skip-add-locks --skip-comments --skip-set-charset --tz-utc "${:LARAVEL_LOAD_DATABASE}" --routines --result-file="${:LARAVEL_LOAD_PATH}" --no-data" failed.

Exit Code: 2(Misuse of shell builtins)

Working directory: /var/www/html

Output:
================


Error Output:
================
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqldump: Couldn't execute 'SELECT COLUMN_NAME,                       JSON_EXTRACT(HISTOGRAM, '$."number-of-buckets-specified"')                FROM information_schema.COLUMN_STATISTICS                WHERE SCHEMA_NAME = 'intranet' AND TABLE_NAME = 'attendance_reasons';': Unknown table 'COLUMN_STATISTICS' in information_schema (1109)

  at vendor/symfony/process/Process.php:272
    268β–•      */
    269β–•     public function mustRun(callable $callback = null, array $env = []): self
    270β–•     {
    271β–•         if (0 !== $this->run($callback, $env)) {
  ➜ 272β–•             throw new ProcessFailedException($this);
    273β–•         }
    274β–• 
    275β–•         return $this;
    276β–•     }

      +16 vendor frames 
  17  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

After applying this fix:

sail artisan schema:dump
mysqldump: [Warning] Using a password on the command line interface can be insecure.
Database schema dumped successfully.

Originally posted by @22Nick22 in #40832 (comment)


Confirming: just got snagged by this myself (fresh Laravel 9 install using MariaDB via Sail)

Making the changes in this PR got it to work

Originally posted by @benmag in #40832 (comment)

@taylorotwell taylorotwell merged commit 33ef96e into laravel:8.x Jul 1, 2022
@BrandonSurowiec BrandonSurowiec deleted the fix-schema-dump-maria-db branch July 1, 2022 20:48
@direc85
Copy link

direc85 commented Aug 19, 2022

@BrandonSurowiec I know this is closed already, but I ran into another issues because of this fix, please see #43530. I have been trying hard to replicate this issue, but so far I haven't been able to reproduce the issue, but I'm getting the warning instead - both with Laravel 8 and 9, with and without Sail, always with MariaDB installed. Could you try adding this line

dump($this->getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION)."\n");

to vendor/laravel/framework/src/Illuminate/Database/MySqlConnection.php function isMaria() and see what the output is in the situations where you would before get the crash?

Edit: I'm currently running a manually-configured MariaDB container, and I'm getting this output myself with the addition above:

$ artisan schema:dump
^ "5.5.5-10.6.8-MariaDB-1:10.6.8+maria~focal\n"
mysqldump: unknown variable 'column-statistics=0'
^ "5.5.5-10.6.8-MariaDB-1:10.6.8+maria~focal\n"

   INFO  Database schema dumped successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants