line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "use_perl.h" |
2
|
|
|
|
|
|
|
#include "debug.h" |
3
|
|
|
|
|
|
|
#include "macro.h" |
4
|
|
|
|
|
|
|
#include "context.h" |
5
|
|
|
|
|
|
|
#include "state.h" |
6
|
|
|
|
|
|
|
#include "parser.h" |
7
|
|
|
|
|
|
|
#include "xsutil.h" |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
MODULE = MySQL::Dump::Parser::XS PACKAGE = MySQL::Dump::Parser::XS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
void |
14
|
|
|
|
|
|
|
new(...) |
15
|
|
|
|
|
|
|
PPCODE: |
16
|
|
|
|
|
|
|
{ |
17
|
4
|
50
|
|
|
|
|
if (items != 1) { |
18
|
0
|
|
|
|
|
|
croak("Invalid argument count: %d", items); |
19
|
|
|
|
|
|
|
} |
20
|
4
|
50
|
|
|
|
|
const char *klass = SvPV_nolen(ST(0)); |
21
|
|
|
|
|
|
|
|
22
|
4
|
|
|
|
|
|
HV* state = newState(aTHX); |
23
|
4
|
|
|
|
|
|
SV* self = newRV_inc_mortal((SV*)state); |
24
|
4
|
|
|
|
|
|
sv_bless(self, gv_stashpv(klass, 1)); |
25
|
4
|
|
|
|
|
|
SvREADONLY_on(self); |
26
|
4
|
50
|
|
|
|
|
XPUSHs(self); |
27
|
4
|
|
|
|
|
|
XSRETURN(1); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
void |
31
|
|
|
|
|
|
|
reset(...) |
32
|
|
|
|
|
|
|
PPCODE: |
33
|
|
|
|
|
|
|
{ |
34
|
0
|
0
|
|
|
|
|
if (items != 1) { |
35
|
0
|
|
|
|
|
|
croak("Invalid argument count: %d", items); |
36
|
|
|
|
|
|
|
} |
37
|
0
|
|
|
|
|
|
HV* state = (HV*)SvRV(ST(0)); |
38
|
0
|
|
|
|
|
|
hv_clear(state); |
39
|
0
|
|
|
|
|
|
initState(aTHX_ state); |
40
|
0
|
|
|
|
|
|
XSRETURN(0); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
void |
44
|
|
|
|
|
|
|
parse(...) |
45
|
|
|
|
|
|
|
PPCODE: |
46
|
|
|
|
|
|
|
{ |
47
|
182
|
50
|
|
|
|
|
if (items != 2) { |
48
|
0
|
|
|
|
|
|
croak("Invalid argument count: %d", items); |
49
|
|
|
|
|
|
|
} |
50
|
182
|
|
|
|
|
|
HV* state = (HV*)SvRV(ST(0)); |
51
|
182
|
|
|
|
|
|
SV* src = ST(1); |
52
|
|
|
|
|
|
|
|
53
|
182
|
50
|
|
|
|
|
AV* ret = parse(aTHX_ state, SvPV_nolen(src)); |
54
|
182
|
100
|
|
|
|
|
if (ret == NULL) { |
55
|
173
|
|
|
|
|
|
XSRETURN(0); |
56
|
|
|
|
|
|
|
return; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
I32 size = 0; |
60
|
27
|
50
|
|
|
|
|
XSUTIL_AV_FOREACH(ret, entry, { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
61
|
|
|
|
|
|
|
XPUSHs(entry); |
62
|
|
|
|
|
|
|
size++; |
63
|
|
|
|
|
|
|
}); |
64
|
9
|
|
|
|
|
|
XSRETURN(size); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
void |
68
|
|
|
|
|
|
|
current_target_table(...) |
69
|
|
|
|
|
|
|
PPCODE: |
70
|
|
|
|
|
|
|
{ |
71
|
3
|
50
|
|
|
|
|
if (items != 1) { |
72
|
0
|
|
|
|
|
|
croak("Invalid argument count: %d", items); |
73
|
|
|
|
|
|
|
} |
74
|
3
|
|
|
|
|
|
HV* state = (HV*)SvRV(ST(0)); |
75
|
3
|
|
|
|
|
|
SV* table = get_table(aTHX_ state); |
76
|
3
|
50
|
|
|
|
|
XPUSHs(table); |
77
|
3
|
|
|
|
|
|
XSRETURN(1); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
void |
81
|
|
|
|
|
|
|
columns(...) |
82
|
|
|
|
|
|
|
PPCODE: |
83
|
|
|
|
|
|
|
{ |
84
|
3
|
50
|
|
|
|
|
if (items != 2) { |
85
|
0
|
|
|
|
|
|
croak("Invalid argument count: %d", items); |
86
|
|
|
|
|
|
|
} |
87
|
3
|
|
|
|
|
|
HV* state = (HV*)SvRV(ST(0)); |
88
|
3
|
|
|
|
|
|
SV* table = ST(1); |
89
|
|
|
|
|
|
|
|
90
|
3
|
|
|
|
|
|
HV* schema = get_or_create_schema(aTHX_ state, table); |
91
|
3
|
|
|
|
|
|
AV* columns = get_or_create_columns(aTHX_ schema); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
I32 size = 0; |
94
|
24
|
50
|
|
|
|
|
XSUTIL_AV_FOREACH(columns, entry, { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
95
|
|
|
|
|
|
|
XPUSHs(entry); |
96
|
|
|
|
|
|
|
size++; |
97
|
|
|
|
|
|
|
}); |
98
|
3
|
|
|
|
|
|
XSRETURN(size); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
void |
102
|
|
|
|
|
|
|
tables(...) |
103
|
|
|
|
|
|
|
PPCODE: |
104
|
|
|
|
|
|
|
{ |
105
|
3
|
50
|
|
|
|
|
if (items != 1) { |
106
|
0
|
|
|
|
|
|
croak("Invalid argument count: %d", items); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
3
|
|
|
|
|
|
HV* state = (HV*)SvRV(ST(0)); |
110
|
3
|
|
|
|
|
|
SV** ssv = XSUTIL_HV_FETCH(state, "schema"); |
111
|
3
|
50
|
|
|
|
|
if (! ssv) { |
112
|
0
|
|
|
|
|
|
XSRETURN(0); |
113
|
|
|
|
|
|
|
return; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
I32 size = 0; |
117
|
6
|
50
|
|
|
|
|
XSUTIL_HV_FOREACH((HV*)SvRV(*ssv), entry, { |
|
|
100
|
|
|
|
|
|
118
|
|
|
|
|
|
|
SV* key = hv_iterkeysv(entry); |
119
|
|
|
|
|
|
|
XPUSHs(key); |
120
|
|
|
|
|
|
|
size++; |
121
|
|
|
|
|
|
|
}); |
122
|
3
|
|
|
|
|
|
XSRETURN(size); |
123
|
|
|
|
|
|
|
} |