mariadb/mysql-test/suite/plugins
Tony Chen 6d35506647 MDEV-7381 Implement reversed executable comments
Add support for reversed executable comments using /*!!version */ and
/*M!!version */ syntax. These execute the comment body only when the
server version is strictly less than the specified version, which is
the inverse of the existing /*!version */ syntax.

This enables writing portable SQL that uses newer syntax on new servers
while falling back to older syntax on older servers, e.g.:

  CREATE /*!100000 OR REPLACE */ TABLE /*!!100000 IF NOT EXISTS */ t1 ...

On MariaDB >= 10.0 this expands to CREATE OR REPLACE TABLE t1, while
on older versions it expands to CREATE TABLE IF NOT EXISTS t1.

Implementation: in lex_one_token(), after detecting a versioned comment
(/*! or /*M!), check for an additional '!' character. If present, invert
the version comparison so the comment body is expanded only when
MYSQL_VERSION_ID < version.

Tests added to main.comments and plugins.server_audit confirming:
- Reversed comments with version <= server version do not execute
- Reversed comments with version > server version execute
- MariaDB-specific /*M!! variant works correctly
- Reversed comments without a version number always execute
- Audit plugin correctly logs executed reversed comments
- Combined forward + reversed comments in a single statement

All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the
BSD-new license. I am contributing on behalf of my employer Amazon Web
Services, Inc.
2026-03-03 14:10:03 +02:00
..
r MDEV-7381 Implement reversed executable comments 2026-03-03 14:10:03 +02:00
t MDEV-7381 Implement reversed executable comments 2026-03-03 14:10:03 +02:00
disabled.def Merge branch '10.1' into 10.2 2019-07-26 07:03:39 +02:00
suite.pm MDEV-23024 Remove Cassandra Storage Engine 2020-07-14 16:24:50 +03:00