SQL Plan greater than 2048 characters is not printed at all in ISQL [CORE2370] #2792
Labels
affect-version: 1.5.4
affect-version: 1.5.5
affect-version: 2.0.0
affect-version: 2.0.1
affect-version: 2.0.2
affect-version: 2.0.3
affect-version: 2.0.4
affect-version: 2.0.5
affect-version: 2.1.0
affect-version: 2.1.1
affect-version: 2.5 Alpha 1
component: isql
fix-version: 2.5 Beta 2
priority: minor
type: bug
Submitted by: Bill Oliver (verbguy)
Assigned to: Claudio Valderrama C. (robocop)
Jira_subtask_outward CORE2509
Is related to QA394
I have a query plan with unions that is greater than 2048 characters, it is 5764 characters. The result is that in ISQL, I only get a blank line for the plan!
The trivial fix is to bump up the size of the buffer in ISQL's process_plan(). I increased buffer size to 8096, and it worked fine.
Perhaps a better fix is to max out the buffer size in process_plan(), so we don't have to touch this area again. We know that the maximum possible length of the plan is MAX_SSHORT, see dsql.cpp's DSQL_get_plan_info(). Anything longer than this, and the plan will be returned, but it will end in ellipses. That's ok.
I've coded a patch for this issue. In testing, it seems to me that dsql.cpp's put_item() length check is off by one, but I'd like the committer to double-check this.
### Eclipse Workspace Patch 1.0
#P firebird2
Index: src/dsql/dsql.cpp
RCS file: /cvsroot/firebird/firebird2/src/dsql/dsql.cpp,v
retrieving revision 1.276
diff -u -r1.276 dsql.cpp
--- src/dsql/dsql.cpp 3 Mar 2009 14:55:53 -0000 1.276
+++ src/dsql/dsql.cpp 12 Mar 2009 17:59:18 -0000
@@ -2740,7 +2740,7 @@
const UCHAR* const end)
{
- if (ptr + length + 3 >= end) {
+ if (ptr + length + 3 > end) {
*ptr = isc_info_truncated;
return NULL;
}
Index: src/isql/isql.epp
RCS file: /cvsroot/firebird/firebird2/src/isql/isql.epp,v
retrieving revision 1.268
diff -u -r1.268 isql.epp
--- src/isql/isql.epp 1 Mar 2009 15:42:18 -0000 1.268
+++ src/isql/isql.epp 12 Mar 2009 17:59:18 -0000
@@ -7943,11 +7943,11 @@
// any result to the caller.
static void process_plan()
{
- // Bug 7565: A plan larger than plan_buffer will not be displayed
- // Bug 7565: Note also that the plan must fit into Print_Buffer
-
const SCHAR plan_info[] = { isc_info_sql_get_plan };
- TEXT plan_buffer[PRINT_BUFFER_LENGTH];
+
+ // max length of plan is MAX_SSHORT
+ // add 1 for SQL info item, and 2 for actual length of the plan
+ TEXT plan_buffer[MAX_SSHORT + 3];
memset(plan_buffer, 0, sizeof(plan_buffer));
if (isc_dsql_sql_info(isc_status, &global_Stmt, sizeof(plan_info), plan_info,
sizeof(plan_buffer), plan_buffer))
Commits: 1faf0f0
The text was updated successfully, but these errors were encountered: