2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * SQL data types definition
8 namespace PMA\libraries
;
11 * Class holding type definitions for MySQL.
15 class TypesMySQL
extends Types
18 * Returns the data type description.
20 * @param string $type The data type to get a description.
25 public function getTypeDescription($type)
27 $type = mb_strtoupper($type);
31 'A 1-byte integer, signed range is -128 to 127, unsigned range is ' .
36 'A 2-byte integer, signed range is -32,768 to 32,767, unsigned ' .
37 'range is 0 to 65,535'
41 'A 3-byte integer, signed range is -8,388,608 to 8,388,607, ' .
42 'unsigned range is 0 to 16,777,215'
46 'A 4-byte integer, signed range is ' .
47 '-2,147,483,648 to 2,147,483,647, unsigned range is 0 to ' .
52 'An 8-byte integer, signed range is -9,223,372,036,854,775,808 ' .
53 'to 9,223,372,036,854,775,807, unsigned range is 0 to ' .
54 '18,446,744,073,709,551,615'
58 'A fixed-point number (M, D) - the maximum number of digits (M) ' .
59 'is 65 (default 10), the maximum number of decimals (D) is 30 ' .
64 'A small floating-point number, allowable values are ' .
65 '-3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38 to ' .
70 'A double-precision floating-point number, allowable values are ' .
71 '-1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and ' .
72 '2.2250738585072014E-308 to 1.7976931348623157E+308'
76 'Synonym for DOUBLE (exception: in REAL_AS_FLOAT SQL mode it is ' .
77 'a synonym for FLOAT)'
81 'A bit-field type (M), storing M of bits per value (default is 1, ' .
86 'A synonym for TINYINT(1), a value of zero is considered false, ' .
87 'nonzero values are considered true'
90 return __('An alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE');
93 __('A date, supported range is %1$s to %2$s'), '1000-01-01',
98 __('A date and time combination, supported range is %1$s to %2$s'),
99 '1000-01-01 00:00:00', '9999-12-31 23:59:59'
103 'A timestamp, range is 1970-01-01 00:00:01 UTC to 2038-01-09 ' .
104 '03:14:07 UTC, stored as the number of seconds since the epoch ' .
105 '(1970-01-01 00:00:00 UTC)'
109 __('A time, range is %1$s to %2$s'), '-838:59:59', '838:59:59'
113 "A year in four-digit (4, default) or two-digit (2) format, the " .
114 "allowable values are 70 (1970) to 69 (2069) or 1901 to 2155 and " .
119 'A fixed-length (0-255, default 1) string that is always ' .
120 'right-padded with spaces to the specified length when stored'
125 'A variable-length (%s) string, the effective maximum length ' .
126 'is subject to the maximum row size'
131 'A TEXT column with a maximum length of 255 (2^8 - 1) characters, ' .
132 'stored with a one-byte prefix indicating the length of the value ' .
137 'A TEXT column with a maximum length of 65,535 (2^16 - 1) ' .
138 'characters, stored with a two-byte prefix indicating the length ' .
139 'of the value in bytes'
143 'A TEXT column with a maximum length of 16,777,215 (2^24 - 1) ' .
144 'characters, stored with a three-byte prefix indicating the ' .
145 'length of the value in bytes'
149 'A TEXT column with a maximum length of 4,294,967,295 or 4GiB ' .
150 '(2^32 - 1) characters, stored with a four-byte prefix indicating ' .
151 'the length of the value in bytes'
155 'Similar to the CHAR type, but stores binary byte strings rather ' .
156 'than non-binary character strings'
160 'Similar to the VARCHAR type, but stores binary byte strings ' .
161 'rather than non-binary character strings'
165 'A BLOB column with a maximum length of 255 (2^8 - 1) bytes, ' .
166 'stored with a one-byte prefix indicating the length of the value'
170 'A BLOB column with a maximum length of 16,777,215 (2^24 - 1) ' .
171 'bytes, stored with a three-byte prefix indicating the length of ' .
176 'A BLOB column with a maximum length of 65,535 (2^16 - 1) bytes, ' .
177 'stored with a two-byte prefix indicating the length of the value'
181 'A BLOB column with a maximum length of 4,294,967,295 or 4GiB ' .
182 '(2^32 - 1) bytes, stored with a four-byte prefix indicating the ' .
183 'length of the value'
187 "An enumeration, chosen from the list of up to 65,535 values or " .
188 "the special '' error value"
191 return __("A single value chosen from a set of up to 64 members");
193 return __('A type that can store a geometry of any type');
195 return __('A point in 2-dimensional space');
197 return __('A curve with linear interpolation between points');
199 return __('A polygon');
201 return __('A collection of points');
202 case 'MULTILINESTRING':
204 'A collection of curves with linear interpolation between points'
207 return __('A collection of polygons');
208 case 'GEOMETRYCOLLECTION':
209 return __('A collection of geometry objects of any type');
212 'Stores and enables efficient access to data in JSON'
213 . ' (JavaScript Object Notation) documents'
220 * Returns class of a type, used for functions available for type
223 * @param string $type The data type to get a class.
228 public function getTypeClass($type)
230 $type = mb_strtoupper($type);
274 case 'MULTILINESTRING':
276 case 'GEOMETRYCOLLECTION':
287 * Returns array of functions available for a class.
289 * @param string $class The class to get function list.
294 public function getFunctionsClass($class)
335 if ((PMA_MARIADB
&& PMA_MYSQL_INT_VERSION
< 100012)
336 || PMA_MYSQL_INT_VERSION
< 50603
338 $ret = array_diff($ret, array('INET6_NTOA'));
408 'UNCOMPRESSED_LENGTH',
416 if ((PMA_MARIADB
&& PMA_MYSQL_INT_VERSION
< 100012)
417 || PMA_MYSQL_INT_VERSION
< 50603
419 $ret = array_diff($ret, array('INET6_ATON'));
450 * Returns array of all attributes available.
455 public function getAttributes()
462 'on update CURRENT_TIMESTAMP',
467 * Returns array of all column types available.
469 * VARCHAR, TINYINT, TEXT and DATE are listed first, based on
470 * estimated popularity.
475 public function getColumns()
477 $ret = parent
::getColumns();
479 $ret[_pgettext('numeric types', 'Numeric')] = array(
497 $ret[_pgettext('date and time types', 'Date and time')] = array(
506 $ret[_pgettext('string types', 'String')] = array(
527 $ret[_pgettext('spatial types', 'Spatial')] = array(
535 'GEOMETRYCOLLECTION',
538 if (PMA_MYSQL_INT_VERSION
>= 50708
539 && \PMA\libraries\Util
::getServerType() != 'MariaDB'
541 $ret['JSON'] = array(
550 * Returns an array of integer types
552 * @return string[] integer types
554 public function getIntegerTypes()
556 return array('tinyint', 'smallint', 'mediumint', 'int', 'bigint');
560 * Returns the min and max values of a given integer type
562 * @param string $type integer type
563 * @param boolean $signed whether signed
565 * @return string[] min and max values
567 public function getIntegerRange($type, $signed = true)
569 static $min_max_data = array(
571 'tinyint' => array('0', '255'),
572 'smallint' => array('0', '65535'),
573 'mediumint' => array('0', '16777215'),
574 'int' => array('0', '4294967295'),
575 'bigint' => array('0', '18446744073709551615')
578 'tinyint' => array('-128', '127'),
579 'smallint' => array('-32768', '32767'),
580 'mediumint' => array('-8388608', '8388607'),
581 'int' => array('-2147483648', '2147483647'),
582 'bigint' => array('-9223372036854775808', '9223372036854775807')
585 $relevantArray = $signed
586 ?
$min_max_data['signed']
587 : $min_max_data['unsigned'];
588 return isset($relevantArray[$type]) ?
$relevantArray[$type] : array('', '');