Skip to content

Commit ec3daea

Browse files
committedJun 13, 2023
ext/pdo_pgsql: connection status update to distinguish from truly bad quality connections.
Close GH-11443
1 parent dd8514a commit ec3daea

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed
 

‎ext/pdo_pgsql/pgsql_driver.c

+27-7
Original file line numberDiff line numberDiff line change
@@ -463,33 +463,53 @@ static int pdo_pgsql_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *return_
463463
case PDO_ATTR_CONNECTION_STATUS:
464464
switch (PQstatus(H->server)) {
465465
case CONNECTION_STARTED:
466-
ZVAL_STRINGL(return_value, "Waiting for connection to be made.", sizeof("Waiting for connection to be made.")-1);
466+
ZVAL_STRINGL(return_value, "Waiting for connection to be made.", strlen("Waiting for connection to be made."));
467467
break;
468468

469469
case CONNECTION_MADE:
470470
case CONNECTION_OK:
471-
ZVAL_STRINGL(return_value, "Connection OK; waiting to send.", sizeof("Connection OK; waiting to send.")-1);
471+
ZVAL_STRINGL(return_value, "Connection OK; waiting to send.", strlen("Connection OK; waiting to send."));
472472
break;
473473

474474
case CONNECTION_AWAITING_RESPONSE:
475-
ZVAL_STRINGL(return_value, "Waiting for a response from the server.", sizeof("Waiting for a response from the server.")-1);
475+
ZVAL_STRINGL(return_value, "Waiting for a response from the server.", strlen("Waiting for a response from the server."));
476476
break;
477477

478478
case CONNECTION_AUTH_OK:
479-
ZVAL_STRINGL(return_value, "Received authentication; waiting for backend start-up to finish.", sizeof("Received authentication; waiting for backend start-up to finish.")-1);
479+
ZVAL_STRINGL(return_value, "Received authentication; waiting for backend start-up to finish.", strlen("Received authentication; waiting for backend start-up to finish."));
480480
break;
481481
#ifdef CONNECTION_SSL_STARTUP
482482
case CONNECTION_SSL_STARTUP:
483-
ZVAL_STRINGL(return_value, "Negotiating SSL encryption.", sizeof("Negotiating SSL encryption.")-1);
483+
ZVAL_STRINGL(return_value, "Negotiating SSL encryption.", strlen("Negotiating SSL encryption."));
484484
break;
485485
#endif
486486
case CONNECTION_SETENV:
487-
ZVAL_STRINGL(return_value, "Negotiating environment-driven parameter settings.", sizeof("Negotiating environment-driven parameter settings.")-1);
487+
ZVAL_STRINGL(return_value, "Negotiating environment-driven parameter settings.", strlen("Negotiating environment-driven parameter settings."));
488488
break;
489489

490+
#ifdef CONNECTION_CONSUME
491+
case CONNECTION_CONSUME:
492+
ZVAL_STRINGL(return_value, "Flushing send queue/consuming extra data.", strlen("Flushing send queue/consuming extra data."));
493+
break;
494+
#endif
495+
#ifdef CONNECTION_GSS_STARTUP
496+
case CONNECTION_SSL_STARTUP:
497+
ZVAL_STRINGL(return_value, "Negotiating GSSAPI.", strlen("Negotiating GSSAPI."));
498+
break;
499+
#endif
500+
#ifdef CONNECTION_CHECK_TARGET
501+
case CONNECTION_CHECK_TARGET:
502+
ZVAL_STRINGL(return_value, "Connection OK; checking target server properties.", strlen("Connection OK; checking target server properties."));
503+
break;
504+
#endif
505+
#ifdef CONNECTION_CHECK_STANDBY
506+
case CONNECTION_CHECK_STANDBY:
507+
ZVAL_STRINGL(return_value, "Connection OK; checking if server in standby.", strlen("Connection OK; checking if server in standby."));
508+
break;
509+
#endif
490510
case CONNECTION_BAD:
491511
default:
492-
ZVAL_STRINGL(return_value, "Bad connection.", sizeof("Bad connection.")-1);
512+
ZVAL_STRINGL(return_value, "Bad connection.", strlen("Bad connection."));
493513
break;
494514
}
495515
break;

0 commit comments

Comments
 (0)
Please sign in to comment.