Skip to content

Commit

Permalink
Do not use CREATE OR REPLACE FUNCTION (#554)
Browse files Browse the repository at this point in the history
Signed-off-by: Ana Hobden <[email protected]>
  • Loading branch information
Hoverbear authored May 16, 2022
1 parent 8672747 commit 80e0ac0
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pgx-examples/triggers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use pgx::*;
pg_module_magic!();

/// ```sql
/// CREATE OR REPLACE FUNCTION trigger_example()
/// CREATE FUNCTION trigger_example()
/// RETURNS TRIGGER
/// LANGUAGE c
/// AS 'MODULE_PATHNAME', 'trigger_example_wrapper';
Expand Down
2 changes: 1 addition & 1 deletion pgx-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ Currently `sql` can be provided one of the following:
* Disable SQL generation with `#[pgx(sql = false)]`
* Call custom SQL generator function with `#[pgx(sql = path::to_function)]`
* Render a specific fragment of SQL with a string `#[pgx(sql = "CREATE OR REPLACE FUNCTION ...")]`
* Render a specific fragment of SQL with a string `#[pgx(sql = "CREATE FUNCTION ...")]`
*/
#[proc_macro_attribute]
Expand Down
2 changes: 1 addition & 1 deletion pgx-tests/src/tests/pg_extern_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ mod tests {

// Ensures `@MODULE_PATHNAME@` and `@FUNCTION_NAME@` are handled.
#[pg_extern(sql = r#"
CREATE OR REPLACE FUNCTION tests."overridden_sql_with_fn_name"() RETURNS void
CREATE FUNCTION tests."overridden_sql_with_fn_name"() RETURNS void
STRICT
LANGUAGE c /* Rust */
AS '@MODULE_PATHNAME@', '@FUNCTION_NAME@';
Expand Down
2 changes: 1 addition & 1 deletion pgx-tests/src/tests/schema_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ mod test_schema {
) -> Result<String, Box<dyn std::error::Error + Send + Sync + 'static>> {
if let SqlGraphEntity::Function(ref func) = entity {
Ok(format!("\
CREATE OR REPLACE FUNCTION test_schema.\"func_generated_with_custom_name\"() RETURNS void\n\
CREATE FUNCTION test_schema.\"func_generated_with_custom_name\"() RETURNS void\n\
LANGUAGE c /* Rust */\n\
AS 'MODULE_PATHNAME', '{unaliased_name}_wrapper';\
",
Expand Down
2 changes: 1 addition & 1 deletion pgx-utils/src/sql_entity_graph/pg_extern/entity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl ToSql for PgExternEntity {
let module_pathname = &context.get_module_pathname();

let fn_sql = format!("\
CREATE OR REPLACE FUNCTION {schema}\"{name}\"({arguments}) {returns}\n\
CREATE FUNCTION {schema}\"{name}\"({arguments}) {returns}\n\
{extern_attrs}\
{search_path}\
LANGUAGE c /* Rust */\n\
Expand Down
4 changes: 2 additions & 2 deletions pgx/src/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ Generates:
```sql
-- src/lib.rs:11
-- aggregate::demo_sum_state
CREATE OR REPLACE FUNCTION "demo_sum_state"(
CREATE FUNCTION "demo_sum_state"(
"this" DemoSum, /* aggregate::DemoSum */
"arg_one" integer /* i32 */
) RETURNS DemoSum /* aggregate::DemoSum */
Expand Down Expand Up @@ -246,7 +246,7 @@ Creates:
```sql
-- src/lib.rs:13
-- aggregate::demo_sum_state
CREATE OR REPLACE FUNCTION "demo_sum_state"(
CREATE FUNCTION "demo_sum_state"(
"this" DemoSumState, /* aggregate::DemoSumState */
"arg_one" integer /* i32 */
) RETURNS DemoSumState /* aggregate::DemoSumState */
Expand Down
4 changes: 2 additions & 2 deletions pgx/src/fcinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::{pg_sys, void_mut_ptr, AllocatedByRust, FromDatum, PgBox, PgMemoryCon
/// This example will create a SQL function like so:
///
/// ```sql
/// CREATE OR REPLACE FUNCTION fun_with_default_arg_value(a integer, b integer DEFAULT 99) RETURNS integer ...;
/// CREATE FUNCTION fun_with_default_arg_value(a integer, b integer DEFAULT 99) RETURNS integer ...;
/// ```
///
/// ```rust
Expand Down Expand Up @@ -61,7 +61,7 @@ pub struct NULL;
/// This example will create a SQL function like so:
///
/// ```sql
/// CREATE OR REPLACE FUNCTION get_a_set() RETURNS TABLE (id integer, title text) ...;
/// CREATE FUNCTION get_a_set() RETURNS TABLE (id integer, title text) ...;
/// ```
///
/// ```rust
Expand Down

0 comments on commit 80e0ac0

Please sign in to comment.