Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL: extract views in "create view if not exists VIEW ..." #3850

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sort=no
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
messages_data input.sql /^CREATE VIEW IF NOT EXISTS messages_data AS$/;" V
21 changes: 21 additions & 0 deletions Units/parser-sql.r/sql-create-view-if-not-exists.d/input.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- Taken from leapp-0.15.1/res/schema/audit-layout.sql

CREATE VIEW IF NOT EXISTS messages_data AS
SELECT
message.id AS id,
message.context AS context,
message.stamp AS stamp,
message.topic AS topic,
message.type AS type,
data_source.actor AS actor,
data_source.phase AS phase,
msg_data.hash AS message_hash,
msg_data.data AS message_data,
host.hostname AS hostname
FROM
message
JOIN
data_source ON data_source.id = message.data_source_id,
message_data AS msg_data ON message.message_data_hash = msg_data.hash,
host ON host.id = data_source.host_id
;
5 changes: 5 additions & 0 deletions parsers/sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -2752,10 +2752,15 @@ static void parseView (tokenInfo *const token)
* create view VIEW;
* create view VIEW as ...;
* create view VIEW (...) as ...;
* create view if not exists VIEW as ...;
* -- [SQLITE] https://www.sqlite.org/lang_createview.html
*/

readIdentifier (name);
readToken (token);

parseIdAfterIfNotExists(name, token, false);

if (isType (token, TOKEN_PERIOD))
{
readIdentifier (name);
Expand Down