Skip to content

Commit ae574fd

Browse files
committed
Fix rename hook
1 parent fd8474f commit ae574fd

File tree

5 files changed

+10
-38
lines changed

5 files changed

+10
-38
lines changed

src/hooks.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,6 @@ pathman_process_utility_hook(Node *parsetree,
715715
if (IsPathmanReady())
716716
{
717717
Oid partition_relid;
718-
AttrNumber partitioned_col;
719718

720719
/* Override standard COPY statement if needed */
721720
if (is_pathman_related_copy(parsetree))
@@ -733,10 +732,8 @@ pathman_process_utility_hook(Node *parsetree,
733732

734733
/* Override standard RENAME statement if needed */
735734
if (is_pathman_related_table_rename(parsetree,
736-
&partition_relid,
737-
&partitioned_col))
735+
&partition_relid))
738736
PathmanRenameConstraint(partition_relid,
739-
partitioned_col,
740737
(const RenameStmt *) parsetree);
741738
}
742739

src/include/relation_info.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,6 @@ typedef struct
113113
max;
114114
} RangeEntry;
115115

116-
/* Used to convert 'varno' attributes accodirdingly to working query */
117-
typedef struct
118-
{
119-
Oid relid; /* relid by which we can determine what rte we need in current query */
120-
int res_idx; /* varno will be used for Var */
121-
} RTEMapItem;
122-
123116
/*
124117
* PartRelationInfo
125118
* Per-relation partitioning information

src/include/utility_stmt_hooking.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@
2121
/* Various traits */
2222
bool is_pathman_related_copy(Node *parsetree);
2323
bool is_pathman_related_table_rename(Node *parsetree,
24-
Oid *partition_relid_out,
25-
AttrNumber *partitioned_col_out);
24+
Oid *partition_relid_out);
2625

2726
/* Statement handlers */
2827
void PathmanDoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed);
2928
void PathmanRenameConstraint(Oid partition_relid,
30-
AttrNumber partitioned_col,
3129
const RenameStmt *partition_rename_stmt);
3230

3331

src/partition_filter.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,6 @@ struct expr_walker_context
533533
const PartRelationInfo *prel;
534534
TupleTableSlot *slot;
535535
HeapTuple tup;
536-
bool clear;
537536
};
538537

539538
/* Fills CustomConst nodes with values from slot */
@@ -555,20 +554,12 @@ adapt_values (Node *node, struct expr_walker_context *context)
555554
attnum = ((CustomConst *)node)->varattno;
556555
Assert(attnum != InvalidAttrNumber);
557556

558-
if (context->clear)
559-
{
560-
cst->constvalue = (Datum) 0;
561-
cst->constisnull = true;
562-
}
563-
else
564-
{
565-
/* check that type is still same */
566-
Assert(context->slot->tts_tupleDescriptor->
567-
attrs[attnum - 1]->atttypid == cst->consttype);
568-
cst->constvalue = heap_getattr(context->tup, attnum,
569-
context->slot->tts_tupleDescriptor, &isNull);
570-
cst->constisnull = isNull;
571-
}
557+
/* check that type is still same */
558+
Assert(context->slot->tts_tupleDescriptor->
559+
attrs[attnum - 1]->atttypid == cst->consttype);
560+
cst->constvalue = heap_getattr(context->tup, attnum,
561+
context->slot->tts_tupleDescriptor, &isNull);
562+
cst->constisnull = isNull;
572563
return false;
573564
}
574565

@@ -638,7 +629,6 @@ partition_filter_exec(CustomScanState *node)
638629
expr_walker_context.prel = prel;
639630
expr_walker_context.slot = slot;
640631
expr_walker_context.tup = ExecCopySlotTuple(slot);
641-
expr_walker_context.clear = false;
642632

643633
/* Fetch values from slot for expression */
644634
adapt_values(prel->expr, (void *) &expr_walker_context);

src/utility_stmt_hooking.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ is_pathman_related_copy(Node *parsetree)
134134
*/
135135
bool
136136
is_pathman_related_table_rename(Node *parsetree,
137-
Oid *partition_relid_out, /* ret value */
138-
AttrNumber *partitioned_col_out) /* ret value */
137+
Oid *partition_relid_out) /* ret value */
139138
{
140139
RenameStmt *rename_stmt = (RenameStmt *) parsetree;
141140
Oid partition_relid,
@@ -147,7 +146,6 @@ is_pathman_related_table_rename(Node *parsetree,
147146

148147
/* Set default values */
149148
if (partition_relid_out) *partition_relid_out = InvalidOid;
150-
if (partitioned_col_out) *partitioned_col_out = InvalidAttrNumber;
151149

152150
if (!IsA(parsetree, RenameStmt))
153151
return false;
@@ -167,14 +165,11 @@ is_pathman_related_table_rename(Node *parsetree,
167165
return false;
168166

169167
/* Is parent partitioned? */
170-
/* FIX this
171168
if ((prel = get_pathman_relation_info(parent_relid)) != NULL)
172169
{
173170
if (partition_relid_out) *partition_relid_out = partition_relid;
174-
if (partitioned_col_out) *partitioned_col_out = prel->attnum;
175-
176171
return true;
177-
} */
172+
}
178173

179174
return false;
180175
}
@@ -692,7 +687,6 @@ prepare_rri_for_copy(EState *estate,
692687
*/
693688
void
694689
PathmanRenameConstraint(Oid partition_relid, /* cached partition Oid */
695-
AttrNumber partitioned_col, /* partitioned column */
696690
const RenameStmt *part_rename_stmt) /* partition rename stmt */
697691
{
698692
char *old_constraint_name,

0 commit comments

Comments
 (0)