Doc #77240 [Asn->Csd]: Incorrect binding near constraint errors.

From: Date: Sun, 17 Mar 2019 17:50:48 +0000
Subject: Doc #77240 [Asn->Csd]: Incorrect binding near constraint errors.
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-16487@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77240&edit=1

 ID:                 77240
 Updated by:         cmb@php.net
 Reported by:        dave at mausner dot us
 Summary:            Incorrect binding near constraint errors.
-Status:             Assigned
+Status:             Closed
 Type:               Documentation Problem
 Package:            SQLite related
 Operating System:   win 10
 PHP Version:        7.2.12
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


Previous Comments:
------------------------------------------------------------------------
[2019-03-17 17:50:12] cmb@php.net

Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=347015
Log: Fix #77240: Incorrect binding near constraint errors

------------------------------------------------------------------------
[2018-12-05 10:42:06] cmb@php.net

> This bug is similar to #77051.

Actually, this ticket is a duplicate of bug #77051, which will be
fixed in PHP 7.2.14 and PHP 7.3.0 (the latter is scheduled for
release tomorrow, the former on 3 Jan 2019).

> This is rather non-intuitive, because the php doc does not hint
> that reset() is required before bindValue(), moreover the doc on
> reset() doesn't really explain its purpose.

Indeed, the docs should be improved to cater to PHP versions where
this bug is not fixed.  There is already a respective note on
::bindParams()[1], but this should be placed more prominently, and
also placed on the man pages of related functions.

[1] <http://php.net/manual/en/sqlite3stmt.bindparam.php#refsect1-sqlite3stmt.bindparam-notes>

------------------------------------------------------------------------
[2018-12-05 06:11:18] dave at mausner dot us

This bug is similar to #77051. After reading that, I added:
@$bugsql->reset();
before the bindValue calls. This solves the problem.

This is rather non-intuitive, because the php doc does not hint that reset() is required before
bindValue(), moreover the doc on reset() doesn't really explain its purpose.

I observed that the first call to reset() after a constraint violation runs silently, but the NEXT
calls to reset() after a SECOND or more consecutive violations issue a diagnostic that "reset
cannot be performed". 

This is a nuisance diagnostic because adjacent violations caused by consecutive inserts should be
handled the same way, silently--it's not the programmer's fault.

------------------------------------------------------------------------
[2018-12-04 21:53:59] dave at mausner dot us

Also occurs in:
PHP 7.2.12 (cli) (built: Nov  8 2018 05:47:24) (NTS MSVC15 (Visual C++ 2017) x64)
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

------------------------------------------------------------------------
[2018-12-04 20:19:08] dave at mausner dot us

It seems to me that if only one constraint error 19 occurs amid good inserts, the error is not
harmful.  However, if two or more constraint errors occur consecutively, the NEXT good insert will
contain junky data values.

The test data demonstrates this. As the occurrence of non-unique keys increases, the amount of junk
increases, too. Yet the internal echo shows that the intended data was not junk.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=77240


--
Edit this bug report at https://bugs.php.net/bug.php?id=77240&edit=1


Thread (2 messages)

« previous php.doc.bugs (#16487) next »