Issue #3 resolved

custom type introspection

Clark C. Evans
created an issue

Via //Gavin Casey//

{{{ When I try to run any query I get the following error

File "build/bdist.linux-x86_64/egg/htsql/ctl/request.py", line 163, in execute response.set(body=''.join(iterator)) File "build/bdist.linux-x86_64/egg/htsql/application.py", line 84, in call body = wsgi(environ, start_response) File "build/bdist.linux-x86_64/egg/htsql/wsgi.py", line 39, in call status, headers, body = request.render(environ) File "build/bdist.linux-x86_64/egg/htsql/request.py", line 138, in render product = self.produce() File "build/bdist.linux-x86_64/egg/htsql/request.py", line 109, in produce plan = self.translate() File "build/bdist.linux-x86_64/egg/htsql/request.py", line 98, in translate binding = bind(syntax) File "build/bdist.linux-x86_64/egg/htsql/tr/bind.py", line 593, in bind bindings = bind_all(syntax, state, base) File "build/bdist.linux-x86_64/egg/htsql/tr/bind.py", line 566, in bind_all bindings = list(bind()) File "build/bdist.linux-x86_64/egg/htsql/tr/bind.py", line 219, in call segment = self.state.bind(self.syntax.segment) File "build/bdist.linux-x86_64/egg/htsql/tr/bind.py", line 145, in bind return bind(syntax, self, base) File "build/bdist.linux-x86_64/egg/htsql/tr/bind.py", line 593, in bind bindings = bind_all(syntax, state, base) File "build/bdist.linux-x86_64/egg/htsql/tr/bind.py", line 566, in bind_all bindings = list(bind()) File "build/bdist.linux-x86_64/egg/htsql/tr/bind.py", line 259, in call base = self.state.bind(self.syntax.base) File "build/bdist.linux-x86_64/egg/htsql/tr/bind.py", line 145, in bind return bind(syntax, self, base) File "build/bdist.linux-x86_64/egg/htsql/tr/bind.py", line 593, in bind bindings = bind_all(syntax, state, base) File "build/bdist.linux-x86_64/egg/htsql/tr/bind.py", line 566, in bind_all bindings = list(bind()) File "build/bdist.linux-x86_64/egg/htsql/tr/bind.py", line 469, in call binding = lookup(self.state.base, self.syntax) File "build/bdist.linux-x86_64/egg/htsql/tr/lookup.py", line 533, in lookup lookup = Lookup(binding, identifier) File "build/bdist.linux-x86_64/egg/htsql/tr/lookup.py", line 115, in init super(Lookup, self).init(binding) File "build/bdist.linux-x86_64/egg/htsql/tr/lookup.py", line 77, in init catalog = introspect() File "build/bdist.linux-x86_64/egg/htsql_pgsql/introspect.py", line 94, in call return self.introspect_catalog() File "build/bdist.linux-x86_64/egg/htsql_pgsql/introspect.py", line 97, in introspect_catalog schemas = self.introspect_schemas() File "build/bdist.linux-x86_64/egg/htsql_pgsql/introspect.py", line 120, in introspect_schemas tables = self.introspect_tables(oid) File "build/bdist.linux-x86_64/egg/htsql_pgsql/introspect.py", line 136, in introspect_tables columns = self.introspect_columns(oid) File "build/bdist.linux-x86_64/egg/htsql_pgsql/introspect.py", line 155, in introspect_columns domain = self.introspect_domain(relid, num) File "build/bdist.linux-x86_64/egg/htsql_pgsql/introspect.py", line 232, in introspect_domain typ = self.meta.pg_type[att.atttypid] KeyError: 0

I do have custom defined domains in my database but that does not appear to be the issue as I have tested this in isolatiion in another db. Could someone please give me some idea where to look next. }}}

Comments (1)

  1. Kirill Simonov

    I believe it's caused by a dropped column which is still in the system catalog.

    To reproduce:

    CREATE TYPE tp AS ...;
    CREATE TABLE T (x tp, ...);
    INSERT ...
    ALTER TABLE T DROP COLUMN x;
    DROP TYPE tp;
    

    Now `pg_catalog.pg_attribute` still contains a record corresponding to the dropped column with a zero reference to `pg_catalog.pg_type`.

    Fixed in f8b8dfc6b304

  2. Log in to comment