2003-12-08 03:19:18 +08:00
|
|
|
/* $OpenLDAP$ */
|
|
|
|
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
*
|
2004-01-02 03:15:16 +08:00
|
|
|
* Copyright 1999-2004 The OpenLDAP Foundation.
|
2003-12-08 03:19:18 +08:00
|
|
|
* Portions Copyright 1999 Dmitry Kovalev.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted only as authorized by the OpenLDAP
|
|
|
|
* Public License.
|
2000-05-27 00:03:32 +08:00
|
|
|
*
|
2003-12-08 03:19:18 +08:00
|
|
|
* A copy of this license is available in the file LICENSE in the
|
|
|
|
* top-level directory of the distribution or, alternatively, at
|
|
|
|
* <http://www.OpenLDAP.org/license.html>.
|
2000-05-27 00:03:32 +08:00
|
|
|
*/
|
2003-12-08 03:19:18 +08:00
|
|
|
/* ACKNOWLEDGEMENTS:
|
|
|
|
* This work was initially developed by Dmitry Kovalev for inclusion
|
|
|
|
* by OpenLDAP Software.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __BACKSQL_SCHEMA_MAP_H__
|
|
|
|
#define __BACKSQL_SCHEMA_MAP_H__
|
2000-05-27 00:03:32 +08:00
|
|
|
|
2004-01-10 18:42:44 +08:00
|
|
|
typedef struct backsql_oc_map_rec {
|
2002-08-23 16:54:08 +08:00
|
|
|
/*
|
|
|
|
* Structure of corresponding LDAP objectClass definition
|
|
|
|
*/
|
2004-01-10 18:42:44 +08:00
|
|
|
ObjectClass *bom_oc;
|
|
|
|
#define BACKSQL_OC_NAME(ocmap) ((ocmap)->bom_oc->soc_cname.bv_val)
|
2002-08-29 18:55:48 +08:00
|
|
|
|
2004-01-10 18:42:44 +08:00
|
|
|
struct berval bom_keytbl;
|
|
|
|
struct berval bom_keycol;
|
2002-08-14 01:12:27 +08:00
|
|
|
/* expected to return keyval of newly created entry */
|
2004-01-10 18:42:44 +08:00
|
|
|
char *bom_create_proc;
|
2002-08-23 16:54:08 +08:00
|
|
|
/* in case create_proc does not return the keyval of the newly
|
|
|
|
* created row */
|
2004-01-10 18:42:44 +08:00
|
|
|
char *bom_create_keyval;
|
2002-08-14 01:12:27 +08:00
|
|
|
/* supposed to expect keyval as parameter and delete
|
|
|
|
* all the attributes as well */
|
2004-01-10 18:42:44 +08:00
|
|
|
char *bom_delete_proc;
|
2002-08-14 01:12:27 +08:00
|
|
|
/* flags whether delete_proc is a function (whether back-sql
|
|
|
|
* should bind first parameter as output for return code) */
|
2004-01-10 18:42:44 +08:00
|
|
|
int bom_expect_return;
|
|
|
|
unsigned long bom_id;
|
|
|
|
Avlnode *bom_attrs;
|
2002-08-14 01:12:27 +08:00
|
|
|
} backsql_oc_map_rec;
|
|
|
|
|
2004-01-10 18:42:44 +08:00
|
|
|
typedef struct backsql_at_map_rec {
|
2002-08-23 16:54:08 +08:00
|
|
|
/* Description of corresponding LDAP attribute type */
|
2004-01-10 18:42:44 +08:00
|
|
|
AttributeDescription *bam_ad;
|
|
|
|
/* ObjectClass if bam_ad is objectClass */
|
|
|
|
ObjectClass *bam_oc;
|
|
|
|
|
|
|
|
struct berval bam_from_tbls;
|
|
|
|
struct berval bam_join_where;
|
|
|
|
struct berval bam_sel_expr;
|
2004-01-20 06:13:15 +08:00
|
|
|
|
|
|
|
/* TimesTen, or, if a uppercase function is defined,
|
|
|
|
* an uppercased version of bam_sel_expr */
|
|
|
|
struct berval bam_sel_expr_u;
|
|
|
|
|
2002-08-14 01:12:27 +08:00
|
|
|
/* supposed to expect 2 binded values: entry keyval
|
|
|
|
* and attr. value to add, like "add_name(?,?,?)" */
|
2004-01-10 18:42:44 +08:00
|
|
|
char *bam_add_proc;
|
2002-08-14 01:12:27 +08:00
|
|
|
/* supposed to expect 2 binded values: entry keyval
|
|
|
|
* and attr. value to delete */
|
2004-01-10 18:42:44 +08:00
|
|
|
char *bam_delete_proc;
|
2002-08-14 01:12:27 +08:00
|
|
|
/* for optimization purposes attribute load query
|
|
|
|
* is preconstructed from parts on schemamap load time */
|
2004-01-10 18:42:44 +08:00
|
|
|
char *bam_query;
|
2002-08-14 01:12:27 +08:00
|
|
|
/* following flags are bitmasks (first bit used for add_proc,
|
2002-08-23 16:54:08 +08:00
|
|
|
* second - for delete_proc) */
|
2002-08-14 01:12:27 +08:00
|
|
|
/* order of parameters for procedures above;
|
|
|
|
* 1 means "data then keyval", 0 means "keyval then data" */
|
2004-01-10 18:42:44 +08:00
|
|
|
int bam_param_order;
|
2002-08-14 01:12:27 +08:00
|
|
|
/* flags whether one or more of procedures is a function
|
|
|
|
* (whether back-sql should bind first parameter as output
|
|
|
|
* for return code) */
|
2004-01-10 18:42:44 +08:00
|
|
|
int bam_expect_return;
|
|
|
|
|
|
|
|
/* next mapping for attribute */
|
|
|
|
struct backsql_at_map_rec *bam_next;
|
2002-08-14 01:12:27 +08:00
|
|
|
} backsql_at_map_rec;
|
|
|
|
|
2004-01-20 06:13:15 +08:00
|
|
|
#define BACKSQL_AT_MAP_REC_INIT { NULL, NULL, BER_BVC(""), BER_BVC(""), BER_BVNULL, BER_BVNULL, NULL, NULL, NULL, 0, 0, NULL }
|
|
|
|
|
|
|
|
/* define to uppercase filters only if the matching rule requires it
|
|
|
|
* (currently broken) */
|
|
|
|
/* #define BACKSQL_UPPERCASE_FILTER */
|
|
|
|
#define BACKSQL_AT_CANUPPERCASE(at) ((at)->bam_sel_expr_u.bv_val)
|
2004-01-10 18:42:44 +08:00
|
|
|
|
2002-08-14 01:12:27 +08:00
|
|
|
/* defines to support bitmasks above */
|
2002-08-17 00:45:24 +08:00
|
|
|
#define BACKSQL_ADD 0x1
|
|
|
|
#define BACKSQL_DEL 0x2
|
|
|
|
|
|
|
|
#define BACKSQL_IS_ADD(x) ( BACKSQL_ADD & (x) )
|
|
|
|
#define BACKSQL_IS_DEL(x) ( BACKSQL_DEL & (x) )
|
|
|
|
|
|
|
|
#define BACKSQL_NCMP(v1,v2) ber_bvcmp((v1),(v2))
|
2000-05-27 00:03:32 +08:00
|
|
|
|
2002-08-14 01:12:27 +08:00
|
|
|
int backsql_load_schema_map( backsql_info *si, SQLHDBC dbh );
|
2002-08-17 00:45:24 +08:00
|
|
|
/* Deprecated */
|
|
|
|
backsql_oc_map_rec *backsql_name2oc( backsql_info *si, struct berval *oc_name );
|
|
|
|
backsql_oc_map_rec *backsql_oc2oc( backsql_info *si, ObjectClass *oc );
|
|
|
|
backsql_oc_map_rec *backsql_id2oc( backsql_info *si, unsigned long id );
|
|
|
|
/* Deprecated */
|
|
|
|
backsql_at_map_rec *backsql_name2at( backsql_oc_map_rec *objclass,
|
|
|
|
struct berval *at_name );
|
|
|
|
backsql_at_map_rec *backsql_ad2at( backsql_oc_map_rec *objclass,
|
|
|
|
AttributeDescription *ad );
|
2004-01-18 00:27:11 +08:00
|
|
|
int backsql_supad2at( backsql_oc_map_rec *objclass,
|
|
|
|
AttributeDescription *supad, backsql_at_map_rec ***pret );
|
2002-08-14 01:12:27 +08:00
|
|
|
int backsql_destroy_schema_map( backsql_info *si );
|
2000-03-17 03:08:22 +08:00
|
|
|
|
2002-08-14 01:12:27 +08:00
|
|
|
#endif /* __BACKSQL_SCHEMA_MAP_H__ */
|
2001-09-07 21:04:11 +08:00
|
|
|
|