Skip to content

Commit

Permalink
patch ob-connector-c 2.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
weihao.twh committed Sep 22, 2023
2 parents 25e71de + f48ca5c commit 6a6074a
Show file tree
Hide file tree
Showing 20 changed files with 1,498 additions and 377 deletions.
36 changes: 27 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,26 @@ ENDFOREACH()
SET(CC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
SET(CC_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})

SET(CPACK_PACKAGE_VERSION_MAJOR 20)
SET(CPACK_PACKAGE_VERSION_MINOR 1)
SET(CPACK_PACKAGE_VERSION_PATCH 13)
SET(CPACK_PACKAGE_VERSION_MAJOR 0)
SET(CPACK_PACKAGE_VERSION_MINOR 0)
SET(CPACK_PACKAGE_VERSION_PATCH 0)

#get rpm version for Win pack and mariadb_version.h.in
SET(CPACK_PACKAGE_VERSION_RPM "1.0.0")
file(STRINGS ./rpm/libobclient-VER.txt STRLIST LIMIT_COUNT 1)
foreach(STR IN LISTS STRLIST)
SET(CPACK_PACKAGE_VERSION_RPM ${STR})
endforeach(STR)

string(REPLACE "." ";" VERSION_LIST ${CPACK_PACKAGE_VERSION_RPM})
list(GET VERSION_LIST 0 CPACK_PACKAGE_VERSION_MAJOR)
list(GET VERSION_LIST 1 CPACK_PACKAGE_VERSION_MINOR)
list(GET VERSION_LIST 2 CPACK_PACKAGE_VERSION_PATCH)
list(LENGTH VERSION_LIST len)
IF(len EQUAL 4)
list(GET VERSION_LIST 3 CPACK_PACKAGE_VERSION_EXTRA)
ENDIF()

SET(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
MATH(EXPR MARIADB_PACKAGE_VERSION_ID "${CPACK_PACKAGE_VERSION_MAJOR} * 10000 +
${CPACK_PACKAGE_VERSION_MINOR} * 100 +
Expand Down Expand Up @@ -127,6 +144,13 @@ SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDBUG_OFF")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DDBUG_OFF")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDBUG_OFF")

IF(UNIX)
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -z noexecstack -z now -pie -fPIC -fstack-protector-all")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -z noexecstack -z now -pie -fPIC -fstack-protector-all")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -z noexecstack -z now -pie -fPIC -fstack-protector-all")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -z noexecstack -z now -pie -fPIC -fstack-protector-all")
ENDIF()

IF(CMAKE_COMPILER_IS_GNUCC)
INCLUDE(CheckCCompilerFlag)
SET(GCC_FLAGS -Wunused -Wlogical-op -Wno-uninitialized -Wall -Wextra -Wformat-security -Wno-init-self -Wwrite-strings -Wshift-count-overflow -Wdeclaration-after-statement -Wno-undef -Wno-unknown-pragmas)
Expand Down Expand Up @@ -446,12 +470,6 @@ ELSE()

string(TIMESTAMP COMPILE_TIME %Y%m%d%H%M%S)
MESSAGE(STATUS ${COMPILE_TIME})

SET(CPACK_PACKAGE_VERSION_RPM ${CPACK_PACKAGE_VERSION})
file(STRINGS ./rpm/libobclient-VER.txt STRLIST LIMIT_COUNT 1)
foreach(STR IN LISTS STRLIST)
SET(CPACK_PACKAGE_VERSION_RPM ${STR})
endforeach(STR)

IF(NOT PACKAGE_STATUS_SUFFIX)
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "ob-connector-c-${CPACK_PACKAGE_VERSION_RPM}-src")
Expand Down
55 changes: 39 additions & 16 deletions include/mariadb_com.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,30 +378,37 @@ enum ObCapabilityFlagShift
OBCLIENT_CAP_PROXY_REROUTE_SHIFT,
OBCLIENT_CAP_PROXY_SESSION_SYNC_SHIFT,
OBCLIENT_CAP_FULL_LINK_TRACE_SHIFT,
OBCLIENT_CAP_PROXY_NEW_EXTRA_INFO_SHIFT
OBCLIENT_CAP_PROXY_NEW_EXTRA_INFO_SHIFT,
OBCLIENT_CAP_PROXY_SESSION_VAR_SYNC_SHIFT,
OBCLIENT_CAP_PROXY_WEAK_STALE_FEEDBACK_SHIFT,
OBCLIENT_CAP_PROXY_FULL_LINK_TRACE_SHOW_TRACE_SHIFT
};

#define OB_TEST_CAPABILITY(cap, tg_cap) (((cap) & (tg_cap)) == (tg_cap))
#define OBCLIENT_TEST_CAPABILITY(cap, tg_cap) (((cap) & (tg_cap)) == (tg_cap))
#define OBCLIENT_CAP_GET_TYPE(i) (1LL << i)
#define OBCLIENT_CAP_PARTITION_TABLE OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_PARTITION_TABLE_SHIFT)
#define OBCLIENT_CAP_CHANGE_USER OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_CHANGE_USER_SHIFT)
#define OBCLIENT_CAP_READ_WEAK OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_READ_WEAK_SHIFT)
#define OBCLIENT_CAP_CHECKSUM OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_CHECKSUM_SHIFT)
#define OBCLIENT_CAP_SAFE_WEAK_READ OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_SAFE_WEAK_READ_SHIFT)
#define OBCLIENT_CAP_PRIORITY_HIT OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_PRIORITY_HIT_SHIFT)
#define OBCLIENT_CAP_CHECKSUM_SWITCH OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_CHECKSUM_SWITCH_SHIFT)
#define OBCLIENT_CAP_OB_PROTOCOL_V2 OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_OB_PROTOCOL_V2_SHIFT)
#define OBCLIENT_CAP_PARTITION_TABLE OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_PARTITION_TABLE_SHIFT)
#define OBCLIENT_CAP_CHANGE_USER OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_CHANGE_USER_SHIFT)
#define OBCLIENT_CAP_READ_WEAK OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_READ_WEAK_SHIFT)
#define OBCLIENT_CAP_CHECKSUM OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_CHECKSUM_SHIFT)
#define OBCLIENT_CAP_SAFE_WEAK_READ OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_SAFE_WEAK_READ_SHIFT)
#define OBCLIENT_CAP_PRIORITY_HIT OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_PRIORITY_HIT_SHIFT)
#define OBCLIENT_CAP_CHECKSUM_SWITCH OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_CHECKSUM_SWITCH_SHIFT)
#define OBCLIENT_CAP_OB_PROTOCOL_V2 OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_OB_PROTOCOL_V2_SHIFT)
#define OBCLIENT_CAP_EXTRA_OK_PACKET_FOR_STATISTICS OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_EXTRA_OK_PACKET_FOR_STATISTICS_SHIFT)
#define OBCLIENT_CAP_PL_ROUTE OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_PL_ROUTE_SHIFT)
#define OBCLIENT_CAP_PROXY_REROUTE OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_PROXY_REROUTE_SHIFT)
#define OBCLIENT_CAP_PROXY_SESSION_SYNC OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_PROXY_SESSION_SYNC_SHIFT)
#define OBCLIENT_CAP_FULL_LINK_TRACE OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_FULL_LINK_TRACE_SHIFT)
#define OBCLIENT_CAP_PROXY_NEW_EXTRA_INFO OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_PROXY_NEW_EXTRA_INFO_SHIFT)
#define OBCLIENT_CAP_PL_ROUTE OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_PL_ROUTE_SHIFT)
#define OBCLIENT_CAP_PROXY_REROUTE OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_PROXY_REROUTE_SHIFT)
#define OBCLIENT_CAP_PROXY_SESSION_SYNC OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_PROXY_SESSION_SYNC_SHIFT)
#define OBCLIENT_CAP_FULL_LINK_TRACE OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_FULL_LINK_TRACE_SHIFT)
#define OBCLIENT_CAP_PROXY_NEW_EXTRA_INFO OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_PROXY_NEW_EXTRA_INFO_SHIFT)
#define OBCLIENT_CAP_PROXY_SESSION_VAR_SYNC OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_PROXY_SESSION_VAR_SYNC_SHIFT)
#define OBCLIENT_CAP_PROXY_WEAK_STALE_FEEDBACK OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_PROXY_WEAK_STALE_FEEDBACK_SHIFT)
#define OBCLIENT_CAP_PROXY_FULL_LINK_TRACE_SHOW_TRACE OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_PROXY_FULL_LINK_TRACE_SHOW_TRACE_SHIFT)

static const unsigned long OBPROXY_DEFAULT_CAPABILITY_FLAG =
(OBCLIENT_CAP_OB_PROTOCOL_V2
| OBCLIENT_CAP_FULL_LINK_TRACE
| OBCLIENT_CAP_PROXY_NEW_EXTRA_INFO);
| OBCLIENT_CAP_PROXY_NEW_EXTRA_INFO
| OBCLIENT_CAP_PROXY_FULL_LINK_TRACE_SHOW_TRACE);

static const long OB_MAX_UINT32_BUF_LEN = 11; // string length of max uint32_t(2**32 - 1)
static const long OB_MAX_UINT64_BUF_LEN = 22; // string length of max uint64_t(2**64 - 1)
Expand All @@ -415,6 +422,22 @@ static const char *const OB_MYSQL_CONNECTION_ID = "__connection_id";
static const char *const OB_MYSQL_PROXY_CONNECTION_ID = "__proxy_connection_id";
static const char *const OB_MYSQL_GLOBAL_VARS_VERSION = "__global_vars_version";


enum ObClientLobLocatorVersion
{
OBCLIENT_LOB_LOCATORV1 = 1,
OBCLIENT_LOB_LOCATORV2 = 2,
OBCLIENT_LOB_LOCATOR_ERROR
};
enum ObCapabilityFlagLob
{
OBCLIENT_CAP_OB_LOB_LOCATOR_V2 = 0
};
#define OBCLIENT_CAP_OB_LOB_LOCATOR_V2 OBCLIENT_CAP_GET_TYPE(OBCLIENT_CAP_OB_LOB_LOCATOR_V2)
static const unsigned long OBCLIENT_CAP_OB_LOB_LOCATOR_V2_FLAG = OBCLIENT_CAP_OB_LOB_LOCATOR_V2;
static const char *const OB_MYSQL_LOB_LOCATOR_V2 = "__ob_client_attribute_capability_flag";


typedef enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG,
MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE,
Expand Down
85 changes: 83 additions & 2 deletions include/mariadb_stmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,65 @@ typedef struct ObLobLocator
char data_[1]; // rowid + varchar
} OB_LOB_LOCATOR;


typedef struct st_ObClientMemLobCommon
{
uint32_t magic_; // Keep the old version consistent
uint32_t version_ : 8;
uint32_t type_ : 4; // Persistent/TmpFull/TmpDelta
uint32_t read_only_ : 1; // Whether to write
uint32_t is_inrow_ : 1;
uint32_t is_open_ : 1; // only persist lob could be open
uint32_t is_simple : 1;
uint32_t has_extern : 1;
uint32_t reserved_ : 15;
}ObClientMemLobCommon;
typedef struct st_ObClientMemLobExternHeader
{
int64_t snapshot_ver_;
uint64_t table_id_;
uint32_t column_idx_;
uint16_t has_tx_info : 1;
uint16_t has_cid_hash : 1;
uint16_t has_view_info : 1;
uint16_t extern_flags_ : 13;
uint16_t rowkey_size_;
uint32_t payload_offset_;
uint32_t payload_size_;
}ObClientMemLobExternHeader;
typedef struct st_ObClientLobCommon
{
uint32_t version_ : 8;
uint32_t is_init_ : 1;
uint32_t is_empty_ : 1;
uint32_t in_row_ : 1;
uint32_t opt_encrypt_ : 1;
uint32_t opt_compress_ : 1;
uint32_t opt_deduplicate_ : 1;
uint32_t has_content_type_ : 1;
uint32_t use_big_endian_ : 1;
uint32_t is_mem_loc_ : 1;
uint32_t reserve_ : 15;
}ObClientLobCommon;
typedef struct st_ObClientLobData
{
uint64_t tablet_id_;
uint64_t lob_id_;
uint64_t byte_size_;
}ObClientLobData;
typedef struct ObLobLocatorV2
{
ObClientMemLobCommon common;
ObClientMemLobExternHeader extern_header;
char data_[1];
}OB_LOB_LOCATOR_V2;
uint8_t get_ob_lob_locator_version(void *lob);
int64_t get_ob_lob_payload_data_len(void *lob);
int stmt_get_data_from_lobv2(MYSQL *mysql, void * lob, enum_field_types dty,
int64_t char_offset, int64_t byte_offset, int64_t char_len, int64_t byte_len, char *buf, const int64_t buf_len, int64_t *data_len, int64_t *act_len);



typedef struct st_mysqlnd_upsert_result
{
unsigned int warning_count;
Expand Down Expand Up @@ -374,7 +433,7 @@ enum enum_ob20_protocol
PROTOCOL_OB20_FORCE_CLOSE = 0,
PROTOCOL_OB20_AUTO_OPEN,
PROTOCOL_OB20_FORCE_OPEN,
PROTOCOL_OB20_FLAY_MAX
PROTOCOL_OB20_FLAG_MAX
};
my_bool determine_protocol_ob20(MYSQL *mysql);
my_bool get_use_protocol_ob20(MYSQL *mysql);
Expand All @@ -384,15 +443,37 @@ enum enum_full_link_trace
PROTOCOL_FLT_FORCE_CLOSE = 0,
PROTOCOL_FLT_AUTO_OPEN,
PROTOCOL_FLT_FORCE_OPEN,
PROTOCOL_FLT_FLAY_MAX
PROTOCOL_FLT_FLAG_MAX
};
my_bool determine_full_link_trace(MYSQL *mysql);
my_bool get_use_full_link_trace(MYSQL *mysql);

enum enum_flt_show_trace
{
FLT_SHOW_TRACE_FORCE_CLOSE = 0,
FLT_SHOW_TRACE_AUTO_OPEN,
FLT_SHOW_TRACE_FORCE_OPEN,
FLT_SHOW_TRACE_FLAG_MAX
};
my_bool determine_flt_show_trace(MYSQL *mysql);
my_bool get_use_flt_show_trace(MYSQL *mysql);

uint32_t ob_crc32(uint64_t crc, const char *buf, int64_t len);
uint64_t ob_crc64(uint64_t crc, const char *buf, int64_t len);
/*end for support protocol ob20*/

enum enum_ob_client_lob_locatorv2
{
OB_CLIENT_LOB_LOCATORV2_FORCE_CLOSE = 0,
OB_CLIENT_LOB_LOCATORV2_AUTO_OPEN,
OB_CLIENT_LOB_LOCATORV2_FORCE_OPEN,
OB_CLIENT_LOB_LOCATORV2_FLAY_MAX
};
my_bool determine_ob_client_lob_locatorv2(MYSQL *mysql);
my_bool get_use_ob_client_lob_locatorv2(MYSQL *mysql);

my_bool set_nls_format(MYSQL *mysql);

/* add for support bindbyname for plarray */
struct prepare_extend_args_t
{
Expand Down
16 changes: 16 additions & 0 deletions include/mariadb_version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,20 @@
/* Source information */
#define CC_SOURCE_REVISION "@CC_SOURCE_REVISION@"

#ifndef LIBOBCLIENT_VERSION_MAJOR
#define LIBOBCLIENT_VERSION_MAJOR @CPACK_PACKAGE_VERSION_MAJOR@
#endif

#ifndef LIBOBCLIENT_VERSION_MINOR
#define LIBOBCLIENT_VERSION_MINOR @CPACK_PACKAGE_VERSION_MINOR@
#endif

#ifndef LIBOBCLIENT_VERSION_PATCH
#define LIBOBCLIENT_VERSION_PATCH @CPACK_PACKAGE_VERSION_PATCH@
#endif

#ifndef LIBOBCLIENT_VERSION
#define LIBOBCLIENT_VERSION "@CPACK_PACKAGE_VERSION_RPM@"
#endif

#endif /* _mariadb_version_h_ */
32 changes: 31 additions & 1 deletion include/mysql.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,13 @@ struct st_mysql_options {
my_bool can_plarray_bindbyname;
my_bool can_use_protocol_ob20;
my_bool can_use_full_link_trace;
my_bool can_use_ob_client_lob_locatorv2;
my_bool can_use_flt_show_trace;
unsigned long ob_server_version;
unsigned long ob_proxy_version;
unsigned long capability; // system varaiable
} MYSQL;

/**
* @brief
* For mysql_use_result, an additional buffer is needed to store rows.
Expand All @@ -424,7 +427,7 @@ struct st_mysql_options {
typedef struct st_ob_result_extension {
ulong pkt_len;
char *pkt_buffer;
MYSQL_FIELD *mysql_fields;
MYSQL_FIELD *mysql_fields; // ±£´æfieldÐÅÏ¢
} OB_RES_EXT;

struct st_mysql_trace_info;
Expand Down Expand Up @@ -522,6 +525,33 @@ typedef struct st_oracle_time
int offset_hour, offset_minute;
char *tz_name, *tz_abbr;
} ORACLE_TIME;

typedef struct st_ym_object
{
int ym_year;
int ym_month;
int ym_scale;
}YM_OBJECT;
typedef struct st_ds_object
{
int ds_day;
int ds_hour;
int ds_minute;
int ds_second;
int ds_frac_second;
int ds_day_scale;
int ds_frac_second_scale;
}DS_OBJECT;
typedef struct st_oracle_interval
{
unsigned short mysql_type;
char data_symbol; //1:+, -1:- 0, default
union {
struct st_ym_object ym_object;
struct st_ds_object ds_object;
} data_object;
}ORACLE_INTERVAL;

#define AUTO_SEC_PART_DIGITS 39
#endif

Expand Down
Loading

0 comments on commit 6a6074a

Please sign in to comment.