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
Add support for PostgreSQL index storage options, and reflection of index storage options and index access methods #179
Conversation
Add support for specifying PostgreSQL index storage paramters (e.g. fillfactor).
i sure wish PG would stop adding features, but this looks good, will try to merge soon |
Thanks. Tbf, index storage parameters have been around for a long while (since 8.2 by the look of it). |
I've added another patch that add support for reflecting index storage options. |
arg, this is right in my inbox and ive been passing over it - I've milestoned it to 1.0.6: https://bitbucket.org/zzzeek/sqlalchemy/issue/3455/add-postgresql-storage-parameters |
@@ -2607,7 +2624,8 @@ def get_indexes(self, connection, table_name, schema, **kw): | |||
SELECT | |||
i.relname as relname, | |||
ix.indisunique, ix.indexprs, ix.indpred, | |||
a.attname, a.attnum, NULL, ix.indkey%s | |||
a.attname, a.attnum, NULL, ix.indkey%s, | |||
i.reloptions, am.amname |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eek, < 8.5, does this query work perfectly on PG back to the earliest 8.x versions under all circumstances? the reason the SQL for < 8.5 is here is so the many issues we've had with old versions are no longer impacted by new features in our reflection system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK it works back to 8.3.23 at least. good enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I did check, should be fine. All the 8.x versions are now EOL so not sure it's worth keeping the special cases around that much longer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately Amazon Redshift implements an old 8.X version of Postgresql, and the PG dialect is the basis for the redshift dialect so this is still a thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed this breaks code with redshift. Also the reloptions column doesn't exist in database PostgreSQL 8.1 but exists only in database PostgreSQL 8.2 and up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand it, Redshift is a fork of PosgreSQL 8.2. That seems fair enough to fix, I'll look at that.
I don't see a reason why SQLAlchemy should be supporting PostgreSQL 8.1 though, given that it's been EOLed and unsupported since November 2010 (unless another of the forks is based off that version).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I now find it's 8.0.2 (http://docs.aws.amazon.com/redshift/latest/dg/c_redshift-and-postgres-sql.html). I'll amend with that in mind.
It would be good to have a policy on this, perhaps to support 8.0.2 and the currently active versions of PostgreSQL (which are 9.0-9.4 at the moment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I've created a pull request which should fix this. Tested on PostgreSQL 8.0.2 as I don't have access to a Redshift instance.
great pull request thanks very much ! |
Add support for specifying PostgreSQL index storage paramters (e.g.
fillfactor).
See http://www.postgresql.org/docs/9.4/static/sql-createindex.html#SQL-CREATEINDEX-STORAGE-PARAMETERS