{ ************************************************************************* }
{                                                                           }
{  Licensed Materials - Property of IBM and/or HCL                                     }
{                                                                           }
{  IBM Informix Dynamic Server                                              }
{  (c) Copyright IBM Corporation 1996, 2004 All rights reserved.            }
{  (c) Copyright HCL Technologies Ltd. 2017.  All Rights Reserved.             }
{                                                                           }
{ ************************************************************************* }
{                                                                           }
{   Title:      boot930a.sql                                                }
{                                                                           }
{   Description:                                                            }
{       Bootstrapping script for a 9.30 database                            }
{                                                                           }
{ ************************************************************************* }
{                                                                           }
{  ** IMPORTANT - PLEASE READ                                               } 
{                                                                           }
{     All types and routines referenced in this file must be prefixed       }
{     with the user name "informix". E.g., use "informix.boolean"           }
{     and not "boolean"                                                     }
{									    }
{     Also, please follow the formatting conventions!!!                     }
{                                                                           }
{     Please ensure that the identifiers that you choose are <= 18          }
{     characters in length. Otherwise the changes would affect database     }
{     reversion.                                                            }
{                                                                           }
{ ************************************************************************* }

create dba function informix.deepcopy(row) returns row
        external name '(rowdeepcopy)' language C not variant;
create dba function informix.deepcopy(set) returns set
        external name '(collectiondeepcopy)' language C not variant;
create dba function informix.deepcopy(multiset) returns multiset
        external name '(collectiondeepcopy)' language C not variant;
create dba function informix.deepcopy(list) returns list
        external name '(collectiondeepcopy)' language C not variant;

grant execute on function informix.deepcopy(row) to public as informix;
grant execute on function informix.deepcopy(set) to public as informix;
grant execute on function informix.deepcopy(multiset) to public as informix;
grant execute on function informix.deepcopy(list) to public as informix;





---
---	Register builtin java UDRs for Krakatoa
---

create dba procedure sqlj.registerJUDTfuncs(varchar(255)) external name
 'informix.jvp.dbapplet.impl.JarHandler.registerJUDTfuncs(java.lang.String)'
 language java end procedure;

grant execute on procedure sqlj.registerJUDTfuncs(varchar(255))
 to public as sqlj;

create dba procedure sqlj.unregisterJUDTfuncs(varchar(255)) external name
 'informix.jvp.dbapplet.impl.JarHandler.unregisterJUDTfuncs(java.lang.String)'
 language java end procedure;

grant execute on procedure sqlj.unregisterJUDTfuncs(varchar(255)) 
 to public as sqlj;

-- Define gist access method

create dba function informix.gist_create(informix.pointer)
    returns integer
    with (parallelizable)
    external name '(gist_create)'
    language C;

grant execute on function informix.gist_create(informix.pointer) to public as informix ;

create dba function informix.gist_drop(informix.pointer)
    returns integer
    with (parallelizable)
    external name '(gist_drop)' 
    language C;

grant execute on function informix.gist_drop(informix.pointer) to public as informix ;

create dba function informix.gist_open(informix.pointer)
    returns integer
    with (parallelizable)
    external name '(gist_open)' 
    language C;

grant execute on function informix.gist_open(informix.pointer) to public as informix ;

create dba function informix.gist_close(informix.pointer)
    returns integer
    with (parallelizable)
    external name '(gist_close)' 
    language C;

grant execute on function informix.gist_close(informix.pointer) to public as informix ;

create dba function informix.gist_insert(informix.pointer, informix.pointer, informix.pointer)
    returns integer
    with (parallelizable)
    external name '(gist_insert)' 
    language C;

grant execute on function informix.gist_insert(informix.pointer, informix.pointer, informix.pointer) to public as informix ;

create dba function informix.gist_update(informix.pointer, informix.pointer, informix.pointer, informix.pointer, informix.pointer)
    returns integer
    with (parallelizable)
    external name '(gist_update)' 
    language C;

grant execute on function informix.gist_update(informix.pointer, informix.pointer, informix.pointer, informix.pointer, informix.pointer) to public as informix ;

create dba function informix.gist_delete(informix.pointer, informix.pointer, informix.pointer)
    returns integer
    with (parallelizable)
    external name '(gist_delete)' 
    language C;

grant execute on function informix.gist_delete(informix.pointer, informix.pointer, informix.pointer) to public as informix ;

create dba function informix.gist_beginscan(informix.pointer)
    returns integer
    with (parallelizable)
    external name '(gist_beginscan)' 
    language C;

grant execute on function informix.gist_beginscan(informix.pointer) to public as informix ;

create dba function informix.gist_endscan(informix.pointer)
    returns integer
    with (parallelizable)
    external name '(gist_endscan)' 
    language C;

grant execute on function informix.gist_endscan(informix.pointer) to public as informix;

create dba function informix.gist_rescan(informix.pointer)
    returns integer
    with (parallelizable)
    external name '(gist_rescan)' 
    language C;

grant execute on function informix.gist_rescan(informix.pointer) to public as informix ;

create dba function informix.gist_getnext(informix.pointer, informix.pointer, informix.pointer)
    returns integer
    with (parallelizable)
    external name '(gist_getnext)' 
    language C;

grant execute on function informix.gist_getnext(informix.pointer, informix.pointer, informix.pointer) to public as informix ;

-- no gist_stats

create dba function informix.gist_cost(informix.pointer, informix.pointer)
    returns real 
    external name '(gist_cost)'
    language C;

grant execute on function informix.gist_cost(informix.pointer, informix.pointer) to public as informix ;

create dba function informix.gist_check(informix.pointer, integer)
    returns real 
    external name '(gist_check)'
    language C;

grant execute on function informix.gist_check(informix.pointer, integer) to public as informix ;

create secondary access_method informix.gist (
    am_create = informix.gist_create,
    am_drop = informix.gist_drop,
    am_open = informix.gist_open,
    am_close = informix.gist_close,
    am_insert = informix.gist_insert,
    am_update = informix.gist_update,
    am_delete = informix.gist_delete,
    am_beginscan = informix.gist_beginscan,
    am_endscan = informix.gist_endscan,
    am_rescan = informix.gist_rescan,
    am_getnext = informix.gist_getnext,
    am_scancost = informix.gist_cost,
    am_check = informix.gist_check,
    am_sptype = 'D');

-- Define recovery related functions for the gist access method:

create dba function informix.gist_redo(informix.pointer, informix.pointer, integer, integer)
    returns integer
    external name '(gist_redo)'
    language C;

grant execute on function informix.gist_redo(informix.pointer, informix.pointer, integer, integer) to public as informix ;

create dba function informix.gist_undo(informix.pointer, informix.pointer, integer, integer)
    returns integer
    external name '(gist_undo)'
    language C;

grant execute on function informix.gist_undo(informix.pointer, informix.pointer, integer, integer) to public as informix ;

-- mistream
create opaque type informix.stream
(
        internallength=4,
        alignment = 1,
        passedbyvalue
);

create function informix.streamwrite(informix.stream, informix.boolean) 
returns informix.integer 
external name '(mi_streamwrite_boolean)' language c;

create function informix.streamwrite(informix.stream, informix.integer) 
returns informix.integer 
external name '(mi_streamwrite_integer)' language c;

create function informix.streamwrite(informix.stream, informix.smallfloat) 
returns informix.integer 
external name '(mi_streamwrite_real)' language c;

create function informix.streamwrite(informix.stream, informix.float) 
returns informix.integer 
external name '(mi_streamwrite_double)' language c;

create function informix.streamwrite(informix.stream, informix.decimal) 
returns informix.integer 
external name '(mi_streamwrite_decimal)' language c;

create function informix.streamwrite(informix.stream, informix.money) 
returns informix.integer 
external name '(mi_streamwrite_money)' language c;

create function informix.streamwrite(informix.stream, informix.date) 
returns informix.integer 
external name '(mi_streamwrite_date)' language c;

create function informix.streamwrite(informix.stream, datetime year to second) 
returns informix.integer 
external name '(mi_streamwrite_datetime)' language c;

create function informix.streamwrite(informix.stream, interval hour to minute) 
returns informix.integer 
external name '(mi_streamwrite_interval)' language c;

create function informix.streamwrite(informix.stream, informix.int8) 
returns informix.integer 
external name '(mi_streamwrite_int8)' language c;

create function informix.streamwrite(informix.stream, informix.char) 
returns informix.integer 
external name '(mi_streamwrite_string)' language c;

create function informix.streamwrite(informix.stream, informix.lvarchar) 
returns informix.integer 
external name '(mi_streamwrite_lvarchar)' language c;

create function informix.streamwrite(informix.stream, informix.collection) 
returns informix.integer 
external name '(mi_streamwrite_collection)' language c;

create function informix.streamwrite(informix.stream, informix.blob) 
returns informix.integer 
external name '(mi_streamwrite_lo)' language c;

create function informix.streamwrite(informix.stream, informix.clob) 
returns informix.integer 
external name '(mi_streamwrite_lo)' language c;

create function informix.streamwrite(informix.stream, informix.row) 
returns informix.integer 
external name '(mi_streamwrite_row)' language c;


create function informix.streamread(informix.stream, out informix.boolean) 
returns informix.integer 
external name '(mi_streamread_boolean)' language c;

create function informix.streamread(informix.stream, out informix.integer) 
returns informix.integer 
external name '(mi_streamread_integer)' language c;

create function informix.streamread(informix.stream, out informix.smallfloat) 
returns informix.integer 
external name '(mi_streamread_real)' language c;

create function informix.streamread(informix.stream, out informix.float) 
returns informix.integer 
external name '(mi_streamread_double)' language c;

create function informix.streamread(informix.stream, out informix.decimal) 
returns informix.integer 
external name '(mi_streamread_decimal)' language c;

create function informix.streamread(informix.stream, out informix.money) 
returns informix.integer 
external name '(mi_streamread_money)' language c;

create function informix.streamread(informix.stream, out informix.date) 
returns informix.integer 
external name '(mi_streamread_date)' language c;

create function informix.streamread(informix.stream, out datetime year to second) 
returns informix.integer 
external name '(mi_streamread_datetime)' language c;

create function informix.streamread(informix.stream, out interval hour to minute) 
returns informix.integer 
external name '(mi_streamread_interval)' language c;

create function informix.streamread(informix.stream, out informix.int8) 
returns informix.integer 
external name '(mi_streamread_int8)' language c;

create function informix.streamread(informix.stream, out informix.char) 
returns informix.integer 
external name '(mi_streamread_string)' language c;

create function informix.streamread(informix.stream, out informix.lvarchar) 
returns informix.integer 
external name '(mi_streamread_lvarchar)' language c;

create function informix.streamread(informix.stream, out informix.collection) 
returns informix.integer 
external name '(mi_streamread_collection)' language c;

create function informix.streamread(informix.stream, out informix.blob) 
returns informix.integer 
external name '(mi_streamread_lo)' language c;

create function informix.streamread(informix.stream, out informix.clob) 
returns informix.integer 
external name '(mi_streamread_lo)' language c;

create function informix.streamread(informix.stream, out informix.row) 
returns informix.integer 
external name '(mi_streamread_row)' language c;

create dba function informix.cdrgcdisp(informix.lvarchar)
    returns informix.lvarchar
    external name '(sqcdrGC2Disp)'
    language C;
 
grant execute on function informix.cdrgcdisp(informix.lvarchar)
    to public as informix;

