-
Notifications
You must be signed in to change notification settings - Fork 100
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
Added support for sp_xml_preparedocument and sp_xml_removedocument procedures #3461
base: BABEL_5_X_DEV
Are you sure you want to change the base?
Added support for sp_xml_preparedocument and sp_xml_removedocument procedures #3461
Conversation
…ocedures Signed-off-by: Harsh Dubey <harshdu@amazon.com>
Pull Request Test Coverage Report for Build 13173804274Details
💛 - Coveralls |
CREATE TEMPORARY TABLE IF NOT EXISTS SessionXMLDocuments ( | ||
Handle INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, | ||
Xml_content XML, | ||
NamespaceDefinitions XML | ||
) ON COMMIT PRESERVE ROWS; |
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.
We need to prevent this table from dropping accidentally by end user (may be).
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.
+1
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.
Created catalog table instead of temporary table as we need to see the handles across the sessions. Now the drop issue is fixed.
@@ -333,3 +333,68 @@ GRANT EXECUTE on PROCEDURE sys.sp_enum_oledb_providers() TO PUBLIC; | |||
CREATE OR REPLACE PROCEDURE sys.sp_reset_connection() | |||
AS 'babelfishpg_tsql', 'sp_reset_connection_internal' LANGUAGE C; | |||
GRANT EXECUTE ON PROCEDURE sys.sp_reset_connection() TO PUBLIC; | |||
|
|||
CREATE OR REPLACE PROCEDURE sys.sp_xml_preparedocument( |
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.
with this changes, can you please try out following scenario?
create table #SessionXMLDocuments(handle text, xml)
insert some dummy rows in the this table
DECLARE @hdoc INT;
EXEC sp_xml_preparedocument @hdoc OUTPUT, '<root><child></root', 'xmlns:ns1="http://example.com/ns1"/>';
SELECT @hdoc as handle;
EXEC sp_xml_removedocument @hdoc;
GO
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.
Tried to create the same table name as the new catalog table(sys.babelfish_xml_handles), it showed error that permission denied for sys schema.
CREATE TEMPORARY TABLE IF NOT EXISTS SessionXMLDocuments ( | ||
Handle INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, | ||
Xml_content XML, | ||
NamespaceDefinitions XML | ||
) ON COMMIT PRESERVE ROWS; |
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.
+1
xml_data XML; | ||
ns_data XML; | ||
BEGIN | ||
CREATE TEMPORARY TABLE IF NOT EXISTS SessionXMLDocuments ( |
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 this is session specific can we name this using something like xml_data_sha256(pid of backend) to prevent name collisions? also would likely decrease chances of dropping this table.
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.
We are now creating a catalog table instead of session specific table
|
||
CREATE OR REPLACE PROCEDURE sys.sp_xml_preparedocument( | ||
INOUT hdoc INTEGER, | ||
IN xmltext sys.VARCHAR DEFAULT NULL, |
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.
Add test cases to check max length limits of arguments
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.
Yes, added that tests in the test file.
RAISE EXCEPTION 'The XML input is not well-formed.'; | ||
END IF; | ||
|
||
IF xpath_namespaces IS NULL OR length(xpath_namespaces)=0 OR xml_is_well_formed_document(xpath_namespaces) THEN |
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.
Lets use fully qualified name whereever possible to avoid future issues
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.
Okay, got that.
Also as Rob mentioned there are procedures in T-SQL which returns a list of handles based on backend/session Id, I dont think temp table approach will be able to support that usecase |
Signed-off-by: Harsh Dubey <harshdu@amazon.com>
… in upgrades file Signed-off-by: Harsh Dubey <harshdu@amazon.com>
…in C instead of pgsql. Also implemented callback function to remove the entries on exiting the session. Signed-off-by: Harsh Dubey <harshdu@amazon.com>
…ction in the catalog.c file to mark it as an extended catalog table. Also removed the dump restore condition as we don't need that since we are storing sesion based data. Signed-off-by: Harsh Dubey <harshdu@amazon.com>
Signed-off-by: Harsh Dubey <harshdu@amazon.com>
Description
Currently babelfish does not support procedures like
sp_xml_preparedocument
andsp_xml_removedocument
. This PR adds support for thesp_xml_preparedocument
andsp_xml_removedocument
procedures.The procedure
sp_xml_preparedocument
parses an XML text given as input , stores it at session level and returns a handle to this document, which can be used to fetch the document.Similarly , the purpose of
sp_xml_removedocument
is to remove the internal representation of the XML document and invalidate that handle which was created using thesp_xml_preparedocument
procedure.The syntax for the procedures is as folllows:
sp_xml_preparedocument hdoc OUTPUT [ , xmltext ] [ , xpath_namespaces ] [ ; ]
sp_xml_removedocument hdoc [ ; ]
BABEL-1168
Signed-off-by: Harsh Dubey harshdu@amazon.com
Check List
By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.