Azure / data-api-builder

Data API builder provides modern REST and GraphQL endpoints to your Azure Databases and on-prem stores.
https://aka.ms/dab/docs
MIT License
787 stars 142 forks source link

Enforce data streaming limits stored procedure #2269

Closed rohkhann closed 1 week ago

rohkhann commented 1 week ago

Why make this change?

This change is to give the user the option to decide how much data they want to be able to load into the application memory on the execution of a stored procedure. The restriction is put in place by limiting the amount of data that can be returned by the stored procedure.

What is this change?

This changes edits the stored procedure read logic to stream results from the db. Based on the type of data returned by a column, the appropriate read data streaming function is used (GetBytes, GetChars etc). Only large object types require explicitly streaming from the db (https://learn.microsoft.com/en-us/sql/t-sql/data-types/data-types-transact-sql?view=sql-server-ver16). Currently the large object types we support map to either string objects (for example: nvarchar, varchar, ntext) or byte[] objects (for example: Image)

For stored procedure, we get the information about the result set of the stored procedure and create dbResultSetRows which go into our data table. To create these rows, we read column by column from the dbDataReader. The columnIndex is got from the columnName which can be retrieved from resultset info of the stored procedure. Hence while streaming, we need to specify the ordinal of the column we want to read.

How was this tested?

unit tests added.

rohkhann commented 1 week ago

/azp run

rohkhann commented 1 week ago

/azp run

rohkhann commented 1 week ago

/azp run

rohkhann commented 1 week ago

/azp run

rohkhann commented 1 week ago

/azp run

rohkhann commented 1 week ago

/azp run

rohkhann commented 1 week ago

/azp run

rohkhann commented 1 week ago

/azp run

rohkhann commented 1 week ago

/azp run

rohkhann commented 1 week ago

/azp run

rohkhann commented 1 week ago

/azp run

rohkhann commented 1 week ago

/azp run

rohkhann commented 1 week ago

/azp run

rohkhann commented 1 week ago

/azp run

rohkhann commented 1 week ago

/azp run