Why can't I have a "language sql" anonymous block?
От | Bryn Llewellyn |
---|---|
Тема | Why can't I have a "language sql" anonymous block? |
Дата | |
Msg-id | C9838A29-8C84-4F68-9C41-5CB4665911E5@yugabyte.com обсуждение исходный текст |
Ответы |
Re: Why can't I have a "language sql" anonymous block?
|
Список | pgsql-general |
My question is this:
create procedure p_sql()
security definer
language sql
as $body$
drop table if exists t cascade;
create table t(k serial primary key, v text not null);
Was there a deliberate decision not to allow a “language sql” anonymous block? Or is it just that nobody thought that it would be useful?
Here’s what I mean. First, something that works (using PG Version 14.1):
create procedure p_plpgsql()
security definer
language plpgsql
as $body$
begin
drop table if exists t cascade;
create table t(k serial primary key, v text not null);
end;
$body$;
security definer
language plpgsql
as $body$
begin
drop table if exists t cascade;
create table t(k serial primary key, v text not null);
end;
$body$;
I can transform this trivially to an anonymous block:
do language plpgsql $body$
begin
drop table if exists t cascade;
create table t(k serial primary key, v text not null);
end;
$body$;
begin
drop table if exists t cascade;
create table t(k serial primary key, v text not null);
end;
$body$;
I can also transform the procedure trivially to "language sql”:
security definer
language sql
as $body$
drop table if exists t cascade;
create table t(k serial primary key, v text not null);
$body$;
But trying the corresponding “language sql” anonymous block:
do language sql $body$
begin
drop table if exists t cascade;
create table t(k serial primary key, v text not null);
end;
$body$;
begin
drop table if exists t cascade;
create table t(k serial primary key, v text not null);
end;
$body$;
Causes this error:
0A000 (feature_not_supported): language "sql" does not support inline code execution
В списке pgsql-general по дате отправления: