|
| 1 | +/* |
| 2 | + * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com> |
| 3 | + * |
| 4 | + * This program is free software: you can use, redistribute, and/or modify |
| 5 | + * it under the terms of the GNU Affero General Public License, version 3 |
| 6 | + * or later ("AGPL"), as published by the Free Software Foundation. |
| 7 | + * |
| 8 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
| 9 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 10 | + * FITNESS FOR A PARTICULAR PURPOSE. |
| 11 | + * |
| 12 | + * You should have received a copy of the GNU Affero General Public License |
| 13 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 14 | + */ |
| 15 | + |
| 16 | +#ifndef CLIENT_RAW_BLOCK_WRITE_H |
| 17 | +#define CLIENT_RAW_BLOCK_WRITE_H |
| 18 | + |
| 19 | +#include "clientInt.h" |
| 20 | + |
| 21 | +#ifdef __cplusplus |
| 22 | +extern "C" { |
| 23 | +#endif |
| 24 | + |
| 25 | +// Common macros shared across clientRawBlockWrite.c and clientRawBlockJson.c |
| 26 | + |
| 27 | +#define RAW_LOG_END \ |
| 28 | + if (code != 0) { \ |
| 29 | + uError("%s failed at line:%d since:%s", __func__, lino, tstrerror(code)); \ |
| 30 | + } else { \ |
| 31 | + uDebug("%s return success", __func__); \ |
| 32 | + } |
| 33 | + |
| 34 | +#define RAW_LOG_START uDebug("%s start", __func__); |
| 35 | + |
| 36 | +#define RAW_NULL_CHECK(c) \ |
| 37 | + do { \ |
| 38 | + if (c == NULL) { \ |
| 39 | + lino = __LINE__; \ |
| 40 | + code = terrno; \ |
| 41 | + goto end; \ |
| 42 | + } \ |
| 43 | + } while (0) |
| 44 | + |
| 45 | +#define RAW_FALSE_CHECK(c) \ |
| 46 | + do { \ |
| 47 | + if (!(c)) { \ |
| 48 | + code = TSDB_CODE_INVALID_PARA; \ |
| 49 | + lino = __LINE__; \ |
| 50 | + goto end; \ |
| 51 | + } \ |
| 52 | + } while (0) |
| 53 | + |
| 54 | +#define RAW_RETURN_CHECK(c) \ |
| 55 | + do { \ |
| 56 | + code = c; \ |
| 57 | + if (code != 0) { \ |
| 58 | + lino = __LINE__; \ |
| 59 | + goto end; \ |
| 60 | + } \ |
| 61 | + } while (0) |
| 62 | + |
| 63 | +#define LOG_ID_TAG "connId:0x%" PRIx64 ", QID:0x%" PRIx64 ",func:%s" |
| 64 | +#define LOG_ID_VALUE *(int64_t*)taos, pRequest->requestId, __func__ |
| 65 | + |
| 66 | +#define PROCESS_TABLE_NOT_EXIST(code, tbName) \ |
| 67 | + if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) { \ |
| 68 | + uWarn(LOG_ID_TAG " %s not exists, skip", LOG_ID_VALUE, tbName); \ |
| 69 | + code = TSDB_CODE_SUCCESS; \ |
| 70 | + continue; \ |
| 71 | + } \ |
| 72 | + RAW_RETURN_CHECK(code); |
| 73 | + |
| 74 | +#ifdef __cplusplus |
| 75 | +} |
| 76 | +#endif |
| 77 | + |
| 78 | +#endif // CLIENT_RAW_BLOCK_WRITE_H |
0 commit comments