Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

please trim the sql statement before processing it - e.g. <space>select 1 fails #8089

Closed
cameronbraid opened this issue Feb 21, 2023 · 2 comments · Fixed by #8339
Closed
Labels
type/bug Something isn't working
Milestone

Comments

@cameronbraid
Copy link

cameronbraid commented Feb 21, 2023

Describe the bug

Example in java

standalone repro : (uses testcontainers)

git clone https://github.com/cameronbraid/risingwave-java-received-resultset-tuples-but-no-field-structure-for-them-reproduction
cd risingwave-java-received-resultset-tuples-but-no-field-structure-for-them-reproduction
mvn test

example code :

var list = handle.createQuery(" select 1").mapToMap().list();
java.lang.IllegalStateException: Received resultset tuples, but no field structure for them
 at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2301)
 at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:356)
 at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:496)
 at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:413)
 at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:190)
 at org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:177)
 at org.jdbi.v3.core.statement.SqlLoggerUtil.wrap(SqlLoggerUtil.java:31)
 at org.jdbi.v3.core.statement.SqlStatement.internalExecute(SqlStatement.java:1787)
 at org.jdbi.v3.core.result.ResultProducers.lambda$createResultBearing$3(ResultProducers.java:94)
 at org.jdbi.v3.core.result.ResultIterable.lambda$of$0(ResultIterable.java:58)
 at org.jdbi.v3.core.result.ResultIterable.stream(ResultIterable.java:269)
 at org.jdbi.v3.core.result.ResultIterable.collect(ResultIterable.java:325)
 at org.jdbi.v3.core.result.ResultIterable.list(ResultIterable.java:314)
 at risingwave.TestCase.testCase(TestCase.java:60)
 at java.base/java.util.ArrayList.forEach(Unknown Source)
 at java.base/java.util.ArrayList.forEach(Unknown Source)

To Reproduce

No response

Expected behavior

No response

Additional context

No response

@cameronbraid cameronbraid added the type/bug Something isn't working label Feb 21, 2023
@github-actions github-actions bot added this to the release-0.1.18 milestone Feb 21, 2023
@xiangjinwu
Copy link
Contributor

async fn process_parse_msg(&mut self, msg: FeParseMessage) -> PsqlResult<()> {
let sql = cstr_to_str(&msg.sql_bytes).unwrap();
tracing::trace!("(extended query)parse query: {}", sql);
// Flag indicate whether statement is a query statement.
// TODO: regard DML with RETURNING as a query
let is_query_sql = {
let lower_sql = sql.to_ascii_lowercase();
lower_sql.starts_with("select")
|| lower_sql.starts_with("values")
|| lower_sql.starts_with("show")
|| lower_sql.starts_with("with")
|| lower_sql.starts_with("describe")
|| lower_sql.starts_with("explain")
};

The query is actually executed correctly, but our pgwire extend query protocol is falsely telling the client "this is not a query and do not expect any output".

@ZENOTME Do you recall why it was designed to use naive string comparison rather than invoke the parser?

@ZENOTME
Copy link
Contributor

ZENOTME commented Feb 22, 2023

Before #6849, we parse in frontend. I currently try to move parser to pgwire in extended query mode, it may more complex than simple query mode because we need to replace the parameter in parse tree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
3 participants