* Support php 5.3 for sql parser lib.
This commit is contained in:
+34
-40
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Parses the create definition of a partition.
|
||||
*
|
||||
* Used for parsing `CREATE TABLE` statement.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\SqlParser\Components;
|
||||
|
||||
use PhpMyAdmin\SqlParser\Component;
|
||||
@@ -14,16 +13,14 @@ use PhpMyAdmin\SqlParser\Parser;
|
||||
use PhpMyAdmin\SqlParser\Token;
|
||||
use PhpMyAdmin\SqlParser\TokensList;
|
||||
|
||||
use function implode;
|
||||
use function is_array;
|
||||
use function trim;
|
||||
|
||||
/**
|
||||
* Parses the create definition of a partition.
|
||||
*
|
||||
* Used for parsing `CREATE TABLE` statement.
|
||||
*
|
||||
* @final
|
||||
* @category Components
|
||||
*
|
||||
* @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+
|
||||
*/
|
||||
class PartitionDefinition extends Component
|
||||
{
|
||||
@@ -32,44 +29,44 @@ class PartitionDefinition extends Component
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $OPTIONS = [
|
||||
'STORAGE ENGINE' => [
|
||||
public static $OPTIONS = array(
|
||||
'STORAGE ENGINE' => array(
|
||||
1,
|
||||
'var',
|
||||
],
|
||||
'ENGINE' => [
|
||||
),
|
||||
'ENGINE' => array(
|
||||
1,
|
||||
'var',
|
||||
],
|
||||
'COMMENT' => [
|
||||
),
|
||||
'COMMENT' => array(
|
||||
2,
|
||||
'var',
|
||||
],
|
||||
'DATA DIRECTORY' => [
|
||||
),
|
||||
'DATA DIRECTORY' => array(
|
||||
3,
|
||||
'var',
|
||||
],
|
||||
'INDEX DIRECTORY' => [
|
||||
),
|
||||
'INDEX DIRECTORY' => array(
|
||||
4,
|
||||
'var',
|
||||
],
|
||||
'MAX_ROWS' => [
|
||||
),
|
||||
'MAX_ROWS' => array(
|
||||
5,
|
||||
'var',
|
||||
],
|
||||
'MIN_ROWS' => [
|
||||
),
|
||||
'MIN_ROWS' => array(
|
||||
6,
|
||||
'var',
|
||||
],
|
||||
'TABLESPACE' => [
|
||||
),
|
||||
'TABLESPACE' => array(
|
||||
7,
|
||||
'var',
|
||||
],
|
||||
'NODEGROUP' => [
|
||||
),
|
||||
'NODEGROUP' => array(
|
||||
8,
|
||||
'var',
|
||||
],
|
||||
];
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Whether this entry is a subpartition or a partition.
|
||||
@@ -120,9 +117,9 @@ class PartitionDefinition extends Component
|
||||
*
|
||||
* @return PartitionDefinition
|
||||
*/
|
||||
public static function parse(Parser $parser, TokensList $list, array $options = [])
|
||||
public static function parse(Parser $parser, TokensList $list, array $options = array())
|
||||
{
|
||||
$ret = new static();
|
||||
$ret = new self();
|
||||
|
||||
/**
|
||||
* The state of the parser.
|
||||
@@ -178,10 +175,8 @@ class PartitionDefinition extends Component
|
||||
if ($nextToken->type !== Token::TYPE_NONE) {
|
||||
break;
|
||||
}
|
||||
|
||||
$ret->name .= $nextToken->value;
|
||||
}
|
||||
|
||||
$idx = $list->idx--;
|
||||
// Get the first token after the white space.
|
||||
$nextToken = $list->tokens[++$idx];
|
||||
@@ -201,13 +196,12 @@ class PartitionDefinition extends Component
|
||||
$ret->expr = Expression::parse(
|
||||
$parser,
|
||||
$list,
|
||||
[
|
||||
array(
|
||||
'parenthesesDelimited' => true,
|
||||
'breakOnAlias' => true,
|
||||
]
|
||||
'breakOnAlias' => true
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$state = 5;
|
||||
} elseif ($state === 5) {
|
||||
$ret->options = OptionsArray::parse($parser, $list, static::$OPTIONS);
|
||||
@@ -217,11 +211,12 @@ class PartitionDefinition extends Component
|
||||
$ret->subpartitions = ArrayObj::parse(
|
||||
$parser,
|
||||
$list,
|
||||
['type' => 'PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition']
|
||||
array(
|
||||
'type' => 'PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition'
|
||||
)
|
||||
);
|
||||
++$list->idx;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -237,7 +232,7 @@ class PartitionDefinition extends Component
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function build($component, array $options = [])
|
||||
public static function build($component, array $options = array())
|
||||
{
|
||||
if (is_array($component)) {
|
||||
return "(\n" . implode(",\n", $component) . "\n)";
|
||||
@@ -252,8 +247,7 @@ class PartitionDefinition extends Component
|
||||
return trim(
|
||||
'PARTITION ' . $component->name
|
||||
. (empty($component->type) ? '' : ' VALUES ' . $component->type . ' ' . $component->expr . ' ')
|
||||
. (! empty($component->options) && ! empty($component->type) ? '' : ' ')
|
||||
. $component->options . $subpartitions
|
||||
. ((! empty($component->options) && ! empty($component->type)) ? '' : ' ') . $component->options . $subpartitions
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user