Merge remote-tracking branch 'origin/master'

This commit is contained in:
Michal Čihař 2011-07-06 18:19:25 +02:00
commit c8b2cf6bf3
8 changed files with 356 additions and 471 deletions

View File

@ -2392,23 +2392,6 @@ setfacl -d -m "g:www-data:rwx" tmp
<code>first_timestamp</code>, which is used for first timestamp column
in table.</dd>
<dt id="cfg_NumOperators">$cfg['NumOperators'] array</dt>
<dd>Operators available for search operations on numeric and date columns.
</dd>
<dt id="cfg_TextOperators">$cfg['TextOperators'] array</dt>
<dd>Operators available for search operations on character columns.
Note that we put <code>LIKE</code> by default instead of
<code>LIKE %...%</code>, to avoid unintended performance problems
in case of huge tables.</dd>
<dt id="cfg_EnumOperators">$cfg['EnumOperators'] array</dt>
<dd>Operators available for search operations on ENUM columns.</dd>
<dt id="cfg_NullOperators">$cfg['NullOperators'] array</dt>
<dd>Additional operators available for search operations when the
column can be null.</dd>
</dl>
<!-- TRANSFORMATIONS -->

View File

@ -13,6 +13,7 @@ require_once './libraries/common.inc.php';
require_once './libraries/common.lib.php';
require_once './libraries/db_routines.lib.php';
require_once './libraries/mysql_charsets.lib.php';
require_once './libraries/data_mysql.inc.php';
/**
* Include JavaScript libraries

View File

@ -2872,7 +2872,7 @@ function PMA_getSupportedDatatypes($html = false, $selected = '')
foreach ($cfg['ColumnTypes'] as $key => $value) {
if (is_array($value)) {
$retval .= "<optgroup label='" . htmlspecialchars($key) . "'>";
foreach ($value as $subkey => $subvalue) {
foreach ($value as $subvalue) {
if ($subvalue == $selected) {
$retval .= "<option selected='selected'>";
$retval .= $subvalue;
@ -2896,9 +2896,9 @@ function PMA_getSupportedDatatypes($html = false, $selected = '')
}
} else {
$retval = array();
foreach ($cfg['ColumnTypes'] as $key => $value) {
foreach ($cfg['ColumnTypes'] as $value) {
if (is_array($value)) {
foreach ($value as $subkey => $subvalue) {
foreach ($value as $subvalue) {
if ($subvalue !== '-') {
$retval[] = $subvalue;
}

View File

@ -2740,379 +2740,50 @@ $cfg['DBG']['sql'] = false;
*/
/**
* Column types;
* VARCHAR, TINYINT, TEXT and DATE are listed first, based on estimated popularity
* Column types
*
* Fill in this array to overwrite data from data_*.inc.php files
*
* @global array $cfg['ColumnTypes']
*/
$cfg['ColumnTypes'] = array(
// most used
'INT',
'VARCHAR',
'TEXT',
'DATE',
// numeric
'NUMERIC' => array(
'TINYINT',
'SMALLINT',
'MEDIUMINT',
'INT',
'BIGINT',
'-',
'DECIMAL',
'FLOAT',
'DOUBLE',
'REAL',
'-',
'BIT',
'BOOLEAN',
'SERIAL',
),
// Date/Time
'DATE and TIME' => array(
'DATE',
'DATETIME',
'TIMESTAMP',
'TIME',
'YEAR',
),
// Text
'STRING' => array(
'CHAR',
'VARCHAR',
'-',
'TINYTEXT',
'TEXT',
'MEDIUMTEXT',
'LONGTEXT',
'-',
'BINARY',
'VARBINARY',
'-',
'TINYBLOB',
'MEDIUMBLOB',
'BLOB',
'LONGBLOB',
'-',
'ENUM',
'SET',
),
'SPATIAL' => array(
'GEOMETRY',
'POINT',
'LINESTRING',
'POLYGON',
'MULTIPOINT',
'MULTILINESTRING',
'MULTIPOLYGON',
'GEOMETRYCOLLECTION',
),
);
$cfg['ColumnTypes'] = array();
/**
* Attributes
*
* Fill in this array to overwrite data from data_*.inc.php files
*
* @global array $cfg['AttributeTypes']
*/
$cfg['AttributeTypes'] = array(
'',
'BINARY',
'UNSIGNED',
'UNSIGNED ZEROFILL',
'on update CURRENT_TIMESTAMP',
);
$cfg['AttributeTypes'] = array();
if ($cfg['ShowFunctionFields']) {
/**
* Available functions
*
* Fill in this array to overwrite data from data_*.inc.php files
*
* @global array $cfg['Functions']
*/
$cfg['Functions'] = array(
'ABS',
'ACOS',
'ASCII',
'ASIN',
'ATAN',
'BIN',
'BIT_COUNT',
'BIT_LENGTH',
'CEILING',
'CHAR',
'CHAR_LENGTH',
'COMPRESS',
'CONNECTION_ID',
'COS',
'COT',
'CRC32',
'CURDATE',
'CURRENT_USER',
'CURTIME',
'DATABASE',
'DATE',
'DAYNAME',
'DAYOFMONTH',
'DAYOFWEEK',
'DAYOFYEAR',
'DEGREES',
'DES_DECRYPT',
'DES_ENCRYPT',
'ENCRYPT',
'EXP',
'FLOOR',
'FROM_DAYS',
'FROM_UNIXTIME',
'HEX',
'HOUR',
'INET_ATON',
'INET_NTOA',
'LAST_DAY',
'LENGTH',
'LN',
'LOAD_FILE',
'LOG',
'LOG10',
'LOG2',
'LOWER',
'LTRIM',
'MD5',
'MICROSECOND',
'MINUTE',
'MONTH',
'MONTHNAME',
'NOW',
'OCT',
'OLD_PASSWORD',
'ORD',
'PASSWORD',
'PI',
'QUARTER',
'QUOTE',
'RADIANS',
'RAND',
'REVERSE',
'ROUND',
'RTRIM',
'SECOND',
'SEC_TO_TIME',
'SHA1',
'SIGN',
'SIN',
'SOUNDEX',
'SPACE',
'SQRT',
'SYSDATE',
'TAN',
'TIME',
'TIMESTAMP',
'TIME_TO_SEC',
'TO_DAYS',
'TRIM',
'UNCOMPRESS',
'UNCOMPRESSED_LENGTH',
'UNHEX',
'UNIX_TIMESTAMP',
'UPPER',
'USER',
'UTC_DATE',
'UTC_TIME',
'UTC_TIMESTAMP',
'UUID',
'VERSION',
'WEEK',
'WEEKDAY',
'WEEKOFYEAR',
'YEAR',
'YEARWEEK',
);
$cfg['Functions'] = array();
/**
* Which column types will be mapped to which Group?
*
* Fill in this array to overwrite data from data_*.inc.php files
*
* @global array $cfg['RestrictColumnTypes']
*/
$cfg['RestrictColumnTypes'] = array(
'TINYINT' => 'FUNC_NUMBER',
'SMALLINT' => 'FUNC_NUMBER',
'MEDIUMINT' => 'FUNC_NUMBER',
'INT' => 'FUNC_NUMBER',
'BIGINT' => 'FUNC_NUMBER',
'DECIMAL' => 'FUNC_NUMBER',
'FLOAT' => 'FUNC_NUMBER',
'DOUBLE' => 'FUNC_NUMBER',
'REAL' => 'FUNC_NUMBER',
'BIT' => 'FUNC_NUMBER',
'BOOLEAN' => 'FUNC_NUMBER',
'SERIAL' => 'FUNC_NUMBER',
'DATE' => 'FUNC_DATE',
'DATETIME' => 'FUNC_DATE',
'TIMESTAMP' => 'FUNC_DATE',
'TIME' => 'FUNC_DATE',
'YEAR' => 'FUNC_DATE',
'CHAR' => 'FUNC_CHAR',
'VARCHAR' => 'FUNC_CHAR',
'TINYTEXT' => 'FUNC_CHAR',
'TEXT' => 'FUNC_CHAR',
'MEDIUMTEXT' => 'FUNC_CHAR',
'LONGTEXT' => 'FUNC_CHAR',
'BINARY' => 'FUNC_CHAR',
'VARBINARY' => 'FUNC_CHAR',
'TINYBLOB' => 'FUNC_CHAR',
'MEDIUMBLOB' => 'FUNC_CHAR',
'BLOB' => 'FUNC_CHAR',
'LONGBLOB' => 'FUNC_CHAR',
'ENUM' => '',
'SET' => '',
'GEOMETRY' => 'FUNC_SPATIAL',
'POINT' => 'FUNC_SPATIAL',
'LINESTRING' => 'FUNC_SPATIAL',
'POLYGON' => 'FUNC_SPATIAL',
'MULTIPOINT' => 'FUNC_SPATIAL',
'MULTILINESTRING' => 'FUNC_SPATIAL',
'MULTIPOLYGON' => 'FUNC_SPATIAL',
'GEOMETRYCOLLECTION' => 'FUNC_SPATIAL',
);
$cfg['RestrictColumnTypes'] = array();
/**
* Map above defined groups to any function
*
* Fill in this array to overwrite data from data_*.inc.php files
*
* @global array $cfg['RestrictFunctions']
*/
$cfg['RestrictFunctions'] = array(
'FUNC_CHAR' => array(
'BIN',
'CHAR',
'CURRENT_USER',
'COMPRESS',
'DATABASE',
'DAYNAME',
'DES_DECRYPT',
'DES_ENCRYPT',
'ENCRYPT',
'HEX',
'INET_NTOA',
'LOAD_FILE',
'LOWER',
'LTRIM',
'MD5',
'MONTHNAME',
'OLD_PASSWORD',
'PASSWORD',
'QUOTE',
'REVERSE',
'RTRIM',
'SHA1',
'SOUNDEX',
'SPACE',
'TRIM',
'UNCOMPRESS',
'UNHEX',
'UPPER',
'USER',
'UUID',
),
'FUNC_DATE' => array(
'CURDATE',
'CURTIME',
'DATE',
'FROM_DAYS',
'FROM_UNIXTIME',
'LAST_DAY',
'NOW',
'SEC_TO_TIME',
'SYSDATE',
'TIME',
'TIMESTAMP',
'UTC_DATE',
'UTC_TIME',
'UTC_TIMESTAMP',
'YEAR',
),
'FUNC_NUMBER' => array(
'ABS',
'ACOS',
'ASCII',
'ASIN',
'ATAN',
'BIT_LENGTH',
'BIT_COUNT',
'CEILING',
'CHAR_LENGTH',
'CONNECTION_ID',
'COS',
'COT',
'CRC32',
'DAYOFMONTH',
'DAYOFWEEK',
'DAYOFYEAR',
'DEGREES',
'EXP',
'FLOOR',
'HOUR',
'INET_ATON',
'LENGTH',
'LN',
'LOG',
'LOG2',
'LOG10',
'MICROSECOND',
'MINUTE',
'MONTH',
'OCT',
'ORD',
'PI',
'QUARTER',
'RADIANS',
'RAND',
'ROUND',
'SECOND',
'SIGN',
'SIN',
'SQRT',
'TAN',
'TO_DAYS',
'TIME_TO_SEC',
'UNCOMPRESSED_LENGTH',
'UNIX_TIMESTAMP',
'WEEK',
'WEEKDAY',
'WEEKOFYEAR',
'YEARWEEK',
),
'FUNC_SPATIAL' => array(
'GeomFromText',
'GeomFromWKB',
'GeomCollFromText',
'LineFromText',
'MLineFromText',
'PointFromText',
'MPointFromText',
'PolyFromText',
'MPolyFromText',
'GeomCollFromWKB',
'LineFromWKB',
'MLineFromWKB',
'PointFromWKB',
'MPointFromWKB',
'PolyFromWKB',
'MPolyFromWKB',
),
);
$cfg['RestrictFunctions'] = array();
/**
* Default functions for above defined groups
@ -3126,90 +2797,6 @@ if ($cfg['ShowFunctionFields']) {
'first_timestamp' => 'NOW',
'pk_char36' => 'UUID',
);
} // end if
/**
* Search operators
*
* @global array $cfg['NumOperators']
*/
$cfg['NumOperators'] = array(
'=',
'>',
'>=',
'<',
'<=',
'!=',
'LIKE',
'NOT LIKE',
'IN (...)',
'NOT IN (...)',
'BETWEEN',
'NOT BETWEEN',
);
/**
* Search operators
*
* @global array $cfg['TextOperators']
*/
$cfg['TextOperators'] = array(
'LIKE',
'LIKE %...%',
'NOT LIKE',
'=',
'!=',
'REGEXP',
'REGEXP ^...$',
'NOT REGEXP',
"= ''",
"!= ''",
'IN (...)',
'NOT IN (...)',
'BETWEEN',
'NOT BETWEEN',
);
/**
* Search operators
*
* @global array $cfg['EnumOperators']
*/
$cfg['EnumOperators'] = array(
'=',
'!=',
);
/**
* Search operators
*
* @global array $cfg['SetOperators']
*/
$cfg['SetOperators'] = array(
'IN',
'NOT IN',
);
/**
* Search operators
*
* @global array $cfg['NullOperators']
*/
$cfg['NullOperators'] = array(
'IS NULL',
'IS NOT NULL',
);
/**
* Search operators
*
* @global array $cfg['UnaryOperators']
*/
$cfg['UnaryOperators'] = array(
'IS NULL' => 1,
'IS NOT NULL' => 1,
"= ''" => 1,
"!= ''" => 1
);
}
?>

View File

@ -0,0 +1,276 @@
<?php
/**
* Column types and functions supported by MySQL
*
* @package phpMyAdmin
*/
// VARCHAR, TINYINT, TEXT and DATE are listed first, based on estimated popularity
$cfg['ColumnTypes'] = !empty($cfg['ColumnTypes']) ? $cfg['ColumnTypes'] : array(
// most used
'INT',
'VARCHAR',
'TEXT',
'DATE',
// numeric
'NUMERIC' => array(
'TINYINT',
'SMALLINT',
'MEDIUMINT',
'INT',
'BIGINT',
'-',
'DECIMAL',
'FLOAT',
'DOUBLE',
'REAL',
'-',
'BIT',
'BOOLEAN',
'SERIAL',
),
// Date/Time
'DATE and TIME' => array(
'DATE',
'DATETIME',
'TIMESTAMP',
'TIME',
'YEAR',
),
// Text
'STRING' => array(
'CHAR',
'VARCHAR',
'-',
'TINYTEXT',
'TEXT',
'MEDIUMTEXT',
'LONGTEXT',
'-',
'BINARY',
'VARBINARY',
'-',
'TINYBLOB',
'MEDIUMBLOB',
'BLOB',
'LONGBLOB',
'-',
'ENUM',
'SET',
),
'SPATIAL' => array(
'GEOMETRY',
'POINT',
'LINESTRING',
'POLYGON',
'MULTIPOINT',
'MULTILINESTRING',
'MULTIPOLYGON',
'GEOMETRYCOLLECTION',
),
);
$cfg['AttributeTypes'] = !empty($cfg['AttributeTypes']) ? $cfg['AttributeTypes'] : array(
'',
'BINARY',
'UNSIGNED',
'UNSIGNED ZEROFILL',
'on update CURRENT_TIMESTAMP',
);
if ($cfg['ShowFunctionFields']) {
$cfg['RestrictColumnTypes'] = !empty($cfg['RestrictColumnTypes']) ? $cfg['RestrictColumnTypes'] : array(
'TINYINT' => 'FUNC_NUMBER',
'SMALLINT' => 'FUNC_NUMBER',
'MEDIUMINT' => 'FUNC_NUMBER',
'INT' => 'FUNC_NUMBER',
'BIGINT' => 'FUNC_NUMBER',
'DECIMAL' => 'FUNC_NUMBER',
'FLOAT' => 'FUNC_NUMBER',
'DOUBLE' => 'FUNC_NUMBER',
'REAL' => 'FUNC_NUMBER',
'BIT' => 'FUNC_NUMBER',
'BOOLEAN' => 'FUNC_NUMBER',
'SERIAL' => 'FUNC_NUMBER',
'DATE' => 'FUNC_DATE',
'DATETIME' => 'FUNC_DATE',
'TIMESTAMP' => 'FUNC_DATE',
'TIME' => 'FUNC_DATE',
'YEAR' => 'FUNC_DATE',
'CHAR' => 'FUNC_CHAR',
'VARCHAR' => 'FUNC_CHAR',
'TINYTEXT' => 'FUNC_CHAR',
'TEXT' => 'FUNC_CHAR',
'MEDIUMTEXT' => 'FUNC_CHAR',
'LONGTEXT' => 'FUNC_CHAR',
'BINARY' => 'FUNC_CHAR',
'VARBINARY' => 'FUNC_CHAR',
'TINYBLOB' => 'FUNC_CHAR',
'MEDIUMBLOB' => 'FUNC_CHAR',
'BLOB' => 'FUNC_CHAR',
'LONGBLOB' => 'FUNC_CHAR',
'ENUM' => '',
'SET' => '',
'GEOMETRY' => 'FUNC_SPATIAL',
'POINT' => 'FUNC_SPATIAL',
'LINESTRING' => 'FUNC_SPATIAL',
'POLYGON' => 'FUNC_SPATIAL',
'MULTIPOINT' => 'FUNC_SPATIAL',
'MULTILINESTRING' => 'FUNC_SPATIAL',
'MULTIPOLYGON' => 'FUNC_SPATIAL',
'GEOMETRYCOLLECTION' => 'FUNC_SPATIAL',
);
$restrict_functions = array(
'FUNC_CHAR' => array(
'BIN',
'CHAR',
'CURRENT_USER',
'COMPRESS',
'DATABASE',
'DAYNAME',
'DES_DECRYPT',
'DES_ENCRYPT',
'ENCRYPT',
'HEX',
'INET_NTOA',
'LOAD_FILE',
'LOWER',
'LTRIM',
'MD5',
'MONTHNAME',
'OLD_PASSWORD',
'PASSWORD',
'QUOTE',
'REVERSE',
'RTRIM',
'SHA1',
'SOUNDEX',
'SPACE',
'TRIM',
'UNCOMPRESS',
'UNHEX',
'UPPER',
'USER',
'UUID',
'VERSION',
),
'FUNC_DATE' => array(
'CURDATE',
'CURTIME',
'DATE',
'FROM_DAYS',
'FROM_UNIXTIME',
'LAST_DAY',
'NOW',
'SEC_TO_TIME',
'SYSDATE',
'TIME',
'TIMESTAMP',
'UTC_DATE',
'UTC_TIME',
'UTC_TIMESTAMP',
'YEAR',
),
'FUNC_NUMBER' => array(
'ABS',
'ACOS',
'ASCII',
'ASIN',
'ATAN',
'BIT_LENGTH',
'BIT_COUNT',
'CEILING',
'CHAR_LENGTH',
'CONNECTION_ID',
'COS',
'COT',
'CRC32',
'DAYOFMONTH',
'DAYOFWEEK',
'DAYOFYEAR',
'DEGREES',
'EXP',
'FLOOR',
'HOUR',
'INET_ATON',
'LENGTH',
'LN',
'LOG',
'LOG2',
'LOG10',
'MICROSECOND',
'MINUTE',
'MONTH',
'OCT',
'ORD',
'PI',
'QUARTER',
'RADIANS',
'RAND',
'ROUND',
'SECOND',
'SIGN',
'SIN',
'SQRT',
'TAN',
'TO_DAYS',
'TIME_TO_SEC',
'UNCOMPRESSED_LENGTH',
'UNIX_TIMESTAMP',
'WEEK',
'WEEKDAY',
'WEEKOFYEAR',
'YEARWEEK',
),
'FUNC_SPATIAL' => array(
'GeomFromText',
'GeomFromWKB',
'GeomCollFromText',
'LineFromText',
'MLineFromText',
'PointFromText',
'MPointFromText',
'PolyFromText',
'MPolyFromText',
'GeomCollFromWKB',
'LineFromWKB',
'MLineFromWKB',
'PointFromWKB',
'MPointFromWKB',
'PolyFromWKB',
'MPolyFromWKB',
),
);
if (empty($cfg['RestrictFunctions'])) {
$cfg['RestrictFunctions'] = $restrict_functions;
}
if (empty($cfg['Functions'])) {
// build a list of functions based on $restrict_functions
$cfg['Functions'] = array();
foreach ($restrict_functions as $cat => $functions) {
if ($cat != 'FUNC_SPATIAL') {
$cfg['Functions'] = array_merge($cfg['Functions'], $functions);
}
}
sort($cfg['Functions']);
}
unset($restrict_functions);
} // end if
?>

View File

@ -27,6 +27,9 @@ require_once './libraries/StorageEngine.class.php';
*/
require_once './libraries/Partition.class.php';
// load additional configuration variables
require_once './libraries/data_mysql.inc.php';
if (is_int($cfg['DefaultPropDisplay'])) {
if ($num_fields <= $cfg['DefaultPropDisplay']) {
$display_type = 'vertical';

View File

@ -19,6 +19,9 @@ require_once './libraries/common.lib.php';
*/
require_once './libraries/db_table_exists.lib.php';
// load additional configuration variables
require_once './libraries/data_mysql.inc.php';
/**
* Sets global variables.
* Here it's better to use a if, instead of the '?' operator

View File

@ -129,31 +129,57 @@ if (! isset($param) || $param[0] == '') {
<td><?php echo $fields_collation[$i]; ?></td>
<td><select name="func[]">
<?php
// determine valid operators
if (strncasecmp($fields_type[$i], 'enum', 4) == 0) {
foreach ($GLOBALS['cfg']['EnumOperators'] as $fc) {
echo "\n" . ' '
. '<option value="' . htmlspecialchars($fc) . '">'
. htmlspecialchars($fc) . '</option>';
}
// enum operators
$operators = array(
'=',
'!=',
);
} elseif (preg_match('@char|blob|text|set@i', $fields_type[$i])) {
foreach ($GLOBALS['cfg']['TextOperators'] as $fc) {
echo "\n" . ' '
. '<option value="' . htmlspecialchars($fc) . '">'
. htmlspecialchars($fc) . '</option>';
}
// text operators
$operators = array(
'LIKE',
'LIKE %...%',
'NOT LIKE',
'=',
'!=',
'REGEXP',
'REGEXP ^...$',
'NOT REGEXP',
"= ''",
"!= ''",
'IN (...)',
'NOT IN (...)',
'BETWEEN',
'NOT BETWEEN',
);
} else {
foreach ($GLOBALS['cfg']['NumOperators'] as $fc) {
echo "\n" . ' '
. '<option value="' . htmlspecialchars($fc) . '">'
. htmlspecialchars($fc) . '</option>';
}
// numeric operators
$operators = array(
'=',
'>',
'>=',
'<',
'<=',
'!=',
'LIKE',
'NOT LIKE',
'IN (...)',
'NOT IN (...)',
'BETWEEN',
'NOT BETWEEN',
);
} // end if... else...
// if field can be NULL, add IS NULL and IS NOT NULL
if ($fields_null[$i]) {
foreach ($GLOBALS['cfg']['NullOperators'] as $fc) {
echo "\n" . ' '
. '<option value="' . htmlspecialchars($fc) . '">'
. htmlspecialchars($fc) . '</option>';
}
$operators[] = 'IS NULL';
$operators[] = 'IS NOT NULL';
}
foreach ($operators as $op) {
echo "\n" . ' '
. '<option value="' . htmlspecialchars($op) . '">' . htmlspecialchars($op) . '</option>';
}
?>
@ -327,11 +353,17 @@ else {
$sql_query .= ' WHERE ' . $where;
} else {
$w = $charsets = array();
$unary_operators = array(
'IS NULL' => 1,
'IS NOT NULL' => 1,
"= ''" => 1,
"!= ''" => 1
);
$cnt_func = count($func);
reset($func);
while (list($i, $func_type) = each($func)) {
list($charsets[$i]) = explode('_', $collations[$i]);
if (isset($GLOBALS['cfg']['UnaryOperators'][$func_type]) && $GLOBALS['cfg']['UnaryOperators'][$func_type] == 1) {
if (isset($unary_operators[$func_type])) {
$fields[$i] = '';
$w[] = PMA_backquote($names[$i]) . ' ' . $func_type;