Skip to content

Commit

Permalink
Remove Postgres NOTICE spew generated by DROP FUNCTION IF EXISTS (#…
Browse files Browse the repository at this point in the history
…7911)

Use an explicit conditional when using `DropFunction` in various places
of bootstrap and for reflection cache functions.  This makes it actually
possible to NOTICE postgres messages in bootstrap (pun intended).
Equipped
with this new visibility fix the name of the indexes we place on
properties.
  • Loading branch information
elprans authored Oct 23, 2024
1 parent 275d0e4 commit 1074087
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions edb/pgsql/delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -5373,10 +5373,10 @@ def _create_table(

id = sn.QualName(
module=prop.get_name(schema).module, name=str(prop.id))
index_name = common.convert_name(id, 'idx0', catenate=True)
index_name = common.convert_name(id, 'idx0', catenate=False)

pg_index = dbops.Index(
name=index_name, table_name=new_table_name,
name=index_name[1], table_name=new_table_name,
unique=False, columns=[src_col],
metadata={'code': DEFAULT_INDEX_CODE},
)
Expand Down
8 changes: 7 additions & 1 deletion edb/pgsql/deltadbops.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,13 @@ def create_constr_trigger_function(
return [dbops.CreateFunction(func, or_replace=True)]

def drop_constr_trigger_function(self, proc_name: Tuple[str, ...]):
return [dbops.DropFunction(name=proc_name, args=(), if_exists=True)]
return [dbops.DropFunction(
name=proc_name,
args=(),
# Use a condition instead of if_exists ot reduce annoying
# debug spew from postgres.
conditions=[dbops.FunctionExists(name=proc_name, args=())],
)]

def create_constraint(self, constraint: SchemaConstraintTableConstraint):
# Add the constraint normally to our table
Expand Down
9 changes: 8 additions & 1 deletion edb/server/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,14 @@ def compile_schema_storage_in_delta(
# We drop first instead of using or_replace, in case
# something about the arguments changed.
df = pg_dbops.DropFunction(
name=func.name, args=func.args or (), if_exists=True
name=func.name,
args=func.args or (),
# Use a condition instead of if_exists ot reduce annoying
# debug spew from postgres.
conditions=[pg_dbops.FunctionExists(
name=func.name,
args=func.args or (),
)],
)
df.generate(funcblock)

Expand Down

0 comments on commit 1074087

Please sign in to comment.