Re: Informix/4GL REALLY SUCKS
Posted in 1997
Well, if you've been following this thread like I have (and maybe David Williams is the only one to give a half-assed reading to my post...yes it was half-assed David!), then you'll be very interested to know that for some strange reason, Informix appears to have written the retflo() function, and presumably the retdub() function completely inconsistently with all their other retxxx() functions. I am very eager to get to work tomorrow and actually check the docs, but it appears that while retint() and retlong() accept 'pass-by-value', retflo() demands pass by reference. WHY? I cannot fathom why...If anyone has an explanation, I'd love to hear it. Obviously retquote() is a special case which would demand the reference and not the value but retflo()? Okay, even if there is a reasonable explanation for pass-by-reference for retflo(), why the hell!!!! doesn't Informix provide a function prototype (as in a header file) so the compiler will warn me when I pass it a float instead of a pointer to a float? [If the documentation is really correct and I just missed this, PLEASE don't ignore the question as to the lack of a header file! Header files are a VERY important part of the C language and are intended to allow people to know how to use functions without the need to know what goes on in the internal workings of those functions....as if I really want to know why 4GL can't use standard argument passing.] Also, if there really is a need to be inconsistent, a more obvious notation in the docs would be in order!!! If indeed, the manual correctly showed that retflo() wanted a pointer and not a value, I certainly missed it....and it's not surprising....again, why would you need anything than a standard C data value? C'mon, Informix....people still do use 4GL, although we are rapidly moving away from it and in fact rapidly moving away from dependence on any one specific database engine....Despite market considerations, you're total abandonment of 4GL as a development tool is another major reason.....Are you listening Leffler? Tell me why this is not an inconsistency in the 4GL toolset! This is one example, where you can't say we can solve all our problems by upgrading....and then telling us the next release won't be available for another 3 months. Daniel Wright wrote: > Well, I realize I was rambling a bit, and I did review the Informix manual, > which stated something like popquote() fills in your string with 'len' (the > 2nd argument number of bytes), including the null terminator. It apparently > doesn't know what to do if you are only interested in one character. I was > not using it as a string although I did declare my variable to be long enough > to hold the null terminator....my referencing it as *f_ptr_to_char, doesn't > care about a null terminator either. > > My complaint was that the error message states that in an ESQL/C program, I > have FETCH'ed something into a variable which is too small, and that in a 4GL > program, you should contact Informix. Well, apparently the error was in the > '.ec', but of course it is not stopped until it returns to 4GL. Since I > didn't have any FETCH statements anywhere, it seemed to be a 4GL problem. > > You suggested that I send the C & 4GL program to you to find where I was > destroying memory, THANKS, but I am now convinced I am handling all my > pointers correctly. What I am NOT convinced of is that I am using the poorly > documented 4GL routines properly, although from reading the manual, I believe > I am. > > Anyway, here's the code, and it's output: (please advise as to what I am > doing wrong) > > dev:/home/dannyw> cat fgl.4gl > {******************************************************************************* > > *******************************************************************************} > > MAIN > DEFINE f_tote_time FLOAT > > WHENEVER ANY ERROR STOP > > DISPLAY "BEFORE" > > CALL get_hndl_time_4gl( ) > RETURNING f_tote_time > > DISPLAY "AFTER", f_tote_time > > END MAIN > dev:/home/dannyw> cat ec1.ec > /******************************************************************************* > > get_hndl_time_4gl - set up handling time array and return total tote > time > *******************************************************************************/ > > int get_hndl_time_4gl( int f_argc ) > { > > if (f_argc) > return(0); /*** This should cause a complaint about not > returning proper number of values ***/ > > printf("HERE\\n"); > /*** retquote( "0.023" ); THIS WORKS ***/ > retflo( 0.023 ); /*** THIS core dumps ***/ > printf("THERE\\n"); > return(1); /* ZZZ */ > } > > /*************************************************************************** > * END OF SOURCE > ***************************************************************************/ > dev:/home/dannyw> c4gl ec1.ec fgl.4gl > ec1.c: > fgl.c: > dev:/home/dannyw> ./a.out > BEFORE > HERE > Segmentation fault(coredump) > dev:/home/dannyw> > > Interestingly enough, only floating point retxxx() functions (retdub() and > retflo()) seem to fail. > As is alluded to in the source, retquote() provides the desired result. > > If it looks right to you, try it on your machine and tell me if it > runs....Thanks > > David Williams wrote: > > > In article <2E6586C13341E60D.DF49B756DA06A631.F9B3D91E02C0C761@library- > > proxy.airnews.net>, Daniel Wright <dw420@airmail.net> writes > > >Well, this is one of those misleading error messages I suppose.... > > > > > >My program is written in 4GL and ESQL/C and this is probably totally > > >unrelated to why it started core-dumping (I must be doing something > > >wrong), but it consistently core-dumps when I call retflo() with a value > > >other than zero....no matter if it is hard-coded, cast to a float or > > >whatever.....but I'm still debugging that. This message is about the > > >misleading error message I got. > > > > > >After adding "WHENEVER ANY ERROR STOP" to the code, I got the following > > >output (even after I reduced it to a minimum amount of code, with no > > >database references and no pointer references). > > > > > >dev/home/dannyw/dsc1/inv/ictl> ./a.out > > >Program stopped at "fu_4gl.4gl", line number 8. > > >FORMS statement error number -1235. > > >Character host variable is too short for the data. > > >dev/home/dannyw/dsc1/inv/ictl> finderr 1235 > > >-1235 Character host variable is too short for the data. > > > > > You've tried to put something into a varable and the variable > > is too small. > > > > >In an ESQL/C program, the program has attempted to fetch a column value > > >into a host variable that is not large enough. Use the DESCRIBE command > > >to find out the sizes of column values. > > > > > >If this error arises in a 4GL program, please note all circumstances, > > >and contact the Informix Technical Support Department. > > > > > >Since I naively believed Informix's explanation and wasn't doing any > > >FETCH in my EC module, I presume