diff options
author | unknown <sergefp@mysql.com> | 2004-05-21 04:27:50 +0400 |
---|---|---|
committer | unknown <sergefp@mysql.com> | 2004-05-21 04:27:50 +0400 |
commit | e7710af7f4c41e77355f5599aafb04999b358292 (patch) | |
tree | a744f3804c5f4a55fabbc3344ef1ec8b1c9e3b52 /mysys/my_error.c | |
parent | 201412da7571f5078dae6cdb2067f64a3de5bef8 (diff) | |
download | mariadb-git-e7710af7f4c41e77355f5599aafb04999b358292.tar.gz |
WL#1622 "SQL Syntax for Prepared Statements": Post-review fixes (1 of 2)
mysql-test/r/ps.result:
Added tests for PREPARE stmt1 FROM @var syntax
mysql-test/t/ps.test:
Added tests for PREPARE stmt1 FROM @var syntax
mysys/my_error.c:
Added support for "%.*s" format
sql/item.cc:
Removed one redundant Item_param::set_value function
sql/item.h:
Removed one redundant Item_param::set_value function
sql/mysqld.cc:
Reformmated the code
sql/share/czech/errmsg.txt:
Changed ER_UNKNOWN_STMT_HANDLER format string
sql/share/dutch/errmsg.txt:
Changed ER_UNKNOWN_STMT_HANDLER format string
sql/share/english/errmsg.txt:
Changed ER_UNKNOWN_STMT_HANDLER format string
sql/share/estonian/errmsg.txt:
Changed ER_UNKNOWN_STMT_HANDLER format string
sql/share/french/errmsg.txt:
Changed ER_UNKNOWN_STMT_HANDLER format string
sql/share/german/errmsg.txt:
Changed ER_UNKNOWN_STMT_HANDLER format string
sql/share/greek/errmsg.txt:
Changed ER_UNKNOWN_STMT_HANDLER format string
sql/share/hungarian/errmsg.txt:
Changed ER_UNKNOWN_STMT_HANDLER format string
sql/share/italian/errmsg.txt:
Changed ER_UNKNOWN_STMT_HANDLER format string
sql/share/japanese/errmsg.txt:
Changed ER_UNKNOWN_STMT_HANDLER format string
sql/share/korean/errmsg.txt:
Changed ER_UNKNOWN_STMT_HANDLER format string
sql/share/norwegian-ny/errmsg.txt:
Changed ER_UNKNOWN_STMT_HANDLER format string
sql/share/norwegian/errmsg.txt:
Changed ER_UNKNOWN_STMT_HANDLER format string
sql/share/polish/errmsg.txt:
Changed ER_UNKNOWN_STMT_HANDLER format string
sql/share/portuguese/errmsg.txt:
Changed ER_UNKNOWN_STMT_HANDLER format string
sql/share/romanian/errmsg.txt:
Changed ER_UNKNOWN_STMT_HANDLER format string
sql/share/russian/errmsg.txt:
Changed ER_UNKNOWN_STMT_HANDLER format string
sql/share/slovak/errmsg.txt:
Changed ER_UNKNOWN_STMT_HANDLER format string
sql/share/spanish/errmsg.txt:
Changed ER_UNKNOWN_STMT_HANDLER format string
sql/share/swedish/errmsg.txt:
Changed ER_UNKNOWN_STMT_HANDLER format string
sql/share/ukrainian/errmsg.txt:
Changed ER_UNKNOWN_STMT_HANDLER format string
sql/sql_class.h:
SQL Prepared statements now can't be used by binary protocol commands
sql/sql_lex.h:
Added support for PREPARE stmt1 FROM @var syntax.
sql/sql_parse.cc:
Added support for PREPARE stmt1 FROM @var syntax.
sql/sql_prepare.cc:
Code cleanup
sql/sql_yacc.yy:
Added support for PREPARE stmt1 FROM @var syntax.
Diffstat (limited to 'mysys/my_error.c')
-rw-r--r-- | mysys/my_error.c | 55 |
1 files changed, 45 insertions, 10 deletions
diff --git a/mysys/my_error.c b/mysys/my_error.c index 6fd346c89f7..7ca7dbae8de 100644 --- a/mysys/my_error.c +++ b/mysys/my_error.c @@ -33,6 +33,12 @@ char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE]; nr Errno MyFlags Flags ... variable list + NOTE + 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. */ int my_error(int nr,myf MyFlags, ...) @@ -43,7 +49,10 @@ int my_error(int nr,myf MyFlags, ...) reg2 char *endpos; char * par; char ebuff[ERRMSGSIZE+20]; + int prec_chars; + my_bool prec_supplied; DBUG_ENTER("my_error"); + LINT_INIT(prec_chars); /* protected by prec_supplied */ va_start(ap,MyFlags); DBUG_PRINT("my", ("nr: %d MyFlags: %d errno: %d", nr, MyFlags, errno)); @@ -59,7 +68,6 @@ int my_error(int nr,myf MyFlags, ...) if (tpos[0] != '%') { *endpos++= *tpos++; /* Copy ordinary char */ - olen++; continue; } if (*++tpos == '%') /* test if %% */ @@ -68,21 +76,48 @@ int my_error(int nr,myf MyFlags, ...) } else { - /* Skipp if max size is used (to be compatible with printf) */ - while (my_isdigit(&my_charset_latin1, *tpos) || *tpos == '.' || *tpos == '-') - tpos++; - if (*tpos == 'l') /* Skipp 'l' argument */ - tpos++; + /* + Skip size/precision flags to be compatible with printf. + The only size/precision flag supported is "%.*s". + "%.*u" and "%.*d" cause + */ + prec_supplied= 0; + if (*tpos== '.') + { + tpos++; + olen--; + if (*tpos == '*') + { + tpos++; + olen--; + prec_chars= va_arg(ap, int); /* get length parameter */ + prec_supplied= 1; + } + } + + if (!prec_supplied) + { + while (my_isdigit(&my_charset_latin1, *tpos) || *tpos == '.' || + *tpos == '-') + tpos++; + + if (*tpos == 'l') /* Skipp 'l' argument */ + tpos++; + } + if (*tpos == 's') /* String parameter */ { 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 */ { - endpos=strmov(endpos,par); - tpos++; - olen+=plen-2; - continue; + memcpy(endpos,par, plen); + endpos += plen; + tpos++; + olen+=plen-2; + continue; } } else if (*tpos == 'd' || *tpos == 'u') /* Integer parameter */ |