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
Implementation of explained plan in XML format #223
base: master
Are you sure you want to change the base?
Conversation
Implementation of explained plan in XML
I think a machine readable plan would be very good, but much better in json than xml. |
I can add json format too if needed. PS. User after connected to db need to choose prefered format presented in e.g. MON$STATEMENTS. EDIT Can i use config same as is for |
❌ Build firebird 1.0.946 failed (commit 8d6bb0d0ff by @) |
I don't see writing of XML header. Is resulting XML valid from standard point of view? I'e does it pass validation at https://www.w3schools.com/xml/xml_validator.asp for example? Is the result still valid for non-ascii object names? |
It is valid, e.g. Postgress also do not show header |
❌ Build firebird 1.0.959 failed (commit 948afa1b92 by @) |
But i do not know what to add here utf8?
Yes, UTF-8 seems to be the only option given that table names are kept in it. But you also
must ensure that XML plan is not converted to connection charset during delivery to client.
BTW, did you check that it works with something like this: "select ... from "<xml>" """""?
|
I did not analysed this because we have currently explained lagacy plan. I supposed this problem was solved somehow (or simply ignored).
good catch :) |
added header of xml and also escape example for (with escape for alias):
|
I see that JSON is harder to addapt in the current code then XML or YAML. JSON have separator between elements |
@@ -448,7 +449,7 @@ interface Statement : ReferenceCounted | |||
uint itemsLength, const uchar* items, | |||
uint bufferLength, uchar* buffer); | |||
uint getType(Status status); | |||
const string getPlan(Status status, boolean detailed); | |||
const string getPlan(Status status, isc_info_sql_plan_format plan_format); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build is failed because of this line:
/home/appveyor/projects/firebird/gen/Release/cloop/release/bin/cloop /home/appveyor/projects/firebird/src/include/firebird/FirebirdInterface.idl pascal /home/appveyor/projects/firebird/src/include/gen/Firebird.pas Firebird --uses SysUtils
--interfaceFile /home/appveyor/projects/firebird/src/misc/pascal/Pascal.interface.pas
--implementationFile /home/appveyor/projects/firebird/src/misc/pascal/Pascal.implementation.pas
--exceptionClass FbException
--functionsFile /home/appveyor/projects/firebird/temp/Release/func.pas
--prefix I
/home/appveyor/projects/firebird/src/include/firebird/FirebirdInterface.idl:452:38: error: Interface/struct 'isc_info_sql_plan_format' not found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I not mistaken, you have to add isc_info_sql_plan_format
definition into /src/misc/pascal/Pascal.interface.pas
Also, I'm not sure it is legal to change interface method declaration, you should add new method instead.
On 10.09.2019 11:33, Vlad Khorsun wrote:
***@***.**** commented on this pull request.
------------------------------------------------------------------------
In src/include/firebird/FirebirdInterface.idl
<#223 (comment)>:
> @@ -448,7 +449,7 @@ interface Statement : ReferenceCounted
uint itemsLength, const uchar* items,
uint bufferLength, uchar* buffer);
uint getType(Status status);
- const string getPlan(Status status, boolean detailed);
+ const string getPlan(Status status, isc_info_sql_plan_format plan_format);
The build is failed because of this line:
/home/appveyor/projects/firebird/gen/Release/cloop/release/bin/cloop
/home/appveyor/projects/firebird/src/include/firebird/FirebirdInterface.idl
pascal
/home/appveyor/projects/firebird/src/include/gen/Firebird.pas
Firebird --uses SysUtils
--interfaceFile
/home/appveyor/projects/firebird/src/misc/pascal/Pascal.interface.pas
--implementationFile
/home/appveyor/projects/firebird/src/misc/pascal/Pascal.implementation.pas
--exceptionClass FbException
--functionsFile
/home/appveyor/projects/firebird/temp/Release/func.pas
--prefix I
/home/appveyor/projects/firebird/src/include/firebird/FirebirdInterface.idl:452:38:
error: Interface/struct 'isc_info_sql_plan_format' not found.
That struct should be described in .idl file to avoid the error.
BTW, I'm unsure (far unsure) is it worth adding new plain struct to API.
Better avoid that.
|
On 10.09.2019 12:24, Vlad Khorsun wrote:
***@***.**** commented on this pull request.
------------------------------------------------------------------------
In src/include/firebird/FirebirdInterface.idl
<#223 (comment)>:
> @@ -448,7 +449,7 @@ interface Statement : ReferenceCounted
uint itemsLength, const uchar* items,
uint bufferLength, uchar* buffer);
uint getType(Status status);
- const string getPlan(Status status, boolean detailed);
+ const string getPlan(Status status, isc_info_sql_plan_format plan_format);
If I not mistaken, you have to add |isc_info_sql_plan_format|
definition into /src/misc/pascal/Pascal.interface.pas
Also, I'm not sure it is legal to change interface method declaration,
Absolutely illegal - did not pay attention first.
… you should add new method instead.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#223?email_source=notifications&email_token=AA44OUJMFTKHAQENCO2QCRTQI5RU7A5CNFSM4IT2XK32YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCEGEJLY#discussion_r322639161>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA44OUO7UV3TUYAIYCZ3S73QI5RU7ANCNFSM4IT2XK3Q>.
|
>Absolutely illegal - did not pay attention first.
New method in same interface will be ok as Vlad Korshun suggested?
|
Isn't it fine as long as size of parameter isn't changed and only value range is expanded in compatible way? Boolean is one byte anyway. |
This will be very good to me if accepted.
I only will need to change enum to start with `0` with plain plan, `1` will be current explained format, `2` xml.
|
On 10.09.2019 13:02, Dimitry Sibiryakov wrote:
Absolutely illegal - did not pay attention first.
Isn't it fine as long as size of parameter isn't changed and only
value range is expanded in compatible way? Boolean is one byte anyway.
Except one issue - what value will be passed as true by old invoker? 1
or 0377 or 0177 or something else non-zero? How will new engin eprocess it?
|
Except one issue - what value will be passed as true by old invoker? 1
Yes, true is guaranteed to be 1 in C++ and Delphi.
|
No, it is not fine. |
From user POV declaration is not changed.
If someone do not retrive new "header" with new interface "version" than all interface functions still working without change needed.
Then interface is not broken and is still compatybile.
But you decide. I will adapt somehow (if i only know how to change something).
Is this final decision?
PS> i did not realized that i answer to git not firebird group ;-) I have edited some posts to make them clearer.
|
It is changed
But if someone ask new functionality using old implementation - he will be badly surprised, at least.
Not completely true.
Add new method to the interface and mark it as new version, for example:
|
@@ -1218,6 +1219,7 @@ interface TraceSQLStatement : TraceStatement | |||
TraceParams getInputs(); | |||
const string getTextUTF8(); | |||
const string getExplainedPlan(); | |||
const string getExplainedPlanXml(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be marked as new version, add lable version:
before the new method
ok. but is this only place or i must revert change also in e.g. And is this supported to have oveloaded functions in above interface? If yes, maybe better choice?
My knowledge about C++ is strongly limited here. |
Yes. Revert change (interface method declaration should never be changed!) and add new method.
Please, don't add confusion, use different method name. |
Yes. Revert change (interface method declaration should never be changed!) and add new method.
But rather than getPlanXml I would prefer getPlanEx with choice of format. It is easier
to expand later if needed.
|
Good concept for me. All already existing getPlan(bool explained) will simply call one method with appropriate parameter. |
getFormattedPlan() maybe? |
|
I suppose i have fixed all problems reported. I think about introducing new PS> it looks like "continuous-integration" is now ok |
✅ Build firebird 1.0.962 completed (commit 02aa1f8427 by @) |
Information of First and Skip values. e.g. SELECT FIRST 5 SKIP 2 * FROM RDB$RELATIONS we will see limitRows=5 skipRows=2
Only TYPE_LITERAL nodes are accepted. Any other can contain subquery e.g. SELECT * FROM RDB$RELATIONS R ROWS (SELECT COUNT(*) FROM RDB$DATABASE) SELECT * FROM RDB$RELATIONS R ROWS (5-(SELECT COUNT(*) FROM RDB$DATABASE))
✅ Build firebird 1.0.988 completed (commit 7486e4e5c5 by @) |
… plan store statistics into plan about: - memory; - physical IO global and global per table; - logical IO global and global per table.
store statistics into plan about:
Currently can be used to store plan into As still there is no SET command to change format of the plan, sample plan:
|
✅ Build firebird 1.0.1009 completed (commit 38e61cea5e by @) |
I forgot about this patch creaded few years ago.
I have modified it slightly and i it migrated from svn to git.
It implement explained plan in format XML.
To test it add e.g in trace option
explain_plan_xml=true
It was discussed previously and need some addoption, but to not forgot about i post this pull request as it will be also simplier to modify something.
PS> if someone can point me how to retrive specified value of e.g.
ROWS 5
in plan printing in FirstRowsStream.cpp then i can add more infos probably in other places too.I mean that i need to know this "5" number. finded self
PS2>make_icu, make_boot, make_all without errors, i do not know why below continuous-integration/travis-ci/pr failed somehow