From 1d4ee7f81c1fff2579c3aab8690f977e99a4840e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Jun 2004 12:09:10 +0400 Subject: Post review fixes for "SQL Syntax for Prepared Statements". mysql-test/r/ps.result: Better error message mysys/my_error.c: Comments added sql/item.cc: Moved a chunk of code from sql_prepare.cc to Item_param::set_from_user_var sql/item.h: Moved a chunk of code from sql_prepare.cc to Item_param::set_from_user_var sql/item_func.cc: Code cleanup sql/mysql_priv.h: Code cleanup sql/sql_class.cc: Code cleanup sql/sql_parse.cc: use user_var_entry::val_str in PREPARE stmt FROM @var. sql/sql_prepare.cc: Post-review fixes and code cleanup. sql/sql_yacc.yy: Coding style fixes --- mysys/my_error.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) (limited to 'mysys') diff --git a/mysys/my_error.c b/mysys/my_error.c index b16c39085fd..8a377f63c7e 100644 --- a/mysys/my_error.c +++ b/mysys/my_error.c @@ -37,8 +37,8 @@ char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE]; The following subset of printf format is supported: "%[0-9.-]*l?[sdu]", where all length flags are parsed but ignored. - Additionally "%.*s" is supported and "%.*[ud]" is correctly parsed but - length value is ignored. + Additionally "%.*s" is supported and "%.*[ud]" is correctly parsed but + the length value is ignored. */ int my_error(int nr,myf MyFlags, ...) @@ -49,7 +49,7 @@ int my_error(int nr,myf MyFlags, ...) reg2 char *endpos; char * par; char ebuff[ERRMSGSIZE+20]; - int prec_chars; + int prec_chars; /* output precision */ my_bool prec_supplied; DBUG_ENTER("my_error"); LINT_INIT(prec_chars); /* protected by prec_supplied */ @@ -76,10 +76,11 @@ int my_error(int nr,myf MyFlags, ...) } else { - /* - Skip size/precision flags to be compatible with printf. - The only size/precision flag supported is "%.*s". - "%.*u" and "%.*d" cause + /* + Skip size/precision flags to be compatible with printf. + The only size/precision flag supported is "%.*s". + If "%.*u" or "%.*d" are encountered, the precision number is read + from the variable argument list but its value is ignored. */ prec_supplied= 0; if (*tpos== '.') @@ -94,52 +95,52 @@ int my_error(int nr,myf MyFlags, ...) prec_supplied= 1; } } - + if (!prec_supplied) { - while (my_isdigit(&my_charset_latin1, *tpos) || *tpos == '.' || + while (my_isdigit(&my_charset_latin1, *tpos) || *tpos == '.' || *tpos == '-') - tpos++; - - if (*tpos == 'l') /* Skipp 'l' argument */ + tpos++; + + if (*tpos == 'l') /* Skip 'l' argument */ tpos++; } if (*tpos == 's') /* String parameter */ { - par = va_arg(ap, char *); - plen = (uint) strlen(par); + par= va_arg(ap, char *); + plen= (uint) strlen(par); if (prec_supplied && prec_chars > 0) plen= min((uint)prec_chars, plen); if (olen + plen < ERRMSGSIZE+2) /* Replace if possible */ { - memcpy(endpos,par, plen); - endpos += plen; + strmake(endpos, par, plen); + endpos+= plen; tpos++; - olen+=plen-2; + olen+= plen-2; continue; } } else if (*tpos == 'd' || *tpos == 'u') /* Integer parameter */ { register int iarg; - iarg = va_arg(ap, int); + iarg= va_arg(ap, int); if (*tpos == 'd') plen= (uint) (int10_to_str((long) iarg, endpos, -10) - endpos); else plen= (uint) (int10_to_str((long) (uint) iarg, endpos, 10) - endpos); if (olen + plen < ERRMSGSIZE+2) /* Replace parameter if possible */ { - endpos+=plen; + endpos+= plen; tpos++; - olen+=plen-2; + olen+= plen-2; continue; } } } - *endpos++='%'; /* % used as % or unknown code */ + *endpos++= '%'; /* % used as % or unknown code */ } - *endpos='\0'; /* End of errmessage */ + *endpos= '\0'; /* End of errmessage */ va_end(ap); DBUG_RETURN((*error_handler_hook)(nr, ebuff, MyFlags)); } -- cgit v1.2.1