连接tbase-v5出错处理
最近更新时间: 2024-06-12 15:06:00
这是因为tbase merge了一些postgresql11存储过程的一些特性,我们可以通过定义一个新的pg_proc视图来达到兼容访问,如下所示。
连接到数据库后创建一个兼容的专用schema。
postgres=# create schema tbase_pg_proc; CREATE SCHEMA postgres=# CREATE OR REPLACE VIEW tbase_pg_proc.pg_proc as select *, case when prokind='a' then true else false end as proisagg, case when prokind='w' then true else false end as proiswindow, oid as oid,xmin as xmin,tableoid tableoid from pg_catalog.pg_proc; CREATE VIEW postgres=#
配置用户的搜索路径。
postgres=# alter role tbase set search_path to tbase_pg_proc,pg_catalog,"$user", public; ALTER ROLE postgres=#
再次断开,连接就可以正常访问function了。
适配function和procedure分开。
postgres=# create or replace function tbase_pg_proc.version() returns text as $$ begin return 'PostgreSQL 11.0 TBase V5 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39), 64-bit'; end; $$ language plpgsql;
返回postgresql11版本号就能将procedure和function 分别返回。