]> git.sur5r.net Git - openldap/commitdiff
remove all referral specific code; now referrals can be used by defining appropriate...
authorPierangelo Masarati <ando@openldap.org>
Wed, 19 Jan 2005 00:00:52 +0000 (00:00 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 19 Jan 2005 00:00:52 +0000 (00:00 +0000)
15 files changed:
servers/slapd/back-sql/back-sql.h
servers/slapd/back-sql/config.c
servers/slapd/back-sql/delete.c
servers/slapd/back-sql/init.c
servers/slapd/back-sql/proto-sql.h
servers/slapd/back-sql/rdbms_depend/mysql/backsql_create.sql
servers/slapd/back-sql/rdbms_depend/mysql/testdb_create.sql
servers/slapd/back-sql/rdbms_depend/mysql/testdb_data.sql
servers/slapd/back-sql/rdbms_depend/mysql/testdb_metadata.sql
servers/slapd/back-sql/rdbms_depend/pgsql/backsql_create.sql
servers/slapd/back-sql/rdbms_depend/pgsql/testdb_create.sql
servers/slapd/back-sql/rdbms_depend/pgsql/testdb_data.sql
servers/slapd/back-sql/rdbms_depend/pgsql/testdb_metadata.sql
servers/slapd/back-sql/schema-map.c
servers/slapd/back-sql/util.c

index 6943160b09c840d5e1207709420a79ba3ee89024..80794716864cf1707d6fd5f8f53958bc37657700 100644 (file)
@@ -480,8 +480,7 @@ typedef struct backsql_info {
        char            *sql_insentry_stmt,
                        *sql_delentry_stmt,
                        *sql_renentry_stmt,
-                       *sql_delobjclasses_stmt,
-                       *sql_delreferrals_stmt;
+                       *sql_delobjclasses_stmt;
        char            *sql_id_query;
        char            *sql_has_children_query;
 
index 51d50e6a6a5bf201979ad8ef0f8a949c2ff6303b..9e82f0b3584fc15945b19c07e122a20cf347eef9 100644 (file)
@@ -321,21 +321,6 @@ backsql_db_config(
                Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
                        "delobjclasses_stmt=%s\n", bi->sql_delobjclasses_stmt, 0, 0 );
 
-       } else if ( !strcasecmp( argv[ 0 ], "delreferrals_stmt" ) ||
-                       !strcasecmp( argv[ 0 ], "delreferrals_query" ) )
-       {
-               if ( argc < 2 ) {
-                       Debug( LDAP_DEBUG_TRACE,
-                               "<==backsql_db_config (%s line %d): "
-                               "missing SQL statement "
-                               "in \"delreferrals_stmt\" directive\n",
-                               fname, lineno, 0 );
-                       return 1;
-               }
-               bi->sql_delreferrals_stmt = ch_strdup( argv[ 1 ] );
-               Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
-                       "delreferrals_stmt=%s\n", bi->sql_delreferrals_stmt, 0, 0 );
-
        } else if ( !strcasecmp( argv[ 0 ], "has_ldapinfo_dn_ru") ) {
                if ( argc < 2 ) {
                        Debug( LDAP_DEBUG_TRACE,
index e094fb58424f4b112a3262fc1cac39678ad36b6f..35648c5f9e67ddd135d8712a7ba9022c860f7c7f 100644 (file)
@@ -385,59 +385,6 @@ backsql_delete( Operation *op, SlapReply *rs )
        }
        SQLFreeStmt( sth, SQL_DROP );
 
-       /* delete referrals, if any... */
-       rc = backsql_Prepare( dbh, &sth, bi->sql_delreferrals_stmt, 0 );
-       if ( rc != SQL_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE,
-                       "   backsql_delete(): "
-                       "error preparing ldap_referrals delete query\n", 
-                       0, 0, 0 );
-               backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc );
-
-               rs->sr_err = LDAP_OTHER;
-               rs->sr_text = "SQL-backend error";
-               e = NULL;
-               goto done;
-       }
-
-       rc = backsql_BindParamID( sth, 1, SQL_PARAM_INPUT, &e_id.eid_id );
-       if ( rc != SQL_SUCCESS ) {
-               Debug( LDAP_DEBUG_TRACE,
-                       "   backsql_delete(): "
-                       "error binding referrals entry ID parameter "
-                       "for objectClass %s\n",
-                       oc->bom_oc->soc_cname.bv_val, 0, 0 );
-               backsql_PrintErrors( bi->sql_db_env, dbh, 
-                       sth, rc );
-               SQLFreeStmt( sth, SQL_DROP );
-
-               rs->sr_text = "SQL-backend error";
-               rs->sr_err = LDAP_OTHER;
-               e = NULL;
-               goto done;
-       }
-
-       rc = SQLExecute( sth );
-       switch ( rc ) {
-       case SQL_NO_DATA:
-               /* apparently there were no referrals
-                * for this entry... */
-       case SQL_SUCCESS:
-               break;
-
-       default:
-               Debug( LDAP_DEBUG_TRACE, "   backsql_delete(): "
-                       "failed to delete record from ldap_referrals\n", 
-                       0, 0, 0 );
-               backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc );
-               SQLFreeStmt( sth, SQL_DROP );
-               rs->sr_err = LDAP_OTHER;
-               rs->sr_text = "SQL-backend error";
-               e = NULL;
-               goto done;
-       }
-       SQLFreeStmt( sth, SQL_DROP );
-
        /* delete entry... */
        rc = backsql_Prepare( dbh, &sth, bi->sql_delentry_stmt, 0 );
        if ( rc != SQL_SUCCESS ) {
index 11aa1ffd38327e72a76cb7dbfde25923f59fa17e..f78b0c7627a14ea95f8253ada8f9f28d460e05b8 100644 (file)
@@ -145,7 +145,6 @@ backsql_db_destroy(
        free( bi->sql_delentry_stmt );
        free( bi->sql_renentry_stmt );
        free( bi->sql_delobjclasses_stmt );
-       free( bi->sql_delreferrals_stmt );
 
        if ( bi->sql_anlist ) {
                int     i;
@@ -404,17 +403,6 @@ backsql_db_open(
                bi->sql_delobjclasses_stmt = ch_strdup( backsql_def_delobjclasses_stmt );
        }
 
-       if ( bi->sql_delreferrals_stmt == NULL ) {
-               Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): "
-                       "referrals deletion SQL statement not specified "
-                       "(use \"delreferrals_stmt\" directive in slapd.conf)\n",
-                       0, 0, 0 );
-               Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): "
-                       "setting \"%s\" by default\n",
-                       backsql_def_delreferrals_stmt, 0, 0 );
-               bi->sql_delreferrals_stmt = ch_strdup( backsql_def_delreferrals_stmt );
-       }
-
        op->o_hdr = (Opheader *)&op[ 1 ];
        op->o_connid = (unsigned long)(-1);
        op->o_bd = bd;
index f0a8237f9f2983678e2705be3cbb56080660a94e..8019284223d1e0e0712fcc321fbfe705c86273c4 100644 (file)
@@ -227,7 +227,6 @@ extern char
        backsql_def_renentry_stmt[],
        backsql_def_insentry_stmt[],
        backsql_def_delobjclasses_stmt[],
-       backsql_def_delreferrals_stmt[],
        backsql_def_subtree_cond[],
        backsql_def_upper_subtree_cond[],
        backsql_id_query[],
index b39df23abdc82485ecbe508e3087669b66939d69..771c1c88bf9118278fa0c24a364a1a726c9402e0 100644 (file)
@@ -49,13 +49,6 @@ alter table ldap_entries add
                dn
        );  
 
-drop table if exists ldap_referrals;
-create table ldap_referrals
- (
-       entry_id integer not null references ldap_entries(id),
-       url text not null
-);
-
 drop table if exists ldap_entry_objclasses;
 create table ldap_entry_objclasses
  (
index b4f96261dd82738ee61afab1bb988b5eb89ef5a2..3c6b71e8b066735d73280127a88249c96e82f58b 100644 (file)
@@ -69,6 +69,7 @@ ALTER TABLE phones  ADD
 drop table if exists referrals;
 CREATE TABLE referrals (
        id int NOT NULL,
-       name varchar(255) NOT NULL
+       name varchar(255) NOT NULL,
+       url varchar(255) NOT NULL
 );
 
index 2084a187954863250f84c7436e64cff573ff87e8..c204ecd8ce78958c5b9802313fd529abb05d3cb6 100644 (file)
@@ -15,4 +15,4 @@ insert into authors_docs (pers_id,doc_id) values (1,1);
 insert into authors_docs (pers_id,doc_id) values (1,2);
 insert into authors_docs (pers_id,doc_id) values (2,1);
 
-insert into referrals (id,name) values (1,'Referral');
+insert into referrals (id,name,url) values (1,'Referral','ldap://localhost:9010/');
index 2857ee656521aae2125943b52f9636db9c29d126..1606600fe994dd4e55a49a231f18308219fbe732 100644 (file)
@@ -77,6 +77,9 @@ values (12,3,'dc','lower(institutes.name)','institutes,ldap_entries AS dcObject,
 insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
 values (13,4,'ou','referrals.name','referrals',NULL,NULL,NULL,3,0);
 
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
+values (14,4,'ref','referrals.url','referrals',NULL,NULL,NULL,3,0);
+
 -- entries mapping: each entry must appear in this table, with a unique DN rooted at the database naming context
 --     id              a unique number > 0 identifying the entry
 --     dn              the DN of the entry, in "pretty" form
@@ -113,9 +116,3 @@ values (1,'dcObject');
 insert into ldap_entry_objclasses (entry_id,oc_name)
 values (7,'extensibleObject');
 
--- referrals mapping: entries that should be treated as referrals are stored here
---     entry_id        the "ldap_entries.id" of the entry that should be treated as a referral
---     url             the URI of the referral
-insert into ldap_referrals (entry_id,url)
-values (7,'ldap://localhost:9010/');
-
index 65aea733cb596f86d3bcc3e36024eef2b7a954fd..a4baa7040018877021b89703bd249d9804476891 100644 (file)
@@ -41,13 +41,6 @@ create table ldap_entries
        UNIQUE ( dn )
 );
 
-drop table ldap_referrals;
-create table ldap_referrals
- (
-       entry_id integer not null references ldap_entries(id),
-       url text not null
-);
-
 drop table ldap_entry_objclasses;
 create table ldap_entry_objclasses
  (
index 30a7378fe4ade6c97066e675bc12ee4d383401f0..0142dd9b15a1c3e8a6cf1f6234938ef8d5eaab9d 100644 (file)
@@ -41,6 +41,7 @@ drop table referrals;
 drop sequence referrals_id_seq;
 create table referrals (
        id serial not null primary key,
-       name varchar(255) not null
+       name varchar(255) not null,
+       url varchar(255) not null
 );
 
index 2084a187954863250f84c7436e64cff573ff87e8..c204ecd8ce78958c5b9802313fd529abb05d3cb6 100644 (file)
@@ -15,4 +15,4 @@ insert into authors_docs (pers_id,doc_id) values (1,1);
 insert into authors_docs (pers_id,doc_id) values (1,2);
 insert into authors_docs (pers_id,doc_id) values (2,1);
 
-insert into referrals (id,name) values (1,'Referral');
+insert into referrals (id,name,url) values (1,'Referral','ldap://localhost:9010/');
index 66d783f6cc0d644df88494160d414330d41d08a0..4afea62502df036e7d121355e6cec86bfa76ecc3 100644 (file)
@@ -53,6 +53,8 @@ insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,
 
 insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (13,4,'ou','referrals.name','referrals',NULL,'UPDATE referrals SET name=? WHERE id=?',NULL,3,0);
 
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (14,4,'ref','referrals.url','referrals',NULL,'UPDATE referrals SET url=? WHERE id=?',NULL,3,0);
+
 -- entries mapping: each entry must appear in this table, with a unique DN rooted at the database naming context
 --     id              a unique number > 0 identifying the entry
 --     dn              the DN of the entry, in "pretty" form
@@ -80,11 +82,6 @@ insert into ldap_entry_objclasses (entry_id,oc_name) values (1,'dcObject');
 
 insert into ldap_entry_objclasses (entry_id,oc_name) values (7,'extensibleObject');
 
--- referrals mapping: entries that should be treated as referrals are stored here
---     entry_id        the "ldap_entries.id" of the entry that should be treated as a referral
---     url             the URI of the referral
-insert into ldap_referrals (entry_id,url) values (7,'ldap://localhost:9010/');
-
 -- procedures
 -- these procedures are specific for this RDBMS and are used in mapping objectClass and attributeType creation/modify/deletion
 create function create_person () returns int
@@ -138,7 +135,7 @@ as '
 create function create_referral () returns int
 as '
        select setval (''referrals_id_seq'', (select case when max(id) is null then 1 else max(id) end from referrals));
-       insert into referrals (id,name,surname
+       insert into referrals (id,name,url
                values ((select case when max(id) is null then 1 else nextval(''referrals_id_seq'') end from referrals),'''','''');
        select max(id) from referrals
 ' language 'sql';
index 618daf5d33cf630ff434a89741e36a6cf2b7d845..7d7be83a8f311bff975ea17b8e430fee9640865a 100644 (file)
@@ -190,8 +190,7 @@ backsql_add_sysmaps( backsql_oc_map_rec *oc_map )
        struct berbuf           bb;
        
        sbv.bv_val = s;
-       snprintf( s, sizeof( s ), "%ld", oc_map->bom_id );
-       sbv.bv_len = strlen( s );
+       sbv.bv_len = snprintf( s, sizeof( s ), "%ld", oc_map->bom_id );
 
        /* extra objectClasses */
        at_map = (backsql_at_map_rec *)ch_calloc(1, 
@@ -285,81 +284,6 @@ backsql_add_sysmaps( backsql_oc_map_rec *oc_map )
                        &sbv );
        at_map->bam_join_where = bb.bb_val;
 
-       /* referral attribute */
-       at_map = (backsql_at_map_rec *)ch_calloc( 1, 
-                       sizeof( backsql_at_map_rec ) );
-       at_map->bam_ad = slap_schema.si_ad_ref;
-       ber_str2bv( "ldap_referrals.url", 0, 1, &at_map->bam_sel_expr );
-       ber_str2bv( "ldap_referrals,ldap_entries", 0, 1, &at_map->bam_from_tbls );
-
-       bb.bb_len = at_map->bam_from_tbls.bv_len + 1;
-       bb.bb_val = at_map->bam_from_tbls;
-       backsql_merge_from_clause( &bb, &oc_map->bom_keytbl );
-       at_map->bam_from_tbls = bb.bb_val;
-
-       BER_BVZERO( &bb.bb_val );
-       bb.bb_len = 0;
-       backsql_strfcat( &bb, "lbcblb",
-                       (ber_len_t)STRLENOF( "ldap_entries.id=ldap_referrals.entry_id AND ldap_entries.keyval=" ),
-                               "ldap_entries.id=ldap_referrals.entry_id AND ldap_entries.keyval=",
-                       &oc_map->bom_keytbl, 
-                       '.', 
-                       &oc_map->bom_keycol,
-                       (ber_len_t)STRLENOF( " AND ldap_entries.oc_map_id=" ), 
-                               " AND ldap_entries.oc_map_id=", 
-                       &sbv );
-
-       at_map->bam_join_where = bb.bb_val;
-
-       at_map->bam_oc = NULL;
-
-       at_map->bam_add_proc = NULL;
-       {
-               char    tmp[] =
-                       "INSERT INTO ldap_referrals "
-                       "(entry_id,url) VALUES "
-                       "((SELECT id FROM ldap_entries "
-                       "WHERE oc_map_id="
-                       "18446744073709551615UL "       /* 64 bit ULONG */
-                       "AND keyval=?),?)";
-               snprintf( tmp, sizeof(tmp), 
-                       "INSERT INTO ldap_referrals "
-                       "(entry_id,url) VALUES "
-                       "((SELECT id FROM ldap_entries "
-                       "WHERE oc_map_id=%lu "
-                       "AND keyval=?),?)", oc_map->bom_id );
-               at_map->bam_add_proc = ch_strdup( tmp );
-       }
-
-       at_map->bam_delete_proc = NULL;
-       {
-               char    tmp[] =
-                       "DELETE FROM ldap_referrals "
-                       "WHERE entry_id=(SELECT id FROM ldap_entries "
-                       "WHERE oc_map_id="
-                       "18446744073709551615UL "       /* 64 bit ULONG */
-                       "AND keyval=?) and url=?";
-               snprintf( tmp, sizeof(tmp), 
-                       "DELETE FROM ldap_referrals "
-                       "WHERE entry_id=(SELECT id FROM ldap_entries "
-                       "WHERE oc_map_id=%lu"
-                       "AND keyval=?) and url=?",
-                       oc_map->bom_id );
-               at_map->bam_delete_proc = ch_strdup( tmp );
-       }
-
-       at_map->bam_param_order = 0;
-       at_map->bam_expect_return = 0;
-       at_map->bam_next = NULL;
-
-       backsql_make_attr_query( oc_map, at_map );
-       if ( avl_insert( &oc_map->bom_attrs, at_map, backsql_cmp_attr, backsql_dup_attr ) == BACKSQL_DUPLICATE ) {
-               Debug( LDAP_DEBUG_TRACE, "backsql_add_sysmaps(): "
-                               "duplicate attribute \"%s\" in objectClass \"%s\" map\n",
-                               at_map->bam_ad->ad_cname.bv_val,
-                               oc_map->bom_oc->soc_cname.bv_val, 0 );
-       }
-
        return 1;
 }
 
index 0b971b024176ddd102e59e4e5fa91247b639a724..641abc7eb1829c74708d386396057164c981eda8 100644 (file)
@@ -55,8 +55,6 @@ char backsql_def_insentry_stmt[] =
        "VALUES (?,?,?,?)";
 char backsql_def_delobjclasses_stmt[] = "DELETE FROM ldap_entry_objclasses "
        "WHERE entry_id=?";
-char backsql_def_delreferrals_stmt[] = "DELETE FROM ldap_referrals "
-       "WHERE entry_id=?";
 char backsql_def_subtree_cond[] = "ldap_entries.dn LIKE CONCAT('%',?)";
 char backsql_def_upper_subtree_cond[] = "(ldap_entries.dn) LIKE CONCAT('%',?)";
 char backsql_id_query[] = "SELECT id,keyval,oc_map_id,dn FROM ldap_entries WHERE ";