Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Roseseed
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Wanxin Li
Roseseed
Commits
b77996c2
Commit
b77996c2
authored
5 years ago
by
Wanxin Li
Browse files
Options
Downloads
Patches
Plain Diff
added create_as_operator
parent
b82756ee
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
SQLPGrammar_new.y
+30
-16
30 additions, 16 deletions
SQLPGrammar_new.y
util_new.c
+7
-0
7 additions, 0 deletions
util_new.c
util_new.h
+1
-0
1 addition, 0 deletions
util_new.h
with
38 additions
and
16 deletions
SQLPGrammar_new.y
+
30
−
16
View file @
b77996c2
...
...
@@ -52,25 +52,32 @@ Query
SelectQuery
: SELECT
: SELECT SelectList
| SELECT Body
{
printf("SelectQuery 1 \n");
$$ = $2;
}
| SELECT SelectList
Body
| SELECT SelectList
{
printf("SelectQuery 2 \n");
$$ = create_rename_operator($2, NULL);
}
| SELECT Body
{
printf("SelectQuery 3 \n");
$$ = create_rename_operator($2, NULL);
}
| SELECT SelectList Body
{
printf("SelectQuery 4 \n");
$$ = create_proj_operator($2, $3);
}
| SELECT DISTINCT Body
{
printf("SelectList
3
\n");
$$ =
$3
;
printf("SelectList
5
\n");
$$ =
create_rename_operator($3, NULL)
;
}
| SELECT DISTINCT SelectList Body
{
printf("SelectList
4
\n");
printf("SelectList
6
\n");
$$ = create_proj_operator($2, $3);
}
;
...
...
@@ -79,12 +86,13 @@ Body
: FROM TableList
{
printf("Body 1 \n");
$$ =
$2
;
$$ =
create_rename_operator($2, NULL)
;
}
| FROM WHERE Pred
{
printf("Body 2 \n");
// todo
$$ = create_rename_operator($3, NULL);
}
| FROM TableList WHERE Pred
{
...
...
@@ -99,7 +107,7 @@ TableList
printf("TableList 1\n");
$$ = create_rename_operator($1, $2);
}
| TableIdentifier VarIdentifier ',' TableList
// keep right-recursive
| TableIdentifier VarIdentifier ',' TableList
{
printf("TableList 2\n");
$$ = create_cross_operator(create_rename_operator($1, $2), $4);
...
...
@@ -108,7 +116,6 @@ TableList
UnionQuery
: '(' SelectQuery ')' UNION UnionQuery
{
printf("UnionQuery 1\n");
...
...
@@ -122,23 +129,31 @@ UnionQuery
| '(' SelectQuery ')'
{
printf("UnionQuery 3\n");
$$ =
$1
;
$$ =
create_rename_operator($1, NULL)
;
}
;
SelectList
: Col
{
printf("SelectList
2
\n");
printf("SelectList
1
\n");
$$ = create_rename_operator($1, NULL);
}
| Col AS AttrIdentifier // todo: create_as_operator
| Col AS AttrIdentifier
{
printf("SelectList 2\n");
$$ = create_as_operator($1, $3);
}
| Col ',' SelectList
{
printf("SelectList
4
\n");
printf("SelectList
3
\n");
$$ = create_rename_operator($1, $2);
}
| Col AS AttrIdentifier ',' SelectList
{
printf("SelectList 4\n");
$$ = create_rename_operator($1, create_as_operator($3, $5));
}
;
Col
...
...
@@ -238,7 +253,6 @@ Conj
{
printf("Conj 2 \n");
$$ = create_and_operator($1, $3);
// $$ = create_not_operator($3);
}
BasicPred
...
...
This diff is collapsed.
Click to expand it.
util_new.c
+
7
−
0
View file @
b77996c2
...
...
@@ -212,6 +212,13 @@ cons_cell* create_eval_operator(cons_cell* logic, cons_cell* cross) {
return
create_cons_cell_w_atom
(
operator
,
var_cons
);
}
cons_cell
*
create_as_operator
(
cons_cell
*
ra1
,
cons_cell
*
ra2
)
{
cons_cell
*
ra2_cons
=
create_cons_cell
(
ra2
,
NULL
);
cons_cell
*
ra1_cons
=
create_cons_cell
(
ra1
,
ra2_cons
);
char
operator
[
3
]
=
"AS
\0
"
;
return
create_cons_cell_w_atom
(
operator
,
ra1_cons
);
}
void
print_cons_tree
(
cons_cell
*
root
)
{
print_cons_tree_helper
(
root
,
0
);
}
...
...
This diff is collapsed.
Click to expand it.
util_new.h
+
1
−
0
View file @
b77996c2
...
...
@@ -83,6 +83,7 @@ cons_cell* create_elim_operator(cons_cell* ra1);
cons_cell
*
create_eval_operator
(
cons_cell
*
logic
,
cons_cell
*
cross
);
cons_cell
*
create_and_operator
(
cons_cell
*
ra1
,
cons_cell
*
ra2
);
cons_cell
*
create_or_operator
(
cons_cell
*
ra1
,
cons_cell
*
ra2
);
cons_cell
*
create_as_operator
(
cons_cell
*
ra1
,
cons_cell
*
ra2
);
// Prints an in order traversal of the tree
void
print_cons_tree
(
cons_cell
*
root
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment