execute procedure ifx_allow_newline('t');

update sysbldobjects set create_sql =
"create constructor type TimeSeries(
        internallength = variable,
        maxlen = 2048,
        alignment = 8
);

" 
where obj_signature = "TimeSeries" and obj_kind = 7;

update sysbldobjects set create_sql =
"create opaque type TimeSeriesAggState(
        internallength = variable,
        maxlen = 2048,
        alignment = 8
);

" 
where obj_signature = "TimeSeriesAggState" and obj_kind = 7;

update sysxtdtypes set align = 8 
where name = "timeseries" or name = "timeseriesaggstate";



delete from sysbldobjects where
obj_signature like 'Alter-ExternalName-Destroy%' or
obj_signature like 'Alter-ExternalName-ts_vtam_close%' or
obj_signature like 'Alter-ExternalName-ts_vtam_scancost%';

delete from sysbldobjdepends where
obj_signature like 'Alter-ExternalName-Destroy%' or
obj_signature like 'Alter-ExternalName-ts_vtam_close%' or
obj_signature like 'Alter-ExternalName-ts_vtam_scancost%';


delete from sysbldobjects where
obj_signature = 'instanceid_bigint';

delete from sysbldobjdepends where
obj_signature = 'instanceid_bigint';

delete from sysbldobjects where bld_id like 'TimeSeries.6.00.%C1' and
obj_signature like 'Alter%TSL_InsCache%';

delete from sysbldobjdepends where bld_id like 'TimeSeries.6.00.%C1' and
obj_signature like 'Alter%TSL_InsCache%';

delete from sysbldobjects where bld_id like 'TimeSeries.6.00.%C1' and
obj_signature like 'Alter%TSL_UpdCache%';

delete from sysbldobjdepends where bld_id like 'TimeSeries.6.00.%C1' and
obj_signature like 'Alter%TSL_UpdCache%';

update sysbldobjects set drop_sql =
"drop procedure TSL_InsCache (varchar (128),varchar (128),lvarchar,bigint,smallint,datetime year to fraction(5),varchar (128),varchar (128));"
where bld_id like 'TimeSeries.6.00.%C1' and obj_kind = 6 and
obj_signature like 'TSL_InsCache%';

update sysbldobjects set drop_sql =
"drop procedure TSL_UpdCache (varchar (128),varchar (128),lvarchar,bigint,smallint,datetime year to fraction(5),varchar (128),varchar (128));"
where bld_id like 'TimeSeries.6.00.%C1' and obj_kind = 6 and
obj_signature like 'TSL_UpdCache%';

update sysbldobjects set drop_sql =
"DROP FUNCTION TSContainerPctUsed(VARCHAR(128), integer);
DROP FUNCTION TSContainerNElems(VARCHAR(128), integer);
DROP FUNCTION TSContainerTotalPages(VARCHAR(128), integer);
DROP FUNCTION TSContainerTotalUsed(VARCHAR(128), integer);
DROP FUNCTION TSContainerUsage(VARCHAR(128), integer);

"
where bld_id like 'TimeSeries.6.00.%C1' and obj_signature = 'ContainerUsage';

update sysbldobjects set drop_sql = " "
where bld_id like 'TimeSeries.6.00.%C1' and obj_signature = 'tscontainerwindowtable';


delete from sysbldobjects where (bld_id like 'TimeSeries.6.00.%C1' or
bld_id like 'TimeSeries.6.00.%C2' or bld_id like 'TimeSeries.6.00.%C1X%' or
bld_id like 'TimeSeries.6.00.%C2X%' or bld_id like 'TimeSeries.5.%') and
obj_kind = 181;

delete from sysbldobjdepends where  (bld_id like 'TimeSeries.6.00.%C1' or
bld_id like 'TimeSeries.6.00.%C2' or bld_id like 'TimeSeries.6.00.%C1X%' or
bld_id like 'TimeSeries.6.00.%C2X%' or bld_id like 'TimeSeries.5.%') and
( obj_kind = 181 or need_obj_kind = 181);

delete from sysbldobjdepends where obj_signature = 'tscontainertable_pool' and
need_obj_signature in ('tscontainertable_128','tscontainertable_triggers');

update sysbldobjects set drop_sql = 
"ALTER TABLE tscontainertable MODIFY (name VARCHAR(128, 1) NOT NULL PRIMARY KEY, subtype VARCHAR(128,1) NOT NULL);"
where obj_signature = "tscontainertable_128";

