!3610 修复分区表文件无法删除、部分array函数coredump的问题

Merge pull request !3610 from 胡正超/recyclebin
This commit is contained in:
opengauss_bot
2023-06-27 03:10:43 +00:00
committed by Gitee
8 changed files with 93 additions and 18 deletions

View File

@ -1787,7 +1787,8 @@ Datum array_varchar_exists(PG_FUNCTION_ARGS)
PG_RETURN_BOOL(false);
}
Datum index_datum = PG_GETARG_DATUM(1);
if (u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
if (u_sess->SPI_cxt.cur_tableof_index == NULL ||
u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("array_varchar_exists must be call in procedure")));
}
@ -1821,7 +1822,8 @@ Datum array_integer_exists(PG_FUNCTION_ARGS)
PG_RETURN_BOOL(false);
}
Datum index_datum = PG_GETARG_DATUM(1);
if (u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
if (u_sess->SPI_cxt.cur_tableof_index == NULL ||
u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("array_integer_exists must be call in procedure")));
}
@ -1966,7 +1968,8 @@ Datum array_varchar_next(PG_FUNCTION_ARGS)
int index = 0;
Datum index_datum = PG_GETARG_DATUM(1);
if (u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
if (u_sess->SPI_cxt.cur_tableof_index == NULL ||
u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("array_varchar_next must be call in procedure")));
}
@ -2016,7 +2019,8 @@ Datum array_varchar_prior(PG_FUNCTION_ARGS)
int index = 0;
Datum index_datum = PG_GETARG_DATUM(1);
if (u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
if (u_sess->SPI_cxt.cur_tableof_index == NULL ||
u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("array_varchar_prior must be call in procedure")));
}
@ -2061,7 +2065,8 @@ Datum array_varchar_first(PG_FUNCTION_ARGS)
PG_RETURN_NULL();
}
if (u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
if (u_sess->SPI_cxt.cur_tableof_index == NULL ||
u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("array_varchar_first must be call in procedure")));
}
@ -2108,7 +2113,8 @@ Datum array_integer_next(PG_FUNCTION_ARGS)
}
Datum index_datum = PG_GETARG_DATUM(1);
if (u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
if (u_sess->SPI_cxt.cur_tableof_index == NULL ||
u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("array_integer_next must be call in procedure")));
}
@ -2165,7 +2171,8 @@ Datum array_integer_prior(PG_FUNCTION_ARGS)
}
Datum index_datum = PG_GETARG_DATUM(1);
if (u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
if (u_sess->SPI_cxt.cur_tableof_index == NULL ||
u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("array_integer_prior must be call in procedure")));
}
@ -2218,7 +2225,8 @@ Datum array_integer_first(PG_FUNCTION_ARGS)
PG_RETURN_NULL();
}
if (u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
if (u_sess->SPI_cxt.cur_tableof_index == NULL ||
u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("array_integer_first must be call in procedure")));
}
@ -2262,7 +2270,8 @@ Datum array_integer_last(PG_FUNCTION_ARGS)
PG_RETURN_NULL();
}
if (u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
if (u_sess->SPI_cxt.cur_tableof_index == NULL ||
u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("array_integer_last must be call in procedure")));
}
@ -2287,7 +2296,8 @@ Datum array_varchar_last(PG_FUNCTION_ARGS)
PG_RETURN_NULL();
}
if (u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
if (u_sess->SPI_cxt.cur_tableof_index == NULL ||
u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("array_varchar_last must be call in procedure")));
}
@ -2343,7 +2353,8 @@ Datum array_integer_deleteidx(PG_FUNCTION_ARGS)
}
Datum index_datum = PG_GETARG_DATUM(1);
if (u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
if (u_sess->SPI_cxt.cur_tableof_index == NULL ||
u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("array_integer_deleteidx must be call in procedure")));
}
@ -2368,7 +2379,8 @@ Datum array_varchar_deleteidx(PG_FUNCTION_ARGS)
}
Datum index_datum = PG_GETARG_DATUM(1);
if (u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
if (u_sess->SPI_cxt.cur_tableof_index == NULL ||
u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("array_varchar_deleteidx must be call in procedure")));
}
@ -2575,7 +2587,8 @@ Datum array_indexby_delete(PG_FUNCTION_ARGS)
checkEnv();
ArrayType* v = PG_GETARG_ARRAYTYPE_P(0);
ArrayType* array = construct_empty_array(ARR_ELEMTYPE(v));
if (u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
if (u_sess->SPI_cxt.cur_tableof_index == NULL ||
u_sess->SPI_cxt.cur_tableof_index->tableOfIndex == NULL) {
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("array_indexby_delete must be call in procedure")));
}

View File

@ -5034,7 +5034,7 @@ RelFileNodeBackend CreateNewRelfilenodePart(Relation parent, Partition part)
part->newcbi = true;
}
partition_create_new_storage(parent, part, newrnode);
partition_create_new_storage(parent, part, newrnode, true);
return newrnode;
}

View File

@ -878,7 +878,8 @@ void smgrmovebuckets(SMgrRelation reln1, SMgrRelation reln2, List *bList)
(*(smgrsw[reln1->smgr_which].smgr_move_buckets))(reln1->smgr_rnode, reln2->smgr_rnode, bList);
}
void partition_create_new_storage(Relation rel, Partition part, const RelFileNodeBackend &filenode)
void partition_create_new_storage(Relation rel, Partition part, const RelFileNodeBackend &filenode,
bool keep_old_relfilenode)
{
if (RelationIsCrossBucketIndex(rel) || IsCreatingCrossBucketIndex(part)) {
RelationData dummyrel;
@ -894,8 +895,7 @@ void partition_create_new_storage(Relation rel, Partition part, const RelFileNod
/*
* Schedule unlinking of the old storage at transaction commit.
*/
if (!u_sess->attr.attr_storage.enable_recyclebin ||
!RelationIsTableAccessMethodUStoreType(rel->rd_options)) {
if (!keep_old_relfilenode) {
PartitionDropStorage(rel, part);
}
}

View File

@ -245,7 +245,8 @@ extern Datum smgrin(PG_FUNCTION_ARGS);
extern Datum smgreq(PG_FUNCTION_ARGS);
extern Datum smgrne(PG_FUNCTION_ARGS);
extern void partition_create_new_storage(Relation rel, Partition part, const RelFileNodeBackend& filenode);
extern void partition_create_new_storage(Relation rel, Partition part, const RelFileNodeBackend& filenode,
bool keep_old_relfilenode = false);
extern ScalarToDatum GetTransferFuncByTypeOid(Oid attTypeOid);
extern bool check_unlink_rel_hashtbl(RelFileNode rnode, ForkNumber forknum);

View File

@ -11,6 +11,10 @@ drop schema if exists plpgsql_array_interface_indexby;
NOTICE: schema "plpgsql_array_interface_indexby" does not exist, skipping
create schema plpgsql_array_interface_indexby;
set current_schema = plpgsql_array_interface_indexby;
-- must be call in procedure --
select array_indexby_delete(array[1, 2]);
ERROR: array_indexby_delete must be call in procedure
CONTEXT: referenced column: array_indexby_delete
-- test array interface count --
create or replace procedure array_interface_p1() as
declare

View File

@ -11,6 +11,43 @@ drop schema if exists plpgsql_array_interface;
NOTICE: schema "plpgsql_array_interface" does not exist, skipping
create schema plpgsql_array_interface;
set current_schema = plpgsql_array_interface;
-- must be call in procedure --
select array_varchar_exists(array['1', '2'], '3');
ERROR: array_varchar_exists must be call in procedure
CONTEXT: referenced column: array_varchar_exists
select array_varchar_next(array['1','2'], '3');
ERROR: array_varchar_next must be call in procedure
CONTEXT: referenced column: array_varchar_next
select array_varchar_prior(array['1','2'], '3');
ERROR: array_varchar_prior must be call in procedure
CONTEXT: referenced column: array_varchar_prior
select array_varchar_first(array['1','2']);
ERROR: array_varchar_first must be call in procedure
CONTEXT: referenced column: array_varchar_first
select array_varchar_last(array['1','2']);
ERROR: array_varchar_last must be call in procedure
CONTEXT: referenced column: array_varchar_last
select array_varchar_deleteidx(array['1','2'], '3');
ERROR: array_varchar_deleteidx must be call in procedure
CONTEXT: referenced column: array_varchar_deleteidx
select array_integer_exists(array[1, 2], 3);
ERROR: array_integer_exists must be call in procedure
CONTEXT: referenced column: array_integer_exists
select array_integer_next(array[1, 2], 3);
ERROR: array_integer_next must be call in procedure
CONTEXT: referenced column: array_integer_next
select array_integer_prior(array[1, 2], 3);
ERROR: array_integer_prior must be call in procedure
CONTEXT: referenced column: array_integer_prior
select array_integer_first(array[1, 2]);
ERROR: array_integer_first must be call in procedure
CONTEXT: referenced column: array_integer_first
select array_integer_last(array[1, 2]);
ERROR: array_integer_last must be call in procedure
CONTEXT: referenced column: array_integer_last
select array_integer_deleteidx(array[1, 2], 3);
ERROR: array_integer_deleteidx must be call in procedure
CONTEXT: referenced column: array_integer_deleteidx
-- test array interface count --
create or replace procedure array_interface_p1()
as

View File

@ -8,6 +8,10 @@ drop schema if exists plpgsql_array_interface_indexby;
create schema plpgsql_array_interface_indexby;
set current_schema = plpgsql_array_interface_indexby;
-- must be call in procedure --
select array_indexby_delete(array[1, 2]);
-- test array interface count --
create or replace procedure array_interface_p1() as
declare

View File

@ -8,6 +8,22 @@ drop schema if exists plpgsql_array_interface;
create schema plpgsql_array_interface;
set current_schema = plpgsql_array_interface;
-- must be call in procedure --
select array_varchar_exists(array['1', '2'], '3');
select array_varchar_next(array['1','2'], '3');
select array_varchar_prior(array['1','2'], '3');
select array_varchar_first(array['1','2']);
select array_varchar_last(array['1','2']);
select array_varchar_deleteidx(array['1','2'], '3');
select array_integer_exists(array[1, 2], 3);
select array_integer_next(array[1, 2], 3);
select array_integer_prior(array[1, 2], 3);
select array_integer_first(array[1, 2]);
select array_integer_last(array[1, 2]);
select array_integer_deleteidx(array[1, 2], 3);
-- test array interface count --
create or replace procedure array_interface_p1()
as