Changeset 10039
- Timestamp:
- 11/29/08 14:15:44 (1 month ago)
- Files:
-
- branches/0.8/jaws/html/libraries/pear/MDB2/Driver/Function/pgsql.php (modified) (2 diffs)
- branches/0.8/jaws/html/libraries/pear/MDB2/Driver/Manager/pgsql.php (modified) (6 diffs)
- branches/0.8/jaws/html/libraries/pear/MDB2/Driver/Reverse/pgsql.php (modified) (2 diffs)
- branches/0.8/jaws/html/libraries/pear/MDB2/Driver/pgsql.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/0.8/jaws/html/libraries/pear/MDB2/Driver/Function/pgsql.php
r7942 r10039 43 43 // +----------------------------------------------------------------------+ 44 44 // 45 // $Id: pgsql.php,v 1.1 0 2008/02/17 18:54:08quipo Exp $45 // $Id: pgsql.php,v 1.11 2008/11/09 19:46:50 quipo Exp $ 46 46 47 47 require_once 'MDB2/Driver/Function/Common.php'; … … 94 94 function unixtimestamp($expression) 95 95 { 96 return 'EXTRACT(EPOCH FROM DATE_TRUNC(\'seconds\', TIMESTAMP '. $expression.'))';96 return 'EXTRACT(EPOCH FROM DATE_TRUNC(\'seconds\', CAST ((' . $expression . ') AS TIMESTAMP)))'; 97 97 } 98 98 branches/0.8/jaws/html/libraries/pear/MDB2/Driver/Manager/pgsql.php
r10037 r10039 43 43 // +----------------------------------------------------------------------+ 44 44 // 45 // $Id: pgsql.php,v 1.8 4 2008/05/13 14:59:30 quipoExp $45 // $Id: pgsql.php,v 1.87 2008/11/29 14:09:59 afz Exp $ 46 46 47 47 require_once 'MDB2/Driver/Manager/Common.php'; … … 396 396 } 397 397 $db->loadModule('Datatype', null, true); 398 $query = "ALTER $field_name TYPE ".$db->datatype->getTypeDeclaration($field['definition']); 398 $type = $db->datatype->getTypeDeclaration($field['definition']); 399 $query = "ALTER $field_name TYPE $type USING CAST($field_name AS $type)"; 399 400 $result = $db->exec("ALTER TABLE $name $query"); 400 401 if (PEAR::isError($result)) { … … 685 686 } 686 687 688 list($schema, $table) = $this->splitTableSchema($table); 689 687 690 $table = $db->quoteIdentifier($table, true); 691 if (!empty($schema)) { 692 $table = $db->quoteIdentifier($schema, true) . '.' .$table; 693 } 688 694 $db->setLimit(1); 689 695 $result2 = $db->query("SELECT * FROM $table"); … … 716 722 } 717 723 724 list($schema, $table) = $this->splitTableSchema($table); 725 718 726 $table = $db->quote($table, 'text'); 719 $subquery = "SELECT indexrelid FROM pg_index, pg_class"; 720 $subquery.= " WHERE pg_class.relname=$table AND pg_class.oid=pg_index.indrelid AND indisunique != 't' AND indisprimary != 't'"; 727 $subquery = "SELECT indexrelid 728 FROM pg_index 729 LEFT JOIN pg_class ON pg_class.oid = pg_index.indrelid 730 LEFT JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid 731 WHERE pg_class.relname = $table 732 AND indisunique != 't' 733 AND indisprimary != 't'"; 734 if (!empty($schema)) { 735 $subquery .= ' AND pg_namespace.nspname = '.$db->quote($schema, 'text'); 736 } 721 737 $query = "SELECT relname FROM pg_class WHERE oid IN ($subquery)"; 722 738 $indexes = $db->queryCol($query, 'text'); … … 758 774 return $db; 759 775 } 760 776 761 777 // is it an UNIQUE index? 762 778 $query = 'SELECT relname … … 807 823 } 808 824 825 list($schema, $table) = $this->splitTableSchema($table); 826 809 827 $table = $db->quote($table, 'text'); 810 828 $query = 'SELECT conname 811 FROM pg_constraint, pg_class 812 WHERE pg_constraint.conrelid = pg_class.oid 813 AND relname = '.$table.' 814 UNION DISTINCT 829 FROM pg_constraint 830 LEFT JOIN pg_class ON pg_constraint.conrelid = pg_class.oid 831 LEFT JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid 832 WHERE relname = ' .$table; 833 if (!empty($schema)) { 834 $query .= ' AND pg_namespace.nspname = ' . $db->quote($schema, 'text'); 835 } 836 $query .= ' 837 UNION DISTINCT 815 838 SELECT relname 816 839 FROM pg_class 817 840 WHERE oid IN ( 818 841 SELECT indexrelid 819 FROM pg_index, pg_class 842 FROM pg_index 843 LEFT JOIN pg_class ON pg_class.oid = pg_index.indrelid 844 LEFT JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid 820 845 WHERE pg_class.relname = '.$table.' 821 AND pg_class.oid = pg_index.indrelid 822 AND indisunique = \'t\')'; 846 AND indisunique = \'t\''; 847 if (!empty($schema)) { 848 $query .= ' AND pg_namespace.nspname = ' . $db->quote($schema, 'text'); 849 } 850 $query .= ')'; 823 851 $constraints = $db->queryCol($query); 824 852 if (PEAR::isError($constraints)) { branches/0.8/jaws/html/libraries/pear/MDB2/Driver/Reverse/pgsql.php
r9167 r10039 44 44 // +----------------------------------------------------------------------+ 45 45 // 46 // $Id: pgsql.php,v 1.7 4 2008/05/13 15:45:46quipo Exp $46 // $Id: pgsql.php,v 1.75 2008/08/22 16:36:20 quipo Exp $ 47 47 48 48 require_once 'MDB2/Driver/Reverse/Common.php'; … … 146 146 && !preg_match("/nextval\('([^']+)'/", $column['default']) 147 147 ) { 148 $pattern = '/ (\'.*\')::[\w ]+$/i';148 $pattern = '/^\'(.*)\'::[\w ]+$/i'; 149 149 $default = $column['default'];#substr($column['adsrc'], 1, -1); 150 150 if (is_null($default) && $notnull) { branches/0.8/jaws/html/libraries/pear/MDB2/Driver/pgsql.php
r9560 r10039 44 44 // +----------------------------------------------------------------------+ 45 45 // 46 // $Id: pgsql.php,v 1.20 1 2008/09/24 06:26:53afz Exp $46 // $Id: pgsql.php,v 1.203 2008/11/29 14:04:46 afz Exp $ 47 47 48 48 /** … … 136 136 => MDB2_ERROR_NOSUCHTABLE, 137 137 '/database .* does not exist/' 138 => MDB2_ERROR_NOT_FOUND, 139 '/constraint .* does not exist/' 138 140 => MDB2_ERROR_NOT_FOUND, 139 141 '/index .* does not exist/' … … 1393 1395 * @param mixed $result_class string which specifies which result class to use 1394 1396 * @param mixed $result_wrap_class string which specifies which class to wrap results in 1395 * @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure 1397 * 1398 * @return mixed MDB2_Result or integer (affected rows) on success, 1399 * a MDB2 error on failure 1396 1400 * @access private 1397 1401 */
