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
|
--- old/Library/src/HTSQL.c 2005-03-18 15:54:48.170275368 +0100
+++ w3c-libwww-5.4.0/Library/src/HTSQL.c 2005-03-18 17:11:38.895338616 +0100
@@ -182,11 +182,25 @@
{
if (me && me->host) {
HTTRACE(SQL_TRACE, "SQL connect. Open a link to server `%s\'\n" _ me->host);
+#if MYSQL_VERSION_ID>=32200
+ if (!mysql_init(&(me->server))) {
+ return NO;
+ }
+#endif
+
+#if MYSQL_VERSION_ID>=40103
+ if ((me->psvr = mysql_real_connect(&(me->server), me->host,
+ me->user ? me->user : "",
+ me->password ? me->password : "",
+ "", 0 , 0 , 0)) == NULL) {
+#else
+
if ((me->psvr = mysql_connect(&(me->server), me->host,
me->user ? me->user : "",
me->password ? me->password : "")) == NULL) {
- HTTRACE(SQL_TRACE, "SQL connect. `%s\' errno %d\n" _
- mysql_error(&me->server) _ mysql_errno(&me->server));
+#endif
+ HTTRACE(SQL_TRACE, "SQL connect. `%s\' errno %d\n" _
+ mysql_error(&me->server) _ mysql_errno(&me->server));
return NO;
}
return YES;
@@ -230,6 +244,7 @@
PUBLIC BOOL HTSQL_selectDB (HTSQL * me, const char * db)
{
BOOL created = NO;
+ char query[1024];
if (me && me->psvr && db) {
HTTRACE(SQL_TRACE, "SQL select.. Database `%s\'\n" _ db);
me->db = NULL;
@@ -240,7 +255,12 @@
/* If the database couldn't be found then create a new one */
if (err == 1049) {
+#if MYSQL_VERSION_ID>=40103
+ sprintf (query, "CREATE DATABASE %s", db);
+ if (mysql_query(me->psvr, query) != 0) {
+#else
if (mysql_create_db(me->psvr, db) < 0) {
+#endif
HTTRACE(SQL_TRACE, "SQL error... `%s\', errno %d\n" _
mysql_error(me->psvr) _ err);
return NO;
|