Filter Queries

Found 1096 queries.

Page 51 of 55
  • All the queries about database objects contain a subcondition to exclude from the result information about the system catalog.
  • Although the statements use SQL constructs (common table expressions; NOT in subqueries) that could cause performance problems in case of large datasets, it shouldn't be a problem in case of the relatively small amount of data in the system catalog of a database.

#1001. Trigger functions with a conditional statement

INFORMATION_SCHEMA+system catalog base tables

This query identifies trigger functions that contain conditional statements (IF or CASE) without a preceding SELECT statement. In PostgreSQL, filtering conditions inside a trigger's CREATE TRIGGER ... WHEN (...) clause is significantly more efficient than checking them inside the function body, because PostgreSQL skips invoking the trigger function altogether when the WHEN condition is false—avoiding unnecessary PL/pgSQL execution overhead. However, PostgreSQL prohibits subqueries inside the WHEN clause; therefore, if a branch depends on querying other tables via SELECT, that conditional logic must remain inside the function body. By excluding routines with a prior SELECT, this query surfaces trigger functions whose conditions likely rely only on NEW, OLD, or simple expressions and could potentially be moved into the trigger's WHEN clause.

Problem detection License: MIT (opens in new tab)

#1002. Trigger is used to enforce referential integrity

INFORMATION_SCHEMA+system catalog base tables

Find tables where user-defined (non-system) triggers are used to implement referential integrity. In addition to table name show the triggers and the number of triggers.

Problem detection License: MIT (opens in new tab)

#1003. Trigger routines branching on hardcoded TG_TABLE_NAME or TG_RELNAME values

INFORMATION_SCHEMA+system catalog base tables

This query identifies trigger functions that compare the special trigger variables TG_TABLE_NAME or TG_RELNAME against hardcoded string literals (e.g., IF TG_TABLE_NAME = 'table_a' THEN ...). Branching on hardcoded table names inside a shared trigger function is a design and maintainability anti-pattern for several reasons:


  • Fragility during table renaming: When a table is renamed via ALTER TABLE ... RENAME TO ..., PostgreSQL automatically updates catalog references (such as pg_trigger), so the trigger continues to fire on the renamed table. However, hardcoded string literals inside the PL/pgSQL routine body are not updated, causing conditions like IF TG_TABLE_NAME = 'old_name' to silently evaluate to FALSE and execute the wrong ELSE branch or skip logic entirely.

  • Code duplication or poor cohesion: If multiple tables share the exact same validation logic and only differ in diagnostic metadata (such as constraint names), branching on TG_TABLE_NAME leads to unnecessary copy-pasted RAISE EXCEPTION blocks. Conversely, if the tables require genuinely different business logic, coupling them inside a single conditional trigger function violates the Single Responsibility Principle (SRP).

Problem detection License: MIT (opens in new tab)

#1004. Trigger routines containing an unreachable RETURN statement after RAISE EXCEPTION

INFORMATION_SCHEMA+system catalog base tables

This query identifies trigger routines that contain an unreachable RETURN statement (such as RETURN NULL;) immediately following a RAISE EXCEPTION statement within the same execution block. In PL/pgSQL, RAISE EXCEPTION immediately aborts execution of the routine and rolls back the current transaction or subtransaction. Consequently, any RETURN statement placed directly after RAISE EXCEPTION in the same scope can never be reached. Such dead code adds unnecessary clutter, confuses the distinction between aborting a transaction (RAISE EXCEPTION) and silently skipping a row operation (RETURN NULL), and creates a maintenance hazard if the exception level is later downgraded to RAISE WARNING or RAISE NOTICE (which would cause the dormant RETURN NULL; statement to execute and silently discard data modifications).

Problem detection License: MIT (opens in new tab)

#1005. Trigger routines hardcoding TABLE or SCHEMA in RAISE EXCEPTION instead of using TG_TABLE_NAME and TG_TABLE_SCHEMA

INFORMATION_SCHEMA+system catalog base tables

This query identifies trigger functions that specify the TABLE (TABLE_NAME) or SCHEMA (SCHEMA_NAME) diagnostic option in a RAISE EXCEPTION ... USING clause using hardcoded string literals (e.g., TABLE = 'vastuvott', SCHEMA = 'public') rather than the built-in PL/pgSQL special trigger variables TG_TABLE_NAME and TG_TABLE_SCHEMA. Hardcoding table and schema names inside trigger exception blocks makes the database schema fragile and harder to maintain. If a table is later renamed (ALTER TABLE ... RENAME TO ...), moved to a different schema (ALTER TABLE ... SET SCHEMA ...), or if the trigger function is reused across multiple tables, hardcoded diagnostic literals silently become stale and report inaccurate metadata to client drivers, ORMs, and logs.

Problem detection License: MIT (opens in new tab)

#1006. Trigger routines specifying CONSTRAINT in RAISE EXCEPTION without TABLE and SCHEMA

INFORMATION_SCHEMA+system catalog base tables

This query identifies trigger functions that raise an exception with a CONSTRAINT (or CONSTRAINT_NAME) option in the USING clause, but omit the corresponding TABLE (TABLE_NAME) or SCHEMA (SCHEMA_NAME) diagnostic options.


When a native PostgreSQL table constraint (CHECK, UNIQUE, PRIMARY KEY, or FOREIGN KEY) is violated, the database server automatically populates three distinct diagnostic fields in the error response packet: PG_DIAG_SCHEMA_NAME, PG_DIAG_TABLE_NAME, and PG_DIAG_CONSTRAINT_NAME (accessible in PL/pgSQL via GET STACKED DIAGNOSTICS and exposed by client drivers such as JDBC, Npgsql, and psycopg). However, when a trigger simulates a constraint violation using RAISE EXCEPTION, PostgreSQL does not populate the schema and table diagnostic fields automatically. Specifying CONSTRAINT without TABLE = TG_TABLE_NAME and SCHEMA = TG_TABLE_SCHEMA results in an incomplete error payload, breaking client-side error handlers, ORMs, and logging frameworks that rely on the (schema_name, table_name, constraint_name) tuple to uniquely identify and map the violated rule.

Problem detection License: MIT (opens in new tab)

#1007. Trigger routines with TG_OP variable that are not associated with a suitable trigger

INFORMATION_SCHEMA+system catalog base tables

Automatically defined TG_OP variable in a trigger function has data type text. Its value is a string of INSERT, UPDATE, DELETE, or TRUNCATE telling for which operation the trigger was fired. Find the routines that according to the TG_OP value must react to a certain operation but the routine is not associated with any triggers that are fired by the operation. For instance, the routine specifies reaction to DELETE operation but the routine is not associated with any DELETE trigger.

Problem detection License: MIT (opens in new tab)

#1008. Triggers that are used to calculate tsvector values react to a wrong set of events

system catalog base tables only

Find triggers on base tables that are used to calculate tsvector values that react to a wrong set of events, i.e., react to the DELETE event or do not react to the INSERT and UPDATE events.

Problem detection License: MIT (opens in new tab)

#1009. Triggers where the CONSTRAINT option in RAISE EXCEPTION does not contain the table name or TG_TABLE_NAME

INFORMATION_SCHEMA+system catalog base tables

This query identifies triggers whose underlying function specifies a CONSTRAINT (or CONSTRAINT_NAME) option in a RAISE EXCEPTION ... USING clause, but constructs the constraint identifier without including either the name of the table to which the trigger is attached (trigger_table) or the built-in PL/pgSQL variable TG_TABLE_NAME (or TG_RELNAME). When a trigger simulates a table constraint by setting the PG_DIAG_CONSTRAINT_NAME diagnostic field via USING CONSTRAINT = ..., following a consistent naming convention that incorporates the table name (e.g., CONSTRAINT = TG_TABLE_NAME || '_<rule>' or CONSTRAINT = '<table_name>_<rule>') ensures that the simulated constraint name is globally unique across the schema and immediately traceable to the affected relation. A missing table reference typically indicates one of three issues:


  • The constraint name in the USING clause was misspelled or abbreviated inconsistently (for example, omitting part of a compound table name).

  • The trigger function was copy-pasted from another table without updating the hardcoded CONSTRAINT identifier.

  • A single trigger function is shared across multiple tables and hardcodes table-specific constraint names in conditional branches rather than constructing the constraint name dynamically via TG_TABLE_NAME.

Problem detection License: MIT (opens in new tab)

#1010. Triggers with arguments from the CREATE TRIGGER statement

INFORMATION_SCHEMA+system catalog base tables

Find triggers that get an argument from the CREATE TRIGGER statement.

General License: MIT (opens in new tab)

#1011. Triggers with SELECT (i.e., probably check data based on another table)

INFORMATION_SCHEMA+system catalog base tables

This query identifies trigger functions intended for constraint enforcement that are susceptible to concurrency anomalies due to PostgreSQL's Multi-Version Concurrency Control (MVCC) model. Since read operations (SELECT) do not block write operations, a trigger that validates cross-row constraints without acquiring explicit locks (e.g., LOCK TABLE or SELECT ... FOR UPDATE) involves a race condition. The query detects triggers that query auxiliary data.

General License: MIT (opens in new tab)

#1012. Triggers with the same name in different schemas

INFORMATION_SCHEMA+system catalog base tables

Find trigger names that are used in a database in more than one schema. Different things should have different names. But here different triggers have the same name. Also make sure that this is not a duplication.

General License: MIT (opens in new tab)

#1013. Triggers with the same name within the same schema

INFORMATION_SCHEMA+system catalog base tables

Find names of triggers that are used within the same schema more than once. Give different triggers different names.

Problem detection License: MIT (opens in new tab)

#1014. Trying to lock a value instead of a row

INFORMATION_SCHEMA+system catalog base tables

This query identifies SQL routines that utilize explicit row locking clauses (e.g., FOR UPDATE, FOR SHARE) in queries that do not target a specific base table or relation. For instance, a statement like SELECT 'text' AS v FOR UPDATE attempts to apply a lock to a scalar constant. Since row-level locks in PostgreSQL require a physical row version (tuple) within a table to be effective, such statements are semantically void. They indicate a fundamental misunderstanding of the concurrency control mechanism and should be corrected to target actual table rows.

Problem detection License: MIT (opens in new tab)

#1015. Tsvector values are not automatically calculated

INFORMATION_SCHEMA+system catalog base tables

Find base table columns with tsvector type in case of which it is not a generated column nor does the table has an associated trigger to calculate the tsvector value automatically.

Problem detection License: MIT (opens in new tab)

#1016. Unbalanced brackets

INFORMATION_SCHEMA+system catalog base tables

Write expressions correctly. Find code fragments that have unbalanced brackets, i.e., the number of opening brackets is not the same as the number of closing brackets.

Problem detection License: MIT (opens in new tab)

#1017. Unbounded textual columns for non-descriptive attributes

INFORMATION_SCHEMA+system catalog base tables

This query identifies base table columns defined as unbounded TEXT or VARCHAR (without a length specifier) that lack any corresponding CHECK constraint to restrict value length. It explicitly excludes foreign key columns and columns heuristically identified as descriptive fields (e.g., names containing "comment", "description", "note"), where arbitrary length is typically acceptable. For structured attributes (such as names, codes, or identifiers), relying on unbounded types without constraints is a design risk, potentially allowing excessive data payload, complicating index usage, and violating domain constraints.

Problem detection License: MIT (opens in new tab)

#1018. Unconditional exceptions in row-level BEFORE triggers

INFORMATION_SCHEMA+system catalog base tables

This query identifies row-level BEFORE triggers that invoke a RAISE WARNING or RAISE EXCEPTION statement without any conditional logic—neither in the trigger's WHEN clause nor within the function body. This means that the trigger unconditionally raises the message for every affected row. This anti-pattern either entirely blocks the triggering DML operation (in the case of an error) or floods the database logs (in the case of a warning), which typically indicates left-over debugging code or an incomplete implementation.

Problem detection License: MIT (opens in new tab)

#1019. Unique constraints made redundant by an exclude constraint

INFORMATION_SCHEMA+system catalog base tables

This query identifies superfluous UNIQUE constraints where the constraint is logically subsumed by a more general EXCLUDE constraint on the same table. It targets cases where the set of columns in a UNIQUE or PRIMARY KEY constraint is a subset of (or equal to) the columns in an EXCLUDE constraint, provided the EXCLUDE constraint uses the equality operator (=) for those same columns. In this scenario, the EXCLUDE constraint already enforces uniqueness as part of its more complex logic, rendering the separate UNIQUE constraint redundant. Eliminating this duplication improves schema clarity and removes an unnecessary constraint check.

Problem detection License: MIT (opens in new tab)

#1020. Unique index definition instead of a key declaration

INFORMATION_SCHEMA+system catalog base tables

This query identifies semantic abstraction violations where data uniqueness is enforced via low-level CREATE UNIQUE INDEX statements instead of declarative PRIMARY KEY, UNIQUE, or EXCLUDE constraints. It specifically targets "plain" unique indexes (excluding partial or expression-based indexes) that are functionally identical to standard constraints. According to the ANSI-SPARC architecture, indexes belong to the internal (physical) schema, while constraints belong to the conceptual schema. Therefore, defining business rules using high-level constraint syntax is preferred for semantic clarity and architectural correctness.

Problem detection License: MIT (opens in new tab)
# Name(sorted ascending, activate to sort descending) Goal(activate to sort ascending) Type(activate to sort ascending) Data source(activate to sort ascending) Last update(activate to sort ascending) License Actions
1001 Trigger functions with a conditional statement This query identifies trigger functions that contain conditional statements (IF or CASE) without a preceding SELECT statement. In PostgreSQL, filtering conditions inside a trigger's CREATE TRIGGER ... WHEN (...) clause is significantly more efficient than checking them inside the function body, because PostgreSQL skips invoking the trigger function altogether when the WHEN condition is false—avoiding unnecessary PL/pgSQL execution overhead. However, PostgreSQL prohibits subqueries inside the WHEN clause; therefore, if a branch depends on querying other tables via SELECT, that conditional logic must remain inside the function body. By excluding routines with a prior SELECT, this query surfaces trigger functions whose conditions likely rely only on NEW, OLD, or simple expressions and could potentially be moved into the trigger's WHEN clause. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1002 Trigger is used to enforce referential integrity Find tables where user-defined (non-system) triggers are used to implement referential integrity. In addition to table name show the triggers and the number of triggers. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1003 Trigger routines branching on hardcoded TG_TABLE_NAME or TG_RELNAME values This query identifies trigger functions that compare the special trigger variables TG_TABLE_NAME or TG_RELNAME against hardcoded string literals (e.g., IF TG_TABLE_NAME = 'table_a' THEN ...). Branching on hardcoded table names inside a shared trigger function is a design and maintainability anti-pattern for several reasons:

  • Fragility during table renaming: When a table is renamed via ALTER TABLE ... RENAME TO ..., PostgreSQL automatically updates catalog references (such as pg_trigger), so the trigger continues to fire on the renamed table. However, hardcoded string literals inside the PL/pgSQL routine body are not updated, causing conditions like IF TG_TABLE_NAME = 'old_name' to silently evaluate to FALSE and execute the wrong ELSE branch or skip logic entirely.

  • Code duplication or poor cohesion: If multiple tables share the exact same validation logic and only differ in diagnostic metadata (such as constraint names), branching on TG_TABLE_NAME leads to unnecessary copy-pasted RAISE EXCEPTION blocks. Conversely, if the tables require genuinely different business logic, coupling them inside a single conditional trigger function violates the Single Responsibility Principle (SRP).

Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1004 Trigger routines containing an unreachable RETURN statement after RAISE EXCEPTION This query identifies trigger routines that contain an unreachable RETURN statement (such as RETURN NULL;) immediately following a RAISE EXCEPTION statement within the same execution block. In PL/pgSQL, RAISE EXCEPTION immediately aborts execution of the routine and rolls back the current transaction or subtransaction. Consequently, any RETURN statement placed directly after RAISE EXCEPTION in the same scope can never be reached. Such dead code adds unnecessary clutter, confuses the distinction between aborting a transaction (RAISE EXCEPTION) and silently skipping a row operation (RETURN NULL), and creates a maintenance hazard if the exception level is later downgraded to RAISE WARNING or RAISE NOTICE (which would cause the dormant RETURN NULL; statement to execute and silently discard data modifications). Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1005 Trigger routines hardcoding TABLE or SCHEMA in RAISE EXCEPTION instead of using TG_TABLE_NAME and TG_TABLE_SCHEMA This query identifies trigger functions that specify the TABLE (TABLE_NAME) or SCHEMA (SCHEMA_NAME) diagnostic option in a RAISE EXCEPTION ... USING clause using hardcoded string literals (e.g., TABLE = 'vastuvott', SCHEMA = 'public') rather than the built-in PL/pgSQL special trigger variables TG_TABLE_NAME and TG_TABLE_SCHEMA. Hardcoding table and schema names inside trigger exception blocks makes the database schema fragile and harder to maintain. If a table is later renamed (ALTER TABLE ... RENAME TO ...), moved to a different schema (ALTER TABLE ... SET SCHEMA ...), or if the trigger function is reused across multiple tables, hardcoded diagnostic literals silently become stale and report inaccurate metadata to client drivers, ORMs, and logs. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1006 Trigger routines specifying CONSTRAINT in RAISE EXCEPTION without TABLE and SCHEMA This query identifies trigger functions that raise an exception with a CONSTRAINT (or CONSTRAINT_NAME) option in the USING clause, but omit the corresponding TABLE (TABLE_NAME) or SCHEMA (SCHEMA_NAME) diagnostic options.


When a native PostgreSQL table constraint (CHECK, UNIQUE, PRIMARY KEY, or FOREIGN KEY) is violated, the database server automatically populates three distinct diagnostic fields in the error response packet: PG_DIAG_SCHEMA_NAME, PG_DIAG_TABLE_NAME, and PG_DIAG_CONSTRAINT_NAME (accessible in PL/pgSQL via GET STACKED DIAGNOSTICS and exposed by client drivers such as JDBC, Npgsql, and psycopg). However, when a trigger simulates a constraint violation using RAISE EXCEPTION, PostgreSQL does not populate the schema and table diagnostic fields automatically. Specifying CONSTRAINT without TABLE = TG_TABLE_NAME and SCHEMA = TG_TABLE_SCHEMA results in an incomplete error payload, breaking client-side error handlers, ORMs, and logging frameworks that rely on the (schema_name, table_name, constraint_name) tuple to uniquely identify and map the violated rule.

Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1007 Trigger routines with TG_OP variable that are not associated with a suitable trigger Automatically defined TG_OP variable in a trigger function has data type text. Its value is a string of INSERT, UPDATE, DELETE, or TRUNCATE telling for which operation the trigger was fired. Find the routines that according to the TG_OP value must react to a certain operation but the routine is not associated with any triggers that are fired by the operation. For instance, the routine specifies reaction to DELETE operation but the routine is not associated with any DELETE trigger. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1008 Triggers that are used to calculate tsvector values react to a wrong set of events Find triggers on base tables that are used to calculate tsvector values that react to a wrong set of events, i.e., react to the DELETE event or do not react to the INSERT and UPDATE events. Problem detection system catalog base tables only MIT (opens in new tab) View
1009 Triggers where the CONSTRAINT option in RAISE EXCEPTION does not contain the table name or TG_TABLE_NAME This query identifies triggers whose underlying function specifies a CONSTRAINT (or CONSTRAINT_NAME) option in a RAISE EXCEPTION ... USING clause, but constructs the constraint identifier without including either the name of the table to which the trigger is attached (trigger_table) or the built-in PL/pgSQL variable TG_TABLE_NAME (or TG_RELNAME). When a trigger simulates a table constraint by setting the PG_DIAG_CONSTRAINT_NAME diagnostic field via USING CONSTRAINT = ..., following a consistent naming convention that incorporates the table name (e.g., CONSTRAINT = TG_TABLE_NAME || '_<rule>' or CONSTRAINT = '<table_name>_<rule>') ensures that the simulated constraint name is globally unique across the schema and immediately traceable to the affected relation. A missing table reference typically indicates one of three issues:

  • The constraint name in the USING clause was misspelled or abbreviated inconsistently (for example, omitting part of a compound table name).

  • The trigger function was copy-pasted from another table without updating the hardcoded CONSTRAINT identifier.

  • A single trigger function is shared across multiple tables and hardcodes table-specific constraint names in conditional branches rather than constructing the constraint name dynamically via TG_TABLE_NAME.

Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1010 Triggers with arguments from the CREATE TRIGGER statement Find triggers that get an argument from the CREATE TRIGGER statement. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1011 Triggers with SELECT (i.e., probably check data based on another table) This query identifies trigger functions intended for constraint enforcement that are susceptible to concurrency anomalies due to PostgreSQL's Multi-Version Concurrency Control (MVCC) model. Since read operations (SELECT) do not block write operations, a trigger that validates cross-row constraints without acquiring explicit locks (e.g., LOCK TABLE or SELECT ... FOR UPDATE) involves a race condition. The query detects triggers that query auxiliary data. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1012 Triggers with the same name in different schemas Find trigger names that are used in a database in more than one schema. Different things should have different names. But here different triggers have the same name. Also make sure that this is not a duplication. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1013 Triggers with the same name within the same schema Find names of triggers that are used within the same schema more than once. Give different triggers different names. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1014 Trying to lock a value instead of a row This query identifies SQL routines that utilize explicit row locking clauses (e.g., FOR UPDATE, FOR SHARE) in queries that do not target a specific base table or relation. For instance, a statement like SELECT 'text' AS v FOR UPDATE attempts to apply a lock to a scalar constant. Since row-level locks in PostgreSQL require a physical row version (tuple) within a table to be effective, such statements are semantically void. They indicate a fundamental misunderstanding of the concurrency control mechanism and should be corrected to target actual table rows. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1015 Tsvector values are not automatically calculated Find base table columns with tsvector type in case of which it is not a generated column nor does the table has an associated trigger to calculate the tsvector value automatically. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1016 Unbalanced brackets Write expressions correctly. Find code fragments that have unbalanced brackets, i.e., the number of opening brackets is not the same as the number of closing brackets. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1017 Unbounded textual columns for non-descriptive attributes This query identifies base table columns defined as unbounded TEXT or VARCHAR (without a length specifier) that lack any corresponding CHECK constraint to restrict value length. It explicitly excludes foreign key columns and columns heuristically identified as descriptive fields (e.g., names containing "comment", "description", "note"), where arbitrary length is typically acceptable. For structured attributes (such as names, codes, or identifiers), relying on unbounded types without constraints is a design risk, potentially allowing excessive data payload, complicating index usage, and violating domain constraints. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1018 Unconditional exceptions in row-level BEFORE triggers This query identifies row-level BEFORE triggers that invoke a RAISE WARNING or RAISE EXCEPTION statement without any conditional logic—neither in the trigger's WHEN clause nor within the function body. This means that the trigger unconditionally raises the message for every affected row. This anti-pattern either entirely blocks the triggering DML operation (in the case of an error) or floods the database logs (in the case of a warning), which typically indicates left-over debugging code or an incomplete implementation. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1019 Unique constraints made redundant by an exclude constraint This query identifies superfluous UNIQUE constraints where the constraint is logically subsumed by a more general EXCLUDE constraint on the same table. It targets cases where the set of columns in a UNIQUE or PRIMARY KEY constraint is a subset of (or equal to) the columns in an EXCLUDE constraint, provided the EXCLUDE constraint uses the equality operator (=) for those same columns. In this scenario, the EXCLUDE constraint already enforces uniqueness as part of its more complex logic, rendering the separate UNIQUE constraint redundant. Eliminating this duplication improves schema clarity and removes an unnecessary constraint check. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1020 Unique index definition instead of a key declaration This query identifies semantic abstraction violations where data uniqueness is enforced via low-level CREATE UNIQUE INDEX statements instead of declarative PRIMARY KEY, UNIQUE, or EXCLUDE constraints. It specifically targets "plain" unique indexes (excluding partial or expression-based indexes) that are functionally identical to standard constraints. According to the ANSI-SPARC architecture, indexes belong to the internal (physical) schema, while constraints belong to the conceptual schema. Therefore, defining business rules using high-level constraint syntax is preferred for semantic clarity and architectural correctness. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View