-
-
Notifications
You must be signed in to change notification settings - Fork 251
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
cargo-pgx
can generate schemas
#441
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Okay, so, this kinda works? |
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Hoverbear
changed the title
(WIP)
Feb 22, 2022
cargo-pgx
can generate schemascargo-pgx
can generate schemas
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Hoverbear
commented
Feb 23, 2022
@@ -0,0 +1,113 @@ | |||
use crate::sql_entity_graph::{pgx_sql::PgxSql, to_sql::ToSqlFn, SqlGraphEntity}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to be better at using git mv
... This is a file that got moved.
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
Signed-off-by: Ana Hobden <[email protected]>
This was referenced Feb 25, 2022
Closed
Merged
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR reworks how we do SQL (again). It amounts to a lot of code movement but very little actual changes.
It does however amount to several API breaks.
What's different?
pgx::datum::sql_entity_graph
andpgx_utils::sql_entity_graph
are merged and present inpgx_utils::sql_entity_graph
together.pgx_utils
is now exported frompgx
atpgx::utils
, this is primarily to exposepgx_utils::sql_entity_graph
without requiring users havepgx_utils
in theirCargo.toml
.sql-generator
binary,.cargo/pgx-linker-script.sh
and related.cargo/config
settings are no longer needed. The old.cargo/config
from 0.1.2x is back.pgx_graph_magic!()
now expands with__pgx_source_only_sql_mappings
and__pgx_typeid_sql_mappings
symbols, allowingcargo-pgx
to get the appropriate SQL mappings.cargo pgx schema
now:--message-format=json
on somecargo
invocations and captures that output.OUT_DIR
used by the relevantpgx_pg_sys
build.OUT_DIR
data to read, generate, then build (withrustc
) a 'stub' shared object. (This gets cached!)dlopen
s that shared object.dlopen
s the extension.pgx_utils::sql_entity_graph::PgxSql
builders as thesql-generator
used to.cargo pgx test
andcargo pgx install
had several changes to make them more appropriately and cleanly capture and pass build data for this new process.cargo pgx schema
,cargo pgx install
, andcargo pgx package
all had outputs changed.sql_graph_entity
related functions got a#[doc(hidden)]
attribute to clean up their docs.RUST_LOG
env vars get correctly passed inpgx test
/UX
Now generating a schema, or packaging/installing/testing an extension looks like so:
Users can optionally enable debug or logging still, here's isolated tracing symbols for a
cargo pgx schema
run where stubs did not exist:And now where they do:
Because we use
--message-format=json-render-diagnostics
Cargo still outputs nice errors:Performance
This PR has a fairly dramatic impact on build performance!
Using this script:
I evaluated both this PR and the latest release:
Caveats
Like before, with the
sql-generator
and the linker script, we have undefined behavior if the downstream user brazenly tries to callpgx_pg_sys
related functionality in something like#[pgx(sql = path::to::my_fn)]
.Upgrading
cargo-pgx
version and update yourpgx
related dependencies to the same..cargo/pgx-linker-script.sh
,src/bin/sql-generator.rs
..cargo/config
with:Cargo.toml
: