]> git.sur5r.net Git - openldap/blob - servers/slapd/back-sql/schema-map.h
Converted ch_malloc, ch_calloc and ch_realloc calls to SLAP_MALLOC,
[openldap] / servers / slapd / back-sql / schema-map.h
1 #ifndef __BACKSQL_SCHEMA_MAP_H__
2 #define __BACKSQL_SCHEMA_MAP_H__
3
4 /*
5  *       Copyright 1999, Dmitry Kovalev <mit@openldap.org>, All rights reserved.
6  *
7  *       Redistribution and use in source and binary forms are permitted only
8  *       as authorized by the OpenLDAP Public License.  A copy of this
9  *       license is available at http://www.OpenLDAP.org/license.html or
10  *       in file LICENSE in the top-level directory of the distribution.
11  */
12
13 typedef struct {
14         /*
15          * Structure of corresponding LDAP objectClass definition
16          */
17         ObjectClass     *oc;
18 #define BACKSQL_OC_NAME(ocmap)  ((ocmap)->oc->soc_cname.bv_val)
19         
20         struct berval   keytbl;
21         struct berval   keycol;
22         /* expected to return keyval of newly created entry */
23         char            *create_proc;
24         /* in case create_proc does not return the keyval of the newly
25          * created row */
26         char            *create_keyval;
27         /* supposed to expect keyval as parameter and delete 
28          * all the attributes as well */
29         char            *delete_proc;
30         /* flags whether delete_proc is a function (whether back-sql 
31          * should bind first parameter as output for return code) */
32         int             expect_return;
33         unsigned long   id;
34         Avlnode         *attrs;
35 } backsql_oc_map_rec;
36
37 typedef struct {
38         /* Description of corresponding LDAP attribute type */
39         AttributeDescription    *ad;
40         struct berval   from_tbls;
41         struct berval   join_where;
42         struct berval   sel_expr;
43         /* supposed to expect 2 binded values: entry keyval 
44          * and attr. value to add, like "add_name(?,?,?)" */
45         char            *add_proc;
46         /* supposed to expect 2 binded values: entry keyval 
47          * and attr. value to delete */
48         char            *delete_proc;
49         /* for optimization purposes attribute load query 
50          * is preconstructed from parts on schemamap load time */
51         char            *query;
52         /* following flags are bitmasks (first bit used for add_proc, 
53          * second - for delete_proc) */
54         /* order of parameters for procedures above; 
55          * 1 means "data then keyval", 0 means "keyval then data" */
56         int             param_order;
57         /* flags whether one or more of procedures is a function 
58          * (whether back-sql should bind first parameter as output 
59          * for return code) */
60         int             expect_return;
61         /* TimesTen */
62         struct berval   sel_expr_u;
63 } backsql_at_map_rec;
64
65 /* defines to support bitmasks above */
66 #define BACKSQL_ADD     0x1
67 #define BACKSQL_DEL     0x2
68
69 #define BACKSQL_IS_ADD(x)       ( BACKSQL_ADD & (x) )
70 #define BACKSQL_IS_DEL(x)       ( BACKSQL_DEL & (x) )
71
72 #define BACKSQL_NCMP(v1,v2)     ber_bvcmp((v1),(v2))
73
74 int backsql_load_schema_map( backsql_info *si, SQLHDBC dbh );
75 /* Deprecated */
76 backsql_oc_map_rec *backsql_name2oc( backsql_info *si, struct berval *oc_name );
77 backsql_oc_map_rec *backsql_oc2oc( backsql_info *si, ObjectClass *oc );
78 backsql_oc_map_rec *backsql_id2oc( backsql_info *si, unsigned long id );
79 /* Deprecated */
80 backsql_at_map_rec *backsql_name2at( backsql_oc_map_rec *objclass,
81                 struct berval *at_name );
82 backsql_at_map_rec *backsql_ad2at( backsql_oc_map_rec *objclass,
83                 AttributeDescription *ad );
84 int backsql_destroy_schema_map( backsql_info *si );
85
86 #endif /* __BACKSQL_SCHEMA_MAP_H__ */
87