Subject: sort by syntax/semantics

From: David Feldcamp <[email-masked]>
Date: Sat, 23 May 92 17:18:03 -0700

Is there some reason that the 'sort by' is restricted to simple attribute names?

For example if I have a class graph with attribute 'node' then I can only specify
'sort by node' and not 'sort by graph.node' or 'sort by <alias for graph>.node'.
If I do one of the latter I get the error message:

Query sent to backend is "retrieve (graph.node) sort by graph.node "
WARN:May 23 17:12:29:parser: syntax error: use "sort by attribute_name" at or near ""

Query sent to backend is "retrieve (a.node) from a in graph sort by a.node "
WARN:May 23 17:05:03:parser: syntax error: use "sort by attribute_name" at or near ""

Is this a known bug?  Can it be fixed?  This is an annoying problem when doing a 
retrieve of the form:

retrieve (a.node, b.node, c.node, ...) from a, b, c in graph where ... sort by ...

and you want to sort by more than one attribute with the same name.  
Even assuming that the first
attribute of several with the same name will be the one sorted does not seem too
safe when building an application which will have to migrate accross versions since
there seems to be no reason to assume that this behavior will persist.

---

From: <[email-masked]>
Date: Sun, 24 May 92 10:24:05 PDT

> Is there some reason that the 'sort by' is restricted to simple

no, the grammar just doesn't contain productions for more complex
sort specs.

> Is this a known bug?  Can it be fixed?  This is an annoying problem
> when doing a retrieve of the form:
>

i don't consider it a bug.  you can express the query above as

	retrieve (a.node, b.node, sortexpr = c.node, ...) ...
	sort by sortexpr

the rhs of the sortexpr assignment in the target list can be an
arbitrarily complex expression.  see the reference manual for
details.
					mike olson
					postgres research group
					uc berkeley
					[email-masked]