Re: cursor name mangling
Posted in 1997
<snip> >Note that the cursor_name() function is present in the 4.1x compiler >and >runtime, but it does nothing -- this allows the same source code to be >used >with either 4.1x or 6.0x I4GL. > In the 6.x family, the cursor_name() function ONLY EXISTS IN 6.01 and above. Yes, I have a customer on 6.00.UE4 - no cursor_name() function. Of course I develop under 6.02.UC1 so a quick check of the customers release notes and a hasty rewrite was called for! [We cannot upgrade the customer as they run another Infromix application which uses the Informix which WE provided] ^^^ ^^^ Grrrrrr! >> Thanks for listening. If you think it's worth posting this to the >rest >> of comp.databases.informix I will. > >Yes, it's probably worth posting it, as amended. Also notify David >Williams who has just taken over the FAQ... > Yep, I'm on it! PS I'm Reeealy close to releasing a new version - I just finished merging new ideas into the FAQ ~ 2am last night! I haven't tried viewing it yet but I'm still moving forward on the new version... >Yours, >Jonathan Leffler (johnl@informix.com) #include <witticism.h> > > >======================================================================= >=== > >Date: Tue, 9 Aug 94 07:59:49 PDT >From: johnl@anubis (Jonathan Leffler) >Subject: Re: 4371 error at compile time, 4GL 6.00.UE1 > >>Date: Tue, 9 Aug 94 09:28:56 CDT >>From: joea@jupiter2 (Joe Arroyo) >>Subject: 4371 error at compile time, 4GL 6.00.UE1 >> >> IHAC reporting that at compile time he receives a -4371 error. >> >> -4371 Cursors must be uniquely declared within one program >module. >> >> He just upgraded to I-4GL RDS version 6.0, Online 6.0 and >changed >> the program to add the Declare Cursor. He claims that the cursor >> name is used only once. >> >> Caselog isn't providing me much help, I've also checked PTS and >> couldn't find any matches. If anyone has upgraded to 6.0 and >> experienced this problem I would like to hear from you or if you >> know what might be causing this error feel free to respond. > >Version 6.00 4GL (both c-code and p-code) uses 6.00 ESQL/C, and 6.00 >ESQL/C >provides only global cursor names. (The -local option to esql doesn't >work >reliably unless your cursor names are short enough: 9 is the maximum >guaranteed to work; anything longer than 16 definitely won't work; >anything >in between may or may not work, depending on the inode number of the >source >file.) I4GL has always worked with cursor names local to the source >file. >To try and maintain the previous semantics, we mangle the cursor names >using an algorithm based on the inode number and the cursor name. All >cursor and statement names therefore look like I01234568_12345678, >where >the digits are in hex. You can suppress this transformation by using >the >-globcurs option to either fglpc or c4gl. > >I need a list of all the cursor names and statement names from the >module >where your customer is running into problems, so that I can see which >two >are hashed to the same value, and we may need to improve the hashing >algorithm. Without this information, the problem cannot be resolved in >the >future. > >Changing the cursor name will fix the problem. Using -globcurs will >fix >the problem in this file -- be wary of using it generally because if >you >use the same cursor name in two different files, they must NOT both be >compiled with -globcurs. Reading the TOOLREL_6.0 release notes (page >14) >would reveal a discussion of this issue, though error 4371 is not >mentioned. See also B31661 for another aspect of this problem. > >Yours, >Jonathan Leffler (johnl@godzilla) > >Date: Wed Aug 2 10:34:31 1995 >From: johnl (Jonathan Leffler) >To: informix-list@rmy.emory.edu >Subject: Cursor Name Mangling -- clashes > >Hi, > >The 6.0x versions of I4GL try to preserve the local cursor and >statement >name semantics of 4.1x ESQL/C, even though 6.0x ESQL/C does not provide >such support. (Don't point out the '-localcurs' option to ESQL/C -- it >doesn't work adequately.) To do so, the I4GL compiler hashes the >cursor >names using an arcane algorithm which is documented in the release >notes. > >Unfortunately, the algorithm is such that if two statement names are >the >same apart from the last two characters, and if the last two characters >of >the two names are one of the 240 pairs listed below, then the names >will >hash to the same value, leading to compilation problems. I attach the >program used to generate this listing so you can reproduce it if you >need >to. Note that it does not test '_' or the digits, so the list is not >100% >complete. > >Advice: make cursor and statement names differ with the early parts of >the >names rather than the later parts of the name. Make the names differ >by >more than two trailing characters. > >Yours, >Jonathan Leffler (johnl@godzilla) > >======================================================================= >=== > >MAIN > > DEFINE i INTEGER > DEFINE j INTEGER > DEFINE n1 CHAR(2) > DEFINE n2 CHAR(2) > DEFINE c1 CHAR(18) > DEFINE c2 CHAR(18) > > FOR i = 0 TO (26 * 26 - 1) > LET n1 = basic_name(i) > LET c1 = CURSOR_NAME(n1) > FOR j = i + 1 TO (26 * 26 - 1) > LET n2 = basic_name(j) > LET c2 = CURSOR_NAME(n2) > IF c1 = c2 THEN > DISPLAY n1, " & ", n2 > END IF > END FOR > END FOR > >END MAIN > >FUNCTION basic_name(i) > > DEFINE i INTEGER >-- DEFINE j INTEGER >-- DEFINE k INTEGER >-- DEFINE c1 CHAR(1) >-- DEFINE c2 CHAR(1) > DEFINE s CHAR(2) > >-- LET j = (i / 26) + ORD("a") >-- LET k = (i MOD 26) + ORD("a") >-- LET c1 = ASCII(j) >-- LET c2 = ASCII(k) >-- LET s = c1, c2 > LET s = ASCII((i / 26) + ORD("a")), ASCII((i MOD 26) + ORD("a")) > > RETURN s > >END FUNCTION > >======================================================================= >=== > >aq & ba ar & bb as & bc at & bd au & be av & bf aw & bg ax & bh >ay & bi az & bj bq & ca br & cb bs & cc bt & cd bu & ce bv & cf >bw & cg bx & ch by & ci bz & cj cq & da cr & db cs & dc ct & dd >cu & de cv & df cw & dg cx & dh cy & di cz & dj dq & ea dr & eb >ds & ec dt & ed du & ee dv & ef dw & eg dx & eh dy & ei dz & ej >eq & fa er & fb es & fc et & fd eu & fe ev & ff ew & fg ex & fh >ey & fi ez & fj fq & ga fr & gb fs & gc ft & gd fu & ge fv & gf >fw & gg fx & gh fy & gi fz & gj gq & ha gr & hb gs & hc gt & hd >gu & he gv & hf gw & hg gx & hh gy & hi gz & hj hq & ia hr & ib >hs & ic ht & id hu & ie hv & if hw & ig hx & ih hy & ii hz & ij >iq & ja ir & jb is & jc it & jd iu & je iv & jf iw & jg ix & j