Clear display on session timeout even when unsaved changes are pending.
[openemr.git] / phpmyadmin / libraries / Types.class.php
blob87c28b9c09d9ae91832cdae127f1846551fadc9b
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * SQL data types definition
6 * @package PhpMyAdmin
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 /**
13 * Generic class holding type definitions.
15 * @package PhpMyAdmin
17 class PMA_Types
19 /**
20 * Returns list of unary operators.
22 * @return string[]
24 public function getUnaryOperators()
26 return array(
27 'IS NULL',
28 'IS NOT NULL',
29 "= ''",
30 "!= ''",
34 /**
35 * Check whether operator is unary.
37 * @param string $op operator name
39 * @return boolean
41 public function isUnaryOperator($op)
43 return in_array($op, $this->getUnaryOperators());
46 /**
47 * Returns list of operators checking for NULL.
49 * @return string[]
51 public function getNullOperators()
53 return array(
54 'IS NULL',
55 'IS NOT NULL',
59 /**
60 * ENUM search operators
62 * @return string[]
64 public function getEnumOperators()
66 return array(
67 '=',
68 '!=',
72 /**
73 * TEXT search operators
75 * @return string[]
77 public function getTextOperators()
79 return array(
80 'LIKE',
81 'LIKE %...%',
82 'NOT LIKE',
83 '=',
84 '!=',
85 'REGEXP',
86 'REGEXP ^...$',
87 'NOT REGEXP',
88 "= ''",
89 "!= ''",
90 'IN (...)',
91 'NOT IN (...)',
92 'BETWEEN',
93 'NOT BETWEEN',
97 /**
98 * Number search operators
100 * @return string[]
102 public function getNumberOperators()
104 return array(
105 '=',
106 '>',
107 '>=',
108 '<',
109 '<=',
110 '!=',
111 'LIKE',
112 'LIKE %...%',
113 'NOT LIKE',
114 'IN (...)',
115 'NOT IN (...)',
116 'BETWEEN',
117 'NOT BETWEEN',
122 * Returns operators for given type
124 * @param string $type Type of field
125 * @param boolean $null Whether field can be NULL
127 * @return string[]
129 public function getTypeOperators($type, $null)
131 $ret = array();
132 $class = $this->getTypeClass($type);
134 if (strncasecmp($type, 'enum', 4) == 0) {
135 $ret = array_merge($ret, $this->getEnumOperators());
136 } elseif ($class == 'CHAR') {
137 $ret = array_merge($ret, $this->getTextOperators());
138 } else {
139 $ret = array_merge($ret, $this->getNumberOperators());
142 if ($null) {
143 $ret = array_merge($ret, $this->getNullOperators());
146 return $ret;
150 * Returns operators for given type as html options
152 * @param string $type Type of field
153 * @param boolean $null Whether field can be NULL
154 * @param string $selectedOperator Option to be selected
156 * @return string Generated Html
158 public function getTypeOperatorsHtml($type, $null, $selectedOperator = null)
160 $html = '';
162 foreach ($this->getTypeOperators($type, $null) as $fc) {
163 if (isset($selectedOperator) && $selectedOperator == $fc) {
164 $selected = ' selected="selected"';
165 } else {
166 $selected = '';
168 $html .= '<option value="' . htmlspecialchars($fc) . '"'
169 . $selected . '>'
170 . htmlspecialchars($fc) . '</option>';
173 return $html;
177 * Returns the data type description.
179 * @param string $type The data type to get a description.
181 * @return string
184 public function getTypeDescription($type)
186 return '';
190 * Returns class of a type, used for functions available for type
191 * or default values.
193 * @param string $type The data type to get a class.
195 * @return string
198 public function getTypeClass($type)
200 return '';
204 * Returns array of functions available for a class.
206 * @param string $class The class to get function list.
208 * @return string[]
211 public function getFunctionsClass($class)
213 return array();
217 * Returns array of functions available for a type.
219 * @param string $type The data type to get function list.
221 * @return string[]
224 public function getFunctions($type)
226 $class = $this->getTypeClass($type);
227 return $this->getFunctionsClass($class);
231 * Returns array of all functions available.
233 * @return string[]
236 public function getAllFunctions()
238 $ret = array_merge(
239 $this->getFunctionsClass('CHAR'),
240 $this->getFunctionsClass('NUMBER'),
241 $this->getFunctionsClass('DATE'),
242 $this->getFunctionsClass('UUID')
244 sort($ret);
245 return $ret;
249 * Returns array of all attributes available.
251 * @return string[]
254 public function getAttributes()
256 return array();
260 * Returns array of all column types available.
262 * @return string[]
265 public function getColumns()
267 // most used types
268 return array(
269 'INT',
270 'VARCHAR',
271 'TEXT',
272 'DATE',
277 * Returns an array of integer types
279 * @return string[] integer types
281 public function getIntegerTypes()
283 return array();
287 * Returns the min and max values of a given integer type
289 * @param string $type integer type
290 * @param boolean $signed whether signed
292 * @return string[] min and max values
294 public function getIntegerRange($type, $signed = true)
296 return array('', '');
301 * Class holding type definitions for MySQL.
303 * @package PhpMyAdmin
305 class PMA_Types_MySQL extends PMA_Types
308 * Returns the data type description.
310 * @param string $type The data type to get a description.
312 * @return string
315 public function getTypeDescription($type)
317 $type = /*overload*/mb_strtoupper($type);
318 switch ($type) {
319 case 'TINYINT':
320 return __(
321 'A 1-byte integer, signed range is -128 to 127, unsigned range is ' .
322 '0 to 255'
324 case 'SMALLINT':
325 return __(
326 'A 2-byte integer, signed range is -32,768 to 32,767, unsigned ' .
327 'range is 0 to 65,535'
329 case 'MEDIUMINT':
330 return __(
331 'A 3-byte integer, signed range is -8,388,608 to 8,388,607, ' .
332 'unsigned range is 0 to 16,777,215'
334 case 'INT':
335 return __(
336 'A 4-byte integer, signed range is ' .
337 '-2,147,483,648 to 2,147,483,647, unsigned range is 0 to ' .
338 '4,294,967,295'
340 case 'BIGINT':
341 return __(
342 'An 8-byte integer, signed range is -9,223,372,036,854,775,808 ' .
343 'to 9,223,372,036,854,775,807, unsigned range is 0 to ' .
344 '18,446,744,073,709,551,615'
346 case 'DECIMAL':
347 return __(
348 'A fixed-point number (M, D) - the maximum number of digits (M) ' .
349 'is 65 (default 10), the maximum number of decimals (D) is 30 ' .
350 '(default 0)'
352 case 'FLOAT':
353 return __(
354 'A small floating-point number, allowable values are ' .
355 '-3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38 to ' .
356 '3.402823466E+38'
358 case 'DOUBLE':
359 return __(
360 'A double-precision floating-point number, allowable values are ' .
361 '-1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and ' .
362 '2.2250738585072014E-308 to 1.7976931348623157E+308'
364 case 'REAL':
365 return __(
366 'Synonym for DOUBLE (exception: in REAL_AS_FLOAT SQL mode it is ' .
367 'a synonym for FLOAT)'
369 case 'BIT':
370 return __(
371 'A bit-field type (M), storing M of bits per value (default is 1, ' .
372 'maximum is 64)'
374 case 'BOOLEAN':
375 return __(
376 'A synonym for TINYINT(1), a value of zero is considered false, ' .
377 'nonzero values are considered true'
379 case 'SERIAL':
380 return __('An alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE');
381 case 'DATE':
382 return sprintf(
383 __('A date, supported range is %1$s to %2$s'), '1000-01-01',
384 '9999-12-31'
386 case 'DATETIME':
387 return sprintf(
388 __('A date and time combination, supported range is %1$s to %2$s'),
389 '1000-01-01 00:00:00', '9999-12-31 23:59:59'
391 case 'TIMESTAMP':
392 return __(
393 'A timestamp, range is 1970-01-01 00:00:01 UTC to 2038-01-09 ' .
394 '03:14:07 UTC, stored as the number of seconds since the epoch ' .
395 '(1970-01-01 00:00:00 UTC)'
397 case 'TIME':
398 return sprintf(
399 __('A time, range is %1$s to %2$s'), '-838:59:59', '838:59:59'
401 case 'YEAR':
402 return __(
403 "A year in four-digit (4, default) or two-digit (2) format, the " .
404 "allowable values are 70 (1970) to 69 (2069) or 1901 to 2155 and " .
405 "0000"
407 case 'CHAR':
408 return __(
409 'A fixed-length (0-255, default 1) string that is always ' .
410 'right-padded with spaces to the specified length when stored'
412 case 'VARCHAR':
413 return sprintf(
415 'A variable-length (%s) string, the effective maximum length ' .
416 'is subject to the maximum row size'
417 ), '0-65,535'
419 case 'TINYTEXT':
420 return __(
421 'A TEXT column with a maximum length of 255 (2^8 - 1) characters, ' .
422 'stored with a one-byte prefix indicating the length of the value ' .
423 'in bytes'
425 case 'TEXT':
426 return __(
427 'A TEXT column with a maximum length of 65,535 (2^16 - 1) ' .
428 'characters, stored with a two-byte prefix indicating the length ' .
429 'of the value in bytes'
431 case 'MEDIUMTEXT':
432 return __(
433 'A TEXT column with a maximum length of 16,777,215 (2^24 - 1) ' .
434 'characters, stored with a three-byte prefix indicating the ' .
435 'length of the value in bytes'
437 case 'LONGTEXT':
438 return __(
439 'A TEXT column with a maximum length of 4,294,967,295 or 4GiB ' .
440 '(2^32 - 1) characters, stored with a four-byte prefix indicating ' .
441 'the length of the value in bytes'
443 case 'BINARY':
444 return __(
445 'Similar to the CHAR type, but stores binary byte strings rather ' .
446 'than non-binary character strings'
448 case 'VARBINARY':
449 return __(
450 'Similar to the VARCHAR type, but stores binary byte strings ' .
451 'rather than non-binary character strings'
453 case 'TINYBLOB':
454 return __(
455 'A BLOB column with a maximum length of 255 (2^8 - 1) bytes, ' .
456 'stored with a one-byte prefix indicating the length of the value'
458 case 'MEDIUMBLOB':
459 return __(
460 'A BLOB column with a maximum length of 16,777,215 (2^24 - 1) ' .
461 'bytes, stored with a three-byte prefix indicating the length of ' .
462 'the value'
464 case 'BLOB':
465 return __(
466 'A BLOB column with a maximum length of 65,535 (2^16 - 1) bytes, ' .
467 'stored with a two-byte prefix indicating the length of the value'
469 case 'LONGBLOB':
470 return __(
471 'A BLOB column with a maximum length of 4,294,967,295 or 4GiB ' .
472 '(2^32 - 1) bytes, stored with a four-byte prefix indicating the ' .
473 'length of the value'
475 case 'ENUM':
476 return __(
477 "An enumeration, chosen from the list of up to 65,535 values or " .
478 "the special '' error value"
480 case 'SET':
481 return __("A single value chosen from a set of up to 64 members");
482 case 'GEOMETRY':
483 return __('A type that can store a geometry of any type');
484 case 'POINT':
485 return __('A point in 2-dimensional space');
486 case 'LINESTRING':
487 return __('A curve with linear interpolation between points');
488 case 'POLYGON':
489 return __('A polygon');
490 case 'MULTIPOINT':
491 return __('A collection of points');
492 case 'MULTILINESTRING':
493 return __(
494 'A collection of curves with linear interpolation between points'
496 case 'MULTIPOLYGON':
497 return __('A collection of polygons');
498 case 'GEOMETRYCOLLECTION':
499 return __('A collection of geometry objects of any type');
501 return '';
505 * Returns class of a type, used for functions available for type
506 * or default values.
508 * @param string $type The data type to get a class.
510 * @return string
513 public function getTypeClass($type)
515 $type = /*overload*/mb_strtoupper($type);
516 switch ($type) {
517 case 'TINYINT':
518 case 'SMALLINT':
519 case 'MEDIUMINT':
520 case 'INT':
521 case 'BIGINT':
522 case 'DECIMAL':
523 case 'FLOAT':
524 case 'DOUBLE':
525 case 'REAL':
526 case 'BIT':
527 case 'BOOLEAN':
528 case 'SERIAL':
529 return 'NUMBER';
531 case 'DATE':
532 case 'DATETIME':
533 case 'TIMESTAMP':
534 case 'TIME':
535 case 'YEAR':
536 return 'DATE';
538 case 'CHAR':
539 case 'VARCHAR':
540 case 'TINYTEXT':
541 case 'TEXT':
542 case 'MEDIUMTEXT':
543 case 'LONGTEXT':
544 case 'BINARY':
545 case 'VARBINARY':
546 case 'TINYBLOB':
547 case 'MEDIUMBLOB':
548 case 'BLOB':
549 case 'LONGBLOB':
550 case 'ENUM':
551 case 'SET':
552 return 'CHAR';
554 case 'GEOMETRY':
555 case 'POINT':
556 case 'LINESTRING':
557 case 'POLYGON':
558 case 'MULTIPOINT':
559 case 'MULTILINESTRING':
560 case 'MULTIPOLYGON':
561 case 'GEOMETRYCOLLECTION':
562 return 'SPATIAL';
565 return '';
569 * Returns array of functions available for a class.
571 * @param string $class The class to get function list.
573 * @return string[]
576 public function getFunctionsClass($class)
578 switch ($class) {
579 case 'CHAR':
580 $ret = array(
581 'AES_DECRYPT',
582 'AES_ENCRYPT',
583 'BIN',
584 'CHAR',
585 'COMPRESS',
586 'CURRENT_USER',
587 'DATABASE',
588 'DAYNAME',
589 'DES_DECRYPT',
590 'DES_ENCRYPT',
591 'ENCRYPT',
592 'HEX',
593 'INET6_NTOA',
594 'INET_NTOA',
595 'LOAD_FILE',
596 'LOWER',
597 'LTRIM',
598 'MD5',
599 'MONTHNAME',
600 'OLD_PASSWORD',
601 'PASSWORD',
602 'QUOTE',
603 'REVERSE',
604 'RTRIM',
605 'SHA1',
606 'SOUNDEX',
607 'SPACE',
608 'TRIM',
609 'UNCOMPRESS',
610 'UNHEX',
611 'UPPER',
612 'USER',
613 'UUID',
614 'VERSION',
617 if ((PMA_MARIADB && PMA_MYSQL_INT_VERSION < 100012)
618 || PMA_MYSQL_INT_VERSION < 50603
620 $ret = array_diff($ret, array('INET6_NTOA'));
622 return $ret;
624 case 'DATE':
625 return array(
626 'CURRENT_DATE',
627 'CURRENT_TIME',
628 'DATE',
629 'FROM_DAYS',
630 'FROM_UNIXTIME',
631 'LAST_DAY',
632 'NOW',
633 'SEC_TO_TIME',
634 'SYSDATE',
635 'TIME',
636 'TIMESTAMP',
637 'UTC_DATE',
638 'UTC_TIME',
639 'UTC_TIMESTAMP',
640 'YEAR',
643 case 'NUMBER':
644 $ret = array(
645 'ABS',
646 'ACOS',
647 'ASCII',
648 'ASIN',
649 'ATAN',
650 'BIT_LENGTH',
651 'BIT_COUNT',
652 'CEILING',
653 'CHAR_LENGTH',
654 'CONNECTION_ID',
655 'COS',
656 'COT',
657 'CRC32',
658 'DAYOFMONTH',
659 'DAYOFWEEK',
660 'DAYOFYEAR',
661 'DEGREES',
662 'EXP',
663 'FLOOR',
664 'HOUR',
665 'INET6_ATON',
666 'INET_ATON',
667 'LENGTH',
668 'LN',
669 'LOG',
670 'LOG2',
671 'LOG10',
672 'MICROSECOND',
673 'MINUTE',
674 'MONTH',
675 'OCT',
676 'ORD',
677 'PI',
678 'QUARTER',
679 'RADIANS',
680 'RAND',
681 'ROUND',
682 'SECOND',
683 'SIGN',
684 'SIN',
685 'SQRT',
686 'TAN',
687 'TO_DAYS',
688 'TO_SECONDS',
689 'TIME_TO_SEC',
690 'UNCOMPRESSED_LENGTH',
691 'UNIX_TIMESTAMP',
692 'UUID_SHORT',
693 'WEEK',
694 'WEEKDAY',
695 'WEEKOFYEAR',
696 'YEARWEEK',
698 if ((PMA_MARIADB && PMA_MYSQL_INT_VERSION < 100012)
699 || PMA_MYSQL_INT_VERSION < 50603
701 $ret = array_diff($ret, array('INET6_ATON'));
703 return $ret;
705 case 'SPATIAL':
706 return array(
707 'GeomFromText',
708 'GeomFromWKB',
710 'GeomCollFromText',
711 'LineFromText',
712 'MLineFromText',
713 'PointFromText',
714 'MPointFromText',
715 'PolyFromText',
716 'MPolyFromText',
718 'GeomCollFromWKB',
719 'LineFromWKB',
720 'MLineFromWKB',
721 'PointFromWKB',
722 'MPointFromWKB',
723 'PolyFromWKB',
724 'MPolyFromWKB',
727 return array();
731 * Returns array of all attributes available.
733 * @return string[]
736 public function getAttributes()
738 return array(
740 'BINARY',
741 'UNSIGNED',
742 'UNSIGNED ZEROFILL',
743 'on update CURRENT_TIMESTAMP',
748 * Returns array of all column types available.
750 * VARCHAR, TINYINT, TEXT and DATE are listed first, based on
751 * estimated popularity.
753 * @return string[]
756 public function getColumns()
758 $ret = parent::getColumns();
759 // numeric
760 $ret[_pgettext('numeric types', 'Numeric')] = array(
761 'TINYINT',
762 'SMALLINT',
763 'MEDIUMINT',
764 'INT',
765 'BIGINT',
766 '-',
767 'DECIMAL',
768 'FLOAT',
769 'DOUBLE',
770 'REAL',
771 '-',
772 'BIT',
773 'BOOLEAN',
774 'SERIAL',
777 // Date/Time
778 $ret[_pgettext('date and time types', 'Date and time')] = array(
779 'DATE',
780 'DATETIME',
781 'TIMESTAMP',
782 'TIME',
783 'YEAR',
786 // Text
787 $ret[_pgettext('string types', 'String')] = array(
788 'CHAR',
789 'VARCHAR',
790 '-',
791 'TINYTEXT',
792 'TEXT',
793 'MEDIUMTEXT',
794 'LONGTEXT',
795 '-',
796 'BINARY',
797 'VARBINARY',
798 '-',
799 'TINYBLOB',
800 'MEDIUMBLOB',
801 'BLOB',
802 'LONGBLOB',
803 '-',
804 'ENUM',
805 'SET',
808 $ret[_pgettext('spatial types', 'Spatial')] = array(
809 'GEOMETRY',
810 'POINT',
811 'LINESTRING',
812 'POLYGON',
813 'MULTIPOINT',
814 'MULTILINESTRING',
815 'MULTIPOLYGON',
816 'GEOMETRYCOLLECTION',
819 return $ret;
823 * Returns an array of integer types
825 * @return string[] integer types
827 public function getIntegerTypes()
829 return array('tinyint', 'smallint', 'mediumint', 'int', 'bigint');
833 * Returns the min and max values of a given integer type
835 * @param string $type integer type
836 * @param boolean $signed whether signed
838 * @return string[] min and max values
840 public function getIntegerRange($type, $signed = true)
842 static $min_max_data = array(
843 'unsigned' => array(
844 'tinyint' => array('0', '255'),
845 'smallint' => array('0', '65535'),
846 'mediumint' => array('0', '16777215'),
847 'int' => array('0', '4294967295'),
848 'bigint' => array('0', '18446744073709551615')
850 'signed' => array(
851 'tinyint' => array('-128', '127'),
852 'smallint' => array('-32768', '32767'),
853 'mediumint' => array('-8388608', '8388607'),
854 'int' => array('-2147483648', '2147483647'),
855 'bigint' => array('-9223372036854775808', '9223372036854775807')
858 $relevantArray = $signed
859 ? $min_max_data['signed']
860 : $min_max_data['unsigned'];
861 return isset($relevantArray[$type]) ? $relevantArray[$type] : array('', '');
866 * Class holding type definitions for Drizzle.
868 * @package PhpMyAdmin
870 class PMA_Types_Drizzle extends PMA_Types
873 * Returns the data type description.
875 * @param string $type The data type to get a description.
877 * @return string
880 public function getTypeDescription($type)
882 $type = /*overload*/mb_strtoupper($type);
883 switch ($type) {
884 case 'INTEGER':
885 return __('A 4-byte integer, range is -2,147,483,648 to 2,147,483,647');
886 case 'BIGINT':
887 return __(
888 'An 8-byte integer, range is -9,223,372,036,854,775,808 to ' .
889 '9,223,372,036,854,775,807'
891 case 'DECIMAL':
892 return __(
893 'A fixed-point number (M, D) - the maximum number of digits ' .
894 '(M) is 65 (default 10), the maximum number of decimals (D) ' .
895 'is 30 (default 0)'
897 case 'DOUBLE':
898 return __("A system's default double-precision floating-point number");
899 case 'BOOLEAN':
900 return __('True or false');
901 case 'SERIAL':
902 return __('An alias for BIGINT NOT NULL AUTO_INCREMENT UNIQUE');
903 case 'UUID':
904 return __('Stores a Universally Unique Identifier (UUID)');
905 case 'DATE':
906 return sprintf(
907 __('A date, supported range is %1$s to %2$s'), '0001-01-01',
908 '9999-12-31'
910 case 'DATETIME':
911 return sprintf(
913 'A date and time combination, supported range is %1$s to ' .
914 '%2$s'
915 ), '0001-01-01 00:00:0', '9999-12-31 23:59:59'
917 case 'TIMESTAMP':
918 return __(
919 "A timestamp, range is '0001-01-01 00:00:00' UTC to " .
920 "'9999-12-31 23:59:59' UTC; TIMESTAMP(6) can store microseconds"
922 case 'TIME':
923 return sprintf(
924 __('A time, range is %1$s to %2$s'), '00:00:00', '23:59:59'
926 case 'VARCHAR':
927 return sprintf(
929 'A variable-length (%s) string, the effective ' .
930 'maximum length is subject to the maximum row size'
931 ), '0-16,383'
933 case 'TEXT':
934 return __(
935 'A TEXT column with a maximum length of 65,535 (2^16 - 1) ' .
936 'characters, stored with a two-byte prefix indicating the ' .
937 'length of the value in bytes'
939 case 'VARBINARY':
940 return __(
941 'A variable-length (0-65,535) string, uses binary collation ' .
942 'for all comparisons'
944 case 'BLOB':
945 return __(
946 'A BLOB column with a maximum length of 65,535 (2^16 - 1) ' .
947 'bytes, stored with a two-byte prefix indicating the length of ' .
948 'the value'
950 case 'ENUM':
951 return __("An enumeration, chosen from the list of defined values");
954 return '';
958 * Returns class of a type, used for functions available for type
959 * or default values.
961 * @param string $type The data type to get a class.
963 * @return string
966 public function getTypeClass($type)
968 $type = /*overload*/mb_strtoupper($type);
969 switch ($type) {
970 case 'INTEGER':
971 case 'BIGINT':
972 case 'DECIMAL':
973 case 'DOUBLE':
974 case 'BOOLEAN':
975 case 'SERIAL':
976 return 'NUMBER';
978 case 'DATE':
979 case 'DATETIME':
980 case 'TIMESTAMP':
981 case 'TIME':
982 return 'DATE';
984 case 'VARCHAR':
985 case 'TEXT':
986 case 'VARBINARY':
987 case 'BLOB':
988 case 'ENUM':
989 return 'CHAR';
991 case 'UUID':
992 return 'UUID';
994 return '';
998 * Returns array of functions available for a class.
1000 * @param string $class The class to get function list.
1002 * @return string[]
1005 public function getFunctionsClass($class)
1007 switch ($class) {
1008 case 'CHAR':
1009 $ret = array(
1010 'BIN',
1011 'CHAR',
1012 'COMPRESS',
1013 'CURRENT_USER',
1014 'DATABASE',
1015 'DAYNAME',
1016 'HEX',
1017 'LOAD_FILE',
1018 'LOWER',
1019 'LTRIM',
1020 'MD5',
1021 'MONTHNAME',
1022 'QUOTE',
1023 'REVERSE',
1024 'RTRIM',
1025 'SCHEMA',
1026 'SPACE',
1027 'TRIM',
1028 'UNCOMPRESS',
1029 'UNHEX',
1030 'UPPER',
1031 'USER',
1032 'UUID',
1033 'VERSION',
1036 // check for some functions known to be in modules
1037 $functions = array(
1038 'MYSQL_PASSWORD',
1039 'ROT13',
1042 // add new functions
1043 $sql = "SELECT upper(plugin_name) f
1044 FROM data_dictionary.plugins
1045 WHERE plugin_name IN ('" . implode("','", $functions) . "')
1046 AND plugin_type = 'Function'
1047 AND is_active";
1048 $drizzle_functions = $GLOBALS['dbi']->fetchResult($sql, 'f', 'f');
1049 if (count($drizzle_functions) > 0) {
1050 $ret = array_merge($ret, $drizzle_functions);
1051 sort($ret);
1054 return $ret;
1056 case 'UUID':
1057 return array(
1058 'UUID',
1061 case 'DATE':
1062 return array(
1063 'CURRENT_DATE',
1064 'CURRENT_TIME',
1065 'DATE',
1066 'FROM_DAYS',
1067 'FROM_UNIXTIME',
1068 'LAST_DAY',
1069 'NOW',
1070 'SYSDATE',
1071 //'TIME', // https://bugs.launchpad.net/drizzle/+bug/804571
1072 'TIMESTAMP',
1073 'UTC_DATE',
1074 'UTC_TIME',
1075 'UTC_TIMESTAMP',
1076 'YEAR',
1079 case 'NUMBER':
1080 return array(
1081 'ABS',
1082 'ACOS',
1083 'ASCII',
1084 'ASIN',
1085 'ATAN',
1086 'BIT_COUNT',
1087 'CEILING',
1088 'CHAR_LENGTH',
1089 'CONNECTION_ID',
1090 'COS',
1091 'COT',
1092 'CRC32',
1093 'DAYOFMONTH',
1094 'DAYOFWEEK',
1095 'DAYOFYEAR',
1096 'DEGREES',
1097 'EXP',
1098 'FLOOR',
1099 'HOUR',
1100 'LENGTH',
1101 'LN',
1102 'LOG',
1103 'LOG2',
1104 'LOG10',
1105 'MICROSECOND',
1106 'MINUTE',
1107 'MONTH',
1108 'OCT',
1109 'ORD',
1110 'PI',
1111 'QUARTER',
1112 'RADIANS',
1113 'RAND',
1114 'ROUND',
1115 'SECOND',
1116 'SIGN',
1117 'SIN',
1118 'SQRT',
1119 'TAN',
1120 'TO_DAYS',
1121 'TIME_TO_SEC',
1122 'UNCOMPRESSED_LENGTH',
1123 'UNIX_TIMESTAMP',
1124 //'WEEK', // same as TIME
1125 'WEEKDAY',
1126 'WEEKOFYEAR',
1127 'YEARWEEK',
1130 return array();
1134 * Returns array of all attributes available.
1136 * @return string[]
1139 public function getAttributes()
1141 return array(
1143 'on update CURRENT_TIMESTAMP',
1148 * Returns array of all column types available.
1150 * @return string[]
1153 public function getColumns()
1155 $types_num = array(
1156 'INTEGER',
1157 'BIGINT',
1158 '-',
1159 'DECIMAL',
1160 'DOUBLE',
1161 '-',
1162 'BOOLEAN',
1163 'SERIAL',
1164 'UUID',
1166 $types_date = array(
1167 'DATE',
1168 'DATETIME',
1169 'TIMESTAMP',
1170 'TIME',
1172 $types_string = array(
1173 'VARCHAR',
1174 'TEXT',
1175 '-',
1176 'VARBINARY',
1177 'BLOB',
1178 '-',
1179 'ENUM',
1181 if (PMA_MYSQL_INT_VERSION >= 70132) {
1182 $types_string[] = '-';
1183 $types_string[] = 'IPV6';
1186 $ret = parent::getColumns();
1187 // numeric
1188 $ret[_pgettext('numeric types', 'Numeric')] = $types_num;
1190 // Date/Time
1191 $ret[_pgettext('date and time types', 'Date and time')] = $types_date;
1193 // Text
1194 $ret[_pgettext('string types', 'String')] = $types_string;
1196 return $ret;
1200 * Returns an array of integer types
1202 * @return string[] integer types
1204 public function getIntegerTypes()
1206 return array('integer', 'bigint');
1210 * Returns the min and max values of a given integer type
1212 * @param string $type integer type
1213 * @param boolean $signed whether signed (ignored for Drizzle)
1215 * @return string[] min and max values
1217 public function getIntegerRange($type, $signed = true)
1219 static $min_max_data = array(
1220 'integer' => array('-2147483648', '2147483647'),
1221 'bigint' => array('-9223372036854775808', '9223372036854775807')
1223 return isset($min_max_data[$type]) ? $min_max_data[$type] : array('', '');