python-postgres / be

pg-python: Execute Python 3 code from PostgreSQL functions.
Other
5 stars 2 forks source link

Anonymous Composite Cache #5

Closed jwp closed 14 years ago

jwp commented 14 years ago

Postgres.Statement and Postgres.Function will create anonymous composite types to manage their return value. In cases where the function module needs to be reloaded, often a new TupleDesc will be blessed even though it's the same as it was before. In Postgres.Statement's case, no blessing occurs and the user is forced to deal with the limitations.

In order to compensate for potential leaks in such edge cases, a hash should be used to identify an existing blessed composite that suites the need of a given Postgres.Statement or Postgres.Function.

jwp commented 14 years ago

Partially complete. Adding tests. It's nice to be able to compare Postgres.Statement() results.

jwp commented 14 years ago

Implement an anonymous composite cache.

By using an explicit cache for anonymous composites, it allows re-use of blessed TupleDesc's. This is important to mitigate leaks in certain situations such as table returning functions and now Postgres.Statement's.

In statement's case, fully anonymous TupleDesc's were being used. This makes working with the resulting DatumTuples rather difficult as the standard operators cannot be used with records that do reference a blessed TupleDesc.

The misfortune here is that Postgres.Statement will never release the output type when the statement returns rows.

closed by 65c88603d008f66ff8dbab88f365411d06bab37a