mirror of
https://github.com/timescale/timescaledb.git
synced 2025-04-20 03:21:15 +08:00
Validate parameters when creating partition info
Partitioning function information for closed (space) dimensions is passed from SQL as REGPROC. This leaves no possibility for this info to be NULL when internal partitioning function data structure is populated.
This commit is contained in:
parent
148f2da924
commit
570f2f8b96
@ -95,6 +95,8 @@ partitioning_func_get_default(void)
|
||||
bool
|
||||
partitioning_func_is_default(const char *schema, const char *funcname)
|
||||
{
|
||||
Assert(schema != NULL && funcname != NULL);
|
||||
|
||||
return strcmp(DEFAULT_PARTITIONING_FUNC_SCHEMA, schema) == 0 &&
|
||||
strcmp(DEFAULT_PARTITIONING_FUNC_NAME, funcname) == 0;
|
||||
}
|
||||
@ -157,6 +159,11 @@ partitioning_info_create(const char *schema,
|
||||
Var *var;
|
||||
FuncExpr *expr;
|
||||
|
||||
if (schema == NULL || partfunc == NULL || partcol == NULL)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
|
||||
errmsg("partitioning function information cannot be null")));
|
||||
|
||||
pinfo = palloc0(sizeof(PartitioningInfo));
|
||||
StrNCpy(pinfo->partfunc.name, partfunc, NAMEDATALEN);
|
||||
StrNCpy(pinfo->column, partcol, NAMEDATALEN);
|
||||
@ -166,8 +173,8 @@ partitioning_info_create(const char *schema,
|
||||
if (pinfo->column_attnum == InvalidAttrNumber)
|
||||
return NULL;
|
||||
|
||||
if (schema != NULL)
|
||||
StrNCpy(pinfo->partfunc.schema, schema, NAMEDATALEN);
|
||||
|
||||
StrNCpy(pinfo->partfunc.schema, schema, NAMEDATALEN);
|
||||
|
||||
/* Lookup the type cache entry to access the hash function for the type */
|
||||
columntype = get_atttype(relid, pinfo->column_attnum);
|
||||
|
Loading…
x
Reference in New Issue
Block a user