1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-07 00:04:31 +03:00

manually merged

Gluh's SESSION/GLOBAL for @variables fix in sql_yacc.yy and
Bar's well_formed_len() changes in ndb code
did not make it and should be re-applied manually
This commit is contained in:
serg@serg.mylan
2005-04-06 21:19:20 +02:00
20 changed files with 154 additions and 32 deletions

View File

@@ -149,7 +149,8 @@ typedef struct my_charset_handler_st
uint (*numchars)(struct charset_info_st *, const char *b, const char *e); uint (*numchars)(struct charset_info_st *, const char *b, const char *e);
uint (*charpos)(struct charset_info_st *, const char *b, const char *e, uint pos); uint (*charpos)(struct charset_info_st *, const char *b, const char *e, uint pos);
uint (*well_formed_len)(struct charset_info_st *, uint (*well_formed_len)(struct charset_info_st *,
const char *b,const char *e, uint nchars); const char *b,const char *e,
uint nchars, int *error);
uint (*lengthsp)(struct charset_info_st *, const char *ptr, uint length); uint (*lengthsp)(struct charset_info_st *, const char *ptr, uint length);
uint (*numcells)(struct charset_info_st *, const char *b, const char *e); uint (*numcells)(struct charset_info_st *, const char *b, const char *e);
@@ -349,7 +350,8 @@ int my_wildcmp_8bit(CHARSET_INFO *,
uint my_numchars_8bit(CHARSET_INFO *, const char *b, const char *e); uint my_numchars_8bit(CHARSET_INFO *, const char *b, const char *e);
uint my_numcells_8bit(CHARSET_INFO *, const char *b, const char *e); uint my_numcells_8bit(CHARSET_INFO *, const char *b, const char *e);
uint my_charpos_8bit(CHARSET_INFO *, const char *b, const char *e, uint pos); uint my_charpos_8bit(CHARSET_INFO *, const char *b, const char *e, uint pos);
uint my_well_formed_len_8bit(CHARSET_INFO *, const char *b, const char *e, uint pos); uint my_well_formed_len_8bit(CHARSET_INFO *, const char *b, const char *e,
uint pos, int *error);
int my_mbcharlen_8bit(CHARSET_INFO *, uint c); int my_mbcharlen_8bit(CHARSET_INFO *, uint c);
@@ -367,7 +369,8 @@ int my_wildcmp_mb(CHARSET_INFO *,
uint my_numchars_mb(CHARSET_INFO *, const char *b, const char *e); uint my_numchars_mb(CHARSET_INFO *, const char *b, const char *e);
uint my_numcells_mb(CHARSET_INFO *, const char *b, const char *e); uint my_numcells_mb(CHARSET_INFO *, const char *b, const char *e);
uint my_charpos_mb(CHARSET_INFO *, const char *b, const char *e, uint pos); uint my_charpos_mb(CHARSET_INFO *, const char *b, const char *e, uint pos);
uint my_well_formed_len_mb(CHARSET_INFO *, const char *b, const char *e, uint pos); uint my_well_formed_len_mb(CHARSET_INFO *, const char *b, const char *e,
uint pos, int *error);
uint my_instr_mb(struct charset_info_st *, uint my_instr_mb(struct charset_info_st *,
const char *b, uint b_length, const char *b, uint b_length,
const char *s, uint s_length, const char *s, uint s_length,

View File

@@ -14,6 +14,7 @@ Created 2/23/1996 Heikki Tuuri
#include "ut0byte.h" #include "ut0byte.h"
#include "rem0cmp.h" #include "rem0cmp.h"
#include "trx0trx.h"
/****************************************************************** /******************************************************************
Allocates memory for a persistent cursor object and initializes the cursor. */ Allocates memory for a persistent cursor object and initializes the cursor. */
@@ -206,7 +207,14 @@ btr_pcur_restore_position(
ut_a(cursor->pos_state == BTR_PCUR_WAS_POSITIONED ut_a(cursor->pos_state == BTR_PCUR_WAS_POSITIONED
|| cursor->pos_state == BTR_PCUR_IS_POSITIONED); || cursor->pos_state == BTR_PCUR_IS_POSITIONED);
ut_a(cursor->old_stored == BTR_PCUR_OLD_STORED); if (cursor->old_stored != BTR_PCUR_OLD_STORED) {
ut_print_buf(stderr, (const byte*)cursor, sizeof(btr_pcur_t));
if (cursor->trx_if_known) {
trx_print(stderr, cursor->trx_if_known);
}
ut_a(0);
}
if (cursor->rel_pos == BTR_PCUR_AFTER_LAST_IN_TREE if (cursor->rel_pos == BTR_PCUR_AFTER_LAST_IN_TREE
|| cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE) { || cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE) {

View File

@@ -478,6 +478,10 @@ struct btr_pcur_struct{
BTR_PCUR_WAS_POSITIONED, BTR_PCUR_WAS_POSITIONED,
BTR_PCUR_NOT_POSITIONED */ BTR_PCUR_NOT_POSITIONED */
ulint search_mode; /* PAGE_CUR_G, ... */ ulint search_mode; /* PAGE_CUR_G, ... */
trx_t* trx_if_known; /* the transaction, if we know it;
otherwise this field is not defined;
can ONLY BE USED in error prints in
fatal assertion failures! */
/*-----------------------------*/ /*-----------------------------*/
/* NOTE that the following fields may possess dynamically allocated /* NOTE that the following fields may possess dynamically allocated
memory which should be freed if not needed anymore! */ memory which should be freed if not needed anymore! */

View File

@@ -493,6 +493,8 @@ btr_pcur_open(
btr_cur_search_to_nth_level(index, 0, tuple, mode, latch_mode, btr_cur_search_to_nth_level(index, 0, tuple, mode, latch_mode,
btr_cursor, 0, mtr); btr_cursor, 0, mtr);
cursor->pos_state = BTR_PCUR_IS_POSITIONED; cursor->pos_state = BTR_PCUR_IS_POSITIONED;
cursor->trx_if_known = NULL;
} }
/****************************************************************** /******************************************************************
@@ -535,6 +537,8 @@ btr_pcur_open_with_no_init(
cursor->pos_state = BTR_PCUR_IS_POSITIONED; cursor->pos_state = BTR_PCUR_IS_POSITIONED;
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
cursor->trx_if_known = NULL;
} }
/********************************************************************* /*********************************************************************
@@ -568,6 +572,8 @@ btr_pcur_open_at_index_side(
pcur->pos_state = BTR_PCUR_IS_POSITIONED; pcur->pos_state = BTR_PCUR_IS_POSITIONED;
pcur->old_stored = BTR_PCUR_OLD_NOT_STORED; pcur->old_stored = BTR_PCUR_OLD_NOT_STORED;
pcur->trx_if_known = NULL;
} }
/************************************************************************** /**************************************************************************
@@ -592,6 +598,8 @@ btr_pcur_open_at_rnd_pos(
btr_pcur_get_btr_cur(cursor), mtr); btr_pcur_get_btr_cur(cursor), mtr);
cursor->pos_state = BTR_PCUR_IS_POSITIONED; cursor->pos_state = BTR_PCUR_IS_POSITIONED;
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
cursor->trx_if_known = NULL;
} }
/****************************************************************** /******************************************************************
@@ -617,4 +625,6 @@ btr_pcur_close(
cursor->latch_mode = BTR_NO_LATCHES; cursor->latch_mode = BTR_NO_LATCHES;
cursor->pos_state = BTR_PCUR_NOT_POSITIONED; cursor->pos_state = BTR_PCUR_NOT_POSITIONED;
cursor->trx_if_known = NULL;
} }

View File

@@ -68,6 +68,8 @@ log. */
#define OS_FILE_OVERWRITE 53 #define OS_FILE_OVERWRITE 53
#define OS_FILE_OPEN_RAW 54 #define OS_FILE_OPEN_RAW 54
#define OS_FILE_CREATE_PATH 55 #define OS_FILE_CREATE_PATH 55
#define OS_FILE_OPEN_RETRY 56 /* for os_file_create() on
the first ibdata file */
#define OS_FILE_READ_ONLY 333 #define OS_FILE_READ_ONLY 333
#define OS_FILE_READ_WRITE 444 #define OS_FILE_READ_WRITE 444

View File

@@ -413,8 +413,6 @@ os_file_lock(
"InnoDB: using the same InnoDB data or log files.\n"); "InnoDB: using the same InnoDB data or log files.\n");
} }
close(fd);
return(-1); return(-1);
} }
@@ -989,6 +987,7 @@ try_again:
} else if (access_type == OS_FILE_READ_WRITE } else if (access_type == OS_FILE_READ_WRITE
&& os_file_lock(file, name)) { && os_file_lock(file, name)) {
*success = FALSE; *success = FALSE;
close(file);
file = -1; file = -1;
#endif #endif
} else { } else {
@@ -1101,6 +1100,7 @@ os_file_create_simple_no_error_handling(
} else if (access_type == OS_FILE_READ_WRITE } else if (access_type == OS_FILE_READ_WRITE
&& os_file_lock(file, name)) { && os_file_lock(file, name)) {
*success = FALSE; *success = FALSE;
close(file);
file = -1; file = -1;
#endif #endif
} else { } else {
@@ -1152,7 +1152,8 @@ try_again:
if (create_mode == OS_FILE_OPEN_RAW) { if (create_mode == OS_FILE_OPEN_RAW) {
create_flag = OPEN_EXISTING; create_flag = OPEN_EXISTING;
share_mode = FILE_SHARE_WRITE; share_mode = FILE_SHARE_WRITE;
} else if (create_mode == OS_FILE_OPEN) { } else if (create_mode == OS_FILE_OPEN
|| create_mode == OS_FILE_OPEN_RETRY) {
create_flag = OPEN_EXISTING; create_flag = OPEN_EXISTING;
} else if (create_mode == OS_FILE_CREATE) { } else if (create_mode == OS_FILE_CREATE) {
create_flag = CREATE_NEW; create_flag = CREATE_NEW;
@@ -1243,7 +1244,8 @@ try_again:
try_again: try_again:
ut_a(name); ut_a(name);
if (create_mode == OS_FILE_OPEN || create_mode == OS_FILE_OPEN_RAW) { if (create_mode == OS_FILE_OPEN || create_mode == OS_FILE_OPEN_RAW
|| create_mode == OS_FILE_OPEN_RETRY) {
mode_str = "OPEN"; mode_str = "OPEN";
create_flag = O_RDWR; create_flag = O_RDWR;
} else if (create_mode == OS_FILE_CREATE) { } else if (create_mode == OS_FILE_CREATE) {
@@ -1316,6 +1318,23 @@ try_again:
} else if (create_mode != OS_FILE_OPEN_RAW } else if (create_mode != OS_FILE_OPEN_RAW
&& os_file_lock(file, name)) { && os_file_lock(file, name)) {
*success = FALSE; *success = FALSE;
if (create_mode == OS_FILE_OPEN_RETRY) {
int i;
ut_print_timestamp(stderr);
fputs(" InnoDB: Retrying to lock the first data file\n",
stderr);
for (i = 0; i < 100; i++) {
os_thread_sleep(1000000);
if (!os_file_lock(file, name)) {
*success = TRUE;
return(file);
}
}
ut_print_timestamp(stderr);
fputs(" InnoDB: Unable to open the first data file\n",
stderr);
}
close(file);
file = -1; file = -1;
#endif #endif
} else { } else {

View File

@@ -2644,6 +2644,8 @@ row_sel_get_clust_rec_for_mysql(
clust_rec = btr_pcur_get_rec(prebuilt->clust_pcur); clust_rec = btr_pcur_get_rec(prebuilt->clust_pcur);
prebuilt->clust_pcur->trx_if_known = trx;
/* Note: only if the search ends up on a non-infimum record is the /* Note: only if the search ends up on a non-infimum record is the
low_match value the real match to the search tuple */ low_match value the real match to the search tuple */
@@ -3406,6 +3408,8 @@ shortcut_fails_too_big_rec:
btr_pcur_open_with_no_init(index, search_tuple, mode, btr_pcur_open_with_no_init(index, search_tuple, mode,
BTR_SEARCH_LEAF, BTR_SEARCH_LEAF,
pcur, 0, &mtr); pcur, 0, &mtr);
pcur->trx_if_known = trx;
} else { } else {
if (mode == PAGE_CUR_G) { if (mode == PAGE_CUR_G) {
btr_pcur_open_at_index_side(TRUE, index, btr_pcur_open_at_index_side(TRUE, index,

View File

@@ -789,6 +789,11 @@ open_or_create_data_files(
files[i] = os_file_create( files[i] = os_file_create(
name, OS_FILE_OPEN_RAW, OS_FILE_NORMAL, name, OS_FILE_OPEN_RAW, OS_FILE_NORMAL,
OS_DATA_FILE, &ret); OS_DATA_FILE, &ret);
} else if (i == 0) {
files[i] = os_file_create(
name, OS_FILE_OPEN_RETRY,
OS_FILE_NORMAL,
OS_DATA_FILE, &ret);
} else { } else {
files[i] = os_file_create( files[i] = os_file_create(
name, OS_FILE_OPEN, OS_FILE_NORMAL, name, OS_FILE_OPEN, OS_FILE_NORMAL,

View File

@@ -179,3 +179,7 @@ set @v1=null, @v2=1, @v3=1.1, @v4=now();
select coercibility(@v1),coercibility(@v2),coercibility(@v3),coercibility(@v4); select coercibility(@v1),coercibility(@v2),coercibility(@v3),coercibility(@v4);
coercibility(@v1) coercibility(@v2) coercibility(@v3) coercibility(@v4) coercibility(@v1) coercibility(@v2) coercibility(@v3) coercibility(@v4)
2 2 2 2 2 2 2 2
set session @honk=99;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@honk=99' at line 1
set one_shot @honk=99;
ERROR HY000: The SET ONE_SHOT syntax is reserved for purposes internal to the MySQL server

View File

@@ -112,3 +112,11 @@ select FIELD( @var,'1it','Hit') as my_column;
select @v, coercibility(@v); select @v, coercibility(@v);
set @v1=null, @v2=1, @v3=1.1, @v4=now(); set @v1=null, @v2=1, @v3=1.1, @v4=now();
select coercibility(@v1),coercibility(@v2),coercibility(@v3),coercibility(@v4); select coercibility(@v1),coercibility(@v2),coercibility(@v3),coercibility(@v4);
#
# Bug #9286 SESSION/GLOBAL should be disallowed for user variables
#
--error 1064
set session @honk=99;
--error 1105
set one_shot @honk=99;

View File

@@ -658,6 +658,7 @@ private:
// Release all cursor operations in connection // Release all cursor operations in connection
void releaseOps(NdbOperation*); void releaseOps(NdbOperation*);
void releaseScanOperations(NdbIndexScanOperation*); void releaseScanOperations(NdbIndexScanOperation*);
void releaseExecutedScanOperation(NdbIndexScanOperation*);
// Set the transaction identity of the transaction // Set the transaction identity of the transaction
void setTransactionId(Uint64 aTransactionId); void setTransactionId(Uint64 aTransactionId);

View File

@@ -948,6 +948,37 @@ NdbTransaction::releaseScanOperations(NdbIndexScanOperation* cursorOp)
} }
}//NdbTransaction::releaseScanOperations() }//NdbTransaction::releaseScanOperations()
/*****************************************************************************
void releaseExecutedScanOperation();
Remark: Release scan op when hupp'ed trans closed (save memory)
******************************************************************************/
void
NdbConnection::releaseExecutedScanOperation(NdbIndexScanOperation* cursorOp)
{
DBUG_ENTER("NdbConnection::releaseExecutedScanOperation");
DBUG_PRINT("enter", ("this=0x%x op=0x%x", (UintPtr)this, (UintPtr)cursorOp))
// here is one reason to make op lists doubly linked
if (m_firstExecutedScanOp == cursorOp) {
m_firstExecutedScanOp = (NdbIndexScanOperation*)cursorOp->theNext;
cursorOp->release();
theNdb->releaseScanOperation(cursorOp);
} else if (m_firstExecutedScanOp != NULL) {
NdbIndexScanOperation* tOp = m_firstExecutedScanOp;
while (tOp->theNext != NULL) {
if (tOp->theNext == cursorOp) {
tOp->theNext = cursorOp->theNext;
cursorOp->release();
theNdb->releaseScanOperation(cursorOp);
break;
}
tOp = (NdbIndexScanOperation*)tOp->theNext;
}
}
DBUG_VOID_RETURN;
}//NdbConnection::releaseExecutedScanOperation()
/***************************************************************************** /*****************************************************************************
NdbOperation* getNdbOperation(const char* aTableName); NdbOperation* getNdbOperation(const char* aTableName);

View File

@@ -5777,7 +5777,7 @@ void Field_datetime::sql_type(String &res) const
int Field_string::store(const char *from,uint length,CHARSET_INFO *cs) int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
{ {
int error= 0; int error= 0, well_formed_error;
uint32 not_used; uint32 not_used;
char buff[STRING_BUFFER_USUAL_SIZE]; char buff[STRING_BUFFER_USUAL_SIZE];
String tmpstr(buff,sizeof(buff), &my_charset_bin); String tmpstr(buff,sizeof(buff), &my_charset_bin);
@@ -5804,7 +5804,8 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
copy_length= field_charset->cset->well_formed_len(field_charset, copy_length= field_charset->cset->well_formed_len(field_charset,
from,from+length, from,from+length,
field_length/ field_length/
field_charset->mbmaxlen); field_charset->mbmaxlen,
&well_formed_error);
memcpy(ptr,from,copy_length); memcpy(ptr,from,copy_length);
if (copy_length < field_length) // Append spaces if shorter if (copy_length < field_length) // Append spaces if shorter
field_charset->cset->fill(field_charset,ptr+copy_length, field_charset->cset->fill(field_charset,ptr+copy_length,
@@ -6152,7 +6153,7 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
uint32 not_used, copy_length; uint32 not_used, copy_length;
char buff[STRING_BUFFER_USUAL_SIZE]; char buff[STRING_BUFFER_USUAL_SIZE];
String tmpstr(buff,sizeof(buff), &my_charset_bin); String tmpstr(buff,sizeof(buff), &my_charset_bin);
int error_code= 0; int error_code= 0, well_formed_error;
enum MYSQL_ERROR::enum_warning_level level= MYSQL_ERROR::WARN_LEVEL_WARN; enum MYSQL_ERROR::enum_warning_level level= MYSQL_ERROR::WARN_LEVEL_WARN;
/* Convert character set if necessary */ /* Convert character set if necessary */
@@ -6172,7 +6173,8 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
copy_length= field_charset->cset->well_formed_len(field_charset, copy_length= field_charset->cset->well_formed_len(field_charset,
from,from+length, from,from+length,
field_length/ field_length/
field_charset->mbmaxlen); field_charset->mbmaxlen,
&well_formed_error);
memcpy(ptr + length_bytes, from, copy_length); memcpy(ptr + length_bytes, from, copy_length);
if (length_bytes == 1) if (length_bytes == 1)
*ptr= (uchar) copy_length; *ptr= (uchar) copy_length;
@@ -6746,7 +6748,7 @@ void Field_blob::put_length(char *pos, uint32 length)
int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs) int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs)
{ {
int error= 0; int error= 0, well_formed_error;
if (!length) if (!length)
{ {
bzero(ptr,Field_blob::pack_length()); bzero(ptr,Field_blob::pack_length());
@@ -6780,7 +6782,8 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs)
copy_length= field_charset->cset->well_formed_len(field_charset, copy_length= field_charset->cset->well_formed_len(field_charset,
from,from + from,from +
min(length, copy_length), min(length, copy_length),
copy_length); copy_length,
&well_formed_error);
if (copy_length < length) if (copy_length < length)
error= 1; error= 1;
Field_blob::store_length(copy_length); Field_blob::store_length(copy_length);

View File

@@ -7020,9 +7020,10 @@ IDENT_sys:
if (thd->charset_is_system_charset) if (thd->charset_is_system_charset)
{ {
CHARSET_INFO *cs= system_charset_info; CHARSET_INFO *cs= system_charset_info;
int dummy_error;
uint wlen= cs->cset->well_formed_len(cs, $1.str, uint wlen= cs->cset->well_formed_len(cs, $1.str,
$1.str+$1.length, $1.str+$1.length,
$1.length); $1.length, &dummy_error);
if (wlen < $1.length) if (wlen < $1.length)
{ {
my_error(ER_INVALID_CHARACTER_STRING, MYF(0), my_error(ER_INVALID_CHARACTER_STRING, MYF(0),

View File

@@ -6294,10 +6294,13 @@ my_mb_wc_big5(CHARSET_INFO *cs __attribute__((unused)),
*/ */
static static
uint my_well_formed_len_big5(CHARSET_INFO *cs __attribute__((unused)), uint my_well_formed_len_big5(CHARSET_INFO *cs __attribute__((unused)),
const char *b, const char *e, uint pos) const char *b, const char *e,
uint pos, int *error)
{ {
const char *b0= b; const char *b0= b;
const char *emb= e - 1; /* Last possible end of an MB character */ const char *emb= e - 1; /* Last possible end of an MB character */
*error= 0;
while (pos && b < e) while (pos && b < e)
{ {
if ((uchar) b[0] < 128) if ((uchar) b[0] < 128)
@@ -6313,6 +6316,7 @@ uint my_well_formed_len_big5(CHARSET_INFO *cs __attribute__((unused)),
else else
{ {
/* Wrong byte sequence */ /* Wrong byte sequence */
*error= 1;
break; break;
} }
} }

View File

@@ -264,18 +264,21 @@ uint my_charpos_mb(CHARSET_INFO *cs __attribute__((unused)),
} }
uint my_well_formed_len_mb(CHARSET_INFO *cs, uint my_well_formed_len_mb(CHARSET_INFO *cs, const char *b, const char *e,
const char *b, const char *e, uint pos) uint pos, int *error)
{ {
const char *b_start= b; const char *b_start= b;
*error= 0;
while (pos) while (pos)
{ {
my_wc_t wc; my_wc_t wc;
int mblen; int mblen;
if ((mblen= cs->cset->mb_wc(cs, &wc, (uchar*) b, (uchar*) e)) <= 0) if ((mblen= cs->cset->mb_wc(cs, &wc, (uchar*) b, (uchar*) e)) <= 0)
{
*error= b < e ? 1 : 0;
break; break;
}
b+= mblen; b+= mblen;
pos--; pos--;
} }

View File

@@ -1122,11 +1122,11 @@ uint my_charpos_8bit(CHARSET_INFO *cs __attribute__((unused)),
uint my_well_formed_len_8bit(CHARSET_INFO *cs __attribute__((unused)), uint my_well_formed_len_8bit(CHARSET_INFO *cs __attribute__((unused)),
const char *start, const char *start, const char *end,
const char *end, uint nchars, int *error)
uint nchars)
{ {
uint nbytes= (uint) (end-start); uint nbytes= (uint) (end-start);
*error= 0;
return min(nbytes, nchars); return min(nbytes, nchars);
} }

View File

@@ -4586,9 +4586,11 @@ uint my_numcells_sjis(CHARSET_INFO *cs __attribute__((unused)),
*/ */
static static
uint my_well_formed_len_sjis(CHARSET_INFO *cs __attribute__((unused)), uint my_well_formed_len_sjis(CHARSET_INFO *cs __attribute__((unused)),
const char *b, const char *e, uint pos) const char *b, const char *e,
uint pos, int *error)
{ {
const char *b0= b; const char *b0= b;
*error= 0;
while (pos && b < e) while (pos && b < e)
{ {
if ((uchar) b[0] < 128) if ((uchar) b[0] < 128)
@@ -4609,6 +4611,7 @@ uint my_well_formed_len_sjis(CHARSET_INFO *cs __attribute__((unused)),
else else
{ {
/* Wrong byte sequence */ /* Wrong byte sequence */
*error= 1;
break; break;
} }
} }

View File

@@ -1273,11 +1273,11 @@ uint my_charpos_ucs2(CHARSET_INFO *cs __attribute__((unused)),
static static
uint my_well_formed_len_ucs2(CHARSET_INFO *cs __attribute__((unused)), uint my_well_formed_len_ucs2(CHARSET_INFO *cs __attribute__((unused)),
const char *b, const char *b, const char *e,
const char *e, uint nchars, int *error)
uint nchars)
{ {
uint nbytes= (e-b) & ~ (uint)1; uint nbytes= (e-b) & ~ (uint)1;
*error= 0;
nchars*= 2; nchars*= 2;
return min(nbytes, nchars); return min(nbytes, nchars);
} }

View File

@@ -8253,11 +8253,12 @@ my_jisx0212_uni_onechar(int code){
static static
uint my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)), uint my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)),
const char *beg, const char *end, uint pos) const char *beg, const char *end,
uint pos, int *error)
{ {
const uchar *b= (uchar *) beg; const uchar *b= (uchar *) beg;
for ( ; pos && b < (uchar*) end; pos--, b++) for ( *error= 0 ; pos && b < (uchar*) end; pos--, b++)
{ {
char *chbeg; char *chbeg;
uint ch= *b; uint ch= *b;
@@ -8267,12 +8268,16 @@ uint my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)),
chbeg= (char *) b++; chbeg= (char *) b++;
if (b >= (uchar *) end) /* need more bytes */ if (b >= (uchar *) end) /* need more bytes */
{
*error= 1;
return chbeg - beg; /* unexpected EOL */ return chbeg - beg; /* unexpected EOL */
}
if (ch == 0x8E) /* [x8E][xA0-xDF] */ if (ch == 0x8E) /* [x8E][xA0-xDF] */
{ {
if (*b >= 0xA0 && *b <= 0xDF) if (*b >= 0xA0 && *b <= 0xDF)
continue; continue;
*error= 1;
return chbeg - beg; /* invalid sequence */ return chbeg - beg; /* invalid sequence */
} }
@@ -8280,12 +8285,16 @@ uint my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)),
{ {
ch= *b++; ch= *b++;
if (b >= (uchar*) end) if (b >= (uchar*) end)
{
*error= 1;
return chbeg - beg; /* unexpected EOL */ return chbeg - beg; /* unexpected EOL */
} }
}
if (ch >= 0xA1 && ch <= 0xFE && if (ch >= 0xA1 && ch <= 0xFE &&
*b >= 0xA1 && *b <= 0xFE) /* [xA1-xFE][xA1-xFE] */ *b >= 0xA1 && *b <= 0xFE) /* [xA1-xFE][xA1-xFE] */
continue; continue;
*error= 1;
return chbeg - beg; /* invalid sequence */ return chbeg - beg; /* invalid sequence */
} }
return b - (uchar *) beg; return b - (uchar *) beg;