dbTalk Databases Forums  

fixed length char handling/declaration by SSQL

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss fixed length char handling/declaration by SSQL in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default fixed length char handling/declaration by SSQL - 07-16-2006 , 08:08 AM






Hi,

I'm new to mysql++ and trying to figure out how to use this.

One of the code snipped I need to write is store some fixed length
binary data (say, char(16)) and want to handle it efficiently or want to
write it in C+ as easy as possible. In other words, I'd like to store
IPv6 address as column and want to handle it via a class. (I plan to
store it as varchar but actually, whether this is efficient in MySQL
point of view is another question - I have not used MySQL very seriously
till now..)

Say, I want to write, for example,

sql_create_3(AddressToAS,
3, 0,
unsigned int, ata_id,
SOME_CLASS_NAME ata_addr,
unsigned int, ata_as);

and, want to use storein(some_vector)...

I understand that it is possible to fetch binary data using
'fetch_lengths' function (according to ML), but since I love power of
SSQLS, I prefer using it if possible. Or, prefer to write or modify some
template to achieve this. I tried to use string but string seems to be
not working well.

I checked mailing list but there are no mention about fixed length
binary as I check. I read reference but no mention about such. I will
read code, but I want to know whether it is possible to write it easily
or not...

Any information appreciated.

shigeya

PS. I didn't know about mysql++ - this library is really good. Actually,
I've tried to write DB independent C++ SQL DB libraries for three times
in last 12 years and always not satisfied with result.. Fortunately I
currently only need to use MySQL for my personal research purpose, so it
perfectly fit to my needs. thanks.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw


Reply With Quote
  #2  
Old   
AT
 
Posts: n/a

Default Re: fixed length char handling/declaration by SSQL - 07-18-2006 , 05:33 AM






Shigeya Suzuki wrote:
Quote:
I understand that it is possible to fetch binary data using
'fetch_lengths' function (according to ML), but since I love power of
SSQLS, I prefer using it if possible. Or, prefer to write or modify some
template to achieve this. I tried to use string but string seems to be
not working well.
From the Wishlist:

o Currently, all overloads for Query's execute(), store()
and use() methods eventually call the const char*
version, which does the actual work of executing the query.
This rules out query strings with embedded nulls, as you're
likely to get with BLOB columns. Also, it means MySQL++
must scan the string for length in a few places. The C API
isn't limited in this way if you use mysql_real_query(),
but you need an accurate length value to call it.

Fix by co-opting the first template query version of each
of these functions, as it takes a single SQLString, which
contains a length and doesn't care about nulls. Also add
an overload taking a const char* and a length parameter,
for cases where the user doesn't want to convert their
data to a std::string variant. Make the latter the actual
terminus of the call chain, as it's cheaper to convert from
SQLString to const char* than the reverse.

Implement that feature, and I believe your problem will be solved. Or,
wait for someone else to get to it. It should be in the next release,
whenever that happens.

Quote:
I've tried to write DB independent C++ SQL DB libraries for three times
in last 12 years and always not satisfied with result..
Again from the Wishlist:

o Abstract all uses of MySQL C API functions into a database
driver class with a generic interface. This is a step
towards database-independence....

In other words, we just haven't gotten to making MySQL++ database
independent yet. If you want to tackle this, too, I'd only caution that
it will break the ABI to do this right. That means we can't accept
patches for this until we're ready to do v3.0, at the earliest.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #3  
Old   
AT
 
Posts: n/a

Default Re: fixed length char handling/declaration by SSQL - 07-19-2006 , 11:57 AM





Warren Young wrote:
Quote:
From the Wishlist:

o Currently, all overloads for Query's execute(), store()
and use() methods eventually call the const char*
version, which does the actual work of executing the query.
This rules out query strings with embedded nulls, as you're
likely to get with BLOB columns. Also, it means MySQL++
must scan the string for length in a few places. The C API
isn't limited in this way if you use mysql_real_query(),
but you need an accurate length value to call it.

Fix by co-opting the first template query version of each
of these functions, as it takes a single SQLString, which
contains a length and doesn't care about nulls. Also add
an overload taking a const char* and a length parameter,
for cases where the user doesn't want to convert their
data to a std::string variant. Make the latter the actual
terminus of the call chain, as it's cheaper to convert from
SQLString to const char* than the reverse.

Implement that feature, and I believe your problem will be solved. Or,
wait for someone else to get to it. It should be in the next release,
whenever that happens.
OK. Since my time at this moment is very limited, I will write some
wrapper class to handle IPv6 address (it's two long longs).

Quote:
I've tried to write DB independent C++ SQL DB libraries for three times
in last 12 years and always not satisfied with result..

Again from the Wishlist:

o Abstract all uses of MySQL C API functions into a database
driver class with a generic interface. This is a step
towards database-independence....

In other words, we just haven't gotten to making MySQL++ database
independent yet. If you want to tackle this, too, I'd only caution that
it will break the ABI to do this right. That means we can't accept
patches for this until we're ready to do v3.0, at the earliest.
That's good, but again, due to limitation of spare time at this moment,
I will not work on this.

Hope I can contribute something in future.

Thank you!

shigeya

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.