先获取alter/drop/create的表名和模式名
create or replace function public.get_tablen_scheman
(in _Qry_1 text,in op_type text)
returns VOID
LANGUAGE plpgsql
as $$
declare
table_n text;
schema_n text;
--_Qry_2 text =replace(lower(_Qry_1),CHR(10),' ');
_Qry_2 text =trim(lower(_Qry_1));
begin
if position(CHR(10) in _Qry_2)<>0 or position(chr(13) in _Qry_2)<>0then
_Qry_2=replace(_Qry_2,chr(10),'');
_Qry_2=replace(_Qry_2,chr(13),'');
end if;
if op_type='CREATE TABLE' and position('create' in _Qry_2)=1 then
if position('as' in _Qry_2)=0 then
if position('exists'in _Qry_2)=0 then
if position('.'in _Qry_2)=0 then
table_n=trim(substring(_Qry_2,min(position('table' in _Qry_2))+6,min(position('(' in _Qry_2))-min(position('table'in _Qry_2))-6));
schema_n='public';
elseif position('.'in _Qry_2)<>0 then
table_n=trim(substring(_Qry_2,min(position('.' in _Qry_2))+1,min(position('(' in _Qry_2))-min(position('.'in _Qry_2))-1));
schema_n=trim(substring(_Qry_2,min(position('table' in _Qry_2))+6,min(position('.' in _Qry_2))-min(position('table'in _Qry_2))-6));
end if;
elseif position('exists'in _Qry_2)<>0 then
if position('.'in _Qry_2)=0 then
table_n=trim(substring(_Qry_2,position('exists' in _Qry_2)+7,min(position('(' in _Qry_2))-position('exists'in _Qry_2)-7));
schema_n='public';
elseif position('.'in _Qry_2)<>0 then
table_n=trim(substring(_Qry_2,min(position('.' in _Qry_2))+1,min(position('(' in _Qry_2))-min(position('.'in _Qry_2))-1));
schema_n=trim(substring(_Qry_2,position('exists' in _Qry_2)+7,min(position('.' in _Qry_2))-position('exists'in _Qry_2)-7));
end if;
end if;
elseif position('as'in _Qry_2)<>0 then
if position('exists'in _Qry_2)=0 then
if position('.'in _Qry_