mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
5bddbc44c6
- Added checking of return value for system(), freopen(), fgets() and chown() - Ensure that calls that require a format strings gets a format string - Other trivial things Updated test suite results (especially for pbxt and embedded server) Removed warning for "Invalid (old?) table or database name 'mysqld.1'" from pbxt tests Speed up some pbxt tests by inserting begin ; commit; around "while loops with inserts" Added mysqld startup option '--debug-flush' Create maria_recovery.trace in data directory instead of current directory client/mysql.cc: Check return value from system() client/mysql_upgrade.c: Check return value from fgets() client/mysqladmin.cc: Check return value from fgets() client/mysqlslap.c: Check return value from system() (but ignore it, as it's not critical) extra/yassl/src/crypto_wrapper.cpp: Check return value from fgets() (but ignore it, as it's internal file) extra/yassl/taocrypt/src/aes.cpp: Added extra {} to remove compiler warning extra/yassl/taocrypt/src/blowfish.cpp: Added extra {} to remove compiler warning extra/yassl/taocrypt/src/misc.cpp: Ifdef not used code include/mysys_err.h: Added error message for failing chown() mysql-test/mysql-test-run.pl: Don't give warning for skipping ndbcluster (never enabled in MariaDB) mysql-test/suite/funcs_1/r/is_columns_is_embedded.result: Update with new information schema information mysql-test/suite/funcs_1/r/is_tables_is_embedded.result: New test mysql-test/suite/funcs_1/r/is_tables_myisam_embedded.result: Update test results (has not been tested for a long time) mysql-test/suite/funcs_1/r/is_tables_mysql_embedded.result: Update test results (has not been tested for a long time) mysql-test/suite/funcs_1/t/is_tables_is.test: Don't run with embedded server (as results differ) I added a new test for embedded server mysql-test/suite/funcs_1/t/is_tables_is_embedded.test: New test mysql-test/suite/pbxt/my.cnf: Allow one to run pbxt tests without having to specify --mysqld=--default-storage-engine=pbxt mysql-test/suite/pbxt/t/count_distinct3.test: Speed up test by inserting begin; ... commit; mysql-test/suite/pbxt/t/subselect.test: Speed up test by inserting begin; ... commit; mysys/errors.c: Added error message for failing chown() mysys/my_copy.c: Added error message for failing chown() mysys/my_redel.c: Added error message for failing chown() mysys/safemalloc.c: Added cast to get rid of compiler warning sql/ha_partition.cc: Fixed wrong argument to sql_print_error() (it requires a format string) sql/log.cc: Test return value of freopen() sql/mysqld.cc: Test return value of freopen() Added startup option '--debug-flush' to be used when one gets a core dump (easy to explain to people on IRC) sql/rpl_rli.cc: Fixed wrong argument to sql_print_error() (it requires a format string) sql/set_var.cc: Added {} to get rid of compiler warnings sql/slave.cc: Fixed wrong argument to mi->report() and sql_print...() (they require a format string) sql/sql_cache.cc: Fixed wrong argument to sql_printinformation() (it requires a format string) sql/sql_parse.cc: Test return value of fgets() sql/sql_plugin.cc: Fixed wrong argument to sql_print_error() (it requires a format string) sql/sql_select.cc: Use unique table name for internal temp tables instead of full path (Simple speed & space optimization) sql/udf_example.c: Removed compiler warning about not used variable storage/maria/ha_maria.cc: Fixed wrong argument to sql_print_error() and ma_check_print_error() (they require a format string) storage/maria/ma_recovery.c: Create maria_recovery.trace in data directory instead of current directory storage/maria/unittest/ma_test_loghandler-t.c: Fixed wrong argument to ok(); Requires a format string storage/pbxt/src/strutil_xt.cc: Detect temporary tables by checking if that path for the table is in the mysql data directory. The database for temporary tables is after this patch, from PBXT point of view, "" This is needed to stop PBXT from calling filename_to_tablename() with the base directory as an argument, which caused ERROR: Invalid (old?) table or database name 'mysqld.1'" in the log when running the test suite. tests/mysql_client_test.c: Fixed compiler warnings unittest/mysys/base64-t.c: Fixed wrong argument to diag() (it requires a format string) Added a comment that the current 'print' of differing buffers doesn't print the right thing, but didn't fix this as it's not important (unless we find a bug in the real code)
126 lines
3.7 KiB
C
126 lines
3.7 KiB
C
/* Copyright (C) 2000 MySQL AB
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
#include "mysys_priv.h"
|
|
#include "mysys_err.h"
|
|
#include <my_dir.h> /* for stat */
|
|
#include <m_string.h>
|
|
#if defined(HAVE_UTIME_H)
|
|
#include <utime.h>
|
|
#elif defined(HAVE_SYS_UTIME_H)
|
|
#include <sys/utime.h>
|
|
#elif !defined(HPUX10)
|
|
#include <time.h>
|
|
struct utimbuf {
|
|
time_t actime;
|
|
time_t modtime;
|
|
};
|
|
#endif
|
|
|
|
|
|
/*
|
|
int my_copy(const char *from, const char *to, myf MyFlags)
|
|
|
|
NOTES
|
|
Ordinary ownership and accesstimes are copied from 'from-file'
|
|
If MyFlags & MY_HOLD_ORIGINAL_MODES is set and to-file exists then
|
|
the modes of to-file isn't changed
|
|
If MyFlags & MY_DONT_OVERWRITE_FILE is set, we will give an error
|
|
if the file existed.
|
|
|
|
WARNING
|
|
Don't set MY_FNABP or MY_NABP bits on when calling this function !
|
|
|
|
RETURN
|
|
0 ok
|
|
# Error
|
|
|
|
*/
|
|
|
|
int my_copy(const char *from, const char *to, myf MyFlags)
|
|
{
|
|
size_t Count;
|
|
my_bool new_file_stat= 0; /* 1 if we could stat "to" */
|
|
int create_flag;
|
|
File from_file,to_file;
|
|
uchar buff[IO_SIZE];
|
|
MY_STAT stat_buff,new_stat_buff;
|
|
DBUG_ENTER("my_copy");
|
|
DBUG_PRINT("my",("from %s to %s MyFlags %d", from, to, MyFlags));
|
|
|
|
from_file=to_file= -1;
|
|
DBUG_ASSERT(!(MyFlags & (MY_FNABP | MY_NABP))); /* for my_read/my_write */
|
|
if (MyFlags & MY_HOLD_ORIGINAL_MODES) /* Copy stat if possible */
|
|
new_file_stat= test(my_stat((char*) to, &new_stat_buff, MYF(0)));
|
|
|
|
if ((from_file=my_open(from,O_RDONLY | O_SHARE,MyFlags)) >= 0)
|
|
{
|
|
if (!my_stat(from, &stat_buff, MyFlags))
|
|
{
|
|
my_errno=errno;
|
|
goto err;
|
|
}
|
|
if (MyFlags & MY_HOLD_ORIGINAL_MODES && new_file_stat)
|
|
stat_buff=new_stat_buff;
|
|
create_flag= (MyFlags & MY_DONT_OVERWRITE_FILE) ? O_EXCL : O_TRUNC;
|
|
|
|
if ((to_file= my_create(to,(int) stat_buff.st_mode,
|
|
O_WRONLY | create_flag | O_BINARY | O_SHARE,
|
|
MyFlags)) < 0)
|
|
goto err;
|
|
|
|
while ((Count=my_read(from_file, buff, sizeof(buff), MyFlags)) != 0)
|
|
{
|
|
if (Count == (uint) -1 ||
|
|
my_write(to_file,buff,Count,MYF(MyFlags | MY_NABP)))
|
|
goto err;
|
|
}
|
|
|
|
if (my_close(from_file,MyFlags) | my_close(to_file,MyFlags))
|
|
DBUG_RETURN(-1); /* Error on close */
|
|
|
|
/* Copy modes if possible */
|
|
|
|
if (MyFlags & MY_HOLD_ORIGINAL_MODES && !new_file_stat)
|
|
DBUG_RETURN(0); /* File copyed but not stat */
|
|
VOID(chmod(to, stat_buff.st_mode & 07777)); /* Copy modes */
|
|
#if !defined(__WIN__) && !defined(__NETWARE__)
|
|
if (chown(to, stat_buff.st_uid,stat_buff.st_gid))
|
|
{
|
|
my_error(EE_CANT_COPY_OWNERSHIP, MYF(ME_JUST_WARNING), to);
|
|
}
|
|
#endif
|
|
#if !defined(VMS) && !defined(__ZTC__)
|
|
if (MyFlags & MY_COPYTIME)
|
|
{
|
|
struct utimbuf timep;
|
|
timep.actime = stat_buff.st_atime;
|
|
timep.modtime = stat_buff.st_mtime;
|
|
VOID(utime((char*) to, &timep)); /* last accessed and modified times */
|
|
}
|
|
#endif
|
|
DBUG_RETURN(0);
|
|
}
|
|
|
|
err:
|
|
if (from_file >= 0) VOID(my_close(from_file,MyFlags));
|
|
if (to_file >= 0)
|
|
{
|
|
VOID(my_close(to_file, MyFlags));
|
|
/* attempt to delete the to-file we've partially written */
|
|
VOID(my_delete(to, MyFlags));
|
|
}
|
|
DBUG_RETURN(-1);
|
|
} /* my_copy */
|