From lechner@cs.uml.edu  Fri Oct  7 17:43:58 2005
Subject: Re: 91-523: Question about [*.viewdefs] file
To: ralmonte@cs.uml.edu (Robert Almonte)
Cc: 05f523,SFrye
RJLRef: $PH/COOL-GEN/viewdefsHelp051007.txt
This is a long response to another RAlmonte question.
Only part 1 is relevant to the take-home exam:

$CASE/gen/ver_13/chgen/NEW_VERSION_FLAG.hlp
= $PH/COOL-GEN/ver_13/chgen/NEW_VERSION_FLAG.hlp
is now a symlink to here and is appended at end-RJL070305)

R Lechner

> From ralmonte@cs.uml.edu  Thu Oct  6 19:38:33 2005
> To: "Bob Lechner" <lechner@cs.uml.edu>
> Subject: Re: 91-523: Question about take home 1.
> 
> About Question T1.
> 
> Does the viewname parameter to pr_dump() only affect how the column will be
> displayed ?
> 
> Where can I find a viewname file sample?
> 
> Thanks,
> 

1. The Chgen Users Manual[s] have a section on View Definition specs
[You all should have read this by now.]

Viewdef files contain viewnames and their table type and version# content.
(These could easily be sucked into a larger metaschema and .msdat file.)
It does NOT affect column format - only the schema controls that now.

For bde, here are current .viewdef file names:
-----------------
saturn.cs.uml.edu(18)> lf ~/bde2alpha_rl/sandbox/bdeNT050526/bdegen13/bde/lib
CVS/                          bdetest.viewdefsBdeOnly*
bde.defaults                  bdetest02f522Team1.viewdefs*
bdenew.dat                    fonts.dat
bdetest.viewdefs              su93defaults.dft
saturn.cs.uml.edu(19)>
-----------------

Views list table types AND a version# and an output mode (r/w/a)
that applies to (all) row objects of that  table type.
See examples for format, chgen User Manuals since genv7 for meaning.

pr_util function/macro meets_view() does the I/O policing.
Meets_view used to have a 'NEW_VERSION' flag 
that disabled it completely  (#ifndef NEW_VERSION ...)
(a brute-force way to avoid version# dependency).
Unfortunately it disables TableType restrictions also.
(NEW_VERSION flag is used in chgen/src/Makefile, not at runtime)
(TBD: a simple fix would be to
disable version# checks but not table type check in meets_view.)

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


2. Possible future extensions (not for this exam):
--------------------------

This exam or my email to SFrye may have mentioned a future
restriction on columns for SQL use,  but that would have
to be added to the View.
(probably by listing a subset of field names within each table
and specifying an order for the selected TA-child columns.).

For this purpose, a new associative entity table VA
(ViewAttribute) associating SV--->TT--->TA with SV--->VV
= ViewVersion or with SV--->VN = ViewName
could be added to the schema.sch file.

SFrye's application (email) suggests that this assocation 
between view tables and TA-rows ought to be acquired 
dynamically for use in interactive (runtime) queries.
Generic pr_util code from chgen would have to INTERPRET
table VA if that table is updatable to support runtime queries.


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

3. More details on meets_view (in bde, chgen and other apps)
---------------------------

3A. Uses in bde (at above bde/pr_util path): 
(Of interest only to bde maintainers :-)

pr_load.c:233:int meets_view(int tbl_idx, int view_idx, hcg_key pkey)
/*********************************************************/
/* This function will determine if the specified key value meets the          */
/* proper version for that table in the specified view idx.                   */
/*********************************************************/
int meets_view(int tbl_idx, int view_idx, hcg_key pkey)
{
  return(hcg_view_list.view_list[view_idx].version_list[tbl_idx] == (get_version
(&pkey)));
}
94sbde_schema.h includes meets_view tests in various find_* macros.

meets_view is not used in pr_dump.c.
(new_version flag in [pr_]dump_row controls version# update in the record).

NEW_VERSION is tested in bde/pr_util/pr_load.c:load_data()
apparently to test alternate meets-view to skip or load records:
(at pr_load.c:1901 on 051007): 
---------
/* The next block skips unwanted table versions 
 * Alt: why not use meets_view() here? - RJL: 031012
 * Added NEW_VERSION brackets - RJL 031023
 */
#ifndef NEW_VERSION
        if (((char) hcg_version) !=
         hcg_view_list.view_list[hcg_view_idx].version_list[hcg_tbl_idx]) {
            rowsNotInView++;
            hcg_read_next(); //(skip this record)
            continue;
        }
#endif
-----------------


3B.Use in chgen bootstrapping:  
(Of interest only to chgen maintainers :-)

However, in chgen/src, which pr_load()s the .msdat file:
------------
saturn.cs.uml.edu(57)> pwd
/tmp_mnt/nfs/galaxy/misc/proj3/case/gen/ver_13/chgen/src
saturn.cs.uml.edu(58)> grep 'meets_view|NEW_VERSION' I* M*
saturn.cs.uml.edu(59)>
-------------
The chgen Makefile dropped -DNEW_VERSION in -r 1.13:
------------
saturn.cs.uml.edu(93)> cvs diff -r 1.12 -r 1.13 chgen/src/Makefile | grep NEW_VERSION
10:< CFLAGS = -g -Wp,-lang-c -DDEBUG -DNEW_VERSION
------------------
Howeever,  my rev. 1.13 comments do not mention this  
[shame on me!] from 'cvs log chgen/src/Makefile':
-------------------------
revision 1.13
date: 2005/07/14 18:27:11;  author: lechner;  state: Exp;  lines: +211 -33
Major update/restoral of Makefile for chgen13:
#define'd GENPR in CFLAGS as condition on pr_load.c content
 to avoid duplicating def's in lut.c + other chgen/src files,
 and split chgen/obj into two ../{$HOSTTYPE} subdir'ys.

Added GENPR to CFLAGS = -ggdb -DDEBUG -DGENPR -Wall

Restored customized gen_lut derivation from gen_lut.c
 which runs during (default) 'make all';
 'make most' skips this pre-requisite.)

Customized generation of chgen_release_date.c by
 'make release', which runs $(SRCDIR)/set_release_date[.csh]

Problem TBFixed: improve build efficiency:
 'make all' always compiles EVERY source .c file
----------------------------
===================================================================

RJLRef: $PH/COOL-GEN/ver_13/chgen/NEW_VERSION_FLAG.hlp
From lechner Wed Apr 19 19:59:46 1995
Subject: Re: NEW_VERSION flag when compiling chgen for use in 95s522
Date: Wed, 19 Apr 1995 19:59:45 -0400 (EDT)
>
> [remus1](224)> pwd
> /nfs/jupiter/proj3/case/gen/ver_8/src
> [remus1](226)> grep NEW_V Makefile.*
> Makefile.5dec94:3:CFLAGS = -g -DDEBUG -DNEW_VERSION -D${MACHINE}
> Makefile.ver_8.alpha:3:CFLAGS = -g -DDEBUG -DNEW_VERSION -D${MACHINE}
> [remus1](227)>
>
> So  to restrict the output of pr_load to a specified view,
> you need to rebuild chgen  without -DNEW_VERSION .
>
(as in MakefileALpha and MakefileLinux - RJL070201)

See  $PH/COOL-GEN/viewdefsHelp051007.txt for more details.


