/*
 * $Id: history.inter 3340 2009-12-14 00:00:49Z unsaved $
 *
 * Tests simple recalls and executes : and :;.
 */

\c false
/* Since running interactively, need to either invoke with --abortOnErr switch,
 * or use "\c false" Special command, to detect failures. */

CREATE TABLE t(id INTEGER GENERATED BY DEFAULT AS IDENTITY, vc VARCHAR(80));

/* Just verify that an error is not thrown by the two following commands.
   And that they don't effect the command history. */
:b
:h

INSERT INTO t(vc) VALUES('one');
INSERT INTO t(vc) VALUES('two');
INSERT INTO t(vc) VALUES('three');

/* Test simple recall and execution */
:4
:;
:4;
:;

SELECT count(*) FROM t
*if (*? != 6)
    \q Recall and execs failed / 1
*end if

/* SELECT vc FROM t; */
SELECT count(*) FROM t WHERE vc = 'two';
*if (*? != 4)
    \q Recall and execs failed / 2
*end if

:/ee/;

SELECT count(*) FROM t;
*if (*? != 7)
    \q Regex Recall and execs failed / 1
*end if

/* SELECT vc FROM t; */
SELECT count(*) FROM t WHERE vc = 'three';
*if (*? != 2)
    \q Regex Recall and execs failed / 2
*end if
