Просмотр исходного кода

MySQL:
Solaris compilation fixes
VS90 project file
Makefile
few tidy-up code fixes

Aleksandar Fabijanic 17 лет назад
Родитель
Сommit
aaddff0f41

+ 2 - 2
Data/MySQL/Makefile

@@ -8,8 +8,8 @@
 
 include $(POCO_BASE)/build/rules/global
 
-SYSLIBS += -L/usr/local/lib/mysql
-INCLUDE += -I/usr/local/include/mysql/
+SYSLIBS += -L/usr/local/lib/mysql -L/usr/lib/mysql -L/usr/mysql/lib/mysql
+INCLUDE += -I/usr/local/include/mysql/ -I/usr/include/mysql/ -I/usr/mysql/include/mysql
 SYSFLAGS += -DTHREADSAFE -DNO_TCL
 
 objects = Binder Extractor SessionImpl Connector \

+ 278 - 0
Data/MySQL/MySQL_VS90.vcproj

@@ -0,0 +1,278 @@
+<?xml version="1.0" encoding="windows-1251"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="MySQL"
+	ProjectGUID="{D9C692A6-D089-4269-B444-C445ED192F0D}"
+	RootNamespace="MySQL"
+	Keyword="Win32Proj"
+	TargetFrameworkVersion="131072"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="debug_shared|Win32"
+			OutputDirectory="obj\$(ConfigurationName)"
+			IntermediateDirectory="obj\$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories=".\include;.\src;..\..\Foundation\include;..\..\Data\include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MYSQL_EXPORTS;POCO_DLL;NO_TCL;THREADSAFE;__LCC__"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="libmysql.lib"
+				OutputFile="../../bin/PocoMySQLd.dll"
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="../../lib"
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				ImportLibrary="../../lib/PocoMySQLd.lib"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="release_shared|Win32"
+			OutputDirectory="obj\$(ConfigurationName)"
+			IntermediateDirectory="obj\$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories=".\include;.\src;..\..\Foundation\include;..\..\Data\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MYSQL_EXPORTS;POCO_DLL;NO_TCL;THREADSAFE;__LCC__"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="libmysql.lib"
+				OutputFile="../../bin/PocoMySQL.dll"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="../../lib"
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				ImportLibrary="../../lib/PocoMySQL.lib"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath=".\src\Binder.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\Connector.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\Extractor.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\MySQLException.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\MySQLStatementImpl.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\ResultMetadata.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\SessionHandle.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\SessionImpl.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\StatementExecutor.cpp"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath=".\include\Poco\Data\MySQL\Binder.h"
+				>
+			</File>
+			<File
+				RelativePath=".\include\Poco\Data\MySQL\Connector.h"
+				>
+			</File>
+			<File
+				RelativePath=".\include\Poco\Data\MySQL\Extractor.h"
+				>
+			</File>
+			<File
+				RelativePath=".\include\Poco\Data\MySQL\MySQL.h"
+				>
+			</File>
+			<File
+				RelativePath=".\include\Poco\Data\MySQL\MySQLException.h"
+				>
+			</File>
+			<File
+				RelativePath=".\include\Poco\Data\MySQL\MySQLStatementImpl.h"
+				>
+			</File>
+			<File
+				RelativePath=".\include\Poco\Data\MySQL\ResultMetadata.h"
+				>
+			</File>
+			<File
+				RelativePath=".\include\Poco\Data\MySQL\SessionHandle.h"
+				>
+			</File>
+			<File
+				RelativePath=".\include\Poco\Data\MySQL\SessionImpl.h"
+				>
+			</File>
+			<File
+				RelativePath=".\include\Poco\Data\MySQL\StatementExecutor.h"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+			>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

+ 1 - 1
Data/MySQL/src/Binder.cpp

@@ -278,7 +278,7 @@ void Binder::realBind(std::size_t pos, enum_field_types type, const void* buffer
 		size_t s = _bindArray.size();
 		_bindArray.resize(pos + 1);
 
-		memset(&_bindArray[s], 0, sizeof(MYSQL_BIND) * (_bindArray.size() - s));
+		std::memset(&_bindArray[s], 0, sizeof(MYSQL_BIND) * (_bindArray.size() - s));
 	}
 
 	MYSQL_BIND b = {0};

+ 1 - 1
Data/MySQL/src/ResultMetadata.cpp

@@ -198,7 +198,7 @@ void ResultMetadata::init(MYSQL_STMT* stmt)
 
 	{for (size_t i = 0; i < count; i++)
 	{
-		memset(&_row[i], 0, sizeof(MYSQL_BIND));
+		std::memset(&_row[i], 0, sizeof(MYSQL_BIND));
 
 		_row[i].buffer_type   = fields[i].type;
 		_row[i].buffer_length = static_cast<unsigned int>(_columns[i].length());

+ 4 - 2
Data/MySQL/src/SessionImpl.cpp

@@ -36,6 +36,7 @@
 
 #include "Poco/Data/MySQL/SessionImpl.h"
 #include "Poco/Data/MySQL/MySQLStatementImpl.h"
+#include "Poco/NumberParser.h"
 
 
 namespace
@@ -118,7 +119,8 @@ SessionImpl::SessionImpl(const std::string& connectionString) : _mysql(0), _conn
 		throw MySQLException("create session: specify database");
 	}
 
-	if (atoi(options["port"].c_str()) == 0)
+	unsigned int port = 0;
+	if (!NumberParser::tryParseUnsigned(options["port"], port) || 0 == port || port > 65535)
 	{
 		throw MySQLException("create session: specify correct port (numeric in decimal notation)");
 	}
@@ -162,7 +164,7 @@ SessionImpl::SessionImpl(const std::string& connectionString) : _mysql(0), _conn
 			options["user"].c_str(), 
 			options["password"].c_str(), 
 			options["db"].c_str(), 
-			atoi(options["port"].c_str()));
+			port);
 
 	_connected = true;
 }

+ 4 - 9
Data/MySQL/src/StatementExecutor.cpp

@@ -36,6 +36,7 @@
 
 #include <mysql.h>
 #include "Poco/Data/MySQL/StatementExecutor.h"
+#include <sstream>
 
 
 namespace Poco {
@@ -179,15 +180,9 @@ bool StatementExecutor::fetchColumn(size_t n, MYSQL_BIND *bind)
 
 	if ((res != 0) && (res != MYSQL_NO_DATA))
 	{
-		std::string msg;
-		msg += "mysql_stmt_fetch_column(";
-
-		char buff[30];
-		sprintf(buff, "%d", n);
-		msg += buff;
-
-		msg += ") error";
-		throw StatementException(msg, h, _query);
+		std::ostringstream msg;
+		msg << "mysql_stmt_fetch_column(" << n << ") error";
+		throw StatementException(msg.str(), h, _query);
 	}
 
 	return (res == 0);