Skip to content

Commit 98432d5

Browse files
committed
more unifor select results for postgres
1 parent 69e2fe6 commit 98432d5

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

app/src/Core/DatabaseSchemaManager.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ public function getDropDatabaseSqlAction($dbName, $userName, $ifExists = false)
119119

120120
case 'mariadb':
121121
case 'mysql':
122-
/// @todo since mysql 5.7, 'DROP USER IF EXISTS' is supported. We could use it...
123-
$statements = [];
124-
/// @todo test: does dropping the db first have an impact on dropping the user ?
122+
$statements = [
123+
"DROP DATABASE {$ifClause} `$dbName`;"
124+
];
125125
if ($userName != '') {
126+
/// @todo since mysql 5.7, 'DROP USER IF EXISTS' is supported. We could use it...
126127
$statements[] = "DROP USER '$userName'@'%';";
127128
}
128-
$statements[] = "DROP DATABASE {$ifClause} `$dbName`;";
129129
return new Command($statements);
130130

131131
case 'mssql':
@@ -259,6 +259,7 @@ function ($output, $executor) {
259259
case 'sqlite':
260260
return new Command(
261261
null,
262+
/// @todo list the supported utf16 variants as soon as allow using them
262263
function () {
263264
return [];
264265
}
@@ -394,7 +395,8 @@ function ($output, $executor) {
394395
return new Command(
395396
null,
396397
function () {
397-
return [];
398+
// since sqlite does not support users, null seems more appropriate than an empty array...
399+
return null;
398400
}
399401
);
400402

@@ -419,8 +421,6 @@ function ($output, $executor) {
419421
/** @var Executor $executor */
420422
$line = $executor->resultSetToArray($output)[0];
421423
$parts = explode('|', $line);
422-
//preg_match('/version +\| +([^ ]+)/', $line, $matches);
423-
//return $matches[1];
424424
return trim($parts[1]);
425425
}
426426
);

app/src/Core/SqlExecutor/Forked/NativeClient.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public function getProcess($sqlOrFilename, $isFile = false)
7171
$connectString .= $this->databaseConfiguration['dbname'];
7272
}
7373
$options = [
74-
$connectString
74+
$connectString,
75+
'-Pfooter=off'
7576
];
7677
// NB: this triggers a different behaviour that piping multiple commands to stdin, namely
7778
// it wraps all of the commands in a transaction and allows either sql commands or a single meta-command
@@ -176,7 +177,7 @@ public function resultSetToArray($string)
176177
$output = explode("\n", $string);
177178
array_shift($output); // headers
178179
array_shift($output); // '---'
179-
array_pop($output); // '(N rows)'
180+
//array_pop($output); // '(N rows)'
180181
foreach($output as &$line) {
181182
$line = trim($line);
182183
}

doc/TODO.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
## Fixes
22

3-
- check: regression w. mysql (& others) auto drop of users ? does it happen if sql execution fails ?
4-
53
- adminer:
64
+ can not connect to mariadb 5.5
75
+ sqllite not working in pre-filled list of databases (miss filename for root db)
@@ -75,9 +73,10 @@
7573
+ test selecting a string with a | character in it =>
7674
+ no client quotes it: to reliably parse columns we have to rely on tabular format, ie. measure header width...
7775
+ sqllite in default output mode is even worse... (see below)
78-
+ test selecting string with length > 200 chars: ok
76+
+ try to have mssql use a smaller (but dynamic) col width for varchar results
7977
+ investigate the possibility of having the clients emitting directly json results instead of plaintext
8078
+ also: sqlite 3 has a more 'tabular' mode to display results, but it seems not to be able to calculate col. width automatically...
79+
+ test selecting string with length > 200 chars: ok
8180

8281
- improve travis testing:
8382
+ add tests:
@@ -104,6 +103,8 @@
104103

105104
- build:
106105
+ while setting up symfony, have the web site show up a courtesy page
106+
+ when there are no db data files, stack.sh should wait for the db instances to be fully ready...
107+
(use docker native status monitoring to achieve this?)
107108
+ add a composer post-upgrade script that downloads automatically the latest version of adminer or at least checks it
108109
+ run security-checker as part of composer post-install and post-upgrade?
109110
+ stack.sh: force usage of a random (or user-provided) pwd for db root account on startup
@@ -122,15 +123,18 @@
122123
+ add a script that removes docker images and containers (eg. docker-compose down)
123124
+ move from bash to sh ? also, reduce the number of cli commands we use (listed in readme)
124125
+ add shell completion for commands of stack.sh
126+
+ add ./bin/dbconsole as alternative to './bin/stack.sh dbconsole' ?
125127

126128
- worker: improve cli scripts
127129
+ allow to drop many dbs, users in single commands
130+
+ add a user:create command which takes as option the list of dbs to grant access to
128131
+ either remove ./vendor/bin/doctrine-dbal or make it actually work
129132
+ make it possible to have uniform table formatting for SELECT-like queries
130133
- test with rows containing multiple cols, newlines, ...
131134
- sqlite might be problematic
132135
+ when sorting instances, make mariadb_10 go after mariadb_5 and postgresql_10 go after postgresql_9
133136
+ log by default php errors to /var/log/php and mount that dir on host ?
137+
+ add shell completion for commands of dbconsole
134138

135139
- worker: sanitize sql execution cmd:
136140
+ examine in detail and document the differences between running a command vs a file (eg. transaction usage)

doc/WHATSNEW.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Version ?? (unreleased)
44
- New: added dbconsole command: `user:drop`
55

66
- Improved: results of SELECT commands are now displayed using table formatting for MariaDB and MySQL databases
7-
when running dbconsole command `sql:execute`
7+
when running dbconsole command `sql:execute`. Also, results for PostgeSQL databases are more terse (no more footer)
88

99
- Improved: the `database:drop` command reports failures more consistently when trying to drop non-existing databases
1010

0 commit comments

Comments
 (0)