Error 8514, out of temp string space
Posted in 1995
If you get the -8514, out of temporary string space error, here is a techinfo from informix to help you find the problem. Please forgive and typo's, I typed it in from a fax I have, and I don't touch type very well. Paul Watje watjep@hasting.com +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ TechInfo #3925 Short Description: Temporary String Space by Loren West (-4518 errors) Long Description: Author: Loren West of FourGen Software, Inc. (uunet!4gen!lorenw) Temporary String Space (TSS) by Loren West My understanding of how Informix handles Temporary String Space has increased dramatically over the last couple of months, and I'd like to share that information for anyone (everyone) that has ever had a string space problem. 1) TSS in Informix is limited. It is only about 4k or so. 2) Very few things required TSS. Usually, those things use it, then clear the entire TSS when they are done. In my opinion, Informix's 4k limit on TSS is adequate. It only becomes a problem under certain ( and completely avoidable) circumstances. 3) TSS is used in the following scenarios: A) Passing strings to and returning strings from functions B) Internal scratchpad usage within certain 4GL commands. * Scenario (A) is blamed for 4GL running out of temporary string space. It also, usually, is not the source of the problem. 4) In order to understand the source of the problem, it's important to understand how temp string space is used, and when it's cleared. When a string is passed to a 4GL function, the calling function places it into TSS. IMMEDIATELY upon invocation, the called function retrieves it into a local variable, and ( and this is the key) if there is nothing else in TSS, the ENTIRE TSS is cleared and reset. If there is something else in TSS, it waits until that something is used, THEN it resets TSS. If that something never used it, then you get the out of string space problem. The following example shows normal TSS usage: 1 main 2 call myfunct("Hello") 3 end main 4 5 function myfunct(str_var) 6 define 7 str_var char(20) 8 display str_var clipped, " World" 9 end function In the above example, line 2 places the string "Hello" into TSS. Line 7 actually retrieves "Hello" from TSS, puts it into the local str_var variable, and because there is nothing else in TSS< it is cleared and reset. Line 8 puts str_var into TSS, then puts " World" into TSS, the calls (an internal 4GL) display function. This display function retrieves "Hello" from TSS, the retrieves " World" from TSS, then (because there is nothing else on the stack) clears and resets TSS. I then goes about it's business of displaying "Hello World" onto the screen. The following example show how you can get into trouble with TSS: 1 main 2 define 3 local_var char(20) 4 let local_var = "Hello", myfunct(" World") 5 end main 6 7 function myfunct(str_var) 8 define 9 str_var char(20) 10 return str_var 11 end function In line 4, the "Hello" string is put into TSS (for the 'let' command), then " World" is placed into TSS for the function call to myfunct(). The difference here is line 9. When " World" is removed from TSS, it is not cleared because "Hello" is still there. In line 10, TSS is used again to return the string " World" back to the calling function. At this point, TSS contains the following: "Hello" " World" " World" When myfunct() returns, " World" is taken from the TSS, then put back into the TSS for the let command to process. At this time, TSS looks like: "Hello" " World" " World" " World" Finally, the let command gets the " World", then the "Hello", and when it gets the "Hello", the TSS is cleared. This is a normal situation. It used TSS, but not much, and it is appropriately cleared after the 'let' command is done processing. The problem that can arise using this syntax is if the myfunct() command doesn't return right away. If myfunct() calls alot of different functions, and if those functions consume any TSS, then it will not be reset until the first 'let' command has finished processing. You're very likely to get a string space error in this scenario. 5) The following scenarios will result in an out of string space error if the function that is called is a "string hog" ( a string hog function is on that uses TSS alot - not necessarily one that uses alot of TSS, but one that uses TSS alot): A) call a function from within a string concatenation. This will error: let a_string = "Hello", string_hog() This will not: let temp_string = myfunct() let a_string = "String", temp_str B) Using the 'case' command with a string argument: This will error: case a_string when "A" display "OK" when "B" call string_hog() end case This will not: case when a_string = "A" display "OK" when a_string = "B" call string_hog() end case Note also that the 'using' keyword can be categorized as a 'string hog' function. This doesn't mean that it inappropriately uses TSS, it just uses alot. 6) In most cases, finding the source of the string space error is incredibly difficult. It usually is caused in a function far away form the place that the program actually fails. What follows is a function that is guaranteed to work if TSS is clear, and is guaranteed to fail if TSS has something in it. Since there is no way of printing out the TSS, I suggest setting breakpoints in you program (using the debugger), and calling this function from the debugger command line. If you get the string space error when you call this function, then there definitely is something in TSS. If you don't get an error, then there is definitely nothing in TSS. Once you get the error, keep running the program the same way, (calling this function from the debugger command line) and setting breakpoints earlier and earlier. Using this method, you should be able to find the place in the program that uses TSS without resetting it. In most cases, the fix is to write the chunk of code in a different way. Your might find that the error occurs in a C function that you have written. It is very easy to write a C function that doesn't use TSS properly. Because of the fact, also don't