]> git.sur5r.net Git - openldap/blob - servers/slapd/back-sql/schema-map.h
27f07278ef8034c934306c4bc87158c558b4abbe
[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
14 typedef struct {
15         struct berval   name;
16         ObjectClass     *oc;
17         char            *keytbl;
18         char            *keycol;
19         /* expected to return keyval of newly created entry */
20         char            *create_proc;
21         /* supposed to expect keyval as parameter and delete 
22          * all the attributes as well */
23         char            *delete_proc;
24         /* flags whether delete_proc is a function (whether back-sql 
25          * should bind first parameter as output for return code) */
26         int             expect_return;
27         unsigned long   id;
28         Avlnode         *attrs;
29 } backsql_oc_map_rec;
30
31 typedef struct {
32         /* literal name of corresponding LDAP attribute type */
33         struct berval   name;
34         AttributeDescription    *ad;
35         char            *from_tbls;
36         char            *join_where;
37         char            *sel_expr;
38         /* supposed to expect 2 binded values: entry keyval 
39          * and attr. value to add, like "add_name(?,?,?)" */
40         char            *add_proc;
41         /* supposed to expect 2 binded values: entry keyval 
42          * and attr. value to delete */
43         char            *delete_proc;
44         /* for optimization purposes attribute load query 
45          * is preconstructed from parts on schemamap load time */
46         char            *query;
47         /* following flags are bitmasks (first bit used for add_proc, 
48          * second - for modify, third - for delete_proc) */
49         /* order of parameters for procedures above; 
50          * 1 means "data then keyval", 0 means "keyval then data" */
51         int             param_order;
52         /* flags whether one or more of procedures is a function 
53          * (whether back-sql should bind first parameter as output 
54          * for return code) */
55         int             expect_return;
56         /* TimesTen */
57         char            *sel_expr_u;
58 } backsql_at_map_rec;
59
60 /* defines to support bitmasks above */
61 #define BACKSQL_ADD     0x1
62 #define BACKSQL_DEL     0x2
63
64 #define BACKSQL_IS_ADD(x)       ( BACKSQL_ADD & (x) )
65 #define BACKSQL_IS_DEL(x)       ( BACKSQL_DEL & (x) )
66
67 #define BACKSQL_NCMP(v1,v2)     ber_bvcmp((v1),(v2))
68
69 int backsql_load_schema_map( backsql_info *si, SQLHDBC dbh );
70 /* Deprecated */
71 backsql_oc_map_rec *backsql_name2oc( backsql_info *si, struct berval *oc_name );
72 backsql_oc_map_rec *backsql_oc2oc( backsql_info *si, ObjectClass *oc );
73 backsql_oc_map_rec *backsql_id2oc( backsql_info *si, unsigned long id );
74 /* Deprecated */
75 backsql_at_map_rec *backsql_name2at( backsql_oc_map_rec *objclass,
76                 struct berval *at_name );
77 backsql_at_map_rec *backsql_ad2at( backsql_oc_map_rec *objclass,
78                 AttributeDescription *ad );
79 int backsql_destroy_schema_map( backsql_info *si );
80
81 #endif /* __BACKSQL_SCHEMA_MAP_H__ */
82