/*
 * $Id: append.inter 5406 2014-10-13 20:53:18Z unsaved $
 *
 * 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(80));
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

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

INSERT INTO t(vc) VALUES

:a ('prefpost');

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

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

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

:-1
:a AND
 id
= 1

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