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

Commit5ee3a74

Browse files
committed
Band-aid fix for incorrect use of view options as StdRdOptions.
We really ought to make StdRdOptions and the other decoded forms ofreloptions self-identifying, but for the moment, assume that only plainrelations could possibly be user_catalog_tables. Fixes problem with bogus"ON CONFLICT is not supported on table ... used as a catalog table" errorwhen target is a view with cascade option.Discussion: <26681.1477940227@sss.pgh.pa.us>
1 parent674f701 commit5ee3a74

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

‎src/include/utils/rel.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ typedef struct StdRdOptions
270270
*from the pov of logical decoding. Note multiple eval of argument!
271271
*/
272272
#defineRelationIsUsedAsCatalogTable(relation)\
273-
((relation)->rd_options ?\
273+
((relation)->rd_rel->relkind == RELKIND_RELATION && \
274+
(relation)->rd_options ? \
274275
((StdRdOptions *) (relation)->rd_options)->user_catalog_table : false)
275276

276277
/*

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,30 @@ on conflict (b) where coalesce(a, 1) > 0 do nothing;
471471
insert into insertconflict values (1, 2)
472472
on conflict (b) where coalesce(a, 1) > 1 do nothing;
473473
drop table insertconflict;
474+
--
475+
-- test insertion through view
476+
--
477+
create table insertconflict (f1 int primary key, f2 text);
478+
create view insertconflictv as
479+
select * from insertconflict with cascaded check option;
480+
insert into insertconflictv values (1,'foo')
481+
on conflict (f1) do update set f2 = excluded.f2;
482+
select * from insertconflict;
483+
f1 | f2
484+
----+-----
485+
1 | foo
486+
(1 row)
487+
488+
insert into insertconflictv values (1,'bar')
489+
on conflict (f1) do update set f2 = excluded.f2;
490+
select * from insertconflict;
491+
f1 | f2
492+
----+-----
493+
1 | bar
494+
(1 row)
495+
496+
drop view insertconflictv;
497+
drop table insertconflict;
474498
-- ******************************************************************
475499
-- * *
476500
-- * Test inheritance (example taken from tutorial) *

‎src/test/regress/sql/insert_conflict.sql

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,24 @@ on conflict (b) where coalesce(a, 1) > 1 do nothing;
283283

284284
droptable insertconflict;
285285

286+
--
287+
-- test insertion through view
288+
--
289+
290+
createtableinsertconflict (f1intprimary key, f2text);
291+
createviewinsertconflictvas
292+
select*from insertconflict with cascadedcheck option;
293+
294+
insert into insertconflictvvalues (1,'foo')
295+
on conflict (f1) doupdateset f2=excluded.f2;
296+
select*from insertconflict;
297+
insert into insertconflictvvalues (1,'bar')
298+
on conflict (f1) doupdateset f2=excluded.f2;
299+
select*from insertconflict;
300+
301+
dropview insertconflictv;
302+
droptable insertconflict;
303+
286304

287305
-- ******************************************************************
288306
-- * *

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp