Hi,

the following commit does not work as expected.
I was not able to create new tracker, new document, ... every object that uses 
db_insert. I had to revert it.


Mirabilos, any option about why?

Best,
Franck aka nerville

> - Log -----------------------------------------------------------------
> https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=34d969d788abdb48389719ee367bd4844225c27b
> 
> commit 34d969d788abdb48389719ee367bd4844225c27b
> Author: mirabilos <t.gla...@tarent.de>
> Date:   Thu Mar 16 19:28:50 2017 +0100
> 
>     use a slightly better db_insertid()…
>     
>     … but see 
> https://github.com/tarent/hello-php-world/commit/606335b9194560ccd1249b2a064658c6acf32758
>     for why this is still broken and some better functions (which do
>     require refactoring the code using it, though)
> 
> diff --git a/src/common/include/database-pgsql.php 
> b/src/common/include/database-pgsql.php
> index 95b9c31..d914613 100644
> --- a/src/common/include/database-pgsql.php
> +++ b/src/common/include/database-pgsql.php
> @@ -634,12 +634,12 @@ function db_fetch_array_by_row($qhandle, $row) {
>   * @param    resource        $qhandle                Query result set handle.
>   * @param    string          $table_name             Name of the table you 
> inserted into.
>   * @param    string          $pkey_field_name        Field name of the 
> primary key.
> - * @param    resource                $dbserver               Server to which 
> original query was made
> + * @param    resource        $dbserver               Server to which 
> original query was made
>   * @return   int             id of the primary key or 0 on failure.
>   */
>  function db_insertid($qhandle, $table_name, $pkey_field_name, $dbserver = 
> NULL) {
> -     $sql = "SELECT max($pkey_field_name) AS id FROM $table_name";
> -     $res = db_query_params($sql, array(), -1, 0, $dbserver);
> +     $sql = 'SELECT currval(pg_get_serial_sequence($1, $2)) AS id';
> +     $res = db_query_params($sql, array($table_name, $pkey_field_name), -1, 
> 0, $dbserver);
>       if (db_numrows($res) > 0) {
>               return db_result($res, 0, 'id');
>       } else {
> 
> -----------------------------------------------------------------------
> 
> Summary of changes:
>  src/common/include/database-pgsql.php | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> 
> hooks/post-receive
> -- 
> FusionForge
> 
> _______________________________________________
> Fusionforge-commits mailing list
> fusionforge-comm...@lists.fusionforge.org
> http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits

_______________________________________________
Fusionforge-general mailing list
Fusionforge-general@lists.fusionforge.org
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-general

Reply via email to