| drop table if exists test cascade; |
| NOTICE: table "test" does not exist, skipping |
| create table test (d integer, a integer, b integer); |
| NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'd' as the Apache Cloudberry data distribution key for this table. |
| HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. |
| insert into test select a, a, a%25 from generate_series(1,100) a; |
| create or replace function bu() returns trigger as ' |
| begin |
| if new.a != old.a then |
| -- delete from test where a = old.a; |
| -- insert into test (a,b) values (new.a, new.b); |
| return null; |
| end if; |
| return new; |
| end; |
| ' language plpgsql NO SQL; |
| create trigger tg_bu before update |
| on test for each row execute procedure bu(); |
| update test set a=200 where a=10; |
| drop trigger tg_bu on test; |
| drop function bu(); |
| drop table test; |
| create table test (a integer, b integer, c integer); |
| NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Apache Cloudberry data distribution key for this table. |
| HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. |
| insert into test select a, a%25, a%30 from generate_series(1, 100) a; |
| analyze test; |
| create or replace function refcursor(int, int) returns setof int as $$ |
| declare |
| c1 cursor (param1 int, param2 int) for select * from test where a > param1 and b > param2; |
| nonsense record; |
| i int; |
| begin |
| open c1($1, $2); |
| fetch c1 into nonsense; |
| close c1; |
| if found then |
| for i in $1 .. $2 loop |
| return next i + 1; |
| end loop; |
| |
| return; |
| else |
| for i in $1 .. $2 loop |
| return next i - 1; |
| end loop; |
| |
| return; |
| end if; |
| end |
| $$ language plpgsql READS SQL DATA ROWS 10; |
| select * from (select refcursor (1, 10)) t1, test; |
| ERROR: function cannot execute on a QE slice because it accesses relation "public.test" (seg0 slice1 usensimiobmbp.corp.emc.com:18506 pid=17309) |
| CONTEXT: SQL statement "select * from test where a > param1 and b > param2" |
| PL/pgSQL function refcursor(integer,integer) line 7 at OPEN |
| drop function refcursor(int, int); |