summaryrefslogtreecommitdiff
path: root/Userland/Utilities/sql.cpp
AgeCommit message (Collapse)Author
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
2022-03-24sql: Re-prompt user for input after unrecognized commandNicholas Cellino
This fixes a bug in the SQL REPL where after a user enters an unrecognized command, the REPL would not print another "> " prompt and would not accept any more input.
2022-03-23sql: Do not indent next line when current one is blankNicholas Cellino
Previously, if a user pressed Enter without typing a command at the SQL REPL, the next line would be automatically indented. This change makes it so we check if there were any tokens in the command before applying the indentation logic.
2022-02-01sql: Port to LibMainalexmajor
2022-01-31Everywhere: Update copyrights with my new serenityos.org e-mail :^)Timothy Flynn
2022-01-15LibCore+LibIPC+Everywhere: Return Stream::LocalSocket from LocalServersin-ack
This change unfortunately cannot be atomically made without a single commit changing everything. Most of the important changes are in LibIPC/Connection.cpp, LibIPC/ServerConnection.cpp and LibCore/LocalServer.cpp. The notable changes are: - IPCCompiler now generates the decode and decode_message functions such that they take a Core::Stream::LocalSocket instead of the socket fd. - IPC::Decoder now uses the receive_fd method of LocalSocket instead of doing system calls directly on the fd. - IPC::ConnectionBase and related classes now use the Stream API functions. - IPC::ServerConnection no longer constructs the socket itself; instead, a convenience macro, IPC_CLIENT_CONNECTION, is used in place of C_OBJECT and will generate a static try_create factory function for the ServerConnection subclass. The subclass is now responsible for passing the socket constructed in this function to its ServerConnection base; the socket is passed as the first argument to the constructor (as a NonnullOwnPtr<Core::Stream::LocalServer>) before any other arguments. - The functionality regarding taking over sockets from SystemServer has been moved to LibIPC/SystemServerTakeover.cpp. The Core::LocalSocket implementation of this functionality hasn't been deleted due to my intention of removing this class in the near future and to reduce noise on this (already quite noisy) PR.
2021-11-08LibCore: Use ErrorOr<T> for Core::File::open()Andreas Kling
2021-10-05SQL Utility: Implement reading sql filesJan de Visser
Add a number of command line switches: - '-r/--read': Read a SQL file and quit the REPL when done - '-s/--source': Read a SQL file and return to a SQL prompt when done - '--no-sqlrc': Do not read ~/.sqlrc on startup (see below) Add a dot-command: .read <filename>: Read a SQL file and return to a SQL prompt when done In addition, the sql REPL will source the ~/.sqlrc file on startup if it exists, unless the --no-sqlrc flag is set on startup. Note the slight asymmetry between the --read command line flag (which results in the program quitting when the file is read) and the .read command (which doesn't cause a quit). Also fix merge conflict with #10091
2021-10-05SQL Utility: Redesigned the input loopJan de Visser
The existing input loop called the `read_sql` method recursively. This lead to strange behaviour in the event loop. This is solved by encapsulating the REPL in an object and ensuring the `read_sql` method is not called recursively. The method now returns after the first recognized SQL statement or command.
2021-10-05SQL Utility: Implement connection switchingJan de Visser
You can now connect to a different database using the .connect meta command.
2021-10-05SQLServer+SQL+LibSQL: Allow sql client to specify the database nameJan de Visser
The database the sql client connected to was 'hardcoded' to the login name of the calling user. - Extended the IPC API to be more expressive when connecting, by returning the name of the database the client connected to in the 'connected' callback. - Gave the sql client a command line argument (-d/--database) allowing an alternative database name to be specified A subsequent commit will have a dot command allowing the user to connect to different databases from the same sql session.
2021-10-04sql: Account for the single quotes in syntax highlightingMahmoud Mandour
Previously, a String literal token like 'hello' had every char highlighted but for the last 'o' and the closing single quote. This is because the token start is at the opening single quote but the `length` variable only accounted for the value length without the single quotes.
2021-09-11Everywhere: Fix format-vulnerabilitiesBen Wiederhake
Command used: grep -Pirn '(out|warn)ln\((?!["\)]|format,|stderr,|stdout,|output, ")' \ AK Kernel/ Tests/ Userland/ (Plus some manual reviewing.) Let's pick ArgsParser as an example: outln(file, m_general_help); This will fail at runtime if the general help happens to contain braces. Even if this transformation turns out to be unnecessary in a place or two, this way the code is "more obviously" correct.
2021-08-21Utilities: Some minor changes in sql REPL toolJan de Visser
- Added a connection banner - Added '.quit' synonym for '.exit' - Do not display updated/created/deleted banner if there were no changes
2021-08-01Utilities: Remove unused header includesBrian Gianforcaro
2021-07-08Utilities: Teach sql utility to use the SQLClient classJan de Visser
This allows the utility to connect to databases and submit SQL statements.
2021-07-08Everywhere: Add break after the last case label before `default`Daniel Bertalan
We already do this in most places, so the style should be consistent. Also, Clang does not like it, as this could cause an unexpected compile error if some statements are added to the default label or a new label is added above it.
2021-06-24LibSQL: Make lexer and parser more standard SQL compliantJan de Visser
SQL was standardized before there was consensus on sane language syntax constructs had evolved. The language is mostly case-insensitive, with unquoted text converted to upper case. Identifiers can include lower case characters and other 'special' characters by enclosing the identifier with double quotes. A double quote is escaped by doubling it. Likewise, a single quote in a literal string is escaped by doubling it. All this means that the strategy used in the lexer, where a token's value is a StringView 'window' on the source string, does not work, because the value needs to be massaged before being handed to the parser. Therefore a token now has a String containing its value. Given the limited lifetime of a token, this is acceptable overhead. Not doing this means that for example quote removal and double quote escaping would need to be done in the parser or in AST node construction, which would spread lexing basically all over the place. Which would be suboptimal. There was some impact on the sql utility and SyntaxHighlighter component which was addressed by storing the token's end position together with the start position in order to properly highlight it. Finally, reviewing the tests for parsing numeric literals revealed an inconsistency in which tokens we accept or reject: `1a` is accepted but `1e` is rejected. Related to this is the fate of `0x`. Added a FIXME reminding us to address this.
2021-06-24LibSQL: Move Lexer and Parser machinery to AST directoryJan de Visser
The SQL engine is expected to be a fairly sizeable piece of software. Therefore we're starting to restructure the codebase for growth.
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-21Userland: Syntax highlighting of SQL strings and blobsTimothy Flynn
2021-04-20Userland: Add 'sql', a REPL for LibSQLTimothy Flynn
This adds a simple REPL command line utility for (eventually) executing SQL statements / files. Currently, it just validates statements from stdin and prints any errors.