btreeop(1)

btreeop1

Btree database maintenance tool.

Usage

btreeop [-A] [-C] [-D [n] key] [-K [n] key] [-L [2]] [-k prefix] [dbname]

Overview

Btreeop execute simple operations for btree(3) database. Btreeop can create database, write record, read record (sequential or indexed) and delete record from it. Duplicate entries are allowed. Multi-key is available but only primary key can use index of btree(3).

Commands

A capital letter means a command. If no command specified then it assume sequential read operation. The following commands are available:

none

Read records sequentially.

-A

Append records. If database doesn't exist, btreeop creates it.

-C

Create database and write records to it.

-D[n] key

Delete records by the key. By default, n is 0 (primary key).

-K[n] key

Search records by the key. By default, n is 0 (primary key).

-L[2]

List all primary keys. If 2 is specified, list all the key and data pairs.

dbname

Database name. By default, it assume ´btree´.

Options

-k prefix

Scan records which have the prefix as a primary key. This option is valid only with sequential read operation -L command or no command.

Format

To creat (or append) database, btreeop read data from stdin.
The format of the data is the following.

Primary-key Secondary-key-1 Secondary-key-2 Data
(keyno = 0) (keyno = 1) (keyno = 2)
--------------------------------------------------------------
main 246 main.c main () {
func 120 library.c func(a1, a2)
.
.
.

o All key and data are separated by blank('\t' or ' '). o Key cannot include blank. o Data can include blank. o Null data not allowed.

Additionally, META record is available. META record has a key that start with a blank. You can read this record only by indexed read operation (-K option). Usage is unlimited by btreeop.

Examples

Create database.

% btreeop -C
key1 data1
key2 data2
key3 data3
^D
%

Append records.

% btreeop -A
__.VERSION 2
key2 data2-2
^D
%

Sequential read.

% btreeop
key1 data1
key2 data2-2
key2 data2
key3 data3
%

Indexed read.

% btreeop -K key2
key2 data2-2
key2 data2
% btreeop -K ' __.VERSION'
__.VERSION 2
%

List primary keys.

% btreeop -L
key1
key2
key3
%

Delete record.

% btreeop -D ' __.VERSION'
% btreeop -K ' __.VERSION'
%

Files

´btree´

default database name.

Diagnostics

Btreeop exits with a non 0 value if an error occurred, 0 otherwise.

Releases

3 releases since Debian 2.2 (Potato); the text changed 2 times.

  1. 2.2
  2. 3.0
  3. 3.1

Author

Shigio Yamaguchi

History

The btreeop command appeared in FreeBSD 2.2.2.

From global 4.5-1.1 in Debian 3.1 (Sarge). Parsed by carta from the page's man source.