mirror of
https://github.com/fumiama/fumidb.git
synced 2026-06-08 03:53:48 +08:00
add more api
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
// 返回:
|
||||
// NULL 失败,详见 errno
|
||||
// table 指向表头的指针
|
||||
void* create_table(int fd, char* buf, const char* name, int row_len, ...);
|
||||
void* create_table(int fd, char* buf, const char* name, int row_len, const void* list);
|
||||
|
||||
// 加载 ptr 位置的表
|
||||
// len(buf) >= 4096+8+2=4106
|
||||
@@ -54,7 +54,7 @@ int remove_table_index(int fd, void* table, uint16_t pos);
|
||||
// 返回:
|
||||
// 0 失败,详见 errno
|
||||
// ptr 本行插入的位置
|
||||
uint64_t insert_row(int fd, void* table, int row_len, ...);
|
||||
uint64_t insert_row(int fd, void* table, int row_len, const void* list);
|
||||
|
||||
// 根据主键的匹配值查找行
|
||||
// 如果主键不为 string,k 直接装填其值
|
||||
@@ -72,7 +72,7 @@ uint64_t find_row_by_pk(int fd, void* table, key_t k);
|
||||
// 返回:
|
||||
// 非 0 失败,详见 errno
|
||||
// 0 成功
|
||||
int find_row_by(int fd, void* table, int (*f)(uint64_t), int row_len, ...);
|
||||
int find_row_by(int fd, void* table, int (*f)(uint64_t), int row_len, const void* list);
|
||||
|
||||
// 根据主键的匹配值删除行
|
||||
// 如果主键不为 string,k 直接装填其值
|
||||
@@ -89,6 +89,6 @@ int remove_row_by_pk(int fd, void* table, key_t k);
|
||||
// 返回:
|
||||
// 非 0 失败,详见 errno
|
||||
// 0 成功
|
||||
int remove_row_by(int fd, void* table, int row_len, ...);
|
||||
int remove_row_by(int fd, void* table, int row_len, const void* list);
|
||||
|
||||
#endif
|
||||
@@ -4,23 +4,23 @@
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define TYPE_INT8 ((uint8_t)0)
|
||||
#define TYPE_INT16 ((uint8_t)1)
|
||||
#define TYPE_INT32 ((uint8_t)2)
|
||||
#define TYPE_INT64 ((uint8_t)3)
|
||||
#define TYPE_FLOAT ((uint8_t)4)
|
||||
#define TYPE_DOUBLE ((uint8_t)5)
|
||||
#define TYPE_STRING ((uint8_t)6)
|
||||
#define TYPE_BINARY ((uint8_t)7)
|
||||
|
||||
#define EXTYPE_NULL ((uint8_t)0x00)
|
||||
#define EXTYPE_UNIQUE ((uint8_t)0x40)
|
||||
#define EXTYPE_NONNULL ((uint8_t)0x80)
|
||||
#define EXTYPE_FOREIGNKEY ((uint8_t)0xc0)
|
||||
|
||||
typedef uint8_t type_t;
|
||||
typedef uint64_t key_t;
|
||||
|
||||
#define TYPE_INT8 ((type_t)0)
|
||||
#define TYPE_INT16 ((type_t)1)
|
||||
#define TYPE_INT32 ((type_t)2)
|
||||
#define TYPE_INT64 ((type_t)3)
|
||||
#define TYPE_FLOAT ((type_t)4)
|
||||
#define TYPE_DOUBLE ((type_t)5)
|
||||
#define TYPE_STRING ((type_t)6)
|
||||
#define TYPE_BINARY ((type_t)7)
|
||||
|
||||
#define EXTYPE_NULL ((type_t)0x00)
|
||||
#define EXTYPE_UNIQUE ((type_t)0x10)
|
||||
#define EXTYPE_NONNULL ((type_t)0x20)
|
||||
#define EXTYPE_FOREIGNKEY ((type_t)0x40)
|
||||
|
||||
// 获得本类型 index 相对于 buffer 头的偏移
|
||||
int type_offset(type_t t);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user