Re: SQL flagger

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SQL flagger
Date: 2003-01-12 18:56:28
Message-ID: 29592.1042397788@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> The SQL standard requires conforming implementations to provide an
> "SQL flagger" facility ...

> I think we could implement this with relatively little intrusion if we
> create an interface routine, say SQLFlagger(), which takes the entire
> parsetree as its argument can then analyze the syntax in as much
> detail as it likes. (Of course that function would only be called if
> a certain Boolean flag is set.) But a few syntax elements would need
> to checked right within gram.y, such as the omission of the drop
> behavior or the use of TEMP vs. TEMPORARY, which is resolved right in
> the parser and cannot be detected later.

> Should we implement this?

I think we would be better off to implement this as a standalone program
rather than as a backend mode option.

In general, gram.y's behavior should never depend on any runtime
variables. If it does, you get inconsistent results from
SET var = val ; ... other stuff ...
(one query string) compared to
SET var = val
... other stuff ...
(two query strings), because the whole query string is fed through
gram.y before any of it is executed.

Plan B, if you really want to do this in the backend, would be to alter
gram.y's output trees so that all the non-spec constructs are still
recognizable in the raw parse tree, and any conversions needed are done
in analyze.c's processing (which would also be the place to issue the
flagger warnings). This is not necessarily a bad idea; I've always
thought that we do too much work in gram.y anyway. But you will be
fighting a permanent rear-guard action to keep people from
re-introducing variant syntaxes by quick gram.y hacks.

In general I like the idea of a standalone program better, however.
It would be able to have its own grammar tuned to its needs. I don't
think there would be much maintenance problem introduced thereby,
since presumably the flagger's grammar is driven by the spec and won't
need to change when we change what Postgres accepts.

regards, tom lane

In response to

  • SQL flagger at 2003-01-12 18:26:48 from Peter Eisentraut

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joe Conway 2003-01-12 20:26:32 targetlist functions part 1 (was [HACKERS] targetlist functions proposals)
Previous Message Peter Eisentraut 2003-01-12 18:26:48 SQL flagger