chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
$user = $argv[1];
|
||||
$port = $argv[2];
|
||||
$db = 'postgres';
|
||||
|
||||
$conn = new PDO("pgsql:host=localhost;port={$port};dbname={$db}", $user, 'password');
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$queries = [
|
||||
"create table test (pk int, value int, d1 decimal(9, 3), f1 float, c1 char(10), t1 text, primary key(pk))" => 0,
|
||||
"insert into test (pk, value, d1, f1, c1, t1) values (0,0,0.0,0.0,'abc','a1')" => 1,
|
||||
"select * from test" => 1,
|
||||
"select dolt_add('-A');" => 1,
|
||||
"select dolt_commit('-m', 'my commit')" => 1,
|
||||
"select dolt_checkout('-b', 'mybranch')" => 1,
|
||||
"insert into test (pk, value, d1, f1, c1, t1) values (1,1, 123456.789, 420.42,'example','some text')" => 1,
|
||||
"select dolt_commit('-a', '-m', 'my commit2')" => 1,
|
||||
"select dolt_checkout('main')" => 1,
|
||||
"select dolt_merge('mybranch')" => 1,
|
||||
"select COUNT(*) FROM dolt.log" => 1
|
||||
];
|
||||
|
||||
foreach ($queries as $query => $expected) {
|
||||
$result = $conn->query($query);
|
||||
if ($result->rowCount() != $expected) {
|
||||
echo "LENGTH: {$result->rowCount()}\n";
|
||||
echo "QUERY: {$query}\n";
|
||||
echo "EXPECTED: {$expected}\n";
|
||||
echo "RESULT: {$result}";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
$result = $conn->query("SELECT * FROM test WHERE pk = 1");
|
||||
assert(1 == $result->rowCount());
|
||||
while($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
||||
assert(1 == $row['pk']);
|
||||
assert(1 == $row['value']);
|
||||
assert(123456.789 == $row['d1']);
|
||||
assert(420.42 == $row['f1']);
|
||||
assert("example " == $row['c1']);
|
||||
assert("some text" == $row['t1']);
|
||||
}
|
||||
|
||||
exit(0)
|
||||
?>
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
$user = $argv[1];
|
||||
$port = $argv[2];
|
||||
$db = 'postgres';
|
||||
|
||||
$conn = pg_connect("host = localhost port = $port dbname = $db user = $user password = 'password'")
|
||||
or die('Could not connect: ' . pg_result_error());
|
||||
|
||||
$queries = [
|
||||
"create table test (pk int, value int, d1 decimal(9, 3), f1 float, c1 char(10), t1 text, primary key(pk))" => 0,
|
||||
"insert into test (pk, value, d1, f1, c1, t1) values (0,0,0.0,0.0,'abc','a1')" => 0,
|
||||
"select * from test" => 1,
|
||||
"select dolt_add('-A');" => 1,
|
||||
"select dolt_commit('-m', 'my commit')" => 1,
|
||||
"select dolt_checkout('-b', 'mybranch')" => 1,
|
||||
"insert into test (pk, value, d1, f1, c1, t1) values (1,1, 123456.789, 420.42,'example','some text')" => 0,
|
||||
"select dolt_commit('-a', '-m', 'my commit2')" => 1,
|
||||
"select dolt_checkout('main')" => 1,
|
||||
"select dolt_merge('mybranch')" => 1,
|
||||
"select COUNT(*) FROM dolt.log" => 1
|
||||
];
|
||||
|
||||
foreach ($queries as $query => $expected) {
|
||||
$result = pg_query($conn, $query);
|
||||
if (is_bool($result)) {
|
||||
if (!$result) {
|
||||
echo "LENGTH: {pg_num_rows($result)}\n";
|
||||
echo "QUERY: {$query}\n";
|
||||
echo "EXPECTED: {$expected}\n";
|
||||
echo "RESULT: {$result}";
|
||||
exit(1);
|
||||
}
|
||||
} else if (pg_num_rows($result) != $expected) {
|
||||
echo "LENGTH: {pg_num_rows($result)}\n";
|
||||
echo "QUERY: {$query}\n";
|
||||
echo "EXPECTED: {$expected}\n";
|
||||
echo "RESULT: {$result}";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
$result = pg_query($conn, "SELECT * FROM test WHERE pk = 1");
|
||||
assert(1 == pg_num_rows($result));
|
||||
while($row = pg_fetch_assoc($result)) {
|
||||
assert(1 == $row['pk']);
|
||||
assert(1 == $row['value']);
|
||||
assert(123456.789 == $row['d1']);
|
||||
assert(420.42 == $row['f1']);
|
||||
assert("example " == $row['c1']);
|
||||
assert("some text" == $row['t1']);
|
||||
}
|
||||
|
||||
pg_close($conn);
|
||||
|
||||
exit(0)
|
||||
?>
|
||||
Reference in New Issue
Block a user