Repository: edgedb/edgedb

Issue:
Postgres protocol conveys zero tables with official 3.0 release
- EdgeDB Version: "3.0+304325b" (docker), "3.0+7d903be" (local)
- EdgeDB CLI Version: 3.3.0+3f6a0a0
- OS Version: docker, osx 13.2.1

Steps to Reproduce:

Try to connect following docs. Connection is successful, but introspection results in no tables.

I did have it working with RC 2 & 4, so I don't think the issue is me.


Discussion:
Using the `psql` cli
```
_example-> \dt+
Did not find any relations.
_example-> \dt
Did not find any relations.
```
```
_example=> SELECT *
	FROM pg_catalog.pg_tables
	WHERE schemaname != 'pg_catalog' AND
    	schemaname != 'information_schema';

   schemaname   |                 tablename                  | tableowner | tablespace | hasindexes | hasrules | hastriggers | rowsecurity
----------------+--------------------------------------------+------------+------------+------------+----------+-------------+-------------
 edgedbinstdata | instdata                                   | postgres   |            | t          | f        | f           | f
 edgedb         | _db_config                                 | postgres   |            | t          | f        | f           | f
 edgedb         | _dml_dummy                                 | postgres   |            | t          | f        | f           | f
 edgedbstd      | ac418a43-1c45-11ee-8c8c-4d24f0cc1e74       | postgres   |            | t          | f        | f           | f
 edgedbstd      | ac46ed03-1c45-11ee-b645-3b3f2ce3873d       | postgres   |            | t          | f        | f           | f
 edgedbstd      | ac4d32e6-1c45-11ee-8a70-8b13be58225a       | postgres   |            | t          | f        | f           | f
 edgedbpub      | d6a5eeb9-1c6e-11ee-9d0b-c59536b98225       | postgres   |            | t          | f        | t           | f
 edgedbpub      | d71d5214-1c6e-11ee-89a9-8339117c4abc       | postgres   |            | t          | f        | f           | f
 edgedbpub      | d6ee4ca5-1c6e-11ee-a741-55fb63108601       | postgres   |            | t          | f        | t           | f
 edgedbpub      | d72233e8-1c6e-11ee-9da5-5d45c6c0e3b5       | postgres   |            | t          | f        | t           | f
 edgedbpub      | d73a1025-1c6e-11ee-9f9d-6947cd642816       | postgres   |            | t          | f        | t           | f
 edgedbpub      | d75fb155-1c6e-11ee-9a2f-a315d9396f1f       | postgres   |            | t          | f        | f           | f
 edgedbpub      | d7604dba-1c6e-11ee-be9c-efb3cd1fa5b4       | postgres   |            | t          | f        | f           | f
 edgedbstd      | acfc1d49-1c45-11ee-a8a1-e9ea02d91602       | postgres   |            | t          | f        | f           | f
 edgedbstd      | ae0b80bd-1c45-11ee-880b-9f236a1f4ac6       | postgres   |            | t          | f        | f           | f
 edgedbstd      | ae0cb4e2-1c45-11ee-8a80-935a082f7450       | postgres   |            | t          | f        | f           | f
 edgedbstd      | ae940c6a-1c45-11ee-9ac0-ff4fd5317f34       | postgres   |            | t          | f        | f           | f
 edgedbstd      | aec1f0ba-1c45-11ee-9b98-b19e9bbb8e1f       | postgres   |            | t          | f        | f           | f
 edgedbstd      | af206de7-1c45-11ee-8c4a-9fe003a0706f       | postgres   |            | t          | f        | f           | f
 edgedbstd      | af662bce-1c45-11ee-8cfa-2b58656cdc8c       | postgres   |            | t          | f        | f           | f
 edgedbstd      | af9781b0-1c45-11ee-9739-5d812050ff66       | postgres   |            | t          | f        | f           | f
 edgedbstd      | afbfd666-1c45-11ee-8b1e-9d0e8c311e99       | postgres   |            | t          | f        | f           | f
 edgedbstd      | afe781c4-1c45-11ee-84f8-6ba9e696ef18       | postgres   |            | t          | f        | f           | f
 edgedbpub      | d760e563-1c6e-11ee-a1a8-917396ca855d       | postgres   |            | t          | f        | f           | f
 edgedbstd      | b013c76f-1c45-11ee-9c3d-3de42f5ceca1       | postgres   |            | t          | f        | f           | f
 edgedbstd      | b0381462-1c45-11ee-bb81-8fe1b008074c       | postgres   |            | t          | f        | f           | f
 edgedbpub      | d74d01e8-1c6e-11ee-ad3a-8fb557d728ab       | postgres   |            | t          | f        | t           | f
 edgedbstd      | b07ce245-1c45-11ee-b93d-69f736011d5b       | postgres   |            | t          | f        | f           | f
 edgedbpub      | d77cb452-1c6e-11ee-a524-91324f126542       | postgres   |            | t          | f        | f           | f
 edgedbstd      | b17de9d7-1c45-11ee-acb2-3185df790bf4       | postgres   |            | t          | f        | f           | f
 edgedbstd      | b1d127ab-1c45-11ee-9418-471d5b917f30       | postgres   |            | t          | f        | f           | f
 edgedbstd      | b26156a4-1c45-11ee-b9db-5578b4fc2ddc       | postgres   |            | t          | f        | f           | f
```
Are these normal/expected results?
I'm also getting the error in WebStorm while trying to discover schema or execute queries:
> Connection was established but closed as invalid.

---

`psql` cli & Beekeeper Studio give me this while executing a query:
> FATAL:  'funcname'

Ah ok. That only happens when I don't quote the table name. I wasn't aware that it was required to quote the table names.
I suspect this is in @aljazerzen's side of the SQL stuff
Duplicate of #5676. Thanks for additional debugging info.
Ah yeah the `psql \d` command bug is duplicated. But I wouldn't expect that to be the same problem as not being able to run any queries in JetBrains IDEs. I assume it uses a different avenue to discover schema as well, but I'm not sure how to confirm that.

Resolving patch:
diff --git a/edb/pgsql/resolver/range_functions.py b/edb/pgsql/resolver/range_functions.py
--- a/edb/pgsql/resolver/range_functions.py
+++ b/edb/pgsql/resolver/range_functions.py
@@ -27,7 +27,426 @@
     'jsonb_array_elements_text': ['value'],
     'jsonb_each': ['key', 'value'],
     'jsonb_each_text': ['key', 'value'],
-    'pg_options_to_table': ['option_name', 'option_value']
+    'pg_available_extension_versions': [
+        'name',
+        'version',
+        'superuser',
+        'trusted',
+        'relocatable',
+        'schema',
+        'requires',
+        'comment',
+    ],
+    'pg_available_extensions': ['name', 'default_version', 'comment'],
+    'pg_config': ['name', 'setting'],
+    'pg_control_checkpoint': [
+        'checkpoint_lsn',
+        'redo_lsn',
+        'redo_wal_file',
+        'timeline_id',
+        'prev_timeline_id',
+        'full_page_writes',
+        'next_xid',
+        'next_oid',
+        'next_multixact_id',
+        'next_multi_offset',
+        'oldest_xid',
+        'oldest_commit_ts_xid',
+        'checkpoint_time',
+        'newest_commit_ts_xid',
+        'oldest_multi_dbid',
+        'oldest_multi_xid',
+        'oldest_active_xid',
+        'oldest_xid_dbid',
+    ],
+    'pg_control_init': [
+        'max_data_alignment',
+        'database_block_size',
+        'blocks_per_segment',
+        'wal_block_size',
+        'bytes_per_wal_segment',
+        'max_identifier_length',
+        'max_index_columns',
+        'max_toast_chunk_size',
+        'large_object_chunk_size',
+        'float8_pass_by_value',
+        'data_page_checksum_version',
+    ],
+    'pg_control_recovery': [
+        'min_recovery_end_lsn',
+        'min_recovery_end_timeline',
+        'backup_start_lsn',
+        'backup_end_lsn',
+        'end_of_backup_record_required',
+    ],
+    'pg_control_system': [
+        'pg_control_version',
+        'catalog_version_no',
+        'system_identifier',
+        'pg_control_last_modified',
+    ],
+    'pg_copy_logical_replication_slot': [
+        'slot_name',
+        'slot_name',
+        'lsn',
+        'slot_name',
+        'lsn',
+        'lsn',
+    ],
+    'pg_copy_physical_replication_slot': [
+        'slot_name',
+        'lsn',
+        'slot_name',
+        'lsn',
+    ],
+    'pg_create_logical_replication_slot': ['slot_name', 'lsn'],
+    'pg_create_physical_replication_slot': ['slot_name', 'lsn'],
+    'pg_cursor': [
+        'name',
+        'statement',
+        'is_holdable',
+        'is_binary',
+        'is_scrollable',
+        'creation_time',
+    ],
+    'pg_event_trigger_ddl_commands': [
+        'classid',
+        'objid',
+        'objsubid',
+        'command_tag',
+        'object_type',
+        'schema_name',
+        'object_identity',
+        'in_extension',
+        'command',
+    ],
+    'pg_event_trigger_dropped_objects': [
+        'classid',
+        'objid',
+        'objsubid',
+        'original',
+        'normal',
+        'is_temporary',
+        'object_type',
+        'schema_name',
+        'object_name',
+        'object_identity',
+        'address_names',
+        'address_args',
+    ],
+    'pg_event_trigger_table_rewrite_oid': ['oid'],
+    'pg_extension_update_paths': ['source', 'target', 'path'],
+    'pg_get_backend_memory_contexts': [
+        'name',
+        'ident',
+        'parent',
+        'level',
+        'total_bytes',
+        'total_nblocks',
+        'free_bytes',
+        'free_chunks',
+        'used_bytes',
+    ],
+    'pg_get_catalog_foreign_keys': [
+        'fktable',
+        'fkcols',
+        'pktable',
+        'pkcols',
+        'is_array',
+        'is_opt',
+    ],
+    'pg_get_keywords': ['word', 'catcode', 'barelabel', 'catdesc', 'baredesc'],
+    'pg_get_multixact_members': ['xid', 'mode'],
+    'pg_get_object_address': ['classid', 'objid', 'objsubid'],
+    'pg_get_publication_tables': ['relid'],
+    'pg_get_replication_slots': [
+        'slot_name',
+        'plugin',
+        'slot_type',
+        'datoid',
+        'temporary',
+        'active',
+        'active_pid',
+        'xmin',
+        'catalog_xmin',
+        'restart_lsn',
+        'confirmed_flush_lsn',
+        'wal_status',
+        'safe_wal_size',
+        'two_phase',
+    ],
+    'pg_get_shmem_allocations': ['name', 'off', 'size', 'allocated_size'],
+    'pg_hba_file_rules': [
+        'line_number',
+        'type',
+        'database',
+        'user_name',
+        'address',
+        'netmask',
+        'auth_method',
+        'options',
+        'error',
+    ],
+    'pg_identify_object': ['type', 'schema', 'name', 'identity'],
+    'pg_identify_object_as_address': ['type', 'object_names', 'object_args'],
+    'pg_last_committed_xact': ['xid', 'timestamp', 'roident'],
+    'pg_lock_status': [
+        'locktype',
+        'database',
+        'relation',
+        'page',
+        'tuple',
+        'virtualxid',
+        'transactionid',
+        'classid',
+        'objid',
+        'objsubid',
+        'virtualtransaction',
+        'pid',
+        'fastpath',
+        'waitstart',
+        'granted',
+        'mode',
+    ],
+    'pg_logical_slot_get_binary_changes': ['lsn', 'xid', 'data'],
+    'pg_logical_slot_get_changes': ['lsn', 'xid', 'data'],
+    'pg_logical_slot_peek_binary_changes': ['lsn', 'xid', 'data'],
+    'pg_logical_slot_peek_changes': ['lsn', 'xid', 'data'],
+    'pg_ls_archive_statusdir': ['name', 'size', 'modification'],
+    'pg_ls_logdir': ['name', 'size', 'modification'],
+    'pg_ls_tmpdir': [
+        'name',
+        'size',
+        'name',
+        'modification',
+        'size',
+        'modification',
+    ],
+    'pg_ls_waldir': ['name', 'size', 'modification'],
+    'pg_mcv_list_items': [
+        'index',
+        'values',
+        'nulls',
+        'frequency',
+        'base_frequency',
+    ],
+    'pg_options_to_table': ['option_name', 'option_value'],
+    'pg_partition_ancestors': ['relid'],
+    'pg_partition_tree': ['relid', 'parentrelid', 'isleaf', 'level'],
+    'pg_prepared_statement': [
+        'name',
+        'statement',
+        'prepare_time',
+        'parameter_types',
+        'from_sql',
+        'generic_plans',
+        'custom_plans',
+    ],
+    'pg_prepared_xact': ['transaction', 'gid', 'prepared', 'ownerid', 'dbid'],
+    'pg_replication_slot_advance': ['slot_name', 'end_lsn'],
+    'pg_sequence_parameters': [
+        'start_value',
+        'minimum_value',
+        'maximum_value',
+        'increment',
+        'cycle_option',
+        'cache_size',
+        'data_type',
+    ],
+    'pg_show_all_file_settings': [
+        'sourcefile',
+        'sourceline',
+        'seqno',
+        'name',
+        'setting',
+        'applied',
+        'error',
+    ],
+    'pg_show_all_settings': [
+        'name',
+        'setting',
+        'unit',
+        'category',
+        'short_desc',
+        'extra_desc',
+        'context',
+        'vartype',
+        'source',
+        'min_val',
+        'max_val',
+        'sourcefile',
+        'sourceline',
+        'pending_restart',
+        'reset_val',
+        'boot_val',
+        'enumvals',
+    ],
+    'pg_show_replication_origin_status': [
+        'local_id',
+        'external_id',
+        'remote_lsn',
+        'local_lsn',
+    ],
+    'pg_stat_file': [
+        'size',
+        'size',
+        'access',
+        'modification',
+        'access',
+        'modification',
+        'change',
+        'change',
+        'creation',
+        'isdir',
+        'creation',
+        'isdir',
+    ],
+    'pg_stat_get_activity': [
+        'datid',
+        'pid',
+        'usesysid',
+        'application_name',
+        'state',
+        'query',
+        'wait_event_type',
+        'wait_event',
+        'xact_start',
+        'query_start',
+        'ssl',
+        'backend_start',
+        'state_change',
+        'client_addr',
+        'client_hostname',
+        'client_port',
+        'backend_xid',
+        'backend_xmin',
+        'query_id',
+        'leader_pid',
+        'gss_enc',
+        'gss_princ',
+        'gss_auth',
+        'ssl_issuer_dn',
+        'ssl_client_serial',
+        'ssl_client_dn',
+        'sslbits',
+        'sslcipher',
+        'sslversion',
+        'backend_type',
+    ],
+    'pg_stat_get_archiver': [
+        'archived_count',
+        'last_archived_wal',
+        'last_archived_time',
+        'failed_count',
+        'last_failed_wal',
+        'last_failed_time',
+        'stats_reset',
+    ],
+    'pg_stat_get_progress_info': [
+        'pid',
+        'datid',
+        'relid',
+        'param1',
+        'param2',
+        'param3',
+        'param4',
+        'param5',
+        'param6',
+        'param7',
+        'param20',
+        'param18',
+        'param17',
+        'param16',
+        'param15',
+        'param14',
+        'param13',
+        'param12',
+        'param11',
+        'param10',
+        'param9',
+        'param8',
+        'param19',
+    ],
+    'pg_stat_get_replication_slot': [
+        'slot_name',
+        'spill_txns',
+        'spill_count',
+        'spill_bytes',
+        'stream_txns',
+        'stream_count',
+        'stream_bytes',
+        'total_txns',
+        'total_bytes',
+        'stats_reset',
+    ],
+    'pg_stat_get_slru': [
+        'name',
+        'blks_zeroed',
+        'blks_hit',
+        'blks_read',
+        'blks_written',
+        'blks_exists',
+        'flushes',
+        'truncates',
+        'stats_reset',
+    ],
+    'pg_stat_get_subscription': [
+        'subid',
+        'relid',
+        'pid',
+        'received_lsn',
+        'last_msg_send_time',
+        'last_msg_receipt_time',
+        'latest_end_lsn',
+        'latest_end_time',
+    ],
+    'pg_stat_get_wal': [
+        'wal_records',
+        'wal_fpi',
+        'wal_bytes',
+        'wal_buffers_full',
+        'wal_write',
+        'wal_sync',
+        'wal_write_time',
+        'wal_sync_time',
+        'stats_reset',
+    ],
+    'pg_stat_get_wal_receiver': [
+        'pid',
+        'status',
+        'receive_start_lsn',
+        'receive_start_tli',
+        'written_lsn',
+        'flushed_lsn',
+        'received_tli',
+        'last_msg_send_time',
+        'last_msg_receipt_time',
+        'latest_end_lsn',
+        'latest_end_time',
+        'slot_name',
+        'sender_host',
+        'sender_port',
+        'conninfo',
+    ],
+    'pg_stat_get_wal_senders': [
+        'pid',
+        'state',
+        'sent_lsn',
+        'write_lsn',
+        'flush_lsn',
+        'replay_lsn',
+        'write_lag',
+        'flush_lag',
+        'replay_lag',
+        'sync_priority',
+        'sync_state',
+        'reply_time',
+    ],
+    'pg_stop_backup': ['lsn', 'labelfile', 'spcmapfile'],
+    'pg_timezone_abbrevs': ['abbrev', 'utc_offset', 'is_ds'],
+    'pg_timezone_names': ['name', 'abbrev', 'utc_offset', 'is_dst'],
+    'pg_walfile_name_offset': ['file_name', 'file_offset'],
+    'pg_xact_commit_timestamp_origin': ['timestamp', 'roident'],
 }
 
 # retrieved with
@@ -36,8 +455,7 @@
     procedures AS (
         SELECT *
         FROM pg_proc
-        WHERE proname NOT ILIKE 'pg\_%'
-          AND proname NOT ILIKE 'ts\_%'
+        WHERE proname NOT ILIKE 'ts\_%'
           AND proname NOT ILIKE '\_%'
           AND proname != 'unnest'
           AND proname != 'aclexplode'


Test patch: