Contents

Previous

Next



Database Utilities

The Source-Navigator utilities dbdump, dbcp, and dbimp access and maintain databases that can be started from user shells or applications. These utilities are located in the .../bin directory.

Note

The scripts in this chapter are written to work under the UNIX operating system. When running under DOS, the scripts must be changed.

dbdump

The dbdump utility provides a complete listing, or a dump, of the contents of a database table. Its usage is:

dbdump ?-separator char? file

dbdump separates the key and data parts with a semicolon (;). The hash character (#) and brackets ({}) indicate an empty field. The shell script below lists the name and locations of the project class.

#!/bin/sh

dbdump=$HOME/snavigator/bin/dbdump
project=tmp

$dbdump -s ' ' $project.cl | awk '{printf
    "%s,%s,%s\n",$1,$3,$2}'

dbcp

The dbcp utility copies and compacts the database. Space freed up by deleting key/data pairs from btree tables is never reclaimed, although it is normally made available for reuse. When copying a database with dbcp, deleted records are not copied, resulting in a much better page-fill factor and reduced disk space requirements. Its usage is:

dbcp input_table output_table

The following shell script compresses the tables of a Source-Navigator project.

#!/bin/sh

execdir=$HOME/snavigator/bin
dbcp=$execdir/dbcp

project=TEST
cd .paf

for i in $project.[a-z]*
do
  $dbcp $i $$.tmp
  mv $$.tmp $i
done

You can use this script even for currently-running Source-Navigator projects because compressing database tables does not affect performance. Hash tables may also be copied with dbcp, but there will be no space savings.

dbimp

The dbimp utility inserts, updates, and deletes records in a project database. It reads commands from its standard input.

Its usage is:

dbimp ?-c cache_size? ?-C cross_cache_size?
          ?-l? ?-f file? db_prefix

References to local variables are stored only if the -l flag is specified.

db_prefix contains the name of the database directory, for example, .sn and the base name of the project file. If the project file is called test.proj, db_prefix could be called SNDB4/test.

The format of the commands (read from standard input) must follow this syntax:

COMMAND;KEY;DATA

If COMMAND is greater than or equal to 0, dbimp inserts KEY/DATA pairs. The value of COMMAND must be between PAF_FILE and PAF_COMMENT_DEF, inclusive. (For the numerical values see sn.h.)

The following example inserts a function (strcopy) definition.

8;strcopy 000001.004 x.c;4.1 0x0 {int} {} {} {}

The following example inserts a method definition (pro3) of the class xharom.

17;xharom pro3 000036.005 x.C;36.11 0x2 {int} {} {} {}

The instructions below insert cross-references (Refers-to and Referred-by) into the project database. The ? symbol represents the sn_sep separator character in the instructions below.

16;#?abc?fu?abc?var?lv?w?000004?x.c;#
15;abc?var?lv?#?abc?fu?w?000004?x.c;#
16;#?abc?fu?#?hello?fu?p?000005?x.c;#
15;#?hello?fu?#?abc?fu?p?000005?x.c;#

See Database Table Structures for information on the structure of the Source-Navigator database tables.

The following example deletes the cross-reference information for the file x.c:

-2;0;x.c

Limitations

Undefined results occur if the COMMAND does not have a legal value.

In the commands, you may use only single blank spaces and no tabs.


Contents

Previous

Next