Permalink
Browse files

create new target: MySQL debug, more win32 compatibility

git-svn-id: http://kazuho.31tools.com/svn/incline/trunk@262 4d3e2a30-9d6d-0410-bc8c-dac56cff10b3
  • Loading branch information...
1 parent 467ae95 commit ee9a8330dff0a156aeb1dc3ef7e3c313c603e3b4 kazuho committed Nov 6, 2009
Showing with 154 additions and 20 deletions.
  1. +10 −4 src/getoptpp.h
  2. +4 −0 src/incline_dbms.cc
  3. +5 −1 src/incline_dbms.h
  4. +9 −2 src/incline_fw_async_qtable.cc
  5. +1 −1 src/incline_mysql.h
  6. +4 −6 src/incline_util.cc
  7. +2 −3 src/interthr_call.h
  8. +24 −3 src/tmd.h
  9. +3 −0 win32/incline.sln
  10. +92 −0 win32/incline.vcproj
View
@@ -136,10 +136,16 @@ namespace getoptpp {
: opt_value_base<int>(shortname, longname, required, desc, defval) {}
virtual void handle() {
opt_value_base<int>::handle();
- if (sscanf(optarg, "%d", &value_) != 1) {
- std::cerr << "--" << get_option().name << " only accepts numbers"
- << std::endl;
- exit(1);
+ if (
+#ifdef _MSC_VER
+ sscanf_s(optarg, "%d", &value_, sizeof(value_))
+#else
+ sscanf(optarg, "%d", &value_)
+#endif
+ != 1) {
+ std::cerr << "--" << get_option().name << " only accepts numbers"
+ << std::endl;
+ exit(1);
}
}
};
View
@@ -10,6 +10,10 @@
# include "incline_pgsql.h"
#endif
+#ifdef _MSC_VER
+# pragma warning(disable : 4996) /* no warnings for vsprintf */
+#endif
+
using namespace std;
getoptpp::opt_str incline_dbms::opt_rdbms_('r', "rdbms", true, "rdbms name",
View
@@ -64,7 +64,11 @@ class incline_dbms {
unsigned short port() const { return port_; }
virtual std::string escape(const std::string& s) = 0;
virtual unsigned long long execute(const std::string& stmt) = 0;
- void query(std::vector<std::vector<value_t> >& rows, const char* fmt, ...) __attribute__((__format__(__printf__, 3, 4)));
+ void query(std::vector<std::vector<value_t> >& rows, const char* fmt, ...)
+#ifdef __GNUC__
+ __attribute__((__format__(__printf__, 3, 4)))
+#endif
+ ;
virtual void query(std::vector<std::vector<value_t> >& rows, const std::string& stmt) = 0;
virtual std::string get_column_def(const std::string& table_name, const std::string& column_name) = 0;
protected:
@@ -1,3 +1,6 @@
+#ifdef WIN32
+#include <windows.h>
+#endif
#include "incline_dbms.h"
#include "incline_def_async_qtable.h"
#include "incline_driver_async_qtable.h"
@@ -41,15 +44,19 @@ incline_fw_async_qtable::do_run()
}
// sleep and retry if no data
if (iq_ids.empty()) {
- sleep(mgr()->poll_interval());
+#ifdef WIN32
+ Sleep(mgr()->poll_interval() * 1000);
+#else
+ sleep(mgr()->poll_interval());
+#endif
continue;
}
if (! extra_cond.empty()) {
last_id = iq_ids.back();
}
// update and remove from queue if successful
if (do_update_rows(delete_pks, insert_rows)) {
- dbh_->execute(clear_queue_query_base_ + '('
+ dbh_->execute(clear_queue_query_base_ + '('
+ incline_util::join(',', iq_ids) + ')');
}
} catch (incline_dbms::deadlock_error_t&) {
View
@@ -4,7 +4,7 @@
#include "incline_dbms.h"
namespace tmd {
- struct conn_t;
+ class conn_t;
}
class incline_mysql : public incline_dbms {
View
@@ -2,12 +2,10 @@
#include <cstdarg>
#include "incline_util.h"
-#ifdef _MSC_VER
-# define SNPRINTF _snprintf_s
-# pragma warning(push)
-# pragma warning(disable : 4244) /* conversion from int to char */
-#else
-# define SNPRINTF snprintf
+#ifdef _MSC_VER
+# define SNPRINTF _snprintf_s
+#else
+# define SNPRINTF snprintf
#endif
using namespace std;
View
@@ -29,7 +29,6 @@
#define interthr_call_h
extern "C" {
-#include <alloca.h>
#include <pthread.h>
}
#include <algorithm>
@@ -162,8 +161,7 @@ struct interthr_call_t {
handler->call(*request);
return;
}
- call_info_t* ci
- = static_cast<call_info_t*>(alloca(sizeof(call_info_t) * remain));
+ call_info_t* ci = new call_info_t [remain];
pthread_cond_t ret_cond;
pthread_cond_init(&ret_cond, NULL);
for (Iter it = first; it != last; ++it, ++ci) {
@@ -180,6 +178,7 @@ struct interthr_call_t {
}
pthread_mutex_unlock(&multi_mutex_);
pthread_cond_destroy(&ret_cond);
+ delete [] ci;
}
};
View
@@ -29,6 +29,9 @@
#ifndef tmd_H
#define tmd_H
+#ifdef WIN32
+#include <windows.h>
+#endif
extern "C" {
#include <assert.h>
#include <stdarg.h>
@@ -39,9 +42,18 @@ extern "C" {
#include <string>
#include <vector>
+#ifdef _MSC_VER
+# pragma warning(push)
+# pragma warning(disable : 4996) // no warnings for sscanf
+#endif
+
namespace tmd {
- std::string ssprintf(const char* fmt, ...) __attribute__((__format__(__printf__, 1, 2)));
+ std::string ssprintf(const char* fmt, ...)
+#ifdef __GNUC__
+ __attribute__((__format__(__printf__, 1, 2)))
+#endif
+ ;
inline std::string ssprintf(const char* fmt, ...)
{
char buf[4096];
@@ -151,7 +163,7 @@ namespace tmd {
inline std::string escape(MYSQL* mysql, const std::string& s)
{
char* buf = new char[s.size() * 2 + 1];
- mysql_real_escape_string(mysql, buf, s.c_str(), s.size());
+ mysql_real_escape_string(mysql, buf, s.c_str(), static_cast<unsigned long>(s.size()));
std::string r(buf);
delete [] buf;
return r;
@@ -180,7 +192,10 @@ namespace tmd {
}
void execute(MYSQL* mysql, const char* fmt, ...)
- __attribute__((__format__(__printf__, 2, 3)));
+#ifdef __GNUC__
+ __attribute__((__format__(__printf__, 2, 3)))
+#endif
+ ;
inline void execute(MYSQL* mysql, const char* fmt, ...)
{
va_list args;
@@ -209,7 +224,9 @@ namespace tmd {
num_fields_ = mysql_num_fields(res_);
}
query_t(MYSQL* mysql, const char* fmt, ...)
+#ifdef __GNUC__
__attribute__((__format__(__printf__, 3, 4)))
+#endif
: row_(NULL), lengths_(NULL) {
va_list args;
va_start(args, fmt);
@@ -280,4 +297,8 @@ namespace tmd {
}
+#ifdef _MSC_VER
+# pragma warning(pop)
+#endif
+
#endif
View
@@ -6,11 +6,14 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
+ MySQL Debug|Win32 = MySQL Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D455B920-6C6C-4644-950A-71AF92F2E88E}.Debug|Win32.ActiveCfg = Debug|Win32
{D455B920-6C6C-4644-950A-71AF92F2E88E}.Debug|Win32.Build.0 = Debug|Win32
+ {D455B920-6C6C-4644-950A-71AF92F2E88E}.MySQL Debug|Win32.ActiveCfg = MySQL Debug|Win32
+ {D455B920-6C6C-4644-950A-71AF92F2E88E}.MySQL Debug|Win32.Build.0 = MySQL Debug|Win32
{D455B920-6C6C-4644-950A-71AF92F2E88E}.Release|Win32.ActiveCfg = Release|Win32
{D455B920-6C6C-4644-950A-71AF92F2E88E}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
View
@@ -166,6 +166,82 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
+ <Configuration
+ Name="MySQL Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="src;C:\Program Files\MySQL\MySQL Server 5.1\include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;WITH_MYSQL"
+ 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"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
</Configurations>
<References>
</References>
@@ -250,6 +326,14 @@
<File
RelativePath="..\src\incline_pgsql.cc"
>
+ <FileConfiguration
+ Name="MySQL Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath="..\src\incline_util.cc"
@@ -340,6 +424,14 @@
<File
RelativePath="..\src\incline_pgsql.h"
>
+ <FileConfiguration
+ Name="MySQL Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath="..\src\incline_util.h"

0 comments on commit ee9a833

Please sign in to comment.