-
Notifications
You must be signed in to change notification settings - Fork 15
/
install_sql.cpp
7855 lines (7564 loc) · 407 KB
/
install_sql.cpp
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
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Modified copy of MDBug install.sql
For copyright and license notice of install_sql function contents, see beginning of ocelotgui.cpp.
This file was made by downloading MDBug's install.sql and editing. Most of the editing was done thus:
(1) replace all \ with \\ (2) replace all " with \" (3) replace all \n with " \n" (4) replace all //" with
";\n\nif (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;\nstrcpy(x,
Pass &mysql[MYSQL_MAIN_CONNECTION].
*/
/*
Six lines have been commented out in xxxmdbug.privilege_checks(). This is only a temporary solution for a race.
One line has been commented out in xxxmdbug.setup_internal(). The job is now being done in ocelotgui.cpp.
Three lines have been commented out because "REPAIR TABLE mysql.proc" is now not needed (I hope).
Five lines are changed in xxxmdbug.dbms_pipe_receive so that there is one critical SET statement rather thn three (less race).
In debuggee_wait_loop "PREPARE xxxmdbug_stmt FROM @xxxmdbug_what_to_call;" was replaced with "LEAVE x;".
In insert_into_statements two lines were changed because a statement within an ELSE wasn't generated.
*/
/*
2016-06-12 Several lines have been added in xxxmdbug.generate().
This was a fix for github bug#1. If hostname=% is must be inside backticks.
*/
/*
2016-06-13 A begin...end block has been added in xxxmdbug.generate_icc_process_user_command_set_server_variables
and generate_icc_process_user_command_set_server_variables.
This was a fix for the MySQL 5.7 switch to performance_schema use.
*/
/*
2018-05-25 Functions must be called deterministic now, due to a change
in MySQL 8.0. Routines referencing information_schema.server_variables
must be removed (there are substitutes in the C code), due to a change
in MySQL 8.0. All string comparisons must have an explicit collate
clause, due to a change in MySQL 8.0.
*/
/*
2024-07-10 More string comparisons must have an explicit collate
clause, due to a change in MariaDB 11.5.
*/
/* #include "install_sql.h" relies on "#if (OCELOT_MYSQL_DEBUGGER == 1)" which is true by default. */
/* Todo: This file's routines are unneccessary if NEW_SETUP == 1 but I haven't gotten around to removing all references to them. */
#ifndef INSTALL_SQL_CPP
/* todo: ensure this doesn't waste space by including things in ocelotgui.h that are unnecessary */
//TEST!! #include "ocelotgui.h"
//#include "ui_ocelotgui.h"
int MainWindow::debug_mdbug_install_sql(MYSQL *mysql, char *x)
{
strcpy(x,
"SET @xxxmdbug_copyright = '"
""
"This file is part of MDBug."
""
"(c) Copyright 2012 Hewlett-Packard Development Company, L.P."
""
"This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License"
"as published by the Free Software Foundation; version 2 of the License."
""
"This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty"
"of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details."
""
"You should have received a copy of the GNU General Public License along with this program; if not, see"
"<http://www.gnu.org/licenses>."
""
"Linking MDBug statically or dynamically with other modules is making a combined work based on MDBug. Thus, the terms and"
"conditions of the GNU General Public License cover the whole combination."
""
"In addition, as a special exception, the copyright holders of MDBug give you permission to combine MDBug with free"
"software programs or libraries that are released under the GNU LGPL and with code included in the standard release"
"of Eclipse under the Eclipse Public License version 1.0 (or modified versions of such code, with unchanged license)."
"You may copy and distribute such a system following the terms of the GNU GPL for MDBug and the licenses of the other"
"code concerned, provided that you include the source code of that other code when and as the GNU GPL requires"
"distribution of source code."
""
"Note that people who make modified versions of MDBug are not obligated to grant this special exception for their"
"modified versions; it is their choice whether to do so. The GNU General Public License gives permission to release a"
"modified version without this exception; this exception also makes it possible to release a modified version which"
"carries forward this exception."
"'");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
""
"/* THE MDBUG CORE DEBUGGER"
" Version 0.3 Alpha"
" Last Revision 2012-09-11"
" Written by Peter Gulutzan */"
""
"/* If install has been done before, then get rid of all old routines or tables"
" which we will be replacing during this install. But do not get rid of"
" setup_log, or any surrogate routines which happen to be in xxxmdbug,"
" such as 'xxxmdbugxxxPicc_core' procedures."
" That is why we cannot do the easy thing, DROP DATABASE IF EXISTS xxxmdbug. */"
""
"SET @xxxmdbug_saved_sql_mode=@@sql_mode");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"SET SESSION sql_mode=''");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
//strcpy(x,
//""
//"REPAIR TABLE mysql.proc");
//
//if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
//MYSQL_RES *debug_res= NULL; /* added because REPAIR returns a result set */
//debug_res= mysql_store_result(mysql);
//if (debug_res != NULL) mysql_free_result(debug_res);
strcpy(x,
""
"CREATE DATABASE IF NOT EXISTS xxxmdbug");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP TABLE IF EXISTS xxxmdbug.copyright");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP TABLE IF EXISTS xxxmdbug.readme");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.add_delimiters");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.become_debuggee_connection");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.breakpoint_delete");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.check_surrogate_routine");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.checks_and_warnings");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.clear_warnings");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.command");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.command_i_status");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.command_r_breakpoints");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.command_r_call_stack");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.command_r_prepared_statements");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.command_r_server_variables");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.command_r_statements_executed");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.command_r_user_variables");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.command_r_variables");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.compare");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.create_breakpoints_table");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.create_prepared_statements_table");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.create_routines_table");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.create_server_variables_table");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.create_setup_log_table");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.create_statements_executed_table");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.create_statements_table");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.create_tmp_user_variables_table");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.create_tokens_table");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.create_user_variables_table");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.create_variables_table");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.dbms_pipe_clean");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.dbms_pipe_receive");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.dbms_pipe_receive_with_timeout");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.dbms_pipe_send");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.debuggee_get_surrogate_name");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.debuggee_stop");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.debuggee_wait_loop");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.debugger_wait_and_receive");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.delete_from_linked_list");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.delete_from_prepared_statements");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.determine_what_variables_are_in_scope");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.fixed_breakpoints_clear");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.fixed_delete");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.fixed_insert");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.fixed_prepared_statements_clear");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.fixed_routines_clear");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.fixed_select");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.fixed_statements_executed_clear");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.fixed_update");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.fixed_variables_clear");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.generate");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.generate_ender");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.generate_icc_core");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.generate_icc_process_user_command_r_server_variables");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.generate_icc_process_user_command_set_server_variables");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.generate_label");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.generate_routine_entry_parameter");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.generate_starter");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.generate_statement_text");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.generate_statement_text_as_is");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.get_current_schema_identifier_and_routine_identifier");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.get_from_linked_list");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.get_setup_group_name");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.get_token_identifier_type");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.get_token_type");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_breakpoint_check");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_change_statement_status");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_copy_table_row_to_variable");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_copy_variable_to_table_row");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_core");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_end");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_get_user_command");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_process_user_command");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_process_user_command_attach");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_process_user_command_break");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_process_user_command_execute");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_process_user_command_r_breakpoints");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_process_user_command_r_call_stack");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_process_user_command_r_prepared_statements");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_process_user_command_r_server_variables");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_process_user_command_set_server_variables");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_process_user_command_r_statements_executed");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_process_user_command_r_user_variables");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_process_user_command_r_variables");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_process_user_command_set");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_process_user_command_step_or_next");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_send_statement_status");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.icc_start");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.initialize_variables");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.insert_into_linked_list");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.insert_into_prepared_statements");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.insert_into_routines");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.insert_into_statements");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.insert_into_tokens");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.insert_into_tokens_linked_list");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.insert_into_variables_declared_variables");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.insert_into_variables_parameters");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.insert_into_variables_user_variables");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.install_check");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP FUNCTION IF EXISTS xxxmdbug.isnumeric");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP FUNCTION IF EXISTS xxxmdbug.is_debuggee_and_is_attached");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.multiple_name_parser");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.mysql_proc_insert");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.mysql_proc_insert_caller");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.overflow_check");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.preparer");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.prepare_while_ansi_quotes_yes");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.prepare_while_ansi_quotes_no");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.privilege_checks");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.reset");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.retype");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.routine_entry");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.routine_exit");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.setup");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.setup_internal");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.setup_switches");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.setxxxmdbug_channel");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.set_default_schema");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.statement_change");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.syntax_check_for_breakpoint");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.syntax_check_for_debug");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.syntax_check_for_set");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.update_linked_list");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.update_statements_executed");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.uvar");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.view_and_trigger_and_event_check");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"DROP PROCEDURE IF EXISTS xxxmdbug.walkthrough");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
""
"SET @xxxmdbug_start_timestamp = CURRENT_TIMESTAMP");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
""
"CREATE TABLE xxxmdbug.copyright (copyright TEXT CHARACTER SET utf8)");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
"INSERT INTO xxxmdbug.copyright VALUES (@xxxmdbug_copyright)");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
""
"/*"
"DBMS_PIPE"
"========="
""
"The dbms_pipe routines enable passing messages between connections."
"dbms_pipe_send(prefix,string) -- \"sends\" a message in string parameter"
"dbms_pipe_receive(prefix,erase,string) -- \"receives a message in string parameter"
"Requires super privilege."
"Todo: need something for \"clear pipe x\" or \"clear all pipes\" or \"clear pipes which have no connections\""
""
"*/"
""
"CREATE PROCEDURE xxxmdbug.dbms_pipe_send (prefix VARCHAR(66) CHARACTER SET utf8,"
" string MEDIUMTEXT CHARACTER SET utf8)"
"BEGIN"
" DECLARE v CHAR(1) CHARACTER SET utf8;"
" /* If @@init_connect is null, change it to empty string -- else all sending will fail."
" The simpler-looking check \"IF @@init_connect IS NULL THEN SET global init_connect = ''; END IF;\""
" is no good, it seems that \"is null\" can be true even when @@init_connect is not null. */"
" SET v = LEFT(@@init_connect,1);"
" IF v IS NULL THEN SET global init_connect = ''; END IF;"
" CALL xxxmdbug.dbms_pipe_clean(string);"
" SET global init_connect = CONCAT(@@init_connect,'/*',prefix,string,'*/');"
" END");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
""
"/* Receive."
" Ignore messages which don't start with prefix."
" Erase received messages if erase = 1."
" Return message value in string."
" This is changed from the original MDBug routine -- putting multiple SET statements into one big SET statement to avoid races."
" Todo: Sometimes we can receive a blank message. Check that you're checking for that (by looking if p_message_start <> 0) */"
"CREATE PROCEDURE xxxmdbug.dbms_pipe_receive (prefix VARCHAR(66) CHARACTER SET utf8,"
" erase INT,"
" OUT string MEDIUMTEXT CHARACTER SET utf8,"
" OUT p_message_start INT)"
"BEGIN"
" DECLARE v_message_start INT;"
" DECLARE v_message MEDIUMTEXT CHARACTER SET utf8 DEFAULT '';"
" DECLARE v_star_plus_slash_plus_prefix VARCHAR(66) CHARACTER SET utf8;"
" SET v_star_plus_slash_plus_prefix=CONCAT('/*',prefix);"
" SET v_message_start = INSTR(@@init_connect,v_star_plus_slash_plus_prefix);"
" IF v_message_start <> 0 THEN"
" IF erase = 0 THEN"
" SET v_message = SUBSTRING(@@init_connect FROM INSTR(@@init_connect,v_star_plus_slash_plus_prefix)+LENGTH('/*') FOR (LOCATE('*/',@@init_connect,INSTR(@@init_connect,v_star_plus_slash_plus_prefix)) - (INSTR(@@init_connect,v_star_plus_slash_plus_prefix)+LENGTH('/*'))));"
" END IF;"
" IF erase = 1 THEN"
" SET v_message = SUBSTRING(@@init_connect FROM INSTR(@@init_connect,v_star_plus_slash_plus_prefix)+LENGTH('/*') FOR (LOCATE('*/',@@init_connect,INSTR(@@init_connect,v_star_plus_slash_plus_prefix)) - (INSTR(@@init_connect,v_star_plus_slash_plus_prefix)+LENGTH('/*')))),"
" global init_connect = CONCAT(LEFT(@@init_connect,INSTR(@@init_connect,v_star_plus_slash_plus_prefix)-1),"
" RIGHT(@@init_connect,LENGTH(@@init_connect)-(LOCATE('*/',@@init_connect,INSTR(@@init_connect,v_star_plus_slash_plus_prefix))+1)));"
" END IF;"
" SET v_message = RIGHT(v_message,LENGTH(v_message)-LENGTH(prefix));"
" END IF;"
" SET string = v_message;"
" SET string = REPLACE(string,'*([xxxmdbug)','*'); /* We got rid of *s and /s to avoid possible /* comments. Now put them back. */"
" SET string = REPLACE(string,'/([xxxmdbug)','/');"
" SET p_message_start = v_message_start;"
" END");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
""
"/* Eliminate any occurrences of '*' or '/' in string -- anything that might cause comment parts to be in init_connect is dangerous."
" Todo: Oh, and do some trivial encryption while you're at it."
" Maybe sending everything as hex(xor(xxxmdbug_channel)) is a solution. */"
"CREATE PROCEDURE xxxmdbug.dbms_pipe_clean (INOUT string MEDIUMTEXT CHARACTER SET utf8)"
"BEGIN"
" SET string = REPLACE(string,'*','*([xxxmdbug)');"
" SET string = REPLACE(string,'/','/([xxxmdbug)');"
" END");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
""
"/* Getting VARCHAR values to debugger from debuggee.."
" The affected items are variables.value, variables.old_value, server_variables.value, server_variables.old_value,"
" user_variables.value, user_variables.old_value, prepared_statements.statement_text, breakpoints.condition_value,"
" information_status.last_command, information_status.last_command_result."
" These values might contain 's (single quotes) which will confuse the tokenizer."
" So debuggee hexes them before passing and debugger unhexes them after receiving."
" For example in icc_send_statement_status, send HEX(@xxxmdbug_status_last_command), and in command_i_status,"
" insert UNHEX(v_last_command) and v_last_command now has size = 66*2."
" Todo: since the result of UNHEX is binary, some variables don't need to be UTF8."
" Todo: pass source data type and character set too. */"
""
"/* Called by debugger."
" For everything except 'info', send message from debugger to debuggee."
" So far we only send C message."
" Todo: 'd' for delay n seconds, thus allowing a nicer demo */"
"CREATE PROCEDURE xxxmdbug.command (xxxmdbug_channel VARCHAR(66) CHARACTER SET utf8, message VARCHAR(8192) CHARACTER SET utf8)"
"command:"
"BEGIN"
" DECLARE v_length_of_first_token INT;"
" DECLARE v_value_of_first_token VARCHAR(66) CHARACTER SET utf8;"
" DECLARE v_value_of_second_token VARCHAR(66) CHARACTER SET utf8;"
" DECLARE v_token_count INT;"
" DECLARE v_value VARCHAR(66) CHARACTER SET utf8;"
" DECLARE v_prefix VARCHAR(128) CHARACTER SET utf8; /* sizeof('xxxmdbug_' + xxxmdbug_channel) + 'C ' + room to grow */"
" DECLARE v_error_message VARCHAR(128) CHARACTER SET utf8;"
""
" CALL xxxmdbug.initialize_variables();"
" CALL xxxmdbug.privilege_checks();"
""
" CALL xxxmdbug.setxxxmdbug_channel(xxxmdbug_channel); /* sets @xxxmdbug_channel */"
""
" CALL xxxmdbug.create_tokens_table();"
" CALL xxxmdbug.insert_into_tokens('','',message,0);"
" SET v_token_count = (SELECT COUNT(*) FROM xxxmdbug.tokens);"
" IF v_token_count = 0 THEN SIGNAL SQLSTATE '05678' SET mysql_errno=@xxxmdbug_signal_errno, message_text='no arguments'; END IF;"
" SET v_value_of_first_token = (SELECT value FROM xxxmdbug.tokens WHERE token_number = 1);"
" SET v_value_of_second_token = (SELECT value FROM xxxmdbug.tokens WHERE token_number = 2);"
" SET v_length_of_first_token = LENGTH(v_value_of_first_token);"
"syntax_check: BEGIN"
" IF v_value_of_first_token = LEFT('attach',v_length_of_first_token) THEN"
" IF v_token_count>1 THEN SIGNAL SQLSTATE '05678' SET mysql_errno=@xxxmdbug_signal_errno, message_text='(attach) too many arguments'; END IF;"
" SET v_value_of_first_token = 'attach';"
" LEAVE syntax_check;"
" END IF;"
" IF v_value_of_first_token = LEFT('breakpoint',v_length_of_first_token) THEN"
" CALL xxxmdbug.syntax_check_for_breakpoint();"
" SET v_value_of_first_token = 'breakpoint';"
" LEAVE syntax_check;"
" END IF;"
" IF v_value_of_first_token = 'c' THEN"
" SIGNAL SQLSTATE '05678' SET mysql_errno=@xxxmdbug_signal_errno, message_text= 'ambiguous command, could be an abbreviation for either clear or continue';"
" END IF;"
" IF v_value_of_first_token = LEFT('clear',v_length_of_first_token) THEN"
" CALL xxxmdbug.syntax_check_for_breakpoint();"
" SET v_value_of_first_token = 'clear';"
" LEAVE syntax_check;"
" END IF;"
" IF v_value_of_first_token = LEFT('continue',v_length_of_first_token) THEN"
" IF v_token_count>1 THEN SIGNAL SQLSTATE '05678' SET mysql_errno=@xxxmdbug_signal_errno, message_text='(continue) too many arguments'; END IF;"
" SET v_value_of_first_token = 'continue';"
" LEAVE syntax_check;"
" END IF;"
" IF v_value_of_first_token = 'd' OR v_value_of_first_token = 'de' THEN"
" SIGNAL SQLSTATE '05678' SET mysql_errno=@xxxmdbug_signal_errno, message_text= 'ambiguous command, could be an abbreviation for either debug or delete';"
" END IF;"
" IF v_value_of_first_token = LEFT('debug',v_length_of_first_token) THEN"
" CALL xxxmdbug.syntax_check_for_debug();"
" SET v_value_of_first_token = 'debug';"
" LEAVE syntax_check;"
" END IF;"
" IF v_value_of_first_token = LEFT('delete',v_length_of_first_token) THEN"
" SET v_value = (SELECT value FROM xxxmdbug.tokens WHERE token_number = 2); /* will be null if 'delete' with no number */"
" IF v_value NOT BETWEEN 1 AND 10000 THEN SIGNAL SQLSTATE '05678' SET mysql_errno=@xxxmdbug_signal_errno, message_text='(delete) second argument is not a number'; END IF;"
" IF v_token_count>2 THEN SIGNAL SQLSTATE '05678' SET mysql_errno=@xxxmdbug_signal_errno, message_text='(delete) too many arguments'; END IF;"
" SET v_value_of_first_token = 'delete';"
" LEAVE syntax_check;"
" END IF;"
" IF v_value_of_first_token = 'e' OR v_value_of_first_token = 'ex' THEN"
" SIGNAL SQLSTATE '05678' SET mysql_errno=@xxxmdbug_signal_errno, message_text= 'ambiguous command, could be an abbreviation for either exit or execute';"
" END IF;"
" IF v_value_of_first_token = LEFT('execute',v_length_of_first_token) THEN"
""
" /* I can check that the first word might begin a"
" preparable statement. Actually checking whether"
" PREPARE works might also be feasible but would"
" involve much labour because some errors would"
" be applicable only to the debugger, which has"
" different privileges or defaults. */"
" IF v_value_of_second_token NOT IN ("
" 'ALTER','ANALYZE','CACHE','CALL','CHANGE','CHECKSUM','COMMIT',"
" 'CREATE','DELETE','DO','DROP','FLUSH','GRANT','INSERT','INSTALL',"
" 'KILL','LOAD','OPTIMIZE','RENAME','REPAIR','REPLACE','RESET',"
" 'REVOKE','ROLLBACK','SELECT','SET','SHOW','SLAVE','UNINSTALL','UPDATE') THEN"
" SIGNAL SQLSTATE '05678' SET mysql_errno=@xxxmdbug_signal_errno, message_text= 'Statement is not preparable';"
" END IF;"
" SET v_value_of_first_token = 'execute';"
" LEAVE syntax_check;"
" END IF;"
" IF v_value_of_first_token = LEFT('exit',v_length_of_first_token) THEN"
" IF v_token_count>1 THEN SIGNAL SQLSTATE '05678' SET mysql_errno=@xxxmdbug_signal_errno, message_text='(exit) too many arguments'; END IF;"
" SET v_value_of_first_token = 'exit';"
" LEAVE syntax_check;"
" END IF;"
" IF v_value_of_first_token = LEFT('information',v_length_of_first_token) THEN"
" IF v_value_of_second_token<>'status' THEN SIGNAL SQLSTATE '05678' SET mysql_errno=@xxxmdbug_signal_errno, message_text='(information) second word not recognized'; END IF;"
" SET v_value_of_first_token = 'information';"
" LEAVE syntax_check;"
" END IF;"
" IF v_value_of_first_token = LEFT('leave',v_length_of_first_token) THEN"
" IF v_token_count>1 THEN SIGNAL SQLSTATE '05678' SET mysql_errno=@xxxmdbug_signal_errno, message_text='(leave) too many arguments'; END IF;"
" SET v_value_of_first_token = 'leave';"
" LEAVE syntax_check;"
" END IF;"
""
" IF v_value_of_first_token = LEFT('next',v_length_of_first_token) THEN"
" IF v_token_count>1 THEN SIGNAL SQLSTATE '05678' SET mysql_errno=@xxxmdbug_signal_errno, message_text='(next) too many arguments'; END IF;"
" SET v_value_of_first_token = 'next';"
" LEAVE syntax_check;"
" END IF;"
""
" IF v_value_of_first_token = LEFT('refresh',v_length_of_first_token) THEN"
" IF v_value_of_second_token NOT IN ('call_stack','breakpoints','variables','server_variables','user_variables',"
" 'statements_executed','prepared_statements') THEN"
" SIGNAL SQLSTATE '05678' SET mysql_errno=@xxxmdbug_signal_errno, message_text= '(refresh) Invalid argument';"
" END IF;"
" SET v_value_of_first_token = 'refresh';"
" LEAVE syntax_check;"
" END IF;"
" IF v_value_of_first_token = 's' THEN"
" SIGNAL SQLSTATE '05678' SET mysql_errno=@xxxmdbug_signal_errno, message_text= 'ambiguous command, could be an abbreviation for set or skip or source or step';"
" END IF;"
" IF v_value_of_first_token = LEFT('set',v_length_of_first_token) THEN"
" CALL xxxmdbug.syntax_check_for_set();"
" SET v_value_of_first_token = 'set';"
" LEAVE syntax_check;"
" END IF;"
" IF v_value_of_first_token = LEFT('skip',v_length_of_first_token) THEN"
" IF v_token_count>1 THEN SIGNAL SQLSTATE '05678' SET mysql_errno=@xxxmdbug_signal_errno, message_text='(skip) too many arguments'; END IF;"
" SET v_value_of_first_token = 'skip';"
" LEAVE syntax_check;"
" END IF;"
" IF v_value_of_first_token = LEFT('source',v_length_of_first_token) THEN"
" SET v_value_of_first_token = 'source';"
" LEAVE syntax_check;"
" END IF;"
" IF v_value_of_first_token = LEFT('step',v_length_of_first_token) THEN"
" IF v_token_count>1 THEN SIGNAL SQLSTATE '05678' SET mysql_errno=@xxxmdbug_signal_errno, message_text='(step) too many arguments'; END IF;"
" SET v_value_of_first_token = 'step';"
" LEAVE syntax_check;"
" END IF;"
""
" IF v_value_of_first_token = LEFT('tbreakpoint',v_length_of_first_token) THEN"
" CALL xxxmdbug.syntax_check_for_breakpoint();"
" SET v_value_of_first_token = 'tbreakpoint';"
" LEAVE syntax_check;"
" END IF;"
""
" SET v_error_message=CONCAT('unknown command: ',v_value_of_first_token);"
" SIGNAL SQLSTATE '05678' SET mysql_errno=@xxxmdbug_signal_errno, message_text=v_error_message;"
" END; /* end of syntax_check */"
""
" SET @xxxmdbug_last_command = message; /* This is never used. Maybe I put it in for debugging reasons. */"
""
" /* There is nothing to if v_value_of_first_token='attach', which doesn't do much. But consider for 'attach':"
" todo: see whether debuggee is waiting for you particularly"
" todo: see whether channel is empty"
" todo: send connection_id along with attach message. */"
""
" IF v_value_of_first_token ='information' AND v_value_of_second_token = 'status' THEN"
" CALL xxxmdbug.command_i_status();"
" LEAVE command;"
" END IF;"
""
" IF v_value_of_first_token='source' THEN"
" SET message=RIGHT(message,LENGTH(message)-v_length_of_first_token);"
" CALL xxxmdbug.setup_internal(message,0);"
" LEAVE command;"
" END IF;"
""
" IF v_value_of_first_token = 'refresh' THEN"
" IF v_value_of_second_token ='call_stack' THEN CALL xxxmdbug.command_r_call_stack(message); END IF;"
" IF v_value_of_second_token ='breakpoints' THEN CALL xxxmdbug.command_r_breakpoints(message); END IF;"
" IF v_value_of_second_token ='variables' THEN CALL xxxmdbug.command_r_variables(message); END IF;"
" IF v_value_of_second_token ='server_variables' THEN CALL xxxmdbug.command_r_server_variables(message); END IF;"
" IF v_value_of_second_token ='user_variables' THEN CALL xxxmdbug.command_r_user_variables(message); END IF;"
" IF v_value_of_second_token ='statements_executed' THEN CALL xxxmdbug.command_r_statements_executed(message); END IF;"
" IF v_value_of_second_token ='prepared_statements' THEN CALL xxxmdbug.command_r_prepared_statements(message); END IF;"
" /* anything else is probably bad syntax, and that will have beeen stop by earlier syntax checking */"
" ELSE"
" SET v_prefix = CONCAT('xxxmdbug_',@xxxmdbug_channel,@xxxmdbug_prefix_end_for_command); /* 'C ' */"
" CALL xxxmdbug.dbms_pipe_send(v_prefix,message);"
" END IF;"
" END");
if (lmysql->ldbms_mysql_real_query(mysql, x, strlen(x))) return -1;
strcpy(x,
""
"/* We do not actually do anything for command(...,'breakpoint ...'), except pipe it to the debuggee."
" But there are many syntax errors to check for. */"
"/* syntax_check_for_breakpoint() is called from command() and follows"
" the same sequence of checks as icc_process_user_command_break()."
" In fact it would be surprising if icc_process_user_command_break()"
" saw bad syntax because syntax_check_for_breakpoint() should catch"
" everything severe. */"
"/* todo: syntax must allow type,"
" check for identifier contains supplementary characters."
" check for too-long-literal happens before changing 0x... to longblob."
" decide between SQL-ish syntax and gdb-ish syntax."
" perhaps @variable_name could be legal instead of literal. */"
"/* break. expect \"break|tbreak [[schema_identifier.]routine_identifier] line_number_minimum[-line_number_maximum] [variable=value]\". */"
"/* this syntax check is also used for the 'clear' command. */"
"CREATE PROCEDURE xxxmdbug.syntax_check_for_breakpoint ()"
"BEGIN"
" DECLARE break_token_number INT;"
" DECLARE break_token VARCHAR(66) CHARACTER SET utf8;"
" DECLARE v_schema_identifier VARCHAR(66) CHARACTER SET utf8 DEFAULT '';"
" DECLARE v_routine_identifier VARCHAR(66) CHARACTER SET utf8 DEFAULT '';"
" DECLARE v_routine_type VARCHAR(10) CHARACTER SET utf8 DEFAULT 'ROUTINE';"
" DECLARE v_line_number_minimum INT DEFAULT 0;"
" DECLARE v_line_number_maximum INT DEFAULT 0;"
" DECLARE v_condition_identifier VARCHAR(66) CHARACTER SET utf8 DEFAULT '';"
" DECLARE v_condition_operator VARCHAR(2) CHARACTER SET utf8 DEFAULT '';"
" DECLARE v_condition_value VARCHAR(66) CHARACTER SET utf8 DEFAULT '';"
" DECLARE v_junk VARCHAR(256) CHARACTER SET utf8;"
" DECLARE routine_type VARCHAR(1) CHARACTER SET utf8; /* 'F' or 'P', taken from surrogate routine identifier */"
" DECLARE v_surrogate_routine_identifier VARCHAR(66) CHARACTER SET utf8;"
" DECLARE v_surrogate_schema_identifier VARCHAR(66) CHARACTER SET utf8;"
" DECLARE v_remainder_of_original_name VARCHAR(8192) CHARACTER SET utf8;"
""
" /* if it doesn't start with line_number, then it must be starting with [[schema_identifier.]routine_identifier] */"
""
" SET break_token_number = 2;"
""
" SET break_token = (SELECT value FROM xxxmdbug.tokens WHERE token_number = break_token_number);"
""
" CALL xxxmdbug.get_token_identifier_type(break_token);"
""
" IF @xxxmdbug_token_type IN (1,2,3) THEN /* is break_token any kind of identifier? */"
" SET break_token = (SELECT value FROM xxxmdbug.tokens WHERE token_number = break_token_number+1);"
" IF break_token = '.' THEN"
" SET v_schema_identifier = (SELECT value FROM xxxmdbug.tokens WHERE token_number = break_token_number);"
" SET v_routine_identifier = (SELECT value FROM xxxmdbug.tokens WHERE token_number = break_token_number+2);"
" SET break_token_number=break_token_number+3;"
" ELSE"
" SET v_schema_identifier = @xxxmdbug_default_schema;"
" SET v_routine_identifier = (SELECT value FROM xxxmdbug.tokens WHERE token_number = break_token_number);"
" SET break_token_number=break_token_number+1;"
" END IF;"
""
" /* It is okay if the routine is not in the setup group that is being debugged."
" It is not okay if the routine cannot be found. */"
" IF (SELECT COUNT(*) FROM information_schema.routines"
" WHERE routine_schema COLLATE utf8_general_ci LIKE v_schema_identifier AND routine_name COLLATE utf8mb3_general_ci LIKE v_routine_identifier)=0 THEN"
" SIGNAL SQLSTATE '05678' SET mysql_errno=@xxxmdbug_signal_errno, message_text= 'Routine not found';"
" END IF;"
""
" /* I used to have an additional check: it is not okay if the routine's surrogate cannot be found."
" I decided that is too strict, since it should be okay if debugger user has no privilege on a subsidiary routine."
" Also the method of checking, calling debuggee_get_surrogate_name, ran into trouble when I escaped for % and _. */"
""
" END IF;"
""
" SET break_token = (SELECT value FROM xxxmdbug.tokens WHERE token_number = break_token_number);"
""
" CALL xxxmdbug.get_token_identifier_type(break_token);"
" IF @xxxmdbug_token_type=0 THEN CALL xxxmdbug.get_token_type(break_token); END IF;"
""
" IF @xxxmdbug_token_type <> 4 THEN"
" SIGNAL SQLSTATE '05678' SET mysql_errno=@xxxmdbug_signal_errno, message_text= 'There has to be a line number';"
" ELSE"
" SET v_line_number_minimum = break_token;"
" SET break_token = (SELECT value FROM xxxmdbug.tokens WHERE token_number = break_token_number+1);"
" IF break_token = '-' THEN"
" SET break_token = (SELECT value FROM xxxmdbug.tokens WHERE token_number = break_token_number+2);"
" CALL xxxmdbug.get_token_identifier_type(break_token);"
" IF @xxxmdbug_token_type=0 THEN CALL xxxmdbug.get_token_type(break_token); END IF;"
" IF @xxxmdbug_token_type <> 4 THEN"
" SIGNAL SQLSTATE '05678' SET mysql_errno=@xxxmdbug_signal_errno, message_text= 'Maximum line number must be an integer';"
" END IF;"
" SET v_line_number_maximum = break_token;"
" IF v_line_number_maximum < v_line_number_minimum THEN"
" SIGNAL SQLSTATE '05678' SET mysql_errno=@xxxmdbug_signal_errno, message_text= 'Maximum line number < minimum line number';"
" END IF;"
" SET break_token_number=break_token_number+3;"