31 printf(
"%s() returned error %d: %s\n", foo, st,
ups_strerror(st));
37 #define DBNAME_CUSTOMER 1 38 #define DBNAME_ORDER 2 41 #define DBIDX_CUSTOMER 0 45 #define MAX_CUSTOMERS 4 64 main(
int argc,
char **argv) {
91 { 1,
"Alan Antonov Corp." },
92 { 2,
"Barry Broke Inc." },
93 { 3,
"Carl Caesar Lat." },
94 { 4,
"Doris Dove Brd." }
111 error(
"ups_env_create", st);
122 error(
"ups_env_create_db(customer)", st);
125 error(
"ups_env_create_db(order)", st);
129 error(
"ups_env_create_db(c2o)", st);
132 for (i = 0; i <
MAX_DBS; i++) {
135 error(
"ups_cursor_create" , st);
146 key.
size =
sizeof(int);
147 key.
data = &customers[i].
id;
150 record.
data = &customers[i];
154 error(
"ups_db_insert (customer)", st);
165 key.
size =
sizeof(int);
173 error(
"ups_db_insert (order)", st);
185 key.
size =
sizeof(int);
188 record.
size =
sizeof(int);
189 record.
data = &orders[i].
id;
193 error(
"ups_db_insert(c2o)", st);
216 error(
"ups_cursor_next(customer)", st);
222 printf(
"customer %d ('%s')\n", customer->
id, customer->
name);
234 c2o_key.
data = &customer->
id;
235 c2o_key.
size =
sizeof(int);
240 error(
"ups_cursor_find(c2o)", st);
244 error(
"ups_cursor_move(c2o)", st);
249 order_id = *(
int *)c2o_record.
data;
250 ord_key.
data = &order_id;
251 ord_key.
size =
sizeof(
int);
257 st =
ups_db_find(db[1], 0, &ord_key, &ord_record, 0);
259 error(
"ups_db_find(order)", st);
261 printf(
" order: %d (assigned to %s)\n",
262 order_id, (
char *)ord_record.
data);
275 error(
"ups_cursor_next(c2o)", st);
287 error(
"ups_env_close", st);
289 printf(
"success!\n");
UPS_EXPORT const char *UPS_CALLCONV ups_strerror(ups_status_t status)
UPS_EXPORT ups_status_t UPS_CALLCONV ups_env_close(ups_env_t *env, uint32_t flags)
UPS_EXPORT ups_status_t UPS_CALLCONV ups_db_insert(ups_db_t *db, ups_txn_t *txn, ups_key_t *key, ups_record_t *record, uint32_t flags)
UPS_EXPORT ups_status_t UPS_CALLCONV ups_db_find(ups_db_t *db, ups_txn_t *txn, ups_key_t *key, ups_record_t *record, uint32_t flags)
UPS_EXPORT ups_status_t UPS_CALLCONV ups_cursor_move(ups_cursor_t *cursor, ups_key_t *key, ups_record_t *record, uint32_t flags)
Include file for upscaledb embedded database.
UPS_EXPORT ups_status_t UPS_CALLCONV ups_cursor_find(ups_cursor_t *cursor, ups_key_t *key, ups_record_t *record, uint32_t flags)
#define UPS_PARAM_RECORD_SIZE
struct ups_cursor_t ups_cursor_t
#define UPS_ONLY_DUPLICATES
#define UPS_ENABLE_DUPLICATE_KEYS
UPS_EXPORT ups_status_t UPS_CALLCONV ups_env_create(ups_env_t **env, const char *filename, uint32_t flags, uint32_t mode, const ups_parameter_t *param)
int main(int argc, char **argv)
UPS_EXPORT ups_status_t UPS_CALLCONV ups_env_create_db(ups_env_t *env, ups_db_t **db, uint16_t name, uint32_t flags, const ups_parameter_t *params)
void error(const char *foo, ups_status_t st)
#define UPS_PARAM_KEY_TYPE
UPS_EXPORT ups_status_t UPS_CALLCONV ups_cursor_create(ups_cursor_t **cursor, ups_db_t *db, ups_txn_t *txn, uint32_t flags)
#define UPS_KEY_NOT_FOUND
struct ups_env_t ups_env_t