php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64609 pg_convert enum type support
Submitted: 2013-04-08 02:21 UTC Modified: 2013-06-01 21:50 UTC
From: jasen at treshna dot com Assigned: mbeccati
Status: Closed Package: PostgreSQL related
PHP Version: 5.4.13 OS: linux
Private report: No CVE-ID:
 [2013-04-08 02:21 UTC] jasen at treshna dot com
Description:
------------
pg_convert, pg_update, pg_insert 
can't handle inputs that reference enum columns.

syntactically enum columns can be treated like string columns.



Test script:
---------------
<?php
function sql_assert($c,$q)
{
	$r=pg_query($c,$q);
	if($r)
	{
		pg_free_result($r);
		return;
	}
	echo "FAILED: $q\nERROR:".pg_last_error($c)."\n";
	echo "can't initialise the test environment - giving up";
	die(1);
}
$con=pg_connect("host=127.0.0.1 user=test password=php5 dbname=phptest");
sql_assert($con,"drop type if exists enumtest cascade;");
sql_assert($con," create type enumtest as enum ( 'alpha', 'beta', 'gamma' );");
sql_assert($con," drop table if exists e_test;");
sql_assert($con," create table e_test( id integer, label text, num enumtest );");
print_r(pg_convert($con,"e_test",array('id'=>11,'label'=>'fail','num'=>'gamma')));


Expected result:
----------------
some text starting with the word Array

Actual result:
--------------
nothing.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-04-08 02:58 UTC] jasen at treshna dot com
on looking at the source 
php_pgsql_convert() in ext/pgsql/pgsql.c 

It looks like this usage goes against the design principles of pg_convert and thus pg_insert pg_delete pg_update (etc...) perhaps the documentation could be ammended to reflect this.


other things I noticed

 no support of ipv6
 attempts to validate dates using regex
 [2013-06-01 21:50 UTC] mbeccati@php.net
-Summary: pg_convert barfs on enum columns +Summary: pg_convert enum type support -Assigned To: +Assigned To: mbeccati
 [2013-06-02 04:35 UTC] mbeccati@php.net
Automatic comment on behalf of mbeccati
Revision: http://git.php.net/?p=php-src.git;a=commit;h=25aae37229a439109c020150d0f496ef4a237ecd
Log: Fixed bug #64609 (pg_convert enum type support)
 [2013-06-02 04:35 UTC] mbeccati@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sat Apr 19 09:02:28 2014 UTC