/*
 * $Id: append.inter,v 1.1 2007/08/09 03:29:27 unsaved Exp $
 *
 * Tests interactive commands :a*.
 */

\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);
INSERT INTO t (vc) VALUES('a');
INSERT INTO t (vc) VALUES('b');
INSERT INTO t (vc) VALUES('c');
INSERT INTO t (vc) VALUES('b');

SELECT count(*) FROM t
*if (*? != 4)
    \q Sanity check failed / 1
*end if

SELECT count(*) FROM t WHERE vc = 'b';
*if (*? != 2)
    \q Sanity check failed / 2
*end if

INSERT INTO t(vc) VALUES ('pref

:apost');

SELECT count(*) FROM t
*if (*? != 5)
    \q Append + repl failed / 1
*end if

SELECT vc FROM t;
SELECT count(*) FROM t WHERE vc = 'prefpost';
*if (*? != 1)
    \q Append + repl failed / 2
*end if

SELECT count(*) FROM t;

\p Intervening command making previous become command # -2.
:h
:-2a WHERE vc = 'b';

*if (*? != 2)
    \q Recall + Append + exec failed / 1
*end if

:-2
:a AND

id = 1

:;
*if (*? != 1)
    \q Recall + multi-line Append failed / 1
*end if
