{ ************************************************************************* }
{                                                                           }
{  Licensed Materials - Property of IBM and/or HCL                                     }
{                                                                           }
{  IBM Informix Dynamic Server                                              }
{  (c) Copyright IBM Corporation 2008 All rights reserved.                  }
{  (c) Copyright HCL Technologies Ltd. 2017.  All Rights Reserved.                  }
{                                                                           }
{   Title:      boot1150.sql                                                }
{                                                                           }
{   Description:                                                            }
{       Bootstrapping script for a 11.50 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.explain_sql(INOUT major_version int,
                                     INOUT minor_version int,
                                     requested_locale varchar(33),
                                     xml_input blob,
                                     xml_filter blob,
                                     OUT xml_output blob,
                                     OUT xml_message blob)
returns blob as xml_plan
with (HANDLESNULLS)
external name '(explain_sql)'
language C;

grant execute on function informix.explain_sql(int, int, varchar(33), blob,
blob, blob, blob) to public as informix;

create dba function informix.xsltransform(informix.lvarchar,
                                          informix.lvarchar)
returns informix.lvarchar(32739)
with (NOT VARIANT, HANDLESNULLS, PARALLELIZABLE, CLASS = 'idsxmlvp',
      PERCALL_COST = 32768 )
external name '$INFORMIXDIR/lib/libxml.udr(xsltransform_lv)'    
language C;

grant execute on function informix.xsltransform(informix.lvarchar, informix.lvarchar) to public as informix;

create dba function informix.xsltransform(informix.clob,
                                          informix.lvarchar)
returns informix.lvarchar(32739)
with (NOT VARIANT, HANDLESNULLS, PARALLELIZABLE, CLASS = 'idsxmlvp',
      PERCALL_COST = 32768 )
external name '$INFORMIXDIR/lib/libxml.udr(xsltransformincloblv)'    
language C;

grant execute on function informix.xsltransform(informix.clob,informix.lvarchar)
to public as informix;

create dba function informix.xsltransform(informix.clob,
                                          informix.clob)
returns informix.lvarchar(32739)
with (NOT VARIANT, HANDLESNULLS, PARALLELIZABLE, CLASS = 'idsxmlvp',
      PERCALL_COST = 32768 )
external name '$INFORMIXDIR/lib/libxml.udr(xsltransforminclob)'    
language C;

grant execute on function informix.xsltransform(informix.clob,informix.clob)
to public as informix;

create dba function informix.xsltransform(informix.blob,
                                          informix.lvarchar)
returns informix.lvarchar(32739)
with (NOT VARIANT, HANDLESNULLS, PARALLELIZABLE, CLASS = 'idsxmlvp',
      PERCALL_COST = 32768 )
external name '$INFORMIXDIR/lib/libxml.udr(xsltransforminbloblv)'    
language C;

grant execute on function informix.xsltransform(informix.blob,informix.lvarchar)
to public as informix;

create dba function informix.xsltransform(informix.blob,
                                          informix.blob)
returns informix.lvarchar(32739)
with (NOT VARIANT, HANDLESNULLS, PARALLELIZABLE, CLASS = 'idsxmlvp',
      PERCALL_COST = 32768 )
external name '$INFORMIXDIR/lib/libxml.udr(xsltransforminblob)'
language C;

grant execute on function informix.xsltransform(informix.blob,informix.blob)
to public as informix;

create dba function informix.xsltransformAsClob(informix.lvarchar,
                                                informix.lvarchar)
returns informix.clob
with (NOT VARIANT, HANDLESNULLS, PARALLELIZABLE, CLASS = 'idsxmlvp',
      PERCALL_COST = 32768 )
external name '$INFORMIXDIR/lib/libxml.udr(xsltransformclobinlv)'
language C;

grant execute on function informix.xsltransformAsClob(informix.lvarchar,informix.lvarchar) to public as informix;

create dba function informix.xsltransformAsClob(informix.clob,
                                                informix.lvarchar)
returns informix.clob
with (NOT VARIANT, HANDLESNULLS, PARALLELIZABLE, CLASS = 'idsxmlvp',
      PERCALL_COST = 32768 )
external name '$INFORMIXDIR/lib/libxml.udr(xsltransformclob_lv)'
language C;

grant execute on function informix.xsltransformAsClob(informix.clob,informix.lvarchar) to public as informix;

create dba function informix.xsltransformAsClob(informix.clob,
                                                informix.clob)
returns informix.clob
with (NOT VARIANT, HANDLESNULLS, PARALLELIZABLE, CLASS = 'idsxmlvp',
      PERCALL_COST = 32768 )
external name '$INFORMIXDIR/lib/libxml.udr(xsltransformclob)'
language C;

grant execute on function informix.xsltransformAsClob(informix.clob,informix.clob) to public as informix;

create dba function informix.xsltransformAsBlob(informix.lvarchar,
                                                informix.lvarchar)
returns informix.blob
with (NOT VARIANT, HANDLESNULLS, PARALLELIZABLE, CLASS = 'idsxmlvp',
      PERCALL_COST = 32768 )
external name '$INFORMIXDIR/lib/libxml.udr(xsltransformblobinlv)'
language C;

grant execute on function informix.xsltransformAsBlob(informix.lvarchar,informix.lvarchar) to public as informix;

create dba function informix.xsltransformAsBlob(informix.blob,
                                                informix.lvarchar)
returns informix.blob
with (NOT VARIANT, HANDLESNULLS, PARALLELIZABLE, CLASS = 'idsxmlvp',
      PERCALL_COST = 32768 )
external name '$INFORMIXDIR/lib/libxml.udr(xsltransformblob_lv)'
language C;

grant execute on function informix.xsltransformAsBlob(informix.blob,informix.lvarchar) to public as informix;

create dba function informix.xsltransformAsBlob(informix.blob,
                                                informix.blob)
returns informix.blob
with (NOT VARIANT, HANDLESNULLS, PARALLELIZABLE, CLASS = 'idsxmlvp',
      PERCALL_COST = 32768 )
external name '$INFORMIXDIR/lib/libxml.udr(xsltransformblob)'
language C;

grant execute on function informix.xsltransformAsBlob(informix.blob,informix.blob) to public as informix;

create dba function informix.ifx_checksum(informix.bigint, informix.integer)
    returns informix.integer
    with (NOT VARIANT, HANDLESNULLS, PARALLELIZABLE)
    external name '(bigint_checksum)'
    language C;

grant execute on function informix.ifx_checksum(informix.bigint, informix.integer) to public as informix;

{ RCI and STATIC HASH index methods }

create function informix.rci_create(informix.pointer)
    returns int
    external name '(rci_create)'
    language C;

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

create function informix.rci_drop(informix.pointer)
    returns int
    external name '(rci_drop)' 
    language C;

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

create function informix.rci_open(informix.pointer)
    returns int
    external name '(rci_open)' 
    language C;

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

create function informix.rci_close(informix.pointer)
    returns int
    external name '(rci_close)' 
    language C;

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

create function informix.rci_insert(informix.pointer, informix.pointer, informix.pointer)
    returns int
    external name '(shash_stub3)' 
    language C;

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

create function informix.rci_delete(informix.pointer, informix.pointer, informix.pointer)
    returns int
    external name '(shash_stub3)' 
    language C;

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

create function informix.rci_update(informix.pointer, informix.pointer, informix.pointer, informix.pointer, informix.pointer)
    returns int
    external name '(shash_stub5)' 
    language C;

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

create function informix.rci_beginscan(informix.pointer)
    returns int
    external name '(rci_beginscan)' 
    language C;

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

create function informix.rci_scancost(informix.pointer)
    returns float
    external name '(rci_scancost)' 
    language C;

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

create function informix.rci_endscan(informix.pointer)
    returns int
    external name '(rci_endscan)' 
    language C;

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

create function informix.rci_rescan(informix.pointer)
    returns int
    external name '(rci_rescan)' 
    language C;

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

create function informix.rci_getnext(informix.pointer, informix.pointer, informix.pointer)
    returns int
    external name '(rci_getnext)' 
    language C;

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


create secondary access_method informix.ifx_rci (
    am_create = informix.rci_create,
    am_drop = informix.rci_drop,
    am_open = informix.rci_open,
    am_close = informix.rci_close,
    am_insert = informix.rci_insert,
    am_delete = informix.rci_delete,
    am_update = informix.rci_update,
    am_scancost = informix.rci_scancost,
    am_beginscan = informix.rci_beginscan,
    am_endscan = informix.rci_endscan,
    am_rescan = informix.rci_rescan,
    am_getnext = informix.rci_getnext,
    am_sptype = 'D',
    am_unique);

create function informix.shash_create(informix.pointer)
    returns int
    external name '(shash_create)'
    language C;

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

create function informix.shash_drop(informix.pointer)
    returns int
    external name '(shash_stub1)' 
    language C;

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

create function informix.shash_open(informix.pointer)
    returns int
    external name '(shash_stub1)' 
    language C;

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

create function informix.shash_close(informix.pointer)
    returns int
    external name '(shash_stub1)' 
    language C;

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

create function informix.shash_insert(informix.pointer, informix.pointer, informix.pointer)
    returns int
    external name '(shash_stub3)' 
    language C;

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

create function informix.shash_delete(informix.pointer, informix.pointer, informix.pointer)
    returns int
    external name '(shash_stub3)' 
    language C;

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

create function informix.shash_update(informix.pointer, informix.pointer, informix.pointer, informix.pointer, informix.pointer)
    returns int
    external name '(shash_stub5)' 
    language C;

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

create function informix.shash_beginscan(informix.pointer)
    returns int
    external name '(shash_beginscan)' 
    language C;

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

create function informix.shash_scancost(informix.pointer)
    returns float
    external name '(shash_scancost)' 
    language C;

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

create function informix.shash_endscan(informix.pointer)
    returns int
    external name '(shash_endscan)' 
    language C;

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

create function informix.shash_rescan(informix.pointer)
    returns int
    external name '(shash_rescan)' 
    language C;

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

create function informix.shash_getnext(informix.pointer, informix.pointer, informix.pointer)
    returns int
    external name '(shash_getnext)' 
    language C;

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

create secondary access_method informix.ifx_shash (
    am_create = informix.shash_create,
    am_drop = informix.shash_drop,
    am_open = informix.shash_open,
    am_close = informix.shash_close,
    am_insert = informix.shash_insert,
    am_delete = informix.shash_delete,
    am_update = informix.shash_update,
    am_scancost = informix.shash_scancost,
    am_beginscan = informix.shash_beginscan,
    am_endscan = informix.shash_endscan,
    am_rescan = informix.shash_rescan,
    am_getnext = informix.shash_getnext,
    am_sptype = 'D',
    am_unique);


create function informix.bytetoblob(references byte, char(128), char(128))
        returns informix.blob
        external name '(bytetoblob_colspec)'
        language c not variant;

grant execute on function informix.bytetoblob(references byte, char(128), char(128))
        to public as informix;

create function informix.texttoclob(references text, char(128), char(128))
        returns informix.clob
        external name '(bytetoblob_colspec)'
        language c not variant;

grant execute on function informix.texttoclob(references text, char(128), char(128))
        to public as informix;
