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

Commit8b39345

Browse files
committed
In INSERT/UPDATE, use the table's real tuple descriptor as target.
This back-patches commit20d3fe9 into the v12 and v13 branches.At the time I thought that commit was not fixing any observablebug, but Bertrand Drouvot showed otherwise: adding a dropped columnto the previously-considered scenario crashes v12 and v13, unless thedropped column happens to be an integer. That is, of course, becausethe tupdesc we derive from the plan output tlist fails to describethe dropped column accurately, so that we'll do the wrong thing witha tuple in which that column isn't NULL.There is no bug in pre-v12 branches because they already did usethe table's real tuple descriptor for any trigger-returned tuple.It seems that this set of bugs can be blamed on the changes thatremoved es_trig_tuple_slot, though I've not attempted to pin thatdown precisely.Although there's no code change needed in HEAD, update the test caseto include a dropped column there too.Discussion:https://postgr.es/m/db5d97c8-f48a-51e2-7b08-b73d5434d425@amazon.comDiscussion:https://postgr.es/m/16644-5da7ef98a7ac4545@postgresql.org
1 parentd50e3b1 commit8b39345

File tree

2 files changed

+47
-16
lines changed

2 files changed

+47
-16
lines changed

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

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -216,34 +216,56 @@ select * from trigtest;
216216

217217
drop table trigtest;
218218
-- Check behavior with an implicit column default, too (bug #16644)
219-
create table trigtest (a integer);
219+
create table trigtest (
220+
a integer,
221+
b bool default true not null,
222+
c text default 'xyzzy' not null);
220223
create trigger trigger_return_old
221224
before insert or delete or update on trigtest
222225
for each row execute procedure trigger_return_old();
223226
insert into trigtest values(1);
224227
select * from trigtest;
225-
a
226-
---
227-
1
228+
a | b | c
229+
---+---+-------
230+
1 | t | xyzzy
231+
(1 row)
232+
233+
alter table trigtest add column d integer default 42 not null;
234+
select * from trigtest;
235+
a | b | c | d
236+
---+---+-------+----
237+
1 | t | xyzzy | 42
238+
(1 row)
239+
240+
update trigtest set a = 2 where a = 1 returning *;
241+
a | b | c | d
242+
---+---+-------+----
243+
1 | t | xyzzy | 42
244+
(1 row)
245+
246+
select * from trigtest;
247+
a | b | c | d
248+
---+---+-------+----
249+
1 | t | xyzzy | 42
228250
(1 row)
229251

230-
alter table trigtestadd column b integer default 42 not null;
252+
alter table trigtestdrop column b;
231253
select * from trigtest;
232-
a |b
233-
---+----
234-
1 | 42
254+
a | c | d
255+
---+-------+----
256+
1 |xyzzy |42
235257
(1 row)
236258

237259
update trigtest set a = 2 where a = 1 returning *;
238-
a |b
239-
---+----
240-
1 | 42
260+
a | c | d
261+
---+-------+----
262+
1 |xyzzy |42
241263
(1 row)
242264

243265
select * from trigtest;
244-
a |b
245-
---+----
246-
1 | 42
266+
a | c | d
267+
---+-------+----
268+
1 |xyzzy |42
247269
(1 row)
248270

249271
drop table trigtest;

‎src/test/regress/sql/triggers.sql‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,10 @@ select * from trigtest;
155155
droptable trigtest;
156156

157157
-- Check behavior with an implicit column default, too (bug #16644)
158-
createtabletrigtest (ainteger);
158+
createtabletrigtest (
159+
ainteger,
160+
b bool default truenot null,
161+
ctext default'xyzzy'not null);
159162

160163
createtriggertrigger_return_old
161164
before insertordeleteorupdateon trigtest
@@ -164,7 +167,13 @@ create trigger trigger_return_old
164167
insert into trigtestvalues(1);
165168
select*from trigtest;
166169

167-
altertable trigtest add column binteger default42not null;
170+
altertable trigtest add column dinteger default42not null;
171+
172+
select*from trigtest;
173+
update trigtestset a=2where a=1 returning*;
174+
select*from trigtest;
175+
176+
altertable trigtest drop column b;
168177

169178
select*from trigtest;
170179
update trigtestset a=2where a=1 returning*;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp