[MDEV-23251] Client compatible delimiter for mysqltest Created: 2020-07-22  Updated: 2022-04-26

Status: Open
Project: MariaDB Server
Component/s: None
Fix Version/s: None

Type: Task Priority: Minor
Reporter: Alexander Barkov Assignee: Nikita Malyavin
Resolution: Unresolved Votes: 0
Labels: beginner-friendly, gsoc22


 Description   

It's very annoying that the DELIMITER command has a different syntax in the client and in mysqltest:

  • Client:

    DELIMITER $$
    BEGIN NOT ATOMIC
      SELECT 1;
    END;
    $$
    DELIMITER ;
    

  • mysqltest:

    DELIMITER $$;
    BEGIN NOT ATOMIC
      SELECT 1;
    END;
    $$
    DELIMITER ;$$
    

We want to unify "mysqltest" and "mariadb" so any script can be pasted to either of them without modifications.

Originally, there was a proposal to support both styles and to make it possible to choose between the two styles by introducing new switches:

  • A new command to specify the delimiter style in a *.test file:

    --delimiter=client
    --delimiter=mysqltest
    

    with mysqltest being default (the current behavior).

  • Add a command line option to mysqltest to specify the default delimiter behavior:

    mysqltest --delimiter=client
    

  • Add a way to define delimiter style per the entire suite. This can probably be done by putting a my.cnf file into the suite directory:

    [mysqltest]
    delimiter=client
    

After discussion with the team (nikitamalyavin, serg, bar) we decided that having switches to choose between DELIMITER style would be over-engineering. Let's have the new behaviour hard-coded.

So non of these switches are needed.

We'll do the following:

1. Change mysqltest so instead of this style:

DELIMITER $$;
BEGIN NOT ATOMIC
  SELECT 1;
END;
$$
DELIMITER ;$$

it only understands just this style, compatible to the "mariadb" command line client:

DELIMITER $$
BEGIN NOT ATOMIC
  SELECT 1;
END;
$$
DELIMITER ;

2. Instead of adding the switches, we just fix all test result files *.result accordingly, to use the new DELIMITER style.

This change in the task means less programming on the step N1, but some time on the step N2.

A quick estimation in MariaDB-10.9 sources gives 10658 matches in 641 test files:

$ ag -i --stats-only delimiter mysql-test/
10658 matches
641 files contained matches
14818 files searched

But it seems most of them can most likely be changed using a simple script.



 Comments   
Comment by Sergei Golubchik [ 2020-07-22 ]

I don't see any reason why mysqltest should have non-mysql syntax for delimiter at all. Let's just change it to be compatible, update all tests once and be done with it. Why would we need a choice here ?

Comment by Alexander Barkov [ 2020-07-23 ]

My idea was to start using client delimiter with new tests, but it's OK to update all existing tests.

I think we'll still need to have the choice though. But with --delimiter=client as the default:

We have engines that work both with MySQL and MariaDB, and they have their own tests.
When an engine is fetched as a submodule, we don't have a control over the DELIMITER used in tests.

Comment by RinChanNOW [ 2022-04-18 ]

I want to have a try.

Comment by Alexander Barkov [ 2022-04-21 ]

I'm fine to go without a command line option. Having just hard-coded client-style delimiter in mysqltest should be fine.

Comment by Alexander Barkov [ 2022-04-21 ]

It would be nice to add eventually PostgreSQL style delimiters:

CREATE PROCEDURE p1(arg1 INT) AS $body$
    INSERT INTO foo(my_column) VALUES(arg1);
$body$ LANGUAGE sql;

I find it more convenient than setting DELIMITER.

Comment by Abe Hanoka [ 2022-04-25 ]

I feel this is something I can tackle with help from a mentor.

Generated at Thu Feb 08 09:21:00 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.