[MDEV-23668] $$ "Full-Escape" Syntax for mysql CLI and mysqltest Created: 2020-09-04  Updated: 2020-09-13

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

Type: Task Priority: Major
Reporter: Roel Van de Paar Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: None


 Description   

With thanks to bar for the great idea, this feature request to implement $$ syntax markers in the mysql client (and mysqltest), which would avoid the need for any delimiter inside them. This would allow single-line CREATE PROCEDURE statements (very handy for QA and MTR tests etc.) and other goodies like not having to change delimiters, being able to insert binary data directly, etc.

CREATE PROCEDURE p() $$ BEGIN; BEGIN; SELECT 1; END; END; $$;

SELECT $$ some_binary_data $$;

etc.

PostgreSQL also has something like this in $$ (as does Bash from memory, with a different syntax):
https://www.postgresonline.com/journal/archives/376-Dollar-quoting-for-escaping-single-quotes.html
https://www.postgresql.org/docs/current/plpgsql-development-tips.html#PLPGSQL-QUOTE-TIPS



 Comments   
Comment by Roel Van de Paar [ 2020-09-04 ]

sanja any thoughts on this?

Comment by Roel Van de Paar [ 2020-09-04 ]

DELIMITER //
CREATE PROCEDURE loopme()
  LOOP
    SELECT 1;
  END LOOP
//
DELIMITER ;
CALL loopme();

vs

CREATE PROCEDURE loopme() $$ LOOP SELECT 1; END LOOP $$; CALL dorepeat();

And one can maintain the original formatting if so desired:

CREATE PROCEDURE loop() $$
 LOOP
   SELECT 1;
 END LOOP
$$;
CALL dorepeat();

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