LWN.net Logo

PostgreSQL and the SQL standards process

PostgreSQL and the SQL standards process

Posted Sep 22, 2011 3:56 UTC (Thu) by ringerc (subscriber, #3071)
Parent article: PostgreSQL and the SQL standards process

For what it's worth, I've seen strong interest in following the standards on the Pg lists - even in cases where the standards are of dubious sense or downright stupid. That applies both for formal ISO standard features and where compatibility with major-vendor language extensions like to_char is in question. The documentation reflects that, with clear coverage of which Pg features are part of the standard and which are extensions.

There's certainly a lot of frustration with the standard process's exclusion of some of the key groups who use it, like open source database developers and JDBC driver developers. The difficulty of accessing the released standards documentation is another store point.

For users without corporate backing to buy $lots copies of the standards it is vary frustrating to have to rely on circulating old drafts and other vendors' documentation. This devalues the standard, because it's so hard to know what is and isn't standard that it's hard to code to the standard - so people just pick a vendor dialect and stop caring.

Personally, I think the best thing that can happen to the SQL standards process at this point is to put it quietly out of its misery and reboot the whole thing. We - end users, database implementers, middleware/ORM implementers, JDBC/ODBC/ADO/etc driver implementers, etc - need a language with the same core capabilities but a sane, machine-readable syntax. SQL's god-awful pseudo-natural-language monstrosity of a grammar is a nightmare to work with. Parsing it is hard enough, but transforming it and proving things about it is horrifying. I'd be delighted to see adoption of a language that could express all the concepts, but:

- Is ordered sanely, with subjects before predicates before outcomes;

- Is easily represented as an easy-to-work-with in-memory tree (like a DOM or similar, but hopefully not XML) for easy transformation and composition;

- Is designed to be composed from smaller pieces, so it's easy to shuffle around subqueries, predicates, etc without messing with the stupidities of "AND" and commas;

- Is capable of expressing the same queries and plans (for easy porting) so it still has inner, left outer, right outer, and full/cross joins, is still relational, still supports grouping, aggregation, windowing, etc;

- Gets rid of all pseudo-function language syntax in favour of using true functions or a generic and extensible expression structure that doesn't require syntax changes for every new feature like CTEs, window functions, etc;

- Is designed WITH THE ACTIVE INVOLVEMENT OF PEOPLE WHO IMPLEMENT JDBC/ODBC DRIVERS, and PEOPLE WHO HAVE IMPLEMENTED LANGUAGE INTEGRATED QUERYING OR CRITERIA APIs. This is a big one. The amount of suffering that SQL causes for JDBC driver developers cannot be understated, and they get off easy compared to the poor individuals who try to produce programmatic query builders/criteria APIs/language integrated querying like JPA 2.0 criteria, LINQ, etc.

- ... and most importantly, because it's a saner way of writing the same queries as SQL, can be transformed into SQL to be sent to backends that don't support it yet, so the chicken-and-egg problem of adoption vs support can be resolved.

Most current efforts like Muldis-D seem to miss the last point - that if you want adoption, you're going to need to be able to transform to SQL in the medium term so people can use it on platforms that don't yet support the new, saner language.


(Log in to post comments)

PostgreSQL and the SQL standards process

Posted Sep 23, 2011 2:30 UTC (Fri) by flewellyn (subscriber, #5047) [Link]

A Lisplike domain-specific language could do what you specify, although the ordering in point 1 wouldn't hold. It'd be prefix notation. If that's acceptable though, Lisp is already known to be easy to parse, transform, compose, and work with functionally.

PostgreSQL and the SQL standards process

Posted Sep 30, 2011 19:04 UTC (Fri) by Baylink (subscriber, #755) [Link]

Very specifically: I'd like to see something that makes it easy to trace queries in, say, "mtop" back to the source code whence they came.

In that vein, and since the proper collection of eyeballs are probably reading the commments to this particular posting, I'd like to propose a device which might or might not work in that context, and get the input of people who know which:

Select $FIELDS from $TABLE where $CONDITIONS *AND NOT GETDATE() equals 1011-03-01* (where the date is some date earlier than today, and specific to each query; it serves as a tag).

Kevin Falcone, who I think is one of the SQL gurus on RT, suggested this would break the query cache, but I'm not sure that's true a) because it would be the same on any given query, and b) because it depends on a function, which can be evaluated away as part of the optimizer (assuming that keeps it from messing up the cache, which I don't know; hence, you folks. :-)

Anyone have an opinion on this, or the larger problem it's aimed at?

PostgreSQL and the SQL standards process

Posted Oct 5, 2011 10:52 UTC (Wed) by Jannes (subscriber, #80396) [Link]

Not sure what you're getting at actually. Why use a function at all, does the GETDATE have any use?

Why not use constants .... AND 0 < 78238923123 (your random tag) ?

And while you're at it, why not just make it a comment? I've used that before to make queries easily identifiable in SHOW PROCESSLIST: (in MySQL)

/* YourTag Function Name blabla */ SELECT * FROM blabla;

The comment has the extra advantage of not affecting the query cache at all (at least in MySQL).

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds