Visitar URL original
Add support for MariaDB system-versioned tables and the SEQUENCE table option by xmaks82 · Pull Request #683 · phpmyadmin/sql-parser · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add the MariaDB SEQUENCE table option
SHOW CREATE TABLE prints SEQUENCE=1 for sequence tables
since MariaDB 10.3. The option was silently dropped.

Signed-off-by: Магда М.Г. <mail@mgmagda.ru>
  • Loading branch information
Магда М.Г.
Магда М.Г. committed Oct 23, 2026
commit 247aabed1c97e8e40f6f7100cd1c47c0dff0ce77
4 changes: 2 additions & 2 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2147,12 +2147,12 @@ parameters:

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEmpty\\(\\)\\.$#"
count: 3
count: 4
path: tests/Builder/CreateStatementTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#"
count: 36
count: 37
path: tests/Builder/CreateStatementTest.php

-
Expand Down
4 changes: 4 additions & 0 deletions src/Statements/CreateStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ class CreateStatement extends Statement
],
// MariaDB system-versioned tables.
'WITH SYSTEM VERSIONING' => 24,
'SEQUENCE' => [
25,
'var=',
],
];

/**
Expand Down
14 changes: 14 additions & 0 deletions tests/Builder/CreateStatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -913,4 +913,18 @@ public function testBuildCreateTableSystemVersioning(): void
$this->assertEmpty($parser->errors);
$this->assertEquals($sql, $parser->statements[0]->build());
}

public function testBuildCreateTableSequence(): void
{
Context::load('MariaDb100300');

$sql = "CREATE TABLE `s` (\n"
. " `next_not_cached_value` bigint(21) NOT NULL,\n"
. " `minimum_value` bigint(21) NOT NULL\n"
. ') ENGINE=InnoDB SEQUENCE=1';

$parser = new Parser($sql);
$this->assertEmpty($parser->errors);
$this->assertEquals($sql, $parser->statements[0]->build());
}
}
1 change: 1 addition & 0 deletions tests/Parser/CreateStatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public static function createProvider(): array
['parser/parseCreateTableUuidColumn_mariadb_100700'],
['parser/parseCreateTableSystemVersioning_mariadb_100300'],
['parser/parseCreateTableSystemVersioning2_mariadb_100300'],
['parser/parseCreateTableSequence_mariadb_100300'],
['parser/parseCreateTrigger'],
['parser/parseCreateUser1'],
['parser/parseCreateUser2'],
Expand Down
10 changes: 10 additions & 0 deletions tests/data/parser/parseCreateTableSequence_mariadb_100300.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CREATE TABLE `s` (
`next_not_cached_value` bigint(21) NOT NULL,
`minimum_value` bigint(21) NOT NULL,
`maximum_value` bigint(21) NOT NULL,
`start_value` bigint(21) NOT NULL COMMENT 'start value when sequences is created or value if RESTART is used',
`increment` bigint(21) NOT NULL COMMENT 'increment value',
`cache_size` bigint(21) unsigned NOT NULL,
`cycle_option` tinyint(1) unsigned NOT NULL COMMENT '0 if no cycles are allowed, 1 if the sequence should begin a new cycle when maximum_value is passed',
`cycle_count` bigint(21) NOT NULL COMMENT 'How many cycles have been done'
) ENGINE=InnoDB SEQUENCE=1;
Loading