Index: openacs-4/packages/acs-kernel/acs-kernel.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/acs-kernel.info,v diff -u -N -r1.150.2.25 -r1.150.2.26 --- openacs-4/packages/acs-kernel/acs-kernel.info 12 Apr 2020 08:52:42 -0000 1.150.2.25 +++ openacs-4/packages/acs-kernel/acs-kernel.info 11 May 2020 18:51:26 -0000 1.150.2.26 @@ -9,15 +9,15 @@ f t - + OpenACS Core Team Routines and data models providing the foundation for OpenACS-based Web services. 2017-08-06 OpenACS The OpenACS kernel contains the core datamodel create and drop scripts for such things as objects, groups, parties and the supporting PL/SQL and PL/pgSQL procedures. 3 - + 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; Index: openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.10.0d29-5.10.0d29.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/upgrade/Attic/upgrade-5.10.0d29-5.10.0d29.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.10.0d29-5.10.0d29.sql 11 May 2020 18:51:26 -0000 1.1.2.1 @@ -0,0 +1,31 @@ +-- +-- procedure util__table_exists/1 +-- +CREATE OR REPLACE FUNCTION util__table_exists( + name text +) RETURNS boolean AS $$ +DECLARE + v_schema varchar; + v_tablename varchar; +BEGIN + 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;