Back to index

openldap  2.4.31
back-ndb.h
Go to the documentation of this file.
00001 /* $OpenLDAP$ */
00002 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00003  *
00004  * Copyright 2008-2012 The OpenLDAP Foundation.
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted only as authorized by the OpenLDAP
00009  * Public License.
00010  *
00011  * A copy of this license is available in the file LICENSE in the
00012  * top-level directory of the distribution or, alternatively, at
00013  * <http://www.OpenLDAP.org/license.html>.
00014  */
00015 /* ACKNOWLEDGEMENTS:
00016  * This work was initially developed by Howard Chu for inclusion
00017  * in OpenLDAP Software. This work was sponsored by MySQL.
00018  */
00019 
00020 #ifndef SLAPD_NDB_H
00021 #define SLAPD_NDB_H
00022 
00023 #include "slap.h"
00024 
00025 #include <mysql.h>
00026 #include <NdbApi.hpp>
00027 
00028 LDAP_BEGIN_DECL
00029 
00030 /* The general design is to use one relational table per objectclass. This is
00031  * complicated by objectclass inheritance and auxiliary classes though.
00032  *
00033  * Attributes must only occur in a single table. For objectclasses that inherit
00034  * from other classes, attributes defined in the superior class are only stored
00035  * in the superior class' table. When multiple unrelated classes define the same
00036  * attributes, an attributeSet should be defined instead, containing all of the
00037  * common attributes.
00038  *
00039  * The no_set table lists which other attributeSets apply to the current
00040  * objectClass. The no_attrs table lists all of the non-inherited attributes of
00041  * the class, including those residing in an attributeSet.
00042  *
00043  * Usually the table is named identically to the objectClass, but it can also
00044  * be explicitly named something else if needed.
00045  */
00046 #define NDB_MAX_OCSETS      8
00047 
00048 struct ndb_attrinfo;
00049 
00050 typedef struct ndb_ocinfo {
00051        struct berval no_name;      /* objectclass cname */
00052        struct berval no_table;
00053        ObjectClass *no_oc;
00054        struct ndb_ocinfo *no_sets[NDB_MAX_OCSETS];
00055        struct ndb_attrinfo **no_attrs;
00056        int no_flag;
00057        int no_nsets;
00058        int no_nattrs;
00059 } NdbOcInfo;
00060 
00061 #define       NDB_INFO_ATLEN       0x01
00062 #define       NDB_INFO_ATSET       0x02
00063 #define       NDB_INFO_INDEX       0x04
00064 #define       NDB_INFO_ATBLOB      0x08
00065 
00066 typedef struct ndb_attrinfo {
00067        struct berval na_name;      /* attribute cname */
00068        AttributeDescription *na_desc;
00069        AttributeType *na_attr;
00070        NdbOcInfo *na_oi;
00071        int na_flag;
00072        int na_len;
00073        int na_column;
00074        int na_ixcol;
00075 } NdbAttrInfo;
00076 
00077 typedef struct ListNode {
00078        struct ListNode *ln_next;
00079        void *ln_data;
00080 } ListNode;
00081 
00082 #define       NDB_IS_OPEN(ni)      (ni->ni_cluster != NULL)
00083 
00084 struct ndb_info {
00085        /* NDB connection */
00086        char *ni_connectstr;
00087        char *ni_dbname;
00088        Ndb_cluster_connection **ni_cluster;
00089 
00090        /* MySQL connection parameters */
00091        MYSQL ni_sql;
00092        char *ni_hostname;
00093        char *ni_username;
00094        char *ni_password;
00095        char *ni_socket;
00096        unsigned long ni_clflag;
00097        unsigned int ni_port;
00098 
00099        /* Search filter processing */
00100        int ni_search_stack_depth;
00101        void *ni_search_stack;
00102 
00103 #define       DEFAULT_SEARCH_STACK_DEPTH  16
00104 #define       MINIMUM_SEARCH_STACK_DEPTH  8
00105 
00106        /* Schema config */
00107        NdbOcInfo *ni_opattrs;
00108        ListNode *ni_attridxs;
00109        ListNode *ni_attrlens;
00110        ListNode *ni_attrsets;
00111        ListNode *ni_attrblobs;
00112        ldap_pvt_thread_rdwr_t ni_ai_rwlock;
00113        Avlnode *ni_ai_tree;
00114        ldap_pvt_thread_rdwr_t ni_oc_rwlock;
00115        Avlnode *ni_oc_tree;
00116        int ni_nconns;       /* number of connections to open */
00117        int ni_nextconn;     /* next conn to use */
00118        ldap_pvt_thread_mutex_t ni_conn_mutex;
00119 };
00120 
00121 #define       NDB_MAX_RDNS  16
00122 #define       NDB_RDN_LEN   128
00123 #define       NDB_MAX_OCS   64
00124 
00125 #define       DN2ID_TABLE   "OL_dn2id"
00126 #define       EID_COLUMN    0U
00127 #define       VID_COLUMN    1U
00128 #define       OCS_COLUMN    1U
00129 #define       RDN_COLUMN    2U
00130 #define       IDX_COLUMN    (2U+NDB_MAX_RDNS)
00131 
00132 #define       NEXTID_TABLE  "OL_nextid"
00133 
00134 #define       NDB_OC_BUFLEN 1026   /* 1024 data plus 2 len bytes */
00135 
00136 #define       INDEX_NAME    "OL_index"
00137 
00138 typedef struct NdbRdns {
00139        short nr_num;
00140        char nr_buf[NDB_MAX_RDNS][NDB_RDN_LEN+1];
00141 } NdbRdns;
00142 
00143 typedef struct NdbOcs {
00144        int no_ninfo;
00145        int no_ntext;
00146        int no_nitext;       /* number of implicit classes */
00147        NdbOcInfo *no_info[NDB_MAX_OCS];
00148        struct berval no_text[NDB_MAX_OCS];
00149        struct berval no_itext[NDB_MAX_OCS];      /* implicit classes */
00150 } NdbOcs;
00151 
00152 typedef struct NdbArgs {
00153        Ndb *ndb;
00154        NdbTransaction *txn;
00155        Entry *e;
00156        NdbRdns *rdns;
00157        struct berval *ocs;
00158        int erdns;
00159 } NdbArgs;
00160 
00161 #define       NDB_NO_SUCH_OBJECT   626
00162 #define       NDB_ALREADY_EXISTS   630
00163 
00164 LDAP_END_DECL
00165 
00166 #include "proto-ndb.h"
00167 
00168 #endif