Passed
Push — master ( bb9122...7ad73a )
by William
11:07
created

DbiDummy::findFiloQuery()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 11
nc 5
nop 1
dl 0
loc 22
rs 9.6111
c 1
b 0
f 0
1
<?php
2
/**
3
 * Fake database driver for testing purposes
4
 *
5
 * It has hardcoded results for given queries what makes easy to use it
6
 * in testsuite. Feel free to include other queries which your test will
7
 * need.
8
 */
9
10
declare(strict_types=1);
11
12
namespace PhpMyAdmin\Tests\Stubs;
13
14
use PhpMyAdmin\Dbal\DatabaseName;
15
use PhpMyAdmin\Dbal\DbiExtension;
16
use PhpMyAdmin\FieldMetadata;
17
18
use function addslashes;
19
use function count;
20
use function is_array;
21
use function is_bool;
22
use function is_int;
23
use function preg_replace;
24
use function str_replace;
25
use function trim;
26
27
use const MYSQLI_TYPE_BLOB;
28
use const MYSQLI_TYPE_DATETIME;
29
use const MYSQLI_TYPE_DECIMAL;
30
use const MYSQLI_TYPE_STRING;
31
32
/**
33
 * Fake database driver for testing purposes
34
 *
35
 * It has hardcoded results for given queries what makes easy to use it
36
 * in testsuite. Feel free to include other queries which your test will
37
 * need.
38
 */
39
class DbiDummy implements DbiExtension
40
{
41
    /**
42
     * First in, last out queries
43
     *
44
     * The results will be distributed in the filo way
45
     *
46
     * @var array
47
     * @phpstan-var array{
48
     *     'query': string,
49
     *     'result': ((int[]|string[]|array{string: string})[])|bool|bool[]|empty-array,
50
     *     'columns'?: string[],
51
     *     'metadata'?: object[]|empty-array,
52
     *     'used'?: bool,
53
     *     'pos'?: int
54
     * }[]
55
     */
56
    private $filoQueries = [];
57
58
    /**
59
     * @var array
60
     * @phpstan-var array{
61
     *     'query': string,
62
     *     'result': ((int[]|string[]|array{string: string})[])|bool|bool[]|empty-array,
63
     *     'columns'?: string[],
64
     *     'metadata'?: object[]|empty-array,
65
     *     'pos'?: int
66
     * }[]
67
     */
68
    private $dummyQueries = [];
69
70
    public const OFFSET_GLOBAL = 1000;
71
72
    public function __construct()
73
    {
74
        $this->init();
75
    }
76
77
    /**
78
     * connects to the database server
79
     *
80
     * @param string $user     mysql user name
81
     * @param string $password mysql user password
82
     * @param array  $server   host/port/socket/persistent
83
     *
84
     * @return mixed false on error or a mysqli object on success
85
     */
86
    public function connect(
87
        $user,
88
        $password,
89
        array $server = []
90
    ) {
91
        return true;
92
    }
93
94
    /**
95
     * selects given database
96
     *
97
     * @param string|DatabaseName $databaseName name of db to select
98
     * @param object              $link         mysql link resource
99
     *
100
     * @return bool
101
     */
102
    public function selectDb($databaseName, $link)
103
    {
104
        $GLOBALS['dummy_db'] = (string) $databaseName;
105
106
        return true;
107
    }
108
109
    public function hasUnUsedQueries(): bool
110
    {
111
        foreach ($this->filoQueries as $query) {
112
            if (($query['used'] ?? false) === true) {
113
                continue;
114
            }
115
116
            return true;
117
        }
118
119
        return false;
120
    }
121
122
    /**
123
     * @return false|int|null
124
     */
125
    private function findFiloQuery(string $query)
126
    {
127
        for ($i = 0, $nb = count($this->filoQueries); $i < $nb; $i++) {
128
            if ($this->filoQueries[$i]['query'] !== $query) {
129
                continue;
130
            }
131
132
            if ($this->filoQueries[$i]['used'] ?? false) {
133
                continue;// Is has already been used
134
            }
135
136
            $this->filoQueries[$i]['pos'] = 0;
137
            $this->filoQueries[$i]['used'] = true;
138
139
            if (! is_array($this->filoQueries[$i]['result'])) {
140
                return false;
141
            }
142
143
            return $i;
144
        }
145
146
        return null;
147
    }
148
149
    /**
150
     * runs a query and returns the result
151
     *
152
     * @param string $query   query to run
153
     * @param object $link    mysql link resource
154
     * @param int    $options query options
155
     *
156
     * @return mixed
157
     */
158
    public function realQuery($query, $link = null, $options = 0)
159
    {
160
        $query = trim((string) preg_replace('/  */', ' ', str_replace("\n", ' ', $query)));
161
        $filoQuery = $this->findFiloQuery($query);
162
        if ($filoQuery !== null) {// Found a matching query
163
            return $filoQuery;
164
        }
165
166
        for ($i = 0, $nb = count($this->dummyQueries); $i < $nb; $i++) {
167
            if ($this->dummyQueries[$i]['query'] !== $query) {
168
                continue;
169
            }
170
171
            $this->dummyQueries[$i]['pos'] = 0;
172
            if (! is_array($this->dummyQueries[$i]['result'])) {
173
                return false;
174
            }
175
176
            return $i + self::OFFSET_GLOBAL;
177
        }
178
179
        echo 'Not supported query: ' . $query . "\n";
180
181
        return false;
182
    }
183
184
    /**
185
     * Run the multi query and output the results
186
     *
187
     * @param object $link  connection object
188
     * @param string $query multi query statement to execute
189
     *
190
     * @return array|bool
191
     */
192
    public function realMultiQuery($link, $query)
193
    {
194
        return false;
195
    }
196
197
    /**
198
     * returns result data from $result
199
     *
200
     * @param object $result MySQL result
201
     */
202
    public function fetchAny($result): ?array
203
    {
204
        $query_data = &$this->getQueryData($result);
205
        if ($query_data['pos'] >= count((array) $query_data['result'])) {
206
            return null;
207
        }
208
209
        $ret = $query_data['result'][$query_data['pos']];
210
        $query_data['pos'] += 1;
211
212
        return $ret;
213
    }
214
215
    /**
216
     * returns array of rows with associative and numeric keys from $result
217
     *
218
     * @param object $result result  MySQL result
219
     */
220
    public function fetchArray($result): ?array
221
    {
222
        $query_data = &$this->getQueryData($result);
223
        $data = $this->fetchAny($result);
224
        if (
225
            ! is_array($data)
226
            || ! isset($query_data['columns'])
227
        ) {
228
            return $data;
229
        }
230
231
        foreach ($data as $key => $val) {
232
            $data[$query_data['columns'][$key]] = $val;
233
        }
234
235
        return $data;
236
    }
237
238
    /**
239
     * returns array of rows with associative keys from $result
240
     *
241
     * @param object $result MySQL result
242
     */
243
    public function fetchAssoc($result): ?array
244
    {
245
        $data = $this->fetchAny($result);
246
        $query_data = &$this->getQueryData($result);
247
        if (! is_array($data) || ! isset($query_data['columns'])) {
248
            return $data;
249
        }
250
251
        $ret = [];
252
        foreach ($data as $key => $val) {
253
            $ret[$query_data['columns'][$key]] = $val;
254
        }
255
256
        return $ret;
257
    }
258
259
    /**
260
     * returns array of rows with numeric keys from $result
261
     *
262
     * @param object $result MySQL result
263
     */
264
    public function fetchRow($result): ?array
265
    {
266
        return $this->fetchAny($result);
267
    }
268
269
    /**
270
     * Adjusts the result pointer to an arbitrary row in the result
271
     *
272
     * @param object $result database result
273
     * @param int    $offset offset to seek
274
     *
275
     * @return bool true on success, false on failure
276
     */
277
    public function dataSeek($result, $offset)
278
    {
279
        $query_data = &$this->getQueryData($result);
280
        if ($offset > count($query_data['result'])) {
281
            return false;
282
        }
283
284
        $query_data['pos'] = $offset;
285
286
        return true;
287
    }
288
289
    /**
290
     * Frees memory associated with the result
291
     *
292
     * @param object $result database result
293
     *
294
     * @return void
295
     */
296
    public function freeResult($result)
297
    {
298
    }
299
300
    /**
301
     * Check if there are any more query results from a multi query
302
     *
303
     * @param object $link the connection object
304
     *
305
     * @return bool false
306
     */
307
    public function moreResults($link)
308
    {
309
        return false;
310
    }
311
312
    /**
313
     * Prepare next result from multi_query
314
     *
315
     * @param object $link the connection object
316
     *
317
     * @return bool false
318
     */
319
    public function nextResult($link)
320
    {
321
        return false;
322
    }
323
324
    /**
325
     * Store the result returned from multi query
326
     *
327
     * @param object $link the connection object
328
     *
329
     * @return mixed false when empty results / result set when not empty
330
     */
331
    public function storeResult($link)
332
    {
333
        return false;
334
    }
335
336
    /**
337
     * Returns a string representing the type of connection used
338
     *
339
     * @param object $link mysql link
340
     *
341
     * @return string type of connection used
342
     */
343
    public function getHostInfo($link)
344
    {
345
        return '';
346
    }
347
348
    /**
349
     * Returns the version of the MySQL protocol used
350
     *
351
     * @param object $link mysql link
352
     *
353
     * @return int version of the MySQL protocol used
354
     */
355
    public function getProtoInfo($link)
356
    {
357
        return -1;
358
    }
359
360
    /**
361
     * returns a string that represents the client library version
362
     *
363
     * @param object $link connection link
364
     *
365
     * @return string MySQL client library version
366
     */
367
    public function getClientInfo($link)
368
    {
369
        return 'libmysql - mysqlnd x.x.x-dev (phpMyAdmin tests)';
370
    }
371
372
    /**
373
     * returns last error message or false if no errors occurred
374
     *
375
     * @param object $link connection link
376
     *
377
     * @return string|bool error or false
378
     */
379
    public function getError($link)
380
    {
381
        return false;
382
    }
383
384
    /**
385
     * returns the number of rows returned by last query
386
     *
387
     * @param object|bool $result MySQL result
388
     *
389
     * @return string|int
390
     */
391
    public function numRows($result)
392
    {
393
        if (is_bool($result)) {
394
            return 0;
395
        }
396
397
        $query_data = &$this->getQueryData($result);
398
399
        return count($query_data['result']);
400
    }
401
402
    /**
403
     * returns the number of rows affected by last query
404
     *
405
     * @param object $link           the mysql object
406
     * @param bool   $get_from_cache whether to retrieve from cache
407
     *
408
     * @return string|int
409
     */
410
    public function affectedRows($link = null, $get_from_cache = true)
411
    {
412
        global $cached_affected_rows;
413
414
        return $cached_affected_rows ?? 0;
415
    }
416
417
    /**
418
     * returns metainfo for fields in $result
419
     *
420
     * @param object $result result set identifier
421
     *
422
     * @return FieldMetadata[]|null meta info for fields in $result
423
     */
424
    public function getFieldsMeta($result): ?array
425
    {
426
        $query_data = &$this->getQueryData($result);
427
        if (! isset($query_data['metadata'])) {
428
            return [];
429
        }
430
431
        return $query_data['metadata'];
432
    }
433
434
    /**
435
     * return number of fields in given $result
436
     *
437
     * @param object $result MySQL result
438
     *
439
     * @return int  field count
440
     */
441
    public function numFields($result)
442
    {
443
        $query_data = &$this->getQueryData($result);
444
        if (! isset($query_data['columns'])) {
445
            return 0;
446
        }
447
448
        return count($query_data['columns']);
449
    }
450
451
    /**
452
     * returns the length of the given field $i in $result
453
     *
454
     * @param object $result result set identifier
455
     * @param int    $i      field
456
     *
457
     * @return int length of field
458
     */
459
    public function fieldLen($result, $i)
460
    {
461
        return -1;
462
    }
463
464
    /**
465
     * returns name of $i. field in $result
466
     *
467
     * @param object $result result set identifier
468
     * @param int    $i      field
469
     *
470
     * @return string name of $i. field in $result
471
     */
472
    public function fieldName($result, $i)
473
    {
474
        $query_data = &$this->getQueryData($result);
475
        if (! isset($query_data['columns'])) {
476
            return '';
477
        }
478
479
        return $query_data['columns'][$i];
480
    }
481
482
    /**
483
     * returns properly escaped string for use in MySQL queries
484
     *
485
     * @param mixed  $link   database link
486
     * @param string $string string to be escaped
487
     *
488
     * @return string a MySQL escaped string
489
     */
490
    public function escapeString($link, $string)
491
    {
492
        return addslashes($string);
493
    }
494
495
    /**
496
     * Adds query result for testing
497
     *
498
     * @param string     $query    SQL
499
     * @param array|bool $result   Expected result
500
     * @param string[]   $columns  The result columns
501
     * @param object[]   $metadata The result metadata
502
     * @phpstan-param (int[]|string[]|array{string: string})[]|bool|bool[] $result
503
     *
504
     * @return void
505
     */
506
    public function addResult(string $query, $result, array $columns = [], array $metadata = [])
507
    {
508
        $this->filoQueries[] = [
509
            'query' => $query,
510
            'result' => $result,
511
            'columns' => $columns,
512
            'metadata' => $metadata,
513
        ];
514
    }
515
516
    /**
517
     * @param mixed  $link  link
518
     * @param string $query query
519
     *
520
     * @return object|false
521
     */
522
    public function prepare($link, string $query)
523
    {
524
        return false;
525
    }
526
527
    /**
528
     * Return query data for ID
529
     *
530
     * @param object|int $result result set identifier
531
     *
532
     * @return array
533
     */
534
    private function &getQueryData($result): array
535
    {
536
        if (! is_int($result)) {
537
            // This never happens
538
            return [];
539
        }
540
541
        if ($result >= self::OFFSET_GLOBAL) {
542
            return $this->dummyQueries[$result - self::OFFSET_GLOBAL];
543
        }
544
545
        return $this->filoQueries[$result];
546
    }
547
548
    private function init(): void
549
    {
550
        /**
551
         * Array of queries this "driver" supports
552
         */
553
        $this->dummyQueries = [
554
            [
555
                'query' => 'SELECT 1',
556
                'result' => [['1']],
557
            ],
558
            [
559
                'query'  => 'SELECT CURRENT_USER();',
560
                'result' => [['pma_test@localhost']],
561
            ],
562
            [
563
                'query'  => "SHOW VARIABLES LIKE 'lower_case_table_names'",
564
                'result' => [
565
                    [
566
                        'lower_case_table_names',
567
                        '1',
568
                    ],
569
                ],
570
            ],
571
            [
572
                'query'  => 'SELECT 1 FROM mysql.user LIMIT 1',
573
                'result' => [['1']],
574
            ],
575
            [
576
                'query'  => 'SELECT 1 FROM `INFORMATION_SCHEMA`.`USER_PRIVILEGES`'
577
                    . " WHERE `PRIVILEGE_TYPE` = 'CREATE USER'"
578
                    . " AND '''pma_test''@''localhost''' LIKE `GRANTEE` LIMIT 1",
579
                'result' => [['1']],
580
            ],
581
            [
582
                'query'  => 'SELECT 1 FROM (SELECT `GRANTEE`, `IS_GRANTABLE`'
583
                    . ' FROM `INFORMATION_SCHEMA`.`COLUMN_PRIVILEGES`'
584
                    . ' UNION SELECT `GRANTEE`, `IS_GRANTABLE`'
585
                    . ' FROM `INFORMATION_SCHEMA`.`TABLE_PRIVILEGES`'
586
                    . ' UNION SELECT `GRANTEE`, `IS_GRANTABLE`'
587
                    . ' FROM `INFORMATION_SCHEMA`.`SCHEMA_PRIVILEGES`'
588
                    . ' UNION SELECT `GRANTEE`, `IS_GRANTABLE`'
589
                    . ' FROM `INFORMATION_SCHEMA`.`USER_PRIVILEGES`) t'
590
                    . " WHERE `IS_GRANTABLE` = 'YES'"
591
                    . " AND '''pma_test''@''localhost''' LIKE `GRANTEE` LIMIT 1",
592
                'result' => [['1']],
593
            ],
594
            [
595
                'query'  => 'SHOW MASTER LOGS',
596
                'result' => [
597
                    [
598
                        'Log_name' => 'index1',
599
                        'File_size' => 100,
600
                    ],
601
                    [
602
                        'Log_name' => 'index2',
603
                        'File_size' => 200,
604
                    ],
605
                ],
606
            ],
607
            [
608
                'query'  => 'SHOW STORAGE ENGINES',
609
                'result' => [
610
                    [
611
                        'Engine'  => 'dummy',
612
                        'Support' => 'YES',
613
                        'Comment' => 'dummy comment',
614
                    ],
615
                    [
616
                        'Engine'  => 'dummy2',
617
                        'Support' => 'NO',
618
                        'Comment' => 'dummy2 comment',
619
                    ],
620
                    [
621
                        'Engine'  => 'FEDERATED',
622
                        'Support' => 'NO',
623
                        'Comment' => 'Federated MySQL storage engine',
624
                    ],
625
                    [
626
                        'Engine'  => 'Pbxt',
627
                        'Support' => 'NO',
628
                        'Comment' => 'Pbxt storage engine',
629
                    ],
630
                ],
631
            ],
632
            [
633
                'query'  => 'SHOW STATUS WHERE Variable_name'
634
                    . ' LIKE \'Innodb\\_buffer\\_pool\\_%\''
635
                    . ' OR Variable_name = \'Innodb_page_size\';',
636
                'result' => [
637
                    [
638
                        'Innodb_buffer_pool_pages_data',
639
                        0,
640
                    ],
641
                    [
642
                        'Innodb_buffer_pool_pages_dirty',
643
                        0,
644
                    ],
645
                    [
646
                        'Innodb_buffer_pool_pages_flushed',
647
                        0,
648
                    ],
649
                    [
650
                        'Innodb_buffer_pool_pages_free',
651
                        0,
652
                    ],
653
                    [
654
                        'Innodb_buffer_pool_pages_misc',
655
                        0,
656
                    ],
657
                    [
658
                        'Innodb_buffer_pool_pages_total',
659
                        4096,
660
                    ],
661
                    [
662
                        'Innodb_buffer_pool_read_ahead_rnd',
663
                        0,
664
                    ],
665
                    [
666
                        'Innodb_buffer_pool_read_ahead',
667
                        0,
668
                    ],
669
                    [
670
                        'Innodb_buffer_pool_read_ahead_evicted',
671
                        0,
672
                    ],
673
                    [
674
                        'Innodb_buffer_pool_read_requests',
675
                        64,
676
                    ],
677
                    [
678
                        'Innodb_buffer_pool_reads',
679
                        32,
680
                    ],
681
                    [
682
                        'Innodb_buffer_pool_wait_free',
683
                        0,
684
                    ],
685
                    [
686
                        'Innodb_buffer_pool_write_requests',
687
                        64,
688
                    ],
689
                    [
690
                        'Innodb_page_size',
691
                        16384,
692
                    ],
693
                ],
694
            ],
695
            [
696
                'query'  => 'SHOW ENGINE INNODB STATUS;',
697
                'result' => false,
698
            ],
699
            [
700
                'query'  => 'SELECT @@innodb_version;',
701
                'result' => [
702
                    ['1.1.8'],
703
                ],
704
            ],
705
            [
706
                'query'  => 'SELECT @@disabled_storage_engines',
707
                'result' => [
708
                    [''],
709
                ],
710
            ],
711
            [
712
                'query' => 'SHOW GLOBAL VARIABLES ;',
713
                'result' => [],
714
            ],
715
            [
716
                'query'  => 'SHOW GLOBAL VARIABLES LIKE \'innodb_file_per_table\';',
717
                'result' => [
718
                    [
719
                        'innodb_file_per_table',
720
                        'OFF',
721
                    ],
722
                ],
723
            ],
724
            [
725
                'query'  => 'SHOW GLOBAL VARIABLES LIKE \'innodb_file_format\';',
726
                'result' => [
727
                    [
728
                        'innodb_file_format',
729
                        'Antelope',
730
                    ],
731
                ],
732
            ],
733
            [
734
                'query'  => 'SELECT @@collation_server',
735
                'result' => [
736
                    ['utf8_general_ci'],
737
                ],
738
            ],
739
            [
740
                'query'  => 'SELECT @@lc_messages;',
741
                'result' => [],
742
            ],
743
            [
744
                'query'  => 'SHOW SESSION VARIABLES LIKE \'FOREIGN_KEY_CHECKS\';',
745
                'result' => [
746
                    [
747
                        'foreign_key_checks',
748
                        'ON',
749
                    ],
750
                ],
751
            ],
752
            [
753
                'query'  => 'SHOW TABLES FROM `pma_test`;',
754
                'result' => [
755
                    ['table1'],
756
                    ['table2'],
757
                ],
758
            ],
759
            [
760
                'query'  => 'SHOW TABLES FROM `pmadb`',
761
                'result' => [
762
                    ['column_info'],
763
                ],
764
            ],
765
            [
766
                'query'   => 'SHOW COLUMNS FROM `pma_test`.`table1`',
767
                'columns' => [
768
                    'Field',
769
                    'Type',
770
                    'Null',
771
                    'Key',
772
                    'Default',
773
                    'Extra',
774
                ],
775
                'result'  => [
776
                    [
777
                        'i',
778
                        'int(11)',
779
                        'NO',
780
                        'PRI',
781
                        'NULL',
782
                        'auto_increment',
783
                    ],
784
                    [
785
                        'o',
786
                        'int(11)',
787
                        'NO',
788
                        'MUL',
789
                        'NULL',
790
                        '',
791
                    ],
792
                ],
793
            ],
794
            [
795
                'query'  => 'SHOW INDEXES FROM `pma_test`.`table1` WHERE (Non_unique = 0)',
796
                'result' => [],
797
            ],
798
            [
799
                'query'   => 'SHOW COLUMNS FROM `pma_test`.`table2`',
800
                'columns' => [
801
                    'Field',
802
                    'Type',
803
                    'Null',
804
                    'Key',
805
                    'Default',
806
                    'Extra',
807
                ],
808
                'result'  => [
809
                    [
810
                        'i',
811
                        'int(11)',
812
                        'NO',
813
                        'PRI',
814
                        'NULL',
815
                        'auto_increment',
816
                    ],
817
                    [
818
                        'o',
819
                        'int(11)',
820
                        'NO',
821
                        'MUL',
822
                        'NULL',
823
                        '',
824
                    ],
825
                ],
826
            ],
827
            [
828
                'query'  => 'SHOW INDEXES FROM `pma_test`.`table1`',
829
                'result' => [],
830
            ],
831
            [
832
                'query'  => 'SHOW INDEXES FROM `pma_test`.`table2`',
833
                'result' => [],
834
            ],
835
            [
836
                'query'   => 'SHOW COLUMNS FROM `pma`.`table1`',
837
                'columns' => [
838
                    'Field',
839
                    'Type',
840
                    'Null',
841
                    'Key',
842
                    'Default',
843
                    'Extra',
844
                    'Privileges',
845
                    'Comment',
846
                ],
847
                'result'  => [
848
                    [
849
                        'i',
850
                        'int(11)',
851
                        'NO',
852
                        'PRI',
853
                        'NULL',
854
                        'auto_increment',
855
                        'select,insert,update,references',
856
                        '',
857
                    ],
858
                    [
859
                        'o',
860
                        'varchar(100)',
861
                        'NO',
862
                        'MUL',
863
                        'NULL',
864
                        '',
865
                        'select,insert,update,references',
866
                        '',
867
                    ],
868
                ],
869
            ],
870
            [
871
                'query'   => 'SELECT `CHARACTER_SET_NAME` AS `Charset`,'
872
                    . ' `DEFAULT_COLLATE_NAME` AS `Default collation`,'
873
                    . ' `DESCRIPTION` AS `Description`,'
874
                    . ' `MAXLEN` AS `Maxlen`'
875
                    . ' FROM `information_schema`.`CHARACTER_SETS`',
876
                'columns' => [
877
                    'Charset',
878
                    'Default collation',
879
                    'Description',
880
                    'Maxlen',
881
                ],
882
                'result'  => [
883
                    [
884
                        'armscii8',
885
                        'ARMSCII-8 Armenian',
886
                        'armscii8_general_ci',
887
                        '1',
888
                    ],
889
                    [
890
                        'utf8',
891
                        'utf8_general_ci',
892
                        'UTF-8 Unicode',
893
                        '3',
894
                    ],
895
                    [
896
                        'utf8mb4',
897
                        'UTF-8 Unicode',
898
                        'utf8mb4_0900_ai_ci',
899
                        '4',
900
                    ],
901
                    [
902
                        'latin1',
903
                        'latin1_swedish_ci',
904
                        'cp1252 West European',
905
                        '1',
906
                    ],
907
                ],
908
            ],
909
            [
910
                'query'   => 'SELECT `COLLATION_NAME` AS `Collation`,'
911
                    . ' `CHARACTER_SET_NAME` AS `Charset`,'
912
                    . ' `ID` AS `Id`,'
913
                    . ' `IS_DEFAULT` AS `Default`,'
914
                    . ' `IS_COMPILED` AS `Compiled`,'
915
                    . ' `SORTLEN` AS `Sortlen`'
916
                    . ' FROM `information_schema`.`COLLATIONS`',
917
                'columns' => [
918
                    'Collation',
919
                    'Charset',
920
                    'Id',
921
                    'Default',
922
                    'Compiled',
923
                    'Sortlen',
924
                ],
925
                'result'  => [
926
                    [
927
                        'utf8mb4_general_ci',
928
                        'utf8mb4',
929
                        '45',
930
                        'Yes',
931
                        'Yes',
932
                        '1',
933
                    ],
934
                    [
935
                        'armscii8_general_ci',
936
                        'armscii8',
937
                        '32',
938
                        'Yes',
939
                        'Yes',
940
                        '1',
941
                    ],
942
                    [
943
                        'utf8_general_ci',
944
                        'utf8',
945
                        '33',
946
                        'Yes',
947
                        'Yes',
948
                        '1',
949
                    ],
950
                    [
951
                        'utf8_bin',
952
                        'utf8',
953
                        '83',
954
                        '',
955
                        'Yes',
956
                        '1',
957
                    ],
958
                    [
959
                        'latin1_swedish_ci',
960
                        'latin1',
961
                        '8',
962
                        'Yes',
963
                        'Yes',
964
                        '1',
965
                    ],
966
                ],
967
            ],
968
            [
969
                'query'  => 'SELECT `TABLE_NAME` FROM `INFORMATION_SCHEMA`.`TABLES`'
970
                    . ' WHERE `TABLE_SCHEMA`=\'pma_test\' AND `TABLE_TYPE` IN (\'BASE TABLE\', \'SYSTEM VERSIONED\')',
971
                'result' => [],
972
            ],
973
            [
974
                'query'   => 'SELECT `column_name`, `mimetype`, `transformation`,'
975
                    . ' `transformation_options`, `input_transformation`,'
976
                    . ' `input_transformation_options`'
977
                    . ' FROM `pmadb`.`column_info`'
978
                    . ' WHERE `db_name` = \'pma_test\' AND `table_name` = \'table1\''
979
                    . ' AND ( `mimetype` != \'\' OR `transformation` != \'\''
980
                    . ' OR `transformation_options` != \'\''
981
                    . ' OR `input_transformation` != \'\''
982
                    . ' OR `input_transformation_options` != \'\')',
983
                'columns' => [
984
                    'column_name',
985
                    'mimetype',
986
                    'transformation',
987
                    'transformation_options',
988
                    'input_transformation',
989
                    'input_transformation_options',
990
                ],
991
                'result'  => [
992
                    [
993
                        'o',
994
                        'text/plain',
995
                        'sql',
996
                        '',
997
                        'regex',
998
                        '/pma/i',
999
                    ],
1000
                    [
1001
                        'col',
1002
                        't',
1003
                        'o/p',
1004
                        '',
1005
                        'i/p',
1006
                        '',
1007
                    ],
1008
                ],
1009
            ],
1010
            [
1011
                'query'   => 'SELECT `column_name`, `mimetype`, `transformation`,'
1012
                    . ' `transformation_options`, `input_transformation`,'
1013
                    . ' `input_transformation_options`'
1014
                    . ' FROM `information_schema`.`column_info`'
1015
                    . ' WHERE `db_name` = \'my_db\' AND `table_name` = \'test_tbl\''
1016
                    . ' AND ( `mimetype` != \'\' OR `transformation` != \'\''
1017
                    . ' OR `transformation_options` != \'\''
1018
                    . ' OR `input_transformation` != \'\''
1019
                    . ' OR `input_transformation_options` != \'\')',
1020
                'columns' => [
1021
                    'column_name',
1022
                    'mimetype',
1023
                    'transformation',
1024
                    'transformation_options',
1025
                    'input_transformation',
1026
                    'input_transformation_options',
1027
                ],
1028
                'result'  => [
1029
                    [
1030
                        'vc',
1031
                        '',
1032
                        'output/text_plain_json.php',
1033
                        '',
1034
                        'Input/Text_Plain_JsonEditor.php',
1035
                        '',
1036
                    ],
1037
                    [
1038
                        'vc',
1039
                        '',
1040
                        'output/text_plain_formatted.php',
1041
                        '',
1042
                        'Text_Plain_Substring.php',
1043
                        '1',
1044
                    ],
1045
                ],
1046
            ],
1047
            [
1048
                'query'  => 'SELECT TABLE_NAME FROM information_schema.VIEWS'
1049
                    . ' WHERE TABLE_SCHEMA = \'pma_test\' AND TABLE_NAME = \'table1\'',
1050
                'result' => [],
1051
            ],
1052
            [
1053
                'query'  => 'SELECT TABLE_NAME FROM information_schema.VIEWS'
1054
                    . ' WHERE TABLE_SCHEMA = \'ODS_DB\' AND TABLE_NAME = \'Shop\'',
1055
                'result' => [],
1056
            ],
1057
            [
1058
                'query'  => 'SELECT TABLE_NAME FROM information_schema.VIEWS'
1059
                    . ' WHERE TABLE_SCHEMA = \'ODS_DB\' AND TABLE_NAME = \'pma_bookmark\'',
1060
                'result' => [],
1061
            ],
1062
            [
1063
                'query'  => 'SELECT TABLE_NAME FROM information_schema.VIEWS'
1064
                    . ' WHERE TABLE_SCHEMA = \'my_dataset\' AND TABLE_NAME = \'company_users\'',
1065
                'result' => [],
1066
            ],
1067
            [
1068
                'query'  => 'SELECT TABLE_NAME FROM information_schema.VIEWS'
1069
                    . ' WHERE TABLE_SCHEMA = \'my_db\' '
1070
                    . 'AND TABLE_NAME = \'test_tbl\' AND IS_UPDATABLE = \'YES\'',
1071
                'result' => [],
1072
            ],
1073
            [
1074
                'query'   => 'SELECT *, `TABLE_SCHEMA` AS `Db`, `TABLE_NAME` AS `Name`,'
1075
                    . ' `TABLE_TYPE` AS `TABLE_TYPE`, `ENGINE` AS `Engine`,'
1076
                    . ' `ENGINE` AS `Type`, `VERSION` AS `Version`,'
1077
                    . ' `ROW_FORMAT` AS `Row_format`, `TABLE_ROWS` AS `Rows`,'
1078
                    . ' `AVG_ROW_LENGTH` AS `Avg_row_length`,'
1079
                    . ' `DATA_LENGTH` AS `Data_length`,'
1080
                    . ' `MAX_DATA_LENGTH` AS `Max_data_length`,'
1081
                    . ' `INDEX_LENGTH` AS `Index_length`, `DATA_FREE` AS `Data_free`,'
1082
                    . ' `AUTO_INCREMENT` AS `Auto_increment`,'
1083
                    . ' `CREATE_TIME` AS `Create_time`, `UPDATE_TIME` AS `Update_time`,'
1084
                    . ' `CHECK_TIME` AS `Check_time`, `TABLE_COLLATION` AS `Collation`,'
1085
                    . ' `CHECKSUM` AS `Checksum`, `CREATE_OPTIONS` AS `Create_options`,'
1086
                    . ' `TABLE_COMMENT` AS `Comment`'
1087
                    . ' FROM `information_schema`.`TABLES` t'
1088
                    . ' WHERE `TABLE_SCHEMA` IN (\'pma_test\')'
1089
                    . ' AND t.`TABLE_NAME` = \'table1\' ORDER BY Name ASC',
1090
                'columns' => [
1091
                    'TABLE_CATALOG',
1092
                    'TABLE_SCHEMA',
1093
                    'TABLE_NAME',
1094
                    'TABLE_TYPE',
1095
                    'ENGINE',
1096
                    'VERSION',
1097
                    'ROW_FORMAT',
1098
                    'TABLE_ROWS',
1099
                    'AVG_ROW_LENGTH',
1100
                    'DATA_LENGTH',
1101
                    'MAX_DATA_LENGTH',
1102
                    'INDEX_LENGTH',
1103
                    'DATA_FREE',
1104
                    'AUTO_INCREMENT',
1105
                    'CREATE_TIME',
1106
                    'UPDATE_TIME',
1107
                    'CHECK_TIME',
1108
                    'TABLE_COLLATION',
1109
                    'CHECKSUM',
1110
                    'CREATE_OPTIONS',
1111
                    'TABLE_COMMENT',
1112
                    'Db',
1113
                    'Name',
1114
                    'TABLE_TYPE',
1115
                    'Engine',
1116
                    'Type',
1117
                    'Version',
1118
                    'Row_format',
1119
                    'Rows',
1120
                    'Avg_row_length',
1121
                    'Data_length',
1122
                    'Max_data_length',
1123
                    'Index_length',
1124
                    'Data_free',
1125
                    'Auto_increment',
1126
                    'Create_time',
1127
                    'Update_time',
1128
                    'Check_time',
1129
                    'Collation',
1130
                    'Checksum',
1131
                    'Create_options',
1132
                    'Comment',
1133
                ],
1134
                'result'  => [
1135
                    [
1136
                        'def',
1137
                        'smash',
1138
                        'issues_issue',
1139
                        'BASE TABLE',
1140
                        'InnoDB',
1141
                        '10',
1142
                        'Compact',
1143
                        '9136',
1144
                        '862',
1145
                        '7880704',
1146
                        '0',
1147
                        '1032192',
1148
                        '420478976',
1149
                        '155862',
1150
                        '2012-08-29 13:28:28',
1151
                        'NULL',
1152
                        'NULL',
1153
                        'utf8_general_ci',
1154
                        'NULL',
1155
                        '',
1156
                        '',
1157
                        'smash',
1158
                        'issues_issue',
1159
                        'BASE TABLE',
1160
                        'InnoDB',
1161
                        'InnoDB',
1162
                        '10',
1163
                        'Compact',
1164
                        '9136',
1165
                        '862',
1166
                        '7880704',
1167
                        '0',
1168
                        '1032192',
1169
                        '420478976',
1170
                        '155862',
1171
                        '2012-08-29 13:28:28',
1172
                        'NULL',
1173
                        'NULL',
1174
                        'utf8_general_ci',
1175
                        'NULL',
1176
                    ],
1177
                ],
1178
            ],
1179
            [
1180
                'query'   => 'SELECT *, `TABLE_SCHEMA` AS `Db`, `TABLE_NAME` AS `Name`,'
1181
                    . ' `TABLE_TYPE` AS `TABLE_TYPE`, `ENGINE` AS `Engine`,'
1182
                    . ' `ENGINE` AS `Type`, `VERSION` AS `Version`,'
1183
                    . ' `ROW_FORMAT` AS `Row_format`, `TABLE_ROWS` AS `Rows`,'
1184
                    . ' `AVG_ROW_LENGTH` AS `Avg_row_length`,'
1185
                    . ' `DATA_LENGTH` AS `Data_length`,'
1186
                    . ' `MAX_DATA_LENGTH` AS `Max_data_length`,'
1187
                    . ' `INDEX_LENGTH` AS `Index_length`, `DATA_FREE` AS `Data_free`,'
1188
                    . ' `AUTO_INCREMENT` AS `Auto_increment`,'
1189
                    . ' `CREATE_TIME` AS `Create_time`, `UPDATE_TIME` AS `Update_time`,'
1190
                    . ' `CHECK_TIME` AS `Check_time`, `TABLE_COLLATION` AS `Collation`,'
1191
                    . ' `CHECKSUM` AS `Checksum`, `CREATE_OPTIONS` AS `Create_options`,'
1192
                    . ' `TABLE_COMMENT` AS `Comment`'
1193
                    . ' FROM `information_schema`.`TABLES` t'
1194
                    . ' WHERE `TABLE_SCHEMA` IN (\'pma_test\')'
1195
                    . ' AND t.`TABLE_NAME` = \'table1\' ORDER BY Name ASC',
1196
                'columns' => [
1197
                    'TABLE_CATALOG',
1198
                    'TABLE_SCHEMA',
1199
                    'TABLE_NAME',
1200
                    'TABLE_TYPE',
1201
                    'ENGINE',
1202
                    'VERSION',
1203
                    'ROW_FORMAT',
1204
                    'TABLE_ROWS',
1205
                    'AVG_ROW_LENGTH',
1206
                    'DATA_LENGTH',
1207
                    'MAX_DATA_LENGTH',
1208
                    'INDEX_LENGTH',
1209
                    'DATA_FREE',
1210
                    'AUTO_INCREMENT',
1211
                    'CREATE_TIME',
1212
                    'UPDATE_TIME',
1213
                    'CHECK_TIME',
1214
                    'TABLE_COLLATION',
1215
                    'CHECKSUM',
1216
                    'CREATE_OPTIONS',
1217
                    'TABLE_COMMENT',
1218
                    'Db',
1219
                    'Name',
1220
                    'TABLE_TYPE',
1221
                    'Engine',
1222
                    'Type',
1223
                    'Version',
1224
                    'Row_format',
1225
                    'Rows',
1226
                    'Avg_row_length',
1227
                    'Data_length',
1228
                    'Max_data_length',
1229
                    'Index_length',
1230
                    'Data_free',
1231
                    'Auto_increment',
1232
                    'Create_time',
1233
                    'Update_time',
1234
                    'Check_time',
1235
                    'Collation',
1236
                    'Checksum',
1237
                    'Create_options',
1238
                    'Comment',
1239
                ],
1240
                'result'  => [
1241
                    [
1242
                        'def',
1243
                        'smash',
1244
                        'issues_issue',
1245
                        'BASE TABLE',
1246
                        'InnoDB',
1247
                        '10',
1248
                        'Compact',
1249
                        '9136',
1250
                        '862',
1251
                        '7880704',
1252
                        '0',
1253
                        '1032192',
1254
                        '420478976',
1255
                        '155862',
1256
                        '2012-08-29 13:28:28',
1257
                        'NULL',
1258
                        'NULL',
1259
                        'utf8_general_ci',
1260
                        'NULL',
1261
                        '',
1262
                        '',
1263
                        'smash',
1264
                        'issues_issue',
1265
                        'BASE TABLE',
1266
                        'InnoDB',
1267
                        'InnoDB',
1268
                        '10',
1269
                        'Compact',
1270
                        '9136',
1271
                        '862',
1272
                        '7880704',
1273
                        '0',
1274
                        '1032192',
1275
                        '420478976',
1276
                        '155862',
1277
                        '2012-08-29 13:28:28',
1278
                        'NULL',
1279
                        'NULL',
1280
                        'utf8_general_ci',
1281
                        'NULL',
1282
                    ],
1283
                ],
1284
            ],
1285
            [
1286
                'query'   => 'SELECT *, `TABLE_SCHEMA` AS `Db`, `TABLE_NAME` AS `Name`,'
1287
                    . ' `TABLE_TYPE` AS `TABLE_TYPE`, `ENGINE` AS `Engine`,'
1288
                    . ' `ENGINE` AS `Type`, `VERSION` AS `Version`,'
1289
                    . ' `ROW_FORMAT` AS `Row_format`, `TABLE_ROWS` AS `Rows`,'
1290
                    . ' `AVG_ROW_LENGTH` AS `Avg_row_length`,'
1291
                    . ' `DATA_LENGTH` AS `Data_length`,'
1292
                    . ' `MAX_DATA_LENGTH` AS `Max_data_length`,'
1293
                    . ' `INDEX_LENGTH` AS `Index_length`, `DATA_FREE` AS `Data_free`,'
1294
                    . ' `AUTO_INCREMENT` AS `Auto_increment`,'
1295
                    . ' `CREATE_TIME` AS `Create_time`, `UPDATE_TIME` AS `Update_time`,'
1296
                    . ' `CHECK_TIME` AS `Check_time`, `TABLE_COLLATION` AS `Collation`,'
1297
                    . ' `CHECKSUM` AS `Checksum`, `CREATE_OPTIONS` AS `Create_options`,'
1298
                    . ' `TABLE_COMMENT` AS `Comment`'
1299
                    . ' FROM `information_schema`.`TABLES` t'
1300
                    . ' WHERE `TABLE_SCHEMA` IN (\'my_db\')'
1301
                    . ' AND t.`TABLE_NAME` = \'test_tbl\' ORDER BY Name ASC',
1302
                'columns' => [
1303
                    'TABLE_CATALOG',
1304
                    'TABLE_SCHEMA',
1305
                    'TABLE_NAME',
1306
                    'TABLE_TYPE',
1307
                    'ENGINE',
1308
                    'VERSION',
1309
                    'ROW_FORMAT',
1310
                    'TABLE_ROWS',
1311
                    'AVG_ROW_LENGTH',
1312
                    'DATA_LENGTH',
1313
                    'MAX_DATA_LENGTH',
1314
                    'INDEX_LENGTH',
1315
                    'DATA_FREE',
1316
                    'AUTO_INCREMENT',
1317
                    'CREATE_TIME',
1318
                    'UPDATE_TIME',
1319
                    'CHECK_TIME',
1320
                    'TABLE_COLLATION',
1321
                    'CHECKSUM',
1322
                    'CREATE_OPTIONS',
1323
                    'TABLE_COMMENT',
1324
                    'Db',
1325
                    'Name',
1326
                    'TABLE_TYPE',
1327
                    'Engine',
1328
                    'Type',
1329
                    'Version',
1330
                    'Row_format',
1331
                    'Rows',
1332
                    'Avg_row_length',
1333
                    'Data_length',
1334
                    'Max_data_length',
1335
                    'Index_length',
1336
                    'Data_free',
1337
                    'Auto_increment',
1338
                    'Create_time',
1339
                    'Update_time',
1340
                    'Check_time',
1341
                    'Collation',
1342
                    'Checksum',
1343
                    'Create_options',
1344
                    'Comment',
1345
                ],
1346
                'result'  => [],
1347
            ],
1348
            [
1349
                'query'  => 'SELECT COUNT(*) FROM `pma_test`.`table1`',
1350
                'result' => [[0]],
1351
            ],
1352
            [
1353
                'query'  => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
1354
                    . '`USER_PRIVILEGES`'
1355
                    . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
1356
                    . ' AND PRIVILEGE_TYPE=\'TRIGGER\'',
1357
                'result' => [],
1358
            ],
1359
            [
1360
                'query'  => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
1361
                    . '`SCHEMA_PRIVILEGES`'
1362
                    . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
1363
                    . ' AND PRIVILEGE_TYPE=\'TRIGGER\' AND \'pma_test\''
1364
                    . ' LIKE `TABLE_SCHEMA`',
1365
                'result' => [],
1366
            ],
1367
            [
1368
                'query'  => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
1369
                    . '`TABLE_PRIVILEGES`'
1370
                    . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
1371
                    . ' AND PRIVILEGE_TYPE=\'TRIGGER\' AND \'pma_test\''
1372
                    . ' LIKE `TABLE_SCHEMA` AND TABLE_NAME=\'table1\'',
1373
                'result' => [],
1374
            ],
1375
            [
1376
                'query'  => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
1377
                    . '`USER_PRIVILEGES`'
1378
                    . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
1379
                    . ' AND PRIVILEGE_TYPE=\'EVENT\'',
1380
                'result' => [],
1381
            ],
1382
            [
1383
                'query'  => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
1384
                    . '`SCHEMA_PRIVILEGES`'
1385
                    . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
1386
                    . ' AND PRIVILEGE_TYPE=\'EVENT\' AND \'pma_test\''
1387
                    . ' LIKE `TABLE_SCHEMA`',
1388
                'result' => [],
1389
            ],
1390
            [
1391
                'query'  => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
1392
                    . '`TABLE_PRIVILEGES`'
1393
                    . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
1394
                    . ' AND PRIVILEGE_TYPE=\'EVENT\''
1395
                    . ' AND TABLE_SCHEMA=\'pma\\\\_test\' AND TABLE_NAME=\'table1\'',
1396
                'result' => [],
1397
            ],
1398
            [
1399
                'query'  => 'RENAME TABLE `pma_test`.`table1` TO `pma_test`.`table3`;',
1400
                'result' => [],
1401
            ],
1402
            [
1403
                'query'  => 'SELECT TRIGGER_SCHEMA, TRIGGER_NAME, EVENT_MANIPULATION,'
1404
                    . ' EVENT_OBJECT_TABLE, ACTION_TIMING, ACTION_STATEMENT, '
1405
                    . 'EVENT_OBJECT_SCHEMA, EVENT_OBJECT_TABLE, DEFINER'
1406
                    . ' FROM information_schema.TRIGGERS'
1407
                    . ' WHERE EVENT_OBJECT_SCHEMA= \'pma_test\''
1408
                    . ' AND EVENT_OBJECT_TABLE = \'table1\';',
1409
                'result' => [],
1410
            ],
1411
            [
1412
                'query'  => 'SHOW TABLES FROM `pma`;',
1413
                'result' => [],
1414
            ],
1415
            [
1416
                'query'  => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
1417
                    . "`SCHEMA_PRIVILEGES` WHERE GRANTEE='''pma_test''@''localhost'''"
1418
                    . " AND PRIVILEGE_TYPE='EVENT' AND TABLE_SCHEMA='pma'",
1419
                'result' => [],
1420
            ],
1421
            [
1422
                'query'  => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
1423
                    . "`SCHEMA_PRIVILEGES` WHERE GRANTEE='''pma_test''@''localhost'''"
1424
                    . " AND PRIVILEGE_TYPE='TRIGGER' AND TABLE_SCHEMA='pma'",
1425
                'result' => [],
1426
            ],
1427
            [
1428
                'query'  => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
1429
                    . "`TABLE_PRIVILEGES` WHERE GRANTEE='''pma_test''@''localhost'''"
1430
                    . " AND PRIVILEGE_TYPE='TRIGGER' AND 'db' LIKE `TABLE_SCHEMA` AND TABLE_NAME='table'",
1431
                'result' => [],
1432
            ],
1433
            [
1434
                'query'   => 'SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA'
1435
                    . ' WHERE SCHEMA_NAME = \'pma_test\' LIMIT 1',
1436
                'columns' => ['DEFAULT_COLLATION_NAME'],
1437
                'result'  => [
1438
                    ['utf8_general_ci'],
1439
                ],
1440
            ],
1441
            [
1442
                'query'   => 'SELECT @@collation_database',
1443
                'columns' => ['@@collation_database'],
1444
                'result'  => [
1445
                    ['bar'],
1446
                ],
1447
            ],
1448
            [
1449
                'query'  => 'SHOW TABLES FROM `phpmyadmin`',
1450
                'result' => [],
1451
            ],
1452
            [
1453
                'query'   => 'SELECT tracking_active FROM `pmadb`.`tracking`' .
1454
                    " WHERE db_name = 'pma_test_db'" .
1455
                    " AND table_name = 'pma_test_table'" .
1456
                    ' ORDER BY version DESC LIMIT 1',
1457
                'columns' => ['tracking_active'],
1458
                'result'  => [
1459
                    [1],
1460
                ],
1461
            ],
1462
            [
1463
                'query'  => 'SELECT tracking_active FROM `pmadb`.`tracking`' .
1464
                    " WHERE db_name = 'pma_test_db'" .
1465
                    " AND table_name = 'pma_test_table2'" .
1466
                    ' ORDER BY version DESC LIMIT 1',
1467
                'result' => [],
1468
            ],
1469
            [
1470
                'query'  => 'SHOW SLAVE STATUS',
1471
                'result' => [
1472
                    [
1473
                        'Slave_IO_State'              => 'running',
1474
                        'Master_Host'                 => 'localhost',
1475
                        'Master_User'                 => 'Master_User',
1476
                        'Master_Port'                 => '1002',
1477
                        'Connect_Retry'               => 'Connect_Retry',
1478
                        'Master_Log_File'             => 'Master_Log_File',
1479
                        'Read_Master_Log_Pos'         => 'Read_Master_Log_Pos',
1480
                        'Relay_Log_File'              => 'Relay_Log_File',
1481
                        'Relay_Log_Pos'               => 'Relay_Log_Pos',
1482
                        'Relay_Master_Log_File'       => 'Relay_Master_Log_File',
1483
                        'Slave_IO_Running'            => 'NO',
1484
                        'Slave_SQL_Running'           => 'NO',
1485
                        'Replicate_Do_DB'             => 'Replicate_Do_DB',
1486
                        'Replicate_Ignore_DB'         => 'Replicate_Ignore_DB',
1487
                        'Replicate_Do_Table'          => 'Replicate_Do_Table',
1488
                        'Replicate_Ignore_Table'      => 'Replicate_Ignore_Table',
1489
                        'Replicate_Wild_Do_Table'     => 'Replicate_Wild_Do_Table',
1490
                        'Replicate_Wild_Ignore_Table' => 'Replicate_Wild_Ignore_Table',
1491
                        'Last_Errno'                  => 'Last_Errno',
1492
                        'Last_Error'                  => 'Last_Error',
1493
                        'Skip_Counter'                => 'Skip_Counter',
1494
                        'Exec_Master_Log_Pos'         => 'Exec_Master_Log_Pos',
1495
                        'Relay_Log_Space'             => 'Relay_Log_Space',
1496
                        'Until_Condition'             => 'Until_Condition',
1497
                        'Until_Log_File'              => 'Until_Log_File',
1498
                        'Until_Log_Pos'               => 'Until_Log_Pos',
1499
                        'Master_SSL_Allowed'          => 'Master_SSL_Allowed',
1500
                        'Master_SSL_CA_File'          => 'Master_SSL_CA_File',
1501
                        'Master_SSL_CA_Path'          => 'Master_SSL_CA_Path',
1502
                        'Master_SSL_Cert'             => 'Master_SSL_Cert',
1503
                        'Master_SSL_Cipher'           => 'Master_SSL_Cipher',
1504
                        'Master_SSL_Key'              => 'Master_SSL_Key',
1505
                        'Seconds_Behind_Master'       => 'Seconds_Behind_Master',
1506
                    ],
1507
                ],
1508
            ],
1509
            [
1510
                'query'  => 'SHOW MASTER STATUS',
1511
                'result' => [
1512
                    [
1513
                        'File'             => 'master-bin.000030',
1514
                        'Position'         => '107',
1515
                        'Binlog_Do_DB'     => 'Binlog_Do_DB',
1516
                        'Binlog_Ignore_DB' => 'Binlog_Ignore_DB',
1517
                    ],
1518
                ],
1519
            ],
1520
            [
1521
                'query'  => 'SHOW GRANTS',
1522
                'result' => [],
1523
            ],
1524
            [
1525
                'query'  => 'SELECT `SCHEMA_NAME` FROM `INFORMATION_SCHEMA`.`SCHEMATA`, '
1526
                    . '(SELECT DB_first_level FROM ( SELECT DISTINCT '
1527
                    . "SUBSTRING_INDEX(SCHEMA_NAME, '_', 1) DB_first_level "
1528
                    . 'FROM INFORMATION_SCHEMA.SCHEMATA WHERE TRUE ) t ORDER BY '
1529
                    . 'DB_first_level ASC LIMIT 0, 100) t2 WHERE TRUE AND 1 = LOCATE('
1530
                    . "CONCAT(DB_first_level, '_'), CONCAT(SCHEMA_NAME, '_')) "
1531
                    . 'ORDER BY SCHEMA_NAME ASC',
1532
                'columns' => ['SCHEMA_NAME'],
1533
                'result' => [
1534
                    ['test'],
1535
                ],
1536
            ],
1537
            [
1538
                'query'  => 'SELECT COUNT(*) FROM ( SELECT DISTINCT SUBSTRING_INDEX('
1539
                    . "SCHEMA_NAME, '_', 1) DB_first_level "
1540
                    . 'FROM INFORMATION_SCHEMA.SCHEMATA WHERE TRUE ) t',
1541
                'result' => [
1542
                    [1],
1543
                ],
1544
            ],
1545
            [
1546
                'query'  => 'SELECT `PARTITION_METHOD` '
1547
                    . 'FROM `information_schema`.`PARTITIONS` '
1548
                    . "WHERE `TABLE_SCHEMA` = 'db' AND `TABLE_NAME` = 'table' LIMIT 1",
1549
                'result' => [],
1550
            ],
1551
            [
1552
                'query' => 'SHOW PLUGINS',
1553
                'result' => [
1554
                    [
1555
                        'Name' => 'partition',
1556
                        'Status' => 'ACTIVE',
1557
                        'Type' => 'STORAGE ENGINE',
1558
                        'Library' => null,
1559
                        'License' => 'GPL',
1560
                    ],
1561
                ],
1562
            ],
1563
            [
1564
                'query' => 'SELECT * FROM information_schema.PLUGINS ORDER BY PLUGIN_TYPE, PLUGIN_NAME',
1565
                'result' => [
1566
                    [
1567
                        'PLUGIN_NAME' => 'BLACKHOLE',
1568
                        'PLUGIN_VERSION' => '1.0',
1569
                        'PLUGIN_STATUS' => 'ACTIVE',
1570
                        'PLUGIN_TYPE' => 'STORAGE ENGINE',
1571
                        'PLUGIN_TYPE_VERSION' => '100316.0',
1572
                        'PLUGIN_LIBRARY' => 'ha_blackhole.so',
1573
                        'PLUGIN_LIBRARY_VERSION' => '1.13',
1574
                        'PLUGIN_AUTHOR' => 'MySQL AB',
1575
                        'PLUGIN_DESCRIPTION' => '/dev/null storage engine (anything you write to it disappears)',
1576
                        'PLUGIN_LICENSE' => 'GPL',
1577
                        'LOAD_OPTION' => 'ON',
1578
                        'PLUGIN_MATURITY' => 'Stable',
1579
                        'PLUGIN_AUTH_VERSION' => '1.0',
1580
                    ],
1581
                ],
1582
            ],
1583
            [
1584
                'query'  => "SHOW FULL TABLES FROM `default` WHERE `Table_type` IN('BASE TABLE', 'SYSTEM VERSIONED')",
1585
                'result' => [
1586
                    [
1587
                        'test1',
1588
                        'BASE TABLE',
1589
                    ],
1590
                    [
1591
                        'test2',
1592
                        'BASE TABLE',
1593
                    ],
1594
                ],
1595
            ],
1596
            [
1597
                'query'  => 'SHOW FULL TABLES FROM `default` '
1598
                    . "WHERE `Table_type` NOT IN('BASE TABLE', 'SYSTEM VERSIONED')",
1599
                'result' => [],
1600
            ],
1601
            [
1602
                'query'  => "SHOW FUNCTION STATUS WHERE `Db`='default'",
1603
                'result' => [['Name' => 'testFunction']],
1604
            ],
1605
            [
1606
                'query'  => "SHOW PROCEDURE STATUS WHERE `Db`='default'",
1607
                'result' => [],
1608
            ],
1609
            [
1610
                'query'  => 'SHOW EVENTS FROM `default`',
1611
                'result' => [],
1612
            ],
1613
            [
1614
                'query'  => 'FLUSH PRIVILEGES',
1615
                'result' => [],
1616
            ],
1617
            [
1618
                'query'  => 'SELECT * FROM `mysql`.`db` LIMIT 1',
1619
                'result' => [],
1620
            ],
1621
            [
1622
                'query'  => 'SELECT * FROM `mysql`.`columns_priv` LIMIT 1',
1623
                'result' => [],
1624
            ],
1625
            [
1626
                'query'  => 'SELECT * FROM `mysql`.`tables_priv` LIMIT 1',
1627
                'result' => [],
1628
            ],
1629
            [
1630
                'query'  => 'SELECT * FROM `mysql`.`procs_priv` LIMIT 1',
1631
                'result' => [],
1632
            ],
1633
            [
1634
                'query' => 'DELETE FROM `mysql`.`db` WHERE `host` = "" '
1635
                    . 'AND `Db` = "" AND `User` = ""',
1636
                'result' => true,
1637
            ],
1638
            [
1639
                'query' => 'DELETE FROM `mysql`.`columns_priv` WHERE '
1640
                    . '`host` = "" AND `Db` = "" AND `User` = ""',
1641
                'result' => true,
1642
            ],
1643
            [
1644
                'query' => 'DELETE FROM `mysql`.`tables_priv` WHERE '
1645
                    . '`host` = "" AND `Db` = "" AND `User` = "" AND Table_name = ""',
1646
                'result' => true,
1647
            ],
1648
            [
1649
                'query'  => 'DELETE FROM `mysql`.`procs_priv` WHERE '
1650
                    . '`host` = "" AND `Db` = "" AND `User` = "" AND `Routine_name` = "" '
1651
                    . 'AND `Routine_type` = ""',
1652
                'result' => true,
1653
            ],
1654
            [
1655
                'query' => 'SELECT `plugin` FROM `mysql`.`user` WHERE '
1656
                    . '`User` = "pma_username" AND `Host` = "pma_hostname" LIMIT 1',
1657
                'result' => [],
1658
            ],
1659
            [
1660
                'query'  => 'SELECT @@default_authentication_plugin',
1661
                'result' => [
1662
                    ['@@default_authentication_plugin' => 'mysql_native_password'],
1663
                ],
1664
            ],
1665
            [
1666
                'query'  => 'SELECT TABLE_NAME FROM information_schema.VIEWS WHERE '
1667
                    . "TABLE_SCHEMA = 'db' AND TABLE_NAME = 'table'",
1668
                'result' => [],
1669
            ],
1670
            [
1671
                'query'  => 'SELECT *, `TABLE_SCHEMA` AS `Db`, '
1672
                    . '`TABLE_NAME` AS `Name`, `TABLE_TYPE` AS `TABLE_TYPE`, '
1673
                    . '`ENGINE` AS `Engine`, `ENGINE` AS `Type`, '
1674
                    . '`VERSION` AS `Version`, `ROW_FORMAT` AS `Row_format`, '
1675
                    . '`TABLE_ROWS` AS `Rows`, `AVG_ROW_LENGTH` AS `Avg_row_length`, '
1676
                    . '`DATA_LENGTH` AS `Data_length`, '
1677
                    . '`MAX_DATA_LENGTH` AS `Max_data_length`, '
1678
                    . '`INDEX_LENGTH` AS `Index_length`, `DATA_FREE` AS `Data_free`, '
1679
                    . '`AUTO_INCREMENT` AS `Auto_increment`, '
1680
                    . '`CREATE_TIME` AS `Create_time`, '
1681
                    . '`UPDATE_TIME` AS `Update_time`, `CHECK_TIME` AS `Check_time`, '
1682
                    . '`TABLE_COLLATION` AS `Collation`, `CHECKSUM` AS `Checksum`, '
1683
                    . '`CREATE_OPTIONS` AS `Create_options`, '
1684
                    . '`TABLE_COMMENT` AS `Comment` '
1685
                    . 'FROM `information_schema`.`TABLES` t '
1686
                    . "WHERE `TABLE_SCHEMA` IN ('db') "
1687
                    . "AND t.`TABLE_NAME` = 'table' ORDER BY Name ASC",
1688
                'result' => [],
1689
            ],
1690
            [
1691
                'query'  => "SHOW TABLE STATUS FROM `db` WHERE `Name` LIKE 'table%'",
1692
                'result' => [],
1693
            ],
1694
            [
1695
                'query'  => "SHOW TABLE STATUS FROM `my_dataset` WHERE `Name` LIKE 'company\_users%'",
1696
                'result' => [],
1697
            ],
1698
            [
1699
                'query'  => 'SELECT *, `TABLE_SCHEMA` AS `Db`, `TABLE_NAME` AS `Name`,'
1700
                . ' `TABLE_TYPE` AS `TABLE_TYPE`, `ENGINE` AS `Engine`,'
1701
                . ' `ENGINE` AS `Type`, `VERSION` AS `Version`, `ROW_FORMAT` AS `Row_format`,'
1702
                . ' `TABLE_ROWS` AS `Rows`, `AVG_ROW_LENGTH` AS `Avg_row_length`,'
1703
                . ' `DATA_LENGTH` AS `Data_length`, `MAX_DATA_LENGTH` AS `Max_data_length`,'
1704
                . ' `INDEX_LENGTH` AS `Index_length`, `DATA_FREE` AS `Data_free`,'
1705
                . ' `AUTO_INCREMENT` AS `Auto_increment`, `CREATE_TIME` AS `Create_time`,'
1706
                . ' `UPDATE_TIME` AS `Update_time`, `CHECK_TIME` AS `Check_time`,'
1707
                . ' `TABLE_COLLATION` AS `Collation`, `CHECKSUM` AS `Checksum`,'
1708
                . ' `CREATE_OPTIONS` AS `Create_options`, `TABLE_COMMENT` AS `Comment`'
1709
                . " FROM `information_schema`.`TABLES` t WHERE `TABLE_SCHEMA` IN ('table1')"
1710
                . " AND t.`TABLE_NAME` = 'pma_test' ORDER BY Name ASC",
1711
                'columns' => [
1712
                    'TABLE_CATALOG',
1713
                    'TABLE_SCHEMA',
1714
                    'TABLE_NAME',
1715
                    'TABLE_TYPE',
1716
                    'ENGINE',
1717
                    'VERSION',
1718
                    'ROW_FORMAT',
1719
                    'TABLE_ROWS',
1720
                    'AVG_ROW_LENGTH',
1721
                    'DATA_LENGTH',
1722
                    'MAX_DATA_LENGTH',
1723
                    'INDEX_LENGTH',
1724
                    'DATA_FREE',
1725
                    'AUTO_INCREMENT',
1726
                    'CREATE_TIME',
1727
                    'UPDATE_TIME',
1728
                    'CHECK_TIME',
1729
                    'TABLE_COLLATION',
1730
                    'CHECKSUM',
1731
                    'CREATE_OPTIONS',
1732
                    'TABLE_COMMENT',
1733
                    'Db',
1734
                    'Name',
1735
                    'TABLE_TYPE',
1736
                    'Engine',
1737
                    'Type',
1738
                    'Version',
1739
                    'Row_format',
1740
                    'Rows',
1741
                    'Avg_row_length',
1742
                    'Data_length',
1743
                    'Max_data_length',
1744
                    'Index_length',
1745
                    'Data_free',
1746
                    'Auto_increment',
1747
                    'Create_time',
1748
                    'Update_time',
1749
                    'Check_time',
1750
                    'Collation',
1751
                    'Checksum',
1752
                    'Create_options',
1753
                    'Comment',
1754
                ],
1755
                'result' => [
1756
                    [
1757
                        'ref',
1758
                        'pma_test',
1759
                        'table1',
1760
                        'BASE TABLE',
1761
                        'DBIdummy',
1762
                        '11',
1763
                        'Redundant',
1764
                        '123456',
1765
                        '42',
1766
                        '21708991',
1767
                        '281474976710655',// MyISAM
1768
                        '2048',// MyISAM
1769
                        '2547',
1770
                        '5',
1771
                        '2014-06-24 17:30:00',
1772
                        '2018-06-25 18:35:12',
1773
                        '2015-04-24 19:30:59',
1774
                        'utf8mb4_general_ci',
1775
                        '3844432963',
1776
                        'row_format=REDUNDANT',
1777
                        'Test comment for "table1" in \'pma_test\'',
1778
                        'table1',
1779
                        'DBIdummy',
1780
                        '11',
1781
                        'Redundant',
1782
                        '123456',
1783
                        '42',
1784
                        '21708991',
1785
                        '281474976710655',// MyISAM
1786
                        '2048',// MyISAM
1787
                        '2547',
1788
                        '5',
1789
                        '2014-06-24 17:30:00',
1790
                        '2018-06-25 18:35:12',
1791
                        '2015-04-24 19:30:59',
1792
                        'utf8mb4_general_ci',
1793
                        '3844432963',
1794
                        'row_format=REDUNDANT',
1795
                        'Test comment for "table1" in \'pma_test\'',
1796
                    ],
1797
                ],
1798
            ],
1799
            [
1800
                'query'  => "SHOW TABLE STATUS FROM `table1` WHERE `Name` LIKE 'pma\_test%'",
1801
                'columns' => [
1802
                    'Name',
1803
                    'TABLE_TYPE',
1804
                    'Engine',
1805
                    'Type',
1806
                    'Version',
1807
                    'Row_format',
1808
                    'Rows',
1809
                    'Avg_row_length',
1810
                    'Data_length',
1811
                    'Max_data_length',
1812
                    'Index_length',
1813
                    'Data_free',
1814
                    'Auto_increment',
1815
                    'Create_time',
1816
                    'Update_time',
1817
                    'Check_time',
1818
                    'Collation',
1819
                    'Checksum',
1820
                    'Create_options',
1821
                    'Comment',
1822
                ],
1823
                'result' => [
1824
                    [
1825
                        'table1',
1826
                        'DBIdummy',
1827
                        '11',
1828
                        'Redundant',
1829
                        '123456',
1830
                        '42',
1831
                        '21708991',
1832
                        '281474976710655',// MyISAM
1833
                        '2048',// MyISAM
1834
                        '2547',
1835
                        '5',
1836
                        '2014-06-24 17:30:00',
1837
                        '2018-06-25 18:35:12',
1838
                        '2015-04-24 19:30:59',
1839
                        'utf8mb4_general_ci',
1840
                        '3844432963',
1841
                        'row_format=REDUNDANT',
1842
                        'Test comment for "table1" in \'pma_test\'',
1843
                    ],
1844
                ],
1845
            ],
1846
            [
1847
                'query'  => 'SELECT *, CAST(BIN_NAME AS CHAR CHARACTER SET utf8) AS SCHEMA_NAME'
1848
                    . ' FROM (SELECT BINARY s.SCHEMA_NAME AS BIN_NAME, s.DEFAULT_COLLATION_NAME'
1849
                    . " FROM `information_schema`.SCHEMATA s WHERE `SCHEMA_NAME` LIKE 'pma_test'"
1850
                    . ' GROUP BY BINARY s.SCHEMA_NAME, s.DEFAULT_COLLATION_NAME ORDER BY'
1851
                    . ' BINARY `SCHEMA_NAME` ASC) a',
1852
                'result' => [
1853
                    [
1854
                        'BIN_NAME' => 'pma_test',
1855
                        'DEFAULT_COLLATION_NAME' => 'utf8mb4_general_ci',
1856
                        'SCHEMA_NAME' => 'pma_test',
1857
                    ],
1858
                ],
1859
            ],
1860
            [
1861
                'query' => 'SELECT *, CAST(BIN_NAME AS CHAR CHARACTER SET utf8) AS SCHEMA_NAME'
1862
                    . ' FROM (SELECT BINARY s.SCHEMA_NAME AS BIN_NAME, s.DEFAULT_COLLATION_NAME'
1863
                    . ' FROM `information_schema`.SCHEMATA s GROUP BY BINARY s.SCHEMA_NAME,'
1864
                    . ' s.DEFAULT_COLLATION_NAME ORDER BY BINARY `SCHEMA_NAME` ASC) a',
1865
                'columns' => [
1866
                    'BIN_NAME',
1867
                    'DEFAULT_COLLATION_NAME',
1868
                    'SCHEMA_NAME',
1869
                ],
1870
                'result' => [
1871
                    [
1872
                        'sakila',
1873
                        'utf8_general_ci',
1874
                        'sakila',
1875
                    ],
1876
                    [
1877
                        'employees',
1878
                        'latin1_swedish_ci',
1879
                        'employees',
1880
                    ],
1881
                ],
1882
            ],
1883
1884
            [
1885
                'query' => 'SELECT *, CAST(BIN_NAME AS CHAR CHARACTER SET utf8) AS SCHEMA_NAME'
1886
                    . ' FROM (SELECT BINARY s.SCHEMA_NAME AS BIN_NAME, s.DEFAULT_COLLATION_NAME,'
1887
                    . ' COUNT(t.TABLE_SCHEMA) AS SCHEMA_TABLES, SUM(t.TABLE_ROWS) AS'
1888
                    . ' SCHEMA_TABLE_ROWS, SUM(t.DATA_LENGTH) AS SCHEMA_DATA_LENGTH,'
1889
                    . ' SUM(t.MAX_DATA_LENGTH) AS SCHEMA_MAX_DATA_LENGTH, SUM(t.INDEX_LENGTH)'
1890
                    . ' AS SCHEMA_INDEX_LENGTH, SUM(t.DATA_LENGTH + t.INDEX_LENGTH) AS'
1891
                    . " SCHEMA_LENGTH, SUM(IF(t.ENGINE <> 'InnoDB', t.DATA_FREE, 0)) AS"
1892
                    . ' SCHEMA_DATA_FREE FROM `information_schema`.SCHEMATA s LEFT JOIN'
1893
                    . ' `information_schema`.TABLES t ON BINARY t.TABLE_SCHEMA = BINARY'
1894
                    . ' s.SCHEMA_NAME GROUP BY BINARY s.SCHEMA_NAME,'
1895
                    . ' s.DEFAULT_COLLATION_NAME ORDER BY `SCHEMA_TABLES` DESC) a',
1896
                'columns' => [
1897
                    'BIN_NAME',
1898
                    'DEFAULT_COLLATION_NAME',
1899
                    'SCHEMA_TABLES',
1900
                    'SCHEMA_TABLE_ROWS',
1901
                    'SCHEMA_DATA_LENGTH',
1902
                    'SCHEMA_INDEX_LENGTH',
1903
                    'SCHEMA_LENGTH',
1904
                    'SCHEMA_DATA_FREE',
1905
                    'SCHEMA_NAME',
1906
                ],
1907
                'result' => [
1908
                    [
1909
                        'sakila',
1910
                        'utf8_general_ci',
1911
                        '23',
1912
                        '47274',
1913
                        '4358144',
1914
                        '2392064',
1915
                        '6750208',
1916
                        '0',
1917
                        'sakila',
1918
                    ],
1919
                    [
1920
                        'employees',
1921
                        'latin1_swedish_ci',
1922
                        '8',
1923
                        '3912174',
1924
                        '148111360',
1925
                        '5816320',
1926
                        '153927680',
1927
                        '0',
1928
                        'employees',
1929
                    ],
1930
                ],
1931
            ],
1932
            [
1933
                'query'  => 'SELECT @@have_partitioning;',
1934
                'result' => [],
1935
            ],
1936
            [
1937
                'query'  => 'SELECT @@lower_case_table_names',
1938
                'result' => [],
1939
            ],
1940
            [
1941
                'query'  => 'SELECT `PLUGIN_NAME`, `PLUGIN_DESCRIPTION` FROM `information_schema`.`PLUGINS`'
1942
                    . ' WHERE `PLUGIN_TYPE` = \'AUTHENTICATION\';',
1943
                'columns' => ['PLUGIN_NAME', 'PLUGIN_DESCRIPTION'],
1944
                'result' => [
1945
                    ['mysql_old_password', 'Old MySQL-4.0 authentication'],
1946
                    ['mysql_native_password', 'Native MySQL authentication'],
1947
                    ['sha256_password', 'SHA256 password authentication'],
1948
                    ['caching_sha2_password', 'Caching sha2 authentication'],
1949
                    ['auth_socket', 'Unix Socket based authentication'],
1950
                    ['unknown_auth_plugin', 'Unknown authentication'],
1951
                ],
1952
            ],
1953
            [
1954
                'query'  => 'SHOW TABLES FROM `db`;',
1955
                'result' => [],
1956
            ],
1957
            [
1958
                'query'  => 'SELECT `PRIVILEGE_TYPE` FROM '
1959
                    . '`INFORMATION_SCHEMA`.`SCHEMA_PRIVILEGES` '
1960
                    . "WHERE GRANTEE='''pma_test''@''localhost''' "
1961
                    . "AND PRIVILEGE_TYPE='EVENT' AND 'db' LIKE `TABLE_SCHEMA`",
1962
                'result' => [],
1963
            ],
1964
            [
1965
                'query'  => 'SELECT `PRIVILEGE_TYPE` FROM '
1966
                    . '`INFORMATION_SCHEMA`.`SCHEMA_PRIVILEGES` '
1967
                    . "WHERE GRANTEE='''pma_test''@''localhost''' "
1968
                    . "AND PRIVILEGE_TYPE='TRIGGER' AND 'db' LIKE `TABLE_SCHEMA`",
1969
                'result' => [],
1970
            ],
1971
            [
1972
                'query'  => 'SELECT (COUNT(DB_first_level) DIV 100) * 100 from '
1973
                    . "( SELECT distinct SUBSTRING_INDEX(SCHEMA_NAME, '_', 1) "
1974
                    . 'DB_first_level FROM INFORMATION_SCHEMA.SCHEMATA '
1975
                    . "WHERE `SCHEMA_NAME` < 'db' ) t",
1976
                'result' => [],
1977
            ],
1978
            [
1979
                'query'  => 'SELECT (COUNT(DB_first_level) DIV 100) * 100 from '
1980
                    . "( SELECT distinct SUBSTRING_INDEX(SCHEMA_NAME, '_', 1) "
1981
                    . 'DB_first_level FROM INFORMATION_SCHEMA.SCHEMATA '
1982
                    . "WHERE `SCHEMA_NAME` < 'pma_test' ) t",
1983
                'result' => [],
1984
            ],
1985
            [
1986
                'query'  => 'SELECT `SCHEMA_NAME` FROM '
1987
                    . '`INFORMATION_SCHEMA`.`SCHEMATA`, '
1988
                    . '(SELECT DB_first_level FROM ( SELECT DISTINCT '
1989
                    . "SUBSTRING_INDEX(SCHEMA_NAME, '_', 1) DB_first_level FROM "
1990
                    . 'INFORMATION_SCHEMA.SCHEMATA WHERE TRUE ) t '
1991
                    . 'ORDER BY DB_first_level ASC LIMIT , 100) t2 WHERE TRUE AND '
1992
                    . "1 = LOCATE(CONCAT(DB_first_level, '_'), "
1993
                    . "CONCAT(SCHEMA_NAME, '_')) ORDER BY SCHEMA_NAME ASC",
1994
                'result' => [],
1995
            ],
1996
            [
1997
                'query' => 'SELECT @@ndb_version_string',
1998
                'result' => [['ndb-7.4.10']],
1999
            ],
2000
            [
2001
                'query' => 'SELECT *, `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS'
2002
                    . ' `Type`, `COLLATION_NAME` AS `Collation`, `IS_NULLABLE` AS'
2003
                    . ' `Null`, `COLUMN_KEY` AS `Key`, `COLUMN_DEFAULT` AS `Default`,'
2004
                    . ' `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`,'
2005
                    . ' `COLUMN_COMMENT` AS `Comment` FROM `information_schema`.`COLUMNS`'
2006
                    . " WHERE `TABLE_SCHEMA` = 'information_schema' AND `TABLE_NAME` = 'PMA'",
2007
                'result' => [],
2008
            ],
2009
            [
2010
                'query' => 'SELECT TABLE_NAME, COLUMN_NAME, REFERENCED_TABLE_NAME,'
2011
                    . ' REFERENCED_COLUMN_NAME FROM information_schema.key_column_usage'
2012
                    . " WHERE referenced_table_name IS NOT NULL AND TABLE_SCHEMA = 'test'"
2013
                    . " AND TABLE_NAME IN ('table1','table2') AND"
2014
                    . " REFERENCED_TABLE_NAME IN ('table1','table2');",
2015
                'result' => [
2016
                    [
2017
                        'TABLE_NAME' => 'table2',
2018
                        'COLUMN_NAME' => 'idtable2',
2019
                        'REFERENCED_TABLE_NAME' => 'table1',
2020
                        'REFERENCED_COLUMN_NAME' => 'idtable1',
2021
                    ],
2022
                ],
2023
            ],
2024
            [
2025
                'query' => 'SELECT `item_name`, `item_type` FROM `pmadb`.`navigationhiding`'
2026
                    . " WHERE `username`='user' AND `db_name`='db' AND `table_name`=''",
2027
                'result' => [
2028
                    [
2029
                        'item_name' => 'tableName',
2030
                        'item_type' => 'table',
2031
                    ],
2032
                    [
2033
                        'item_name' => 'viewName',
2034
                        'item_type' => 'view',
2035
                    ],
2036
                ],
2037
            ],
2038
            [
2039
                'query' => 'SELECT `Table_priv` FROM `mysql`.`tables_priv` WHERE `User` ='
2040
                    . ' \'PMA_username\' AND `Host` = \'PMA_hostname\' AND `Db` ='
2041
                    . ' \'PMA_db\' AND `Table_name` = \'PMA_table\';',
2042
                'result' => [
2043
                    ['Table_priv' => 'Select,Insert,Update,References,Create View,Show view'],
2044
                ],
2045
            ],
2046
            [
2047
                'query' => 'SHOW COLUMNS FROM `my_db`.`test_tbl`',
2048
                'result' => [],
2049
            ],
2050
            [
2051
                'query' => 'SHOW COLUMNS FROM `mysql`.`tables_priv` LIKE \'Table_priv\';',
2052
                'result' => [
2053
                    ['Type' => 'set(\'Select\',\'Insert\',\'Update\',\'References\',\'Create View\',\'Show view\')'],
2054
                ],
2055
            ],
2056
            [
2057
                'query' => 'SHOW COLUMNS FROM `PMA_db`.`PMA_table`;',
2058
                'columns' => [
2059
                    'Field',
2060
                    'Type',
2061
                    'Null',
2062
                    'Key',
2063
                    'Default',
2064
                    'Extra',
2065
                ],
2066
                'result' => [
2067
                    [
2068
                        'id',
2069
                        'int(11)',
2070
                        'NO',
2071
                        'PRI',
2072
                        null,
2073
                        'auto_increment',
2074
                    ],
2075
                    [
2076
                        'name',
2077
                        'varchar(20)',
2078
                        'NO',
2079
                        '',
2080
                        null,
2081
                        '',
2082
                    ],
2083
                    [
2084
                        'datetimefield',
2085
                        'datetime',
2086
                        'NO',
2087
                        '',
2088
                        null,
2089
                        '',
2090
                    ],
2091
                ],
2092
            ],
2093
            [
2094
                'query' => 'SELECT `Column_name`, `Column_priv` FROM `mysql`.`columns_priv`'
2095
                    . ' WHERE `User` = \'PMA_username\' AND `Host` = \'PMA_hostname\' AND'
2096
                    . ' `Db` = \'PMA_db\' AND `Table_name` = \'PMA_table\';',
2097
                'columns' => [
2098
                    'Column_name',
2099
                    'Column_priv',
2100
                ],
2101
                'result' => [
2102
                    [
2103
                        'id',
2104
                        'Select',
2105
                    ],
2106
                    [
2107
                        'name',
2108
                        'Select',
2109
                    ],
2110
                    [
2111
                        'datetimefield',
2112
                        'Select',
2113
                    ],
2114
                ],
2115
            ],
2116
            [
2117
                'query' => 'SHOW GLOBAL STATUS',
2118
                'columns' => ['Variable_name', 'Value'],
2119
                'result' => [
2120
                    ['Aborted_clients', '0'],
2121
                    ['Aborted_connects', '0'],
2122
                    ['Com_delete_multi', '0'],
2123
                    ['Com_create_function', '0'],
2124
                    ['Com_empty_query', '0'],
2125
                ],
2126
            ],
2127
            [
2128
                'query' => 'SHOW GLOBAL VARIABLES',
2129
                'columns' => ['Variable_name', 'Value'],
2130
                'result' => [
2131
                    ['auto_increment_increment', '1'],
2132
                    ['auto_increment_offset', '1'],
2133
                    ['automatic_sp_privileges', 'ON'],
2134
                    ['back_log', '50'],
2135
                    ['big_tables', 'OFF'],
2136
                    ['version', '8.0.2'],
2137
                ],
2138
            ],
2139
            [
2140
                'query' => 'SELECT start_time, user_host, Sec_to_Time(Sum(Time_to_Sec(query_time))) '
2141
                    . 'as query_time, Sec_to_Time(Sum(Time_to_Sec(lock_time))) as lock_time,'
2142
                    . ' SUM(rows_sent) AS rows_sent, SUM(rows_examined) AS rows_examined,'
2143
                    . ' db, sql_text, COUNT(sql_text) AS \'#\' FROM `mysql`.`slow_log` WHERE'
2144
                    . ' start_time > FROM_UNIXTIME(0) AND start_time < FROM_UNIXTIME(10) GROUP BY sql_text',
2145
                'columns' => ['sql_text', '#'],
2146
                'result' => [
2147
                    ['insert sql_text', 11],
2148
                    ['update sql_text', 10],
2149
                ],
2150
            ],
2151
            [
2152
                'query' => 'SELECT TIME(event_time) as event_time, user_host, thread_id,'
2153
                    . ' server_id, argument, count(argument) as \'#\' FROM `mysql`.`general_log`'
2154
                    . ' WHERE command_type=\'Query\' AND event_time > FROM_UNIXTIME(0)'
2155
                    . ' AND event_time < FROM_UNIXTIME(10) AND argument REGEXP \'^(INSERT'
2156
                    . '|SELECT|UPDATE|DELETE)\' GROUP by argument',
2157
                'columns' => ['sql_text', '#', 'argument'],
2158
                'result' => [
2159
                    ['insert sql_text', 10, 'argument argument2'],
2160
                    ['update sql_text', 11, 'argument3 argument4'],
2161
                ],
2162
            ],
2163
            [
2164
                'query' => 'SET PROFILING=1;',
2165
                'result' => [],
2166
            ],
2167
            [
2168
                'query' => 'query',
2169
                'result' => [],
2170
            ],
2171
            [
2172
                'query' => 'EXPLAIN query',
2173
                'columns' => ['sql_text', '#', 'argument'],
2174
                'result' => [
2175
                    ['insert sql_text', 10, 'argument argument2'],
2176
                ],
2177
            ],
2178
            [
2179
                'query' => 'SELECT seq,state,duration FROM INFORMATION_SCHEMA.PROFILING WHERE QUERY_ID=1 ORDER BY seq',
2180
                'result' => [],
2181
            ],
2182
            [
2183
                'query' => 'SHOW GLOBAL VARIABLES WHERE Variable_name IN '
2184
                    . '("general_log","slow_query_log","long_query_time","log_output")',
2185
                'columns' => ['Variable_name', 'Value'],
2186
                'result' => [
2187
                    ['general_log', 'OFF'],
2188
                    ['log_output', 'FILE'],
2189
                    ['long_query_time', '10.000000'],
2190
                    ['slow_query_log', 'OFF'],
2191
                ],
2192
            ],
2193
            [
2194
                'query' => 'INSERT INTO `db`.`table` (`username`, `export_type`, `template_name`, `template_data`)'
2195
                    . ' VALUES (\'user\', \'type\', \'name\', \'data\');',
2196
                'result' => [],
2197
            ],
2198
            [
2199
                'query' => 'SELECT * FROM `db`.`table` WHERE `username` = \'user\''
2200
                    . ' AND `export_type` = \'type\' ORDER BY `template_name`;',
2201
                'columns' => ['id', 'username', 'export_type', 'template_name', 'template_data'],
2202
                'result' => [
2203
                    ['1', 'user1', 'type1', 'name1', 'data1'],
2204
                    ['2', 'user2', 'type2', 'name2', 'data2'],
2205
                ],
2206
            ],
2207
            [
2208
                'query' => 'DELETE FROM `db`.`table` WHERE `id` = 1 AND `username` = \'user\';',
2209
                'result' => [],
2210
            ],
2211
            [
2212
                'query' => 'SELECT * FROM `db`.`table` WHERE `id` = 1 AND `username` = \'user\';',
2213
                'columns' => ['id', 'username', 'export_type', 'template_name', 'template_data'],
2214
                'result' => [
2215
                    ['1', 'user1', 'type1', 'name1', 'data1'],
2216
                ],
2217
            ],
2218
            [
2219
                'query' => 'UPDATE `db`.`table` SET `template_data` = \'data\''
2220
                    . ' WHERE `id` = 1 AND `username` = \'user\';',
2221
                'result' => [],
2222
            ],
2223
            [
2224
                'query' => 'SHOW SLAVE HOSTS',
2225
                'columns' => ['Server_id', 'Host'],
2226
                'result' => [
2227
                    ['Server_id1', 'Host1'],
2228
                    ['Server_id2', 'Host2'],
2229
                ],
2230
            ],
2231
            [
2232
                'query' => 'SHOW ALL SLAVES STATUS',
2233
                'result' => [],
2234
            ],
2235
            [
2236
                'query' => 'SHOW COLUMNS FROM `mysql`.`user`',
2237
                'columns' => ['Field', 'Type', 'Null'],
2238
                'result' => [['host', 'char(60)', 'NO']],
2239
            ],
2240
            [
2241
                'query' => 'SHOW INDEXES FROM `mysql`.`user`',
2242
                'result' => [],
2243
            ],
2244
            [
2245
                'query' => 'SHOW INDEXES FROM `my_db`.`test_tbl`',
2246
                'result' => [],
2247
            ],
2248
            [
2249
                'query' => 'SELECT USER();',
2250
                'result' => [],
2251
            ],
2252
            [
2253
                'query' => 'SHOW PROCESSLIST',
2254
                'columns' => ['Id', 'User', 'Host', 'db', 'Command', 'Time', 'State', 'Info'],
2255
                'result' => [['Id1', 'User1', 'Host1', 'db1', 'Command1', 'Time1', 'State1', 'Info1']],
2256
            ],
2257
            [
2258
                'query' => 'SELECT * FROM `INFORMATION_SCHEMA`.`PROCESSLIST` ORDER BY `db` ASC',
2259
                'columns' => ['Id', 'User', 'Host', 'db', 'Command', 'Time', 'State', 'Info'],
2260
                'result' => [['Id1', 'User1', 'Host1', 'db1', 'Command1', 'Time1', 'State1', 'Info1']],
2261
            ],
2262
            [
2263
                'query' => 'SELECT * FROM `INFORMATION_SCHEMA`.`PROCESSLIST` ORDER BY `Host` DESC',
2264
                'columns' => ['Id', 'User', 'Host', 'db', 'Command', 'Time', 'State', 'Info'],
2265
                'result' => [['Id1', 'User1', 'Host1', 'db1', 'Command1', 'Time1', 'State1', 'Info1']],
2266
            ],
2267
            [
2268
                'query' => 'SELECT * FROM `INFORMATION_SCHEMA`.`PROCESSLIST` ORDER BY `process` DESC',
2269
                'columns' => ['Id', 'User', 'Host', 'db', 'Command', 'Time', 'State', 'Info'],
2270
                'result' => [['Id1', 'User1', 'Host1', 'db1', 'Command1', 'Time1', 'State1', 'Info1']],
2271
            ],
2272
            [
2273
                'query' => 'SELECT UNIX_TIMESTAMP() - 36000',
2274
                'result' => [],
2275
            ],
2276
            [
2277
                'query' => 'SELECT MAX(version) FROM `pmadb`.`tracking` WHERE `db_name` = \'db\''
2278
                    . ' AND `table_name` = \'hello_world\'',
2279
                'columns' => ['version'],
2280
                'result' => [['10']],
2281
            ],
2282
            [
2283
                'query' => 'SELECT MAX(version) FROM `pmadb`.`tracking` WHERE `db_name` = \'db\''
2284
                    . ' AND `table_name` = \'hello_lovely_world\'',
2285
                'columns' => ['version'],
2286
                'result' => [['10']],
2287
            ],
2288
            [
2289
                'query' => 'SELECT MAX(version) FROM `pmadb`.`tracking` WHERE `db_name` = \'db\''
2290
                    . ' AND `table_name` = \'hello_lovely_world2\'',
2291
                'columns' => ['version'],
2292
                'result' => [['10']],
2293
            ],
2294
            [
2295
                'query' => 'SELECT DISTINCT db_name, table_name FROM `pmadb`.`tracking`'
2296
                    . ' WHERE db_name = \'PMA_db\' ORDER BY db_name, table_name',
2297
                'columns' => ['db_name', 'table_name', 'version'],
2298
                'result' => [['PMA_db', 'PMA_table', '10']],
2299
            ],
2300
            [
2301
                'query' => 'SELECT * FROM `pmadb`.`tracking` WHERE db_name = \'PMA_db\''
2302
                    . ' AND table_name = \'PMA_table\' ORDER BY version DESC',
2303
                'columns' => ['db_name', 'table_name', 'version', 'date_created', 'date_updated', 'tracking_active'],
2304
                'result' => [
2305
                    ['PMA_db', 'PMA_table', '1', 'date_created', 'date_updated', '1'],
2306
                    ['PMA_db', 'PMA_table', '2', 'date_created', 'date_updated', '0'],
2307
                ],
2308
            ],
2309
            [
2310
                'query' => 'SELECT tracking_active FROM `pmadb`.`tracking` WHERE db_name = \'PMA_db\''
2311
                    . ' AND table_name = \'PMA_table\' ORDER BY version DESC LIMIT 1',
2312
                'columns' => ['tracking_active'],
2313
                'result' => [['1']],
2314
            ],
2315
            [
2316
                'query' => 'SHOW TABLE STATUS FROM `PMA_db` WHERE `Name` LIKE \'PMA\_table%\'',
2317
                'columns' => ['Name'],
2318
                'result' => [['PMA_table']],
2319
            ],
2320
            [
2321
                'query' => 'SELECT `id` FROM `table_1` WHERE `id` > 10 AND (`id` <> 20)',
2322
                'columns' => ['id'],
2323
                'result' => [['11'], ['12']],
2324
            ],
2325
            [
2326
                'query' => 'SELECT * FROM `table_1` WHERE `id` > 10',
2327
                'columns' => ['column'],
2328
                'result' => [['row1'], ['row2']],
2329
            ],
2330
            [
2331
                'query' => 'SELECT * FROM `PMA`.`table_1` LIMIT 1',
2332
                'columns' => ['column'],
2333
                'result' => [['table']],
2334
            ],
2335
            [
2336
                'query' => 'SELECT * FROM `PMA`.`table_2` LIMIT 1',
2337
                'columns' => ['column'],
2338
                'result' => [['table']],
2339
            ],
2340
            [
2341
                'query' => 'SELECT `ENGINE` FROM `information_schema`.`tables` WHERE `table_name` = "table_1"'
2342
                    . ' AND `table_schema` = "PMA" AND UPPER(`engine`)'
2343
                    . ' IN ("INNODB", "FALCON", "NDB", "INFINIDB", "TOKUDB", "XTRADB", "SEQUENCE", "BDB")',
2344
                'columns' => ['ENGINE'],
2345
                'result' => [['INNODB']],
2346
            ],
2347
            [
2348
                'query' => 'SELECT `ENGINE` FROM `information_schema`.`tables` WHERE `table_name` = "table_2"'
2349
                    . ' AND `table_schema` = "PMA" AND UPPER(`engine`)'
2350
                    . ' IN ("INNODB", "FALCON", "NDB", "INFINIDB", "TOKUDB", "XTRADB", "SEQUENCE", "BDB")',
2351
                'columns' => ['ENGINE'],
2352
                'result' => [['INNODB']],
2353
            ],
2354
            [
2355
                'query' => 'SHOW BINLOG EVENTS IN \'index1\' LIMIT 3, 10',
2356
                'columns' => ['Info', 'Log_name', 'Pos', 'Event_type', 'Orig_log_pos', 'End_log_pos', 'Server_id'],
2357
                'result' => [
2358
                    [
2359
                        'index1_Info',
2360
                        'index1_Log_name',
2361
                        'index1_Pos',
2362
                        'index1_Event_type',
2363
                        'index1_Orig_log_pos',
2364
                        'index1_End_log_pos',
2365
                        'index1_Server_id',
2366
                    ],
2367
                ],
2368
            ],
2369
            [
2370
                'query' => 'SHOW FULL COLUMNS FROM `testdb`.`mytable` LIKE \'\_id\'',
2371
                'columns' => ['Field', 'Type', 'Collation', 'Null', 'Key', 'Default', 'Extra', 'Privileges', 'Comment'],
2372
                'result' => [
2373
                    [
2374
                        '_id',
2375
                        'tinyint(4)',
2376
                        null,
2377
                        'NO',
2378
                        '',
2379
                        null,
2380
                        '',
2381
                        'select,insert,update,references',
2382
                        '',
2383
                    ],
2384
                ],
2385
            ],
2386
            [
2387
                'query' => 'SHOW FULL COLUMNS FROM `testdb`.`mytable`',
2388
                'columns' => ['Field', 'Type', 'Collation', 'Null', 'Key', 'Default', 'Extra', 'Privileges', 'Comment'],
2389
                'result' => [
2390
                    [
2391
                        'aid',
2392
                        'tinyint(4)',
2393
                        null,
2394
                        'NO',
2395
                        'PRI',
2396
                        null,
2397
                        '',
2398
                        'select,insert,update,references',
2399
                        '',
2400
                    ],
2401
                    [
2402
                        '_id',
2403
                        'tinyint(4)',
2404
                        null,
2405
                        'NO',
2406
                        '',
2407
                        null,
2408
                        '',
2409
                        'select,insert,update,references',
2410
                        '',
2411
                    ],
2412
                ],
2413
            ],
2414
            [
2415
                'query'  => 'SHOW INDEXES FROM `testdb`.`mytable`',
2416
                'result' => [],
2417
            ],
2418
            [
2419
                'query' => 'SHOW CREATE TABLE `testdb`.`mytable`',
2420
                'columns' => ['Table', 'Create Table'],
2421
                'result' => [
2422
                    [
2423
                        'test',
2424
                        'CREATE TABLE `test` ('
2425
                        . '    `aid` tinyint(4) NOT NULL,'
2426
                        . '    `_id` tinyint(4) NOT NULL,'
2427
                        . '    PRIMARY KEY (`aid`)'
2428
                        . ') ENGINE=InnoDB DEFAULT CHARSET=latin1',
2429
                    ],
2430
                ],
2431
            ],
2432
            [
2433
                'query' => 'SELECT * FROM `testdb`.`mytable` LIMIT 1',
2434
                'columns' => ['aid', '_id'],
2435
                'result' => [
2436
                    [
2437
                        1,
2438
                        1,
2439
                    ],
2440
                ],
2441
            ],
2442
            [
2443
                'query' => 'SHOW CREATE TABLE `test_db`.`test_table`',
2444
                'columns' => ['Table', 'Create Table'],
2445
                'result' => [['test_table', 'CREATE TABLE `test_table`']],
2446
            ],
2447
            [
2448
                'query' => 'SHOW COLUMNS FROM `test_db`.`test_table`',
2449
                'columns' => ['Field', 'Type', 'Null', 'Key', 'Default', 'Extra'],
2450
                'result' => [
2451
                    ['id', 'int(11)', 'NO', 'PRI', 'NULL', 'auto_increment'],
2452
                    ['name', 'varchar(20)', 'NO', '', 'NULL', ''],
2453
                    ['datetimefield', 'datetime', 'NO', '', 'NULL', ''],
2454
                ],
2455
            ],
2456
            [
2457
                'query' => 'SHOW FULL COLUMNS FROM `test_db`.`test_table`',
2458
                'columns' => ['Field', 'Type', 'Null', 'Key', 'Default', 'Extra'],
2459
                'result' => [
2460
                    ['id', 'int(11)', 'NO', 'PRI', 'NULL', 'auto_increment'],
2461
                    ['name', 'varchar(20)', 'NO', '', 'NULL', ''],
2462
                    ['datetimefield', 'datetime', 'NO', '', 'NULL', ''],
2463
                ],
2464
            ],
2465
            [
2466
                'query' => 'DESC `test_db`.`test_table`',
2467
                'columns' => ['Field', 'Type', 'Null', 'Key', 'Default', 'Extra'],
2468
                'result' => [
2469
                    ['id', 'int(11)', 'NO', 'PRI', 'NULL', 'auto_increment'],
2470
                    ['name', 'varchar(20)', 'NO', '', 'NULL', ''],
2471
                    ['datetimefield', 'datetime', 'NO', '', 'NULL', ''],
2472
                ],
2473
            ],
2474
            [
2475
                'query' => 'SHOW TABLE STATUS FROM `test_db` WHERE `Name` LIKE \'test\_table%\'',
2476
                'columns' => ['Name', 'Engine', 'Rows'],
2477
                'result' => [['test_table', 'InnoDB', '3']],
2478
            ],
2479
            [
2480
                'query' => 'SHOW TABLE STATUS FROM `test_db` WHERE Name = \'test_table\'',
2481
                'columns' => ['Name', 'Engine', 'Rows'],
2482
                'result' => [['test_table', 'InnoDB', '3']],
2483
            ],
2484
            [
2485
                'query' => 'SHOW INDEXES FROM `test_db`.`test_table`',
2486
                'columns' => ['Table', 'Non_unique', 'Key_name', 'Column_name'],
2487
                'result' => [['test_table', '0', 'PRIMARY', 'id']],
2488
            ],
2489
            [
2490
                'query' => 'SHOW INDEX FROM `test_table`;',
2491
                'columns' => ['Table', 'Non_unique', 'Key_name', 'Column_name'],
2492
                'result' => [['test_table', '0', 'PRIMARY', 'id']],
2493
            ],
2494
            [
2495
                'query' => 'SHOW TRIGGERS FROM `test_db` LIKE \'test_table\';',
2496
                'columns' => ['Trigger', 'Event', 'Table', 'Statement', 'Timing', 'Definer'],
2497
                'result' => [['test_trigger', 'INSERT', 'test_table', 'BEGIN END', 'AFTER', 'definer@localhost']],
2498
            ],
2499
            [
2500
                'query' => 'SELECT * FROM `test_db`.`test_table_yaml`;',
2501
                'columns' => ['id', 'name', 'datetimefield', 'textfield'],
2502
                'metadata' => [
2503
                    new FieldMetadata(MYSQLI_TYPE_DECIMAL, 0, (object) []),
2504
                    new FieldMetadata(MYSQLI_TYPE_STRING, 0, (object) []),
2505
                    new FieldMetadata(MYSQLI_TYPE_DATETIME, 0, (object) []),
2506
                    new FieldMetadata(MYSQLI_TYPE_STRING, 0, (object) []),
2507
                ],
2508
                'result' => [
2509
                    ['1', 'abcd', '2011-01-20 02:00:02', null],
2510
                    ['2', 'foo', '2010-01-20 02:00:02', null],
2511
                    ['3', 'Abcd', '2012-01-20 02:00:02', null],
2512
                    ['4', 'Abcd', '2012-01-20 02:00:02', '123'],
2513
                    ['5', 'Abcd', '2012-01-20 02:00:02', '+30.2103210000'],
2514
                ],
2515
            ],
2516
            [
2517
                'query' => 'SELECT * FROM `test_db`.`test_table`;',
2518
                'columns' => ['id', 'name', 'datetimefield'],
2519
                'result' => [
2520
                    ['1', 'abcd', '2011-01-20 02:00:02'],
2521
                    ['2', 'foo', '2010-01-20 02:00:02'],
2522
                    ['3', 'Abcd', '2012-01-20 02:00:02'],
2523
                ],
2524
            ],
2525
            [
2526
                'query' => 'SELECT * FROM `test_db`.`test_table_complex`;',
2527
                'columns' => ['f1', 'f2', 'f3', 'f4'],
2528
                'result' => [
2529
                    ['"\'"><iframe onload=alert(1)>шеллы', '0x12346857fefe', "My awesome\nText", '0xaf1234f68c57fefe'],
2530
                    [null, null, null, null],
2531
                    ['', '0x1', 'шеллы', '0x2'],
2532
                ],
2533
                'metadata' => [
2534
                    new FieldMetadata(MYSQLI_TYPE_STRING, 0, (object) ['charsetnr' => 33]),
2535
                    new FieldMetadata(MYSQLI_TYPE_STRING, 0, (object) ['charsetnr' => 63]),
2536
                    new FieldMetadata(MYSQLI_TYPE_BLOB, 0, (object) ['charsetnr' => 23]),
2537
                    new FieldMetadata(MYSQLI_TYPE_BLOB, 0, (object) ['charsetnr' => 63]),
2538
                ],
2539
            ],
2540
            [
2541
                'query' => 'SHOW PROCEDURE STATUS;',
2542
                'columns' => ['Db', 'Name', 'Type'],
2543
                'result' => [
2544
                    ['test_db', 'test_proc1', 'PROCEDURE'],
2545
                    ['test_db', 'test_proc2', 'PROCEDURE'],
2546
                ],
2547
            ],
2548
            [
2549
                'query' => 'SHOW FUNCTION STATUS;',
2550
                'columns' => ['Db', 'Name', 'Type'],
2551
                'result' => [['test_db', 'test_func', 'FUNCTION']],
2552
            ],
2553
            [
2554
                'query' => 'SHOW CREATE PROCEDURE `test_db`.`test_proc1`',
2555
                'columns' => ['Procedure', 'Create Procedure'],
2556
                'result' => [['test_proc1', 'CREATE PROCEDURE `test_proc1` (p INT) BEGIN END']],
2557
            ],
2558
            [
2559
                'query' => 'SHOW CREATE PROCEDURE `test_db`.`test_proc2`',
2560
                'columns' => ['Procedure', 'Create Procedure'],
2561
                'result' => [['test_proc2', 'CREATE PROCEDURE `test_proc2` (p INT) BEGIN END']],
2562
            ],
2563
            [
2564
                'query' => 'SHOW CREATE FUNCTION `test_db`.`test_func`',
2565
                'columns' => ['Function', 'Create Function'],
2566
                'result' => [['test_func', 'CREATE FUNCTION `test_func` (p INT) RETURNS int(11) BEGIN END']],
2567
            ],
2568
            [
2569
                'query'  => 'USE `test_db`',
2570
                'result' => [],
2571
            ],
2572
            [
2573
                'query'  => 'SET SQL_QUOTE_SHOW_CREATE = 0',
2574
                'result' => [],
2575
            ],
2576
            [
2577
                'query'  => 'SET SQL_QUOTE_SHOW_CREATE = 1',
2578
                'result' => [],
2579
            ],
2580
            [
2581
                'query' => 'UPDATE `test_tbl` SET `vc` = \'…zff s sf\' WHERE `test`.`ser` = 2',
2582
                'result' => [],
2583
            ],
2584
            [
2585
                'query' => 'UPDATE `test_tbl` SET `vc` = \'…ss s s\' WHERE `test`.`ser` = 1',
2586
                'result' => [],
2587
            ],
2588
            [
2589
                'query' => 'SELECT LAST_INSERT_ID();',
2590
                'result' => [],
2591
            ],
2592
            [
2593
                'query' => 'SHOW WARNINGS',
2594
                'result' => [],
2595
            ],
2596
            [
2597
                'query' => 'SELECT * FROM `information_schema`.`bookmark` WHERE dbase = \'my_db\''
2598
                . ' AND (user = \'user\') AND `label` = \'test_tbl\' LIMIT 1',
2599
                'result' => [],
2600
            ],
2601
            [
2602
                'query' => 'SELECT `prefs` FROM `information_schema`.`table_uiprefs` WHERE `username` = \'user\''
2603
                . ' AND `db_name` = \'my_db\' AND `table_name` = \'test_tbl\'',
2604
                'result' => [],
2605
            ],
2606
            [
2607
                'query' => 'SELECT DATABASE()',
2608
                'result' => [],
2609
            ],
2610
            [
2611
                'query' => 'SELECT * FROM `test_tbl` LIMIT 0, 25',
2612
                'columns' => ['vc', 'text', 'ser'],
2613
                'result' => [
2614
                    [
2615
                        'sss s s  ',
2616
                        '…z',
2617
                        1,
2618
                    ],
2619
                    [
2620
                        'zzff s sf',
2621
                        '…zff',
2622
                        2,
2623
                    ],
2624
                ],
2625
            ],
2626
            [
2627
                'query' => 'SELECT @@have_profiling',
2628
                'result' => [],
2629
            ],
2630
            [
2631
                'query'  => 'SELECT TABLE_NAME FROM information_schema.VIEWS'
2632
                    . ' WHERE TABLE_SCHEMA = \'my_db\' AND TABLE_NAME = \'test_tbl\'',
2633
                'result' => [],
2634
            ],
2635
            [
2636
                'query' => 'SHOW FULL COLUMNS FROM `my_db`.`test_tbl`',
2637
                'result' => [],
2638
            ],
2639
            [
2640
                'query' => 'SHOW TABLE STATUS FROM `my_db` WHERE `Name` LIKE \'test\_tbl%\'',
2641
                'result' => [],
2642
            ],
2643
            [
2644
                'query' => 'SHOW CREATE TABLE `my_db`.`test_tbl`',
2645
                'result' => [],
2646
            ],
2647
            [
2648
                'query' => 'SELECT COUNT(*) FROM `my_db`.`test_tbl`',
2649
                'result' => [],
2650
            ],
2651
            [
2652
                'query' => 'SELECT `master_field`, `foreign_db`, `foreign_table`, `foreign_field`'
2653
                . ' FROM `information_schema`.`relation`'
2654
                . ' WHERE `master_db` = \'my_db\' AND `master_table` = \'test_tbl\'',
2655
                'result' => [],
2656
            ],
2657
            [
2658
                'query' => 'SELECT `test_tbl`.`vc` FROM `my_db`.`test_tbl` WHERE `test`.`ser` = 2',
2659
                'result' => [],
2660
            ],
2661
            [
2662
                'query' => 'SELECT * FROM `pmadb`.`usergroups` ORDER BY `usergroup` ASC',
2663
                'columns' => ['usergroup', 'tab', 'allowed'],
2664
                'result' => [['usergroup', 'server_sql', 'Y']],
2665
            ],
2666
            [
2667
                'query' => 'DESCRIBE `test_table`',
2668
                'columns' => ['Field', 'Type', 'Null', 'Key', 'Default', 'Extra'],
2669
                'result' => [
2670
                    ['id', 'int(11)', 'NO', 'PRI', 'NULL', 'auto_increment'],
2671
                    ['name', 'varchar(20)', 'NO', '', 'NULL', ''],
2672
                    ['datetimefield', 'datetime', 'NO', '', 'NULL', ''],
2673
                ],
2674
            ],
2675
            [
2676
                'query' => 'SELECT * FROM `test_table` WHERE `id` = 4;',
2677
                'columns' => ['id', 'name', 'datetimefield'],
2678
                'result' => [['4', '101', '2013-01-20 02:00:02']],
2679
            ],
2680
            [
2681
                'query' => 'SELECT * FROM `mysql`.`user` WHERE `User` = \'username\' AND `Host` = \'hostname\';',
2682
                'columns' => ['Host', 'User', 'Password'],
2683
                'result' => [['hostname', 'username', 'password']],
2684
            ],
2685
            [
2686
                'query' => 'SELECT COUNT(*) FROM (SELECT * FROM company_users WHERE not_working_count != 0 ) as cnt',
2687
                'result' => false,
2688
            ],
2689
            [
2690
                'query' => 'SELECT COUNT(*) FROM (SELECT * FROM company_users ) as cnt',
2691
                'result' => [
2692
                    [4],
2693
                ],
2694
            ],
2695
            [
2696
                'query' => 'SELECT COUNT(*) FROM (SELECT * FROM company_users WHERE working_count = 0 ) as cnt',
2697
                'result' => [
2698
                    [15],
2699
                ],
2700
            ],
2701
            [
2702
                'query' => 'SELECT COUNT(*) FROM `my_dataset`.`company_users`',
2703
                'result' => [
2704
                    [18],
2705
                ],
2706
            ],
2707
            [
2708
                'query' => 'SELECT COUNT(*) FROM ('
2709
                . 'SELECT *, 1, (SELECT COUNT(*) FROM tbl1) as c1, '
2710
                . '(SELECT 1 FROM tbl2) as c2 FROM company_users WHERE subquery_case = 0 ) as cnt',
2711
                'result' => [
2712
                    [42],
2713
                ],
2714
            ],
2715
            [
2716
                'query' => 'CREATE TABLE `event` SELECT DISTINCT `eventID`, `Start_time`,'
2717
                . ' `DateOfEvent`, `NumberOfGuests`, `NameOfVenue`, `LocationOfVenue` FROM `test_tbl`;',
2718
                'result' => [],
2719
            ],
2720
            [
2721
                'query' => 'ALTER TABLE `event` ADD PRIMARY KEY(`eventID`);',
2722
                'result' => [],
2723
            ],
2724
            [
2725
                'query' => 'CREATE TABLE `table2` SELECT DISTINCT `Start_time`,'
2726
                            . ' `TypeOfEvent`, `period` FROM `test_tbl`;',
2727
                'result' => [],
2728
            ],
2729
            [
2730
                'query' => 'ALTER TABLE `table2` ADD PRIMARY KEY(`Start_time`);',
2731
                'result' => [],
2732
            ],
2733
            [
2734
                'query' => 'DROP TABLE `test_tbl`',
2735
                'result' => [],
2736
            ],
2737
            [
2738
                'query' => 'CREATE TABLE `batch_log2` SELECT DISTINCT `ID`, `task` FROM `test_tbl`;',
2739
                'result' => [],
2740
            ],
2741
            [
2742
                'query' => 'ALTER TABLE `batch_log2` ADD PRIMARY KEY(`ID`, `task`);',
2743
                'result' => [],
2744
            ],
2745
            [
2746
                'query' => 'CREATE TABLE `table2` SELECT DISTINCT `task`, `timestamp` FROM `test_tbl`;',
2747
                'result' => [],
2748
            ],
2749
            [
2750
                'query' => 'ALTER TABLE `table2` ADD PRIMARY KEY(`task`);',
2751
                'result' => [],
2752
            ],
2753
        ];
2754
        /**
2755
         * Current database.
2756
         */
2757
        $GLOBALS['dummy_db'] = '';
2758
2759
        /* Some basic setup for dummy driver */
2760
        $GLOBALS['cfg']['DBG']['sql'] = false;
2761
    }
2762
}
2763