提交 11a5a807 编写于 作者: H Heikki Linnakangas

Move UAO isolation test cases from TINC to a new pg_regress based suite.

This new "isolation2" suite uses the same Python helper that TINC used,
to run these special isolation test cases.
上级 78c9dc10
......@@ -118,6 +118,7 @@ installcheck-world:
$(MAKE) -C src/test installcheck-good
$(MAKE) -C src/test installcheck-bugbuster
$(MAKE) -C src/test/isolation installcheck
$(MAKE) -C src/test/isolation2 installcheck
$(MAKE) -C src/pl installcheck
#$(MAKE) -C src/interfaces/ecpg installcheck
#$(MAKE) -C contrib installcheck
......
#
# Makefile for isolation2 tests
#
subdir = src/test/isolation2
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
# where to find psql for testing an existing installation
PSQLDIR = $(bindir)
ifeq ($(PORTNAME), win32)
LDLIBS += -lws2_32
endif
override CPPFLAGS := -I$(srcdir) -I$(libpq_srcdir) -I$(srcdir)/../regress $(CPPFLAGS)
override LDLIBS := $(libpq_pgport) $(LDLIBS)
all: pg_isolation2_regress$(X)
pg_regress.o:
$(MAKE) -C $(top_builddir)/src/test/regress pg_regress.o
rm -f $@ && $(LN_S) $(top_builddir)/src/test/regress/pg_regress.o .
gpstringsubs.pl:
rm -f $@ && $(LN_S) $(top_builddir)/src/test/regress/gpstringsubs.pl
gpdiff.pl: atmsort.pm explain.pm
rm -f $@ && $(LN_S) $(top_builddir)/src/test/regress/gpdiff.pl
atmsort.pm:
rm -f $@ && $(LN_S) $(top_builddir)/src/test/regress/atmsort.pm
explain.pm:
rm -f $@ && $(LN_S) $(top_builddir)/src/test/regress/explain.pm
pg_isolation2_regress$(X): isolation2_main.o pg_regress.o
$(CC) $(CFLAGS) $^ $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@
clean distclean:
rm -f pg_isolation2_regress$(X) $(OBJS) isolation2_main.o
rm -f pg_regress.o
rm -f gpstringsubs.pl gpdiff.pl atmsort.pm explain.pm
rm -rf $(pg_regress_clean_files)
installcheck: all gpdiff.pl gpstringsubs.pl
./pg_isolation2_regress --psqldir='$(PSQLDIR)' --inputdir=$(srcdir) --schedule=$(srcdir)/isolation2_schedule
This directory contains additional "isolation"-style tests. That is,
tests that require multiple simultaneous connections to the database.
Some of these could be moved to the main isolation test suite, in
src/test/isolation, but for historical reasons, these tests use a different
syntax for specifying the tests. See sql_isolation_testcase.py for more
details on the syntax.
-- @Description Ensures that an alter table while a vacuum operation is ok
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100000) AS i;
INSERT 100000
DELETE FROM ao WHERE a < 12000;
DELETE 11999
......
-- @Description Ensures that an alter table while a vacuum operation is ok
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100000) AS i;
INSERT 100000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100000) AS i;
INSERT 100000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100000) AS i;
INSERT 100000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100000) AS i;
INSERT 100000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100000) AS i;
INSERT 100000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100000) AS i;
INSERT 100000
DELETE FROM ao WHERE a < 12000;
DELETE 71994
......
-- @Description Tests the behavior of full vacuum w.r.t. the pg_class statistics
--
--
DROP TABLE IF EXISTS foo;
DROP
CREATE TABLE foo (a INT, b INT, c CHAR(128)) WITH (appendonly=true) DISTRIBUTED BY (a);
CREATE
CREATE INDEX foo_index ON foo(b);
CREATE
INSERT INTO foo SELECT i as a, i as b, 'hello world' as c FROM generate_series(1, 50) AS i;
INSERT 50
INSERT INTO foo SELECT i as a, i as b, 'hello world' as c FROM generate_series(51, 100) AS i;
INSERT 50
ANALYZE foo;
ANALYZE
-- ensure that the scan go through the index
SET enable_seqscan=false;
......@@ -28,7 +41,7 @@ relname |reltuples
---------+---------
foo_index|85
(1 row)
SELECT segno, tupcount,state FROM gp_aoseg_name('foo');
SELECT segno, tupcount,state FROM gp_toolkit.__gp_aoseg_name('foo');
segno|tupcount|state
-----+--------+-----
1 |0 |1
......
-- @Description Tests the basic behavior of (lazy) vacuum when called from utility mode
--
--
DROP TABLE IF EXISTS foo;
DROP
CREATE TABLE foo (a INT, b INT, c CHAR(128)) WITH (appendonly=true);
CREATE
CREATE INDEX foo_index ON foo(b);
CREATE
INSERT INTO foo SELECT i as a, 1 as b, 'hello world' as c FROM generate_series(1, 100) AS i;
INSERT 100
DELETE FROM foo WHERE a < 20;
DELETE 19
......@@ -15,7 +23,7 @@ count
-----
81
(1 row)
2U: SELECT segno, tupcount FROM gp_aoseg_name('foo');
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('foo');
segno|tupcount
-----+--------
0 |81
......
-- @Description Tests the basic behavior of (lazy) vacuum when called from utility mode
--
DROP TABLE IF EXISTS foo;
DROP
CREATE TABLE foo (a INT, b INT, c CHAR(128)) WITH (appendonly=true);
CREATE
CREATE INDEX foo_index ON foo(b);
CREATE
INSERT INTO foo SELECT i as a, 1 as b, 'hello world' as c FROM generate_series(1, 100) AS i;
INSERT 100
DELETE FROM foo WHERE a < 20;
DELETE 19
......@@ -15,7 +23,7 @@ count
-----
81
(1 row)
2U: SELECT segno, tupcount FROM gp_aoseg_name('foo');
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('foo');
segno|tupcount
-----+--------
0 |40
......
-- @Description Tests the compaction of data inserted in utility mode
--
--
DROP TABLE IF EXISTS foo;
DROP
CREATE TABLE foo (a INT, b INT, c CHAR(128)) WITH (appendonly=true);
CREATE
CREATE INDEX foo_index ON foo(b);
CREATE
INSERT INTO foo VALUES (1, 1, 'c');
INSERT 1
SELECT segno, tupcount, state FROM gp_aoseg_name('foo');
SELECT segno, tupcount, state FROM gp_toolkit.__gp_aoseg_name('foo');
segno|tupcount|state
-----+--------+-----
1 |1 |1
......@@ -12,14 +18,14 @@ segno|tupcount|state
INSERT 1
2U: INSERT INTO foo VALUES (3, 3, 'c');
INSERT 1
2U: SELECT segno, tupcount, state FROM gp_aoseg_name('foo');
2U: SELECT segno, tupcount, state FROM gp_toolkit.__gp_aoseg_name('foo');
segno|tupcount|state
-----+--------+-----
0 |2 |1
1 |1 |1
(2 rows)
-- We know that the master does update its tupcount yet
SELECT segno, tupcount, state FROM gp_aoseg_name('foo');
SELECT segno, tupcount, state FROM gp_toolkit.__gp_aoseg_name('foo');
segno|tupcount|state
-----+--------+-----
1 |1 |1
......@@ -30,7 +36,7 @@ UPDATE foo SET b = -1 WHERE a = 3;
UPDATE 1
VACUUM foo;
VACUUM
2U: SELECT segno, tupcount, state FROM gp_aoseg_name('foo');
2U: SELECT segno, tupcount, state FROM gp_toolkit.__gp_aoseg_name('foo');
segno|tupcount|state
-----+--------+-----
0 |0 |1
......@@ -38,7 +44,7 @@ segno|tupcount|state
2 |1 |1
3 |0 |1
(4 rows)
SELECT segno, tupcount, state FROM gp_aoseg_name('foo');
SELECT segno, tupcount, state FROM gp_toolkit.__gp_aoseg_name('foo');
segno|tupcount|state
-----+--------+-----
1 |2 |1
......
-- @Description Tests the compaction of data inserted in utility mode
--
DROP TABLE IF EXISTS foo;
DROP
CREATE TABLE foo (a INT, b INT, c CHAR(128)) WITH (appendonly=true);
CREATE
CREATE INDEX foo_index ON foo(b);
CREATE
INSERT INTO foo VALUES (1, 1, 'c');
INSERT 1
SELECT segno, tupcount, state FROM gp_aoseg_name('foo');
SELECT segno, tupcount, state FROM gp_toolkit.__gp_aoseg_name('foo');
segno|tupcount|state
-----+--------+-----
1 |1 |1
......@@ -12,14 +18,14 @@ segno|tupcount|state
INSERT 1
2U: INSERT INTO foo VALUES (3, 3, 'c');
INSERT 1
2U: SELECT segno, tupcount, state FROM gp_aoseg_name('foo');
2U: SELECT segno, tupcount, state FROM gp_toolkit.__gp_aoseg_name('foo');
segno|tupcount|state
-----+--------+-----
0 |2 |1
1 |1 |1
(2 rows)
-- We know that the master does update its tupcount yet
SELECT segno, tupcount, state FROM gp_aoseg_name('foo');
SELECT segno, tupcount, state FROM gp_toolkit.__gp_aoseg_name('foo');
segno|tupcount|state
-----+--------+-----
1 |1 |1
......@@ -30,7 +36,7 @@ UPDATE foo SET b = -1 WHERE a = 3;
UPDATE 1
VACUUM foo;
VACUUM
2U: SELECT segno, tupcount, state FROM gp_aoseg_name('foo');
2U: SELECT segno, tupcount, state FROM gp_toolkit.__gp_aoseg_name('foo');
segno|tupcount|state
-----+--------+-----
0 |0 |1
......@@ -38,7 +44,7 @@ segno|tupcount|state
2 |1 |1
3 |0 |1
(4 rows)
SELECT segno, tupcount, state FROM gp_aoseg_name('foo');
SELECT segno, tupcount, state FROM gp_toolkit.__gp_aoseg_name('foo');
segno|tupcount|state
-----+--------+-----
1 |2 |1
......
-- @Description Tests the visibility when a cursor has been created before the delete.
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT) WITH (appendonly=true);
CREATE
insert into ao select generate_series(1, 100);
INSERT 100
1: BEGIN;
BEGIN
......
-- @Description Tests the visibility when a cursor has been created before the delete.
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT) WITH (appendonly=true);
CREATE
insert into ao select generate_series(1, 10);
INSERT 10
1: BEGIN;
BEGIN
......
-- @Description Tests the visibility when a cursor has been created before the update.
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,100) AS i;
INSERT 100
1: BEGIN;
BEGIN
......
-- @Description Tests the visibility of an "with hold" cursor w.r.t. deletes.
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT) WITH (appendonly=true);
CREATE
insert into ao select generate_series(1,100);
INSERT 100
1: DECLARE cur CURSOR WITH HOLD FOR SELECT a FROM ao ORDER BY a;
DECLARE
......
-- @Description Tests the visibility of an "with hold" cursor w.r.t. deletes.
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT) WITH (appendonly=true);
CREATE
insert into ao select generate_series(1,10);
INSERT 10
1: BEGIN;
BEGIN
......
-- @Description Ensures that a delete before a vacuum operation is ok
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100) AS i;
INSERT 100
DELETE FROM ao WHERE a < 12;
DELETE 11
......
-- @Description Ensures that a drop table while a vacuum operation is ok
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100000) AS i;
INSERT 100000
DELETE FROM ao WHERE a < 12000;
DELETE 11999
......
-- @Description Tests the AO segment file selection policy
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT) WITH (appendonly=true);
CREATE
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
-- Actual test begins
1: INSERT INTO AO VALUES (1);
INSERT 1
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
segno|tupcount
-----+--------
1 |127
(1 row)
1: INSERT INTO AO VALUES (2);
INSERT 1
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
segno|tupcount
-----+--------
1 |128
(1 row)
1: BEGIN;
BEGIN
1: INSERT INTO AO VALUES (2);
INSERT 1
2: BEGIN;
BEGIN
2: INSERT INTO AO VALUES (2);
INSERT 1
1: COMMIT;
COMMIT
2: COMMIT;
COMMIT
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
segno|tupcount
-----+--------
1 |129
2 | 1
(2 rows)
1: insert into ao select generate_series(1,100000);
INSERT 100000
1: INSERT INTO AO VALUES (2);
INSERT 1
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
segno|tupcount
-----+--------
1 | 100129
2 | 2
(2 rows)
-- @Description Tests the AO segment file selection policy
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT) WITH (appendonly=true);
CREATE
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
1: INSERT INTO AO VALUES (1);
INSERT 1
-- Actual test begins
1: INSERT INTO AO VALUES (1);
INSERT 1
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
segno|tupcount
-----+--------
1 |127
(1 row)
1: INSERT INTO AO VALUES (2);
INSERT 1
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
segno|tupcount
-----+--------
1 |127
(1 row)
1: BEGIN;
BEGIN
1: INSERT INTO AO VALUES (2);
INSERT 1
2: BEGIN;
BEGIN
2: INSERT INTO AO VALUES (2);
INSERT 1
1: COMMIT;
COMMIT
2: COMMIT;
COMMIT
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
segno|tupcount
-----+--------
1 |127
(1 row)
1: insert into ao select generate_series(1,100000);
INSERT 100000
1: INSERT INTO AO VALUES (2);
INSERT 1
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
segno|tupcount
-----+--------
1 |50128
(1 row)
-- @Description Ensures that an insert during a vacuum operation is ok
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT) WITH (appendonly=true);
CREATE
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
DELETE FROM ao WHERE a < 128;
DELETE 2667
......
-- @Description The locks held after different operations
--
-- @product_version gpdb: 4.3.3.0O2
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100) AS i;
INSERT 100
DROP VIEW IF EXISTS locktest;
DROP
create view locktest as select coalesce( case when relname like 'pg_toast%index' then 'toast index' when relname like 'pg_toast%' then 'toast table' when relname like 'pg_aovisimap%index' then 'visimap index' when relname like 'pg_aovisimap%' then 'visimap table' when relname like 'pg_aoseg%index' then 'aoseg index' when relname like 'pg_aoseg%' then 'aoseg table' when relname like 'pg_aocsseg%index' then 'aoseg index' when relname like 'pg_aocsseg%' then 'aoseg table' else relname end, 'dropped table'), mode, locktype from pg_locks l, pg_class c, pg_database d where relation is not null and l.database = d.oid and l.relation = c.oid and relname != 'gp_fault_strategy' and d.datname = current_database() order by 1, 3, 2;
CREATE
-- Actual test begins
1: BEGIN;
BEGIN
1: INSERT INTO ao VALUES (200, 200);
......
-- @Description The locks held after different operations
--
-- @product_version gpdb: 4.3.3.0O2
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100) AS i;
INSERT 100
DROP VIEW IF EXISTS locktest;
DROP
create view locktest as select coalesce( case when relname like 'pg_toast%index' then 'toast index' when relname like 'pg_toast%' then 'toast table' when relname like 'pg_aovisimap%index' then 'visimap index' when relname like 'pg_aovisimap%' then 'visimap table' when relname like 'pg_aoseg%index' then 'aoseg index' when relname like 'pg_aoseg%' then 'aoseg table' when relname like 'pg_aocsseg%index' then 'aoseg index' when relname like 'pg_aocsseg%' then 'aoseg table' else relname end, 'dropped table'), mode, locktype from pg_locks l, pg_class c, pg_database d where relation is not null and l.database = d.oid and l.relation = c.oid and relname != 'gp_fault_strategy' and d.datname = current_database() order by 1, 3, 2;
CREATE
-- Actual test begins
1: BEGIN;
BEGIN
1: INSERT INTO ao VALUES (200, 200);
......@@ -92,4 +102,3 @@ pg_locks |AccessShareLock|relation
(5 rows)
1: COMMIT;
COMMIT
-- @Description Tests that DML operatins change the modification count.
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,10) AS i;
INSERT 10
SELECT state, tupcount, modcount FROM gp_aoseg_name('ao');
SELECT state, tupcount, modcount FROM gp_toolkit.__gp_aoseg_name('ao');
state|tupcount|modcount
-----+--------+--------
1 |10 |1
(1 row)
INSERT INTO ao VALUES (11, 11);
INSERT 1
SELECT state, tupcount, modcount FROM gp_aoseg_name('ao');
SELECT state, tupcount, modcount FROM gp_toolkit.__gp_aoseg_name('ao');
state|tupcount|modcount
-----+--------+--------
1 |11 |2
(1 row)
DELETE FROM ao WHERE a = 11;
DELETE 1
SELECT state, tupcount, modcount FROM gp_aoseg_name('ao');
SELECT state, tupcount, modcount FROM gp_toolkit.__gp_aoseg_name('ao');
state|tupcount|modcount
-----+--------+--------
1 |11 |3
(1 row)
UPDATE AO SET b = 0 WHERE a = 10;
UPDATE 1
SELECT state, tupcount, modcount FROM gp_aoseg_name('ao');
SELECT state, tupcount, modcount FROM gp_toolkit.__gp_aoseg_name('ao');
state|tupcount|modcount
-----+--------+--------
1 |12 |4
......
-- @Description Tests that vacuum is not changing the modification count.
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,10) AS i;
INSERT 10
DELETE FROM ao WHERE a < 5;
DELETE 4
SELECT state, tupcount, modcount FROM gp_aoseg_name('ao');
SELECT state, tupcount, modcount FROM gp_toolkit.__gp_aoseg_name('ao');
state|tupcount|modcount
-----+--------+--------
1 |10 |2
(1 row)
VACUUM ao;
VACUUM
SELECT state, tupcount, modcount FROM gp_aoseg_name('ao');
SELECT state, tupcount, modcount FROM gp_toolkit.__gp_aoseg_name('ao');
state|tupcount|modcount
-----+--------+--------
1 |0 |2
......
-- @Description Tests that a delete operation in progress will block all other deletes
-- until the transaction is committed.
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT) WITH (appendonly=true) DISTRIBUTED BY (a);
CREATE
insert into ao select generate_series(1,100);
INSERT 100
DROP VIEW IF EXISTS locktest;
DROP
create view locktest as select coalesce( case when relname like 'pg_toast%index' then 'toast index' when relname like 'pg_toast%' then 'toast table' else relname end, 'dropped table'), mode, locktype from pg_locks l left outer join pg_class c on (l.relation = c.oid), pg_database d where relation is not null and l.database = d.oid and l.gp_segment_id = -1 and relname != 'gp_fault_strategy' and d.datname = current_database() order by 1, 3, 2;
CREATE
-- The actual test begins
1: BEGIN;
BEGIN
2: BEGIN;
......@@ -31,7 +43,7 @@ a
(2 rows)
3: COMMIT;
COMMIT
2U: SELECT * FROM gp_aovisimap_name('ao');
2U: SELECT * FROM gp_toolkit.__gp_aovisimap_name('ao');
tid |segno|row_num
----------------+-----+-------
(33554432,32769)|1 |1
......
-- @Description Tests that a delete operation in progress will block all other deletes
-- until the transaction is committed.
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT) WITH (appendonly=true) DISTRIBUTED BY (a);
CREATE
insert into ao select generate_series(1,100);
INSERT 100
DROP VIEW IF EXISTS locktest;
DROP
create view locktest as select coalesce( case when relname like 'pg_toast%index' then 'toast index' when relname like 'pg_toast%' then 'toast table' else relname end, 'dropped table'), mode, locktype from pg_locks l left outer join pg_class c on (l.relation = c.oid), pg_database d where relation is not null and l.database = d.oid and l.gp_segment_id = -1 and relname != 'gp_fault_strategy' and d.datname = current_database() order by 1, 3, 2;
CREATE
-- The actual test begins
1: BEGIN;
BEGIN
2: BEGIN;
......@@ -31,7 +43,7 @@ a
(2 rows)
3: COMMIT;
COMMIT
2U: SELECT * FROM gp_aovisimap_name('ao');
2U: SELECT * FROM gp_toolkit.__gp_aovisimap_name('ao');
tid |segno|row_num
----------------+-----+-------
(33554432,32769)|1 |1
......
-- @Description Tests that a update operation in progress will block all other updates
-- until the transaction is committed.
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,10) AS i;
INSERT 10
DROP VIEW IF EXISTS locktest;
DROP
create view locktest as select coalesce( case when relname like 'pg_toast%index' then 'toast index' when relname like 'pg_toast%' then 'toast table' else relname end, 'dropped table'), mode, locktype from pg_locks l left outer join pg_class c on (l.relation = c.oid), pg_database d where relation is not null and l.database = d.oid and l.gp_segment_id = -1 and relname != 'gp_fault_strategy' and d.datname = current_database() order by 1, 3, 2;
CREATE
-- The actual test begins
1: BEGIN;
BEGIN
2: BEGIN;
......@@ -29,7 +41,7 @@ a|b
3|3
4|4
(4 rows)
2U: SELECT * FROM gp_aovisimap_name('ao');
2U: SELECT * FROM gp_toolkit.__gp_aovisimap_name('ao');
tid |segno|row_num
----------------+-----+-------
(33554432,32769)|1 |1
......
-- @Description Tests that a update operation in progress will block all other updates
-- until the transaction is committed.
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,10) AS i;
INSERT 10
DROP VIEW IF EXISTS locktest;
DROP
create view locktest as select coalesce( case when relname like 'pg_toast%index' then 'toast index' when relname like 'pg_toast%' then 'toast table' else relname end, 'dropped table'), mode, locktype from pg_locks l left outer join pg_class c on (l.relation = c.oid), pg_database d where relation is not null and l.database = d.oid and l.gp_segment_id = -1 and relname != 'gp_fault_strategy' and d.datname = current_database() order by 1, 3, 2;
CREATE
-- The actual test begins
1: BEGIN;
BEGIN
2: BEGIN;
......@@ -29,9 +41,8 @@ a|b
3|3
4|4
(4 rows)
2U: SELECT * FROM gp_aovisimap_name('ao');
2U: SELECT * FROM gp_toolkit.__gp_aovisimap_name('ao');
tid |segno|row_num
----------------+-----+-------
(33554432,32769)|1 |1
(1 row)
-- @Description Tests that a update operation in progress will block all other updates
-- until the transaction is committed.
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,10) AS i;
INSERT 10
DROP VIEW IF EXISTS locktest;
DROP
create view locktest as select coalesce( case when relname like 'pg_toast%index' then 'toast index' when relname like 'pg_toast%' then 'toast table' else relname end, 'dropped table'), mode, locktype from pg_locks l left outer join pg_class c on (l.relation = c.oid), pg_database d where relation is not null and l.database = d.oid and l.gp_segment_id = -1 and relname != 'gp_fault_strategy' and d.datname = current_database() order by 1, 3, 2;
CREATE
-- The actual test begins
1: BEGIN;
BEGIN
2: BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
......
-- @Description Tests the basic phantom read behavior of GPDB.
-- Actually, no UAO is involved here.
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100) AS i;
INSERT 100
1: BEGIN;
BEGIN
......
-- @Description Tests the basic phantom read behavior of GPDB w.r.t to delete using
-- the default isolation level.
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100) AS i;
INSERT 100
1: BEGIN;
BEGIN
......
-- @Description Tests the basic phantom read behavior of GPDB with serializable.
-- transactions. Actually, no UAO is involved here.
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100) AS i;
INSERT 100
1: BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
BEGIN
......
-- @Description Tests the basic phantom read behavior of GPDB w.r.t to updates using
-- the default isolation level.
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100) AS i;
INSERT 100
1: BEGIN;
BEGIN
......
-- @Description Ensures that a select after a vacuum operation is ok
--
DROP TABLE IF EXISTS ao;
DROP
DROP TABLE IF EXISTS ao2;
DROP
CREATE TABLE ao2 (a INT) WITH (appendonly=true);
CREATE
CREATE TABLE ao (a INT) WITH (appendonly=true);
CREATE
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao2 select generate_series(1,1000);
INSERT 1000
DROP VIEW IF EXISTS locktest;
DROP
create view locktest as select coalesce( case when relname like 'pg_toast%index' then 'toast index' when relname like 'pg_toast%' then 'toast table' else relname end, 'dropped table'), mode, locktype from pg_locks l left outer join pg_class c on (l.relation = c.oid), pg_database d where relation is not null and l.database = d.oid and l.gp_segment_id = -1 and relname != 'gp_fault_strategy' and d.datname = current_database() order by 1, 3, 2;
CREATE
-- The actual test begins
DELETE FROM ao WHERE a < 128;
DELETE 2667
1: BEGIN;
BEGIN
1: SELECT COUNT(*) FROM ao2;
count
-----
1000
(1 row)
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
segno|tupcount
-----+--------
1 |21000
(1 row)
2: VACUUM ao;
VACUUM
1: SELECT COUNT(*) FROM ao;
count
-----
18333
(1 row)
1: SELECT * FROM locktest WHERE coalesce = 'ao';
coalesce|mode |locktype
--------+---------------+--------
ao |AccessShareLock|relation
(1 row)
1: COMMIT;
COMMIT
1: SELECT COUNT(*) FROM ao;
count
-----
18333
(1 row)
3: INSERT INTO ao VALUES (0);
INSERT 1
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
segno|tupcount
-----+--------
1 |1
2 |18333
(2 rows)
-- @Description Ensures that a select after a vacuum operation is ok
--
DROP TABLE IF EXISTS ao;
DROP
DROP TABLE IF EXISTS ao2;
DROP
CREATE TABLE ao2 (a INT) WITH (appendonly=true);
CREATE
CREATE TABLE ao (a INT) WITH (appendonly=true);
CREATE
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao2 select generate_series(1,1000);
INSERT 1000
DROP VIEW IF EXISTS locktest;
DROP
create view locktest as select coalesce( case when relname like 'pg_toast%index' then 'toast index' when relname like 'pg_toast%' then 'toast table' else relname end, 'dropped table'), mode, locktype from pg_locks l left outer join pg_class c on (l.relation = c.oid), pg_database d where relation is not null and l.database = d.oid and l.gp_segment_id = -1 and relname != 'gp_fault_strategy' and d.datname = current_database() order by 1, 3, 2;
CREATE
-- The actual test begins
DELETE FROM ao WHERE a < 128;
DELETE 2667
1: BEGIN;
BEGIN
1: SELECT COUNT(*) FROM ao2;
count
-----
1000
(1 row)
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
segno|tupcount
-----+--------
1 |10521
(1 row)
2: VACUUM ao;
VACUUM
1: SELECT COUNT(*) FROM ao;
count
-----
18333
(1 row)
1: SELECT * FROM locktest WHERE coalesce = 'ao';
coalesce|mode |locktype
--------+---------------+--------
ao |AccessShareLock|relation
(1 row)
1: COMMIT;
COMMIT
1: SELECT COUNT(*) FROM ao;
count
-----
18333
(1 row)
3: INSERT INTO ao VALUES (0);
INSERT 1
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
segno|tupcount
-----+--------
1 |0
2 |9177
(2 rows)
-- @Description Ensures that a serializable select before during a vacuum operation blocks the vacuum.
--
DROP TABLE IF EXISTS ao;
DROP
DROP TABLE IF EXISTS ao2;
DROP
CREATE TABLE ao (a INT) WITH (appendonly=true);
CREATE
CREATE TABLE ao2 (a INT) WITH (appendonly=true);
CREATE
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao2 select generate_series(1,1000);
INSERT 1000
DELETE FROM ao WHERE a < 128;
DELETE 2667
1: BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
BEGIN
1: SELECT COUNT(*) FROM ao2;
count
-----
1000
(1 row)
2: VACUUM ao;
VACUUM
1: SELECT COUNT(*) FROM ao;
count
-----
18333
(1 row)
1: COMMIT;
COMMIT
3: INSERT INTO ao VALUES (0);
INSERT 1
-- @Description Ensures that a select before a vacuum operation is ok
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT) WITH (appendonly=true);
CREATE
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
DROP VIEW IF EXISTS locktest;
DROP
create view locktest as select coalesce( case when relname like 'pg_toast%index' then 'toast index' when relname like 'pg_toast%' then 'toast table' else relname end, 'dropped table'), mode, locktype from pg_locks l left outer join pg_class c on (l.relation = c.oid), pg_database d where relation is not null and l.database = d.oid and l.gp_segment_id = -1 and relname != 'gp_fault_strategy' and d.datname = current_database() order by 1, 3, 2;
CREATE
DELETE FROM ao WHERE a < 128;
DELETE 2667
1: BEGIN;
BEGIN
1: SELECT COUNT(*) FROM ao;
count
-----
18333
(1 row)
1: SELECT * FROM locktest WHERE coalesce = 'ao';
coalesce|mode |locktype
--------+---------------+--------
ao |AccessShareLock|relation
(1 row)
2&: VACUUM ao; <waiting ...>
1: COMMIT;
COMMIT
2<: <... completed>
VACUUM
1: SELECT COUNT(*) FROM ao;
count
-----
18333
(1 row)
3: INSERT INTO ao VALUES (0);
INSERT 1
-- @Description Ensures that a select during a delete operation is ok
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT) WITH (appendonly=true);
CREATE
insert into ao select generate_series(1,100);
INSERT 100
2: BEGIN;
BEGIN
......@@ -45,7 +51,7 @@ a
8
9
(5 rows)
2U: SELECT * FROM gp_aovisimap_name('ao');
2U: SELECT * FROM gp_toolkit.__gp_aovisimap_name('ao');
tid |segno|row_num
----------------+-----+-------
(33554432,32769)|1 |1
......
-- @Description Ensures that a select during a delete operation is ok
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT) WITH (appendonly=true);
CREATE
insert into ao select generate_series(1,100);
INSERT 100
2: BEGIN;
BEGIN
......@@ -45,7 +51,7 @@ a
8
9
(5 rows)
2U: SELECT * FROM gp_aovisimap_name('ao');
2U: SELECT * FROM gp_toolkit.__gp_aovisimap_name('ao');
tid |segno|row_num
----------------+-----+-------
(33554432,32769)|1 |1
......@@ -53,4 +59,3 @@ tid |segno|row_num
(2 rows)
4: INSERT INTO ao VALUES (0);
INSERT 1
-- @Description Ensures that a select during a full vacuum operation is ok
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT) WITH (appendonly=true);
CREATE
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
DELETE FROM ao WHERE a < 128;
DELETE 2667
1: BEGIN;
BEGIN
1>: SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;COMMIT; <waiting ...>
2: VACUUM FULL ao;
VACUUM
1<: <... completed>
SELECT
3: INSERT INTO ao VALUES (0);
INSERT 1
-- @Description Ensures that a select during a vacuum operation is ok
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT) WITH (appendonly=true);
CREATE
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
DELETE FROM ao WHERE a < 128;
DELETE 2667
1: BEGIN;
BEGIN
1>: SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;COMMIT;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;COMMIT; <waiting ...>
2: VACUUM ao;
VACUUM
1<: <... completed>
SELECT
3: INSERT INTO ao VALUES (0);
INSERT 1
-- @Description Ensures that a select from a serializalbe transaction is ok after vacuum
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT) WITH (appendonly=true);
CREATE
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
DELETE FROM ao WHERE a < 128;
DELETE 2667
1: BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
BEGIN
2: VACUUM ao;
VACUUM
1: SELECT COUNT(*) FROM ao;
count
-----
18333
(1 row)
3: INSERT INTO ao VALUES (0);
INSERT 1
-- @Description Ensures that a serializable select before during a vacuum operation avoids the compaction.
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT) WITH (appendonly=true);
CREATE
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
DELETE FROM ao WHERE a < 128;
DELETE 2667
1: BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
BEGIN
1: SELECT COUNT(*) FROM ao;
count
-----
18333
(1 row)
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
segno|tupcount
-----+--------
1 |21000
(1 row)
2: VACUUM ao;
VACUUM
1: SELECT COUNT(*) FROM ao;
count
-----
18333
(1 row)
1: COMMIT;
COMMIT
3: INSERT INTO ao VALUES (0);
INSERT 1
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
segno|tupcount
-----+--------
1 |21001
(1 row)
-- @Description Ensures that a serializable select before during a vacuum operation avoids the compaction.
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT) WITH (appendonly=true);
CREATE
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
DELETE FROM ao WHERE a < 128;
DELETE 2667
1: BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
BEGIN
1: SELECT COUNT(*) FROM ao;
count
-----
18333
(1 row)
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
segno|tupcount
-----+--------
1 |10521
(1 row)
2: VACUUM ao;
VACUUM
1: SELECT COUNT(*) FROM ao;
count
-----
18333
(1 row)
1: COMMIT;
COMMIT
3: INSERT INTO ao VALUES (0);
INSERT 1
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
segno|tupcount
-----+--------
1 |10521
(1 row)
-- @Description Ensures that an insert during a vacuum operation is ok
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT) WITH (appendonly=true);
CREATE
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
DELETE FROM ao WHERE a < 128;
DELETE 2667
......
-- @Description Ensures that an update during a vacuum operation is ok
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,10) AS i;
INSERT 10
DELETE FROM ao WHERE a < 2;
DELETE 1
......
-- @Description Ensures that an update during a vacuum operation is ok
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,1000) AS i;
INSERT 1000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,1000) AS i;
INSERT 1000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,1000) AS i;
INSERT 1000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,1000) AS i;
INSERT 1000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,1000) AS i;
INSERT 1000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,1000) AS i;
INSERT 1000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,1000) AS i;
INSERT 1000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,1000) AS i;
INSERT 1000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,1000) AS i;
INSERT 1000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,1000) AS i;
INSERT 1000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,1000) AS i;
INSERT 1000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,1000) AS i;
INSERT 1000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,1000) AS i;
INSERT 1000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,1000) AS i;
INSERT 1000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,1000) AS i;
INSERT 1000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,1000) AS i;
INSERT 1000
DELETE FROM ao WHERE a < 128;
DELETE 2032
......
-- @Description Ensures that an update before a vacuum operation is ok
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100) AS i;
INSERT 100
DELETE FROM ao WHERE a < 12;
DELETE 11
......
-- @Description Ensures that a vacuum with serializable works ok
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100) AS i;
INSERT 100
DELETE FROM ao WHERE a < 20;
DELETE 19
......@@ -10,14 +16,14 @@ count
-----
81
(1 row)
SELECT segno, tupcount FROM gp_aoseg_name('ao');
SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
segno|tupcount
-----+--------
1 |100
(1 row)
VACUUM ao;
VACUUM
SELECT segno, tupcount FROM gp_aoseg_name('ao');
SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
segno|tupcount
-----+--------
1 |0
......
-- @Description Ensures that a vacuum with serializable works ok
--
--
DROP TABLE IF EXISTS ao;
DROP
DROP TABLE IF EXISTS ao2;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
CREATE TABLE ao2 (a INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100) AS i;
INSERT 100
DELETE FROM ao WHERE a < 20;
DELETE 19
......@@ -17,14 +27,14 @@ count
-----
0
(1 row)
2: SELECT segno, tupcount FROM gp_aoseg_name('ao');
2: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
segno|tupcount
-----+--------
1 |100
(1 row)
2: VACUUM ao;
VACUUM
2: SELECT segno, tupcount FROM gp_aoseg_name('ao');
2: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
segno|tupcount
-----+--------
1 |0
......
-- @Description Ensures that a vacuum with serializable works ok
--
--
DROP TABLE IF EXISTS ao;
DROP
DROP TABLE IF EXISTS ao2;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
CREATE TABLE ao2 (a INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100) AS i;
INSERT 100
DELETE FROM ao WHERE a < 20;
DELETE 19
......@@ -10,14 +20,14 @@ count
-----
81
(1 row)
SELECT segno, tupcount FROM gp_aoseg_name('ao');
SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
segno|tupcount
-----+--------
1 |100
(1 row)
VACUUM ao;
VACUUM
SELECT segno, tupcount FROM gp_aoseg_name('ao');
SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
segno|tupcount
-----+--------
1 |0
......
-- @Description Ensures that a vacuum during insert operations is ok
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT) WITH (appendonly=true);
CREATE
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
insert into ao select generate_series(1,1000);
INSERT 1000
DELETE FROM ao WHERE a < 128;
DELETE 2667
......
-- @Description Ensures that an vacuum while a vacuum operation is ok
--
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 10000) AS i;
INSERT 10000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 10000) AS i;
INSERT 10000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 10000) AS i;
INSERT 10000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 10000) AS i;
INSERT 10000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 10000) AS i;
INSERT 10000
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 10000) AS i;
INSERT 10000
DELETE FROM ao WHERE a < 1200;
DELETE 7194
......
/*-------------------------------------------------------------------------
*
* isolation2_main --- pg_regress test launcher for Python isolation tests
*
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/test/isolation2/isolation2_main.c
*
*-------------------------------------------------------------------------
*/
#include "pg_regress.h"
/*
* start a Python isolation tester process for specified file (including
* redirection), and return process ID
*/
static PID_TYPE
isolation_start_test(const char *testname,
_stringlist ** resultfiles,
_stringlist ** expectfiles,
_stringlist ** tags)
{
PID_TYPE pid;
char infile[MAXPGPATH];
char outfile[MAXPGPATH];
char expectfile[MAXPGPATH];
char psql_cmd[MAXPGPATH * 3];
size_t offset = 0;
/*
* Look for files in the output dir first, consistent with a vpath search.
* This is mainly to create more reasonable error messages if the file is
* not found. It also allows local test overrides when running pg_regress
* outside of the source tree.
*/
snprintf(infile, sizeof(infile), "%s/sql/%s.sql",
outputdir, testname);
if (!file_exists(infile))
snprintf(infile, sizeof(infile), "%s/sql/%s.sql",
inputdir, testname);
snprintf(outfile, sizeof(outfile), "%s/results/%s.out",
outputdir, testname);
snprintf(expectfile, sizeof(expectfile), "%s/expected/%s.out",
outputdir, testname);
if (!file_exists(expectfile))
snprintf(expectfile, sizeof(expectfile), "%s/expected/%s.out",
inputdir, testname);
add_stringlist_item(resultfiles, outfile);
add_stringlist_item(expectfiles, expectfile);
/*
* GPDB_91_MERGE_FIXME: pg_regress --launcher argument was added in PostgreSQL 9.1.
* We don't have it in GPDB yet. Re-enable this when we merge with 9.1.
*/
#if PG_VERSION_NUM >= 90100
if (launcher)
offset += snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
"%s ", launcher);
#endif
snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
SYSTEMQUOTE "python ./sql_isolation_testcase.py --dbname=\"%s\" < \"%s\" > \"%s\" 2>&1" SYSTEMQUOTE,
dblist->str,
infile,
outfile);
pid = spawn_process(psql_cmd);
if (pid == INVALID_PID)
{
fprintf(stderr, _("could not start process for test %s\n"),
testname);
exit_nicely(2);
}
return pid;
}
static void
isolation_init(void)
{
/* set default regression database name */
add_stringlist_item(&dblist, "isolation2test");
}
int
main(int argc, char *argv[])
{
return regression_main(argc, argv, isolation_init, isolation_start_test);
}
# Tests on Append-Optimized tables.
test: alter_while_vacuum
test: alter_while_vacuum2
test: compaction_full_stats
test: compaction_utility
test: compaction_utility_insert
test: cursor_before_delete
test: cursor_before_deletevacuum
test: cursor_before_update
test: cursor_withhold
test: cursor_withhold2
test: delete_while_vacuum
test: drop_while_vacuum
test: insert_policy
test: insert_while_vacuum
test: locks_reindex
test: max_concurrency
test: max_concurrency2
test: modcount
test: modcount_vacuum
test: parallel_delete
test: parallel_update
test: parallel_update_readcommitted
test: phantom_reads
test: phantom_reads_delete
test: phantom_reads_serializable
test: phantom_reads_update
test: select_after_vacuum
test: select_after_vacuum_serializable
test: select_before_vacuum
test: select_while_delete
test: select_while_full_vacuum
test: select_while_vacuum
test: select_while_vacuum_serializable
test: select_while_vacuum_serializable2
test: selectinsert_while_vacuum
test: selectinsertupdate_while_vacuum
test: selectupdate_while_vacuum
test: update_while_vacuum
test: vacuum_self_serializable
test: vacuum_self_serializable2
test: vacuum_self_serializable3
test: vacuum_while_insert
test: vacuum_while_vacuum
-- @Description Ensures that an alter table while a vacuum operation is ok
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100000) AS i;
DELETE FROM ao WHERE a < 12000;
1: SELECT COUNT(*) FROM ao;
......
-- start_ignore
SET gp_create_table_random_default_distribution=off;
-- end_ignore
-- @Description Ensures that an alter table while a vacuum operation is ok
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
......@@ -11,3 +10,10 @@ INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100000) AS i;
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100000) AS i;
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100000) AS i;
DELETE FROM ao WHERE a < 12000;
1: SELECT COUNT(*) FROM ao;
2: set debug_appendonly_print_compaction=true;
2>: VACUUM ao;
1: Alter table ao set with ( reorganize='true') distributed randomly;
2<:
1: SELECT COUNT(*) FROM ao WHERE a < 12010;
-- @Description Tests the behavior of full vacuum w.r.t. the pg_class statistics
--
DROP TABLE IF EXISTS foo;
CREATE TABLE foo (a INT, b INT, c CHAR(128)) WITH (appendonly=true) DISTRIBUTED BY (a);
CREATE INDEX foo_index ON foo(b);
INSERT INTO foo SELECT i as a, i as b, 'hello world' as c FROM generate_series(1, 50) AS i;
INSERT INTO foo SELECT i as a, i as b, 'hello world' as c FROM generate_series(51, 100) AS i;
ANALYZE foo;
-- ensure that the scan go through the index
SET enable_seqscan=false;
......@@ -9,4 +16,4 @@ DELETE FROM foo WHERE a < 16;
VACUUM FULL foo;
SELECT relname, reltuples FROM pg_class WHERE relname = 'foo';
SELECT relname, reltuples FROM pg_class WHERE relname = 'foo_index';
SELECT segno, tupcount,state FROM gp_aoseg_name('foo');
SELECT segno, tupcount,state FROM gp_toolkit.__gp_aoseg_name('foo');
-- start_ignore
SET gp_create_table_random_default_distribution=off;
-- end_ignore
-- @Description Tests the basic behavior of (lazy) vacuum when called from utility mode
--
DROP TABLE IF EXISTS foo;
CREATE TABLE foo (a INT, b INT, c CHAR(128)) WITH (appendonly=true);
CREATE INDEX foo_index ON foo(b);
INSERT INTO foo SELECT i as a, 1 as b, 'hello world' as c FROM generate_series(1, 100) AS i;
DELETE FROM foo WHERE a < 20;
SELECT COUNT(*) FROM foo;
2U: VACUUM foo;
SELECT COUNT(*) FROM foo;
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('foo');
-- @Description Tests the compaction of data inserted in utility mode
--
DROP TABLE IF EXISTS foo;
CREATE TABLE foo (a INT, b INT, c CHAR(128)) WITH (appendonly=true);
CREATE INDEX foo_index ON foo(b);
INSERT INTO foo VALUES (1, 1, 'c');
SELECT segno, tupcount, state FROM gp_aoseg_name('foo');
SELECT segno, tupcount, state FROM gp_toolkit.__gp_aoseg_name('foo');
2U: INSERT INTO foo VALUES (2, 2, 'c');
2U: INSERT INTO foo VALUES (3, 3, 'c');
2U: SELECT segno, tupcount, state FROM gp_aoseg_name('foo');
2U: SELECT segno, tupcount, state FROM gp_toolkit.__gp_aoseg_name('foo');
-- We know that the master does update its tupcount yet
SELECT segno, tupcount, state FROM gp_aoseg_name('foo');
SELECT segno, tupcount, state FROM gp_toolkit.__gp_aoseg_name('foo');
DELETE FROM foo WHERE a = 2;
UPDATE foo SET b = -1 WHERE a = 3;
VACUUM foo;
2U: SELECT segno, tupcount, state FROM gp_aoseg_name('foo');
SELECT segno, tupcount, state FROM gp_aoseg_name('foo');
2U: SELECT segno, tupcount, state FROM gp_toolkit.__gp_aoseg_name('foo');
SELECT segno, tupcount, state FROM gp_toolkit.__gp_aoseg_name('foo');
-- @Description Tests the visibility when a cursor has been created before the delete.
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT) WITH (appendonly=true);
insert into ao select generate_series(1, 100);
1: BEGIN;
1: DECLARE cur CURSOR FOR SELECT a FROM ao ORDER BY a;
......
-- @Description Tests the visibility when a cursor has been created before the delete.
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT) WITH (appendonly=true);
insert into ao select generate_series(1, 10);
1: BEGIN;
1: DECLARE cur CURSOR FOR SELECT a FROM ao ORDER BY a;
......
-- @Description Tests the visibility when a cursor has been created before the update.
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,100) AS i;
1: BEGIN;
1: DECLARE cur CURSOR FOR SELECT a,b FROM ao ORDER BY a;
......
-- @Description Tests the visibility of an "with hold" cursor w.r.t. deletes.
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT) WITH (appendonly=true);
insert into ao select generate_series(1,100);
1: DECLARE cur CURSOR WITH HOLD FOR SELECT a FROM ao ORDER BY a;
1: FETCH NEXT IN cur;
......
-- @Description Tests the visibility of an "with hold" cursor w.r.t. deletes.
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT) WITH (appendonly=true);
insert into ao select generate_series(1,10);
1: BEGIN;
1: DECLARE cur CURSOR WITH HOLD FOR SELECT a FROM ao ORDER BY a;
......
-- @Description Ensures that a delete before a vacuum operation is ok
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100) AS i;
DELETE FROM ao WHERE a < 12;
1: BEGIN;
......
-- @Description Ensures that a drop table while a vacuum operation is ok
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100000) AS i;
DELETE FROM ao WHERE a < 12000;
1: SELECT COUNT(*) FROM ao;
......
-- start_ignore
SET gp_create_table_random_default_distribution=off;
-- end_ignore
-- @Description Tests the AO segment file selection policy
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT) WITH (appendonly=true);
1: INSERT INTO AO VALUES (1);
......@@ -129,3 +128,19 @@ CREATE TABLE ao (a INT) WITH (appendonly=true);
1: INSERT INTO AO VALUES (1);
1: INSERT INTO AO VALUES (1);
1: INSERT INTO AO VALUES (1);
-- Actual test begins
1: INSERT INTO AO VALUES (1);
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
1: INSERT INTO AO VALUES (2);
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
1: BEGIN;
1: INSERT INTO AO VALUES (2);
2: BEGIN;
2: INSERT INTO AO VALUES (2);
1: COMMIT;
2: COMMIT;
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
1: insert into ao select generate_series(1,100000);
1: INSERT INTO AO VALUES (2);
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
-- @Description Ensures that an insert during a vacuum operation is ok
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT) WITH (appendonly=true);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
DELETE FROM ao WHERE a < 128;
2>: VACUUM ao;
......
-- start_ignore
SET gp_create_table_random_default_distribution=off;
-- end_ignore
-- @Description The locks held after different operations
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100) AS i;
......@@ -26,3 +23,20 @@ create view locktest as select coalesce(
l.relation = c.oid and
relname != 'gp_fault_strategy' and
d.datname = current_database() order by 1, 3, 2;
-- Actual test begins
1: BEGIN;
1: INSERT INTO ao VALUES (200, 200);
SELECT * FROM locktest;
2U: SELECT * FROM locktest;
1: COMMIT;
1: BEGIN;
1: DELETE FROM ao WHERE a = 1;
SELECT * FROM locktest;
2U: SELECT * FROM locktest;
1: COMMIT;
1: BEGIN;
1: UPDATE ao SET b = -1 WHERE a = 2;
SELECT * FROM locktest;
2U: SELECT * FROM locktest;
1: COMMIT;
-- @Description Insert into a ao relation with 127 concurrent transactions
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
1: BEGIN;
2: BEGIN;
......@@ -383,4 +385,4 @@
126: COMMIT;
127: COMMIT;
SELECT * FROM ao;
SELECT * FROM gp_aoseg_name('ao') ORDER BY segno;
SELECT * FROM gp_toolkit.__gp_aoseg_name('ao') ORDER BY segno;
-- @Description Insert into a ao relation with 128 concurrent transactions.
-- The 128th transaction is expected to fail.
--
--
--
-- start_matchsubs
-- m/could not find segment file to use for inserting into relation ao .*/
-- s/could not find segment file to use for inserting into relation ao .*/could not find segment file to use for inserting into relation ao ###/
-- end_matchsubs
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
1: BEGIN;
2: BEGIN;
......@@ -387,4 +395,4 @@
127: COMMIT;
128: ROLLBACK;
SELECT * FROM ao;
SELECT * FROM gp_aoseg_name('ao') ORDER BY segno;
SELECT * FROM gp_toolkit.__gp_aoseg_name('ao') ORDER BY segno;
-- @Description Tests that DML operatins change the modification count.
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,10) AS i;
SELECT state, tupcount, modcount FROM gp_toolkit.__gp_aoseg_name('ao');
INSERT INTO ao VALUES (11, 11);
SELECT state, tupcount, modcount FROM gp_toolkit.__gp_aoseg_name('ao');
DELETE FROM ao WHERE a = 11;
SELECT state, tupcount, modcount FROM gp_toolkit.__gp_aoseg_name('ao');
UPDATE AO SET b = 0 WHERE a = 10;
SELECT state, tupcount, modcount FROM gp_toolkit.__gp_aoseg_name('ao');
-- start_ignore
SET gp_create_table_random_default_distribution=off;
-- end_ignore
-- @Description Tests that vacuum is not changing the modification count.
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,10) AS i;
DELETE FROM ao WHERE a < 5;
SELECT state, tupcount, modcount FROM gp_toolkit.__gp_aoseg_name('ao');
VACUUM ao;
SELECT state, tupcount, modcount FROM gp_toolkit.__gp_aoseg_name('ao');
-- start_ignore
SET gp_create_table_random_default_distribution=off;
-- end_ignore
-- @Description Tests that a delete operation in progress will block all other deletes
-- until the transaction is committed.
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT) WITH (appendonly=true) DISTRIBUTED BY (a);
insert into ao select generate_series(1,100);
......@@ -18,3 +17,17 @@ create view locktest as select coalesce(
l.gp_segment_id = -1 and
relname != 'gp_fault_strategy' and
d.datname = current_database() order by 1, 3, 2;
-- The actual test begins
1: BEGIN;
2: BEGIN;
2: DELETE FROM ao WHERE a = 1;
2: SELECT * FROM locktest WHERE coalesce = 'ao';
1&: DELETE FROM ao WHERE a = 2;
2: COMMIT;
1<:
1: COMMIT;
3: BEGIN;
3: SELECT * FROM ao WHERE a < 5 ORDER BY a;
3: COMMIT;
2U: SELECT * FROM gp_toolkit.__gp_aovisimap_name('ao');
-- start_ignore
SET gp_create_table_random_default_distribution=off;
-- end_ignore
-- @Description Tests that a update operation in progress will block all other updates
-- until the transaction is committed.
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,10) AS i;
......@@ -18,3 +17,15 @@ create view locktest as select coalesce(
l.gp_segment_id = -1 and
relname != 'gp_fault_strategy' and
d.datname = current_database() order by 1, 3, 2;
-- The actual test begins
1: BEGIN;
2: BEGIN;
2: UPDATE ao SET b = 42 WHERE a = 1;
2: SELECT * FROM locktest WHERE coalesce = 'ao';
1&: UPDATE ao SET b = 42 WHERE a = 2;
2: COMMIT;
1<:
1: COMMIT;
3: SELECT * FROM ao WHERE a < 5 ORDER BY a;
2U: SELECT * FROM gp_toolkit.__gp_aovisimap_name('ao');
-- start_ignore
SET gp_create_table_random_default_distribution=off;
-- end_ignore
-- @Description Tests that a update operation in progress will block all other updates
-- until the transaction is committed.
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,10) AS i;
......@@ -18,3 +17,13 @@ create view locktest as select coalesce(
l.gp_segment_id = -1 and
relname != 'gp_fault_strategy' and
d.datname = current_database() order by 1, 3, 2;
-- The actual test begins
1: BEGIN;
2: BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
1: UPDATE ao SET b = 42 WHERE b = 1;
2&: UPDATE ao SET b = -1 WHERE b = 1;
1: COMMIT;
2<:
2: COMMIT;
SELECT * FROM ao WHERE b < 2;
-- @Description Tests the basic phantom read behavior of GPDB.
-- Actually, no UAO is involved here.
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100) AS i;
1: BEGIN;
1: SELECT * FROM ao WHERE b BETWEEN 20 AND 30 ORDER BY a;
......
-- @Description Tests the basic phantom read behavior of GPDB w.r.t to delete using
-- the default isolation level.
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100) AS i;
1: BEGIN;
1: SELECT * FROM ao WHERE b BETWEEN 20 AND 30 ORDER BY a;
......
-- @Description Tests the basic phantom read behavior of GPDB with serializable.
-- transactions. Actually, no UAO is involved here.
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100) AS i;
1: BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1: SELECT * FROM ao WHERE b BETWEEN 20 AND 30 ORDER BY a;
......
-- @Description Tests the basic phantom read behavior of GPDB w.r.t to updates using
-- the default isolation level.
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100) AS i;
1: BEGIN;
1: SELECT * FROM ao WHERE b BETWEEN 20 AND 30 ORDER BY a;
......
-- start_ignore
SET gp_create_table_random_default_distribution=off;
-- end_ignore
-- @Description Ensures that a select after a vacuum operation is ok
--
DROP TABLE IF EXISTS ao;
DROP TABLE IF EXISTS ao2;
CREATE TABLE ao2 (a INT) WITH (appendonly=true);
CREATE TABLE ao (a INT) WITH (appendonly=true);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
......@@ -25,6 +25,7 @@ insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao2 select generate_series(1,1000);
DROP VIEW IF EXISTS locktest;
create view locktest as select coalesce(
......@@ -38,3 +39,16 @@ create view locktest as select coalesce(
l.gp_segment_id = -1 and
relname != 'gp_fault_strategy' and
d.datname = current_database() order by 1, 3, 2;
-- The actual test begins
DELETE FROM ao WHERE a < 128;
1: BEGIN;
1: SELECT COUNT(*) FROM ao2;
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
2: VACUUM ao;
1: SELECT COUNT(*) FROM ao;
1: SELECT * FROM locktest WHERE coalesce = 'ao';
1: COMMIT;
1: SELECT COUNT(*) FROM ao;
3: INSERT INTO ao VALUES (0);
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
-- start_ignore
SET gp_create_table_random_default_distribution=off;
-- end_ignore
-- @Description Ensures that a serializable select before during a vacuum operation blocks the vacuum.
--
DROP TABLE IF EXISTS ao;
DROP TABLE IF EXISTS ao2;
CREATE TABLE ao (a INT) WITH (appendonly=true);
CREATE TABLE ao2 (a INT) WITH (appendonly=true);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
......@@ -25,4 +25,12 @@ insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao2 select generate_series(1,1000);
DELETE FROM ao WHERE a < 128;
1: BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1: SELECT COUNT(*) FROM ao2;
2: VACUUM ao;
1: SELECT COUNT(*) FROM ao;
1: COMMIT;
3: INSERT INTO ao VALUES (0);
-- start_ignore
SET gp_create_table_random_default_distribution=off;
-- end_ignore
-- @Description Ensures that a select before a vacuum operation is ok
--
DROP TABLE IF EXISTS ao;
DROP TABLE IF EXISTS ao2;
CREATE TABLE ao2 (a INT) WITH (appendonly=true);
CREATE TABLE ao (a INT) WITH (appendonly=true);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
......@@ -27,7 +23,6 @@ insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao2 select generate_series(1,1000);
DROP VIEW IF EXISTS locktest;
create view locktest as select coalesce(
......@@ -41,3 +36,13 @@ create view locktest as select coalesce(
l.gp_segment_id = -1 and
relname != 'gp_fault_strategy' and
d.datname = current_database() order by 1, 3, 2;
DELETE FROM ao WHERE a < 128;
1: BEGIN;
1: SELECT COUNT(*) FROM ao;
1: SELECT * FROM locktest WHERE coalesce = 'ao';
2&: VACUUM ao;
1: COMMIT;
2<:
1: SELECT COUNT(*) FROM ao;
3: INSERT INTO ao VALUES (0);
-- @Description Ensures that a select during a delete operation is ok
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT) WITH (appendonly=true);
insert into ao select generate_series(1,100);
2: BEGIN;
2: SELECT * FROM ao WHERE a < 5 ORDER BY a;
......@@ -9,5 +12,5 @@
2: COMMIT;
2: SELECT * FROM ao WHERE a < 5 ORDER BY a;
4: SELECT * FROM ao WHERE a < 10 ORDER BY a;
2U: SELECT * FROM gp_aovisimap_name('ao');
2U: SELECT * FROM gp_toolkit.__gp_aovisimap_name('ao');
4: INSERT INTO ao VALUES (0);
-- start_ignore
SET gp_create_table_random_default_distribution=off;
-- end_ignore
-- @Description Ensures that a select during a full vacuum operation is ok
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT) WITH (appendonly=true);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
......@@ -26,3 +24,9 @@ insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
DELETE FROM ao WHERE a < 128;
1: BEGIN;
1>: SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;COMMIT;
2: VACUUM FULL ao;
1<:
3: INSERT INTO ao VALUES (0);
-- @Description Ensures that a select during a vacuum operation is ok
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT) WITH (appendonly=true);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
DELETE FROM ao WHERE a < 128;
1: BEGIN;
1>: SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;COMMIT;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;COMMIT;
2: VACUUM ao;
1<:
3: INSERT INTO ao VALUES (0);
-- start_ignore
SET gp_create_table_random_default_distribution=off;
-- end_ignore
-- @Description Ensures that a select from a serializalbe transaction is ok after vacuum
--
DROP TABLE IF EXISTS ao;
DROP TABLE IF EXISTS ao2;
CREATE TABLE ao (a INT) WITH (appendonly=true);
CREATE TABLE ao2 (a INT) WITH (appendonly=true);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
......@@ -27,5 +23,9 @@ insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao2 select generate_series(1,1000);
DELETE FROM ao WHERE a < 128;
1: BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
2: VACUUM ao;
1: SELECT COUNT(*) FROM ao;
3: INSERT INTO ao VALUES (0);
-- start_ignore
SET gp_create_table_random_default_distribution=off;
-- end_ignore
-- @Description Ensures that a serializable select before during a vacuum operation avoids the compaction.
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT) WITH (appendonly=true);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
......@@ -26,3 +24,12 @@ insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
DELETE FROM ao WHERE a < 128;
1: BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1: SELECT COUNT(*) FROM ao;
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
2: VACUUM ao;
1: SELECT COUNT(*) FROM ao;
1: COMMIT;
3: INSERT INTO ao VALUES (0);
2U: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
-- @Description Ensures that an insert during a vacuum operation is ok
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT) WITH (appendonly=true);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
DELETE FROM ao WHERE a < 128;
4: BEGIN;
......
-- @Description Ensures that an update during a vacuum operation is ok
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,10) AS i;
DELETE FROM ao WHERE a < 2;
4: BEGIN;
......
-- start_ignore
SET gp_create_table_random_default_distribution=off;
-- end_ignore
-- @Description Ensures that an update during a vacuum operation is ok
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,1000) AS i;
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,1000) AS i;
......@@ -20,3 +18,16 @@ INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,1000) AS i;
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,1000) AS i;
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,1000) AS i;
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1,1000) AS i;
DELETE FROM ao WHERE a < 128;
4: BEGIN;
4: SELECT COUNT(*) FROM ao;
5: BEGIN;
4: SELECT COUNT(*) FROM ao;
4: BEGIN;
4: SELECT COUNT(*) FROM ao;
2>: VACUUM ao;
4: SELECT COUNT(*) FROM ao;SELECT COUNT(*) FROM ao;BEGIN;UPDATE ao SET b=1 WHERE a > 500;UPDATE ao SET b=1 WHERE a > 400;COMMIT;
2<:
3: SELECT COUNT(*) FROM ao WHERE b = 1;
3: INSERT INTO ao VALUES (0);
-- @Description Ensures that an update before a vacuum operation is ok
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100) AS i;
DELETE FROM ao WHERE a < 12;
1: BEGIN;
......
-- @Description Ensures that a vacuum with serializable works ok
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100) AS i;
DELETE FROM ao WHERE a < 20;
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
SELECT COUNT(*) FROM ao;
SELECT segno, tupcount FROM gp_aoseg_name('ao');
SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
VACUUM ao;
SELECT segno, tupcount FROM gp_aoseg_name('ao');
SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
SELECT COUNT(*) FROM ao;
-- @Description Ensures that a vacuum with serializable works ok
--
DROP TABLE IF EXISTS ao;
DROP TABLE IF EXISTS ao2;
CREATE TABLE ao (a INT, b INT) WITH (appendonly=true);
CREATE TABLE ao2 (a INT) WITH (appendonly=true);
INSERT INTO ao SELECT i as a, i as b FROM generate_series(1, 100) AS i;
DELETE FROM ao WHERE a < 20;
1: SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1: SELECT COUNT(*) FROM ao;
1: BEGIN;
1: SELECT COUNT(*) FROM ao2;
2: SELECT segno, tupcount FROM gp_aoseg_name('ao');
2: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
2: VACUUM ao;
2: SELECT segno, tupcount FROM gp_aoseg_name('ao');
2: SELECT segno, tupcount FROM gp_toolkit.__gp_aoseg_name('ao');
1: SELECT COUNT(*) FROM ao;
1: COMMIT;
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册