summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmakelists.txt9
-rw-r--r--libmysql/mytest.c147
-rw-r--r--libmysqld/lib_sql.cc2
-rw-r--r--mysql-test/r/csv.result30
-rw-r--r--mysql-test/t/csv.test23
-rw-r--r--server-tools/instance-manager/guardian.cc2
-rw-r--r--server-tools/instance-manager/mysql_connection.cc2
-rw-r--r--sql/ha_partition.cc4
-rw-r--r--sql/sql_delete.cc1
-rw-r--r--sql/sql_handler.cc1
-rw-r--r--storage/csv/ha_tina.cc28
-rw-r--r--win/README5
12 files changed, 239 insertions, 15 deletions
diff --git a/cmakelists.txt b/cmakelists.txt
index 70b017c757d..0e91f49be90 100644
--- a/cmakelists.txt
+++ b/cmakelists.txt
@@ -3,6 +3,9 @@ PROJECT(MySql)
# This reads user configuration, generated by configure.js.
INCLUDE(win/configure.data)
+# Hardcode support for CSV storage engine
+SET(WITH_CSV_STORAGE_ENGINE TRUE)
+
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/mysql_version.h.in
${CMAKE_SOURCE_DIR}/include/mysql_version.h @ONLY)
@@ -18,6 +21,12 @@ IF(WITH_BLACKHOLE_STORAGE_ENGINE)
SET (mysql_se_decls "${mysql_se_decls}, blackhole_hton")
SET (mysql_se_ha_src ${mysql_se_ha_src} "../sql/ha_blackhole.cc")
ENDIF(WITH_BLACKHOLE_STORAGE_ENGINE)
+IF(WITH_CSV_STORAGE_ENGINE)
+ ADD_DEFINITIONS(-D WITH_CSV_STORAGE_ENGINE)
+ SET (mysql_se_htons "${mysql_se_htons}, &tina_hton")
+ SET (mysql_se_decls "${mysql_se_decls}, tina_hton")
+ SET (mysql_se_ha_src ${mysql_se_ha_src} "../storage/csv/ha_tina.cc")
+ENDIF(WITH_CSV_STORAGE_ENGINE)
IF(WITH_EXAMPLE_STORAGE_ENGINE)
ADD_DEFINITIONS(-D WITH_EXAMPLE_STORAGE_ENGINE)
SET (mysql_se_htons "${mysql_se_htons}, &example_hton")
diff --git a/libmysql/mytest.c b/libmysql/mytest.c
index a1dc13db39f..e1acf3e2136 100644
--- a/libmysql/mytest.c
+++ b/libmysql/mytest.c
@@ -1,54 +1,103 @@
/*C4*/
+
/****************************************************************/
+
/* Author: Jethro Wright, III TS : 3/ 4/1998 9:15 */
+
/* Date: 02/18/1998 */
+
/* mytest.c : do some testing of the libmySQL.DLL.... */
+
/* */
+
/* History: */
+
/* 02/18/1998 jw3 also sprach zarathustra.... */
+
/****************************************************************/
+
+
+
#include <windows.h>
+
#include <stdio.h>
+
#include <string.h>
+
+
#include <mysql.h>
+
+
#define DEFALT_SQL_STMT "SELECT * FROM db"
+
#ifndef offsetof
+
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+
#endif
+
+
+
/********************************************************
+
**
+
** main :-
+
**
+
********************************************************/
+
+
int
+
main( int argc, char * argv[] )
+
{
+
+
char szSQL[ 200 ], aszFlds[ 25 ][ 25 ], szDB[ 50 ] ;
+
const char *pszT;
int i, j, k, l, x ;
+
MYSQL * myData ;
+
MYSQL_RES * res ;
+
MYSQL_FIELD * fd ;
+
MYSQL_ROW row ;
+
+
//....just curious....
+
printf( "sizeof( MYSQL ) == %d\n", (int) sizeof( MYSQL ) ) ;
if ( argc == 2 )
+
{
+
strcpy( szDB, argv[ 1 ] ) ;
+
strcpy( szSQL, DEFALT_SQL_STMT ) ;
+
if (!strcmp(szDB,"--debug"))
+
{
+
strcpy( szDB, "mysql" ) ;
+
printf("Some mysql struct information (size and offset):\n");
+
printf("net:\t%3d %3d\n",(int) sizeof(myData->net),
(int) offsetof(MYSQL,net));
printf("host:\t%3d %3d\n",(int) sizeof(myData->host),
@@ -75,101 +124,199 @@ main( int argc, char * argv[] )
printf("options:\t%3d %3d\n",(int) sizeof(myData->options),
(int) offsetof(MYSQL,options));
puts("");
+
}
+
}
+
else if ( argc > 2 ) {
+
strcpy( szDB, argv[ 1 ] ) ;
+
strcpy( szSQL, argv[ 2 ] ) ;
+
}
+
else {
+
strcpy( szDB, "mysql" ) ;
+
strcpy( szSQL, DEFALT_SQL_STMT ) ;
+
}
+
//....
+
+
if ( (myData = mysql_init((MYSQL*) 0)) &&
+
mysql_real_connect( myData, NULL, NULL, NULL, NULL, MYSQL_PORT,
+
NULL, 0 ) )
+
{
+
myData->reconnect= 1;
if ( mysql_select_db( myData, szDB ) < 0 ) {
+
printf( "Can't select the %s database !\n", szDB ) ;
+
mysql_close( myData ) ;
+
return 2 ;
+
}
+
}
+
else {
+
printf( "Can't connect to the mysql server on port %d !\n",
+
MYSQL_PORT ) ;
+
mysql_close( myData ) ;
+
return 1 ;
+
}
+
//....
+
if ( ! mysql_query( myData, szSQL ) ) {
+
res = mysql_store_result( myData ) ;
+
i = (int) mysql_num_rows( res ) ; l = 1 ;
+
printf( "Query: %s\nNumber of records found: %ld\n", szSQL, i ) ;
+
//....we can get the field-specific characteristics here....
+
for ( x = 0 ; fd = mysql_fetch_field( res ) ; x++ )
+
strcpy( aszFlds[ x ], fd->name ) ;
+
//....
+
while ( row = mysql_fetch_row( res ) ) {
+
j = mysql_num_fields( res ) ;
+
printf( "Record #%ld:-\n", l++ ) ;
+
for ( k = 0 ; k < j ; k++ )
+
printf( " Fld #%d (%s): %s\n", k + 1, aszFlds[ k ],
+
(((row[k]==NULL)||(!strlen(row[k])))?"NULL":row[k])) ;
+
puts( "==============================\n" ) ;
+
}
+
mysql_free_result( res ) ;
+
}
+
else printf( "Couldn't execute %s on the server !\n", szSQL ) ;
+
//....
+
puts( "==== Diagnostic info ====" ) ;
+
pszT = mysql_get_client_info() ;
+
printf( "Client info: %s\n", pszT ) ;
+
//....
+
pszT = mysql_get_host_info( myData ) ;
+
printf( "Host info: %s\n", pszT ) ;
+
//....
+
pszT = mysql_get_server_info( myData ) ;
+
printf( "Server info: %s\n", pszT ) ;
+
//....
+
res = mysql_list_processes( myData ) ; l = 1 ;
+
if (res)
+
{
+
for ( x = 0 ; fd = mysql_fetch_field( res ) ; x++ )
+
strcpy( aszFlds[ x ], fd->name ) ;
+
while ( row = mysql_fetch_row( res ) ) {
+
j = mysql_num_fields( res ) ;
+
printf( "Process #%ld:-\n", l++ ) ;
+
for ( k = 0 ; k < j ; k++ )
+
printf( " Fld #%d (%s): %s\n", k + 1, aszFlds[ k ],
+
(((row[k]==NULL)||(!strlen(row[k])))?"NULL":row[k])) ;
+
puts( "==============================\n" ) ;
+
}
+
}
+
else
+
{
+
printf("Got error %s when retreiving processlist\n",mysql_error(myData));
+
}
+
//....
+
res = mysql_list_tables( myData, "%" ) ; l = 1 ;
+
for ( x = 0 ; fd = mysql_fetch_field( res ) ; x++ )
+
strcpy( aszFlds[ x ], fd->name ) ;
+
while ( row = mysql_fetch_row( res ) ) {
+
j = mysql_num_fields( res ) ;
+
printf( "Table #%ld:-\n", l++ ) ;
+
for ( k = 0 ; k < j ; k++ )
+
printf( " Fld #%d (%s): %s\n", k + 1, aszFlds[ k ],
+
(((row[k]==NULL)||(!strlen(row[k])))?"NULL":row[k])) ;
+
puts( "==============================\n" ) ;
+
}
+
//....
+
pszT = mysql_stat( myData ) ;
+
puts( pszT ) ;
+
//....
+
mysql_close( myData ) ;
+
return 0 ;
+
+
}
+
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index 70022d526a5..9e763df8a0a 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -274,7 +274,6 @@ static int emb_stmt_execute(MYSQL_STMT *stmt)
{
DBUG_ENTER("emb_stmt_execute");
char header[5];
- MYSQL_DATA *res;
THD *thd;
int4store(header, stmt->stmt_id);
@@ -1033,7 +1032,6 @@ void Protocol_simple::prepare_for_resend()
data->embedded_info->prev_ptr= &cur->next;
next_field=cur->data;
next_mysql_field= data->embedded_info->fields_list;
-err:
DBUG_VOID_RETURN;
}
diff --git a/mysql-test/r/csv.result b/mysql-test/r/csv.result
index 70eaac2eb4e..3adcc895474 100644
--- a/mysql-test/r/csv.result
+++ b/mysql-test/r/csv.result
@@ -5085,6 +5085,36 @@ Table Op Msg_type Msg_text
test.test_repair_table5 repair status OK
SELECT * FROM test_repair_table5;
num magic_no company_name founded
+INSERT INTO test_repair_table5 VALUES (1, 102, "CORRECT", 1876);
+SELECT * FROM test_repair_table5;
+num magic_no company_name founded
+1 0102 CORRECT 1876
+FLUSH TABLES;
+CHECK TABLE test_repair_table5;
+Table Op Msg_type Msg_text
+test.test_repair_table5 check error Corrupt
+REPAIR TABLE test_repair_table5;
+Table Op Msg_type Msg_text
+test.test_repair_table5 repair status OK
+SELECT * FROM test_repair_table5;
+num magic_no company_name founded
+1 0102 CORRECT 1876
+INSERT INTO test_repair_table5 VALUES (1, 102, "CORRECT2", 1876);
+SELECT * FROM test_repair_table5;
+num magic_no company_name founded
+1 0102 CORRECT 1876
+1 0102 CORRECT2 1876
+FLUSH TABLES;
+CHECK TABLE test_repair_table5;
+Table Op Msg_type Msg_text
+test.test_repair_table5 check error Corrupt
+REPAIR TABLE test_repair_table5;
+Table Op Msg_type Msg_text
+test.test_repair_table5 repair status OK
+SELECT * FROM test_repair_table5;
+num magic_no company_name founded
+1 0102 CORRECT 1876
+1 0102 CORRECT2 1876
DROP TABLE test_repair_table5;
create table t1 (a int) engine=csv;
insert t1 values (1);
diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test
index 63c76e79fc7..9ba99167ab9 100644
--- a/mysql-test/t/csv.test
+++ b/mysql-test/t/csv.test
@@ -1477,8 +1477,29 @@ CREATE TABLE test_repair_table5 (
CHECK TABLE test_repair_table5;
REPAIR TABLE test_repair_table5;
SELECT * FROM test_repair_table5;
-DROP TABLE test_repair_table5;
+INSERT INTO test_repair_table5 VALUES (1, 102, "CORRECT", 1876);
+SELECT * FROM test_repair_table5;
+# Corrupt a table -- put a row with wrong # of columns at end of file
+--exec perl -e 'print "\"1\",\"101\",\"IBM\"\n";' >> $MYSQLTEST_VARDIR/master-data/test/test_repair_table5.CSV
+
+FLUSH TABLES;
+CHECK TABLE test_repair_table5;
+REPAIR TABLE test_repair_table5;
+# The correct record inserted should still be in the file
+SELECT * FROM test_repair_table5;
+INSERT INTO test_repair_table5 VALUES (1, 102, "CORRECT2", 1876);
+SELECT * FROM test_repair_table5;
+
+# Corrupt table again -- put a row with wrong # of columns at end of file
+--exec perl -e 'print "\"1\",\"101\",\"IBM\"\n";' >> $MYSQLTEST_VARDIR/master-data/test/test_repair_table5.CSV
+
+FLUSH TABLES;
+CHECK TABLE test_repair_table5;
+REPAIR TABLE test_repair_table5;
+# The two correct records inserted should still be in the file
+SELECT * FROM test_repair_table5;
+DROP TABLE test_repair_table5;
#
# BUG#13406 - incorrect amount of "records deleted"
diff --git a/server-tools/instance-manager/guardian.cc b/server-tools/instance-manager/guardian.cc
index 7a532263846..3be672cd71c 100644
--- a/server-tools/instance-manager/guardian.cc
+++ b/server-tools/instance-manager/guardian.cc
@@ -201,8 +201,6 @@ void Guardian_thread::run()
while (node != NULL)
{
- struct timespec timeout;
-
GUARD_NODE *current_node= (GUARD_NODE *) node->data;
instance= ((GUARD_NODE *) node->data)->instance;
process_instance(instance, current_node, &guarded_instances, node);
diff --git a/server-tools/instance-manager/mysql_connection.cc b/server-tools/instance-manager/mysql_connection.cc
index bf39c843f0a..dcd1807701f 100644
--- a/server-tools/instance-manager/mysql_connection.cc
+++ b/server-tools/instance-manager/mysql_connection.cc
@@ -136,7 +136,7 @@ int Mysql_connection_thread::init()
/* Initialize random number generator */
{
ulong seed1= (ulong) &rand_st + rand();
- ulong seed2= rand() + time(0);
+ ulong seed2= (ulong) rand() + time(0);
randominit(&rand_st, seed1, seed2);
}
/* Fill scramble - server's random message used for handshake */
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 3f74b555f4a..af020511dfd 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -1135,7 +1135,6 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt,
partition_element *part_elem= part_it++;
if (all_parts || part_elem->part_state == PART_CHANGED)
{
- handler *file;
if (m_is_sub_partitioned)
{
List_iterator<partition_element> sub_it(part_elem->subpartitions);
@@ -2311,7 +2310,7 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
err_handler:
while (file-- != m_file)
(*file)->close();
-err:
+
DBUG_RETURN(error);
}
@@ -2915,7 +2914,6 @@ int ha_partition::rnd_init(bool scan)
int error;
uint i= 0;
uint32 part_id;
- handler **file;
DBUG_ENTER("ha_partition::rnd_init");
include_partition_fields_in_used_fields();
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 804270992e5..4365d5b04ce 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -870,7 +870,6 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
TABLE *table;
bool error;
uint closed_log_tables= 0, lock_logger= 0;
- TABLE_LIST *tmp_table_list;
uint path_length;
DBUG_ENTER("mysql_truncate");
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index 9dfa20da522..18b63ba49a3 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -337,7 +337,6 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
ha_rows select_limit_cnt, ha_rows offset_limit_cnt)
{
TABLE_LIST *hash_tables;
- TABLE **table_ptr;
TABLE *table;
MYSQL_LOCK *lock;
List<Item> list;
diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc
index 537e5b1bcc4..810292488fa 100644
--- a/storage/csv/ha_tina.cc
+++ b/storage/csv/ha_tina.cc
@@ -451,6 +451,7 @@ static int free_share(TINA_SHARE *share)
result_code= 1;
if (share->mapped_file)
my_munmap(share->mapped_file, share->file_stat.st_size);
+ share->mapped_file= NULL;
result_code= my_close(share->data_file,MYF(0));
hash_delete(&tina_open_tables, (byte*) share);
thr_lock_delete(&share->lock);
@@ -1228,9 +1229,10 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt)
my_free((char*)buf, MYF(0));
- /* The file is ok */
if (rc == HA_ERR_END_OF_FILE)
{
+ /* All rows were read ok until end of file, the file does not need repair. */
+
/*
If rows_recorded != rows_repaired, we should update
rows_recorded value to the current amount of rows.
@@ -1258,11 +1260,29 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt)
if (my_munmap(share->mapped_file, share->file_stat.st_size))
DBUG_RETURN(-1);
-
- my_rename(repaired_fname, share->data_file_name, MYF(0));
-
/* We set it to null so that get_mmap() won't try to unmap it */
share->mapped_file= NULL;
+
+ /*
+ Close the "to"-file before renaming
+ On Windows one cannot rename a file, which descriptor
+ is still open. EACCES will be returned when trying to delete
+ the "to"-file in my_rename()
+ */
+ my_close(share->data_file,MYF(0));
+
+ if (my_rename(repaired_fname, share->data_file_name, MYF(0)))
+ DBUG_RETURN(-1);
+
+ /* Open the file again, it should now be repaired */
+ if ((share->data_file= my_open(share->data_file_name, O_RDWR|O_APPEND,
+ MYF(0))) == -1)
+ DBUG_RETURN(-1);
+
+ /* Seek to end of file, any inserts will be appended there */
+ if (my_seek(share->data_file, 0, SEEK_END, MYF(0)) == MY_FILEPOS_ERROR)
+ DBUG_RETURN(-1);
+
if (get_mmap(share, 0) > 0)
DBUG_RETURN(-1);
diff --git a/win/README b/win/README
index dcd65516abe..4aab39575e0 100644
--- a/win/README
+++ b/win/README
@@ -75,3 +75,8 @@ Current issues
--------------
1. After changing configuration (eg. adding or removing a storage engine), it
may be necessary to clean the build tree to remove any stale objects.
+
+2. To use Visual C++ Express Edition you also need to install the Platform SDK.
+Please see this link: http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/
+At step 4 you only need to add the libraries advapi32.lib and user32.lib to
+the file "corewin_express.vsprops" in order to avoid link errors.