I'm doing some benchmark testing of command line execution of postgres queries vs. JDBC using the Lehigh Benchmark Dataset as test data, including their test queries.
Everything else is working fine, except when I try to execute a single string query using psql.
The query is the string I'm creating and executing using
Runtime.getRuntime().exec("time ./psql -U lehigh -d lehigh -c 'SELECT u.id FROM undergraduatestudent u;';")
It works fine on the mac command line, but when run from within Java, I get the following errors:
---> psql: warning: extra command-line argument "u.id" ignored
---> psql: warning: extra command-line argument "FROM" ignored
---> psql: warning: extra command-line argument "undergraduatestudent" ignored
---> psql: warning: extra command-line argument "u;';" ignored
---> ERROR: unterminated quoted string at or near "'SELECT"
---> LINE 1: 'SELECT
---> ^
Essentially everything after "SELECT" isn't being recognized as part of the query. There are 14 queries where this is happening, but this is the shortest one, and will suffice to solve the problem.
I've tried moving the -U and -d to afterwards, as was suggested in a different post, but I got the same results.
I'm running this in Eclipse on a Mac in Capitan (though I don't believe either of these things are having an effect on things).
I'm aware of the -f option, but I have to time this per query, so I prefer the -c option.