Issue 7024 - OpenLDAP does not save the attribute "jpegPhoto" in the sql database
Summary: OpenLDAP does not save the attribute "jpegPhoto" in the sql database
Status: VERIFIED SUSPENDED
Alias: None
Product: OpenLDAP
Classification: Unclassified
Component: slapd (show other issues)
Version: 2.4.26
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-22 06:47 UTC by daniil@chics.ru
Modified: 2020-06-26 15:05 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description daniil@chics.ru 2011-08-22 06:47:05 UTC
Full_Name: Daniil Harun
Version: 2.4.26
OS: FreeBSD, Linux
URL: 
Submission from: (NULL) (80.85.151.246)


OpenLDAP does not save the attribute "jpegphoto" in the sql database.
Use back-sql, unixodbc and postgresql database. The reason for the problem of
the use of the data type SQL_VARCHAR instead of SQL_LONGVARBINARY.

slapd debug output:

   backsql_modify_internal(): adding new values for attribute "jpegPhoto"
   backsql_modify_internal(): arg(2)=1
   backsql_modify_internal(): arg(1)="����";
executing "UPDATE personal SET jpegphoto=? WHERE id=?"
   backsql_modify_internal(): add_proc execution failed (rc=-1, prc=0)
Return code: -1
   nativeErrCode=7 SQLengineState=22021 msg="ERROR: invalid byte sequence for
encoding "UTF8": 0xff;
Error while executing the query"


SQL tracing is enabled:

[ODBC][23880][1313994179.641693][SQLPrepare.c][196]
                Entry:
                        Statement = 0x293eae00
                        SQL = [UPDATE personal SET jpegphoto=? WHERE
id=?][length = 42 (SQL_NTS)]
[ODBC][23880][1313994179.641791][SQLPrepare.c][371]
                Exit:[SQL_SUCCESS]
[ODBC][23880][1313994179.641886][SQLBindParameter.c][217]
                Entry:
                        Statement = 0x293eae00
                        Param Number = 2
                        Param Type = 1
                        C Type = -27 SQL_C_UBIGINT
                        SQL Type = 4 SQL_INTEGER
                        Col Def = 0
                        Scale = 0
                        Rgb Value = 0xbf1fc7a4
                        Value Max = 0
                        StrLen Or Ind = 0x0
[ODBC][23880][1313994179.641988][SQLBindParameter.c][397]
                Exit:[SQL_SUCCESS]
[ODBC][23880][1313994179.642182][SQLBindParamet[ODBC][23880][1313994179.641693][SQLPrepare.c][196]
                Entry:
                        Statement = 0x293eae00
                        SQL = [UPDATE personal SET jpegphoto=? WHERE
id=?][length = 42 (SQL_NTS)]
[ODBC][23880][1313994179.641791][SQLPrepare.c][371]
                Exit:[SQL_SUCCESS]
[ODBC][23880][1313994179.641886][SQLBindParameter.c][217]
                Entry:
                        Statement = 0x293eae00
                        Param Number = 2
                        Param Type = 1
                        C Type = -27 SQL_C_UBIGINT
                        SQL Type = 4 SQL_INTEGER
                        Col Def = 0
                        Scale = 0
                        Rgb Value = 0xbf1fc7a4
                        Value Max = 0
                        StrLen Or Ind = 0x0
[ODBC][23880][1313994179.641988][SQLBindParameter.c][397]
                Exit:[SQL_SUCCESS]
[ODBC][23880][1313994179.642182][SQLBindParameter.c][217]
                Entry:
                        Statement = 0x293eae00
                        Param Number = 1
                        Param Type = 1
                        C Type = 1 SQL_C_CHAR
                        SQL Type = 12 SQL_VARCHAR
                        Col Def = 2790
                        Scale = 0
                        Rgb Value = 0x29529700
                        Value Max = 2790
                        StrLen Or Ind = 0x0
[ODBC][23880][1313994179.642284][SQLBindParameter.c][397]
                Exit:[SQL_SUCCESS]
[ODBC][23880][1313994179.642741][SQLExecute.c][187]
                Entry:
                        Statement = 0x293eae00
[ODBC][23880][1313994179.645733][SQLExecute.c][348]
                Exit:[SQL_ERROR]
                DIAG [22021] ERROR: invalid byte sequence for encoding "UTF8":
0xff;
Error while executing the query
er.c][217]
                Entry:
                        Statement = 0x293eae00
                        Param Number = 1
                        Param Type = 1
                        C Type = 1 SQL_C_CHAR
                        SQL Type = 12 SQL_VARCHAR
                        Col Def = 2790
                        Scale = 0
                        Rgb Value = 0x29529700
                        Value Max = 2790
                        StrLen Or Ind = 0x0
[ODBC][23880][1313994179.642284][SQLBindParameter.c][397]
                Exit:[SQL_SUCCESS]
[ODBC][23880][1313994179.642741][SQLExecute.c][187]
                Entry:
                        Statement = 0x293eae00
[ODBC][23880][1313994179.645733][SQLExecute.c][348]
                Exit:[SQL_ERROR]
                DIAG [22021] ERROR: invalid byte sequence for encoding "UTF8":
0xff;
Error while executing the query

OpenLDAP uses the wrong data - types SQL_C_CHAR,SQL_VARCHAR instead of
SQL_C_BINARY,SQL_LONGVARBINARY. 
How to make use of the correct data types?
Comment 1 ando@openldap.org 2011-08-22 16:25:09 UTC
back-sql calls backsql_BindParamBerVal(), which indeed considers the data as
SQL_C_CHAR, SQL_VARCHAR.  A binary variant can be easily defined, but back-sql
will need to know what attribute values need to be treated as binaries.  A
general approach to this requires to modify the attribute mapping, to add a
"type" flag.

p.
Comment 2 ando@openldap.org 2011-08-22 16:25:21 UTC
changed notes
moved from Incoming to Software Bugs
Comment 3 daniil@chics.ru 2011-08-23 06:27:50 UTC
> back-sql calls backsql_BindParamBerVal(), which indeed considers the data as
> SQL_C_CHAR, SQL_VARCHAR.  A binary variant can be easily defined, but back-sql
> will need to know what attribute values need to be treated as binaries.  A
> general approach to this requires to modify the attribute mapping, to add a
> "type" flag.
>
> p.
>    
I have carefully read the documentation (man slapd-sql) but could not 
find how to modify the attribute mapping and add a "type" flag.

Comment 4 ando@openldap.org 2011-08-23 11:17:28 UTC
>
>> back-sql calls backsql_BindParamBerVal(), which indeed considers the
>> data as
>> SQL_C_CHAR, SQL_VARCHAR.  A binary variant can be easily defined, but
>> back-sql
>> will need to know what attribute values need to be treated as binaries.
>> A
>> general approach to this requires to modify the attribute mapping, to
>> add a
>> "type" flag.
>>
>> p.
>>
> I have carefully read the documentation (man slapd-sql) but could not
> find how to modify the attribute mapping and add a "type" flag.

I meant: modify the code.  Since back-sql is basically unmaintained (any
volunteers out there?) this feature won't likely be added, not to mention
the fact that it would break all existing installations.

p.

Comment 5 ando@openldap.org 2011-09-09 19:37:27 UTC
changed state Open to Suspended
Comment 6 OpenLDAP project 2014-08-01 21:04:38 UTC
back-sql