From: U-QUAN-W4\Administrator Date: Mon, 1 Feb 2010 13:46:40 +0000 (+0800) Subject: bug fix 2010/02/01 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=add5970099ec907a96af75b8aae7556fda1db37e;p=users%2Fquan74%2Fpgadmin-import.git bug fix 2010/02/01 --- diff --git a/pgadmin/frm/frmImport.cpp b/pgadmin/frm/frmImport.cpp index d27f17ca5..7bcda5660 100755 --- a/pgadmin/frm/frmImport.cpp +++ b/pgadmin/frm/frmImport.cpp @@ -1252,11 +1252,12 @@ void frmImport::OnColSettingFormatStyle(wxCommandEvent &ev) void frmImport::OnColSettingCellChange(wxGridEvent &ev) { - int evrownr = ev.GetRow(); - if (m_colsettingerrnum==-1) return; + int evrownr = ev.GetRow(); + + ResetColSettingOnEmptyColEditor(evrownr); ParseColsImpSetting(evrownr); } @@ -1603,43 +1604,43 @@ void frmImport::ImportData() return; } m_impconn->SetNonblocking(); + } - if (m_impconn->ExecuteVoid(wxT("BEGIN TRANSACTION;"), false)) + if (m_impconn && m_impconn->ExecuteVoid(wxT("BEGIN TRANSACTION;"), false)) + { + if (logstmt) { - if (logstmt) + if (logtoscr) { - if (logtoscr) - { - txtLogMessages->AppendText(wxT("BEGIN TRANSACTION;")); - txtLogMessages->AppendText(END_OF_LINE); - } - if (m_logfile) - { - m_logfile->Write(wxT("BEGIN TRANSACTION;")); - m_logfile->Write(END_OF_LINE); - } + txtLogMessages->AppendText(wxT("BEGIN TRANSACTION;")); + txtLogMessages->AppendText(END_OF_LINE); } - - txtLogMessages->AppendText(_("Transaction begin.")); - txtLogMessages->AppendText(END_OF_LINE); - if (loginfo && m_logfile) + if (m_logfile) { - m_logfile->Write(_("Transaction begin.")); + m_logfile->Write(wxT("BEGIN TRANSACTION;")); m_logfile->Write(END_OF_LINE); } } - else - { - if (logerror) - { - if (logtoscr) - txtLogMessages->AppendText(m_impconn->GetLastError()); - if (m_logfile) - m_logfile->Write(m_impconn->GetLastError()); - } - return; + txtLogMessages->AppendText(_("Transaction begin.")); + txtLogMessages->AppendText(END_OF_LINE); + if (loginfo && m_logfile) + { + m_logfile->Write(_("Transaction begin.")); + m_logfile->Write(END_OF_LINE); + } + } + else + { + if (logerror) + { + if (logtoscr) + txtLogMessages->AppendText(m_impconn->GetLastError()); + if (m_logfile) + m_logfile->Write(m_impconn->GetLastError()); } + + return; } if (impmode==IMPORTMODECOPY) @@ -4321,12 +4322,12 @@ bool frmImport::GenCSVSQLData(wxString& rowdatalist, wxString& rowlog, wxString* else rowdatalist.Append(wxT("NULL")); } - else if (m_colonemptyact[dbcolidx]==IMPDEFAULT) + else if (impmode==IMPORTMODEINSERT && m_colonemptyact[dbcolidx]==IMPDEFAULT) rowdatalist.Append(wxT("DEFAULT")); else if (m_colonemptyact[dbcolidx]==IMPEMPTY) { - if (impmode==IMPORTMODECOPY) - rowdatalist.Append(wxT("\"\"")); + if (impmode==IMPORTMODECOPY); + //rowdatalist.Append(wxT("\"\"")); else rowdatalist.Append(wxT("''")); } @@ -4406,7 +4407,7 @@ bool frmImport::GenCSVSQLData(wxString& rowdatalist, wxString& rowlog, wxString* haserror = true; rowdatalist.Append(wxT("")); } - else if (m_colonemptyact[dbcolidx]==IMPDEFAULT) + else if (impmode==IMPORTMODECOPY && m_colonemptyact[dbcolidx]==IMPDEFAULT) rowdatalist.Append(wxT("DEFAULT")); else if (m_colonemptyact[dbcolidx]==IMPZERONUMBER) rowdatalist.Append(IMPZERONUMBERDISP); @@ -4414,8 +4415,8 @@ bool frmImport::GenCSVSQLData(wxString& rowdatalist, wxString& rowlog, wxString* rowdatalist.Append(IMPZEROINTERVALDISP); else if (m_colonemptyact[dbcolidx]==IMPEMPTY) { - if (impmode==IMPORTMODECOPY) - rowdatalist.Append(wxT("\"\"")); + if (impmode==IMPORTMODECOPY); + //rowdatalist.Append(wxT("\"\"")); else rowdatalist.Append(wxT("''")); } @@ -4695,7 +4696,7 @@ bool frmImport::GenODBCSQLData(wxString& rowvals, wxString& rowlog, SQLWCHAR** o haserror = true; rowvals.Append(wxT("")); } - else if (m_colonemptyact[dbcolidx]==IMPDEFAULT) + else if (impmode==IMPORTMODECOPY && m_colonemptyact[dbcolidx]==IMPDEFAULT) rowvals.Append(wxT("DEFAULT")); else if (m_colonemptyact[dbcolidx]==IMPZERONUMBER) rowvals.Append(IMPZERONUMBERDISP); @@ -4703,8 +4704,8 @@ bool frmImport::GenODBCSQLData(wxString& rowvals, wxString& rowlog, SQLWCHAR** o rowvals.Append(IMPZEROINTERVALDISP); else if (m_colonemptyact[dbcolidx]==IMPEMPTY) { - if (impmode==IMPORTMODECOPY) - rowvals.Append(wxT("\"\"")); + if (impmode==IMPORTMODECOPY); + //rowvals.Append(wxT("\"\"")); else rowvals.Append(wxT("''")); } @@ -4776,12 +4777,12 @@ bool frmImport::GenODBCSQLData(wxString& rowvals, wxString& rowlog, SQLWCHAR** o else rowvals.Append(wxT("NULL")); } - else if (m_colonemptyact[dbcolidx]==IMPDEFAULT) + else if (impmode==IMPORTMODECOPY && m_colonemptyact[dbcolidx]==IMPDEFAULT) rowvals.Append(wxT("DEFAULT")); else if (m_colonemptyact[dbcolidx]==IMPEMPTY) { - if (impmode==IMPORTMODECOPY) - rowvals.Append(wxT("\"\"")); + if (impmode==IMPORTMODECOPY); + //rowvals.Append(wxT("\"\"")); else rowvals.Append(wxT("''")); } @@ -5545,7 +5546,7 @@ void frmImport::ResetColSettingSrcColEditor(bool resetsrccol) } } -void frmImport::ResetColSettingOnEmptyColEditor() +void frmImport::ResetColSettingOnEmptyColEditor(int dbcolnr) { // This function will reset: // Trim column's default value @@ -5563,10 +5564,22 @@ void frmImport::ResetColSettingOnEmptyColEditor() else return; + size_t fromcolnr, tocolnr; + if (dbcolnr=wxNOT_FOUND) + { + fromcolnr = (size_t)0; + tocolnr = m_tgtcolsnum; + } + else + { + fromcolnr = (size_t)dbcolnr; + tocolnr = (size_t)dbcolnr+1; + } + size_t rowidx; wxString tgtcoltype, srccolname, onemptyact; bool hassrccol; - for (rowidx=(size_t)0; rowidxName(); srccolname = gridColSetting->GetCellValue(rowidx, SRCCOLNAMENUM); @@ -5582,8 +5595,7 @@ void frmImport::ResetColSettingOnEmptyColEditor() gridColSetting->SetCellEditor(rowidx, actcolnum, new pgGridCellChioceEditor()); gce_onempty = (pgGridCellChioceEditor*)gridColSetting->GetCellEditor(rowidx, actcolnum); - if (hassrccol) - gce_onempty->Append(IMPERRORDISP); + gce_onempty->Append(IMPERRORDISP); if ((!hassrccol || impmode==IMPORTMODEINSERT) && (!m_tgtcolsisnotnull[rowidx] || (m_tgtcolsisnotnull[rowidx] && m_tgtcolshasdef[rowidx]))) gce_onempty->Append(IMPDEFAULTDISP); if (hassrccol && !m_tgtcolsisnotnull[rowidx]) @@ -5595,20 +5607,12 @@ void frmImport::ResetColSettingOnEmptyColEditor() if (onemptyact.IsEmpty() || !gce_onempty->Contains(onemptyact)) { - if (hassrccol) - { - if (m_tgtcolsisnotnull[rowidx]) - gridColSetting->SetCellValue(rowidx, actcolnum, IMPERRORDISP); - else - gridColSetting->SetCellValue(rowidx, actcolnum, IMPDEFAULTDISP); - } + if ((!hassrccol || impmode==IMPORTMODEINSERT) && m_tgtcolshasdef[rowidx]) + gridColSetting->SetCellValue(rowidx, actcolnum, IMPDEFAULTDISP); + else if (m_tgtcolsisnotnull[rowidx]) + gridColSetting->SetCellValue(rowidx, actcolnum, IMPERRORDISP); else - { - if (!m_tgtcolsisnotnull[rowidx] || (m_tgtcolsisnotnull[rowidx] && m_tgtcolshasdef[rowidx])) - gridColSetting->SetCellValue(rowidx, actcolnum, IMPDEFAULTDISP); - else - gridColSetting->SetCellValue(rowidx, actcolnum, IMPBOOLFALSEDISP); - } + gridColSetting->SetCellValue(rowidx, actcolnum, IMPNULLDISP); } } else if (tgtcoltype==wxT("integer") || tgtcoltype==wxT("bigint") || tgtcoltype==wxT("smallint") || tgtcoltype==wxT("numeric") || @@ -5621,9 +5625,8 @@ void frmImport::ResetColSettingOnEmptyColEditor() gridColSetting->SetCellEditor(rowidx, actcolnum, new pgGridCellChioceEditor()); gce_onempty = (pgGridCellChioceEditor*)gridColSetting->GetCellEditor(rowidx, actcolnum); - if (hassrccol) - gce_onempty->Append(IMPERRORDISP); - if (!m_tgtcolsisnotnull[rowidx] || (m_tgtcolsisnotnull[rowidx] && m_tgtcolshasdef[rowidx])) + gce_onempty->Append(IMPERRORDISP); + if ((!hassrccol || impmode==IMPORTMODEINSERT) && (!m_tgtcolsisnotnull[rowidx] || (m_tgtcolsisnotnull[rowidx] && m_tgtcolshasdef[rowidx]))) gce_onempty->Append(IMPDEFAULTDISP); if (!m_tgtcolsisnotnull[rowidx]) gce_onempty->Append(IMPNULLDISP); @@ -5634,20 +5637,12 @@ void frmImport::ResetColSettingOnEmptyColEditor() if (onemptyact.IsEmpty() || !gce_onempty->Contains(onemptyact)) { - if (hassrccol) - { - if (m_tgtcolsisnotnull[rowidx]) - gridColSetting->SetCellValue(rowidx, actcolnum, IMPERRORDISP); - else - gridColSetting->SetCellValue(rowidx, actcolnum, IMPDEFAULTDISP); - } + if ((!hassrccol || impmode==IMPORTMODEINSERT) && m_tgtcolshasdef[rowidx]) + gridColSetting->SetCellValue(rowidx, actcolnum, IMPDEFAULTDISP); + else if (m_tgtcolsisnotnull[rowidx]) + gridColSetting->SetCellValue(rowidx, actcolnum, IMPERRORDISP); else - { - if (!m_tgtcolsisnotnull[rowidx] || (m_tgtcolsisnotnull[rowidx] && m_tgtcolshasdef[rowidx])) - gridColSetting->SetCellValue(rowidx, actcolnum, IMPDEFAULTDISP); - else - gridColSetting->SetCellValue(rowidx, actcolnum, IMPZERONUMBERDISP); - } + gridColSetting->SetCellValue(rowidx, actcolnum, IMPNULLDISP); } } else if (tgtcoltype==wxT("character") || tgtcoltype == wxT("character varying") || tgtcoltype == wxT("text")) @@ -5658,13 +5653,12 @@ void frmImport::ResetColSettingOnEmptyColEditor() gridColSetting->SetCellEditor(rowidx, actcolnum, new pgGridCellChioceEditor()); gce_onempty = (pgGridCellChioceEditor*)gridColSetting->GetCellEditor(rowidx, actcolnum); - if (hassrccol) - gce_onempty->Append(IMPERRORDISP); + gce_onempty->Append(IMPERRORDISP); + if ((!hassrccol || impmode==IMPORTMODEINSERT) && (!m_tgtcolsisnotnull[rowidx] || (m_tgtcolsisnotnull[rowidx] && m_tgtcolshasdef[rowidx]))) + gce_onempty->Append(IMPDEFAULTDISP); if (!m_tgtcolsisnotnull[rowidx]) gce_onempty->Append(IMPNULLDISP); gce_onempty->Append(IMPEMPTYDISP); - if (!m_tgtcolsisnotnull[rowidx] || (m_tgtcolsisnotnull[rowidx] && m_tgtcolshasdef[rowidx])) - gce_onempty->Append(IMPDEFAULTDISP); gce_onempty->Append(IMPCONSTDISP); if (impmode==IMPORTMODEINSERT) gce_onempty->Append(IMPEXPRDISP); @@ -5680,12 +5674,11 @@ void frmImport::ResetColSettingOnEmptyColEditor() gridColSetting->SetCellEditor(rowidx, actcolnum, new pgGridCellChioceEditor()); gce_onempty = (pgGridCellChioceEditor*)gridColSetting->GetCellEditor(rowidx, actcolnum); - if (hassrccol) - gce_onempty->Append(IMPERRORDISP); + gce_onempty->Append(IMPERRORDISP); + if ((!hassrccol || impmode==IMPORTMODEINSERT) && (!m_tgtcolsisnotnull[rowidx] || (m_tgtcolsisnotnull[rowidx] && m_tgtcolshasdef[rowidx]))) + gce_onempty->Append(IMPDEFAULTDISP); if (!m_tgtcolsisnotnull[rowidx]) gce_onempty->Append(IMPNULLDISP); - if (!m_tgtcolsisnotnull[rowidx] || (m_tgtcolsisnotnull[rowidx] && m_tgtcolshasdef[rowidx])) - gce_onempty->Append(IMPDEFAULTDISP); if (impmode==IMPORTMODEINSERT) gce_onempty->Append(IMPCURDATEDISP); gce_onempty->Append(IMPCLIENTTIMEDISP); @@ -5695,20 +5688,12 @@ void frmImport::ResetColSettingOnEmptyColEditor() if (onemptyact.IsEmpty() || !gce_onempty->Contains(onemptyact)) { - if (hassrccol) - { - if (m_tgtcolsisnotnull[rowidx]) - gridColSetting->SetCellValue(rowidx, actcolnum, IMPERRORDISP); - else - gridColSetting->SetCellValue(rowidx, actcolnum, IMPDEFAULTDISP); - } + if ((!hassrccol || impmode==IMPORTMODEINSERT) && m_tgtcolshasdef[rowidx]) + gridColSetting->SetCellValue(rowidx, actcolnum, IMPDEFAULTDISP); + else if (m_tgtcolsisnotnull[rowidx]) + gridColSetting->SetCellValue(rowidx, actcolnum, IMPERRORDISP); else - { - if (!m_tgtcolsisnotnull[rowidx] || (m_tgtcolsisnotnull[rowidx] && m_tgtcolshasdef[rowidx])) - gridColSetting->SetCellValue(rowidx, actcolnum, IMPDEFAULTDISP); - else - gridColSetting->SetCellValue(rowidx, actcolnum, wxT("")); - } + gridColSetting->SetCellValue(rowidx, actcolnum, IMPNULLDISP); } } else if (tgtcoltype == wxT("time") || tgtcoltype == wxT("timetz") @@ -5720,12 +5705,11 @@ void frmImport::ResetColSettingOnEmptyColEditor() gridColSetting->SetCellEditor(rowidx, actcolnum, new pgGridCellChioceEditor()); gce_onempty = (pgGridCellChioceEditor*)gridColSetting->GetCellEditor(rowidx, actcolnum); - if (hassrccol) - gce_onempty->Append(IMPERRORDISP); + gce_onempty->Append(IMPERRORDISP); + if ((!hassrccol || impmode==IMPORTMODEINSERT) && (!m_tgtcolsisnotnull[rowidx] || (m_tgtcolsisnotnull[rowidx] && m_tgtcolshasdef[rowidx]))) + gce_onempty->Append(IMPDEFAULTDISP); if (!m_tgtcolsisnotnull[rowidx]) gce_onempty->Append(IMPNULLDISP); - if (!m_tgtcolsisnotnull[rowidx] || (m_tgtcolsisnotnull[rowidx] && m_tgtcolshasdef[rowidx])) - gce_onempty->Append(IMPDEFAULTDISP); gce_onempty->Append(IMPCONSTDISP); if (impmode==IMPORTMODEINSERT) { @@ -5738,20 +5722,12 @@ void frmImport::ResetColSettingOnEmptyColEditor() if (onemptyact.IsEmpty() || !gce_onempty->Contains(onemptyact)) { - if (hassrccol) - { - if (m_tgtcolsisnotnull[rowidx]) - gridColSetting->SetCellValue(rowidx, actcolnum, IMPERRORDISP); - else - gridColSetting->SetCellValue(rowidx, actcolnum, IMPDEFAULTDISP); - } + if ((!hassrccol || impmode==IMPORTMODEINSERT) && m_tgtcolshasdef[rowidx]) + gridColSetting->SetCellValue(rowidx, actcolnum, IMPDEFAULTDISP); + else if (m_tgtcolsisnotnull[rowidx]) + gridColSetting->SetCellValue(rowidx, actcolnum, IMPERRORDISP); else - { - if (!m_tgtcolsisnotnull[rowidx] || (m_tgtcolsisnotnull[rowidx] && m_tgtcolshasdef[rowidx])) - gridColSetting->SetCellValue(rowidx, actcolnum, IMPDEFAULTDISP); - else - gridColSetting->SetCellValue(rowidx, actcolnum, wxT("")); - } + gridColSetting->SetCellValue(rowidx, actcolnum, IMPNULLDISP); } } else if (tgtcoltype == wxT("timestamp") || tgtcoltype == wxT("timestamptz") @@ -5763,11 +5739,10 @@ void frmImport::ResetColSettingOnEmptyColEditor() gridColSetting->SetCellEditor(rowidx, actcolnum, new pgGridCellChioceEditor()); gce_onempty = (pgGridCellChioceEditor*)gridColSetting->GetCellEditor(rowidx, actcolnum); - if (hassrccol) - gce_onempty->Append(IMPERRORDISP); + gce_onempty->Append(IMPERRORDISP); if (!m_tgtcolsisnotnull[rowidx]) gce_onempty->Append(IMPNULLDISP); - if (!m_tgtcolsisnotnull[rowidx] || (m_tgtcolsisnotnull[rowidx] && m_tgtcolshasdef[rowidx])) + if ((!hassrccol || impmode==IMPORTMODEINSERT) && (!m_tgtcolsisnotnull[rowidx] || (m_tgtcolsisnotnull[rowidx] && m_tgtcolshasdef[rowidx]))) gce_onempty->Append(IMPDEFAULTDISP); gce_onempty->Append(IMPCONSTDISP); if (impmode==IMPORTMODEINSERT) @@ -5781,20 +5756,12 @@ void frmImport::ResetColSettingOnEmptyColEditor() if (onemptyact.IsEmpty() || !gce_onempty->Contains(onemptyact)) { - if (hassrccol) - { - if (m_tgtcolsisnotnull[rowidx]) - gridColSetting->SetCellValue(rowidx, actcolnum, IMPERRORDISP); - else - gridColSetting->SetCellValue(rowidx, actcolnum, IMPDEFAULTDISP); - } + if ((!hassrccol || impmode==IMPORTMODEINSERT) && m_tgtcolshasdef[rowidx]) + gridColSetting->SetCellValue(rowidx, actcolnum, IMPDEFAULTDISP); + else if (m_tgtcolsisnotnull[rowidx]) + gridColSetting->SetCellValue(rowidx, actcolnum, IMPERRORDISP); else - { - if (!m_tgtcolsisnotnull[rowidx] || (m_tgtcolsisnotnull[rowidx] && m_tgtcolshasdef[rowidx])) - gridColSetting->SetCellValue(rowidx, actcolnum, IMPDEFAULTDISP); - else - gridColSetting->SetCellValue(rowidx, actcolnum, wxT("")); - } + gridColSetting->SetCellValue(rowidx, actcolnum, IMPNULLDISP); } } else if (tgtcoltype == wxT("interval")) @@ -5805,11 +5772,10 @@ void frmImport::ResetColSettingOnEmptyColEditor() gridColSetting->SetCellEditor(rowidx, actcolnum, new pgGridCellChioceEditor()); gce_onempty = (pgGridCellChioceEditor*)gridColSetting->GetCellEditor(rowidx, actcolnum); - if (hassrccol) - gce_onempty->Append(IMPERRORDISP); + gce_onempty->Append(IMPERRORDISP); if (!m_tgtcolsisnotnull[rowidx]) gce_onempty->Append(IMPNULLDISP); - if (!m_tgtcolsisnotnull[rowidx] || (m_tgtcolsisnotnull[rowidx] && m_tgtcolshasdef[rowidx])) + if ((!hassrccol || impmode==IMPORTMODEINSERT) && (!m_tgtcolsisnotnull[rowidx] || (m_tgtcolsisnotnull[rowidx] && m_tgtcolshasdef[rowidx]))) gce_onempty->Append(IMPDEFAULTDISP); gce_onempty->Append(IMPZEROINTERVALDISP); gce_onempty->Append(IMPCONSTDISP); @@ -5818,20 +5784,12 @@ void frmImport::ResetColSettingOnEmptyColEditor() if (onemptyact.IsEmpty() || !gce_onempty->Contains(onemptyact)) { - if (hassrccol) - { - if (m_tgtcolsisnotnull[rowidx]) - gridColSetting->SetCellValue(rowidx, actcolnum, IMPERRORDISP); - else - gridColSetting->SetCellValue(rowidx, actcolnum, IMPDEFAULTDISP); - } + if ((!hassrccol || impmode==IMPORTMODEINSERT) && m_tgtcolshasdef[rowidx]) + gridColSetting->SetCellValue(rowidx, actcolnum, IMPDEFAULTDISP); + else if (m_tgtcolsisnotnull[rowidx]) + gridColSetting->SetCellValue(rowidx, actcolnum, IMPERRORDISP); else - { - if (!m_tgtcolsisnotnull[rowidx] || (m_tgtcolsisnotnull[rowidx] && m_tgtcolshasdef[rowidx])) - gridColSetting->SetCellValue(rowidx, actcolnum, IMPDEFAULTDISP); - else - gridColSetting->SetCellValue(rowidx, actcolnum, IMPZEROINTERVALDISP); - } + gridColSetting->SetCellValue(rowidx, actcolnum, IMPNULLDISP); } } else @@ -5842,32 +5800,23 @@ void frmImport::ResetColSettingOnEmptyColEditor() gridColSetting->SetCellEditor(rowidx, actcolnum, new pgGridCellChioceEditor()); gce_onempty = (pgGridCellChioceEditor*)gridColSetting->GetCellEditor(rowidx, actcolnum); - if (hassrccol) - gce_onempty->Append(IMPERRORDISP); + gce_onempty->Append(IMPERRORDISP); + if ((!hassrccol || impmode==IMPORTMODEINSERT) && (!m_tgtcolsisnotnull[rowidx] || (m_tgtcolsisnotnull[rowidx] && m_tgtcolshasdef[rowidx]))) + gce_onempty->Append(IMPDEFAULTDISP); if (!m_tgtcolsisnotnull[rowidx]) gce_onempty->Append(IMPNULLDISP); - if (!m_tgtcolsisnotnull[rowidx] || (m_tgtcolsisnotnull[rowidx] && m_tgtcolshasdef[rowidx])) - gce_onempty->Append(IMPDEFAULTDISP); gce_onempty->Append(IMPCONSTDISP); if (impmode==IMPORTMODEINSERT) gce_onempty->Append(IMPEXPRDISP); if (onemptyact.IsEmpty() || !gce_onempty->Contains(onemptyact)) { - if (hassrccol) - { - if (m_tgtcolsisnotnull[rowidx]) - gridColSetting->SetCellValue(rowidx, actcolnum, IMPERRORDISP); - else - gridColSetting->SetCellValue(rowidx, actcolnum, IMPDEFAULTDISP); - } + if ((!hassrccol || impmode==IMPORTMODEINSERT) && m_tgtcolshasdef[rowidx]) + gridColSetting->SetCellValue(rowidx, actcolnum, IMPDEFAULTDISP); + else if (m_tgtcolsisnotnull[rowidx]) + gridColSetting->SetCellValue(rowidx, actcolnum, IMPERRORDISP); else - { - if (!m_tgtcolsisnotnull[rowidx] || (m_tgtcolsisnotnull[rowidx] && m_tgtcolshasdef[rowidx])) - gridColSetting->SetCellValue(rowidx, actcolnum, IMPDEFAULTDISP); - else - gridColSetting->SetCellValue(rowidx, actcolnum, IMPCONSTDISP); - } + gridColSetting->SetCellValue(rowidx, actcolnum, IMPNULLDISP); } } diff --git a/pgadmin/include/frm/frmImport.h b/pgadmin/include/frm/frmImport.h index 877e30a7e..eb3a2c9d6 100755 --- a/pgadmin/include/frm/frmImport.h +++ b/pgadmin/include/frm/frmImport.h @@ -165,7 +165,7 @@ private: void InitColSettingPage(); void ResetColSettingPage(); void ResetColSettingSrcColEditor(bool resetsrccol = true); - void ResetColSettingOnEmptyColEditor(); + void ResetColSettingOnEmptyColEditor(int dbcolnr = wxNOT_FOUND); void ResetColSettingFmtColEditor(); void ResetColsSettingStatus(int dbcolnr = wxNOT_FOUND); void ParseColsImpSetting(int dbcolnr = wxNOT_FOUND); diff --git a/pgadmin/include/utils/pgcsvfile.h b/pgadmin/include/utils/pgcsvfile.h index 7507dc9a8..e15778f11 100755 --- a/pgadmin/include/utils/pgcsvfile.h +++ b/pgadmin/include/utils/pgcsvfile.h @@ -14,7 +14,7 @@ class pgCSVFile public: // Archive format enum ArchiveFormat { ARCHUNKNOWN=0, ARCHZIP=0x1, ARCHTAR=0x2, ARCHGZIP=0x4, ARCHBZIP2=0x8 }; - static const uint MAXENTRYNUM = 127; + static const unsigned int MAXENTRYNUM = 127; // Unix: LF, Dos: CR LF, Mac: CR static const wxChar LF = wxT('\n');//'LF' = 0xA = 10 static const wxChar CR = wxT('\r');//'CR' = 0xD = 13 diff --git a/pgadmin/utils/pgcsvfile.cpp b/pgadmin/utils/pgcsvfile.cpp index f228a87d4..803482c0b 100755 --- a/pgadmin/utils/pgcsvfile.cpp +++ b/pgadmin/utils/pgcsvfile.cpp @@ -1280,7 +1280,14 @@ size_t pgCSVFile::GenCSVPreview(const bool isinit) break; } if (GenMoreFilePreview(NULL)==wxInvalidOffset) + { + GenHeader(); + + if (isinit) + m_pvrowsnum = m_firstrowisheader?m_pvparsedrowsnum-1:m_pvparsedrowsnum; + return m_pvparsedrowsnum; + } filedata = m_pvfilecont.GetData(); isfileeof = Eof(); }