2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1999-2003 The OpenLDAP Foundation.
5 * Portions Copyright 1999 Dmitry Kovalev.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
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>.
17 * This work was initially developed by Dmitry Kovalev for inclusion
18 * by OpenLDAP Software.
21 #ifndef __BACKSQL_SCHEMA_MAP_H__
22 #define __BACKSQL_SCHEMA_MAP_H__
26 * Structure of corresponding LDAP objectClass definition
29 #define BACKSQL_OC_NAME(ocmap) ((ocmap)->oc->soc_cname.bv_val)
33 /* expected to return keyval of newly created entry */
35 /* in case create_proc does not return the keyval of the newly
38 /* supposed to expect keyval as parameter and delete
39 * all the attributes as well */
41 /* flags whether delete_proc is a function (whether back-sql
42 * should bind first parameter as output for return code) */
49 /* Description of corresponding LDAP attribute type */
50 AttributeDescription *ad;
51 struct berval from_tbls;
52 struct berval join_where;
53 struct berval sel_expr;
54 /* supposed to expect 2 binded values: entry keyval
55 * and attr. value to add, like "add_name(?,?,?)" */
57 /* supposed to expect 2 binded values: entry keyval
58 * and attr. value to delete */
60 /* for optimization purposes attribute load query
61 * is preconstructed from parts on schemamap load time */
63 /* following flags are bitmasks (first bit used for add_proc,
64 * second - for delete_proc) */
65 /* order of parameters for procedures above;
66 * 1 means "data then keyval", 0 means "keyval then data" */
68 /* flags whether one or more of procedures is a function
69 * (whether back-sql should bind first parameter as output
73 struct berval sel_expr_u;
76 /* defines to support bitmasks above */
77 #define BACKSQL_ADD 0x1
78 #define BACKSQL_DEL 0x2
80 #define BACKSQL_IS_ADD(x) ( BACKSQL_ADD & (x) )
81 #define BACKSQL_IS_DEL(x) ( BACKSQL_DEL & (x) )
83 #define BACKSQL_NCMP(v1,v2) ber_bvcmp((v1),(v2))
85 int backsql_load_schema_map( backsql_info *si, SQLHDBC dbh );
87 backsql_oc_map_rec *backsql_name2oc( backsql_info *si, struct berval *oc_name );
88 backsql_oc_map_rec *backsql_oc2oc( backsql_info *si, ObjectClass *oc );
89 backsql_oc_map_rec *backsql_id2oc( backsql_info *si, unsigned long id );
91 backsql_at_map_rec *backsql_name2at( backsql_oc_map_rec *objclass,
92 struct berval *at_name );
93 backsql_at_map_rec *backsql_ad2at( backsql_oc_map_rec *objclass,
94 AttributeDescription *ad );
95 int backsql_destroy_schema_map( backsql_info *si );
97 #endif /* __BACKSQL_SCHEMA_MAP_H__ */