Skip to content

Commit

Permalink
fix privilege issue on non-windows
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 c7ae160 commit cb7a297
Showing 1 changed file with 36 additions and 28 deletions.
64 changes: 36 additions & 28 deletions tests/htap.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,48 @@ pdo_snowflake.loglevel=TRACE
$dbh = new PDO($dsn, $user, $password);
$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
echo 'Connected to Snowflake' . "\n";
$sth = $dbh->query("create or replace database db1");
$sth = $dbh->query("create or replace hybrid table t1 (a int primary key, b int)");
$sth = $dbh->query("insert into t1 values (1, 2), (2, 3), (3, 4)");
$sth = $dbh->query("create or replace database db2");
$sth = $dbh->query("create or replace hybrid table t2 (a int primary key, b int)");
$sth = $dbh->query("insert into t2 values (1, 3), (2, 2), (3, 4)");
$sth = $dbh->query("create or replace database db3");
$sth = $dbh->query("create or replace hybrid table t3 (a int primary key, b int)");
$sth = $dbh->query("insert into t3 values (1, 3), (2, 2), (3, 4)");
$sth = $dbh->query("select * from db1.public.t1 x, db2.public.t2 y, db3.public.t3 z where x.a = y.a and y.a = z.a;");
$sth = $dbh->query("insert into db2.public.t2 (select y.a*100*z.a, y.b*15*z.b from db1.public.t1 y, db3.public.t3 z where y.a=z.a);");
$sth = $dbh->query("select * from db1.public.t1 x, db2.public.t2 y, db3.public.t3 z where x.a = y.a and y.a = z.a;");
$sth = $dbh->query("select * from db1.public.t1 x, db2.public.t2 y where x.a = y.a;");
$sth = $dbh->query("select * from db2.public.t2 y, db3.public.t3 z where y.a = z.a;");
// run queries on Windows only as the test account on Linux/Mac
// don't have the necessary privileges
if (PHP_OS_FAMILY === "Windows")
{
$sth = $dbh->query("create or replace database db1");
$sth = $dbh->query("create or replace hybrid table t1 (a int primary key, b int)");
$sth = $dbh->query("insert into t1 values (1, 2), (2, 3), (3, 4)");
$sth = $dbh->query("create or replace database db2");
$sth = $dbh->query("create or replace hybrid table t2 (a int primary key, b int)");
$sth = $dbh->query("insert into t2 values (1, 3), (2, 2), (3, 4)");
$sth = $dbh->query("create or replace database db3");
$sth = $dbh->query("create or replace hybrid table t3 (a int primary key, b int)");
$sth = $dbh->query("insert into t3 values (1, 3), (2, 2), (3, 4)");
$sth = $dbh->query("select * from db1.public.t1 x, db2.public.t2 y, db3.public.t3 z where x.a = y.a and y.a = z.a;");
$sth = $dbh->query("insert into db2.public.t2 (select y.a*100*z.a, y.b*15*z.b from db1.public.t1 y, db3.public.t3 z where y.a=z.a);");
$sth = $dbh->query("select * from db1.public.t1 x, db2.public.t2 y, db3.public.t3 z where x.a = y.a and y.a = z.a;");
$sth = $dbh->query("select * from db1.public.t1 x, db2.public.t2 y where x.a = y.a;");
$sth = $dbh->query("select * from db2.public.t2 y, db3.public.t3 z where y.a = z.a;");
}
$dbh = null;

// test with non-default behavior
$dbh = new PDO("$dsn;disablequerycontextcache=true;includeretryreason=false", $user, $password);
$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
echo 'Connected to Snowflake' . "\n";
$sth = $dbh->query("create or replace database db1");
$sth = $dbh->query("create or replace hybrid table t1 (a int primary key, b int)");
$sth = $dbh->query("insert into t1 values (1, 2), (2, 3), (3, 4)");
$sth = $dbh->query("create or replace database db2");
$sth = $dbh->query("create or replace hybrid table t2 (a int primary key, b int)");
$sth = $dbh->query("insert into t2 values (1, 3), (2, 2), (3, 4)");
$sth = $dbh->query("create or replace database db3");
$sth = $dbh->query("create or replace hybrid table t3 (a int primary key, b int)");
$sth = $dbh->query("insert into t3 values (1, 3), (2, 2), (3, 4)");
$sth = $dbh->query("select * from db1.public.t1 x, db2.public.t2 y, db3.public.t3 z where x.a = y.a and y.a = z.a;");
$sth = $dbh->query("insert into db2.public.t2 (select y.a*100*z.a, y.b*15*z.b from db1.public.t1 y, db3.public.t3 z where y.a=z.a);");
$sth = $dbh->query("select * from db1.public.t1 x, db2.public.t2 y, db3.public.t3 z where x.a = y.a and y.a = z.a;");
$sth = $dbh->query("select * from db1.public.t1 x, db2.public.t2 y where x.a = y.a;");
$sth = $dbh->query("select * from db2.public.t2 y, db3.public.t3 z where y.a = z.a;");
if (PHP_OS_FAMILY === "Windows")
{
$sth = $dbh->query("create or replace database db1");
$sth = $dbh->query("create or replace hybrid table t1 (a int primary key, b int)");
$sth = $dbh->query("insert into t1 values (1, 2), (2, 3), (3, 4)");
$sth = $dbh->query("create or replace database db2");
$sth = $dbh->query("create or replace hybrid table t2 (a int primary key, b int)");
$sth = $dbh->query("insert into t2 values (1, 3), (2, 2), (3, 4)");
$sth = $dbh->query("create or replace database db3");
$sth = $dbh->query("create or replace hybrid table t3 (a int primary key, b int)");
$sth = $dbh->query("insert into t3 values (1, 3), (2, 2), (3, 4)");
$sth = $dbh->query("select * from db1.public.t1 x, db2.public.t2 y, db3.public.t3 z where x.a = y.a and y.a = z.a;");
$sth = $dbh->query("insert into db2.public.t2 (select y.a*100*z.a, y.b*15*z.b from db1.public.t1 y, db3.public.t3 z where y.a=z.a);");
$sth = $dbh->query("select * from db1.public.t1 x, db2.public.t2 y, db3.public.t3 z where x.a = y.a and y.a = z.a;");
$sth = $dbh->query("select * from db1.public.t1 x, db2.public.t2 y where x.a = y.a;");
$sth = $dbh->query("select * from db2.public.t2 y, db3.public.t3 z where y.a = z.a;");
}
$dbh = null;
?>
===DONE===
Expand Down

0 comments on commit cb7a297

Please sign in to comment.