If one is testing the sql backend functionality of openldap in connection with a MySQL Database, it is likely that slapd will not start. The following error can be observed when starting slapd with debugging enabled by using the -d 1 parameter:
backsql_load_schema_map(): error executing at_query:
Return code: -1
Native error code: 1054
SQL engine state: S0022
Message: [unixODBC][TCX][MyODBC]
Unknown column 'sel_expr_u' in 'field list'
==>backsql_free_db_conn()
backsql_free_db_conn(): closing db connection
This error appears as the MySQL Templates shipped with openldap 2.2 are broken and have been so for quite some time. :-(
The short workaround ist adding the sel_expr_u row to your ldap_attr_mappings table as follows:
ALTER TABLE `ldap_attr_mappings` ADD `sel_expr_u` VARCHAR( 255 ) AFTER `sel_expr` ;
However, there are more problems...
The easiest solution is to drop all tables and create them anew:
backsql_create.sql:
CREATE TABLE `ldap_attr_mappings` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`oc_map_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
`name` varchar(255) NOT NULL DEFAULT '',
`sel_expr` varchar(255) NOT NULL DEFAULT '',
`sel_expr_u` varchar(255) DEFAULT NULL,
`from_tbls` varchar(255) NOT NULL DEFAULT '',
`join_where` varchar(255) DEFAULT NULL,
`add_proc` varchar(255) NOT NULL DEFAULT '',
`delete_proc` varchar(255) NOT NULL DEFAULT '',
`param_order` int(11) NOT NULL DEFAULT '0',
`expect_return` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `ldap_entries` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`dn` varchar(255) NOT NULL DEFAULT '',
`oc_map_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
`parent` int(11) NOT NULL DEFAULT '0',
`keyval` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `unq1_ldap_entries` (`oc_map_id`,`keyval`),
UNIQUE KEY `unq2_ldap_entries` (`dn`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `ldap_entry_objclasses` (
`entry_id` int(11) NOT NULL DEFAULT '0',
`oc_name` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `ldap_oc_mappings` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(64) NOT NULL DEFAULT '',
`keytbl` varchar(64) NOT NULL DEFAULT '',
`keycol` varchar(64) NOT NULL DEFAULT '',
`create_proc` varchar(255) DEFAULT NULL,
`delete_proc` varchar(255) DEFAULT NULL,
`expect_return` tinyint(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `ldap_referrals` (
`entry_id` int(11) NOT NULL DEFAULT '0',
`url` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
test_create.sql:
CREATE TABLE `persons` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
`surname` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `institutes` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `documents` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL DEFAULT '',
`abstract` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `authors_docs` (
`pers_id` int(11) NOT NULL DEFAULT '0',
`doc_id` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`pers_id`,`doc_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `phones` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`phone` varchar(255) NOT NULL DEFAULT '',
`pers_id` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;