Обсуждение: How to know if a query is semantically correct without execute it?

Поиск
Список
Период
Сортировка

How to know if a query is semantically correct without execute it?

От
Juan Daniel Santana Rodes
Дата:
Hi...
I am programming a procedure in plpgsql language and it must return a boolean response.
The procedure must return TRUE if the query is semantically correct and if not correct, return FALSE.
This must be done without running the query.
Greetings to all, thanks in advance.
__________________________________________________
"Todos el 12 de Septiembre con una Cinta Amarilla"
FIN A LA INJUSTICIA, LIBERENLOS YA!!
http://www.antiterroristas.cu
                                    
http://justiciaparaloscinco.wordpress.com


Re: How to know if a query is semantically correct without execute it?

От
CR Lender
Дата:
On 2013-09-19 02:01, Juan Daniel Santana Rodes wrote:
> I am programming a procedure in plpgsql language and it must return a
> boolean response. The procedure must return TRUE if the query is
> semantically correct and if not correct, return FALSE. This must be
> done without running the query.

You could use EXPLAIN instead of running the actual query, catching the
eventual errors and returning TRUE or FALSE depending on the outcome.
I'm not sure what you mean by "semantically correct", but in addition to
simple syntax errors, non-existent relations, columns, functions, etc,
would also be caught.

regards,
CRL


Re: How to know if a query is semantically correct without execute it?

От
David Johnston
Дата:
Juan Daniel Santana Rodés wrote
> Hi...
> I am programming a procedure in plpgsql language and it must return a
> boolean response.
> The procedure must return TRUE if the query is semantically correct and if
> not correct, return FALSE.
> This must be done without running the query.
> Greetings to all, thanks in advance.

You can confirm syntax (in theory, using explain) but not semantics.  The
later basically means that the query does what it's author intended.  Any
two queries with desired identical semantics must give the same output given
identical input - though the syntax of the two queries can differ.

You probably meant syntactically but since both terms have meaning in this
context picking the wrong word is confusing to others.

I'm not sure how safe doing so would be...or where limitations may exist -
i.e., some queries may not be able to be evaluated in this way.

David J.




--
View this message in context:
http://postgresql.1045698.n5.nabble.com/How-to-know-if-a-query-is-semantically-correct-without-execute-it-tp5771547p5771556.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.