Changeset: ed39e0bf9e67 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/ed39e0bf9e67 Added Files: sql/test/BugTracker-2024/Tests/7536-mclient-forgets-to-flush.SQL.py Modified Files: clients/mapiclient/mclient.c sql/test/BugTracker-2024/Tests/All Branch: Dec2023 Log Message:
mclient: close redirected output stream before exiting Fixes #7536 diffs (56 lines): diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c --- a/clients/mapiclient/mclient.c +++ b/clients/mapiclient/mclient.c @@ -3763,6 +3763,8 @@ main(int argc, char **argv) } mapi_destroy(mid); + if (toConsole != stdout_stream && toConsole != stderr_stream) + close_stream(toConsole); mnstr_destroy(stdout_stream); mnstr_destroy(stderr_stream); if (priv.buf != NULL) diff --git a/sql/test/BugTracker-2024/Tests/7536-mclient-forgets-to-flush.SQL.py b/sql/test/BugTracker-2024/Tests/7536-mclient-forgets-to-flush.SQL.py new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2024/Tests/7536-mclient-forgets-to-flush.SQL.py @@ -0,0 +1,31 @@ +import gzip +import os +import tempfile +import subprocess + + +# This SQL script redirects the output to a file (the %s). +# We will check that all output arrives there, even if it's a gzipped file. +SCRIPT = r""" +\>%s +SELECT 'Donald Knuth'; +""" + + +with tempfile.TemporaryDirectory('mtest') as dir: + outputfile = os.path.join(dir, 'output.txt.gz') + inputfile = os.path.join(dir, 'input.sql') + + with open(inputfile, 'w') as f: + f.write(SCRIPT % outputfile) + + subprocess.check_call([ + 'mclient', '-i', + '-p', os.environ['MAPIPORT'], + inputfile, + ]) + + with gzip.open(outputfile, 'rt', encoding='utf-8') as f: + content = f.read() + + assert 'Donald Knuth' in content diff --git a/sql/test/BugTracker-2024/Tests/All b/sql/test/BugTracker-2024/Tests/All --- a/sql/test/BugTracker-2024/Tests/All +++ b/sql/test/BugTracker-2024/Tests/All @@ -57,3 +57,4 @@ 7512-concurrent-globaltmp-instantiate-cr 7513-uri-authority-parse-issue 7528-jarowinkler-null 7537-prepare_stmt_with_dropped_table +7536-mclient-forgets-to-flush _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org