taos.h 15.6 KB
Newer Older
H
hzcheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
 *
 * This program is free software: you can use, redistribute, and/or modify
 * it under the terms of the GNU Affero General Public License, version 3
 * or later ("AGPL"), as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef TDENGINE_TAOS_H
#define TDENGINE_TAOS_H

H
Haojun Liao 已提交
19
#include <stdbool.h>
L
Liu Jicong 已提交
20
#include <stdint.h>
H
hzcheng 已提交
21 22 23 24 25

#ifdef __cplusplus
extern "C" {
#endif

S
Shengliang Guan 已提交
26 27 28
typedef void   TAOS;
typedef void   TAOS_STMT;
typedef void   TAOS_RES;
L
Liu Jicong 已提交
29
typedef void **TAOS_ROW;
L
Liu Jicong 已提交
30
typedef void   TAOS_SUB;
H
hzcheng 已提交
31

H
hzcheng 已提交
32
// Data type definition
L
Liu Jicong 已提交
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
#define TSDB_DATA_TYPE_NULL       0   // 1 bytes
#define TSDB_DATA_TYPE_BOOL       1   // 1 bytes
#define TSDB_DATA_TYPE_TINYINT    2   // 1 byte
#define TSDB_DATA_TYPE_SMALLINT   3   // 2 bytes
#define TSDB_DATA_TYPE_INT        4   // 4 bytes
#define TSDB_DATA_TYPE_BIGINT     5   // 8 bytes
#define TSDB_DATA_TYPE_FLOAT      6   // 4 bytes
#define TSDB_DATA_TYPE_DOUBLE     7   // 8 bytes
#define TSDB_DATA_TYPE_VARCHAR    8   // string, alias for varchar
#define TSDB_DATA_TYPE_TIMESTAMP  9   // 8 bytes
#define TSDB_DATA_TYPE_NCHAR      10  // unicode string
#define TSDB_DATA_TYPE_UTINYINT   11  // 1 byte
#define TSDB_DATA_TYPE_USMALLINT  12  // 2 bytes
#define TSDB_DATA_TYPE_UINT       13  // 4 bytes
#define TSDB_DATA_TYPE_UBIGINT    14  // 8 bytes
#define TSDB_DATA_TYPE_JSON       15  // json string
#define TSDB_DATA_TYPE_VARBINARY  16  // binary
#define TSDB_DATA_TYPE_DECIMAL    17  // decimal
#define TSDB_DATA_TYPE_BLOB       18  // binary
H
Haojun Liao 已提交
52
#define TSDB_DATA_TYPE_MEDIUMBLOB 19
L
Liu Jicong 已提交
53
#define TSDB_DATA_TYPE_BINARY     TSDB_DATA_TYPE_VARCHAR  // string
D
Dingle Zhang 已提交
54 55
#define TSDB_DATA_TYPE_GEOMETRY   20  // geometry
#define TSDB_DATA_TYPE_MAX        21
H
hzcheng 已提交
56

H
hzcheng 已提交
57 58 59 60 61 62
typedef enum {
  TSDB_OPTION_LOCALE,
  TSDB_OPTION_CHARSET,
  TSDB_OPTION_TIMEZONE,
  TSDB_OPTION_CONFIGDIR,
  TSDB_OPTION_SHELL_ACTIVITY_TIMER,
63
  TSDB_OPTION_USE_ADAPTER,
H
hzcheng 已提交
64 65 66
  TSDB_MAX_OPTIONS
} TSDB_OPTION;

H
Haojun Liao 已提交
67 68
typedef enum {
  TSDB_SML_UNKNOWN_PROTOCOL = 0,
L
Liu Jicong 已提交
69 70 71
  TSDB_SML_LINE_PROTOCOL = 1,
  TSDB_SML_TELNET_PROTOCOL = 2,
  TSDB_SML_JSON_PROTOCOL = 3,
H
Haojun Liao 已提交
72 73 74 75 76 77 78 79 80 81 82 83
} TSDB_SML_PROTOCOL_TYPE;

typedef enum {
  TSDB_SML_TIMESTAMP_NOT_CONFIGURED = 0,
  TSDB_SML_TIMESTAMP_HOURS,
  TSDB_SML_TIMESTAMP_MINUTES,
  TSDB_SML_TIMESTAMP_SECONDS,
  TSDB_SML_TIMESTAMP_MILLI_SECONDS,
  TSDB_SML_TIMESTAMP_MICRO_SECONDS,
  TSDB_SML_TIMESTAMP_NANO_SECONDS,
} TSDB_SML_TIMESTAMP_TYPE;

S
slguan 已提交
84
typedef struct taosField {
L
Liu Jicong 已提交
85 86 87
  char    name[65];
  int8_t  type;
  int32_t bytes;
H
hzcheng 已提交
88 89
} TAOS_FIELD;

D
dapan1121 已提交
90 91 92 93 94 95 96 97
typedef struct TAOS_FIELD_E {
  char    name[65];
  int8_t  type;
  uint8_t precision;
  uint8_t scale;
  int32_t bytes;
} TAOS_FIELD_E;

98
#ifdef WINDOWS
99
#define DLL_EXPORT __declspec(dllexport)
100
#else
L
Liu Jicong 已提交
101
#define DLL_EXPORT
102
#endif
L
[#1054]  
lihui 已提交
103

H
Haojun Liao 已提交
104
typedef void (*__taos_async_fn_t)(void *param, TAOS_RES *res, int code);
105
typedef void (*__taos_notify_fn_t)(void *param, void *ext, int type);
106

D
dapan1121 已提交
107
typedef struct TAOS_MULTI_BIND {
L
Liu Jicong 已提交
108
  int       buffer_type;
L
Liu Jicong 已提交
109
  void     *buffer;
D
dapan1121 已提交
110
  uintptr_t buffer_length;
L
Liu Jicong 已提交
111 112
  int32_t  *length;
  char     *is_null;
L
Liu Jicong 已提交
113
  int       num;
D
dapan1121 已提交
114
} TAOS_MULTI_BIND;
D
fix bug  
dapan1121 已提交
115

116 117 118 119 120 121 122 123 124 125
typedef enum {
  SET_CONF_RET_SUCC = 0,
  SET_CONF_RET_ERR_PART = -1,
  SET_CONF_RET_ERR_INNER = -2,
  SET_CONF_RET_ERR_JSON_INVALID = -3,
  SET_CONF_RET_ERR_JSON_PARSE = -4,
  SET_CONF_RET_ERR_ONLY_ONCE = -5,
  SET_CONF_RET_ERR_TOO_LONG = -6
} SET_CONF_RET_CODE;

126
typedef enum {
K
kailixu 已提交
127
  TAOS_NOTIFY_PASSVER = 0,
128 129
} TAOS_NOTIFY_TYPE;

130 131 132
#define RET_MSG_LENGTH 1024
typedef struct setConfRet {
  SET_CONF_RET_CODE retCode;
L
Liu Jicong 已提交
133
  char              retMsg[RET_MSG_LENGTH];
134 135
} setConfRet;

136 137 138 139
typedef struct TAOS_VGROUP_HASH_INFO {
  int32_t  vgId;
  uint32_t hashBegin;
  uint32_t hashEnd;
dengyihao's avatar
dengyihao 已提交
140
} TAOS_VGROUP_HASH_INFO;
141 142

typedef struct TAOS_DB_ROUTE_INFO {
dengyihao's avatar
dengyihao 已提交
143 144 145 146 147
  int32_t                routeVersion;
  int16_t                hashPrefix;
  int16_t                hashSuffix;
  int8_t                 hashMethod;
  int32_t                vgNum;
148
  TAOS_VGROUP_HASH_INFO *vgHash;
dengyihao's avatar
dengyihao 已提交
149
} TAOS_DB_ROUTE_INFO;
150

L
Liu Jicong 已提交
151 152
DLL_EXPORT void       taos_cleanup(void);
DLL_EXPORT int        taos_options(TSDB_OPTION option, const void *arg, ...);
153
DLL_EXPORT setConfRet taos_set_config(const char *config);
L
Liu Jicong 已提交
154 155
DLL_EXPORT int        taos_init(void);
DLL_EXPORT TAOS      *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port);
156 157
DLL_EXPORT TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port);
DLL_EXPORT void  taos_close(TAOS *taos);
L
Liu Jicong 已提交
158

X
xsren 已提交
159
DLL_EXPORT const char *taos_data_type(int type);
L
Liu Jicong 已提交
160 161

DLL_EXPORT TAOS_STMT *taos_stmt_init(TAOS *taos);
dengyihao's avatar
dengyihao 已提交
162
DLL_EXPORT TAOS_STMT *taos_stmt_init_with_reqid(TAOS *taos, int64_t reqid);
L
Liu Jicong 已提交
163 164 165 166 167 168 169
DLL_EXPORT int        taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length);
DLL_EXPORT int        taos_stmt_set_tbname_tags(TAOS_STMT *stmt, const char *name, TAOS_MULTI_BIND *tags);
DLL_EXPORT int        taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name);
DLL_EXPORT int        taos_stmt_set_tags(TAOS_STMT *stmt, TAOS_MULTI_BIND *tags);
DLL_EXPORT int        taos_stmt_set_sub_tbname(TAOS_STMT *stmt, const char *name);
DLL_EXPORT int        taos_stmt_get_tag_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields);
DLL_EXPORT int        taos_stmt_get_col_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields);
170
// let stmt to reclaim TAOS_FIELD_E that was allocated by `taos_stmt_get_tag_fields`/`taos_stmt_get_col_fields`
171
DLL_EXPORT void taos_stmt_reclaim_fields(TAOS_STMT *stmt, TAOS_FIELD_E *fields);
L
Liu Jicong 已提交
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187

DLL_EXPORT int       taos_stmt_is_insert(TAOS_STMT *stmt, int *insert);
DLL_EXPORT int       taos_stmt_num_params(TAOS_STMT *stmt, int *nums);
DLL_EXPORT int       taos_stmt_get_param(TAOS_STMT *stmt, int idx, int *type, int *bytes);
DLL_EXPORT int       taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind);
DLL_EXPORT int       taos_stmt_bind_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind);
DLL_EXPORT int       taos_stmt_bind_single_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, int colIdx);
DLL_EXPORT int       taos_stmt_add_batch(TAOS_STMT *stmt);
DLL_EXPORT int       taos_stmt_execute(TAOS_STMT *stmt);
DLL_EXPORT TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt);
DLL_EXPORT int       taos_stmt_close(TAOS_STMT *stmt);
DLL_EXPORT char     *taos_stmt_errstr(TAOS_STMT *stmt);
DLL_EXPORT int       taos_stmt_affected_rows(TAOS_STMT *stmt);
DLL_EXPORT int       taos_stmt_affected_rows_once(TAOS_STMT *stmt);

DLL_EXPORT TAOS_RES *taos_query(TAOS *taos, const char *sql);
dengyihao's avatar
dengyihao 已提交
188
DLL_EXPORT TAOS_RES *taos_query_with_reqid(TAOS *taos, const char *sql, int64_t reqId);
L
Liu Jicong 已提交
189 190 191 192

DLL_EXPORT TAOS_ROW taos_fetch_row(TAOS_RES *res);
DLL_EXPORT int      taos_result_precision(TAOS_RES *res);  // get the time precision of result
DLL_EXPORT void     taos_free_result(TAOS_RES *res);
D
dapan1121 已提交
193
DLL_EXPORT void     taos_kill_query(TAOS *taos);
L
Liu Jicong 已提交
194 195 196
DLL_EXPORT int      taos_field_count(TAOS_RES *res);
DLL_EXPORT int      taos_num_fields(TAOS_RES *res);
DLL_EXPORT int      taos_affected_rows(TAOS_RES *res);
197
DLL_EXPORT int64_t  taos_affected_rows64(TAOS_RES *res);
H
Haojun Liao 已提交
198

L
[#1054]  
lihui 已提交
199
DLL_EXPORT TAOS_FIELD *taos_fetch_fields(TAOS_RES *res);
L
Liu Jicong 已提交
200 201 202 203
DLL_EXPORT int         taos_select_db(TAOS *taos, const char *db);
DLL_EXPORT int         taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields);
DLL_EXPORT void        taos_stop_query(TAOS_RES *res);
DLL_EXPORT bool        taos_is_null(TAOS_RES *res, int32_t row, int32_t col);
204
DLL_EXPORT bool        taos_is_update_query(TAOS_RES *res);
L
Liu Jicong 已提交
205
DLL_EXPORT int         taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows);
L
Liu Jicong 已提交
206 207
DLL_EXPORT int         taos_fetch_block_s(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows);
DLL_EXPORT int         taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData);
L
Liu Jicong 已提交
208
DLL_EXPORT int        *taos_get_column_data_offset(TAOS_RES *res, int columnIndex);
L
Liu Jicong 已提交
209
DLL_EXPORT int         taos_validate_sql(TAOS *taos, const char *sql);
H
Haojun Liao 已提交
210
DLL_EXPORT void        taos_reset_current_db(TAOS *taos);
H
hzcheng 已提交
211

L
Liu Jicong 已提交
212 213
DLL_EXPORT int      *taos_fetch_lengths(TAOS_RES *res);
DLL_EXPORT TAOS_ROW *taos_result_block(TAOS_RES *res);
214

215 216
DLL_EXPORT const char *taos_get_server_info(TAOS *taos);
DLL_EXPORT const char *taos_get_client_info();
217
DLL_EXPORT int         taos_get_current_db(TAOS *taos, char *database, int len, int *required);
S
slguan 已提交
218

219 220
DLL_EXPORT const char *taos_errstr(TAOS_RES *res);
DLL_EXPORT int         taos_errno(TAOS_RES *res);
H
hzcheng 已提交
221

dengyihao's avatar
dengyihao 已提交
222 223 224 225
DLL_EXPORT void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param);
DLL_EXPORT void taos_query_a_with_reqid(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param, int64_t reqid);
DLL_EXPORT void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param);
DLL_EXPORT void taos_fetch_raw_block_a(TAOS_RES *res, __taos_async_fn_t fp, void *param);
L
Liu Jicong 已提交
226
DLL_EXPORT const void *taos_get_raw_block(TAOS_RES *res);
H
hzcheng 已提交
227

dengyihao's avatar
dengyihao 已提交
228 229
DLL_EXPORT int taos_get_db_route_info(TAOS *taos, const char *db, TAOS_DB_ROUTE_INFO *dbInfo);
DLL_EXPORT int taos_get_table_vgId(TAOS *taos, const char *db, const char *table, int *vgId);
D
dapan1121 已提交
230
DLL_EXPORT int taos_get_tables_vgId(TAOS *taos, const char *db, const char *table[], int tableNum, int *vgId);
231

232
DLL_EXPORT int taos_load_table_info(TAOS *taos, const char *tableNameList);
233

234 235 236
// set heart beat thread quit mode , if quicByKill 1 then kill thread else quit from inner
DLL_EXPORT void taos_set_hb_quit(int8_t quitByKill);

K
kailixu 已提交
237
DLL_EXPORT int taos_set_notify_cb(TAOS *taos, __taos_notify_fn_t fp, void *param, int type);
238

239 240
/*  --------------------------schemaless INTERFACE------------------------------- */

wmmhello's avatar
wmmhello 已提交
241
DLL_EXPORT TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision);
dengyihao's avatar
dengyihao 已提交
242 243 244 245 246 247
DLL_EXPORT TAOS_RES *taos_schemaless_insert_with_reqid(TAOS *taos, char *lines[], int numLines, int protocol,
                                                       int precision, int64_t reqid);
DLL_EXPORT TAOS_RES *taos_schemaless_insert_raw(TAOS *taos, char *lines, int len, int32_t *totalRows, int protocol,
                                                int precision);
DLL_EXPORT TAOS_RES *taos_schemaless_insert_raw_with_reqid(TAOS *taos, char *lines, int len, int32_t *totalRows,
                                                           int protocol, int precision, int64_t reqid);
248 249
DLL_EXPORT TAOS_RES *taos_schemaless_insert_ttl(TAOS *taos, char *lines[], int numLines, int protocol, int precision,
                                                int32_t ttl);
250
DLL_EXPORT TAOS_RES *taos_schemaless_insert_ttl_with_reqid(TAOS *taos, char *lines[], int numLines, int protocol,
251
                                                           int precision, int32_t ttl, int64_t reqid);
252
DLL_EXPORT TAOS_RES *taos_schemaless_insert_raw_ttl(TAOS *taos, char *lines, int len, int32_t *totalRows, int protocol,
253
                                                    int precision, int32_t ttl);
254
DLL_EXPORT TAOS_RES *taos_schemaless_insert_raw_ttl_with_reqid(TAOS *taos, char *lines, int len, int32_t *totalRows,
255
                                                               int protocol, int precision, int32_t ttl, int64_t reqid);
L
Liu Jicong 已提交
256

L
Liu Jicong 已提交
257
/* --------------------------TMQ INTERFACE------------------------------- */
L
Liu Jicong 已提交
258

L
Liu Jicong 已提交
259
typedef struct tmq_t      tmq_t;
L
Liu Jicong 已提交
260 261
typedef struct tmq_conf_t tmq_conf_t;
typedef struct tmq_list_t tmq_list_t;
L
Liu Jicong 已提交
262

L
Liu Jicong 已提交
263
typedef void(tmq_commit_cb(tmq_t *, int32_t code, void *param));
L
Liu Jicong 已提交
264

L
Liu Jicong 已提交
265
DLL_EXPORT tmq_list_t *tmq_list_new();
L
Liu Jicong 已提交
266
DLL_EXPORT int32_t     tmq_list_append(tmq_list_t *, const char *);
L
Liu Jicong 已提交
267
DLL_EXPORT void        tmq_list_destroy(tmq_list_t *);
L
Liu Jicong 已提交
268
DLL_EXPORT int32_t     tmq_list_get_size(const tmq_list_t *);
L
Liu Jicong 已提交
269
DLL_EXPORT char      **tmq_list_to_c_array(const tmq_list_t *);
L
Liu Jicong 已提交
270

L
Liu Jicong 已提交
271
DLL_EXPORT tmq_t *tmq_consumer_new(tmq_conf_t *conf, char *errstr, int32_t errstrLen);
L
Liu Jicong 已提交
272

L
Liu Jicong 已提交
273
DLL_EXPORT const char *tmq_err2str(int32_t code);
L
Liu Jicong 已提交
274

L
Liu Jicong 已提交
275
/* ------------------------TMQ CONSUMER INTERFACE------------------------ */
H
Haojun Liao 已提交
276
typedef struct tmq_topic_assignment {
277 278 279 280
  int32_t vgId;
  int64_t currentOffset;
  int64_t begin;
  int64_t end;
H
Haojun Liao 已提交
281
} tmq_topic_assignment;
L
Liu Jicong 已提交
282

L
Liu Jicong 已提交
283 284 285
DLL_EXPORT int32_t   tmq_subscribe(tmq_t *tmq, const tmq_list_t *topic_list);
DLL_EXPORT int32_t   tmq_unsubscribe(tmq_t *tmq);
DLL_EXPORT int32_t   tmq_subscription(tmq_t *tmq, tmq_list_t **topics);
L
Liu Jicong 已提交
286 287
DLL_EXPORT TAOS_RES *tmq_consumer_poll(tmq_t *tmq, int64_t timeout);
DLL_EXPORT int32_t   tmq_consumer_close(tmq_t *tmq);
L
Liu Jicong 已提交
288 289
DLL_EXPORT int32_t   tmq_commit_sync(tmq_t *tmq, const TAOS_RES *msg);
DLL_EXPORT void      tmq_commit_async(tmq_t *tmq, const TAOS_RES *msg, tmq_commit_cb *cb, void *param);
290
DLL_EXPORT int32_t   tmq_commit_offset_sync(tmq_t *tmq, const char *pTopicName, int32_t vgId, int64_t offset);
291
DLL_EXPORT void      tmq_commit_offset_async(tmq_t *tmq, const char *pTopicName, int32_t vgId, int64_t offset, tmq_commit_cb *cb, void *param);
292 293
DLL_EXPORT int32_t   tmq_get_topic_assignment(tmq_t *tmq, const char *pTopicName, tmq_topic_assignment **assignment,
                                              int32_t *numOfAssignment);
T
t_max 已提交
294
DLL_EXPORT void      tmq_free_assignment(tmq_topic_assignment* pAssignment);
295
DLL_EXPORT int32_t   tmq_offset_seek(tmq_t *tmq, const char *pTopicName, int32_t vgId, int64_t offset);
L
Liu Jicong 已提交
296

297 298 299 300 301 302 303
DLL_EXPORT const char *tmq_get_topic_name(TAOS_RES *res);
DLL_EXPORT const char *tmq_get_db_name(TAOS_RES *res);
DLL_EXPORT int32_t     tmq_get_vgroup_id(TAOS_RES *res);
DLL_EXPORT int64_t     tmq_get_vgroup_offset(TAOS_RES* res);
DLL_EXPORT int64_t     tmq_position(tmq_t *tmq, const char *pTopicName, int32_t vgId);
DLL_EXPORT int64_t     tmq_committed(tmq_t *tmq, const char *pTopicName, int32_t vgId);

L
Liu Jicong 已提交
304 305 306 307 308 309 310 311 312 313
/* ----------------------TMQ CONFIGURATION INTERFACE---------------------- */

enum tmq_conf_res_t {
  TMQ_CONF_UNKNOWN = -2,
  TMQ_CONF_INVALID = -1,
  TMQ_CONF_OK = 0,
};

typedef enum tmq_conf_res_t tmq_conf_res_t;

L
Liu Jicong 已提交
314
DLL_EXPORT tmq_conf_t    *tmq_conf_new();
L
Liu Jicong 已提交
315
DLL_EXPORT tmq_conf_res_t tmq_conf_set(tmq_conf_t *conf, const char *key, const char *value);
L
Liu Jicong 已提交
316
DLL_EXPORT void           tmq_conf_destroy(tmq_conf_t *conf);
L
Liu Jicong 已提交
317
DLL_EXPORT void           tmq_conf_set_auto_commit_cb(tmq_conf_t *conf, tmq_commit_cb *cb, void *param);
L
Liu Jicong 已提交
318

L
Liu Jicong 已提交
319
/* -------------------------TMQ MSG HANDLE INTERFACE---------------------- */
320

321 322
/* ------------------------------ TAOSX -----------------------------------*/
// note: following apis are unstable
L
Liu Jicong 已提交
323 324 325 326
enum tmq_res_t {
  TMQ_RES_INVALID = -1,
  TMQ_RES_DATA = 1,
  TMQ_RES_TABLE_META = 2,
327
  TMQ_RES_METADATA = 3,
L
Liu Jicong 已提交
328 329
};

330 331
typedef struct tmq_raw_data {
  void    *raw;
wmmhello's avatar
wmmhello 已提交
332 333
  uint32_t raw_len;
  uint16_t raw_type;
334 335
} tmq_raw_data;

L
Liu Jicong 已提交
336
typedef enum tmq_res_t tmq_res_t;
wmmhello's avatar
wmmhello 已提交
337

338 339 340 341 342
DLL_EXPORT const char *tmq_get_table_name(TAOS_RES *res);
DLL_EXPORT tmq_res_t   tmq_get_res_type(TAOS_RES *res);
DLL_EXPORT int32_t     tmq_get_raw(TAOS_RES *res, tmq_raw_data *raw);
DLL_EXPORT int32_t     tmq_write_raw(TAOS *taos, tmq_raw_data raw);
DLL_EXPORT int         taos_write_raw_block(TAOS *taos, int numOfRows, char *pData, const char *tbname);
343 344
DLL_EXPORT int         taos_write_raw_block_with_fields(TAOS *taos, int rows, char *pData, const char *tbname,
                                                        TAOS_FIELD *fields, int numFields);
345 346 347 348 349 350
DLL_EXPORT void        tmq_free_raw(tmq_raw_data raw);
// Returning null means error. Returned result need to be freed by tmq_free_json_meta
DLL_EXPORT char *tmq_get_json_meta(TAOS_RES *res);
DLL_EXPORT void  tmq_free_json_meta(char *jsonMeta);

/* ---------------------------- TAOSX END -------------------------------- */
L
Liu Jicong 已提交
351

S
Shengliang Guan 已提交
352 353 354 355 356 357 358 359 360 361
typedef enum {
  TSDB_SRV_STATUS_UNAVAILABLE = 0,
  TSDB_SRV_STATUS_NETWORK_OK = 1,
  TSDB_SRV_STATUS_SERVICE_OK = 2,
  TSDB_SRV_STATUS_SERVICE_DEGRADED = 3,
  TSDB_SRV_STATUS_EXTING = 4,
} TSDB_SERVER_STATUS;

DLL_EXPORT TSDB_SERVER_STATUS taos_check_server_status(const char *fqdn, int port, char *details, int maxlen);

H
hzcheng 已提交
362 363 364 365 366
#ifdef __cplusplus
}
#endif

#endif