Re: [libdbi-users] dbi_result_get_string_idx fails on VARCHAR COLLATE 'binary'

2010-01-21 Thread Markus Hoenicka
Vikram Noel Ambrose noel.ambr...@gmail.com was heard to say:

 By the way, the url for the source code repository is dead on the website.

Thanks for the heads up. I may have missed a SourceForge announcement  
about restructuring their CVS servers.

regards,
Markus


-- 
Markus Hoenicka
http://www.mhoenicka.de
AQ score 38



--
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
___
libdbi-users mailing list
libdbi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-users


Re: [libdbi-users] dbi_result_get_string_idx fails on VARCHAR COLLATE 'binary'

2010-01-20 Thread Vikram Noel Ambrose
Markus Hoenicka wrote:
 Vikram Noel Ambrose writes:
   Yes of course. VARCHAR should be treated as NULL terminated character 
   strings and not binary. As long as libdbi is consistent as to what it 
   thinks a VARCHAR(256) COLLATE 'binary' refers to, then I'll be happy.
   

 I've checked in a fixed version of dbd_mysql.c. I've also pasted in
 the patch below. It should apply cleanly to previous versions as well,
 as that part of the code hasn't been touched for a while. Vikram,
 could you please check whether this fixes your problem?
   

Looks like its working Markus. Tested using mysql-5.1.37 on Ubuntu-9.10 
x86_64.

By the way, the url for the source code repository is dead on the website.


Vikram.

--
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
___
libdbi-users mailing list
libdbi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-users


Re: [libdbi-users] dbi_result_get_string_idx fails on VARCHAR COLLATE 'binary'

2010-01-18 Thread Markus Hoenicka
Toby Thain t...@telegraphics.com.au was heard to say:

 This is probably driver dependent. IMHO the first check would be to
 see if the unexpected reversion to binary type is occurring within
 libdbi or in libmysqlclient (or mysqld).


I bet it is. The mysql driver uses some weird check (in  
_translate_mysql_type) to find out whether or not a field is binary.  
Unless I'm dense the code in question may actually cause other  
problems as well, so I'd like to ask everyone with some MySQL  
knowledge to have a look at it. Also, the existing check may be  
version dependent. Vikram, which MySQL version are you running?

regards,
Markus

-- 
Markus Hoenicka
http://www.mhoenicka.de
AQ score 38



--
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
___
libdbi-users mailing list
libdbi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-users


Re: [libdbi-users] dbi_result_get_string_idx fails on VARCHAR COLLATE 'binary'

2010-01-18 Thread Toby Thain

On 18-Jan-10, at 3:47 AM, Markus Hoenicka wrote:

 Toby Thain t...@telegraphics.com.au was heard to say:

 This is probably driver dependent. IMHO the first check would be to
 see if the unexpected reversion to binary type is occurring within
 libdbi or in libmysqlclient (or mysqld).


 I bet it is. The mysql driver uses some weird check (in
 _translate_mysql_type) to find out whether or not a field is binary.
 Unless I'm dense the code in question may actually cause other
 problems as well,

I have discussed this issue with Vikram on #mysql and IMHO it is  
wrong in concept for a collation change to affect column type: As it  
is not concerning the contents of the field but merely  
interpretation. Naturally he didn't expect to have to change his code.

But then perhaps the driver writer held a different opinion.

 so I'd like to ask everyone with some MySQL
 knowledge to have a look at it.

Sure.

--Toby

 Also, the existing check may be
 version dependent. Vikram, which MySQL version are you running?

 regards,
 Markus

 -- 
 Markus Hoenicka
 http://www.mhoenicka.de
 AQ score 38



 -- 
 
 Throughout its 18-year history, RSA Conference consistently  
 attracts the
 world's best and brightest in the field, creating opportunities for  
 Conference
 attendees to learn about information security's most important  
 issues through
 interactions with peers, luminaries and emerging and established  
 companies.
 http://p.sf.net/sfu/rsaconf-dev2dev
 ___
 libdbi-users mailing list
 libdbi-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/libdbi-users


--
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
___
libdbi-users mailing list
libdbi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-users


Re: [libdbi-users] dbi_result_get_string_idx fails on VARCHAR COLLATE 'binary'

2010-01-18 Thread Vikram Noel Ambrose
Toby Thain wrote:
 On 18-Jan-10, at 7:38 PM, Markus Hoenicka wrote:

   
 Markus Hoenicka writes:
 
 information. This check simply looks spurious to me:

 if(field-charsetnr == 63)

   
 It probably isn't as wrong as I thought initially. MySQL gurus, please
 correct me if I'm wrong, but I take the following from the manual:

 The purpose of the field-charsetnr==63 is to tell TEXT and BLOB
 fields apart (and their relatives of other sizes). Both are
 represented by a FIELD_TYPE_BLOB (or MYSQL_TYPE_BLOB) type. The former
 is a NULL-terminated string with a character set and a collation, the
 latter is a binary object without character set or collation. There is
 apparently no way to tell these apart other than by their
 field-charsetnr value.

 Therefore I tend to think the proper fix is to rearrange the case
 statements in the mysql driver (see the _translate_mysql_type
 function). The VAR_STRING and STRING types should be moved below the
 default: entry to never mark those as binary.
 

 I haven't looked at the code, but that sounds good.

   
 Vikram, do I understand correctly that you don't expect to be able to
 store binary strings in a VARCHAR(256) COLLATE 'binary' column? If
 we fix the driver as I suggested above, you'd get back only the part
 of the string up to the first NULL.
 

 Seems like a quite reasonable expectation when fetching using _string  
 function.

   

Yes of course. VARCHAR should be treated as NULL terminated character 
strings and not binary. As long as libdbi is consistent as to what it 
thinks a VARCHAR(256) COLLATE 'binary' refers to, then I'll be happy.

Vikram.

--
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
___
libdbi-users mailing list
libdbi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-users


Re: [libdbi-users] dbi_result_get_string_idx fails on VARCHAR COLLATE 'binary'

2010-01-17 Thread Vikram Noel Ambrose
Markus Hoenicka wrote:
 Vikram Noel Ambrose writes:
   Either mysql is telling libdbi that the field is binary or libdbi is 
   getting confused somewhere.
   

 Could you please insert a call to dbi_result_get_field_type_idx() to
 see what mysql thinks this is?
   

It returns type 4. Which is DBI_TYPE_BINARY in my dbi.h

I don't have another db to test with at the moment, but does this return 
type 4 when using other drivers on a column declared varchar with binary 
collation?

It should always be type 3 (DBI_TYPE_STRING).

Vikram.

--
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
___
libdbi-users mailing list
libdbi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-users


[libdbi-users] dbi_result_get_string_idx fails on VARCHAR COLLATE 'binary'

2010-01-16 Thread Markus Hoenicka
Vikram Noel Ambrose writes:
  When I invoke dbi_result_get_string_idx on a column declared 
  VARCHAR(256) COLLATE 'binary', libdbi complains that: The requested 
  variable type does not match what libdbi thinks it should be.
  
  I then tried using _get_binary_idx, but that seems to cause the next dbi 
  call to segfault (_get_short_idx). I wasn't sure if dbi was giving me 
  the '\0' character, so I called _get_field_length_idx and that just 
  returns 0. I don't have any idea whats going on now.
  
  Has anyone else run into this?

I've never tried things like this. Which driver do you use?

regards,
Markus

-- 
Markus Hoenicka
http://www.mhoenicka.de
AQ score 38

--
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
___
libdbi-users mailing list
libdbi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-users


Re: [libdbi-users] dbi_result_get_string_idx fails on VARCHAR COLLATE 'binary'

2010-01-16 Thread Vikram Noel Ambrose
Markus Hoenicka wrote:
 Vikram Noel Ambrose writes:
   When I invoke dbi_result_get_string_idx on a column declared 
   VARCHAR(256) COLLATE 'binary', libdbi complains that: The requested 
   variable type does not match what libdbi thinks it should be.
   
   I then tried using _get_binary_idx, but that seems to cause the next dbi 
   call to segfault (_get_short_idx). I wasn't sure if dbi was giving me 
   the '\0' character, so I called _get_field_length_idx and that just 
   returns 0. I don't have any idea whats going on now.
   
   Has anyone else run into this?

 I've never tried things like this. Which driver do you use?

 regards,
 Markus

   

This was on the mysql driver with mysql-5.1.37 on x86_64.

I managed to work around the problem with get_binary_idx but its rather 
inconvenient to treat null terminated character strings as binary.

Either mysql is telling libdbi that the field is binary or libdbi is 
getting confused somewhere.

VARCHAR should be string regardless of the collation used.

I wonder what would happen with another database.


Vikram.

--
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
___
libdbi-users mailing list
libdbi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-users


Re: [libdbi-users] dbi_result_get_string_idx fails on VARCHAR COLLATE 'binary'

2010-01-16 Thread Markus Hoenicka
Vikram Noel Ambrose writes:
  Either mysql is telling libdbi that the field is binary or libdbi is 
  getting confused somewhere.
  

Could you please insert a call to dbi_result_get_field_type_idx() to
see what mysql thinks this is?

regards,
Markus

-- 
Markus Hoenicka
http://www.mhoenicka.de
AQ score 38

--
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
___
libdbi-users mailing list
libdbi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-users


[libdbi-users] dbi_result_get_string_idx fails on VARCHAR COLLATE 'binary'

2010-01-15 Thread Vikram Noel Ambrose
When I invoke dbi_result_get_string_idx on a column declared 
VARCHAR(256) COLLATE 'binary', libdbi complains that: The requested 
variable type does not match what libdbi thinks it should be.

I then tried using _get_binary_idx, but that seems to cause the next dbi 
call to segfault (_get_short_idx). I wasn't sure if dbi was giving me 
the '\0' character, so I called _get_field_length_idx and that just 
returns 0. I don't have any idea whats going on now.

Has anyone else run into this?


Vikram.




--
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
___
libdbi-users mailing list
libdbi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-users