Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 94DFB65036E; Thu, 24 Jul 2008 21:17:20 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 78657-01-5; Thu, 24 Jul 2008 21:16:42 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from fetter.org (start.fetter.org [66.92.188.65]) by postgresql.org (Postfix) with ESMTP id 4236C65034B; Thu, 24 Jul 2008 21:15:16 -0300 (ADT) Received: by fetter.org (Postfix, from userid 500) id B616DFBC8C0; Thu, 24 Jul 2008 17:15:13 -0700 (PDT) Date: Thu, 24 Jul 2008 17:15:13 -0700 From: David Fetter To: Tatsuo Ishii Cc: tgl@sss.pgh.pa.us, pgsql-patches@postgresql.org, pgsql-hackers@postgresql.org, y-asaba@sraoss.co.jp Subject: Re: [PATCHES] WITH RECUSIVE patches 0723 Message-ID: <20080725001513.GF16438@fetter.org> References: <20080723.225435.55841946.t-ishii@sraoss.co.jp> <15216.1216825160@sss.pgh.pa.us> <20080724010550.GA1938@fetter.org> <20080724.135537.44977938.t-ishii@sraoss.co.jp> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ReaqsoxgOBHFXBhH" Content-Disposition: inline In-Reply-To: <20080724.135537.44977938.t-ishii@sraoss.co.jp> User-Agent: Mutt/1.5.18 (2008-05-17) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200807/1155 X-Sequence-Number: 121415 --ReaqsoxgOBHFXBhH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jul 24, 2008 at 01:55:37PM +0900, Tatsuo Ishii wrote: > > Program received signal SIGSEGV, Segmentation fault. > > Thanks for the report. Here is the new patches from Yoshiyuki. Thanks for the patch :) Now, I get a different problem, this time with the following code intended to materialize paths on the fly and summarize down to a certain depth in a tree: CREATE TABLE tree( id INTEGER PRIMARY KEY, parent_id INTEGER REFERENCES tree(id) ); INSERT INTO tree VALUES (1, NULL), (2, 1), (3,1), (4,2), (5,2), (6,2), (7,3), (8,3), (9,4), (10,4), (11,7), (12,7), (13,7), (14, 9), (15,11), (16,11); WITH RECURSIVE t(id, path) AS ( VALUES(1,ARRAY[NULL::integer]) UNION ALL SELECT tree.id, t.path || tree.id FROM tree JOIN t ON (tree.parent_id = t.id) ) SELECT t1.id, count(t2.*) FROM t t1 JOIN t t2 ON ( t1.path[1:2] = t2.path[1:2] AND array_upper(t1.path,1) = 2 AND array_upper(t2.path,1) > 2 ) GROUP BY t1.id; ERROR: unrecognized node type: 203 Please apply the attached patch to help out with tab completion in psql. Cheers, David. -- David Fetter http://fetter.org/ Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter Skype: davidfetter XMPP: david.fetter@gmail.com Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate --ReaqsoxgOBHFXBhH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="wr_tab_complete.patch" *** a/src/bin/psql/tab-complete.c --- b/src/bin/psql/tab-complete.c *************** *** 613,621 **** psql_completion(char *text, int start, int end) "COMMENT", "COMMIT", "COPY", "CREATE", "DEALLOCATE", "DECLARE", "DELETE FROM", "DISCARD", "DROP", "END", "EXECUTE", "EXPLAIN", "FETCH", "GRANT", "INSERT", "LISTEN", "LOAD", "LOCK", "MOVE", "NOTIFY", "PREPARE", ! "REASSIGN", "REINDEX", "RELEASE", "RESET", "REVOKE", "ROLLBACK", "SAVEPOINT", "SELECT", "SET", "SHOW", "START", "TRUNCATE", "UNLISTEN", ! "UPDATE", "VACUUM", "VALUES", NULL }; static const char *const backslash_commands[] = { --- 613,621 ---- "COMMENT", "COMMIT", "COPY", "CREATE", "DEALLOCATE", "DECLARE", "DELETE FROM", "DISCARD", "DROP", "END", "EXECUTE", "EXPLAIN", "FETCH", "GRANT", "INSERT", "LISTEN", "LOAD", "LOCK", "MOVE", "NOTIFY", "PREPARE", ! "REASSIGN", "RECURSIVE", "REINDEX", "RELEASE", "RESET", "REVOKE", "ROLLBACK", "SAVEPOINT", "SELECT", "SET", "SHOW", "START", "TRUNCATE", "UNLISTEN", ! "UPDATE", "VACUUM", "VALUES", "WITH", NULL }; static const char *const backslash_commands[] = { *************** *** 2044,2049 **** psql_completion(char *text, int start, int end) --- 2044,2058 ---- pg_strcasecmp(prev2_wd, "ANALYZE") == 0)) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL); + /* WITH [RECURSIVE] */ + else if (pg_strcasecmp(prev_wd, "WITH") == 0) + { + static const char *const list_WITH[] = + {"RECURSIVE", NULL}; + + COMPLETE_WITH_LIST(list_WITH); + } + /* ANALYZE */ /* If the previous word is ANALYZE, produce list of tables */ else if (pg_strcasecmp(prev_wd, "ANALYZE") == 0) --ReaqsoxgOBHFXBhH--