Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: rework TypeInfoCache #3062

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

WIP: rework TypeInfoCache #3062

wants to merge 1 commit into from

Conversation

vlsi
Copy link
Member

@vlsi vlsi commented Dec 7, 2023

The idea is to use the recent pg_type fields (e.g. typarray to detect arrays), and ::regclass to parse type names.

The previous code had several drawbacks:

  • Many Map for navigating between oids, names, and other information. It is hard to maintain, and it is hard to invalidate the caches.
  • Lack of support for identifier quoting, and search_path. For instance, = ANY(current_schemas(..)) order by oid limit 1 might produce wrong oids.

The PR uses where oid = ?::regtype approach to lookup types with the full support of identifier quoting.
We do not need that many cache maps, so the invalidation with the new approach would be easier.

This is an early draft, and it might make sense to make PgType into different subclasses. For instance, there might be PgArrayType extends PgType, and PgArray { PgArrayType getType(); }.

TODO:

  • Invalidate type cache on schema_path changes, create, drop statements
  • Make sure the new approach does not generate new roundtrips for known types like int4
  • Fix association of Java class <-> oid
  • Move PgType to a top-level, and add subtypes (e.g. PgArrayType for use in PgArray)

The idea is to use the recent pg_type fields (e.g. typarray to detect arrays),
and ::regclass to parse type names
@@ -2275,7 +2275,8 @@ protected void processResults(ResultHandler handler, int flags, boolean adaptive
// Handle status.
String status = receiveCommandStatus();
if (isFlushCacheOnDeallocate()
&& (status.startsWith("DEALLOCATE ALL") || status.startsWith("DISCARD ALL"))) {
&& (status.startsWith("DEALLOCATE ALL") || status.startsWith("DISCARD ALL")
|| status.startsWith("CREATE ") || status.endsWith("DROP "))) {
deallocateEpoch++;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ends with ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be status.startsWith("DROP ") ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants