Newsgroups: comp.databases.informix
Subject: Cursor Name Mangling -- clashes

From: johnl@informix.com (Jonathan Leffler)
Date: 2 Aug 1995 14:13:04 -0400

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 & jh
iy & ji  iz & jj  jq & ka  jr & kb  js & kc  jt & kd  ju & ke  jv & kf
jw & kg  jx & kh  jy & ki  jz & kj  kq & la  kr & lb  ks & lc  kt & ld
ku & le  kv & lf  kw & lg  kx & lh  ky & li  kz & lj  lq & ma  lr & mb
ls & mc  lt & md  lu & me  lv & mf  lw & mg  lx & mh  ly & mi  lz & mj
mq & na  mr & nb  ms & nc  mt & nd  mu & ne  mv & nf  mw & ng  mx & nh
my & ni  mz & nj  nq & oa  nr & ob  ns & oc  nt & od  nu & oe  nv & of
nw & og  nx & oh  ny & oi  nz & oj  pq & qa  pr & qb  ps & qc  pt & qd
pu & qe  pv & qf  pw & qg  px & qh  py & qi  pz & qj  qq & ra  qr & rb
qs & rc  qt & rd  qu & re  qv & rf  qw & rg  qx & rh  qy & ri  qz & rj
rq & sa  rr & sb  rs & sc  rt & sd  ru & se  rv & sf  rw & sg  rx & sh
ry & si  rz & sj  sq & ta  sr & tb  ss & tc  st & td  su & te  sv & tf
sw & tg  sx & th  sy & ti  sz & tj  tq & ua  tr & ub  ts & uc  tt & ud
tu & ue  tv & uf  tw & ug  tx & uh  ty & ui  tz & uj  uq & va  ur & vb
us & vc  ut & vd  uu & ve  uv & vf  uw & vg  ux & vh  uy & vi  uz & vj
vq & wa  vr & wb  vs & wc  vt & wd  vu & we  vv & wf  vw & wg  vx & wh
vy & wi  vz & wj  wq & xa  wr & xb  ws & xc  wt & xd  wu & xe  wv & xf
ww & xg  wx & xh  wy & xi  wz & xj  xq & ya  xr & yb  xs & yc  xt & yd
xu & ye  xv & yf  xw & yg  xx & yh  xy & yi  xz & yj  yq & za  yr & zb
ys & zc  yt & zd  yu & ze  yv & zf  yw & zg  yx & zh  yy & zi  yz & zj

===========================================================================
