[Date Prev][Date Next] [Chronological] [Thread] [Top]

Back-sql and reserved words (ITS#3221)

Full_Name: Paul Koetsier
Version: 2.1.30
OS: Linux
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (


I'm running into a problem with reserved words when trying to use back-sql
together with MaxDB.
When trying to store inetOrgPerson entries in a table, I discovered that "uid"
is a reserved word in MaxDB. I therefore tried storing this attribute in a
column called uitattr. However, when trying to retrieve entries, I noticed that
back-sql was trying to perform a query that uses the attribute name as an alias
and were failing as a result:
backsql_get_attr_values(): error preparing query: SELECT certificateuser.uidattr
AS   uid FROM certificateuser WHERE certificateuser.id=?
Return code: -1
Native error code: -7006
SQL engine state: 3006

As MaxDB accepts the use of reserved words as an alias when enclosed in double
quotes, I decided to make the following change to
diff /usr/src/openldap-2.1.30.org/servers/slapd/back-sql/schema-map.c
<       backsql_strfcat( &tmps, &tmpslen, "lblblblbcbl",
>       backsql_strfcat( &tmps, &tmpslen, "lblcbclblbcbl",
<                       (ber_len_t)sizeof( " AS " ) - 1, " AS ",
>                       (ber_len_t)sizeof( " AS " ) - 1, " AS ",
>                       '"',
>                       '"',

This patch is working fine for me.
Would this be the correct way to resolve the issue?