Mika Raento wrote:
> Monty Taylor kirjoitti:
>> Monty Taylor wrote:
>>> Maybe we should load the data dictionary at initialization time and have
>>> our wrappers for equal and setValue for char* types do a lookup in the
>>> data dictionary on the column type and either space pad char columns or
>>> add length to the varchar columns. That could all be done once in C++ in
>>> the swig file and taken advantage of by all the languages. Sound
> Using the datadict sounds good. I could imagine taking much more
> advantage of it for scripting languages in general: create a single
> NdbRecAttr::value() as well which returns the correct target language
> type for the underlying database type (including making strings out of
> aRef() and get_size_in_bytes()).
Yes, I agree. I had also done this in the Python code, but I think that
doing it in the SWIG wrapper and using it everywhere will be good - at
least as much as we can.
>> + memcpy(theModifiedValue,theValue,strlen(theValue));
> I would like to pass in the length instead of strlen. This will make it
> possible to use with binary data which may include nulls. Most of the
> target languages already keep the length. I don't know if there's a nice
> way to split the string into data and length in SWIG or whether you need
> a small language-specific wrapper for that bit.
I agree. I think we can do this with typemaps perhaps. But I think we'll
also need a languages specific bit, as getting the length from each
language will be different.
>> I haven't really tested this yet - but I thought I'd get some thoughts
>> on this approach before going to far. What do you think? If you want to
>> avoid the switch, you can just use setValueRaw.
> I second keeping the raw interface available.
I did a quick test, and there are some issues with the code I posted,
namely I'm actually masking the setValue method I define with the rename
setValue statement. I'll figure that out in the morning - unless you
beat me to it. :)
MySQL Inc., www.mysql.com
Get More with MySQL! www.mysql.com/consulting