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

Commitf8519a6

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 parent804b6b6 commitf8519a6

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
@@ -790,7 +790,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
790790
Relationrel;
791791
Oidrelid;
792792
Node*query=NULL;
793-
RangeTblEntry*rte;
793+
List*range_table=NIL;
794794

795795
/* Disallow COPY to/from file or program except to superusers. */
796796
if (!pipe&& !superuser())
@@ -815,6 +815,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
815815
AclModerequired_access= (is_from ?ACL_INSERT :ACL_SELECT);
816816
List*attnums;
817817
ListCell*cur;
818+
RangeTblEntry*rte;
818819

819820
Assert(!stmt->query);
820821

@@ -829,6 +830,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
829830
rte->relid=RelationGetRelid(rel);
830831
rte->relkind=rel->rd_rel->relkind;
831832
rte->requiredPerms=required_access;
833+
range_table=list_make1(rte);
832834

833835
tupDesc=RelationGetDescr(rel);
834836
attnums=CopyGetAttnums(tupDesc,rel,stmt->attlist);
@@ -842,7 +844,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
842844
else
843845
rte->selectedCols=bms_add_member(rte->selectedCols,attno);
844846
}
845-
ExecCheckRTPerms(list_make1(rte), true);
847+
ExecCheckRTPerms(range_table, true);
846848

847849
/*
848850
* Permission check for row security policies.
@@ -921,7 +923,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
921923

922924
cstate=BeginCopyFrom(rel,stmt->filename,stmt->is_program,
923925
stmt->attlist,stmt->options);
924-
cstate->range_table=list_make1(rte);
926+
cstate->range_table=range_table;
925927
*processed=CopyFrom(cstate);/* copy from file to database */
926928
EndCopyFrom(cstate);
927929
}
@@ -930,7 +932,6 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
930932
cstate=BeginCopyTo(rel,query,queryString,relid,
931933
stmt->filename,stmt->is_program,
932934
stmt->attlist,stmt->options);
933-
cstate->range_table=list_make1(rte);
934935
*processed=DoCopyTo(cstate);/* copy from database to file */
935936
EndCopyTo(cstate);
936937
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp