~ubuntu-branches/ubuntu/vivid/mediatomb/vivid

« back to all changes in this revision

Viewing changes to src/storage/mysql/mysql_storage.cc

  • Committer: Bazaar Package Importer
  • Author(s): Andres Mejia
  • Date: 2008-03-02 13:09:16 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080302130916-zlljdze3kt7vuq4b
Tags: 0.11.0-1
* New upstream release.
* Include message about which inotify headers will be used when enabling
  inotify runtime support.
* Fixed error with use of INTERFACE in init script. Also removed use of -m
  option.
* Including new config.xml options.
* Added more build dependencies for new upstream release.
* Removed build dependency of libid3-dev, taglib is now preferred.
* mediatomb.xpm and manpage.xml is now included in orig tarball.
* inotify patch is not needed anymore.
* md5 patch has been committed upstream and is no longer needed. Also removed
  README.Debian.
* TwinHelix PNG fix is now used. Removed from TODO.
* Adding dependency of iceweasel for mediatomb package.
* Updated copyright file.
* Updated watch file.
* Updated rules file for proper configure options.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
    Copyright (C) 2005 Gena Batyan <bgeradz@mediatomb.cc>,
8
8
                       Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>
9
9
    
10
 
    Copyright (C) 2006-2007 Gena Batyan <bgeradz@mediatomb.cc>,
 
10
    Copyright (C) 2006-2008 Gena Batyan <bgeradz@mediatomb.cc>,
11
11
                            Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>,
12
12
                            Leonhard Wimmer <leo@mediatomb.cc>
13
13
    
24
24
    version 2 along with MediaTomb; if not, write to the Free Software
25
25
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
26
26
    
27
 
    $Id: mysql_storage.cc 1354 2007-06-07 23:02:34Z jin_eld $
 
27
    $Id: mysql_storage.cc 1698 2008-02-23 20:48:30Z lww $
28
28
*/
29
29
 
30
30
/// \file mysql_storage.cc
35
35
 
36
36
#ifdef HAVE_MYSQL
37
37
 
38
 
#define MYSQL_SET_NAMES "/*!40101 SET NAMES utf8 */"
 
38
//#define MYSQL_SET_NAMES "/*!40101 SET NAMES utf8 */"
39
39
 
40
40
//#define MYSQL_SELECT_DEBUG
41
41
//#define MYSQL_EXEC_DEBUG
42
42
 
43
43
#include "mysql_storage.h"
44
44
#include "config_manager.h"
45
 
#include "destroyer.h"
46
45
 
47
46
#ifdef AUTO_CREATE_DATABASE
48
47
    #include "mysql_create_sql.h"
63
62
#define MYSQL_UPDATE_2_3_3 "ALTER TABLE `mt_autoscan` ADD `path_ids` BLOB AFTER `location`"
64
63
#define MYSQL_UPDATE_2_3_4 "UPDATE `mt_internal_setting` SET `value`='3' WHERE `key`='db_version' AND `value`='2'"
65
64
 
 
65
// updates 3->4
 
66
#define MYSQL_UPDATE_3_4_1 "ALTER TABLE `mt_cds_object` ADD `service_id` varchar(255) default NULL"
 
67
#define MYSQL_UPDATE_3_4_2 "ALTER TABLE `mt_cds_object` ADD KEY `cds_object_service_id` (`service_id`)"
 
68
#define MYSQL_UPDATE_3_4_3 "UPDATE `mt_internal_setting` SET `value`='4' WHERE `key`='db_version' AND `value`='3'"
 
69
 
66
70
 
67
71
using namespace zmm;
68
72
using namespace mxml;
142
146
    
143
147
    mysql_init_key_initialized = true;
144
148
    
 
149
    mysql_options(&db, MYSQL_SET_CHARSET_NAME, "utf8");
 
150
    
 
151
    #ifdef HAVE_MYSQL_OPT_RECONNECT
 
152
        my_bool my_bool_var = true;
 
153
        mysql_options(&db, MYSQL_OPT_RECONNECT, &my_bool_var);
 
154
    #endif
 
155
    
145
156
    res_mysql = mysql_real_connect(&db,
146
157
        dbHost.c_str(),
147
158
        dbUser.c_str(),
156
167
        throw _Exception(_("The connection to the MySQL database has failed: ") + getError(&db));
157
168
    }
158
169
    
 
170
    /*
159
171
    int res = mysql_real_query(&db, MYSQL_SET_NAMES, strlen(MYSQL_SET_NAMES));
160
172
    if(res)
161
173
    {
162
174
        String myError = getError(&db);
163
175
        throw _StorageException(nil, _("MySQL query 'SET NAMES' failed!"));
164
176
    }
 
177
    */
165
178
    
166
 
    #ifdef HAVE_MYSQL_OPT_RECONNECT
167
 
        my_bool my_bool_var = true;
168
 
        mysql_options(&db, MYSQL_OPT_RECONNECT, &my_bool_var);
169
 
    #endif
170
179
    
171
180
    mysql_connection = true;
172
181
    
250
259
        log_info("database upgrade successful.\n");
251
260
        dbVersion = _("3");
252
261
    }
 
262
    
 
263
    if (dbVersion == "3")
 
264
    {
 
265
        log_info("Doing an automatic database upgrade from database version 3 to version 4...\n");
 
266
        _exec(MYSQL_UPDATE_3_4_1);
 
267
        _exec(MYSQL_UPDATE_3_4_2);
 
268
        _exec(MYSQL_UPDATE_3_4_3);
 
269
        log_info("database upgrade successful.\n");
 
270
        dbVersion = _("4");
 
271
    }
 
272
    
253
273
    /* --- --- ---*/
254
274
    
255
 
    if (! string_ok(dbVersion) || dbVersion != "3")
 
275
    if (! string_ok(dbVersion) || dbVersion != "4")
256
276
        throw _Exception(_("The database seems to be from a newer version (database version ") + dbVersion + ")!");
257
277
    
258
278
    AUTOUNLOCK();
356
376
    *q << "INSERT INTO " << QTB << INTERNAL_SETTINGS_TABLE << QTE << " (`key`, `value`) "
357
377
    "VALUES (" << quote(key) << ", "<< quotedValue << ") "
358
378
    "ON DUPLICATE KEY UPDATE `value` = " << quotedValue;
359
 
    execSB(q);
 
379
    SQLStorage::exec(q);
360
380
}
361
381
 
362
382
void MysqlStorage::_exec(const char *query)