未验证 提交 472fff2e 编写于 作者: X xiaoleizi2016 提交者: GitHub

Merge branch 'master' into issue0402

...@@ -181,6 +181,8 @@ obproxy-tmp* ...@@ -181,6 +181,8 @@ obproxy-tmp*
src/.DS_Store src/.DS_Store
unittest/.DS_Store unittest/.DS_Store
ob_proxy_parser.output ob_proxy_parser.output
.vscode/*
rpm/.dep_create
deps/3rd/home deps/3rd/home
deps/3rd/var deps/3rd/var
deps/3rd/usr deps/3rd/usr
......
...@@ -42,7 +42,8 @@ ...@@ -42,7 +42,8 @@
http://www.quicklz.com/) http://www.quicklz.com/)
http://www.goof.com/pcg/marc/liblzf.html) http://www.goof.com/pcg/marc/liblzf.html)
http://www.fastlz.org/ http://www.fastlz.org/
http://stackoverflow.com/a/32095106/646947 http://stackoverflow.com/*
https://stackoverflow.com/*
http://fastcompression.blogspot.com/p/lz4.html http://fastcompression.blogspot.com/p/lz4.html
https://groups.google.com/forum/# https://groups.google.com/forum/#
https://github.com/mcmilk/zstdmt https://github.com/mcmilk/zstdmt
......
...@@ -73,14 +73,19 @@ function do_config() ...@@ -73,14 +73,19 @@ function do_config()
echo -e "\033[31m ===build debug version=== \033[0m" echo -e "\033[31m ===build debug version=== \033[0m"
;; ;;
xgcov) xgcov)
# configure for release # configure for gcov
./configure --with-gcc-version=9.3.0 --with-coverage=yes --enable-buildtime=no --enable-strip-ut=no --enable-silent-rules --enable-dlink-observer=no ./configure --with-gcc-version=9.3.0 --with-coverage=yes --enable-buildtime=no --enable-strip-ut=no --enable-silent-rules --enable-dlink-observer=no
echo -e "\033[31m ===build gcov version=== \033[0m" echo -e "\033[31m ===build gcov version=== \033[0m"
;; ;;
xperf) xasan)
# configure for release # configure for asan
./configure --with-gcc-version=9.3.0 --with-coverage=no --enable-buildtime=no --enable-strip-ut=no --enable-silent-rules --enable-dlink-observer=no --with-release --with-perf ./configure --with-gcc-version=9.3.0 --with-coverage=no --enable-buildtime=no --enable-strip-ut=no --enable-silent-rules --enable-dlink-observer=no --with-asan
echo -e "\033[31m ===build perf version=== \033[0m" echo -e "\033[31m ===build asan version=== \033[0m"
;;
xso)
# configure for obproxy_so
./configure --with-gcc-version=9.3.0 --with-coverage=no --enable-buildtime=no --enable-strip-ut=no --enable-silent-rules --enable-dlink-observer=no --with-release --with-so
echo -e "\033[31m ===build so version=== \033[0m"
;; ;;
*) *)
# configure for release # configure for release
...@@ -116,7 +121,7 @@ function do_rpm() ...@@ -116,7 +121,7 @@ function do_rpm()
cd ${TMP_DIR}/BUILD cd ${TMP_DIR}/BUILD
echo "[BUILD] make rpms..._prefix=${PREFIX} spec_file=${SPEC_FILE}" echo "[BUILD] make rpms..._prefix=${PREFIX} spec_file=${SPEC_FILE}"
rpmbuild --define "_topdir ${TMP_DIR}" --define "NAME ${PACKAGE}" --define "VERSION ${VERSION}" --define "_prefix ${PREFIX}" --define "RELEASE ${RELEASE}" -ba ${TOPDIR}/deps/3rd/${SPEC_FILE} || exit 2 rpmbuild --define "_topdir ${TMP_DIR}" --define "NAME ${PACKAGE}" --define "VERSION ${VERSION}" --define "_prefix ${PREFIX}" --define "RELEASE ${RELEASE}" --define "rpm_path ${TOPDIR}" -ba ${TOPDIR}/deps/3rd/${SPEC_FILE} || exit 2
echo "[BUILD] make rpms done." echo "[BUILD] make rpms done."
cd ${TOPDIR} cd ${TOPDIR}
......
AC_INIT([OceanBase], AC_INIT([OceanBase],
[3.2.3.5], [4.1.0.0],
[wgs13579@gmail.com], [wgs13579@gmail.com],
[obproxy-ce], [obproxy-ce],
[http://oceanbase.taobao.org/]) [http://oceanbase.taobao.org/])
obapi_version="3.2.3.5" obapi_version="4.1.0.0"
AC_SUBST(obapi_version) AC_SUBST(obapi_version)
AC_DISABLE_STATIC AC_DISABLE_STATIC
...@@ -26,12 +26,12 @@ ...@@ -26,12 +26,12 @@
if test "$withval" = "yes"; then if test "$withval" = "yes"; then
case "$host_cpu" in case "$host_cpu" in
*aarch64* ) *aarch64* )
AM_CXXFLAGS="-g -O2 -D_OB_VERSION=1000 -D_NO_EXCEPTION -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DNDEBUG -D__USE_LARGEFILE64 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -Wall -Wextra -Wno-unused-parameter -Wformat -Wno-conversion -Wno-deprecated -Wno-invalid-offsetof -Wno-unused-result -Wno-format-security -finline-functions -fno-strict-aliasing -mtune=generic -Wno-psabi -Wno-sign-compare -Wno-class-memaccess -Wno-deprecated-copy -Wno-ignored-qualifiers -Wno-aligned-new -Wno-format-truncation -Wno-literal-suffix -Wno-format-overflow -Wno-stringop-truncation -Wno-memset-elt-size -Wno-cast-function-type -Wno-address-of-packed-member -fuse-ld=lld -ffunction-sections -Wl,--no-warn-symbol-ordering,--symbol-ordering-file,${ac_abs_confdir}/hotfuncs.txt" AM_CXXFLAGS="-g -O2 -D_OB_VERSION=1000 -D_NO_EXCEPTION -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DNDEBUG -D__USE_LARGEFILE64 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -Wall -Wextra -Wno-unused-parameter -Wformat -Wno-conversion -Wno-deprecated -Wno-invalid-offsetof -Wno-unused-result -Wno-format-security -finline-functions -fno-strict-aliasing -mtune=generic -march=armv8-a+crc -Wno-psabi -Wno-sign-compare -Wno-class-memaccess -Wno-deprecated-copy -Wno-ignored-qualifiers -Wno-aligned-new -Wno-format-truncation -Wno-literal-suffix -Wno-format-overflow -Wno-stringop-truncation -Wno-memset-elt-size -Wno-cast-function-type -Wno-address-of-packed-member -fno-omit-frame-pointer"
AM_CFLAGS="-g -O2 -D_OB_VERSION=1000 -DCOMPATIBLE -D__USE_LARGEFILE64 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DNDEBUG -finline-functions -fno-strict-aliasing -Wall -mtune=generic -Wno-psabi -Wno-sign-compare -fuse-ld=lld -ffunction-sections -Wl,--no-warn-symbol-ordering,--symbol-ordering-file,${ac_abs_confdir}/hotfuncs.txt" AM_CFLAGS="-g -O2 -D_OB_VERSION=1000 -DCOMPATIBLE -D__USE_LARGEFILE64 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DNDEBUG -finline-functions -fno-strict-aliasing -Wall -mtune=generic -Wno-psabi -Wno-sign-compare"
;; ;;
* ) * )
AM_CXXFLAGS="-g -O2 -D_OB_VERSION=1000 -D_NO_EXCEPTION -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DNDEBUG -D__USE_LARGEFILE64 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -Wall -Wextra -Wno-unused-parameter -Wformat -Wno-conversion -Wno-deprecated -Wno-invalid-offsetof -Wno-unused-result -Wno-format-security -finline-functions -fno-strict-aliasing -mtune=core2 -Wno-psabi -Wno-sign-compare -Wno-class-memaccess -Wno-deprecated-copy -Wno-ignored-qualifiers -Wno-aligned-new -Wno-format-truncation -Wno-literal-suffix -Wno-format-overflow -Wno-stringop-truncation -Wno-memset-elt-size -Wno-cast-function-type -Wno-address-of-packed-member -fuse-ld=lld -ffunction-sections -Wl,--no-warn-symbol-ordering,--symbol-ordering-file,${ac_abs_confdir}/hotfuncs.txt" AM_CXXFLAGS="-g -O2 -D_OB_VERSION=1000 -D_NO_EXCEPTION -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DNDEBUG -D__USE_LARGEFILE64 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -Wall -Wextra -Wno-unused-parameter -Wformat -Wno-conversion -Wno-deprecated -Wno-invalid-offsetof -Wno-unused-result -Wno-format-security -finline-functions -fno-strict-aliasing -mtune=core2 -Wno-psabi -Wno-sign-compare -Wno-class-memaccess -Wno-deprecated-copy -Wno-ignored-qualifiers -Wno-aligned-new -Wno-format-truncation -Wno-literal-suffix -Wno-format-overflow -Wno-stringop-truncation -Wno-memset-elt-size -Wno-cast-function-type -Wno-address-of-packed-member -fno-omit-frame-pointer"
AM_CFLAGS="-g -O2 -D_OB_VERSION=1000 -DCOMPATIBLE -D__USE_LARGEFILE64 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DNDEBUG -finline-functions -fno-strict-aliasing -Wall -mtune=core2 -Wno-psabi -Wno-sign-compare -fuse-ld=lld -ffunction-sections -Wl,--no-warn-symbol-ordering,--symbol-ordering-file,${ac_abs_confdir}/hotfuncs.txt" AM_CFLAGS="-g -O2 -D_OB_VERSION=1000 -DCOMPATIBLE -D__USE_LARGEFILE64 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DNDEBUG -finline-functions -fno-strict-aliasing -Wall -mtune=core2 -Wno-psabi -Wno-sign-compare"
;; ;;
esac esac
fi fi
...@@ -41,6 +41,26 @@ ...@@ -41,6 +41,26 @@
] ]
) )
AC_ARG_WITH([so],
AS_HELP_STRING([--with-so],
[with so support (default is NO)]),
[
if test "$withval" = "yes"; then
support_so=yes
AM_CXXFLAGS="${AM_CXXFLAGS} -fPIC"
AM_CFLAGS="${AM_CFLAGS} -fPIC"
fi
],
[support_so=no]
)
AM_CONDITIONAL([HAVE_SO], test x$support_so = xyes )
if test "$support_so" == "no"; then
AM_CXXFLAGS="${AM_CXXFLAGS} -fuse-ld=lld -ffunction-sections -Wl,--no-warn-symbol-ordering,--symbol-ordering-file,${ac_abs_confdir}/hotfuncs.txt"
AM_CFLAGS="${AM_CFLAGS} -fuse-ld=lld -ffunction-sections -Wl,--no-warn-symbol-ordering,--symbol-ordering-file,${ac_abs_confdir}/hotfuncs.txt"
fi
#check gcc version, add -Wno-ignored-qualifiers flag for gcc version greater than 4.3.0 #check gcc version, add -Wno-ignored-qualifiers flag for gcc version greater than 4.3.0
GCC_VERSION=`$CC -dumpfullversion -dumpversion` GCC_VERSION=`$CC -dumpfullversion -dumpversion`
if test $? -eq 0; then if test $? -eq 0; then
...@@ -101,21 +121,16 @@ ...@@ -101,21 +121,16 @@
], ],
[]) [])
AC_ARG_WITH([perf], AC_ARG_WITH([asan],
AS_HELP_STRING([--with-perf], AS_HELP_STRING([--with-asan],
[with perf (default is NO)]), [with asan (default is NO)]),
[ [
if test "$withval" = "yes"; then if test "$withval" = "yes"; then
# The following parameters are options for using gperftools, AM_CXXFLAGS="${AM_CXXFLAGS} -fsanitize=address -fstack-protector-strong -fno-optimize-sibling-calls -fno-omit-frame-pointer -static-libasan -fno-var-tracking-assignments -fno-optimize-sibling-calls -fno-inline -DUSING_ASAN"
# currently not using tcmalloc AM_CFLAGS="${AM_CFLAGS} -fsanitize=address -fstack-protector-strong -fno-optimize-sibling-calls -fno-omit-frame-pointer -static-libasan -fno-var-tracking-assignments -fno-optimize-sibling-calls -fno-inline -DUSING_ASAN"
# test_perf=yes
# AM_CXXFLAGS="${AM_CXXFLAGS} -D__NEED_PERF__"
# AM_LDFLAGS="${AM_LDFLAGS} -lprofiler"
AM_CXXFLAGS="${AM_CXXFLAGS} -fno-omit-frame-pointer"
AM_CFLAGS="${AM_CFLAGS} -fno-omit-frame-pointer"
fi fi
], ],
[with_perf=no] [with_asan=no]
) )
AC_ARG_WITH([5u-support], AC_ARG_WITH([5u-support],
......
...@@ -34,16 +34,29 @@ OceanBase Database Proxy ...@@ -34,16 +34,29 @@ OceanBase Database Proxy
%setup %setup
%build %build
./configure CXX=${CXX} CC=${CC} --with-gcc-version=9.3.0 RELEASEID=%{RELEASE} --prefix=%{_prefix} --with-test-case=no --with-release=yes --with-tblib-root=/opt/csr/common --with-easy-root=/usr --with-easy-lib-path=/usr/lib64 --with-svnfile --enable-shared=default --enable-silent-rules mkdir -p lib
mkdir -p unittest cp ${TOOLS_DIR}/lib64/libstdc++.so.6.0.28 lib/libstdc++.so.6
#./configure CXX=${CXX} CC=${CC} --with-gcc-version=9.3.0 --with-so --prefix=%{_prefix} --with-test-case=no --with-release=yes --with-tblib-root=/opt/csr/common --with-easy-root=/usr --with-easy-lib-path=/usr/lib64 --with-svnfile --enable-shared=default --enable-silent-rules
CPU_CORES=`grep -c ^processor /proc/cpuinfo` CPU_CORES=`grep -c ^processor /proc/cpuinfo`
MAKE_ARGS="-j $CPU_CORES" MAKE_ARGS="-j $CPU_CORES"
#make $MAKE_ARGS
#cp src/obproxy/.libs/libobproxy_so.so.0.0.0 lib/libobproxy_so.so
#make distclean >/dev/null 2>&1
#find . -path ./tools/codestyle/astyle/build -prune -o -path ./doc -prune -o -name Makefile -exec rm -f {} \;
#find . -name .deps -prune -exec rm -rf {} \;
./configure CXX=${CXX} CC=${CC} --with-gcc-version=9.3.0 RELEASEID=%{RELEASE} --prefix=%{_prefix} --with-test-case=no --with-release=yes --with-tblib-root=/opt/csr/common --with-easy-root=/usr --with-easy-lib-path=/usr/lib64 --with-svnfile --enable-shared=default --enable-silent-rules
mkdir -p unittest
make $MAKE_ARGS make $MAKE_ARGS
%install %install
make DESTDIR=$RPM_BUILD_ROOT install make DESTDIR=$RPM_BUILD_ROOT install
mkdir -p $RPM_BUILD_ROOT%{install_dir}/bin mkdir -p $RPM_BUILD_ROOT%{install_dir}/bin
mkdir -p $RPM_BUILD_ROOT%{install_dir}/lib
cp src/obproxy/obproxy $RPM_BUILD_ROOT%{install_dir}/bin cp src/obproxy/obproxy $RPM_BUILD_ROOT%{install_dir}/bin
cp -r lib/* $RPM_BUILD_ROOT%{install_dir}/lib
cp script/deploy/obproxyd.sh $RPM_BUILD_ROOT%{install_dir}/bin cp script/deploy/obproxyd.sh $RPM_BUILD_ROOT%{install_dir}/bin
%clean %clean
...@@ -54,12 +67,19 @@ rm -rf $RPM_BUILD_ROOT ...@@ -54,12 +67,19 @@ rm -rf $RPM_BUILD_ROOT
%dir %{install_dir}/bin %dir %{install_dir}/bin
%{install_dir}/bin/obproxy %{install_dir}/bin/obproxy
%{install_dir}/bin/obproxyd.sh %{install_dir}/bin/obproxyd.sh
%{install_dir}/lib/libstdc++.so.6
%pre %pre
rm -rf %{install_dir}/log rm -rf %{install_dir}/log
rm -rf %{install_dir}/bin rm -rf %{install_dir}/bin
rm -rf %{install_dir}/etc rm -rf %{install_dir}/etc
rm -rf %{install_dir}/.conf rm -rf %{install_dir}/.conf
rm -rf /u01/obproxy/lib
mkdir -p /u01/obproxy/lib
%post %post
chown -R admin:admin %{install_dir} chown -R admin:admin %{install_dir}
ln -s %{install_dir}/lib/libobproxy_so.so /u01/obproxy/lib/libobproxy_so.so.0
ln -s %{install_dir}/lib/libobproxy_so.so /u01/obproxy/lib/libobproxy_so.so
ln -s %{install_dir}/lib/libprotobuf.so.18 /u01/obproxy/lib/libprotobuf.so.18
ln -s %{install_dir}/lib/libstdc++.so.6 /u01/obproxy/lib/libstdc++.so.6
...@@ -1601,14 +1601,6 @@ static int easy_ssl_dhparam(easy_ssl_ctx_t *ssl, char *file) ...@@ -1601,14 +1601,6 @@ static int easy_ssl_dhparam(easy_ssl_ctx_t *ssl, char *file)
DH *dh; DH *dh;
BIO *bio; BIO *bio;
/*
* -----BEGIN DH PARAMETERS-----
* MIGHAoGBALu8LcrYRnSQfEP89YDpz9vZWKP1aLQtSwju1OsPs1BMbAMCducQgAxc
* y7qokiYUxb7spWWl/fHSh6K8BJvmd4Bg6RqSp1fjBI9osHb302zI8pul34HcLKcl
* 7OZicMyaUDXYzs7vnqAnSmOrHlj6/UmI0PZdFGdX2gcd8EXP4WubAgEC
* -----END DH PARAMETERS-----
*/
static unsigned char dh1024_p[] = { static unsigned char dh1024_p[] = {
0xBB, 0xBC, 0x2D, 0xCA, 0xD8, 0x46, 0x74, 0x90, 0x7C, 0x43, 0xFC, 0xF5, 0xBB, 0xBC, 0x2D, 0xCA, 0xD8, 0x46, 0x74, 0x90, 0x7C, 0x43, 0xFC, 0xF5,
0x80, 0xE9, 0xCF, 0xDB, 0xD9, 0x58, 0xA3, 0xF5, 0x68, 0xB4, 0x2D, 0x4B, 0x80, 0xE9, 0xCF, 0xDB, 0xD9, 0x58, 0xA3, 0xF5, 0x68, 0xB4, 0x2D, 0x4B,
...@@ -1677,19 +1669,6 @@ static int easy_ssl_dhparam_mysql(easy_ssl_ctx_t *ssl) ...@@ -1677,19 +1669,6 @@ static int easy_ssl_dhparam_mysql(easy_ssl_ctx_t *ssl)
{ {
DH *dh; DH *dh;
/*
Diffie-Hellman key.
Generated using: >openssl dhparam -5 -C 2048
-----BEGIN DH PARAMETERS-----
MIIBCAKCAQEAil36wGZ2TmH6ysA3V1xtP4MKofXx5n88xq/aiybmGnReZMviCPEJ
46+7VCktl/RZ5iaDH1XNG1dVQmznt9pu2G3usU+k1/VB4bQL4ZgW4u0Wzxh9PyXD
glm99I9Xyj4Z5PVE4MyAsxCRGA1kWQpD9/zKAegUBPLNqSo886Uqg9hmn8ksyU9E
BV5eAEciCuawh6V0O+Sj/C3cSfLhgA0GcXp3OqlmcDu6jS5gWjn3LdP1U0duVxMB
h/neTSCSvtce4CAMYMjKNVh9P1nu+2d9ZH2Od2xhRIqMTfAS1KTqF3VmSWzPFCjG
mjxx/bg6bOOjpgZapvB6ABWlWmRmAAWFtwIBBQ==
-----END DH PARAMETERS-----
*/
static unsigned char dh2048_p[]= static unsigned char dh2048_p[]=
{ {
0x8A, 0x5D, 0xFA, 0xC0, 0x66, 0x76, 0x4E, 0x61, 0xFA, 0xCA, 0xC0, 0x37, 0x8A, 0x5D, 0xFA, 0xC0, 0x66, 0x76, 0x4E, 0x61, 0xFA, 0xCA, 0xC0, 0x37,
......
...@@ -147,7 +147,7 @@ function check_opt() ...@@ -147,7 +147,7 @@ function check_opt()
OBPROXY_OPT_LOCAL="${OBPROXY_OPT_LOCAL},$OBPROXY_EXTRA_OPT" OBPROXY_OPT_LOCAL="${OBPROXY_OPT_LOCAL},$OBPROXY_EXTRA_OPT"
fi fi
OBPROXY_OPT_LOCAL=",enable_cached_server=true,enable_get_rslist_remote=true,monitor_stat_dump_interval=1s,enable_qos=true,enable_standby=false,query_digest_time_threshold=2ms,monitor_cost_ms_unit=true,enable_strict_kernel_release=false,enable_proxy_scramble=true,work_thread_num=$WORK_THREAD_NUM,proxy_mem_limited='2G',log_dir_size_threshold=10G${OBPROXY_OPT_LOCAL}" OBPROXY_OPT_LOCAL=",server_detect_mode=0,enable_primary_zone=false,enable_cached_server=true,enable_get_rslist_remote=true,monitor_stat_dump_interval=1s,enable_qos=true,enable_standby=false,query_digest_time_threshold=2ms,monitor_cost_ms_unit=true,enable_strict_kernel_release=false,enable_proxy_scramble=true,work_thread_num=$WORK_THREAD_NUM,proxy_mem_limited='2G',log_dir_size_threshold=10G${OBPROXY_OPT_LOCAL}"
} }
# change to the path where this script locates. # change to the path where this script locates.
......
...@@ -131,8 +131,10 @@ enum ObKVCachePolicy ...@@ -131,8 +131,10 @@ enum ObKVCachePolicy
struct ObKVCacheConfig struct ObKVCacheConfig
{ {
public: public:
ObKVCacheConfig(); /* this function is defined for c driver client compile */
void reset(); ObKVCacheConfig() {};
/* this function is defined for c driver client compile */
void reset() {};
bool is_valid_; bool is_valid_;
int64_t priority_; int64_t priority_;
char cache_name_[MAX_CACHE_NAME_LENGTH]; char cache_name_[MAX_CACHE_NAME_LENGTH];
...@@ -267,9 +269,12 @@ class ObKVCacheInstMap; ...@@ -267,9 +269,12 @@ class ObKVCacheInstMap;
class ObKVCacheInstHandle class ObKVCacheInstHandle
{ {
public: public:
ObKVCacheInstHandle(); /* this function is defined for c driver client compile */
virtual ~ObKVCacheInstHandle(); ObKVCacheInstHandle() {};
void reset(); /* this function is defined for c driver client compile */
virtual ~ObKVCacheInstHandle() {};
/* this function is defined for c driver client compile */
void reset() {};
inline ObKVCacheInst *get_inst() { return inst_; } inline ObKVCacheInst *get_inst() { return inst_; }
private: private:
friend class ObKVCacheInstMap; friend class ObKVCacheInstMap;
...@@ -291,8 +296,10 @@ struct ObKVCacheInfo ...@@ -291,8 +296,10 @@ struct ObKVCacheInfo
class ObKVCacheInstMap class ObKVCacheInstMap
{ {
public: public:
ObKVCacheInstMap(); /* this function is defined for c driver client compile */
virtual ~ObKVCacheInstMap(); ObKVCacheInstMap() {};
/* this function is defined for c driver client compile */
virtual ~ObKVCacheInstMap() {};
int init(const int64_t max_entry_cnt, const ObKVCacheConfig *configs); int init(const int64_t max_entry_cnt, const ObKVCacheConfig *configs);
void destroy(); void destroy();
int get_cache_inst( int get_cache_inst(
...@@ -319,8 +326,10 @@ private: ...@@ -319,8 +326,10 @@ private:
class ObKVCacheStore class ObKVCacheStore
{ {
public: public:
ObKVCacheStore(); /* this function is defined for c driver client compile */
virtual ~ObKVCacheStore(); ObKVCacheStore() {};
/* this function is defined for c driver client compile */
virtual ~ObKVCacheStore() {};
int init(ObKVCacheInstMap &insts, const int64_t max_cache_size, const int64_t block_size); int init(ObKVCacheInstMap &insts, const int64_t max_cache_size, const int64_t block_size);
void destroy(); void destroy();
int set_priority(const int64_t cache_id, const int64_t old_priority, const int64_t new_priority); int set_priority(const int64_t cache_id, const int64_t old_priority, const int64_t new_priority);
...@@ -394,8 +403,10 @@ private: ...@@ -394,8 +403,10 @@ private:
class ObKVCacheMap class ObKVCacheMap
{ {
public: public:
ObKVCacheMap(); /* this function is defined for c driver client compile */
virtual ~ObKVCacheMap(); ObKVCacheMap() {};
/* this function is defined for c driver client compile */
virtual ~ObKVCacheMap() {};
int init(const int64_t bucket_num, ObKVCacheStore *store); int init(const int64_t bucket_num, ObKVCacheStore *store);
void destroy(); void destroy();
int erase_all(); int erase_all();
...@@ -452,19 +463,23 @@ class ObKVCacheHandle; ...@@ -452,19 +463,23 @@ class ObKVCacheHandle;
class ObKVGlobalCache class ObKVGlobalCache
{ {
public: public:
static ObKVGlobalCache &get_instance(); /* this function is defined for c driver client compile */
static ObKVGlobalCache &get_instance() {return *(new ObKVGlobalCache());};
int init(const int64_t bucket_num = DEFAULT_BUCKET_NUM, int init(const int64_t bucket_num = DEFAULT_BUCKET_NUM,
const int64_t max_cache_size = DEFAULT_MAX_CACHE_SIZE, const int64_t max_cache_size = DEFAULT_MAX_CACHE_SIZE,
const int64_t block_size = common::OB_MALLOC_BIG_BLOCK_SIZE); const int64_t block_size = common::OB_MALLOC_BIG_BLOCK_SIZE);
void destroy(); void destroy();
void reload_priority(); /* this function is defined for c driver client compile */
void reload_priority() {};
int get_tenant_cache_info(const uint64_t tenant_id, ObIArray<ObKVCacheInfo> &infos); int get_tenant_cache_info(const uint64_t tenant_id, ObIArray<ObKVCacheInfo> &infos);
int get_all_cache_info(ObIArray<ObKVCacheInfo> &infos); int get_all_cache_info(ObIArray<ObKVCacheInfo> &infos);
private: private:
template<class Key, class Value> friend class ObKVCache; template<class Key, class Value> friend class ObKVCache;
friend class ObKVCacheHandle; friend class ObKVCacheHandle;
ObKVGlobalCache(); /* this function is defined for c driver client compile */
virtual ~ObKVGlobalCache(); ObKVGlobalCache() {}
/* this function is defined for c driver client compile */
virtual ~ObKVGlobalCache() {}
int register_cache(const char *cache_name, const int64_t priority, int64_t &cache_id); int register_cache(const char *cache_name, const int64_t priority, int64_t &cache_id);
void deregister_cache(const int64_t cache_id); void deregister_cache(const int64_t cache_id);
int set_priority(const int64_t cache_id, const int64_t priority); int set_priority(const int64_t cache_id, const int64_t priority);
...@@ -482,7 +497,8 @@ private: ...@@ -482,7 +497,8 @@ private:
ObKVMemBlockHandle *&mb_handle); ObKVMemBlockHandle *&mb_handle);
int erase(const int64_t cache_id, const ObIKVCacheKey &key); int erase(const int64_t cache_id, const ObIKVCacheKey &key);
void revert(ObKVMemBlockHandle *mb_handle); void revert(ObKVMemBlockHandle *mb_handle);
void wash(); /* this function is defined for c driver client compile */
void wash() {};
private: private:
static const int64_t DEFAULT_BUCKET_NUM = 10000000L; static const int64_t DEFAULT_BUCKET_NUM = 10000000L;
static const int64_t DEFAULT_MAX_CACHE_SIZE = 1024L * 1024L * 1024L * 1024L; //1T static const int64_t DEFAULT_MAX_CACHE_SIZE = 1024L * 1024L * 1024L * 1024L; //1T
......
...@@ -58,10 +58,13 @@ public: ...@@ -58,10 +58,13 @@ public:
public: public:
friend class ObISQLClient; friend class ObISQLClient;
ReadResult(); /* this function is defined for c driver client compile */
virtual ~ReadResult(); ReadResult() {}
/* this function is defined for c driver client compile */
virtual ~ReadResult() {}
sqlclient::ObMySQLResult *mysql_result(); /* this function is defined for c driver client compile */
sqlclient::ObMySQLResult *mysql_result() {return nullptr;}
// FIXME : remove // FIXME : remove
sqlclient::ObMySQLResult *get_result() { return mysql_result(); } sqlclient::ObMySQLResult *get_result() { return mysql_result(); }
......
...@@ -1563,7 +1563,7 @@ static int double_float(const ObObjType expect_type, ObObjCastParams &params, ...@@ -1563,7 +1563,7 @@ static int double_float(const ObObjType expect_type, ObObjCastParams &params,
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_ERROR("invalid input type", LOG_ERROR("invalid input type",
K(ret), K(in), K(expect_type)); K(ret), K(in), K(expect_type));
} else if (CAST_FAIL(real_range_check(expect_type, in.get_double(), value))) { } else if (!lib::is_oracle_mode() && CAST_FAIL(real_range_check(expect_type, in.get_double(), value))) {
} else { } else {
out.set_float(expect_type, value); out.set_float(expect_type, value);
} }
...@@ -2975,17 +2975,30 @@ static int string_datetime(const ObObjType expect_type, ObObjCastParams &params, ...@@ -2975,17 +2975,30 @@ static int string_datetime(const ObObjType expect_type, ObObjCastParams &params,
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
ObScale res_scale = -1; ObScale res_scale = -1;
ObString utf8_string;
if (OB_UNLIKELY((ObStringTC != in.get_type_class() if (OB_UNLIKELY((ObStringTC != in.get_type_class()
&& ObTextTC != in.get_type_class()) && ObTextTC != in.get_type_class())
|| ObDateTimeTC != ob_obj_type_class(expect_type))) { || ObDateTimeTC != ob_obj_type_class(expect_type))) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_ERROR("invalid input type", LOG_ERROR("invalid input type",
K(ret), K(in), K(expect_type)); K(ret), K(in), K(expect_type));
} else if (lib::is_oracle_mode() && in.is_blob()) {
ret = OB_NOT_SUPPORTED;
LOG_ERROR("invalid use of blob type", K(ret), K(in), K(expect_type));
LOG_USER_ERROR(OB_NOT_SUPPORTED, "Cast to blob type");
} else if (OB_FAIL(convert_string_collation(in.get_string(), in.get_collation_type(), utf8_string, ObCharset::get_system_collation(), params))) {
LOG_WARN("convert_string_collation", K(ret));
} else { } else {
const ObTimeZoneInfo *tz_info = (ObTimestampType == expect_type) ? params.dtc_params_.tz_info_ : NULL;
int64_t value = 0; int64_t value = 0;
if (CAST_FAIL(ObTimeConverter::str_to_datetime(in.get_string(), tz_info, value, &res_scale))) { ObTimeConvertCtx cvrt_ctx(params.dtc_params_.tz_info_, ObTimestampType == expect_type);
if (lib::is_oracle_mode()) {
cvrt_ctx.oracle_nls_format_ = params.dtc_params_.get_nls_format(ObDateTimeType);
CAST_FAIL(ObTimeConverter::str_to_date_oracle(utf8_string, cvrt_ctx, value));
} else { } else {
CAST_FAIL(ObTimeConverter::str_to_datetime(utf8_string, cvrt_ctx.tz_info_, value, &res_scale));
}
if(OB_SUCC(ret)) {
SET_RES_DATETIME(out); SET_RES_DATETIME(out);
} }
} }
...@@ -3067,29 +3080,56 @@ static int string_string(const ObObjType expect_type, ObObjCastParams &params, ...@@ -3067,29 +3080,56 @@ static int string_string(const ObObjType expect_type, ObObjCastParams &params,
ObString str; ObString str;
in.get_string(str); in.get_string(str);
if (0 != str.length() if (0 != str.length()
&& CS_TYPE_BINARY != in.get_collation_type() // in mysql mode if charset is binary then not convert
&& CS_TYPE_BINARY != params.dest_collation_ // in oracle mode if charset is binary then convert
&& ((CS_TYPE_BINARY != in.get_collation_type() && CS_TYPE_BINARY != params.dest_collation_)
|| lib::is_oracle_mode())
&& CS_TYPE_INVALID != in.get_collation_type() && CS_TYPE_INVALID != in.get_collation_type()
&& CS_TYPE_INVALID != params.dest_collation_ && CS_TYPE_INVALID != params.dest_collation_
&& (ObCharset::charset_type_by_coll(in.get_collation_type()) && (ObCharset::charset_type_by_coll(in.get_collation_type())
!= ObCharset::charset_type_by_coll(params.dest_collation_))) { != ObCharset::charset_type_by_coll(params.dest_collation_))) {
char *buf = NULL; char *buf = NULL;
// buf_len is related to the encoding length, gbk uses 2 bytes to encode a character, utf8mb4 uses 1 to 4 bytes const int32_t CharConvertFactorNum = 4;
// CharConvertFactorNum is a multiple of the requested memory size
const int32_t CharConvertFactorNum = 2;
int32_t buf_len = str.length() * CharConvertFactorNum; int32_t buf_len = str.length() * CharConvertFactorNum;
uint32_t result_len = 0; uint32_t result_len = 0;
if (OB_UNLIKELY(NULL == (buf = static_cast<char*>(params.alloc(buf_len))))) { if (OB_UNLIKELY(NULL == (buf = static_cast<char*>(params.alloc(buf_len))))) {
ret = OB_ALLOCATE_MEMORY_FAILED; ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_ERROR("alloc memory failed", K(ret)); LOG_ERROR("alloc memory failed", K(ret));
} else if (OB_FAIL(ObCharset::charset_convert(in.get_collation_type(), } else {
str.ptr(), ret = ObCharset::charset_convert(in.get_collation_type(),
str.length(), str.ptr(),
params.dest_collation_, str.length(),
buf, params.dest_collation_,
buf_len, buf,
result_len))) { buf_len,
LOG_WARN("charset convert failed", K(ret), K(in.get_collation_type()), K(params.dest_collation_)); result_len);
if (OB_SUCCESS != ret) {
int32_t str_offset = 0;
int32_t buf_offset = 0;
ObString question_mark("?");
while (str_offset < str.length() && buf_offset + question_mark.length() <= buf_len) {
int64_t offset = ObCharset::charpos(in.get_collation_type(), str.ptr() + str_offset,
str.length() - str_offset, 1);
ret = ObCharset::charset_convert(in.get_collation_type(), str.ptr() + str_offset,
static_cast<uint32_t>(offset), params.dest_collation_, buf + buf_offset, buf_len - buf_offset, result_len);
str_offset += static_cast<int32_t>(offset);
if (OB_SUCCESS == ret && result_len > 0) {
buf_offset += result_len;
} else {
MEMCPY(buf + buf_offset, question_mark.ptr(), question_mark.length());
buf_offset += question_mark.length();
}
}
if (str_offset < str.length()) {
ret = OB_SIZE_OVERFLOW;
LOG_WARN("size overflow", K(ret), K(str));
} else {
// The log is printed here to remind that there are characters that fail to convert and are replaced by '?'
LOG_DEBUG("charset convert failed", K(ret), K(in.get_collation_type()), K(params.dest_collation_));
result_len = static_cast<uint32_t>(buf_offset);
ret = OB_SUCCESS;
}
}
} }
LOG_DEBUG("convert result", K(str), "result", ObHexEscapeSqlStr(ObString(result_len, buf))); LOG_DEBUG("convert result", K(str), "result", ObHexEscapeSqlStr(ObString(result_len, buf)));
...@@ -4125,9 +4165,17 @@ int obj_accuracy_check(ObCastCtx &cast_ctx, ...@@ -4125,9 +4165,17 @@ int obj_accuracy_check(ObCastCtx &cast_ctx,
const ObObj *&res_obj) const ObObj *&res_obj)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
bool valid_accuracy = true;
ObObjType type = obj.get_type();
if (ob_is_number_tc(type) || ob_is_double_tc(type) || ob_is_float_tc(type)) {
if (accuracy.precision_ == -1 || accuracy.scale_ == -1) {
valid_accuracy = false; // invalid accuracy
}
}
if (accuracy.is_valid()) { LOG_DEBUG("obj_accuracy_check before", K(obj), K(accuracy), K(cs_type), K(valid_accuracy));
LOG_DEBUG("obj_accuracy_check before", K(obj), K(accuracy), K(cs_type));
if (valid_accuracy && accuracy.is_valid()) {
switch (obj.get_type_class()) { switch (obj.get_type_class()) {
case ObFloatTC: { case ObFloatTC: {
ret = float_range_check(cast_ctx, accuracy, obj, buf_obj, res_obj, cast_ctx.cast_mode_); ret = float_range_check(cast_ctx, accuracy, obj, buf_obj, res_obj, cast_ctx.cast_mode_);
......
...@@ -90,6 +90,8 @@ enum ObObjType ...@@ -90,6 +90,8 @@ enum ObObjType
ObNCharType = 44, // nchar ObNCharType = 44, // nchar
ObURowIDType = 45, // UROWID ObURowIDType = 45, // UROWID
ObLobType = 46, // Oracle Lob ObLobType = 46, // Oracle Lob
ObJsonType = 47, // Json Type
ObGeometryType = 48, // Geometry type
ObMaxType // invalid type, or count of obj type ObMaxType // invalid type, or count of obj type
}; };
...@@ -295,7 +297,7 @@ inline bool ob_is_blob(const ObObjType type, const ObCollationType cs_type) ...@@ -295,7 +297,7 @@ inline bool ob_is_blob(const ObObjType type, const ObCollationType cs_type)
inline bool is_obj_type_supported(ObObjType type) inline bool is_obj_type_supported(ObObjType type)
{ {
return (type > ObNullType && type < ObUnknownType) return (type > ObNullType && type < ObUnknownType)
|| ob_is_otimestamp_type(type); || ob_is_otimestamp_type(type) || ob_is_number_tc(type);
} }
// to_string adapter // to_string adapter
......
...@@ -249,7 +249,7 @@ int64_t ObObj::get_deep_copy_size() const ...@@ -249,7 +249,7 @@ int64_t ObObj::get_deep_copy_size() const
int64_t ret = 0; int64_t ret = 0;
if (is_string_type()) { if (is_string_type()) {
ret += val_len_; ret += val_len_;
} else if (ObNumberType == meta_.get_type() || ObUNumberType == meta_.get_type()) { } else if (ob_is_number_tc(get_type())) {
ret += (sizeof(uint32_t) * nmb_desc_.len_); ret += (sizeof(uint32_t) * nmb_desc_.len_);
} }
return ret; return ret;
...@@ -443,7 +443,7 @@ ObObjTypeFuncs OBJ_FUNCS[ObMaxType] = ...@@ -443,7 +443,7 @@ ObObjTypeFuncs OBJ_FUNCS[ObMaxType] =
DEF_FUNC_ENTRY(ObRawType), // 39, raw DEF_FUNC_ENTRY(ObRawType), // 39, raw
DEF_FUNC_ENTRY(ObNullType), // 40 DEF_FUNC_ENTRY(ObNullType), // 40
DEF_FUNC_ENTRY(ObNullType), // 41 DEF_FUNC_ENTRY(ObNullType), // 41
DEF_FUNC_ENTRY(ObNullType), // 42 DEF_FUNC_ENTRY(ObNumberFloatType), // 42
DEF_FUNC_ENTRY(ObNVarchar2Type), // 43, nvarchar2 DEF_FUNC_ENTRY(ObNVarchar2Type), // 43, nvarchar2
DEF_FUNC_ENTRY(ObNCharType), // 44, nchar DEF_FUNC_ENTRY(ObNCharType), // 44, nchar
}; };
......
...@@ -383,6 +383,13 @@ public: ...@@ -383,6 +383,13 @@ public:
void set_time_value(const int64_t value); void set_time_value(const int64_t value);
void set_year_value(const uint8_t value); void set_year_value(const uint8_t value);
void set_timestamp_tz(const int64_t time_us, const uint32_t time_ctx_desc) { set_otimestamp_value(ObTimestampTZType, time_us, time_ctx_desc); }
void set_timestamp_ltz(const int64_t time_us, const uint16_t time_desc) { set_otimestamp_value(ObTimestampLTZType, time_us, time_desc); }
void set_timestamp_nano(const int64_t time_us, const uint16_t time_desc) { set_otimestamp_value(ObTimestampNanoType, time_us, time_desc); }
void set_timestamp_tz(const ObOTimestampData &value) { set_otimestamp_value(ObTimestampTZType, value); }
void set_timestamp_ltz(const ObOTimestampData &value) { set_otimestamp_value(ObTimestampLTZType, value); }
void set_timestamp_nano(const ObOTimestampData &value) { set_otimestamp_value(ObTimestampNanoType, value); }
void set_string(const ObObjType type, const char *ptr, const ObString::obstr_size_t size); void set_string(const ObObjType type, const char *ptr, const ObString::obstr_size_t size);
void set_string(const ObObjType type, const ObString &value); void set_string(const ObObjType type, const ObString &value);
void set_varchar(const ObString &value); void set_varchar(const ObString &value);
......
...@@ -49,8 +49,10 @@ public: ...@@ -49,8 +49,10 @@ public:
int init(const uint64_t table_id, const int32_t partition_idx, const int32_t partition_cnt); int init(const uint64_t table_id, const int32_t partition_idx, const int32_t partition_cnt);
int parse(const char* str); int parse(const char* str);
void reset(); /* this function is defined for c driver client compile */
bool is_valid() const; void reset() {};
/* this function is defined for c driver client compile */
bool is_valid() const {return true;};
uint64_t hash() const; uint64_t hash() const;
uint64_t inner_hash() const; uint64_t inner_hash() const;
int compare(const ObPartitionKey &other) const; int compare(const ObPartitionKey &other) const;
......
...@@ -40,11 +40,19 @@ class ObCond ...@@ -40,11 +40,19 @@ class ObCond
static const int64_t SPIN_WAIT_NUM = 0; static const int64_t SPIN_WAIT_NUM = 0;
static const int64_t BUSY_INTERVAL = 1000; static const int64_t BUSY_INTERVAL = 1000;
public: public:
explicit ObCond(const int64_t spin_wait_num = SPIN_WAIT_NUM); /* this function is defined for c driver client compile */
~ObCond(); explicit ObCond(const int64_t spin_wait_num = SPIN_WAIT_NUM) :spin_wait_num_(spin_wait_num) {}
/* this function is defined for c driver client compile */
~ObCond() {}
public: public:
void signal(); /* this function is defined for c driver client compile */
int timedwait(const int64_t time_us); void signal() {}
/* this function is defined for c driver client compile */
int timedwait(const int64_t time_us)
{
UNUSED(time_us);
return OB_NOT_IMPLEMENT;
}
int wait(); int wait();
private: private:
const int64_t spin_wait_num_; const int64_t spin_wait_num_;
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#include "common/ob_range.h" #include "common/ob_range.h"
#include "lib/utility/utility.h" #include "lib/utility/utility.h"
#include "lib/regex/ob_regex.h" #include "lib/regex/ob_regex.h"
#include "lib/allocator/ob_allocator.h"
#include "obproxy/opsql/expr_parser/ob_expr_parse_result.h"
namespace oceanbase namespace oceanbase
...@@ -100,6 +102,45 @@ public: ...@@ -100,6 +102,45 @@ public:
return ret; return ret;
} }
int build_row_key(int64_t columns_num, ObIAllocator &allocator) {
// build row key like (min, min, min : max, max, max)
int ret = OB_SUCCESS;
if (columns_num < 0 || columns_num > OBPROXY_MAX_PART_LEVEL) {
ret = OB_INVALID_ARGUMENT;
COMMON_LOG(WARN, "invalid", K(columns_num));
} else {
void *start_objs_buf = NULL;
void *end_objs_buf = NULL;
if (OB_ISNULL((start_objs_buf = allocator.alloc(sizeof(ObObj) * columns_num))) && columns_num != 0) {
ret = OB_ALLOCATE_MEMORY_FAILED;
COMMON_LOG(WARN, "fail to alloc new obj", K(ret), K(columns_num));
} else if (OB_ISNULL(end_objs_buf = allocator.alloc(sizeof(ObObj) * columns_num)) && columns_num !=0) {
ret = OB_ALLOCATE_MEMORY_FAILED;
COMMON_LOG(WARN, "fail to alloc new obj", K(ret), K(columns_num));
} else {
for (int i = 0; OB_SUCC(ret) && i < columns_num; i++) {
ObObj *start = NULL;
ObObj *end = NULL;
if (OB_ISNULL(start = new (reinterpret_cast<ObObj*>(start_objs_buf) + i) ObObj())) {
ret = OB_ERR_UNEXPECTED;
COMMON_LOG(WARN, "failed to do placement new", K(start_objs_buf), K(ret));
} else if (OB_ISNULL(end = new (reinterpret_cast<ObObj*>(end_objs_buf) + i) ObObj())) {
ret = OB_ERR_UNEXPECTED;
COMMON_LOG(WARN, "failed to do placement new", K(end_objs_buf), K(ret));
} else {
start->set_min_value();
end->set_max_value();
}
}
if (OB_SUCC(ret)) {
start_key_.assign(reinterpret_cast<ObObj*>(start_objs_buf), columns_num);
end_key_.assign(reinterpret_cast<ObObj*>(end_objs_buf), columns_num);
}
}
}
return ret;
}
// new compare func for tablet.range and scan_param.range // new compare func for tablet.range and scan_param.range
inline int compare_with_endkey2(const ObNewRange &r) const inline int compare_with_endkey2(const ObNewRange &r) const
{ {
......
...@@ -307,6 +307,15 @@ int ObSMUtils::get_ob_type(ObObjType &ob_type, EMySQLFieldType mysql_type) ...@@ -307,6 +307,15 @@ int ObSMUtils::get_ob_type(ObObjType &ob_type, EMySQLFieldType mysql_type)
case OB_MYSQL_TYPE_COMPLEX: case OB_MYSQL_TYPE_COMPLEX:
ob_type = ObExtendType; ob_type = ObExtendType;
break; break;
case OB_MYSQL_TYPE_OB_UROWID:
ob_type = ObURowIDType;
break;
case OB_MYSQL_TYPE_JSON:
ob_type = ObJsonType;
break;
case OB_MYSQL_TYPE_GEOMETRY:
ob_type = ObGeometryType;
break;
default: default:
_OB_LOG(WARN, "unsupport MySQL type %d", mysql_type); _OB_LOG(WARN, "unsupport MySQL type %d", mysql_type);
ret = OB_OBJ_TYPE_ERROR; ret = OB_OBJ_TYPE_ERROR;
......
...@@ -40,9 +40,16 @@ lib/charset/ob_charset.cpp\ ...@@ -40,9 +40,16 @@ lib/charset/ob_charset.cpp\
lib/charset/ob_ctype.h\ lib/charset/ob_ctype.h\
lib/charset/ob_ctype.c\ lib/charset/ob_ctype.c\
lib/charset/ob_ctype_utf8.c\ lib/charset/ob_ctype_utf8.c\
lib/charset/ob_ctype_gb18030.cc\
lib/charset/ob_ctype_gbk.c\
lib/charset/ob_ctype_utf16.c\
lib/charset/ob_ctype_uca.c\
lib/charset/ob_ctype_mb.c\ lib/charset/ob_ctype_mb.c\
lib/charset/ob_ctype_bin.c\ lib/charset/ob_ctype_bin.c\
lib/charset/ob_ctype_simple.c\
lib/charset/ob_ctype_latin1.c\
lib/charset/ob_mysql_global.h\ lib/charset/ob_mysql_global.h\
lib/charset/ob_config.h\
lib/charset/ob_dtoa.h\ lib/charset/ob_dtoa.h\
lib/charset/ob_dtoa.c\ lib/charset/ob_dtoa.c\
lib/charset/ob_uctype.h\ lib/charset/ob_uctype.h\
...@@ -151,6 +158,7 @@ lib/oblog/ob_trace_log.h\ ...@@ -151,6 +158,7 @@ lib/oblog/ob_trace_log.h\
lib/oblog/ob_trace_log.cpp\ lib/oblog/ob_trace_log.cpp\
lib/oblog/ob_warning_buffer.h\ lib/oblog/ob_warning_buffer.h\
lib/oblog/ob_warning_buffer.cpp\ lib/oblog/ob_warning_buffer.cpp\
lib/oblog/ob_simple_trace.h\
lib/queue/ob_dedup_queue.h\ lib/queue/ob_dedup_queue.h\
lib/queue/ob_dedup_queue.cpp\ lib/queue/ob_dedup_queue.cpp\
lib/queue/ob_fixed_queue.h\ lib/queue/ob_fixed_queue.h\
...@@ -207,6 +215,10 @@ lib/utility/ob_template_utils.h\ ...@@ -207,6 +215,10 @@ lib/utility/ob_template_utils.h\
lib/utility/serialization.h\ lib/utility/serialization.h\
lib/utility/ob_unify_serialize.h\ lib/utility/ob_unify_serialize.h\
lib/utility/ob_serialization_helper.h\ lib/utility/ob_serialization_helper.h\
lib/utility/ob_2_0_full_link_trace_util.h\
lib/utility/ob_2_0_full_link_trace_util.cpp\
lib/utility/ob_2_0_full_link_trace_info.h\
lib/utility/ob_2_0_full_link_trace_info.cpp\
lib/net/ob_addr.h\ lib/net/ob_addr.h\
lib/net/ob_addr.cpp\ lib/net/ob_addr.cpp\
lib/net/tbnetutil.cpp\ lib/net/tbnetutil.cpp\
...@@ -226,6 +238,9 @@ lib/stat/ob_stat_template.h\ ...@@ -226,6 +238,9 @@ lib/stat/ob_stat_template.h\
lib/stat/ob_di_list.h\ lib/stat/ob_di_list.h\
lib/stat/ob_di_tls.h\ lib/stat/ob_di_tls.h\
lib/trace/ob_trace_event.h\ lib/trace/ob_trace_event.h\
lib/trace/ob_trace.h\
lib/trace/ob_trace.cpp\
lib/trace/ob_trace_def.h\
lib/profile/ob_trace_id.h\ lib/profile/ob_trace_id.h\
lib/wait_event/ob_wait_class.h\ lib/wait_event/ob_wait_class.h\
lib/wait_event/ob_wait_event.h\ lib/wait_event/ob_wait_event.h\
......
...@@ -28,6 +28,8 @@ using namespace oceanbase::lib; ...@@ -28,6 +28,8 @@ using namespace oceanbase::lib;
EXTERN_C_BEGIN EXTERN_C_BEGIN
#ifndef USING_ASAN
extern void *__libc_malloc(size_t size); extern void *__libc_malloc(size_t size);
extern void __libc_free(void *ptr); extern void __libc_free(void *ptr);
extern void *__libc_realloc(void *ptr, size_t size); extern void *__libc_realloc(void *ptr, size_t size);
...@@ -290,4 +292,6 @@ int posix_memalign(void **memptr, size_t alignment, size_t size) ...@@ -290,4 +292,6 @@ int posix_memalign(void **memptr, size_t alignment, size_t size)
return err; return err;
} }
#endif
EXTERN_C_END EXTERN_C_END
...@@ -21,17 +21,36 @@ namespace common ...@@ -21,17 +21,36 @@ namespace common
class ObConcurrentFIFOAllocator : public common::ObIAllocator class ObConcurrentFIFOAllocator : public common::ObIAllocator
{ {
public: public:
ObConcurrentFIFOAllocator(); /* this function is defined for c driver client compile */
virtual ~ObConcurrentFIFOAllocator(); ObConcurrentFIFOAllocator() {};
/* this function is defined for c driver client compile */
virtual ~ObConcurrentFIFOAllocator() {};
public: public:
/* this function is defined for c driver client compile */
int init(const int64_t total_limit, int init(const int64_t total_limit,
const int64_t hold_limit, const int64_t hold_limit,
const int64_t page_size); const int64_t page_size)
void destroy(); {
UNUSED(total_limit);
UNUSED(hold_limit);
UNUSED(page_size);
return OB_NOT_IMPLEMENT;
}
/* this function is defined for c driver client compile */
void destroy() {};
public: public:
void set_mod_id(const int64_t mod_id); void set_mod_id(const int64_t mod_id);
void *alloc(const int64_t size); /* this function is defined for c driver client compile */
void free(void *ptr); void *alloc(const int64_t size)
{
UNUSED(size);
return nullptr;
}
/* this function is defined for c driver client compile */
void free(void *ptr)
{
UNUSED(ptr);
}
int64_t allocated(); int64_t allocated();
int64_t hold() const {return 0;} int64_t hold() const {return 0;}
int64_t get_direct_alloc_count(); int64_t get_direct_alloc_count();
......
...@@ -89,16 +89,26 @@ private: ...@@ -89,16 +89,26 @@ private:
static const int64_t ALREADY_FREE = 0xf5eebef0; static const int64_t ALREADY_FREE = 0xf5eebef0;
static const int64_t SPECIAL_FLAG = -1; static const int64_t SPECIAL_FLAG = -1;
public: public:
ObFIFOAllocator(); /* this function is defined for c driver client compile */
~ObFIFOAllocator(); ObFIFOAllocator() {};
/* this function is defined for c driver client compile */
~ObFIFOAllocator() {};
/* this function is defined for c driver client compile */
int init(ObIAllocator *allocator, const int64_t page_size, int init(ObIAllocator *allocator, const int64_t page_size,
const int64_t page_hold_limit = 32); const int64_t page_hold_limit = 32)
void reset(); {
UNUSED(allocator);
UNUSED(page_size);
UNUSED(page_hold_limit);
return OB_NOT_IMPLEMENT;
}
/* this function is defined for c driver client compile */
void reset() { /* not support */ }
void reuse() { /* not support */ } void reuse() { /* not support */ }
void *alloc(const int64_t size); void *alloc(const int64_t size) { UNUSED(size); return NULL; }
void *alloc_align(const int64_t size, const int64_t align); void *alloc_align(const int64_t size, const int64_t align);
void free(void *p); void free(void *p) { UNUSED(p); }
void set_mod_id(int64_t mod_id); void set_mod_id(int64_t mod_id);
inline int64_t used() const inline int64_t used() const
......
...@@ -54,8 +54,10 @@ private: ...@@ -54,8 +54,10 @@ private:
class ObLfFIFOAllocator : public common::ObIAllocator class ObLfFIFOAllocator : public common::ObIAllocator
{ {
public: public:
ObLfFIFOAllocator(); /* this function is defined for c driver client compile */
virtual ~ObLfFIFOAllocator(); ObLfFIFOAllocator() {}
/* this function is defined for c driver client compile */
virtual ~ObLfFIFOAllocator() {}
public: public:
int init(const int64_t page_size, int init(const int64_t page_size,
const int64_t mod_id, const int64_t mod_id,
...@@ -64,8 +66,9 @@ public: ...@@ -64,8 +66,9 @@ public:
const int64_t total_limit = INT64_MAX); const int64_t total_limit = INT64_MAX);
void destroy(); void destroy();
public: public:
void *alloc(const int64_t size); /* this function is defined for c driver client compile */
void free(void *ptr); void *alloc(const int64_t size) { UNUSED(size); return NULL; }
void free(void *ptr) { UNUSED(ptr); }
bool is_fragment(void *ptr); bool is_fragment(void *ptr);
int64_t allocated() { return allocated_size_; } int64_t allocated() { return allocated_size_; }
void set_mod_id(const int64_t mod_id) { mem_attr_.mod_id_ = mod_id; } void set_mod_id(const int64_t mod_id) { mem_attr_.mod_id_ = mod_id; }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "lib/thread_local/ob_tsi_factory.h" #include "lib/thread_local/ob_tsi_factory.h"
#include "lib/utility/utility.h" #include "lib/utility/utility.h"
#include <algorithm> #include <algorithm>
#include "obutils/ob_proxy_config.h"
#ifdef __OB_MTRACE__ #ifdef __OB_MTRACE__
#include <execinfo.h> #include <execinfo.h>
#endif #endif
......
...@@ -235,6 +235,7 @@ MOD_ITEM_DEF(OB_PROXY_QOS) ...@@ -235,6 +235,7 @@ MOD_ITEM_DEF(OB_PROXY_QOS)
MOD_ITEM_DEF(OB_PROXY_SSL_RELATED) MOD_ITEM_DEF(OB_PROXY_SSL_RELATED)
MOD_ITEM_DEF(OB_PROXY_CONFIG_TABLE) MOD_ITEM_DEF(OB_PROXY_CONFIG_TABLE)
MOD_ITEM_DEF(OB_PROMETHEUS_RELATED) MOD_ITEM_DEF(OB_PROMETHEUS_RELATED)
MOD_ITEM_DEF(OB_PROXY_SESS_SYNC)
//mergeservermodules //mergeservermodules
MOD_ITEM_DEF(OB_MS_CELL_ARRAY) MOD_ITEM_DEF(OB_MS_CELL_ARRAY)
......
此差异已折叠。
...@@ -27,15 +27,29 @@ enum ObCharsetType ...@@ -27,15 +27,29 @@ enum ObCharsetType
CHARSET_INVALID = 0, CHARSET_INVALID = 0,
CHARSET_BINARY = 1, CHARSET_BINARY = 1,
CHARSET_UTF8MB4 = 2, CHARSET_UTF8MB4 = 2,
CHARSET_GBK = 3,
CHARSET_UTF16 = 4,
CHARSET_GB18030 = 5,
CHARSET_LATIN1 = 6,
CHARSET_MAX, CHARSET_MAX,
}; };
enum ObCollationType enum ObCollationType
{ {
CS_TYPE_INVALID = 0, CS_TYPE_INVALID = 0,
CS_TYPE_LATIN1_SWEDISH_CI = 8,
CS_TYPE_GBK_CHINESE_CI = 28,
CS_TYPE_UTF8MB4_GENERAL_CI = 45, CS_TYPE_UTF8MB4_GENERAL_CI = 45,
CS_TYPE_UTF8MB4_BIN = 46, CS_TYPE_UTF8MB4_BIN = 46,
CS_TYPE_LATIN1_BIN = 47,
CS_TYPE_UTF16_GENERAL_CI = 54,
CS_TYPE_UTF16_BIN = 55,
CS_TYPE_BINARY = 63, CS_TYPE_BINARY = 63,
CS_TYPE_GBK_BIN = 87,
CS_TYPE_UTF16_UNICODE_CI = 101,
CS_TYPE_UTF8MB4_UNICODE_CI = 224,
CS_TYPE_GB18030_CHINESE_CI = 248,
CS_TYPE_GB18030_BIN = 249,
CS_TYPE_MAX, CS_TYPE_MAX,
}; };
/* /*
...@@ -89,8 +103,8 @@ private: ...@@ -89,8 +103,8 @@ private:
virtual ~ObCharset() {}; virtual ~ObCharset() {};
public: public:
static const int64_t CHARSET_WRAPPER_COUNT = 2; static const int64_t CHARSET_WRAPPER_COUNT = 6;
static const int64_t COLLATION_WRAPPER_COUNT = 3; static const int64_t COLLATION_WRAPPER_COUNT = 13;
static double strntod(const char *str, static double strntod(const char *str,
size_t str_len, size_t str_len,
...@@ -190,7 +204,8 @@ public: ...@@ -190,7 +204,8 @@ public:
static size_t charpos(ObCollationType collation_type, static size_t charpos(ObCollationType collation_type,
const char *str, const char *str,
const int64_t str_len, const int64_t str_len,
const int64_t length); const int64_t length,
int *ret = NULL);
// match like pattern // match like pattern
static bool wildcmp(ObCollationType collation_type, static bool wildcmp(ObCollationType collation_type,
const ObString &str, const ObString &str,
......
/**
* Copyright (c) 2021 OceanBase
* OceanBase Database Proxy(ODP) is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#ifndef OB_CONFIG_H
#define OB_CONFIG_H
#define _GNU_SOURCE 1
#define SIZEOF_SIZE_T 8
#define SIZEOF_CHARP 8
#define SIZEOF_VOIDP 8
#define SIZEOF_LONG 8
#define SIZEOF_CHAR 1
#define HAS_CHAR 1
#define HAS_LONG 1
#define HAS_CHARP 1
#define SIZEOF_SHORT 2
#define HAS_SHORT 1
#define SIZEOF_INT 4
#define HAS_INT 1
#define SIZEOF_LONG_LONG 8
#define HAS_LONG_LONG 1
#define SIZEOF_OFF_T 8
#define HAS_OFF_T 1
#define SIZEOF_SIGSET_T 128
#define HAS_SIGSET_T 1
#define HAS_SIZE_T 1
#define SIZEOF_UINT 4
#define HAS_UINT 1
#define SIZEOF_ULONG 8
#define HAS_ULONG 1
#define HAS_U_INT32_T 1
#define SIZEOF_U_INT32_T 4
#define HAS_MBSTATE_T
#define MAX_INDEXES 64U
#define QSORT_TYPE_IS_VOID 1
#define SIGNAL_RETURN_TYPE_IS_VOID 1
#define VOID_SIGHANDLER 1
#define RETSIGTYPE void
#define RETQSORTTYPE void
#define STRUCT_RLIMIT struct rlimit
#define SOCKET_SIZE_TYPE socklen_t
#endif
...@@ -12,85 +12,93 @@ ...@@ -12,85 +12,93 @@
#include "lib/charset/ob_ctype.h" #include "lib/charset/ob_ctype.h"
static uint32_t static uint32
ob_convert_internal(char *to, uint32_t to_length, ob_convert_internal(char *to, uint32 to_length,
const ObCharsetInfo *to_cs, const ObCharsetInfo *to_cs,
const char *from, uint32_t from_length, const char *from, uint32 from_length,
const ObCharsetInfo *from_cs, uint32_t *errors) const ObCharsetInfo *from_cs, uint *errors)
{ {
int res; unsigned int error_num= 0;
int cnvres;
ob_wc_t wc; ob_wc_t wc;
const unsigned char *from_end = (const unsigned char*) from + from_length; const unsigned char *from_end= (const unsigned char*) from + from_length;
char *to_start= to; char *to_start= to;
unsigned char *to_end= (unsigned char*) to + to_length; unsigned char *to_end= (unsigned char*) to + to_length;
ob_charset_conv_mb_wc mb_wc= from_cs->cset->mb_wc;
ob_charset_conv_wc_mb wc_mb= to_cs->cset->wc_mb; ob_charset_conv_wc_mb wc_mb= to_cs->cset->wc_mb;
uint32_t error_count= 0; ob_charset_conv_mb_wc mb_wc= from_cs->cset->mb_wc;
pbool conitnue = TRUE;
while (1) { while (conitnue) {
if ((res = (*mb_wc)((unsigned char *) from, from_end, &wc)) > 0) { if ((cnvres= (*mb_wc)(from_cs, &wc, (unsigned char*) from, from_end)) > 0) {
from+= res; from+= cnvres;
} else if (res == OB_CS_ERR_ILLEGAL_SEQUENCE) { } else if (cnvres == OB_CS_ILSEQ) {
error_count++;
from++; from++;
wc= '?'; wc= '?';
} else if (res > OB_CS_ERR_TOOSMALL) { error_num++;
/* } else if (cnvres > OB_CS_TOOSMALL) {
A correct multibyte sequence detected from+= (-cnvres);
But it doesn't have Unicode mapping.
*/
error_count++;
from+= (-res);
wc= '?'; wc= '?';
error_num++;
} else { } else {
break; // Not enough characters break;
} }
outp: pbool go = TRUE;
if ((res= (*wc_mb)(wc, (unsigned char*) to, to_end)) > 0) { while (go) {
to+= res; go = FALSE;
} else if (res == OB_CS_ERR_ILLEGAL_UNICODE && wc != '?') { if ((cnvres= (*wc_mb)(to_cs, wc, (unsigned char*) to, to_end)) > 0)
error_count++; to+= cnvres;
wc= '?'; else if (cnvres == OB_CS_ILUNI && wc != '?') {
goto outp; error_num++;
} else { wc= '?';
break; go = TRUE;
} else {
conitnue = FALSE;
}
} }
} }
*errors= error_count; *errors= error_num;
return (uint32_t) (to - to_start); return (uint32) (to - to_start);
} }
uint32_t
ob_convert(char *to, uint32_t to_length, const ObCharsetInfo *to_cs, uint32
const char *from, uint32_t from_length, ob_convert(char *to, uint32 to_length, const ObCharsetInfo *to_cs,
const ObCharsetInfo *from_cs, uint32_t *errors) { const char *from, uint32 from_length,
uint32_t length, length2; const ObCharsetInfo *from_cs, uint *errors)
/* {
If any of the character sets is not ASCII compatible, uint32 length, length2;
immediately switch to slow mb_wc->wc_mb method.
*/
if ((to_cs->state | from_cs->state) & OB_CS_NONASCII) { if ((to_cs->state | from_cs->state) & OB_CS_NONASCII) {
return ob_convert_internal(to, to_length, to_cs, return ob_convert_internal(to, to_length, to_cs, from, from_length, from_cs, errors);
from, from_length, from_cs, errors); } else {
length= length2= OB_MIN(to_length, from_length);
} }
length= length2= to_length < from_length ? to_length : from_length; #if defined(__i386__)
while (length >= 4) {
if ((*(uint32*)from) & 0x80808080) break;
*((uint32*) to) = *((const uint32*) from);
from += 4;
to += 4;
length -= 4;
}
#endif /* __i386__ */
for (; ; *to++= *from++, length--) { while (TRUE) {
if (!length) { if (!length) {
*errors= 0; *errors= 0;
return length2; return length2;
} } else if (*((unsigned char*) from) > 0x7F) {
if (*((unsigned char*) from) > 0x7F) { /* A non-ASCII character */ uint32 copied_length= length2 - length;
uint32_t copied_length= length2 - length;
to_length-= copied_length; to_length-= copied_length;
from_length-= copied_length; from_length-= copied_length;
return copied_length + ob_convert_internal(to, to_length, to_cs, return copied_length + ob_convert_internal(to, to_length, to_cs,
from, from_length, from_cs, from, from_length, from_cs,
errors); errors);
} }
*to++= *from++;
length--;
} }
return 0; return 0;
} }
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -31,12 +31,12 @@ typedef enum ...@@ -31,12 +31,12 @@ typedef enum
//================================================== //==================================================
double ob_strtod(const char *str, char **end, int *error); double ob_strtod(const char *str, char **end, int *error);
size_t ob_fcvt(double x, int precision, int width, char *to, ob_bool *error); size_t ob_fcvt(double x, int precision, int width, char *to, bool *error);
size_t ob_gcvt(double x, ob_gcvt_arg_type type, int width, char *to, ob_bool *error); size_t ob_gcvt(double x, ob_gcvt_arg_type type, int width, char *to, bool *error);
size_t ob_gcvt_opt(double x, ob_gcvt_arg_type type, int width, char *to, ob_bool *error, size_t ob_gcvt_opt(double x, ob_gcvt_arg_type type, int width, char *to, bool *error,
ob_bool use_oracle_mode); bool use_oracle_mode);
size_t ob_gcvt_strict(double x, ob_gcvt_arg_type type, int width, char *to, ob_bool *error, size_t ob_gcvt_strict(double x, ob_gcvt_arg_type type, int width, char *to, bool *error,
ob_bool use_oracle_mode, ob_bool use_force_e_format); bool use_oracle_mode, bool use_force_e_format);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
此差异已折叠。
此差异已折叠。
...@@ -24,6 +24,26 @@ char ObBase64Encoder::BASE64_CHARS[] = ...@@ -24,6 +24,26 @@ char ObBase64Encoder::BASE64_CHARS[] =
"abcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyz"
"0123456789+/"; "0123456789+/";
int ObBase64Encoder::FROM_BASE64_TABLE[] =
{
/*00*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-2,-2,-2,-2,-2,-1,-1,
/*10*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
/*20*/ -2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63, /* !"#$%&'()*+,-./ */
/*30*/ 52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1, /* 0123456789:;<=>? */
/*40*/ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14, /* @ABCDEFGHIJKLMNO */
/*50*/ 15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1, /* PQRSTUVWXYZ[\]^_ */
/*60*/ -1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40, /* `abcdefghijklmno */
/*70*/ 41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1, /* pqrstuvwxyz{|}~ */
/*80*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
/*90*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
/*A0*/ -2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
/*B0*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
/*C0*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
/*D0*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
/*E0*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
/*F0*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
};
template<int N> template<int N>
struct InitBase64Values struct InitBase64Values
{ {
...@@ -127,7 +147,8 @@ int ObBase64Encoder::encode(const uint8_t *input, const int64_t input_len, ...@@ -127,7 +147,8 @@ int ObBase64Encoder::encode(const uint8_t *input, const int64_t input_len,
} }
int ObBase64Encoder::decode(const char *input, const int64_t input_len, int ObBase64Encoder::decode(const char *input, const int64_t input_len,
uint8_t *output, const int64_t output_len, int64_t &pos) uint8_t *output, const int64_t output_len,
int64_t &pos, bool skip_spaces)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
if (OB_ISNULL(input) || OB_ISNULL(output) || if (OB_ISNULL(input) || OB_ISNULL(output) ||
...@@ -136,23 +157,28 @@ int ObBase64Encoder::decode(const char *input, const int64_t input_len, ...@@ -136,23 +157,28 @@ int ObBase64Encoder::decode(const char *input, const int64_t input_len,
_OB_LOG(WARN, "invalid argument input=%p, output=%p, input_len=%ld, output_len=%ld, pos=%ld", _OB_LOG(WARN, "invalid argument input=%p, output=%p, input_len=%ld, output_len=%ld, pos=%ld",
input, output, input_len, output_len, pos); input, output, input_len, output_len, pos);
} else { } else {
// unused
// int64_t remain_len = input_len;
uint8_t uint8_array_3[3]; uint8_t uint8_array_3[3];
uint8_t uint8_array_4[4]; uint8_t uint8_array_4[4];
int64_t i = 0; int64_t i = 0;
int64_t rounds = input_len / 4; int64_t rounds = input_len / 4;
if ((rounds * 3) + pos > output_len) { if (OB_UNLIKELY(rounds * 3 + pos > output_len)) {
ret = OB_BUF_NOT_ENOUGH; ret = OB_BUF_NOT_ENOUGH;
_OB_LOG(WARN, "buffer not enough, pos=%ld, output_len=%ld, input_len=%ld", _OB_LOG(WARN, "buffer not enough, pos=%ld, output_len=%ld, input_len=%ld",
pos, output_len, input_len); pos, output_len, input_len);
} }
const char *iter_input = input; const char *iter_input = input;
int64_t skipped_spaces = 0;
for(; OB_SUCC(ret) && '=' != *iter_input && iter_input < input + input_len; iter_input++) { for(; OB_SUCC(ret) && '=' != *iter_input && iter_input < input + input_len; iter_input++) {
if (OB_UNLIKELY(!is_base64_char(*iter_input))) { if (OB_UNLIKELY(!is_base64_char(*iter_input))) {
ret = OB_INVALID_ROWID; if (skip_spaces) {
_OB_LOG(WARN, "invalid base64 char, cur_idx=%ld, char=%c", if (my_base64_decoder_skip_spaces(*iter_input)) {
++skipped_spaces;
}
} else {
ret = OB_INVALID_ARGUMENT;
_OB_LOG(WARN, "invalid base64 char, cur_idx=%ld, char=%c",
iter_input - input, *iter_input); iter_input - input, *iter_input);
}
} else { } else {
uint8_array_4[i++] = (uint8_t)(*iter_input); uint8_array_4[i++] = (uint8_t)(*iter_input);
if (4 == i) { if (4 == i) {
...@@ -172,14 +198,26 @@ int ObBase64Encoder::decode(const char *input, const int64_t input_len, ...@@ -172,14 +198,26 @@ int ObBase64Encoder::decode(const char *input, const int64_t input_len,
} // for end } // for end
int64_t cur_idx = iter_input - input; int64_t cur_idx = iter_input - input;
for (const char *iter = iter_input; iter < input + input_len; iter++) { for (const char *iter = iter_input; iter < input + input_len; iter++) {
// all the rest chars must be '=' if (skip_spaces) {
if (OB_UNLIKELY('=' != *iter)) { if (my_base64_decoder_skip_spaces(*iter)) {
ret = OB_INVALID_ROWID; ++skipped_spaces;
}
} else {
// all the rest chars must be '='
if (OB_UNLIKELY('=' != *iter)) {
ret = OB_INVALID_ARGUMENT;
}
} }
} // end for }// end for
if (OB_UNLIKELY(cur_idx + 3 <= input_len)) { if (skip_spaces) {
int64_t valid_len = input_len - skipped_spaces;
if (valid_len % 4 != 0 || valid_len < 4 || cur_idx + 3 <= valid_len) {
ret = OB_INVALID_ARGUMENT;
}
}
if (OB_UNLIKELY((cur_idx + 3 <= input_len) && !skip_spaces)) {
// only last char or last two chars can be '=' // only last char or last two chars can be '='
ret = OB_INVALID_ROWID; ret = OB_INVALID_ARGUMENT;
} else if (i > 0) { } else if (i > 0) {
for (int k = 0; k < i; k++) { for (int k = 0; k < i; k++) {
uint8_array_4[k] = BASE64_VALUES[uint8_array_4[k]]; uint8_array_4[k] = BASE64_VALUES[uint8_array_4[k]];
...@@ -189,7 +227,11 @@ int ObBase64Encoder::decode(const char *input, const int64_t input_len, ...@@ -189,7 +227,11 @@ int ObBase64Encoder::decode(const char *input, const int64_t input_len,
if (OB_UNLIKELY(pos + i - 1 >= output_len)) { if (OB_UNLIKELY(pos + i - 1 >= output_len)) {
ret = OB_BUF_NOT_ENOUGH; ret = OB_BUF_NOT_ENOUGH;
_OB_LOG(WARN, "buffer not enought, pos=%ld, output_len = %ld, i = %ld", pos, output_len, i); if (skip_spaces && (pos + i - 1 >= output_len)) {
ret = OB_INVALID_ARGUMENT;
} else {
_OB_LOG(WARN, "buffer not enough, pos=%ld, output_len = %ld, i = %ld", pos, output_len, i);
}
} else { } else {
for (int k = 0; k < i - 1; k++) { for (int k = 0; k < i - 1; k++) {
output[pos++] = (uint8_t)(uint8_array_3[k]); output[pos++] = (uint8_t)(uint8_array_3[k]);
...@@ -199,6 +241,7 @@ int ObBase64Encoder::decode(const char *input, const int64_t input_len, ...@@ -199,6 +241,7 @@ int ObBase64Encoder::decode(const char *input, const int64_t input_len,
} }
return ret; return ret;
} }
} }
} // end namespace oceanbase } // end namespace oceanbase
...@@ -26,6 +26,7 @@ private: ...@@ -26,6 +26,7 @@ private:
template<int N> template<int N>
friend class InitBase64Values; friend class InitBase64Values;
static char BASE64_CHARS[]; static char BASE64_CHARS[];
static int FROM_BASE64_TABLE[];
static uint8_t BASE64_VALUES[256]; static uint8_t BASE64_VALUES[256];
...@@ -33,6 +34,14 @@ static char BASE64_CHARS[]; ...@@ -33,6 +34,14 @@ static char BASE64_CHARS[];
{ {
return std::isalnum(c) || c == '+' || c == '/'; return std::isalnum(c) || c == '+' || c == '/';
} }
static inline bool my_base64_decoder_skip_spaces(char c)
{
if (FROM_BASE64_TABLE[(uint8_t) c] != -2) {
return false;
}
return true;
}
public: public:
static int64_t needed_encoded_length(const int64_t buf_size) static int64_t needed_encoded_length(const int64_t buf_size)
{ {
...@@ -48,7 +57,8 @@ public: ...@@ -48,7 +57,8 @@ public:
char* output, const int64_t output_len, int64_t &pos); char* output, const int64_t output_len, int64_t &pos);
static int decode(const char* input, const int64_t input_len, static int decode(const char* input, const int64_t input_len,
uint8_t* output, const int64_t output_len, int64_t &pos); uint8_t* output, const int64_t output_len,
int64_t &pos, bool skip_spaces = false);
}; };
} // end namespace common } // end namespace common
} // end namespace oceanbase } // end namespace oceanbase
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#define SCRAMBLE_LENGTH 20 #define SCRAMBLE_LENGTH 20
#define SHA1_HASH_SIZE 20 /* Hash size in bytes */ #define SHA1_HASH_SIZE 20 /* Hash size in bytes */
#define ENC_STRING_BUF_LEN SCRAMBLE_LENGTH * 2 + 1 //strlen(hash str) + '*' #define ENC_STRING_BUF_LEN SCRAMBLE_LENGTH * 2 + 2 //strlen(hash str) + '*' + '\0'
#define ENC_BUF_LEN SCRAMBLE_LENGTH * 2 + 2 //strlen(hash str) + '*' + '\0' #define ENC_BUF_LEN SCRAMBLE_LENGTH * 2 + 2 //strlen(hash str) + '*' + '\0'
#define SHA1CircularShift(bits,word) (((word) << (bits)) | ((word) >> (32-(bits)))) #define SHA1CircularShift(bits,word) (((word) << (bits)) | ((word) >> (32-(bits))))
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "lib/hash_func/ob_hash_func.h" #include "lib/hash_func/ob_hash_func.h"
#include "lib/hash/ob_hashutils.h" #include "lib/hash/ob_hashutils.h"
#include "lib/list/ob_intrusive_list.h" #include "lib/list/ob_intrusive_list.h"
#include "lib/lock/ob_drw_lock.h"
namespace oceanbase namespace oceanbase
{ {
...@@ -240,11 +241,117 @@ public: ...@@ -240,11 +241,117 @@ public:
return ret; return ret;
} }
private: protected:
ObBuildInBucket buckets_[bucket_num]; ObBuildInBucket buckets_[bucket_num];
int64_t count_; // of elements stored in the map. int64_t count_; // of elements stored in the map.
BucketChain bucket_chain_; BucketChain bucket_chain_;
}; };
template <typename H, int64_t bucket_num = 16>
class ObBuildInHashMapForRefCount : public ObBuildInHashMap <H, bucket_num> {
public:
// Make embedded types easier to use by importing them to the class namespace.
typedef H Hasher; // Rename and promote.
typedef typename Hasher::Key Key; // Key type.
typedef typename Hasher::Value Value; // Stored value (element) type.
typedef typename Hasher::ListHead ListHead; // Anchor for value chain.
ObBuildInHashMapForRefCount() : ObBuildInHashMap<H, bucket_num>() {}
// put a key value pair into HashMap
// @retval OB_SUCCESS for success
// @retval OB_HASH_EXIST when the value's pointer already exist
int set_refactored(Value *value)
{
int ret = OB_SUCCESS;
Key key = Hasher::key(value);
obsys::CWLockGuard wlock(locks_[Hasher::hash(key) % bucket_num]);
ret = ObBuildInHashMap<H, bucket_num>::set_refactored(value);
if (OB_SUCC(ret)) {
Hasher::inc_ref(value);
}
return ret;
}
// put a key value pair into HashMap
// @retval OB_SUCCESS for success
// @retval OB_HASH_EXIST when the value's key already exist
int unique_set(Value *value)
{
int ret = OB_SUCCESS;
Key key = Hasher::key(value);
obsys::CWLockGuard wlock(locks_[Hasher::hash(key) % bucket_num]);
struct ObBuildInHashMap<H, bucket_num>::ObBuildInBucket &bucket = ObBuildInHashMap<H, bucket_num>::buckets_[Hasher::hash(key) % bucket_num];
if (!bucket.chain_.in(value)) {
Value *v = bucket.chain_.head_;
while (NULL != v && ((!Hasher::equal(key, Hasher::key(v)) && (v != value)) || 0 == Hasher::get_ref(v))) {
v = ListHead::next(v);
}
if (NULL == v) {
bucket.chain_.push(value);
++ObBuildInHashMap<H, bucket_num>::count_;
// not empty, put it on the non-empty list.
if (1 == ++(bucket.count_)) {
ObBuildInHashMap<H, bucket_num>::bucket_chain_.push(&bucket);
}
} else {
ret = OB_HASH_EXIST;
}
} else {
ret = OB_HASH_EXIST;
}
if (OB_SUCC(ret)) {
Hasher::inc_ref(value);
}
return ret;
}
// @retval OB_SUCCESS for success
// @retval OB_HASH_NOT_EXIST for key not exist
int get_refactored(Key key, Value *&value)
{
int ret = OB_HASH_NOT_EXIST;
obsys::CRLockGuard rlock(locks_[Hasher::hash(key) % bucket_num]);
const struct ObBuildInHashMap<H, bucket_num>::ObBuildInBucket &bucket = ObBuildInHashMap<H, bucket_num>::buckets_[Hasher::hash(key) % bucket_num];
Value *v = bucket.chain_.head_;
while (NULL != v && (!Hasher::equal(key, Hasher::key(v)) || 0 == Hasher::get_ref(v))) {
v = ListHead::next(v);
}
if (NULL != (value = v)) {
ret = OB_SUCCESS;;
}
if (OB_SUCC(ret)) {
while (true) {
int64_t ref = Hasher::get_ref(v);
if(ref > 0) {
if (!Hasher::bcas_ref(value, ref, ref + 1)) {
PAUSE();
} else {
break;
}
} else {
ret = OB_HASH_NOT_EXIST;
value = NULL;
break;
}
}
}
return ret;
}
void remove(Value* value)
{
if (NULL != value) {
obsys::CWLockGuard wlock(locks_[Hasher::hash(Hasher::key(value)) % bucket_num]);
ObBuildInHashMap<H, bucket_num>::remove(value);
Hasher::destroy(value);
}
}
protected:
mutable obsys::CRWLock locks_[bucket_num];
};
} // namespace hash } // namespace hash
} // namespace common } // namespace common
} // namespace oceanbase } // namespace oceanbase
......
...@@ -23,8 +23,10 @@ namespace common ...@@ -23,8 +23,10 @@ namespace common
class ObBucketLock class ObBucketLock
{ {
public: public:
ObBucketLock(); /* this function is defined for c driver client compile */
virtual ~ObBucketLock(); ObBucketLock() {}
/* this function is defined for c driver client compile */
virtual ~ObBucketLock() {}
int init( int init(
const uint64_t bucket_cnt, const uint64_t bucket_cnt,
const uint32_t latch_id = ObLatchIds::DEFAULT_BUCKET_LOCK, const uint32_t latch_id = ObLatchIds::DEFAULT_BUCKET_LOCK,
......
...@@ -279,7 +279,10 @@ int ObLatchWaitQueue::try_lock( ...@@ -279,7 +279,10 @@ int ObLatchWaitQueue::try_lock(
COMMON_LOG(ERROR, "Fail to add proc to wait list, ", K(ret)); COMMON_LOG(ERROR, "Fail to add proc to wait list, ", K(ret));
} }
} }
proc.wait_ = 1;
if (OB_EAGAIN == ret) {
proc.wait_ = 1;
}
} }
unlock_bucket(bucket); unlock_bucket(bucket);
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -334,7 +334,8 @@ enum ObNameId ...@@ -334,7 +334,8 @@ enum ObNameId
}; };
// get name at runtime // get name at runtime
const char* get_name(int32_t id); /* this function is defined for c driver client compile */
inline const char* get_name(int32_t id) {((void)(id)); return nullptr;};
const char* get_description(int32_t id); const char* get_description(int32_t id);
} // end namespace name_id_map } // end namespace name_id_map
} // end namespace oceanbase } // end namespace oceanbase
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册