diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c
index d9e278bfa2..93f7b293e7 100644
--- a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c
+++ b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c
@@ -2597,7 +2597,6 @@ TdsPrintTup(TupleTableSlot *slot, DestReceiver *self)
break;
case TDS_TYPE_CHAR:
case TDS_TYPE_NCHAR:
- case TDS_TYPE_XML:
case TDS_TYPE_BINARY:
/*
@@ -2606,6 +2605,14 @@ TdsPrintTup(TupleTableSlot *slot, DestReceiver *self)
*/
simpleRowSize += 2;
break;
+ case TDS_TYPE_XML:
+ /*
+ * To send NULL,we have to
+ * indicate it using 0xffffffffffffffff
+ * (PLP_NULL)
+ */
+ simpleRowSize += 8;
+ break;
case TDS_TYPE_SQLVARIANT:
/*
@@ -2627,7 +2634,7 @@ TdsPrintTup(TupleTableSlot *slot, DestReceiver *self)
}
}
- if (nullMapSize < simpleRowSize)
+ if (nullMapSize <= simpleRowSize)
{
rowToken = TDS_TOKEN_NBCROW;
}
@@ -2710,7 +2717,6 @@ TdsPrintTup(TupleTableSlot *slot, DestReceiver *self)
break;
case TDS_TYPE_CHAR:
case TDS_TYPE_NCHAR:
- case TDS_TYPE_XML:
case TDS_TYPE_BINARY:
/*
@@ -2719,6 +2725,14 @@ TdsPrintTup(TupleTableSlot *slot, DestReceiver *self)
*/
TdsPutInt16LE(0xffff);
break;
+ case TDS_TYPE_XML:
+
+ /*
+ * In case of TDS version lower than or equal to 7.3A,
+ * we need to send 0xffffffffffffffff (PLP_NULL)
+ */
+ TdsPutUInt64LE(0xffffffffffffffff);
+ break;
case TDS_TYPE_SQLVARIANT:
/*
diff --git a/test/JDBC/expected/TestXML.out b/test/JDBC/expected/TestXML.out
index dc7168f245..1c68f4a9b0 100644
--- a/test/JDBC/expected/TestXML.out
+++ b/test/JDBC/expected/TestXML.out
@@ -27,3 +27,28 @@ xml
~~END~~
DROP TABLE XML_dt;
+
+CREATE TABLE [dbo].[notification_definition]([id] [bigint] NOT NULL,[name_tx] [nvarchar](200) NOT NULL,[description_tx] [nvarchar](max) NULL,[schedule_xml] [xml] NULL,[default_sender_tx] [nvarchar](200) NULL,[lock_id] [tinyint] NOT NULL,[settings_xml] [xml] NULL,[agency_id] [bigint] NULL)
+INSERT [dbo].[NOTIFICATION_DEFINITION] VALUES (13, N'INTRA_MSG', N'Intra-System Message', NULL, N'donotreply_OPMQA@ospreycompliancesuite.com', 63,N'NTF_SUB_INTRA_MSGNTF_MSG_INTRA_MSGPolicyDocumentTemplateVars11', 1)
+~~ROW COUNT: 1~~
+
+SELECT ID,NAME_TX,LOCK_ID,DESCRIPTION_TX,N'' as emptystring, SCHEDULE_XML,DEFAULT_SENDER_TX,SETTINGS_XML,AGENCY_ID FROM NOTIFICATION_DEFINITION
+~~START~~
+bigint#!#nvarchar#!#tinyint#!#nvarchar#!#nvarchar#!#xml#!#nvarchar#!#xml#!#bigint
+13#!#INTRA_MSG#!#63#!#Intra-System Message#!##!##!#donotreply_OPMQA@ospreycompliancesuite.com#!#NTF_SUB_INTRA_MSGNTF_MSG_INTRA_MSGPolicyDocumentTemplateVars11#!#1
+~~END~~
+
+DROP TABLE [dbo].[notification_definition];
+
+CREATE TABLE [dbo].[notification_definition]([id] [bigint] NOT NULL,[name_tx] [nvarchar](200) NOT NULL,[description_tx] [nvarchar](max) NULL,[schedule_xml] [xml] NULL,[default_sender_tx] [nvarchar](200) NULL,[lock_id] [tinyint] NOT NULL,[settings_xml] [xml] NULL,[agency_id] [bigint] NULL)
+prepst#!# INSERT [dbo].[NOTIFICATION_DEFINITION] VALUES(?, ?, ?, ?, ?, ?, ?, ?) #!#bigint|-|a|-|13#!#nvarchar|-|b|-|INTRA_MSG#!#nvarchar|-|c|-|Intra-System Message#!#XML|-|d|-|NULL#!#nvarchar|-|e|-|donotreply_OPMQA#!#tinyint|-|f|-|63#!#XML|-|g|-|NTF_SUB_INTRA_MSGNTF_MSG_INTRA_MSGPolicyDocumentTemplateVars11#!#bigint|-|h|-|1
+~~ROW COUNT: 1~~
+
+#INSERT [dbo].[NOTIFICATION_DEFINITION] VALUES (13, N'INTRA_MSG', N'Intra-System Message', NULL, N'donotreply_OPMQA@ospreycompliancesuite.com', 63,N'NTF_SUB_INTRA_MSGNTF_MSG_INTRA_MSGPolicyDocumentTemplateVars11', 1)
+SELECT ID,NAME_TX,LOCK_ID,DESCRIPTION_TX,N'' as emptystring, SCHEDULE_XML,DEFAULT_SENDER_TX,SETTINGS_XML,AGENCY_ID FROM NOTIFICATION_DEFINITION
+~~START~~
+bigint#!#nvarchar#!#tinyint#!#nvarchar#!#nvarchar#!#xml#!#nvarchar#!#xml#!#bigint
+13#!#INTRA_MSG#!#63#!#Intra-System Message#!##!#NULL#!#donotreply_OPMQA#!#NTF_SUB_INTRA_MSGNTF_MSG_INTRA_MSGPolicyDocumentTemplateVars11#!#1
+~~END~~
+
+DROP TABLE [dbo].[notification_definition];
diff --git a/test/JDBC/input/datatypes/TestXML.txt b/test/JDBC/input/datatypes/TestXML.txt
index 11b9ac8e13..89898fee9a 100644
--- a/test/JDBC/input/datatypes/TestXML.txt
+++ b/test/JDBC/input/datatypes/TestXML.txt
@@ -8,4 +8,15 @@ INSERT INTO XML_dt values(NULL)
#INSERT INTO XML_dt values('')
INSERT INTO XML_dt values(Contact Name 2YYY-YYY-YYYY)
SELECT * FROM XML_dt;
-DROP TABLE XML_dt;
\ No newline at end of file
+DROP TABLE XML_dt;
+
+CREATE TABLE [dbo].[notification_definition]([id] [bigint] NOT NULL,[name_tx] [nvarchar](200) NOT NULL,[description_tx] [nvarchar](max) NULL,[schedule_xml] [xml] NULL,[default_sender_tx] [nvarchar](200) NULL,[lock_id] [tinyint] NOT NULL,[settings_xml] [xml] NULL,[agency_id] [bigint] NULL)
+INSERT [dbo].[NOTIFICATION_DEFINITION] VALUES (13, N'INTRA_MSG', N'Intra-System Message', NULL, N'donotreply_OPMQA@ospreycompliancesuite.com', 63,N'NTF_SUB_INTRA_MSGNTF_MSG_INTRA_MSGPolicyDocumentTemplateVars11', 1)
+SELECT ID,NAME_TX,LOCK_ID,DESCRIPTION_TX,N'' as emptystring, SCHEDULE_XML,DEFAULT_SENDER_TX,SETTINGS_XML,AGENCY_ID FROM NOTIFICATION_DEFINITION
+DROP TABLE [dbo].[notification_definition];
+
+CREATE TABLE [dbo].[notification_definition]([id] [bigint] NOT NULL,[name_tx] [nvarchar](200) NOT NULL,[description_tx] [nvarchar](max) NULL,[schedule_xml] [xml] NULL,[default_sender_tx] [nvarchar](200) NULL,[lock_id] [tinyint] NOT NULL,[settings_xml] [xml] NULL,[agency_id] [bigint] NULL)
+prepst#!# INSERT [dbo].[NOTIFICATION_DEFINITION] VALUES(@a, @b, @c, @d, @e, @f, @g, @h) #!#bigint|-|a|-|13#!#nvarchar|-|b|-|INTRA_MSG#!#nvarchar|-|c|-|Intra-System Message#!#XML|-|d|-|NULL#!#nvarchar|-|e|-|donotreply_OPMQA#!#tinyint|-|f|-|63#!#XML|-|g|-|NTF_SUB_INTRA_MSGNTF_MSG_INTRA_MSGPolicyDocumentTemplateVars11#!#bigint|-|h|-|1
+#INSERT [dbo].[NOTIFICATION_DEFINITION] VALUES (13, N'INTRA_MSG', N'Intra-System Message', NULL, N'donotreply_OPMQA@ospreycompliancesuite.com', 63,N'NTF_SUB_INTRA_MSGNTF_MSG_INTRA_MSGPolicyDocumentTemplateVars11', 1)
+SELECT ID,NAME_TX,LOCK_ID,DESCRIPTION_TX,N'' as emptystring, SCHEDULE_XML,DEFAULT_SENDER_TX,SETTINGS_XML,AGENCY_ID FROM NOTIFICATION_DEFINITION
+DROP TABLE [dbo].[notification_definition];