> 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
> where more than one schema is in use, because it doesn't trouble to
> schema-qualify table names.
Ok, the following patch should solve this concern. It also tries to
connect as little times as possible (the previous one would connect one
time per table plus one per database; this one connects two times per
database).
Alvaro Herrera
for contrib/intarray.
The cause was that the library uses its own function to construct a new
array, new_intArrayType, and that function did not set the new array
struct attribute elemtype.
Joe Conway
that are explicitly JOINed are not considered dependencies unless they
are actually used in the query: mere presence in the joinaliasvars
list of a JOIN RTE doesn't count as being used. The patch touches
a number of files because I needed to generalize the API of
query_tree_walker to support an additional flag bit, but the changes
are otherwise quite small.
- Properly drop tables in jdbc regression tests with cascade for 7.3
- problem with Statement.execute() and executeUpdate() not clearing binds
- problem with ResultSet not correctly handling default encoding
- changes to correctly support show transaction isolation level in 7.3
- changed DatabaseMetaDataTest to handle differences in FK names in 7.3
- better fix for dynamically checking server NAME data length
(With the fixes above the jdbc regression tests pass on jdbc2 and jdbc3
against both a 7.2 and 7.3 server)
Patchs submitted by David Wall (d.wall@computer.org):
- problem with getBlob when largeobject oid is null
- improvements to BlobOutputStream
Patch submitted by Haris Peco (snpe@snpe.co.yu):
- problem with callable statement not supporting prepared statement methods
Modified Files:
jdbc/org/postgresql/Driver.java.in
jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java
jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java
jdbc/org/postgresql/jdbc2/Jdbc2ResultSet.java
jdbc/org/postgresql/jdbc3/Jdbc3ResultSet.java
jdbc/org/postgresql/largeobject/BlobOutputStream.java
jdbc/org/postgresql/largeobject/LargeObject.java
jdbc/org/postgresql/test/TestUtil.java
jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java
jdbc/org/postgresql/test/jdbc2/optional/BaseDataSourceTest.java
jdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java
jdbc/org/postgresql/test/jdbc2/optional/SimpleDataSourceTest.java
never been the correct procedure for locking a relation, and the
recently-found ALTER TABLE bug with adding a constraint and a toast
table in the same command shows why it's a bad idea.