btree index parser err
sql:
CREATE UNIQUE INDEX t_role_tcd_unique_index ON dino.t_role USING btree (tenant_id,
code,(CASE WHEN (del_flag = 1) THEN id ELSE (del_flag)::bigint END));
cannot be parsed
int main() { PgQueryPlpgsqlParseResult result;
//目前无法解析的sql
result =
pg_query_parse_plpgsql("CREATE UNIQUE INDEX t_role_tcd_unique_index ON dino.t_role USING btree (tenant_id, \
code,(CASE WHEN (del_flag = 1) THEN id ELSE (del_flag)::bigint END));"); 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);
return 0;
}
result.plpgsql_funcs output as []
Why are you using pg_query_parse_plpgsql() there instead of pg_query_parse()? That statement is “plain” SQL, isn't it?
Using the pg_query_parse function works fine, but I'm not sure if there is a bug in pg_query_parse_plpgsql
Per the earlier comment, pg_query_parse_plpgsql is not intended to parse arbitrary SQL (it parses PL/pgSQL function definitions), thus closing this as won't fix.