2023-07-25 monetdb-relation-关键数据结构-记录

摘要:

monetdb-relation-关键数据结构-记录

关键数据结构:

expression_type

typedef enum expression_type {
	e_atom,
	e_column,
	e_cmp,
	e_func,
	e_aggr,
	e_convert,
	e_psm
} expression_type;

expression


typedef struct expression {
	expression_type type;	/* atom, cmp, func/aggr */
	sql_exp_name alias;
	void *l;
	void *r;
	void *f;	/* func's and aggr's, also e_cmp may have have 2 arguments */
	unsigned int flag; /* cmp types, PSM types/level */
	unsigned int
	 card:2,	/* card (0 truth value!) (1 atoms) (2 aggr) (3 multi value) */
	 freevar:4,	/* free variable, ie binds to the upper dependent join */
	 intern:1,
	 anti:1,
	 ascending:1,	/* order direction */
	 nulls_last:1,	/* return null after all other rows */
	 zero_if_empty:1, 	/* in case of partial aggregator computation, some aggregators need to return 0 instead of NULL */
	 distinct:1,

	 semantics:1,	/* is vs = semantics (nil = nil vs unknown != unknown), ranges with or without nil, aggregation with or without nil */
	 need_no_nil:1,
	 has_no_nil:1,
	 unique:1,	/* expression has unique values, but it may have multiple NULL values! */

	 base:1,
	 ref:1,		/* used to indicate an other expression may reference this one */
	 used:1,	/* used for quick dead code removal */
	 symmetric:1; /* compare between symmetric */
	sql_subtype	tpe;
	void *p;	/* properties for the optimizer */
} sql_exp;

ddl_statement

typedef enum ddl_statement {
	ddl_output,
	ddl_list,
	ddl_psm,
	ddl_exception,
	ddl_create_seq,
	ddl_alter_seq,
	ddl_drop_seq,
	ddl_alter_table_add_range_partition,
	ddl_alter_table_add_list_partition,
	ddl_release,
	ddl_commit,
	ddl_rollback,
	ddl_trans,
	ddl_create_schema,
	ddl_drop_schema,
	ddl_create_table,
	ddl_drop_table,
	ddl_create_view,
	ddl_drop_view,
	ddl_drop_constraint,
	ddl_alter_table,
	ddl_create_type,
	ddl_drop_type,
	ddl_drop_index,
	ddl_create_function,
	ddl_drop_function,
	ddl_create_trigger,
	ddl_drop_trigger,
	ddl_grant_roles,
	ddl_revoke_roles,
	ddl_grant,
	ddl_revoke,
	ddl_grant_func,
	ddl_revoke_func,
	ddl_create_user,
	ddl_drop_user,
	ddl_alter_user,
	ddl_rename_user,
	ddl_create_role,
	ddl_drop_role,
	ddl_alter_table_add_table,
	ddl_alter_table_del_table,
	ddl_alter_table_set_access,
	ddl_comment_on,
	ddl_rename_schema,
	ddl_rename_table,
	ddl_rename_column,
	ddl_maxops /* evaluated to the max value, should be always kept at the bottom */
} ddl_statement;

operator_type

typedef enum operator_type {
	op_basetable = 0,
	op_table,
	op_ddl,
	op_project,		/* includes order by */
	op_select,
	op_join,
	op_left,
	op_right,
	op_full,
	op_semi,
	op_anti,
	op_union,
	op_inter,
	op_except,
	op_groupby,
	op_topn,
	op_sample,
	op_insert,	/* insert(l=table, r insert expressions) */
	op_update,	/* update(l=table, r update expressions) */
	op_delete,	/* delete(l=table, r delete expression) */
	op_truncate, /* truncate(l=table) */
	op_merge
} operator_type;

relation

typedef struct relation {
	sql_ref ref;

	operator_type op;
	void *l;
	void *r;
	list *exps;
	list *attr; /* attributes: mark-joins return extra attributes */
				/* later put all 'projection' attributes in here, ie for set ops, project/group/table/basetable by
				 * select/ (semi/anti/left/outer/right)join will use exps for predicates
				 * groupby will use exps for group by exps
				 * project can use exps for the order by bits
				 * topn/sample use exps for the input arguments of the limit/sample
				 */
	int nrcols;	/* nr of cols */
	unsigned int
	 flag:16,
	 card:4,	/* 0, 1 (row), 2 aggr, 3 */
	 dependent:1, 	/* dependent join */
	 distinct:1,
	 processed:1,   /* fully processed or still in the process of building */
	 outer:1,	/* used as outer (ungrouped) */
	 grouped:1,	/* groupby processed all the group by exps */
	 single:1;
	/*
	 * Used by rewriters at rel_unnest, rel_optimizer and rel_distribute so a relation is not modified twice
	 * The list is kept at rel_optimizer_private.h Please update it accordingly
	 */
	uint8_t used;
	void *p;	/* properties for the optimizer, distribution */
} sql_rel;

你可能感兴趣的:(数据结构,monetdb,数据库,关系型数据库)