Re: [HACKERS] UPDATE of partition key

From: Amit Khandekar <amitdkhan(dot)pg(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
Subject: Re: [HACKERS] UPDATE of partition key
Date: 2017-12-22 15:00:12
Message-ID: CAJ3gD9c1REsuuy9gtoXsbtFMssiPqG6Lh0zCdEspkmXXHAqbrA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 15 December 2017 at 18:28, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> Reviewing the preparatory patch:
>
> + PartitionTupleRouting *partition_tuple_routing;
> + /* Tuple-routing support info */
>
> Something's wrong with the formatting here.

Moved the comment above the declaration.

>
> - PartitionDispatch **pd,
> - ResultRelInfo ***partitions,
> - TupleConversionMap ***tup_conv_maps,
> - TupleTableSlot **partition_tuple_slot,
> - int *num_parted, int *num_partitions)
> + PartitionTupleRouting **partition_tuple_routing)
>
> Since we're consolidating all of ExecSetupPartitionTupleRouting's
> output parameters into a single structure, I think it might make more
> sense to have it just return that value. I think it's only done with
> output parameter today because there are so many different things
> being produced, and we can't return them all.

You mean ExecSetupPartitionTupleRouting() will return the structure
(not pointer to structure), and the caller will get the copy of the
structure like this ? :

mtstate->mt_partition_tuple_routing =
ExecSetupPartitionTupleRouting(mtstate, rel, node->nominalRelation, estate);

I am ok with that, but just wanted to confirm if that is what you are
saying. I don't recall seeing a structure return value in PG code, so
not sure if it is conventional in PG to do that. Hence, I am somewhat
inclined to keep it as output param. It also avoids a structure copy.

Another way is for ExecSetupPartitionTupleRouting() to palloc this
structure, and return its pointer, but then caller would have to
anyway do a structure copy, so that's not convenient, and I don't
think you are suggesting this way either.

>
> + PartitionTupleRouting *ptr = mtstate->mt_partition_tuple_routing;
>
> This is just nitpicking, but I don't find "ptr" to be the greatest
> variable name; it looks too much like "pointer". Maybe we could use
> "routing" or "proute" or something.

Done. Renamed it to "proute".

>
> It seems to me that we could improve things here by adding a function
> ExecCleanupTupleRouting(PartitionTupleRouting *) which would do the
> various heap_close(), ExecDropSingleTupleTableSlot(), and
> ExecCloseIndices() operations which are currently performed in
> CopyFrom() and, by separate code, in ExecEndModifyTable().
>

Done. Changes are kept in a new preparatory patch
0005-Organize-cleanup-done-for-partition-tuple-routing.patch

Yet to address your other review comments.

Attached is patch v31. (Preparatory patches to be applied in order of
patch numbers, followed by the main patch)

Thanks
-Amit

Attachment Content-Type Size
0001-Encapsulate-partition-related-info-in-a-structure_v2.patch application/octet-stream 23.0 KB
0002-Changed-is_partition_attr-to-has_partition_attrs.patch application/octet-stream 5.9 KB
0003-Renaming-parameters-of-map_partition_var_attnos.patch application/octet-stream 2.9 KB
0004-Refactor-CheckConstraint-related-code.patch application/octet-stream 9.8 KB
0005-Organize-cleanup-done-for-partition-tuple-routing.patch application/octet-stream 5.3 KB
update-partition-key_v31.patch application/octet-stream 113.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2017-12-22 15:10:23 Re: [HACKERS] Proposal: Local indexes for partitioned table
Previous Message Alvaro Herrera 2017-12-22 14:31:54 Re: WIP: a way forward on bootstrap data