fix bug #1859646
authorioguix <ioguix>
Fri, 28 Dec 2007 17:43:25 +0000 (17:43 +0000)
committerioguix <ioguix>
Fri, 28 Dec 2007 17:43:25 +0000 (17:43 +0000)
classes/database/Postgres83.php
functions.php

index 4520c13c8fa4aad03a77d423c50b815219186908..8d96e65eea51910f346d926fd1618b9f080cded1 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * PostgreSQL 8.3 support
  *
- * $Id: Postgres83.php,v 1.16 2007/12/12 04:11:10 xzilla Exp $
+ * $Id: Postgres83.php,v 1.17 2007/12/28 17:43:26 ioguix Exp $
  */
 
 include_once('./classes/database/Postgres82.php');
@@ -648,6 +648,8 @@ class Postgres83 extends Postgres82 {
                return $this->selectSet($sql);
        }
 
+       // Function methods
+
        /**
         * Creates a new function.
         * @param $funcname The name of the function to create
@@ -696,7 +698,8 @@ class Postgres83 extends Postgres82 {
                $sql .= " LANGUAGE \"{$language}\"";
 
                // Add costs
-               $sql .= " COST {$cost}";
+               if (!empty($cost))
+                       $sql .= " COST {$cost}";
 
                if ($rows <> 0 ){
                        $sql .= " ROWS {$rows}";
index dd5ca07b4693236fed3b1209d8d4b3ad5fe63c4f..b42c11ae34fd0e36f484e5e2188703a5ebd11fcc 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Manage functions in a database
         *
-        * $Id: functions.php,v 1.74 2007/12/16 01:14:22 ioguix Exp $
+        * $Id: functions.php,v 1.75 2007/12/28 17:43:25 ioguix Exp $
         */
 
        // Include application functions
        function doDrop($confirm) {
                global $data, $misc;
                global $lang, $_reload_browser;
-               
+
                if (empty($_REQUEST['function']) && empty($_REQUEST['ma'])) {
                        doDefault($lang['strspecifyfunctiontodrop']);
                        exit();
                if ($confirm) {
                        $misc->printTrail('schema');
                        $misc->printTitle($lang['strdrop'],'pg.function.drop');
-                       
+
                        echo "<form action=\"functions.php\" method=\"post\">\n";
-                       
+
                        //If multi drop
                        if (isset($_REQUEST['ma'])) {
                                foreach($_REQUEST['ma'] as $v) {
                        }
 
                        echo "<input type=\"hidden\" name=\"action\" value=\"drop\" />\n";
-                       
+
                        echo $misc->form;
                        // Show cascade drop option if supportd
                        if ($data->hasDropBehavior()) {
                elseif ($fnlang != 'internal' && !$def) doCreate($lang['strfunctionneedsdef'],$szJS);
                else {
                        // Append array symbol to type if chosen
-                       $status = $data->createFunction($_POST['formFunction'], empty($_POST["nojs"]) ? buildFunctionArguments($_POST) : $_POST["formArguments"],
+                       $status = $data->createFunction($_POST['formFunction'], empty($_POST['nojs'])? buildFunctionArguments($_POST) : $_POST['formArguments'],
                                        $_POST['formReturns'] . $_POST['formArray'] , $def , $_POST['formLanguage'],
                                        $_POST['formProperties'], $_POST['formSetOf'] == 'SETOF',
                                        $cost, $rows, false);
         * Build out the function arguments string
         */
        function buildFunctionArguments($arrayVars) {
-               $arrayArgs = array();
-               foreach($arrayVars["formArgName"] as $pK => $pV) {
-                       $arrayArgs[] = $arrayVars["formArgModes"][$pK]." ". trim($pV) ." ". trim($arrayVars["formArgType"][$pK]) . $arrayVars["formArgArray"][$pK];
+               if(isset($_POST['formArgName'])) {
+                       $arrayArgs = array();
+                       foreach($arrayVars['formArgName'] as $pK => $pV) {
+                               $arrayArgs[] = $arrayVars['formArgModes'][$pK].' '. trim($pV) .' '. trim($arrayVars['formArgType'][$pK]) . $arrayVars['formArgArray'][$pK];
+                       }
+                       return implode(",",$arrayArgs);
                }
-               return implode(",",$arrayArgs);
+               return '';
        }
 
        /**