Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Table and Index partitioning in Babelfish #399

Merged
8 changes: 8 additions & 0 deletions src/backend/access/common/reloptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,8 @@ static void initialize_reloptions(void);
static void parse_one_reloption(relopt_value *option, char *text_str,
int text_len, bool validate);

pltsql_partitioned_table_reloptions_hook_type pltsql_partitioned_table_reloptions_hook = NULL;

/*
* Get the length of a string reloption (either default or the user-defined
* value). This is used for allocation purposes when building a set of
Expand Down Expand Up @@ -2001,10 +2003,16 @@ bytea *
partitioned_table_reloptions(Datum reloptions, bool validate)
{
if (validate && reloptions)
{
/* For babelfish partitioned table, allow usage of reloptions in TSQL dialect. */
sumitj824 marked this conversation as resolved.
Show resolved Hide resolved
if (pltsql_partitioned_table_reloptions_hook && pltsql_partitioned_table_reloptions_hook(reloptions))
sumitj824 marked this conversation as resolved.
Show resolved Hide resolved
sumitj824 marked this conversation as resolved.
Show resolved Hide resolved
return NULL;

ereport(ERROR,
errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("cannot specify storage parameters for a partitioned table"),
errhint("Specify storage parameters for its leaf partitions instead."));
}
return NULL;
}

Expand Down
2 changes: 2 additions & 0 deletions src/include/access/reloptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,7 @@ extern bytea *index_reloptions(amoptions_function amoptions, Datum reloptions,
extern bytea *attribute_reloptions(Datum reloptions, bool validate);
extern bytea *tablespace_reloptions(Datum reloptions, bool validate);
extern LOCKMODE AlterTableGetRelOptionsLockLevel(List *defList);
typedef bool (*pltsql_partitioned_table_reloptions_hook_type)();
extern PGDLLEXPORT pltsql_partitioned_table_reloptions_hook_type pltsql_partitioned_table_reloptions_hook;

#endif /* RELOPTIONS_H */
1 change: 1 addition & 0 deletions src/include/nodes/parsenodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,7 @@ typedef struct PartitionSpec
PartitionStrategy strategy;
List *partParams; /* List of PartitionElems */
int location; /* token location, or -1 if unknown */
char *tsql_partition_scheme; /* tsql partition scheme name */
} PartitionSpec;

/*
Expand Down
Loading