Skip to content

Trino.Data.ADO: Fix CommandBehavior flag read in ExecuteDbReaderAsync #22

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions trino-csharp/Trino.Data.ADO/Server/TrinoCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,26 +208,30 @@ public async Task<RecordExecutor> RunQuery(long bufferSizeBytes = Constants.Defa
protected override async Task<DbDataReader> ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
{
RecordExecutor queryExecutor;
switch (behavior)

if ((behavior == CommandBehavior.Default)
|| ((behavior & CommandBehavior.SingleResult) == CommandBehavior.SingleResult))
{
case CommandBehavior.Default:
// Single result means only run one query. Trino only supports one query.
case CommandBehavior.SingleResult:
queryExecutor = await RunQuery().ConfigureAwait(false);
break;
case CommandBehavior.SingleRow:
// Single row requires the reader to be created and the first row to be read.
queryExecutor = await RunQuery().ConfigureAwait(false);
return new TrinoDataReader(queryExecutor);
case CommandBehavior.SchemaOnly:
queryExecutor = await RunNonQuery().ConfigureAwait(false);
break;
case CommandBehavior.CloseConnection:
// Trino has no concept of a connection because every call is a new connection.
queryExecutor = await RunQuery().ConfigureAwait(false);
break;
default:
throw new NotSupportedException();
queryExecutor = await RunQuery().ConfigureAwait(false);
}
else if ((behavior & CommandBehavior.SingleRow) == CommandBehavior.SingleRow)
{
// Single row requires the reader to be created and the first row to be read.
queryExecutor = await RunQuery().ConfigureAwait(false);
}
else if ((behavior & CommandBehavior.SchemaOnly) == CommandBehavior.SchemaOnly)
{
queryExecutor = await RunNonQuery().ConfigureAwait(false);
}
else if ((behavior & CommandBehavior.CloseConnection) == CommandBehavior.CloseConnection)
{
// Trino has no concept of a connection because every call is a new connection.
queryExecutor = await RunQuery().ConfigureAwait(false);
}
else
{
throw new NotSupportedException();
}

// always wait for the schema when creating an IEnumerable
Expand Down