Skip to content

Commit cb0c0e4

Browse files
committed
fbdoc: mysql_init() must allocate MYSQL structure due to mismatched version of mysql/mysql.bi and mysql library
1 parent 1f8bb73 commit cb0c0e4

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

doc/libfbdoc/CWikiConSql.bas

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace fb.fbdoc
6161
( _
6262
)
6363

64-
db = new MYSQL
64+
db = NULL
6565
connected = FALSE
6666

6767
end constructor
@@ -73,9 +73,7 @@ namespace fb.fbdoc
7373
if( connected ) then
7474
Disconnect()
7575
end if
76-
if( db <> NULL ) then
77-
delete db
78-
end if
76+
db = NULL
7977

8078
end destructor
8179

@@ -91,6 +89,10 @@ namespace fb.fbdoc
9189

9290
function = FALSE
9391

92+
if( connected = TRUE ) then
93+
return TRUE
94+
end if
95+
9496
if( db_host = NULL ) then
9597
exit function
9698
end if
@@ -109,14 +111,16 @@ namespace fb.fbdoc
109111

110112
printlog "Connecting to database: " + *db_name + " on " + *db_host + ":" + str(db_port)
111113

112-
if( NULL = mysql_init( db )) then
114+
'' we must let mysql_init() allocate; mysql/mysql.bi is
115+
'' too out of date to trust the sizeof( MYSQL )
116+
db = mysql_init( NULL )
117+
118+
if( NULL = db ) then
113119
printlog "Error " + str(mysql_errno(db)) + ": " + *mysql_error(db)
114120
printlog "Unable to initialize mysql"
115121
return FALSE
116122
end if
117123

118-
exit function
119-
120124
if( NULL = mysql_real_connect(db, db_host, db_user, db_pass, db_name, db_port, NULL, 0)) then
121125
mysql_close( db )
122126
printlog "Unable to connect to database"
@@ -341,7 +345,7 @@ namespace fb.fbdoc
341345
return FALSE
342346
end if
343347

344-
sql = "SELECT tag FROM wikka_pages WHERE ( latest = 'Y' )"
348+
sql = "SELECT tag FROM wikka_pages WHERE ( latest = 'Y' ) ORDER BY tag"
345349

346350
if( 0 <> mysql_real_query( ctx->db_conn->db, sql, len(sql)) ) then
347351
return FALSE

0 commit comments

Comments
 (0)