Commit raw version of adrian's null import patch so i can work on it elsewhere.
authorchriskl <chriskl>
Wed, 5 Oct 2005 13:05:32 +0000 (13:05 +0000)
committerchriskl <chriskl>
Wed, 5 Oct 2005 13:05:32 +0000 (13:05 +0000)
BUGS
dataimport.php
lang/english.php
lang/recoded/english.php
tblproperties.php

diff --git a/BUGS b/BUGS
index 4f7c8e2da665b08c1f790f2670389f4a24a7cb30..ee8459d279c158319164daf51100083b31728e4a 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -11,6 +11,7 @@ dump sequences when dumping tables
 fix dumping clustering info
 
 Need to fix:
+* After changing password need to update data structures to avoid logouts
 * The getType function needs to be ported to 7.2 and 7.3 classes to add
   pretty type name and schema support
 * Report login errors
index 0734deb198c7790d5e191e6a88f7c8e1e7d43f91..312143cb409687bef45215d5be708a8e9a7cdc19 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Does an import to a particular table from a text file
         *
-        * $Id: dataimport.php,v 1.8 2005/03/04 02:27:38 chriskl Exp $
+        * $Id: dataimport.php,v 1.9 2005/10/05 13:05:32 chriskl Exp $
         */
 
        // Prevent timeouts on large exports (non-safe mode only)
                } 
        }
 
+       function LoadNULLArray(&$Array) {
+               $Success = true;
+               $AllowedNulls = $_POST['AllowedNulls'];
+               if (!is_null($AllowedNulls)) {
+                       $Array = array();
+                       foreach($AllowedNulls as $NullChar) {
+                               if ($NullChar == 'Default') {
+                                       $Array[2] = "\\N";
+                               } else if ($NullChar == 'NULL') {
+                                       $Array[0] = "NULL";
+                               } else if ($NullChar == 'EmptyString') {
+                                       $Array[1] = null;
+                               } else {
+                                       $misc->printMsg(sprintf($lang['strimporter-badnull'], $NullChar));
+                                       exit;
+                               }
+                       }
+               }
+       }
+
+       function DetermineNull($field, $NullArray) {
+               $FoundANull = false;
+               while((list($Ignored, $Nulls) = each($NullArray)) && ($FoundANull == false)) {
+                       if ($Nulls == $field) {
+                               $FoundANull = true;
+                       }
+               }
+               reset($NullArray);
+               return $FoundANull;
+       }
+
 
        $misc->printHeader($lang['strimport']);
        $misc->printTrail('table');
                $fd = fopen($_FILES['source']['tmp_name'], 'r');
                // Check that file was opened successfully
                if ($fd !== false) {            
+                       $NullArray = null;
+                       LoadNULLArray($NullArray);
                        $status = $data->beginTransaction();
                        if ($status != 0) {
-                               $misc->printMsg($lang['strimporterror']);
+                               $misc->printMsg($lang['strimporterror-badtransaction']);
                                exit;
                        }
 
                                                break;
                                        default:
                                                $data->rollbackTransaction();
-                                               $misc->printMsg($lang['strimporterror']);
+                                               $misc->printMsg($lang['strimporterror-fileformat']);
                                                exit;                   
                                }
                        }
                                        else $csv_delimiter = "\t";
                                        // Get first line of field names
                                        $fields = fgetcsv($fd, $csv_max_line, $csv_delimiter);
-                                       $row = 1;
+                                       $row = 2; //We start on the line AFTER the field names
                                        while ($line = fgetcsv($fd, $csv_max_line, $csv_delimiter)) {
                                                // Build value map
                                                $vars = array();
                                                foreach ($fields as $f) {
                                                        // Check that there is a column
                                                        if (!isset($line[$i])) {
-                                                               $misc->printMsg(sprintf($lang['strimporterrorline'], $row));
+                                                               $misc->printMsg(sprintf($lang['strimporterrorline-badcolumnnum'], $row));
                                                                exit;
                                                        }
                                                        // Check for nulls
-                                                       if ($line[$i] == '\\N') $nulls[$f] = 'on';
+                                                       if (DetermineNull($line[$i], $NullArray)) {
+                                                               $nulls[$f] = 'on';
+                                                       }
                                                        // Add to value array
                                                        $vars[$f] = $line[$i];
                                                        // Format is always VALUE
                                                $status = $data->insertRow($_REQUEST['table'], $vars, $nulls, $format, $types);
                                                if ($status != 0) {
                                                        $data->rollbackTransaction();
-                                                       $misc->printMsg(sprintf($lang['strimporterrorline'], $row));
+                                                       $misc->printMsg(sprintf($lang['strimporterrorline-dberror'], $row));
                                                        exit;
                                                }
                                                $row++;
        
                        $status = $data->endTransaction();
                        if ($status != 0) {
-                               $misc->printMsg($lang['strimporterror']);
+                               $misc->printMsg($lang['strimporterror-badtransaction']);
                                exit;
                        }
                        fclose($fd);
                }
                else {
                        // File could not be opened
-                       $misc->printMsg($lang['strimporterror']);
+                       $misc->printMsg($lang['strimporterror-unopenedfile']);
                }
        }
        else {
                // Upload went wrong
-               $misc->printMsg($lang['strimporterror']);
+               $misc->printMsg($lang['strimporterror-uploadedfile']);
        }
        
        $misc->printFooter();
index a306485fd5418ab625c6a8c3add87b6908383c41..887557b62444910d9897729c399a432b53ecfc82 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.181 2005/08/11 23:01:44 soranzo Exp $
+        * $Id: english.php,v 1.182 2005/10/05 13:05:32 chriskl Exp $
         */
 
        // Language and character set
        $lang['strprimary'] = 'Primary';
        $lang['strexport'] = 'Export';
        $lang['strimport'] = 'Import';
+       $lang['strAllowedNulls'] = 'Allowed Null Characters';
+       $lang['strNULL'] = 'NULL (The word)';
+       $lang['strEmptyString'] = 'Empty String/Field';
+       $lang['strBackslashN'] = '\N (Export Default)';
        $lang['strsql'] = 'SQL';
        $lang['stradmin'] = 'Admin';
        $lang['strvacuum'] = 'Vacuum';
        $lang['strnoreportsdb'] = 'You have not created the reports database. Read the INSTALL file for directions.';
        $lang['strnouploads'] = 'File uploads are disabled.';
        $lang['strimporterror'] = 'Import error.';
+       $lang['strimporter-badnull'] = 'The NULL character you have supplied [%s], has not been configured for use yet.';
+       $lang['strimporterror-badtransaction'] = 'Import error (There was a problem starting/ending the transaction).';
+       $lang['strimporterror-fileformat'] = 'Import error (Failed to determine which file format was given).';
        $lang['strimporterrorline'] = 'Import error on line %s.';
+       $lang['strimporterrorline-badcolumnnum'] = 'Import error on line %s.  (This line does not possess the correct number of columns)';
+       $lang['strimporterrorline-dberror'] = 'Import error on line %s.  (This line could not be inserted into the database)';
+       $lang['strimporterror-unopenedfile'] = 'Import error (Uploaded file could not be opened by the import engine)';
+       $lang['strimporterror-uploadedfile'] = 'Import error:  (File could not be uploaded to the server)';
        $lang['strcannotdumponwindows'] = 'Dumping of complex table and schema names on Windows is not supported.';
 
        // Tables
index 52b1ee2a2963b60afa3dfa1d179a0e45f68d2026..4b20c35849a386ab36d6e22c42ac81cef5800c6a 100644 (file)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.133 2005/08/11 23:01:45 soranzo Exp $
+        * $Id: english.php,v 1.134 2005/10/05 13:05:32 chriskl Exp $
         */
 
        // Language and character set
        $lang['strprimary'] = 'Primary';
        $lang['strexport'] = 'Export';
        $lang['strimport'] = 'Import';
+       $lang['strAllowedNulls'] = 'Allowed Null Characters';
+       $lang['strNULL'] = 'NULL (The word)';
+       $lang['strEmptyString'] = 'Empty String/Field';
+       $lang['strBackslashN'] = '\N (Export Default)';
        $lang['strsql'] = 'SQL';
        $lang['stradmin'] = 'Admin';
        $lang['strvacuum'] = 'Vacuum';
        $lang['strnoreportsdb'] = 'You have not created the reports database. Read the INSTALL file for directions.';
        $lang['strnouploads'] = 'File uploads are disabled.';
        $lang['strimporterror'] = 'Import error.';
+       $lang['strimporter-badnull'] = 'The NULL character you have supplied [%s], has not been configured for use yet.';
+       $lang['strimporterror-badtransaction'] = 'Import error (There was a problem starting/ending the transaction).';
+       $lang['strimporterror-fileformat'] = 'Import error (Failed to determine which file format was given).';
        $lang['strimporterrorline'] = 'Import error on line %s.';
+       $lang['strimporterrorline-badcolumnnum'] = 'Import error on line %s.  (This line does not possess the correct number of columns)';
+       $lang['strimporterrorline-dberror'] = 'Import error on line %s.  (This line could not be inserted into the database)';
+       $lang['strimporterror-unopenedfile'] = 'Import error (Uploaded file could not be opened by the import engine)';
+       $lang['strimporterror-uploadedfile'] = 'Import error:  (File could not be uploaded to the server)';
        $lang['strcannotdumponwindows'] = 'Dumping of complex table and schema names on Windows is not supported.';
 
        // Tables
index 29fbda3364f5a3efce03f4a451e1193de75f0aa1..02c46ce7b8384865607cb1f64bf3b63f720fec1c 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List tables in a database
         *
-        * $Id: tblproperties.php,v 1.63 2005/05/02 15:47:24 chriskl Exp $
+        * $Id: tblproperties.php,v 1.64 2005/10/05 13:05:32 chriskl Exp $
         */
 
        // Include application functions
                                        echo "<option value=\"xml\">XML</option>\n";
                                }
                                echo "</select>\n</td>\n</tr>\n";
+                               echo "<tr><th class=\"data left required\">{$lang['strAllowedNulls']}</th>";
+                               echo "<td><select multiple size=\"3\" name=\"AllowedNulls[]\">\n";
+                               echo "<option value=\"Default\">{$lang['strBackslashN']}</option>\n";
+                               echo "<option value=\"NULL\">{$lang['strNULL']}</option>\n";
+                               echo "<option value=\"EmptyString\">{$lang['strEmptyString'] }</option>\n";
+                               echo "</select>\n</td>\n</tr>\n";
                                echo "<tr><th class=\"data left required\">{$lang['strfile']}</th>";
                                echo "<td><input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"{$max_size}\" />\n";
                                echo "<input type=\"file\" name=\"source\" />\n";