Welcome to mirror list, hosted at ThFree Co, Russian Federation.

DBIDummy.class.php « dbi « libraries - github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 66d82f2011ec7be444bd08ebbd9728dd0c1793b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * Fake database driver for testing purposes
 *
 * It has hardcoded results for given queries what makes easy to use it
 * in testsuite. Feel free to include other queries which your test will
 * need.
 *
 * @package    PhpMyAdmin-DBI
 * @subpackage Dummy
 */
if (! defined('PHPMYADMIN')) {
    exit;
}

require_once './libraries/dbi/DBIExtension.int.php';

/**
 * Array of queries this "driver" supports
 */
$GLOBALS['dummy_queries'] = array(
    array('query' => 'SELECT 1', 'result' => array(array('1'))),
    array(
        'query' => 'SELECT CURRENT_USER();',
        'result' => array(array('pma_test@localhost')),
    ),
    array(
        'query' => 'SELECT 1 FROM mysql.user LIMIT 1',
        'result' => array(array('1')),
    ),
    array(
        'query' => "SELECT 1 FROM `INFORMATION_SCHEMA`.`USER_PRIVILEGES`"
            . " WHERE `PRIVILEGE_TYPE` = 'CREATE USER'"
            . " AND '''pma_test''@''localhost''' LIKE `GRANTEE` LIMIT 1",
        'result' => array(array('1')),
    ),
    array(
        'query' => "SELECT 1 FROM (SELECT `GRANTEE`, `IS_GRANTABLE`"
            . " FROM `INFORMATION_SCHEMA`.`COLUMN_PRIVILEGES`"
            . " UNION SELECT `GRANTEE`, `IS_GRANTABLE`"
            . " FROM `INFORMATION_SCHEMA`.`TABLE_PRIVILEGES`"
            . " UNION SELECT `GRANTEE`, `IS_GRANTABLE`"
            . " FROM `INFORMATION_SCHEMA`.`SCHEMA_PRIVILEGES`"
            . " UNION SELECT `GRANTEE`, `IS_GRANTABLE`"
            . " FROM `INFORMATION_SCHEMA`.`USER_PRIVILEGES`) t"
            . " WHERE `IS_GRANTABLE` = 'YES'"
            . " AND '''pma_test''@''localhost''' LIKE `GRANTEE` LIMIT 1",
        'result' => array(array('1')),
    ),
    array(
        'query' => 'SHOW MASTER LOGS',
        'result' => false,
    ),
    array(
        'query' => 'SHOW STORAGE ENGINES',
        'result' => array(
            array(
                'Engine' => 'dummy',
                'Support' => 'YES',
                'Comment' => 'dummy comment'
            ),
            array(
                'Engine' => 'dummy2',
                'Support' => 'NO',
                'Comment' => 'dummy2 comment'
            ),
            array(
                'Engine' => 'FEDERATED',
                'Support' => 'NO',
                'Comment' => 'Federated MySQL storage engine'
            ),
        )
    ),
    array(
        'query' => 'SHOW STATUS WHERE Variable_name'
            . ' LIKE \'Innodb\\_buffer\\_pool\\_%\''
            . ' OR Variable_name = \'Innodb_page_size\';',
        'result' => array(
            array('Innodb_buffer_pool_pages_data', 0),
            array('Innodb_buffer_pool_pages_dirty', 0),
            array('Innodb_buffer_pool_pages_flushed', 0),
            array('Innodb_buffer_pool_pages_free', 0),
            array('Innodb_buffer_pool_pages_misc', 0),
            array('Innodb_buffer_pool_pages_total', 4096),
            array('Innodb_buffer_pool_read_ahead_rnd', 0),
            array('Innodb_buffer_pool_read_ahead', 0),
            array('Innodb_buffer_pool_read_ahead_evicted', 0),
            array('Innodb_buffer_pool_read_requests', 64),
            array('Innodb_buffer_pool_reads', 32),
            array('Innodb_buffer_pool_wait_free', 0),
            array('Innodb_buffer_pool_write_requests', 64),
            array('Innodb_page_size', 16384),
        )
    ),
    array(
        'query' => 'SHOW ENGINE INNODB STATUS;',
        'result' => false,
    ),
    array(
        'query' => 'SELECT @@innodb_version;',
        'result' => array(
            array('1.1.8'),
        )
    ),
    array(
        'query' => 'SHOW GLOBAL VARIABLES LIKE \'innodb_file_per_table\';',
        'result' => array(
            array('innodb_file_per_table', 'OFF'),
        )
    ),
    array(
        'query' => 'SHOW GLOBAL VARIABLES LIKE \'innodb_file_format\';',
        'result' => array(
            array('innodb_file_format', 'Antelope'),
        )
    ),
    array(
        'query' => 'SHOW VARIABLES LIKE \'collation_server\'',
        'result' => array(
            array('collation_server', 'utf8_general_ci'),
        )
    ),
    array(
        'query' => 'SHOW VARIABLES LIKE \'language\';',
        'result' => array(),
    ),
    array(
        'query' => 'SHOW SESSION VARIABLES LIKE \'FOREIGN_KEY_CHECKS\';',
        'result' => array(
            array('foreign_key_checks', 'ON')
        ),
    ),
    array(
        'query' => 'SHOW TABLES FROM `pma_test`;',
        'result' => array(
            array('table1'),
            array('table2'),
        )
    ),
    array(
        'query' => 'SHOW TABLES FROM `pmadb`',
        'result' => array(
            array('column_info'),
        )
    ),
    array(
        'query' => 'SHOW COLUMNS FROM `pma_test`.`table1`',
        'columns' => array(
            'Field', 'Type', 'Null', 'Key', 'Default', 'Extra'
        ),
        'result' => array(
            array('i', 'int(11)', 'NO', 'PRI', 'NULL', 'auto_increment'),
            array('o', 'int(11)', 'NO', 'MUL', 'NULL', ''),
        )
    ),
    array(
        'query' => 'SHOW INDEXES FROM `pma_test`.`table1` WHERE (Non_unique = 0)',
        'result' => array(),
    ),
    array(
        'query' => 'SHOW COLUMNS FROM `pma_test`.`table2`',
        'columns' => array(
            'Field', 'Type', 'Null', 'Key', 'Default', 'Extra'
        ),
        'result' => array(
            array('i', 'int(11)', 'NO', 'PRI', 'NULL', 'auto_increment'),
            array('o', 'int(11)', 'NO', 'MUL', 'NULL', ''),
        )
    ),
    array(
        'query' => 'SHOW INDEXES FROM `pma_test`.`table1`',
        'result' => array(),
    ),
    array(
        'query' => 'SHOW INDEXES FROM `pma_test`.`table2`',
        'result' => array(),
    ),
    array(
        'query' => 'SHOW COLUMNS FROM `pma`.`table1`',
        'columns' => array(
            'Field', 'Type', 'Null', 'Key', 'Default', 'Extra',
            'Privileges', 'Comment'
        ),
        'result' => array(
            array(
                'i', 'int(11)', 'NO', 'PRI', 'NULL', 'auto_increment',
                'select,insert,update,references', ''
            ),
            array(
                'o', 'varchar(100)', 'NO', 'MUL', 'NULL', '',
                'select,insert,update,references', ''
            ),
        )
    ),
    array(
        'query' => 'SELECT * FROM information_schema.CHARACTER_SETS',
        'columns' => array(
            'CHARACTER_SET_NAME', 'DEFAULT_COLLATE_NAME', 'DESCRIPTION', 'MAXLEN'
        ),
        'result' => array(
            array('utf8', 'utf8_general_ci', 'UTF-8 Unicode', 3),
        )
    ),
    array(
        'query' => 'SELECT * FROM information_schema.COLLATIONS',
        'columns' => array(
            'COLLATION_NAME', 'CHARACTER_SET_NAME', 'ID', 'IS_DEFAULT',
            'IS_COMPILED', 'SORTLEN'
        ),
        'result' => array(
            array('utf8_general_ci', 'utf8', 33, 'Yes', 'Yes', 1),
            array('utf8_bin', 'utf8', 83, '', 'Yes', 1),
        )
    ),
    array(
        'query' => 'SELECT `TABLE_NAME` FROM `INFORMATION_SCHEMA`.`TABLES`'
            . ' WHERE `TABLE_SCHEMA`=\'pma_test\' AND `TABLE_TYPE`=\'BASE TABLE\'',
        'result' => array(),
    ),
    array(
        'query' => 'SELECT upper(plugin_name) f FROM data_dictionary.plugins'
            . ' WHERE plugin_name IN (\'MYSQL_PASSWORD\',\'ROT13\')'
            . ' AND plugin_type = \'Function\' AND is_active',
        'columns' => array('f'),
        'result' => array(array('ROT13')),
    ),
    array(
        'query' => 'SELECT `column_name`, `mimetype`, `transformation`,'
            . ' `transformation_options`, `input_transformation`,'
            . ' `input_transformation_options`'
            . ' FROM `pmadb`.`column_info`'
            . ' WHERE `db_name` = \'pma_test\' AND `table_name` = \'table1\''
            . ' AND ( `mimetype` != \'\' OR `transformation` != \'\''
            . ' OR `transformation_options` != \'\''
            . ' OR `input_transformation` != \'\''
            . ' OR `input_transformation_options` != \'\')',
        'columns' => array(
            'column_name', 'mimetype', 'transformation', 'transformation_options',
            'input_transformation', 'input_transformation_options'
        ),
        'result' => array(
            array('o', 'text/plain', 'sql', '', 'regex', '/pma/i'),
            array('col', 't', 'o/p', '', 'i/p', '')
        )
    ),
    array(
        'query' => 'SELECT TABLE_NAME FROM information_schema.VIEWS'
            . ' WHERE TABLE_SCHEMA = \'pma_test\' AND TABLE_NAME = \'table1\'',
        'result' => array(),
    ),
    array(
        'query' => 'SELECT *, `TABLE_SCHEMA` AS `Db`, `TABLE_NAME` AS `Name`,'
            . ' `TABLE_TYPE` AS `TABLE_TYPE`, `ENGINE` AS `Engine`,'
            . ' `ENGINE` AS `Type`, `VERSION` AS `Version`,'
            . ' `ROW_FORMAT` AS `Row_format`, `TABLE_ROWS` AS `Rows`,'
            . ' `AVG_ROW_LENGTH` AS `Avg_row_length`,'
            . ' `DATA_LENGTH` AS `Data_length`,'
            . ' `MAX_DATA_LENGTH` AS `Max_data_length`,'
            . ' `INDEX_LENGTH` AS `Index_length`, `DATA_FREE` AS `Data_free`,'
            . ' `AUTO_INCREMENT` AS `Auto_increment`,'
            . ' `CREATE_TIME` AS `Create_time`, `UPDATE_TIME` AS `Update_time`,'
            . ' `CHECK_TIME` AS `Check_time`, `TABLE_COLLATION` AS `Collation`,'
            . ' `CHECKSUM` AS `Checksum`, `CREATE_OPTIONS` AS `Create_options`,'
            . ' `TABLE_COMMENT` AS `Comment`'
            . ' FROM `information_schema`.`TABLES` t'
            . ' WHERE BINARY `TABLE_SCHEMA` IN (\'pma_test\')'
            . ' AND t.`TABLE_NAME` = \'table1\' ORDER BY Name ASC',
        'columns' => array(
            'TABLE_CATALOG', 'TABLE_SCHEMA', 'TABLE_NAME', 'TABLE_TYPE', 'ENGINE',
            'VERSION', 'ROW_FORMAT', 'TABLE_ROWS', 'AVG_ROW_LENGTH', 'DATA_LENGTH',
            'MAX_DATA_LENGTH', 'INDEX_LENGTH', 'DATA_FREE', 'AUTO_INCREMENT',
            'CREATE_TIME', 'UPDATE_TIME', 'CHECK_TIME', 'TABLE_COLLATION',
            'CHECKSUM', 'CREATE_OPTIONS', 'TABLE_COMMENT', 'Db', 'Name',
            'TABLE_TYPE', 'Engine', 'Type', 'Version', 'Row_format', 'Rows',
            'Avg_row_length', 'Data_length', 'Max_data_length', 'Index_length',
            'Data_free', 'Auto_increment', 'Create_time', 'Update_time',
            'Check_time', 'Collation', 'Checksum', 'Create_options', 'Comment'
        ),
        'result' => array(
            array(
                'def', 'smash', 'issues_issue', 'BASE TABLE', 'InnoDB', '10',
                'Compact', '9136', '862', '7880704', '0', '1032192', '420478976',
                '155862', '2012-08-29 13:28:28', 'NULL', 'NULL', 'utf8_general_ci',
                'NULL', '', '', 'smash', 'issues_issue', 'BASE TABLE', 'InnoDB',
                'InnoDB', '10', 'Compact', '9136', '862', '7880704', '0', '1032192',
                '420478976', '155862', '2012-08-29 13:28:28', 'NULL', 'NULL',
                'utf8_general_ci', 'NULL'
            ),
        ),
    ),
    array(
        'query' => 'SELECT *, `TABLE_SCHEMA` AS `Db`, `TABLE_NAME` AS `Name`,'
            . ' `TABLE_TYPE` AS `TABLE_TYPE`, `ENGINE` AS `Engine`,'
            . ' `ENGINE` AS `Type`, `VERSION` AS `Version`,'
            . ' `ROW_FORMAT` AS `Row_format`, `TABLE_ROWS` AS `Rows`,'
            . ' `AVG_ROW_LENGTH` AS `Avg_row_length`,'
            . ' `DATA_LENGTH` AS `Data_length`,'
            . ' `MAX_DATA_LENGTH` AS `Max_data_length`,'
            . ' `INDEX_LENGTH` AS `Index_length`, `DATA_FREE` AS `Data_free`,'
            . ' `AUTO_INCREMENT` AS `Auto_increment`,'
            . ' `CREATE_TIME` AS `Create_time`, `UPDATE_TIME` AS `Update_time`,'
            . ' `CHECK_TIME` AS `Check_time`, `TABLE_COLLATION` AS `Collation`,'
            . ' `CHECKSUM` AS `Checksum`, `CREATE_OPTIONS` AS `Create_options`,'
            . ' `TABLE_COMMENT` AS `Comment`'
            . ' FROM `information_schema`.`TABLES` t'
            . ' WHERE `TABLE_SCHEMA` IN (\'pma_test\')'
            . ' AND t.`TABLE_NAME` = \'table1\' ORDER BY Name ASC',
        'columns' => array('TABLE_CATALOG', 'TABLE_SCHEMA', 'TABLE_NAME',
            'TABLE_TYPE', 'ENGINE', 'VERSION', 'ROW_FORMAT', 'TABLE_ROWS',
            'AVG_ROW_LENGTH', 'DATA_LENGTH', 'MAX_DATA_LENGTH',
            'INDEX_LENGTH', 'DATA_FREE', 'AUTO_INCREMENT', 'CREATE_TIME',
            'UPDATE_TIME', 'CHECK_TIME', 'TABLE_COLLATION', 'CHECKSUM',
            'CREATE_OPTIONS', 'TABLE_COMMENT', 'Db', 'Name', 'TABLE_TYPE',
            'Engine', 'Type', 'Version', 'Row_format', 'Rows',
            'Avg_row_length', 'Data_length', 'Max_data_length',
            'Index_length', 'Data_free', 'Auto_increment', 'Create_time',
            'Update_time', 'Check_time', 'Collation', 'Checksum',
            'Create_options', 'Comment'),
        'result' => array(
            array('def', 'smash', 'issues_issue', 'BASE TABLE', 'InnoDB', '10',
                'Compact', '9136', '862', '7880704', '0', '1032192',
                '420478976', '155862', '2012-08-29 13:28:28', 'NULL', 'NULL',
                'utf8_general_ci', 'NULL', '', '', 'smash', 'issues_issue',
                'BASE TABLE', 'InnoDB', 'InnoDB', '10', 'Compact', '9136',
                '862', '7880704', '0', '1032192', '420478976', '155862',
                '2012-08-29 13:28:28', 'NULL', 'NULL', 'utf8_general_ci',
                'NULL'),
        ),
    ),
    array(
        'query' => 'SELECT COUNT(*) FROM `pma_test`.`table1`',
        'result' => array(array(0)),
    ),
    array(
        'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
            . '`USER_PRIVILEGES`'
            . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
            . ' AND PRIVILEGE_TYPE=\'TRIGGER\'',
        'result' => array(),
    ),
    array(
        'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
            . '`SCHEMA_PRIVILEGES`'
            . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
            . ' AND PRIVILEGE_TYPE=\'TRIGGER\' AND \'pma_test\''
            . ' LIKE `TABLE_SCHEMA`',
        'result' => array(),
    ),
    array(
        'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
            . '`TABLE_PRIVILEGES`'
            . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
            . ' AND PRIVILEGE_TYPE=\'TRIGGER\' AND \'pma_test\''
            . ' LIKE `TABLE_SCHEMA` AND TABLE_NAME=\'table1\'',
        'result' => array(),
    ),
    array(
        'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
            . '`USER_PRIVILEGES`'
            . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
            . ' AND PRIVILEGE_TYPE=\'EVENT\'',
        'result' => array(),
    ),
    array(
        'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
            . '`SCHEMA_PRIVILEGES`'
            . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
            . ' AND PRIVILEGE_TYPE=\'EVENT\' AND \'pma_test\''
            . ' LIKE `TABLE_SCHEMA`',
        'result' => array(),
    ),
    array(
        'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.'
            . '`TABLE_PRIVILEGES`'
            . ' WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\''
            . ' AND PRIVILEGE_TYPE=\'EVENT\''
            . ' AND TABLE_SCHEMA=\'pma\\\\_test\' AND TABLE_NAME=\'table1\'',
        'result' => array(),
    ),
    array(
        'query' => 'RENAME TABLE `pma_test`.`table1` TO `pma_test`.`table3`;',
        'result' => array(),
    ),
    array(
        'query' => 'SELECT TRIGGER_SCHEMA, TRIGGER_NAME, EVENT_MANIPULATION,'
            . ' EVENT_OBJECT_TABLE, ACTION_TIMING, ACTION_STATEMENT, '
            . 'EVENT_OBJECT_SCHEMA, EVENT_OBJECT_TABLE, DEFINER'
            . ' FROM information_schema.TRIGGERS'
            . ' WHERE EVENT_OBJECT_SCHEMA= \'pma_test\''
            . ' AND EVENT_OBJECT_TABLE = \'table1\';',
        'result' => array(),
    ),
    array(
        'query' => 'SHOW TABLES FROM `pma`;',
        'result' => array(),
    ),
    array(
        'query' => "SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`."
            . "`SCHEMA_PRIVILEGES` WHERE GRANTEE='''pma_test''@''localhost'''"
            . " AND PRIVILEGE_TYPE='EVENT' AND TABLE_SCHEMA='pma'",
        'result' => array(),
    ),
    array(
        'query' => "SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`."
            . "`SCHEMA_PRIVILEGES` WHERE GRANTEE='''pma_test''@''localhost'''"
            . " AND PRIVILEGE_TYPE='TRIGGER' AND TABLE_SCHEMA='pma'",
        'result' => array(),
    ),
    array(
        'query' => 'SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA'
        . ' WHERE SCHEMA_NAME = \'pma_test\' LIMIT 1',
        'columns' => array('DEFAULT_COLLATION_NAME'),
        'result' => array(
            array('utf8_general_ci')
        )
    ),
    array(
        'query' => 'SELECT DEFAULT_COLLATION_NAME FROM data_dictionary.SCHEMAS'
            . ' WHERE SCHEMA_NAME = \'pma_test\' LIMIT 1',
        'columns' => array('DEFAULT_COLLATION_NAME'),
        'result' => array(
            array('utf8_general_ci_pma_drizzle')
        )
    ),
    array(
        'query' => 'SHOW VARIABLES LIKE \'collation_database\'',
        'columns' => array('variable_name', 'variable_value'),
        'result' => array(
            array('foo', 'bar'),
        )
    ),
    array(
        'query' => "SHOW TABLES FROM `phpmyadmin`",
        'result' => array(),
    ),
    array(
        'query' => "SELECT tracking_active FROM `pmadb`.`tracking`" .
            " WHERE db_name = 'pma_test_db'" .
            " AND table_name = 'pma_test_table'" .
            " ORDER BY version DESC",
        'columns' => array('tracking_active'),
        'result' => array(
                array(1)
            )
    ),
    array(
        'query' => "SELECT tracking_active FROM `pmadb`.`tracking`" .
            " WHERE db_name = 'pma_test_db'" .
            " AND table_name = 'pma_test_table2'" .
            " ORDER BY version DESC",
        'result' => array()
    ),
    array(
        'query' => "SHOW SLAVE STATUS",
        'result' => array(
            array(
                'Slave_IO_State' => 'running',
                'Master_Host' => 'locahost',
                'Master_User' => 'Master_User',
                'Master_Port' => '1002',
                'Connect_Retry' => 'Connect_Retry',
                'Master_Log_File' => 'Master_Log_File',
                'Read_Master_Log_Pos' => 'Read_Master_Log_Pos',
                'Relay_Log_File' => 'Relay_Log_File',
                'Relay_Log_Pos' => 'Relay_Log_Pos',
                'Relay_Master_Log_File' =>  'Relay_Master_Log_File',
                'Slave_IO_Running' => 'NO',
                'Slave_SQL_Running' => 'NO',
                'Replicate_Do_DB' => 'Replicate_Do_DB',
                'Replicate_Ignore_DB' => 'Replicate_Ignore_DB',
                'Replicate_Do_Table' => 'Replicate_Do_Table',
                'Replicate_Ignore_Table' => 'Replicate_Ignore_Table',
                'Replicate_Wild_Do_Table' => 'Replicate_Wild_Do_Table',
                'Replicate_Wild_Ignore_Table' => 'Replicate_Wild_Ignore_Table',
                'Last_Errno' => 'Last_Errno',
                'Last_Error' => 'Last_Error',
                'Skip_Counter' =>  'Skip_Counter',
                'Exec_Master_Log_Pos' => 'Exec_Master_Log_Pos',
                'Relay_Log_Space' => 'Relay_Log_Space',
                'Until_Condition' => 'Until_Condition',
                'Until_Log_File' => 'Until_Log_File',
                'Until_Log_Pos' => 'Until_Log_Pos',
                'Master_SSL_Allowed' => 'Master_SSL_Allowed',
                'Master_SSL_CA_File' => 'Master_SSL_CA_File',
                'Master_SSL_CA_Path' => 'Master_SSL_CA_Path',
                'Master_SSL_Cert' => 'Master_SSL_Cert',
                'Master_SSL_Cipher' => 'Master_SSL_Cipher',
                'Master_SSL_Key' => 'Master_SSL_Key',
                'Seconds_Behind_Master' => 'Seconds_Behind_Master',
            )
        )
    ),
    array(
        'query' => "SHOW MASTER STATUS",
        'result' => array(
            array(
                "File" => "master-bin.000030",
                "Position" => "107",
                "Binlog_Do_DB" => "Binlog_Do_DB",
                "Binlog_Ignore_DB" => "Binlog_Ignore_DB",
            )
        )
    ),
    array(
        'query' => "SHOW GRANTS",
        'result' => array()
    ),
    array(
        'query' => "SELECT `SCHEMA_NAME` FROM `INFORMATION_SCHEMA`.`SCHEMATA`, "
            . "(SELECT DB_first_level FROM ( SELECT DISTINCT "
            . "SUBSTRING_INDEX(SCHEMA_NAME, '_', 1) DB_first_level "
            . "FROM INFORMATION_SCHEMA.SCHEMATA WHERE TRUE ) t ORDER BY "
            . "DB_first_level ASC LIMIT 0, 100) t2 WHERE 1 = LOCATE("
            . "CONCAT(DB_first_level, '_'), CONCAT(SCHEMA_NAME, '_')) "
            . "ORDER BY SCHEMA_NAME ASC",
        'result' => array(
            "test",
        )
    ),
    array(
        'query' => "SELECT COUNT(*) FROM ( SELECT DISTINCT SUBSTRING_INDEX("
            . "SCHEMA_NAME, '_', 1) DB_first_level "
            . "FROM INFORMATION_SCHEMA.SCHEMATA WHERE TRUE ) t",
        'result' => array(
            array(1),
        )
    ),
    array(
        'query' => "SELECT `PARTITION_METHOD` FROM `information_schema`.`PARTITIONS` "
            . "WHERE `TABLE_SCHEMA` = 'db' AND `TABLE_NAME` = 'table'",
        'result' => array()
    ),
    array(
        'query' => "SHOW PLUGINS",
        'result' => array(
            array('Name' => 'partition')
        )
    ),
    array(
        'query' => "SHOW FULL TABLES FROM `default` WHERE `Table_type`='BASE TABLE'",
        'result' => array(
            array("test1", "BASE TABLE"),
            array("test2", "BASE TABLE"),
        )
    ),
    array(
        'query' => "SHOW FULL TABLES FROM `default` WHERE `Table_type`!='BASE TABLE'",
        'result' => array()
    ),
    array(
        'query' => "SHOW FUNCTION STATUS WHERE `Db`='default'",
        'result' => array(array("Name" => "testFunction"))
    ),
    array(
        'query' => "SHOW PROCEDURE STATUS WHERE `Db`='default'",
        'result' => array()
    ),
    array(
        'query' => "SHOW EVENTS FROM `default`",
        'result' => array()
    ),
    array(
        'query' => "FLUSH PRIVILEGES",
        'result' => array()
    ),
    array(
        'query' => "SELECT * FROM `mysql`.`db` LIMIT 1",
        'result' => array()
    ),
    array(
        'query' => "SELECT * FROM `mysql`.`columns_priv` LIMIT 1",
        'result' => array()
    ),
    array(
        'query' => "SELECT * FROM `mysql`.`tables_priv` LIMIT 1",
        'result' => array()
    ),
    array(
        'query' => "SELECT * FROM `mysql`.`procs_priv` LIMIT 1",
        'result' => array()
    )
);
/**
 * Current database.
 */
$GLOBALS['dummy_db'] = '';

/* Some basic setup for dummy driver */
$GLOBALS['userlink'] = 1;
$GLOBALS['controllink'] = 2;
$GLOBALS['cfg']['DBG']['sql'] = false;
if (! defined('PMA_DRIZZLE')) {
    define('PMA_DRIZZLE', 0);
}
if (! defined('PMA_MARIADB')) {
    define('PMA_MARIADB', 0);
}

/**
 * Fake database driver for testing purposes
 *
 * It has hardcoded results for given queries what makes easy to use it
 * in testsuite. Feel free to include other queries which your test will
 * need.
 *
 * @package    PhpMyAdmin-DBI
 * @subpackage Dummy
 */
class PMA_DBI_Dummy implements PMA_DBI_Extension
{
    /**
     * connects to the database server
     *
     * @param string $user                 mysql user name
     * @param string $password             mysql user password
     * @param bool   $is_controluser       whether this is a control user connection
     * @param array  $server               host/port/socket/persistent
     * @param bool   $auxiliary_connection (when true, don't go back to login if
     *                                     connection fails)
     *
     * @return mixed false on error or a mysqli object on success
     */
    public function connect(
        $user, $password, $is_controluser = false, $server = null,
        $auxiliary_connection = false
    ) {
        return true;
    }

    /**
     * selects given database
     *
     * @param string   $dbname name of db to select
     * @param resource $link   mysql link resource
     *
     * @return bool
     */
    public function selectDb($dbname, $link)
    {
        $GLOBALS['dummy_db'] = $dbname;
        return true;
    }

    /**
     * runs a query and returns the result
     *
     * @param string   $query   query to run
     * @param resource $link    mysql link resource
     * @param int      $options query options
     *
     * @return mixed
     */
    public function realQuery($query, $link = null, $options = 0)
    {
        $query = trim(preg_replace('/  */', ' ', str_replace("\n", ' ', $query)));
        for ($i = 0, $nb = count($GLOBALS['dummy_queries']); $i < $nb; $i++) {
            if ($GLOBALS['dummy_queries'][$i]['query'] != $query) {
                continue;
            }

            $GLOBALS['dummy_queries'][$i]['pos'] = 0;
            if (!is_array($GLOBALS['dummy_queries'][$i]['result'])) {
                return false;
            }

            return $i;
        }
        echo "Not supported query: $query\n";
        return false;
    }

    /**
     * Run the multi query and output the results
     *
     * @param resource $link  connection object
     * @param string   $query multi query statement to execute
     *
     * @return result collection | boolean(false)
     */
    public function realMultiQuery($link, $query)
    {
        return false;
    }

    /**
     * returns result data from $result
     *
     * @param object $result result  MySQL result
     *
     * @return array
     */
    public function fetchAny($result)
    {
        $query_data = $GLOBALS['dummy_queries'][$result];
        if ($query_data['pos'] >= count($query_data['result'])) {
            return false;
        }
        $ret = $query_data['result'][$query_data['pos']];
        $GLOBALS['dummy_queries'][$result]['pos'] += 1;
        return $ret;
    }

    /**
     * returns array of rows with associative and numeric keys from $result
     *
     * @param object $result result  MySQL result
     *
     * @return array
     */
    public function fetchArray($result)
    {
        $data = $this->fetchAny($result);
        if (!is_array($data)
            || !isset($GLOBALS['dummy_queries'][$result]['columns'])
        ) {
            return $data;
        }

        foreach ($data as $key => $val) {
            $data[$GLOBALS['dummy_queries'][$result]['columns'][$key]] = $val;
        }
        return $data;
    }

    /**
     * returns array of rows with associative keys from $result
     *
     * @param object $result MySQL result
     *
     * @return array
     */
    public function fetchAssoc($result)
    {
        $data = $this->fetchAny($result);
        if (!is_array($data)
            || !isset($GLOBALS['dummy_queries'][$result]['columns'])
        ) {
            return $data;
        }

        $ret = array();
        foreach ($data as $key => $val) {
            $ret[$GLOBALS['dummy_queries'][$result]['columns'][$key]] = $val;
        }
        return $ret;
    }

    /**
     * returns array of rows with numeric keys from $result
     *
     * @param object $result MySQL result
     *
     * @return array
     */
    public function fetchRow($result)
    {
        $data = $this->fetchAny($result);
        return $data;
    }

    /**
     * Adjusts the result pointer to an arbitrary row in the result
     *
     * @param object  $result database result
     * @param integer $offset offset to seek
     *
     * @return bool true on success, false on failure
     */
    public function dataSeek($result, $offset)
    {
        if ($offset > count($GLOBALS['dummy_queries'][$result]['result'])) {
            return false;
        }
        $GLOBALS['dummy_queries'][$result]['pos'] = $offset;
        return true;
    }

    /**
     * Frees memory associated with the result
     *
     * @param object $result database result
     *
     * @return void
     */
    public function freeResult($result)
    {
        return;
    }

    /**
     * Check if there are any more query results from a multi query
     *
     * @param resource $link the connection object
     *
     * @return bool false
     */
    public function moreResults($link)
    {
        return false;
    }

    /**
     * Prepare next result from multi_query
     *
     * @param resource $link the connection object
     *
     * @return boolean false
     */
    public function nextResult($link)
    {
        return false;
    }

    /**
     * Store the result returned from multi query
     *
     * @param resource $link the connection object
     *
     * @return mixed false when empty results / result set when not empty
     */
    public function storeResult($link)
    {
        return false;
    }

    /**
     * Returns a string representing the type of connection used
     *
     * @param resource $link mysql link
     *
     * @return string type of connection used
     */
    public function getHostInfo($link)
    {
        return '';
    }

    /**
     * Returns the version of the MySQL protocol used
     *
     * @param resource $link mysql link
     *
     * @return integer version of the MySQL protocol used
     */
    public function getProtoInfo($link)
    {
        return -1;
    }

    /**
     * returns a string that represents the client library version
     *
     * @return string MySQL client library version
     */
    public function getClientInfo()
    {
        return '';
    }

    /**
     * returns last error message or false if no errors occurred
     *
     * @param resource $link connection link
     *
     * @return string|bool $error or false
     */
    public function getError($link)
    {
        return false;
    }

    /**
     * returns the number of rows returned by last query
     *
     * @param object $result MySQL result
     *
     * @return string|int
     */
    public function numRows($result)
    {
        if (is_bool($result)) {
            return 0;
        }

        return count($GLOBALS['dummy_queries'][$result]['result']);
    }

    /**
     * returns the number of rows affected by last query
     *
     * @param resource $link           the mysql object
     * @param bool     $get_from_cache whether to retrieve from cache
     *
     * @return string|int
     */
    public function affectedRows($link = null, $get_from_cache = true)
    {
        return 0;
    }

    /**
     * returns metainfo for fields in $result
     *
     * @param object $result result set identifier
     *
     * @return array meta info for fields in $result
     */
    public function getFieldsMeta($result)
    {
        return array();
    }

    /**
     * return number of fields in given $result
     *
     * @param object $result MySQL result
     *
     * @return int  field count
     */
    public function numFields($result)
    {
        if (!isset($GLOBALS['dummy_queries'][$result]['columns'])) {
            return 0;
        }

        return count($GLOBALS['dummy_queries'][$result]['columns']);
    }

    /**
     * returns the length of the given field $i in $result
     *
     * @param object $result result set identifier
     * @param int    $i      field
     *
     * @return int length of field
     */
    public function fieldLen($result, $i)
    {
        return -1;
    }

    /**
     * returns name of $i. field in $result
     *
     * @param object $result result set identifier
     * @param int    $i      field
     *
     * @return string name of $i. field in $result
     */
    public function fieldName($result, $i)
    {
        return '';
    }

    /**
     * returns concatenated string of human readable field flags
     *
     * @param object $result result set identifier
     * @param int    $i      field
     *
     * @return string field flags
     */
    public function fieldFlags($result, $i)
    {
        return '';
    }
}