1
/* - mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 MySQL
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
#include <drizzled/server_includes.h>
23
#include <drizzled/field/longstr.h>
26
Check if we lost any important data and send a truncation error/warning
29
Field_longstr::report_if_important_data()
30
ptr - Truncated rest of string
31
end - End of truncated string
34
0 - None was truncated (or we don't count cut fields)
35
2 - Some bytes was truncated
38
Check if we lost any important data (anything in a binary string,
39
or any non-space in others). If only trailing spaces was lost,
40
send a truncation note, otherwise send a truncation error.
44
Field_longstr::report_if_important_data(const char *ptr, const char *end)
46
if ((ptr < end) && table->in_use->count_cuted_fields)
48
if (test_if_important_data(field_charset, ptr, end))
50
if (table->in_use->abort_on_warning)
51
set_warning(DRIZZLE_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1);
53
set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1);
55
else /* If we lost only spaces then produce a NOTE, not a WARNING */
56
set_warning(DRIZZLE_ERROR::WARN_LEVEL_NOTE, ER_WARN_DATA_TRUNCATED, 1);
62
int Field_longstr::store_decimal(const my_decimal *d)
64
char buff[DECIMAL_MAX_STR_LENGTH+1];
65
String str(buff, sizeof(buff), &my_charset_bin);
66
my_decimal2string(E_DEC_FATAL_ERROR, d, 0, 0, 0, &str);
67
return store(str.ptr(), str.length(), str.charset());
70
uint32_t Field_longstr::max_data_length() const
72
return field_length + (field_length > 255 ? 2 : 1);