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

Avoid manipulating search path in table metadata fetch #147

Merged
merged 4 commits into from Dec 11, 2018

Conversation

Projects
None yet
2 participants
@cwegrzyn
Copy link
Contributor

cwegrzyn commented Jun 28, 2018

We've run into some issues with transactions and the way that _get_all_column_info manipulates the search path. The search path manipulation only appears to be necessary because pg_table_def is used-- but pg_table_def is a pretty simple view that we can integrate into the query, minus its pesky search path filter.

For reference, pg_table_def is defined on Redshift as follows:

CREATE OR REPLACE VIEW pg_catalog.pg_table_def AS
SELECT n.nspname AS schemaname, c.relname AS tablename, a.attname AS "column", format_type(a.atttypid, a.atttypmod) AS "type", format_encoding(a.attencodingtype::integer) AS "encoding", a.attisdistkey AS "distkey", a.attsortkeyord AS "sortkey", a.attnotnull AS "notnull"
FROM pg_namespace n, pg_class c, pg_attribute a
WHERE n.oid = c.relnamespace AND c.oid = a.attrelid AND a.attnum > 0 AND NOT a.attisdropped AND pg_table_is_visible(c.oid)
ORDER BY n.nspname, c.relname, a.attnum

pg_table_is_visible is the bit that limits to tables in the search path.

Todos

  • MIT compatible
  • Tests
  • Documentation
  • Updated CHANGES.rst
@cwegrzyn

This comment has been minimized.

Copy link
Contributor

cwegrzyn commented Jul 18, 2018

Hey! I was just wondering about next steps for merging this in. I'd be happy to add an entry to CHANGES. Not sure if new tests/docs are relevant here. We're also bumping into the issue solved by #105, so I'd be happy to update that one to reflect the changes here.

@jklukas
Copy link
Collaborator

jklukas left a comment

Passing integration tests, so this looks great! All we need is a line in CHANGES.rst that describes the change in behavior and links to this PR, and I'll go ahead and merge.

cwegrzyn added some commits Dec 10, 2018

@cwegrzyn

This comment has been minimized.

Copy link
Contributor

cwegrzyn commented Dec 10, 2018

Does that look okay?

@jklukas
Copy link
Collaborator

jklukas left a comment

small typo to fix

Show resolved Hide resolved CHANGES.rst Outdated
Fix typo in CHANGES.rst
Co-Authored-By: cwegrzyn <chris.wegrzyn@gmail.com>
@cwegrzyn

This comment has been minimized.

Copy link
Contributor

cwegrzyn commented Dec 11, 2018

Oops, thanks! Committed

@jklukas jklukas merged commit e60c519 into sqlalchemy-redshift:master Dec 11, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@jklukas

This comment has been minimized.

Copy link
Collaborator

jklukas commented Dec 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment