Skip to content

Commit

Permalink
Add connection parameters for query context cache and retry context
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-hx committed Sep 22, 2023
1 parent 134fa03 commit ec1d2b8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions php_pdo_snowflake_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,7 @@ enum {
#define PDO_SNOWFLAKE_CONN_ATTR_PRIV_KEY_FILE_PWD_IDX 14
#define PDO_SNOWFLAKE_CONN_ATTR_PROXY_IDX 15
#define PDO_SNOWFLAKE_CONN_ATTR_NO_PROXY_IDX 16
#define PDO_SNOWFLAKE_CONN_ATTR_DISABLE_QUERY_CONTEXT_CACHE_IDX 17
#define PDO_SNOWFLAKE_CONN_ATTR_INCLUDE_RETRY_REASON_IDX 18

#endif /* PHP_PDO_SNOWFLAKE_INT_H */
20 changes: 19 additions & 1 deletion snowflake_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,9 @@ pdo_snowflake_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* {{{ */
{"priv_key_file", NULL, 0},
{"priv_key_file_pwd", NULL, 0},
{"proxy", NULL, 0},
{"no_proxy", NULL, 0}
{"no_proxy", NULL, 0},
{"disablequerycontextcache", "false", 0},
{"includeretryreason", "true", 0}
};

// Parse the input data parameters
Expand Down Expand Up @@ -768,6 +770,22 @@ pdo_snowflake_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* {{{ */
PDO_LOG_DBG(
"no_proxy: %s", vars[PDO_SNOWFLAKE_CONN_ATTR_NO_PROXY_IDX].optval);

snowflake_set_attribute(
H->server, SF_CON_DISABLE_QUERY_CONTEXT_CACHE,
(strcasecmp(vars[PDO_SNOWFLAKE_CONN_ATTR_DISABLE_QUERY_CONTEXT_CACHE_IDX].optval, "true") == 0) ?
&SF_BOOLEAN_TRUE : &SF_BOOLEAN_FALSE);
PDO_LOG_DBG(
"disablequerycontextcache: %s",
vars[PDO_SNOWFLAKE_CONN_ATTR_DISABLE_QUERY_CONTEXT_CACHE_IDX].optval);

snowflake_set_attribute(
H->server, SF_CON_INCLUDE_RETRY_REASON,
(strcasecmp(vars[PDO_SNOWFLAKE_CONN_ATTR_INCLUDE_RETRY_REASON_IDX].optval, "true") == 0) ?
&SF_BOOLEAN_TRUE : &SF_BOOLEAN_FALSE);
PDO_LOG_DBG(
"includeretryreason: %s",
vars[PDO_SNOWFLAKE_CONN_ATTR_INCLUDE_RETRY_REASON_IDX].optval);

if (snowflake_connect(H->server) > 0) {
pdo_snowflake_error(dbh);
goto cleanup;
Expand Down
2 changes: 1 addition & 1 deletion tests/connect.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pdo_snowflake.cacert=libsnowflakeclient/cacert.pem
include __DIR__ . "/common.php";

// full parameters
$dbh = new PDO("$dsn;application=phptest;authenticator=snowflake;priv_key_file=tests/p8test.pem;priv_key_file_pwd=test", $user, $password);
$dbh = new PDO("$dsn;application=phptest;authenticator=snowflake;priv_key_file=tests/p8test.pem;priv_key_file_pwd=test;disablequerycontext=true;includeretryreason=false", $user, $password);
// create table for testing autocommit later
$tablename = "autocommittest" . rand();
$count = $dbh->exec("create or replace table " . $tablename . "(c1 int)");
Expand Down

0 comments on commit ec1d2b8

Please sign in to comment.