Why can't I have a "language sql" anonymous block? - Mailing list pgsql-general

From Bryn Llewellyn
Subject Why can't I have a "language sql" anonymous block?
Date
Msg-id C9838A29-8C84-4F68-9C41-5CB4665911E5@yugabyte.com
Whole thread Raw
Responses Re: Why can't I have a "language sql" anonymous block?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
My question is this:

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$;

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$;

I can also transform the procedure trivially to "language sql”:

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);
$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$;

Causes this error:

0A000 (feature_not_supported): language "sql" does not support inline code execution


pgsql-general by date:

Previous
From: Jean Baro
Date:
Subject: Re: Where can I follow the progress of "Pluggable Storage" development?
Next
From: Tom Lane
Date:
Subject: Re: Why can't I have a "language sql" anonymous block?