Run from stdin
Closed this issue · 2 comments
fljdin commented
A really cool feature would be use of stdin to dispatch SQL statements, like this prototype
cat <<EOF | psql -At | dispatch run -j 4
SELECT format('REINDEX INDEX %I;', indexrelid::regclass)
FROM pg_index WHERE indisvalid = false OR indisready = false
EOF
It means psql
command type should be the default, or even the only compatible command type.
fljdin commented
After some hack, this feature needs a new shell parser to deal with various type passed by input but it becomes more effective to use xargs
as replacement
- with a new flag?
cat <<EOF | psql -At | dispatch run -j 4 -t psql
SELECT format('REINDEX INDEX %I;', indexrelid::regclass)
FROM pg_index WHERE indisvalid = false OR indisready = false
EOF
cat <<OEF | psql-At | dispatch run -j 4 -t shell
SELECT format('reindexdb -t %I;', tablename) FROM pg_tables
WHERE schemaname = 'public' AND tablename NOT IN ('log')
EOF
- with
xargs
?
cat <<EOF | psql -At | xargs -P 4 -d';' -I % psql -c %
SELECT format('REINDEX INDEX %I;', indexrelid::regclass)
FROM pg_index WHERE indisvalid = false OR indisready = false
EOF
cat <<EOF | psql -At | xargs -P 4 -d';' -I % sh -x -c %
SELECT format('reindexdb -t %I;', tablename) FROM pg_tables
WHERE schemaname = 'public' AND tablename NOT IN ('log')
EOF
fljdin commented
Too much work for no real interest.