Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ endif()

option(COMDB2_TEST "Turn ON to compile with testing features" OFF)
if(COMDB2_TEST)
add_definitions(-DCOMDB2_TEST)
add_definitions(-DCOMDB2_TEST)
add_definitions(-DCDB2API_TEST)
endif()

option(WITH_TINFO "Turn ON on platforms where tinfo library is required for cdb2sql" OFF)
Expand Down
4 changes: 0 additions & 4 deletions cdb2api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ include_directories(
add_definitions(-DDISABLE_HOSTADDR_CACHE)
add_definitions(-DSBUF2_SERVER=0)

if (COMDB2_TEST)
add_definitions(-DCDB2API_TEST)
endif()

if (COMDB2_BBCMAKE)
include(${EXTRA_PLUGINS}/cdb2api/cdb2api.cmake)
add_library(opencdb2api STATIC ${src})
Expand Down
12 changes: 6 additions & 6 deletions cdb2api/cdb2api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,7 @@ struct newsqlheader {
int length;
};

#ifdef CDB2API_TEST
void cdb2_set_min_retries(int min_retries)
{
if (min_retries > 0) {
Expand All @@ -1434,6 +1435,7 @@ void cdb2_set_max_retries(int max_retries)
MAX_RETRIES = max_retries;
}
}
#endif

void cdb2_hndl_set_min_retries(cdb2_hndl_tp *hndl, int min_retries)
{
Expand Down Expand Up @@ -6817,6 +6819,7 @@ const char *cdb2_column_name(cdb2_hndl_tp *hndl, int col)
return ret;
}

#ifdef CDB2API_TEST
int cdb2_snapshot_file(cdb2_hndl_tp *hndl, int *snapshot_file,
int *snapshot_offset)
{
Expand All @@ -6830,18 +6833,14 @@ int cdb2_snapshot_file(cdb2_hndl_tp *hndl, int *snapshot_file,
(*snapshot_offset) = hndl->snapshot_offset;
return 0;
}

void cdb2_getinfo(cdb2_hndl_tp *hndl, int *intrans, int *hasql)
{
(*intrans) = hndl->in_trans;
(*hasql) = hndl->is_hasql;
}
#endif

void cdb2_set_debug_trace(cdb2_hndl_tp *hndl)
{
hndl->debug_trace = 1;
}

#ifdef CDB2API_TEST
void cdb2_dump_ports(cdb2_hndl_tp *hndl, FILE *out)
{
int i;
Expand Down Expand Up @@ -6875,6 +6874,7 @@ const char *cdb2_cnonce(cdb2_hndl_tp *hndl)

return hndl->cnonce.str;
}
#endif

const char *cdb2_errstr(cdb2_hndl_tp *hndl)
{
Expand Down
27 changes: 8 additions & 19 deletions cdb2api/cdb2api.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ void cdb2_set_comdb2db_config(char *cfg_file);
void cdb2_set_comdb2db_info(char *cfg_info);
void cdb2_set_sockpool(const char *sp_path);
void cdb2_set_identity(cdb2_hndl_tp *hndl, const void *identity);
int cdb2_get_comdb2db(char **comdb2db_name, char **comdb2db_class);

int cdb2_open(cdb2_hndl_tp **hndl, const char *dbname, const char *type, int flags);

Expand All @@ -232,16 +231,6 @@ int cdb2_column_type(cdb2_hndl_tp *hndl, int col);
int cdb2_column_size(cdb2_hndl_tp *hndl, int col);
void *cdb2_column_value(cdb2_hndl_tp *hndl, int col);
const char *cdb2_errstr(cdb2_hndl_tp *hndl);
const char *cdb2_cnonce(cdb2_hndl_tp *hndl);
void cdb2_set_debug_trace(cdb2_hndl_tp *hndl);
void cdb2_dump_ports(cdb2_hndl_tp *hndl, FILE *out);
void cdb2_cluster_info(cdb2_hndl_tp *hndl, char **cluster, int *ports, int max, int *count);
int cdb2_snapshot_file(cdb2_hndl_tp *hndl, int *file, int *offset);
void cdb2_getinfo(cdb2_hndl_tp *hndl, int *intrans, int *hasql);
void cdb2_set_max_retries(int max_retries);
void cdb2_set_min_retries(int min_retries);
void cdb2_hndl_set_max_retries(cdb2_hndl_tp *hndl, int max_retries);
void cdb2_hndl_set_min_retries(cdb2_hndl_tp *hndl, int min_retries);

int cdb2_bind_param(cdb2_hndl_tp *hndl, const char *name, int type,
const void *varaddr, int length);
Expand All @@ -251,19 +240,15 @@ int cdb2_bind_array(cdb2_hndl_tp *, const char *, cdb2_coltype, const void *, si
int cdb2_bind_array_index(cdb2_hndl_tp *, int, cdb2_coltype, const void *, size_t, size_t);
int cdb2_clearbindings(cdb2_hndl_tp *hndl);

/* SOCKPOOL CLIENT APIS */
void cdb2_enable_sockpool();
void cdb2_disable_sockpool();

const char *cdb2_dbname(cdb2_hndl_tp *hndl);
const char *cdb2_host(cdb2_hndl_tp *hndl);

void cdb2_enable_sockpool(void);
void cdb2_disable_sockpool(void);

int cdb2_init_ssl(int init_libssl, int init_libcrypto);
int cdb2_is_ssl_encrypted(cdb2_hndl_tp *hndl);

int cdb2_clear_ack(cdb2_hndl_tp *hndl);

char *cdb2_string_escape(cdb2_hndl_tp *hndl, const char *str);

// on success, `*value` points to dynamically allocated memory
// that must be freed by the caller.
int cdb2_get_property(cdb2_hndl_tp *hndl, const char *key, char **value);
Expand Down Expand Up @@ -334,6 +319,10 @@ int cdb2_register_retry_callback(cdb2_hndl_tp *hndl, RETRY_CALLBACK f);
void cdb2_identity_create();
void cdb2_identity_destroy(int is_task_exit);
int cdb2_identity_valid();
int cdb2_init_ssl(int init_libssl, int init_libcrypto);
int cdb2_is_ssl_encrypted(cdb2_hndl_tp *hndl);

char *cdb2_string_escape(cdb2_hndl_tp *hndl, const char *str);

struct cdb2_identity {
void (*resetIdentity_start)();
Expand Down
15 changes: 15 additions & 0 deletions cdb2api/cdb2api_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#include <sbuf2.h>
#include "cdb2api.h"

#if defined __cplusplus
extern "C" {
#endif

SBUF2 *cdb2_socket_pool_get(cdb2_hndl_tp *hndl, const char *typestr, int dbnum, int *port, int *was_from_local_cache);
// use this one for fastsql since client_sbuf and server_sbuf are different
int cdb2_socket_pool_get_fd(cdb2_hndl_tp *hndl, const char *typestr, int dbnum, int *port);
Expand All @@ -38,6 +42,13 @@ int cdb2_read_line(char *line, int maxlen, SBUF2 *s, const char *buf, int *chrno

void cdb2_setIdentityBlob(cdb2_hndl_tp *hndl, void *id);

void cdb2_hndl_set_max_retries(cdb2_hndl_tp *hndl, int max_retries);
void cdb2_hndl_set_min_retries(cdb2_hndl_tp *hndl, int min_retries);

int cdb2_get_comdb2db(char **comdb2db_name, char **comdb2db_class);

void cdb2_set_debug_trace(cdb2_hndl_tp *hndl);

#ifndef WITH_DL_LIBS
#define WITH_DL_LIBS 0
#endif
Expand All @@ -47,4 +58,8 @@ void cdb2_set_install_libs(void (*ptr)(const char *));
void cdb2_set_uninstall_libs(void (*ptr)(const char *));
#endif

#if defined __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions cdb2api/cdb2api_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ struct cdb2_hndl;
const char *get_default_cluster(void);
const char *get_default_cluster_hndl(struct cdb2_hndl *);

void cdb2_set_max_retries(int max_retries);
void cdb2_set_min_retries(int min_retries);

void cdb2_cluster_info(cdb2_hndl_tp *hndl, char **cluster, int *ports, int max, int *count);
const char *cdb2_cnonce(cdb2_hndl_tp *hndl);
int cdb2_snapshot_file(cdb2_hndl_tp *hndl, int *file, int *offset);
void cdb2_dump_ports(cdb2_hndl_tp *hndl, FILE *out);

#if defined __cplusplus
}
#endif /* __cplusplus */
Expand Down
1 change: 1 addition & 0 deletions db/machcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <string.h>
#include <sys_wrap.h>
#include <cdb2api.h>
#include <cdb2api_int.h>
#include <machcache.h>

struct class_machs {
Expand Down
1 change: 1 addition & 0 deletions db/phys_rep.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "phys_rep.h"
#include <cdb2api.h>
#include <cdb2api_int.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
Expand Down
1 change: 1 addition & 0 deletions db/reverse_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "cdb2_constants.h"
#include "comdb2.h"
#include "cdb2api.h"
#include "cdb2api_int.h"
#include "list.h"
#include "logmsg.h"
#include "net_int.h"
Expand Down
1 change: 1 addition & 0 deletions db/sqllogfill.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
#include <sqllogfill.h>
#include <cdb2api.h>
#include <cdb2api_int.h>
#include <sys_wrap.h>
#include <parse_lsn.h>
#include <unistd.h>
Expand Down
3 changes: 3 additions & 0 deletions plugins/reversesql/reversesql.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
#include "phys_rep.h"
#include "reversesql.h"

#include "cdb2api.h"
#include "cdb2api_int.h"

extern int gbl_revsql_debug;
extern int gbl_revsql_cdb2_debug;
extern int gbl_revsql_allow_command_exec;
Expand Down
1 change: 1 addition & 0 deletions tests/tools/cdb2_close_early.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <unistd.h>

#include <cdb2api.h>
#include <cdb2api_int.h>
#include <gettimeofday_ms.h>

static char *argv0 = NULL;
Expand Down
2 changes: 2 additions & 0 deletions tests/tools/cdb2api_unit.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <assert.h>
#include <bb_oscompat.h>
#include <cdb2api.c>
#include <cdb2api_test.h>
#include <cdb2api_int.h>

void test_is_sql_read()
{
Expand Down
1 change: 1 addition & 0 deletions tests/tools/ins_upd_del.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <string.h>
#include <arpa/inet.h>
#include <cdb2api.h>
#include <cdb2api_test.h>
#include <unistd.h>
#include <time.h>
#include <sstream>
Expand Down
1 change: 1 addition & 0 deletions tests/tools/inscntdel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <string.h>
#include <arpa/inet.h>
#include <cdb2api.h>
#include <cdb2api_test.h>
#include <unistd.h>
#include <time.h>
#include <sstream>
Expand Down
2 changes: 2 additions & 0 deletions tests/tools/insert.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "testutil.h"
#include "nemesis.h"
#include <cdb2api.h>
#include <cdb2api_int.h>
#include <cdb2api_test.h>

enum eventtypes {
PARTITION_EVENT = 0x00000001,
Expand Down
1 change: 1 addition & 0 deletions tests/tools/nemesis.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <strings.h>
#include <alloca.h>
#include <cdb2api.h>
#include <cdb2api_test.h>
#include <signal.h>
#include "testutil.h"
#include "nemesis.h"
Expand Down
2 changes: 2 additions & 0 deletions tests/tools/register.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "testutil.h"
#include "nemesis.h"
#include <cdb2api.h>
#include <cdb2api_int.h>
#include <cdb2api_test.h>

enum eventtypes {
PARTITION_EVENT = 0x00000001,
Expand Down
2 changes: 2 additions & 0 deletions tests/tools/selectv.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <signal.h>

#include <cdb2api.h>
#include <cdb2api_int.h>
#include <cdb2api_test.h>

static char *argv0 = NULL;

Expand Down
1 change: 1 addition & 0 deletions tests/tools/selectv_rcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <sys/wait.h>

#include <cdb2api.h>
#include <cdb2api_int.h>

char *dbname = NULL;
char *stage = "default";
Expand Down
1 change: 1 addition & 0 deletions tests/tools/sicountbug.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <string.h>
#include <strings.h>
#include <cdb2api.h>
#include <cdb2api_int.h>
#include <epochlib.h>
#include <errno.h>
#include <assert.h>
Expand Down
2 changes: 2 additions & 0 deletions tests/tools/tcl/tclcdb2.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "tcl.h"
#include "tclcdb2.h"
#include "cdb2api.h"
#include "cdb2api_int.h"
#include "cdb2api_test.h"

/*
* NOTE: Flag values for the <pkg>_Unload callback function (Tcl 8.5+).
Expand Down
2 changes: 2 additions & 0 deletions tests/tools/testutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <stdarg.h>
#include <errno.h>
#include <inttypes.h>
#include <cdb2api.h>
#include <cdb2api_test.h>

#define FMTSZ 512

Expand Down
Loading