summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-09-23 19:55:37 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-09-23 19:55:37 +0000
commit7791397d95512088dca065a4e187bb443b3a6a96 (patch)
treeca43eab36735561842965d399810941c37288e9b
parentc85769fcdc89c0f51ca528bc090fe99f30a08518 (diff)
downloadhercules-7791397d95512088dca065a4e187bb443b3a6a96.tar.gz
hercules-7791397d95512088dca065a4e187bb443b3a6a96.tar.bz2
hercules-7791397d95512088dca065a4e187bb443b3a6a96.tar.xz
hercules-7791397d95512088dca065a4e187bb443b3a6a96.zip
* Added flag svn:executable to the configure script.
* Added code for MySQL versions (below 5.0) that don't have MYSQL_DATA_TRUNCATED. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11281 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-Trunk.txt3
-rwxr-xr-x[-rw-r--r--]configure0
-rw-r--r--src/common/sql.c49
3 files changed, 39 insertions, 13 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 26e8242f9..8de95ff3c 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -4,6 +4,9 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2007/09/23
+ * Added flag svn:executable to the configure script.
+ * Added code for MySQL versions (below 5.0) that don't have
+ MYSQL_DATA_TRUNCATED.
* map_addflooritem and struct item_drop_list using id's instead of
struct map_session_data's (fixes bugreport:36).
* Fixed buildin_escape_sql not properly escaping in sql servers. [FlavioJS]
diff --git a/configure b/configure
index 6f6028911..6f6028911 100644..100755
--- a/configure
+++ b/configure
diff --git a/src/common/sql.c b/src/common/sql.c
index cc6e81009..6b69c8ce4 100644
--- a/src/common/sql.c
+++ b/src/common/sql.c
@@ -487,6 +487,30 @@ static void Sql_P_ShowDebugMysqlFieldInfo(const char* prefix, enum enum_field_ty
+/// Reports debug information about a truncated column.
+///
+/// @private
+static void SqlStmt_P_ShowDebugTruncatedColumn(SqlStmt* self, size_t i)
+{
+ MYSQL_RES* meta;
+ MYSQL_FIELD* field;
+ MYSQL_BIND* column;
+
+ meta = mysql_stmt_result_metadata(self->stmt);
+ field = mysql_fetch_field_direct(meta, (unsigned int)i);
+ ShowSQL("DB error - data of field '%s' was truncated.\n", field->name);
+ ShowDebug("column - %lu\n", (unsigned long)i);
+ Sql_P_ShowDebugMysqlFieldInfo("data - ", field->type, field->flags&UNSIGNED_FLAG, self->column_lengths[i].length, "");
+ column = &self->columns[i];
+ if( column->buffer_type == MYSQL_TYPE_STRING )
+ Sql_P_ShowDebugMysqlFieldInfo("buffer - ", column->buffer_type, column->is_unsigned, column->buffer_length, "+1(nul-terminator)");
+ else
+ Sql_P_ShowDebugMysqlFieldInfo("buffer - ", column->buffer_type, column->is_unsigned, column->buffer_length, "");
+ mysql_free_result(meta);
+}
+
+
+
/// Allocates and initializes a new SqlStmt handle.
SqlStmt* SqlStmt_Malloc(Sql* sql)
{
@@ -741,6 +765,8 @@ int SqlStmt_NextRow(SqlStmt* self)
// check for errors
if( err == MYSQL_NO_DATA )
return SQL_NO_DATA;
+#if defined(MYSQL_DATA_TRUNCATED)
+ // MySQL 5.0/5.1 defines and returns MYSQL_DATA_TRUNCATED [FlavioJS]
if( err == MYSQL_DATA_TRUNCATED )
{
my_bool truncated;
@@ -761,25 +787,14 @@ int SqlStmt_NextRow(SqlStmt* self)
column->error = NULL;
if( truncated )
{// report truncated column
- MYSQL_RES* meta;
- MYSQL_FIELD* field;
-
- meta = mysql_stmt_result_metadata(self->stmt);
- field = mysql_fetch_field_direct(meta, (unsigned int)i);
- ShowSQL("DB error - data of field '%s' was truncated.\n", field->name);
- ShowDebug("column - %lu\n", (unsigned long)i);
- Sql_P_ShowDebugMysqlFieldInfo("data - ", field->type, field->flags&UNSIGNED_FLAG, self->column_lengths[i].length, "");
- if( column->buffer_type == MYSQL_TYPE_STRING )
- Sql_P_ShowDebugMysqlFieldInfo("buffer - ", column->buffer_type, column->is_unsigned, column->buffer_length, "+1(nul-terminator)");
- else
- Sql_P_ShowDebugMysqlFieldInfo("buffer - ", column->buffer_type, column->is_unsigned, column->buffer_length, "");
- mysql_free_result(meta);
+ SqlStmt_P_ShowDebugTruncatedColumn(self, i);
return SQL_ERROR;
}
}
ShowSQL("DB error - data truncated (unknown source)\n");
return SQL_ERROR;
}
+#endif
if( err )
{
ShowSQL("DB error - %s\n", mysql_stmt_error(self->stmt));
@@ -791,6 +806,14 @@ int SqlStmt_NextRow(SqlStmt* self)
for( i = 0; i < cols; ++i )
{
length = self->column_lengths[i].length;
+#if !defined(MYSQL_DATA_TRUNCATED)
+ // MySQL 4.1/(below?) returns success even if data is truncated, so we test truncation manually [FlavioJS]
+ if( self->columns[i].buffer_length < length )
+ {// report truncated column
+ SqlStmt_P_ShowDebugTruncatedColumn(self, i);
+ return SQL_ERROR;
+ }
+#endif
if( self->column_lengths[i].out_length )
*self->column_lengths[i].out_length = (uint32)length;
column = &self->columns[i];