回答編集履歴
5
変更
test
CHANGED
@@ -38,7 +38,7 @@
|
|
38
38
|
|
39
39
|
mysql_init(&mysql);
|
40
40
|
|
41
|
-
mysql_real_connect(&mysql,"localhost", "root", "
|
41
|
+
mysql_real_connect(&mysql,"localhost", "root", "passwd","", 0, 0, 0);
|
42
42
|
|
43
43
|
if (&mysql == NULL) {
|
44
44
|
|
4
変更
test
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
|
25
25
|
MYSQL_STMT *stmt;
|
26
26
|
|
27
|
-
MYSQL
|
27
|
+
MYSQL mysql;
|
28
28
|
|
29
29
|
MYSQL_BIND par[1];
|
30
30
|
|
@@ -36,37 +36,39 @@
|
|
36
36
|
|
37
37
|
|
38
38
|
|
39
|
-
mysql_init(mysql);
|
39
|
+
mysql_init(&mysql);
|
40
|
-
|
40
|
+
|
41
|
-
mysql_real_connect(mysql,"localhost","root","","t
|
41
|
+
mysql_real_connect(&mysql,"localhost", "root", "teraoka","ts2100", 0, 0, 0);
|
42
|
-
|
42
|
+
|
43
|
-
if (mysql == NULL) {
|
43
|
+
if (&mysql == NULL) {
|
44
|
-
|
44
|
+
|
45
|
-
|
45
|
+
printf(mysql_error(&mysql));
|
46
|
-
|
46
|
+
|
47
|
-
|
47
|
+
return 1;
|
48
48
|
|
49
49
|
}
|
50
50
|
|
51
51
|
puts("==== Regular Execution ====");
|
52
52
|
|
53
|
+
fflush( stdout );
|
54
|
+
|
53
55
|
|
54
56
|
|
55
57
|
char sql1[]= "SELECT user, host FROM mysql.user WHERE host LIKE '%localhost%'";
|
56
58
|
|
57
|
-
state = mysql_query(mysql, sql1);
|
59
|
+
state = mysql_query(&mysql, sql1);
|
58
60
|
|
59
61
|
if (state != 0) {
|
60
62
|
|
61
|
-
printf(mysql_error(mysql));
|
63
|
+
printf(mysql_error(&mysql));
|
62
|
-
|
64
|
+
|
63
|
-
e
|
65
|
+
return 1;
|
64
|
-
|
66
|
+
|
65
|
-
}
|
67
|
+
}
|
66
|
-
|
67
|
-
|
68
|
-
|
68
|
+
|
69
|
+
|
70
|
+
|
69
|
-
result = mysql_store_result(mysql);
|
71
|
+
result = mysql_store_result(&mysql);
|
70
72
|
|
71
73
|
printf("Rows: %d\n", mysql_num_rows(result));
|
72
74
|
|
@@ -76,21 +78,21 @@
|
|
76
78
|
|
77
79
|
printf("%s@%s\n", row[0], row[1]);
|
78
80
|
|
79
|
-
}
|
81
|
+
}
|
80
|
-
|
82
|
+
|
81
|
-
mysql_free_result(result);
|
83
|
+
mysql_free_result(result);
|
82
84
|
|
83
85
|
|
84
86
|
|
85
87
|
puts("==== Prepared Statement ====");
|
86
88
|
|
87
|
-
stmt = mysql_stmt_init(mysql);
|
89
|
+
stmt = mysql_stmt_init(&mysql);
|
88
90
|
|
89
91
|
if (!stmt) {
|
90
92
|
|
91
93
|
fprintf(stderr, " mysql_stmt_init(), out of memory\n");
|
92
94
|
|
93
|
-
exit(
|
95
|
+
exit(0);
|
94
96
|
|
95
97
|
}
|
96
98
|
|
@@ -104,7 +106,7 @@
|
|
104
106
|
|
105
107
|
fprintf(stderr, " %s\n", mysql_stmt_error(stmt));
|
106
108
|
|
107
|
-
exit(
|
109
|
+
exit(0);
|
108
110
|
|
109
111
|
}
|
110
112
|
|
@@ -128,11 +130,11 @@
|
|
128
130
|
|
129
131
|
if (mysql_stmt_bind_param(stmt,par)){
|
130
132
|
|
131
|
-
fprintf(stderr, " mysql_stmt_bind_param() failed\n");
|
133
|
+
fprintf(stderr, " mysql_stmt_bind_param() failed\n");
|
132
|
-
|
134
|
+
|
133
|
-
fprintf(stderr, " %s\n", mysql_stmt_error(stmt));
|
135
|
+
fprintf(stderr, " %s\n", mysql_stmt_error(stmt));
|
134
|
-
|
136
|
+
|
135
|
-
exit(
|
137
|
+
exit(0);
|
136
138
|
|
137
139
|
}
|
138
140
|
|
@@ -146,7 +148,7 @@
|
|
146
148
|
|
147
149
|
fprintf(stderr, " %s\n", mysql_stmt_error(stmt));
|
148
150
|
|
149
|
-
exit(
|
151
|
+
exit(0);
|
150
152
|
|
151
153
|
}
|
152
154
|
|
@@ -182,7 +184,7 @@
|
|
182
184
|
|
183
185
|
fprintf(stderr, " %s\n", mysql_stmt_error(stmt));
|
184
186
|
|
185
|
-
exit(
|
187
|
+
exit(0);
|
186
188
|
|
187
189
|
}
|
188
190
|
|
@@ -194,7 +196,7 @@
|
|
194
196
|
|
195
197
|
fprintf(stderr, " %s\n", mysql_stmt_error(stmt));
|
196
198
|
|
197
|
-
exit(
|
199
|
+
exit(0);
|
198
200
|
|
199
201
|
}
|
200
202
|
|
@@ -210,6 +212,8 @@
|
|
210
212
|
|
211
213
|
mysql_stmt_close(stmt);
|
212
214
|
|
213
|
-
mysql_close(mysql);
|
215
|
+
mysql_close(&mysql);
|
216
|
+
|
217
|
+
}
|
214
218
|
|
215
219
|
```
|
3
変更
test
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
|
25
25
|
MYSQL_STMT *stmt;
|
26
26
|
|
27
|
-
MYSQL *
|
27
|
+
MYSQL *mysql;
|
28
28
|
|
29
29
|
MYSQL_BIND par[1];
|
30
30
|
|
@@ -38,9 +38,9 @@
|
|
38
38
|
|
39
39
|
mysql_init(mysql);
|
40
40
|
|
41
|
-
|
41
|
+
mysql_real_connect(mysql,"localhost","root","","test",0,NULL,0);
|
42
|
-
|
42
|
+
|
43
|
-
if (
|
43
|
+
if (mysql == NULL) {
|
44
44
|
|
45
45
|
printf(mysql_error(mysql));
|
46
46
|
|
@@ -54,11 +54,11 @@
|
|
54
54
|
|
55
55
|
char sql1[]= "SELECT user, host FROM mysql.user WHERE host LIKE '%localhost%'";
|
56
56
|
|
57
|
-
state = mysql_query(
|
57
|
+
state = mysql_query(mysql, sql1);
|
58
58
|
|
59
59
|
if (state != 0) {
|
60
60
|
|
61
|
-
printf(mysql_error(
|
61
|
+
printf(mysql_error(mysql));
|
62
62
|
|
63
63
|
exit(1);
|
64
64
|
|
@@ -66,7 +66,7 @@
|
|
66
66
|
|
67
67
|
|
68
68
|
|
69
|
-
result = mysql_store_result(
|
69
|
+
result = mysql_store_result(mysql);
|
70
70
|
|
71
71
|
printf("Rows: %d\n", mysql_num_rows(result));
|
72
72
|
|
@@ -212,6 +212,4 @@
|
|
212
212
|
|
213
213
|
mysql_close(mysql);
|
214
214
|
|
215
|
-
mysql_close(connection);
|
216
|
-
|
217
215
|
```
|
2
変更
test
CHANGED
@@ -38,7 +38,7 @@
|
|
38
38
|
|
39
39
|
mysql_init(mysql);
|
40
40
|
|
41
|
-
connection = mysql_real_connect(m,"localhost","root","","test",0,NULL,0);
|
41
|
+
connection = mysql_real_connect(mysql,"localhost","root","","test",0,NULL,0);
|
42
42
|
|
43
43
|
if (connection == NULL) {
|
44
44
|
|
1
変更
test
CHANGED
@@ -38,7 +38,7 @@
|
|
38
38
|
|
39
39
|
mysql_init(mysql);
|
40
40
|
|
41
|
-
connection = mysql_real_connect(m
|
41
|
+
connection = mysql_real_connect(m,"localhost","root","","test",0,NULL,0);
|
42
42
|
|
43
43
|
if (connection == NULL) {
|
44
44
|
|