Fix MariaDB 10.2 current_timestamp()
Fixes #13968 and fixes #13999. Closes #14177. Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
This commit is contained in:
parent
efb51ae3f3
commit
de250fbae3
@ -13,6 +13,7 @@ phpMyAdmin - ChangeLog
|
||||
- issue #14239 Line and some other charts ignore result set order of values chosen for the x-axis
|
||||
- issue #14260 Fixed configuration for DefaultLang and Lang
|
||||
- issue #14264 Linking for 'Distinct values' broken
|
||||
- issue #13968 Fix MariaDB 10.2 current_timestamp()
|
||||
|
||||
4.8.0.1 (2018-04-19)
|
||||
- issue [security] Multiple CSRF vulnerabilities, See PMASA-2018-02
|
||||
|
||||
@ -3291,7 +3291,7 @@ function autoPopulate (input_id, offset) {
|
||||
}
|
||||
var col_default = central_column_list[db + '_' + table][offset].col_default.toUpperCase();
|
||||
var $input4 = $('#' + input_id + '4');
|
||||
if (col_default !== '' && col_default !== 'NULL' && col_default !== 'CURRENT_TIMESTAMP') {
|
||||
if (col_default !== '' && col_default !== 'NULL' && col_default !== 'CURRENT_TIMESTAMP' && col_default !== 'CURRENT_TIMESTAMP()') {
|
||||
$input4.val('USER_DEFINED');
|
||||
$input4.next().next().show();
|
||||
$input4.next().next().val(central_column_list[db + '_' + table][offset].col_default);
|
||||
|
||||
@ -347,7 +347,7 @@ AJAX.registerOnload('tbl_change.js', function () {
|
||||
} else if (theType === 'datetime' || theType === 'timestamp') {
|
||||
var tmstmp = false;
|
||||
dt_value = dt_value.trim();
|
||||
if (dt_value === 'CURRENT_TIMESTAMP') {
|
||||
if (dt_value === 'CURRENT_TIMESTAMP' || dt_value === 'current_timestamp()') {
|
||||
return true;
|
||||
}
|
||||
if (theType === 'timestamp') {
|
||||
|
||||
@ -514,7 +514,8 @@ class CentralColumns
|
||||
|
||||
$query .= ' ' . $column['col_extra'];
|
||||
if ($column['col_default']) {
|
||||
if ($column['col_default'] != 'CURRENT_TIMESTAMP') {
|
||||
if ($column['col_default'] != 'CURRENT_TIMESTAMP'
|
||||
|| $column['col_default'] != 'current_timestamp()') {
|
||||
$query .= ' DEFAULT \'' . $this->dbi->escapeString(
|
||||
$column['col_default']
|
||||
) . '\'';
|
||||
@ -936,8 +937,10 @@ class CentralColumns
|
||||
$meta['DefaultType'] = 'NONE';
|
||||
} else {
|
||||
if ($row['col_default'] == 'CURRENT_TIMESTAMP'
|
||||
|| $row['col_default'] == 'NULL'
|
||||
|| $row['col_default'] == 'current_timestamp()'
|
||||
) {
|
||||
$meta['DefaultType'] = 'CURRENT_TIMESTAMP';
|
||||
} elseif ($row['col_default'] == 'NULL') {
|
||||
$meta['DefaultType'] = $row['col_default'];
|
||||
} else {
|
||||
$meta['DefaultType'] = 'USER_DEFINED';
|
||||
@ -1083,8 +1086,10 @@ class CentralColumns
|
||||
$meta['DefaultType'] = 'NONE';
|
||||
} else {
|
||||
if ($row['col_default'] == 'CURRENT_TIMESTAMP'
|
||||
|| $row['col_default'] == 'NULL'
|
||||
|| $row['col_default'] == 'current_timestamp()'
|
||||
) {
|
||||
$meta['DefaultType'] = 'CURRENT_TIMESTAMP';
|
||||
} elseif ($row['col_default'] == 'NULL') {
|
||||
$meta['DefaultType'] = $row['col_default'];
|
||||
} else {
|
||||
$meta['DefaultType'] = 'USER_DEFINED';
|
||||
|
||||
@ -417,7 +417,8 @@ class TableStructureController extends TableController
|
||||
}
|
||||
$current_timestamp = ($data['Type'] == 'timestamp'
|
||||
|| $data['Type'] == 'datetime')
|
||||
&& $data['Default'] == 'CURRENT_TIMESTAMP';
|
||||
&& ($data['Default'] == 'CURRENT_TIMESTAMP'
|
||||
|| $data['Default'] == 'current_timestamp()');
|
||||
|
||||
if ($data['Null'] === 'YES' && $data['Default'] === null) {
|
||||
$default_type = 'NULL';
|
||||
|
||||
@ -2753,7 +2753,8 @@ class InsertEdit
|
||||
$current_value = "b'" . $this->dbi->escapeString($current_value)
|
||||
. "'";
|
||||
} elseif (! ($type == 'datetime' || $type == 'timestamp')
|
||||
|| $current_value != 'CURRENT_TIMESTAMP'
|
||||
|| ($current_value != 'CURRENT_TIMESTAMP'
|
||||
&& $current_value != 'current_timestamp()')
|
||||
) {
|
||||
$current_value = "'" . $this->dbi->escapeString($current_value)
|
||||
. "'";
|
||||
|
||||
@ -566,6 +566,7 @@ class Table
|
||||
}
|
||||
// else fall-through intended, no break here
|
||||
case 'CURRENT_TIMESTAMP' :
|
||||
case 'current_timestamp()':
|
||||
$query .= ' DEFAULT ' . $default_type;
|
||||
|
||||
if (strlen($length) !== 0
|
||||
|
||||
@ -1767,12 +1767,12 @@ class Util
|
||||
*/
|
||||
$tag_params_strings[] = 'data-post="' . (isset($parts[1]) ? $parts[1] : '') . '"';
|
||||
$url = $parts[0];
|
||||
if(array_key_exists('class', $tag_params)
|
||||
if(array_key_exists('class', $tag_params)
|
||||
&& strpos($tag_params['class'], 'create_view') !== false
|
||||
) {
|
||||
$url .= '?' . explode('&', $parts[1], 2)[0];
|
||||
$url .= '?' . explode('&', $parts[1], 2)[0];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
foreach ($tag_params as $par_name => $par_value) {
|
||||
@ -4025,7 +4025,8 @@ class Util
|
||||
*/
|
||||
public static function addMicroseconds($value)
|
||||
{
|
||||
if (empty($value) || $value == 'CURRENT_TIMESTAMP') {
|
||||
if (empty($value) || $value == 'CURRENT_TIMESTAMP'
|
||||
|| $value == 'current_timestamp()') {
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
@ -203,6 +203,7 @@ for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {
|
||||
break;
|
||||
case 'NULL':
|
||||
case 'CURRENT_TIMESTAMP':
|
||||
case 'current_timestamp()':
|
||||
$columnMeta['Default'] = $columnMeta['DefaultType'];
|
||||
break;
|
||||
}
|
||||
@ -256,6 +257,7 @@ for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {
|
||||
}
|
||||
break;
|
||||
case 'CURRENT_TIMESTAMP':
|
||||
case 'current_timestamp()':
|
||||
$columnMeta['DefaultType'] = 'CURRENT_TIMESTAMP';
|
||||
$columnMeta['DefaultValue'] = '';
|
||||
break;
|
||||
|
||||
@ -523,6 +523,19 @@ class TableTest extends PmaTestCase
|
||||
$query
|
||||
);
|
||||
|
||||
//$default_type is current_timestamp()
|
||||
$default_type = 'current_timestamp()';
|
||||
$query = Table::generateFieldSpec(
|
||||
$name, $type, $length, $attribute, $collation,
|
||||
$null, $default_type, $default_value, $extra, $comment,
|
||||
$virtuality, $expression, $move_to
|
||||
);
|
||||
$this->assertEquals(
|
||||
"`PMA_name` BOOLEAN PMA_attribute NULL DEFAULT current_timestamp() "
|
||||
. "AUTO_INCREMENT COMMENT 'PMA_comment' FIRST",
|
||||
$query
|
||||
);
|
||||
|
||||
// $type is 'TIMESTAMP(3), $default_type is CURRENT_TIMESTAMP(3)
|
||||
$type = 'TIMESTAMP';
|
||||
$length = '3';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user