Commit 4eabbff7 authored by unknown's avatar unknown

Merge mysql.com:/home/jonas/src/mysql-5.0

into mysql.com:/home/jonas/src/mysql-5.0-ndb


mysql-test/r/ndb_index_unique.result:
  Auto merged
mysql-test/t/ndb_index_unique.test:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
parents c9b20854 6603f7a8
......@@ -25,7 +25,10 @@ Any other options will be passed directly to configure.
Note: this script is intended for internal use by MySQL developers.
EOF
--with-debug=full ) full_debug="=full"; shift ;;
* ) break ;;
* )
echo "Unknown option '$1'"
exit 1
break ;;
esac
done
......@@ -62,6 +65,7 @@ fast_cflags="-O3 -fno-omit-frame-pointer"
reckless_cflags="-O3 -fomit-frame-pointer "
debug_cflags="-DUNIV_MUST_NOT_INLINE -DEXTRA_DEBUG -DFORCE_INIT_OF_VARS -DSAFEMALLOC -DPEDANTIC_SAFEMALLOC -DSAFE_MUTEX"
debug_extra_cflags="-O1 -Wuninitialized"
base_cxxflags="-felide-constructors -fno-exceptions -fno-rtti"
amd64_cxxflags="-DBIG_TABLES"
......@@ -80,7 +84,7 @@ local_infile_configs="--enable-local-infile"
debug_configs="--with-debug$full_debug"
if [ -z "$full_debug" ]
then
debug_cflags="$debug_cflags -O1 -Wuninitialized"
debug_cflags="$debug_cflags $debug_extra_cflags"
fi
if gmake --version > /dev/null 2>&1
......
#! /bin/sh
path=`dirname $0`
. "$path/SETUP.sh"
. "$path/SETUP.sh" $@ --with-debug=full
extra_flags="$pentium64_cflags $debug_cflags"
c_warnings="$c_warnings $debug_extra_warnings"
......
......@@ -172,6 +172,7 @@ nick@nick.leippe.com
papa@gbichot.local
patg@krsna.patg.net
patg@patrick-galbraiths-computer.local
patg@pc248.lfp.kcls.org
paul@central.snake.net
paul@frost.snake.net
paul@ice.local
......
......@@ -1678,12 +1678,12 @@ if test "$with_debug" = "yes"
then
# Medium debug.
CFLAGS="$DEBUG_CFLAGS $DEBUG_OPTIMIZE_CC -DDBUG_ON -DSAFE_MUTEX $CFLAGS"
CXXFLAGS="$DEBUG_CXXFLAGS $DEBUG_OPTIMIZE_CXX -DSAFE_MUTEX $CXXFLAGS"
CXXFLAGS="$DEBUG_CXXFLAGS $DEBUG_OPTIMIZE_CXX -DDBUG_ON -DSAFE_MUTEX $CXXFLAGS"
elif test "$with_debug" = "full"
then
# Full debug. Very slow in some cases
CFLAGS="$DEBUG_CFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC $CFLAGS"
CXXFLAGS="$DEBUG_CXXFLAGS -DSAFE_MUTEX -DSAFEMALLOC $CXXFLAGS"
CFLAGS="$DEBUG_CFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC -DUNIV_DEBUG $CFLAGS"
CXXFLAGS="$DEBUG_CXXFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC -DUNIV_DEBUG $CXXFLAGS"
else
# Optimized version. No debug
CFLAGS="$OPTIMIZE_CFLAGS -DDBUG_OFF $CFLAGS"
......
......@@ -259,6 +259,8 @@ extern char wild_many,wild_one,wild_prefix;
extern const char *charsets_dir;
extern char *defaults_extra_file;
extern my_bool timed_mutexes;
typedef struct wild_file_pack /* Struct to hold info when selecting files */
{
uint wilds; /* How many wildcards */
......
......@@ -80,6 +80,10 @@ memory is read outside the allocated blocks. */
/* Make a non-inline debug version */
#ifdef DBUG_ON
#define UNIV_DEBUG
#endif /* DBUG_ON */
/*
#define UNIV_DEBUG
#define UNIV_MEM_DEBUG
......
-- require r/have_federated_db.require
disable_query_log;
show variables like "have_federated_db";
show variables like "have_federated_engine";
enable_query_log;
#################### include/testdb_only.inc ######################
# #
# We must prevent to work on databases created by customers, #
# because we DROP/CREATE/MODIFY objects with sometimes common #
# names like STAFF, EMPLOYEE etc. #
# #
# Therefore we check the environment variable USE_RUNNING_SERVER. #
# USE_RUNNING_SERVER is exported by "mysql-test-run" and could #
# contain the following values: #
# 0 -- mysql-test-run was started without the --extern option #
# That means the test will be performed within the test #
# area 'mysql-test/var/...' . #
# 1 -- mysql-test-run was started with the --extern option #
# That means the test will be performed by an already #
# running server and data modifications will most probably #
# outside of the common test area 'mysql-test/var/...' . #
# #
# If USE_RUNNING_SERVER is not 0 the test will be skipped. #
# #
###################################################################
--disable_query_log
eval set @USE_RUNNING_SERVER= '$USE_RUNNING_SERVER';
--require r/testdb_only.require
SELECT 'use extern server'
AS "Variable_name ",
IF(@USE_RUNNING_SERVER= '1','YES',
IF(@USE_RUNNING_SERVER= '0','NO','UNEXPECTED'))
AS "Value" ;
--enable_query_log
......@@ -224,7 +224,7 @@ EXTRA_MASTER_OPT=""
EXTRA_MYSQL_TEST_OPT=""
EXTRA_MYSQLDUMP_OPT=""
EXTRA_MYSQLBINLOG_OPT=""
USE_RUNNING_SERVER=""
USE_RUNNING_SERVER=0
USE_NDBCLUSTER=""
USE_RUNNING_NDBCLUSTER=""
DO_GCOV=""
......@@ -255,7 +255,7 @@ NDBD_EXTRA_OPTS=
while test $# -gt 0; do
case "$1" in
--embedded-server) USE_EMBEDDED_SERVER=1 USE_MANAGER=0 NO_SLAVE=1 ; \
USE_RUNNING_SERVER="" RESULT_EXT=".es" TEST_MODE="embedded" ;;
USE_RUNNING_SERVER=0 RESULT_EXT=".es" TEST_MODE="embedded" ;;
--user=*) DBUSER=`$ECHO "$1" | $SED -e "s;--user=;;"` ;;
--force) FORCE=1 ;;
--timer) USE_TIMER=1 ;;
......@@ -265,8 +265,8 @@ while test $# -gt 0; do
MASTER_MYSQLD=`$ECHO "$1" | $SED -e "s;--master-binary=;;"` ;;
--slave-binary=*)
SLAVE_MYSQLD=`$ECHO "$1" | $SED -e "s;--slave-binary=;;"` ;;
--local) USE_RUNNING_SERVER="" ;;
--extern) USE_RUNNING_SERVER="1" ;;
--local) USE_RUNNING_SERVER=0 ;;
--extern) USE_RUNNING_SERVER=1 ;;
--with-ndbcluster)
USE_NDBCLUSTER="--ndbcluster" ;;
--ndb-connectstring=*)
......@@ -303,7 +303,7 @@ while test $# -gt 0; do
--no-manager | --skip-manager) USE_MANAGER=0 ;;
--manager)
USE_MANAGER=1
USE_RUNNING_SERVER=
USE_RUNNING_SERVER=0
;;
--start-and-exit)
START_AND_EXIT=1
......@@ -372,7 +372,7 @@ while test $# -gt 0; do
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --gdb"
# This needs to be checked properly
# USE_MANAGER=1
USE_RUNNING_SERVER=""
USE_RUNNING_SERVER=0
;;
--client-gdb )
if [ x$BINARY_DIST = x1 ] ; then
......@@ -385,7 +385,7 @@ while test $# -gt 0; do
--manual-gdb )
DO_GDB=1
MANUAL_GDB=1
USE_RUNNING_SERVER=""
USE_RUNNING_SERVER=0
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --gdb"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --gdb"
;;
......@@ -394,7 +394,7 @@ while test $# -gt 0; do
$ECHO "Note: you will get more meaningful output on a source distribution compiled with debugging option when running tests with --ddd option"
fi
DO_DDD=1
USE_RUNNING_SERVER=""
USE_RUNNING_SERVER=0
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --gdb"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --gdb"
;;
......@@ -412,7 +412,7 @@ while test $# -gt 0; do
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-safemalloc --skip-bdb"
SLEEP_TIME_AFTER_RESTART=10
SLEEP_TIME_FOR_DELETE=60
USE_RUNNING_SERVER=""
USE_RUNNING_SERVER=0
if test "$1" = "--valgrind-all"
then
VALGRIND="$VALGRIND -v --show-reachable=yes"
......@@ -627,9 +627,9 @@ fi
if [ -z "$1" ]
then
USE_RUNNING_SERVER=""
USE_RUNNING_SERVER=0
fi
if [ -n "$USE_RUNNING_SERVER" ]
if [ $USE_RUNNING_SERVER -eq 1 ]
then
MASTER_MYSOCK=$LOCAL_SOCKET;
DBUSER=${DBUSER:-test}
......@@ -801,7 +801,7 @@ report_stats () {
$ECHO "http://www.mysql.com/doc/en/MySQL_test_suite.html"
fi
if test -z "$USE_RUNNING_SERVER"
if [ $USE_RUNNING_SERVER -eq 0 ]
then
# Report if there was any fatal warnings/errors in the log files
......@@ -1511,7 +1511,7 @@ run_testcase ()
done
fi
if [ -z "$USE_RUNNING_SERVER" ] ;
if [ $USE_RUNNING_SERVER -eq 0 ] ;
then
if [ -f $master_opt_file ] ;
then
......@@ -1655,7 +1655,7 @@ run_testcase ()
if [ x$FORCE != x1 ] ; then
$ECHO "Aborting: $tname failed in $TEST_MODE mode. To continue, re-run with '--force'."
$ECHO
if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && \
if [ -z "$DO_GDB" ] && [ $USE_RUNNING_SERVER -eq 0 ] && \
[ -z "$DO_DDD" ] && [ -z "$USE_EMBEDDED_SERVER" ]
then
mysql_stop
......@@ -1664,7 +1664,7 @@ run_testcase ()
exit 1
fi
FAILED_CASES="$FAILED_CASES $tname"
if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && \
if [ -z "$DO_GDB" ] && [ $USE_RUNNING_SERVER -eq 0 ] && \
[ -z "$DO_DDD" ] && [ -z "$USE_EMBEDDED_SERVER" ]
then
mysql_restart
......@@ -1683,7 +1683,7 @@ run_testcase ()
[ "$DO_GCOV" ] && gcov_prepare
[ "$DO_GPROF" ] && gprof_prepare
if [ -z "$USE_RUNNING_SERVER" ]
if [ $USE_RUNNING_SERVER -eq 0 ]
then
if [ -z "$FAST_START" ]
then
......@@ -1744,6 +1744,9 @@ fi
$ECHO "Starting Tests"
# Some test cases need USE_RUNNING_SERVER
export USE_RUNNING_SERVER
#
# This can probably be deleted
#
......@@ -1816,7 +1819,7 @@ fi
$ECHO $DASH72
$ECHO
if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && [ -z "$DO_DDD" ]
if [ -z "$DO_GDB" ] && [ $USE_RUNNING_SERVER -eq 0 ] && [ -z "$DO_DDD" ]
then
mysql_stop
fi
......
......@@ -130,9 +130,9 @@ delete from federated.t1;
select * from federated.t1 where id = 5;
id name other created
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`) ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`) );
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`) ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (name, other) values ('First Name', 11111);
insert into federated.t1 (name, other) values ('Second Name', NULL);
insert into federated.t1 (name, other) values ('Third Name', 33333);
......@@ -162,7 +162,7 @@ id name other
7 Seventh Name NULL
10 NULL fee fie foe fum
update federated.t1 set name = 'Fourth Name', other = 'four four four' where name IS NULL and other IS NULL;
update federated.t1 set other = 'two two two two' where name = 'Secend Name';
update federated.t1 set other = 'two two two two' where name = 'Second Name';
update federated.t1 set other = 'seven seven' where name like 'Sec%';
update federated.t1 set other = 'seven seven' where name = 'Seventh Name';
update federated.t1 set name = 'Tenth Name' where other like 'fee fie%';
......@@ -181,6 +181,85 @@ id name other
9 Ninth Name 99999
10 Tenth Name fee fie foe fum
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name`
varchar(32) NOT NULL DEFAULT '', `other` varchar(20) NOT NULL DEFAULT '', PRIMARY KEY (`id`), key nameoth (name, other) );
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32) NOT NULL DEFAULT '', `other` varchar(20) NOT NULL DEFAULT '', PRIMARY KEY (`id`), key nameoth (name, other)) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (name, other) values ('First Name', '1111');
insert into federated.t1 (name, other) values ('Second Name', '2222');
insert into federated.t1 (name, other) values ('Third Name', '3333');
select * from federated.t1 where name = 'Second Name';
id name other
2 Second Name 2222
select * from federated.t1 where other = '2222';
id name other
2 Second Name 2222
select * from federated.t1 where name = 'Third Name';
id name other
3 Third Name 3333
select * from federated.t1 where name = 'Third Name' and other = '3333';
id name other
3 Third Name 3333
drop table if exists federated.t1;
CREATE TABLE federated.t1
(id int NOT NULL auto_increment,
name char(32) NOT NULL DEFAULT '',
bincol binary(4) NOT NULL,
floatval decimal(5,2) NOT NULL DEFAULT 0.0,
other int NOT NULL DEFAULT 0,
primary key(id),
key nameoth(name, other),
key bincol(bincol),
key floatval(floatval));
drop table if exists federated.t1;
CREATE TABLE federated.t1
(id int NOT NULL auto_increment,
name char(32) NOT NULL DEFAULT '',
bincol binary(4) NOT NULL,
floatval decimal(5,2) NOT NULL DEFAULT 0.0,
other int NOT NULL DEFAULT 0,
primary key(id),
key nameoth(name,other),
key bincol(bincol),
key floatval(floatval))
ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (name, bincol, floatval, other) values ('first', 0x65, 11.11, 1111);
insert into federated.t1 (name, bincol, floatval, other) values ('second', 0x66, 22.22, 2222);
insert into federated.t1 (name, bincol, floatval, other) values ('third', 'g', 22.22, 2222);
select * from federated.t1;
id name bincol floatval other
1 first e 11.11 1111
2 second f 22.22 2222
3 third g 22.22 2222
select * from federated.t1 where name = 'second';
id name bincol floatval other
2 second f 22.22 2222
select * from federated.t1 where bincol= 'f';
id name bincol floatval other
2 second f 22.22 2222
select * from federated.t1 where bincol= 0x66;
id name bincol floatval other
2 second f 22.22 2222
select * from federated.t1 where bincol= 0x67;
id name bincol floatval other
3 third g 22.22 2222
select * from federated.t1 where bincol= 'g';
id name bincol floatval other
3 third g 22.22 2222
select * from federated.t1 where floatval=11.11;
id name bincol floatval other
1 first e 11.11 1111
select * from federated.t1 where name='third';
id name bincol floatval other
3 third g 22.22 2222
select * from federated.t1 where other=2222;
id name bincol floatval other
2 second f 22.22 2222
3 third g 22.22 2222
select * from federated.t1 where name='third' and other=2222;
id name bincol floatval other
3 third g 22.22 2222
drop table if exists federated.t1;
CREATE TABLE federated.t1 (id int, name varchar(32), floatval float, other int) DEFAULT CHARSET=latin1;
drop table if exists federated.t1;
CREATE TABLE federated.t1 (id int, name varchar(32), floatval float, other int) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
......@@ -550,16 +629,46 @@ delete from federated.t1 where i50=20;
select * from federated.t1;
i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15 i16 i17 i18 i19 i20 i21 i22 i23 i24 i25 i26 i27 i28 i29 i30 i31 i32 i33 i34 i35 i36 i37 i38 i39 i40 i41 i42 i43 i44 i45 i46 i47 i48 i49 i50 i51 i52 i53 i54 i55 i56 i57 i58 i59 i60 i61 i62 i63 i64 i65 i66 i67 i68 i69 i70 i71 i72 i73 i74 i75 i76 i77 i78 i79 i80 i81 i82 i83 i84 i85 i86 i87 i88 i89 i90 i91 i92 i93 i94 i95 i96 i97 i98 i99 i100 i101 i102 i103 i104 i105 i106 i107 i108 i109 i110 i111 i112 i113 i114 i115 i116 i117 i118 i119 i120 i121 i122 i123 i124 i125 i126 i127 i128 i129 i130 i131 i132 i133 i134 i135 i136 i137 i138 i139 i140 i141 i142 i143 i144 i145 i146 i147 i148 i149 i150 i151 i152 i153 i154 i155 i156 i157 i158 i159 i160 i161 i162 i163 i164 i165 i166 i167 i168 i169 i170 i171 i172 i173 i174 i175 i176 i177 i178 i179 i180 i181 i182 i183 i184 i185 i186 i187 i188 i189 i190 i191 i192 i193 i194 i195 i196 i197 i198 i199 i200 i201 i202 i203 i204 i205 i206 i207 i208 i209 i210 i211 i212 i213 i214 i215 i216 i217 i218 i219 i220 i221 i222 i223 i224 i225 i226 i227 i228 i229 i230 i231 i232 i233 i234 i235 i236 i237 i238 i239 i240 i241 i242 i243 i244 i245 i246 i247 i248 i249 i250 i251 i252 i253 i254 i255 i256 i257 i258 i259 i260 i261 i262 i263 i264 i265 i266 i267 i268 i269 i270 i271 i272 i273 i274 i275 i276 i277 i278 i279 i280 i281 i282 i283 i284 i285 i286 i287 i288 i289 i290 i291 i292 i293 i294 i295 i296 i297 i298 i299 i300 i301 i302 i303 i304 i305 i306 i307 i308 i309 i310 i311 i312 i313 i314 i315 i316 i317 i318 i319 i320 i321 i322 i323 i324 i325 i326 i327 i328 i329 i330 i331 i332 i333 i334 i335 i336 i337 i338 i339 i340 i341 i342 i343 i344 i345 i346 i347 i348 i349 i350 i351 i352 i353 i354 i355 i356 i357 i358 i359 i360 i361 i362 i363 i364 i365 i366 i367 i368 i369 i370 i371 i372 i373 i374 i375 i376 i377 i378 i379 i380 i381 i382 i383 i384 i385 i386 i387 i388 i389 i390 i391 i392 i393 i394 i395 i396 i397 i398 i399 i400 i401 i402 i403 i404 i405 i406 i407 i408 i409 i410 i411 i412 i413 i414 i415 i416 i417 i418 i419 i420 i421 i422 i423 i424 i425 i426 i427 i428 i429 i430 i431 i432 i433 i434 i435 i436 i437 i438 i439 i440 i441 i442 i443 i444 i445 i446 i447 i448 i449 i450 i451 i452 i453 i454 i455 i456 i457 i458 i459 i460 i461 i462 i463 i464 i465 i466 i467 i468 i469 i470 i471 i472 i473 i474 i475 i476 i477 i478 i479 i480 i481 i482 i483 i484 i485 i486 i487 i488 i489 i490 i491 i492 i493 i494 i495 i496 i497 i498 i499 i500 i501 i502 i503 i504 i505 i506 i507 i508 i509 i510 i511 i512 i513 i514 i515 i516 i517 i518 i519 i520 i521 i522 i523 i524 i525 i526 i527 i528 i529 i530 i531 i532 i533 i534 i535 i536 i537 i538 i539 i540 i541 i542 i543 i544 i545 i546 i547 i548 i549 i550 i551 i552 i553 i554 i555 i556 i557 i558 i559 i560 i561 i562 i563 i564 i565 i566 i567 i568 i569 i570 i571 i572 i573 i574 i575 i576 i577 i578 i579 i580 i581 i582 i583 i584 i585 i586 i587 i588 i589 i590 i591 i592 i593 i594 i595 i596 i597 i598 i599 i600 i601 i602 i603 i604 i605 i606 i607 i608 i609 i610 i611 i612 i613 i614 i615 i616 i617 i618 i619 i620 i621 i622 i623 i624 i625 i626 i627 i628 i629 i630 i631 i632 i633 i634 i635 i636 i637 i638 i639 i640 i641 i642 i643 i644 i645 i646 i647 i648 i649 i650 i651 i652 i653 i654 i655 i656 i657 i658 i659 i660 i661 i662 i663 i664 i665 i666 i667 i668 i669 i670 i671 i672 i673 i674 i675 i676 i677 i678 i679 i680 i681 i682 i683 i684 i685 i686 i687 i688 i689 i690 i691 i692 i693 i694 i695 i696 i697 i698 i699 i700 i701 i702 i703 i704 i705 i706 i707 i708 i709 i710 i711 i712 i713 i714 i715 i716 i717 i718 i719 i720 i721 i722 i723 i724 i725 i726 i727 i728 i729 i730 i731 i732 i733 i734 i735 i736 i737 i738 i739 i740 i741 i742 i743 i744 i745 i746 i747 i748 i749 i750 i751 i752 i753 i754 i755 i756 i757 i758 i759 i760 i761 i762 i763 i764 i765 i766 i767 i768 i769 i770 i771 i772 i773 i774 i775 i776 i777 i778 i779 i780 i781 i782 i783 i784 i785 i786 i787 i788 i789 i790 i791 i792 i793 i794 i795 i796 i797 i798 i799 i800 i801 i802 i803 i804 i805 i806 i807 i808 i809 i810 i811 i812 i813 i814 i815 i816 i817 i818 i819 i820 i821 i822 i823 i824 i825 i826 i827 i828 i829 i830 i831 i832 i833 i834 i835 i836 i837 i838 i839 i840 i841 i842 i843 i844 i845 i846 i847 i848 i849 i850 i851 i852 i853 i854 i855 i856 i857 i858 i859 i860 i861 i862 i863 i864 i865 i866 i867 i868 i869 i870 i871 i872 i873 i874 i875 i876 i877 i878 i879 i880 i881 i882 i883 i884 i885 i886 i887 i888 i889 i890 i891 i892 i893 i894 i895 i896 i897 i898 i899 i900 i901 i902 i903 i904 i905 i906 i907 i908 i909 i910 i911 i912 i913 i914 i915 i916 i917 i918 i919 i920 i921 i922 i923 i924 i925 i926 i927 i928 i929 i930 i931 i932 i933 i934 i935 i936 i937 i938 i939 i940 i941 i942 i943 i944 i945 i946 i947 i948 i949 i950 i951 i952 i953 i954 i955 i956 i957 i958 i959 i960 i961 i962 i963 i964 i965 i966 i967 i968 i969 i970 i971 i972 i973 i974 i975 i976 i977 i978 i979 i980 i981 i982 i983 i984 i985 i986 i987 i988 i989 i990 i991 i992 i993 i994 i995 i996 i997 i998 i999 i1000 b
drop table if exists federated.t1;
create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code)) DEFAULT CHARSET=latin1;
create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob NOT NULL, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code), index(fileguts(10))) DEFAULT CHARSET=latin1;
drop table if exists federated.t1;
create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code)) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob NOT NULL, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code), index(fileguts(10))) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (code, fileguts, creation_date) values ('ASDFWERQWETWETAWETA', '*()w*09*$()*#)(*09*^90*d)(*s()d8g)(s*ned)(*)(s*d)(*hn(d*)(*sbn)D((#$*(#*%%&#&^$#&#&#&#&^&#*&*#$*&^*(&#(&Q*&&(*!&!(*&*(#&*(%&#<S-F8>*<S-F8><S-F8><S-F8>#<S-F8>#<S-F8>#<S-F8>[[', '2003-03-03 03:03:03');
insert into federated.t1 (code, fileguts, creation_date) values ('DEUEUEUEUEUEUEUEUEU', '*()w*09*$()*#)(*09*^90*d)(*s()d8g)(s*ned)(*)(s*d)(*hn(d*)(*sbn)D((#$*(#*%%&#&^$#&#&#&#&^&#*&*#$*&^*(&#(&Q*&&(*!&!(*&*(#&*(%&#<S-F8>*<S-F8><S-F8><S-F8>#<S-F8>#<S-F8>#<S-F8>[[', '2004-04-04 04:04:04');
insert into federated.t1 (code, fileguts, creation_date) values ('DEUEUEUEUEUEUEUEUEU', 'jimbob', '2004-04-04 04:04:04');
select * from federated.t1;
id code fileguts creation_date entered_time
1 ASDFWERQWETWETAWETA *()w*09*$()*#)(*09*^90*d)(*s()d8g)(s*ned)(*)(s*d)(*hn(d*)(*sbn)D((#$*(#*%%&#&^$#&#&#&#&^&#*&*#$*&^*(&#(&Q*&&(*!&!(*&*(#&*(%&#<S-F8>*<S-F8><S-F8><S-F8>#<S-F8>#<S-F8>#<S-F8>[[ 2003-03-03 03:03:03 2004-04-04 04:04:04
2 DEUEUEUEUEUEUEUEUEU *()w*09*$()*#)(*09*^90*d)(*s()d8g)(s*ned)(*)(s*d)(*hn(d*)(*sbn)D((#$*(#*%%&#&^$#&#&#&#&^&#*&*#$*&^*(&#(&Q*&&(*!&!(*&*(#&*(%&#<S-F8>*<S-F8><S-F8><S-F8>#<S-F8>#<S-F8>#<S-F8>[[ 2004-04-04 04:04:04 2004-04-04 04:04:04
3 DEUEUEUEUEUEUEUEUEU jimbob 2004-04-04 04:04:04 2004-04-04 04:04:04
select * from federated.t1 where fileguts = 'jimbob';
id code fileguts creation_date entered_time
3 DEUEUEUEUEUEUEUEUEU jimbob 2004-04-04 04:04:04 2004-04-04 04:04:04
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `country_id` int(20) NOT NULL DEFAULT 0, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`), key (country_id));
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `country_id` int(20) NOT NULL DEFAULT 0, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`), key (country_id) ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (name, country_id, other) values ('Kumar', 1, 11111);
insert into federated.t1 (name, country_id, other) values ('Lenz', 2, 22222);
insert into federated.t1 (name, country_id, other) values ('Marizio', 3, 33333);
insert into federated.t1 (name, country_id, other) values ('Monty', 4, 33333);
insert into federated.t1 (name, country_id, other) values ('Sanja', 5, 33333);
drop table if exists federated.countries;
Warnings:
Note 1051 Unknown table 'countries'
CREATE TABLE federated.countries ( `id` int(20) NOT NULL auto_increment, `country` varchar(32), primary key (id));
insert into federated.countries (country) values ('India');
insert into federated.countries (country) values ('Germany');
insert into federated.countries (country) values ('Italy');
insert into federated.countries (country) values ('Finland');
insert into federated.countries (country) values ('Ukraine');
select federated.t1.*, federated.countries.country from federated.t1 left join federated.countries on federated.t1.country_id = federated.countries.id;
id country_id name other country
1 1 Kumar 11111 India
2 2 Lenz 22222 Germany
3 3 Marizio 33333 Italy
4 4 Monty 33333 Finland
5 5 Sanja 33333 Ukraine
drop table federated.countries;
drop table if exists federated.t1;
drop database if exists federated;
drop table if exists federated.t1;
......
Variable_name Value
have_federated_db YES
have_federated_engine YES
......@@ -778,3 +778,20 @@ sid wnid
39560 01019090000
37994 01019090000
drop table t1;
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (2), (1), (1), (2), (1);
SELECT a FROM t1 ORDER BY a;
a
1
1
1
2
2
(SELECT a FROM t1) ORDER BY a;
a
1
1
1
2
2
DROP TABLE t1;
Variable_name Value
use extern server NO
......@@ -6,6 +6,7 @@ delete from mysql.tables_priv where user like 'mysqltest\_%';
delete from mysql.columns_priv where user like 'mysqltest\_%';
flush privileges;
grant usage on *.* to mysqltest_1@localhost with max_queries_per_hour 2;
flush user_resources;
select * from t1;
i
select * from t1;
......@@ -16,6 +17,7 @@ select * from t1;
ERROR 42000: User 'mysqltest_1' has exceeded the 'max_questions' resource (current value: 2)
drop user mysqltest_1@localhost;
grant usage on *.* to mysqltest_1@localhost with max_updates_per_hour 2;
flush user_resources;
select * from t1;
i
select * from t1;
......@@ -34,6 +36,7 @@ select * from t1;
i
drop user mysqltest_1@localhost;
grant usage on *.* to mysqltest_1@localhost with max_connections_per_hour 2;
flush user_resources;
select * from t1;
i
select * from t1;
......@@ -47,6 +50,7 @@ ERROR 42000: User 'mysqltest_1' has exceeded the 'max_connections' resource (cur
drop user mysqltest_1@localhost;
flush privileges;
grant usage on *.* to mysqltest_1@localhost with max_user_connections 2;
flush user_resources;
select * from t1;
i
select * from t1;
......@@ -56,6 +60,7 @@ ERROR 42000: User 'mysqltest_1' has exceeded the 'max_user_connections' resource
select * from t1;
i
grant usage on *.* to mysqltest_1@localhost with max_user_connections 3;
flush user_resources;
select * from t1;
i
connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK);
......@@ -71,6 +76,7 @@ select @@session.max_user_connections, @@global.max_user_connections;
@@session.max_user_connections @@global.max_user_connections
2 2
grant usage on *.* to mysqltest_1@localhost;
flush user_resources;
select @@session.max_user_connections, @@global.max_user_connections;
@@session.max_user_connections @@global.max_user_connections
2 2
......@@ -79,6 +85,7 @@ i
connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK);
ERROR 42000: User mysqltest_1 already has more than 'max_user_connections' active connections
grant usage on *.* to mysqltest_1@localhost with max_user_connections 3;
flush user_resources;
select @@session.max_user_connections, @@global.max_user_connections;
@@session.max_user_connections @@global.max_user_connections
3 2
......
......@@ -68,12 +68,14 @@ select * from federated.t1 where id = 5;
delete from federated.t1;
select * from federated.t1 where id = 5;
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`) ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
connection slave;
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`) );
connection master;
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`) ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (name, other) values ('First Name', 11111);
insert into federated.t1 (name, other) values ('Second Name', NULL);
insert into federated.t1 (name, other) values ('Third Name', 33333);
......@@ -90,19 +92,78 @@ select * from federated.t1 where name IS NULL;
select * from federated.t1 where name IS NULL and other IS NULL;
select * from federated.t1 where name IS NULL or other IS NULL;
update federated.t1 set name = 'Fourth Name', other = 'four four four' where name IS NULL and other IS NULL;
update federated.t1 set other = 'two two two two' where name = 'Secend Name';
update federated.t1 set other = 'two two two two' where name = 'Second Name';
update federated.t1 set other = 'seven seven' where name like 'Sec%';
update federated.t1 set other = 'seven seven' where name = 'Seventh Name';
update federated.t1 set name = 'Tenth Name' where other like 'fee fie%';
select * from federated.t1 where name IS NULL or other IS NULL ;
select * from federated.t1;
# test multi-keys
connection slave;
drop table if exists federated.t1;
CREATE TABLE federated.t1 (id int, name varchar(32), floatval float, other int) DEFAULT CHARSET=latin1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name`
varchar(32) NOT NULL DEFAULT '', `other` varchar(20) NOT NULL DEFAULT '', PRIMARY KEY (`id`), key nameoth (name, other) );
connection master;
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32) NOT NULL DEFAULT '', `other` varchar(20) NOT NULL DEFAULT '', PRIMARY KEY (`id`), key nameoth (name, other)) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (name, other) values ('First Name', '1111');
insert into federated.t1 (name, other) values ('Second Name', '2222');
insert into federated.t1 (name, other) values ('Third Name', '3333');
select * from federated.t1 where name = 'Second Name';
select * from federated.t1 where other = '2222';
select * from federated.t1 where name = 'Third Name';
select * from federated.t1 where name = 'Third Name' and other = '3333';
connection slave;
drop table if exists federated.t1;
CREATE TABLE federated.t1
(id int NOT NULL auto_increment,
name char(32) NOT NULL DEFAULT '',
bincol binary(4) NOT NULL,
floatval decimal(5,2) NOT NULL DEFAULT 0.0,
other int NOT NULL DEFAULT 0,
primary key(id),
key nameoth(name, other),
key bincol(bincol),
key floatval(floatval));
# test other types of indexes
connection master;
drop table if exists federated.t1;
CREATE TABLE federated.t1
(id int NOT NULL auto_increment,
name char(32) NOT NULL DEFAULT '',
bincol binary(4) NOT NULL,
floatval decimal(5,2) NOT NULL DEFAULT 0.0,
other int NOT NULL DEFAULT 0,
primary key(id),
key nameoth(name,other),
key bincol(bincol),
key floatval(floatval))
ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (name, bincol, floatval, other) values ('first', 0x65, 11.11, 1111);
insert into federated.t1 (name, bincol, floatval, other) values ('second', 0x66, 22.22, 2222);
insert into federated.t1 (name, bincol, floatval, other) values ('third', 'g', 22.22, 2222);
select * from federated.t1;
select * from federated.t1 where name = 'second';
select * from federated.t1 where bincol= 'f';
select * from federated.t1 where bincol= 0x66;
select * from federated.t1 where bincol= 0x67;
select * from federated.t1 where bincol= 'g';
select * from federated.t1 where floatval=11.11;
select * from federated.t1 where name='third';
select * from federated.t1 where other=2222;
select * from federated.t1 where name='third' and other=2222;
# test NULLs
connection slave;
drop table if exists federated.t1;
CREATE TABLE federated.t1 (id int, name varchar(32), floatval float, other int) DEFAULT CHARSET=latin1;
connection master;
drop table if exists federated.t1;
CREATE TABLE federated.t1 (id int, name varchar(32), floatval float, other int) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
# these both should be the same
......@@ -452,15 +513,17 @@ select * from federated.t1;
connection slave;
drop table if exists federated.t1;
create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code)) DEFAULT CHARSET=latin1;
create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob NOT NULL, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code), index(fileguts(10))) DEFAULT CHARSET=latin1;
connection master;
drop table if exists federated.t1;
create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code)) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob NOT NULL, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code), index(fileguts(10))) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (code, fileguts, creation_date) values ('ASDFWERQWETWETAWETA', '*()w*09*$()*#)(*09*^90*d)(*s()d8g)(s*ned)(*)(s*d)(*hn(d*)(*sbn)D((#$*(#*%%&#&^$#&#&#&#&^&#*&*#$*&^*(&#(&Q*&&(*!&!(*&*(#&*(%&#<S-F8>*<S-F8><S-F8><S-F8>#<S-F8>#<S-F8>#<S-F8>[[', '2003-03-03 03:03:03');
insert into federated.t1 (code, fileguts, creation_date) values ('DEUEUEUEUEUEUEUEUEU', '*()w*09*$()*#)(*09*^90*d)(*s()d8g)(s*ned)(*)(s*d)(*hn(d*)(*sbn)D((#$*(#*%%&#&^$#&#&#&#&^&#*&*#$*&^*(&#(&Q*&&(*!&!(*&*(#&*(%&#<S-F8>*<S-F8><S-F8><S-F8>#<S-F8>#<S-F8>#<S-F8>[[', '2004-04-04 04:04:04');
insert into federated.t1 (code, fileguts, creation_date) values ('DEUEUEUEUEUEUEUEUEU', 'jimbob', '2004-04-04 04:04:04');
select * from federated.t1;
drop table if exists federated.t1;
select * from federated.t1 where fileguts = 'jimbob';
# test blob indexes
# TODO
#
......@@ -490,11 +553,36 @@ drop table if exists federated.t1;
# drop table if exists federated.t1;
#
# test joins with non-federated table
connection slave;
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `country_id` int(20) NOT NULL DEFAULT 0, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`), key (country_id));
connection master;
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `country_id` int(20) NOT NULL DEFAULT 0, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`), key (country_id) ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (name, country_id, other) values ('Kumar', 1, 11111);
insert into federated.t1 (name, country_id, other) values ('Lenz', 2, 22222);
insert into federated.t1 (name, country_id, other) values ('Marizio', 3, 33333);
insert into federated.t1 (name, country_id, other) values ('Monty', 4, 33333);
insert into federated.t1 (name, country_id, other) values ('Sanja', 5, 33333);
drop table if exists federated.countries;
CREATE TABLE federated.countries ( `id` int(20) NOT NULL auto_increment, `country` varchar(32), primary key (id));
insert into federated.countries (country) values ('India');
insert into federated.countries (country) values ('Germany');
insert into federated.countries (country) values ('Italy');
insert into federated.countries (country) values ('Finland');
insert into federated.countries (country) values ('Ukraine');
select federated.t1.*, federated.countries.country from federated.t1 left join federated.countries on federated.t1.country_id = federated.countries.id;
drop table federated.countries;
connection master;
--disable_warnings
drop table if exists federated.t1;
drop database if exists federated;
--enable_warnings
......
......@@ -539,3 +539,13 @@ explain select * from t1 where wnid like '0101%' order by wnid;
select * from t1 where wnid like '0101%' order by wnid;
drop table t1;
#
# Bug #7672 - a wrong result for a select query in braces followed by order by
#
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (2), (1), (1), (2), (1);
SELECT a FROM t1 ORDER BY a;
(SELECT a FROM t1) ORDER BY a;
DROP TABLE t1;
......@@ -19,6 +19,8 @@ flush privileges;
# Test of MAX_QUERIES_PER_HOUR limit
grant usage on *.* to mysqltest_1@localhost with max_queries_per_hour 2;
# This ensures that counters are reset and makes test scheduling independent
flush user_resources;
connect (mqph, localhost, mysqltest_1,,);
connection mqph;
select * from t1;
......@@ -37,6 +39,7 @@ disconnect mqph2;
# Test of MAX_UPDATES_PER_HOUR limit
grant usage on *.* to mysqltest_1@localhost with max_updates_per_hour 2;
flush user_resources;
connect (muph, localhost, mysqltest_1,,);
connection muph;
select * from t1;
......@@ -60,6 +63,7 @@ disconnect muph2;
# Test of MAX_CONNECTIONS_PER_HOUR limit
grant usage on *.* to mysqltest_1@localhost with max_connections_per_hour 2;
flush user_resources;
connect (mcph1, localhost, mysqltest_1,,);
connection mcph1;
select * from t1;
......@@ -86,6 +90,7 @@ drop user mysqltest_1@localhost;
# We need this to reset internal mqh_used variable
flush privileges;
grant usage on *.* to mysqltest_1@localhost with max_user_connections 2;
flush user_resources;
connect (muc1, localhost, mysqltest_1,,);
connection muc1;
select * from t1;
......@@ -102,6 +107,7 @@ select * from t1;
# Changing of limit should also help (and immediately)
connection default;
grant usage on *.* to mysqltest_1@localhost with max_user_connections 3;
flush user_resources;
connect (muc4, localhost, mysqltest_1,,);
connection muc4;
select * from t1;
......@@ -127,6 +133,7 @@ set global max_user_connections= 2;
select @@session.max_user_connections, @@global.max_user_connections;
# Let us check that global limit works
grant usage on *.* to mysqltest_1@localhost;
flush user_resources;
connect (muca1, localhost, mysqltest_1,,);
connection muca1;
select @@session.max_user_connections, @@global.max_user_connections;
......@@ -139,6 +146,7 @@ connect (muca3, localhost, mysqltest_1,,);
# Now we are testing that per-account limit prevails over gloabl limit
connection default;
grant usage on *.* to mysqltest_1@localhost with max_user_connections 3;
flush user_resources;
connect (muca3, localhost, mysqltest_1,,);
connection muca3;
select @@session.max_user_connections, @@global.max_user_connections;
......
......@@ -25,6 +25,8 @@
#include "my_alarm.h"
#endif
my_bool timed_mutexes= 0;
/* from my_init */
my_string home_dir=0,my_progname=0;
char NEAR curr_dir[FN_REFLEN]= {0},
......
......@@ -524,6 +524,115 @@ Field *Field::new_key_field(MEM_ROOT *root, struct st_table *new_table,
return tmp;
}
/*
SYNOPSIS
Field::quote_data()
unquoted_string Pointer pointing to the value of a field
DESCRIPTION
Simple method that passes the field type to the method "type_quote"
To get a true/false value as to whether the value in string1 needs
to be enclosed with quotes. This ensures that values in the final
sql statement to be passed to the remote server will be quoted properly
RETURN_VALUE
void Immediately - if string doesn't need quote
void Upon prepending/appending quotes on each side of variable
*/
bool Field::quote_data(String *unquoted_string)
{
char escaped_string[IO_SIZE];
char *unquoted_string_buffer= (char *)(unquoted_string->ptr());
uint need_quotes;
DBUG_ENTER("Field::quote_data");
// this is the same call that mysql_real_escape_string() calls
escape_string_for_mysql(&my_charset_bin, (char *)escaped_string,
unquoted_string->ptr(), unquoted_string->length());
if (is_null())
DBUG_RETURN(0);
need_quotes= needs_quotes();
if (need_quotes == 0)
{
DBUG_RETURN(0);
}
else
{
// reset string, then re-append with quotes and escaped values
unquoted_string->length(0);
if (unquoted_string->append("'"))
DBUG_RETURN(1);
if (unquoted_string->append((char *)escaped_string))
DBUG_RETURN(1);
if (unquoted_string->append("'"))
DBUG_RETURN(1);
}
//DBUG_PRINT("Field::quote_data",
// ("FINAL quote_flag %d unquoted_string %s escaped_string %s",
//needs_quotes, unquoted_string->c_ptr_quick(), escaped_string));
DBUG_RETURN(0);
}
/*
Quote a field type if needed
SYNOPSIS
Field::type_quote
DESCRIPTION
Simple method to give true/false whether a field should be quoted.
Used when constructing INSERT and UPDATE queries to the remote server
see write_row and update_row
RETURN VALUE
0 if value is of type NOT needing quotes
1 if value is of type needing quotes
*/
bool Field::needs_quotes(void)
{
DBUG_ENTER("Field::type_quote");
switch(type()) {
//FIX this when kernel is fixed
case MYSQL_TYPE_VARCHAR :
case FIELD_TYPE_STRING :
case FIELD_TYPE_VAR_STRING :
case FIELD_TYPE_YEAR :
case FIELD_TYPE_NEWDATE :
case FIELD_TYPE_TIME :
case FIELD_TYPE_TIMESTAMP :
case FIELD_TYPE_DATE :
case FIELD_TYPE_DATETIME :
case FIELD_TYPE_TINY_BLOB :
case FIELD_TYPE_BLOB :
case FIELD_TYPE_MEDIUM_BLOB :
case FIELD_TYPE_LONG_BLOB :
case FIELD_TYPE_GEOMETRY :
DBUG_RETURN(1);
case FIELD_TYPE_DECIMAL :
case FIELD_TYPE_TINY :
case FIELD_TYPE_SHORT :
case FIELD_TYPE_INT24 :
case FIELD_TYPE_LONG :
case FIELD_TYPE_FLOAT :
case FIELD_TYPE_DOUBLE :
case FIELD_TYPE_LONGLONG :
case FIELD_TYPE_NULL :
case FIELD_TYPE_SET :
case FIELD_TYPE_ENUM :
DBUG_RETURN(0);
default: DBUG_RETURN(0);
}
DBUG_RETURN(0);
}
/****************************************************************************
Field_null, a field that always return NULL
......
......@@ -228,6 +228,8 @@ public:
ptr= old_ptr;
return str;
}
bool quote_data(String *unquoted_string);
bool needs_quotes(void);
virtual bool send_binary(Protocol *protocol);
virtual char *pack(char* to, const char *from, uint max_length=~(uint) 0)
{
......
......@@ -123,8 +123,8 @@
ha_federated::write_row
<for every field/column>
ha_federated::quote_data
ha_federated::quote_data
Field::quote_data
Field::quote_data
</for every field/column>
ha_federated::reset
......@@ -136,18 +136,18 @@
ha_federated::index_init
ha_federated::index_read
ha_federated::index_read_idx
ha_federated::quote_data
Field::quote_data
ha_federated::rnd_next
ha_federated::convert_row_to_internal_format
ha_federated::update_row
<quote 3 cols, new and old data>
<ha_federated::quote_data
<ha_federated::quote_data
<ha_federated::quote_data
<ha_federated::quote_data
<ha_federated::quote_data
<ha_federated::quote_data
Field::quote_data
Field::quote_data
Field::quote_data
Field::quote_data
Field::quote_data
Field::quote_data
</quote 3 cols, new and old data>
ha_federated::extra
......@@ -415,7 +415,7 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table, uint table_create_fla
share->scheme= my_strdup(table->s->comment, MYF(0));
if (share->username= strstr(share->scheme, "://"))
if ((share->username= strstr(share->scheme, "://")))
{
share->scheme[share->username - share->scheme] = '\0';
if (strcmp(share->scheme, "mysql") != 0)
......@@ -429,18 +429,18 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table, uint table_create_fla
}
share->username+= 3;
if (share->hostname= strchr(share->username, '@'))
if ((share->hostname= strchr(share->username, '@')))
{
share->username[share->hostname - share->username]= '\0';
share->hostname++;
if (share->password= strchr(share->username, ':'))
if ((share->password= strchr(share->username, ':')))
{
share->username[share->password - share->username]= '\0';
share->password++;
share->username= share->username;
// make sure there isn't an extra / or @
if (strchr(share->password, '/') || strchr(share->hostname, '@'))
if ((strchr(share->password, '/') || strchr(share->hostname, '@')))
{
DBUG_PRINT("ha_federated::parse_url",
("this connection string is not in the correct format!!!\n"));
......@@ -453,14 +453,14 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table, uint table_create_fla
user:@hostname:port/database/table
Then password is a null string, so set to NULL
*/
if (share->password[0] == '\0')
if ((share->password[0] == '\0'))
share->password= NULL;
}
else
share->username= share->username;
// make sure there isn't an extra / or @
if (strchr(share->username, '/') || strchr(share->hostname, '@'))
if ((strchr(share->username, '/')) || (strchr(share->hostname, '@')))
{
DBUG_PRINT("ha_federated::parse_url",
("this connection string is not in the correct format!!!\n"));
......@@ -469,12 +469,12 @@ Then password is a null string, so set to NULL
DBUG_RETURN(-1);
}
if (share->database= strchr(share->hostname, '/'))
if ((share->database= strchr(share->hostname, '/')))
{
share->hostname[share->database - share->hostname]= '\0';
share->database++;
if (share->sport= strchr(share->hostname, ':'))
if ((share->sport= strchr(share->hostname, ':')))
{
share->hostname[share->sport - share->hostname]= '\0';
share->sport++;
......@@ -484,7 +484,7 @@ Then password is a null string, so set to NULL
share->port= atoi(share->sport);
}
if (share->table_base_name= strchr(share->database, '/'))
if ((share->table_base_name= strchr(share->database, '/')))
{
share->database[share->table_base_name - share->database]= '\0';
share->table_base_name++;
......@@ -507,7 +507,7 @@ Then password is a null string, so set to NULL
DBUG_RETURN(-1);
}
// make sure there's not an extra /
if (strchr(share->table_base_name, '/'))
if ((strchr(share->table_base_name, '/')))
{
DBUG_PRINT("ha_federated::parse_url",
("this connection string is not in the correct format!!!\n"));
......@@ -586,126 +586,117 @@ uint ha_federated::convert_row_to_internal_format(byte *record, MYSQL_ROW row)
DBUG_RETURN(0);
}
/*
SYNOPSIS
quote_data()
unquoted_string Pointer pointing to the value of a field
field MySQL Field pointer to field being checked for type
DESCRIPTION
Simple method that passes the field type to the method "type_quote"
To get a true/false value as to whether the value in string1 needs
to be enclosed with quotes. This ensures that values in the final
sql statement to be passed to the remote server will be quoted properly
RETURN_VALUE
void Immediately - if string doesn't need quote
void Upon prepending/appending quotes on each side of variable
*/
void ha_federated::quote_data(String *unquoted_string, Field *field )
bool ha_federated::create_where_from_key(
String *to,
KEY *key_info,
const byte *key,
uint key_length
)
{
char escaped_string[IO_SIZE];
char *unquoted_string_buffer;
unquoted_string_buffer= unquoted_string->c_ptr_quick();
int quote_flag;
DBUG_ENTER("ha_federated::quote_data");
// this is the same call that mysql_real_escape_string() calls
escape_string_for_mysql(&my_charset_bin, (char *)escaped_string,
unquoted_string->c_ptr_quick(), unquoted_string->length());
DBUG_PRINT("ha_federated::quote_data",
("escape_string_for_mysql unescaped %s escaped %s",
unquoted_string->c_ptr_quick(), escaped_string));
if (field->is_null())
{
DBUG_PRINT("ha_federated::quote_data",
("NULL, no quoted needed for unquoted_string %s, returning.",
unquoted_string->c_ptr_quick()));
DBUG_VOID_RETURN;
}
uint second_loop= 0;
KEY_PART_INFO *key_part;
bool needs_quotes;
quote_flag= type_quote(field->type());
if (quote_flag == 0)
{
DBUG_PRINT("ha_federated::quote_data",
("quote flag 0 no quoted needed for unquoted_string %s, returning.",
unquoted_string->c_ptr_quick()));
DBUG_VOID_RETURN;
}
else
DBUG_ENTER("ha_federated::create_where_from_key");
for (key_part= key_info->key_part ; (int) key_length > 0 ; key_part++)
{
// reset string, then re-append with quotes and escaped values
unquoted_string->length(0);
unquoted_string->append("'");
unquoted_string->append((char *)escaped_string);
unquoted_string->append("'");
}
DBUG_PRINT("ha_federated::quote_data",
("FINAL quote_flag %d unquoted_string %s escaped_string %s",
quote_flag, unquoted_string->c_ptr_quick(), escaped_string));
DBUG_VOID_RETURN;
}
/*
Quote a field type if needed
Field *field= key_part->field;
needs_quotes= field->needs_quotes();
//bool needs_quotes= type_quote(field->type());
DBUG_PRINT("ha_federated::create_where_from_key", ("key name %s type %d", field->field_name, field->type()));
uint length= key_part->length;
if (second_loop++ && to->append(" AND ",5))
DBUG_RETURN(1);
if (to->append('`') || to->append(field->field_name) ||
to->append("` ",2))
DBUG_RETURN(1); // Out of memory
if (key_part->null_bit)
{
if (*key++)
{
if (to->append("IS NULL",7))
DBUG_PRINT("ha_federated::create_where_from_key", ("NULL type %s", to->c_ptr_quick()));
DBUG_RETURN(1);
key_length-= key_part->store_length;
key+= key_part->store_length-1;
continue;
}
key_length--;
}
if (to->append("= "))
DBUG_RETURN(1);
if (needs_quotes && to->append("'"))
DBUG_RETURN(1);
if (key_part->type == HA_KEYTYPE_BIT)
{
/* This is can be threated as a hex string */
Field_bit *field= (Field_bit *) (key_part->field);
char buff[64+2], *ptr;
byte *end= (byte *)(key) + length;
buff[0]='0';
buff[1]='x';
for (ptr= buff+2 ; key < end ; key++)
{
uint tmp= (uint) (uchar) *key;
*ptr++=_dig_vec_upper[tmp >> 4];
*ptr++=_dig_vec_upper[tmp & 15];
}
if (to->append(buff, (uint) (ptr-buff)))
DBUG_RETURN(1);
SYNOPSIS
ha_federated::type_quote
int field Enumerated field type number
DBUG_PRINT("ha_federated::create_where_from_key", ("bit type %s", to->c_ptr_quick()));
key_length-= length;
continue;
}
if (key_part->key_part_flag & HA_BLOB_PART)
{
uint blob_length= uint2korr(key);
key+= HA_KEY_BLOB_LENGTH;
key_length-= HA_KEY_BLOB_LENGTH;
if (append_escaped(to, (char *)(key), blob_length))
DBUG_RETURN(1);
DBUG_PRINT("ha_federated::create_where_from_key", ("blob type %s", to->c_ptr_quick()));
length= key_part->length;
}
else if (key_part->key_part_flag & HA_VAR_LENGTH_PART)
{
length= uint2korr(key);
key+= HA_KEY_BLOB_LENGTH;
if (append_escaped(to, (char *)(key), length))
DBUG_RETURN(1);
DESCRIPTION
Simple method to give true/false whether a field should be quoted.
Used when constructing INSERT and UPDATE queries to the remote server
see write_row and update_row
DBUG_PRINT("ha_federated::create_where_from_key", ("varchar type %s", to->c_ptr_quick()));
}
else
{
DBUG_PRINT("ha_federated::create_where_from_key", ("else block, unknown type so far"));
char buff[MAX_FIELD_WIDTH];
String str(buff, sizeof(buff), field->charset()), *res;
RETURN VALUE
0 if value is of type NOT needing quotes
1 if value is of type needing quotes
*/
uint ha_federated::type_quote(int type)
{
DBUG_ENTER("ha_federated::type_quote");
DBUG_PRINT("ha_federated::type_quote", ("field type %d", type));
switch(type) {
//FIX this is a bug, fix when kernel is fixed
case MYSQL_TYPE_VARCHAR :
case FIELD_TYPE_STRING :
case FIELD_TYPE_VAR_STRING :
case FIELD_TYPE_YEAR :
case FIELD_TYPE_NEWDATE :
case FIELD_TYPE_TIME :
case FIELD_TYPE_TIMESTAMP :
case FIELD_TYPE_DATE :
case FIELD_TYPE_DATETIME :
case FIELD_TYPE_TINY_BLOB :
case FIELD_TYPE_BLOB :
case FIELD_TYPE_MEDIUM_BLOB :
case FIELD_TYPE_LONG_BLOB :
case FIELD_TYPE_GEOMETRY :
DBUG_RETURN(1);
res= field->val_str(&str, (char *)(key));
if (field->result_type() == STRING_RESULT)
{
if (append_escaped(to, (char *) res->ptr(), res->length()))
DBUG_RETURN(1);
res= field->val_str(&str, (char *)(key));
case FIELD_TYPE_DECIMAL :
case FIELD_TYPE_TINY :
case FIELD_TYPE_SHORT :
case FIELD_TYPE_INT24 :
case FIELD_TYPE_LONG :
case FIELD_TYPE_FLOAT :
case FIELD_TYPE_DOUBLE :
case FIELD_TYPE_LONGLONG :
case FIELD_TYPE_NULL :
case FIELD_TYPE_SET :
case FIELD_TYPE_ENUM :
DBUG_PRINT("ha_federated::create_where_from_key", ("else block, string type", to->c_ptr_quick()));
}
else if (to->append(res->ptr(), res->length()))
DBUG_RETURN(1);
}
if (needs_quotes && to->append("'"))
DBUG_RETURN(1);
DBUG_PRINT("ha_federated::create_where_from_key", ("final value for 'to' %s", to->c_ptr_quick()));
key+= length;
key_length-= length;
DBUG_RETURN(0);
default: DBUG_RETURN(0);
}
DBUG_RETURN(0);
DBUG_RETURN(1);
}
int load_conn_info(FEDERATED_SHARE *share, TABLE *table)
......@@ -975,7 +966,7 @@ int ha_federated::write_row(byte * buf)
int x= 0, num_fields= 0;
Field **field;
ulong current_query_id= 1;
ulong tmp_query_id;
ulong tmp_query_id= 1;
int all_fields_have_same_query_id= 1;
char insert_buffer[IO_SIZE];
......@@ -1060,7 +1051,8 @@ int ha_federated::write_row(byte * buf)
insert_string.append((*field)->field_name);
// quote these fields if they require it
quote_data(&insert_field_value_string, *field);
(*field)->quote_data(&insert_field_value_string);
// append the value
values_string.append(insert_field_value_string);
insert_field_value_string.length(0);
......@@ -1068,9 +1060,10 @@ int ha_federated::write_row(byte * buf)
// append commas between both fields and fieldnames
insert_string.append(',');
values_string.append(',');
DBUG_PRINT("ha_federated::write_row",
("insert_string %s values_string %s insert_field_value_string %s",
insert_string.c_ptr_quick(), values_string.c_ptr_quick(), insert_field_value_string.c_ptr_quick()));
DBUG_PRINT("ha_federated::write_row",
("insert_string %s values_string %s insert_field_value_string %s",
insert_string.c_ptr_quick(), values_string.c_ptr_quick(),
insert_field_value_string.c_ptr_quick()));
}
}
......@@ -1137,8 +1130,8 @@ int ha_federated::update_row(
byte * new_data
)
{
uint x= 0;
uint has_a_primary_key;
int x= 0;
uint has_a_primary_key= 0;
int primary_key_field_num;
char old_field_value_buffer[IO_SIZE], new_field_value_buffer[IO_SIZE];
char update_buffer[IO_SIZE], where_buffer[IO_SIZE];
......@@ -1205,7 +1198,7 @@ int ha_federated::update_row(
{
// otherwise =
(*field)->val_str(&new_field_value);
quote_data(&new_field_value, *field);
(*field)->quote_data(&new_field_value);
if ( has_a_primary_key )
{
......@@ -1223,7 +1216,7 @@ int ha_federated::update_row(
{
(*field)->val_str(&old_field_value,
(char *)(old_data + (*field)->offset()));
quote_data(&old_field_value, *field);
(*field)->quote_data(&old_field_value);
where_string.append(old_field_value);
}
}
......@@ -1235,7 +1228,7 @@ int ha_federated::update_row(
{
(*field)->val_str(&old_field_value,
(char *)(old_data + (*field)->offset()));
quote_data(&old_field_value, *field);
(*field)->quote_data(&old_field_value);
where_string.append(old_field_value);
}
}
......@@ -1312,7 +1305,7 @@ int ha_federated::delete_row(const byte * buf)
{
delete_string.append("=");
(*field)->val_str(&data_string);
quote_data(&data_string, *field);
(*field)->quote_data(&data_string);
}
delete_string.append(data_string);
......@@ -1366,8 +1359,11 @@ int ha_federated::index_read_idx(byte * buf, uint index, const byte * key,
__attribute__((unused)))
{
char index_value[IO_SIZE];
char key_value[IO_SIZE];
char test_value[IO_SIZE];
String index_string(index_value, sizeof(index_value), &my_charset_bin);
index_string.length(0);
uint keylen;
char sql_query_buffer[IO_SIZE];
String sql_query(sql_query_buffer, sizeof(sql_query_buffer), &my_charset_bin);
......@@ -1376,20 +1372,20 @@ int ha_federated::index_read_idx(byte * buf, uint index, const byte * key,
DBUG_ENTER("ha_federated::index_read_idx");
statistic_increment(table->in_use->status_var.ha_read_key_count,&LOCK_status);
index_string.length(0);
sql_query.length(0);
sql_query.append(share->select_query);
sql_query.append(" WHERE ");
sql_query.append(table->key_info[index].key_part->field->field_name);
sql_query.append(" = ");
table->key_info[index].key_part->field->val_str(&index_string, (char *)(key));
quote_data(&index_string, table->key_info[index].key_part->field);
keylen= strlen((char *)(key));
create_where_from_key(&index_string, &table->key_info[index], key, keylen);
sql_query.append(index_string);
DBUG_PRINT("ha_federated::index_read_idx",
("sql_query %s", sql_query.c_ptr_quick()));
("current key %d key value %s index_string value %s length %d", index, (char *)(key),index_string.c_ptr_quick(),
index_string.length()));
DBUG_PRINT("ha_federated::index_read_idx",
("current position %d sql_query %s", current_position,
sql_query.c_ptr_quick()));
if (mysql_real_query(mysql, sql_query.c_ptr_quick(), sql_query.length()))
{
......@@ -1540,7 +1536,7 @@ int ha_federated::rnd_pos(byte * buf, byte *pos)
{
DBUG_ENTER("ha_federated::rnd_pos");
statistic_increment(table->in_use->status_var.ha_read_rnd_count,&LOCK_status);
memcpy(current_position, pos, sizeof(MYSQL_ROW_OFFSET)); // pos is not aligned
memcpy_fixed(&current_position, pos, sizeof(MYSQL_ROW_OFFSET)); // pos is not aligned
result->current_row= 0;
result->data_cursor= current_position;
DBUG_RETURN(rnd_next(buf));
......
......@@ -71,10 +71,8 @@ private:
return 0 on success
return errorcode otherwise
*/
//FIX
uint convert_row_to_internal_format(byte *buf, MYSQL_ROW row);
uint type_quote(int type);
void quote_data(String *string1, Field *field);
bool ha_federated::create_where_from_key(String *to, KEY *key_info, const byte *key, uint key_length);
public:
ha_federated(TABLE *table): handler(table),
......@@ -104,7 +102,7 @@ public:
{
return (HA_TABLE_SCAN_ON_INDEX | HA_NOT_EXACT_COUNT |
HA_PRIMARY_KEY_IN_READ_INDEX | HA_FILE_BASED | HA_AUTO_PART_KEY |
HA_TABLE_SCAN_ON_INDEX);
HA_TABLE_SCAN_ON_INDEX | HA_CAN_INDEX_BLOBS);
}
/*
This is a bitmap of flags that says how the storage engine
......@@ -132,7 +130,7 @@ public:
/*
The next method will never be called if you do not implement indexes.
*/
virtual double read_time(ha_rows rows) { return (double) rows / 20.0+1; }
virtual double read_time(uint index, uint ranges, ha_rows rows) { return (double) rows / 20.0+1; }
/*
Everything below are methods that we implment in ha_federated.cc.
......
......@@ -712,6 +712,10 @@ void free_des_key_file();
/* sql_do.cc */
bool mysql_do(THD *thd, List<Item> &values);
/* sql_analyse.h */
bool append_escaped(String *to_str, String *from_str);
bool append_escaped(String *to_str, char *from, uint from_len);
/* sql_show.cc */
bool mysqld_show_open_tables(THD *thd,const char *wild);
bool mysqld_show_logs(THD *thd);
......@@ -1001,8 +1005,7 @@ extern ulong ha_read_count, ha_discover_count;
extern ulong table_cache_size;
extern ulong max_connections,max_connect_errors, connect_timeout;
extern ulong slave_net_timeout;
extern ulong max_user_connections;
extern my_bool timed_mutexes;
extern uint max_user_connections;
extern ulong what_to_log,flush_time;
extern ulong query_buff_size, thread_stack,thread_stack_min;
extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit;
......
......@@ -333,9 +333,9 @@ ulong delayed_insert_errors,flush_time, thread_created;
ulong specialflag=0;
ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
ulong max_connections,max_used_connections,
max_connect_errors, max_user_connections = 0;
max_connect_errors;
uint max_user_connections= 0;
ulong thread_id=1L,current_pid;
my_bool timed_mutexes= 0;
ulong slow_launch_threads = 0, sync_binlog_period;
ulong expire_logs_days = 0;
ulong rpl_recovery_rank=0;
......@@ -5254,8 +5254,8 @@ The minimum value for this variable is 4096.",
REQUIRED_ARG, 32, 1, ~0L, 0, 1, 0},
{"max_user_connections", OPT_MAX_USER_CONNECTIONS,
"The maximum number of active connections for a single user (0 = no limit).",
(gptr*) &max_user_connections, (gptr*) &max_user_connections, 0, GET_ULONG,
REQUIRED_ARG, 0, 1, ~0L, 0, 1, 0},
(gptr*) &max_user_connections, (gptr*) &max_user_connections, 0, GET_UINT,
REQUIRED_ARG, 0, 1, ~0, 0, 1, 0},
{"max_write_lock_count", OPT_MAX_WRITE_LOCK_COUNT,
"After this many write locks, allow some read locks to run in between.",
(gptr*) &max_write_lock_count, (gptr*) &max_write_lock_count, 0, GET_ULONG,
......
......@@ -732,7 +732,7 @@ struct show_var_st init_vars[]= {
{"have_crypt", (char*) &have_crypt, SHOW_HAVE},
{"have_csv", (char*) &have_csv_db, SHOW_HAVE},
{"have_example_engine", (char*) &have_example_db, SHOW_HAVE},
{"have_federated_db", (char*) &have_federated_db, SHOW_HAVE},
{"have_federated_engine", (char*) &have_federated_db, SHOW_HAVE},
{"have_geometry", (char*) &have_geometry, SHOW_HAVE},
{"have_innodb", (char*) &have_innodb, SHOW_HAVE},
{"have_isam", (char*) &have_isam, SHOW_HAVE},
......@@ -1599,6 +1599,14 @@ Item *sys_var::item(THD *thd, enum_var_type var_type, LEX_STRING *base)
var_type= OPT_GLOBAL;
}
switch (type()) {
case SHOW_INT:
{
uint value;
pthread_mutex_lock(&LOCK_global_system_variables);
value= *(uint*) value_ptr(thd, var_type, base);
pthread_mutex_unlock(&LOCK_global_system_variables);
return new Item_uint((int32) value);
}
case SHOW_LONG:
{
ulong value;
......
......@@ -740,7 +740,7 @@ public:
return type != OPT_GLOBAL || !option_limits;
}
void set_default(THD *thd, enum_var_type type);
SHOW_TYPE type() { return SHOW_LONG; }
SHOW_TYPE type() { return SHOW_INT; }
byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
};
......
......@@ -59,7 +59,8 @@ int compare_ulonglong2(void* cmp_arg __attribute__((unused)),
return compare_ulonglong(s,t);
}
static bool append_escaped(String *to_str, String *from_str);
bool append_escaped(String *to_str, String *from_str);
bool append_escaped(String *to_str, char *from, uint from_len);
Procedure *
proc_analyse_init(THD *thd, ORDER *param, select_result *result,
......@@ -1052,7 +1053,7 @@ uint check_ulonglong(const char *str, uint length)
1 Out of memory
*/
static bool append_escaped(String *to_str, String *from_str)
bool append_escaped(String *to_str, String *from_str)
{
char *from, *end, c;
......@@ -1086,3 +1087,38 @@ static bool append_escaped(String *to_str, String *from_str)
}
return 0;
}
bool append_escaped(String *to_str, char *from, uint from_len)
{
char *end, c;
if (to_str->realloc(to_str->length() + from_len))
return 1;
end= from + from_len;
for (; from < end; from++)
{
c= *from;
switch (c) {
case '\0':
c= '0';
break;
case '\032':
c= 'Z';
break;
case '\\':
case '\'':
break;
default:
goto normal_character;
}
if (to_str->append('\\'))
return 1;
normal_character:
if (to_str->append(c))
return 1;
}
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment