修复DELETE目标表不是普通表时产生的core问题

This commit is contained in:
li-judong
2023-12-08 16:39:05 +08:00
committed by totaj
parent 00878f5678
commit 1614b9faae
3 changed files with 18 additions and 0 deletions

View File

@ -225,6 +225,11 @@ int setTargetTable(ParseState* pstate, RangeVar* relRv, bool inh, bool alsoSourc
(errcode(ERRCODE_DUPLICATE_ALIAS), errmsg("table name \"%s\" specified more than once",
relRv->alias->aliasname)));
} else if (relRv->alias == NULL && strcmp(rte1->eref->aliasname, relRv->relname) == 0) {
if (rte1->rtekind != RTE_RELATION) {
ereport(ERROR,
(errcode(ERRCODE_OPERATE_NOT_SUPPORTED),
errmsg("The target table \"%s\" of the DELETE is not updatable", relRv->relname)));
}
if (list_member_ptr(pstate->p_target_rangetblentry, rte1)) {
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_ALIAS), errmsg("table name \"%s\" specified more than once",

View File

@ -1048,5 +1048,12 @@ select * from t_t_mutil_t2;
drop view multiview1;
drop view multiview2;
drop view multiview3;
-- issue
WITH with_t1 AS ( SELECT TRUE AS c23 , -9213573085711696683 AS c49 ) DELETE with_t1 FROM with_t1;
ERROR: The target table "with_t1" of the DELETE is not updatable
DELETE subq_t1 FROM (SELECT 100 AS A) subq_t1;
ERROR: The target table "subq_t1" of the DELETE is not updatable
DELETE func_t1 FROM generate_series(1, 10) func_t1;
ERROR: The target table "func_t1" of the DELETE is not updatable
\c regression
drop database multidelete;

View File

@ -505,5 +505,11 @@ select * from t_t_mutil_t2;
drop view multiview1;
drop view multiview2;
drop view multiview3;
-- issue
WITH with_t1 AS ( SELECT TRUE AS c23 , -9213573085711696683 AS c49 ) DELETE with_t1 FROM with_t1;
DELETE subq_t1 FROM (SELECT 100 AS A) subq_t1;
DELETE func_t1 FROM generate_series(1, 10) func_t1;
\c regression
drop database multidelete;