"MySQL server does not detect if garbage chars at the end of query":
Detect garbage chars at the end of the query or at the end of a query
for a prepared statement (which happens if mysql_real_query() or mysql_prepare()
were called with a too big 'length' parameter (bigger than the real intended
length of the query: then we receive a query + garbage characters from the
client). This resulted in garbage chars written into the binlog.
Now instead the client receives something like:
'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 '!stmt'
at line 1' i.e. the server is pointing at the weird tail of the query
(this '!stmt' are the garbage chars sent by the client).
All tests pass, except mysqldump.test and ctype_utf8.test but they failed
before the patch.
sql/sql_parse.cc:
Detect garbage chars at the end of the query
(which happens if mysql_real_query() was called with a too big 'length'
parameter (bigger than the real intended length of the query: then
we receive a query + garbage characters from the client).
sql/sql_prepare.cc:
Detect garbage chars at the end of the query
(which happens if mysql_prepare() was called with a too big 'length'
parameter (bigger than the real intended length of the query: then
we receive a query + garbage characters from the client).
tests/client_test.c:
The change to sql_parse.cc and sql_prepare.cc rightfully gives many
syntax errors to tests/client_test.c which is full of
mysql_prepare(mysql, "SHOW TABLES", 100).
Correcting all these commands.
Done clean-up in prep stmt API functions:
1) Removed some checks that were performed only in debug version
were making debug version more tolerable to user errors than
production (and thus caused problems for example masking some
bugs).
2) Also removed some other checks to make prep stmt API
consistent with the rest of C API (this also in line with
general politics - make checks in only those places where
errors are very common and hard to spot).
include/mysql.h:
Removed CHECK_EXTRA_ARGUMENTS define since it is no longer used
anywhere.
libmysql/libmysql.c:
Added check that will cause mysql_fetch() to bark then it is
used without calling mysql_execute() before.
Removed checks that were performed only in debug version and
caused problems since they were making debug version more
tolerable to user errors than production. Also removed some
other checks to make prep stmt API consistent in this regard
with the rest of C API (this also in line with general politics -
make checks in only those places where errors are very common
and hard to spot).
tests/client_test.c:
Updated tests to reflect removal of some checks in prep stmt API.
Removed lines that caused bug #2473 to pop up, should be added
as separate test with the fix for this bug.
Added test for bug#2248 "mysql_fetch without prior mysql_execute
hangs"
libmysqld/lib_sql.cc:
Prepared_statement now resides entirely in sql_prepare.cc
Embedded versions of setup_params_data moved to sql_prepare.cc
sql/mysql_priv.h:
removed declarations for non-existing functions
sql/slave.cc:
no thd->init_for_queries() any more
sql/sql_class.cc:
added Statement and Statement_map classes.
PREP_STMT replaced with Statement (Prepared_statement) and moved to
sql_prepare.cc
sql/sql_class.h:
added Statement and Statement_map classes.
PREP_STMT replaced with Statement (Prepared_statement) and moved to
sql_prepare.cc
sql/sql_parse.cc:
thd->init_for_queries() doesn't exist any more
comment moved to proper place
sql/sql_prepare.cc:
PREP_STMT replaced with Prepared_statement
minor code cleanups
tests/client_test.c:
Later in the test we rely on order of rows, which normally is not defined.
My patch changes the order.
"You can always mysql_real_query a query with placeholders
after mysql_prepare()"
sql/sql_class.cc:
prepare_command removed
sql/sql_class.h:
prepare_command removed
sql/sql_prepare.cc:
prepare_command removed
sql/sql_yacc.yy:
prepare_command removed
tests/client_test.c:
added test for bug #1946: "You can always
mysql_real_query a query with placeholders after mysql_prepare()"
We treat Item_param whose value is not set as non-const.
This allows us to avoid use of Item_param's value (not yet existing) in
those fix_fields and fix_length_and_dec that do calculations if their
Items arguments are const. So we can call fix_fields for such items from
mysql_prepare safely.
sql/item.cc:
Now Item_param is non-constant (const_item()==FALSE) until its value is set.
sql/item.h:
Added Item::const_during_execution() method which indicates constants that will be known
during execution phase (but they may be not known during preparing phase for example parameters
of prep. statements.)
Made Item_param non-constant until its is value set, so its value won't be requested during
prepare statement step.
sql/item_func.cc:
Fulltext search AGAINST clause now allows prepared statement parameter as its argument.
Removed duplicate used_tables_cache update in Item_func_match::fix_fields()
(it is set during Item_func::fix_fields).
tests/client_test.c:
Added test for bug #1500 "Server crash with mysql_prepare"
Changed ~Item_func_in() to call cleanup() (to fix memory leak)
Fixed test_multi_statements() test in client_test
include/mysql.h:
Changed mysql_next_result() to return int instead of bool
libmysql/libmysql.c:
Changed mysql_next_result() to return int instead of bool
Added check to mysql_next_result() to ensure that it's not called in wrong context.
sql/item_cmpfunc.cc:
Indentation fixes
sql/item_cmpfunc.h:
Changed ~Item_func_in() to call cleanup()
(Fixed memory leak in cmp_item_row())
tests/client_test.c:
Fixed test_multi_statements() test.
Fixed. Enabled test case in client_test.c.
sql/sql_prepare.cc:
BUG#1644: Insertion of more than 3 NULL columns with parameter binding fails
Added missing parentheses in IS_PARAM_NULL to get the right bit.
tests/client_test.c:
BUG#1644: Insertion of more than 3 NULL columns with parameter binding fails
Fixed. Enabled test case.
And added new test for BUG#1644. (Disabled for now, not fixed yet.)
tests/client_test.c:
A few more fixes:
- Avoid buffer overruns in printf().
- Corrected index for comment field in show table status output.
And added new test for BUG#1644. (Disabled for now, not fixed yet.)
Note:
- All test results haven't been inspected in detail to see if they are correct.
- Some result set printing seems to have the wrong field width; most notably
date/time fields and type fields (e.g. "int(4)").
- There are still some valgrind complaints, but they seem to be in assert() or
in libmysql.
tests/client_test.c:
A major overhaul to adopt to recent changes:
- SHOW TABLE result has changed (more columns)
- EXPLAIN result has VAR_STRING types now
- Added missing mysql_bind_result() calls
- Adopted to mysql_fetch_column() semantics: Don't use same pointers in MYSQL_BIND
structs for fetch_column as for binding.
- Removed a number of duplicated calls to tests
- Added missing initialization of MYSQL_BIND structs fields (lenght fields),
to shutup valgrind.
.c files (the IBM Visual Age C compiler aborts with a syntax error
on these)
libmysql/dll.c:
- replaced C++-style comment with the proper syntax for .c files
(the IBM Visual Age C compiler aborts with a syntax error on these)
libmysql/libmysql.c:
- replaced C++-style comment with the proper syntax for .c files
(the IBM Visual Age C compiler aborts with a syntax error on these)
mysys/my_getopt.c:
- replaced C++-style comment with the proper syntax for .c files
(the IBM Visual Age C compiler aborts with a syntax error on these)
sql/net_serv.cc:
- replaced C++-style comment with the proper syntax for .c files
(the IBM Visual Age C compiler aborts with a syntax error on these)
strings/ctype-bin.c:
- replaced C++-style comment with the proper syntax for .c files
(the IBM Visual Age C compiler aborts with a syntax error on these)
tests/client_test.c:
- replaced C++-style comment with the proper syntax for .c files
(the IBM Visual Age C compiler aborts with a syntax error on these)
client/mysqltest.c:
Auto merged
include/mysql.h:
Auto merged
libmysql/errmsg.c:
Auto merged
libmysql/libmysql.c:
Auto merged
mysql-test/mysql-test-run.sh:
Auto merged
sql/field.cc:
Auto merged
sql/item.cc:
Auto merged
sql/item.h:
Auto merged
sql/item_cmpfunc.cc:
Auto merged
sql/item_func.cc:
Auto merged
sql/item_func.h:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/mysqld.cc:
Auto merged
sql/share/portuguese/errmsg.txt:
Auto merged
sql/share/spanish/errmsg.txt:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_table.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
tests/client_test.c:
Auto merged
Note that mix_innodb_myisam_binlog and union fails after this patch (Will be fixed shortly by maintaners of this code)
client/mysql.cc:
After merge fix
include/mysql.h:
Some additions to MYSQL_BIND for cleaner prepared statement code
libmysql/libmysql.c:
mysql_prepare_result -> mysql_get_metadata()
Added test for offset overflow when using mysql_fetch_column()
Cleaned up mysql_fetch_column()
Optimized fetch_result() usage
mysql-test/r/func_group.result:
Updated results after merge
mysql-test/r/func_test.result:
Updated results after merge
mysql-test/r/grant.result:
Updated results after merge
mysql-test/r/loaddata.result:
Updated results after merge
mysql-test/r/lowercase_table.result:
Updated results after merge
mysql-test/r/mix_innodb_myisam_binlog.result:
Updated results after merge (note that this is still not correct; Need patch to mysqld to fix this properly)
mysql-test/r/myisam.result:
Updated results after merge
mysql-test/r/range.result:
Updated results after merge
mysql-test/r/rpl_loaddata.result:
Updated results after merge
mysql-test/r/rpl_loaddata_rule_m.result:
Updated results after merge
mysql-test/r/rpl_loaddata_rule_s.result:
Updated results after merge
mysql-test/r/rpl_log.result:
Updated results after merge
mysql-test/r/union.result:
Updated results after merge
mysql-test/t/lowercase_table.test:
Update after merge
mysql-test/t/myisam.test:
Update after merge
mysql-test/t/union.test:
Update after merge
sql-bench/compare-results.sh:
Fix for now output format
sql/field.h:
Added is_null_in_record() to make ha_innodb.cc code more general
sql/ha_innodb.cc:
Removed some functions that uses inernal (private) MySQL information
sql/item_cmpfunc.cc:
After merge fix
sql/log_event.cc:
After merge fix; (Some code should be checked by Guilhem)
sql/opt_range.cc:
Simple optimzation and after merge fixes
sql/slave.cc:
After merge fix
sql/sql_acl.cc:
After merge fix + code cleanup
sql/sql_select.cc:
After merge fix
sql/sql_show.cc:
After merge fix
sql/sql_table.cc:
After merge fix
Cleanup of mysql_checksum_table()
sql/sql_union.cc:
After merge fixes.
Note that after this the union test still fails; Will be fixed shortly...
tests/client_test.c:
mysql_prepare_result() -> mysql_get_metadata()
sql/item.h:
constructor and method for aloning AND/OR structure of WHERE clause
sql/item_cmpfunc.cc:
constructor and method for aloning AND/OR structure of WHERE clause
sql/item_cmpfunc.h:
constructor and method for aloning AND/OR structure of WHERE clause
sql/item_func.cc:
constructor for aloning AND/OR structure of WHERE clause
sql/item_func.h:
constructor for aloning AND/OR structure of WHERE clause
sql/sql_lex.cc:
field for saving WHERE root
sql/sql_lex.h:
field for saving WHERE root
sql/sql_prepare.cc:
saving WHERE root
creating new AND/OR structure before executing prepared statement
tests/client_test.c:
test suite for bug #1180
tests/client_test.c:
test for timestamp bug (BR #819)
sql/sql_insert.cc:
Enable warnings by default for single value list
protocol
mysql-test/t/warnings.test:
Updated test for single value list insert warning
mysql-test/r/warnings.result:
Updated warnings results
Windows build fix
VC++Files/sql/mysqld.dsp:
Added sql_state.c to wrk space
include/mysql_com.h:
Windows build fix (mismatch declaration of my_bool and bool from defination)
include/thr_alarm.h:
Windows build fix
libmysql/libmysql.c:
Fix for mysql_list_fields & reset stmt buffers from stmt_free_result
tests/client_test.c:
Updated test for DEFAULT value for mysql_list_fields()
New tests for mysql_stmt_free_result()
(fix for memory ovverun bug from DBD(ranger) + changes for removal of collation from explain)
tests/client_test.c:
protocol test update
(fix for memory ovverun bug from DBD(ranger) + changes for removal of collation from explain)
2. Test for corrupted .frm and the SHOW TABLE STATUS
sql/sql_show.cc:
Fix for the crash in debug mode when the .frm is corrupted and SHOW TABLE STATUS is executed
This also fixes to return the error message to comment field in SHOW TABLE STATUS when the .frm is corrupted
tests/client_test.c:
test for corrupted .frm and the SHOW TABLE STATUS
tests/client_test.c:
Updated tests for MYSQL_FIELD members for misc cases
libmysql/libmysql.c:
Remove the assignment from stmt->fields to stmt->mysql->fields
Added tests for singed and unsigned conversion (client_test.c)
tests/client_test.c:
Tests for singed and unsigned conversion
libmysql/libmysql.c:
Fix signed and unsigned conversion - When field and buffer types are different
Added a new conversion bug test
Changed options with default_options read from my.ini from [client] section
More cleanups for better usage
libmysql/libmysql.c:
Conversion fix - bug report from PHP
tests/client_test.c:
Added a new conversion bug test
Changed options with default_options read from my.ini from [client] section
More cleanups for better usage
Fix the buffer_length ovveride when length ptr is NULL - libmysql
libmysql/libmysql.c:
Fix the buffer_length ovveride when length ptr is NULL
tests/client_test.c:
Few misc cases check from PHP
Add tests for show commands + MYSQL_TYPE_NULL coverage
tests/client_test.c:
Add tests for show commands + MYSQL_TYPE_NULL coverage
libmysql/libmysql.c:
Fix alloc_stmt_fields for non-select statements
Enable test_stmt_close() and test output to stdout(client_test)
tests/client_test.c:
Enable test_stmt_close() and test output to stdout
libmysql/libmysql.c:
Fix stmt_close not to close the resources on error
cmd-line-utils/libedit/chared.c:
Removed RCSID to get rid of compiler warnings
cmd-line-utils/libedit/common.c:
Removed RCSID to get rid of compiler warnings
cmd-line-utils/libedit/el.c:
Removed RCSID to get rid of compiler warnings
cmd-line-utils/libedit/emacs.c:
Removed RCSID to get rid of compiler warnings
cmd-line-utils/libedit/fgetln.c:
Removed RCSID to get rid of compiler warnings
Removed compiler warning
cmd-line-utils/libedit/hist.c:
Removed RCSID to get rid of compiler warnings
cmd-line-utils/libedit/history.c:
Removed RCSID to get rid of compiler warnings
cmd-line-utils/libedit/key.c:
Removed RCSID to get rid of compiler warnings
cmd-line-utils/libedit/map.c:
Removed RCSID to get rid of compiler warnings
cmd-line-utils/libedit/parse.c:
Removed RCSID to get rid of compiler warnings
cmd-line-utils/libedit/prompt.c:
Removed RCSID to get rid of compiler warnings
cmd-line-utils/libedit/read.c:
Removed RCSID to get rid of compiler warnings
cmd-line-utils/libedit/readline.c:
Removed RCSID to get rid of compiler warnings
cmd-line-utils/libedit/refresh.c:
Removed RCSID to get rid of compiler warnings
cmd-line-utils/libedit/search.c:
Removed RCSID to get rid of compiler warnings
cmd-line-utils/libedit/sig.c:
Removed RCSID to get rid of compiler warnings
cmd-line-utils/libedit/term.c:
Removed RCSID to get rid of compiler warnings
cmd-line-utils/libedit/tokenizer.c:
Removed RCSID to get rid of compiler warnings
cmd-line-utils/libedit/tty.c:
Removed RCSID to get rid of compiler warnings
cmd-line-utils/libedit/vi.c:
Removed RCSID to get rid of compiler warnings
mysys/Makefile.am:
Remove library dependency for charset2html to get correct makefile
tests/client_test.c:
Indentation change