[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
(ITS#3386) Deal with null and binary attributes for a sql backend
Full_Name: Theodore Villette
Version: 2.2.17
OS: Linux LFS, kernel 2.4.26
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (160.92.7.69)
Using openldap with a sql backend.
Some modifications have to be made to deal with null and binary attributes.
Here is what i have done. It seems to work but may be improved because i am not
familiar with c and SQLBind functions. Besides i must have forgotten some
cases.
For release 2.2.17
/servers/slapd/back-sql/add.c:
line 40 to avoid segmentation fault on null attributes:
#define backsql_attr_skip(ad,vals) \
( \
vals == NULL \
|| ( (ad) == slap_schema.si_ad_objectClass \
&& (vals)[ 1 ].bv_val == NULL ) \
|| is_at_operational( (ad)->ad_type ) \
|| ( (vals)[ 0 ].bv_val == NULL ) \
)
line 92 to avoid segmentation fault on null attributes:
if ( c_mod->sm_values != NULL && backsql_attr_skip( ad, c_mod->sm_values ) )
{
continue;
}
line 350, to make a binary bind instead of a char bind:
SQLBindParameter( sth, pno + 2 - po,
SQL_PARAM_INPUT,
SQL_C_BINARY, SQL_VARBINARY,
at_val->bv_len, 0, at_val->bv_val,
at_val->bv_len, &(at_val->bv_len) );
/servers/slapd/back-sql/entry-id.c:
function backsql_get_attr_vals
line 370, to get the correct length of the attribute's value:
bv.bv_len = row.value_len[i]; /*instead of bv.bv_len = strlen( row.cols[ i ]
);*/
/servers/slapd/back-sql/sql-wrap.c:
function BindRowAsStrings (may be renamed?)
line 192, to make a binary bind instead of using char bind:
col_prec = MAX_ATTR_LEN;
row->cols[ i - 1 ] = (char *)ch_calloc( col_prec + 1, sizeof( char ) );
row->col_prec[ i - 1 ] = col_prec;
rc = SQLBindCol( sth, (SQLUSMALLINT)i,
SQL_C_BINARY,
(SQLPOINTER)row->cols[ i - 1 ],
col_prec + 1,
&row->value_len[ i - 1 ] );
} else {
row->cols[ i - 1 ] = (char *)ch_calloc( col_prec + 1, sizeof( char ) );
row->col_prec[ i - 1 ] = col_prec;
rc = SQLBindCol( sth, (SQLUSMALLINT)i,
SQL_C_BINARY,
(SQLPOINTER)row->cols[ i - 1 ],
col_prec + 1,
&row->value_len[ i - 1 ] );
}
}
Here it is for me,
Thanks