Issue #7 resolved

oracle htsql exception at assert name not in table.columns

Anonymous created an issue

{{{

!python

Traceback (most recent call last): File "/usr/bin/htsql-ctl", line 9, in <module> load_entry_point('HTSQL==2.2.1', 'console_scripts', 'htsql-ctl')() File "/usr/lib/python2.6/dist-packages/htsql_ctl/init.py", line 60, in main return ctl.main(sys.argv) File "/usr/lib/python2.6/dist-packages/htsql_ctl/script.py", line 202, in main return routine.run() File "/usr/lib/python2.6/dist-packages/htsql_ctl/shell.py", line 974, in run self.state.app = HTSQL(db, extensions) File "/usr/lib/python2.6/dist-packages/htsql/application.py", line 138, in init addon.validate() File "/usr/lib/python2.6/dist-packages/htsql/init.py", line 113, in validate introspect() File "/usr/lib/python2.6/dist-packages/htsql/cache.py", line 45, in wrapper value = service(args, **kwds) File "/usr/lib/python2.6/dist-packages/htsql/introspect.py", line 87, in introspect catalog = introspect() File "/usr/lib/python2.6/dist-packages/htsql/introspect.py", line 40, in IntrospectCleanup.call catalog = super(IntrospectCleanup, self).call() File "/usr/lib/python2.6/dist-packages/htsql_engine/oracle/introspect.py", line 126, in IntrospectOracle.call table.add_column(name, domain, is_nullable, has_default) File "/usr/lib/python2.6/dist-packages/htsql/entity.py", line 231, in add_column is_nullable, has_default) File "/usr/lib/python2.6/dist-packages/htsql/entity.py", line 298, in init assert name not in table.columns }}}

Comments (9)

  1. Kirill Simonov
    • changed status to open

    Could you possibly give me the output of the query:

    SELECT * FROM all_tab_columns c
    WHERE (SELECT COUNT(*) FROM all_tab_columns d WHERE d.owner = c.owner AND d.table_name = c.table_name AND d.column_name = c.column_name) > 1
    
  2. Anonymous

    some test data may help us.

    select * from ALL_TAB_COLUMNS c where c.OWNER = 'TEST1'
    

    this query work ok.return data.

    TEST1	ANNO_MESSAGE	ANNO_ID
    TEST1	ANNO_MESSAGE	ANNO_USERID
    TEST1	ANNO_MESSAGE	DZZ_ID
    TEST1	ANNO_MESSAGE	ANNO_TITLE
    
    !sql
    select OWNER ,TABLE_NAME,COLUMN_NAME, 
    (select COUNT(*) from ALL_TAB_COLUMNS D where D.OWNER = C.OWNER and D.TABLE_NAME = C.TABLE_NAME and D.COLUMN_NAME = C.COLUMN_NAME) as total
    from ALL_TAB_COLUMNS C
    where owner = 'TEST1' ;
    

    this query return data,note,total column always return 1. TEST1 ANNO_MESSAGE ANNO_ID 1 TEST1 ANNO_MESSAGE ANNO_USERID 1 TEST1 ANNO_MESSAGE DZZ_ID 1 TEST1 ANNO_MESSAGE ANNO_TITLE 1 TEST1 ANNO_MESSAGE ANNO_CONTENT 1 TEST1 ANNO_MESSAGE ANNO_TIME 1 TEST1 ANNO_MESSAGE SEND_ORG 1 , so,the query is not work as expect.

  3. Kirill Simonov

    This is strange. The only way I could see this error triggered is when `ALL_TAB_COLUMNS` contains duplicate records.

    Could you patch the file `/usr/lib/python2.6/dist-packages/htsql/entity.py` replacing the line

        assert name not in table.columns
    

    with

        assert name not in table.columns, (table, name)
    

    and run it again? This should report the table and the column name of the duplicate record.

    Also, how did you start htsql?

  4. Anonymous

    Oh. a good news,I detected problem.

    I simply add a print name and print table before assert.and run again, then i saw code stopped at which column.

    The problem is I have a view with five Unicode column name(Chinese).

    Can I do some job fix this Unicode problem?

  5. Kirill Simonov

    HTSQL supports Unicode column names, but for Oracle, environment variable NLS_LANG should be set to a correct value. Try to assign

    $ export NLS_LANG=.UTF8
    

    before starting HTSQL.

  6. Anonymous

    Thanks a lot, problem solved.

    The idea of this project is really good, I love it,and I can do some to improve it.

  7. Log in to comment