\set ON_ERROR_STOP 1

drop table if exists test_table cascade;

select version();

create temporary table test_table
(
    xxx varchar(32),
    expected varchar(32)
);

insert into test_table values ('My Q Name',      'My Q Name' );;
insert into test_table values ('QMy Q Name',     'My Q Name' );;
insert into test_table values ('My Q NameQ',     'My Q Name' );;
insert into test_table values ('QMy Q NameQ',    'My Q Name' );;

insert into test_table values ('QQMy Q Name',    'QMy Q Name' );;
insert into test_table values ('My Q NameQQ',    'My Q NameQ' );;
insert into test_table values ('QQMy Q NameQQ',  'QMy Q NameQ' );;

-- Return sring xxx with first and last "Q" removed...
create temporary view test_view as
select xxx, expected, substring(xxx from 'Q?#"%#"Q?' FOR '#') as actual from test_table;

select xxx,expected,actual,(actual <> expected) as error from test_view;
