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

Commitd5d46e6

Browse files
committed
Clean up range-table building in copy.c
Commit804b6b6 added the build of arange table in copy.c to initialize the EState es_range_table since itcan be needed in error paths. Unfortunately, that commit didn'tappreciate that some code paths might end up not initializing the rtewhich is used to build the range table.Fix that and clean up a couple others things along the way- build itonly once and don't explicitly set it on the !is_from path as itdoesn't make any sense there (cstate is palloc0'd, so this isn't anissue from an initializing standpoint either).The prior commit went back to 9.0, but this only goes back to 9.1 asprior to that the range table build happens immediately after buildingthe RTE and therefore doesn't suffer from this issue.Pointed out by Robert.
1 parent4b98742 commitd5d46e6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

‎src/backend/commands/copy.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
783783
boolpipe= (stmt->filename==NULL);
784784
Relationrel;
785785
Oidrelid;
786-
RangeTblEntry*rte;
786+
List*range_table=NIL;
787787

788788
/* Disallow COPY to/from file or program except to superusers. */
789789
if (!pipe&& !superuser())
@@ -808,6 +808,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
808808
AclModerequired_access= (is_from ?ACL_INSERT :ACL_SELECT);
809809
List*attnums;
810810
ListCell*cur;
811+
RangeTblEntry*rte;
811812

812813
Assert(!stmt->query);
813814

@@ -822,6 +823,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
822823
rte->relid=RelationGetRelid(rel);
823824
rte->relkind=rel->rd_rel->relkind;
824825
rte->requiredPerms=required_access;
826+
range_table=list_make1(rte);
825827

826828
tupDesc=RelationGetDescr(rel);
827829
attnums=CopyGetAttnums(tupDesc,rel,stmt->attlist);
@@ -835,7 +837,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
835837
else
836838
rte->selectedCols=bms_add_member(rte->selectedCols,attno);
837839
}
838-
ExecCheckRTPerms(list_make1(rte), true);
840+
ExecCheckRTPerms(range_table, true);
839841
}
840842
else
841843
{
@@ -855,7 +857,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
855857

856858
cstate=BeginCopyFrom(rel,stmt->filename,stmt->is_program,
857859
stmt->attlist,stmt->options);
858-
cstate->range_table=list_make1(rte);
860+
cstate->range_table=range_table;
859861
*processed=CopyFrom(cstate);/* copy from file to database */
860862
EndCopyFrom(cstate);
861863
}
@@ -864,7 +866,6 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
864866
cstate=BeginCopyTo(rel,stmt->query,queryString,
865867
stmt->filename,stmt->is_program,
866868
stmt->attlist,stmt->options);
867-
cstate->range_table=list_make1(rte);
868869
*processed=DoCopyTo(cstate);/* copy from database to file */
869870
EndCopyTo(cstate);
870871
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp