Add columns to pg_dist_object for distributed functions

This PR simply adds the columns to pg_dist_object and
implements the necessary metadata changes to keep track of
distribution argument of the functions/procedures.
pull/2979/head
Onder Kalaci 2019-09-16 12:47:33 +02:00
parent af9fb9f785
commit cde6b02858
5 changed files with 51 additions and 6 deletions

View File

@ -38,6 +38,11 @@ CREATE TABLE citus.pg_dist_object (
object_names text[] DEFAULT NULL,
object_args text[] DEFAULT NULL,
-- fields that are only valid for distributed
-- functions/procedures
distribution_argument_index int,
colocationid int,
CONSTRAINT pg_dist_object_pkey PRIMARY KEY (classid, objid, objsubid)
);

View File

@ -79,13 +79,17 @@ BEGIN
RETURNING
type,
object_names,
object_args
object_args,
distribution_argument_index,
colocationid
)
INSERT INTO citus.pg_dist_object (classid, objid, objsubid)
INSERT INTO citus.pg_dist_object (classid, objid, objsubid, distribution_argument_index, colocationid)
SELECT
address.classid,
address.objid,
address.objsubid
address.objsubid,
naming.distribution_argument_index,
naming.colocationid
FROM
old_records naming,
pg_get_object_address(naming.type, naming.object_names, naming.object_args) address;

View File

@ -79,13 +79,17 @@ BEGIN
RETURNING
type,
object_names,
object_args
object_args,
distribution_argument_index,
colocationid
)
INSERT INTO citus.pg_dist_object (classid, objid, objsubid)
INSERT INTO citus.pg_dist_object (classid, objid, objsubid, distribution_argument_index, colocationid)
SELECT
address.classid,
address.objid,
address.objsubid
address.objsubid,
naming.distribution_argument_index,
naming.colocationid
FROM
old_records naming,
pg_get_object_address(naming.type, naming.object_names, naming.object_args) address;

View File

@ -28,6 +28,9 @@ typedef struct FormData_pg_dist_object
Oid objid; /* object id of the distributed object */
int32 objsubid; /* object sub id of the distributed object, eg. attnum */
uint32 distribution_argument_index; /* only valid for distributed functions/procedures */
uint32 colocationid; /* only valid for distributed functions/procedures */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
text type;
text[] object_names;

View File

@ -0,0 +1,29 @@
/*-------------------------------------------------------------------------
*
* pg_dist_object.h
* definition of the relation that holds the object information on the
* cluster (pg_dist_object).
*
* Copyright (c) 2019, Citus Data, Inc.
*
*-------------------------------------------------------------------------
*/
#ifndef PG_DIST_OBJECT_H
#define PG_DIST_OBJECT_H
/* ----------------
* compiler constants for pg_dist_object
* ----------------
*/
#define Natts_pg_dist_object 8
#define Anum_pg_dist_object_classid 1
#define Anum_pg_dist_object_objid 2
#define Anum_pg_dist_object_objsubid 3
#define Anum_pg_dist_object_type 4
#define Anum_pg_dist_object_object_names 5
#define Anum_pg_dist_object_object_args 6
#define Anum_pg_dist_object_distribution_arg_index 7
#define Anum_pg_dist_object_colocation_id 8
#endif /* PG_DIST_OBJECT_H */