EiffelStore reads only 1024 characters of a string

13 Messages Forum Options Options
Embed this topic
Permalink
Peter Wyss
EiffelStore reads only 1024 characters of a string
Reply Threaded MoreMore options
Print post
Permalink
Hi,

I tried to read a string from a MySQL database (field defined as TEXT). To
do so I used the DB_SELECTION class.
This works if the string contains 1024 characters or less. But if the string
has more than 1024 characters, the remaining chars in the resulting Eiffel
String are filled up with random bytes (or whatever there is at this memory
position).

Changing #define DB_MAX_STRING_LEN 1024 in
library/store/dbms/rdbms/odbc/Clib/odbc.h seems to help. But why is the
string limited in the first place?

Regards
Peter

_______________________________________________
Es-devel mailing list
Es-devel@...
http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
Emmanuel Stapf
RE: EiffelStore reads only 1024 characters of a string
Reply Threaded MoreMore options
Print post
Permalink
Could you try to replace at line 751 of `odbc.c' the following code:

                                default:
                                        /*bufSize += GetDbColLength(dap, i) + 1;*/
                                        break;
                        }
                        type = GetDbColType(dap, i);
                        switch (type) {
                                case SQL_LONGVARBINARY:
                                case SQL_LONGVARCHAR:
                                        SetDbColLength(dap, i, DB_MAX_STRING_LEN);
                                        break;
                        }
                        bufSize += GetDbColLength(dap, i) + 1;
                }
        }


by just:

                                default:
                                        /*bufSize += GetDbColLength(dap, i) + 1;*/
break;
                        }
                        bufSize += GetDbColLength(dap, i) + 1;
                }
        }

and tell me if it works better.

Thanks,
Manu

> -----Original Message-----
> From: es-devel-bounces@...
> [mailto:es-devel-bounces@...] On Behalf Of Peter Wyss
> Sent: Tuesday, June 26, 2007 5:04 AM
> To: es-devel@...
> Subject: [Es-devel] EiffelStore reads only 1024 characters of a string
>
> Hi,
>
> I tried to read a string from a MySQL database (field defined
> as TEXT). To do so I used the DB_SELECTION class.
> This works if the string contains 1024 characters or less.
> But if the string has more than 1024 characters, the
> remaining chars in the resulting Eiffel String are filled up
> with random bytes (or whatever there is at this memory position).
>
> Changing #define DB_MAX_STRING_LEN 1024 in
> library/store/dbms/rdbms/odbc/Clib/odbc.h seems to help. But
> why is the string limited in the first place?
>
> Regards
> Peter
>
> _______________________________________________
> Es-devel mailing list
> Es-devel@...
> http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
>

_______________________________________________
Es-devel mailing list
Es-devel@...
http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
------------------------------------------------------------------------  
Eiffel Software
805-685-1006
http://www.eiffel.com       
Customer support: http://support.eiffel.com       
User group: http://groups.eiffel.com/join       
------------------------------------------------------------------------  
Patrick Ruckstuhl
Re: EiffelStore reads only 1024 characters of a string
Reply Threaded MoreMore options
Print post
Permalink
This seems not to work, we got the following odbc warning

ODBC WARNING Inter code: <9>
  Native Err#=501 , SQLSTATE=01004, Error_Info='[MySQL][ODBC 3.51
Driver][mysqld-5.0.32-Debian_7etch1-log]String data, right truncated'

and a crash

Exception in main: ******************************** Thread exception
*****************************
In thread           Root thread            0x0 (thread id)
*******************************************************************************
-------------------------------------------------------------------------------
Class / Object      Routine                Nature of exception
  Effect
-------------------------------------------------------------------------------
ODBC                put_data @1            Segmentation fault:
<00002AB922DEE558>                         Operating system signal.
  Fail
-------------------------------------------------------------------------------
ODBC                put_data @1
<00002AB922DEE558>                         Routine failure.
  Fail
-------------------------------------------------------------------------------
DATABASE_STRING_EX  get_value @1
<00002AB922E3C338>                         Routine failure.
  Fail
-------------------------------------------------------------------------------
DATABASE_DATA       fill_in @36
<00002AB922E3C2A8>                         Routine failure.
  Fail
-------------------------------------------------------------------------------
DATABASE_TUPLE      fill_in @1
<00002AB922E3C288>                         Routine failure.
  Fail
-------------------------------------------------------------------------------
DB_RESULT           fill_in @1
<00002AB922E3C268>                         Routine failure.
  Fail
-------------------------------------------------------------------------------
DB_SELECTION        load_result @6
<00002AB922E3A788>                         Routine failure.
  Fail


> Could you try to replace at line 751 of `odbc.c' the following code:
>
> default:
> /*bufSize += GetDbColLength(dap, i) + 1;*/
> break;
> }
> type = GetDbColType(dap, i);
> switch (type) {
> case SQL_LONGVARBINARY:
> case SQL_LONGVARCHAR:
> SetDbColLength(dap, i, DB_MAX_STRING_LEN);
> break;
> }
> bufSize += GetDbColLength(dap, i) + 1;
> }
> }
>
>
> by just:
>
> default:
> /*bufSize += GetDbColLength(dap, i) + 1;*/
> break;
> }
> bufSize += GetDbColLength(dap, i) + 1;
> }
> }
>
> and tell me if it works better.
>
> Thanks,
> Manu
>
>> -----Original Message-----
>> From: es-devel-bounces@...
>> [mailto:es-devel-bounces@...] On Behalf Of Peter Wyss
>> Sent: Tuesday, June 26, 2007 5:04 AM
>> To: es-devel@...
>> Subject: [Es-devel] EiffelStore reads only 1024 characters of a string
>>
>> Hi,
>>
>> I tried to read a string from a MySQL database (field defined
>> as TEXT). To do so I used the DB_SELECTION class.
>> This works if the string contains 1024 characters or less.
>> But if the string has more than 1024 characters, the
>> remaining chars in the resulting Eiffel String are filled up
>> with random bytes (or whatever there is at this memory position).
>>
>> Changing #define DB_MAX_STRING_LEN 1024 in
>> library/store/dbms/rdbms/odbc/Clib/odbc.h seems to help. But
>> why is the string limited in the first place?
>>
>> Regards
>> Peter
>>
>> _______________________________________________
>> Es-devel mailing list
>> Es-devel@...
>> http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
>>

_______________________________________________
Es-devel mailing list
Es-devel@...
http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
Peter Wyss
AW: Re: EiffelStore reads only 1024 characters of a string
Reply Threaded MoreMore options
Print post
Permalink
Hi,

did you find another solution we could try?

Peter

-----Ursprüngliche Nachricht-----
Von: es-devel-bounces@...
[mailto:es-devel-bounces@...] Im Auftrag von Patrick Ruckstuhl
Gesendet: Mittwoch, 11. Juli 2007 12:59
An: es-devel@...
Betreff: [Es-devel] Re: EiffelStore reads only 1024 characters of a string

This seems not to work, we got the following odbc warning

ODBC WARNING Inter code: <9>
  Native Err#=501 , SQLSTATE=01004, Error_Info='[MySQL][ODBC 3.51
Driver][mysqld-5.0.32-Debian_7etch1-log]String data, right truncated'

and a crash

Exception in main: ******************************** Thread exception
*****************************
In thread           Root thread            0x0 (thread id)
****************************************************************************
***
----------------------------------------------------------------------------
---
Class / Object      Routine                Nature of exception
  Effect
----------------------------------------------------------------------------
---
ODBC                put_data @1            Segmentation fault:
<00002AB922DEE558>                         Operating system signal.
  Fail
----------------------------------------------------------------------------
---
ODBC                put_data @1
<00002AB922DEE558>                         Routine failure.
  Fail
----------------------------------------------------------------------------
---
DATABASE_STRING_EX  get_value @1
<00002AB922E3C338>                         Routine failure.
  Fail
----------------------------------------------------------------------------
---
DATABASE_DATA       fill_in @36
<00002AB922E3C2A8>                         Routine failure.
  Fail
----------------------------------------------------------------------------
---
DATABASE_TUPLE      fill_in @1
<00002AB922E3C288>                         Routine failure.
  Fail
----------------------------------------------------------------------------
---
DB_RESULT           fill_in @1
<00002AB922E3C268>                         Routine failure.
  Fail
----------------------------------------------------------------------------
---
DB_SELECTION        load_result @6
<00002AB922E3A788>                         Routine failure.
  Fail


> Could you try to replace at line 751 of `odbc.c' the following code:
>
> default:
> /*bufSize += GetDbColLength(dap, i)
+ 1;*/
> break;
> }
> type = GetDbColType(dap, i);
> switch (type) {
> case SQL_LONGVARBINARY:
> case SQL_LONGVARCHAR:
> SetDbColLength(dap, i,
DB_MAX_STRING_LEN);

> break;
> }
> bufSize += GetDbColLength(dap, i) + 1;
> }
> }
>
>
> by just:
>
> default:
> /*bufSize += GetDbColLength(dap, i)
+ 1;*/

> break;
> }
> bufSize += GetDbColLength(dap, i) + 1;
> }
> }
>
> and tell me if it works better.
>
> Thanks,
> Manu
>
>> -----Original Message-----
>> From: es-devel-bounces@...
>> [mailto:es-devel-bounces@...] On Behalf Of Peter Wyss
>> Sent: Tuesday, June 26, 2007 5:04 AM
>> To: es-devel@...
>> Subject: [Es-devel] EiffelStore reads only 1024 characters of a string
>>
>> Hi,
>>
>> I tried to read a string from a MySQL database (field defined
>> as TEXT). To do so I used the DB_SELECTION class.
>> This works if the string contains 1024 characters or less.
>> But if the string has more than 1024 characters, the
>> remaining chars in the resulting Eiffel String are filled up
>> with random bytes (or whatever there is at this memory position).
>>
>> Changing #define DB_MAX_STRING_LEN 1024 in
>> library/store/dbms/rdbms/odbc/Clib/odbc.h seems to help. But
>> why is the string limited in the first place?
>>
>> Regards
>> Peter
>>
>> _______________________________________________
>> Es-devel mailing list
>> Es-devel@...
>> http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
>>

_______________________________________________
Es-devel mailing list
Es-devel@...
http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel

_______________________________________________
Es-devel mailing list
Es-devel@...
http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
Emmanuel Stapf
RE: Re: EiffelStore reads only 1024 characters of a string
Reply Threaded MoreMore options
Print post
Permalink
Could you try updating to rev#69659 of odbc.c? The issue should be fixed.

Manu

> -----Original Message-----
> From: es-devel-bounces@...
> [mailto:es-devel-bounces@...] On Behalf Of Peter Wyss
> Sent: Friday, July 20, 2007 4:09 AM
> To: es-devel@...
> Subject: AW: [Es-devel] Re: EiffelStore reads only 1024
> characters of a string
>
> Hi,
>
> did you find another solution we could try?
>
> Peter
>
> -----Ursprüngliche Nachricht-----
> Von: es-devel-bounces@...
> [mailto:es-devel-bounces@...] Im Auftrag von
> Patrick Ruckstuhl
> Gesendet: Mittwoch, 11. Juli 2007 12:59
> An: es-devel@...
> Betreff: [Es-devel] Re: EiffelStore reads only 1024
> characters of a string
>
> This seems not to work, we got the following odbc warning
>
> ODBC WARNING Inter code: <9>
>   Native Err#=501 , SQLSTATE=01004, Error_Info='[MySQL][ODBC
> 3.51 Driver][mysqld-5.0.32-Debian_7etch1-log]String data,
> right truncated'
>
> and a crash
>
> Exception in main: ******************************** Thread exception
> *****************************
> In thread           Root thread            0x0 (thread id)
> **************************************************************
> **************
> ***
> --------------------------------------------------------------
> --------------
> ---
> Class / Object      Routine                Nature of exception
>   Effect
> --------------------------------------------------------------
> --------------
> ---
> ODBC                put_data @1            Segmentation fault:
> <00002AB922DEE558>                         Operating system signal.
>   Fail
> --------------------------------------------------------------
> --------------
> ---
> ODBC                put_data @1
> <00002AB922DEE558>                         Routine failure.
>   Fail
> --------------------------------------------------------------
> --------------
> ---
> DATABASE_STRING_EX  get_value @1
> <00002AB922E3C338>                         Routine failure.
>   Fail
> --------------------------------------------------------------
> --------------
> ---
> DATABASE_DATA       fill_in @36
> <00002AB922E3C2A8>                         Routine failure.
>   Fail
> --------------------------------------------------------------
> --------------
> ---
> DATABASE_TUPLE      fill_in @1
> <00002AB922E3C288>                         Routine failure.
>   Fail
> --------------------------------------------------------------
> --------------
> ---
> DB_RESULT           fill_in @1
> <00002AB922E3C268>                         Routine failure.
>   Fail
> --------------------------------------------------------------
> --------------
> ---
> DB_SELECTION        load_result @6
> <00002AB922E3A788>                         Routine failure.
>   Fail
>
>
> > Could you try to replace at line 751 of `odbc.c' the following code:
> >
> > default:
> > /*bufSize +=
> GetDbColLength(dap, i)
> + 1;*/
> > break;
> > }
> > type = GetDbColType(dap, i);
> > switch (type) {
> > case SQL_LONGVARBINARY:
> > case SQL_LONGVARCHAR:
> > SetDbColLength(dap, i,
> DB_MAX_STRING_LEN);
> > break;
> > }
> > bufSize += GetDbColLength(dap, i) + 1;
> > }
> > }
> >
> >
> > by just:
> >
> > default:
> > /*bufSize +=
> GetDbColLength(dap, i)
> + 1;*/
> > break;
> > }
> > bufSize += GetDbColLength(dap, i) + 1;
> > }
> > }
> >
> > and tell me if it works better.
> >
> > Thanks,
> > Manu
> >
> >> -----Original Message-----
> >> From: es-devel-bounces@...
> >> [mailto:es-devel-bounces@...] On Behalf Of Peter Wyss
> >> Sent: Tuesday, June 26, 2007 5:04 AM
> >> To: es-devel@...
> >> Subject: [Es-devel] EiffelStore reads only 1024 characters of a
> >> string
> >>
> >> Hi,
> >>
> >> I tried to read a string from a MySQL database (field defined as
> >> TEXT). To do so I used the DB_SELECTION class.
> >> This works if the string contains 1024 characters or less.
> >> But if the string has more than 1024 characters, the
> remaining chars
> >> in the resulting Eiffel String are filled up with random bytes (or
> >> whatever there is at this memory position).
> >>
> >> Changing #define DB_MAX_STRING_LEN 1024 in
> >> library/store/dbms/rdbms/odbc/Clib/odbc.h seems to help.
> But why is
> >> the string limited in the first place?
> >>
> >> Regards
> >> Peter
> >>
> >> _______________________________________________
> >> Es-devel mailing list
> >> Es-devel@...
> >> http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
> >>
>
> _______________________________________________
> Es-devel mailing list
> Es-devel@...
> http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
>
> _______________________________________________
> Es-devel mailing list
> Es-devel@...
> http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
>

_______________________________________________
Es-devel mailing list
Es-devel@...
http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
------------------------------------------------------------------------  
Eiffel Software
805-685-1006
http://www.eiffel.com       
Customer support: http://support.eiffel.com       
User group: http://groups.eiffel.com/join       
------------------------------------------------------------------------  
Peter Wyss
AW: Re: EiffelStore reads only 1024 characters of a string
Reply Threaded MoreMore options
Print post
Permalink
Thanks for your answer

It still does not work with field type TEXT and LONGTEXT, but it works with
a VARCHAR. Unfortunately a VARCHAR is limited to ~64K.

Peter

-----Ursprüngliche Nachricht-----
Von: Emmanuel Stapf [ES] [mailto:manus@...]
Gesendet: Mittwoch, 25. Juli 2007 00:21
An: 'Peter Wyss'; es-devel@...
Betreff: RE: [Es-devel] Re: EiffelStore reads only 1024 characters of a
string

Could you try updating to rev#69659 of odbc.c? The issue should be fixed.

Manu

> -----Original Message-----
> From: es-devel-bounces@...
> [mailto:es-devel-bounces@...] On Behalf Of Peter Wyss
> Sent: Friday, July 20, 2007 4:09 AM
> To: es-devel@...
> Subject: AW: [Es-devel] Re: EiffelStore reads only 1024 characters of
> a string
>
> Hi,
>
> did you find another solution we could try?
>
> Peter
>
> -----Ursprüngliche Nachricht-----
> Von: es-devel-bounces@...
> [mailto:es-devel-bounces@...] Im Auftrag von Patrick
> Ruckstuhl
> Gesendet: Mittwoch, 11. Juli 2007 12:59
> An: es-devel@...
> Betreff: [Es-devel] Re: EiffelStore reads only 1024 characters of a
> string
>
> This seems not to work, we got the following odbc warning
>
> ODBC WARNING Inter code: <9>
>   Native Err#=501 , SQLSTATE=01004, Error_Info='[MySQL][ODBC
> 3.51 Driver][mysqld-5.0.32-Debian_7etch1-log]String data, right
> truncated'
>
> and a crash
>
> Exception in main: ******************************** Thread exception
> *****************************
> In thread           Root thread            0x0 (thread id)
> **************************************************************
> **************
> ***
> --------------------------------------------------------------
> --------------
> ---
> Class / Object      Routine                Nature of exception
>   Effect
> --------------------------------------------------------------
> --------------
> ---
> ODBC                put_data @1            Segmentation fault:
> <00002AB922DEE558>                         Operating system signal.
>   Fail
> --------------------------------------------------------------
> --------------
> ---
> ODBC                put_data @1
> <00002AB922DEE558>                         Routine failure.
>   Fail
> --------------------------------------------------------------
> --------------
> ---
> DATABASE_STRING_EX  get_value @1
> <00002AB922E3C338>                         Routine failure.
>   Fail
> --------------------------------------------------------------
> --------------
> ---
> DATABASE_DATA       fill_in @36
> <00002AB922E3C2A8>                         Routine failure.
>   Fail
> --------------------------------------------------------------
> --------------
> ---
> DATABASE_TUPLE      fill_in @1
> <00002AB922E3C288>                         Routine failure.
>   Fail
> --------------------------------------------------------------
> --------------
> ---
> DB_RESULT           fill_in @1
> <00002AB922E3C268>                         Routine failure.
>   Fail
> --------------------------------------------------------------
> --------------
> ---
> DB_SELECTION        load_result @6
> <00002AB922E3A788>                         Routine failure.
>   Fail
>
>
> > Could you try to replace at line 751 of `odbc.c' the following code:
> >
> > default:
> > /*bufSize +=
> GetDbColLength(dap, i)
> + 1;*/
> > break;
> > }
> > type = GetDbColType(dap, i);
> > switch (type) {
> > case SQL_LONGVARBINARY:
> > case SQL_LONGVARCHAR:
> > SetDbColLength(dap, i,
> DB_MAX_STRING_LEN);
> > break;
> > }
> > bufSize += GetDbColLength(dap, i) + 1;
> > }
> > }
> >
> >
> > by just:
> >
> > default:
> > /*bufSize +=
> GetDbColLength(dap, i)
> + 1;*/
> > break;
> > }
> > bufSize += GetDbColLength(dap, i) + 1;
> > }
> > }
> >
> > and tell me if it works better.
> >
> > Thanks,
> > Manu
> >
> >> -----Original Message-----
> >> From: es-devel-bounces@...
> >> [mailto:es-devel-bounces@...] On Behalf Of Peter Wyss
> >> Sent: Tuesday, June 26, 2007 5:04 AM
> >> To: es-devel@...
> >> Subject: [Es-devel] EiffelStore reads only 1024 characters of a
> >> string
> >>
> >> Hi,
> >>
> >> I tried to read a string from a MySQL database (field defined as
> >> TEXT). To do so I used the DB_SELECTION class.
> >> This works if the string contains 1024 characters or less.
> >> But if the string has more than 1024 characters, the
> remaining chars
> >> in the resulting Eiffel String are filled up with random bytes (or
> >> whatever there is at this memory position).
> >>
> >> Changing #define DB_MAX_STRING_LEN 1024 in
> >> library/store/dbms/rdbms/odbc/Clib/odbc.h seems to help.
> But why is
> >> the string limited in the first place?
> >>
> >> Regards
> >> Peter
> >>
> >> _______________________________________________
> >> Es-devel mailing list
> >> Es-devel@...
> >> http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
> >>
>
> _______________________________________________
> Es-devel mailing list
> Es-devel@...
> http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
>
> _______________________________________________
> Es-devel mailing list
> Es-devel@...
> http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
>

_______________________________________________
Es-devel mailing list
Es-devel@...
http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
Emmanuel Stapf
RE: Re: EiffelStore reads only 1024 characters of a string
Reply Threaded MoreMore options
Print post
Permalink
> It still does not work with field type TEXT and LONGTEXT, but
> it works with a VARCHAR. Unfortunately a VARCHAR is limited to ~64K.

Unfortunately with ODBC there is not much I can do there. How do you do your
update/retrieve?

Manu

_______________________________________________
Es-devel mailing list
Es-devel@...
http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
------------------------------------------------------------------------  
Eiffel Software
805-685-1006
http://www.eiffel.com       
Customer support: http://support.eiffel.com       
User group: http://groups.eiffel.com/join       
------------------------------------------------------------------------  
Peter Wyss
AW: Re: EiffelStore reads only 1024 characters of a string
Reply Threaded MoreMore options
Print post
Permalink
I don't understand why it is possible to retrieve about 64KB from a VARCHAR
field (which is the maximung length for this field type), but only 1KB from
a TEXT or LONGTEXT field. The rest of the content is filled with random
memory fragments.
Data is retrievied with the DB_SELECTION class.

Peter

-----Ursprüngliche Nachricht-----
Von: Emmanuel Stapf [ES] [mailto:manus@...]
Gesendet: Mittwoch, 25. Juli 2007 16:48
An: 'Peter Wyss'; es-devel@...
Betreff: RE: [Es-devel] Re: EiffelStore reads only 1024 characters of a
string

> It still does not work with field type TEXT and LONGTEXT, but it works
> with a VARCHAR. Unfortunately a VARCHAR is limited to ~64K.

Unfortunately with ODBC there is not much I can do there. How do you do your
update/retrieve?

Manu

_______________________________________________
Es-devel mailing list
Es-devel@...
http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
Emmanuel Stapf
RE: Re: EiffelStore reads only 1024 characters of a string
Reply Threaded MoreMore options
Print post
Permalink
> I don't understand why it is possible to retrieve about 64KB
> from a VARCHAR field (which is the maximung length for this
> field type), but only 1KB from a TEXT or LONGTEXT field. The
> rest of the content is filled with random memory fragments.
> Data is retrievied with the DB_SELECTION class.

This might be very specific to the ODBC handle you are using. Could you
provide a test case and submit a problem report? That will make it easier to
see what you are producing. It would be even better if you provide the
creation of the database in your sample as well.

Regards,
Manu

_______________________________________________
Es-devel mailing list
Es-devel@...
http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
------------------------------------------------------------------------  
Eiffel Software
805-685-1006
http://www.eiffel.com       
Customer support: http://support.eiffel.com       
User group: http://groups.eiffel.com/join       
------------------------------------------------------------------------  
Patrick Ruckstuhl
Re: EiffelStore reads only 1024 characters of a string
Reply Threaded MoreMore options
Print post
Permalink
Emmanuel Stapf [ES] wrote:

>> I don't understand why it is possible to retrieve about 64KB
>> from a VARCHAR field (which is the maximung length for this
>> field type), but only 1KB from a TEXT or LONGTEXT field. The
>> rest of the content is filled with random memory fragments.
>> Data is retrievied with the DB_SELECTION class.
>
> This might be very specific to the ODBC handle you are using. Could you
> provide a test case and submit a problem report? That will make it easier to
> see what you are producing. It would be even better if you provide the
> creation of the database in your sample as well.

I looked up some information about odbc and implemented a c version that
retrieves an arbitrary amount of data and it works perfectly well. The
trick is that you just call SQLGetData until everything is retrieved.
I had a quick look at the implementation in EiffelStore and it seems
that this does not call SQLGetData until it is done.
See the sample C code below that works in C. I think something similar
in EiffelStore should work, so do SQLGetData until everything is retrieved.

#include <stdio.h>
#include <sql.h>
#include <sqlext.h>

main() {
SQLHENV env;
SQLHDBC dbc;
SQLHSTMT stmt;
SQLRETURN ret; /* ODBC API return status */
SQLSMALLINT columns; /* number of columns in result-set */
int row = 0;

/* Allocate an environment handle */
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
/* We want ODBC 3 support */
SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);
/* Allocate a connection handle */
SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
/* Connect */
SQLDriverConnect(dbc, NULL, "DSN=origo;UID=origo;PWD=origo;", SQL_NTS,
                  NULL, 0, NULL, SQL_DRIVER_COMPLETE);
/* Allocate a statement handle */
SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);

SQLExecDirect(stmt, "SELECT data FROM user", SQL_NTS);

/* Loop through the rows in the result-set */
while (SQL_SUCCEEDED(ret = SQLFetch(stmt))) {
        SQLINTEGER indicator;
         char buf[512];
        int cnt = 0;

        do
        {
                /* retrieve column data as a string */
                ret = SQLGetData(stmt, 1, SQL_C_CHAR, buf, sizeof(buf), &indicator);

                cnt += indicator;

          if (SQL_SUCCEEDED(ret))
                {
              /* Handle null columns */
                        printf("retrieved %d\n", cnt);
            printf(buf);
          }
        }
        while ( ret != SQL_SUCCESS );
     }
}


_______________________________________________
Es-devel mailing list
Es-devel@...
http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
Emmanuel Stapf
RE: Re: EiffelStore reads only 1024 characters of a string
Reply Threaded MoreMore options
Print post
Permalink
The new version of EiffelStore does that but not in a loop, if the first
call to GetData fails, then we allocate a buffer large enough to hold the
data and reissue the call. You could change `odbc_next_row' to see this and
try to do a loop instead of just one call.

Regards,
Manu

> -----Original Message-----
> From: es-devel-bounces@...
> [mailto:es-devel-bounces@...] On Behalf Of
> Patrick Ruckstuhl
> Sent: Wednesday, July 25, 2007 3:38 PM
> To: es-devel@...
> Subject: [Es-devel] Re: EiffelStore reads only 1024
> characters of a string
>
> Emmanuel Stapf [ES] wrote:
> >> I don't understand why it is possible to retrieve about
> 64KB from a
> >> VARCHAR field (which is the maximung length for this field
> type), but
> >> only 1KB from a TEXT or LONGTEXT field. The rest of the content is
> >> filled with random memory fragments.
> >> Data is retrievied with the DB_SELECTION class.
> >
> > This might be very specific to the ODBC handle you are using. Could
> > you provide a test case and submit a problem report? That
> will make it
> > easier to see what you are producing. It would be even
> better if you
> > provide the creation of the database in your sample as well.
>
> I looked up some information about odbc and implemented a c
> version that retrieves an arbitrary amount of data and it
> works perfectly well. The trick is that you just call
> SQLGetData until everything is retrieved.
> I had a quick look at the implementation in EiffelStore and
> it seems that this does not call SQLGetData until it is done.
> See the sample C code below that works in C. I think
> something similar in EiffelStore should work, so do
> SQLGetData until everything is retrieved.
>
> #include <stdio.h>
> #include <sql.h>
> #include <sqlext.h>
>
> main() {
> SQLHENV env;
> SQLHDBC dbc;
> SQLHSTMT stmt;
> SQLRETURN ret; /* ODBC API return status */ SQLSMALLINT
> columns; /* number of columns in result-set */ int row = 0;
>
> /* Allocate an environment handle */
> SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
> /* We want ODBC 3 support */
> SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);
> /* Allocate a connection handle */
> SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
> /* Connect */
> SQLDriverConnect(dbc, NULL, "DSN=origo;UID=origo;PWD=origo;", SQL_NTS,
>                   NULL, 0, NULL, SQL_DRIVER_COMPLETE);
> /* Allocate a statement handle */
> SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
>
> SQLExecDirect(stmt, "SELECT data FROM user", SQL_NTS);
>
> /* Loop through the rows in the result-set */ while
> (SQL_SUCCEEDED(ret = SQLFetch(stmt))) {
> SQLINTEGER indicator;
>          char buf[512];
> int cnt = 0;
>
> do
> {
>        /* retrieve column data as a string */
> ret = SQLGetData(stmt, 1, SQL_C_CHAR, buf,
> sizeof(buf), &indicator);
>
> cnt += indicator;
>
>           if (SQL_SUCCEEDED(ret))
> {
>               /* Handle null columns */
> printf("retrieved %d\n", cnt);
>     printf(buf);
>           }
> }
> while ( ret != SQL_SUCCESS );
>      }
> }
>
>
> _______________________________________________
> Es-devel mailing list
> Es-devel@...
> http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
>

_______________________________________________
Es-devel mailing list
Es-devel@...
http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
------------------------------------------------------------------------  
Eiffel Software
805-685-1006
http://www.eiffel.com       
Customer support: http://support.eiffel.com       
User group: http://groups.eiffel.com/join       
------------------------------------------------------------------------  
Patrick Ruckstuhl
Re: EiffelStore reads only 1024 characters of a string
Reply Threaded MoreMore options
Print post
Permalink
After fixing the comparison it seems to work now with the version in
EiffelStore.

Btw. will you make a 6.1 weekly build with those fixes soon?

Thanks for the help,
Patrick

> The new version of EiffelStore does that but not in a loop, if the first
> call to GetData fails, then we allocate a buffer large enough to hold the
> data and reissue the call. You could change `odbc_next_row' to see this and
> try to do a loop instead of just one call.
>
> Regards,
> Manu
>
>> -----Original Message-----
>> From: es-devel-bounces@...
>> [mailto:es-devel-bounces@...] On Behalf Of
>> Patrick Ruckstuhl
>> Sent: Wednesday, July 25, 2007 3:38 PM
>> To: es-devel@...
>> Subject: [Es-devel] Re: EiffelStore reads only 1024
>> characters of a string
>>
>> Emmanuel Stapf [ES] wrote:
>>>> I don't understand why it is possible to retrieve about
>> 64KB from a
>>>> VARCHAR field (which is the maximung length for this field
>> type), but
>>>> only 1KB from a TEXT or LONGTEXT field. The rest of the content is
>>>> filled with random memory fragments.
>>>> Data is retrievied with the DB_SELECTION class.
>>> This might be very specific to the ODBC handle you are using. Could
>>> you provide a test case and submit a problem report? That
>> will make it
>>> easier to see what you are producing. It would be even
>> better if you
>>> provide the creation of the database in your sample as well.
>> I looked up some information about odbc and implemented a c
>> version that retrieves an arbitrary amount of data and it
>> works perfectly well. The trick is that you just call
>> SQLGetData until everything is retrieved.
>> I had a quick look at the implementation in EiffelStore and
>> it seems that this does not call SQLGetData until it is done.
>> See the sample C code below that works in C. I think
>> something similar in EiffelStore should work, so do
>> SQLGetData until everything is retrieved.
>>
>> #include <stdio.h>
>> #include <sql.h>
>> #include <sqlext.h>
>>
>> main() {
>> SQLHENV env;
>> SQLHDBC dbc;
>> SQLHSTMT stmt;
>> SQLRETURN ret; /* ODBC API return status */ SQLSMALLINT
>> columns; /* number of columns in result-set */ int row = 0;
>>
>> /* Allocate an environment handle */
>> SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
>> /* We want ODBC 3 support */
>> SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);
>> /* Allocate a connection handle */
>> SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
>> /* Connect */
>> SQLDriverConnect(dbc, NULL, "DSN=origo;UID=origo;PWD=origo;", SQL_NTS,
>>                   NULL, 0, NULL, SQL_DRIVER_COMPLETE);
>> /* Allocate a statement handle */
>> SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
>>
>> SQLExecDirect(stmt, "SELECT data FROM user", SQL_NTS);
>>
>> /* Loop through the rows in the result-set */ while
>> (SQL_SUCCEEDED(ret = SQLFetch(stmt))) {
>> SQLINTEGER indicator;
>>          char buf[512];
>> int cnt = 0;
>>
>> do
>> {
>>        /* retrieve column data as a string */
>> ret = SQLGetData(stmt, 1, SQL_C_CHAR, buf,
>> sizeof(buf), &indicator);
>>
>> cnt += indicator;
>>
>>           if (SQL_SUCCEEDED(ret))
>> {
>>               /* Handle null columns */
>> printf("retrieved %d\n", cnt);
>>     printf(buf);
>>           }
>> }
>> while ( ret != SQL_SUCCESS );
>>      }
>> }
>>
>>
>> _______________________________________________
>> Es-devel mailing list
>> Es-devel@...
>> http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
>>

_______________________________________________
Es-devel mailing list
Es-devel@...
http://rock.inf.ethz.ch/cgi-bin/mailman/listinfo/es-devel
Emmanuel Stapf