From tsilveri Sun Apr 24 11:49:05 1994
Received: by cs.uml.edu id AA17269
  (5.67a+/IDA-1.5); Fri, 22 Apr 1994 19:34:32 -0400
From: Bob Lechner <lechner>
Message-Id: <199404222334.AA17269@cs.uml.edu>
Subject: Notes on  genv7 bug meeting today 4/22
To: jhyun@cs.uml.edu, mcook@cs.uml.edu, mlamson@cs.uml.edu, hsano@cs.uml.edu,
        jmin@cs.uml.edu, mkeswani@cs.uml.edu, tsilveri@cs.uml.edu,
        schetty@cs.uml.edu, sharpana@cs.uml.edu, bguddeti@cs.uml.edu,
        fakhursh@cs.uml.edu, cyeng@cs.uml.edu, czhou@cs.uml.edu,
        wwenyen@cs.uml.edu, dolu@cs.uml.edu, namin@cs.uml.edu,
        dgrant@cs.uml.edu, tseeley@cs.uml.edu, wward@cs.uml.edu,
        jrichard@cs.uml.edu, lking@cs.uml.edu, mtorpey@cs.uml.edu,
        nosulliv@cs.uml.edu, zbrundag@cs.uml.edu, schiou@cs.uml.edu,
        dtong@cs.uml.edu, sislam@cs.uml.edu
Date: Fri, 22 Apr 1994 19:34:31 -0400 (EDT)
X-Mailer: ELM [version 2.4 PL22]
Content-Type: text
Content-Length: 4425      
Status: OR

CYeng and WWenyen met with me today regarding a genv7 test
whose results  we don't understand. Genv7 is used by OLCArch.
The session revealed some problems with chgen v7 and potentially 
with gen v8.

Genv7 has the 32-bit internal key format (type hcg_key) but
not the pr_create/set/get/add sequence of calls to encapsulate access
to table fields; the latter was introduced in chgen v6.5 and merged into genv8.
Bde ignores version numbers and may not be affected.

Meets_view location used/checked:
tern(129)> grep meets_view *.c
pr_load.c:112:int meets_view(tbl_idx,view_idx,pkey)
tern(130)> pwd
/nfs/cs/proj3/case/94s523/94solc/cyeng/build3

1. The mysterious bug:
----------------------

CYeng tried pr_adding a literal string constant instead
of a string buffer variable, to resolve a problem with the OPclass
'add viewname table-row-string'  operator command.
This command failed to add a record with pkey BA010003 
after pr_loading a database which already contained BA010001 and BA010002.

More precise tests showed that BA010003 was not added
when pr_add is passed the string entered by the operator,

The reason is still a mystery. It may hve to do with the fact that in 
this case the usual call to pr_gen_pkey is bypassed. 
Any subsequent pr_gen_pkey(view, ttabbrev, ttkey) command will 
probably re-use BA010003 and overwrite the operator-added record. 
THus, the OPerator 'add' command needs fixing to 'do the right thing' 
by informing pr_gen_pkey to update its statistics on max pkey value 
for table BA. A generic fix to chgen requires more study.

Similarly, any add commands contained in the script file need to maintain
the integrity of the max pkey value in some way for pr_gen_pkey. 

Although the above fix is necessary in the long run, it will not 
necessarily fix the 'add' problem. We can't figure out why BA010003 
is not added. 

NOTE: RUnning chgen -DDEBUG will cause pr_add to log to stdout every 
record that it adds to the database. Unfortunately the #ifdef DEBUG
code merely prints the buffer argument to pr_add, not the actual 
contents of the struct that was added, if any.

------------------------------------------------------------------------

2. The meets_view problem:
-----------------------
In the course of inspecting pr_add and pr_dump we  also discovered 
a problem with meets_view: Meets_view is now trivial: it returns
the constant 1. It should be used by pr_add to reject any record whose
type is not in the viewname passed as its first argument, 
or whose version number does not agree with the view's specification
for that table. I suspect that meets_view was trivialized to avoid a problem 
with adding pkeys using version 0: this is not compatible with the
logic of (former) meets_view because there was no way to select an 
absolute version number of 0.  The chgen user guide specifies that 
the view contain a list of <tablename, version-spec> pairs,
with the  meanings:
	k = 0 meaning 'highest existing version#', whatever that is, 
	k > 0 meaning 'absolute version# k',
	k < 0 meaning '(highest version#) - k'  (k-th highest version)

Meets_view was designed to reject any record that is not on the table
list or that is on the list but has the wrong version number.
This means that at most one version of a table can be pr_dumped
per view. To dump two versions requires two pr_dump cals with distinct
version numbers in the viewname arguments.

The trivialized meets_view had no reason to be called, so there are 
no view table and version checks in chgem v7's utilities.
This is not important now but will eventually have to be fixed
(when view and version control are needed in chgen applications).


[DEBUGGING NOTE: a view could be specifed containing tables EI and AI only, 
for use as a debug aid: e.g., dump the EI and AI tables at start and end 
of the k-th iteration of the main loop to files checkpoint-odd.k and 
checkpoint-even.k: if table EI contain any duplicates, the que is not 
completely consumed, deleted and re-filled during the cycle.
The AI tables should identify each AI whose current state has been 
changed by actions during the cycle and (indirectly) each transition that 
was made and the event type that caused it.]

------------------------------------------------------------------------
3. TBD: search genv6/7/8 reports for mention of bugs/fixes,
and also for the reasons why genv7 trivialized and then dis-used
function meets_view.




From lechner Fri Apr 22 20:07:05 1994
Subject: More info onmeets_view
To: lechner (Bob Lechner)
Date: Fri, 22 Apr 1994 20:07:05 -0400 (EDT)
Cc: cyyeng, wwenyen (Wenyen Wang(William))
X-Mailer: ELM [version 2.4 PL22]
Content-Type: text
Content-Length: 4535      
Status: OR

meets_view is discussed in final_report.tex in 
	/nfs/cs/proj3/case/gen/ver_7/doc.
There it is non-trivial (grep meets_view fin*.tex ==> line 439 and 2527):
---------------------------------------------------------------------
Line 439:
table_loop: calls: find_view_idx, meets_view
Expected Result: loops through given table, stopping at all rows that
                 meet the version for this view
Correct Result: Yes

      meets_view:
      Expected Result: Status indicating whether given row is visible
                       in a given view
      Correct Result: Yes
------------------------------------------------------------------
Line 2526:
\begin{verbatim}
int meets_view(tbl_idx, view_idx, pkey)
\end{verbatim}

This function is always called with a form of tbl\#\#curr->tbl\#\#id
Thus, it is always passed an integer key.

\vspace{1ex}
\noindent
Old code:
\begin{verbatim}
int tbl_idx, view_idx;
char *pkey;
{
char ver_temp[3];
strncpy(ver_temp, pkey+2,2);
ver_temp[2] = '\0';
return(hcg_view_list.view_list[view_idx].version_list[tbl_idx] ==
        (char) atoi(ver_temp));
}
\end{verbatim}

\noindent
New code:
\begin{verbatim}
int tbl_idx, view_idx;
key_t pkey;
{
return(hcg_view_list.view_list[view_idx].version_list[tbl_idx] ==
        (get_version(pkey)));
}
\end{verbatim}

-----------------------------------------------------------------------
Here is what the source code contains:

tern(171)> pwd
/nfs/cs/proj3/case/gen/ver_7/src/SCCS
tern(172)> grep meets_view s.*.c 
s.gen_defines.c:1408:    fprintf(schh_fp,"   if ((meets_view(tbl%s_idx,hcg_view_idx,tbl%scurr->tbl%sid)) &&\\\n",sep,sep,sep);
s.gen_defines.c:1427:    fprintf(schh_fp,"   if ((meets_view(tbl%s_idx,hcg_view_idx,tbl%scurr->tbl%sid)) &&\\\n",sep,sep,sep);
s.gen_defines.c:1446:    fprintf(schh_fp,"   if ((meets_view(tbl%s_idx,hcg_view_idx,tbl%scurr->tbl%sid)) &&\\\n",sep,sep,sep);
s.gen_defines.c:1471:    fprintf(schh_fp,"  if (meets_view(tbl%s_idx,hcg_view_idx,tbl%scurr->tbl%sid))\n\n",sep,sep,sep);
s.gen_defines.c:1514:    fprintf(schh_fp,"   if ((meets_view(tbl%s_idx,hcg_view_idx,tblvar->tbl%sid)) &&\\\n",sep,sep);
s.gen_defines.c:1532:    fprintf(schh_fp,"   if ((meets_view(tbl%s_idx,hcg_view_idx,tblvar->tbl%sid)) &&\\\n",sep,sep);
s.gen_defines.c:1557:    fprintf(schh_fp,"  if (meets_view(tbl%s_idx,hcg_view_idx,tblvar->tbl%sid))\n\n",sep,sep);

Of particular interest is this line:

s.gen_pr_utils.c:20:c Added additional fix to meets_view for zero version problem
s.gen_pr_utils.c:242:   fprintf(prload_fp, "int meets_view(tbl_idx,view_idx,pkey)\n");
tern(173)> 

------------------------------------------------------------------------

Line 20 says:
^As 00004/00000/00248
^Ad D 1.4 92/12/22 10:46:27 cmurphy 4 3
^Ac Added additional fix to meets_view for zero version problem
--------------------------------------------------------------------
gen_pr_utils (via sccs get from the above SCCS directory) contains  
the nontrivial definition of meets_view (latest version):

        fprintf(prload_fp, "/******************************************************************************/\n");
        fprintf(prload_fp, "/* This routine will extract a version number and row_number out of the       */\n");
        fprintf(prload_fp, "/* specified key value.  The results are stored in the globals hcg_version    */\n");
        fprintf(prload_fp, "/* and hcg_row.                                                               */\n");
        fprintf(prload_fp, "/******************************************************************************/\n");
        fprintf(prload_fp, "/* This function will determine if the specified key value meets the          */\n");
        fprintf(prload_fp, "/* proper version for that table in the specified view idx.                   */\n");
        fprintf(prload_fp, "/******************************************************************************/\n");
  /**** 93s523 ****/
        fprintf(prload_fp, "int meets_view(tbl_idx,view_idx,pkey)\n");
        fprintf(prload_fp, "int   tbl_idx;\n");
        fprintf(prload_fp, "int   view_idx;\n");
        fprintf(prload_fp, "key_t pkey;\n");
        fprintf(prload_fp, "{\n");
#ifndef NEW_VERSION
        fprintf(prload_fp,"  return(hcg_view_list.view_list[view_idx].version_list[tbl_idx] == (get_version(&pkey)))\n");
#else
        fprintf(prload_fp,"  return(1);\n");
#endif
        fprintf(prload_fp, "}\n\n");

----------------------------------------------------------------


Therefore it is still a mystery why meets_view was trivialized.

From lechner Sat Apr 23 00:08:07 1994
Received: by cs.uml.edu id AA01821
  (5.67a+/IDA-1.5); Sat, 23 Apr 1994 00:08:06 -0400
From: Bob Lechner <lechner>
Message-Id: <199404230408.AA01821@cs.uml.edu>
Subject: NEW_VERSION flag
To: cyeng (Cheng-Lu Louis Yeng), wwenyen (Wenyen Wang(William))
Date: Sat, 23 Apr 1994 00:08:05 -0400 (EDT)
Cc: lechner (Bob Lechner)
X-Mailer: ELM [version 2.4 PL22]
Content-Type: text
Content-Length: 1142      
Status: OR

#Ifdef NEW_VERSION controls meets_view definition.
THe makefile in /nfs/cs/proj3/case/gen/ver_7/test/schooldb8
omits it:
---------------------------------------------------
tern(557)>  cat Makefile
# This Makefile was generated by maker: the makefile generator (c) 1991 AJS.
# This Makefile is in the public domain -AJS
# There is NO WARRANTY on this software... 
#

CFLAGS = -DNEW_VERSION
# LDFLAGS = -s
# Comment these lines out to avoid info for the debugger.

CC = /bin/cc
RM = /bin/rm -f

OFILES = schooldb.o pr_delete.o pr_load.o pr_dump.o pr_stats.o pr_free.o
LIBS = 
EXEC-NAME = schooldb

all: ${EXEC-NAME}
${EXEC-NAME}: ${OFILES}
        ${CC} ${LDFLAGS} -o $@ ${OFILES} ${LIBS}
clean:
        ${RM} ${OFILES} ${EXEC-NAME} core a.out

tern(558)> pwd
/nfs/cs/proj3/case/gen/ver_7/test/schooldb8
tern(559)> 

--------------------------------------------------
Unfortunately the pr_*.c code in those testcase/src directories
does NOT reference meets_view: it is onluy declared:

tern(569)> grep meets_v pr*.c
pr_load.c:112:int meets_view(tbl_idx,view_idx,pkey)
tern(570)> pwd
/nfs/cs/proj3/case/gen/ver_7/test/schooldb8
tern(571)> 

--


