Example additions for MySQL 5
These additions do NOT handle deletions, however they provide a much better starting point. They are based on the testdb and back_sql files shipped with 2.3.11. No table changes were made to the provided tables, however several functions have been added:
INSERT INTO `ldap_attr_mappings` (`id`, `oc_map_id`, `name`, `sel_expr`, `sel_expr_u`, `from_tbls`, `join_where`, `add_proc`, `delete_proc`, `param_order`, `expect_return`) VALUES (1,1,'cn','concat(persons.name,\' \',persons.surname)',NULL,'persons',NULL,NULL,NULL,3,0),
(2,1,'telephoneNumber','phones.phone',NULL,'persons,phones','phones.pers_id=persons.id','insert into phones (id,phone,pers_id) values (newphone(),?,?)',NULL,3,0),
(3,1,'givenName','persons.name',NULL,'persons',NULL,'update persons set name=? where id=?',NULL,3,0),
(4,1,'sn','persons.surname',NULL,'persons',NULL,'update persons set surname=? where id=?',NULL,3,0),
(5,1,'userPassword','persons.password',NULL,'persons','persons.password IS NOT NULL','update persons set password=? where id=?',NULL,3,0),
(6,1,'seeAlso','seeAlso.dn',NULL,'ldap_entries AS seeAlso,documents,authors_docs,persons','seeAlso.keyval=documents.id AND seeAlso.oc_map_id=2 AND authors_docs.doc_id=documents.id AND authors_docs.pers_id=persons.id',NULL,NULL,3,0);
INSERT INTO `ldap_oc_mappings` (`id`, `name`, `keytbl`, `keycol`, `create_proc`, `delete_proc`, `expect_return`) VALUES (1,'inetOrgPerson','persons','id','select newperson();',NULL,0),(2,'document','documents','id','select max(id)+1 from ldap_entries;',NULL,0),(3,'organization','institutes','id','select max(id)+1
from ldap_entries;',NULL,0),(4,'referral','referrals','id','select max(id)+1 from ldap_entries;',NULL,0);
DELIMITER ;;
DROP FUNCTION IF EXISTS `newperson` ;;
SET SESSION SQL_MODE="";;
CREATE FUNCTION `newperson`() RETURNS int(11)
DETERMINISTIC
BEGIN
DECLARE newkey integer(11);
select max(id)+1 into newkey from persons;
insert into persons (id) values (newkey);
RETURN newkey;
END ;;
SET SESSION SQL_MODE=@OLD_SQL_MODE;;
DROP FUNCTION IF EXISTS `newphone` ;;
SET SESSION SQL_MODE="";;
CREATE FUNCTION `newphone`() RETURNS int(11)
DETERMINISTIC
BEGIN
DECLARE newkey integer(11);
select max(id)+1 into newkey from phones;
RETURN newkey;
END ;;
DELIMITER ;
dpinkard@accessline.com, ando@sys-net.it |