Back Midas Rome Roody Rootana
  Midas DAQ System  Not logged in ELOG logo
Entry  26 Apr 2017, Konstantin Olchanski, Info, added db_get_value_string() 
    Reply  26 Apr 2017, Stefan Ritt, Info, added db_get_value_string() 
       Reply  02 May 2017, Konstantin Olchanski, Info, added db_get_value_string() 
    Reply  02 May 2017, Konstantin Olchanski, Info, added db_resize_string() 
Message ID: 1284     Entry time: 02 May 2017     In reply to: 1280
Author: Konstantin Olchanski 
Topic: Info 
Subject: added db_resize_string() 
> Since we have been regularly running into problems with db_get_xxx(TID_STRING) and string buffers of mismatched size,
> I now implemented db_get_value_string(hdb, hkey, key_name, index, &string, create).

I run into problems with string arrays - non-array strings have unlimited length, but string arrays have fixed string length, usually set at creation time.

This causes a problem with growing arrays using db_get_value_string(), when converting a non-array variable to an array, the wrong
string length gets used, and one gets an array with useless string length. There is no way to specify the correct array string length
without adding more parameters to db_get_value_string() and confusing and complicating it for the typical case where it is used
against simple (non-array) odb entries.

To clarify the situation, db_get_value_string() was changed to reject attempts to resize an array and
calls of db_get_value_string(index>0 and create==TRUE) now return an error.

To create and resize string arrays, I added a new function - db_resize_array(hdb, hkey, key_name, num_values, max_string_size).

Here,
num_values is the new array size, making it possible to grow or shrink an array
max_string_size is the new string size, making it possible to change the array string length after the array was created (there was no midas function to do this before now).

I added a json-rpc call for db_resize_string().

But it still needs to be added to odbedit and mhttpd.

K.O.
ELOG V3.1.4-2e1708b5