Re: Is this legal SQL? Is it a good practice?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Carlos Moreno <moreno(at)mochima(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Is this legal SQL? Is it a good practice?
Date: 2004-08-24 22:57:30
Message-ID: 13002.1093388250@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Carlos Moreno <moreno(at)mochima(dot)com> writes:
> I always thought the semicolon was a psql thing,
> which it would use to determine when the user is
> done entering the SQL statement.

Exactly. psql parses what you type sufficiently well to locate
command-ending semicolons, and then sends one command at a time to the
backend. libpq is much dumber; it just takes the string you give it and
ships that to the backend.

The backend's current behavior with multi-command input strings has been
that way since the beginning (or at least since before I got here).
People have occasionally proposed removing the feature, but it's pretty
well entrenched on backwards-compatibility grounds.

Note that the new "v3" fe/be protocol does *not* allow multiple commands
in an extended-query-mode input string, so if you are of the opinion
that allowing multiple commands is a bad idea you can just use extended
query mode all the time. (In libpq that translates to not using PQexec,
but one of the newer functions.)

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Marc G. Fournier 2004-08-24 23:15:15 Re: Unsupported 3rd-party solutions (Was: Few questions
Previous Message Stephan Szabo 2004-08-24 22:51:13 Re: Deadlocks caused by referential integrity checks