On Tue, Sep 30, 2014 at 9:05 PM, Feike Steenbergen <
feikesteenbergen@gmail.com> wrote:
> There seems to be a provision in ./src/bin/psql/common.c for these
> statements. The function is command_no_begin.
This function skips BEGIN statements for queries that cannot run within a
transaction block by scanning keywords at the beginning of the query
string, and it is true that CREATE TYPE ... ADD VALUE is not added. Now,
skip_white_space is able to skip whitespaces and comments but it is harder
to analyze the type name itself as it could be a combination of the
keywords you are analyzing, for example let's imagine this valid custom
type:
=# CREATE TYPE "create type foo add value" AS (a INT);
CREATE TYPE
=# \dT
List of data types
Schema | Name | Description
--------+-----------------------------+-------------
public | "create type foo add value" |
(1 row)
It is true that this behavior could be improved by having an additional
function able to skip an object name safely for a query string, but I
simply imagine that such additional logic has not been added in psql until
now because of the lack of complains about this behavior on a feature that
has been released 3 years ago.
Regards,
--
Michael