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

Commit88b45aa

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 parent9406884 commit88b45aa

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
@@ -738,7 +738,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString)
738738
boolpipe= (stmt->filename==NULL);
739739
Relationrel;
740740
uint64processed;
741-
RangeTblEntry*rte;
741+
List*range_table=NIL;
742742

743743
/* Disallow file COPY except to superusers. */
744744
if (!pipe&& !superuser())
@@ -754,6 +754,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString)
754754
AclModerequired_access= (is_from ?ACL_INSERT :ACL_SELECT);
755755
List*attnums;
756756
ListCell*cur;
757+
RangeTblEntry*rte;
757758

758759
Assert(!stmt->query);
759760

@@ -766,6 +767,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString)
766767
rte->relid=RelationGetRelid(rel);
767768
rte->relkind=rel->rd_rel->relkind;
768769
rte->requiredPerms=required_access;
770+
range_table=list_make1(rte);
769771

770772
tupDesc=RelationGetDescr(rel);
771773
attnums=CopyGetAttnums(tupDesc,rel,stmt->attlist);
@@ -779,7 +781,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString)
779781
else
780782
rte->selectedCols=bms_add_member(rte->selectedCols,attno);
781783
}
782-
ExecCheckRTPerms(list_make1(rte), true);
784+
ExecCheckRTPerms(range_table, true);
783785
}
784786
else
785787
{
@@ -796,15 +798,14 @@ DoCopy(const CopyStmt *stmt, const char *queryString)
796798

797799
cstate=BeginCopyFrom(rel,stmt->filename,
798800
stmt->attlist,stmt->options);
799-
cstate->range_table=list_make1(rte);
801+
cstate->range_table=range_table;
800802
processed=CopyFrom(cstate);/* copy from file to database */
801803
EndCopyFrom(cstate);
802804
}
803805
else
804806
{
805807
cstate=BeginCopyTo(rel,stmt->query,queryString,stmt->filename,
806808
stmt->attlist,stmt->options);
807-
cstate->range_table=list_make1(rte);
808809
processed=DoCopyTo(cstate);/* copy from database to file */
809810
EndCopyTo(cstate);
810811
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp