123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- # Copyright Materialize, Inc. and contributors. All rights reserved.
- #
- # Use of this software is governed by the Business Source License
- # included in the LICENSE file at the root of this repository.
- #
- # As of the Change Date specified in that file, in accordance with
- # the Business Source License, use of this software will be governed
- # by the Apache License, Version 2.0.
- reset-server
- # regclass
- statement OK
- create schema s
- statement ok
- CREATE TABLE t(i int);
- statement ok
- CREATE TABLE s.t(i int);
- statement ok
- CREATE DATABASE d;
- statement ok
- CREATE TABLE d.public.t();
- statement ok
- CREATE MATERIALIZED VIEW m AS SELECT * FROM t;
- statement ok
- CREATE MATERIALIZED VIEW s.m AS SELECT * FROM s.t;
- query T
- SELECT 't'::regclass::oid::int
- ----
- 20190
- query T
- SELECT 's.t'::regclass::oid::int
- ----
- 20191
- query T
- SELECT 't'::regclass = 's.t'::regclass
- ----
- false
- query T
- SELECT 'public.t'::regclass::text;
- ----
- t
- query T
- SELECT 't'::regclass::text;
- ----
- t
- query T
- SELECT 's.t'::regclass::text;
- ----
- s.t
- statement ok
- SET search_path = s, public
- query T
- SELECT 's.t'::regclass::text;
- ----
- t
- query T
- SELECT 't'::regclass::oid::int
- ----
- 20191
- query T
- SELECT 'public.t'::regclass::text;
- ----
- public.t
- statement ok
- SET search_path = public
- query T
- SELECT 's.t'::regclass::text;
- ----
- s.t
- query T
- SELECT 'public.t'::regclass::text;
- ----
- t
- query T
- SELECT 'd.public.t'::regclass::text;
- ----
- d.public.t
- query T
- SELECT 'm'::regclass::oid::int
- ----
- 20195
- query T
- SELECT 's.m'::regclass::oid::int
- ----
- 20196
- query T
- SELECT 'm'::regclass = 's.m'::regclass
- ----
- false
- query error db error: ERROR: relation "abs" does not exist
- SELECT 'abs'::regclass
- query error db error: ERROR: relation "dne" does not exist
- SELECT 'dne'::regclass
- statement ok
- CREATE TABLE "2"()
- query T
- SELECT 2::regclass
- ----
- 2
- query T
- SELECT '2'::regclass
- ----
- 2
- # PG supports this
- query error db error: ERROR: string is not a valid identifier: "2"
- SELECT '2'::text::regclass
- query B
- SELECT '"2"'::regclass != 2
- ----
- true
- query T
- SELECT '"2"'::regclass::text
- ----
- 2
- statement ok
- CREATE TABLE "2x"()
- query T
- SELECT '"2x"'::regclass::text
- ----
- 2x
- query error db error: ERROR: relation "dne" does not exist
- SELECT 'dne'::regclass;
- # Check that we handle functions and classes w/ same name
- statement ok
- CREATE TABLE array_length();
- query T
- SELECT 'array_length'::regclass::text;
- ----
- array_length
- query T
- SELECT 'array_length'::regproc::text;
- ----
- array_length
- # Check that we handle types and classes w/ same name
- statement ok
- CREATE TABLE int4();
- query T
- SELECT 'int4'::regclass::text;
- ----
- int4
- query T
- SELECT 'int4'::regtype::text;
- ----
- int4
- query T
- SELECT 'int4'::regclass::oid = 'int4'::regtype::oid;
- ----
- false
- query T
- SELECT 1::regclass
- ----
- 1
- query T
- SELECT 1::int4::regclass
- ----
- 1
- query T
- SELECT 1::oid::regclass
- ----
- 1
- query T
- SELECT 1::oid::regclass::oid
- ----
- 1
- query T
- SELECT '1'::regclass
- ----
- 1
- query T
- SELECT '1'::pg_catalog.regclass
- ----
- 1
- query T
- SELECT '1'::regclass::text
- ----
- 1
- query T
- SELECT 'mz_tables'::regclass::text
- ----
- mz_tables
- query B
- SELECT 'mz_tables'::regclass = (SELECT oid FROM mz_objects WHERE name = 'mz_tables')
- ----
- true
- query B
- SELECT 'mz_tables'::regclass::oid = (SELECT oid FROM mz_objects WHERE name = 'mz_tables')
- ----
- true
- # This shouldn't be an error but seems to be impacted by
- # some evaluation order issue akin to database-issues#4972
- # # Regression for 9194
- # query B
- # select 'mz_tables'::regclass::oid::text::regclass = (SELECT oid FROM mz_objects WHERE name = 'mz_tables')
- # ----
- # true
- query error relation "nonexistent" does not exist
- SELECT 'nonexistent'::regclass
- statement ok
- CREATE TABLE text_to_regclass (a text);
- statement ok
- INSERT INTO text_to_regclass VALUES (NULL), ('mz_tables');
- # Overflows its stack in debug mode
- # query T
- # SELECT a::regclass::text FROM text_to_regclass ORDER BY a
- # ----
- # mz_tables
- # NULL
- # Make sure that there are no classes with duplicate OIDs
- query I
- select oid from (select count(*) as cnt, oid from pg_catalog.pg_class group by oid) where cnt>1
- ----
- query T
- SELECT NULL::regclass::text
- ----
- NULL
- # ensure that all existing types can be cast to their respective names
- statement OK
- select oid, oid::regclass::text from (select oid from pg_catalog.pg_class)
- # ensure that catalog items can be resolved if the active database is invalid
- statement OK
- SET database TO ''
- query T
- SELECT 'mz_tables'::regclass = (SELECT oid FROM mz_objects WHERE name = 'mz_tables')
- ----
- true
- query T
- SELECT 'mz_internal.mz_recent_activity_log'::regclass = (SELECT oid FROM mz_objects WHERE name = 'mz_recent_activity_log')
- ----
- true
- query T
- SELECT 'materialize.public.t'::regclass::oid::int
- ----
- 20190
- query error db error: ERROR: relation "t" does not exist
- SELECT 't'::regclass::oid::int
|