]> git.sur5r.net Git - openldap/blob - servers/slapd/back-sql/schema-map.h
cleanup error messages
[openldap] / servers / slapd / back-sql / schema-map.h
1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 1999-2004 The OpenLDAP Foundation.
5  * Portions Copyright 1999 Dmitry Kovalev.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
12  * A copy of this license is available in the file LICENSE in the
13  * top-level directory of the distribution or, alternatively, at
14  * <http://www.OpenLDAP.org/license.html>.
15  */
16 /* ACKNOWLEDGEMENTS:
17  * This work was initially developed by Dmitry Kovalev for inclusion
18  * by OpenLDAP Software.
19  */
20
21 #ifndef __BACKSQL_SCHEMA_MAP_H__
22 #define __BACKSQL_SCHEMA_MAP_H__
23
24 typedef struct backsql_oc_map_rec {
25         /*
26          * Structure of corresponding LDAP objectClass definition
27          */
28         ObjectClass     *bom_oc;
29 #define BACKSQL_OC_NAME(ocmap)  ((ocmap)->bom_oc->soc_cname.bv_val)
30         
31         struct berval   bom_keytbl;
32         struct berval   bom_keycol;
33         /* expected to return keyval of newly created entry */
34         char            *bom_create_proc;
35         /* in case create_proc does not return the keyval of the newly
36          * created row */
37         char            *bom_create_keyval;
38         /* supposed to expect keyval as parameter and delete 
39          * all the attributes as well */
40         char            *bom_delete_proc;
41         /* flags whether delete_proc is a function (whether back-sql 
42          * should bind first parameter as output for return code) */
43         int             bom_expect_return;
44         unsigned long   bom_id;
45         Avlnode         *bom_attrs;
46 } backsql_oc_map_rec;
47
48 typedef struct backsql_at_map_rec {
49         /* Description of corresponding LDAP attribute type */
50         AttributeDescription    *bam_ad;
51         /* ObjectClass if bam_ad is objectClass */
52         ObjectClass             *bam_oc;
53
54         struct berval   bam_from_tbls;
55         struct berval   bam_join_where;
56         struct berval   bam_sel_expr;
57
58         /* TimesTen, or, if a uppercase function is defined,
59          * an uppercased version of bam_sel_expr */
60         struct berval   bam_sel_expr_u;
61
62         /* supposed to expect 2 binded values: entry keyval 
63          * and attr. value to add, like "add_name(?,?,?)" */
64         char            *bam_add_proc;
65         /* supposed to expect 2 binded values: entry keyval 
66          * and attr. value to delete */
67         char            *bam_delete_proc;
68         /* for optimization purposes attribute load query 
69          * is preconstructed from parts on schemamap load time */
70         char            *bam_query;
71         /* following flags are bitmasks (first bit used for add_proc, 
72          * second - for delete_proc) */
73         /* order of parameters for procedures above; 
74          * 1 means "data then keyval", 0 means "keyval then data" */
75         int             bam_param_order;
76         /* flags whether one or more of procedures is a function 
77          * (whether back-sql should bind first parameter as output 
78          * for return code) */
79         int             bam_expect_return;
80
81         /* next mapping for attribute */
82         struct backsql_at_map_rec       *bam_next;
83 } backsql_at_map_rec;
84
85 #define BACKSQL_AT_MAP_REC_INIT { NULL, NULL, BER_BVC(""), BER_BVC(""), BER_BVNULL, BER_BVNULL, NULL, NULL, NULL, 0, 0, NULL }
86
87 /* define to uppercase filters only if the matching rule requires it
88  * (currently broken) */
89 /* #define      BACKSQL_UPPERCASE_FILTER */
90 #define BACKSQL_AT_CANUPPERCASE(at)     ((at)->bam_sel_expr_u.bv_val)
91
92 /* defines to support bitmasks above */
93 #define BACKSQL_ADD     0x1
94 #define BACKSQL_DEL     0x2
95
96 #define BACKSQL_IS_ADD(x)       ( BACKSQL_ADD & (x) )
97 #define BACKSQL_IS_DEL(x)       ( BACKSQL_DEL & (x) )
98
99 #define BACKSQL_NCMP(v1,v2)     ber_bvcmp((v1),(v2))
100
101 int backsql_load_schema_map( backsql_info *si, SQLHDBC dbh );
102 /* Deprecated */
103 backsql_oc_map_rec *backsql_name2oc( backsql_info *si, struct berval *oc_name );
104 backsql_oc_map_rec *backsql_oc2oc( backsql_info *si, ObjectClass *oc );
105 backsql_oc_map_rec *backsql_id2oc( backsql_info *si, unsigned long id );
106 /* Deprecated */
107 backsql_at_map_rec *backsql_name2at( backsql_oc_map_rec *objclass,
108                 struct berval *at_name );
109 backsql_at_map_rec *backsql_ad2at( backsql_oc_map_rec *objclass,
110                 AttributeDescription *ad );
111 int backsql_supad2at( backsql_oc_map_rec *objclass,
112                 AttributeDescription *supad, backsql_at_map_rec ***pret );
113 int backsql_destroy_schema_map( backsql_info *si );
114
115 #endif /* __BACKSQL_SCHEMA_MAP_H__ */
116