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

Commit2fb67fa

Browse files
committed
More bogosity in alter_table test: sometimes causes prepare test to fail
by means of arbitrarily renaming tables the other test depends on.
1 parente8a4515 commit2fb67fa

File tree

2 files changed

+41
-187
lines changed

2 files changed

+41
-187
lines changed

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

Lines changed: 27 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -94,190 +94,45 @@ SELECT * FROM tmp;
9494

9595
DROP TABLE tmp;
9696
--
97-
-- rename -
98-
-- should preserve indices, which we can check by seeing if a SELECT
99-
-- chooses an indexscan; however, in the absence of vacuum statistics
100-
-- it might not. Therefore, vacuum first.
97+
-- rename - check on both non-temp and temp tables
10198
--
102-
VACUUM ANALYZE tenk1;
103-
ALTER TABLE tenk1 RENAME TO ten_k;
104-
-- 20 values, sorted
105-
SELECT unique1 FROM ten_k WHERE unique1 < 20;
106-
unique1
107-
---------
108-
0
109-
1
110-
2
111-
3
112-
4
113-
5
114-
6
115-
7
116-
8
117-
9
118-
10
119-
11
120-
12
121-
13
122-
14
123-
15
124-
16
125-
17
126-
18
127-
19
128-
(20 rows)
99+
CREATE TABLE tmp (regtable int);
100+
CREATE TEMP TABLE tmp (tmptable int);
101+
ALTER TABLE tmp RENAME TO tmp_new;
102+
SELECT * FROM tmp;
103+
regtable
104+
----------
105+
(0 rows)
129106

130-
-- 20 values, sorted
131-
SELECT unique2 FROM ten_k WHERE unique2 < 20;
132-
unique2
133-
---------
134-
0
135-
1
136-
2
137-
3
138-
4
139-
5
140-
6
141-
7
142-
8
143-
9
144-
10
145-
11
146-
12
147-
13
148-
14
149-
15
150-
16
151-
17
152-
18
153-
19
154-
(20 rows)
107+
SELECT * FROM tmp_new;
108+
tmptable
109+
----------
110+
(0 rows)
155111

156-
-- 100 values, sorted
157-
SELECT hundred FROM ten_k WHERE hundred = 50;
158-
hundred
159-
---------
160-
50
161-
50
162-
50
163-
50
164-
50
165-
50
166-
50
167-
50
168-
50
169-
50
170-
50
171-
50
172-
50
173-
50
174-
50
175-
50
176-
50
177-
50
178-
50
179-
50
180-
50
181-
50
182-
50
183-
50
184-
50
185-
50
186-
50
187-
50
188-
50
189-
50
190-
50
191-
50
192-
50
193-
50
194-
50
195-
50
196-
50
197-
50
198-
50
199-
50
200-
50
201-
50
202-
50
203-
50
204-
50
205-
50
206-
50
207-
50
208-
50
209-
50
210-
50
211-
50
212-
50
213-
50
214-
50
215-
50
216-
50
217-
50
218-
50
219-
50
220-
50
221-
50
222-
50
223-
50
224-
50
225-
50
226-
50
227-
50
228-
50
229-
50
230-
50
231-
50
232-
50
233-
50
234-
50
235-
50
236-
50
237-
50
238-
50
239-
50
240-
50
241-
50
242-
50
243-
50
244-
50
245-
50
246-
50
247-
50
248-
50
249-
50
250-
50
251-
50
252-
50
253-
50
254-
50
255-
50
256-
50
257-
50
258-
50
259-
50
260-
(100 rows)
112+
ALTER TABLE tmp RENAME TO tmp_new2;
113+
SELECT * FROM tmp;-- should fail
114+
ERROR: relation "tmp" does not exist
115+
SELECT * FROM tmp_new;
116+
tmptable
117+
----------
118+
(0 rows)
261119

262-
ALTER TABLE ten_k RENAME TO tenk1;
263-
-- 5 values, sorted
264-
SELECT unique1 FROM tenk1 WHERE unique1 < 5;
265-
unique1
266-
---------
267-
0
268-
1
269-
2
270-
3
271-
4
272-
(5 rows)
120+
SELECT * FROM tmp_new2;
121+
regtable
122+
----------
123+
(0 rows)
273124

125+
DROP TABLE tmp_new;
126+
DROP TABLE tmp_new2;
274127
-- ALTER TABLE ... RENAME on non-table relations
275128
-- renaming indexes (FIXME: this should probably test the index's functionality)
276129
ALTER TABLE onek_unique1 RENAME TO tmp_onek_unique1;
277130
ALTER TABLE tmp_onek_unique1 RENAME TO onek_unique1;
278131
-- renaming views
279132
CREATE VIEW tmp_view (unique1) AS SELECT unique1 FROM tenk1;
280133
ALTER TABLE tmp_view RENAME TO tmp_view_new;
134+
-- analyze to ensure we get an indexscan here
135+
ANALYZE tenk1;
281136
-- 5 values, sorted
282137
SELECT unique1 FROM tenk1 WHERE unique1 < 5;
283138
unique1

‎src/test/regress/sql/alter_table.sql

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,28 +144,25 @@ DROP TABLE tmp;
144144

145145

146146
--
147-
-- rename -
148-
-- should preserve indices, which we can check by seeing if a SELECT
149-
-- chooses an indexscan; however, in the absence of vacuum statistics
150-
-- it might not. Therefore, vacuum first.
147+
-- rename - check on both non-temp and temp tables
151148
--
152-
VACUUM ANALYZE tenk1;
149+
CREATETABLEtmp (regtableint);
150+
CREATE TEMP TABLE tmp (tmptableint);
153151

154-
ALTERTABLEtenk1 RENAME TOten_k;
152+
ALTERTABLEtmp RENAME TOtmp_new;
155153

156-
-- 20 values, sorted
157-
SELECTunique1FROMten_kWHERE unique1<20;
154+
SELECT*FROM tmp;
155+
SELECT*FROMtmp_new;
158156

159-
-- 20 values, sorted
160-
SELECT unique2FROM ten_kWHERE unique2<20;
157+
ALTERTABLE tmp RENAME TO tmp_new2;
161158

162-
-- 100 values, sorted
163-
SELECT hundredFROM ten_kWHERE hundred=50;
159+
SELECT*FROM tmp;-- should fail
160+
SELECT*FROM tmp_new;
161+
SELECT*FROM tmp_new2;
164162

165-
ALTERTABLE ten_k RENAME TO tenk1;
163+
DROPTABLE tmp_new;
164+
DROPTABLE tmp_new2;
166165

167-
-- 5 values, sorted
168-
SELECT unique1FROM tenk1WHERE unique1<5;
169166

170167
-- ALTER TABLE ... RENAME on non-table relations
171168
-- renaming indexes (FIXME: this should probably test the index's functionality)
@@ -174,6 +171,8 @@ ALTER TABLE tmp_onek_unique1 RENAME TO onek_unique1;
174171
-- renaming views
175172
CREATEVIEWtmp_view (unique1)ASSELECT unique1FROM tenk1;
176173
ALTERTABLE tmp_view RENAME TO tmp_view_new;
174+
-- analyze to ensure we get an indexscan here
175+
ANALYZE tenk1;
177176
-- 5 values, sorted
178177
SELECT unique1FROM tenk1WHERE unique1<5;
179178
DROPVIEW tmp_view_new;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp