YACDB
Yet Another C(rappy) Database
db_ops.h
Go to the documentation of this file.
1
8#pragma once
9#include "../../diskio/include/diskio.h"
10#include "../../diskio/include/db_structs.h"
11#include "../../diskio/include/diskiod.h"
12
13#include "record.h"
14#include "cursor.h"
15#include "cursor_bt.h"
16#include <string.h>
17#include <assert.h>
18
23#define TABLES 0
24
29#define COLUMNS 1
30
35#define TABLES_NAMES 2
36
41#define COLUMNS_TIDX 3
42
47#define COLUMNS_NAMES 4
48
53
57void *get_row(Page root, Key key, Cursor **cursor);
58
62struct record *get_n_record(Page root, Key key, size_t n);
63
67Page get_table_addr(Key table_id);
68
72Key get_table_id(char *table_name);
73
78Key get_next_id(Key root_id);
79
83Key insert_row(Key root_id, struct record **records, size_t size);
84
85Key advanced_insert_row(Key tidx, struct record **records, size_t size);
86
96 char *table_name,
97 char **column_names,
98 short nb_cols);
99
113short *get_column_offsets(
114 Key table_id,
115 char *col_names[],
116 size_t nb_cols);
117
126 char *table_name,
127 Key key,
128 char *col_names[],
129 size_t nb_cols);
130
140char *select_all(
141 char *table_name,
142 char *col_names[],
143 size_t nb_cols);
144
157char *select_where(
158 char *table_name,
159 char *col_names[],
160 size_t nb_cols,
161 char *where_col_name,
162 struct record *where_record);
163
168void exit_db();
Operations on b-plus-trees using a cursor.
void * get_row(Page root, Key key, Cursor **cursor)
Get row from table with root root.
Definition: db_ops.c:336
char * select_all(char *table_name, char *col_names[], size_t nb_cols)
Selects all rows from a table.
Definition: db_ops.c:1021
char * select_where(char *table_name, char *col_names[], size_t nb_cols, char *where_col_name, struct record *where_record)
Selects all rows from a table where the given column is equal to the given value.
Definition: db_ops.c:1097
Key get_next_id(Key root_id)
Get the next available index in the table.
Definition: db_ops.c:509
Key get_table_id(char *table_name)
Get the table id from a table name.
Definition: db_ops.c:475
Key insert_row(Key root_id, struct record **records, size_t size)
Insert a row into the table with key root_id.
Definition: db_ops.c:538
short * get_column_offsets(Key table_id, char *col_names[], size_t nb_cols)
Get the offsets of a list of columns in a table.
Definition: db_ops.c:626
struct record * get_n_record(Page root, Key key, size_t n)
Retrieves the nth record from the row with key key.
Definition: db_ops.c:388
char * select_row_columns(char *table_name, Key key, char *col_names[], size_t nb_cols)
Selects a row from a table with the given key.
Definition: db_ops.c:934
void exit_db()
Exits and closes the database properly.
Definition: db_ops.c:1292
Page create_table(char *table_name, char **column_names, short nb_cols)
Creates a new table in the database.
Definition: db_ops.c:733
int initialize_tables()
Create initial tables.
Definition: db_ops.c:303
Page get_table_addr(Key table_id)
Get the table tree address of the given table.
Definition: db_ops.c:452
size_t Page
A address to a page.
Definition: db_structs.h:18
unsigned long Key
A key to a record.
Definition: diskio.h:28
A structure for handling data of unknown type.
Definition: cursor.h:19
Handles the general record type that abstracts away from the actual type of the data.
Definition: record.h:19