Commit f5de8af2 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Sync with HEAD

Ready for release
parent cd78e968
......@@ -15,9 +15,9 @@
ol_package=OpenLDAP
ol_major=2
ol_minor=3
ol_patch=X
ol_patch=4
ol_api_inc=20303
ol_api_current=0
ol_api_revision=3
ol_api_age=0
ol_release_date="2005/05/10"
ol_release_date="2005/06/10"
......@@ -207,7 +207,6 @@ is builtin in back-sql; see macro
is set to 8192).
This is \fIexperimental\fP and may change in future releases.
.TP
.TP
.B strcast_func <SQL function name>
Specifies the name of a function that converts a given value to a string
......@@ -216,6 +215,7 @@ for strongly typed RDBMSes with little implicit casting (like PostgreSQL),
when a literal string is specified.
This is \fIexperimental\fP and may change in future releases.
.TP
.B concat_pattern <pattern>
This statement defines the
.B pattern
......@@ -235,6 +235,17 @@ Carefully check the documentation of your RDBMS or stay with the examples
for supported ones.
This is \fIexperimental\fP and may change in future releases.
.TP
.B aliasing_keyword <string>
Define the aliasing keyword. Some RDBMSes use the word "\fIAS\fP"
(the default), others don't use any.
.TP
.B aliasing_quote <string>
Define the quoting char of the aliasing keyword. Some RDBMSes
don't require any (the default), others may require single
or double quotes.
.TP
.B has_ldapinfo_dn_ru { NO | yes }
Explicitly inform the backend whether the dn_ru column
......
......@@ -493,6 +493,10 @@ typedef struct backsql_info {
BerVarray sql_concat_func;
struct berval sql_strcast_func;
struct berval sql_aliasing;
struct berval sql_aliasing_quote;
struct berval sql_dn_oc_aliasing;
AttributeName *sql_anlist;
unsigned int sql_flags;
......
......@@ -321,7 +321,7 @@ 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 ], "has_ldapinfo_dn_ru") ) {
} else if ( !strcasecmp( argv[ 0 ], "has_ldapinfo_dn_ru" ) ) {
if ( argc < 2 ) {
Debug( LDAP_DEBUG_TRACE,
"<==backsql_db_config (%s line %d): "
......@@ -352,7 +352,7 @@ backsql_db_config(
"has_ldapinfo_dn_ru=%s\n",
BACKSQL_HAS_LDAPINFO_DN_RU( bi ) ? "yes" : "no", 0, 0 );
} else if ( !strcasecmp( argv[ 0 ], "fail_if_no_mapping") ) {
} else if ( !strcasecmp( argv[ 0 ], "fail_if_no_mapping" ) ) {
if ( argc < 2 ) {
Debug( LDAP_DEBUG_TRACE,
"<==backsql_db_config (%s line %d): "
......@@ -381,7 +381,7 @@ backsql_db_config(
"fail_if_no_mapping=%s\n",
BACKSQL_FAIL_IF_NO_MAPPING( bi ) ? "yes" : "no", 0, 0 );
} else if ( !strcasecmp( argv[ 0 ], "allow_orphans") ) {
} else if ( !strcasecmp( argv[ 0 ], "allow_orphans" ) ) {
if ( argc < 2 ) {
Debug( LDAP_DEBUG_TRACE,
"<==backsql_db_config (%s line %d): "
......@@ -443,7 +443,7 @@ backsql_db_config(
return 1;
}
} else if ( !strcasecmp( argv[ 0 ], "sqllayer") ) {
} else if ( !strcasecmp( argv[ 0 ], "sqllayer" ) ) {
if ( backsql_api_config( bi, argv[ 1 ], argc - 2, &argv[ 2 ] ) )
{
Debug( LDAP_DEBUG_TRACE,
......@@ -466,7 +466,7 @@ backsql_db_config(
Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
"id_query=%s\n", bi->sql_id_query, 0, 0 );
} else if ( !strcasecmp( argv[ 0 ], "use_subtree_shortcut") ) {
} else if ( !strcasecmp( argv[ 0 ], "use_subtree_shortcut" ) ) {
if ( argc < 2 ) {
Debug( LDAP_DEBUG_TRACE,
"<==backsql_db_config (%s line %d): "
......@@ -496,7 +496,7 @@ backsql_db_config(
BACKSQL_USE_SUBTREE_SHORTCUT( bi ) ? "yes" : "no",
0, 0 );
} else if ( !strcasecmp( argv[ 0 ], "fetch_all_attrs") ) {
} else if ( !strcasecmp( argv[ 0 ], "fetch_all_attrs" ) ) {
if ( argc < 2 ) {
Debug( LDAP_DEBUG_TRACE,
"<==backsql_db_config (%s line %d): "
......@@ -526,7 +526,7 @@ backsql_db_config(
BACKSQL_FETCH_ALL_ATTRS( bi ) ? "yes" : "no",
0, 0 );
} else if ( !strcasecmp( argv[ 0 ], "fetch_attrs") ) {
} else if ( !strcasecmp( argv[ 0 ], "fetch_attrs" ) ) {
char *str, *s, *next;
char delimstr[] = ",";
......@@ -561,8 +561,8 @@ backsql_db_config(
return -1;
}
} else if ( !strcasecmp( argv[ 0 ], "check_schema") ) {
if ( argc < 2 ) {
} else if ( !strcasecmp( argv[ 0 ], "check_schema" ) ) {
if ( argc != 2 ) {
Debug( LDAP_DEBUG_TRACE,
"<==backsql_db_config (%s line %d): "
"missing { yes | no }"
......@@ -591,6 +591,41 @@ backsql_db_config(
BACKSQL_CHECK_SCHEMA( bi ) ? "yes" : "no",
0, 0 );
} else if ( !strcasecmp( argv[ 0 ], "aliasing_keyword" ) ) {
if ( argc != 2 ) {
Debug( LDAP_DEBUG_TRACE,
"<==backsql_db_config (%s line %d): "
"missing arg "
"in \"aliasing_keyword <string>\" directive\n",
fname, lineno, 0 );
return 1;
}
if ( ! BER_BVISNULL( &bi->sql_aliasing ) ) {
ch_free( bi->sql_aliasing.bv_val );
}
ber_str2bv( argv[ 1 ], strlen( argv[ 1 ] ) + 1, 1,
&bi->sql_aliasing );
/* add a trailing space... */
bi->sql_aliasing.bv_val[ bi->sql_aliasing.bv_len - 1] = ' ';
} else if ( !strcasecmp( argv[ 0 ], "aliasing_quote" ) ) {
if ( argc != 2 ) {
Debug( LDAP_DEBUG_TRACE,
"<==backsql_db_config (%s line %d): "
"missing arg "
"in \"aliasing_quote <string>\" directive\n",
fname, lineno, 0 );
return 1;
}
if ( ! BER_BVISNULL( &bi->sql_aliasing_quote ) ) {
ch_free( bi->sql_aliasing_quote.bv_val );
}
ber_str2bv( argv[ 1 ], 0, 1, &bi->sql_aliasing_quote );
} else {
return SLAP_CONF_UNKNOWN;
}
......
......@@ -147,6 +147,9 @@ backsql_db_destroy(
free( bi->sql_renentry_stmt );
free( bi->sql_delobjclasses_stmt );
free( bi->sql_aliasing.bv_val );
free( bi->sql_aliasing_quote.bv_val );
if ( bi->sql_anlist ) {
int i;
......@@ -201,6 +204,21 @@ backsql_db_open(
}
}
/*
* see back-sql.h for default values
*/
if ( BER_BVISNULL( &bi->sql_aliasing ) ) {
ber_str2bv( BACKSQL_ALIASING,
STRLENOF( BACKSQL_ALIASING ),
1, &bi->sql_aliasing );
}
if ( BER_BVISNULL( &bi->sql_aliasing_quote ) ) {
ber_str2bv( BACKSQL_ALIASING_QUOTE,
STRLENOF( BACKSQL_ALIASING_QUOTE ),
1, &bi->sql_aliasing_quote );
}
/*
* Prepare cast string as required
*/
......@@ -445,21 +463,31 @@ backsql_db_open(
bi->sql_id_query = bb.bb_val.bv_val;
}
/*
/*
* Prepare children ID selection query
*/
bi->sql_has_children_query = NULL;
bb.bb_val.bv_val = NULL;
bb.bb_val.bv_len = 0;
BER_BVZERO( &bb.bb_val );
bb.bb_len = 0;
backsql_strfcat( &bb, "sb",
backsql_strfcat( &bb, "sbsb",
"SELECT COUNT(distinct subordinates.id) "
"FROM ldap_entries,ldap_entries " BACKSQL_ALIASING "subordinates "
"FROM ldap_entries,ldap_entries ",
&bi->sql_aliasing, "subordinates "
"WHERE subordinates.parent=ldap_entries.id AND ",
&bi->sql_children_cond );
bi->sql_has_children_query = bb.bb_val.bv_val;
/*
* Prepare DN and objectClass aliasing bit of query
*/
BER_BVZERO( &bb.bb_val );
bb.bb_len = 0;
backsql_strfcat( &bb, "sbbsbsbbsb",
" ", &bi->sql_aliasing, &bi->sql_aliasing_quote,
"objectClass", &bi->sql_aliasing_quote,
",ldap_entries.dn ", &bi->sql_aliasing,
&bi->sql_aliasing_quote, "dn", &bi->sql_aliasing_quote );
bi->sql_dn_oc_aliasing = bb.bb_val;
backsql_free_db_conn( op );
if ( !BACKSQL_SCHEMA_LOADED( bi ) ) {
Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): "
......@@ -475,6 +503,7 @@ backsql_db_open(
/* enable if only one suffix is defined */
bi->sql_flags |= BSQLF_USE_SUBTREE_SHORTCUT;
}
bi->sql_flags |= BSQLF_CHECK_SCHEMA;
Debug( LDAP_DEBUG_TRACE, "<==backsql_db_open(): "
......
......@@ -242,7 +242,7 @@ struct berbuf * backsql_strfcat( struct berbuf *dest, const char *fmt, ... );
int backsql_entry_addattr( Entry *e, AttributeDescription *ad,
struct berval *at_val, void *memctx );
int backsql_merge_from_clause( struct berbuf *dest_from,
int backsql_merge_from_clause( backsql_info *bi, struct berbuf *dest_from,
struct berval *src_from );
int backsql_split_pattern( const char *pattern, BerVarray *split_pattern,
......
......@@ -120,7 +120,7 @@ example=> <control-D>
3.1.5) Run the test:
[root@localhost]# cd $SOURCES/tests
[root@localhost]# SLAPD_USE_SQL=postgres ./run test031
[root@localhost]# SLAPD_USE_SQL=pgsql ./run test031
3.2) MySQL
......
......@@ -100,19 +100,21 @@ backsql_dup_attr( void *v_m1, void *v_m2 )
static int
backsql_make_attr_query(
backsql_info *bi,
backsql_oc_map_rec *oc_map,
backsql_at_map_rec *at_map )
{
struct berbuf bb = BB_NULL;
backsql_strfcat( &bb, "lblblblbcbl",
backsql_strfcat( &bb, "lblbbbblblbcbl",
(ber_len_t)STRLENOF( "SELECT " ), "SELECT ",
&at_map->bam_sel_expr,
(ber_len_t)STRLENOF( " " BACKSQL_ALIASING BACKSQL_ALIASING_QUOTE ),
" " BACKSQL_ALIASING BACKSQL_ALIASING_QUOTE,
(ber_len_t)STRLENOF( " " ), " ",
&bi->sql_aliasing,
&bi->sql_aliasing_quote,
&at_map->bam_ad->ad_cname,
(ber_len_t)STRLENOF( BACKSQL_ALIASING_QUOTE " FROM " ),
BACKSQL_ALIASING_QUOTE " FROM ",
&bi->sql_aliasing_quote,
(ber_len_t)STRLENOF( " FROM " ), " FROM ",
&at_map->bam_from_tbls,
(ber_len_t)STRLENOF( " WHERE " ), " WHERE ",
&oc_map->bom_keytbl,
......@@ -126,12 +128,11 @@ backsql_make_attr_query(
&at_map->bam_join_where );
}
backsql_strfcat( &bb, "lbl",
(ber_len_t)STRLENOF( " ORDER BY " BACKSQL_ALIASING_QUOTE ),
" ORDER BY " BACKSQL_ALIASING_QUOTE,
backsql_strfcat( &bb, "lbbb",
(ber_len_t)STRLENOF( " ORDER BY " ), " ORDER BY ",
&bi->sql_aliasing_quote,
&at_map->bam_ad->ad_cname,
(ber_len_t)STRLENOF( BACKSQL_ALIASING_QUOTE ),
BACKSQL_ALIASING_QUOTE );
&bi->sql_aliasing_quote );
at_map->bam_query = bb.bb_val.bv_val;
......@@ -162,7 +163,7 @@ backsql_make_attr_query(
}
static int
backsql_add_sysmaps( backsql_oc_map_rec *oc_map )
backsql_add_sysmaps( backsql_info *bi, backsql_oc_map_rec *oc_map )
{
backsql_at_map_rec *at_map;
char s[] = "+9223372036854775807L";
......@@ -183,7 +184,7 @@ backsql_add_sysmaps( backsql_oc_map_rec *oc_map )
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 );
backsql_merge_from_clause( bi, &bb, &oc_map->bom_keytbl );
at_map->bam_from_tbls = bb.bb_val;
BER_BVZERO( &bb.bb_val );
......@@ -240,7 +241,7 @@ backsql_add_sysmaps( backsql_oc_map_rec *oc_map )
at_map->bam_expect_return = 0;
at_map->bam_next = NULL;
backsql_make_attr_query( oc_map, at_map );
backsql_make_attr_query( bi, 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",
......@@ -359,7 +360,7 @@ backsql_oc_get_attr_mapping( void *v_oc, void *v_bas )
}
ber_str2bv( at_row.cols[ 2 ], 0, 0, &bv );
backsql_merge_from_clause( &bb, &bv );
backsql_merge_from_clause( bas->bas_bi, &bb, &bv );
at_map->bam_from_tbls = bb.bb_val;
if ( at_row.value_len[ 3 ] < 0 ) {
BER_BVZERO( &at_map->bam_join_where );
......@@ -386,7 +387,7 @@ backsql_oc_get_attr_mapping( void *v_oc, void *v_bas )
if ( next == at_row.cols[ 7 ] || next[0] != '\0' ) {
/* error */
}
backsql_make_attr_query( oc_map, at_map );
backsql_make_attr_query( bas->bas_bi, oc_map, at_map );
Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_attr_mapping(): "
"preconstructed query \"%s\"\n",
at_map->bam_query, 0, 0 );
......@@ -419,7 +420,7 @@ backsql_oc_get_attr_mapping( void *v_oc, void *v_bas )
"autoadding 'objectClass' and 'ref' mappings\n",
BACKSQL_OC_NAME( oc_map ), 0, 0 );
(void)backsql_add_sysmaps( oc_map );
(void)backsql_add_sysmaps( bas->bas_bi, oc_map );
return BACKSQL_AVL_CONTINUE;
}
......
......@@ -1247,8 +1247,8 @@ equality_match:;
static int
backsql_srch_query( backsql_srch_info *bsi, struct berval *query )
{
backsql_info *bi = (backsql_info *)bsi->bsi_op->o_bd->be_private;
int rc;
backsql_info *bi = (backsql_info *)bsi->bsi_op->o_bd->be_private;
int rc;
assert( query );
BER_BVZERO( query );
......@@ -1288,14 +1288,8 @@ backsql_srch_query( backsql_srch_info *bsi, struct berval *query )
&bsi->bsi_oc->bom_oc->soc_cname,
'\'' );
}
backsql_strfcat( &bsi->bsi_sel, "l",
(ber_len_t)STRLENOF( " " BACKSQL_ALIASING
BACKSQL_ALIASING_QUOTE "objectClass" BACKSQL_ALIASING_QUOTE
",ldap_entries.dn " BACKSQL_ALIASING BACKSQL_ALIASING_QUOTE "dn" BACKSQL_ALIASING_QUOTE ),
" " BACKSQL_ALIASING
BACKSQL_ALIASING_QUOTE "objectClass" BACKSQL_ALIASING_QUOTE
",ldap_entries.dn " BACKSQL_ALIASING BACKSQL_ALIASING_QUOTE "dn" BACKSQL_ALIASING_QUOTE );
backsql_strfcat( &bsi->bsi_sel, "b", &bi->sql_dn_oc_aliasing );
backsql_strfcat( &bsi->bsi_from, "lb",
(ber_len_t)STRLENOF( " FROM ldap_entries," ),
" FROM ldap_entries,",
......
......@@ -275,7 +275,7 @@ backsql_entry_addattr(
}
static char *
backsql_get_table_spec( char **p )
backsql_get_table_spec( backsql_info *bi, char **p )
{
char *s, *q;
struct berbuf res = BB_NULL;
......@@ -312,13 +312,19 @@ backsql_get_table_spec( char **p )
}
/* oracle doesn't understand "AS" :( and other RDBMSes don't need it */
backsql_strcat( &res, " " BACKSQL_ALIASING BACKSQL_ALIASING_QUOTE, s, BACKSQL_ALIASING_QUOTE, NULL );
backsql_strfcat( &res, "lbbsb",
STRLENOF( " " ), " ",
&bi->sql_aliasing,
&bi->sql_aliasing_quote,
s,
&bi->sql_aliasing_quote );
return res.bb_val.bv_val;
}
int
backsql_merge_from_clause(
backsql_info *bi,
struct berbuf *dest_from,
struct berval *src_from )
{
......@@ -340,7 +346,7 @@ backsql_merge_from_clause(
}
while ( *p ) {
s = backsql_get_table_spec( &p );
s = backsql_get_table_spec( bi, &p );
#ifdef BACKSQL_TRACE
Debug( LDAP_DEBUG_TRACE, "backsql_merge_from_clause(): "
......
......@@ -1157,21 +1157,35 @@ config_generic(ConfigArgs *c) {
#ifdef SLAPD_MODULES
case CFG_MODLOAD:
/* If we're just adding a module on an existing modpath,
* make sure we've selected the current path.
*/
if ( c->op == LDAP_MOD_ADD && modcur != c->private ) {
modcur = c->private;
/* This should never fail */
if ( module_path( modcur->mp_path.bv_val )) {
sprintf( c->msg, "<%s> module path no longer valid",
c->argv[0] );
Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
c->log, c->msg, modcur->mp_path.bv_val );
return(1);
}
}
if(module_load(c->argv[1], c->argc - 2, (c->argc > 2) ? c->argv + 2 : NULL))
return(1);
/* Record this load on the current path */
{
struct berval bv;
ModPaths *mp;
char *ptr = c->line + STRLENOF("moduleload");
while (!isspace(*ptr)) ptr++;
while (isspace(*ptr)) ptr++;
char *ptr;
if ( c->op == SLAP_CONFIG_ADD ) {
ptr = c->line + STRLENOF("moduleload");
while (!isspace(*ptr)) ptr++;
while (isspace(*ptr)) ptr++;
} else {
ptr = c->line;
}
ber_str2bv(ptr, 0, 1, &bv);
if ( c->op == SLAP_CONFIG_ADD )
mp = modcur;
else
mp = c->private;
ber_bvarray_add( &mp->mp_loads, &bv );
ber_bvarray_add( &modcur->mp_loads, &bv );
}
break;
......@@ -1192,8 +1206,7 @@ config_generic(ConfigArgs *c) {
mp->mp_loads = NULL;
modlast = mp;
c->private = mp;
if ( c->op == SLAP_CONFIG_ADD )
modcur = mp;
modcur = mp;
}
break;
......
......@@ -1807,7 +1807,8 @@ slapd_daemon_task(
int r, w;
r = SLAP_EVENT_IS_READ( i );
w = SLAP_EVENT_IS_WRITE( i );
/* writefds was not initialized if nwriters was zero */
w = nwriters ? SLAP_EVENT_IS_WRITE( i ) : 0;
if ( r || w ) {
Debug( LDAP_DEBUG_CONNS, " %d%s%s", i,
r ? "r" : "", w ? "w" : "" );
......
......@@ -63,10 +63,10 @@ dbpasswd secret
#ibmdb2#insentry_stmt "insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values ((select case when max(id) is null then 1 else max(id) + 1 end from ldap_entries),?,?,?,?)"
#
# PostgreSQL
#postgres#insentry_stmt "insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values ((select case when max(id) is null then 1 else max(id) + 1 end from ldap_entries),?,?,?,?)"
#postgres#upper_func "upper"
#postgres#strcast_func "text"
#postgres#concat_pattern "?||?"
#pgsql#insentry_stmt "insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values ((select case when max(id) is null then 1 else max(id) + 1 end from ldap_entries),?,?,?,?)"
#pgsql#upper_func "upper"
#pgsql#strcast_func "text"
#pgsql#concat_pattern "?||?"
#
# MySQL
#mysql#concat_pattern "concat(?,?)"
......
......@@ -63,10 +63,10 @@ dbpasswd secret
#ibmdb2#insentry_stmt "insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values ((select case when max(id) is null then 1 else max(id) + 1 end from ldap_entries),?,?,?,?)"
#
# PostgreSQL
#postgres#insentry_stmt "insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values ((select case when max(id) is null then 1 else max(id) + 1 end from ldap_entries),?,?,?,?)"
#postgres#upper_func "upper"
#postgres#strcast_func "text"
#postgres#concat_pattern "?||?"
#pgsql#insentry_stmt "insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values ((select case when max(id) is null then 1 else max(id) + 1 end from ldap_entries),?,?,?,?)"
#pgsql#upper_func "upper"
#pgsql#strcast_func "text"
#pgsql#concat_pattern "?||?"
#
# MySQL
#mysql#concat_pattern "concat(?,?)"
......
......@@ -31,7 +31,7 @@ echo "###"
echo "### Set SLAPD_USE_SQL to the desired RDBMS to enable this test;"
echo "###"
echo "### Currently supported RDBMSes are:"
echo "### ibmdb2, mysql, postgres"
echo "### ibmdb2, mysql, pgsql"
echo "###"
echo "### Set SLAPD_USE_SQLWRITE=yes to enable the write tests"
echo "###"
......
......@@ -79,7 +79,7 @@ fi
case ${RDBMS} in
# list here the RDBMSes whose mapping allows writes
postgres|ibmdb2)
pgsql|ibmdb2)
MANAGERDN="cn=Manager,${BASEDN}"
echo "Testing add..."
$LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment