-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Incorrect query is parsed without any errors #157
Comments
Hi, please can you clarify what the problem is? It's not easy to tell from what you wrote above... |
Hi @lelit, The query is incorrect, because there is no |
Oh, I see. This is another case where the problem is in the underlying If I change the original simple_plpgsql.c using your statement like this #include <pg_query.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
PgQueryPlpgsqlParseResult result;
result = pg_query_parse_plpgsql(" \
CREATE OR REPLACE FUNCTION update_customer_total_sales(customer_id INT) \
RETURNS VOID AS $$ \
DECLARE \
total NUMERIC; \
BEGIN \
SELECT COALESCE(SUM(amount), 0) INTO total \
FROM orders \
WHERE customer_id $1; \
UPDATE customers \
SET total_sales = total \
WHERE customer_id; \
RAISE NOTICE 'Total sales for customer ID %: %', customer_id, total; \
END; \
$$ LANGUAGE plpgsql;");
if (result.error) {
printf("error: %s at %d\n", result.error->message, result.error->cursorpos);
} else {
printf("%s\n", result.plpgsql_funcs);
}
pg_query_free_plpgsql_parse_result(result);
// Optional, this ensures all memory is freed upon program exit (useful when running Valgrind)
pg_query_exit();
return 0;
} and execute it $ make examples/simple_plpgsql
$ examples/simple_plpgsql I get
Can you try creating an issue there? |
Thanks, see issue libpg_query#261. |
Query
Returns
The text was updated successfully, but these errors were encountered: