Open anjohnson opened 6 years ago
I'm not clear on how this would work. I guess you mean to use dbChannelFinalFieldSize(chan)
instead of MAX_STRING_SIZE
? Can I do this through dbGet()
?
For monitors and gets using dbChannelFinalFieldSize(chan)
would allow any filters to modify the string (not that we have any filters that do string processing yet to my knowledge), so yes. For puts you could use dbChannelFieldSize(chan)
to determine the max length if you need it.
This may be harder than I thought to do properly though, and we might want to change dbAccess to make it simpler. As I showed above a pvget from pvaSrv works, but that's because the code just copies an unlimited zero-terminated string from static_cast<char *>(dbChannelField(chan))
. For most uses that should work, but it isn't bullet-proof against an unterminated string. I don't see a problem with copying up to a zero-terminator as long as you take no more than dbChannelFinalFieldSize(chan)
bytes.
The code for dbGet(chan, DBF_STRING, pbuffer 0, 0, 0)
can't handle long strings because there's no way to tell it how big pbuffer is, so it uses the smaller of MAX_STRING_SIZE
or chan->addr.field_size
. I already added special routines for handling long strings to dbLink.c in 3.15, and we might want to do something similar in dbAccess.c for dbGet()
and dbPut()
.
This may be harder than I thought to do properly though
This was my reading of the situation :)
we might want to do something similar in dbAccess.c
I would prefer this to filling up QSRV with workarounds for limitations in this API.
Since QSRV talks directly to dbAccess it could determine how long a DBF_STRING field's buffer is (they are allowed to be longer than MAX_STRING_SIZE, e.g. the
NAME
field, and theVAL
fields of the lsi, lso and printf record types). QSRV could thus provide access to long string fields without truncation, although it doesn't at the moment.This is using pvaSrv, which handles this long string's value (although possibly more by luck than by design):
This is using QSRV, which truncates the long string's value at 39 characters: