Manuel Mayr wrote: > First of all those scripts don't offer new features or functionality. > They only provide facilities to create tables and content for the > SQL backend.
Having the script is by itself already a new feature.
> We want to add them to the bindir, only for unix like platforms, since
> both are shell scripts.
So Windows users aren't allowed to have this convenience?
> Best regards,
> Manuel
>
> Stefan Manegold wrote:
>> To ensure a smooth finalization of our combined effort to get the upcoming
>> release out "as fast as possible" and without any self-made hurdles, I
>> assume that adding these new "feature(s)" in the *release branch* has been
>> coordinated with Sjoerd, right?
>> (In particular wrt. how/where they need to be added to the source and
>> in particular binary packages, documentation, and which platforms they are
>> targeted for (Windows??).)
>>
>> Greetings from Vienna,
>>
>> Stefan
>>
>> On Mon, Sep 24, 2007 at 09:10:33AM +0000, Manuel Mayr wrote:
>>
>>> Update of /cvsroot/monetdb/pathfinder/src/sqlhelpers/db2tools
>>> In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18874
>>>
>>> Added Files:
>>> Tag: XQuery_0-20
>>> common.inc load table
>>> Log Message:
>>>
>>>
>>> Shell scripts to create tables, and load content for SQL-backend
>>>
>>>
>>> --- NEW FILE: load ---
>>> #!/bin/sh
>>>
>>> THIS=${0}
>>> THISDIR=${0%/*}
>>> THISFILE=${0##*/}
>>> DB2=`which db2`
>>>
>>> source common.inc
>>>
>>> ################################################
>>> # FUNCTIONS
>>>
>>> function load_table {
>>> #check parameter list
>>> if [ ${#} -ne 3 ]; then
>>> error "Usage: ${0} <file> <schema> <table>"
>>> fi
>>>
>>> SCHEMA=${2}
>>> FILE=${1}
>>> TABLE=${3}
>>>
>>> # set schema to ours
>>> ${DB2} "set current schema ${SCHEMA}"
>>>
>>> # create the names-table
>>> ${DB2} -t<<EOT
>>> LOAD FROM ${FILE} OF DEL
>>> MODIFIED BY DELPRIORITYCHAR
>>> REPLACE INTO ${TABLE}
>>> NONRECOVERABLE
>>> INDEXING MODE rebuild;
>>> EOT
>>>
>>> ${DB2} "SET INTEGRITY FOR ${TABLE} IMMEDIATE CHECKED"
>>> EFLAG=${?}
>>> return ${EFLAG}
>>> }
>>>
>>> function print_help () {
>>> out "Pathfinder XQuery"
>>> out "(c) Database Group, Technische Universitaet Muenchen"
>>> out ""
>>> out "Usage: ${THISFILE} (create|drop) <db> <schema> <file>"
>>> out ""
>>> out -e "\t<db>:\t\tName of the Database the content should be
>>> placed/removed."
>>> out -e "\t<schema>:\tName of the Schema the content should be
>>> placed/removed."
>>> out -e "\t<names_file>:\tNames file"
>>> out -e "\t<file>:\tEncoded document"
>>> }
>>>
>>> ################################################
>>> # MAIN
>>>
>>> if [ $# -ne 4 ]; then
>>> print_help;
>>> exit 0;
>>> fi
>>>
>>> DATABASE=${1}
>>> SCHEMA=${2}
>>> NFILE=${3}
>>> LFILE=${4}
>>>
>>> ${DB2} "connect to ${DATABASE}"
>>>
>>> EFLAG=${?}
>>> out -ne "Connecting to database ${DATABASE} ... "; fail $EFLAG;
>>>
>>> test ${EFLAG} -ne 0 && exit 1;
>>>
>>> load_table "${NFILE}" "${SCHEMA}" "${TAB_NAMES}";
>>> EFLAG=${?};
>>> out -ne "Loading ${SCHEMA}.${TAB_NAMES} ... "; fail ${EFLAG};
>>>
>>> load_table ${LFILE} "${SCHEMA}" "${TAB_DOC}";
>>> EFLAG=${?};
>>> out -ne "Loading ${SCHEMA}.${TAB_DOC} ... "; fail ${EFLAG};
>>>
>>> ${DB2} "terminate"
>>>
>>> --- NEW FILE: table ---
>>> #!/bin/sh
>>>
>>> THIS=${0}
>>> THISDIR=${0%/*}
>>> THISFILE=${0##*/}
>>> DB2=`which db2`
>>>
>>> source common.inc
>>>
>>> ################################################
>>> # FUNCTIONS
>>>
>>> function create_names {
>>> #check parameter list
>>> if [ ${#} -ne 2 ]; then
>>> error "Usage: ${0} <schema> <tabname>"
>>> fi
>>>
>>> SCHEMA=${1}
>>> TABNAME=${2}
>>>
>>> # set schema to ours
>>> ${DB2} "set current schema ${SCHEMA}"
>>>
>>> # create the names-table
>>> ${DB2} -t<<EOT
>>> CREATE TABLE ${TABNAME}(nameid INT NOT NULL PRIMARY KEY,
>>> name VARCHAR(32) NOT NULL);
>>> EOT
>>> EFLAG=${?}
>>> return ${EFLAG}
>>> }
>>>
>>> function create_doc {
>>> #check parameter list
>>> if [ ${#} -ne 3 ]; then
>>> error "Usage: ${0} <schema> <tabname> <namesname>"
>>> fi
>>>
>>> SCHEMA=${1}
>>> TABNAME=${2}
>>> NAMESNAME=${3}
>>>
>>> ${DB2} "set current schema ${SCHEMA}"
>>>
>>> ${DB2} -t<<EOT
>>> CREATE TABLE ${TABNAME}(pre INT NOT NULL PRIMARY KEY,
>>> size INT NOT NULL,
>>> level SMALLINT NOT NULL,
>>> kind SMALLINT,
>>> nameid INT,
>>> value VARCHAR(100),
>>> guide INT NOT NULL,
>>> FOREIGN KEY (nameid) references ${NAMESNAME}(nameid));
>>> EOT
>>> EFLAG=${?}
>>> return ${EFLAG}
>>> }
>>>
>>> function create_xmldoc {
>>> #check parameter list
>>> if [ ${#} -ne 4 ]; then
>>> error "Usage: ${0} <schema> <tabname> <docname> <namesname>"
>>> fi
>>>
>>> SCHEMA=${1}
>>> TABNAME=${2}
>>> DOCNAME=${3}
>>> NAMENAME=${4}
>>>
>>> ${DB2} "set current schema ${SCHEMA}"
>>>
>>> ${DB2} -t<<EOT
>>> CREATE VIEW ${TABNAME}(pre, size, level, kind, guide,
>>> nameid, value, name) AS
>>> (SELECT pre, size, level, kind, guide,
>>> doc.nameid, value, name
>>> FROM ${DOCNAME} AS doc
>>> LEFT OUTER JOIN
>>> ${NAMESNAME} AS names
>>> ON doc.nameid = names.nameid);
>>> EOT
>>> EFLAG=${?}
>>> return ${EFLAG}
>>> }
>>>
>>> function drop_table {
>>> #check parameter list
>>> if [ ${#} -ne 1 ]; then
>>> error "Usage: ${0} <table>"
>>> fi
>>>
>>> TABLE=${1}
>>>
>>> ${DB2} "drop table ${TABLE}"
>>> }
>>>
>>> function drop_names {
>>> #check parameter list
>>> if [ ${#} -ne 1 ]; then
>>> error "Usage: ${0} <schema>"
>>> fi
>>>
>>> SCHEMA=${1}
>>>
>>> ${DB2} "set current schema ${SCHEMA}"
>>> drop_table "${TAB_NAMES}"
>>> EFLAG=${?}
>>> return ${EFLAG}
>>> }
>>>
>>> function drop_doc {
>>> #check parameter list
>>> if [ ${#} -ne 1 ]; then
>>> error "Usage: ${0} <schema>"
>>> fi
>>>
>>> SCHEMA=${1}
>>>
>>> ${DB2} "set current schema ${SCHEMA}"
>>> drop_table "${TAB_DOC}"
>>> EFLAG=${?}
>>> return ${EFLAG}
>>> }
>>>
>>> function drop_xmldoc {
>>> #check parameter list
>>> if [ ${#} -ne 1 ]; then
>>> error "Usage: ${0} <schema>"
>>> fi
>>>
>>> SCHEMA=${1}
>>>
>>> ${DB2} "set current schema ${SCHEMA}"
>>> ${DB2} "drop view xmldoc"
>>> EFLAG=${?}
>>> return ${EFLAG}
>>> }
>>>
>>> function print_help () {
>>> out "Pathfinder XQuery"
>>> out "(c) Database Group, Technische Universitaet Muenchen"
>>> out ""
>>> out "Usage: $THISFILE (create|drop) <db> <schema>"
>>> out ""
>>> out -e "\t(create|drop):\teither create or drop the tables "
>>> out -e "\t<db>:\t\tName of the Database the tables should be
>>> placed/removed."
>>> out -e "\t<schema>:\tName of the Schema the tables should be
>>> placed/removed."
>>> }
>>>
>>> ################################################
>>> # MAIN
>>>
>>> if [ $# -ne 3 ]; then
>>> print_help;
>>> exit 0;
>>> fi
>>>
>>> OPTION=${1}
>>> DATABASE=${2}
>>> SCHEMA=${3}
>>>
>>> ${DB2} "connect to ${DATABASE}"
>>> EFLAG=$?
>>> out -ne "Connecting to database ${DATABASE} ... "; fail $EFLAG;
>>> test $EFLAG -ne 0 && exit 1;
>>>
>>> case ${OPTION} in
>>> create) create_names ${SCHEMA} ${TAB_NAMES};
>>> EFLAG=${?};
>>> out -ne "Creating ${SCHEMA}.${TAB_NAMES} ... "; fail ${EFLAG};
>>>
>>> create_doc ${SCHEMA} ${TAB_DOC} ${TAB_NAMES};
>>> EFLAG=${?};
>>> out -ne "Creating ${SCHEMA}.${TAB_DOC} ... "; fail ${EFLAG};
>>>
>>> create_xmldoc ${SCHEMA} ${TAB_XMLDOC} ${TAB_DOC} ${TAB_NAMES};
>>> EFLAG=${?};
>>> out -ne "Creating ${SCHEMA}.${TAB_XMLDOC} ... "; fail ${EFLAG};
>>> ;;
>>>
>>> drop) drop_xmldoc ${SCHEMA}
>>> EFLAG=${?}
>>> out -ne "Dropping ${SCHEMA}.${TAB_XMLDOC} ... "; fail ${EFLAG};
>>>
>>> drop_doc ${SCHEMA}
>>> EFLAG=${?}
>>> out -ne "Dropping ${SCHEMA}.${TAB_DOC} ... "; fail ${EFLAG};
>>>
>>> drop_names ${SCHEMA}
>>> EFLAG=${?}
>>> out -ne "Dropping ${SCHEMA}.${TAB_NAMES} ... "; fail ${EFLAG};
>>> ;;
>>> *) print_help;
>>> exit 1;
>>> ;;
>>> esac
>>> ${DB2} "terminate"
>>>
>>> --- NEW FILE: common.inc ---
>>> DEBUG=0
>>>
>>> TAB_NAMES="names"
>>> TAB_DOC="doc"
>>> TAB_XMLDOC="xmldoc"
>>>
>>> DB2=`which db2`
>>>
>>> function fail {
>>> if [ ${#} -ne 1 ]; then
>>> error "Wrong use of fail"
>>> fi
>>>
>>> if [ ${1} -eq 0 ]; then
>>> out "Success"
>>> return 0;
>>> else
>>> out "Failed"
>>> return 0;
>>> fi
>>> }
>>>
>>> function error {
>>> if [ ${#} -ne 1 ]; then
>>> echo "Wrong use of error"
>>> exit 1;
>>> fi
>>> echo -e "Error: ${1}"
>>> exit 1
>>> }
>>>
>>> function warning
>>> {
>>> if [ ${#} -ne 1 ]; then
>>> error "Wrong use of debug"
>>> fi
>>> echo -e "Warning: ${1}"
>>> }
>>>
>>> function out {
>>> if [ ${#} -eq 1 ]; then
>>> echo -e "${1}"
>>> return 0;
>>> fi
>>> if [ ${#} -eq 2 ]; then
>>> echo "${1}" "${2}"
>>> else
>>> error "wrong use of out"
>>> fi
>>> }
>>>
>>> function debug {
>>> if [ ${#} -ne 1 ]; then
>>> error "Wrong use of debug"
>>> fi
>>> test ${DEBUG} -eq 1 && echo -e "Debug: ${1}"
>>> }
>>>
>>> function LOG1 {
>>> prompt="\n# `date +%H:%M:%S` > "; { echo -en "$prompt$prompt" ; echo
>>> -n "$*" ; echo -en "$prompt\n\n" ; } >&2;
>>> }
>>>
>>> function getAbsolutePath {
>>> if [ -z ${1} ]; then
>>> error "Wrong use of ${0}";
>>> fi
>>>
>>> PATH_=${1%/*}
>>> FILE_=${1##*/}
>>>
>>> echo `cd ${PATH_} 2> /dev/null && pwd || echo ${PATH_}`/${FILE_}
>>> }
>>>
>>> test -z $DB2 && error "DB2 not available";
>>>
>>>
>>> -------------------------------------------------------------------------
>>> This SF.net email is sponsored by: Microsoft
>>> Defy all challenges. Microsoft(R) Visual Studio 2005.
>>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>>> _______________________________________________
>>> Monetdb-pf-checkins mailing list
>>> [EMAIL PROTECTED]
>>> https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins
>>>
>>>
>>
>
>
--
Sjoerd Mullender
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________ Monetdb-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/monetdb-developers
