Re: Question about "compound" queries.

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: "Anton A(dot) Melnikov" <aamelnikov(at)inbox(dot)ru>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Question about "compound" queries.
Date: 2022-10-24 22:36:10
Message-ID: CAKFQuwbqMTSoptwsyVZtNBds4-96rAJBbt03S3jknsRG_6GSpA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Oct 24, 2022 at 3:02 PM Anton A. Melnikov <aamelnikov(at)inbox(dot)ru>
wrote:

> Hello!
>
> Please, could somebody explain what the "compound" queries were created
> for?
> Maybe i'm calling them wrong. It's about queries like:
> SELECT 1 + 2 \; SELECT 2.0 AS "float" \; SELECT 1;
>
> Such queries can neither be prepared nor used in the extended protocol with
> ERROR: cannot insert multiple commands into a prepared statement.
> What are their advantages?
> And what is the proper name for such queries? "Compound" or something else?
> Would be very grateful for clarification.
>

I suspect they came about out of simplicity - being able to simply take a
text file with a bunch of SQL commands in a script and send them as-is to
the server without any client-side parsing and let the server just deal
with it. It works because the system needs to do those kinds of things
anyway so, why not make it user-facing, even if most uses would find its
restrictions makes it undesirable to use.

David J.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jacob Champion 2022-10-25 00:03:23 Re: [PATCH] Add `verify-system` sslmode to use system CA pool for server cert
Previous Message Matheus Alcantara 2022-10-24 22:13:55 Re: Interesting areas for beginners