Removed PMA_RTN_parseOneParameter().
Signed-off-by: Dan Ungureanu <udan1107@gmail.com>
This commit is contained in:
parent
02f6c7f4c0
commit
bf6e14393d
@ -79,82 +79,6 @@ function PMA_RTN_main($type)
|
||||
}
|
||||
} // end PMA_RTN_main()
|
||||
|
||||
/**
|
||||
* This function parses a string containing one parameter of a routine
|
||||
* and returns an array containing the information about this parameter.
|
||||
*
|
||||
* @param string $value A string containing one parameter of a routine
|
||||
*
|
||||
* @return array Parsed information about the input parameter
|
||||
*/
|
||||
function PMA_RTN_parseOneParameter($value)
|
||||
{
|
||||
global $param_directions;
|
||||
|
||||
$retval = array(0 => '',
|
||||
1 => '',
|
||||
2 => '',
|
||||
3 => '',
|
||||
4 => '');
|
||||
$parsed_param = PMA_SQP_parse($value);
|
||||
$pos = 0;
|
||||
if (in_array(
|
||||
/*overload*/mb_strtoupper($parsed_param[$pos]['data']),
|
||||
$param_directions
|
||||
)) {
|
||||
$retval[0] = /*overload*/mb_strtoupper($parsed_param[0]['data']);
|
||||
$pos++;
|
||||
}
|
||||
if ($parsed_param[$pos]['type'] == 'alpha_identifier'
|
||||
|| $parsed_param[$pos]['type'] == 'quote_backtick'
|
||||
) {
|
||||
$retval[1] = PMA_Util::unQuote(
|
||||
$parsed_param[$pos]['data']
|
||||
);
|
||||
$pos++;
|
||||
}
|
||||
$depth = 0;
|
||||
$param_length = '';
|
||||
$param_opts = array();
|
||||
for ($i = $pos; $i < $parsed_param['len']; $i++) {
|
||||
if (($parsed_param[$i]['type'] == 'alpha_columnType'
|
||||
|| $parsed_param[$i]['type'] == 'alpha_functionName') && $depth == 0
|
||||
) {
|
||||
$retval[2] = /*overload*/mb_strtoupper($parsed_param[$i]['data']);
|
||||
} else if ($parsed_param[$i]['type'] == 'punct_bracket_open_round'
|
||||
&& $depth == 0
|
||||
) {
|
||||
$depth = 1;
|
||||
} else if ($parsed_param[$i]['type'] == 'punct_bracket_close_round'
|
||||
&& $depth == 1
|
||||
) {
|
||||
$depth = 0;
|
||||
} else if ($depth == 1) {
|
||||
$param_length .= $parsed_param[$i]['data'];
|
||||
} else if ($parsed_param[$i]['type'] == 'alpha_reservedWord'
|
||||
&& /*overload*/mb_strtoupper($parsed_param[$i]['data']) == 'CHARSET'
|
||||
&& $depth == 0
|
||||
) {
|
||||
if ($parsed_param[$i+1]['type'] == 'alpha_charset'
|
||||
|| $parsed_param[$i+1]['type'] == 'alpha_identifier'
|
||||
) {
|
||||
$param_opts[] = /*overload*/mb_strtolower(
|
||||
$parsed_param[$i+1]['data']
|
||||
);
|
||||
}
|
||||
} else if ($parsed_param[$i]['type'] == 'alpha_columnAttrib'
|
||||
&& $depth == 0
|
||||
) {
|
||||
$param_opts[] = /*overload*/mb_strtoupper($parsed_param[$i]['data']);
|
||||
}
|
||||
}
|
||||
$retval[3] = $param_length;
|
||||
sort($param_opts);
|
||||
$retval[4] = implode(' ', $param_opts);
|
||||
|
||||
return $retval;
|
||||
} // end PMA_RTN_parseOneParameter()
|
||||
|
||||
/**
|
||||
* This function looks through the contents of a parsed
|
||||
* SHOW CREATE [PROCEDURE | FUNCTION] query and extracts
|
||||
|
||||
@ -62,57 +62,5 @@ class PMA_RTN_ParameterParser_Test extends PHPUnit_Framework_TestCase
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_RTN_parseOneParameter
|
||||
*
|
||||
* @param string $source Source
|
||||
* @param array $target Expected output
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @dataProvider paramProvider
|
||||
*/
|
||||
public function testParseOneParameter($source, $target)
|
||||
{
|
||||
PMA_RTN_setGlobals();
|
||||
$this->assertEquals($target, PMA_RTN_parseOneParameter($source));
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testParseOneParameter
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function paramProvider()
|
||||
{
|
||||
return array(
|
||||
array('`foo` TEXT', array('', 'foo', 'TEXT', '', '')),
|
||||
array('`foo` INT(20)', array('', 'foo', 'INT', '20', '')),
|
||||
array('DECIMAL(5,5)', array('', '', 'DECIMAL', '5,5', '')),
|
||||
array(
|
||||
'IN `fo``fo` INT UNSIGNED',
|
||||
array('IN', 'fo`fo', 'INT', '', 'UNSIGNED')
|
||||
),
|
||||
array(
|
||||
'OUT bar VARCHAR(1) CHARSET utf8',
|
||||
array('OUT', 'bar', 'VARCHAR', '1', 'utf8')
|
||||
),
|
||||
array(
|
||||
'`"baz\'\'` ENUM(\'a\', \'b\') CHARSET latin1',
|
||||
array('', '"baz\'\'', 'ENUM', '\'a\',\'b\'', 'latin1')
|
||||
),
|
||||
array(
|
||||
'INOUT `foo` DECIMAL(5,2) UNSIGNED ZEROFILL',
|
||||
array('INOUT', 'foo', 'DECIMAL', '5,2', 'UNSIGNED ZEROFILL')
|
||||
),
|
||||
array(
|
||||
'`foo``s func` SET(\'test\'\'esc"\', \'more\\\'esc\')',
|
||||
array(
|
||||
'', 'foo`s func', 'SET', '\'test\'\'esc"\',\'more\\\'esc\'', ''
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user