Bug #72621 [Opn->Nab]: pg_execute(): NULL Date converts to empty string

From: Date: Sat, 21 Nov 2020 17:28:39 +0000
Subject: Bug #72621 [Opn->Nab]: pg_execute(): NULL Date converts to empty string
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-230496@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72621&edit=1

 ID:                 72621
 Updated by:         kalle@php.net
 Reported by:        ravisen at mail dot ru
 Summary:            pg_execute(): NULL Date converts to empty string
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            PostgreSQL related
 Operating System:   Centos 7
 PHP Version:        7.0.8
 Block user comment: N
 Private report:     N

 New Comment:

.


Previous Comments:
------------------------------------------------------------------------
[2020-11-21 17:12:51] dev at dcolt dot org

Just tested this in PHP 7.4.12, on Gentoo, against Postgresql 13.1

And I do get the Expected result (Record added to the table)

I also made a reference program in C++ to test the libpq functions directly.

Reference code:
---------------
#include <array>
#include <iostream>
#include <libpq-fe.h>

int main() {
  PGconn *conn =
      PQconnectdb("dbname=test user=postgres password=postgres");

  PGresult *result = PQprepare(
      conn, "",
      "INSERT INTO t_lot_steps( n_id_lot,  d_start )  VALUES ( $1, $2 ) ", 0,
      nullptr);

  std::array<const char *, 2> params = {"1", nullptr};

  PGresult *returnResult =
      PQexecPrepared(conn, "", 2, params.data(), nullptr, nullptr, 0);

  auto status = PQresultStatus(returnResult);

  PQfinish(conn);
  return 0;
}

------------------------------------------------------------------------
[2016-07-19 13:33:04] ravisen at mail dot ru

Description:
------------
NULL Date converts to empty string

Test script:
---------------
/* SQL Table
CREATE TABLE t_lot_steps
(
  n_id_lot integer NOT NULL, 
  d_start date
)
*/

$sql = 'INSERT INTO t_lot_steps( n_id_lot,  d_start )  VALUES ( $1, $2 ) ';
$bindsData = [ 1, null ];

$conn = pg_connect(...);
pg_prepare($conn, '', $sql);
pg_execute($conn, '', $bindsData);


Expected result:
----------------
Record added to the table

Actual result:
--------------
E_WARNING pg_execute(): Query failed: ERROR: invalid input syntax for type date: ""


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



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


Thread (3 messages)

« previous php.bugs (#230496) next »