函数使用限制: 1. 不支持函数中DML,DDL,创建临时表; 2. 不支持函数里面涉及SQL 查询语句; 3. 不支持函数中使用下列方式给变量赋值,但没禁止; DECLARE res int DEFAULT 0; SET res=(SELECT COUNT(*) FROM t); 或:SELECT COUNT(*) INTO @res FROM t; 4. 不支持预处理。 SQL 场景使用限制: SQL 中有子查询并且子查询没有from 子句,没有查询任何表,仅有投影部分。 如: select * from t1 where b > (select now()) ; -- 子查询(select now())没有from 子句, 没有查询任何表 1. 存储过程中的定义中包含了此场景的SQL,执行存储过程时,预期报错,不 被支持; 2. 不支持对此场景的SQL 预处理执行; 3. 不支持在event 中执行此场景的SQL, event 调度执行时预期报错, 不被支持。 示例: 存储过程示例: DELIMITER // CREATE PROCEDURE testpro () BEGIN select * from t1 where b > (select now()) ; -- 子查询(select now()) 没有查询任 何表 END // DELIMITER ; call testpro(); -- 预期报错 ERROR 1149 (42000): (GBA-02SC-1001) The query includes syntax that is not supported by the gcluster. {STATEMENT: call testpro() INSTRUCTION: select * from t where d > (select now()) [1]} prepare 示例:
GBase 8a MPP Cluster 产品手册 5 数据库管理指南 文档版本953(2022-09-15) 南大通用数据技术股份有限公司 1382 gbase> delimiter // gbase> create procedure p1() begin set @sql_str='select * from t where d > (select now())'; prepare stmt from @sql_str; execute stmt; end // Query OK, 0 rows affected (Elapsed: 00:00:00.05) gbase> delimiter ; gbase> call p1(); ERROR 1149 (42000): (GBA-02SC-1001) The query includes syntax that is not supported by the gcluster. {STATEMENT: call p1() INSTRUCTION: execute stmt [3]} event 示例: create event myEvent2 on schedule every 10 second starts current_timestamp + interval 20 second ends current_timestamp + interval 1 minute on completion not preserve do insert into t2 select * from t1 where b > (select now()); -- 子查询(select now()) 没有查询任何表, event 调度执行时预期报错:(GBA-02SC-1001) The query includes syntax that is not supported by the gcluster