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

Re: Back-sql and reserved words (ITS#3221)



lists.p.koetsier@unicast.nl wrote:

>Full_Name: Paul Koetsier
>Version: 2.1.30
>OS: Linux
>URL: ftp://ftp.openldap.org/incoming/
>Submission from: (NULL) (145.64.134.243)
>  
>
After further investigation, I found out that some of the currently 
supported RDBMSes
don't like the double quotes around aliases.  In HEAD/RE22 there is some 
code that
you may want to play with to see if it fixes your problem.  In 
back-sql.h there is a
BACKSQL_ALIASING macro that allows to define if aliasing uses the 
keyword "AS"
or not.  By deafult it is set to "AS ", but it can be set to "" to avoid 
using it.  This
has little to do with your problem, I'm writing it here only to leave 
trace of it.  The second
macro, BACKSQL_ALIASING_QUOTE, allows to define what char is used to quote
aliases.  By default it is undefined.  Define it to the desired char 
('"' in your case").
With PostgreSQL/MySQL/IBM db2 the default works fine; let me know if any 
of the
proposed changes works with MaxDB.

p.

>Hi,
>
>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
>servers/slapd/back-sql/schema-map.c:
>diff /usr/src/openldap-2.1.30.org/servers/slapd/back-sql/schema-map.c
>./schema-map.c
>60c60
><       backsql_strfcat( &tmps, &tmpslen, "lblblblbcbl",
>---
>  
>
>>      backsql_strfcat( &tmps, &tmpslen, "lblcbclblbcbl",
>>    
>>
>63c63,64
><                       (ber_len_t)sizeof( " AS " ) - 1, " AS ",
>---
>  
>
>>                      (ber_len_t)sizeof( " AS " ) - 1, " AS ",
>>                      '"',
>>    
>>
>64a66
>  
>
>>                      '"',
>>    
>>
>
>This patch is working fine for me.
>Would this be the correct way to resolve the issue?
>  
>





    SysNet - via Dossi,8 27100 Pavia Tel: +390382573859 Fax: +390382476497