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

Reject unsupported aggregates during anon query validation. #70

Merged
merged 2 commits into from
Mar 17, 2021

Conversation

cristianberneanu
Copy link
Collaborator

Closes #14.


static void verify_aggregators(Query *query)
{
query_tree_walker(query, verify_aggregator, NULL, QTW_DONT_COPY_QUERY);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QTW_DONT_COPY_QUERY has no effect because this is not a mutator. I think 0 can be passed as flags.

Comment on lines 66 to 67
if (IsA(node, Query))
return query_tree_walker((Query *)node, verify_aggregator, context, QTW_DONT_COPY_QUERY);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a query_or_expression_tree_walker in nodeFuncs which could handle the checking for us.

bool query_or_expression_tree_walker(Node *node, bool (*walker) (), void *context, int flags) {
	if (node && IsA(node, Query))
		return query_tree_walker((Query *) node, walker, context, flags);
	else
		return walker(node, context);
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only useful for starting the inspection when we don't know if the node is a query or an expression.
We already know we are starting from a query node, so we don't need to check anything at that point.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tail call could be replaced with that and the condition could be dropped. Anyhow we don't gain much with this change so it's fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it can't be used there, it would go into an infinite loop (it calls the walker directly instead of expression_tree_walker).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you're right. Sorry!

@cristianberneanu
Copy link
Collaborator Author

Ready for review.

@cristianberneanu cristianberneanu merged commit 6de385e into master Mar 17, 2021
@cristianberneanu cristianberneanu deleted the cristian/misc branch March 17, 2021 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reject unsupported aggregates during anon query validation
2 participants