Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » PHP
  • » [PDO] Re: [PHP-DEV] [PATCH] New PDO methods for PostgreSQL driver [RSS Feed]

#1 May 26, 2010 06:13:49

Stanley S.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PDO] Re: [PHP-DEV] [PATCH] New PDO methods for PostgreSQL driver


On Tue, May 25, 2010 at 6:37 PM, Wez Furlong <king***@*mail.com> wrote:
> On Mon, May 24, 2010 at 3:07 PM, Pierre Joye <pierre.***@*mail.com> wrote:
>> On Mon, May 24, 2010 at 8:56 PM, Ilia Alshanetsky <i***@*rohost.org> wrote:
>>> Pierre,
>>> As one of the original authors of PDO that is news to me. PDO was designed
>>> to allow common functionality to be provided via a common interface, however
>>> it was also designed to recognize that not all database interfaces are the
>>> same.
>>> ...
>>> Preventing addition of functionality for a driver, just because there are no
>>> equivalents in other DB interfaces, makes little sense, IMHO.
>
> I 100% agree; see below for more color.
>
>> The original specs did not specify any way to do such things in a
>> clean and nice way. It is also relatively obvious than having drivers
>> specific features in the "core" PDO was a mistake.
>
> I seem to remember writing that down in a spec doc somewhere. In case
> I'm smoking crack, the convention for driver specific functionality is
> to prefix those methods with the name of the driver (for example:
> pgsqlLOBCreate).


However, if it can be abstracted to work across multiple drivers it
should be named as such to allow other driver developers to support it
and if they don't then we could throw an "unsupported" exception.

I would proposed naming the methods as:
connection->copyFrom($file, $table, array(PDO_COPY_ARGS) );
stmt->copyTo($file, array(PDO_COPY_ARGS) )

Then each driver could report supports or not supports accordingly.
For example, this would nicely map to FreeTDS BCP extensions.

>
> This should be taken as explicitly allowing for this path; that was
> our intention when we built PDO.
>
> It is in no way a mistake to allow driver specific functions; in fact,
> quite the opposite; without them, there is no compelling reason for
> vendors to bother coding support for PDO if they're going to have to
> add some other vector to enable the full features of their products,
> and this also extends to users; why use what we've been pushing as the
> one true way, if it is not in fact the one true way?
>
>> I also did not say that we should not have driver specific additions
>> to PDO but if we do it, we actually need to discuss how we want to do
>> it. And this discussion has began (w/o much activities) on the PDO
>> lists.
>
> I confess to being busy, but I don't recall any conversation where
> this capability was revoked or otherwise called out as wrong.
>
> --Wez.
>
> --
> PDO Working Group Mailing List (http://pdo.php.net)
> To unsubscribe, visit:http://www.php.net/unsub.php>
>

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#2 June 3, 2010 21:43:08

Sufficool, S.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PDO] Re: [PHP-DEV] [PATCH] New PDO methods for PostgreSQL driver


Am I missing something or can't you just add another set of function pointers
to the PDO driver and statements like:

driver_methods = {
...
pg_copy_from, /* OR NULL IF NOT SUPPORTED */
pg_copy_to
};

statement_methods = {
...
pg_copy_to
};

Then if the driver does not implement it, throw an exception. Then, in the
future, these could be abstracted on a higher level for drivers that don't
support it by using lower level INSERT / SELECTS. The difference in the
abstraction being that the files would be on the client side, not the server.

The initial values would of course be NULL except fo the PostgreSQL PDO drivers.

Then call the functions as $pdo_obj->copyFrom(...) and $pdo_obj->copyTo(...) or
$pdo_stmt->copyTo(...)

>-----Original Message-----
>From: Denis Gasparin
>Sent: Thursday, June 03, 2010 1:32 PM
>To: Johannes Schlüter
>Cc: Pierre Joye; Jonathan Wage; Ilia Alshanetsky; Matteo
>Beccati; intern***@*ists.php.net; pdo; Ferenc Kovacs
>Subject: Re: New PDO methods for
>PostgreSQL driver
>
>
>Hi.
>
>It is similar to what I tried to do with the pgsql driver
>(look at my previous post).
>
>I could try to restore the old patch, compare with your and
>then re-test it.
>
>If this is the way to follow, then the optimal solution (?)
>would be to add a standard function to the pdo driver that
>translates the connection between old driver and PDO one
>(there could be some problems because of different same DMBS
>drivers (mysql, mysqli for example)).
>
>
>Denis
>
>
>----- Messaggio originale -----
>> Da: "Johannes Schlüter" <johan***@*chlueters.de>
>> A: "Denis Gasparin" <denis.gaspa***@*distar.com>
>> Cc: "Pierre Joye" <pierre.***@*mail.com>, "Jonathan Wage"
>> <jonw***@*mail.com>, "Ilia Alshanetsky" <i***@*rohost.org>, "Matteo
>> Beccati" <p***@*eccati.com>, intern***@*ists.php.net, "pdo"
>> <p***@*ists.php.net>, "Ferenc Kovacs" <i***@*yrael.hu>
>> Inviato: Giovedì, 3 giugno 2010 22:19:57
>> Oggetto: Re: New PDO methods for PostgreSQL driver
>
>> On Thu, 2010-06-03 at 21:48 +0200, Denis Gasparin wrote:
>> > As I wrote last week, according to me too the best
>solution would be
>> > to share the PDO opened connection between the old pgsql
>driver and
>> > the PDO one That was the original way we tried to develop the patch
>> > without success.
>>
>> Would be helpful to tell what your problem was.
>>
>>https://code.launchpad.net/~johannes-s/php-mysqlnd/pdo2mysqliis a
>> branch adding a pdo::toMysqli() method. I won't commit it to PHP in
>> that form but should be a good start. I don't know much about the
>> pgsql extension, but maybe it helps.
>>
>> johannes
>
>--
>PDO Working Group Mailing List (http://pdo.php.net)
>To unsubscribe, visit:http://www.php.net/unsub.php>
>

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#3 June 12, 2010 11:25:45

Pierre J.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PDO] Re: [PHP-DEV] [PATCH] New PDO methods for PostgreSQL driver


hi Ilia,

So you basically say that the worries and wishes raised here are
simply irrelevant and at the end of the day you decide what PDO can or
cannot be?

I'm very disappointed by these two commits. I don't think it is the
way we should develop PDO and it is clear that I'm not the only one to
think that. As it is trunk, I won't battle too much to revert it but
be sure that is not something I will let in for any of the upcoming
releases as it is clearly bad design.

Cheers,
--
Pierre

On Thu, Jun 10, 2010 at 2:12 PM, Ilia Alshanetsky <i***@*rohost.org> wrote:
> I've added the transaction code as a generic method inTransaction(), by
> default it'll just use in_txn internal parameter, but allows the driver to
> extend this (as was done in PostgreSQL) and provide a detailed status code.
>
> On Wed, May 26, 2010 at 1:11 PM, Denis Gasparin
> <denis.gaspa***@*distar.com>wrote:
>
>>
>> I attached to this mail a new version of the patch both in unified and
>> single file format.
>>
>> I attached the unit tests for all the new methods too.
>> They are three files: one for pgsqlIsInTransaction(), one for
>> pgsqlCopyFrom*  methods and one for pgsqlCopyTo* methods.
>>
>> I did a typo writing the documentation in my first mail. The typo is about
>> the $fields parameter.
>> It is actually a string (not an array) with field names separated by comma.
>>
>> If needed, I can write also documentation in a more suitable format for php
>> web site.
>>
>> The updated documentation of the methods follows.
>>
>> Any feedback is appreciated.
>>
>> Thank you in advance,
>> Denis
>>
>> pgsqlIsInTransaction()
>>
>>    It uses the native Postgresql functions to check transaction status.
>>    It returns one of the following status codes:
>>        * PDO:GSQL_TRANSACTION_IDLE: connection in idle status
>>       * PDO:GSQL_TRANSACTION_ACTIVE: connection is executing a command
>>       * PDO:GSQL_TRANSACTION_INTRANS: connection is idle in a valid
>> transaction block
>>       * PDO:GSQL_TRANSACTION_INERROR: connection is idle, in a failed
>> transaction block
>>       * PDO:GSQL_TRANSACTION_UNKNOWN: connection is in a bad status
>>
>>
>>
>> pgsqlCopyFromArray($table,Array $data,$delimiter,$null, Array $fields)
>>
>>    It uses the native Postgresql copy construct to append $data to $table.
>>    It returns boolean.
>>    Parameters:
>>       * (mandatory) $table: table to append data to
>>       * (mandatory) $data: Array of rows with data in table field order
>>                           (or as specified in the $fields array). Fields
>> must be separated by $delimiter or by
>>                           postgresql standard \t)
>>       * $delimiter: alternative delimiter to use in place of the standard
>> postgres delimiter ("\t")
>>       * $null: alternative string to use as null value. Default is "\N"
>>        * $fields: string with table fields that are specified in $data
>> parameter. Fields are separated by comma
>>
>>
>>
>> pgsqlCopyFromFile($table,$filename,$delimiter,$null,$fields)
>>
>>    It uses the native Postgresql copy construct to append $filename
>> contents to $table.
>>    It returns boolean.
>>    Parameters:
>>       * (mandatory) $table: table to append data to.
>>       * (mandatory) $filename: file with contents to append to $table. See
>> Postgresql documentation for the format.
>>       * $delimiter: alternative delimiter to use in place of the standard
>> postgres delimiter ("\t")
>>       * $null: alternative string to use as null value. Default is "\N"
>>        * $fields: string with table fields that are specified in $filename
>> file. Fields are separated by comma
>>
>> pgsqlCopyToArray($table,$delimiter,$null,$fields)
>>
>>    It uses the native Postgresql copy construct to retrieve $table contents
>> and store them to an array.
>>    It returns an array of rows or false in case of problems.
>>    The format of the rows into the array is indicated in the $delimiter,
>> $null and $fields parameters.
>>    Parameters:
>>       * (mandatory) $table: table to retrieve data from.
>>       * $delimiter: alternative delimiter to use in place of the standard
>> postgres delimiter ("\t")
>>       * $null: alternative string to use as null value. Default is "\N"
>>        * $fields: string with table fields to include in the row of the
>> array. Fields are separated by comma
>>
>>
>> pgsqlCopyToFile($table,$filename,$delimiter,$null,$fields)
>>
>>
>>    It uses the native Postgresql copy construct to retrieve $table contents
>> and store them into a file.
>>    It returns boolean.
>>    The format of the rows stored into the file is indicated in the
>> $delimiter, $null and $fields parameters.
>>    Parameters:
>>       * (mandatory) $table: table to retrieve data from.
>>       * (mandatory) $filename: file where to store the contents of the
>> table
>>       * $delimiter: alternative delimiter to use in place of the standard
>> postgres delimiter ("\t")
>>       * $null: alternative string to use as null value. Default is "\N"
>>        * $fields: string with table fields to include in the row of the
>> array. Fields are separated by comma
>>
>>
>> ----- Messaggio originale -----
>> > Da: "Ilia Alshanetsky" <i***@*rohost.org>
>> > A: "Denis Gasparin" <denis.gaspa***@*distar.com>
>> > Cc: intern***@*ists.php.net
>> > Inviato: Martedì, 25 maggio 2010 18:40:09
>> > Oggetto: Re: New PDO methods for PostgreSQL driver
>>
>> > Good reason, I'll review the patch in the next day or two.
>> >
>> >
>> > On Mon, May 24, 2010 at 5:55 PM, Denis Gasparin <
>> > denis.gaspa***@*distar.com > wrote:
>> >
>> >
>> >
>> > The copy to/from sql statements accept both as main parameter a
>> > filename or stdout/stdin respectively.
>> >
>> > The filename represents a file in the database filesystem (apache/php
>> > and postgresql must reside on the same machine or share the file via
>> > shared filesystem). I quote from the postgresql manual:
>> >
>> > <<<
>> > COPY with a file name instructs the PostgreSQL server to directly read
>> > from or write to a file. The file must be accessible to the server and
>> > the name must be specified from the viewpoint of the (database)
>> > server.
>> > >>>
>> >
>> > Because of this "limitation", if you'd like to load a csv file into
>> > pgsql via copy command, you must before copy into a shared folder and
>> > the issue the copy from filename command.
>> > Using the methods added to PDO, you can do it directly from the
>> > webserver.
>> >
>> > About copying to/from stdin and stdout, PostgreSQL enters a particular
>> > status after a copy stdin/stdout command has been issued via sql.
>> > These status codes are PGRES_COPY_OUT and PGRES_COPY_IN. When in this
>> > status, the only way to interact with the database server is via
>> > PQgetCopyData and PQputCopyData.
>> >
>> > There are not PDO methods or functions that implements these functions
>> > and there is no way to share the connection between PDO driver and old
>> > pgsql drivers.
>> >
>> > These are the relevant PostgreSQL man pages:
>> >
>> >http://www.postgresql.org/docs/8.2/interactive/libpq-copy..html>> >http://www.postgresql.org/docs/8.2/interactive/sql-copy.html>> >
>> > Denis
>> >
>> >
>> >
>> >
>> > > Denis could you elaborate on what makes use of the COPY code via Sql
>> > > behave differently then a PHP method call?
>> > >
>> > > Ilia Alshanetsky
>> > > CIO/CSO Centah Inc.
>> > >
>> > > On 2010-05-24, at 15:45, Denis Gasparin < denis.gaspa***@*distar.com
>> > > >
>> > > wrote:
>> > >
>> > > >
>> > > > I'll provide the patches in a single file as soon as possible..
>> > > >
>> > > > Actually all the methods are wrappers against the native
>> > > > PostgreSQL commands (connection status, copy to/from).
>> > > >
>> > > > I needed to develop them as methods because it is not possible to
>> > > > get the same results with a sql statement (in particular for
>> > > > connection status).
>> > > >
>> > > > It was not possible also for COPY TO/FROM because of the way
>> > > > PostgreSQL handle them ( special functions were developed also for
>> > > > the old pgsql driver).
>> > > >
>> > > > We are currently using them in production and we needed them in
>> > > > order to avoid additional connections to database (one with the
>> > > > old driver and one with PDO).
>> > > >
>> > > > Denis
>> > > >
>> > > >
>> > > > ----- Messaggio originale -----
>> > > >> Da: "Ilia Alshanetsky" < i***@*rohost.org >
>> > > >> A: "Denis Gasparin" < denis.gaspa***@*distar.com >
>> > > >> Cc: intern***@*ists.php.net
>> > > >> Inviato: Lunedì, 24 maggio 2010 19:54:46
>> > > >> Oggetto: Re: New PDO methods for PostgreSQL
>> > > >> driver
>> > > >
>> > > >> Denis,
>> > > >>
>> > > >>
>> > > >> Could you merge the patches into a single for easier code review.
>> > > >> Also, the copy to/from file seems like it would just be a wrapper
>> > > >> against the native COPY PostgreSQL command, is there really a
>> > > >> need to provide a method for it?
>> > > >>
>> > > >>
>> > > >> On Mon, May 24, 2010 at 4:57 AM, Denis Gasparin <
>> > > >> denis.gaspa***@*distar.com > wrote:
>> > > >>
>> > > >>
>> > > >> Hi.
>> > > >>
>> > > >> I developed some patches for PDO/Postgresql driver in order to
>> > > >> add some useful methods that were available in the original pgsql
>> > > >> driver.
>> > > >>
>> > > >> The attached patches apply on 5.3.2 and svn 5.3.x.
>> > > >> If needed, i have patches also for 5.2.x.
>> > > >>
>> > > >> Please comment and tell me improvements or tips.
>> > > >>
>> > > >> Thank you in advance,
>> > > >>
>> > > >> Denis Gasparin
>> > > >>
>> > > >> Documentation of the added methods follows:
>> > > >>
>> > > >> pgsqlIsInTransaction()
>> > > >>
>> > > >> It uses the native Postgresql functions to check transaction
>> > > >> status..
>> > > >> It returns one of the following status codes:
>> > > >> * PDO::PGSQL_TRANSACTION_IDLE: connection in idle status
>> > > >> * PDO::PGSQL_TRANSACTION_ACTIVE: connection is executing a
>> > > >> command * PDO::PGSQL_TRANSACTION_INTRANS: connection is idle in a
>> > > >> valid transaction block
>> > > >> * PDO::PGSQL_TRANSACTION_INERROR: connection is idle, in a failed
>> > > >> transaction block
>> > > >> * PDO::PGSQL_TRANSACTION_UNKNOWN: connection is in a bad status
>> > > >>
>> > > >>
>> > > >>
>> > > >> pgsqlCopyFromArray($table,Array $data,$delimiter,$null, Array
>> > > >> $fields)
>> > > >>
>> > > >> It uses the native Postgresql copy construct to append $data to
>> > > >> $table. It returns boolean.
>> > > >> Parameters: * (mandatory) $table: table to append data to
>> > > >> * (mandatory) $data: Array of rows with data in table field order
>> > > >> (or as specified in the $fields array). Fields must be separated
>> > > >> by $delimiter or by
>> > > >> postgresql standard \t)
>> > > >> * $delimiter: alternative delimiter to use in place of the
>> > > >> standard postgres delimiter ("\t")
>> > > >> * $null: alternative string to use as null value. Default is "\N"
>> > > >> * $fields: array with table fields that are specified in $data
>> > > >> parameter
>> > > >>
>> > > >>
>> > > >>
>> > > >> pgsqlCopyFromFile($table,$filename,$delimiter,$null,$fields)
>> > > >>
>> > > >> It uses the native Postgresql copy construct to append $filename
>> > > >> contents to $table.
>> > > >> It returns boolean.
>> > > >> Parameters: * (mandatory) $table: table to append data to.
>> > > >> * (mandatory) $filename: file with contents to append to $table.
>> > > >> See Postgresql documentation for the format.
>> > > >> * $delimiter: alternative delimiter to use in place of the
>> > > >> standard postgres delimiter ("\t")
>> > > >> * $null: alternative string to use as null value. Default is "\N"
>> > > >> * $fields: array with table fields that are specified in
>> > > >> $filename file
>> > > >>
>> > > >> pgsqlCopyToArray($table,$delimiter,$null,$fields)
>> > > >>
>> > > >> It uses the native Postgresql copy construct to retrieve $table
>> > > >> contents and store them to an array.
>> > > >> It returns an array of rows or false in case of problems.
>> > > >> The format of the rows into the array is indicated in the
>> > > >> $delimiter, $null and $fields parameters.
>> > > >> Parameters: * (mandatory) $table: table to retrieve data from..
>> > > >> * $delimiter: alternative delimiter to use in place of the
>> > > >> standard postgres delimiter ("\t")
>> > > >> * $null: alternative string to use as null value. Default is "\N"
>> > > >> * $fields: array with table fields to include in the row of the
>> > > >> array.
>> > > >>
>> > > >>
>> > > >> pgsqlCopyToFile($table,$filename,$delimiter,$null,$fields)
>> > > >>
>> > > >>
>> > > >> It uses the native Postgresql copy construct to retrieve $table
>> > > >> contents and store them into a file.
>> > > >> It returns boolean.
>> > > >> The format of the rows stored into the file is indicated in the
>> > > >> $delimiter, $null and $fields parameters.
>> > > >> Parameters: * (mandatory) $table: table to retrieve data from..
>> > > >> * (mandatory) $filename: file where to store the contents of the
>> > > >> table * $delimiter: alternative delimiter to use in place of the
>> > > >> standard postgres delimiter ("\t")
>> > > >> * $null: alternative string to use as null value. Default is "\N"
>> > > >> * $fields: array with table fields to include in the row of the
>> > > >> array.
>> > > >>
>> > > >> -- PHP Internals - PHP Runtime Development Mailing List
>> > > >> To unsubscribe, visit:http://www.php.net/unsub.php>>
>



--
Pierre

@pierrejoye |http://blog.thepimp.net|http://www.libgd.org--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#4 June 12, 2010 11:39:17

Jonathan W.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PDO] Re: [PHP-DEV] [PATCH] New PDO methods for PostgreSQL driver


Same, I am disappointed to see this committed still after the concerns
raised here.

- Jon

On Sat, Jun 12, 2010 at 6:24 AM, Pierre Joye <pierre.***@*mail.com> wrote:

> hi Ilia,
>
> So you basically say that the worries and wishes raised here are
> simply irrelevant and at the end of the day you decide what PDO can or
> cannot be?
>
> I'm very disappointed by these two commits. I don't think it is the
> way we should develop PDO and it is clear that I'm not the only one to
> think that. As it is trunk, I won't battle too much to revert it but
> be sure that is not something I will let in for any of the upcoming
> releases as it is clearly bad design.
>
> Cheers,
> --
> Pierre
>
> On Thu, Jun 10, 2010 at 2:12 PM, Ilia Alshanetsky <i***@*rohost.org>
> wrote:
> > I've added the transaction code as a generic method inTransaction(), by
> > default it'll just use in_txn internal parameter, but allows the driver
> to
> > extend this (as was done in PostgreSQL) and provide a detailed status
> code.
> >
> > On Wed, May 26, 2010 at 1:11 PM, Denis Gasparin
> > <denis.gaspa***@*distar.com>wrote:
> >
> >>
> >> I attached to this mail a new version of the patch both in unified and
> >> single file format.
> >>
> >> I attached the unit tests for all the new methods too.
> >> They are three files: one for pgsqlIsInTransaction(), one for
> >> pgsqlCopyFrom* methods and one for pgsqlCopyTo* methods.
> >>
> >> I did a typo writing the documentation in my first mail. The typo is
> about
> >> the $fields parameter.
> >> It is actually a string (not an array) with field names separated by
> comma.
> >>
> >> If needed, I can write also documentation in a more suitable format for
> php
> >> web site.
> >>
> >> The updated documentation of the methods follows.
> >>
> >> Any feedback is appreciated.
> >>
> >> Thank you in advance,
> >> Denis
> >>
> >> pgsqlIsInTransaction()
> >>
> >> It uses the native Postgresql functions to check transaction status.
> >> It returns one of the following status codes:
> >> * PDO:GSQL_TRANSACTION_IDLE: connection in idle status
> >> * PDO:GSQL_TRANSACTION_ACTIVE: connection is executing a command
> >> * PDO:GSQL_TRANSACTION_INTRANS: connection is idle in a valid
> >> transaction block
> >> * PDO:GSQL_TRANSACTION_INERROR: connection is idle, in a failed
> >> transaction block
> >> * PDO:GSQL_TRANSACTION_UNKNOWN: connection is in a bad status
> >>
> >>
> >>
> >> pgsqlCopyFromArray($table,Array $data,$delimiter,$null, Array $fields)
> >>
> >> It uses the native Postgresql copy construct to append $data to
> $table.
> >> It returns boolean.
> >> Parameters:
> >> * (mandatory) $table: table to append data to
> >> * (mandatory) $data: Array of rows with data in table field order
> >> (or as specified in the $fields array). Fields
> >> must be separated by $delimiter or by
> >> postgresql standard \t)
> >> * $delimiter: alternative delimiter to use in place of the
> standard
> >> postgres delimiter ("\t")
> >> * $null: alternative string to use as null value. Default is "\N"
> >> * $fields: string with table fields that are specified in $data
> >> parameter. Fields are separated by comma
> >>
> >>
> >>
> >> pgsqlCopyFromFile($table,$filename,$delimiter,$null,$fields)
> >>
> >> It uses the native Postgresql copy construct to append $filename
> >> contents to $table.
> >> It returns boolean.
> >> Parameters:
> >> * (mandatory) $table: table to append data to.
> >> * (mandatory) $filename: file with contents to append to $table.
> See
> >> Postgresql documentation for the format.
> >> * $delimiter: alternative delimiter to use in place of the
> standard
> >> postgres delimiter ("\t")
> >> * $null: alternative string to use as null value. Default is "\N"
> >> * $fields: string with table fields that are specified in
> $filename
> >> file. Fields are separated by comma
> >>
> >> pgsqlCopyToArray($table,$delimiter,$null,$fields)
> >>
> >> It uses the native Postgresql copy construct to retrieve $table
> contents
> >> and store them to an array.
> >> It returns an array of rows or false in case of problems.
> >> The format of the rows into the array is indicated in the $delimiter,
> >> $null and $fields parameters.
> >> Parameters:
> >> * (mandatory) $table: table to retrieve data from.
> >> * $delimiter: alternative delimiter to use in place of the
> standard
> >> postgres delimiter ("\t")
> >> * $null: alternative string to use as null value. Default is "\N"
> >> * $fields: string with table fields to include in the row of the
> >> array. Fields are separated by comma
> >>
> >>
> >> pgsqlCopyToFile($table,$filename,$delimiter,$null,$fields)
> >>
> >>
> >> It uses the native Postgresql copy construct to retrieve $table
> contents
> >> and store them into a file.
> >> It returns boolean.
> >> The format of the rows stored into the file is indicated in the
> >> $delimiter, $null and $fields parameters.
> >> Parameters:
> >> * (mandatory) $table: table to retrieve data from.
> >> * (mandatory) $filename: file where to store the contents of the
> >> table
> >> * $delimiter: alternative delimiter to use in place of the
> standard
> >> postgres delimiter ("\t")
> >> * $null: alternative string to use as null value. Default is "\N"
> >> * $fields: string with table fields to include in the row of the
> >> array. Fields are separated by comma
> >>
> >>
> >> ----- Messaggio originale -----
> >> > Da: "Ilia Alshanetsky" <i***@*rohost.org>
> >> > A: "Denis Gasparin" <denis.gaspa***@*distar.com>
> >> > Cc: intern***@*ists.php.net
> >> > Inviato: Martedì, 25 maggio 2010 18:40:09
> >> > Oggetto: Re: New PDO methods for PostgreSQL driver
> >>
> >> > Good reason, I'll review the patch in the next day or two.
> >> >
> >> >
> >> > On Mon, May 24, 2010 at 5:55 PM, Denis Gasparin <
> >> > denis.gaspa***@*distar.com > wrote:
> >> >
> >> >
> >> >
> >> > The copy to/from sql statements accept both as main parameter a
> >> > filename or stdout/stdin respectively.
> >> >
> >> > The filename represents a file in the database filesystem (apache/php
> >> > and postgresql must reside on the same machine or share the file via
> >> > shared filesystem). I quote from the postgresql manual:
> >> >
> >> > <<<
> >> > COPY with a file name instructs the PostgreSQL server to directly read
> >> > from or write to a file. The file must be accessible to the server and
> >> > the name must be specified from the viewpoint of the (database)
> >> > server.
> >> > >>>
> >> >
> >> > Because of this "limitation", if you'd like to load a csv file into
> >> > pgsql via copy command, you must before copy into a shared folder and
> >> > the issue the copy from filename command.
> >> > Using the methods added to PDO, you can do it directly from the
> >> > webserver.
> >> >
> >> > About copying to/from stdin and stdout, PostgreSQL enters a particular
> >> > status after a copy stdin/stdout command has been issued via sql.
> >> > These status codes are PGRES_COPY_OUT and PGRES_COPY_IN. When in this
> >> > status, the only way to interact with the database server is via
> >> > PQgetCopyData and PQputCopyData.
> >> >
> >> > There are not PDO methods or functions that implements these functions
> >> > and there is no way to share the connection between PDO driver and old
> >> > pgsql drivers.
> >> >
> >> > These are the relevant PostgreSQL man pages:
> >> >
> >> >http://www.postgresql.org/docs/8.2/interactive/libpq-copy..html> >> >http://www.postgresql.org/docs/8.2/interactive/sql-copy.html> >> >
> >> > Denis
> >> >
> >> >
> >> >
> >> >
> >> > > Denis could you elaborate on what makes use of the COPY code via Sql
> >> > > behave differently then a PHP method call?
> >> > >
> >> > > Ilia Alshanetsky
> >> > > CIO/CSO Centah Inc.
> >> > >
> >> > > On 2010-05-24, at 15:45, Denis Gasparin <
> denis.gaspa***@*distar.com
> >> > > >
> >> > > wrote:
> >> > >
> >> > > >
> >> > > > I'll provide the patches in a single file as soon as possible..
> >> > > >
> >> > > > Actually all the methods are wrappers against the native
> >> > > > PostgreSQL commands (connection status, copy to/from).
> >> > > >
> >> > > > I needed to develop them as methods because it is not possible to
> >> > > > get the same results with a sql statement (in particular for
> >> > > > connection status).
> >> > > >
> >> > > > It was not possible also for COPY TO/FROM because of the way
> >> > > > PostgreSQL handle them ( special functions were developed also for
> >> > > > the old pgsql driver).
> >> > > >
> >> > > > We are currently using them in production and we needed them in
> >> > > > order to avoid additional connections to database (one with the
> >> > > > old driver and one with PDO).
> >> > > >
> >> > > > Denis
> >> > > >
> >> > > >
> >> > > > ----- Messaggio originale -----
> >> > > >> Da: "Ilia Alshanetsky" < i***@*rohost.org >
> >> > > >> A: "Denis Gasparin" < denis.gaspa***@*distar.com >
> >> > > >> Cc: intern***@*ists.php.net
> >> > > >> Inviato: Lunedì, 24 maggio 2010 19:54:46
> >> > > >> Oggetto: Re: New PDO methods for PostgreSQL
> >> > > >> driver
> >> > > >
> >> > > >> Denis,
> >> > > >>
> >> > > >>
> >> > > >> Could you merge the patches into a single for easier code review.
> >> > > >> Also, the copy to/from file seems like it would just be a wrapper
> >> > > >> against the native COPY PostgreSQL command, is there really a
> >> > > >> need to provide a method for it?
> >> > > >>
> >> > > >>
> >> > > >> On Mon, May 24, 2010 at 4:57 AM, Denis Gasparin <
> >> > > >> denis.gaspa***@*distar.com > wrote:
> >> > > >>
> >> > > >>
> >> > > >> Hi.
> >> > > >>
> >> > > >> I developed some patches for PDO/Postgresql driver in order to
> >> > > >> add some useful methods that were available in the original pgsql
> >> > > >> driver.
> >> > > >>
> >> > > >> The attached patches apply on 5.3.2 and svn 5.3.x.
> >> > > >> If needed, i have patches also for 5.2.x.
> >> > > >>
> >> > > >> Please comment and tell me improvements or tips.
> >> > > >>
> >> > > >> Thank you in advance,
> >> > > >>
> >> > > >> Denis Gasparin
> >> > > >>
> >> > > >> Documentation of the added methods follows:
> >> > > >>
> >> > > >> pgsqlIsInTransaction()
> >> > > >>
> >> > > >> It uses the native Postgresql functions to check transaction
> >> > > >> status..
> >> > > >> It returns one of the following status codes:
> >> > > >> * PDO::PGSQL_TRANSACTION_IDLE: connection in idle status
> >> > > >> * PDO::PGSQL_TRANSACTION_ACTIVE: connection is executing a
> >> > > >> command * PDO::PGSQL_TRANSACTION_INTRANS: connection is idle in a
> >> > > >> valid transaction block
> >> > > >> * PDO::PGSQL_TRANSACTION_INERROR: connection is idle, in a failed
> >> > > >> transaction block
> >> > > >> * PDO::PGSQL_TRANSACTION_UNKNOWN: connection is in a bad status
> >> > > >>
> >> > > >>
> >> > > >>
> >> > > >> pgsqlCopyFromArray($table,Array $data,$delimiter,$null, Array
> >> > > >> $fields)
> >> > > >>
> >> > > >> It uses the native Postgresql copy construct to append $data to
> >> > > >> $table. It returns boolean.
> >> > > >> Parameters: * (mandatory) $table: table to append data to
> >> > > >> * (mandatory) $data: Array of rows with data in table field order
> >> > > >> (or as specified in the $fields array). Fields must be separated
> >> > > >> by $delimiter or by
> >> > > >> postgresql standard \t)
> >> > > >> * $delimiter: alternative delimiter to use in place of the
> >> > > >> standard postgres delimiter ("\t")
> >> > > >> * $null: alternative string to use as null value. Default is "\N"
> >> > > >> * $fields: array with table fields that are specified in $data
> >> > > >> parameter
> >> > > >>
> >> > > >>
> >> > > >>
> >> > > >> pgsqlCopyFromFile($table,$filename,$delimiter,$null,$fields)
> >> > > >>
> >> > > >> It uses the native Postgresql copy construct to append $filename
> >> > > >> contents to $table.
> >> > > >> It returns boolean.
> >> > > >> Parameters: * (mandatory) $table: table to append data to.
> >> > > >> * (mandatory) $filename: file with contents to append to $table.
> >> > > >> See Postgresql documentation for the format.
> >> > > >> * $delimiter: alternative delimiter to use in place of the
> >> > > >> standard postgres delimiter ("\t")
> >> > > >> * $null: alternative string to use as null value. Default is "\N"
> >> > > >> * $fields: array with table fields that are specified in
> >> > > >> $filename file
> >> > > >>
> >> > > >> pgsqlCopyToArray($table,$delimiter,$null,$fields)
> >> > > >>
> >> > > >> It uses the native Postgresql copy construct to retrieve $table
> >> > > >> contents and store them to an array.
> >> > > >> It returns an array of rows or false in case of problems.
> >> > > >> The format of the rows into the array is indicated in the
> >> > > >> $delimiter, $null and $fields parameters.
> >> > > >> Parameters: * (mandatory) $table: table to retrieve data from..
> >> > > >> * $delimiter: alternative delimiter to use in place of the
> >> > > >> standard postgres delimiter ("\t")
> >> > > >> * $null: alternative string to use as null value. Default is "\N"
> >> > > >> * $fields: array with table fields to include in the row of the
> >> > > >> array.
> >> > > >>
> >> > > >>
> >> > > >> pgsqlCopyToFile($table,$filename,$delimiter,$null,$fields)
> >> > > >>
> >> > > >>
> >> > > >> It uses the native Postgresql copy construct to retrieve $table
> >> > > >> contents and store them into a file.
> >> > > >> It returns boolean.
> >> > > >> The format of the rows stored into the file is indicated in the
> >> > > >> $delimiter, $null and $fields parameters.
> >> > > >> Parameters: * (mandatory) $table: table to retrieve data from..
> >> > > >> * (mandatory) $filename: file where to store the contents of the
> >> > > >> table * $delimiter: alternative delimiter to use in place of the
> >> > > >> standard postgres delimiter ("\t")
> >> > > >> * $null: alternative string to use as null value. Default is "\N"
> >> > > >> * $fields: array with table fields to include in the row of the
> >> > > >> array.
> >> > > >>
> >> > > >> -- PHP Internals - PHP Runtime Development Mailing List
> >> > > >> To unsubscribe, visit:http://www.php.net/unsub.php> >>
> >
>
>
>
> --
> Pierre
>
> @pierrejoye |http://blog.thepimp.net|http://www.libgd.org>
> --
> PDO Working Group Mailing List (http://pdo.php.net)
> To unsubscribe, visit:http://www.php.net/unsub.php>
>


--
Jonathan H. Wagehttp://www.twitter.com/jwage

Offline

#5 June 12, 2010 12:55:52

Ilia A.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PDO] Re: [PHP-DEV] [PATCH] New PDO methods for PostgreSQL driver


The concerns you raised about custom methods specific to database drivers
were not reflective of the PDO's intent as was clarified by Wez and myself.

The code that was introduced was specific to PostgreSQL, the common
functionality was introduced in a way that allows each driver to implement.

On Sat, Jun 12, 2010 at 12:24 PM, Pierre Joye <pierre.***@*mail.com> wrote:

> hi Ilia,
>
> So you basically say that the worries and wishes raised here are
> simply irrelevant and at the end of the day you decide what PDO can or
> cannot be?
>
> I'm very disappointed by these two commits. I don't think it is the
> way we should develop PDO and it is clear that I'm not the only one to
> think that. As it is trunk, I won't battle too much to revert it but
> be sure that is not something I will let in for any of the upcoming
> releases as it is clearly bad design.
>
> Cheers,
> --
> Pierre
>
> On Thu, Jun 10, 2010 at 2:12 PM, Ilia Alshanetsky <i***@*rohost.org>
> wrote:
> > I've added the transaction code as a generic method inTransaction(), by
> > default it'll just use in_txn internal parameter, but allows the driver
> to
> > extend this (as was done in PostgreSQL) and provide a detailed status
> code.
> >
> > On Wed, May 26, 2010 at 1:11 PM, Denis Gasparin
> > <denis.gaspa***@*distar.com>wrote:
> >
> >>
> >> I attached to this mail a new version of the patch both in unified and
> >> single file format.
> >>
> >> I attached the unit tests for all the new methods too.
> >> They are three files: one for pgsqlIsInTransaction(), one for
> >> pgsqlCopyFrom* methods and one for pgsqlCopyTo* methods.
> >>
> >> I did a typo writing the documentation in my first mail. The typo is
> about
> >> the $fields parameter.
> >> It is actually a string (not an array) with field names separated by
> comma.
> >>
> >> If needed, I can write also documentation in a more suitable format for
> php
> >> web site.
> >>
> >> The updated documentation of the methods follows.
> >>
> >> Any feedback is appreciated.
> >>
> >> Thank you in advance,
> >> Denis
> >>
> >> pgsqlIsInTransaction()
> >>
> >> It uses the native Postgresql functions to check transaction status.
> >> It returns one of the following status codes:
> >> * PDO:GSQL_TRANSACTION_IDLE: connection in idle status
> >> * PDO:GSQL_TRANSACTION_ACTIVE: connection is executing a command
> >> * PDO:GSQL_TRANSACTION_INTRANS: connection is idle in a valid
> >> transaction block
> >> * PDO:GSQL_TRANSACTION_INERROR: connection is idle, in a failed
> >> transaction block
> >> * PDO:GSQL_TRANSACTION_UNKNOWN: connection is in a bad status
> >>
> >>
> >>
> >> pgsqlCopyFromArray($table,Array $data,$delimiter,$null, Array $fields)
> >>
> >> It uses the native Postgresql copy construct to append $data to
> $table.
> >> It returns boolean.
> >> Parameters:
> >> * (mandatory) $table: table to append data to
> >> * (mandatory) $data: Array of rows with data in table field order
> >> (or as specified in the $fields array). Fields
> >> must be separated by $delimiter or by
> >> postgresql standard \t)
> >> * $delimiter: alternative delimiter to use in place of the
> standard
> >> postgres delimiter ("\t")
> >> * $null: alternative string to use as null value. Default is "\N"
> >> * $fields: string with table fields that are specified in $data
> >> parameter. Fields are separated by comma
> >>
> >>
> >>
> >> pgsqlCopyFromFile($table,$filename,$delimiter,$null,$fields)
> >>
> >> It uses the native Postgresql copy construct to append $filename
> >> contents to $table.
> >> It returns boolean.
> >> Parameters:
> >> * (mandatory) $table: table to append data to.
> >> * (mandatory) $filename: file with contents to append to $table.
> See
> >> Postgresql documentation for the format.
> >> * $delimiter: alternative delimiter to use in place of the
> standard
> >> postgres delimiter ("\t")
> >> * $null: alternative string to use as null value. Default is "\N"
> >> * $fields: string with table fields that are specified in
> $filename
> >> file. Fields are separated by comma
> >>
> >> pgsqlCopyToArray($table,$delimiter,$null,$fields)
> >>
> >> It uses the native Postgresql copy construct to retrieve $table
> contents
> >> and store them to an array.
> >> It returns an array of rows or false in case of problems.
> >> The format of the rows into the array is indicated in the $delimiter,
> >> $null and $fields parameters.
> >> Parameters:
> >> * (mandatory) $table: table to retrieve data from.
> >> * $delimiter: alternative delimiter to use in place of the
> standard
> >> postgres delimiter ("\t")
> >> * $null: alternative string to use as null value. Default is "\N"
> >> * $fields: string with table fields to include in the row of the
> >> array. Fields are separated by comma
> >>
> >>
> >> pgsqlCopyToFile($table,$filename,$delimiter,$null,$fields)
> >>
> >>
> >> It uses the native Postgresql copy construct to retrieve $table
> contents
> >> and store them into a file.
> >> It returns boolean.
> >> The format of the rows stored into the file is indicated in the
> >> $delimiter, $null and $fields parameters.
> >> Parameters:
> >> * (mandatory) $table: table to retrieve data from.
> >> * (mandatory) $filename: file where to store the contents of the
> >> table
> >> * $delimiter: alternative delimiter to use in place of the
> standard
> >> postgres delimiter ("\t")
> >> * $null: alternative string to use as null value. Default is "\N"
> >> * $fields: string with table fields to include in the row of the
> >> array. Fields are separated by comma
> >>
> >>
> >> ----- Messaggio originale -----
> >> > Da: "Ilia Alshanetsky" <i***@*rohost.org>
> >> > A: "Denis Gasparin" <denis.gaspa***@*distar.com>
> >> > Cc: intern***@*ists.php.net
> >> > Inviato: Martedì, 25 maggio 2010 18:40:09
> >> > Oggetto: Re: New PDO methods for PostgreSQL driver
> >>
> >> > Good reason, I'll review the patch in the next day or two.
> >> >
> >> >
> >> > On Mon, May 24, 2010 at 5:55 PM, Denis Gasparin <
> >> > denis.gaspa***@*distar.com > wrote:
> >> >
> >> >
> >> >
> >> > The copy to/from sql statements accept both as main parameter a
> >> > filename or stdout/stdin respectively.
> >> >
> >> > The filename represents a file in the database filesystem (apache/php
> >> > and postgresql must reside on the same machine or share the file via
> >> > shared filesystem). I quote from the postgresql manual:
> >> >
> >> > <<<
> >> > COPY with a file name instructs the PostgreSQL server to directly read
> >> > from or write to a file. The file must be accessible to the server and
> >> > the name must be specified from the viewpoint of the (database)
> >> > server.
> >> > >>>
> >> >
> >> > Because of this "limitation", if you'd like to load a csv file into
> >> > pgsql via copy command, you must before copy into a shared folder and
> >> > the issue the copy from filename command.
> >> > Using the methods added to PDO, you can do it directly from the
> >> > webserver.
> >> >
> >> > About copying to/from stdin and stdout, PostgreSQL enters a particular
> >> > status after a copy stdin/stdout command has been issued via sql.
> >> > These status codes are PGRES_COPY_OUT and PGRES_COPY_IN. When in this
> >> > status, the only way to interact with the database server is via
> >> > PQgetCopyData and PQputCopyData.
> >> >
> >> > There are not PDO methods or functions that implements these functions
> >> > and there is no way to share the connection between PDO driver and old
> >> > pgsql drivers.
> >> >
> >> > These are the relevant PostgreSQL man pages:
> >> >
> >> >http://www.postgresql.org/docs/8.2/interactive/libpq-copy..html> >> >http://www.postgresql.org/docs/8.2/interactive/sql-copy.html> >> >
> >> > Denis
> >> >
> >> >
> >> >
> >> >
> >> > > Denis could you elaborate on what makes use of the COPY code via Sql
> >> > > behave differently then a PHP method call?
> >> > >
> >> > > Ilia Alshanetsky
> >> > > CIO/CSO Centah Inc.
> >> > >
> >> > > On 2010-05-24, at 15:45, Denis Gasparin <
> denis.gaspa***@*distar.com
> >> > > >
> >> > > wrote:
> >> > >
> >> > > >
> >> > > > I'll provide the patches in a single file as soon as possible..
> >> > > >
> >> > > > Actually all the methods are wrappers against the native
> >> > > > PostgreSQL commands (connection status, copy to/from).
> >> > > >
> >> > > > I needed to develop them as methods because it is not possible to
> >> > > > get the same results with a sql statement (in particular for
> >> > > > connection status).
> >> > > >
> >> > > > It was not possible also for COPY TO/FROM because of the way
> >> > > > PostgreSQL handle them ( special functions were developed also for
> >> > > > the old pgsql driver).
> >> > > >
> >> > > > We are currently using them in production and we needed them in
> >> > > > order to avoid additional connections to database (one with the
> >> > > > old driver and one with PDO).
> >> > > >
> >> > > > Denis
> >> > > >
> >> > > >
> >> > > > ----- Messaggio originale -----
> >> > > >> Da: "Ilia Alshanetsky" < i***@*rohost.org >
> >> > > >> A: "Denis Gasparin" < denis.gaspa***@*distar.com >
> >> > > >> Cc: intern***@*ists.php.net
> >> > > >> Inviato: Lunedì, 24 maggio 2010 19:54:46
> >> > > >> Oggetto: Re: New PDO methods for PostgreSQL
> >> > > >> driver
> >> > > >
> >> > > >> Denis,
> >> > > >>
> >> > > >>
> >> > > >> Could you merge the patches into a single for easier code review.
> >> > > >> Also, the copy to/from file seems like it would just be a wrapper
> >> > > >> against the native COPY PostgreSQL command, is there really a
> >> > > >> need to provide a method for it?
> >> > > >>
> >> > > >>
> >> > > >> On Mon, May 24, 2010 at 4:57 AM, Denis Gasparin <
> >> > > >> denis.gaspa***@*distar.com > wrote:
> >> > > >>
> >> > > >>
> >> > > >> Hi.
> >> > > >>
> >> > > >> I developed some patches for PDO/Postgresql driver in order to
> >> > > >> add some useful methods that were available in the original pgsql
> >> > > >> driver.
> >> > > >>
> >> > > >> The attached patches apply on 5.3.2 and svn 5.3.x.
> >> > > >> If needed, i have patches also for 5.2.x.
> >> > > >>
> >> > > >> Please comment and tell me improvements or tips.
> >> > > >>
> >> > > >> Thank you in advance,
> >> > > >>
> >> > > >> Denis Gasparin
> >> > > >>
> >> > > >> Documentation of the added methods follows:
> >> > > >>
> >> > > >> pgsqlIsInTransaction()
> >> > > >>
> >> > > >> It uses the native Postgresql functions to check transaction
> >> > > >> status..
> >> > > >> It returns one of the following status codes:
> >> > > >> * PDO::PGSQL_TRANSACTION_IDLE: connection in idle status
> >> > > >> * PDO::PGSQL_TRANSACTION_ACTIVE: connection is executing a
> >> > > >> command * PDO::PGSQL_TRANSACTION_INTRANS: connection is idle in a
> >> > > >> valid transaction block
> >> > > >> * PDO::PGSQL_TRANSACTION_INERROR: connection is idle, in a failed
> >> > > >> transaction block
> >> > > >> * PDO::PGSQL_TRANSACTION_UNKNOWN: connection is in a bad status
> >> > > >>
> >> > > >>
> >> > > >>
> >> > > >> pgsqlCopyFromArray($table,Array $data,$delimiter,$null, Array
> >> > > >> $fields)
> >> > > >>
> >> > > >> It uses the native Postgresql copy construct to append $data to
> >> > > >> $table. It returns boolean.
> >> > > >> Parameters: * (mandatory) $table: table to append data to
> >> > > >> * (mandatory) $data: Array of rows with data in table field order
> >> > > >> (or as specified in the $fields array). Fields must be separated
> >> > > >> by $delimiter or by
> >> > > >> postgresql standard \t)
> >> > > >> * $delimiter: alternative delimiter to use in place of the
> >> > > >> standard postgres delimiter ("\t")
> >> > > >> * $null: alternative string to use as null value. Default is "\N"
> >> > > >> * $fields: array with table fields that are specified in $data
> >> > > >> parameter
> >> > > >>
> >> > > >>
> >> > > >>
> >> > > >> pgsqlCopyFromFile($table,$filename,$delimiter,$null,$fields)
> >> > > >>
> >> > > >> It uses the native Postgresql copy construct to append $filename
> >> > > >> contents to $table.
> >> > > >> It returns boolean.
> >> > > >> Parameters: * (mandatory) $table: table to append data to.
> >> > > >> * (mandatory) $filename: file with contents to append to $table.
> >> > > >> See Postgresql documentation for the format.
> >> > > >> * $delimiter: alternative delimiter to use in place of the
> >> > > >> standard postgres delimiter ("\t")
> >> > > >> * $null: alternative string to use as null value. Default is "\N"
> >> > > >> * $fields: array with table fields that are specified in
> >> > > >> $filename file
> >> > > >>
> >> > > >> pgsqlCopyToArray($table,$delimiter,$null,$fields)
> >> > > >>
> >> > > >> It uses the native Postgresql copy construct to retrieve $table
> >> > > >> contents and store them to an array.
> >> > > >> It returns an array of rows or false in case of problems.
> >> > > >> The format of the rows into the array is indicated in the
> >> > > >> $delimiter, $null and $fields parameters.
> >> > > >> Parameters: * (mandatory) $table: table to retrieve data from..
> >> > > >> * $delimiter: alternative delimiter to use in place of the
> >> > > >> standard postgres delimiter ("\t")
> >> > > >> * $null: alternative string to use as null value. Default is "\N"
> >> > > >> * $fields: array with table fields to include in the row of the
> >> > > >> array.
> >> > > >>
> >> > > >>
> >> > > >> pgsqlCopyToFile($table,$filename,$delimiter,$null,$fields)
> >> > > >>
> >> > > >>
> >> > > >> It uses the native Postgresql copy construct to retrieve $table
> >> > > >> contents and store them into a file.
> >> > > >> It returns boolean.
> >> > > >> The format of the rows stored into the file is indicated in the
> >> > > >> $delimiter, $null and $fields parameters.
> >> > > >> Parameters: * (mandatory) $table: table to retrieve data from..
> >> > > >> * (mandatory) $filename: file where to store the contents of the
> >> > > >> table * $delimiter: alternative delimiter to use in place of the
> >> > > >> standard postgres delimiter ("\t")
> >> > > >> * $null: alternative string to use as null value. Default is "\N"
> >> > > >> * $fields: array with table fields to include in the row of the
> >> > > >> array.
> >> > > >>
> >> > > >> -- PHP Internals - PHP Runtime Development Mailing List
> >> > > >> To unsubscribe, visit:http://www.php.net/unsub.php> >>
> >
>
>
>
> --
> Pierre
>
> @pierrejoye |http://blog.thepimp.net|http://www.libgd.org>

Offline

#6 June 12, 2010 13:27:13

Pierre J.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PDO] Re: [PHP-DEV] [PATCH] New PDO methods for PostgreSQL driver


hi Ilia,

Having bad design in the initial PDO implementation does not mean that
we have to continue to do it this way.

The concerns raised in this discussion are very valid. I do not see
nor understand the need to commit these additions at this stage. It
has been obvious that PDO needs discussions about its future and
roadmaps. Doing what you just can very badly affect the way we work
with our users or vendors.That's not going to help PHP nor PDO.

With the risk of pissing off you, Wez and certainly other, being the
initiator of PDO, the main develepers or whatever other role do not
give you the rights to choose alone the direction that PDO should take
(neither do I). PDO stands for PHP Data Object, key part being "PHP",
as in core, standard data object layer.

I won't discuss this any longer in this thread, but please keep in
mind what has been said here. And also be ready to discuss these
additions again in the near future.

Cheers,

On Sat, Jun 12, 2010 at 1:54 PM, Ilia Alshanetsky <i***@*rohost.org> wrote:
> The concerns you raised about custom methods specific to database drivers
> were not reflective of the PDO's intent as was clarified by Wez and myself.
> The code that was introduced was specific to PostgreSQL, the common
> functionality was introduced in a way that allows each driver to implement.
>
> On Sat, Jun 12, 2010 at 12:24 PM, Pierre Joye <pierre.***@*mail.com> wrote:
>>
>> hi Ilia,
>>
>> So you basically say that the worries and wishes raised here are
>> simply irrelevant and at the end of the day you decide what PDO can or
>> cannot be?
>>
>> I'm very disappointed by these two commits. I don't think it is the
>> way we should develop PDO and it is clear that I'm not the only one to
>> think that. As it is trunk, I won't battle too much to revert it but
>> be sure that is not something I will let in for any of the upcoming
>> releases as it is clearly bad design.
>>
>> Cheers,
>> --
>> Pierre
>>
>> On Thu, Jun 10, 2010 at 2:12 PM, Ilia Alshanetsky <i***@*rohost.org>
>> wrote:
>> > I've added the transaction code as a generic method inTransaction(), by
>> > default it'll just use in_txn internal parameter, but allows the driver
>> > to
>> > extend this (as was done in PostgreSQL) and provide a detailed status
>> > code.
>> >
>> > On Wed, May 26, 2010 at 1:11 PM, Denis Gasparin
>> > <denis.gaspa***@*distar.com>wrote:
>> >
>> >>
>> >> I attached to this mail a new version of the patch both in unified and
>> >> single file format.
>> >>
>> >> I attached the unit tests for all the new methods too.
>> >> They are three files: one for pgsqlIsInTransaction(), one for
>> >> pgsqlCopyFrom*  methods and one for pgsqlCopyTo* methods.
>> >>
>> >> I did a typo writing the documentation in my first mail. The typo is
>> >> about
>> >> the $fields parameter.
>> >> It is actually a string (not an array) with field names separated by
>> >> comma.
>> >>
>> >> If needed, I can write also documentation in a more suitable format for
>> >> php
>> >> web site.
>> >>
>> >> The updated documentation of the methods follows.
>> >>
>> >> Any feedback is appreciated.
>> >>
>> >> Thank you in advance,
>> >> Denis
>> >>
>> >> pgsqlIsInTransaction()
>> >>
>> >>    It uses the native Postgresql functions to check transaction status.
>> >>    It returns one of the following status codes:
>> >>        * PDO:GSQL_TRANSACTION_IDLE: connection in idle status
>> >>       * PDO:GSQL_TRANSACTION_ACTIVE: connection is executing a command
>> >>       * PDO:GSQL_TRANSACTION_INTRANS: connection is idle in a valid
>> >> transaction block
>> >>       * PDO:GSQL_TRANSACTION_INERROR: connection is idle, in a failed
>> >> transaction block
>> >>       * PDO:GSQL_TRANSACTION_UNKNOWN: connection is in a bad status
>> >>
>> >>
>> >>
>> >> pgsqlCopyFromArray($table,Array $data,$delimiter,$null, Array $fields)
>> >>
>> >>    It uses the native Postgresql copy construct to append $data to
>> >> $table.
>> >>    It returns boolean.
>> >>    Parameters:
>> >>       * (mandatory) $table: table to append data to
>> >>       * (mandatory) $data: Array of rows with data in table field order
>> >>                           (or as specified in the $fields array).
>> >> Fields
>> >> must be separated by $delimiter or by
>> >>                           postgresql standard \t)
>> >>       * $delimiter: alternative delimiter to use in place of the
>> >> standard
>> >> postgres delimiter ("\t")
>> >>       * $null: alternative string to use as null value. Default is "\N"
>> >>        * $fields: string with table fields that are specified in $data
>> >> parameter. Fields are separated by comma
>> >>
>> >>
>> >>
>> >> pgsqlCopyFromFile($table,$filename,$delimiter,$null,$fields)
>> >>
>> >>    It uses the native Postgresql copy construct to append $filename
>> >> contents to $table.
>> >>    It returns boolean.
>> >>    Parameters:
>> >>       * (mandatory) $table: table to append data to.
>> >>       * (mandatory) $filename: file with contents to append to $table.
>> >> See
>> >> Postgresql documentation for the format.
>> >>       * $delimiter: alternative delimiter to use in place of the
>> >> standard
>> >> postgres delimiter ("\t")
>> >>       * $null: alternative string to use as null value. Default is "\N"
>> >>        * $fields: string with table fields that are specified in
>> >> $filename
>> >> file. Fields are separated by comma
>> >>
>> >> pgsqlCopyToArray($table,$delimiter,$null,$fields)
>> >>
>> >>    It uses the native Postgresql copy construct to retrieve $table
>> >> contents
>> >> and store them to an array.
>> >>    It returns an array of rows or false in case of problems.
>> >>    The format of the rows into the array is indicated in the
>> >> $delimiter,
>> >> $null and $fields parameters.
>> >>    Parameters:
>> >>       * (mandatory) $table: table to retrieve data from.
>> >>       * $delimiter: alternative delimiter to use in place of the
>> >> standard
>> >> postgres delimiter ("\t")
>> >>       * $null: alternative string to use as null value. Default is "\N"
>> >>        * $fields: string with table fields to include in the row of the
>> >> array. Fields are separated by comma
>> >>
>> >>
>> >> pgsqlCopyToFile($table,$filename,$delimiter,$null,$fields)
>> >>
>> >>
>> >>    It uses the native Postgresql copy construct to retrieve $table
>> >> contents
>> >> and store them into a file.
>> >>    It returns boolean.
>> >>    The format of the rows stored into the file is indicated in the
>> >> $delimiter, $null and $fields parameters.
>> >>    Parameters:
>> >>       * (mandatory) $table: table to retrieve data from.
>> >>       * (mandatory) $filename: file where to store the contents of the
>> >> table
>> >>       * $delimiter: alternative delimiter to use in place of the
>> >> standard
>> >> postgres delimiter ("\t")
>> >>       * $null: alternative string to use as null value. Default is "\N"
>> >>        * $fields: string with table fields to include in the row of the
>> >> array. Fields are separated by comma
>> >>
>> >>
>> >> ----- Messaggio originale -----
>> >> > Da: "Ilia Alshanetsky" <i***@*rohost.org>
>> >> > A: "Denis Gasparin" <denis.gaspa***@*distar.com>
>> >> > Cc: intern***@*ists.php.net
>> >> > Inviato: Martedì, 25 maggio 2010 18:40:09
>> >> > Oggetto: Re: New PDO methods for PostgreSQL driver
>> >>
>> >> > Good reason, I'll review the patch in the next day or two.
>> >> >
>> >> >
>> >> > On Mon, May 24, 2010 at 5:55 PM, Denis Gasparin <
>> >> > denis.gaspa***@*distar.com > wrote:
>> >> >
>> >> >
>> >> >
>> >> > The copy to/from sql statements accept both as main parameter a
>> >> > filename or stdout/stdin respectively.
>> >> >
>> >> > The filename represents a file in the database filesystem (apache/php
>> >> > and postgresql must reside on the same machine or share the file via
>> >> > shared filesystem). I quote from the postgresql manual:
>> >> >
>> >> > <<<
>> >> > COPY with a file name instructs the PostgreSQL server to directly
>> >> > read
>> >> > from or write to a file. The file must be accessible to the server
>> >> > and
>> >> > the name must be specified from the viewpoint of the (database)
>> >> > server.
>> >> > >>>
>> >> >
>> >> > Because of this "limitation", if you'd like to load a csv file into
>> >> > pgsql via copy command, you must before copy into a shared folder and
>> >> > the issue the copy from filename command.
>> >> > Using the methods added to PDO, you can do it directly from the
>> >> > webserver.
>> >> >
>> >> > About copying to/from stdin and stdout, PostgreSQL enters a
>> >> > particular
>> >> > status after a copy stdin/stdout command has been issued via sql.
>> >> > These status codes are PGRES_COPY_OUT and PGRES_COPY_IN. When in this
>> >> > status, the only way to interact with the database server is via
>> >> > PQgetCopyData and PQputCopyData.
>> >> >
>> >> > There are not PDO methods or functions that implements these
>> >> > functions
>> >> > and there is no way to share the connection between PDO driver and
>> >> > old
>> >> > pgsql drivers.
>> >> >
>> >> > These are the relevant PostgreSQL man pages:
>> >> >
>> >> >http://www.postgresql.org/docs/8.2/interactive/libpq-copy..html>> >> >http://www.postgresql.org/docs/8.2/interactive/sql-copy.html>> >> >
>> >> > Denis
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > > Denis could you elaborate on what makes use of the COPY code via
>> >> > > Sql
>> >> > > behave differently then a PHP method call?
>> >> > >
>> >> > > Ilia Alshanetsky
>> >> > > CIO/CSO Centah Inc.
>> >> > >
>> >> > > On 2010-05-24, at 15:45, Denis Gasparin <
>> >> > > denis.gaspa***@*distar.com
>> >> > > >
>> >> > > wrote:
>> >> > >
>> >> > > >
>> >> > > > I'll provide the patches in a single file as soon as possible..
>> >> > > >
>> >> > > > Actually all the methods are wrappers against the native
>> >> > > > PostgreSQL commands (connection status, copy to/from).
>> >> > > >
>> >> > > > I needed to develop them as methods because it is not possible to
>> >> > > > get the same results with a sql statement (in particular for
>> >> > > > connection status).
>> >> > > >
>> >> > > > It was not possible also for COPY TO/FROM because of the way
>> >> > > > PostgreSQL handle them ( special functions were developed also
>> >> > > > for
>> >> > > > the old pgsql driver).
>> >> > > >
>> >> > > > We are currently using them in production and we needed them in
>> >> > > > order to avoid additional connections to database (one with the
>> >> > > > old driver and one with PDO).
>> >> > > >
>> >> > > > Denis
>> >> > > >
>> >> > > >
>> >> > > > ----- Messaggio originale -----
>> >> > > >> Da: "Ilia Alshanetsky" < i***@*rohost.org >
>> >> > > >> A: "Denis Gasparin" < denis.gaspa***@*distar.com >
>> >> > > >> Cc: intern***@*ists.php.net
>> >> > > >> Inviato: Lunedì, 24 maggio 2010 19:54:46
>> >> > > >> Oggetto: Re: New PDO methods for PostgreSQL
>> >> > > >> driver
>> >> > > >
>> >> > > >> Denis,
>> >> > > >>
>> >> > > >>
>> >> > > >> Could you merge the patches into a single for easier code
>> >> > > >> review.
>> >> > > >> Also, the copy to/from file seems like it would just be a
>> >> > > >> wrapper
>> >> > > >> against the native COPY PostgreSQL command, is there really a
>> >> > > >> need to provide a method for it?
>> >> > > >>
>> >> > > >>
>> >> > > >> On Mon, May 24, 2010 at 4:57 AM, Denis Gasparin <
>> >> > > >> denis.gaspa***@*distar.com > wrote:
>> >> > > >>
>> >> > > >>
>> >> > > >> Hi.
>> >> > > >>
>> >> > > >> I developed some patches for PDO/Postgresql driver in order to
>> >> > > >> add some useful methods that were available in the original
>> >> > > >> pgsql
>> >> > > >> driver.
>> >> > > >>
>> >> > > >> The attached patches apply on 5.3.2 and svn 5.3.x.
>> >> > > >> If needed, i have patches also for 5.2.x.
>> >> > > >>
>> >> > > >> Please comment and tell me improvements or tips.
>> >> > > >>
>> >> > > >> Thank you in advance,
>> >> > > >>
>> >> > > >> Denis Gasparin
>> >> > > >>
>> >> > > >> Documentation of the added methods follows:
>> >> > > >>
>> >> > > >> pgsqlIsInTransaction()
>> >> > > >>
>> >> > > >> It uses the native Postgresql functions to check transaction
>> >> > > >> status..
>> >> > > >> It returns one of the following status codes:
>> >> > > >> * PDO::PGSQL_TRANSACTION_IDLE: connection in idle status
>> >> > > >> * PDO::PGSQL_TRANSACTION_ACTIVE: connection is executing a
>> >> > > >> command * PDO::PGSQL_TRANSACTION_INTRANS: connection is idle in
>> >> > > >> a
>> >> > > >> valid transaction block
>> >> > > >> * PDO::PGSQL_TRANSACTION_INERROR: connection is idle, in a
>> >> > > >> failed
>> >> > > >> transaction block
>> >> > > >> * PDO::PGSQL_TRANSACTION_UNKNOWN: connection is in a bad status
>> >> > > >>
>> >> > > >>
>> >> > > >>
>> >> > > >> pgsqlCopyFromArray($table,Array $data,$delimiter,$null, Array
>> >> > > >> $fields)
>> >> > > >>
>> >> > > >> It uses the native Postgresql copy construct to append $data to
>> >> > > >> $table. It returns boolean.
>> >> > > >> Parameters: * (mandatory) $table: table to append data to
>> >> > > >> * (mandatory) $data: Array of rows with data in table field
>> >> > > >> order
>> >> > > >> (or as specified in the $fields array). Fields must be separated
>> >> > > >> by $delimiter or by
>> >> > > >> postgresql standard \t)
>> >> > > >> * $delimiter: alternative delimiter to use in place of the
>> >> > > >> standard postgres delimiter ("\t")
>> >> > > >> * $null: alternative string to use as null value. Default is
>> >> > > >> "\N"
>> >> > > >> * $fields: array with table fields that are specified in $data
>> >> > > >> parameter
>> >> > > >>
>> >> > > >>
>> >> > > >>
>> >> > > >> pgsqlCopyFromFile($table,$filename,$delimiter,$null,$fields)
>> >> > > >>
>> >> > > >> It uses the native Postgresql copy construct to append $filename
>> >> > > >> contents to $table.
>> >> > > >> It returns boolean.
>> >> > > >> Parameters: * (mandatory) $table: table to append data to.
>> >> > > >> * (mandatory) $filename: file with contents to append to $table.
>> >> > > >> See Postgresql documentation for the format.
>> >> > > >> * $delimiter: alternative delimiter to use in place of the
>> >> > > >> standard postgres delimiter ("\t")
>> >> > > >> * $null: alternative string to use as null value. Default is
>> >> > > >> "\N"
>> >> > > >> * $fields: array with table fields that are specified in
>> >> > > >> $filename file
>> >> > > >>
>> >> > > >> pgsqlCopyToArray($table,$delimiter,$null,$fields)
>> >> > > >>
>> >> > > >> It uses the native Postgresql copy construct to retrieve $table
>> >> > > >> contents and store them to an array.
>> >> > > >> It returns an array of rows or false in case of problems.
>> >> > > >> The format of the rows into the array is indicated in the
>> >> > > >> $delimiter, $null and $fields parameters.
>> >> > > >> Parameters: * (mandatory) $table: table to retrieve data from..
>> >> > > >> * $delimiter: alternative delimiter to use in place of the
>> >> > > >> standard postgres delimiter ("\t")
>> >> > > >> * $null: alternative string to use as null value. Default is
>> >> > > >> "\N"
>> >> > > >> * $fields: array with table fields to include in the row of the
>> >> > > >> array.
>> >> > > >>
>> >> > > >>
>> >> > > >> pgsqlCopyToFile($table,$filename,$delimiter,$null,$fields)
>> >> > > >>
>> >> > > >>
>> >> > > >> It uses the native Postgresql copy construct to retrieve $table
>> >> > > >> contents and store them into a file.
>> >> > > >> It returns boolean.
>> >> > > >> The format of the rows stored into the file is indicated in the
>> >> > > >> $delimiter, $null and $fields parameters.
>> >> > > >> Parameters: * (mandatory) $table: table to retrieve data from..
>> >> > > >> * (mandatory) $filename: file where to store the contents of the
>> >> > > >> table * $delimiter: alternative delimiter to use in place of the
>> >> > > >> standard postgres delimiter ("\t")
>> >> > > >> * $null: alternative string to use as null value. Default is
>> >> > > >> "\N"
>> >> > > >> * $fields: array with table fields to include in the row of the
>> >> > > >> array.
>> >> > > >>
>> >> > > >> -- PHP Internals - PHP Runtime Development Mailing List
>> >> > > >> To unsubscribe, visit:http://www.php.net/unsub.php>> >>
>> >
>>
>>
>>
>> --
>> Pierre
>>
>> @pierrejoye |http://blog.thepimp.net|http://www.libgd.org>
>



--
Pierre

@pierrejoye |http://blog.thepimp.net|http://www.libgd.org--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#7 June 14, 2010 17:07:02

Pierre J.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PDO] Re: [PHP-DEV] [PATCH] New PDO methods for PostgreSQL driver


On Sat, Jun 12, 2010 at 12:24 PM, Pierre Joye <pierre.***@*mail.com> wrote:
> hi Ilia,
>
> So you basically say that the worries and wishes raised here are
> simply irrelevant and at the end of the day you decide what PDO can or
> cannot be?
>
> I'm very disappointed by these two commits. I don't think it is the
> way we should develop PDO and it is clear that I'm not the only one to
> think that. As it is trunk, I won't battle too much to revert it but
> be sure that is not something I will let in for any of the upcoming
> releases as it is clearly bad design.

I did not see that you even committed that to 5.3. That's definitively a no go.

Cheers,
--
Pierre

@pierrejoye |http://blog.thepimp.net|http://www.libgd.org--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#8 June 15, 2010 12:05:34

Ilia A.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PDO] Re: [PHP-DEV] [PATCH] New PDO methods for PostgreSQL driver


Pierre,

That is not your decision, since when do you decide what goes into PDO,
that's a decision between the extension maintainer and the release master
and since you are neither...

On Mon, Jun 14, 2010 at 12:06 PM, Pierre Joye <pierre.***@*mail.com> wrote:

> On Sat, Jun 12, 2010 at 12:24 PM, Pierre Joye <pierre.***@*mail.com>
> wrote:
> > hi Ilia,
> >
> > So you basically say that the worries and wishes raised here are
> > simply irrelevant and at the end of the day you decide what PDO can or
> > cannot be?
> >
> > I'm very disappointed by these two commits. I don't think it is the
> > way we should develop PDO and it is clear that I'm not the only one to
> > think that. As it is trunk, I won't battle too much to revert it but
> > be sure that is not something I will let in for any of the upcoming
> > releases as it is clearly bad design.
>
> I did not see that you even committed that to 5.3. That's definitively a no
> go.
>
> Cheers,
> --
> Pierre
>
> @pierrejoye |http://blog.thepimp.net|http://www.libgd.org>

Offline

  • Root
  • » PHP
  • » [PDO] Re: [PHP-DEV] [PATCH] New PDO methods for PostgreSQL driver [RSS Feed]

Board footer

Moderator control

Enjoy the 14th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support