-
-
Notifications
You must be signed in to change notification settings - Fork 254
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
Redo SQL-gen macros to handle things uniformly #1488
Comments
There are errors we could catch if we were clearer about linking things together, at least. For instance, this snippet: extension_sql!(
r#"
CREATE OR REPLACE PROCEDURE my_proc(name VARCHAR) LANGUAGE C AS 'MODULE_PATHNAME', 'my_proc';
"#,
name = "my_proc"
);
#[pg_guard]
pub extern "C" fn my_proc(name: *const c_char) {
todo!()
} This code exists because at the time, pgrx doesn't have support for Apparently Lines 1157 to 1166 in 70cab89
|
Note that this doesn't "really" work for ...question to answer: why is it not, in fact, |
This initially was about a rename. But since then, I have noticed there are so many small, subtly related issues, like:
In each case, it's a sign we're not thinking quite precisely about how the SQL itself works and thus the arguments we must allow an extension writer to impute to it, but are instead playing whack-a-mole with small problems. Emitting SQL needs first-class handling instead of being a bunch of ad-hoc I think the real problem here isn't necessarily about the names, but about handling things much more consistently, and with careful thought about the actual SQL. Which might mean we should rename things, since we probably don't actually want creating a function usable in a trigger to be distinct from creating a function. |
One possible structure I am thinking of is implementing a It may also not be worth macros at all, this is just a thought. Having a highly regular handling, with each struct implementing a trait that defines it as having a "format to SQL" call, may be sufficient. |
Should we name DDL-gen macros for their DDL? e.g.
derive(CreateType)
and#[create_function(or_replace)]
?This is just a thought, because I feel that stuff like
PostgresType
is a little vague, as ispg_extern
. I have seen signs that sometimes people get confused and think you should be using that for "all functions used 'for Postgres'", when that isn't the case as many should be, e.g. in callbacks, regularextern "C"
. They have somewhat more specific purposes, e.g. generating DDL, and should be clearly marked. Thus this is effectively a sub-issue of #1454.The only problem is that it wouldn't strictly replace e.g.
pg_extern
as a notion, becausepg_extern
does more than just emit DDL but also handles the Postgres V1 ABI, and you can also turn off schema emission, and etc. In other words, the names are somewhat vague because the concepts they define are also somewhat nebulous.On the other hand, maybe truly separating "generate DDL for this" and "handle the ABI" as notions, with a sensible default of "both", is exactly what is called for.
The text was updated successfully, but these errors were encountered: