Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Lehre und Unterricht
Datenbank- und Informations-Systeme
DataEngineering
Commits
866bb77c
Commit
866bb77c
authored
May 22, 2020
by
Marcel Huber
Browse files
shellcheck corrected scripts
parent
03ef07b9
Changes
3
Hide whitespace changes
Inline
Side-by-side
ColumnStore/Queries_MonetDB.sh
View file @
866bb77c
#!/bin/sh
#!/bin/
ba
sh
_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
ColumnStore/Queries_PostgreSQL.sh
View file @
866bb77c
#!/bin/sh
#!/bin/
ba
sh
_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
=
"
\q
echo "
...
...
@@ -34,14 +35,16 @@ SET track_counts TO false;
-- columns is in effect when using wrapped mode
\p
set 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
"
\p
set 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
ColumnStore/Queries_common.sh
View file @
866bb77c
# 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)"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment