openldap/servers/slapd/back-sql/schema-map.h
Pierangelo Masarati 05348c5fc5 CHANGES:
- now all write operations appear to work correctly with PostgeSQL 7.0
- all write operations have been made transactional (atomic writes to
  entries are committed separately only in case of complete^1 success
  while all other operations are rolled-back by default)
- more cleanup and handling of exceptional conditions

TODO:
- deen to check with different databases and more up to date versions
  of both unixODBC and PostgreSQL.

^1: attribute add/modify/delete operations silently succeed if the
    appropriate add/delete proc does not exist for each attribute;
    this may be correct to hide undesired/unimplemented correspondence
    between LDAP and SQL databases; however, a more appropriate
    LDAP behavior would be a failure with LDAP_UNAVAILABLE if a
    single write operation cannot be executed for such reason
2002-08-16 16:45:24 +00:00

83 lines
2.7 KiB
C

#ifndef __BACKSQL_SCHEMA_MAP_H__
#define __BACKSQL_SCHEMA_MAP_H__
/*
* Copyright 1999, Dmitry Kovalev <mit@openldap.org>, All rights reserved.
*
* Redistribution and use in source and binary forms are permitted only
* as authorized by the OpenLDAP Public License. A copy of this
* license is available at http://www.OpenLDAP.org/license.html or
* in file LICENSE in the top-level directory of the distribution.
*/
typedef struct {
struct berval name;
ObjectClass *oc;
char *keytbl;
char *keycol;
/* expected to return keyval of newly created entry */
char *create_proc;
/* supposed to expect keyval as parameter and delete
* all the attributes as well */
char *delete_proc;
/* flags whether delete_proc is a function (whether back-sql
* should bind first parameter as output for return code) */
int expect_return;
unsigned long id;
Avlnode *attrs;
} backsql_oc_map_rec;
typedef struct {
/* literal name of corresponding LDAP attribute type */
struct berval name;
AttributeDescription *ad;
char *from_tbls;
char *join_where;
char *sel_expr;
/* supposed to expect 2 binded values: entry keyval
* and attr. value to add, like "add_name(?,?,?)" */
char *add_proc;
/* supposed to expect 2 binded values: entry keyval
* and attr. value to delete */
char *delete_proc;
/* for optimization purposes attribute load query
* is preconstructed from parts on schemamap load time */
char *query;
/* following flags are bitmasks (first bit used for add_proc,
* second - for modify, third - for delete_proc) */
/* order of parameters for procedures above;
* 1 means "data then keyval", 0 means "keyval then data" */
int param_order;
/* flags whether one or more of procedures is a function
* (whether back-sql should bind first parameter as output
* for return code) */
int expect_return;
/* TimesTen */
char *sel_expr_u;
} backsql_at_map_rec;
/* defines to support bitmasks above */
#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))
int backsql_load_schema_map( backsql_info *si, SQLHDBC dbh );
/* 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 );
int backsql_destroy_schema_map( backsql_info *si );
#endif /* __BACKSQL_SCHEMA_MAP_H__ */