mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-17 11:03:36 +08:00
Use NameData and namestrcpy for names
Using `strlcpy` to copy variables holding PostgreSQL names can cause issues since names are fixed-size types of length 64. This means that any data that follows the initial null-terminated string will also be part of the data. Instead of using `const char*` for PostgreSQL names, use `NameData` type for PostgreSQL names and use `namestrcpy` to copy them rather than `strlcpy`.
This commit is contained in:
parent
0963609271
commit
38b71d0e70
@ -20,6 +20,7 @@ accidentally triggering the load of a previous DB version.**
|
|||||||
* #5214 Fix use of prepared statement in async module
|
* #5214 Fix use of prepared statement in async module
|
||||||
* #5290 Compression can't be enabled on continuous aggregates when segmentby/orderby columns need quotation
|
* #5290 Compression can't be enabled on continuous aggregates when segmentby/orderby columns need quotation
|
||||||
* #5239 Fix next_start calculation for fixed schedules
|
* #5239 Fix next_start calculation for fixed schedules
|
||||||
|
* #5336 Use NameData and namestrcpy for names
|
||||||
|
|
||||||
## 2.9.3 (2023-02-03)
|
## 2.9.3 (2023-02-03)
|
||||||
|
|
||||||
|
@ -43,8 +43,12 @@ remove_containers() {
|
|||||||
docker rm -vf ${CONTAINER_CLEAN_RESTORE} 2>/dev/null
|
docker rm -vf ${CONTAINER_CLEAN_RESTORE} 2>/dev/null
|
||||||
docker rm -vf ${CONTAINER_UPDATED} 2>/dev/null
|
docker rm -vf ${CONTAINER_UPDATED} 2>/dev/null
|
||||||
docker rm -vf ${CONTAINER_CLEAN_RERUN} 2>/dev/null
|
docker rm -vf ${CONTAINER_CLEAN_RERUN} 2>/dev/null
|
||||||
docker volume rm -f ${CLEAN_VOLUME} 2>/dev/null
|
if [[ -n "${CLEAN_VOLUME}" ]]; then
|
||||||
docker volume rm -f ${UPDATE_VOLUME} 2>/dev/null
|
docker volume rm -f ${CLEAN_VOLUME} 2>/dev/null
|
||||||
|
fi
|
||||||
|
if [[ -n "${UPDATE_VOLUME}" ]]; then
|
||||||
|
docker volume rm -f ${UPDATE_VOLUME} 2>/dev/null
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
|
@ -122,7 +122,11 @@ partitioning_func_set_func_fmgr(PartitioningFunc *pf, Oid argtype, DimensionType
|
|||||||
if (dimtype != DIMENSION_TYPE_CLOSED && dimtype != DIMENSION_TYPE_OPEN)
|
if (dimtype != DIMENSION_TYPE_CLOSED && dimtype != DIMENSION_TYPE_OPEN)
|
||||||
elog(ERROR, "invalid dimension type %u", dimtype);
|
elog(ERROR, "invalid dimension type %u", dimtype);
|
||||||
|
|
||||||
funcoid = ts_lookup_proc_filtered(pf->schema, pf->name, &pf->rettype, filter, &argtype);
|
funcoid = ts_lookup_proc_filtered(NameStr(pf->schema),
|
||||||
|
NameStr(pf->name),
|
||||||
|
&pf->rettype,
|
||||||
|
filter,
|
||||||
|
&argtype);
|
||||||
|
|
||||||
if (!OidIsValid(funcoid))
|
if (!OidIsValid(funcoid))
|
||||||
{
|
{
|
||||||
@ -145,7 +149,7 @@ partitioning_func_set_func_fmgr(PartitioningFunc *pf, Oid argtype, DimensionType
|
|||||||
List *
|
List *
|
||||||
ts_partitioning_func_qualified_name(PartitioningFunc *pf)
|
ts_partitioning_func_qualified_name(PartitioningFunc *pf)
|
||||||
{
|
{
|
||||||
return list_make2(makeString(pf->schema), makeString(pf->name));
|
return list_make2(makeString(NameStr(pf->schema)), makeString(NameStr(pf->name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Oid
|
static Oid
|
||||||
@ -184,16 +188,16 @@ ts_partitioning_info_create(const char *schema, const char *partfunc, const char
|
|||||||
errmsg("partitioning function information cannot be null")));
|
errmsg("partitioning function information cannot be null")));
|
||||||
|
|
||||||
pinfo = palloc0(sizeof(PartitioningInfo));
|
pinfo = palloc0(sizeof(PartitioningInfo));
|
||||||
strlcpy(pinfo->partfunc.name, partfunc, NAMEDATALEN);
|
namestrcpy(&pinfo->partfunc.name, partfunc);
|
||||||
strlcpy(pinfo->column, partcol, NAMEDATALEN);
|
namestrcpy(&pinfo->column, partcol);
|
||||||
pinfo->column_attnum = get_attnum(relid, pinfo->column);
|
pinfo->column_attnum = get_attnum(relid, NameStr(pinfo->column));
|
||||||
pinfo->dimtype = dimtype;
|
pinfo->dimtype = dimtype;
|
||||||
|
|
||||||
/* handle the case that the attribute has been dropped */
|
/* handle the case that the attribute has been dropped */
|
||||||
if (pinfo->column_attnum == InvalidAttrNumber)
|
if (pinfo->column_attnum == InvalidAttrNumber)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
strlcpy(pinfo->partfunc.schema, schema, NAMEDATALEN);
|
namestrcpy(&pinfo->partfunc.schema, schema);
|
||||||
|
|
||||||
/* Lookup the type cache entry to access the hash function for the type */
|
/* Lookup the type cache entry to access the hash function for the type */
|
||||||
columntype = get_atttype(relid, pinfo->column_attnum);
|
columntype = get_atttype(relid, pinfo->column_attnum);
|
||||||
@ -250,8 +254,8 @@ ts_partitioning_func_apply(PartitioningInfo *pinfo, Oid collation, Datum value)
|
|||||||
if (fcinfo->isnull)
|
if (fcinfo->isnull)
|
||||||
elog(ERROR,
|
elog(ERROR,
|
||||||
"partitioning function \"%s.%s\" returned NULL",
|
"partitioning function \"%s.%s\" returned NULL",
|
||||||
pinfo->partfunc.schema,
|
NameStr(pinfo->partfunc.schema),
|
||||||
pinfo->partfunc.name);
|
NameStr(pinfo->partfunc.name));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
|
|
||||||
typedef struct PartitioningFunc
|
typedef struct PartitioningFunc
|
||||||
{
|
{
|
||||||
char schema[NAMEDATALEN];
|
NameData schema;
|
||||||
char name[NAMEDATALEN];
|
NameData name;
|
||||||
Oid rettype;
|
Oid rettype;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -38,7 +38,7 @@ typedef struct PartitioningFunc
|
|||||||
|
|
||||||
typedef struct PartitioningInfo
|
typedef struct PartitioningInfo
|
||||||
{
|
{
|
||||||
char column[NAMEDATALEN];
|
NameData column;
|
||||||
AttrNumber column_attnum;
|
AttrNumber column_attnum;
|
||||||
DimensionType dimtype;
|
DimensionType dimtype;
|
||||||
PartitioningFunc partfunc;
|
PartitioningFunc partfunc;
|
||||||
|
@ -381,7 +381,7 @@ static void
|
|||||||
catalog_database_info_init(CatalogDatabaseInfo *info)
|
catalog_database_info_init(CatalogDatabaseInfo *info)
|
||||||
{
|
{
|
||||||
info->database_id = MyDatabaseId;
|
info->database_id = MyDatabaseId;
|
||||||
strlcpy(info->database_name, get_database_name(MyDatabaseId), NAMEDATALEN);
|
namestrcpy(&info->database_name, get_database_name(MyDatabaseId));
|
||||||
info->schema_id = get_namespace_oid(CATALOG_SCHEMA_NAME, false);
|
info->schema_id = get_namespace_oid(CATALOG_SCHEMA_NAME, false);
|
||||||
info->owner_uid = catalog_owner();
|
info->owner_uid = catalog_owner();
|
||||||
|
|
||||||
|
@ -1378,7 +1378,7 @@ typedef struct CatalogTableInfo
|
|||||||
|
|
||||||
typedef struct CatalogDatabaseInfo
|
typedef struct CatalogDatabaseInfo
|
||||||
{
|
{
|
||||||
char database_name[NAMEDATALEN];
|
NameData database_name;
|
||||||
Oid database_id;
|
Oid database_id;
|
||||||
Oid schema_id;
|
Oid schema_id;
|
||||||
Oid owner_uid;
|
Oid owner_uid;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user