This file /usr/proj3/case/95s523/meets_view.hlp contains an explanation of how chgen builds a nontrivial version of meets_view foruse by pr_load and pr_dump. It requires NEW_VERSION to NOT be defined in chgen's makefile (ver_8) This is of interest to the bde.dat conversion projects and to the olc juiceplant projects in 95s522. which need to constrain the view to economize on log printing during simulation. E.g. perhaps only the EI que gets printed by the main loop. Subject: meets_view needs '#ifndef NEW_VERSION' when compiling chgen: Date: Thu, 16 Mar 1995 02:34:26 -0500 (EST) Ref: /usr/proj3/case/95s523/meets_view.hlp and /usr/proj3/case/gen/ver_8/meets_view.hlp pr_load/pr_dump do not check if the table is in the view before doing I/O because meets_view, which they call, has this body: (from gen_pr_utils.c in case/gen/ver_8/src): #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 A nontrivial meets_view check requires NEW_VERSION to be 'undefined'. which only works at CHGEN COMPILE TIME. This should be done in the application's Makefile. This causes meets_view to invoke and return (hcg_view_list.view_list[view_idx].version_list[tbl_idx] == (get_version(&pkey))) instead of always returning 1. It compares the current table row's version number (subfield of the pkey) to the desired version number for this table (selected by tbl_idx) and the view (selected by view_idx). ------------------------------------------------------------- How NEW_VERSION constrains the table types to be loaded/dumped: (We don't have any pr_ routines with NEW_VERSION undefined so we have to look at the fprint statements in the gen_pr*routines.) NEW_VERSION is used in several places: tern(185)> pwd /nfs/jupiter/proj3/case/gen/ver_8/src tern(186)> grep NEW_VERSION *.c gen_load_data.c:69:#ifndef NEW_VERSION gen_pr_add.c:104:#ifndef NEW_VERSION gen_pr_dump.c:102:#ifndef NEW_VERSION gen_pr_utils.c:156:#ifndef NEW_VERSION gen_pr_utils.c:256:#ifndef NEW_VERSION E.g., in gen_pr_dump.c, these checks are made for each internal table type: #ifndef NEW_VERSION fprintf(prdump_fp,"\tif ((hcg_view_list.view_list[hcg_view_idx].version_list[hcg_tbl_idx] != '\\0') &&\n"); fprintf(prdump_fp,"\t (hcg_ts_list[hcg_tbl_idx].ts_list[hcg_view_list .view_list[hcg_view_idx].version_list[hcg_tbl_idx]].rcount > 0))\n"); #else fprintf(prdump_fp,"\tif (hcg_ts_list[hcg_tbl_idx].ts_list[hcg_view_list.view_list[hcg_view_idx].version_list[hcg_tbl_idx]].rcount > 0)\n"); #endif so the added condition #ifndef NEW_VERSION is: if ((hcg_view_list.view_list[hcg_view_idx].version_list[hcg_tbl_idx] != '\\0') A table not in the view will be excluded by a \0 entry in the inner array version_list[hcg_tbl_idx]. This array is initialized when the view definition file is scanned by pr_init.c. In bde/schema/pr_load.c, pr_init first zeroes this array (line 1698+ below) and then changes it if the table type appears with a legitimate version number in some view_element of the named view in the .vdf file: --------------------------------------------- for (i=0; i<100; i++) hcg_view_list.view_list[hcg_view_list.num_views].version_list[i] = '\0'; After parsing out table_abbrev, if find_tbl_idx(table_abbrev) succeeds, hcg_version is defined from the view_elelement field , checked against limits, and entered into the hcg data structures: if (hcg_version > 0) hcg_view_list.view_list[hcg_view_idx].version_list[hcg_tbl_idx] = (char) hcg_version; else hcg_view_list.view_list[hcg_view_idx].version_list[hcg_tbl_idx] = (char) hcg_table_seq_list[hcg_tbl_idx].maxver+hcg_version; ----------------------------------------------- Therefore it appears that a legitimate table in the view gets a legal version number assigned in the nested array version_list[hcg_tbl_idx] above, otherwise the table keeps its initial zero value.