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

Commit86437dd

Browse files
committed
postgres_fdw: Fix cache lookup failure while creating error context.
This is fallout from join pushdown; get_relid_attribute_name can'thandle an attribute number of 0, indicating a whole-row reference,and shouldn't be called in that case.Etsuro Fujita, reviewed by Ashutosh Bapat
1 parent5f3499b commit86437dd

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

‎contrib/postgres_fdw/expected/postgres_fdw.out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2591,6 +2591,9 @@ CONTEXT: column "c8" of foreign table "ft1"
25912591
SELECT ft1.c1, ft2.c2, ft1.c8 FROM ft1, ft2 WHERE ft1.c1 = ft2.c1 AND ft1.c1 = 1; -- ERROR
25922592
ERROR: invalid input syntax for integer: "foo"
25932593
CONTEXT: column "c8" of foreign table "ft1"
2594+
SELECT ft1.c1, ft2.c2, ft1 FROM ft1, ft2 WHERE ft1.c1 = ft2.c1 AND ft1.c1 = 1; -- ERROR
2595+
ERROR: invalid input syntax for integer: "foo"
2596+
CONTEXT: whole-row reference to foreign table "ft1"
25942597
ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE user_enum;
25952598
-- ===================================================================
25962599
-- subtransaction

‎contrib/postgres_fdw/postgres_fdw.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4528,6 +4528,7 @@ conversion_error_callback(void *arg)
45284528
{
45294529
constchar*attname=NULL;
45304530
constchar*relname=NULL;
4531+
boolis_wholerow= false;
45314532
ConversionLocation*errpos= (ConversionLocation*)arg;
45324533

45334534
if (errpos->rel)
@@ -4560,12 +4561,22 @@ conversion_error_callback(void *arg)
45604561
Assert(IsA(var,Var));
45614562

45624563
rte=rt_fetch(var->varno,estate->es_range_table);
4564+
4565+
if (var->varattno==0)
4566+
is_wholerow= true;
4567+
else
4568+
attname=get_relid_attribute_name(rte->relid,var->varattno);
4569+
45634570
relname=get_rel_name(rte->relid);
4564-
attname=get_relid_attribute_name(rte->relid,var->varattno);
45654571
}
45664572

4567-
if (attname&&relname)
4568-
errcontext("column \"%s\" of foreign table \"%s\"",attname,relname);
4573+
if (relname)
4574+
{
4575+
if (is_wholerow)
4576+
errcontext("whole-row reference to foreign table \"%s\"",relname);
4577+
elseif (attname)
4578+
errcontext("column \"%s\" of foreign table \"%s\"",attname,relname);
4579+
}
45694580
}
45704581

45714582
/*

‎contrib/postgres_fdw/sql/postgres_fdw.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ DROP FUNCTION f_test(int);
627627
ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPEint;
628628
SELECT*FROM ft1WHERE c1=1;-- ERROR
629629
SELECTft1.c1,ft2.c2,ft1.c8FROM ft1, ft2WHEREft1.c1=ft2.c1ANDft1.c1=1;-- ERROR
630+
SELECTft1.c1,ft2.c2, ft1FROM ft1, ft2WHEREft1.c1=ft2.c1ANDft1.c1=1;-- ERROR
630631
ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE user_enum;
631632

632633
-- ===================================================================

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp