forked from bloomberg/comdb2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
constraints.h
59 lines (48 loc) · 1.75 KB
/
constraints.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
Copyright 2019 Bloomberg Finance L.P.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef INCLUDED_CONSTRAINTS_H
#define INCLUDED_CONSTRAINTS_H
#include "cdb2_constants.h"
#define MAXREF 64
typedef struct {
short dbnum;
short ixnum;
} fk_ref_type;
typedef struct {
short num;
fk_ref_type ref[MAXREF];
} fk_ref_array_type;
typedef struct {
struct dbtable *lcltable;
char *consname;
char *lclkeyname;
int nrules;
int flags;
char **table;
char **keynm;
} constraint_t;
typedef struct {
char *consname;
char *expr;
} check_constraint_t;
struct ireq;
int skip_lookup_for_nullfkey(const struct dbtable *db, int ixnum, int nulls);
int check_single_key_constraint(struct ireq *ruleiq, const constraint_t *ct,
const char *lcl_tag, const char *lcl_key,
const struct dbtable *table, void *trans, int *remote_ri);
constraint_t *get_constraint_for_ix(struct dbtable *db_table, int ix);
int convert_key_to_foreign_key(constraint_t *ct, char *lcl_tag, char *lcl_key,
char *tblname, bdb_state_type **r_state,
int *ridx, int *rixlen, char *rkey, int *skip,
int ri);
#endif