Index: openacs-4/packages/acs-kernel/sql/postgresql/utilities-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/utilities-create.sql,v diff -u -N -r1.13 -r1.13.2.1 --- openacs-4/packages/acs-kernel/sql/postgresql/utilities-create.sql 29 Jan 2019 11:30:22 -0000 1.13 +++ openacs-4/packages/acs-kernel/sql/postgresql/utilities-create.sql 11 May 2020 18:51:26 -0000 1.13.2.1 @@ -71,11 +71,28 @@ name text ) RETURNS boolean AS $$ DECLARE + v_schema varchar; + v_tablename varchar; BEGIN - return exists ( - select 1 from pg_class - where relname = name + IF (position('.' in name) = 0) THEN + -- + -- table without a schema name + -- + return exists ( + select 1 from pg_class + where relname = name and pg_table_is_visible(oid)); + ELSE + -- + -- table with schema name + -- + SELECT split_part(name, '.', 1) into v_schema; + SELECT split_part(name, '.', 2) into v_tablename; + return exists ( + select 1 from information_schema.tables + where table_schema = v_schema + and table_name = v_tablename); + END IF; END; $$ LANGUAGE plpgsql;