convenient_website /phpmyadmin/libraries/data_drizzle.inc.php

Language PHP Lines 225
MD5 Hash 29b58976d1005cbcd9ce51a7133f06fd Estimated Cost $4,698 (why?)
Repository https://bitbucket.org/adarshj/convenient_website.git View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<?php
/**
 * Column types and functions supported by Drizzle
 *
 * @package PhpMyAdmin
 */

$auto_column_types = empty($cfg['ColumnTypes']);

// VARCHAR, TINYINT, TEXT and DATE are listed first, based on estimated popularity
$cfg['ColumnTypes'] = !empty($cfg['ColumnTypes']) ? $cfg['ColumnTypes'] : array(
    // most used
    'INTEGER',
    'VARCHAR',
    'TEXT',
    'DATE',

    // numeric
    'NUMERIC' => array(
        'INTEGER',
        'BIGINT',
        '-',
        'DECIMAL',
        'DOUBLE',
        '-',
        'BOOLEAN',
        'SERIAL',
        'UUID',
    ),


    // Date/Time
    'DATE and TIME' => array(
        'DATE',
        'DATETIME',
        'TIMESTAMP',
        'TIME',
    ),

    // Text
    'STRING' => array(
        'VARCHAR',
        'TEXT',
        '-',
        'VARBINARY',
        'BLOB',
        '-',
        'ENUM',
    ),
);

if ($auto_column_types && PMA_MYSQL_INT_VERSION >= 20120130) {
    $cfg['ColumnTypes']['STRING'][] = '-';
    $cfg['ColumnTypes']['STRING'][] = 'IPV6';
}
unset($auto_column_types);

$cfg['AttributeTypes'] = !empty($cfg['AttributeTypes']) ? $cfg['AttributeTypes'] : array(
   '',
   'on update CURRENT_TIMESTAMP',
);

if ($cfg['ShowFunctionFields']) {
    $cfg['RestrictColumnTypes'] = !empty($cfg['RestrictColumnTypes']) ? $cfg['RestrictColumnTypes'] : array(
        'INTEGER'   => 'FUNC_NUMBER',
        'BIGINT'    => 'FUNC_NUMBER',
        'DECIMAL'   => 'FUNC_NUMBER',
        'DOUBLE'    => 'FUNC_NUMBER',
        'BOOLEAN'   => 'FUNC_NUMBER',
        'SERIAL'    => 'FUNC_NUMBER',

        'DATE'      => 'FUNC_DATE',
        'DATETIME'  => 'FUNC_DATE',
        'TIMESTAMP' => 'FUNC_DATE',
        'TIME'      => 'FUNC_DATE',

        'VARCHAR'    => 'FUNC_CHAR',
        'TEXT'       => 'FUNC_CHAR',
        'VARBINARY'  => 'FUNC_CHAR',
        'BLOB'       => 'FUNC_CHAR',
        'UUID'       => 'FUNC_UUID',
        'ENUM'       => '',
    );

    $restrict_functions = array(
        'FUNC_CHAR' => array(
            'BIN',
            'CHAR',
            'CURRENT_USER',
            'COMPRESS',
            'DATABASE',
            'DAYNAME',
            'HEX',
            'LOAD_FILE',
            'LOWER',
            'LTRIM',
            'MD5',
            'MONTHNAME',
            'QUOTE',
            'REVERSE',
            'RTRIM',
            'SCHEMA',
            'SPACE',
            'TRIM',
            'UNCOMPRESS',
            'UNHEX',
            'UPPER',
            'USER',
            'UUID',
            'VERSION',
        ),

        'FUNC_UUID' => array(
            'UUID',
        ),

        'FUNC_DATE' => array(
            'CURRENT_DATE',
            'CURRENT_TIME',
            'DATE',
            'FROM_DAYS',
            'FROM_UNIXTIME',
            'LAST_DAY',
            'NOW',
            'SYSDATE',
            //'TIME', // https://bugs.launchpad.net/drizzle/+bug/804571
            'TIMESTAMP',
            'UTC_DATE',
            'UTC_TIME',
            'UTC_TIMESTAMP',
            'YEAR',
        ),

        'FUNC_NUMBER' => array(
            'ABS',
            'ACOS',
            'ASCII',
            'ASIN',
            'ATAN',
            'BIT_COUNT',
            'CEILING',
            'CHAR_LENGTH',
            'CONNECTION_ID',
            'COS',
            'COT',
            'CRC32',
            'DAYOFMONTH',
            'DAYOFWEEK',
            'DAYOFYEAR',
            'DEGREES',
            'EXP',
            'FLOOR',
            'HOUR',
            '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', // same as TIME
            'WEEKDAY',
            'WEEKOFYEAR',
            'YEARWEEK',
        ),
    );
    $cfg_default_restrict_funcs = empty($cfg['RestrictFunctions']);
    if ($cfg_default_restrict_funcs) {
        $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) {
            $cfg['Functions'] = array_merge($cfg['Functions'], $functions);
        }

        // check for some functions known to be in modules
        $functions = array(
            'MYSQL_PASSWORD' => 'FUNC_CHAR',
            'ROT13' => 'FUNC_CHAR',
        );
        // add new functions
        $sql = "SELECT upper(plugin_name) f
            FROM data_dictionary.plugins
            WHERE plugin_name IN ('" . implode("','", array_keys($functions)) . "')
              AND plugin_type = 'Function'
              AND is_active";
        $drizzle_functions = PMA_DBI_fetch_result($sql, 'f', 'f');
        $cfg['Functions'] = array_merge($cfg['Functions'], $drizzle_functions);
        if ($cfg_default_restrict_funcs) {
            foreach ($drizzle_functions as $function) {
                $category = $functions[$function];
                $cfg['RestrictFunctions'][$category][] = $function;
            }
            foreach ($cfg['RestrictFunctions'] as &$v) {
                sort($v);
            }
            unset($v);
        }

        sort($cfg['Functions']);
    }
    unset($restrict_functions);
} // end if

?>
Back to Top