Skip to content

[Bug]: Exporting views with union does not put a space before the keyword union #19692

@offsides

Description

@offsides

Describe the bug

When exporting a view with a union statement, there is no space between the word 'union' and the token before it. While this isn't a problem if the previous token is a closing parenthesis, it is a problem if it isn't, for example:

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `sshkeys`  AS SELECT `A`.`username` AS `username`, sshkey_convert(`A`.`public_key` AS `public_key`) AS `public_key` FROM (`ftp_accounts`.`sshkeys` `A` left join `ftp_accounts`.`accounts` `B` on(`A`.`username` = `B`.`username`)) WHERE `B`.`status` & 3 = 3union all (select `C`.`username` AS `username`,sshkey_convert(`C`.`public_key` AS `public_key`) AS `public_key` from `ftp_accounts`.`system_keys` `C` where sysuser_status(`C`.`username` AS `username`) = 0) ;

As shown above, the view gets exported with '[...]B.status & 3 = 3union all [...]', which causes an error when run.

How to Reproduce

Create a view with a union where the union statement comes after an expression other than a closing parenthesis.

Expected behavior

I expected the exported create view statement to be valid SQL.

Screenshots

No response

Operating System

Linux

Web Server

Apache/2.4.62 (RHEL 9)

Database Server

MariaDB

Database version

10.5.27-MariaDB-log

PHP version

8.1.30

phpMyAdmin version

5.2.2-1.el9.remi

browser

Firefox v137.0.2

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA problem or regression with an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions