* Limited manual detection of data truncation to string/enum/blob columns.

* Renamed conf-tmpl to conf.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@11284 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
FlavioJS 2007-09-24 09:13:50 +00:00
parent d28555c927
commit 909992ed5a
75 changed files with 31 additions and 24 deletions

View File

@ -3,6 +3,9 @@ Date Added
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2007/09/24
* Limited manual detection of data truncation to string/enum/blob columns.
* Renamed conf-tmpl to conf. [FlavioJS]
2007/09/23
* Added flag svn:executable to the configure script.
* Added code for MySQL versions (below 5.0) that don't have

View File

@ -2,15 +2,15 @@
HAVE_MYSQL=@HAVE_MYSQL@
ifeq ($(HAVE_MYSQL),yes)
ALL_DEPENDS=common common_sql login login_sql char char_sql map map_sql ladmin tools converters plugins conf
SQL_DEPENDS=common_sql login_sql char_sql map_sql conf
ALL_DEPENDS=common common_sql login login_sql char char_sql map map_sql ladmin tools converters plugins save
SQL_DEPENDS=common_sql login_sql char_sql map_sql
COMMON_SQL_DEPENDS=
LOGIN_SQL_DEPENDS=common_sql
CHAR_SQL_DEPENDS=common_sql
MAP_SQL_DEPENDS=common_sql
CONVERTERS_DEPENDS=common_sql
else
ALL_DEPENDS=common login char map ladmin tools plugins conf
ALL_DEPENDS=common login char map ladmin tools plugins save
SQL_DEPENDS=needs_mysql
COMMON_SQL_DEPENDS=needs_mysql
LOGIN_SQL_DEPENDS=needs_mysql
@ -21,7 +21,7 @@ endif
#####################################################################
.PHONY: txt sql common common_sql login login_sql char char_sql map map_sql \
ladmin tools converters plugins addons conf clean help depend
ladmin tools converters plugins addons save clean help depend
all: $(ALL_DEPENDS)
@ -65,19 +65,7 @@ converters: $(CONVERTERS_DEPENDS)
plugins addons: common
@$(MAKE) -C src/plugins
conf:
# conf:
# 1) create conf and conf/import folders
# 2) add missing import files
# 3) copy the rest of the files and folders
# 4) remove remaining .svn folders
@echo "building conf folder..."
@if test ! -d conf ; then mkdir conf ; fi
@if test ! -d conf/import ; then mkdir conf/import ; fi
@for f in $$(ls conf-tmpl/import) ; do if test ! -e conf/import/$$f ; then cp conf-tmpl/import/$$f conf/import ; fi ; done
@for f in $$(ls conf-tmpl) ; do if test "$$f" != "import" ; then cp -rf conf-tmpl/$$f conf ; fi ; done
@rm -rf conf/*/.svn
# save:
save:
# 1) create save folder
# 2) add missing files
# 3) remove remaining .svn folder
@ -114,12 +102,12 @@ help:
@echo "'converters' - builds the login/char converters"
@echo "'plugins' - builds all the plugins in src/plugins"
@echo "'addons'"
@echo "'conf' - builds conf and save folders from the templates"
@echo "'save' - builds save folder from the template"
@echo "'all' - builds all above targets"
@echo "'txt' - builds txt servers (targets 'common' 'login' 'char' 'map' and"
@echo " 'conf')"
@echo " 'save')"
@echo "'sql' - builds sql servers (targets 'common_sql' 'login_sql' 'char_sql'"
@echo " 'map_sql' and 'conf')"
@echo " and 'map_sql')"
@echo "'clean' - cleans builds and objects"
@echo "'help' - outputs this message"

View File

@ -394,40 +394,52 @@ static int Sql_P_BindSqlDataType(MYSQL_BIND* bind, enum SqlDataType buffer_type,
switch( buffer_type )
{
case SQLDT_NULL: bind->buffer_type = MYSQL_TYPE_NULL;
buffer_len = 0;// FIXME length = ? [FlavioJS]
break;
// fixed size
case SQLDT_UINT8: bind->is_unsigned = 1;
case SQLDT_INT8: bind->buffer_type = MYSQL_TYPE_TINY;
buffer_len = 1;
break;
case SQLDT_UINT16: bind->is_unsigned = 1;
case SQLDT_INT16: bind->buffer_type = MYSQL_TYPE_SHORT;
buffer_len = 2;
break;
case SQLDT_UINT32: bind->is_unsigned = 1;
case SQLDT_INT32: bind->buffer_type = MYSQL_TYPE_LONG;
buffer_len = 4;
break;
case SQLDT_UINT64: bind->is_unsigned = 1;
case SQLDT_INT64: bind->buffer_type = MYSQL_TYPE_LONGLONG;
buffer_len = 8;
break;
// platform dependent size
case SQLDT_UCHAR: bind->is_unsigned = 1;
case SQLDT_CHAR: bind->buffer_type = Sql_P_SizeToMysqlIntType(sizeof(char));
buffer_len = sizeof(char);
break;
case SQLDT_USHORT: bind->is_unsigned = 1;
case SQLDT_SHORT: bind->buffer_type = Sql_P_SizeToMysqlIntType(sizeof(short));
buffer_len = sizeof(short);
break;
case SQLDT_UINT: bind->is_unsigned = 1;
case SQLDT_INT: bind->buffer_type = Sql_P_SizeToMysqlIntType(sizeof(int));
buffer_len = sizeof(int);
break;
case SQLDT_ULONG: bind->is_unsigned = 1;
case SQLDT_LONG: bind->buffer_type = Sql_P_SizeToMysqlIntType(sizeof(long));
buffer_len = sizeof(long);
break;
case SQLDT_ULONGLONG: bind->is_unsigned = 1;
case SQLDT_LONGLONG: bind->buffer_type = Sql_P_SizeToMysqlIntType(sizeof(long long));
buffer_len = sizeof(long long);
break;
// floating point
case SQLDT_FLOAT: bind->buffer_type = MYSQL_TYPE_FLOAT;
buffer_len = 4;
break;
case SQLDT_DOUBLE: bind->buffer_type = MYSQL_TYPE_DOUBLE;
buffer_len = 8;
break;
// other
case SQLDT_STRING:
@ -806,17 +818,21 @@ int SqlStmt_NextRow(SqlStmt* self)
for( i = 0; i < cols; ++i )
{
length = self->column_lengths[i].length;
column = &self->columns[i];
#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 )
if( column->buffer_length < length )
{// report truncated column
SqlStmt_P_ShowDebugTruncatedColumn(self, i);
return SQL_ERROR;
if( column->buffer_type == MYSQL_TYPE_STRING || column->buffer_type == MYSQL_TYPE_BLOB )
{// string/enum/blob column
SqlStmt_P_ShowDebugTruncatedColumn(self, i);
return SQL_ERROR;
}
// FIXME numeric types and null [FlavioJS]
}
#endif
if( self->column_lengths[i].out_length )
*self->column_lengths[i].out_length = (uint32)length;
column = &self->columns[i];
if( column->buffer_type == MYSQL_TYPE_STRING )
{// clear unused part of the string/enum buffer (and nul-terminate)
memset((char*)column->buffer + length, 0, column->buffer_length - length + 1);