Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit97e8346

Browse files
committed
Regression tests for TOAST.
Kevin Grittner, per discussion of bug #5989
1 parentb429519 commit97e8346

File tree

6 files changed

+62
-10
lines changed

6 files changed

+62
-10
lines changed

‎src/test/regress/expected/delete.out

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
CREATE TABLE delete_test (
22
id SERIAL PRIMARY KEY,
3-
a INT
3+
a INT,
4+
b text
45
);
56
NOTICE: CREATE TABLE will create implicit sequence "delete_test_id_seq" for serial column "delete_test.id"
67
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "delete_test_pkey" for table "delete_test"
78
INSERT INTO delete_test (a) VALUES (10);
8-
INSERT INTO delete_test (a) VALUES (50);
9+
INSERT INTO delete_test (a, b) VALUES (50, repeat('x', 10000));
910
INSERT INTO delete_test (a) VALUES (100);
1011
-- allow an alias to be specified for DELETE's target table
1112
DELETE FROM delete_test AS dt WHERE dt.a > 75;
@@ -16,11 +17,19 @@ ERROR: invalid reference to FROM-clause entry for table "delete_test"
1617
LINE 1: DELETE FROM delete_test dt WHERE delete_test.a > 25;
1718
^
1819
HINT: Perhaps you meant to reference the table alias "dt".
19-
SELECT* FROM delete_test;
20-
id | a
21-
----+----
22-
1 | 10
23-
2 | 50
20+
SELECTid, a, char_length(b) FROM delete_test;
21+
id | a| char_length
22+
----+----+-------------
23+
1 | 10 |
24+
2 | 50 | 10000
2425
(2 rows)
2526

27+
-- delete a row with a TOASTed value
28+
DELETE FROM delete_test WHERE a > 25;
29+
SELECT id, a, char_length(b) FROM delete_test;
30+
id | a | char_length
31+
----+----+-------------
32+
1 | 10 |
33+
(1 row)
34+
2635
DROP TABLE delete_test;

‎src/test/regress/expected/insert.out

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,21 @@ select * from inserttest;
6262
2 | 3 | values are fun!
6363
(7 rows)
6464

65+
--
66+
-- TOASTed value test
67+
--
68+
insert into inserttest values(30, 50, repeat('x', 10000));
69+
select col1, col2, char_length(col3) from inserttest;
70+
col1 | col2 | char_length
71+
------+------+-------------
72+
| 3 | 7
73+
| 5 | 7
74+
| 5 | 4
75+
| 7 | 7
76+
10 | 20 | 2
77+
-1 | 2 | 7
78+
2 | 3 | 15
79+
30 | 50 | 10000
80+
(8 rows)
81+
6582
drop table inserttest;

‎src/test/regress/expected/update.out

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,13 @@ ERROR: invalid reference to FROM-clause entry for table "update_test"
8787
LINE 1: UPDATE update_test AS t SET b = update_test.b + 10 WHERE t.a...
8888
^
8989
HINT: Perhaps you meant to reference the table alias "t".
90+
-- Make sure that we can update to a TOASTed value.
91+
UPDATE update_test SET c = repeat('x', 10000) WHERE c = 'car';
92+
SELECT a, b, char_length(c) FROM update_test;
93+
a | b | char_length
94+
-----+----+-------------
95+
100 | 20 |
96+
11 | 41 | 10000
97+
(2 rows)
98+
9099
DROP TABLE update_test;

‎src/test/regress/sql/delete.sql

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
CREATETABLEdelete_test (
22
idSERIALPRIMARY KEY,
3-
aINT
3+
aINT,
4+
btext
45
);
56

67
INSERT INTO delete_test (a)VALUES (10);
7-
INSERT INTO delete_test (a)VALUES (50);
8+
INSERT INTO delete_test (a, b)VALUES (50, repeat('x',10000));
89
INSERT INTO delete_test (a)VALUES (100);
910

1011
-- allow an alias to be specified for DELETE's target table
@@ -14,6 +15,11 @@ DELETE FROM delete_test AS dt WHERE dt.a > 75;
1415
-- to be referenced
1516
DELETEFROM delete_test dtWHEREdelete_test.a>25;
1617

17-
SELECT*FROM delete_test;
18+
SELECT id, a, char_length(b)FROM delete_test;
19+
20+
-- delete a row with a TOASTed value
21+
DELETEFROM delete_testWHERE a>25;
22+
23+
SELECT id, a, char_length(b)FROM delete_test;
1824

1925
DROPTABLE delete_test;

‎src/test/regress/sql/insert.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,11 @@ insert into inserttest values(10, 20, '40'), (-1, 2, DEFAULT),
2828

2929
select*from inserttest;
3030

31+
--
32+
-- TOASTed value test
33+
--
34+
insert into inserttestvalues(30,50, repeat('x',10000));
35+
36+
select col1, col2, char_length(col3)from inserttest;
37+
3138
droptable inserttest;

‎src/test/regress/sql/update.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,8 @@ UPDATE update_test SET (a,b) = (select a,b FROM update_test where c = 'foo')
5454
-- to the original table name
5555
UPDATE update_testAS tSET b=update_test.b+10WHEREt.a=10;
5656

57+
-- Make sure that we can update to a TOASTed value.
58+
UPDATE update_testSET c= repeat('x',10000)WHERE c='car';
59+
SELECT a, b, char_length(c)FROM update_test;
60+
5761
DROPTABLE update_test;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp