diff options
author | Peter Eisentraut | 2019-05-15 17:37:52 +0000 |
---|---|---|
committer | Peter Eisentraut | 2019-05-22 16:41:53 +0000 |
commit | 66a4bad83aaa6613a45a00a488c04427f9969fb4 (patch) | |
tree | ccb6a7ebbe8db2a9d8bedc27c63edb0f70db26c0 /src/test | |
parent | 03de5187d50af67d154a47cf00899290dca13003 (diff) |
Convert ExecComputeStoredGenerated to use tuple slots
This code was still using the old style of forming a heap tuple rather
than using tuple slots. This would be less efficient if a non-heap
access method was used. And using tuple slots is actually quite a bit
faster when using heap as well.
Also add some test cases for generated columns with null values and
with varlena values. This lack of coverage was discovered while
working on this patch.
Discussion: https://www.postgresql.org/message-id/flat/20190331025744.ugbsyks7czfcoksd%40alap3.anarazel.de
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/regress/expected/generated.out | 31 | ||||
-rw-r--r-- | src/test/regress/sql/generated.sql | 10 |
2 files changed, 35 insertions, 6 deletions
diff --git a/src/test/regress/expected/generated.out b/src/test/regress/expected/generated.out index d4ed3f7ae1b..f62c93f4686 100644 --- a/src/test/regress/expected/generated.out +++ b/src/test/regress/expected/generated.out @@ -226,15 +226,16 @@ NOTICE: merging multiple inherited definitions of column "b" ERROR: inherited column "b" has a generation conflict DROP TABLE gtesty; -- test stored update -CREATE TABLE gtest3 (a int PRIMARY KEY, b int GENERATED ALWAYS AS (a * 3) STORED); -INSERT INTO gtest3 (a) VALUES (1), (2), (3); +CREATE TABLE gtest3 (a int, b int GENERATED ALWAYS AS (a * 3) STORED); +INSERT INTO gtest3 (a) VALUES (1), (2), (3), (NULL); SELECT * FROM gtest3 ORDER BY a; a | b ---+--- 1 | 3 2 | 6 3 | 9 -(3 rows) + | +(4 rows) UPDATE gtest3 SET a = 22 WHERE a = 2; SELECT * FROM gtest3 ORDER BY a; @@ -243,7 +244,29 @@ SELECT * FROM gtest3 ORDER BY a; 1 | 3 3 | 9 22 | 66 -(3 rows) + | +(4 rows) + +CREATE TABLE gtest3a (a text, b text GENERATED ALWAYS AS (a || '+' || a) STORED); +INSERT INTO gtest3a (a) VALUES ('a'), ('b'), ('c'), (NULL); +SELECT * FROM gtest3a ORDER BY a; + a | b +---+----- + a | a+a + b | b+b + c | c+c + | +(4 rows) + +UPDATE gtest3a SET a = 'bb' WHERE a = 'b'; +SELECT * FROM gtest3a ORDER BY a; + a | b +----+------- + a | a+a + bb | bb+bb + c | c+c + | +(4 rows) -- COPY TRUNCATE gtest1; diff --git a/src/test/regress/sql/generated.sql b/src/test/regress/sql/generated.sql index da11b8c9b89..6a56ae260f6 100644 --- a/src/test/regress/sql/generated.sql +++ b/src/test/regress/sql/generated.sql @@ -95,12 +95,18 @@ CREATE TABLE gtest1_2 () INHERITS (gtest1, gtesty); -- error DROP TABLE gtesty; -- test stored update -CREATE TABLE gtest3 (a int PRIMARY KEY, b int GENERATED ALWAYS AS (a * 3) STORED); -INSERT INTO gtest3 (a) VALUES (1), (2), (3); +CREATE TABLE gtest3 (a int, b int GENERATED ALWAYS AS (a * 3) STORED); +INSERT INTO gtest3 (a) VALUES (1), (2), (3), (NULL); SELECT * FROM gtest3 ORDER BY a; UPDATE gtest3 SET a = 22 WHERE a = 2; SELECT * FROM gtest3 ORDER BY a; +CREATE TABLE gtest3a (a text, b text GENERATED ALWAYS AS (a || '+' || a) STORED); +INSERT INTO gtest3a (a) VALUES ('a'), ('b'), ('c'), (NULL); +SELECT * FROM gtest3a ORDER BY a; +UPDATE gtest3a SET a = 'bb' WHERE a = 'b'; +SELECT * FROM gtest3a ORDER BY a; + -- COPY TRUNCATE gtest1; INSERT INTO gtest1 (a) VALUES (1), (2); |