Commit 866bb77c authored by Marcel Huber's avatar Marcel Huber
Browse files

shellcheck corrected scripts

parent 03ef07b9
#!/bin/sh
#!/bin/bash
_MY_DIR="$(cd $(dirname ${0:-.}) && pwd)"
_EX_DIR="$(realpath --relative-to=. $_MY_DIR)"
_MY_DIR="$(cd "$(dirname "${0:-.}")" && pwd)"
_EX_DIR="$(realpath --relative-to=. "$_MY_DIR")"
test -z "$_EX_DIR" && _EX_DIR=.
eo0=""
eo1=""
source $_EX_DIR/Queries_common.sh
# shellcheck source=./Queries_common.sh
. $_EX_DIR/Queries_common.sh
# disable globbing for star queries (*)
set -f
cat <<EOF
......@@ -23,38 +24,36 @@ set schema ds2;
set role sysadmin;
--
$(for q in "${queries[@]}"; do
explainopts="$(eval echo $(echo \"\$$(cut -d'|' -f1 <<<$q)\"))";
aufgabe="$(cut -d'|' -f2 <<<$q)";
aufgabe_desc="$(cut -d'|' -f3 <<<$q)";
query="$(cut -d'|' -f4 <<<$q)";
query_escaped="$(echo -n $query | sed 's/\x27/\\\x27/g')";
baseindex="";
indexcond="";
explainopts="$(eval echo $(echo \"\$$(cut -d'|' -f1 <<<"$q")\"))";
aufgabe="$(cut -d'|' -f2 <<<"$q")";
aufgabe_desc="$(cut -d'|' -f3 <<<"$q")";
query="$(cut -d'|' -f4 <<<"$q")";
query_escaped="$(echo -n "$query" | sed 's/\x27/\\\x27/g')";
echo "\f tab"
echo "select '--== Query "$aufgabe_desc" ==--';"
echo "select '-- tag::"${aufgabe}"[]';"
echo "select '-- tag::"${aufgabe}"-query[]';"
echo "select '"$query_escaped"';"
echo "select '-- end::"${aufgabe}"-query[]';"
echo "select '-- tag::"${aufgabe}"-plan[]';"
echo "select '--== Query $aufgabe_desc ==--';"
echo "select '-- tag::${aufgabe}[]';"
echo "select '-- tag::${aufgabe}-query[]';"
echo "select '$query_escaped';"
echo "select '-- end::${aufgabe}-query[]';"
echo "select '-- tag::${aufgabe}-plan[]';"
echo "\f raw"
echo "plan $query"
echo "\f tab"
echo "select '-- end::"${aufgabe}"-plan[]';"
echo "select '-- tag::"${aufgabe}"-timing[]';"
echo "select '-- end::${aufgabe}-plan[]';"
echo "select '-- tag::${aufgabe}-timing[]';"
echo "\f trash"
echo "\t performance"
echo "$query"
echo "\t none"
echo "\f tab"
echo "select '-- end::"${aufgabe}"-timing[]';"
echo "select '-- tag::"${aufgabe}"-trace[]';"
echo "select '-- end::${aufgabe}-timing[]';"
echo "select '-- tag::${aufgabe}-trace[]';"
echo "\f rowcount"
echo "trace $query"
echo "\f csv+;"
echo "select ticks as usec, stmt from sys.tracelog;"
echo "\f tab"
echo "select '-- end::"${aufgabe}"-trace[]';"
echo "select '-- end::"${aufgabe}"[]';"
echo "select '-- end::${aufgabe}-trace[]';"
echo "select '-- end::${aufgabe}[]';"
done)
EOF
#!/bin/sh
#!/bin/bash
_MY_DIR="$(cd $(dirname ${0:-.}) && pwd)"
_EX_DIR="$(realpath --relative-to=. $_MY_DIR)"
_MY_DIR="$(cd "$(dirname "${0:-.}")" && pwd)"
_EX_DIR="$(realpath --relative-to=. "$_MY_DIR")"
test -z "$_EX_DIR" && _EX_DIR=.
db_name=${1:-ds2}
......@@ -10,7 +10,8 @@ db_user=${2:-$db_name}
eo0=""
eo1="EXPLAIN (ANALYZE 1,COSTS 0,TIMING 1,BUFFERS 0,VERBOSE 0,FORMAT TEXT)"
source $_EX_DIR/Queries_common.sh
# shellcheck source=./Queries_common.sh
. $_EX_DIR/Queries_common.sh
echostr=""
echostr="\qecho "
......@@ -34,14 +35,16 @@ SET track_counts TO false;
-- columns is in effect when using wrapped mode
\pset columns $colwidth
\c $db_name $db_user
$(sed -n '/CREATE INDEX/ p' $_EX_DIR/ds2_indexes.sql)
\c postgres postgres
VACUUM (ANALYZE);
\c $db_name $db_user
$(for q in "${queries[@]}"; do
explainopts="$(eval echo $(echo \"\$$(cut -d'|' -f1 <<<$q)\"))";
aufgabe="$(cut -d'|' -f2 <<<$q)";
aufgabe_desc="$(cut -d'|' -f3 <<<$q)";
query="$(cut -d'|' -f4 <<<$q)";
baseindex="";
indexcond="";
explainopts="$(eval echo $(echo \"\$$(cut -d'|' -f1 <<<"$q")\"))";
aufgabe="$(cut -d'|' -f2 <<<"$q")";
aufgabe_desc="$(cut -d'|' -f3 <<<"$q")";
query="$(cut -d'|' -f4 <<<"$q")";
echo "${echostr}--== Query $aufgabe_desc ==--"
echo "${echostr}-- tag::${aufgabe}[]"
echo "\! echo \"$explainopts\" >/tmp/qa"
......@@ -52,7 +55,6 @@ $(for q in "${queries[@]}"; do
echo "${echostr}-- tag::${aufgabe}-query[]"
echo "\! cat /tmp/q"
echo "${echostr}-- end::${aufgabe}-query[]"
echo "BEGIN;"
echo "${echostr}-- tag::${aufgabe}-explain[]"
echo "\pset format asciidoc"
echo "${echostr}-- tag::${aufgabe}-explain-adoc[]"
......@@ -63,7 +65,6 @@ $(for q in "${queries[@]}"; do
echo "\i /tmp/qa"
echo "${echostr}-- end::${aufgabe}-explain-text[]"
echo "${echostr}-- end::${aufgabe}-explain[]"
echo "ROLLBACK;"
echo "${echostr}-- end::${aufgabe}[]"
done)
EOF
# shellcheck shell=bash
# shellcheck disable=SC2034
queries=(
"eo1|lastname-firstname-customers|(Q1)|select lastname, firstname from customers;||customers(lastname,firstname)"
"eo1|lastname-firstname-customers-id1000|(Q2)|select lastname, firstname from customers where customerid=1000;||customers(lastname,firstname)"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment