From e69becf133867fff26b59ba74ec1ee722ce1e81e Mon Sep 17 00:00:00 2001 From: "monty@narttu.mysql.fi" <> Date: Wed, 15 Nov 2000 23:00:06 +0200 Subject: changed to use IO_CACHE instead of FILE --- client/mysqlimport.c | 4 ++-- client/sql_string.cc | 26 +++++++++++++++----------- client/sql_string.h | 18 +++++++++--------- 3 files changed, 26 insertions(+), 22 deletions(-) (limited to 'client') diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 68cd84fbbb7..d00c99d4061 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -25,7 +25,7 @@ ** * * ** ************************* */ -#define IMPORT_VERSION "2.5" +#define IMPORT_VERSION "2.6" #include #include @@ -125,7 +125,7 @@ file. The SQL command 'LOAD DATA INFILE' is used to import the rows.\n"); Give the column names in a comma separated list.\n\ This is same as giving columns to LOAD DATA INFILE.\n\ -C, --compress Use compression in server/client protocol\n\ - -d, --delete Deletes first all rows from table.\n\ + -d, --delete First delete all rows from table.\n\ -f, --force Continue even if we get an sql-error.\n\ -h, --host=... Connect to host.\n\ -i, --ignore If duplicate unique key was found, keep old row.\n\ diff --git a/client/sql_string.cc b/client/sql_string.cc index 7ca2d3c419e..4b9ebef21f1 100644 --- a/client/sql_string.cc +++ b/client/sql_string.cc @@ -95,17 +95,6 @@ bool String::realloc(uint32 alloc_length) return FALSE; } - -#ifdef NOT_NEEDED -bool String::set(long num) -{ - if (alloc(14)) - return TRUE; - str_length=(uint32) (int10_to_str(num,Ptr,-10)-Ptr); - return FALSE; -} -#endif - bool String::set(longlong num) { if (alloc(21)) @@ -274,6 +263,7 @@ bool String::append(const char *s,uint32 arg_length) return FALSE; } +#ifdef TO_BE_REMOVED bool String::append(FILE* file, uint32 arg_length, myf my_flags) { if (realloc(str_length+arg_length)) @@ -286,6 +276,20 @@ bool String::append(FILE* file, uint32 arg_length, myf my_flags) str_length+=arg_length; return FALSE; } +#endif + +bool String::append(IO_CACHE* file, uint32 arg_length) +{ + if (realloc(str_length+arg_length)) + return TRUE; + if (my_b_read(file, (byte*) Ptr + str_length, arg_length)) + { + shrink(str_length); + return TRUE; + } + str_length+=arg_length; + return FALSE; +} uint32 String::numchars() { diff --git a/client/sql_string.h b/client/sql_string.h index 8711cf314ad..74dbc4cc6bd 100644 --- a/client/sql_string.h +++ b/client/sql_string.h @@ -100,16 +100,16 @@ public: bool set(ulonglong num); bool set(double num,uint decimals=2); inline void free() + { + if (alloced) { - if (alloced) - { - alloced=0; - Alloced_length=0; - my_free(Ptr,MYF(0)); - Ptr=0; - } + alloced=0; + Alloced_length=0; + my_free(Ptr,MYF(0)); + Ptr=0; + str_length=0; /* Safety */ } - + } inline bool alloc(uint32 arg_length) { if (arg_length < Alloced_length) @@ -152,7 +152,7 @@ public: bool copy(const char *s,uint32 arg_length); // Allocate new string bool append(const String &s); bool append(const char *s,uint32 arg_length=0); - bool append(FILE* file, uint32 arg_length, myf my_flags); + bool append(IO_CACHE* file, uint32 arg_length); int strstr(const String &search,uint32 offset=0); // Returns offset to substring or -1 int strrstr(const String &search,uint32 offset=0); // Returns offset to substring or -1 bool replace(uint32 offset,uint32 arg_length,const String &to); -- cgit v1.2.1