ankane / dexter

The automatic indexer for Postgres
MIT License
1.9k stars 47 forks source link

syntax error at or near "MATERIALIZED" #35

Closed tobwen closed 4 years ago

tobwen commented 4 years ago

error

SQL: SELECT * FROM pg_available_extensions WHERE name = 'hypopg' AND installed_version IS NOT NULL
SQL: SET lock_timeout = '5s'
Started
Processing 1 new query fingerprints
SQL: SELECT hypopg_reset()
SQL: SELECT table_schema || '.' || table_name AS table_name FROM information_schema.tables WHERE table_catalog = current_database()
SQL: SHOW server_version_num
SQL: SELECT schemaname || '.' || matviewname AS table_name FROM pg_matviews
SQL: SELECT current_schemas(true)
SQL: SELECT schemaname || '.' || viewname AS table_name, definition FROM pg_views WHERE schemaname NOT IN ('information_schema', 'pg_catalog')
Traceback (most recent call last):
        15: from /usr/local/bin/dexter:23:in `<main>'
        14: from /usr/local/bin/dexter:23:in `load'
        13: from /var/lib/gems/2.5.0/gems/pgdexter-0.3.7/exe/dexter:7:in `<top (required)>'
        12: from /var/lib/gems/2.5.0/gems/pgdexter-0.3.7/lib/dexter/client.rb:8:in `start'
        11: from /var/lib/gems/2.5.0/gems/pgdexter-0.3.7/lib/dexter/client.rb:33:in `perform'
        10: from /var/lib/gems/2.5.0/gems/pgdexter-0.3.7/lib/dexter/processor.rb:53:in `perform'
         9: from /var/lib/gems/2.5.0/gems/pgdexter-0.3.7/lib/dexter/processor.rb:59:in `process_queries'
         8: from /var/lib/gems/2.5.0/gems/pgdexter-0.3.7/lib/dexter/processor.rb:59:in `synchronize'
         7: from /var/lib/gems/2.5.0/gems/pgdexter-0.3.7/lib/dexter/processor.rb:60:in `block in process_queries'
         6: from /var/lib/gems/2.5.0/gems/pgdexter-0.3.7/lib/dexter/processor.rb:76:in `process_queries_without_lock'
         5: from /var/lib/gems/2.5.0/gems/pgdexter-0.3.7/lib/dexter/indexer.rb:60:in `process_queries'
         4: from /var/lib/gems/2.5.0/gems/pgdexter-0.3.7/lib/dexter/indexer.rb:598:in `database_view_tables'
         3: from /var/lib/gems/2.5.0/gems/pgdexter-0.3.7/lib/dexter/indexer.rb:598:in `each'
         2: from /var/lib/gems/2.5.0/gems/pgdexter-0.3.7/lib/dexter/indexer.rb:599:in `block in database_view_tables'
         1: from /var/lib/gems/2.5.0/gems/pg_query-1.2.0/lib/pg_query/parse.rb:5:in `parse'
/var/lib/gems/2.5.0/gems/pg_query-1.2.0/lib/pg_query/parse.rb:5:in `_raw_parse': syntax error at or near "MATERIALIZED" (scan.l:1121) (PgQuery::ParseError)

how to reproduce

$ psql -U tobwen -d test -c 'CREATE TABLE ratings AS SELECT 3 AS user_id;'
$ echo 'LOG:  duration: 14.077 ms  statement: SELECT * FROM ratings WHERE user_id = 3;' > test.log
$ cat test.log | dexter -U tobwen -d test --log-sql --log-level debug2

environment

ankane commented 4 years ago

Hey @tobwen, thanks for reporting! It looks like Dexter is having trouble parsing one of the view definitions (not sure why on the of the views returned from pg_views would have MATERIALIZED in it). I pushed a change to log when this happens so it no longer throws an error. An updated Debian package should be available shortly so you can try it.

ankane commented 4 years ago

It looks like there's currently an error with the packaging service. Will let you know when a new version is available.

ankane commented 4 years ago

New package is published.

tobwen commented 4 years ago

You did it. Thanks a lot!