summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorserg@serg.mylan <>2004-08-20 00:52:43 +0200
committerserg@serg.mylan <>2004-08-20 00:52:43 +0200
commit62722e7b0528a97ef0b5831cb27c1acfd4d5e856 (patch)
tree5fff92365d8baf56b0bfb2391843398321d56ee2 /sql
parent22546845f2651074cff2d48aa708365f40c1cfa9 (diff)
parent068a57b12c46b15dd9e8192fe0fb0def468eb5ab (diff)
downloadmariadb-git-62722e7b0528a97ef0b5831cb27c1acfd4d5e856.tar.gz
merged
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc20
-rw-r--r--sql/ha_innodb.cc27
-rw-r--r--sql/log.cc5
-rw-r--r--sql/mysql_priv.h1
-rw-r--r--sql/sql_class.h2
5 files changed, 42 insertions, 13 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 522daa9e2cd..96f4fa8fd86 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -4279,7 +4279,7 @@ int Field_str::store(double nr)
{
bool use_scientific_notation=TRUE;
char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE];
- int length;
+ uint length;
if (field_length < 32 && nr > 1) // TODO: negative numbers
{
if (ceiling == 0)
@@ -4295,11 +4295,19 @@ int Field_str::store(double nr)
}
use_scientific_notation= (ceiling < nr);
}
- length= sprintf(buff, "%-.*g",
- use_scientific_notation ? max(0,field_length-5) : field_length,
- nr);
- DBUG_ASSERT(length <= field_length);
- return store((const char *)buff, (uint) length, charset());
+ length= (uint)sprintf(buff, "%-.*g",
+ use_scientific_notation ? max(0,(int)field_length-5) : field_length,
+ nr);
+ /*
+ +1 below is because "precision" in %g above means the
+ max. number of significant digits, not the output width.
+ Thus the width can be larger than number of significant digits by 1
+ (for decimal point)
+ the test for field_length < 5 is for extreme cases,
+ like inserting 500.0 in char(1)
+ */
+ DBUG_ASSERT(field_length < 5 || length <= field_length+1);
+ return store((const char *)buff, min(length, field_length), charset());
}
int Field_string::store(longlong nr)
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index b1e5a16bc32..5aa7c02fcc0 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -40,6 +40,7 @@ have disables the InnoDB inlining in this file. */
#include <m_ctype.h>
#include <hash.h>
#include <myisampack.h>
+#include <mysys_err.h>
#define MAX_ULONG_BIT ((ulong) 1 << (sizeof(ulong)*8-1))
@@ -433,6 +434,7 @@ innobase_mysql_tmpfile(void)
/* out: temporary file descriptor, or < 0 on error */
{
char filename[FN_REFLEN];
+ int fd2 = -1;
File fd = create_temp_file(filename, NullS, "ib",
#ifdef __WIN__
O_BINARY | O_TRUNC | O_SEQUENTIAL |
@@ -440,12 +442,31 @@ innobase_mysql_tmpfile(void)
#endif /* __WIN__ */
O_CREAT | O_EXCL | O_RDWR,
MYF(MY_WME));
-#ifndef __WIN__
if (fd >= 0) {
+#ifndef __WIN__
+ /* On Windows, open files cannot be removed, but files can be
+ created with the O_TEMPORARY flag to the same effect
+ ("delete on close"). */
unlink(filename);
- }
#endif /* !__WIN__ */
- return(fd);
+ /* Copy the file descriptor, so that the additional resources
+ allocated by create_temp_file() can be freed by invoking
+ my_close().
+
+ Because the file descriptor returned by this function
+ will be passed to fdopen(), it will be closed by invoking
+ fclose(), which in turn will invoke close() instead of
+ my_close(). */
+ fd2 = dup(fd);
+ if (fd2 < 0) {
+ DBUG_PRINT("error",("Got error %d on dup",fd2));
+ my_errno=errno;
+ my_error(EE_OUT_OF_FILERESOURCES,
+ MYF(ME_BELL+ME_WAITTANG), filename, my_errno);
+ }
+ my_close(fd, MYF(MY_WME));
+ }
+ return(fd2);
}
/*************************************************************************
diff --git a/sql/log.cc b/sql/log.cc
index bcac7267f8b..240965fdca3 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -1878,11 +1878,10 @@ void MYSQL_LOG::set_max_size(ulong max_size_arg)
Disable_binlog::Disable_binlog(THD *thd_arg) :
- thd(thd_arg),
- save_options(thd_arg->options)
+ thd(thd_arg), save_options(thd_arg->options)
{
thd_arg->options&= ~OPTION_BIN_LOG;
-};
+}
Disable_binlog::~Disable_binlog()
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 4b8a14474fa..031f021e261 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -519,6 +519,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
HA_CREATE_INFO *create_info,
List<create_field> &fields, List<Key> &keys,
bool tmp_table, uint select_field_count);
+
TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
const char *db, const char *name,
List<create_field> *extra_fields,
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 1fb2d5071f6..586458127d4 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1026,7 +1026,7 @@ public:
so we internally disable it temporarily by creating the Disable_binlog
object and reset the state by destroying the object (don't forget that! or
write code so that the object gets automatically destroyed when leaving a
- function...).
+ block, see example in sql_table.cc).
*/
class Disable_binlog {
private: