mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-04 00:27:19 +02:00
> be a useful function for many users. However, I found the fact that > if connectby_tree has the following data, connectby() tries to search the end > of roots without knowing that the relations are infinite(-5-9-10-11-9-10-11-) . > I hope connectby() supports a check routine to find infinite relations. > > > CREATE TABLE connectby_tree(keyid int, parent_keyid int); > INSERT INTO connectby_tree VALUES(1,NULL); > INSERT INTO connectby_tree VALUES(2,1); > INSERT INTO connectby_tree VALUES(3,1); > INSERT INTO connectby_tree VALUES(4,2); > INSERT INTO connectby_tree VALUES(5,2); > INSERT INTO connectby_tree VALUES(6,4); > INSERT INTO connectby_tree VALUES(7,3); > INSERT INTO connectby_tree VALUES(8,6); > INSERT INTO connectby_tree VALUES(9,5); > > INSERT INTO connectby_tree VALUES(10,9); > INSERT INTO connectby_tree VALUES(11,10); > INSERT INTO connectby_tree VALUES(9,11); <-- infinite > The attached patch fixes the infinite recursion bug in contrib/tablefunc/tablefunc.c:connectby found by Masaru Sugawara. test=# SELECT * FROM connectby('connectby_tree', 'keyid', 'parent_keyid', '2', 4, '~') AS t(keyid int, parent_keyid int, level int, branch text); keyid | parent_keyid | level | branch -------+--------------+-------+------------- 2 | | 0 | 2 4 | 2 | 1 | 2~4 6 | 4 | 2 | 2~4~6 8 | 6 | 3 | 2~4~6~8 5 | 2 | 1 | 2~5 9 | 5 | 2 | 2~5~9 10 | 9 | 3 | 2~5~9~10 11 | 10 | 4 | 2~5~9~10~11 (8 rows) test=# SELECT * FROM connectby('connectby_tree', 'keyid', 'parent_keyid', '2', 5, '~') AS t(keyid int, parent_keyid int, level int, branch text); ERROR: infinite recursion detected I implemented it by checking the branch string for repeated keys (whether or not the branch is returned). The performance hit was pretty minimal -- about 1% for a moderately complex test case (220000 record table, 9 level tree with 3800 members). Joe Conway |
||
---|---|---|
.. | ||
array | ||
btree_gist | ||
chkpass | ||
cube | ||
dbase | ||
dblink | ||
dbmirror | ||
dbsize | ||
earthdistance | ||
findoidjoins | ||
fulltextindex | ||
fuzzystrmatch | ||
intagg | ||
intarray | ||
ipc_check | ||
isbn_issn | ||
lo | ||
ltree | ||
mac | ||
miscutil | ||
mSQL-interface | ||
mysql | ||
noupdate | ||
oid2name | ||
oracle | ||
pg_dumplo | ||
pg_logger | ||
pg_upgrade | ||
pgbench | ||
pgcrypto | ||
pgstattuple | ||
reindexdb | ||
retep | ||
rserv | ||
rtree_gist | ||
seg | ||
spi | ||
start-scripts | ||
string | ||
tablefunc | ||
tips | ||
tools | ||
tsearch | ||
userlock | ||
vacuumlo | ||
xml | ||
contrib-global.mk | ||
Makefile | ||
README |
The PostgreSQL contrib tree --------------------------- This subtree contains porting tools, analysis utilities, and plug-in features that are not part of the core PostgreSQL system, mainly because they address a limited audience or are too experimental to be part of the main source tree. This does not preclude their usefulness. Each subdirectory contains a README file with information about the module. Most items can be built with `gmake all' and installed with `gmake install' in the usual fashion, after you have run the `configure' script in the top-level directory. Some directories supply new user-defined functions, operators, or types. After you have installed the files you need to register the new entities in the database system by running the commands in the supplied .sql file. For example, $ psql -d dbname -f module.sql See the PostgreSQL documentation for more information about this procedure. Index: ------ array - Array iterator functions by Massimo Dal Zotto <dz@cs.unitn.it> btree_gist - Support for emulating BTREE indexing in GiST by Oleg Bartunov <oleg@sai.msu.su> and Teodor Sigaev <teodor@stack.net> chkpass - An auto-encrypted password datatype by D'Arcy J.M. Cain <darcy@druid.net> cube - Multidimensional-cube datatype (GiST indexing example) by Gene Selkov, Jr. <selkovjr@mcs.anl.gov> dbase - Converts from dbase/xbase to PostgreSQL by Maarten.Boekhold <Maarten.Boekhold@reuters.com>, Frank Koormann <fkoorman@usf.uni-osnabrueck.de>, Ivan Baldo <lubaldo@adinet.com.uy> dblink - Allows remote query execution by Joe Conway <mail@joeconway.com> dbmirror - Replication server by Steven Singer <ssinger@navtechinc.com> dbsize - Reports database and table disk space by Peter Eisentraut <peter_e@gmx.net> earthdistance - Operator for computing earth distance for two points by Hal Snyder <hal@vailsys.com> findoidjoins - Finds the joins used by oid columns by examining the actual values in the oid columns and row oids. by Bruce Momjian <pgman@candle.pha.pa.us> fulltextindex - Full text indexing using triggers by Maarten Boekhold <maartenb@dutepp0.et.tudelft.nl> fuzzystrmatch - Levenshtein, metaphone, and soundex fuzzy string matching by Joe Conway <mail@joeconway.com>, Joel Burton <jburton@scw.org> intagg - Integer aggregator by mlw <markw@mohawksoft.com> intarray - Index support for arrays of int4, using GiST by Teodor Sigaev <teodor@stack.net> and Oleg Bartunov <oleg@sai.msu.su> ipc_check - Simple test script to help in configuring IPC. FreeBSD only, for now. isbn_issn - PostgreSQL type extensions for ISBN (books) and ISSN (serials) by Garrett A. Wollman <wollman@khavrinen.lcs.mit.edu> lo - Large Object maintenance by Peter Mount <peter@retep.org.uk> ltree - Tree-like data structures by Teodor Sigaev <teodor@stack.net> and Oleg Bartunov <oleg@sai.msu.su> mSQL-interface - mSQL API translation library by Aldrin Leal <aldrin@americasnet.com> mac - Support functions for MAC address types by Lawrence E. Rosenman <ler@lerctr.org> miscutil - PostgreSQL assert checking and various utility functions by Massimo Dal Zotto <dz@cs.unitn.it> mysql - Utility to convert MySQL schema dumps to SQL92 and PostgreSQL by Thomas Lockhart <lockhart@alumni.caltech.edu> Max Rudensky <fonin@ziet.zhitomir.ua> Valentine Danilchuk <valdan@ziet.zhitomir.ua> noupdate - Trigger to prevent updates on single columns oid2name - Maps numeric files to table names by B Palmer <bpalmer@crimelabs.net> oracle - Converts Oracle database schema to PostgreSQL by Gilles Darold <gilles@darold.net> pg_dumplo - Dump large objects by Karel Zak <zakkr@zf.jcu.cz> pg_logger - Stdin-to-syslog gateway for PostgreSQL by Nathan Myers <ncm@nospam.cantrip.org> pg_upgrade - Upgrade from previous PostgreSQL version without pg_dump/reload by Bruce Momjian <pgman@candle.pha.pa.us> pgbench - TPC-B like benchmarking tool by Tatsuo Ishii <t-ishii@sra.co.jp> pgcrypto - Cryptographic functions by Marko Kreen <marko@l-t.ee> reindexdb - Reindexes a database by Shaun Thomas <sthomas@townnews.com> pgstattuple - A function returns the percentage of "dead" tuples in a table by Tatsuo Ishii <t-ishii@sra.co.jp> retep - Tools to build retep tools packages by Peter T Mount <peter@retep.org.uk> rserv - Replication server by Vadim B. Mikheev <vadim4o@email.com> rtree_gist - Support for emulating RTREE indexing in GiST by Oleg Bartunov <oleg@sai.msu.su> and Teodor Sigaev <teodor@stack.net> seg - Confidence-interval datatype (GiST indexing example) by Gene Selkov, Jr. <selkovjr@mcs.anl.gov> spi - Various trigger functions, examples for using SPI. start-scripts - Scripts for starting the server at boot time. string - C-like input/output conversion routines for strings by Massimo Dal Zotto <dz@cs.unitn.it> tablefunc - Examples of functions returning tables by Joe Conway <mail@joeconway.com> tips/apache_logging - Getting Apache to log to PostgreSQL by Terry Mackintosh <terry@terrym.com> tools - Assorted developer tools by Massimo Dal Zotto <dz@cs.unitn.it> tsearch - Full-text-index support using GiST by Teodor Sigaev <teodor@stack.net> and Oleg Bartunov <oleg@sai.msu.su>. userlock - User locks by Massimo Dal Zotto <dz@cs.unitn.it> vacuumlo - Remove orphaned large objects by Peter T Mount <peter@retep.org.uk> xml - Storing XML in PostgreSQL by John Gray <jgray@azuli.co.uk>