Skip to content

Commit 52ce468

Browse files
authored
Add snowflake pdo driver (#1218)
* Add support for pdo_snowflake * Fix typo
1 parent d19fe9d commit 52ce468

4 files changed

Lines changed: 46 additions & 3 deletions

File tree

data/special-requirements

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ lz4 !jessie
66
memprof !alpine3.9 !alpine3.10 !alpine3.11 !alpine3.12 !alpine3.13 !alpine3.14 !alpine3.15
77
parallel zts
88
parle !jessie
9+
pdo_snowflake !jessie !stretch !alpine
910
phpy !buster
1011
pthreads zts
1112
saxon !alpine3.7 !alpine3.8 !alpine3.9 !alpine3.10 !alpine3.11 !7.2-alpine !7.3-alpine !7.4-alpine

data/supported-extensions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ pdo_mysql 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4 8.5
8484
pdo_oci 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4 8.5
8585
pdo_odbc 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4 8.5
8686
pdo_pgsql 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4 8.5
87+
pdo_snowflake 8.1 8.2 8.3 8.4
8788
pdo_sqlsrv 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4
8889
pgsql 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4 8.5
8990
phalcon 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4

install-php-extensions

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -671,8 +671,8 @@ expandASpellDictionaries() {
671671
# $@: the PHP module handles
672672
#
673673
# Set:
674-
# PACKAGES_PERSISTENT_NEW the list of packages required at runtume that must be installed
675-
# PACKAGES_PERSISTENT_PRE the list of packages required at runtume that are already installed
674+
# PACKAGES_PERSISTENT_NEW the list of packages required at runtime that must be installed
675+
# PACKAGES_PERSISTENT_PRE the list of packages required at runtime that are already installed
676676
# PACKAGES_VOLATILE the list of packages required at compile time that must be installed
677677
# PACKAGES_PREVIOUS the list of packages (with their version) that are installed right now (calculated only on Debian and only if PACKAGES_PERSISTENT_NEW or PACKAGES_VOLATILE are not empty)
678678
# COMPILE_LIBS
@@ -1464,6 +1464,10 @@ buildRequiredPackageLists() {
14641464
buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile gnupg apt-transport-https"
14651465
fi
14661466
;;
1467+
pdo_snowflake@debian)
1468+
buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libstdc++6 libcurl4"
1469+
buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile cmake g++ $buildRequiredPackageLists_libssldev libcurl4-openssl-dev"
1470+
;;
14671471
ssh2@alpine)
14681472
buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libssh2"
14691473
buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libssh2-dev"
@@ -1924,7 +1928,7 @@ getModuleFullPath() {
19241928
# $1: the name of the PHP extension
19251929
#
19261930
# Return:
1927-
# 0 (true): if suceeded
1931+
# 0 (true): if succeeded
19281932
# non-zero (false): in case of errors
19291933
postProcessModule() {
19301934
postProcessModule_file="$(getModuleFullPath "$1")"
@@ -4345,6 +4349,29 @@ installRemoteModule() {
43454349
fi
43464350
fi
43474351
;;
4352+
pdo_snowflake)
4353+
if test -z "$installRemoteModule_version"; then
4354+
installRemoteModule_version="$(curl -sSLf https://api.github.com/repos/snowflakedb/pdo_snowflake/releases/latest 2>/dev/null | grep -o '"tag_name": *"[^"]*"' | head -1 | sed 's/.*"v*\([^"]*\)".*/\1/')"
4355+
if test -z "$installRemoteModule_version"; then
4356+
printf 'Failed to detect pdo_snowflake version\n' >&2
4357+
exit 1
4358+
fi
4359+
fi
4360+
installRemoteModule_src="$(getPackageSource "https://github.com/snowflakedb/pdo_snowflake/archive/refs/tags/v${installRemoteModule_version}.tar.gz")"
4361+
cd "$installRemoteModule_src"
4362+
chmod +x scripts/build_pdo_snowflake.sh
4363+
PHP_HOME="$(php-config --prefix)" ./scripts/build_pdo_snowflake.sh
4364+
cp modules/pdo_snowflake.so "$PHP_EXTDIR/pdo_snowflake.so"
4365+
if test -f libsnowflakeclient/cacert.pem; then
4366+
installRemoteModule_cacert_path="/usr/local/share/snowflake/cacert.pem"
4367+
mkdir -p "$(dirname "$installRemoteModule_cacert_path")"
4368+
cp libsnowflakeclient/cacert.pem "$installRemoteModule_cacert_path"
4369+
installRemoteModule_ini_extra="pdo_snowflake.cacert=$installRemoteModule_cacert_path"
4370+
fi
4371+
cd - >/dev/null
4372+
rm -rf "$installRemoteModule_src"
4373+
installRemoteModule_manuallyInstalled=1
4374+
;;
43484375
ssh2)
43494376
if test -z "$installRemoteModule_version"; then
43504377
if test $PHP_MAJMIN_VERSION -le 506; then

scripts/tests/pdo_snowflake

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
require_once __DIR__ . '/_bootstrap.php';
5+
6+
try {
7+
new PDO('snowflake:account=test;warehouse=test;database=test;schema=test', 'test_user', 'test_password');
8+
} catch (PDOException $x) {
9+
if (stripos($x->getMessage(), 'could not find driver') !== false ||
10+
stripos($x->getMessage(), 'invalid data source') !== false) {
11+
fwrite(STDERR, trim($x->getMessage() . "\n"));
12+
exit(1);
13+
}
14+
}

0 commit comments

Comments
 (0)