Commit 5746fcc9 authored by Olivier Bertrand's avatar Olivier Bertrand

- Make INI and XML tables not writing null column values

modified:
  mysql-test/suite/connect/r/dbf.result
  storage/connect/tabsys.cpp
  storage/connect/tabxml.cpp
  storage/connect/tabxml.h
parent 19e9fa45
...@@ -605,7 +605,7 @@ INSERT INTO t1 VALUES ('30',DEFAULT,30,DEFAULT); ...@@ -605,7 +605,7 @@ INSERT INTO t1 VALUES ('30',DEFAULT,30,DEFAULT);
SELECT * FROM t1; SELECT * FROM t1;
c1 c2 i1 i2 c1 c2 i1 i2
10 10 10 10 10 10 10 10
20 20 0 20 def 20 123
30 def 30 123 30 def 30 123
CALL dbf_header('MYSQLD_DATADIR/test/t1.dbf'); CALL dbf_header('MYSQLD_DATADIR/test/t1.dbf');
-------- -------- -------- --------
......
...@@ -543,6 +543,10 @@ void INICOL::WriteColumn(PGLOBAL g) ...@@ -543,6 +543,10 @@ void INICOL::WriteColumn(PGLOBAL g)
if (Value != To_Val) if (Value != To_Val)
Value->SetValue_pval(To_Val, false); // Convert the updated value Value->SetValue_pval(To_Val, false); // Convert the updated value
// Null key are missing keys
if (Value->IsNull())
return;
p = Value->GetCharString(Valbuf); p = Value->GetCharString(Valbuf);
if (strlen(p) > (unsigned)Long) { if (strlen(p) > (unsigned)Long) {
......
...@@ -81,7 +81,6 @@ XMLDEF::XMLDEF(void) ...@@ -81,7 +81,6 @@ XMLDEF::XMLDEF(void)
Limit = 0; Limit = 0;
Xpand = false; Xpand = false;
Usedom = false; Usedom = false;
Skipnull = false;
} // end of XMLDEF constructor } // end of XMLDEF constructor
/***********************************************************************/ /***********************************************************************/
...@@ -144,7 +143,6 @@ bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) ...@@ -144,7 +143,6 @@ bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
DefNs = Cat->GetStringCatInfo(g, Name, "DefNs", ""); DefNs = Cat->GetStringCatInfo(g, Name, "DefNs", "");
Limit = Cat->GetIntCatInfo(Name, "Limit", 2); Limit = Cat->GetIntCatInfo(Name, "Limit", 2);
Xpand = (Cat->GetIntCatInfo(Name, "Expand", 0) != 0); Xpand = (Cat->GetIntCatInfo(Name, "Expand", 0) != 0);
Skipnull = (Cat->GetIntCatInfo(Name, "Skipnull", 0) != 0);
Header = Cat->GetIntCatInfo(Name, "Header", 0); Header = Cat->GetIntCatInfo(Name, "Header", 0);
Cat->GetCharCatInfo(Name, "Xmlsup", "*", buf, sizeof(buf)); Cat->GetCharCatInfo(Name, "Xmlsup", "*", buf, sizeof(buf));
...@@ -227,7 +225,6 @@ TDBXML::TDBXML(PXMLDEF tdp) : TDBASE(tdp) ...@@ -227,7 +225,6 @@ TDBXML::TDBXML(PXMLDEF tdp) : TDBASE(tdp)
Coltype = tdp->Coltype; Coltype = tdp->Coltype;
Limit = tdp->Limit; Limit = tdp->Limit;
Xpand = tdp->Xpand; Xpand = tdp->Xpand;
Skipnull = tdp->Skipnull;
Changed = false; Changed = false;
Checked = false; Checked = false;
NextSame = false; NextSame = false;
...@@ -272,7 +269,6 @@ TDBXML::TDBXML(PTDBXML tdbp) : TDBASE(tdbp) ...@@ -272,7 +269,6 @@ TDBXML::TDBXML(PTDBXML tdbp) : TDBASE(tdbp)
Coltype = tdbp->Coltype; Coltype = tdbp->Coltype;
Limit = tdbp->Limit; Limit = tdbp->Limit;
Xpand = tdbp->Xpand; Xpand = tdbp->Xpand;
Skipnull = tdbp->Skipnull;
Changed = tdbp->Changed; Changed = tdbp->Changed;
Checked = tdbp->Checked; Checked = tdbp->Checked;
NextSame = tdbp->NextSame; NextSame = tdbp->NextSame;
...@@ -733,7 +729,6 @@ bool TDBXML::OpenDB(PGLOBAL g) ...@@ -733,7 +729,6 @@ bool TDBXML::OpenDB(PGLOBAL g)
/* OpenDB: initialize the XML file processing. */ /* OpenDB: initialize the XML file processing. */
/*********************************************************************/ /*********************************************************************/
Write = (Mode == MODE_INSERT || Mode == MODE_UPDATE); Write = (Mode == MODE_INSERT || Mode == MODE_UPDATE);
Skipnull = (Skipnull && Mode == MODE_INSERT);
if (Initialize(g)) if (Initialize(g))
return true; return true;
...@@ -1256,7 +1251,7 @@ void XMLCOL::WriteColumn(PGLOBAL g) ...@@ -1256,7 +1251,7 @@ void XMLCOL::WriteColumn(PGLOBAL g)
if (Value != To_Val) if (Value != To_Val)
Value->SetValue_pval(To_Val, false); // Convert the updated value Value->SetValue_pval(To_Val, false); // Convert the updated value
if (Tdbp->Skipnull && Value->IsZero()) if (Value->IsNull())
return; return;
/*********************************************************************/ /*********************************************************************/
...@@ -1476,7 +1471,7 @@ void XMULCOL::WriteColumn(PGLOBAL g) ...@@ -1476,7 +1471,7 @@ void XMULCOL::WriteColumn(PGLOBAL g)
if (Value != To_Val) if (Value != To_Val)
Value->SetValue_pval(To_Val, false); // Convert the updated value Value->SetValue_pval(To_Val, false); // Convert the updated value
if (Tdbp->Skipnull && Value->IsZero()) if (Value->IsNull())
return; return;
/*********************************************************************/ /*********************************************************************/
...@@ -1692,7 +1687,7 @@ void XPOSCOL::WriteColumn(PGLOBAL g) ...@@ -1692,7 +1687,7 @@ void XPOSCOL::WriteColumn(PGLOBAL g)
if (Value != To_Val) if (Value != To_Val)
Value->SetValue_pval(To_Val, false); // Convert the updated value Value->SetValue_pval(To_Val, false); // Convert the updated value
if (Tdbp->Skipnull && Value->IsZero()) if (Value->IsNull())
return; return;
/*********************************************************************/ /*********************************************************************/
......
...@@ -52,7 +52,6 @@ class DllExport XMLDEF : public TABDEF { /* Logical table description */ ...@@ -52,7 +52,6 @@ class DllExport XMLDEF : public TABDEF { /* Logical table description */
int Header; /* n first rows are header rows */ int Header; /* n first rows are header rows */
bool Xpand; /* Put multiple tags in several rows */ bool Xpand; /* Put multiple tags in several rows */
bool Usedom; /* True: DOM, False: libxml2 */ bool Usedom; /* True: DOM, False: libxml2 */
bool Skipnull; /* True: skip writing null nodes */
}; // end of XMLDEF }; // end of XMLDEF
#if defined(INCLUDE_TDBXML) #if defined(INCLUDE_TDBXML)
...@@ -127,7 +126,6 @@ class DllExport TDBXML : public TDBASE { ...@@ -127,7 +126,6 @@ class DllExport TDBXML : public TDBASE {
bool Usedom; // True for DOM, False for libxml2 bool Usedom; // True for DOM, False for libxml2
bool Bufdone; // True when column buffers allocated bool Bufdone; // True when column buffers allocated
bool Nodedone; // True when column nodes allocated bool Nodedone; // True when column nodes allocated
bool Skipnull; // True to skip writing nullnodes
bool Void; // True if the file does not exist bool Void; // True if the file does not exist
char *Xfile; // The XML file char *Xfile; // The XML file
char *Enc; // New XML table file encoding char *Enc; // New XML table file encoding
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment