Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: guilib/guilib.vcproj
- ===================================================================
- --- guilib/guilib.vcproj (revision 30970)
- +++ guilib/guilib.vcproj (working copy)
- @@ -22,7 +22,7 @@
- AdditionalOptions="/EHa"
- Optimization="0"
- OptimizeForProcessor="2"
- - AdditionalIncludeDirectories="../xbmc;freetype2\include;"$(XDK)\Samples\Xbox\Common\Include";../xbmc/lib/boost"
- + AdditionalIncludeDirectories=""C:\Program Files\MySQL\MySQL Connector C 6.0.2\include";../xbmc;freetype2\include;"$(XDK)\Samples\Xbox\Common\Include";../xbmc/lib/boost"
- PreprocessorDefinitions="_DEBUG;_XBOX;_LIB"
- StringPooling="FALSE"
- MinimalRebuild="FALSE"
- Index: xbmc.vcproj
- ===================================================================
- --- xbmc.vcproj (revision 30970)
- +++ xbmc.vcproj (working copy)
- @@ -212,11 +212,12 @@
- Name="VCCLCompilerTool"
- AdditionalOptions="/EHa"
- Optimization="1"
- + GlobalOptimizations="TRUE"
- InlineFunctionExpansion="1"
- FavorSizeOrSpeed="2"
- OmitFramePointers="TRUE"
- OptimizeForProcessor="2"
- - AdditionalIncludeDirectories="./xbmc;./xbmc/cores/dvdplayer/Codecs/ffmpeg;./xbmc/cores/dvdplayer/;./guilib;./guilib/common;"$(XDK)\Samples\Xbox\Common\Include";xbmc/lib/libUPnP/Platinum/Source/Devices/MediaServer;xbmc/lib/libUPnP/Platinum/Source/Devices/MediaRenderer;xbmc/lib/libUPnP/Platinum/Source/Devices/MediaConnect;xbmc/lib/libUPnP/Platinum/Source/Core;xbmc/lib/libUPnP/Platinum/Source/Platinum;xbmc/lib/libUPnP/Neptune/Source/Core;xbmc/lib/libUPnP/Neptune/Source/System/Xbox;./xbmc/lib/boost;./xbmc/lib/libRTMP;./xbmc/utils;./xbmc/xbox;./xbmc/lib/libcurl/include;./xbmc/lib;xbmc/lib/libPython/python/PC"
- + AdditionalIncludeDirectories=""C:\Program Files\MySQL\MySQL Connector C 6.0.2\include";./xbmc;./xbmc/cores/dvdplayer/Codecs/ffmpeg;./xbmc/cores/dvdplayer/;./guilib;./guilib/common;"$(XDK)\Samples\Xbox\Common\Include";xbmc/lib/libUPnP/Platinum/Source/Devices/MediaServer;xbmc/lib/libUPnP/Platinum/Source/Devices/MediaRenderer;xbmc/lib/libUPnP/Platinum/Source/Devices/MediaConnect;xbmc/lib/libUPnP/Platinum/Source/Core;xbmc/lib/libUPnP/Platinum/Source/Platinum;xbmc/lib/libUPnP/Neptune/Source/Core;xbmc/lib/libUPnP/Neptune/Source/System/Xbox;./xbmc/lib/boost;./xbmc/lib/libRTMP;./xbmc/utils;./xbmc/xbox;./xbmc/lib/libcurl/include;./xbmc/lib;xbmc/lib/libPython/python/PC"
- PreprocessorDefinitions="_XBOX;_XBMC;NDEBUG;HAVE_MSWINDOWS;NOMINMAX"
- StringPooling="TRUE"
- ExceptionHandling="FALSE"
- @@ -233,11 +234,13 @@
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLinkerTool"
- - AdditionalDependencies="xapilib.lib d3dx8.lib d3d8.lib xgraphics.lib dsound.lib xboxkrnl.lib xonline.lib xkbd.lib xvoice.lib xbdm.lib"
- + AdditionalDependencies="xapilib.lib d3dx8.lib d3d8.lib xgraphics.lib dsound.lib xboxkrnl.lib xonline.lib xkbd.lib xvoice.lib xbdm.lib ws2_32.lib mysqlclient.lib"
- + ShowProgress="0"
- OutputFile="$(OutDir)/$(ProjectName).exe"
- LinkIncremental="1"
- + AdditionalLibraryDirectories=""C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Lib";"C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt""
- IgnoreDefaultLibraryNames="libc"
- - GenerateDebugInformation="TRUE"
- + GenerateDebugInformation="FALSE"
- ProgramDatabaseFile="$(OutDir)/$(ProjectName).pdb"
- SubSystem="2"
- OptimizeReferences="2"
- @@ -263,7 +266,8 @@
- StackSize="0x80000"
- InsertFile=".\media\dsstdfx.bin,dsstdfx,r"
- FormatUD="TRUE"
- - NoPreload="LIBXBMS;LIBSMB;ISO9660;LIBHTTP;LIBMP4;LIBXDAAP;PLATINUM;LCODE"
- + NoLibWarn="FALSE"
- + NoPreload="LIBXBMS;LIBSMB;ISO9660;LIBHTTP;LIBMP4;LIBXDAAP;PLATINUM;LCODE;MYSQLCLIENT"
- TitleID="0xFACE008"
- MediaTypes="0x80000007"
- TitleName="XBMC"
- @@ -4887,6 +4891,15 @@
- RelativePath=".\xbmc\lib\sqLite\dataset.h">
- </File>
- <File
- + RelativePath=".\xbmc\lib\sqLite\DllLibMySQL.h">
- + </File>
- + <File
- + RelativePath=".\xbmc\lib\sqLite\mysqldataset.cpp">
- + </File>
- + <File
- + RelativePath=".\xbmc\lib\sqLite\mysqldataset.h">
- + </File>
- + <File
- RelativePath=".\xbmc\lib\sqLite\qry_dat.cpp">
- </File>
- <File
- @@ -4912,6 +4925,10 @@
- RelativePath=".\xbmc\lib\SlingboxLib\SlingboxLib.h">
- </File>
- </Filter>
- + <Filter
- + Name="libmysqlclient"
- + Filter="">
- + </Filter>
- </Filter>
- </Files>
- <Globals>
- Index: xbmc/AdvancedSettings.cpp
- ===================================================================
- --- xbmc/AdvancedSettings.cpp (revision 30970)
- +++ xbmc/AdvancedSettings.cpp (working copy)
- @@ -691,6 +691,29 @@
- XMLUtils::GetInt(pRootElement, "bginfoloadermaxthreads", m_bgInfoLoaderMaxThreads);
- m_bgInfoLoaderMaxThreads = std::max(1, m_bgInfoLoaderMaxThreads);
- +
- + TiXmlElement* pDatabase = pRootElement->FirstChildElement("videodatabase");
- + if (pDatabase)
- + {
- + CLog::Log(LOGWARNING, "VIDEO database configuration is experimental.");
- + XMLUtils::GetString(pDatabase, "type", m_databaseVideo.type);
- + XMLUtils::GetString(pDatabase, "host", m_databaseVideo.host);
- + XMLUtils::GetString(pDatabase, "port", m_databaseVideo.port);
- + XMLUtils::GetString(pDatabase, "user", m_databaseVideo.user);
- + XMLUtils::GetString(pDatabase, "pass", m_databaseVideo.pass);
- + XMLUtils::GetString(pDatabase, "name", m_databaseVideo.name);
- + }
- +
- + pDatabase = pRootElement->FirstChildElement("musicdatabase");
- + if (pDatabase)
- + {
- + XMLUtils::GetString(pDatabase, "type", m_databaseMusic.type);
- + XMLUtils::GetString(pDatabase, "host", m_databaseMusic.host);
- + XMLUtils::GetString(pDatabase, "port", m_databaseMusic.port);
- + XMLUtils::GetString(pDatabase, "user", m_databaseMusic.user);
- + XMLUtils::GetString(pDatabase, "pass", m_databaseMusic.pass);
- + XMLUtils::GetString(pDatabase, "name", m_databaseMusic.name);
- + }
- // load in the GUISettings overrides:
- g_guiSettings.LoadXML(pRootElement, true); // true to hide the settings we read in
- Index: xbmc/AdvancedSettings.h
- ===================================================================
- --- xbmc/AdvancedSettings.h (revision 30970)
- +++ xbmc/AdvancedSettings.h (working copy)
- @@ -25,7 +25,21 @@
- #include "tinyXML/tinyxml.h"
- #include "StdString.h"
- #include "StringUtils.h"
- +// #include "Database.h"
- +#ifndef DBSettingsDefined
- +#define DBSettingsDefined
- +typedef struct _DatabaseSettings
- +{
- + CStdString type;
- + CStdString host;
- + CStdString port;
- + CStdString user;
- + CStdString pass;
- + CStdString name;
- +} DatabaseSettings;
- +#endif
- +
- struct TVShowRegexp
- {
- bool byDate;
- @@ -219,7 +233,8 @@
- bool m_bPythonVerbose;
- int m_bgInfoLoaderMaxThreads;
- + DatabaseSettings m_databaseMusic; // advanced music database setup
- + DatabaseSettings m_databaseVideo; // advanced video database setup
- };
- -extern CAdvancedSettings g_advancedSettings;
- -
- +extern CAdvancedSettings g_advancedSettings;
- \ No newline at end of file
- Index: xbmc/Database.cpp
- ===================================================================
- --- xbmc/Database.cpp (revision 30970)
- +++ xbmc/Database.cpp (working copy)
- @@ -23,6 +23,7 @@
- #include "Database.h"
- #include "Util.h"
- #include "Settings.h"
- +#include "AdvancedSettings.h"
- #include "Crc32.h"
- #include "FileSystem/SpecialProtocol.h"
- @@ -83,24 +84,81 @@
- bool CDatabase::Open()
- {
- + DatabaseSettings db_fallback;
- + return Open(db_fallback);
- +}
- +
- +bool CDatabase::Open(DatabaseSettings db)
- +{
- if (IsOpen())
- {
- m_iRefCount++;
- return true;
- }
- - CStdString strDatabase;
- - CUtil::AddFileToFolder(g_settings.GetDatabaseFolder(), m_strDatabaseFile, strDatabase);
- + m_dbSettings = db;
- - m_pDB.reset(new SqliteDatabase() ) ;
- - m_pDB->setDatabase(_P(strDatabase).c_str());
- + bool bFallback = true;
- + if ( m_dbSettings.type.Equals("mysql") )
- + {
- + // check we have all information before we cancel the fallback
- + if ( ! (m_dbSettings.host.IsEmpty() || m_dbSettings.user.IsEmpty() || m_dbSettings.pass.IsEmpty()) )
- + bFallback = false;
- + else
- + CLog::Log(LOGINFO, "essential mysql database information is missing (eg. host, user, pass)");
- + }
- + // set default database name if appropriate
- + if ( m_dbSettings.name.IsEmpty() )
- + m_dbSettings.name = m_strDefaultDatabaseName;
- +
- + // always safely fallback to sqlite3
- + if (bFallback)
- + {
- + m_dbSettings.type = "sqlite3";
- + m_dbSettings.host = _P(g_settings.GetDatabaseFolder());
- + }
- +
- + // create the appropriate database structure
- + if (m_dbSettings.type.Equals("sqlite3"))
- + {
- + m_pDB.reset( new SqliteDatabase() ) ;
- + }
- + else if (m_dbSettings.type.Equals("mysql"))
- + {
- + m_pDB.reset( new MysqlDatabase() ) ;
- + }
- + else
- + {
- + CLog::Log(LOGERROR, "Unable to determine database type: %s", m_dbSettings.type.c_str());
- + return false;
- + }
- +
- + // host name is always required
- + m_pDB->setHostName(m_dbSettings.host.c_str());
- +
- + if (!m_dbSettings.port.IsEmpty())
- + m_pDB->setPort(m_dbSettings.port.c_str());
- +
- + if (!m_dbSettings.user.IsEmpty())
- + m_pDB->setLogin(m_dbSettings.user.c_str());
- +
- + if (!m_dbSettings.pass.IsEmpty())
- + m_pDB->setPasswd(m_dbSettings.pass.c_str());
- +
- + // database name is always required
- + m_pDB->setDatabase(m_dbSettings.name.c_str());
- +
- + // create the datasets
- m_pDS.reset(m_pDB->CreateDataset());
- m_pDS2.reset(m_pDB->CreateDataset());
- + CLog::Log(LOGDEBUG, "CDatabase: Connecting to database %s at %s:%s",
- + m_dbSettings.name.c_str(), m_dbSettings.host.c_str(), m_dbSettings.port.c_str());
- +
- if (m_pDB->connect() != DB_CONNECTION_OK)
- {
- - CLog::Log(LOGERROR, "Unable to open %s (old version?)", strDatabase.c_str());
- + CLog::Log(LOGERROR, "Unable to open database at host: %s db: %s (old version?)", m_dbSettings.host.c_str(), m_dbSettings.name.c_str());
- return false;
- }
- @@ -117,33 +175,68 @@
- int version = 0;
- m_pDS->query("SELECT idVersion FROM version\n");
- if (m_pDS->num_rows() > 0)
- + {
- + float fVersion = m_pDS->fv("idVersion").get_asFloat();
- + if (fVersion < 2)
- + { // old version - drop db completely
- + CLog::Log(LOGERROR, "Unable to open %s (old version?)", m_dbSettings.name.c_str());
- + Close();
- + m_pDB->drop();
- + return false;
- + }
- + else if (fVersion < 3)
- + {
- + // has to be old version - drop the version table
- + m_pDS->close();
- + CLog::Log(LOGINFO, "dropping version table");
- + m_pDS->exec("drop table version");
- + CLog::Log(LOGINFO, "creating version table");
- + version = 3;
- + m_pDS->exec("CREATE TABLE version (idVersion integer)\n");
- + CStdString strSQL=FormatSQL("INSERT INTO version (idVersion) values(%i)\n", version);
- + m_pDS->exec(strSQL.c_str());
- + }
- + else
- version = m_pDS->fv("idVersion").get_asInt();
- -
- - if (version < GetMinVersion())
- + }
- + CDatabase::UpdateOldVersion(version); // always call this
- + if (version < m_version)
- {
- - CLog::Log(LOGNOTICE, "Attempting to update the database %s from version %i to %i", m_strDatabaseFile.c_str(), version, GetMinVersion());
- + CLog::Log(LOGNOTICE, "Attempting to update the database %s from version %i to %i", m_dbSettings.name.c_str(), version, m_version);
- if (UpdateOldVersion(version) && UpdateVersionNumber())
- - CLog::Log(LOGINFO, "Update to version %i successfull", GetMinVersion());
- + CLog::Log(LOGINFO, "Update to version %i successfull", m_version);
- else
- {
- - CLog::Log(LOGERROR, "Can't update the database %s from version %i to %i", m_strDatabaseFile.c_str(), version, GetMinVersion());
- + CLog::Log(LOGERROR, "Can't update the database %s from version %i to %i", m_dbSettings.name.c_str(), version, m_version);
- Close();
- return false;
- }
- }
- - else if (version > GetMinVersion())
- + else if (version > m_version)
- {
- - CLog::Log(LOGERROR, "Can't open the database %s as it is a NEWER version than what we were expecting!", m_strDatabaseFile.c_str());
- + CLog::Log(LOGERROR, "Can't open the database %s as it is a NEWER version than what we were expecting!", m_dbSettings.name.c_str());
- Close();
- return false;
- }
- - m_pDS->exec("PRAGMA cache_size=16384\n");
- - m_pDS->exec("PRAGMA synchronous='NORMAL'\n");
- - m_pDS->exec("PRAGMA journal_mode='TRUNCATE'\n");
- -// m_pDS->exec("PRAGMA journal_mode='OFF'\n");
- - m_pDS->exec("PRAGMA count_changes='OFF'\n");
- + // sqlite3 post connection operations
- + if (m_dbSettings.type.Equals("sqlite3"))
- + {
- + // Modern file systems have a cluster/block size of 4k.
- + // To gain better performance when performing write
- + // operations to the database, set the page size of the
- + // database file to 4k.
- + // This needs to be done before any table is created.
- + m_pDS->exec("PRAGMA page_size=4096\n");
- + // Also set the memory cache size to 16k
- + m_pDS->exec("PRAGMA default_cache_size=4096\n");
- +
- + m_pDS->exec("PRAGMA cache_size=4096\n");
- + m_pDS->exec("PRAGMA synchronous='NORMAL'\n");
- + m_pDS->exec("PRAGMA count_changes='OFF'\n");
- + }
- +
- m_iRefCount++;
- return true;
- }
- @@ -177,7 +270,10 @@
- bool CDatabase::Compress(bool bForce /* =true */)
- {
- - // compress database
- + // can only compress sqlite3 databases
- + if (!m_dbSettings.type.Equals("sqlite3"))
- + return false;
- +
- try
- {
- if (NULL == m_pDB.get()) return false;
- @@ -203,7 +299,7 @@
- }
- catch (...)
- {
- - CLog::Log(LOGERROR, "Compressing the database %s failed", m_strDatabaseFile.c_str());
- + CLog::Log(LOGERROR, "Compressing the database %s failed", m_dbSettings.name.c_str());
- return false;
- }
- return true;
- @@ -263,16 +359,6 @@
- bool CDatabase::CreateTables()
- {
- - // all fatx formatted partitions, except the utility drive,
- - // have a cluster size of 16k. To gain better performance
- - // when performing write operations to the database, set
- - // the page size of the database file to 16k.
- - // This needs to be done before any table is created.
- - CLog::Log(LOGINFO, "Set page size");
- - m_pDS->exec("PRAGMA page_size=16384\n");
- - // Also set the memory cache size to 16k
- - CLog::Log(LOGINFO, "Set default cache size");
- - m_pDS->exec("PRAGMA default_cache_size=16384\n");
- CLog::Log(LOGINFO, "creating version table");
- m_pDS->exec("CREATE TABLE version (idVersion integer, iCompressCount integer)\n");
- Index: xbmc/Database.h
- ===================================================================
- --- xbmc/Database.h (revision 30970)
- +++ xbmc/Database.h (working copy)
- @@ -21,19 +21,36 @@
- *
- */
- +#include "lib/sqLite/mysqldataset.h"
- #include "lib/sqLite/sqlitedataset.h"
- +#include <memory>
- +
- +#ifndef DBSettingsDefined
- +#define DBSettingsDefined
- +typedef struct _DatabaseSettings
- +{
- + CStdString type;
- + CStdString host;
- + CStdString port;
- + CStdString user;
- + CStdString pass;
- + CStdString name;
- +} DatabaseSettings;
- +#endif
- +
- class CDatabase
- {
- public:
- CDatabase(void);
- virtual ~CDatabase(void);
- - bool Open();
- bool IsOpen();
- void Close();
- bool Compress(bool bForce=true);
- void Interupt();
- + bool Open(DatabaseSettings db);
- +
- void BeginTransaction();
- virtual bool CommitTransaction();
- void RollbackTransaction();
- @@ -43,14 +60,18 @@
- protected:
- void Split(const CStdString& strFileNameAndPath, CStdString& strPath, CStdString& strFileName);
- DWORD ComputeCRC(const CStdString &text);
- -
- + virtual bool Open();
- virtual bool CreateTables();
- virtual bool UpdateOldVersion(int version) { return true; };
- virtual int GetMinVersion() const=0;
- bool m_bOpen;
- - CStdString m_strDatabaseFile;
- + int m_version;
- +
- + DatabaseSettings m_dbSettings;
- + CStdString m_strDefaultDatabaseName;
- +
- std::auto_ptr<dbiplus::Database> m_pDB;
- std::auto_ptr<dbiplus::Dataset> m_pDS;
- std::auto_ptr<dbiplus::Dataset> m_pDS2;
- Index: xbmc/lib/sqLite/dataset.cpp
- ===================================================================
- --- xbmc/lib/sqLite/dataset.cpp (revision 30970)
- +++ xbmc/lib/sqLite/dataset.cpp (working copy)
- @@ -63,9 +63,9 @@
- return connect();
- }
- +// int Database::connect() { }
- -
- //************* Dataset implementation ***************
- Dataset::Dataset() {
- Index: xbmc/lib/sqLite/DllLibMySQL.h
- ===================================================================
- --- xbmc/lib/sqLite/DllLibMySQL.h (revision 0)
- +++ xbmc/lib/sqLite/DllLibMySQL.h (working copy)
- @@ -0,0 +1,1419 @@
- +#pragma once
- +
- +/*
- + * Copyright (C) 2011 Robert Johnston
- + *
- + * This Program is free software; you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation; either version 2, or (at your option)
- + * any later version.
- + *
- + * This Program is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + * GNU General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with XBMC; see the file COPYING. If not, write to
- + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- + * http://www.gnu.org/copyleft/gpl.html
- + *
- + *
- + * Some Portions Copyright (C) 2000-2003 MySQL AB, also licensed under
- + * the GPL
- + *
- + * This file contains all the headers and function declarations
- + * necessary to dynamically load libmysql.dll with XBMC's DLL loader.
- + */
- +
- +
- +
- +#include "DynamicDll.h"
- +
- +#ifndef _XBOX
- + #ifdef LoadImage
- + #undef LoadImage
- + #endif
- +#endif
- +
- +/* status return codes */
- +#define MYSQL_NO_DATA 100
- +#define MYSQL_DATA_TRUNCATED 101
- +#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
- +#define HAVE_MYSQL_REAL_CONNECT
- +#define MYSQL_COUNT_ERROR (~(my_ulonglong) 0)
- +#define ALLOC_MAX_BLOCK_TO_DROP 4096
- +#define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10
- +#define ER_WARN_DATA_TRUNCATED WARN_DATA_TRUNCATED
- +#define mysql_library_init mysql_server_init
- +#define mysql_library_end mysql_server_end
- +#define LOCAL_INFILE_ERROR_LEN 512
- +//#define max_allowed_packet (*mysql_get_parameters()->p_max_allowed_packet)
- +//#define net_buffer_length (*mysql_get_parameters()->p_net_buffer_length)
- +#define PROTOCOL_VERSION 10
- +#define MYSQL_SERVER_VERSION "6.0.0"
- +#define MYSQL_VERSION_ID 60000
- +#define MYSQL_PORT 3306
- +#define MYSQL_PORT_DEFAULT 0
- +#define MYSQL_UNIX_ADDR "/tmp/mysql.sock"
- +#define MYSQL_CONFIG_NAME "my"
- +#define MYSQL_COMPILATION_COMMENT "Source distribution"
- +#define LICENSE GPL
- +#define list_rest(a) ((a)->next)
- +#define list_push(a,b) (a)=list_cons((b),(a))
- +#define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old) ; my_free((unsigned char *) old,MYF(MY_FAE)); }
- +
- +#define HOSTNAME_LENGTH 60
- +#define SYSTEM_CHARSET_MBMAXLEN 4
- +#define NAME_CHAR_LEN 64 /* Field/table name length */
- +#define USERNAME_CHAR_LENGTH 16
- +#define NAME_LEN (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN)
- +#define USERNAME_LENGTH (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN)
- +
- +#define SERVER_VERSION_LENGTH 60
- +#define SQLSTATE_LENGTH 5
- +
- +/*
- + Maximum length of comments
- +*/
- +#define TABLE_COMMENT_INLINE_MAXLEN 180 /* pre 6.0: 60 (3-byte) characters */
- +#define TABLE_COMMENT_MAXLEN 2048
- +#define COLUMN_COMMENT_MAXLEN 1024
- +#define INDEX_COMMENT_MAXLEN 1024
- +
- +
- +/*
- + USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
- + username and hostname parts of the user identifier with trailing zero in
- + MySQL standard format:
- + user_name_part@host_name_part\0
- +*/
- +#define USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2
- +
- +#define LOCAL_HOST "localhost"
- +#define LOCAL_HOST_NAMEDPIPE "."
- +
- +
- +#if defined(__WIN__) && !defined( _CUSTOMCONFIG_)
- +#define MYSQL_NAMEDPIPE "MySQL"
- +#define MYSQL_SERVICENAME "MySQL"
- +#endif /* __WIN__ */
- +
- +#ifdef _global_h
- +ulong STDCALL net_field_length(uchar **packet);
- +my_ulonglong net_field_length_ll(uchar **packet);
- +uchar *net_store_length(uchar *pkg, ulonglong length);
- +#endif
- +
- +#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
- +#define MYSQL_STMT_HEADER 4
- +#define MYSQL_LONG_DATA_HEADER 6
- +
- +#define NOT_FIXED_DEC 31
- +
- +
- +#ifndef _global_h /* If not standard header */
- +#include <sys/types.h>
- +typedef char my_bool;
- +#if (defined(_WIN32) || defined(_WIN64)) && !defined(__WIN__)
- +#define __WIN__
- +#endif
- +
- +#ifndef my_socket_defined
- +#ifdef __WIN__
- +#define my_socket SOCKET
- +#else
- +typedef int my_socket;
- +#endif /* __WIN__ */
- +#endif /* my_socket_defined */
- +#endif /* _global_h */
- +
- +
- +/*
- + You should add new commands to the end of this list, otherwise old
- + servers won't be able to handle them as 'unsupported'.
- +*/
- +
- +enum enum_server_command
- +{
- + COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST,
- + COM_CREATE_DB, COM_DROP_DB, COM_REFRESH, COM_SHUTDOWN, COM_STATISTICS,
- + COM_PROCESS_INFO, COM_CONNECT, COM_PROCESS_KILL, COM_DEBUG, COM_PING,
- + COM_TIME, COM_DELAYED_INSERT, COM_CHANGE_USER, COM_BINLOG_DUMP,
- + COM_TABLE_DUMP, COM_CONNECT_OUT, COM_REGISTER_SLAVE,
- + COM_STMT_PREPARE, COM_STMT_EXECUTE, COM_STMT_SEND_LONG_DATA, COM_STMT_CLOSE,
- + COM_STMT_RESET, COM_SET_OPTION, COM_STMT_FETCH, COM_DAEMON,
- + /* don't forget to update const char *command_name[] in sql_parse.cc */
- +
- + /* Must be last */
- + COM_END
- +};
- +
- +
- +/*
- + Length of random string sent by server on handshake; this is also length of
- + obfuscated password, recieved from client
- +*/
- +#define SCRAMBLE_LENGTH 20
- +#define SCRAMBLE_LENGTH_323 8
- +/* length of password stored in the db: new passwords are preceeded with '*' */
- +#define SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH*2+1)
- +#define SCRAMBLED_PASSWORD_CHAR_LENGTH_323 (SCRAMBLE_LENGTH_323*2)
- +
- +
- +#define NOT_NULL_FLAG 1 /* Field can't be NULL */
- +#define PRI_KEY_FLAG 2 /* Field is part of a primary key */
- +#define UNIQUE_KEY_FLAG 4 /* Field is part of a unique key */
- +#define MULTIPLE_KEY_FLAG 8 /* Field is part of a key */
- +#define BLOB_FLAG 16 /* Field is a blob */
- +#define UNSIGNED_FLAG 32 /* Field is unsigned */
- +#define ZEROFILL_FLAG 64 /* Field is zerofill */
- +#define BINARY_FLAG 128 /* Field is binary */
- +
- +/* The following are only sent to new clients */
- +#define ENUM_FLAG 256 /* field is an enum */
- +#define AUTO_INCREMENT_FLAG 512 /* field is a autoincrement field */
- +#define TIMESTAMP_FLAG 1024 /* Field is a timestamp */
- +#define SET_FLAG 2048 /* field is a set */
- +#define NO_DEFAULT_VALUE_FLAG 4096 /* Field doesn't have default value */
- +#define ON_UPDATE_NOW_FLAG 8192 /* Field is set to NOW on UPDATE */
- +#define NUM_FLAG 32768 /* Field is num (for clients) */
- +#define PART_KEY_FLAG 16384 /* Intern; Part of some key */
- +#define GROUP_FLAG 32768 /* Intern: Group field */
- +#define UNIQUE_FLAG 65536 /* Intern: Used by sql_yacc */
- +#define BINCMP_FLAG 131072 /* Intern: Used by sql_yacc */
- +#define GET_FIXED_FIELDS_FLAG (1 << 18) /* Used to get fields in item tree */
- +#define FIELD_IN_PART_FUNC_FLAG (1 << 19)/* Field part of partition func */
- +#define FIELD_IN_ADD_INDEX (1<< 20) /* Intern: Field used in ADD INDEX */
- +#define FIELD_IS_RENAMED (1<< 21) /* Intern: Field is being renamed */
- +#define FIELD_STORAGE_FLAGS 22 /* Storage type: bit 22, 23 and 24 */
- +#define COLUMN_FORMAT_FLAGS 25 /* Column format: bit 25, 26 and 27 */
- +
- +#define REFRESH_GRANT 1 /* Refresh grant tables */
- +#define REFRESH_LOG 2 /* Start on new log file */
- +#define REFRESH_TABLES 4 /* close all tables */
- +#define REFRESH_HOSTS 8 /* Flush host cache */
- +#define REFRESH_STATUS 16 /* Flush status variables */
- +#define REFRESH_THREADS 32 /* Flush thread cache */
- +#define REFRESH_SLAVE 64 /* Reset master info and restart slave
- + thread */
- +#define REFRESH_MASTER 128 /* Remove all bin logs in the index
- + and truncate the index */
- +
- +/* The following can't be set with mysql_refresh() */
- +#define REFRESH_READ_LOCK 16384 /* Lock tables for read */
- +#define REFRESH_FAST 32768 /* Intern flag */
- +
- +/* RESET (remove all queries) from query cache */
- +#define REFRESH_QUERY_CACHE 65536
- +#define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */
- +#define REFRESH_DES_KEY_FILE 0x40000L
- +#define REFRESH_USER_RESOURCES 0x80000L
- +#define REFRESH_BACKUP_LOG 0x200000L
- +
- +#define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
- +#define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
- +#define CLIENT_LONG_FLAG 4 /* Get all column flags */
- +#define CLIENT_CONNECT_WITH_DB 8 /* One can specify db on connect */
- +#define CLIENT_NO_SCHEMA 16 /* Don't allow database.table.column */
- +#define CLIENT_COMPRESS 32 /* Can use compression protocol */
- +#define CLIENT_ODBC 64 /* Odbc client */
- +#define CLIENT_LOCAL_FILES 128 /* Can use LOAD DATA LOCAL */
- +#define CLIENT_IGNORE_SPACE 256 /* Ignore spaces before '(' */
- +#define CLIENT_PROTOCOL_41 512 /* New 4.1 protocol */
- +#define CLIENT_INTERACTIVE 1024 /* This is an interactive client */
- +#define CLIENT_SSL 2048 /* Switch to SSL after handshake */
- +#define CLIENT_IGNORE_SIGPIPE 4096 /* IGNORE sigpipes */
- +#define CLIENT_TRANSACTIONS 8192 /* Client knows about transactions */
- +#define CLIENT_RESERVED 16384 /* Old flag for 4.1 protocol */
- +#define CLIENT_SECURE_CONNECTION 32768 /* New 4.1 authentication */
- +#define CLIENT_MULTI_STATEMENTS (1UL << 16) /* Enable/disable multi-stmt support */
- +#define CLIENT_MULTI_RESULTS (1UL << 17) /* Enable/disable multi-results */
- +#define CLIENT_PS_MULTI_RESULTS (1UL << 18) /* Multi-results in PS-protocol */
- +
- +#define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30)
- +#define CLIENT_REMEMBER_OPTIONS (1UL << 31)
- +
- +/* Gather all possible capabilites (flags) supported by the server */
- +#define CLIENT_ALL_FLAGS (CLIENT_LONG_PASSWORD | \
- + CLIENT_FOUND_ROWS | \
- + CLIENT_LONG_FLAG | \
- + CLIENT_CONNECT_WITH_DB | \
- + CLIENT_NO_SCHEMA | \
- + CLIENT_COMPRESS | \
- + CLIENT_ODBC | \
- + CLIENT_LOCAL_FILES | \
- + CLIENT_IGNORE_SPACE | \
- + CLIENT_PROTOCOL_41 | \
- + CLIENT_INTERACTIVE | \
- + CLIENT_SSL | \
- + CLIENT_IGNORE_SIGPIPE | \
- + CLIENT_TRANSACTIONS | \
- + CLIENT_RESERVED | \
- + CLIENT_SECURE_CONNECTION | \
- + CLIENT_MULTI_STATEMENTS | \
- + CLIENT_MULTI_RESULTS | \
- + CLIENT_PS_MULTI_RESULTS | \
- + CLIENT_SSL_VERIFY_SERVER_CERT | \
- + CLIENT_REMEMBER_OPTIONS)
- +
- +/*
- + Switch off the flags that are optional and depending on build flags
- + If any of the optional flags is supported by the build it will be switched
- + on before sending to the client during the connection handshake.
- +*/
- +#define CLIENT_BASIC_FLAGS (((CLIENT_ALL_FLAGS & ~CLIENT_SSL) \
- + & ~CLIENT_COMPRESS) \
- + & ~CLIENT_SSL_VERIFY_SERVER_CERT)
- +
- +#define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */
- +#define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */
- +#define SERVER_MORE_RESULTS_EXISTS 8 /* Multi query - next query exists */
- +#define SERVER_QUERY_NO_GOOD_INDEX_USED 16
- +#define SERVER_QUERY_NO_INDEX_USED 32
- +/**
- + The server was able to fulfill the clients request and opened a
- + read-only non-scrollable cursor for a query. This flag comes
- + in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands.
- +*/
- +#define SERVER_STATUS_CURSOR_EXISTS 64
- +/**
- + This flag is sent when a read-only cursor is exhausted, in reply to
- + COM_STMT_FETCH command.
- +*/
- +#define SERVER_STATUS_LAST_ROW_SENT 128
- +#define SERVER_STATUS_DB_DROPPED 256 /* A database was dropped */
- +#define SERVER_STATUS_NO_BACKSLASH_ESCAPES 512
- +/**
- + Sent to the client if after a prepared statement reprepare
- + we discovered that the new statement returns a different
- + number of result set columns.
- +*/
- +#define SERVER_STATUS_METADATA_CHANGED 1024
- +/*
- + Tell clients that this query was logged to the slow query log.
- + Not yet set in the server, but interface is defined for applications
- + to use. See WorkLog 4098.
- +*/
- +#define SERVER_QUERY_WAS_SLOW 2048
- +
- +/**
- + To mark ResultSet containing output parameter values.
- +*/
- +#define SERVER_PS_OUT_PARAMS 4096
- +
- +/**
- + Server status flags that must be cleared when starting
- + execution of a new SQL statement.
- + Flags from this set are only added to the
- + current server status by the execution engine, but
- + never removed -- the execution engine expects them
- + to disappear automagically by the next command.
- +*/
- +#define SERVER_STATUS_CLEAR_SET (SERVER_QUERY_NO_GOOD_INDEX_USED| \
- + SERVER_QUERY_NO_INDEX_USED|\
- + SERVER_MORE_RESULTS_EXISTS|\
- + SERVER_STATUS_METADATA_CHANGED)
- +
- +#define MYSQL_ERRMSG_SIZE 512
- +#define NET_READ_TIMEOUT 30 /* Timeout on read */
- +#define NET_WRITE_TIMEOUT 60 /* Timeout on write */
- +#define NET_WAIT_TIMEOUT 8*60*60 /* Wait for new query */
- +
- +#define ONLY_KILL_QUERY 1
- +
- +
- +struct st_vio; /* Only C */
- +typedef struct st_vio Vio;
- +
- +#define MAX_TINYINT_WIDTH 3 /* Max width for a TINY w.o. sign */
- +#define MAX_SMALLINT_WIDTH 5 /* Max width for a SHORT w.o. sign */
- +#define MAX_MEDIUMINT_WIDTH 8 /* Max width for a INT24 w.o. sign */
- +#define MAX_INT_WIDTH 10 /* Max width for a LONG w.o. sign */
- +#define MAX_BIGINT_WIDTH 20 /* Max width for a LONGLONG */
- +#define MAX_CHAR_WIDTH 255 /* Max length for a CHAR colum */
- +#define MAX_BLOB_WIDTH 16777216 /* Default width for blob */
- +
- +
- +typedef struct st_used_mem
- +{ /* struct for once_alloc (block) */
- + struct st_used_mem *next; /* Next block in use */
- + size_t left; /* memory left in block */
- + size_t size; /* size of block */
- +} USED_MEM;
- +
- +typedef struct st_mem_root
- +{
- + USED_MEM *free; /* blocks with free memory in it */
- + USED_MEM *used; /* blocks almost without free memory */
- + USED_MEM *pre_alloc; /* preallocated block */
- + /* if block have less memory it will be put in 'used' list */
- + size_t min_malloc;
- + size_t block_size; /* initial block size */
- + unsigned int block_num; /* allocated blocks counter */
- + /*
- + first free block in queue test counter (if it exceed
- + MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list)
- + */
- + unsigned int first_block_usage;
- +
- + void (*error_handler)(void);
- +} MEM_ROOT;
- +
- +typedef struct st_net {
- +#if !defined(CHECK_EMBEDDED_DIFFERENCES) || !defined(EMBEDDED_LIBRARY)
- + Vio *vio;
- + unsigned char *buff,*buff_end,*write_pos,*read_pos;
- + my_socket fd; /* For Perl DBI/dbd */
- + /*
- + The following variable is set if we are doing several queries in one
- + command ( as in LOAD TABLE ... FROM MASTER ),
- + and do not want to confuse the client with OK at the wrong time
- + */
- + unsigned long remain_in_buf,length, buf_length, where_b;
- + unsigned long max_packet,max_packet_size;
- + unsigned int pkt_nr,compress_pkt_nr;
- + unsigned int write_timeout, read_timeout, retry_count;
- + int fcntl;
- + unsigned int *return_status;
- + unsigned char reading_or_writing;
- + char save_char;
- + my_bool unused1; /* Please remove with the next incompatible ABI change. */
- + my_bool unused2; /* Please remove with the next incompatible ABI change */
- + my_bool compress;
- + my_bool unused3; /* Please remove with the next incompatible ABI change. */
- + /*
- + Pointer to query object in query cache, do not equal NULL (0) for
- + queries in cache that have not stored its results yet
- + */
- +#endif
- + /*
- + Unused, please remove with the next incompatible ABI change.
- + */
- + unsigned char *unused;
- + unsigned int last_errno;
- + unsigned char error;
- + my_bool unused4; /* Please remove with the next incompatible ABI change. */
- + my_bool unused5; /* Please remove with the next incompatible ABI change. */
- + /** Client library error message buffer. Actually belongs to struct MYSQL. */
- + char last_error[MYSQL_ERRMSG_SIZE];
- + /** Client library sqlstate buffer. Set along with the error message. */
- + char sqlstate[SQLSTATE_LENGTH+1];
- + void *extension;
- +} NET;
- +
- +
- +#define packet_error (~(unsigned long) 0)
- +
- +enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
- + MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG,
- + MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE,
- + MYSQL_TYPE_NULL, MYSQL_TYPE_TIMESTAMP,
- + MYSQL_TYPE_LONGLONG,MYSQL_TYPE_INT24,
- + MYSQL_TYPE_DATE, MYSQL_TYPE_TIME,
- + MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR,
- + MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
- + MYSQL_TYPE_BIT,
- + MYSQL_TYPE_NEWDECIMAL=246,
- + MYSQL_TYPE_ENUM=247,
- + MYSQL_TYPE_SET=248,
- + MYSQL_TYPE_TINY_BLOB=249,
- + MYSQL_TYPE_MEDIUM_BLOB=250,
- + MYSQL_TYPE_LONG_BLOB=251,
- + MYSQL_TYPE_BLOB=252,
- + MYSQL_TYPE_VAR_STRING=253,
- + MYSQL_TYPE_STRING=254,
- + MYSQL_TYPE_GEOMETRY=255,
- + MAX_NO_FIELD_TYPES /* Should always be last */
- +};
- +
- +/* For backward compatibility */
- +#define CLIENT_MULTI_QUERIES CLIENT_MULTI_STATEMENTS
- +#define FIELD_TYPE_DECIMAL MYSQL_TYPE_DECIMAL
- +#define FIELD_TYPE_NEWDECIMAL MYSQL_TYPE_NEWDECIMAL
- +#define FIELD_TYPE_TINY MYSQL_TYPE_TINY
- +#define FIELD_TYPE_SHORT MYSQL_TYPE_SHORT
- +#define FIELD_TYPE_LONG MYSQL_TYPE_LONG
- +#define FIELD_TYPE_FLOAT MYSQL_TYPE_FLOAT
- +#define FIELD_TYPE_DOUBLE MYSQL_TYPE_DOUBLE
- +#define FIELD_TYPE_NULL MYSQL_TYPE_NULL
- +#define FIELD_TYPE_TIMESTAMP MYSQL_TYPE_TIMESTAMP
- +#define FIELD_TYPE_LONGLONG MYSQL_TYPE_LONGLONG
- +#define FIELD_TYPE_INT24 MYSQL_TYPE_INT24
- +#define FIELD_TYPE_DATE MYSQL_TYPE_DATE
- +#define FIELD_TYPE_TIME MYSQL_TYPE_TIME
- +#define FIELD_TYPE_DATETIME MYSQL_TYPE_DATETIME
- +#define FIELD_TYPE_YEAR MYSQL_TYPE_YEAR
- +#define FIELD_TYPE_NEWDATE MYSQL_TYPE_NEWDATE
- +#define FIELD_TYPE_ENUM MYSQL_TYPE_ENUM
- +#define FIELD_TYPE_SET MYSQL_TYPE_SET
- +#define FIELD_TYPE_TINY_BLOB MYSQL_TYPE_TINY_BLOB
- +#define FIELD_TYPE_MEDIUM_BLOB MYSQL_TYPE_MEDIUM_BLOB
- +#define FIELD_TYPE_LONG_BLOB MYSQL_TYPE_LONG_BLOB
- +#define FIELD_TYPE_BLOB MYSQL_TYPE_BLOB
- +#define FIELD_TYPE_VAR_STRING MYSQL_TYPE_VAR_STRING
- +#define FIELD_TYPE_STRING MYSQL_TYPE_STRING
- +#define FIELD_TYPE_CHAR MYSQL_TYPE_TINY
- +#define FIELD_TYPE_INTERVAL MYSQL_TYPE_ENUM
- +#define FIELD_TYPE_GEOMETRY MYSQL_TYPE_GEOMETRY
- +#define FIELD_TYPE_BIT MYSQL_TYPE_BIT
- +
- +
- +/* Shutdown/kill enums and constants */
- +
- +/* Bits for THD::killable. */
- +#define MYSQL_SHUTDOWN_KILLABLE_CONNECT (unsigned char)(1 << 0)
- +#define MYSQL_SHUTDOWN_KILLABLE_TRANS (unsigned char)(1 << 1)
- +#define MYSQL_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2)
- +#define MYSQL_SHUTDOWN_KILLABLE_UPDATE (unsigned char)(1 << 3)
- +
- +enum mysql_enum_shutdown_level {
- + /*
- + We want levels to be in growing order of hardness (because we use number
- + comparisons). Note that DEFAULT does not respect the growing property, but
- + it's ok.
- + */
- + SHUTDOWN_DEFAULT = 0,
- + /* wait for existing connections to finish */
- + SHUTDOWN_WAIT_CONNECTIONS= MYSQL_SHUTDOWN_KILLABLE_CONNECT,
- + /* wait for existing trans to finish */
- + SHUTDOWN_WAIT_TRANSACTIONS= MYSQL_SHUTDOWN_KILLABLE_TRANS,
- + /* wait for existing updates to finish (=> no partial MyISAM update) */
- + SHUTDOWN_WAIT_UPDATES= MYSQL_SHUTDOWN_KILLABLE_UPDATE,
- + /* flush InnoDB buffers and other storage engines' buffers*/
- + SHUTDOWN_WAIT_ALL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1),
- + /* don't flush InnoDB buffers, flush other storage engines' buffers*/
- + SHUTDOWN_WAIT_CRITICAL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1,
- + /* Now the 2 levels of the KILL command */
- +#if MYSQL_VERSION_ID >= 50000
- + KILL_QUERY= 254,
- +#endif
- + KILL_CONNECTION= 255
- +};
- +
- +/*
- + Time declarations shared between the server and client API:
- + you should not add anything to this header unless it's used
- + (and hence should be visible) in mysql.h.
- + If you're looking for a place to add new time-related declaration,
- + it's most likely my_time.h. See also "C API Handling of Date
- + and Time Values" chapter in documentation.
- +*/
- +
- +enum enum_mysql_timestamp_type
- +{
- + MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
- + MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
- +};
- +
- +
- +/*
- + Structure which is used to represent datetime values inside MySQL.
- +
- + We assume that values in this structure are normalized, i.e. year <= 9999,
- + month <= 12, day <= 31, hour <= 23, hour <= 59, hour <= 59. Many functions
- + in server such as my_system_gmt_sec() or make_time() family of functions
- + rely on this (actually now usage of make_*() family relies on a bit weaker
- + restriction). Also functions that produce MYSQL_TIME as result ensure this.
- + There is one exception to this rule though if this structure holds time
- + value (time_type == MYSQL_TIMESTAMP_TIME) days and hour member can hold
- + bigger values.
- +*/
- +typedef struct st_mysql_time
- +{
- + unsigned int year, month, day, hour, minute, second;
- + unsigned long second_part;
- + my_bool neg;
- + enum enum_mysql_timestamp_type time_type;
- +} MYSQL_TIME;
- +
- +
- +enum enum_cursor_type
- +{
- + CURSOR_TYPE_NO_CURSOR= 0,
- + CURSOR_TYPE_READ_ONLY= 1,
- + CURSOR_TYPE_FOR_UPDATE= 2,
- + CURSOR_TYPE_SCROLLABLE= 4
- +};
- +
- +
- +/* options for mysql_set_option */
- +enum enum_mysql_set_option
- +{
- + MYSQL_OPTION_MULTI_STATEMENTS_ON,
- + MYSQL_OPTION_MULTI_STATEMENTS_OFF
- +};
- +
- +#define net_new_transaction(net) ((net)->pkt_nr=0)
- +
- +#ifdef __cplusplus
- +extern "C" {
- +#endif
- +
- +my_bool my_net_init(NET *net, Vio* vio);
- +void my_net_local_init(NET *net);
- +void net_end(NET *net);
- + void net_clear(NET *net, my_bool clear_buffer);
- +my_bool net_realloc(NET *net, size_t length);
- +my_bool net_flush(NET *net);
- +my_bool my_net_write(NET *net,const unsigned char *packet, size_t len);
- +my_bool net_write_command(NET *net,unsigned char command,
- + const unsigned char *header, size_t head_len,
- + const unsigned char *packet, size_t len);
- +int net_real_write(NET *net,const unsigned char *packet, size_t len);
- +unsigned long my_net_read(NET *net);
- +
- +#ifdef _global_h
- +void my_net_set_write_timeout(NET *net, uint timeout);
- +void my_net_set_read_timeout(NET *net, uint timeout);
- +#endif
- +
- +struct sockaddr;
- +int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen,
- + unsigned int timeout);
- +struct my_rnd_struct;
- +
- +#ifdef __cplusplus
- +}
- +#endif
- +
- + /* The following is for user defined functions */
- +
- +enum Item_result
- +{
- + STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT, DECIMAL_RESULT
- +#ifdef MYSQL_SERVER
- + ,IMPOSSIBLE_RESULT /* Yes, we know this is ugly, don't tell us */
- + ,MAX_NO_ITEM_RESULTS = IMPOSSIBLE_RESULT /* Should always be last */
- +#endif
- +};
- +
- +typedef struct st_udf_args
- +{
- + unsigned int arg_count; /* Number of arguments */
- + enum Item_result *arg_type; /* Pointer to item_results */
- + char **args; /* Pointer to argument */
- + unsigned long *lengths; /* Length of string arguments */
- + char *maybe_null; /* Set to 1 for all maybe_null args */
- + char **attributes; /* Pointer to attribute name */
- + unsigned long *attribute_lengths; /* Length of attribute arguments */
- + void *extension;
- +} UDF_ARGS;
- +
- + /* This holds information about the result */
- +
- +typedef struct st_udf_init
- +{
- + my_bool maybe_null; /* 1 if function can return NULL */
- + unsigned int decimals; /* for real functions */
- + unsigned long max_length; /* For string functions */
- + char *ptr; /* free pointer for function data */
- + my_bool const_item; /* 1 if function always returns the same value */
- + void *extension;
- +} UDF_INIT;
- +/*
- + TODO: add a notion for determinism of the UDF.
- + See Item_udf_func::update_used_tables ()
- +*/
- +
- + /* Constants when using compression */
- +#define NET_HEADER_SIZE 4 /* standard header size */
- +#define COMP_HEADER_SIZE 3 /* compression header extra size */
- +
- + /* Prototypes to password functions */
- +
- +/*
- + These functions are used for authentication by client and server and
- + implemented in sql/password.c
- +*/
- +
- +void create_random_string(char *to, unsigned int length,
- + struct my_rnd_struct *rand_st);
- +
- +void hash_password(unsigned long *to, const char *password, unsigned int password_len);
- +void make_scrambled_password_323(char *to, const char *password);
- +void scramble_323(char *to, const char *message, const char *password);
- +my_bool check_scramble_323(const char *, const char *message,
- + unsigned long *salt);
- +void get_salt_from_password_323(unsigned long *res, const char *password);
- +void make_password_from_salt_323(char *to, const unsigned long *salt);
- +
- +void make_scrambled_password(char *to, const char *password);
- +void scramble(char *to, const char *message, const char *password);
- +my_bool check_scramble(const char *reply, const char *message,
- + const unsigned char *hash_stage2);
- +void get_salt_from_password(unsigned char *res, const char *password);
- +void make_password_from_salt(char *to, const unsigned char *hash_stage2);
- +char *octet2hex(char *to, const char *str, unsigned int len);
- +
- +/* end of password.c */
- +
- +char *get_tty_password(const char *opt_message);
- +const char *mysql_errno_to_sqlstate(unsigned int mysql_errno);
- +
- +/* Some other useful functions */
- +
- +my_bool my_thread_init(void);
- +void my_thread_end(void);
- +
- +typedef struct st_list {
- + struct st_list *prev,*next;
- + void *data;
- +} LIST;
- +
- +typedef int (*list_walk_action)(void *,void *);
- +
- +extern LIST *list_add(LIST *root,LIST *element);
- +extern LIST *list_delete(LIST *root,LIST *element);
- +extern LIST *list_cons(void *data,LIST *root);
- +extern LIST *list_reverse(LIST *root);
- +extern void list_free(LIST *root,unsigned int free_data);
- +extern unsigned int list_length(LIST *);
- +extern int list_walk(LIST *,list_walk_action action,unsigned char * argument);
- +
- +typedef struct st_mysql_field {
- + char *name; /* Name of column */
- + char *org_name; /* Original column name, if an alias */
- + char *table; /* Table of column if column was a field */
- + char *org_table; /* Org table name, if table was an alias */
- + char *db; /* Database for table */
- + char *catalog; /* Catalog for table */
- + char *def; /* Default value (set by mysql_list_fields) */
- + unsigned long length; /* Width of column (create length) */
- + unsigned long max_length; /* Max width for selected set */
- + unsigned int name_length;
- + unsigned int org_name_length;
- + unsigned int table_length;
- + unsigned int org_table_length;
- + unsigned int db_length;
- + unsigned int catalog_length;
- + unsigned int def_length;
- + unsigned int flags; /* Div flags */
- + unsigned int decimals; /* Number of decimals in field */
- + unsigned int charsetnr; /* Character set */
- + enum enum_field_types type; /* Type of field. See mysql_com.h for types */
- + void *extension;
- +} MYSQL_FIELD;
- +
- +typedef char **MYSQL_ROW; /* return data as array of strings */
- +typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */
- +
- +#ifndef _global_h
- +#if defined(NO_CLIENT_LONG_LONG)
- +typedef unsigned long my_ulonglong;
- +#elif defined (__WIN__)
- +typedef unsigned __int64 my_ulonglong;
- +#else
- +typedef unsigned long long my_ulonglong;
- +#endif
- +#endif
- +
- +typedef struct st_typelib { /* Different types saved here */
- + unsigned int count; /* How many types */
- + const char *name; /* Name of typelib */
- + const char **type_names;
- + unsigned int *type_lengths;
- +} TYPELIB;
- +
- +extern my_ulonglong find_typeset(char *x, TYPELIB *typelib,int *error_position);
- +extern int find_type_or_exit(const char *x, TYPELIB *typelib,
- + const char *option);
- +extern int find_type(char *x, const TYPELIB *typelib, unsigned int full_name);
- +extern void make_type(char *to,unsigned int nr,TYPELIB *typelib);
- +extern const char *get_type(TYPELIB *typelib,unsigned int nr);
- +extern TYPELIB *copy_typelib(MEM_ROOT *root, TYPELIB *from);
- +
- +extern TYPELIB sql_protocol_typelib;
- +
- +/* backward compatibility define - to be removed eventually */
- +typedef struct st_mysql_rows {
- + struct st_mysql_rows *next; /* list of rows */
- + MYSQL_ROW data;
- + unsigned long length;
- +} MYSQL_ROWS;
- +
- +typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */
- +
- +typedef struct embedded_query_result EMBEDDED_QUERY_RESULT;
- +typedef struct st_mysql_data {
- + MYSQL_ROWS *data;
- + struct embedded_query_result *embedded_info;
- + MEM_ROOT alloc;
- + my_ulonglong rows;
- + unsigned int fields;
- + /* extra info for embedded library */
- + void *extension;
- +} MYSQL_DATA;
- +
- +enum mysql_option
- +{
- + MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, MYSQL_OPT_NAMED_PIPE,
- + MYSQL_INIT_COMMAND, MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP,
- + MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME, MYSQL_OPT_LOCAL_INFILE,
- + MYSQL_OPT_PROTOCOL, MYSQL_SHARED_MEMORY_BASE_NAME, MYSQL_OPT_READ_TIMEOUT,
- + MYSQL_OPT_WRITE_TIMEOUT, MYSQL_OPT_USE_RESULT,
- + MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION,
- + MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH,
- + MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT,
- + MYSQL_OPT_SSL_VERIFY_SERVER_CERT
- +};
- +
- +struct st_mysql_options {
- + unsigned int connect_timeout, read_timeout, write_timeout;
- + unsigned int port, protocol;
- + unsigned long client_flag;
- + char *host,*user,*password,*unix_socket,*db;
- + struct st_dynamic_array *init_commands;
- + char *my_cnf_file,*my_cnf_group, *charset_dir, *charset_name;
- + char *ssl_key; /* PEM key file */
- + char *ssl_cert; /* PEM cert file */
- + char *ssl_ca; /* PEM CA file */
- + char *ssl_capath; /* PEM directory of CA-s? */
- + char *ssl_cipher; /* cipher to use */
- + char *shared_memory_base_name;
- + unsigned long max_allowed_packet;
- + my_bool use_ssl; /* if to use SSL or not */
- + my_bool compress,named_pipe;
- + my_bool unused1;
- + my_bool unused2;
- + my_bool unused3;
- + my_bool unused4;
- + enum mysql_option methods_to_use;
- + char *client_ip;
- + /* Refuse client connecting to server if it uses old (pre-4.1.1) protocol */
- + my_bool secure_auth;
- + /* 0 - never report, 1 - always report (default) */
- + my_bool report_data_truncation;
- +
- + /* function pointers for local infile support */
- + int (*local_infile_init)(void **, const char *, void *);
- + int (*local_infile_read)(void *, char *, unsigned int);
- + void (*local_infile_end)(void *);
- + int (*local_infile_error)(void *, char *, unsigned int);
- + void *local_infile_userdata;
- + void *extension;
- +};
- +
- +enum mysql_status
- +{
- + MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,MYSQL_STATUS_USE_RESULT
- +};
- +
- +enum mysql_protocol_type
- +{
- + MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET,
- + MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY
- +};
- +
- +typedef struct character_set
- +{
- + unsigned int number; /* character set number */
- + unsigned int state; /* character set state */
- + const char *csname; /* collation name */
- + const char *name; /* character set name */
- + const char *comment; /* comment */
- + const char *dir; /* character set directory */
- + unsigned int mbminlen; /* min. length for multibyte strings */
- + unsigned int mbmaxlen; /* max. length for multibyte strings */
- +} MY_CHARSET_INFO;
- +
- +struct st_mysql_methods;
- +struct st_mysql_stmt;
- +
- +typedef struct st_mysql
- +{
- + NET net; /* Communication parameters */
- + unsigned char *connector_fd; /* ConnectorFd for SSL */
- + char *host,*user,*passwd,*unix_socket,*server_version,*host_info;
- + char *info, *db;
- + struct charset_info_st *charset;
- + MYSQL_FIELD *fields;
- + MEM_ROOT field_alloc;
- + my_ulonglong affected_rows;
- + my_ulonglong insert_id; /* id if insert on table with NEXTNR */
- + my_ulonglong extra_info; /* Not used */
- + unsigned long thread_id; /* Id for connection in server */
- + unsigned long packet_length;
- + unsigned int port;
- + unsigned long client_flag,server_capabilities;
- + unsigned int protocol_version;
- + unsigned int field_count;
- + unsigned int server_status;
- + unsigned int server_language;
- + unsigned int warning_count;
- + struct st_mysql_options options;
- + enum mysql_status status;
- + my_bool free_me; /* If free in mysql_close */
- + my_bool reconnect; /* set to 1 if automatic reconnect */
- +
- + /* session-wide random string */
- + char scramble[SCRAMBLE_LENGTH+1];
- + my_bool unused1;
- + void *unused2, *unused3, *unused4, *unused5;
- +
- + LIST *stmts; /* list of all statements */
- + const struct st_mysql_methods *methods;
- + void *thd;
- + /*
- + Points to boolean flag in MYSQL_RES or MYSQL_STMT. We set this flag
- + from mysql_stmt_close if close had to cancel result set of this object.
- + */
- + my_bool *unbuffered_fetch_owner;
- + /* needed for embedded server - no net buffer to store the 'info' */
- + char *info_buffer;
- + void *extension;
- +} MYSQL;
- +
- +
- +typedef struct st_mysql_res {
- + my_ulonglong row_count;
- + MYSQL_FIELD *fields;
- + MYSQL_DATA *data;
- + MYSQL_ROWS *data_cursor;
- + unsigned long *lengths; /* column lengths of current row */
- + MYSQL *handle; /* for unbuffered reads */
- + const struct st_mysql_methods *methods;
- + MYSQL_ROW row; /* If unbuffered read */
- + MYSQL_ROW current_row; /* buffer to current row */
- + MEM_ROOT field_alloc;
- + unsigned int field_count, current_field;
- + my_bool eof; /* Used by mysql_fetch_row */
- + /* mysql_stmt_close() had to cancel this result */
- + my_bool unbuffered_fetch_cancelled;
- + void *extension;
- +} MYSQL_RES;
- +
- +
- +typedef struct st_mysql_parameters
- +{
- + unsigned long *p_max_allowed_packet;
- + unsigned long *p_net_buffer_length;
- + void *extension;
- +} MYSQL_PARAMETERS;
- +
- +/*
- + The following definitions are added for the enhanced
- + client-server protocol
- +*/
- +
- +/* statement state */
- +enum enum_mysql_stmt_state
- +{
- + MYSQL_STMT_INIT_DONE= 1, MYSQL_STMT_PREPARE_DONE, MYSQL_STMT_EXECUTE_DONE,
- + MYSQL_STMT_FETCH_DONE
- +};
- +
- +/*
- + This structure is used to define bind information, and
- + internally by the client library.
- + Public members with their descriptions are listed below
- + (conventionally `On input' refers to the binds given to
- + mysql_stmt_bind_param, `On output' refers to the binds given
- + to mysql_stmt_bind_result):
- +
- + buffer_type - One of the MYSQL_* types, used to describe
- + the host language type of buffer.
- + On output: if column type is different from
- + buffer_type, column value is automatically converted
- + to buffer_type before it is stored in the buffer.
- + buffer - On input: points to the buffer with input data.
- + On output: points to the buffer capable to store
- + output data.
- + The type of memory pointed by buffer must correspond
- + to buffer_type. See the correspondence table in
- + the comment to mysql_stmt_bind_param.
- +
- + The two above members are mandatory for any kind of bind.
- +
- + buffer_length - the length of the buffer. You don't have to set
- + it for any fixed length buffer: float, double,
- + int, etc. It must be set however for variable-length
- + types, such as BLOBs or STRINGs.
- +
- + length - On input: in case when lengths of input values
- + are different for each execute, you can set this to
- + point at a variable containining value length. This
- + way the value length can be different in each execute.
- + If length is not NULL, buffer_length is not used.
- + Note, length can even point at buffer_length if
- + you keep bind structures around while fetching:
- + this way you can change buffer_length before
- + each execution, everything will work ok.
- + On output: if length is set, mysql_stmt_fetch will
- + write column length into it.
- +
- + is_null - On input: points to a boolean variable that should
- + be set to TRUE for NULL values.
- + This member is useful only if your data may be
- + NULL in some but not all cases.
- + If your data is never NULL, is_null should be set to 0.
- + If your data is always NULL, set buffer_type
- + to MYSQL_TYPE_NULL, and is_null will not be used.
- +
- + is_unsigned - On input: used to signify that values provided for one
- + of numeric types are unsigned.
- + On output describes signedness of the output buffer.
- + If, taking into account is_unsigned flag, column data
- + is out of range of the output buffer, data for this column
- + is regarded truncated. Note that this has no correspondence
- + to the sign of result set column, if you need to find it out
- + use mysql_stmt_result_metadata.
- + error - where to write a truncation error if it is present.
- + possible error value is:
- + 0 no truncation
- + 1 value is out of range or buffer is too small
- +
- + Please note that MYSQL_BIND also has internals members.
- +*/
- +
- +typedef struct st_mysql_bind
- +{
- + unsigned long *length; /* output length pointer */
- + my_bool *is_null; /* Pointer to null indicator */
- + void *buffer; /* buffer to get/put data */
- + /* set this if you want to track data truncations happened during fetch */
- + my_bool *error;
- + unsigned char *row_ptr; /* for the current data position */
- + void (*store_param_func)(NET *net, struct st_mysql_bind *param);
- + void (*fetch_result)(struct st_mysql_bind *, MYSQL_FIELD *,
- + unsigned char **row);
- + void (*skip_result)(struct st_mysql_bind *, MYSQL_FIELD *,
- + unsigned char **row);
- + /* output buffer length, must be set when fetching str/binary */
- + unsigned long buffer_length;
- + unsigned long offset; /* offset position for char/binary fetch */
- + unsigned long length_value; /* Used if length is 0 */
- + unsigned int param_number; /* For null count and error messages */
- + unsigned int pack_length; /* Internal length for packed data */
- + enum enum_field_types buffer_type; /* buffer type */
- + my_bool error_value; /* used if error is 0 */
- + my_bool is_unsigned; /* set if integer type is unsigned */
- + my_bool long_data_used; /* If used with mysql_send_long_data */
- + my_bool is_null_value; /* Used if is_null is 0 */
- + void *extension;
- +} MYSQL_BIND;
- +
- +
- +/* statement handler */
- +typedef struct st_mysql_stmt
- +{
- + MEM_ROOT mem_root; /* root allocations */
- + LIST list; /* list to keep track of all stmts */
- + MYSQL *mysql; /* connection handle */
- + MYSQL_BIND *params; /* input parameters */
- + MYSQL_BIND *bind; /* output parameters */
- + MYSQL_FIELD *fields; /* result set metadata */
- + MYSQL_DATA result; /* cached result set */
- + MYSQL_ROWS *data_cursor; /* current row in cached result */
- + /*
- + mysql_stmt_fetch() calls this function to fetch one row (it's different
- + for buffered, unbuffered and cursor fetch).
- + */
- + int (*read_row_func)(struct st_mysql_stmt *stmt,
- + unsigned char **row);
- + /* copy of mysql->affected_rows after statement execution */
- + my_ulonglong affected_rows;
- + my_ulonglong insert_id; /* copy of mysql->insert_id */
- + unsigned long stmt_id; /* Id for prepared statement */
- + unsigned long flags; /* i.e. type of cursor to open */
- + unsigned long prefetch_rows; /* number of rows per one COM_FETCH */
- + /*
- + Copied from mysql->server_status after execute/fetch to know
- + server-side cursor status for this statement.
- + */
- + unsigned int server_status;
- + unsigned int last_errno; /* error code */
- + unsigned int param_count; /* input parameter count */
- + unsigned int field_count; /* number of columns in result set */
- + enum enum_mysql_stmt_state state; /* statement state */
- + char last_error[MYSQL_ERRMSG_SIZE]; /* error message */
- + char sqlstate[SQLSTATE_LENGTH+1];
- + /* Types of input parameters should be sent to server */
- + my_bool send_types_to_server;
- + my_bool bind_param_done; /* input buffers were supplied */
- + unsigned char bind_result_done; /* output buffers were supplied */
- + /* mysql_stmt_close() had to cancel this result */
- + my_bool unbuffered_fetch_cancelled;
- + /*
- + Is set to true if we need to calculate field->max_length for
- + metadata fields when doing mysql_stmt_store_result.
- + */
- + my_bool update_max_length;
- + void *extension;
- +} MYSQL_STMT;
- +
- +enum enum_stmt_attr_type
- +{
- + /*
- + When doing mysql_stmt_store_result calculate max_length attribute
- + of statement metadata. This is to be consistent with the old API,
- + where this was done automatically.
- + In the new API we do that only by request because it slows down
- + mysql_stmt_store_result sufficiently.
- + */
- + STMT_ATTR_UPDATE_MAX_LENGTH,
- + /*
- + unsigned long with combination of cursor flags (read only, for update,
- + etc)
- + */
- + STMT_ATTR_CURSOR_TYPE,
- + /*
- + Amount of rows to retrieve from server per one fetch if using cursors.
- + Accepts unsigned long attribute in the range 1 - ulong_max
- + */
- + STMT_ATTR_PREFETCH_ROWS
- +};
- +
- +
- +typedef struct st_mysql_methods
- +{
- + my_bool (*read_query_result)(MYSQL *mysql);
- + my_bool (*advanced_command)(MYSQL *mysql,
- + enum enum_server_command command,
- + const unsigned char *header,
- + unsigned long header_length,
- + const unsigned char *arg,
- + unsigned long arg_length,
- + my_bool skip_check,
- + MYSQL_STMT *stmt);
- + MYSQL_DATA *(*read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
- + unsigned int fields);
- + MYSQL_RES * (*use_result)(MYSQL *mysql);
- + void (*fetch_lengths)(unsigned long *to,
- + MYSQL_ROW column, unsigned int field_count);
- + void (*flush_use_result)(MYSQL *mysql, my_bool flush_all_results);
- +#if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY)
- + MYSQL_FIELD * (*list_fields)(MYSQL *mysql);
- + my_bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
- + int (*stmt_execute)(MYSQL_STMT *stmt);
- + int (*read_binary_rows)(MYSQL_STMT *stmt);
- + int (*unbuffered_fetch)(MYSQL *mysql, char **row);
- + void (*free_embedded_thd)(MYSQL *mysql);
- + const char *(*read_statistics)(MYSQL *mysql);
- + my_bool (*next_result)(MYSQL *mysql);
- + int (*read_change_user_result)(MYSQL *mysql, char *buff, const char *passwd);
- + int (*read_rows_from_cursor)(MYSQL_STMT *stmt);
- +#endif
- +} MYSQL_METHODS;
- +
- +class DllLibMySQLInterface
- +{
- +public:
- + virtual ~DllLibMySQLInterface() {}
- + virtual int mysql_server_init(int argc, char **argv, char **groups)=0;
- + virtual void mysql_server_end();
- + virtual MYSQL_PARAMETERS mysql_get_parameters();
- + virtual my_bool mysql_thread_init()=0;
- + virtual void mysql_thread_end();
- + virtual long long mysql_num_rows(MYSQL_RES *res)=0;
- + virtual unsigned int mysql_num_fields(MYSQL_RES *res)=0;
- + virtual my_bool mysql_eof(MYSQL_RES *res)=0;
- + virtual MYSQL_FIELD* mysql_fetch_field_direct(MYSQL_RES *res, unsigned int fieldnr);
- + virtual MYSQL_FIELD* mysql_fetch_fields(MYSQL_RES *res);
- + virtual MYSQL_ROW_OFFSET* mysql_row_tell(MYSQL_RES *res);
- + virtual MYSQL_FIELD_OFFSET* mysql_field_tell(MYSQL_RES *res);
- + virtual unsigned int mysql_field_count(MYSQL *mysql)=0;
- + virtual my_ulonglong mysql_affected_rows(MYSQL *mysql)=0;
- + virtual my_ulonglong mysql_insert_id(MYSQL *mysql)=0;
- + virtual unsigned int mysql_errno(MYSQL *mysql)=0;
- + virtual const char mysql_error(MYSQL *mysql)=0;
- + virtual const char mysql_sqlstate(MYSQL *mysql)=0;
- + virtual unsigned int mysql_warning_count(MYSQL *mysql)=0;
- + virtual const char mysql_info(MYSQL *mysql)=0;
- + virtual unsigned long mysql_thread_id(MYSQL *mysql)=0;
- + virtual const char mysql_character_set_name(MYSQL *mysql)=0;
- + virtual int mysql_set_character_set(MYSQL *mysql, const char *csname)=0;
- + virtual MYSQL* mysql_init(MYSQL *mysql);
- + virtual my_bool mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert, const char *ca, const char *capath, const char *cipher)=0;
- + virtual const char mysql_get_ssl_cipher(MYSQL *mysql)=0;
- + virtual my_bool mysql_change_user(MYSQL *mysql, const char *user, const char *passwd, const char *db)=0;
- + virtual MYSQL* mysql_real_connect(MYSQL *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long clientflag);
- + virtual int mysql_select_db(MYSQL *mysql, const char *db)=0;
- + virtual int mysql_query(MYSQL *mysql, const char *q)=0;
- + virtual int mysql_send_query(MYSQL *mysql, const char *q, unsigned long length)=0;
- + virtual int mysql_real_query(MYSQL *mysql, const char *q, unsigned long length)=0;
- + virtual MYSQL_RES* mysql_store_result(MYSQL *mysql);
- + virtual MYSQL_RES* mysql_use_result(MYSQL *mysql);
- + virtual void mysql_get_character_set_info(MYSQL *mysql, MY_CHARSET_INFO *charset);
- + virtual void mysql_set_local_infile_handler(MYSQL *mysql,
- + int (*local_infile_init)(void **, const char *, void *),
- + int (*local_infile_read)(void *, char *, unsigned int),
- + void (*local_infile_end)(void *),
- + int (*local_infile_error)(void *, char*, unsigned int),
- + void *);
- + virtual void mysql_set_local_infile_default(MYSQL *mysql);
- + virtual int mysql_shutdown(MYSQL *mysql, enum mysql_enum_shutdown_level shutdown_level)=0;
- + virtual int mysql_dump_debug_info(MYSQL *mysql)=0;
- + virtual int mysql_refresh(MYSQL *mysql, unsigned int refresh_options)=0;
- + virtual int mysql_kill(MYSQL *mysql,unsigned long pid)=0;
- + virtual int mysql_set_server_option(MYSQL *mysql, enum enum_mysql_set_option option)=0;
- + virtual int mysql_ping(MYSQL *mysql)=0;
- + virtual const char mysql_stat(MYSQL *mysql)=0;
- + virtual const char mysql_get_server_info(MYSQL *mysql)=0;
- + virtual const char mysql_get_client_info()=0;
- + virtual unsigned long mysql_get_client_version()=0;
- + virtual const char mysql_get_host_info(MYSQL *mysql)=0;
- + virtual unsigned long mysql_get_server_version(MYSQL *mysql)=0;
- + virtual unsigned int mysql_get_proto_info(MYSQL *mysql)=0;
- + virtual MYSQL_RES* mysql_list_dbs(MYSQL *mysql,const char *wild);
- + virtual MYSQL_RES* mysql_list_tables(MYSQL *mysql,const char *wild);
- + virtual MYSQL_RES* mysql_list_processes(MYSQL *mysql);
- + virtual int mysql_options(MYSQL *mysql,enum mysql_option option, const void *arg)=0;
- + virtual void mysql_free_result(MYSQL_RES *result);
- + virtual void mysql_data_seek(MYSQL_RES *result, my_ulonglong offset);
- + virtual MYSQL_ROW_OFFSET* mysql_row_seek(MYSQL_RES *result, MYSQL_ROW_OFFSET offset);
- + virtual MYSQL_FIELD_OFFSET* mysql_field_seek(MYSQL_RES *result, MYSQL_FIELD_OFFSET offset);
- + virtual MYSQL_ROW mysql_fetch_row(MYSQL_RES *result);
- + virtual unsigned long* mysql_fetch_lengths(MYSQL_RES *result)=0;
- + virtual MYSQL_FIELD* mysql_fetch_field(MYSQL_RES *result);
- + virtual MYSQL_RES* mysql_list_fields(MYSQL *mysql, const char *table, const char *wild);
- + virtual unsigned long mysql_escape_string(char *to,const char *from, unsigned long from_length)=0;
- + virtual unsigned long mysql_hex_string(char *to,const char *from, unsigned long from_length)=0;
- + virtual unsigned long mysql_real_escape_string(MYSQL *mysql, char *to,const char *from, unsigned long length)=0;
- + virtual void mysql_debug(const char *debug);
- + virtual void myodbc_remove_escape(MYSQL *mysql,char *name);
- + virtual unsigned int mysql_thread_safe(void)=0;
- + virtual my_bool mysql_embedded(void)=0;
- + virtual my_bool mysql_read_query_result(MYSQL *mysql)=0;
- + virtual MYSQL_STMT* mysql_stmt_init(MYSQL *mysql);
- + virtual int mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, unsigned long length)=0;
- + virtual int mysql_stmt_execute(MYSQL_STMT *stmt)=0;
- + virtual int mysql_stmt_fetch(MYSQL_STMT *stmt)=0;
- + virtual int mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind_arg, unsigned int column, unsigned long offset)=0;
- + virtual int mysql_stmt_store_result(MYSQL_STMT *stmt)=0;
- + virtual unsigned long mysql_stmt_param_count(MYSQL_STMT * stmt)=0;
- + virtual my_bool mysql_stmt_attr_set(MYSQL_STMT *stmt, enum enum_stmt_attr_type attr_type, const void *attr)=0;
- + virtual my_bool mysql_stmt_attr_get(MYSQL_STMT *stmt, enum enum_stmt_attr_type attr_type, void *attr)=0;
- + virtual my_bool mysql_stmt_bind_param(MYSQL_STMT * stmt, MYSQL_BIND * bnd)=0;
- + virtual my_bool mysql_stmt_bind_result(MYSQL_STMT * stmt, MYSQL_BIND * bnd)=0;
- + virtual my_bool mysql_stmt_close(MYSQL_STMT * stmt)=0;
- + virtual my_bool mysql_stmt_reset(MYSQL_STMT * stmt)=0;
- + virtual my_bool mysql_stmt_free_result(MYSQL_STMT *stmt)=0;
- + virtual my_bool mysql_stmt_send_long_data(MYSQL_STMT *stmt, unsigned int param_number, const char *data, unsigned long length)=0;
- + virtual MYSQL_RES* mysql_stmt_result_metadata(MYSQL_STMT *stmt);
- + virtual MYSQL_RES* mysql_stmt_param_metadata(MYSQL_STMT *stmt);
- + virtual unsigned int mysql_stmt_errno(MYSQL_STMT * stmt)=0;
- + virtual const char mysql_stmt_error(MYSQL_STMT * stmt)=0;
- + virtual const char mysql_stmt_sqlstate(MYSQL_STMT * stmt)=0;
- + virtual MYSQL_ROW_OFFSET* mysql_stmt_row_seek(MYSQL_STMT *stmt, MYSQL_ROW_OFFSET offset);
- + virtual MYSQL_ROW_OFFSET* mysql_stmt_row_tell(MYSQL_STMT *stmt);
- + virtual void mysql_stmt_data_seek(MYSQL_STMT *stmt, my_ulonglong offset);
- + virtual my_ulonglong mysql_stmt_num_rows(MYSQL_STMT *stmt)=0;
- + virtual my_ulonglong mysql_stmt_affected_rows(MYSQL_STMT *stmt)=0;
- + virtual my_ulonglong mysql_stmt_insert_id(MYSQL_STMT *stmt)=0;
- + virtual unsigned int mysql_stmt_field_count(MYSQL_STMT *stmt)=0;
- + virtual my_bool mysql_commit(MYSQL * mysql)=0;
- + virtual my_bool mysql_rollback(MYSQL * mysql)=0;
- + virtual my_bool mysql_autocommit(MYSQL * mysql, my_bool auto_mode)=0;
- + virtual my_bool mysql_more_results(MYSQL *mysql)=0;
- + virtual int mysql_next_result(MYSQL *mysql)=0;
- + virtual int mysql_stmt_next_result(MYSQL_STMT *stmt)=0;
- + virtual void mysql_close(MYSQL *sock);
- +};
- +
- +class DllLibMySQL : public DllDynamic, DllLibMySQLInterface
- +{
- + DECLARE_DLL_WRAPPER(DllLibMySQL, Q:\\system\\libMySQL.dll)
- + DEFINE_METHOD3(int,mysql_server_init,(int p1, char **p2, char **p3));
- + DEFINE_METHOD0(my_bool,mysql_thread_init);
- + DEFINE_METHOD1(long long, mysql_num_rows,(MYSQL_RES *p1));
- + DEFINE_METHOD1(my_bool, mysql_eof, (MYSQL_RES *p1));
- + DEFINE_METHOD1(unsigned int, mysql_num_fields, (MYSQL_RES *p1));
- + DEFINE_METHOD1(MYSQL_ROW_OFFSET*, mysql_row_tell, (MYSQL_RES *p1))
- + DEFINE_METHOD1(MYSQL_FIELD_OFFSET*, mysql_field_tell, (MYSQL_RES *p1))
- + DEFINE_METHOD1(unsigned int, mysql_field_count, (MYSQL *p1))
- + DEFINE_METHOD1(my_ulonglong, mysql_affected_rows, (MYSQL *p1))
- + DEFINE_METHOD1(my_ulonglong, mysql_insert_id, (MYSQL *p1))
- + DEFINE_METHOD1(unsigned int, mysql_errno, (MYSQL *p1))
- + DEFINE_METHOD1(const char, mysql_error, (MYSQL *p1))
- + DEFINE_METHOD1(const char, mysql_sqlstate, (MYSQL *p1))
- + DEFINE_METHOD1(unsigned int, mysql_warning_count, (MYSQL *p1))
- + DEFINE_METHOD1(const char, mysql_info, (MYSQL *p1))
- + DEFINE_METHOD1(unsigned long, mysql_thread_id, (MYSQL *p1))
- + DEFINE_METHOD1(const char, mysql_character_set_name, (MYSQL *p1))
- + DEFINE_METHOD2(int, mysql_set_character_set, (MYSQL *p1, const char *p2))
- + DEFINE_METHOD1(MYSQL*, mysql_init, (MYSQL *p1))
- + DEFINE_METHOD6(my_bool, mysql_ssl_set, (MYSQL *p1, const char *p2, const char *p3, const char *p4, const char *p5, const char *p6))
- + DEFINE_METHOD1(const char, mysql_get_ssl_cipher, (MYSQL *p1))
- + DEFINE_METHOD4(my_bool, mysql_change_user, (MYSQL *p1, const char *p2, const char *p3, const char *p4))
- + DEFINE_METHOD7(MYSQL*, mysql_real_connect, (MYSQL *p1, const char *p2, const char *p3, const char *p4, const char *p5, unsigned int p6, const char *p7))
- + DEFINE_METHOD2(int, mysql_select_db, (MYSQL *p1, const char *p2))
- + DEFINE_METHOD2(int, mysql_query, (MYSQL *p1, const char *p2))
- + DEFINE_METHOD3(int, mysql_send_query, (MYSQL *p1, const char *p2, unsigned long p3))
- + DEFINE_METHOD3(int, mysql_real_query, (MYSQL *p1, const char *p2, unsigned long p3))
- + DEFINE_METHOD1(MYSQL_RES*, mysql_store_result, (MYSQL *p1))
- + DEFINE_METHOD1(MYSQL_RES*, mysql_use_result, (MYSQL *p1))
- + DEFINE_METHOD2(void, mysql_get_character_set_info, (MYSQL *p1, MY_CHARSET_INFO *p2))
- + DEFINE_METHOD1(void, mysql_set_local_infile_default, (MYSQL *p1))
- + DEFINE_METHOD2(int, mysql_shutdown, (MYSQL *p1, enum mysql_enum_shutdown_level p2))
- + DEFINE_METHOD1(int, mysql_dump_debug_info, (MYSQL *p1))
- + DEFINE_METHOD2(int, mysql_refresh, (MYSQL *p1, unsigned int p2))
- + DEFINE_METHOD2(int, mysql_kill, (MYSQL *p1, unsigned long p2))
- + DEFINE_METHOD2(int, mysql_set_server_option, (MYSQL *p1, enum enum_mysql_set_option p2))
- + DEFINE_METHOD1(int, mysql_ping, (MYSQL *p1))
- + DEFINE_METHOD1(const char, mysql_stat, (MYSQL *p1))
- + DEFINE_METHOD1(const char, mysql_get_server_info, (MYSQL *p1))
- + DEFINE_METHOD0(const char, mysql_get_client_info)
- + DEFINE_METHOD0(unsigned long, mysql_get_client_version)
- + DEFINE_METHOD1(const char, mysql_get_host_info, (MYSQL *p1))
- + DEFINE_METHOD1(unsigned long, mysql_get_server_version, (MYSQL *p1))
- + DEFINE_METHOD1(unsigned int, mysql_get_proto_info, (MYSQL *p1))
- + DEFINE_METHOD2(MYSQL_RES*, mysql_list_dbs, (MYSQL *p1, const char *p2))
- + DEFINE_METHOD2(MYSQL_RES*, mysql_list_tables, (MYSQL *p1, const char *p2))
- + DEFINE_METHOD1(MYSQL_RES*, mysql_list_processes, (MYSQL *p1))
- + DEFINE_METHOD3(int, mysql_options, (MYSQL *p1, enum mysql_option p2, const void *p3))
- + DEFINE_METHOD1(void, mysql_free_result, (MYSQL_RES *p1))
- + DEFINE_METHOD2(void, mysql_data_seek, (MYSQL_RES *p1, my_ulonglong p2))
- + DEFINE_METHOD2(MYSQL_ROW_OFFSET*, mysql_row_seek, (MYSQL_RES *p1, MYSQL_ROW_OFFSET p2))
- + DEFINE_METHOD2(MYSQL_FIELD_OFFSET*, mysql_field_seek, (MYSQL_RES *p1, MYSQL_FIELD_OFFSET p2))
- + DEFINE_METHOD1(MYSQL_ROW, mysql_fetch_row, (MYSQL_RES *p1))
- + DEFINE_METHOD1(unsigned long*, mysql_fetch_lengths, (MYSQL_RES *p1))
- + DEFINE_METHOD1(MYSQL_FIELD*, mysql_fetch_field, (MYSQL_RES *p1))
- + DEFINE_METHOD1(MYSQL_FIELD*, mysql_fetch_fields, (MYSQL_RES *p1))
- + DEFINE_METHOD3(MYSQL_RES*, mysql_list_fields, (MYSQL *p1, const char *p2, const char *p3))
- + DEFINE_METHOD3(unsigned long, mysql_escape_string, (char *p1, const char *p2, unsigned long p3))
- + DEFINE_METHOD3(unsigned long, mysql_hex_string, (char *p1, const char *p2, unsigned long p3))
- + DEFINE_METHOD4(unsigned long, mysql_real_escape_string, (MYSQL *p1, char *p2, const char *p3, unsigned long p4))
- + DEFINE_METHOD1(void, mysql_debug, (const char *p1))
- + DEFINE_METHOD2(void, myodbc_remove_escape, (MYSQL *p1, char *p2))
- + DEFINE_METHOD0(unsigned int, mysql_thread_safe)
- + DEFINE_METHOD0(my_bool, mysql_embedded)
- + DEFINE_METHOD1(my_bool, mysql_read_query_result, (MYSQL *p1))
- + DEFINE_METHOD1(MYSQL_STMT*, mysql_stmt_init, (MYSQL *p1))
- + DEFINE_METHOD3(int, mysql_stmt_prepare, (MYSQL_STMT *p1, const char *p2, unsigned long p3))
- + DEFINE_METHOD1(int, mysql_stmt_execute, (MYSQL_STMT *p1))
- + DEFINE_METHOD1(int, mysql_stmt_fetch, (MYSQL_STMT *p1))
- + DEFINE_METHOD4(int, mysql_stmt_fetch_column, (MYSQL_STMT *p1, MYSQL_BIND *p2, unsigned int p3, unsigned long p4))
- + DEFINE_METHOD1(int, mysql_stmt_store_result, (MYSQL_STMT *p1))
- + DEFINE_METHOD1(unsigned long, mysql_stmt_param_count, (MYSQL_STMT *p1))
- + DEFINE_METHOD3(my_bool, mysql_stmt_attr_set, (MYSQL_STMT *p1, enum enum_stmt_attr_type p2, const void *p3))
- + DEFINE_METHOD3(my_bool, mysql_stmt_attr_get, (MYSQL_STMT *p1, enum enum_stmt_attr_type p2, void *p3))
- + DEFINE_METHOD2(my_bool, mysql_stmt_bind_param, (MYSQL_STMT *p1, MYSQL_BIND *p2))
- + DEFINE_METHOD2(my_bool, mysql_stmt_bind_result, (MYSQL_STMT *p1, MYSQL_BIND *p2))
- + DEFINE_METHOD1(my_bool, mysql_stmt_close, (MYSQL_STMT *p1))
- + DEFINE_METHOD1(my_bool, mysql_stmt_reset, (MYSQL_STMT *p1))
- + DEFINE_METHOD1(my_bool, mysql_stmt_free_result, (MYSQL_STMT *p1))
- + DEFINE_METHOD4(my_bool, mysql_stmt_send_long_data, (MYSQL_STMT *p1, unsigned int p2, const char *p3, unsigned long p4))
- + DEFINE_METHOD1(MYSQL_RES*, mysql_stmt_result_metadata, (MYSQL_STMT *p1))
- + DEFINE_METHOD1(MYSQL_RES*, mysql_stmt_param_metadata, (MYSQL_STMT *p1))
- + DEFINE_METHOD1(unsigned int, mysql_stmt_errno, (MYSQL_STMT *p1))
- + DEFINE_METHOD1(const char, mysql_stmt_error, (MYSQL_STMT *p1))
- + DEFINE_METHOD1(const char, mysql_stmt_sqlstate, (MYSQL_STMT *p1))
- + DEFINE_METHOD2(MYSQL_ROW_OFFSET*, mysql_stmt_row_seek, (MYSQL_STMT *p1, MYSQL_ROW_OFFSET p2))
- + DEFINE_METHOD1(MYSQL_ROW_OFFSET*, mysql_stmt_row_tell, (MYSQL_STMT *p1))
- + DEFINE_METHOD2(void, mysql_stmt_data_seek, (MYSQL_STMT *p1, my_ulonglong p2))
- + DEFINE_METHOD1(my_ulonglong, mysql_stmt_num_rows, (MYSQL_STMT *p1))
- + DEFINE_METHOD1(my_ulonglong, mysql_stmt_affected_rows, (MYSQL_STMT *p1))
- + DEFINE_METHOD1(my_ulonglong, mysql_stmt_insert_id, (MYSQL_STMT *p1))
- + DEFINE_METHOD1(unsigned int, mysql_stmt_field_count, (MYSQL_STMT *p1))
- + DEFINE_METHOD1(my_bool, mysql_commit, (MYSQL *p1))
- + DEFINE_METHOD1(my_bool, mysql_rollback, (MYSQL *p1))
- + DEFINE_METHOD2(my_bool, mysql_autocommit, (MYSQL *p1, my_bool p2))
- + DEFINE_METHOD1(my_bool, mysql_more_results, (MYSQL *p1))
- + DEFINE_METHOD1(int, mysql_next_result, (MYSQL *p1))
- + DEFINE_METHOD1(int, mysql_stmt_next_result, (MYSQL_STMT *p1))
- + DEFINE_METHOD1(void, mysql_close, (MYSQL *p1))
- + DEFINE_METHOD6(void, mysql_set_local_infile_handler, (MYSQL *p1, int (*p2)(void **, const char *, void *), int (*p3)(void *, char *, unsigned int), void (*p4)(void *), int (*p5)(void *, char*, unsigned int), void *p6))
- +
- + BEGIN_METHOD_RESOLVE()
- + RESOLVE_METHOD(mysql_server_init)
- + RESOLVE_METHOD(mysql_thread_init)
- + RESOLVE_METHOD(mysql_num_rows)
- + RESOLVE_METHOD(mysql_num_fields)
- + RESOLVE_METHOD(mysql_row_tell)
- + RESOLVE_METHOD(mysql_eof)
- + RESOLVE_METHOD(mysql_field_tell)
- + RESOLVE_METHOD(mysql_field_count)
- + RESOLVE_METHOD(mysql_affected_rows)
- + RESOLVE_METHOD(mysql_insert_id)
- + RESOLVE_METHOD(mysql_errno)
- + RESOLVE_METHOD(mysql_error)
- + RESOLVE_METHOD(mysql_sqlstate)
- + RESOLVE_METHOD(mysql_warning_count)
- + RESOLVE_METHOD(mysql_info)
- + RESOLVE_METHOD(mysql_thread_id)
- + RESOLVE_METHOD(mysql_character_set_name)
- + RESOLVE_METHOD(mysql_set_character_set)
- + RESOLVE_METHOD(mysql_init)
- + RESOLVE_METHOD(mysql_ssl_set)
- + RESOLVE_METHOD(mysql_get_ssl_cipher)
- + RESOLVE_METHOD(mysql_change_user)
- + RESOLVE_METHOD(mysql_real_connect)
- + RESOLVE_METHOD(mysql_select_db)
- + RESOLVE_METHOD(mysql_query)
- + RESOLVE_METHOD(mysql_send_query)
- + RESOLVE_METHOD(mysql_real_query)
- + RESOLVE_METHOD(mysql_store_result)
- + RESOLVE_METHOD(mysql_use_result)
- + RESOLVE_METHOD(mysql_get_character_set_info)
- + RESOLVE_METHOD(mysql_set_local_infile_default)
- + RESOLVE_METHOD(mysql_shutdown)
- + RESOLVE_METHOD(mysql_dump_debug_info)
- + RESOLVE_METHOD(mysql_refresh)
- + RESOLVE_METHOD(mysql_kill)
- + RESOLVE_METHOD(mysql_set_server_option)
- + RESOLVE_METHOD(mysql_ping)
- + RESOLVE_METHOD(mysql_stat)
- + RESOLVE_METHOD(mysql_get_server_info)
- + RESOLVE_METHOD(mysql_get_client_info)
- + RESOLVE_METHOD(mysql_get_client_version)
- + RESOLVE_METHOD(mysql_get_host_info)
- + RESOLVE_METHOD(mysql_get_server_version)
- + RESOLVE_METHOD(mysql_get_proto_info)
- + RESOLVE_METHOD(mysql_list_dbs)
- + RESOLVE_METHOD(mysql_list_tables)
- + RESOLVE_METHOD(mysql_list_processes)
- + RESOLVE_METHOD(mysql_options)
- + RESOLVE_METHOD(mysql_free_result)
- + RESOLVE_METHOD(mysql_data_seek)
- + RESOLVE_METHOD(mysql_row_seek)
- + RESOLVE_METHOD(mysql_field_seek)
- + RESOLVE_METHOD(mysql_fetch_row)
- + RESOLVE_METHOD(mysql_fetch_lengths)
- + RESOLVE_METHOD(mysql_fetch_field)
- + RESOLVE_METHOD(mysql_fetch_fields)
- + RESOLVE_METHOD(mysql_list_fields)
- + RESOLVE_METHOD(mysql_escape_string)
- + RESOLVE_METHOD(mysql_hex_string)
- + RESOLVE_METHOD(mysql_real_escape_string)
- + RESOLVE_METHOD(mysql_debug)
- + RESOLVE_METHOD(myodbc_remove_escape)
- + RESOLVE_METHOD(mysql_thread_safe)
- + RESOLVE_METHOD(mysql_embedded)
- + RESOLVE_METHOD(mysql_read_query_result)
- + RESOLVE_METHOD(mysql_stmt_init)
- + RESOLVE_METHOD(mysql_stmt_prepare)
- + RESOLVE_METHOD(mysql_stmt_execute)
- + RESOLVE_METHOD(mysql_stmt_fetch)
- + RESOLVE_METHOD(mysql_stmt_fetch_column)
- + RESOLVE_METHOD(mysql_stmt_store_result)
- + RESOLVE_METHOD(mysql_stmt_param_count)
- + RESOLVE_METHOD(mysql_stmt_attr_set)
- + RESOLVE_METHOD(mysql_stmt_attr_get)
- + RESOLVE_METHOD(mysql_stmt_bind_param)
- + RESOLVE_METHOD(mysql_stmt_bind_result)
- + RESOLVE_METHOD(mysql_stmt_close)
- + RESOLVE_METHOD(mysql_stmt_reset)
- + RESOLVE_METHOD(mysql_stmt_free_result)
- + RESOLVE_METHOD(mysql_stmt_send_long_data)
- + RESOLVE_METHOD(mysql_stmt_result_metadata)
- + RESOLVE_METHOD(mysql_stmt_param_metadata)
- + RESOLVE_METHOD(mysql_stmt_errno)
- + RESOLVE_METHOD(mysql_stmt_error)
- + RESOLVE_METHOD(mysql_stmt_sqlstate)
- + RESOLVE_METHOD(mysql_stmt_row_seek)
- + RESOLVE_METHOD(mysql_stmt_row_tell)
- + RESOLVE_METHOD(mysql_stmt_data_seek)
- + RESOLVE_METHOD(mysql_stmt_num_rows)
- + RESOLVE_METHOD(mysql_stmt_affected_rows)
- + RESOLVE_METHOD(mysql_stmt_insert_id)
- + RESOLVE_METHOD(mysql_stmt_field_count)
- + RESOLVE_METHOD(mysql_commit)
- + RESOLVE_METHOD(mysql_rollback)
- + RESOLVE_METHOD(mysql_autocommit)
- + RESOLVE_METHOD(mysql_more_results)
- + RESOLVE_METHOD(mysql_next_result)
- + RESOLVE_METHOD(mysql_stmt_next_result)
- + RESOLVE_METHOD(mysql_close)
- + END_METHOD_RESOLVE()
- +};
- Index: xbmc/lib/sqLite/mysqldataset.cpp
- ===================================================================
- --- xbmc/lib/sqLite/mysqldataset.cpp (revision 0)
- +++ xbmc/lib/sqLite/mysqldataset.cpp (working copy)
- @@ -0,0 +1,682 @@
- +/*
- + * Copyright (C) 2005-2009 Team XBMC
- + * http://xbmc.org
- + *
- + * This Program is free software; you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation; either version 2, or (at your option)
- + * any later version.
- + *
- + * This Program is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + * GNU General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with XBMC; see the file COPYING. If not, write to
- + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- + * http://www.gnu.org/copyleft/gpl.html
- + *
- + */
- +
- +#include <iostream>
- +#include <string>
- +#include <set>
- +
- +#include "mysqldataset.h"
- +#include "utils/log.h"
- +#include "system.h" // for GetLastError()
- +#include "errmsg.h"
- +
- +
- +#define MYSQL_OK 0
- +
- +using namespace std;
- +
- +namespace dbiplus {
- +
- +//************* MysqlDatabase implementation ***************
- +
- +MysqlDatabase::MysqlDatabase() {
- +
- + active = false;
- + _in_transaction = false; // for transaction
- +
- + error = "Unknown database error";//S_NO_CONNECTION;
- + host = "localhost";
- + port = "3306";
- + db = "mysql";
- + login = "root";
- + passwd = "null";
- + conn = NULL;
- + //m_MySQL = new DllLibMySQL;
- + m_MySQL.Load();
- +}
- +
- +MysqlDatabase::~MysqlDatabase() {
- + disconnect();
- + m_MySQL.Unload();
- +}
- +
- +Dataset* MysqlDatabase::CreateDataset() const {
- + return new MysqlDataset((MysqlDatabase*)this);
- +}
- +
- +int MysqlDatabase::status(void) {
- + if (active == false) return DB_CONNECTION_NONE;
- + return DB_CONNECTION_OK;
- +}
- +
- +int MysqlDatabase::setErr(int err_code, const char * qry) {
- + switch (err_code)
- + {
- + case MYSQL_OK:
- + error = "Successful result";
- + break;
- + case CR_COMMANDS_OUT_OF_SYNC:
- + error = "Commands were executed in an improper order";
- + break;
- + case CR_SERVER_GONE_ERROR:
- + error = "The MySQL server has gone away";
- + break;
- + case CR_SERVER_LOST:
- + error = "The connection to the server was lost during this query";
- + break;
- + case CR_UNKNOWN_ERROR:
- + error = "An unknown error occurred";
- + break;
- + case 1146: /* ER_NO_SUCH_TABLE */
- + error = "The table does not exist";
- + break;
- + default:
- + char err[256];
- + // snprintf(err, 256, "Undefined MySQL error: Code (%d)", err_code);
- + error = err;
- + }
- + error += "\nQuery: ";
- + error += qry;
- + error += "\n";
- + return err_code;
- +}
- +
- +const char *MysqlDatabase::getErrorMsg() {
- + return error.c_str();
- +}
- +
- +int MysqlDatabase::connect() {
- + try
- + {
- + // don't reconnect if ping is ok
- + if (conn != NULL && m_MySQL.mysql_ping(conn) == 0)
- + {
- + return DB_CONNECTION_OK;
- + }
- + disconnect();
- +
- + if (conn == NULL)
- + {
- + conn = m_MySQL.mysql_init(conn);
- + }
- +
- + // TODO block to avoid multiple connect on db
- + if (m_MySQL.mysql_real_connect(conn,host.c_str(),login.c_str(),passwd.c_str(),db.c_str(),atoi(port.c_str()),NULL) != NULL)
- + {
- + active = true;
- + return DB_CONNECTION_OK;
- + }
- + // Database doesn't exists
- + if (m_MySQL.mysql_errno(conn) == 1049)
- + {
- + if (create() == MYSQL_OK)
- + {
- + active = true;
- +
- + // disable mysql autocommit since we handle it
- + m_MySQL.mysql_autocommit(conn, false);
- +
- + return DB_CONNECTION_OK;
- + }
- + }
- +
- + CLog::Log(LOGERROR, "Unable to open database:%s [%d](%s)",
- + db.c_str(), m_MySQL.mysql_errno(conn), m_MySQL.mysql_error(conn));
- + return DB_CONNECTION_NONE;
- + }
- + catch(...)
- + {
- + CLog::Log(LOGERROR, "Unable to open database:%s (%u)",
- + db.c_str(), GetLastError());
- + }
- + return DB_CONNECTION_NONE;
- +}
- +
- +void MysqlDatabase::disconnect(void) {
- + if (active == false) return;
- + if (conn == NULL) return;
- + m_MySQL.mysql_close(conn);
- + conn = NULL;
- + active = false;
- +}
- +
- +int MysqlDatabase::create() {
- + const char* seq_table = "sys_seq";
- + if (m_MySQL.mysql_real_connect(conn, host.c_str(), login.c_str(), passwd.c_str(), NULL, atoi(port.c_str()),NULL) == NULL)
- + {
- + throw DbErrors("Can't create database: '%s'\nCan't connect to server",db.c_str());
- + }
- + char sqlcmd[512];
- + sprintf(sqlcmd, "CREATE DATABASE `%s`", db.c_str());
- + if ( query_with_reconnect(sqlcmd) )
- + {
- + throw DbErrors("Can't create database: '%s'\nError: %s", db.c_str(), strerror(errno));
- + }
- + // Reconnect to the server
- + if (m_MySQL.mysql_real_connect(conn, host.c_str(), login.c_str(), passwd.c_str(), db.c_str(), atoi(port.c_str()), NULL) == NULL)
- + {
- + throw DbErrors("Can't create database: '%s'\nCan't reconnect to server",db.c_str());
- + }
- + // Create the sequence table
- + sprintf(sqlcmd,"CREATE TABLE `%s` (`seq_name` VARCHAR( 64 ) NOT NULL, `nextid` INT NOT NULL, PRIMARY KEY ( `seq_name` ))", seq_table);
- + if ( query_with_reconnect(sqlcmd) )
- + {
- + throw DbErrors("Can't create sequence table in '%s'\nError: %s", db.c_str(), strerror(errno));
- + }
- + return MYSQL_OK;
- +}
- +
- +int MysqlDatabase::drop() {
- + if (active == false) throw DbErrors("Can't drop database: no active connection...");
- + char sqlcmd[512];
- + sprintf(sqlcmd,"DROP DATABASE `%s`", db.c_str());
- + if ( query_with_reconnect(sqlcmd) )
- + {
- + throw DbErrors("Can't drop database: '%s'\nError: %s", db.c_str(), strerror(errno));
- + }
- + disconnect();
- + return DB_COMMAND_OK;
- +}
- +
- +int MysqlDatabase::query_with_reconnect(const char* query) {
- + int attempts = 5;
- + int result;
- +
- + // try to reconnect if server is gone (up to 3 times)
- + while ( ((result = m_MySQL.mysql_real_query(conn, query, strlen(query))) == CR_SERVER_GONE_ERROR) &&
- + (attempts-- > 0) )
- + {
- + CLog::Log(LOGINFO,"MYSQL server has gone. Will try %d more attempt(s) to reconnect.", attempts);
- + active = false;
- + connect();
- + }
- +
- + // grab the latest error if not ok
- + if (result != MYSQL_OK)
- + result = m_MySQL.mysql_errno(conn);
- +
- + // set the error return string and return
- + return result;
- +}
- +
- +long MysqlDatabase::nextid(const char* sname) {
- + CLog::Log(LOGDEBUG,"MysqlDatabase::nextid for %s",sname);
- + if (!active) return DB_UNEXPECTED_RESULT;
- + const char* seq_table = "sys_seq";
- + int id;/*,nrow,ncol;*/
- + MYSQL_RES* res;
- + char sqlcmd[512];
- + sprintf(sqlcmd,"select nextid from %s where seq_name = '%s'",seq_table, sname);
- + CLog::Log(LOGDEBUG,"MysqlDatabase::nextid will request");
- + if ((last_err = query_with_reconnect(sqlcmd)) != 0)
- + {
- + return DB_UNEXPECTED_RESULT;
- + }
- + res = m_MySQL.mysql_store_result(conn);
- + if (m_MySQL.mysql_num_rows(res) == 0)
- + {
- + id = 1;
- + sprintf(sqlcmd,"insert into %s (nextid,seq_name) values (%d,'%s')",seq_table,id,sname);
- + m_MySQL.mysql_free_result(res);
- + if ((last_err = query_with_reconnect(sqlcmd)) != 0) return DB_UNEXPECTED_RESULT;
- + return id;
- + }
- + else
- + {
- + MYSQL_ROW row = m_MySQL.mysql_fetch_row(res);
- + //id = (int)row[0];
- + id = -1;
- + unsigned long *lengths;
- + lengths = m_MySQL.mysql_fetch_lengths(res);
- + CLog::Log(LOGINFO,"Next id is [%.*s] ", (int) lengths[0], row[0]);
- + sprintf(sqlcmd,"update %s set nextid=%d where seq_name = '%s'",seq_table,id,sname);
- + if ((last_err = query_with_reconnect(sqlcmd) != 0)) return DB_UNEXPECTED_RESULT;
- + return id;
- + }
- + return DB_UNEXPECTED_RESULT;
- +}
- +
- +// methods for transactions
- +// ---------------------------------------------
- +void MysqlDatabase::start_transaction() {
- + if (active)
- + {
- + CLog::Log(LOGDEBUG,"Mysql Start transaction");
- + _in_transaction = true;
- + }
- +}
- +
- +void MysqlDatabase::commit_transaction() {
- + if (active)
- + {
- + m_MySQL.mysql_commit(conn);
- + CLog::Log(LOGDEBUG,"Mysql commit transaction");
- + _in_transaction = false;
- + }
- +}
- +
- +void MysqlDatabase::rollback_transaction() {
- + if (active)
- + {
- + m_MySQL.mysql_rollback(conn);
- + CLog::Log(LOGDEBUG,"Mysql rollback transaction");
- + _in_transaction = false;
- + }
- +}
- +
- +bool MysqlDatabase::exists() {
- + // Uncorrect name, check if tables are present inside the db
- + connect();
- + if (active && conn != NULL)
- + {
- + MYSQL_RES* res = m_MySQL.mysql_list_dbs(conn, db.c_str());
- + if (res == NULL)
- + {
- + CLog::Log(LOGERROR,"Database is not present, does the user has CREATE DATABASE permission");
- + return false;
- + }
- +
- + bool result = (m_MySQL.mysql_num_rows(res) > 0); // Avoid counting the sequence table
- + m_MySQL.mysql_free_result(res);
- + // Check if there is some tables ( to permit user with no create database rights
- + if (result == true)
- + {
- + res = m_MySQL.mysql_list_tables(conn, NULL);
- + if (res != NULL)
- + {
- + result = (m_MySQL.mysql_num_rows(res) > 1);
- + }
- + m_MySQL.mysql_free_result(res);
- + }
- + return result;
- + }
- + return false;
- +}
- +
- +//************* MysqlDataset implementation ***************
- +
- +MysqlDataset::MysqlDataset():Dataset() {
- + haveError = false;
- + db = NULL;
- + errmsg = NULL;
- + autorefresh = false;
- +}
- +
- +
- +MysqlDataset::MysqlDataset(MysqlDatabase *newDb):Dataset(newDb) {
- + haveError = false;
- + db = newDb;
- + errmsg = NULL;
- + autorefresh = false;
- + m_MySQL.Load();
- +}
- +
- +MysqlDataset::~MysqlDataset() {
- + if (errmsg) free(errmsg);
- + m_MySQL.Unload();
- + }
- +
- +
- +void MysqlDataset::set_autorefresh(bool val) {
- + autorefresh = val;
- +}
- +
- +
- +
- +//--------- protected functions implementation -----------------//
- +
- +MYSQL* MysqlDataset::handle(){
- + if (db != NULL)
- + {
- + return static_cast<MysqlDatabase*>(db)->getHandle();
- + }
- +
- + return NULL;
- +}
- +
- +void MysqlDataset::make_query(StringList &_sql) {
- + string query;
- + int result = 0;
- + try
- + {
- + if (db == NULL) throw DbErrors("No Database Connection");
- + if (autocommit) db->start_transaction();
- +
- + for (list<string>::iterator i =_sql.begin(); i!=_sql.end(); i++)
- + {
- + query = *i;
- + Dataset::parse_sql(query);
- + if ((result = static_cast<MysqlDatabase *>(db)->query_with_reconnect(query.c_str())) != MYSQL_OK)
- + {
- + throw DbErrors(db->getErrorMsg());
- + }
- + } // end of for
- +
- + if (db->in_transaction() && autocommit) db->commit_transaction();
- +
- + active = true;
- + ds_state = dsSelect;
- + if (autorefresh)
- + refresh();
- + } // end of try
- + catch(...)
- + {
- + if (db->in_transaction()) db->rollback_transaction();
- + throw;
- + }
- +
- +}
- +
- +void MysqlDataset::make_insert() {
- + make_query(insert_sql);
- + last();
- +}
- +
- +void MysqlDataset::make_edit() {
- + make_query(update_sql);
- +}
- +
- +
- +void MysqlDataset::make_deletion() {
- + make_query(delete_sql);
- +}
- +
- +void MysqlDataset::fill_fields() {
- + if ((db == NULL) || (result.record_header.size() == 0) || (result.records.size() < (unsigned int)frecno)) return;
- +
- + if (fields_object->size() == 0) // Filling columns name
- + {
- + const unsigned int ncols = result.record_header.size();
- + fields_object->resize(ncols);
- + for (unsigned int i = 0; i < ncols; i++)
- + (*fields_object)[i].props = result.record_header[i];
- + }
- +
- + //Filling result
- + if (result.records.size() != 0)
- + {
- + const sql_record *row = result.records[frecno];
- + if (row)
- + {
- + const unsigned int ncols = row->size();
- + fields_object->resize(ncols);
- + for (unsigned int i = 0; i < ncols; i++)
- + (*fields_object)[i].val = row->at(i);
- + return;
- + }
- + }
- + const unsigned int ncols = result.record_header.size();
- + fields_object->resize(ncols);
- + for (unsigned int i = 0; i < ncols; i++)
- + (*fields_object)[i].val = "";
- +}
- +
- +
- +//------------- public functions implementation -----------------//
- +//FILE* file;
- +int MysqlDataset::exec(const string &sql) {
- + if (!handle()) throw DbErrors("No Database Connection");
- + string qry = sql;
- + int res;
- + exec_res.clear();
- +
- + // enforce the "auto_increment" keyword to be appended to "integer primary key"
- + const char* toFind = "integer primary key";
- + size_t loc = qry.find(toFind);
- + if (loc != string::npos)
- + {
- + qry = qry.insert(loc + strlen(toFind), " auto_increment ");
- + }
- +
- + CLog::Log(LOGDEBUG,"Mysql execute: %s", qry.c_str());
- +
- + if (db->setErr( static_cast<MysqlDatabase *>(db)->query_with_reconnect(qry.c_str()), qry.c_str()) != MYSQL_OK)
- + {
- + throw DbErrors(db->getErrorMsg());
- + }
- + else
- + {
- + // TODO: collect results and store in exec_res
- +
- +
- + return res;
- + }
- +}
- +
- +int MysqlDataset::exec() {
- + return exec(sql);
- +}
- +
- +const void* MysqlDataset::getExecRes() {
- + return &exec_res;
- +}
- +
- +
- +bool MysqlDataset::query(const char *query) {
- + if(!handle()) throw DbErrors("No Database Connection");
- + std::string qry = query;
- + int fs = qry.find("select");
- + int fS = qry.find("SELECT");
- + if (!( fs >= 0 || fS >=0))
- + throw DbErrors("MUST be select SQL!");
- +
- + close();
- +
- + MYSQL_RES *stmt = NULL;
- +
- + if ( static_cast<MysqlDatabase*>(db)->setErr(static_cast<MysqlDatabase*>(db)->query_with_reconnect(query), query) != MYSQL_OK )
- + throw DbErrors(db->getErrorMsg());
- +
- + MYSQL* conn = handle();
- + stmt = m_MySQL.mysql_store_result(conn);
- +
- + // column headers
- + const unsigned int numColumns = m_MySQL.mysql_num_fields(stmt);
- + MYSQL_FIELD *fields = m_MySQL.mysql_fetch_fields(stmt);
- + MYSQL_ROW row;
- + result.record_header.resize(numColumns);
- + for (unsigned int i = 0; i < numColumns; i++)
- + result.record_header[i].name = fields[i].name;
- +
- + // returned rows
- + while ((row = m_MySQL.mysql_fetch_row(stmt)))
- + { // have a row of data
- + sql_record *res = new sql_record;
- + res->resize(numColumns);
- + for (unsigned int i = 0; i < numColumns; i++)
- + {
- + field_value &v = res->at(i);
- + switch (fields[i].type)
- + {
- + case MYSQL_TYPE_LONGLONG:
- + case MYSQL_TYPE_DECIMAL:
- + case MYSQL_TYPE_TINY:
- + case MYSQL_TYPE_SHORT:
- + case MYSQL_TYPE_INT24:
- + case MYSQL_TYPE_LONG:
- + if (row[i] != NULL)
- + {
- + v.set_asInt(atoi(row[i]));
- + }
- + else
- + {
- + v.set_asInt(0);
- + }
- + break;
- + case MYSQL_TYPE_FLOAT:
- + case MYSQL_TYPE_DOUBLE:
- + if (row[i] != NULL)
- + {
- + v.set_asDouble(atol(row[i]));
- + }
- + else
- + {
- + v.set_asDouble(0);
- + }
- + break;
- + case MYSQL_TYPE_STRING:
- + case MYSQL_TYPE_VAR_STRING:
- + case MYSQL_TYPE_VARCHAR:
- + if (row[i] != NULL) v.set_asString((const char *)row[i] );
- + break;
- + case MYSQL_TYPE_TINY_BLOB:
- + case MYSQL_TYPE_MEDIUM_BLOB:
- + case MYSQL_TYPE_LONG_BLOB:
- + case MYSQL_TYPE_BLOB:
- + if (row[i] != NULL) v.set_asString((const char *)row[i]);
- + break;
- + case MYSQL_TYPE_NULL:
- + default:
- + v.set_asString("");
- + v.set_isNull();
- + break;
- + }
- + }
- + result.records.push_back(res);
- + }
- + m_MySQL.mysql_free_result(stmt);
- + active = true;
- + ds_state = dsSelect;
- + this->first();
- + return true;
- +}
- +
- +bool MysqlDataset::query(const string &q) {
- + return query(q.c_str());
- +}
- +
- +void MysqlDataset::open(const string &sql) {
- + set_select_sql(sql);
- + open();
- +}
- +
- +void MysqlDataset::open() {
- + if (select_sql.size())
- + {
- + query(select_sql.c_str());
- + }
- + else
- + {
- + ds_state = dsInactive;
- + }
- +}
- +
- +void MysqlDataset::close() {
- + Dataset::close();
- + result.clear();
- + edit_object->clear();
- + fields_object->clear();
- + ds_state = dsInactive;
- + active = false;
- +}
- +
- +
- +void MysqlDataset::cancel() {
- + if ((ds_state == dsInsert) || (ds_state==dsEdit))
- + {
- + if (result.record_header.size())
- + ds_state = dsSelect;
- + else
- + ds_state = dsInactive;
- + }
- +}
- +
- +
- +int MysqlDataset::num_rows() {
- + return result.records.size();
- +}
- +
- +
- +bool MysqlDataset::eof() {
- + return feof;
- +}
- +
- +
- +bool MysqlDataset::bof() {
- + return fbof;
- +}
- +
- +
- +void MysqlDataset::first() {
- + Dataset::first();
- + this->fill_fields();
- +}
- +
- +void MysqlDataset::last() {
- + Dataset::last();
- + fill_fields();
- +}
- +
- +void MysqlDataset::prev(void) {
- + Dataset::prev();
- + fill_fields();
- +}
- +
- +void MysqlDataset::next(void) {
- +#ifdef _XBOX
- + free_row();
- +#endif
- + Dataset::next();
- + if (!eof())
- + fill_fields();
- +}
- +
- +void MysqlDataset::free_row(void)
- +{
- + if (frecno < 0 || (unsigned int)frecno >= result.records.size())
- + return;
- +
- + sql_record *row = result.records[frecno];
- + if (row)
- + {
- + delete row;
- + result.records[frecno] = NULL;
- + }
- +}
- +
- +bool MysqlDataset::seek(int pos) {
- + if (ds_state == dsSelect)
- + {
- + Dataset::seek(pos);
- + fill_fields();
- + return true;
- + }
- +
- + return false;
- +}
- +
- +int64_t MysqlDataset::lastinsertid() {
- + if (!handle()) DbErrors("No Database Connection");
- + return m_MySQL.mysql_insert_id(handle());
- +}
- +
- +long MysqlDataset::nextid(const char *seq_name) {
- + if (handle())
- + return db->nextid(seq_name);
- +
- + return DB_UNEXPECTED_RESULT;
- +}
- +
- +void MysqlDataset::interrupt() {
- + // Impossible
- +}
- +
- +}//namespace
- Index: xbmc/lib/sqLite/mysqldataset.h
- ===================================================================
- --- xbmc/lib/sqLite/mysqldataset.h (revision 0)
- +++ xbmc/lib/sqLite/mysqldataset.h (working copy)
- @@ -0,0 +1,175 @@
- +/*
- + * Copyright (C) 2005-2009 Team XBMC
- + * http://xbmc.org
- + *
- + * This Program is free software; you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation; either version 2, or (at your option)
- + * any later version.
- + *
- + * This Program is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + * GNU General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with XBMC; see the file COPYING. If not, write to
- + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- + * http://www.gnu.org/copyleft/gpl.html
- + *
- + */
- +
- +#ifndef _MYSQLDATASET_H
- +#define _MYSQLDATASET_H
- +#include <stdio.h>
- +#include "dataset.h"
- +#ifdef _MSC_VER
- +#ifdef _XBOX
- +#include <xtl.h>
- +#include <winsockx.h>
- +#else
- +#include <winsock2.h>
- +#endif
- +#define SHUT_RDWR SD_BOTH
- +#define ETIMEDOUT WSAETIMEDOUT
- +#else
- +#include <netinet/in.h>
- +#include <netinet/tcp.h>
- +#endif
- +#include "DllLibMySQL.h"
- +
- +namespace dbiplus {
- +/***************** Class MysqlDatabase definition ******************
- +
- + class 'MysqlDatabase' connects with MySQL-server
- +
- +******************************************************************/
- +class MysqlDatabase: public Database {
- +protected:
- +/* connect descriptor */
- + MYSQL* conn;
- + bool _in_transaction;
- + int last_err;
- + DllLibMySQL m_MySQL;
- +
- +
- +public:
- +/* default constructor */
- + MysqlDatabase();
- +/* destructor */
- + ~MysqlDatabase();
- +
- + Dataset *CreateDataset() const;
- +
- +/* func. returns connection handle with MySQL-server */
- + MYSQL *getHandle() { return conn; }
- +/* func. returns current status about MySQL-server connection */
- + virtual int status();
- + virtual int setErr(int err_code,const char * qry);
- +/* func. returns error message if error occurs */
- + virtual const char *getErrorMsg();
- +
- +/* func. connects to database-server */
- + virtual int connect();
- +/* func. disconnects from database-server */
- + virtual void disconnect();
- +/* func. creates new database */
- + virtual int create();
- +/* func. deletes database */
- + virtual int drop();
- +/* check if database exists (ie has tables/views defined) */
- + virtual bool exists();
- +
- + virtual long nextid(const char* seq_name);
- +
- +/* virtual methods for transaction */
- +
- + virtual void start_transaction();
- + virtual void commit_transaction();
- + virtual void rollback_transaction();
- +
- + bool in_transaction() {return _in_transaction;};
- + int query_with_reconnect(const char* query);
- +};
- +
- +
- +
- +/***************** Class MysqlDataset definition *******************
- +
- + class 'MysqlDataset' does a query to MySQL-server
- +
- +******************************************************************/
- +
- +class MysqlDataset : public Dataset {
- +protected:
- +/* query results*/
- + result_set result;
- + result_set exec_res;
- + bool autorefresh;
- + char* errmsg;
- + DllLibMySQL m_MySQL;
- + MYSQL* handle();
- +
- +/* Makes direct queries to database */
- + virtual void make_query(StringList &_sql);
- +/* Makes direct inserts into database */
- + virtual void make_insert();
- +/* Edit SQL */
- + virtual void make_edit();
- +/* Delete SQL */
- + virtual void make_deletion();
- +
- +
- +/* This function works only with MySQL database
- + Filling the fields information from select statement */
- + virtual void fill_fields();
- +/* Changing field values during dataset navigation */
- + virtual void free_row(); // free the memory allocated for the current row
- +
- +public:
- +/* constructor */
- + MysqlDataset();
- + MysqlDataset(MysqlDatabase *newDb);
- +
- +/* destructor */
- + ~MysqlDataset();
- +
- +/* set autorefresh boolean value (if true - refresh the data after edit()
- +or insert() operations default = false) */
- + void set_autorefresh(bool val);
- +
- +/* opens a query & then sets a query results */
- + virtual void open();
- + virtual void open(const std::string &sql);
- +/* func. executes a query without results to return */
- + virtual int exec ();
- + virtual int exec (const std::string &sql);
- + virtual const void* getExecRes();
- +/* as open, but with our query exept Sql */
- + virtual bool query(const char *query);
- + virtual bool query(const std::string &query);
- +/* func. closes a query */
- + virtual void close(void);
- +/* Cancel changes, made in insert or edit states of dataset */
- + virtual void cancel();
- +/* last insert id */
- + virtual int64_t lastinsertid();
- +/* sequence numbers */
- + virtual long nextid(const char *seq_name);
- +/* sequence numbers */
- + virtual int num_rows();
- +/* interupt any pending database operation */
- + virtual void interrupt();
- +
- + virtual bool bof();
- + virtual bool eof();
- + virtual void first();
- + virtual void last();
- + virtual void prev();
- + virtual void next();
- +/* Go to record No (starting with 0) */
- + virtual bool seek(int pos=0);
- +
- +};
- +} //namespace
- +#endif
- \ No newline at end of file
- Index: xbmc/lib/sqLite/sqlitedataset.cpp
- ===================================================================
- --- xbmc/lib/sqLite/sqlitedataset.cpp (revision 30970)
- +++ xbmc/lib/sqLite/sqlitedataset.cpp (working copy)
- @@ -168,24 +168,57 @@
- }
- int SqliteDatabase::connect() {
- - try {
- + string db_fullpath;
- + size_t pos = 0;
- +
- + // hostname is the relative folder to the database, ensure it's slash terminated
- + if (host[host.length()-1] != '/' && host[host.length()-1] != '\\')
- + db_fullpath = host + "/";
- + else
- + db_fullpath = host;
- +
- + // db is the filename for the database, ensure it's not slash prefixed
- + if (db[0] == '/' || db[0] == '\\')
- + db_fullpath += db.substr(1);
- + else
- + db_fullpath += db;
- +
- + // ensure the fully qualified path has slashes in the correct direction
- + if ( (db_fullpath[1] == ':') && string("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz").find(db_fullpath[0]) > 0)
- + {
- + while ( (pos = db_fullpath.find("/", pos)) != string::npos )
- + db_fullpath.replace(pos++, 1, "\\");
- + }
- + else
- + {
- + while ( (pos = db_fullpath.find("\\", pos)) != string::npos )
- + db_fullpath.replace(pos++, 1, "/");
- + }
- +
- + // ensure the ".db" extension is appended to the end
- + if ( db_fullpath.find(".db") != (db_fullpath.length()-3) )
- + db_fullpath += ".db";
- +
- + try
- + {
- disconnect();
- - if (sqlite3_open(db.c_str(),&conn/*,NULL*/)==SQLITE_OK) {
- - //cout << "Connected!\n";
- - sqlite3_busy_handler(conn, busy_callback,NULL);
- + if (sqlite3_open(db_fullpath.c_str(), &conn)==SQLITE_OK)
- + {
- + sqlite3_busy_handler(conn, busy_callback, NULL);
- char* err=NULL;
- - if (setErr(sqlite3_exec(getHandle(),"PRAGMA empty_result_callbacks=ON",NULL,NULL,&err),"PRAGMA empty_result_callbacks=ON") != SQLITE_OK) {
- + if (setErr(sqlite3_exec(getHandle(),"PRAGMA empty_result_callbacks=ON",NULL,NULL,&err),"PRAGMA empty_result_callbacks=ON") != SQLITE_OK)
- + {
- throw DbErrors(getErrorMsg());
- }
- active = true;
- return DB_CONNECTION_OK;
- }
- - CLog::Log(LOGERROR, "Unable to open database: %s (%lu)", db.c_str(),GetLastError());
- + CLog::Log(LOGERROR, "unable to open database:%s (%u)", db_fullpath.c_str(), GetLastError());
- return DB_CONNECTION_NONE;
- }
- catch(...)
- {
- - CLog::Log(LOGERROR, "Unable to open database: %s (%lu)", db.c_str(),GetLastError());
- + CLog::Log(LOGERROR, "Unable to open database: %s (%lu)", db_fullpath.c_str(),GetLastError());
- }
- return DB_CONNECTION_NONE;
- }
- Index: xbmc/MusicDatabase.cpp
- ===================================================================
- --- xbmc/MusicDatabase.cpp (revision 30970)
- +++ xbmc/MusicDatabase.cpp (working copy)
- @@ -54,7 +54,7 @@
- using namespace MUSICDATABASEDIRECTORY;
- using namespace MEDIA_DETECT;
- -#define MUSIC_DATABASE_NAME "MyMusic7.db"
- +#define MUSIC_DATABASE_NAME "MyMusic7"
- #define RECENTLY_PLAYED_LIMIT 25
- #define MIN_FULL_SEARCH_LENGTH 3
- @@ -62,7 +62,7 @@
- CMusicDatabase::CMusicDatabase(void)
- {
- - m_strDatabaseFile=MUSIC_DATABASE_NAME;
- + m_strDefaultDatabaseName=MUSIC_DATABASE_NAME;
- }
- CMusicDatabase::~CMusicDatabase(void)
- @@ -70,6 +70,12 @@
- EmptyCache();
- }
- +bool CMusicDatabase::Open()
- +{
- + return CDatabase::Open(g_advancedSettings.m_databaseMusic);
- +}
- +
- +
- bool CMusicDatabase::CreateTables()
- {
- BeginTransaction();
- @@ -78,21 +84,21 @@
- CDatabase::CreateTables();
- CLog::Log(LOGINFO, "create artist table");
- - m_pDS->exec("CREATE TABLE artist ( idArtist integer primary key, strArtist text)\n");
- + m_pDS->exec("CREATE TABLE artist ( idArtist integer primary key, strArtist varchar(256))\n");
- CLog::Log(LOGINFO, "create album table");
- - m_pDS->exec("CREATE TABLE album ( idAlbum integer primary key, strAlbum text, idArtist integer, strExtraArtists text, idGenre integer, strExtraGenres text, iYear integer, idThumb integer)\n");
- + m_pDS->exec("CREATE TABLE album ( idAlbum integer primary key, strAlbum varchar(256), idArtist integer, strExtraArtists text, idGenre integer, strExtraGenres text, iYear integer, idThumb integer)\n");
- CLog::Log(LOGINFO, "create genre table");
- - m_pDS->exec("CREATE TABLE genre ( idGenre integer primary key, strGenre text)\n");
- + m_pDS->exec("CREATE TABLE genre ( idGenre integer primary key, strGenre varchar(256))\n");
- CLog::Log(LOGINFO, "create path table");
- - m_pDS->exec("CREATE TABLE path ( idPath integer primary key, strPath text, strHash text)\n");
- + m_pDS->exec("CREATE TABLE path ( idPath integer primary key, strPath varchar(512), strHash text)\n");
- CLog::Log(LOGINFO, "create song table");
- - m_pDS->exec("CREATE TABLE song ( idSong integer primary key, idAlbum integer, idPath integer, idArtist integer, strExtraArtists text, idGenre integer, strExtraGenres text, strTitle text, iTrack integer, iDuration integer, iYear integer, dwFileNameCRC text, strFileName text, strMusicBrainzTrackID text, strMusicBrainzArtistID text, strMusicBrainzAlbumID text, strMusicBrainzAlbumArtistID text, strMusicBrainzTRMID text, iTimesPlayed integer, iStartOffset integer, iEndOffset integer, idThumb integer, lastplayed text default NULL, rating char default '0', comment text)\n");
- + m_pDS->exec("CREATE TABLE song ( idSong integer primary key, idAlbum integer, idPath integer, idArtist integer, strExtraArtists text, idGenre integer, strExtraGenres text, strTitle varchar(512), iTrack integer, iDuration integer, iYear integer, dwFileNameCRC text, strFileName text, strMusicBrainzTrackID text, strMusicBrainzArtistID text, strMusicBrainzAlbumID text, strMusicBrainzAlbumArtistID text, strMusicBrainzTRMID text, iTimesPlayed integer, iStartOffset integer, iEndOffset integer, idThumb integer, lastplayed text default NULL, rating char default '0', comment text)\n");
- CLog::Log(LOGINFO, "create albuminfo table");
- m_pDS->exec("CREATE TABLE albuminfo ( idAlbumInfo integer primary key, idAlbum integer, iYear integer, idGenre integer, strExtraGenres text, strMoods text, strStyles text, strThemes text, strReview text, strImage text, strLabel text, strType text, iRating integer)\n");
- CLog::Log(LOGINFO, "create albuminfosong table");
- m_pDS->exec("CREATE TABLE albuminfosong ( idAlbumInfoSong integer primary key, idAlbumInfo integer, iTrack integer, strTitle text, iDuration integer)\n");
- CLog::Log(LOGINFO, "create thumb table");
- - m_pDS->exec("CREATE TABLE thumb (idThumb integer primary key, strThumb text)\n");
- + m_pDS->exec("CREATE TABLE thumb (idThumb integer primary key, strThumb varchar(256))\n");
- CLog::Log(LOGINFO, "create artistnfo table");
- m_pDS->exec("CREATE TABLE artistinfo ( idArtistInfo integer primary key, idArtist integer, strBorn text, strFormed text, strGenres text, strMoods text, strStyles text, strInstruments text, strBiography text, strDied text, strDisbanded text, strYearsActive text, strImage text, strFanart text)\n");
- CLog::Log(LOGINFO, "create content table");
- @@ -1340,7 +1346,7 @@
- if (NULL == m_pDS.get()) return false;
- CStdString strSQL;
- - strSQL.Format("select distinct albumview.* from song join albumview on albumview.idAlbum=song.idAlbum where song.lastplayed NOT NULL order by song.lastplayed desc limit %i", RECENTLY_PLAYED_LIMIT);
- + strSQL.Format("select distinct albumview.* from song join albumview on albumview.idAlbum=song.idAlbum where song.lastplayed IS NOT NULL order by song.lastplayed desc limit %i", RECENTLY_PLAYED_LIMIT);
- CLog::Log(LOGDEBUG, "%s query: %s", __FUNCTION__, strSQL.c_str());
- if (!m_pDS->query(strSQL.c_str())) return false;
- int iRowsFound = m_pDS->num_rows();
- @@ -1374,7 +1380,7 @@
- if (NULL == m_pDS.get()) return false;
- CStdString strSQL;
- - strSQL.Format("select * from songview join albumview on (songview.idAlbum = albumview.idAlbum) where albumview.idalbum in (select distinct albumview.idalbum from albumview join song on albumview.idAlbum=song.idAlbum where song.lastplayed NOT NULL order by song.lastplayed desc limit %i)", g_advancedSettings.m_iMusicLibraryRecentlyAddedItems);
- + strSQL.Format("select * from songview join albumview on (songview.idAlbum = albumview.idAlbum) where albumview.idalbum in (select distinct albumview.idalbum from albumview join song on albumview.idAlbum=song.idAlbum where song.lastplayed IS NOT NULL order by song.lastplayed desc limit %i)", g_advancedSettings.m_iMusicLibraryRecentlyAddedItems);
- CLog::Log(LOGDEBUG,"GetRecentlyPlayedAlbumSongs() query: %s", strSQL.c_str());
- if (!m_pDS->query(strSQL.c_str())) return false;
- @@ -1936,7 +1942,7 @@
- // but we must keep all paths that have been scanned that may contain songs in subpaths
- // first create a temporary table of song paths
- - m_pDS->exec("CREATE TEMPORARY TABLE songpaths (idPath integer, strPath)\n");
- + m_pDS->exec("CREATE TEMPORARY TABLE songpaths (idPath integer, strPath varchar(512))\n");
- m_pDS->exec("INSERT INTO songpaths select idPath,strPath from path where idPath in (select idPath from song)\n");
- // grab all paths that aren't immediately connected with a song
- Index: xbmc/MusicDatabase.h
- ===================================================================
- --- xbmc/MusicDatabase.h (revision 30970)
- +++ xbmc/MusicDatabase.h (working copy)
- @@ -112,6 +112,7 @@
- public:
- CMusicDatabase(void);
- virtual ~CMusicDatabase(void);
- + virtual bool Open();
- virtual bool CommitTransaction();
- void EmptyCache();
- Index: xbmc/ProgramDatabase.cpp
- ===================================================================
- --- xbmc/ProgramDatabase.cpp (revision 30970)
- +++ xbmc/ProgramDatabase.cpp (working copy)
- @@ -32,7 +32,7 @@
- //********************************************************************************************************************************
- CProgramDatabase::CProgramDatabase(void)
- {
- - m_strDatabaseFile=PROGRAM_DATABASE_NAME;
- + m_strDefaultDatabaseName=PROGRAM_DATABASE_NAME;
- }
- //********************************************************************************************************************************
- @@ -42,6 +42,11 @@
- }
- //********************************************************************************************************************************
- +bool CProgramDatabase::Open()
- +{
- + return CDatabase::Open();
- +}
- +
- bool CProgramDatabase::CreateTables()
- {
- Index: xbmc/ProgramDatabase.h
- ===================================================================
- --- xbmc/ProgramDatabase.h (revision 30970)
- +++ xbmc/ProgramDatabase.h (working copy)
- @@ -26,13 +26,15 @@
- #define COMPARE_PERCENTAGE 0.90f // 90%
- #define COMPARE_PERCENTAGE_MIN 0.50f // 50%
- -#define PROGRAM_DATABASE_NAME "MyPrograms6.db"
- +#define PROGRAM_DATABASE_NAME "MyPrograms6"
- class CProgramDatabase : public CDatabase
- {
- public:
- CProgramDatabase(void);
- virtual ~CProgramDatabase(void);
- + virtual bool Open();
- +
- bool AddTrainer(int iTitleId, const CStdString& strText);
- bool RemoveTrainer(const CStdString& strText);
- bool GetTrainers(unsigned int iTitleId, std::vector<CStdString>& vecTrainers);
- Index: xbmc/VideoDatabase.cpp
- ===================================================================
- --- xbmc/VideoDatabase.cpp (revision 30970)
- +++ xbmc/VideoDatabase.cpp (working copy)
- @@ -1,23 +1,23 @@
- /*
- - * Copyright (C) 2005-2008 Team XBMC
- - * http://www.xbmc.org
- - *
- - * This Program is free software; you can redistribute it and/or modify
- - * it under the terms of the GNU General Public License as published by
- - * the Free Software Foundation; either version 2, or (at your option)
- - * any later version.
- - *
- - * This Program is distributed in the hope that it will be useful,
- - * but WITHOUT ANY WARRANTY; without even the implied warranty of
- - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- - * GNU General Public License for more details.
- - *
- - * You should have received a copy of the GNU General Public License
- - * along with XBMC; see the file COPYING. If not, write to
- - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- - * http://www.gnu.org/copyleft/gpl.html
- - *
- - */
- +* Copyright (C) 2005-2008 Team XBMC
- +* http://www.xbmc.org
- +*
- +* This Program is free software; you can redistribute it and/or modify
- +* it under the terms of the GNU General Public License as published by
- +* the Free Software Foundation; either version 2, or (at your option)
- +* any later version.
- +*
- +* This Program is distributed in the hope that it will be useful,
- +* but WITHOUT ANY WARRANTY; without even the implied warranty of
- +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- +* GNU General Public License for more details.
- +*
- +* You should have received a copy of the GNU General Public License
- +* along with XBMC; see the file COPYING. If not, write to
- +* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- +* http://www.gnu.org/copyleft/gpl.html
- +*
- +*/
- #include "stdafx.h"
- #include "VideoDatabase.h"
- @@ -45,16 +45,35 @@
- using namespace DIRECTORY;
- using namespace VIDEO;
- +#define VIDEO_DATABASE_NAME "MyVideos34"
- +#define VIDEO_DATABASE_VIEW_TVSHOW "SELECT tvshow.*,path.strPath AS strPath," \
- + "counts.totalcount AS totalCount,counts.watchedcount AS watchedCount," \
- + "counts.totalcount=counts.watchedcount AS watched FROM tvshow " \
- + "JOIN tvshowlinkpath ON tvshow.idShow=tvshowlinkpath.idShow " \
- + "JOIN path ON path.idPath=tvshowlinkpath.idPath " \
- + "LEFT OUTER join (" \
- + " SELECT tvshow.idShow AS idShow,count(1) AS totalcount,count(files.playCount) AS watchedcount FROM tvshow " \
- + " JOIN tvshowlinkepisode ON tvshow.idShow=tvshowlinkepisode.idShow " \
- + " JOIN episode ON episode.idEpisode=tvshowlinkepisode.idEpisode " \
- + " JOIN files ON files.idFile=episode.idFile " \
- + " GROUP BY tvshow.idShow" \
- + ") counts ON tvshow.idShow=counts.idShow "
- +
- //********************************************************************************************************************************
- CVideoDatabase::CVideoDatabase(void)
- {
- - m_strDatabaseFile=GetDefaultDBName();
- + m_strDefaultDatabaseName=VIDEO_DATABASE_NAME;
- }
- //********************************************************************************************************************************
- CVideoDatabase::~CVideoDatabase(void)
- {}
- +bool CVideoDatabase::Open()
- +{
- + return CDatabase::Open(g_advancedSettings.m_databaseVideo);
- +}
- +
- //********************************************************************************************************************************
- bool CVideoDatabase::CreateTables()
- {
- @@ -130,11 +149,11 @@
- m_pDS->exec("CREATE TABLE actors ( idActor integer primary key, strActor text, strThumb text )\n");
- CLog::Log(LOGINFO, "create path table");
- - m_pDS->exec("CREATE TABLE path ( idPath integer primary key, strPath text, strContent text, strScraper text, strHash text, scanRecursive integer, useFolderNames bool, strSettings text, noUpdate bool)\n");
- + m_pDS->exec("CREATE TABLE path ( idPath integer primary key, strPath varchar(512), strContent text, strScraper text, strHash text, scanRecursive integer, useFolderNames bool, strSettings text, noUpdate bool)\n");
- m_pDS->exec("CREATE UNIQUE INDEX ix_path ON path ( strPath )\n");
- CLog::Log(LOGINFO, "create files table");
- - m_pDS->exec("CREATE TABLE files ( idFile integer primary key, idPath integer, strFilename text, playCount integer, lastPlayed text)\n");
- + m_pDS->exec("CREATE TABLE files ( idFile integer primary key, idPath integer, strFilename varchar(512), playCount integer, lastPlayed text)\n");
- m_pDS->exec("CREATE UNIQUE INDEX ix_files ON files ( idPath, strFilename )\n");
- CLog::Log(LOGINFO, "create tvshow table");
- @@ -142,6 +161,9 @@
- for (int i = 0; i < VIDEODB_MAX_COLUMNS; i++)
- {
- CStdString column;
- + if ( i == VIDEODB_ID_EPISODE_SEASON || i == VIDEODB_ID_EPISODE_EPISODE || i == VIDEODB_ID_EPISODE_BOOKMARK)
- + column.Format(",c%02d varchar(24)", i);
- + else
- column.Format(",c%02d text", i);
- columns += column;
- }
- @@ -263,28 +285,13 @@
- "strAudioCodec text, iAudioChannels integer, strAudioLanguage text, strSubtitleLanguage text, iVideoDuration integer)");
- m_pDS->exec("CREATE INDEX ix_streamdetails ON streamdetails (idFile)");
- - CLog::Log(LOGINFO, "create tvshowview");
- - CStdString showview=FormatSQL("create view tvshowview as select tvshow.*,path.strPath as strPath,"
- - "counts.totalcount as totalCount,counts.watchedcount as watchedCount,"
- - "counts.totalcount=counts.watchedcount as watched from tvshow "
- - "join tvshowlinkpath on tvshow.idShow=tvshowlinkpath.idShow "
- - "join path on path.idpath=tvshowlinkpath.idPath "
- - "left outer join ("
- - " select tvshow.idShow as idShow,count(1) as totalcount,count(files.playCount) as watchedcount from tvshow "
- - " join tvshowlinkepisode on tvshow.idShow = tvshowlinkepisode.idShow "
- - " join episode on episode.idEpisode = tvshowlinkepisode.idEpisode "
- - " join files on files.idFile = episode.idFile "
- - " group by tvshow.idShow"
- - ") counts on tvshow.idShow = counts.idShow");
- - m_pDS->exec(showview.c_str());
- -
- CLog::Log(LOGINFO, "create episodeview");
- CStdString episodeview = FormatSQL("create view episodeview as select episode.*,files.strFileName as strFileName,"
- "path.strPath as strPath,files.playCount as playCount,files.lastPlayed as lastPlayed,tvshow.c%02d as strTitle,tvshow.c%02d as strStudio,tvshow.idShow as idShow,"
- "tvshow.c%02d as premiered, tvshow.c%02d as mpaa from episode "
- "join files on files.idFile=episode.idFile "
- - "join tvshowlinkepisode on episode.idepisode=tvshowlinkepisode.idepisode "
- - "join tvshow on tvshow.idshow=tvshowlinkepisode.idshow "
- + "join tvshowlinkepisode on episode.idEpisode=tvshowlinkepisode.idEpisode "
- + "join tvshow on tvshow.idShow=tvshowlinkepisode.idShow "
- "join path on files.idPath=path.idPath",VIDEODB_ID_TV_TITLE, VIDEODB_ID_TV_STUDIOS, VIDEODB_ID_TV_PREMIERED, VIDEODB_ID_TV_MPAA);
- m_pDS->exec(episodeview.c_str());
- @@ -383,7 +390,7 @@
- // then grab all tvshow paths
- if (!m_pDS->query("select strPath,scanRecursive,useFolderNames,strContent,noUpdate from path"
- " where ( strContent = 'tvshows'"
- - " or idPath in (select idpath from tvshowlinkpath))"
- + " or idPath in (select idPath from tvshowlinkpath))"
- " and strPath NOT like 'multipath://%%'"
- " order by strPath"))
- return false;
- @@ -419,8 +426,8 @@
- // not making mistakes must take priority
- if (!m_pDS->query("select strPath,noUpdate from path"
- " where idPath in (select idPath from files join movie on movie.idFile=files.idFile)"
- - " and idPath NOT in (select idpath from tvshowlinkpath)"
- - " and idPath NOT in (select idpath from files where strFileName like 'video_ts.ifo')" // dvdfolders get stacked to a single item in parent folder
- + " and idPath NOT in (select idPath from tvshowlinkpath)"
- + " and idPath NOT in (select idPath from files where strFileName like 'video_ts.ifo')" // dvdfolders get stacked to a single item in parent folder
- " and strPath NOT like 'multipath://%%'"
- " and strContent NOT in ('movies', 'tvshows', 'None')" // these have been added above
- " order by strPath"))
- @@ -457,7 +464,7 @@
- {
- if (NULL == m_pDB.get()) return false;
- if (NULL == m_pDS.get()) return false;
- - strSQL = FormatSQL("select distinct path.idPath from path,tvshowlinkepisode join episode on tvshowlinkepisode.idEpisode=episode.idEpisode join files on files.idPath=path.idPath where episode.idFile = files.idFile and tvshowlinkepisode.idShow=%i",idShow);
- + strSQL = FormatSQL("SELECT DISTINCT idPath FROM files JOIN episode ON episode.idFile=files.idFile JOIN tvshowlinkepisode ON tvshowlinkepisode.idEpisode=episode.idEpisode WHERE tvshowlinkepisode.idShow=%i",idShow);
- m_pDS->query(strSQL.c_str());
- while (!m_pDS->eof())
- {
- @@ -750,7 +757,7 @@
- CStdString strSQL;
- if (idFile == -1)
- - strSQL=FormatSQL("select idMovie from movie join files on files.idFile=movie.idFile where files.idpath = %i",idPath);
- + strSQL=FormatSQL("select idMovie from movie join files on files.idFile=movie.idFile where files.idPath=%i",idPath);
- else
- strSQL=FormatSQL("select idMovie from movie where idFile=%i", idFile);
- @@ -794,7 +801,7 @@
- while (iFound == 0 && CUtil::GetParentPath(strPath1, strParent))
- {
- - strSQL=FormatSQL("select idShow from path,tvshowlinkpath where tvshowlinkpath.idpath = path.idpath and strPath like '%s'",strParent.c_str());
- + strSQL=FormatSQL("select idShow from path,tvshowlinkpath where tvshowlinkpath.idPath=path.idPath and strPath like '%s'",strParent.c_str());
- m_pDS->query(strSQL.c_str());
- if (!m_pDS->eof())
- {
- @@ -920,7 +927,7 @@
- CStdString strSQL=FormatSQL("insert into movie (idMovie, idFile) values (NULL, %i)", idFile);
- m_pDS->exec(strSQL.c_str());
- idMovie = (int)m_pDS->lastinsertid();
- -// CommitTransaction();
- + // CommitTransaction();
- }
- return idMovie;
- @@ -939,7 +946,7 @@
- if (NULL == m_pDB.get()) return -1;
- if (NULL == m_pDS.get()) return -1;
- - CStdString strSQL=FormatSQL("select tvshowlinkpath.idShow from path,tvshowlinkpath where path.strPath like '%s' and path.idPath = tvshowlinkpath.idPath",strPath.c_str());
- + CStdString strSQL=FormatSQL("select tvshowlinkpath.idShow from path,tvshowlinkpath where path.strPath like '%s' and path.idPath=tvshowlinkpath.idPath",strPath.c_str());
- m_pDS->query(strSQL.c_str());
- if (m_pDS->num_rows() != 0)
- return m_pDS->fv("tvshowlinkpath.idShow").get_asInt();
- @@ -954,7 +961,7 @@
- strSQL=FormatSQL("insert into tvshowlinkpath values (%i,%i)",idTvShow,idPath);
- m_pDS->exec(strSQL.c_str());
- -// CommitTransaction();
- + // CommitTransaction();
- return idTvShow;
- }
- @@ -983,7 +990,7 @@
- strSQL=FormatSQL("insert into tvshowlinkepisode (idShow,idEpisode) values (%i,%i)",idShow,idEpisode);
- m_pDS->exec(strSQL.c_str());
- -// CommitTransaction();
- + // CommitTransaction();
- return idEpisode;
- }
- @@ -1370,16 +1377,16 @@
- DeleteThumbForItem(strPath,true);
- CStdString strSQL;
- - strSQL=FormatSQL("delete from genrelinktvshow where idshow=%i", idTvShow);
- + strSQL=FormatSQL("delete from genrelinktvshow where idShow=%i", idTvShow);
- m_pDS->exec(strSQL.c_str());
- - strSQL=FormatSQL("delete from actorlinktvshow where idshow=%i", idTvShow);
- + strSQL=FormatSQL("delete from actorlinktvshow where idShow=%i", idTvShow);
- m_pDS->exec(strSQL.c_str());
- - strSQL=FormatSQL("delete from directorlinktvshow where idshow=%i", idTvShow);
- + strSQL=FormatSQL("delete from directorlinktvshow where idShow=%i", idTvShow);
- m_pDS->exec(strSQL.c_str());
- - strSQL=FormatSQL("delete from studiolinktvshow where idshow=%i", idTvShow);
- + strSQL=FormatSQL("delete from studiolinktvshow where idShow=%i", idTvShow);
- m_pDS->exec(strSQL.c_str());
- // remove all info other than the id
- @@ -1405,23 +1412,23 @@
- void CVideoDatabase::GetMoviesByActor(const CStdString& strActor, CFileItemList& items)
- {
- CStdString where;
- - where.Format("join actorlinkmovie on actorlinkmovie.idmovie=movieview.idmovie join actors on actors.idActor=actorlinkmovie.idActor where actors.stractor='%s'", strActor.c_str());
- + where.Format("join actorlinkmovie on actorlinkmovie.idMovie=movieview.idMovie join actors on actors.idActor=actorlinkmovie.idActor where actors.strActor='%s'", strActor.c_str());
- GetMoviesByWhere("videodb://1/2/", where, "", items);
- }
- void CVideoDatabase::GetTvShowsByActor(const CStdString& strActor, CFileItemList& items)
- {
- - CStdString where = FormatSQL("join actorlinktvshow on actorlinktvshow.idshow=tvshowview.idshow "
- + CStdString where = FormatSQL("join actorlinktvshow on actorlinktvshow.idShow=tvshowview.idShow "
- "join actors on actors.idActor=actorlinktvshow.idActor "
- - "where actors.stractor='%s'", strActor.c_str());
- + "where actors.strActor='%s'", strActor.c_str());
- GetTvShowsByWhere("videodb://2/2/", where, items);
- }
- void CVideoDatabase::GetEpisodesByActor(const CStdString& strActor, CFileItemList& items)
- {
- - CStdString where = FormatSQL("join actorlinkepisode on actorlinkepisode.idepisode=episodeview.idepisode "
- + CStdString where = FormatSQL("join actorlinkepisode on actorlinkepisode.idEpisode=episodeview.idEpisode "
- "join actors on actors.idActor=actorlinkepisode.idActor "
- - "where actors.stractor='%s'", strActor.c_str());
- + "where actors.strActor='%s'", strActor.c_str());
- GetEpisodesByWhere("videodb://2/2/", where, items);
- }
- @@ -1435,9 +1442,9 @@
- CStdString strSQL;
- if (strArtist.IsEmpty()) // TODO: SMARTPLAYLISTS what is this here for???
- - strSQL=FormatSQL("select distinct * from musicvideoview join artistlinkmusicvideo on artistlinkmusicvideo.idmvideo=musicvideoview.idmvideo join actors on actors.idActor=artistlinkmusicvideo.idArtist");
- + strSQL=FormatSQL("select distinct * from musicvideoview join artistlinkmusicvideo on artistlinkmusicvideo.idMVideo=musicvideoview.idMVideo join actors on actors.idActor=artistlinkmusicvideo.idArtist");
- else
- - strSQL=FormatSQL("select * from musicvideoview join artistlinkmusicvideo on artistlinkmusicvideo.idmvideo=musicvideoview.idmvideo join actors on actors.idActor=artistlinkmusicvideo.idArtist where actors.stractor='%s'", strArtist.c_str());
- + strSQL=FormatSQL("select * from musicvideoview join artistlinkmusicvideo on artistlinkmusicvideo.idMVideo=musicvideoview.idMVideo join actors on actors.idActor=artistlinkmusicvideo.idArtist where actors.strActor='%s'", strArtist.c_str());
- m_pDS->query( strSQL.c_str() );
- while (!m_pDS->eof())
- @@ -1486,7 +1493,7 @@
- idTvShow = GetTvShowId(strPath);
- if (idTvShow < 0) return ;
- - CStdString sql = FormatSQL("select * from tvshowview where idshow=%i", idTvShow);
- + CStdString sql = FormatSQL(VIDEO_DATABASE_VIEW_TVSHOW " where idShow=%i", idTvShow);
- if (!m_pDS->query(sql.c_str()))
- return;
- details = GetDetailsForTvShow(m_pDS, true);
- @@ -1506,7 +1513,7 @@
- idEpisode = GetEpisodeId(strFilenameAndPath);
- if (idEpisode < 0) return false;
- - CStdString sql = FormatSQL("select * from episodeview where idepisode=%i",idEpisode);
- + CStdString sql = FormatSQL("select * from episodeview where idEpisode=%i",idEpisode);
- if (!m_pDS->query(sql.c_str()))
- return false;
- details = GetDetailsForEpisode(m_pDS, true);
- @@ -1528,7 +1535,7 @@
- idMVideo = GetMusicVideoId(strFilenameAndPath);
- if (idMVideo < 0) return ;
- - CStdString sql = FormatSQL("select * from musicvideoview where idmvideo=%i", idMVideo);
- + CStdString sql = FormatSQL("select * from musicvideoview where idMVideo=%i", idMVideo);
- if (!m_pDS->query(sql.c_str()))
- return;
- details = GetDetailsForMusicVideo(m_pDS);
- @@ -1685,7 +1692,7 @@
- AddSetToMovie(idMovie, idSet);
- }
- }
- -
- +
- if (details.HasStreamDetails())
- SetStreamDetailsForFileId(details.m_streamDetails, GetFileId(strFilenameAndPath));
- @@ -1975,9 +1982,9 @@
- if (iType == VIDEODB_CONTENT_EPISODES)
- strSQL=FormatSQL("select path.strPath,files.strFileName from path, files, episode where path.idPath=files.idPath and files.idFile=episode.idFile and episode.idEpisode=%i order by strFilename", idMovie );
- if (iType == VIDEODB_CONTENT_TVSHOWS)
- - strSQL=FormatSQL("select path.strPath from path,tvshowlinkpath where path.idpath=tvshowlinkpath.idpath and tvshowlinkpath.idshow=%i", idMovie );
- + strSQL=FormatSQL("select path.strPath from path,tvshowlinkpath where path.idPath=tvshowlinkpath.idPath and tvshowlinkpath.idShow=%i", idMovie );
- if (iType ==VIDEODB_CONTENT_MUSICVIDEOS)
- - strSQL=FormatSQL("select path.strPath,files.strFileName from path, files, musicvideo where path.idPath=files.idPath and files.idFile=musicvideo.idFile and musicvideo.idmvideo=%i order by strFilename", idMovie );
- + strSQL=FormatSQL("select path.strPath,files.strFileName from path, files, musicvideo where path.idPath=files.idPath and files.idFile=musicvideo.idFile and musicvideo.idMVideo=%i order by strFilename", idMovie );
- m_pDS->query( strSQL.c_str() );
- if (!m_pDS->eof())
- @@ -2281,19 +2288,19 @@
- BeginTransaction();
- CStdString strSQL;
- - strSQL=FormatSQL("delete from genrelinkmovie where idmovie=%i", idMovie);
- + strSQL=FormatSQL("delete from genrelinkmovie where idMovie=%i", idMovie);
- m_pDS->exec(strSQL.c_str());
- - strSQL=FormatSQL("delete from actorlinkmovie where idmovie=%i", idMovie);
- + strSQL=FormatSQL("delete from actorlinkmovie where idMovie=%i", idMovie);
- m_pDS->exec(strSQL.c_str());
- - strSQL=FormatSQL("delete from directorlinkmovie where idmovie=%i", idMovie);
- + strSQL=FormatSQL("delete from directorlinkmovie where idMovie=%i", idMovie);
- m_pDS->exec(strSQL.c_str());
- - strSQL=FormatSQL("delete from studiolinkmovie where idmovie=%i", idMovie);
- + strSQL=FormatSQL("delete from studiolinkmovie where idMovie=%i", idMovie);
- m_pDS->exec(strSQL.c_str());
- - strSQL=FormatSQL("delete from setlinkmovie where idmovie=%i", idMovie);
- + strSQL=FormatSQL("delete from setlinkmovie where idMovie=%i", idMovie);
- m_pDS->exec(strSQL.c_str());
- if (!bKeepThumb)
- @@ -2308,10 +2315,10 @@
- {
- ClearBookMarksOfFile(strFilenameAndPath);
- - strSQL=FormatSQL("delete from movie where idmovie=%i", idMovie);
- + strSQL=FormatSQL("delete from movie where idMovie=%i", idMovie);
- m_pDS->exec(strSQL.c_str());
- - strSQL=FormatSQL("delete from movielinktvshow where idmovie=%i", idMovie);
- + strSQL=FormatSQL("delete from movielinktvshow where idMovie=%i", idMovie);
- m_pDS->exec(strSQL.c_str());
- }
- /*
- @@ -2319,7 +2326,7 @@
- else
- {
- // clear the title
- - strSQL=FormatSQL("update movie set c%02d=NULL where idmovie=%i", VIDEODB_ID_TITLE, idMovie);
- + strSQL=FormatSQL("update movie set c%02d=NULL where idMovie=%i", VIDEODB_ID_TITLE, idMovie);
- m_pDS->exec(strSQL.c_str());
- }
- */
- @@ -2350,7 +2357,7 @@
- BeginTransaction();
- - CStdString strSQL=FormatSQL("select tvshowlinkepisode.idepisode,path.strPath,files.strFileName from tvshowlinkepisode,path,files,episode where tvshowlinkepisode.idshow=%i and tvshowlinkepisode.idepisode=episode.idEpisode and episode.idFile=files.idFile and files.idPath=path.idPath",idTvShow);
- + CStdString strSQL=FormatSQL("select tvshowlinkepisode.idEpisode,path.strPath,files.strFileName from tvshowlinkepisode,path,files,episode where tvshowlinkepisode.idShow=%i and tvshowlinkepisode.idEpisode=episode.idEpisode and episode.idFile=files.idFile and files.idPath=path.idPath",idTvShow);
- m_pDS2->query(strSQL.c_str());
- while (!m_pDS2->eof())
- {
- @@ -2362,19 +2369,19 @@
- m_pDS2->next();
- }
- - strSQL=FormatSQL("delete from genrelinktvshow where idshow=%i", idTvShow);
- + strSQL=FormatSQL("delete from genrelinktvshow where idShow=%i", idTvShow);
- m_pDS->exec(strSQL.c_str());
- - strSQL=FormatSQL("delete from actorlinktvshow where idshow=%i", idTvShow);
- + strSQL=FormatSQL("delete from actorlinktvshow where idShow=%i", idTvShow);
- m_pDS->exec(strSQL.c_str());
- - strSQL=FormatSQL("delete from directorlinktvshow where idshow=%i", idTvShow);
- + strSQL=FormatSQL("delete from directorlinktvshow where idShow=%i", idTvShow);
- m_pDS->exec(strSQL.c_str());
- - strSQL=FormatSQL("delete from tvshowlinkpath where idshow=%i", idTvShow);
- + strSQL=FormatSQL("delete from tvshowlinkpath where idShow=%i", idTvShow);
- m_pDS->exec(strSQL.c_str());
- - strSQL=FormatSQL("delete from studiolinktvshow where idshow=%i", idTvShow);
- + strSQL=FormatSQL("delete from studiolinktvshow where idShow=%i", idTvShow);
- m_pDS->exec(strSQL.c_str());
- if (!bKeepThumb)
- @@ -2383,10 +2390,10 @@
- // keep tvshow table and movielink table so we can update data in place
- if (!bKeepId)
- {
- - strSQL=FormatSQL("delete from tvshow where idshow=%i", idTvShow);
- + strSQL=FormatSQL("delete from tvshow where idShow=%i", idTvShow);
- m_pDS->exec(strSQL.c_str());
- - strSQL=FormatSQL("delete from movielinktvshow where idshow=%i", idTvShow);
- + strSQL=FormatSQL("delete from movielinktvshow where idShow=%i", idTvShow);
- m_pDS->exec(strSQL.c_str());
- }
- @@ -2416,16 +2423,16 @@
- }
- CStdString strSQL;
- - strSQL=FormatSQL("delete from actorlinkepisode where idepisode=%i", idEpisode);
- + strSQL=FormatSQL("delete from actorlinkepisode where idEpisode=%i", idEpisode);
- m_pDS->exec(strSQL.c_str());
- - strSQL=FormatSQL("delete from directorlinkepisode where idepisode=%i", idEpisode);
- + strSQL=FormatSQL("delete from directorlinkepisode where idEpisode=%i", idEpisode);
- m_pDS->exec(strSQL.c_str());
- - strSQL=FormatSQL("select tvshowlinkepisode.idshow from tvshowlinkepisode where idepisode=%i",idEpisode);
- + strSQL=FormatSQL("select tvshowlinkepisode.idShow from tvshowlinkepisode where idEpisode=%i",idEpisode);
- m_pDS->query(strSQL.c_str());
- - strSQL=FormatSQL("delete from tvshowlinkepisode where idepisode=%i", idEpisode);
- + strSQL=FormatSQL("delete from tvshowlinkepisode where idEpisode=%i", idEpisode);
- m_pDS->exec(strSQL.c_str());
- if (!bKeepThumb)
- @@ -2465,16 +2472,16 @@
- BeginTransaction();
- CStdString strSQL;
- - strSQL=FormatSQL("delete from genrelinkmusicvideo where idmvideo=%i", idMVideo);
- + strSQL=FormatSQL("delete from genrelinkmusicvideo where idMVideo=%i", idMVideo);
- m_pDS->exec(strSQL.c_str());
- - strSQL=FormatSQL("delete from artistlinkmusicvideo where idmvideo=%i", idMVideo);
- + strSQL=FormatSQL("delete from artistlinkmusicvideo where idMVideo=%i", idMVideo);
- m_pDS->exec(strSQL.c_str());
- - strSQL=FormatSQL("delete from directorlinkmusicvideo where idmvideo=%i", idMVideo);
- + strSQL=FormatSQL("delete from directorlinkmusicvideo where idMVideo=%i", idMVideo);
- m_pDS->exec(strSQL.c_str());
- - strSQL=FormatSQL("delete from studiolinkmusicvideo where idmvideo=%i", idMVideo);
- + strSQL=FormatSQL("delete from studiolinkmusicvideo where idMVideo=%i", idMVideo);
- m_pDS->exec(strSQL.c_str());
- if (!bKeepThumb)
- @@ -2488,7 +2495,7 @@
- {
- ClearBookMarksOfFile(strFilenameAndPath);
- - strSQL=FormatSQL("delete from musicvideo where idmvideo=%i", idMVideo);
- + strSQL=FormatSQL("delete from musicvideo where idMVideo=%i", idMVideo);
- m_pDS->exec(strSQL.c_str());
- }
- /*
- @@ -2496,7 +2503,7 @@
- else
- {
- // clear the title
- - strSQL=FormatSQL("update musicvideo set c%02d=NULL where idmvideo=%i", VIDEODB_ID_MUSICVIDEO_TITLE, idMVideo);
- + strSQL=FormatSQL("update musicvideo set c%02d=NULL where idMVideo=%i", VIDEODB_ID_MUSICVIDEO_TITLE, idMVideo);
- m_pDS->exec(strSQL.c_str());
- }
- */
- @@ -2860,7 +2867,7 @@
- if (NULL == m_pDS.get()) return false;
- CStdString strPath, strFileName;
- CUtil::Split(strFilenameAndPath, strPath, strFileName);
- - CStdString strSQL=FormatSQL("select * from settings, files, path where settings.idfile=files.idfile and path.idpath=files.idpath and path.strPath like '%s' and files.strFileName like '%s'", strPath.c_str() , strFileName.c_str());
- + CStdString strSQL=FormatSQL("select * from settings, files, path where settings.idFile=files.idFile and path.idPath=files.idPath and path.strPath like '%s' and files.strFileName like '%s'", strPath.c_str() , strFileName.c_str());
- #else
- int idFile = GetFileId(strFilenameAndPath);
- if (idFile < 0) return false;
- @@ -3364,7 +3371,7 @@
- "counts.totalcount as totalCount,counts.watchedcount as watchedCount,"
- "counts.totalcount=counts.watchedcount as watched from tvshow "
- "join tvshowlinkpath on tvshow.idShow=tvshowlinkpath.idShow "
- - "join path on path.idpath=tvshowlinkpath.idPath "
- + "join path on path.idPath=tvshowlinkpath.idPath "
- "left outer join ("
- " select tvshow.idShow as idShow,count(1) as totalcount,count(episode.c%02d) as watchedcount from tvshow "
- " join tvshowlinkepisode on tvshow.idShow = tvshowlinkepisode.idShow "
- @@ -3376,8 +3383,8 @@
- "path.strPath as strPath,tvshow.c%02d as strTitle,tvshow.idShow as idShow,"
- "tvshow.c%02d as premiered from episode "
- "join files on files.idFile=episode.idFile "
- - "join tvshowlinkepisode on episode.idepisode=tvshowlinkepisode.idepisode "
- - "join tvshow on tvshow.idshow=tvshowlinkepisode.idshow "
- + "join tvshowlinkepisode on episode.idEpisode=tvshowlinkepisode.idEpisode "
- + "join tvshow on tvshow.idShow=tvshowlinkepisode.idShow "
- "join path on files.idPath=path.idPath",VIDEODB_ID_TV_TITLE, VIDEODB_ID_TV_PREMIERED);
- m_pDS->exec(episodeview.c_str());
- }
- @@ -3480,8 +3487,8 @@
- "path.strPath as strPath,files.playCount as playCount,files.lastPlayed as lastPlayed,tvshow.c%02d as strTitle,tvshow.idShow as idShow,"
- "tvshow.c%02d as premiered from episode "
- "join files on files.idFile=episode.idFile "
- - "join tvshowlinkepisode on episode.idepisode=tvshowlinkepisode.idepisode "
- - "join tvshow on tvshow.idshow=tvshowlinkepisode.idshow "
- + "join tvshowlinkepisode on episode.idEpisode=tvshowlinkepisode.idEpisode "
- + "join tvshow on tvshow.idShow=tvshowlinkepisode.idShow "
- "join path on files.idPath=path.idPath",VIDEODB_ID_TV_TITLE, VIDEODB_ID_TV_PREMIERED);
- m_pDS->exec(episodeview.c_str());
- m_pDS->exec("drop view tvshowview");
- @@ -3489,7 +3496,7 @@
- "counts.totalcount as totalCount,counts.watchedcount as watchedCount,"
- "counts.totalcount=counts.watchedcount as watched from tvshow "
- "join tvshowlinkpath on tvshow.idShow=tvshowlinkpath.idShow "
- - "join path on path.idpath=tvshowlinkpath.idPath "
- + "join path on path.idPath=tvshowlinkpath.idPath "
- "left outer join ("
- " select tvshow.idShow as idShow,count(1) as totalcount,count(files.playCount) as watchedcount from tvshow "
- " join tvshowlinkepisode on tvshow.idShow = tvshowlinkepisode.idShow "
- @@ -3536,8 +3543,8 @@
- "path.strPath as strPath,files.playCount as playCount,files.lastPlayed as lastPlayed,tvshow.c%02d as strTitle,tvshow.c%02d as strStudio,tvshow.idShow as idShow,"
- "tvshow.c%02d as premiered from episode "
- "join files on files.idFile=episode.idFile "
- - "join tvshowlinkepisode on episode.idepisode=tvshowlinkepisode.idepisode "
- - "join tvshow on tvshow.idshow=tvshowlinkepisode.idshow "
- + "join tvshowlinkepisode on episode.idEpisode=tvshowlinkepisode.idEpisode "
- + "join tvshow on tvshow.idShow=tvshowlinkepisode.idShow "
- "join path on files.idPath=path.idPath",VIDEODB_ID_TV_TITLE, VIDEODB_ID_TV_STUDIOS, VIDEODB_ID_TV_PREMIERED);
- m_pDS->exec(episodeview.c_str());
- }
- @@ -3558,14 +3565,14 @@
- "path.strPath as strPath,files.playCount as playCount,files.lastPlayed as lastPlayed,tvshow.c%02d as strTitle,tvshow.c%02d as strStudio,tvshow.idShow as idShow,"
- "tvshow.c%02d as premiered, tvshow.c%02d as mpaa from episode "
- "join files on files.idFile=episode.idFile "
- - "join tvshowlinkepisode on episode.idepisode=tvshowlinkepisode.idepisode "
- - "join tvshow on tvshow.idshow=tvshowlinkepisode.idshow "
- + "join tvshowlinkepisode on episode.idEpisode=tvshowlinkepisode.idEpisode "
- + "join tvshow on tvshow.idShow=tvshowlinkepisode.idShow "
- "join path on files.idPath=path.idPath",VIDEODB_ID_TV_TITLE, VIDEODB_ID_TV_STUDIOS, VIDEODB_ID_TV_PREMIERED, VIDEODB_ID_TV_MPAA);
- m_pDS->exec(episodeview.c_str());
- }
- if (iVersion < 31)
- {
- - const char* tag1[] = {"idmovie","idshow","idepisode","idmvideo","idactor"};
- + const char* tag1[] = {"idMovie","idShow","idEpisode","idMVideo","idActor"};
- const char* tag2[] = {"c08","c06","c06","c02","strThumb"};
- const char* tag3[] = {"movie","tvshow","episode","musicvideo","actors"};
- for (int i=0;i<5;++i)
- @@ -3614,7 +3621,7 @@
- m_pDS->exec("CREATE UNIQUE INDEX ix_setlinkmovie_1 ON setlinkmovie ( idSet, idMovie)\n");
- m_pDS->exec("CREATE UNIQUE INDEX ix_setlinkmovie_2 ON setlinkmovie ( idMovie, idSet)\n");
- }
- -
- +
- if (iVersion < 34)
- {
- m_pDS->exec("DELETE FROM streamdetails");
- @@ -3677,9 +3684,9 @@
- CStdString exec;
- if (type == VIDEODB_CONTENT_TVSHOWS)
- - exec = FormatSQL("UPDATE tvshow set c%02d='%s' WHERE idshow=%i", VIDEODB_ID_TV_FANART, item.GetVideoInfoTag()->m_fanart.m_xml.c_str(), item.GetVideoInfoTag()->m_iDbId);
- + exec = FormatSQL("UPDATE tvshow set c%02d='%s' WHERE idShow=%i", VIDEODB_ID_TV_FANART, item.GetVideoInfoTag()->m_fanart.m_xml.c_str(), item.GetVideoInfoTag()->m_iDbId);
- else if (type == VIDEODB_CONTENT_MOVIES)
- - exec = FormatSQL("UPDATE movie set c%02d='%s' WHERE idmovie=%i", VIDEODB_ID_FANART, item.GetVideoInfoTag()->m_fanart.m_xml.c_str(), item.GetVideoInfoTag()->m_iDbId);
- + exec = FormatSQL("UPDATE movie set c%02d='%s' WHERE idMovie=%i", VIDEODB_ID_FANART, item.GetVideoInfoTag()->m_fanart.m_xml.c_str(), item.GetVideoInfoTag()->m_iDbId);
- try
- {
- @@ -4026,7 +4033,7 @@
- }
- if (!thumb || !fanart) // use the first item's thumb
- {
- - CStdString strSQL = FormatSQL("select strPath, strFileName from movieview join setlinkmovie on setlinkmovie.idMovie=movieview.idmovie where setlinkmovie.idSet=%u",m_pDS->fv("sets.idSet").get_asInt());
- + CStdString strSQL = FormatSQL("select strPath, strFileName from movieview join setlinkmovie on setlinkmovie.idMovie=movieview.idMovie where setlinkmovie.idSet=%u",m_pDS->fv("sets.idSet").get_asInt());
- m_pDS2->query(strSQL.c_str());
- if (!m_pDS2->eof())
- {
- @@ -4046,7 +4053,7 @@
- m_pDS->close();
- }
- -// CLog::Log(LOGDEBUG, "%s Time: %d ms", CTimeUtils::GetTimeMS() - time);
- + // CLog::Log(LOGDEBUG, "%s Time: %d ms", CTimeUtils::GetTimeMS() - time);
- return true;
- }
- catch (...)
- @@ -4066,11 +4073,11 @@
- CStdString strSQL;
- if (g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
- {
- - strSQL=FormatSQL("select musicvideo.c%02d,musicvideo.idMVideo,actors.strActor,path.strPath from musicvideo join artistlinkmusicvideo on artistlinkmusicvideo.idmvideo=musicvideo.idmvideo join actors on actors.idActor=artistlinkmusicvideo.idartist join files on files.idFile = musicvideo.idfile join path on path.idpath = files.idpath",VIDEODB_ID_MUSICVIDEO_ALBUM);
- + strSQL=FormatSQL("select musicvideo.c%02d,musicvideo.idMVideo,actors.strActor,path.strPath from musicvideo join artistlinkmusicvideo on artistlinkmusicvideo.idMVideo=musicvideo.idMVideo join actors on actors.idActor=artistlinkmusicvideo.idartist join files on files.idFile = musicvideo.idFile join path on path.idPath = files.idPath",VIDEODB_ID_MUSICVIDEO_ALBUM);
- }
- else
- {
- - strSQL=FormatSQL("select musicvideo.c%02d,musicvideo.idMVideo,actors.strActor from musicvideo join artistlinkmusicvideo on artistlinkmusicvideo.idmvideo=musicvideo.idmvideo join actors on actors.idActor=artistlinkmusicvideo.idartist",VIDEODB_ID_MUSICVIDEO_ALBUM);
- + strSQL=FormatSQL("select musicvideo.c%02d,musicvideo.idMVideo,actors.strActor from musicvideo join artistlinkmusicvideo on artistlinkmusicvideo.idMVideo=musicvideo.idMVideo join actors on actors.idActor=artistlinkmusicvideo.idartist",VIDEODB_ID_MUSICVIDEO_ALBUM);
- }
- if (idArtist > -1)
- strSQL += FormatSQL(" where artistlinkmusicvideo.idartist=%i",idArtist);
- @@ -4154,7 +4161,7 @@
- m_pDS->close();
- }
- -// CLog::Log(LOGDEBUG, __FUNCTION__" Time: %d ms", CTimeUtils::GetTimeMS() - time);
- + // CLog::Log(LOGDEBUG, __FUNCTION__" Time: %d ms", CTimeUtils::GetTimeMS() - time);
- return true;
- }
- catch (...)
- @@ -4238,10 +4245,10 @@
- else if (idContent == VIDEODB_CONTENT_TVSHOWS)
- strSQL=FormatSQL("select distinct actors.idActor,actors.strActor,actors.strThumb from actors,%slinktvshow,tvshow where actors.idActor=%slinktvshow.id%s and %slinktvshow.idShow = tvshow.idShow", type.c_str(), type.c_str(), type.c_str(), type.c_str());
- else if (idContent == VIDEODB_CONTENT_EPISODES)
- - strSQL=FormatSQL("select actors.idactor,actors.strActor,actors.strThumb,count(1),count(files.playCount) from %slinkepisode,actors,episode,files where actors.idactor=%slinkepisode.id%s and %slinkepisode.idEpisode=episode.idEpisode and files.idfile=episode.idfile group by actors.idactor", type.c_str(), type.c_str(), type.c_str(), type.c_str());
- + strSQL=FormatSQL("select actors.idActor,actors.strActor,actors.strThumb,count(1),count(files.playCount) from %slinkepisode,actors,episode,files where actors.idActor=%slinkepisode.id%s and %slinkepisode.idEpisode=episode.idEpisode and files.idFile=episode.idFile group by actors.idActor", type.c_str(), type.c_str(), type.c_str(), type.c_str());
- else if (idContent == VIDEODB_CONTENT_MUSICVIDEOS)
- {
- - strSQL=FormatSQL("select actors.idActor,actors.strActor,actors.strThumb,count(1),count(files.playCount) from actors join %slinkmusicvideo on actors.idActor=%slinkmusicvideo.id%s join musicvideo on %slinkmusicvideo.idmvideo = musicvideo.idmvideo join files on files.idFile=musicvideo.idFile", type.c_str(), type.c_str(), type.c_str(), type.c_str());
- + strSQL=FormatSQL("select actors.idActor,actors.strActor,actors.strThumb,count(1),count(files.playCount) from actors join %slinkmusicvideo on actors.idActor=%slinkmusicvideo.id%s join musicvideo on %slinkmusicvideo.idMVideo = musicvideo.idMVideo join files on files.idFile=musicvideo.idFile", type.c_str(), type.c_str(), type.c_str(), type.c_str());
- strSQL += " group by actors.idActor";
- }
- }
- @@ -4532,22 +4539,22 @@
- CStdString strIn = FormatSQL("= %i", idShow);
- GetStackedTvShowList(idShow, strIn);
- - CStdString strSQL = FormatSQL("select episode.c%02d,path.strPath,tvshow.c%02d,tvshow.c%02d,count(1),count(files.playCount) from episode join tvshow on tvshow.idshow=tvshowlinkepisode.idshow join tvshowlinkepisode on tvshowlinkepisode.idEpisode = episode.idEpisode join files on files.idFile=episode.idFile ", VIDEODB_ID_EPISODE_SEASON, VIDEODB_ID_TV_TITLE, VIDEODB_ID_TV_GENRE);
- + CStdString strSQL = FormatSQL("select episode.c%02d,path.strPath,tvshow.c%02d,tvshow.c%02d,count(1),count(files.playCount) from episode join tvshow on tvshow.idShow=tvshowlinkepisode.idShow join tvshowlinkepisode on tvshowlinkepisode.idEpisode = episode.idEpisode join files on files.idFile=episode.idFile ", VIDEODB_ID_EPISODE_SEASON, VIDEODB_ID_TV_TITLE, VIDEODB_ID_TV_GENRE);
- CStdString joins = FormatSQL(" join tvshowlinkpath on tvshowlinkpath.idShow = tvshow.idShow join path on path.idPath = tvshowlinkpath.idPath where tvshow.idShow %s ", strIn.c_str());
- CStdString extraJoins, extraWhere;
- if (idActor != -1)
- {
- - extraJoins = "join actorlinktvshow on actorlinktvshow.idshow=tvshow.idshow";
- + extraJoins = "join actorlinktvshow on actorlinktvshow.idShow=tvshow.idShow";
- extraWhere = FormatSQL("and actorlinktvshow.idActor=%i", idActor);
- }
- else if (idDirector != -1)
- {
- - extraJoins = "join directorlinktvshow on directorlinktvshow.idshow=tvshow.idshow";
- + extraJoins = "join directorlinktvshow on directorlinktvshow.idShow=tvshow.idShow";
- extraWhere = FormatSQL("and directorlinktvshow.idDirector=%i",idDirector);
- }
- else if (idGenre != -1)
- {
- - extraJoins = "join genrelinktvshow on genrelinktvshow.idshow=tvshow.idshow";
- + extraJoins = "join genrelinktvshow on genrelinktvshow.idShow=tvshow.idShow";
- extraWhere = FormatSQL("and genrelinktvshow.idGenre=%i", idGenre);
- }
- else if (idYear != -1)
- @@ -4678,17 +4685,17 @@
- {
- CStdString where;
- if (idGenre != -1)
- - where = FormatSQL("join genrelinkmovie on genrelinkmovie.idmovie=movieview.idmovie where genrelinkmovie.idGenre=%i", idGenre);
- + where = FormatSQL("join genrelinkmovie on genrelinkmovie.idMovie=movieview.idMovie where genrelinkmovie.idGenre=%i", idGenre);
- else if (idStudio != -1)
- - where = FormatSQL("join studiolinkmovie on studiolinkmovie.idmovie=movieview.idmovie where studiolinkmovie.idstudio=%i", idStudio);
- + where = FormatSQL("join studiolinkmovie on studiolinkmovie.idMovie=movieview.idMovie where studiolinkmovie.idStudio=%i", idStudio);
- else if (idDirector != -1)
- - where = FormatSQL("join directorlinkmovie on directorlinkmovie.idmovie=movieview.idmovie where directorlinkmovie.idDirector=%i", idDirector);
- + where = FormatSQL("join directorlinkmovie on directorlinkmovie.idMovie=movieview.idMovie where directorlinkmovie.idDirector=%i", idDirector);
- else if (idYear !=-1)
- where = FormatSQL("where c%02d='%i'",VIDEODB_ID_YEAR,idYear);
- else if (idActor != -1)
- - where = FormatSQL("join actorlinkmovie on actorlinkmovie.idmovie=movieview.idmovie join actors on actors.idActor=actorlinkmovie.idActor where actors.idActor=%i",idActor);
- + where = FormatSQL("join actorlinkmovie on actorlinkmovie.idMovie=movieview.idMovie join actors on actors.idActor=actorlinkmovie.idActor where actors.idActor=%i",idActor);
- else if (idSet != -1)
- - where = FormatSQL("join setlinkmovie on setlinkmovie.idMovie=movieview.idmovie where setlinkmovie.idSet=%u",idSet);
- + where = FormatSQL("join setlinkmovie on setlinkmovie.idMovie=movieview.idMovie where setlinkmovie.idSet=%u",idSet);
- return GetMoviesByWhere(strBaseDir, where, "", items, idSet == -1);
- }
- @@ -4713,9 +4720,9 @@
- setsWhere = " where movie.idMovie in (select movieview.idMovie from movieview " + where + ")";
- GetSetsNav("videodb://1/7/", items, VIDEODB_CONTENT_MOVIES, setsWhere);
- if (where.size())
- - strSQL += where + FormatSQL(" and movieview.idmovie NOT in (select idmovie from setlinkmovie)");
- + strSQL += where + FormatSQL(" and movieview.idMovie NOT in (select idMovie from setlinkmovie)");
- else
- - strSQL += FormatSQL("where movieview.idmovie NOT in (select idmovie from setlinkmovie)");
- + strSQL += FormatSQL("where movieview.idMovie NOT in (select idMovie from setlinkmovie)");
- }
- else
- strSQL += where;
- @@ -4771,15 +4778,15 @@
- {
- CStdString where;
- if (idGenre != -1)
- - where = FormatSQL("join genrelinktvshow on genrelinktvshow.idshow=tvshowview.idshow where genrelinktvshow.idGenre=%i ", idGenre);
- + where = FormatSQL("join genrelinktvshow on genrelinktvshow.idShow=tvshow.idShow where genrelinktvshow.idGenre=%i ", idGenre);
- else if (idStudio != -1)
- - where = FormatSQL("join studiolinktvshow on studiolinktvshow.idshow=tvshowview.idshow where studiolinktvshow.idstudio=%i", idStudio);
- + where = FormatSQL("join studiolinktvshow on studiolinktvshow.idShow=tvshow.idShow where studiolinktvshow.idStudio=%i", idStudio);
- else if (idDirector != -1)
- - where = FormatSQL("join directorlinktvshow on directorlinktvshow.idshow=tvshowview.idshow where directorlinktvshow.idDirector=%i", idDirector);
- + where = FormatSQL("join directorlinktvshow on directorlinktvshow.idShow=tvshow.idShow where directorlinktvshow.idDirector=%i", idDirector);
- else if (idYear != -1)
- where = FormatSQL("where c%02d like '%%%i%%'", VIDEODB_ID_TV_PREMIERED,idYear);
- else if (idActor != -1)
- - where = FormatSQL("join actorlinktvshow on actorlinktvshow.idshow=tvshowview.idshow join actors on actors.idActor=actorlinktvshow.idActor where actors.idActor=%i",idActor);
- + where = FormatSQL("join actorlinktvshow on actorlinktvshow.idShow=tvshow.idShow join actors on actors.idActor=actorlinktvshow.idActor where actors.idActor=%i",idActor);
- return GetTvShowsByWhere(strBaseDir, where, items);
- }
- @@ -4794,7 +4801,7 @@
- if (NULL == m_pDB.get()) return false;
- if (NULL == m_pDS.get()) return false;
- - CStdString strSQL = "select * from tvshowview " + where;
- + CStdString strSQL = VIDEO_DATABASE_VIEW_TVSHOW + where;
- // run query
- CLog::Log(LOGDEBUG, "%s query: %s", __FUNCTION__, strSQL.c_str());
- if (!m_pDS->query(strSQL.c_str())) return false;
- @@ -5033,13 +5040,13 @@
- GetStackedTvShowList(idShow, strIn);
- CStdString where = FormatSQL("where idShow %s",strIn.c_str());
- if (idGenre != -1)
- - where = FormatSQL("join genrelinktvshow on genrelinktvshow.idShow=episodeview.idShow where episodeview.idShow=%i and genrelinktvshow.idgenre=%i",idShow,idGenre);
- + where = FormatSQL("join genrelinktvshow on genrelinktvshow.idShow=episodeview.idShow where episodeview.idShow=%i and genrelinktvshow.idGenre=%i",idShow,idGenre);
- else if (idDirector != -1)
- - where = FormatSQL("join directorlinktvshow on directorlinktvshow.idshow=episodeview.idshow where episodeview.idShow=%i and directorlinktvshow.iddirector=%i",idShow,idDirector);
- + where = FormatSQL("join directorlinktvshow on directorlinktvshow.idShow=episodeview.idShow where episodeview.idShow=%i and directorlinktvshow.idDirector=%i",idShow,idDirector);
- else if (idYear !=-1)
- where=FormatSQL("where idShow=%i and premiered like '%%%i%%'",idShow,idYear);
- else if (idActor != -1)
- - where = FormatSQL("join actorlinktvshow on actorlinktvshow.idshow = episodeview.idshow where episodeview.idShow=%i and actorlinktvshow.idactor=%i",idShow,idActor);
- + where = FormatSQL("join actorlinktvshow on actorlinktvshow.idShow = episodeview.idShow where episodeview.idShow=%i and actorlinktvshow.idActor=%i",idShow,idActor);
- if (idSeason != -1)
- {
- @@ -5131,15 +5138,15 @@
- {
- CStdString where;
- if (idGenre != -1)
- - where = FormatSQL("join genrelinkmusicvideo on genrelinkmusicvideo.idmvideo=musicvideoview.idmvideo where genrelinkmusicvideo.idGenre=%i", idGenre);
- + where = FormatSQL("join genrelinkmusicvideo on genrelinkmusicvideo.idMVideo=musicvideoview.idMVideo where genrelinkmusicvideo.idGenre=%i", idGenre);
- else if (idStudio != -1)
- - where = FormatSQL("join studiolinkmusicvideo on studiolinkmusicvideo.idmvideo=musicvideoview.idmvideo where studiolinkmusicvideo.idstudio=%i", idStudio);
- + where = FormatSQL("join studiolinkmusicvideo on studiolinkmusicvideo.idMVideo=musicvideoview.idMVideo where studiolinkmusicvideo.idStudio=%i", idStudio);
- else if (idDirector != -1)
- - where = FormatSQL("join directorlinkmusicvideo on directorlinkmusicvideo.idmvideo=musicvideoview.idmvideo where directorlinkmusicvideo.idDirector=%i", idDirector);
- + where = FormatSQL("join directorlinkmusicvideo on directorlinkmusicvideo.idMVideo=musicvideoview.idMVideo where directorlinkmusicvideo.idDirector=%i", idDirector);
- else if (idYear !=-1)
- where = FormatSQL("where c%02d='%i'",VIDEODB_ID_MUSICVIDEO_YEAR,idYear);
- else if (idArtist != -1)
- - where = FormatSQL("join artistlinkmusicvideo on artistlinkmusicvideo.idmvideo=musicvideoview.idmvideo join actors on actors.idActor=artistlinkmusicvideo.idartist where actors.idActor=%i",idArtist);
- + where = FormatSQL("join artistlinkmusicvideo on artistlinkmusicvideo.idMVideo=musicvideoview.idMVideo join actors on actors.idActor=artistlinkmusicvideo.idartist where actors.idActor=%i",idArtist);
- if (idAlbum != -1)
- {
- CStdString str2 = FormatSQL(" musicvideoview.c%02d=(select c%02d from musicvideo where idMVideo=%i)",VIDEODB_ID_MUSICVIDEO_ALBUM,VIDEODB_ID_MUSICVIDEO_ALBUM,idAlbum);
- @@ -5148,7 +5155,7 @@
- else
- where.Format(" %s %s%s",where.Mid(0).c_str(),"and",str2.c_str());
- }
- -
- +
- return GetMusicVideosByWhere(strBaseDir, where, items);
- }
- @@ -5160,13 +5167,13 @@
- bool CVideoDatabase::GetRecentlyAddedEpisodesNav(const CStdString& strBaseDir, CFileItemList& items)
- {
- - CStdString where = FormatSQL("order by idepisode desc limit %i", g_advancedSettings.m_iVideoLibraryRecentlyAddedItems);
- + CStdString where = FormatSQL("order by idEpisode desc limit %i", g_advancedSettings.m_iVideoLibraryRecentlyAddedItems);
- return GetEpisodesByWhere(strBaseDir, where, items, false);
- }
- bool CVideoDatabase::GetRecentlyAddedMusicVideosNav(const CStdString& strBaseDir, CFileItemList& items)
- {
- - CStdString where = FormatSQL("order by idmvideo desc limit %i", g_advancedSettings.m_iVideoLibraryRecentlyAddedItems);
- + CStdString where = FormatSQL("order by idMVideo desc limit %i", g_advancedSettings.m_iVideoLibraryRecentlyAddedItems);
- return GetMusicVideosByWhere(strBaseDir, where, items);
- }
- @@ -5249,7 +5256,7 @@
- if (NULL == m_pDS2.get()) return false;
- // make sure we use m_pDS2, as this is called in loops using m_pDS
- - CStdString strSQL=FormatSQL("select idshow from tvshowlinkepisode where idEpisode=%i", idEpisode);
- + CStdString strSQL=FormatSQL("select idShow from tvshowlinkepisode where idEpisode=%i", idEpisode);
- m_pDS2->query( strSQL.c_str() );
- int result=-1;
- @@ -5477,9 +5484,9 @@
- if (NULL == m_pDS.get()) return;
- if (g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
- - strSQL=FormatSQL("select genre.idgenre,genre.strgenre,path.strPath from genre,genrelinkmovie,movie,path,files where genre.idGenre=genrelinkMovie.idGenre and genrelinkMovie.idMovie = movie.idMovie and files.idFile=movie.idFile and path.idPath = files.idPath and genre.strGenre like '%%%s%%'",strSearch.c_str());
- + strSQL=FormatSQL("select genre.idGenre,genre.strgenre,path.strPath from genre,genrelinkmovie,movie,path,files where genre.idGenre=genrelinkMovie.idGenre and genrelinkMovie.idMovie = movie.idMovie and files.idFile=movie.idFile and path.idPath = files.idPath and genre.strGenre like '%%%s%%'",strSearch.c_str());
- else
- - strSQL=FormatSQL("select distinct genre.idgenre,genre.strgenre from genre,genrelinkmovie where genrelinkmovie.idgenre=genre.idgenre and strGenre like '%%%s%%'", strSearch.c_str());
- + strSQL=FormatSQL("select distinct genre.idGenre,genre.strgenre from genre,genrelinkmovie where genrelinkmovie.idGenre=genre.idGenre and strGenre like '%%%s%%'", strSearch.c_str());
- m_pDS->query( strSQL.c_str() );
- while (!m_pDS->eof())
- @@ -5518,9 +5525,9 @@
- if (NULL == m_pDS.get()) return;
- if (g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
- - strSQL=FormatSQL("select genre.idgenre,genre.strgenre,path.strPath from genre,genrelinktvshow,tvshow,path,tvshowlinkpath where genre.idGenre=genrelinktvshow.idGenre and genrelinktvshow.idshow = tvshow.idshow and path.idPath = tvshowlinkpath.idPath and tvshowlinkpath.idshow = tvshow.idshow and genre.strGenre like '%%%s%%'",strSearch.c_str());
- + strSQL=FormatSQL("select genre.idGenre,genre.strgenre,path.strPath from genre,genrelinktvshow,tvshow,path,tvshowlinkpath where genre.idGenre=genrelinktvshow.idGenre and genrelinktvshow.idShow = tvshow.idShow and path.idPath = tvshowlinkpath.idPath and tvshowlinkpath.idShow = tvshow.idShow and genre.strGenre like '%%%s%%'",strSearch.c_str());
- else
- - strSQL=FormatSQL("select distinct genre.idgenre,genre.strgenre from genre,genrelinktvshow where genrelinktvshow.idgenre=genre.idgenre and strGenre like '%%%s%%'", strSearch.c_str());
- + strSQL=FormatSQL("select distinct genre.idGenre,genre.strgenre from genre,genrelinktvshow where genrelinktvshow.idGenre=genre.idGenre and strGenre like '%%%s%%'", strSearch.c_str());
- m_pDS->query( strSQL.c_str() );
- while (!m_pDS->eof())
- @@ -5558,9 +5565,9 @@
- if (NULL == m_pDS.get()) return;
- if (g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
- - strSQL=FormatSQL("select actors.idactor,actors.strActor,path.strPath from actorlinkmovie,actors,movie,files,path where actors.idActor=actorlinkmovie.idActor and actorlinkmovie.idmovie=movie.idmovie and files.idFile = movie.idFile and files.idPath = path.idPath and actors.strActor like '%%%s%%'",strSearch.c_str());
- + strSQL=FormatSQL("select actors.idActor,actors.strActor,path.strPath from actorlinkmovie,actors,movie,files,path where actors.idActor=actorlinkmovie.idActor and actorlinkmovie.idMovie=movie.idMovie and files.idFile = movie.idFile and files.idPath = path.idPath and actors.strActor like '%%%s%%'",strSearch.c_str());
- else
- - strSQL=FormatSQL("select distinct actors.idactor,actors.strActor from actorlinkmovie,actors,movie where actors.idActor=actorlinkmovie.idActor and actorlinkmovie.idmovie=movie.idmovie and actors.strActor like '%%%s%%'",strSearch.c_str());
- + strSQL=FormatSQL("select distinct actors.idActor,actors.strActor from actorlinkmovie,actors,movie where actors.idActor=actorlinkmovie.idActor and actorlinkmovie.idMovie=movie.idMovie and actors.strActor like '%%%s%%'",strSearch.c_str());
- m_pDS->query( strSQL.c_str() );
- while (!m_pDS->eof())
- @@ -5598,9 +5605,9 @@
- if (NULL == m_pDS.get()) return;
- if (g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
- - strSQL=FormatSQL("select actors.idactor,actors.strActor,path.strPath from actorlinktvshow,actors,tvshow,path,tvshowlinkpath where actors.idActor=actorlinktvshow.idActor and actorlinktvshow.idshow=tvshow.idshow and tvshowlinkpath.idpath=tvshow.idshow and tvshowlinkpath.idpath=path.idpath and actors.strActor like '%%%s%%'",strSearch.c_str());
- + strSQL=FormatSQL("select actors.idActor,actors.strActor,path.strPath from actorlinktvshow,actors,tvshow,path,tvshowlinkpath where actors.idActor=actorlinktvshow.idActor and actorlinktvshow.idShow=tvshow.idShow and tvshowlinkpath.idPath=tvshow.idShow and tvshowlinkpath.idPath=path.idPath and actors.strActor like '%%%s%%'",strSearch.c_str());
- else
- - strSQL=FormatSQL("select distinct actors.idactor,actors.strActor from actorlinktvshow,actors,tvshow where actors.idActor=actorlinktvshow.idActor and actorlinktvshow.idshow=tvshow.idshow and actors.strActor like '%%%s%%'",strSearch.c_str());
- + strSQL=FormatSQL("select distinct actors.idActor,actors.strActor from actorlinktvshow,actors,tvshow where actors.idActor=actorlinktvshow.idActor and actorlinktvshow.idShow=tvshow.idShow and actors.strActor like '%%%s%%'",strSearch.c_str());
- m_pDS->query( strSQL.c_str() );
- while (!m_pDS->eof())
- @@ -5641,9 +5648,9 @@
- if (!strSearch.IsEmpty())
- strLike = "and actors.strActor like '%%%s%%'";
- if (g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
- - strSQL=FormatSQL("select actors.idactor,actors.strActor,path.strPath from artistlinkmusicvideo,actors,musicvideo,files,path where actors.idActor=artistlinkmusicvideo.idartist and artistlinkmusicvideo.idmvideo=musicvideo.idmvideo and files.idFile = musicvideo.idFile and files.idPath = path.idPath "+strLike,strSearch.c_str());
- + strSQL=FormatSQL("select actors.idActor,actors.strActor,path.strPath from artistlinkmusicvideo,actors,musicvideo,files,path where actors.idActor=artistlinkmusicvideo.idartist and artistlinkmusicvideo.idMVideo=musicvideo.idMVideo and files.idFile = musicvideo.idFile and files.idPath = path.idPath "+strLike,strSearch.c_str());
- else
- - strSQL=FormatSQL("select distinct actors.idactor,actors.strActor from artistlinkmusicvideo,actors where actors.idActor=artistlinkmusicvideo.idartist "+strLike,strSearch.c_str());
- + strSQL=FormatSQL("select distinct actors.idActor,actors.strActor from artistlinkmusicvideo,actors where actors.idActor=artistlinkmusicvideo.idartist "+strLike,strSearch.c_str());
- m_pDS->query( strSQL.c_str() );
- while (!m_pDS->eof())
- @@ -5681,9 +5688,9 @@
- if (NULL == m_pDS.get()) return;
- if (g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
- - strSQL=FormatSQL("select genre.idgenre,genre.strgenre,path.strPath from genre,genrelinkmusicvideo,musicvideo,path,files where genre.idGenre=genrelinkmusicvideo.idGenre and genrelinkmusicvideo.idmvideo = musicvideo.idmvideo and files.idFile=musicvideo.idFile and path.idPath = files.idPath and genre.strGenre like '%%%s%%'",strSearch.c_str());
- + strSQL=FormatSQL("select genre.idGenre,genre.strgenre,path.strPath from genre,genrelinkmusicvideo,musicvideo,path,files where genre.idGenre=genrelinkmusicvideo.idGenre and genrelinkmusicvideo.idMVideo = musicvideo.idMVideo and files.idFile=musicvideo.idFile and path.idPath = files.idPath and genre.strGenre like '%%%s%%'",strSearch.c_str());
- else
- - strSQL=FormatSQL("select distinct genre.idgenre,genre.strgenre from genre,genrelinkmusicvideo where genrelinkmusicvideo.idgenre=genre.idgenre and genre.strGenre like '%%%s%%'", strSearch.c_str());
- + strSQL=FormatSQL("select distinct genre.idGenre,genre.strgenre from genre,genrelinkmusicvideo where genrelinkmusicvideo.idGenre=genre.idGenre and genre.strGenre like '%%%s%%'", strSearch.c_str());
- m_pDS->query( strSQL.c_str() );
- while (!m_pDS->eof())
- @@ -5727,12 +5734,12 @@
- strLike += "like '%%s%%%'";
- }
- if (g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
- - strSQL=FormatSQL("select distinct musicvideo.c%02d,musicvideo.idmvideo,path.strPath from musicvideo,files,path where files.idFile = musicvideo.idFile and files.idPath = path.idPath"+strLike,VIDEODB_ID_MUSICVIDEO_ALBUM,strSearch.c_str());
- + strSQL=FormatSQL("select distinct musicvideo.c%02d,musicvideo.idMVideo,path.strPath from musicvideo,files,path where files.idFile = musicvideo.idFile and files.idPath = path.idPath"+strLike,VIDEODB_ID_MUSICVIDEO_ALBUM,strSearch.c_str());
- else
- {
- if (!strLike.IsEmpty())
- strLike = "where "+strLike.Mid(4);
- - strSQL=FormatSQL("select distinct musicvideo.c%02d,musicvideo.idmvideo from musicvideo"+strLike,VIDEODB_ID_MUSICVIDEO_ALBUM,strSearch.c_str());
- + strSQL=FormatSQL("select distinct musicvideo.c%02d,musicvideo.idMVideo from musicvideo"+strLike,VIDEODB_ID_MUSICVIDEO_ALBUM,strSearch.c_str());
- }
- m_pDS->query( strSQL.c_str() );
- @@ -5777,9 +5784,9 @@
- if (NULL == m_pDS.get()) return;
- if (g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
- - strSQL = FormatSQL("select musicvideo.idmvideo,musicvideo.c%02d,musicvideo.c%02d,path.strPath from musicvideo,files,path where files.idfile=musicvideo.idfile and files.idPath=path.idPath and musicvideo.c%02d like '%%%s%%'",VIDEODB_ID_MUSICVIDEO_ALBUM,VIDEODB_ID_MUSICVIDEO_TITLE,VIDEODB_ID_MUSICVIDEO_ALBUM,strSearch.c_str());
- + strSQL = FormatSQL("select musicvideo.idMVideo,musicvideo.c%02d,musicvideo.c%02d,path.strPath from musicvideo,files,path where files.idFile=musicvideo.idFile and files.idPath=path.idPath and musicvideo.c%02d like '%%%s%%'",VIDEODB_ID_MUSICVIDEO_ALBUM,VIDEODB_ID_MUSICVIDEO_TITLE,VIDEODB_ID_MUSICVIDEO_ALBUM,strSearch.c_str());
- else
- - strSQL = FormatSQL("select musicvideo.idmvideo,musicvideo.c%02d,musicvideo.c%02d from musicvideo where musicvideo.c%02d like '%%%s%%'",VIDEODB_ID_MUSICVIDEO_ALBUM,VIDEODB_ID_MUSICVIDEO_TITLE,VIDEODB_ID_MUSICVIDEO_ALBUM,strSearch.c_str());
- + strSQL = FormatSQL("select musicvideo.idMVideo,musicvideo.c%02d,musicvideo.c%02d from musicvideo where musicvideo.c%02d like '%%%s%%'",VIDEODB_ID_MUSICVIDEO_ALBUM,VIDEODB_ID_MUSICVIDEO_TITLE,VIDEODB_ID_MUSICVIDEO_ALBUM,strSearch.c_str());
- m_pDS->query( strSQL.c_str() );
- while (!m_pDS->eof())
- @@ -5793,7 +5800,7 @@
- CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString()+" - "+m_pDS->fv(2).get_asString()));
- CStdString strDir;
- - strDir.Format("3/2/%ld",m_pDS->fv("musicvideo.idmvideo").get_asInt());
- + strDir.Format("3/2/%ld",m_pDS->fv("musicvideo.idMVideo").get_asInt());
- pItem->m_strPath="videodb://"+ strDir;
- pItem->m_bIsFolder=false;
- @@ -5840,7 +5847,7 @@
- // get songs from returned subtable
- while (!m_pDS->eof())
- {
- - int idMVideo = m_pDS->fv("idmvideo").get_asInt();
- + int idMVideo = m_pDS->fv("idMVideo").get_asInt();
- CVideoInfoTag musicvideo = GetDetailsForMusicVideo(m_pDS);
- if (!checkLocks || g_settings.m_vecProfiles[0].getLockMode() == LOCK_MODE_EVERYONE || g_passwordManager.bMasterUser ||
- g_passwordManager.IsDatabasePathUnlocked(musicvideo.m_strPath,g_settings.m_videoSources))
- @@ -5873,7 +5880,7 @@
- if (NULL == m_pDB.get()) return 0;
- if (NULL == m_pDS.get()) return 0;
- - CStdString strSQL = "select distinct idmvideo from musicvideoview " + strWhere;
- + CStdString strSQL = "select distinct idMVideo from musicvideoview " + strWhere;
- if (!m_pDS->query(strSQL.c_str())) return 0;
- songIDs.clear();
- if (m_pDS->num_rows() == 0)
- @@ -5926,7 +5933,7 @@
- }
- *item->GetVideoInfoTag() = GetDetailsForMusicVideo(m_pDS);
- item->m_strPath.Format("videodb://3/2/%ld",item->GetVideoInfoTag()->m_iDbId);
- - idSong = m_pDS->fv("idmvideo").get_asInt();
- + idSong = m_pDS->fv("idMVideo").get_asInt();
- item->SetLabel(item->GetVideoInfoTag()->m_strTitle);
- m_pDS->close();
- return true;
- @@ -5949,16 +5956,16 @@
- if (strAlbum.IsEmpty() && strTitle.IsEmpty())
- { // we want to return matching artists only
- if (g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
- - strSQL=FormatSQL("select distinct actors.idactor,path.strPath from artistlinkmusicvideo,actors,musicvideo,files,path where actors.idActor=artistlinkmusicvideo.idartist and artistlinkmusicvideo.idmvideo=musicvideo.idmvideo and files.idFile = musicvideo.idFile and files.idPath = path.idPath and actors.strActor like '%s'",strArtist.c_str());
- + strSQL=FormatSQL("select distinct actors.idActor,path.strPath from artistlinkmusicvideo,actors,musicvideo,files,path where actors.idActor=artistlinkmusicvideo.idartist and artistlinkmusicvideo.idMVideo=musicvideo.idMVideo and files.idFile = musicvideo.idFile and files.idPath = path.idPath and actors.strActor like '%s'",strArtist.c_str());
- else
- - strSQL=FormatSQL("select distinct actors.idactor from artistlinkmusicvideo,actors where actors.idActor=artistlinkmusicvideo.idartist and actors.strActor like '%s'",strArtist.c_str());
- + strSQL=FormatSQL("select distinct actors.idActor from artistlinkmusicvideo,actors where actors.idActor=artistlinkmusicvideo.idartist and actors.strActor like '%s'",strArtist.c_str());
- }
- else
- { // we want to return the matching musicvideo
- if (g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
- - strSQL = FormatSQL("select musicvideo.idmvideo from musicvideo,files,path,artistlinkmusicvideo,actors where files.idfile=musicvideo.idfile and files.idPath=path.idPath and musicvideo.%c02d like '%s' and musicvideo.%c02d like '%s' and artistlinkmusicvideo.idmvideo=musicvideo.idmvideo and artistlinkmusicvideo.idartist = actors.idactors and actors.strActor like '%s'",VIDEODB_ID_MUSICVIDEO_ALBUM,strAlbum.c_str(),VIDEODB_ID_MUSICVIDEO_TITLE,strTitle.c_str(),strArtist.c_str());
- + strSQL = FormatSQL("select musicvideo.idMVideo from musicvideo,files,path,artistlinkmusicvideo,actors where files.idFile=musicvideo.idFile and files.idPath=path.idPath and musicvideo.%c02d like '%s' and musicvideo.%c02d like '%s' and artistlinkmusicvideo.idMVideo=musicvideo.idMVideo and artistlinkmusicvideo.idartist = actors.idActors and actors.strActor like '%s'",VIDEODB_ID_MUSICVIDEO_ALBUM,strAlbum.c_str(),VIDEODB_ID_MUSICVIDEO_TITLE,strTitle.c_str(),strArtist.c_str());
- else
- - strSQL = FormatSQL("select musicvideo.idmvideo from musicvideo join artistlinkmusicvideo on artistlinkmusicvideo.idmvideo=musicvideo.idmvideo join actors on actors.idactor=artistlinkmusicvideo.idartist where musicvideo.c%02d like '%s' and musicvideo.c%02d like '%s' and actors.strActor like '%s'",VIDEODB_ID_MUSICVIDEO_ALBUM,strAlbum.c_str(),VIDEODB_ID_MUSICVIDEO_TITLE,strTitle.c_str(),strArtist.c_str());
- + strSQL = FormatSQL("select musicvideo.idMVideo from musicvideo join artistlinkmusicvideo on artistlinkmusicvideo.idMVideo=musicvideo.idMVideo join actors on actors.idActor=artistlinkmusicvideo.idartist where musicvideo.c%02d like '%s' and musicvideo.c%02d like '%s' and actors.strActor like '%s'",VIDEODB_ID_MUSICVIDEO_ALBUM,strAlbum.c_str(),VIDEODB_ID_MUSICVIDEO_TITLE,strTitle.c_str(),strArtist.c_str());
- }
- m_pDS->query( strSQL.c_str() );
- @@ -5993,9 +6000,9 @@
- if (NULL == m_pDS.get()) return;
- if (g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
- - strSQL = FormatSQL("select movie.idmovie,movie.c%02d,path.strPath from movie,files,path where files.idfile=movie.idfile and files.idPath=path.idPath and movie.c%02d like '%%%s%%'",VIDEODB_ID_TITLE,VIDEODB_ID_TITLE,strSearch.c_str());
- + strSQL = FormatSQL("select movie.idMovie,movie.c%02d,path.strPath from movie,files,path where files.idFile=movie.idFile and files.idPath=path.idPath and movie.c%02d like '%%%s%%'",VIDEODB_ID_TITLE,VIDEODB_ID_TITLE,strSearch.c_str());
- else
- - strSQL = FormatSQL("select movie.idmovie,movie.c%02d from movie where movie.c%02d like '%%%s%%'",VIDEODB_ID_TITLE,VIDEODB_ID_TITLE,strSearch.c_str());
- + strSQL = FormatSQL("select movie.idMovie,movie.c%02d from movie where movie.c%02d like '%%%s%%'",VIDEODB_ID_TITLE,VIDEODB_ID_TITLE,strSearch.c_str());
- m_pDS->query( strSQL.c_str() );
- while (!m_pDS->eof())
- @@ -6039,9 +6046,9 @@
- if (NULL == m_pDS.get()) return;
- if (g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
- - strSQL = FormatSQL("select tvshow.idshow,tvshow.c%02d,path.strPath from tvshow,path,tvshowlinkpath where tvshowlinkpath.idpath=path.idpath and tvshowlinkpath.idshow = tvshow.idshow and tvshow.c%02d like '%%%s%%'",VIDEODB_ID_TV_TITLE,VIDEODB_ID_TV_TITLE,strSearch.c_str());
- + strSQL = FormatSQL("select tvshow.idShow,tvshow.c%02d,path.strPath from tvshow,path,tvshowlinkpath where tvshowlinkpath.idPath=path.idPath and tvshowlinkpath.idShow = tvshow.idShow and tvshow.c%02d like '%%%s%%'",VIDEODB_ID_TV_TITLE,VIDEODB_ID_TV_TITLE,strSearch.c_str());
- else
- - strSQL = FormatSQL("select tvshow.idshow,tvshow.c%02d from tvshow where tvshow.c%02d like '%%%s%%'",VIDEODB_ID_TV_TITLE,VIDEODB_ID_TV_TITLE,strSearch.c_str());
- + strSQL = FormatSQL("select tvshow.idShow,tvshow.c%02d from tvshow where tvshow.c%02d like '%%%s%%'",VIDEODB_ID_TV_TITLE,VIDEODB_ID_TV_TITLE,strSearch.c_str());
- m_pDS->query( strSQL.c_str() );
- while (!m_pDS->eof())
- @@ -6055,11 +6062,11 @@
- CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString()));
- CStdString strDir;
- - strDir.Format("2/2/%ld/", m_pDS->fv("tvshow.idshow").get_asInt());
- + strDir.Format("2/2/%ld/", m_pDS->fv("tvshow.idShow").get_asInt());
- pItem->m_strPath="videodb://"+ strDir;
- pItem->m_bIsFolder=true;
- - pItem->GetVideoInfoTag()->m_iDbId = m_pDS->fv("tvshow.idshow").get_asInt();
- + pItem->GetVideoInfoTag()->m_iDbId = m_pDS->fv("tvshow.idShow").get_asInt();
- items.Add(pItem);
- m_pDS->next();
- }
- @@ -6081,9 +6088,9 @@
- if (NULL == m_pDS.get()) return;
- if (g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
- - strSQL = FormatSQL("select episode.idepisode,episode.c%02d,episode.c%02d,tvshowlinkepisode.idshow,tvshow.c%02d,path.strPath from episode,files,path,tvshowlinkepisode,tvshow where files.idfile=episode.idfile and tvshowlinkepisode.idepisode=episode.idepisode and tvshowlinkepisode.idshow=tvshow.idshow and files.idPath=path.idPath and episode.c%02d like '%%%s%%'",VIDEODB_ID_EPISODE_TITLE,VIDEODB_ID_EPISODE_SEASON,VIDEODB_ID_TV_TITLE,VIDEODB_ID_EPISODE_TITLE,strSearch.c_str());
- + strSQL = FormatSQL("select episode.idEpisode,episode.c%02d,episode.c%02d,tvshowlinkepisode.idShow,tvshow.c%02d,path.strPath from episode,files,path,tvshowlinkepisode,tvshow where files.idFile=episode.idFile and tvshowlinkepisode.idEpisode=episode.idEpisode and tvshowlinkepisode.idShow=tvshow.idShow and files.idPath=path.idPath and episode.c%02d like '%%%s%%'",VIDEODB_ID_EPISODE_TITLE,VIDEODB_ID_EPISODE_SEASON,VIDEODB_ID_TV_TITLE,VIDEODB_ID_EPISODE_TITLE,strSearch.c_str());
- else
- - strSQL = FormatSQL("select episode.idepisode,episode.c%02d,episode.c%02d,tvshowlinkepisode.idshow,tvshow.c%02d from episode,tvshowlinkepisode,tvshow where tvshowlinkepisode.idepisode=episode.idepisode and tvshow.idshow=tvshowlinkepisode.idshow and episode.c%02d like '%%%s%%'",VIDEODB_ID_EPISODE_TITLE,VIDEODB_ID_EPISODE_SEASON,VIDEODB_ID_TV_TITLE,VIDEODB_ID_EPISODE_TITLE,strSearch.c_str());
- + strSQL = FormatSQL("select episode.idEpisode,episode.c%02d,episode.c%02d,tvshowlinkepisode.idShow,tvshow.c%02d from episode,tvshowlinkepisode,tvshow where tvshowlinkepisode.idEpisode=episode.idEpisode and tvshow.idShow=tvshowlinkepisode.idShow and episode.c%02d like '%%%s%%'",VIDEODB_ID_EPISODE_TITLE,VIDEODB_ID_EPISODE_SEASON,VIDEODB_ID_TV_TITLE,VIDEODB_ID_EPISODE_TITLE,strSearch.c_str());
- m_pDS->query( strSQL.c_str() );
- while (!m_pDS->eof())
- @@ -6096,7 +6103,7 @@
- }
- CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString()+" ("+m_pDS->fv(4).get_asString()+")"));
- - pItem->m_strPath.Format("videodb://2/2/%ld/%ld/%ld",m_pDS->fv("tvshowlinkepisode.idshow").get_asInt(),m_pDS->fv(2).get_asInt(),m_pDS->fv(0).get_asInt());
- + pItem->m_strPath.Format("videodb://2/2/%ld/%ld/%ld",m_pDS->fv("tvshowlinkepisode.idShow").get_asInt(),m_pDS->fv(2).get_asInt(),m_pDS->fv(0).get_asInt());
- pItem->m_bIsFolder=false;
- items.Add(pItem);
- m_pDS->next();
- @@ -6111,10 +6118,10 @@
- void CVideoDatabase::GetMusicVideosByName(const CStdString& strSearch, CFileItemList& items)
- {
- -// Alternative searching - not quite as fast though due to
- -// retrieving all information
- -// CStdString where = FormatSQL("where c%02d like '%s%%' or c%02d like '%% %s%%'", VIDEODB_ID_MUSICVIDEO_TITLE, strSearch.c_str(), VIDEODB_ID_MUSICVIDEO_TITLE, strSearch.c_str());
- -// GetMusicVideosByWhere("videodb://3/2/", where, items);
- + // Alternative searching - not quite as fast though due to
- + // retrieving all information
- + // CStdString where = FormatSQL("where c%02d like '%s%%' or c%02d like '%% %s%%'", VIDEODB_ID_MUSICVIDEO_TITLE, strSearch.c_str(), VIDEODB_ID_MUSICVIDEO_TITLE, strSearch.c_str());
- + // GetMusicVideosByWhere("videodb://3/2/", where, items);
- CStdString strSQL;
- try
- @@ -6123,9 +6130,9 @@
- if (NULL == m_pDS.get()) return;
- if (g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
- - strSQL = FormatSQL("select musicvideo.idmvideo,musicvideo.c%02d,path.strPath from musicvideo,files,path where files.idfile=musicvideo.idfile and files.idPath=path.idPath and musicvideo.c%02d like '%%%s%%'",VIDEODB_ID_MUSICVIDEO_TITLE,VIDEODB_ID_MUSICVIDEO_TITLE,strSearch.c_str());
- + strSQL = FormatSQL("select musicvideo.idMVideo,musicvideo.c%02d,path.strPath from musicvideo,files,path where files.idFile=musicvideo.idFile and files.idPath=path.idPath and musicvideo.c%02d like '%%%s%%'",VIDEODB_ID_MUSICVIDEO_TITLE,VIDEODB_ID_MUSICVIDEO_TITLE,strSearch.c_str());
- else
- - strSQL = FormatSQL("select musicvideo.idmvideo,musicvideo.c%02d from musicvideo where musicvideo.c%02d like '%%%s%%'",VIDEODB_ID_MUSICVIDEO_TITLE,VIDEODB_ID_MUSICVIDEO_TITLE,strSearch.c_str());
- + strSQL = FormatSQL("select musicvideo.idMVideo,musicvideo.c%02d from musicvideo where musicvideo.c%02d like '%%%s%%'",VIDEODB_ID_MUSICVIDEO_TITLE,VIDEODB_ID_MUSICVIDEO_TITLE,strSearch.c_str());
- m_pDS->query( strSQL.c_str() );
- while (!m_pDS->eof())
- @@ -6139,7 +6146,7 @@
- CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString()));
- CStdString strDir;
- - strDir.Format("3/2/%ld",m_pDS->fv("musicvideo.idmvideo").get_asInt());
- + strDir.Format("3/2/%ld",m_pDS->fv("musicvideo.idMVideo").get_asInt());
- pItem->m_strPath="videodb://"+ strDir;
- pItem->m_bIsFolder=false;
- @@ -6156,12 +6163,12 @@
- void CVideoDatabase::GetEpisodesByPlot(const CStdString& strSearch, CFileItemList& items)
- {
- -// Alternative searching - not quite as fast though due to
- -// retrieving all information
- -// CStdString where = FormatSQL("where c%02d like '%s%%' or c%02d like '%% %s%%'", VIDEODB_ID_EPISODE_PLOT, strSearch.c_str(), VIDEODB_ID_EPISODE_PLOT, strSearch.c_str());
- -// where += FormatSQL("or c%02d like '%s%%' or c%02d like '%% %s%%'", VIDEODB_ID_EPISODE_TITLE, strSearch.c_str(), VIDEODB_ID_EPISODE_TITLE, strSearch.c_str());
- -// GetEpisodesByWhere("videodb://2/2/", where, items);
- -// return;
- + // Alternative searching - not quite as fast though due to
- + // retrieving all information
- + // CStdString where = FormatSQL("where c%02d like '%s%%' or c%02d like '%% %s%%'", VIDEODB_ID_EPISODE_PLOT, strSearch.c_str(), VIDEODB_ID_EPISODE_PLOT, strSearch.c_str());
- + // where += FormatSQL("or c%02d like '%s%%' or c%02d like '%% %s%%'", VIDEODB_ID_EPISODE_TITLE, strSearch.c_str(), VIDEODB_ID_EPISODE_TITLE, strSearch.c_str());
- + // GetEpisodesByWhere("videodb://2/2/", where, items);
- + // return;
- CStdString strSQL;
- try
- @@ -6170,9 +6177,9 @@
- if (NULL == m_pDS.get()) return;
- if (g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
- - strSQL = FormatSQL("select episode.idepisode,episode.c%02d,episode.c%02d,tvshowlinkepisode.idshow,tvshow.c%02d,path.strPath from episode,files,path,tvshowlinkepisode,tvshow where files.idfile=episode.idfile and tvshowlinkepisode.idepisode=episode.idepisode and files.idPath=path.idPath and tvshow.idshow=tvshowlinkepisode.idshow and episode.c%02d like '%%%s%%'",VIDEODB_ID_EPISODE_TITLE,VIDEODB_ID_EPISODE_SEASON,VIDEODB_ID_TV_TITLE,VIDEODB_ID_EPISODE_PLOT,strSearch.c_str());
- + strSQL = FormatSQL("select episode.idEpisode,episode.c%02d,episode.c%02d,tvshowlinkepisode.idShow,tvshow.c%02d,path.strPath from episode,files,path,tvshowlinkepisode,tvshow where files.idFile=episode.idFile and tvshowlinkepisode.idEpisode=episode.idEpisode and files.idPath=path.idPath and tvshow.idShow=tvshowlinkepisode.idShow and episode.c%02d like '%%%s%%'",VIDEODB_ID_EPISODE_TITLE,VIDEODB_ID_EPISODE_SEASON,VIDEODB_ID_TV_TITLE,VIDEODB_ID_EPISODE_PLOT,strSearch.c_str());
- else
- - strSQL = FormatSQL("select episode.idepisode,episode.c%02d,episode.c%02d,tvshowlinkepisode.idshow,tvshow.c%02d from episode,tvshowlinkepisode,tvshow where tvshowlinkepisode.idepisode=episode.idepisode and tvshow.idshow=tvshowlinkepisode.idshow and episode.c%02d like '%%%s%%'",VIDEODB_ID_EPISODE_TITLE,VIDEODB_ID_EPISODE_SEASON,VIDEODB_ID_TV_TITLE,VIDEODB_ID_EPISODE_PLOT,strSearch.c_str());
- + strSQL = FormatSQL("select episode.idEpisode,episode.c%02d,episode.c%02d,tvshowlinkepisode.idShow,tvshow.c%02d from episode,tvshowlinkepisode,tvshow where tvshowlinkepisode.idEpisode=episode.idEpisode and tvshow.idShow=tvshowlinkepisode.idShow and episode.c%02d like '%%%s%%'",VIDEODB_ID_EPISODE_TITLE,VIDEODB_ID_EPISODE_SEASON,VIDEODB_ID_TV_TITLE,VIDEODB_ID_EPISODE_PLOT,strSearch.c_str());
- m_pDS->query( strSQL.c_str() );
- while (!m_pDS->eof())
- @@ -6185,7 +6192,7 @@
- }
- CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString()+" ("+m_pDS->fv(4).get_asString()+")"));
- - pItem->m_strPath.Format("videodb://2/2/%ld/%ld/%ld",m_pDS->fv("tvshowlinkepisode.idshow").get_asInt(),m_pDS->fv(2).get_asInt(),m_pDS->fv(0).get_asInt());
- + pItem->m_strPath.Format("videodb://2/2/%ld/%ld/%ld",m_pDS->fv("tvshowlinkepisode.idShow").get_asInt(),m_pDS->fv(2).get_asInt(),m_pDS->fv(0).get_asInt());
- pItem->m_bIsFolder=false;
- items.Add(pItem);
- m_pDS->next();
- @@ -6208,9 +6215,9 @@
- if (NULL == m_pDS.get()) return;
- if (g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
- - strSQL = FormatSQL("select movie.idmovie, movie.c%02d, path.strPath from movie,files,path where files.idfile=movie.idfile and files.idPath=path.idPath and (movie.c%02d like '%%%s%%' or movie.c%02d like '%%%s%%' or movie.c%02d like '%%%s%%')",VIDEODB_ID_TITLE,VIDEODB_ID_PLOT,strSearch.c_str(),VIDEODB_ID_PLOTOUTLINE,strSearch.c_str(),VIDEODB_ID_TAGLINE,strSearch.c_str());
- + strSQL = FormatSQL("select movie.idMovie, movie.c%02d, path.strPath from movie,files,path where files.idFile=movie.idFile and files.idPath=path.idPath and (movie.c%02d like '%%%s%%' or movie.c%02d like '%%%s%%' or movie.c%02d like '%%%s%%')",VIDEODB_ID_TITLE,VIDEODB_ID_PLOT,strSearch.c_str(),VIDEODB_ID_PLOTOUTLINE,strSearch.c_str(),VIDEODB_ID_TAGLINE,strSearch.c_str());
- else
- - strSQL = FormatSQL("select movie.idmovie, movie.c%02d from movie where (movie.c%02d like '%%%s%%' or movie.c%02d like '%%%s%%' or movie.c%02d like '%%%s%%')",VIDEODB_ID_TITLE,VIDEODB_ID_PLOT,strSearch.c_str(),VIDEODB_ID_PLOTOUTLINE,strSearch.c_str(),VIDEODB_ID_TAGLINE,strSearch.c_str());
- + strSQL = FormatSQL("select movie.idMovie, movie.c%02d from movie where (movie.c%02d like '%%%s%%' or movie.c%02d like '%%%s%%' or movie.c%02d like '%%%s%%')",VIDEODB_ID_TITLE,VIDEODB_ID_PLOT,strSearch.c_str(),VIDEODB_ID_PLOTOUTLINE,strSearch.c_str(),VIDEODB_ID_TAGLINE,strSearch.c_str());
- m_pDS->query( strSQL.c_str() );
- @@ -6249,9 +6256,9 @@
- if (NULL == m_pDS.get()) return;
- if (g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
- - strSQL = FormatSQL("select distinct directorlinkmovie.idDirector,actors.strActor,path.strPath from movie,files,path,actors,directorlinkmovie where files.idfile=movie.idfile and files.idPath=path.idPath and directorlinkmovie.idmovie = movie.idMovie and directorlinkmovie.idDirector = actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str());
- + strSQL = FormatSQL("select distinct directorlinkmovie.idDirector,actors.strActor,path.strPath from movie,files,path,actors,directorlinkmovie where files.idFile=movie.idFile and files.idPath=path.idPath and directorlinkmovie.idMovie = movie.idMovie and directorlinkmovie.idDirector = actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str());
- else
- - strSQL = FormatSQL("select distinct directorlinkmovie.idDirector,actors.strActor from movie,actors,directorlinkmovie where directorlinkmovie.idmovie = movie.idMovie and directorlinkmovie.idDirector = actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str());
- + strSQL = FormatSQL("select distinct directorlinkmovie.idDirector,actors.strActor from movie,actors,directorlinkmovie where directorlinkmovie.idMovie = movie.idMovie and directorlinkmovie.idDirector = actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str());
- m_pDS->query( strSQL.c_str() );
- @@ -6291,9 +6298,9 @@
- if (NULL == m_pDS.get()) return;
- if (g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
- - strSQL = FormatSQL("select distinct directorlinktvshow.idDirector,actors.strActor,path.strPath from tvshow,path,actors,directorlinktvshow,tvshowlinkpath where tvshowlinkpath.idPath=path.idPath and tvshowlinkpath.idshow=tvshow.idshow and directorlinktvshow.idshow = tvshow.idshow and directorlinktvshow.idDirector = actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str());
- + strSQL = FormatSQL("select distinct directorlinktvshow.idDirector,actors.strActor,path.strPath from tvshow,path,actors,directorlinktvshow,tvshowlinkpath where tvshowlinkpath.idPath=path.idPath and tvshowlinkpath.idShow=tvshow.idShow and directorlinktvshow.idShow = tvshow.idShow and directorlinktvshow.idDirector = actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str());
- else
- - strSQL = FormatSQL("select distinct directorlinktvshow.idDirector,actors.strActor from tvshow,actors,directorlinktvshow where directorlinktvshow.idshow = tvshow.idshow and directorlinktvshow.idDirector = actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str());
- + strSQL = FormatSQL("select distinct directorlinktvshow.idDirector,actors.strActor from tvshow,actors,directorlinktvshow where directorlinktvshow.idShow = tvshow.idShow and directorlinktvshow.idDirector = actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str());
- m_pDS->query( strSQL.c_str() );
- @@ -6333,9 +6340,9 @@
- if (NULL == m_pDS.get()) return;
- if (g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
- - strSQL = FormatSQL("select distinct directorlinkmusicvideo.idDirector,actors.strActor,path.strPath from musicvideo,files,path,actors,directorlinkmusicvideo where files.idfile=musicvideo.idfile and files.idPath=path.idPath and directorlinkmusicvideo.idmvideo = musicvideo.idmvideo and directorlinkmusicvideo.idDirector = actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str());
- + strSQL = FormatSQL("select distinct directorlinkmusicvideo.idDirector,actors.strActor,path.strPath from musicvideo,files,path,actors,directorlinkmusicvideo where files.idFile=musicvideo.idFile and files.idPath=path.idPath and directorlinkmusicvideo.idMVideo = musicvideo.idMVideo and directorlinkmusicvideo.idDirector = actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str());
- else
- - strSQL = FormatSQL("select distinct directorlinkmusicvideo.idDirector,actors.strActor from musicvideo,actors,directorlinkmusicvideo where directorlinkmusicvideo.idmvideo = musicvideo.idmvideo and directorlinkmusicvideo.idDirector = actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str());
- + strSQL = FormatSQL("select distinct directorlinkmusicvideo.idDirector,actors.strActor from musicvideo,actors,directorlinkmusicvideo where directorlinkmusicvideo.idMVideo = musicvideo.idMVideo and directorlinkmusicvideo.idDirector = actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str());
- m_pDS->query( strSQL.c_str() );
- @@ -6388,7 +6395,7 @@
- CStdString strPaths;
- for (unsigned int i=0;i<paths->size();++i )
- strPaths.Format("%s,%i",strPaths.Mid(0).c_str(),paths->at(i));
- - sql = FormatSQL("select * from files,path where files.idpath=path.idPath and path.idPath in (%s)",strPaths.Mid(1).c_str());
- + sql = FormatSQL("select * from files,path where files.idPath=path.idPath and path.idPath in (%s)",strPaths.Mid(1).c_str());
- }
- else
- sql = "select * from files, path where files.idPath = path.idPath";
- @@ -6600,18 +6607,18 @@
- {
- strIds.TrimLeft(" ");
- strIds.TrimRight(",");
- - sql = FormatSQL("delete from path where idpath in (%s)",strIds.c_str());
- + sql = FormatSQL("delete from path where idPath in (%s)",strIds.c_str());
- m_pDS->exec(sql.c_str());
- - sql = FormatSQL("delete from tvshowlinkpath where idpath in (%s)",strIds.c_str());
- + sql = FormatSQL("delete from tvshowlinkpath where idPath in (%s)",strIds.c_str());
- m_pDS->exec(sql.c_str());
- }
- CLog::Log(LOGDEBUG, "%s Cleaning tvshow table", __FUNCTION__);
- - sql = "delete from tvshow where idshow not in (select idshow from tvshowlinkpath)";
- + sql = "delete from tvshow where idShow not in (select idShow from tvshowlinkpath)";
- m_pDS->exec(sql.c_str());
- sql = "delete from tvshow where idShow in (select tvshow.idShow from tvshow "
- - "join tvshowlinkpath on tvshow.idshow=tvshowlinkpath.idshow "
- - "join path on path.idpath=tvshowlinkpath.idpath "
- + "join tvshowlinkpath on tvshow.idShow=tvshowlinkpath.idShow "
- + "join path on path.idPath=tvshowlinkpath.idPath "
- "where tvshow.idShow not in (select idShow from tvshowlinkepisode) "
- "and path.strContent == '')";
- m_pDS->exec(sql.c_str());
- @@ -6625,7 +6632,7 @@
- m_pDS->exec(sql.c_str());
- CLog::Log(LOGDEBUG, "%s Cleaning tvshowlinkpath table", __FUNCTION__);
- - sql = "delete from tvshowlinkpath where idshow not in (select idShow from tvshow)";
- + sql = "delete from tvshowlinkpath where idShow not in (select idShow from tvshow)";
- m_pDS->exec(sql.c_str());
- CLog::Log(LOGDEBUG, "%s Cleaning genrelinktvshow table", __FUNCTION__);
- @@ -6639,7 +6646,7 @@
- m_pDS->exec(sql.c_str());
- CLog::Log(LOGDEBUG, "%s Cleaning musicvideo table", __FUNCTION__);
- - sql = "delete from musicvideo where idmvideo in " + musicVideosToDelete;
- + sql = "delete from musicvideo where idMVideo in " + musicVideosToDelete;
- m_pDS->exec(sql.c_str());
- CLog::Log(LOGDEBUG, "%s Cleaning artistlinkmusicvideo table", __FUNCTION__);
- @@ -6709,7 +6716,7 @@
- if (CDirectory::Create(TVFolder))
- { // right - grab the episodes and dump them as well
- CFileItemList episodes;
- - CStdString where = FormatSQL("where idshow=%i", items[i]->GetVideoInfoTag()->m_iDbId);
- + CStdString where = FormatSQL("where idShow=%i", items[i]->GetVideoInfoTag()->m_iDbId);
- GetEpisodesByWhere("videodb://2/2/", where, episodes);
- for (int i = 0; i < episodes.Size(); i++)
- {
- @@ -6868,14 +6875,14 @@
- if (!cachedThumb.IsEmpty() && (overwrite || !CFile::Exists(savedThumb, false)))
- if (!CFile::Cache(cachedThumb, savedThumb))
- CLog::Log(LOGERROR, "%s: Movie thumb export failed! ('%s' -> '%s')", __FUNCTION__, cachedThumb.c_str(), savedThumb.c_str());
- -
- +
- CStdString cachedFanart(item.GetCachedFanart());
- CStdString savedFanart(CUtil::ReplaceExtension(savedThumb, "-fanart.jpg"));
- -
- +
- if (CFile::Exists(cachedFanart, false) && (overwrite || !CFile::Exists(savedFanart, false)))
- if (!CFile::Cache(cachedFanart, savedFanart))
- CLog::Log(LOGERROR, "%s: Movie fanart export failed! ('%s' -> '%s')", __FUNCTION__, cachedFanart.c_str(), savedFanart.c_str());
- -
- +
- if (actorThumbs)
- ExportActorThumbs(actorsDir, movie, singleFiles, overwrite);
- }
- @@ -6965,7 +6972,7 @@
- m_pDS->close();
- // repeat for all tvshows
- - sql = "select * from tvshowview";
- + sql = VIDEO_DATABASE_VIEW_TVSHOW;
- m_pDS->query(sql.c_str());
- total = m_pDS->num_rows();
- @@ -7102,7 +7109,7 @@
- CLog::Log(LOGERROR, "%s: TVShow season thumb export failed ('%s' -> '%s')", __FUNCTION__, cachedThumb.c_str(), savedThumb.c_str());
- }
- }
- -
- +
- // now save the episodes from this show
- sql = FormatSQL("select * from episodeview where idShow=%i order by strFileName, idEpisode",tvshow.m_iDbId);
- pDS->query(sql.c_str());
- Index: xbmc/VideoDatabase.h
- ===================================================================
- --- xbmc/VideoDatabase.h (revision 30970)
- +++ xbmc/VideoDatabase.h (working copy)
- @@ -296,6 +296,7 @@
- CVideoDatabase(void);
- virtual ~CVideoDatabase(void);
- + virtual bool Open();
- virtual bool CommitTransaction();
- Index: xbmc/ViewDatabase.cpp
- ===================================================================
- --- xbmc/ViewDatabase.cpp (revision 30970)
- +++ xbmc/ViewDatabase.cpp (working copy)
- @@ -22,12 +22,14 @@
- #include "stdafx.h"
- #include "ViewDatabase.h"
- #include "Util.h"
- +#include "FileSystem/SpecialProtocol.h"
- +#include "Settings.h"
- #include "ViewState.h"
- //********************************************************************************************************************************
- CViewDatabase::CViewDatabase(void)
- {
- - m_strDatabaseFile = VIEW_DATABASE_NAME;
- + m_strDefaultDatabaseName = VIEW_DATABASE_NAME;
- }
- //********************************************************************************************************************************
- @@ -35,6 +37,10 @@
- {
- }
- +bool CViewDatabase::Open()
- +{
- + return CDatabase::Open();
- +}
- //********************************************************************************************************************************
- bool CViewDatabase::CreateTables()
- Index: xbmc/ViewDatabase.h
- ===================================================================
- --- xbmc/ViewDatabase.h (revision 30970)
- +++ xbmc/ViewDatabase.h (working copy)
- @@ -21,7 +21,7 @@
- */
- #include "Database.h"
- -#define VIEW_DATABASE_NAME "ViewModes.db"
- +#define VIEW_DATABASE_NAME "ViewModes"
- class CViewState;
- @@ -30,6 +30,7 @@
- public:
- CViewDatabase(void);
- virtual ~CViewDatabase(void);
- + virtual bool Open();
- bool GetViewState(const CStdString &path, int windowID, CViewState &state);
- bool SetViewState(const CStdString &path, int windowID, const CViewState &state);
Advertisement
Add Comment
Please, Sign In to add comment