Group: pgsql.hackers


Subject: PostGreSQL and recursive queries...
From: tgl@sss.pgh.pa.us (Tom Lane)
Date: 11/30/2007 10:40:58 AM
Gregory Stark <stark@enterprisedb.com> writes: > I could imagine problems the planner would have to deal with though, such as > what type is "bogon" in this query? > WITH RECURSIVE x(bogon) AS (select bogon from x) select * from x; Just a note --- that's not the planner's problem, either. Semantic interpretation of the meaning of a query is supposed to be completed during parse analysis. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq

Subject: PostGreSQL and recursive queries...
From: tgl@sss.pgh.pa.us (Tom Lane)
Date: 11/30/2007 11:37:04 PM
Sam Mason <sam@samason.me.uk> writes: > Sounds as though you need some sort of type inference algorithm. There > are quite a few decidable ones around, the one by Hindley-Milner being > very popular/common. Decidable means you get the correct answer out in > a reasonable amount of time or it fails, and, barring implementation > bugs, it'll never get stuck trying to figure out what you meant. I think some closer reading of the SQL spec might be called for. I'm pretty sure the spec authors did not intend to require any especially abstruse algorithm to infer the types involved in a recursive query. In fact, if they have not completely abandoned their duty as spec writers, the spec itself should spell out any algorithms required to determine the meaning of a query. (As distinct from algorithms needed to produce an efficient implementation, which is a topic outside the purview of the spec. But "what type is this result column" is surely something the spec is required to define.) regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq