bugfix: cancel change kernel to support some third-party extensions

This commit is contained in:
chenlinfeng3 2020-08-03 13:05:27 +08:00 committed by zhongjun2
parent bc7e4b2d87
commit 1321637262
7 changed files with 82 additions and 38 deletions

View File

@ -524,7 +524,8 @@ FdwRoutine* GetFdwRoutineByServerId(Oid serverid)
/* Get foreign-data wrapper OID for the server. */
tp = SearchSysCache1(FOREIGNSERVEROID, ObjectIdGetDatum(serverid));
if (!HeapTupleIsValid(tp))
return NULL;
ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("cache lookup failed for foreign server %u", serverid)));
serverform = (Form_pg_foreign_server) GETSTRUCT(tp);
fdwid = serverform->srvfdw;
ReleaseSysCache(tp);

View File

@ -1845,7 +1845,12 @@ Oid DefineRelation(CreateStmt* stmt, char relkind, Oid ownerId)
if (colDef->raw_default != NULL) {
RawColumnDefault* rawEnt = NULL;
if (relkind == RELKIND_FOREIGN_TABLE) {
if (!(IsA(stmt, CreateForeignTableStmt) &&
isMOTTableFromSrvName(((CreateForeignTableStmt*)stmt)->servername)))
ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("default values on foreign tables are not supported")));
}
Assert(colDef->cooked_default == NULL);
rawEnt = (RawColumnDefault*)palloc(sizeof(RawColumnDefault));
rawEnt->attnum = attnum;

View File

@ -3586,6 +3586,9 @@ void standard_ProcessUtility(Node* parse_tree, const char* query_string, ParamLi
} break;
case T_AlterDomainStmt:
#ifdef PGXC
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("domain is not yet supported.")));
#endif /* PGXC */
{
AlterDomainStmt* stmt = (AlterDomainStmt*)parse_tree;
@ -4237,6 +4240,10 @@ void standard_ProcessUtility(Node* parse_tree, const char* query_string, ParamLi
} break;
case T_RuleStmt: /* CREATE RULE */
#ifdef PGXC
if (!IsInitdb && !u_sess->attr.attr_sql.enable_cluster_resize && !u_sess->exec_cxt.extension_is_valid)
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("RULE is not yet supported.")));
#endif /* PGXC */
DefineRule((RuleStmt*)parse_tree, query_string);
#ifdef PGXC
if (IS_PGXC_COORDINATOR && !IsConnFromCoord()) {
@ -4920,6 +4927,10 @@ void standard_ProcessUtility(Node* parse_tree, const char* query_string, ParamLi
* ******************************** DOMAIN statements ****
*/
case T_CreateDomainStmt:
#ifdef PGXC
if (!IsInitdb && !u_sess->attr.attr_common.IsInplaceUpgrade)
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("domain is not yet supported.")));
#endif /* PGXC */
DefineDomain((CreateDomainStmt*)parse_tree);
#ifdef PGXC
if (IS_PGXC_COORDINATOR)
@ -8520,6 +8531,9 @@ void CheckObjectInBlackList(ObjectType obj_type, const char* query_string)
return;
else
break;
case OBJECT_AGGREGATE:
tag = "AGGREGATE";
break;
case OBJECT_OPERATOR:
tag = "OPERATOR";
break;
@ -8582,6 +8596,28 @@ void CheckObjectInBlackList(ObjectType obj_type, const char* query_string)
*/
bool CheckExtensionInWhiteList(const char* extension_name, uint32 hash_value, bool hash_check)
{
/* 2902411162 hash for fastcheck, the sql file is much shorter than published version. */
uint32 postgisHashHistory[POSTGIS_VERSION_NUM] = {2902411162, 2959454932};
/* check for extension name */
if (pg_strcasecmp(extension_name, "postgis") == 0) {
/* PostGIS is disabled under 300 deployment */
if (is_feature_disabled(POSTGIS_DOCKING)) {
return false;
}
if (hash_check && !isSecurityMode) {
/* check for postgis hashvalue */
for (int i = 0; i < POSTGIS_VERSION_NUM; i++) {
if (hash_value == postgisHashHistory[i]) {
return true;
}
}
} else {
return true;
}
}
return true;
}

View File

@ -8,7 +8,7 @@ select count(*) from pg_node_env;
select count(*) from pg_os_threads;
count
-------
29
10
(1 row)
-- test backtrace output to log

View File

@ -46,6 +46,8 @@ select * from gtt6;
-- ERROR
create index CONCURRENTLY idx_gtt1 on gtt1 (b);
ERROR: PGXC does not support concurrent INDEX yet
DETAIL: The feature is not currently supported
-- ERROR
cluster gtt1 using gtt1_pkey;
-- ERROR

View File

@ -3230,15 +3230,15 @@ INSERT INTO c VALUES (0), (1);
INSERT INTO d VALUES (1,3), (2,2), (3,1);
-- all three cases should be optimizable into a simple seqscan
explain (verbose on, costs off, nodes off) SELECT a.* FROM a LEFT JOIN b ON a.b_id = b.id;
QUERY PLAN
----------------------------------------
--?.*QUERY PLAN.*
--?----------------------------.*
--? Seq Scan on pg_temp_datanod.*
Output: a.id, a.b_id
(2 rows)
explain (verbose on, costs off, nodes off) SELECT b.* FROM b LEFT JOIN c ON b.c_id = c.id;
QUERY PLAN
----------------------------------------
--?.*QUERY PLAN.*
--?----------------------------.*
--? Seq Scan on pg_temp_datanod.*
Output: b.id, b.c_id
(2 rows)
@ -3246,8 +3246,8 @@ explain (verbose on, costs off, nodes off) SELECT b.* FROM b LEFT JOIN c ON b.c_
explain (verbose on, costs off, nodes off)
SELECT a.* FROM a LEFT JOIN (b left join c on b.c_id = c.id)
ON (a.b_id = b.id);
QUERY PLAN
----------------------------------------
--?QUERY PLAN.*
--?-----------------------------.*
--? Seq Scan on pg_temp_datanod.*
Output: a.id, a.b_id
(2 rows)
@ -3257,8 +3257,8 @@ explain (verbose on, costs off, nodes off)
select id from a where id in (
select b.id from b left join c on b.id = c.id
);
QUERY PLAN
----------------------------------------------------
--?QUERY PLAN.*
--?----------------------------.*
Hash Join
Output: a.id
Hash Cond: (a.id = b.id)
@ -3275,8 +3275,8 @@ select id from a where id in (
explain (verbose on, costs off, nodes off)
select d.* from d left join (select * from b group by b.id, b.c_id) s
on d.a = s.id and d.b = s.c_id;
QUERY PLAN
----------------------------------------
--?QUERY PLAN.*
--?----------------------------.*
--? Seq Scan on pg_temp_datanod.*
Output: d.a, d.b
(2 rows)
@ -3285,8 +3285,8 @@ select d.* from d left join (select * from b group by b.id, b.c_id) s
explain (verbose on, costs off, nodes off)
select d.* from d left join (select distinct * from b) s
on d.a = s.id and d.b = s.c_id;
QUERY PLAN
----------------------------------------
--?QUERY PLAN.*
--?----------------------------.*
--? Seq Scan on pg_temp_datanod.*
Output: d.a, d.b
(2 rows)
@ -3296,8 +3296,8 @@ select d.* from d left join (select distinct * from b) s
explain (verbose on, costs off, nodes off)
select d.* from d left join (select * from b group by b.id, b.c_id) s
on d.a = s.id;
QUERY PLAN
----------------------------------------------------
--?QUERY PLAN.*
--?----------------------------.*
Hash Right Join
Output: d.a, d.b
Hash Cond: (b.id = d.a)
@ -3316,8 +3316,8 @@ select d.* from d left join (select * from b group by b.id, b.c_id) s
explain (verbose on, costs off, nodes off)
select d.* from d left join (select distinct * from b) s
on d.a = s.id;
QUERY PLAN
----------------------------------------------------
--?QUERY PLAN.*
--?----------------------------.*
Hash Right Join
Output: d.a, d.b
Hash Cond: (b.id = d.a)
@ -3337,8 +3337,8 @@ select d.* from d left join (select distinct * from b) s
explain (verbose on, costs off, nodes off)
select d.* from d left join (select id from a union select id from b) s
on d.a = s.id;
QUERY PLAN
----------------------------------------
--?QUERY PLAN.*
--?----------------------------.*
--? Seq Scan on pg_temp_datanod.*
Output: d.a, d.b
(2 rows)
@ -3347,8 +3347,8 @@ select d.* from d left join (select id from a union select id from b) s
explain (verbose on, costs off, nodes off)
select i8.* from int8_tbl i8 left join (select f1 from int4_tbl group by f1) i4
on i8.q1 = i4.f1;
QUERY PLAN
--------------------------------
--?QUERY PLAN.*
--?----------------------------.*
Seq Scan on public.int8_tbl i8
Output: i8.q1, i8.q2
(2 rows)
@ -3371,8 +3371,8 @@ select p.* from parent p left join child c on (p.k = c.k) order by 1,2;
explain (verbose on, costs off, nodes off)
select p.* from parent p left join child c on (p.k = c.k) order by 1,2;
QUERY PLAN
-----------------------------------------------------
--?QUERY PLAN.*
--?----------------------------.*
Sort
Output: p.k, p.pd
Sort Key: p.k, p.pd
@ -3395,8 +3395,8 @@ explain (verbose on, costs off, nodes off)
select p.*, linked from parent p
left join (select c.*, true as linked from child c) as ss
on (p.k = ss.k) order by p.k;
QUERY PLAN
-----------------------------------------------------------------------------
--?QUERY PLAN.*
--?----------------------------.*
Merge Left Join
Output: p.k, p.pd, (true)
Merge Cond: (p.k = c.k)
@ -3418,8 +3418,8 @@ explain (verbose on, costs off, nodes off)
select p.* from
parent p left join child c on (p.k = c.k)
where p.k = 1 and p.k = 2;
QUERY PLAN
--------------------------
--?QUERY PLAN.*
--?----------------.*
Result
Output: p.k, p.pd
One-Time Filter: false
@ -3519,8 +3519,8 @@ select t1.* from
on (t1.f1 = b1.d1)
left join int4_tbl i4
on (i8.q2 = i4.f1);
QUERY PLAN
----------------------------------------------------------------------
--?QUERY PLAN.*
--?----------------------------.*
Hash Left Join
Output: t1.f1
Hash Cond: (i8.q2 = i4.f1)
@ -3586,8 +3586,8 @@ select t1.* from
on (t1.f1 = b1.d1)
left join int4_tbl i4
on (i8.q2 = i4.f1);
QUERY PLAN
----------------------------------------------------------------------
--?QUERY PLAN.*
--?----------------------------.*
Hash Left Join
Output: t1.f1
Hash Cond: (i8.q2 = i4.f1)
@ -3652,8 +3652,8 @@ select * from
on t1.f1 = 'doh!'
left join int4_tbl i4
on i8.q1 = i4.f1;
QUERY PLAN
--------------------------------------------------------------
--?QUERY PLAN.*
--?----------------------------.*
Nested Loop Left Join
Output: t1.f1, i8.q1, i8.q2, t2.f1, i4.f1
-> Seq Scan on public.text_tbl t2
@ -3700,8 +3700,8 @@ CREATE TABLE mj_t2 (a int,c char(10));
insert into mj_t2 values(12,'abcde');
insert into mj_t2 values(12,'efghi');
explain (nodes off, costs off) select * from mj_t1 full outer join mj_t2 on 1=1;
QUERY PLAN
-------------------------------
--?QUERY PLAN.*
--?-----------------------.*
Merge Full Join
-> Seq Scan on mj_t1
-> Materialize

View File

@ -71,7 +71,7 @@ SELECT name, setting FROM pg_settings WHERE name LIKE 'enable%' ORDER BY name;
enable_sonic_optspill | on
enable_sort | on
enable_stream_replication | on
enable_thread_pool | on
enable_thread_pool | off
enable_tidscan | on
enable_upgrade_merge_lock_mode | off
enable_user_metric_persistent | on