Skip to content

Commit

Permalink
Return only user defined indexes from IngresDialect::get_indexes (#60)
Browse files Browse the repository at this point in the history
* Reflect user and system generated indexes
  • Loading branch information
hab6 authored Jul 22, 2024
1 parent d9572d0 commit 87c2cbd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,22 @@ Run (all) tests:

pytest --db ingres_odbc --junit-xml=all_results_junit.xml --maxfail=12000

## Execution Options

### Index Reflection

The default Ingres dialect behavior for index reflection is to return only user-defined indexes.

To inspect all indexes, including those generated by the DBMS, set the connection execution option `inspect_indexes="ALL"`.

Example:

connection.execution_options(inspect_indexes="ALL")
i = sqlalchemy.inspect(connection)
print(i.get_indexes("employee_table"))

Documentation reference [iiindexes catalog](https://docs.actian.com/actianx/12.0/index.html#page/DatabaseAdmin/Standard_Catalogs_for_All_Databases.htm#ww1029558)

## Known Issues

Apache Superset issue [27427](https://github.com/apache/superset/issues/27427)
Expand Down
2 changes: 1 addition & 1 deletion lib/sqlalchemy_ingres/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version_tuple = __version_info__ = (0, 0, 8, "dev0")
version_tuple = __version_info__ = (0, 0, 8, "dev1")
version = version_string = __version__ = '.'.join(map(str, __version_info__))
7 changes: 6 additions & 1 deletion lib/sqlalchemy_ingres/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,11 @@ def get_indexes(self, connection, table_name, schema=None, **kw):
AND i.index_owner = c.index_owner
AND i.base_name = ?"""
params = (self.denormalize_name(table_name),)

if (connection.get_execution_options().get('inspect_indexes') is None or
connection.get_execution_options().get('inspect_indexes').upper() != "ALL"):
sqltext += """
AND i.system_use = 'U'"""

if schema:
sqltext += """
Expand All @@ -816,7 +821,7 @@ def get_indexes(self, connection, table_name, schema=None, **kw):

rs = None
indexes = {}

try:
rs = connection.exec_driver_sql(sqltext, params)

Expand Down

0 comments on commit 87c2cbd

Please sign in to comment.