#!/bin/bash

RASQL="rasql --user rasadmin --passwd rasadmin --quiet"
COLL=test_large
TYPE=GreySet

f=rasql_1.tif

function check()
{
  if [ -f $f ]; then
    output=`file $f`
    if [ "$output" == "rasql_1.tif: data" ]; then
      echo bug not fixed.
    else
      echo bug fixed.
    fi
  else
    echo select failed, file not found.
  fi
}

$RASQL -q "drop collection $COLL" > /dev/null 2>&1
$RASQL -q "create collection $COLL $TYPE" > /dev/null
$RASQL -q "insert into $COLL values marray i in [0:999,0:9999] values 2c" > /dev/null
$RASQL -q 'select tiff(c) from test_large as c' --out file

check
