Filter Queries

Found 1089 queries.

Page 49 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.

#961. Simplify regex by combining alpha and digit classes

INFORMATION_SCHEMA+system catalog base tables

This query identifies regular expressions that can be simplified by consolidating separate character class references. It specifically targets patterns that explicitly match both alphabetic characters ([:alpha:]) and numeric digits ([:digit:], \d, or [0-9]) as separate components within a larger character set (e.g., [[:alpha:][:digit:]]). These distinct classes can be refactored into the single, more concise POSIX character class [:alnum:], which logically represents the union of both. Performing this simplification improves the readability and compactness of the regular expression without altering its behavior.

Problem detection License: MIT (opens in new tab)

#962. Redundant leading or trailing wildcards in regular expressions

INFORMATION_SCHEMA+system catalog base tables

This query identifies regular expressions that contain superfluous .* constructs at the beginning or end of the pattern. In standard unanchored regular expression matching (as performed by PostgreSQL's ~ operator), the engine checks for the pattern's existence anywhere within the string by default. Therefore, a leading or trailing .* is typically redundant, as it explicitly instructs the engine to do what it would already be doing implicitly. Removing these unnecessary wildcards improves the readability and maintainability of the expression and can, in some cases, lead to better performance by reducing unnecessary backtracking.

Problem detection License: MIT (opens in new tab)

#963. Object identifiers using reserved or partially reserved SQL keywords (aggregate view)

INFORMATION_SCHEMA+system catalog base tables

This query identifies reserved or partially reserved SQL keywords in PostgreSQL (categories R, T, and C) that are used as object identifiers, presenting an aggregated summary of their occurrence counts. As Robert C. Martin notes in Clean Code: "Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." In PostgreSQL, "there are several different classes of tokens ranging from those that can never be used as an identifier to those that have absolutely no special status in the parser as compared to an ordinary identifier" (PostgreSQL Documentation). Although PostgreSQL permits these non-unreserved keywords to be used as identifiers—either by enclosing them in double quotes or, for partially reserved categories, using them unquoted only for certain types of database objects—doing so creates several issues:

  • Quoting and syntax friction: Reserved keywords often require double-quoting (e.g., "user" or "order"), making identifiers case-sensitive, tedious to write, and prone to syntax errors in raw SQL queries and ORMs.

  • Portability risks: Even when PostgreSQL allows a partially reserved keyword unquoted in a specific context (such as a column or function name), it may be strictly reserved across all contexts in other RDBMS platforms, significantly complicating future database migrations.

  • Vague semantics: SQL keywords are typically overly generic and fail to convey clear, specific domain information about the named object.

Problem detection License: MIT (opens in new tab)

#964. Row-level triggers with RETURN NULL cancellation logic

INFORMATION_SCHEMA+system catalog base tables

This query identifies row-level BEFORE and INSTEAD OF triggers that explicitly RETURN NULL. In PostgreSQL's trigger execution model, this return value acts as a cancellation signal. For BEFORE triggers on tables, it aborts the operation for the current row, preventing the INSERT, UPDATE, or DELETE and suppressing subsequent triggers. For INSTEAD OF triggers on views, it signals that no modification was performed. While this behavior can be used for conditional logic (e.g., silently ignoring invalid rows), it presents a risk of unintended data loss or logic errors if used incorrectly. These triggers should be audited to ensure the cancellation behavior is intentional and correctly implemented.

General License: MIT (opens in new tab)

#965. Perhaps a reference to the variable NEW is missing

INFORMATION_SCHEMA+system catalog base tables

This query identifies row-level BEFORE INSERT and BEFORE UPDATE triggers whose primary purpose is not to raise an exception, but which never reference the NEW record outside of the RETURN clause. In PostgreSQL, BEFORE triggers are specifically intended either to validate incoming data (raising exceptions upon failure) or to manipulate column values by modifying NEW. If a trigger does neither, it typically indicates that its logic (such as logging or updating related tables) should be relocated to an AFTER trigger, or that the trigger contains obsolete, redundant code.

Problem detection License: MIT (opens in new tab)

#966. Row-level BEFORE triggers on base tables with RETURN NULL cancellation logic

INFORMATION_SCHEMA+system catalog base tables

This query identifies row-level BEFORE triggers on base tables that execute a RETURN NULL statement without raising a corresponding exception. In PostgreSQL, returning NULL from a BEFORE trigger silently aborts the pending INSERT, UPDATE, or DELETE operation for the current row. Unlike an exception, which alerts the calling application to the failure, a silent cancellation allows the transaction to proceed as if successful, but with the data modification discarded. This behavior is often unintentional (e.g., a forgotten RETURN NEW) and poses a significant risk of data loss and difficult-to-debug application logic errors.

Problem detection License: MIT (opens in new tab)

#967. 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)

#968. Validation triggers reading reference tables without FOR SHARE locking

INFORMATION_SCHEMA+system catalog base tables

This query identifies row-level BEFORE triggers that validate data by querying other tables (SELECT ... FROM ... WHERE) before raising an exception, but fail to acquire a shared lock (FOR SHARE) on the referenced rows. Under PostgreSQL's default READ COMMITTED isolation level, reading a reference or classifier row (such as checking whether a status, category, or type is active) without FOR SHARE allows concurrent transactions to deactivate or modify that reference row before the triggering transaction commits, leading to write skew and data integrity violations.

Problem detection License: MIT (opens in new tab)

#969. Modification-time BEFORE UPDATE triggers lacking a WHEN (OLD.* IS DISTINCT FROM NEW.*) condition

INFORMATION_SCHEMA+system catalog base tables

This query identifies row-level BEFORE UPDATE triggers that update a row's modification timestamp column (e.g., NEW.viimase_muutm_aeg := CURRENT_TIMESTAMP(0);), but lack a WHEN (OLD.* IS DISTINCT FROM NEW.*) condition to verify that the row data actually changed. Without this condition, executing a no-op UPDATE statement (where the new column values are identical to the existing values) still fires the trigger and overwrites the modification timestamp. This corrupts audit accuracy by recording a false modification time and forces PostgreSQL to perform unnecessary physical tuple writes, WAL logging, and index maintenance for a row whose business data did not change.

Problem detection License: MIT (opens in new tab)

#970. Row level triggers that update or delete data

INFORMATION_SCHEMA+system catalog base tables

This query identifies row-level triggers that contain UPDATE or DELETE statements within their execution body. Embedding data modification logic directly within row-level triggers introduces implicit side effects that can complicate transaction management and debugging. Furthermore, this pattern significantly increases the risk of causing cascading trigger chains or infinite recursion loops, potentially degrading system performance and stability. Such logic should be carefully audited to ensure it is strictly necessary and correctly implemented.

Problem detection License: MIT (opens in new tab)

#971. Gratuitous context in the names of schema objects

system catalog base tables only

This query identifies schema objects with names that are redundantly prefixed with their own schema's name. It flags any object whose name begins with the schema name plus at least one other character. This enforces the design principle that a schema is a sufficient namespace, and therefore, objects within it do not require the additional, repetitive context in their own names.

Problem detection License: MIT (opens in new tab)

#972. Explicit search_path in SQL-standard SECURITY DEFINER routines

INFORMATION_SCHEMA+system catalog base tables

This query identifies SECURITY DEFINER routines defined with a SQL-standard body (introduced in PostgreSQL 14) that explicitly specify a search_path. While setting the search_path is critical for securing older routine types, it is technically redundant for SQL-standard bodies because they securely resolve objects at parse time. Nevertheless, developers might intentionally configure the path to maintain code consistency and improve readability across the database schema.

General License: MIT (opens in new tab)

#973. SECURITY DEFINER routines vulnerable to pg_temp hijacking

INFORMATION_SCHEMA+system catalog base tables

This query identifies SECURITY DEFINER routines that are vulnerable to Trojan-horse attacks via the pg_temp schema. It flags routines that either do not explicitly set the search_path, or set it incorrectly (e.g., using improper quoting). To secure these privileged routines, pg_temp must be appended as the last entry in the search_path. Omitting the search_path is only safe if every database object within the routine is explicitly schema-qualified. The query correctly excludes routines defined with a SQL-standard body (introduced in PostgreSQL 14), as they resolve objects at parse time and do not require explicit search_path configurations.

Problem detection License: MIT (opens in new tab)

#974. 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)

#975. CHECK constraints on TIMESTAMP and DATE columns that explicitly specify a time zone

INFORMATION_SCHEMA only

This query identifies semantic anomalies in CHECK constraints applied to columns defined as DATE or TIMESTAMP (without time zone). It flags constraints that incorporate time zone conversion logic (e.g., using AT TIME ZONE). Since these data types store "naive" values devoid of time zone offsets, attempting to apply time zone logic makes the constraint's outcome dependent on the current session or server configuration. This non-deterministic behavior is a design flaw, as data validity should be intrinsic and immutable, not dependent on the environment.

Problem detection License: MIT (opens in new tab)

#976. Base table columns with the same name have different types

INFORMATION_SCHEMA only

This query identifies semantic inconsistencies across the database schema by finding base table columns that share the same identifier (name) but are defined with differing data types. According to standard data modeling principles, a shared attribute name implies a shared domain concept (e.g., status_code should consistently be an SMALLINT or a CHAR). Discrepancies in data types for homonymous columns (e.g., is_active being BOOLEAN in one table and SMALLINT in another) hinder interoperability, complicate join logic, and confuse developers.

Problem detection License: MIT (opens in new tab)

#977. Textual code columns lacking specific pattern validation

INFORMATION_SCHEMA+system catalog base tables

This query identifies semantic validation gaps in textual columns intended to store structured codes. It targets non-foreign key columns whose identifiers imply a specific format (e.g., containing the word "code"), but which lack adequate constraints to enforce that format. Specifically, it flags columns that have either no CHECK constraints at all, or only trivial constraints that prohibit empty/whitespace strings. Since "codes" typically adhere to a strict pattern (e.g., fixed length, specific character set), relying solely on a non-empty check is considered insufficient for data integrity.

Problem detection License: MIT (opens in new tab)

#978. Do not leave out the referential constraints (based on classifiers)

INFORMATION_SCHEMA+system catalog base tables

This query identifies short text columns in base tables that are not part of any primary or foreign key, but whose names closely match an existing table in the database. This pattern suggests that the similarly named table might be a classifier (reference) table, and the flagged column should ideally have a foreign key constraint referencing it.

Problem detection License: MIT (opens in new tab)

#979. Unnecessary NULL checks in single-column constraints

INFORMATION_SCHEMA+system catalog base tables

This query identifies single-column CHECK constraints (applied either directly to a base table or through a domain) that explicitly check for NULL values. Constraint definitions should be kept as simple as possible. Because a NULL value causes a logical condition to evaluate to UNKNOWN, and CHECK constraints inherently allow rows that evaluate to either TRUE or UNKNOWN, there is no need to explicitly allow missing values. For instance, instead of writing CHECK (price > 0 OR price IS NULL), the constraint should simply be written as CHECK (price > 0).

Problem detection License: MIT (opens in new tab)

#980. Data type mismatch in check constraints

system catalog base tables only

This query identifies single-column CHECK constraints where the validation logic utilizes operators or functions that are incompatible with the column's native data type. It detects cases where the database must perform implicit casting to evaluate the expression (e.g., performing arithmetic on a TEXT column or string manipulation on a DATE column). Relying on implicit coercion in constraints involves unnecessary computational overhead and frequently indicates a fundamental error in data modeling or constraint formulation.

Problem detection License: MIT (opens in new tab)
# Name(activate to sort ascending) Goal(sorted ascending, activate to sort descending) Type(activate to sort ascending) Data source(activate to sort ascending) Last update(activate to sort ascending) License Actions
961 Simplify regex by combining alpha and digit classes This query identifies regular expressions that can be simplified by consolidating separate character class references. It specifically targets patterns that explicitly match both alphabetic characters ([:alpha:]) and numeric digits ([:digit:], \d, or [0-9]) as separate components within a larger character set (e.g., [[:alpha:][:digit:]]). These distinct classes can be refactored into the single, more concise POSIX character class [:alnum:], which logically represents the union of both. Performing this simplification improves the readability and compactness of the regular expression without altering its behavior. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
962 Redundant leading or trailing wildcards in regular expressions This query identifies regular expressions that contain superfluous .* constructs at the beginning or end of the pattern. In standard unanchored regular expression matching (as performed by PostgreSQL's ~ operator), the engine checks for the pattern's existence anywhere within the string by default. Therefore, a leading or trailing .* is typically redundant, as it explicitly instructs the engine to do what it would already be doing implicitly. Removing these unnecessary wildcards improves the readability and maintainability of the expression and can, in some cases, lead to better performance by reducing unnecessary backtracking. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
963 Object identifiers using reserved or partially reserved SQL keywords (aggregate view) This query identifies reserved or partially reserved SQL keywords in PostgreSQL (categories R, T, and C) that are used as object identifiers, presenting an aggregated summary of their occurrence counts. As Robert C. Martin notes in Clean Code: "Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." In PostgreSQL, "there are several different classes of tokens ranging from those that can never be used as an identifier to those that have absolutely no special status in the parser as compared to an ordinary identifier" (PostgreSQL Documentation). Although PostgreSQL permits these non-unreserved keywords to be used as identifiers—either by enclosing them in double quotes or, for partially reserved categories, using them unquoted only for certain types of database objects—doing so creates several issues:
  • Quoting and syntax friction: Reserved keywords often require double-quoting (e.g., "user" or "order"), making identifiers case-sensitive, tedious to write, and prone to syntax errors in raw SQL queries and ORMs.

  • Portability risks: Even when PostgreSQL allows a partially reserved keyword unquoted in a specific context (such as a column or function name), it may be strictly reserved across all contexts in other RDBMS platforms, significantly complicating future database migrations.

  • Vague semantics: SQL keywords are typically overly generic and fail to convey clear, specific domain information about the named object.

Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
964 Row-level triggers with RETURN NULL cancellation logic This query identifies row-level BEFORE and INSTEAD OF triggers that explicitly RETURN NULL. In PostgreSQL's trigger execution model, this return value acts as a cancellation signal. For BEFORE triggers on tables, it aborts the operation for the current row, preventing the INSERT, UPDATE, or DELETE and suppressing subsequent triggers. For INSTEAD OF triggers on views, it signals that no modification was performed. While this behavior can be used for conditional logic (e.g., silently ignoring invalid rows), it presents a risk of unintended data loss or logic errors if used incorrectly. These triggers should be audited to ensure the cancellation behavior is intentional and correctly implemented. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
965 Perhaps a reference to the variable NEW is missing This query identifies row-level BEFORE INSERT and BEFORE UPDATE triggers whose primary purpose is not to raise an exception, but which never reference the NEW record outside of the RETURN clause. In PostgreSQL, BEFORE triggers are specifically intended either to validate incoming data (raising exceptions upon failure) or to manipulate column values by modifying NEW. If a trigger does neither, it typically indicates that its logic (such as logging or updating related tables) should be relocated to an AFTER trigger, or that the trigger contains obsolete, redundant code. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
966 Row-level BEFORE triggers on base tables with RETURN NULL cancellation logic This query identifies row-level BEFORE triggers on base tables that execute a RETURN NULL statement without raising a corresponding exception. In PostgreSQL, returning NULL from a BEFORE trigger silently aborts the pending INSERT, UPDATE, or DELETE operation for the current row. Unlike an exception, which alerts the calling application to the failure, a silent cancellation allows the transaction to proceed as if successful, but with the data modification discarded. This behavior is often unintentional (e.g., a forgotten RETURN NEW) and poses a significant risk of data loss and difficult-to-debug application logic errors. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
967 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
968 Validation triggers reading reference tables without FOR SHARE locking This query identifies row-level BEFORE triggers that validate data by querying other tables (SELECT ... FROM ... WHERE) before raising an exception, but fail to acquire a shared lock (FOR SHARE) on the referenced rows. Under PostgreSQL's default READ COMMITTED isolation level, reading a reference or classifier row (such as checking whether a status, category, or type is active) without FOR SHARE allows concurrent transactions to deactivate or modify that reference row before the triggering transaction commits, leading to write skew and data integrity violations. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
969 Modification-time BEFORE UPDATE triggers lacking a WHEN (OLD.* IS DISTINCT FROM NEW.*) condition This query identifies row-level BEFORE UPDATE triggers that update a row's modification timestamp column (e.g., NEW.viimase_muutm_aeg := CURRENT_TIMESTAMP(0);), but lack a WHEN (OLD.* IS DISTINCT FROM NEW.*) condition to verify that the row data actually changed. Without this condition, executing a no-op UPDATE statement (where the new column values are identical to the existing values) still fires the trigger and overwrites the modification timestamp. This corrupts audit accuracy by recording a false modification time and forces PostgreSQL to perform unnecessary physical tuple writes, WAL logging, and index maintenance for a row whose business data did not change. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
970 Row level triggers that update or delete data This query identifies row-level triggers that contain UPDATE or DELETE statements within their execution body. Embedding data modification logic directly within row-level triggers introduces implicit side effects that can complicate transaction management and debugging. Furthermore, this pattern significantly increases the risk of causing cascading trigger chains or infinite recursion loops, potentially degrading system performance and stability. Such logic should be carefully audited to ensure it is strictly necessary and correctly implemented. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
971 Gratuitous context in the names of schema objects This query identifies schema objects with names that are redundantly prefixed with their own schema's name. It flags any object whose name begins with the schema name plus at least one other character. This enforces the design principle that a schema is a sufficient namespace, and therefore, objects within it do not require the additional, repetitive context in their own names. Problem detection system catalog base tables only MIT (opens in new tab) View
972 Explicit search_path in SQL-standard SECURITY DEFINER routines This query identifies SECURITY DEFINER routines defined with a SQL-standard body (introduced in PostgreSQL 14) that explicitly specify a search_path. While setting the search_path is critical for securing older routine types, it is technically redundant for SQL-standard bodies because they securely resolve objects at parse time. Nevertheless, developers might intentionally configure the path to maintain code consistency and improve readability across the database schema. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
973 SECURITY DEFINER routines vulnerable to pg_temp hijacking This query identifies SECURITY DEFINER routines that are vulnerable to Trojan-horse attacks via the pg_temp schema. It flags routines that either do not explicitly set the search_path, or set it incorrectly (e.g., using improper quoting). To secure these privileged routines, pg_temp must be appended as the last entry in the search_path. Omitting the search_path is only safe if every database object within the routine is explicitly schema-qualified. The query correctly excludes routines defined with a SQL-standard body (introduced in PostgreSQL 14), as they resolve objects at parse time and do not require explicit search_path configurations. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
974 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
975 CHECK constraints on TIMESTAMP and DATE columns that explicitly specify a time zone This query identifies semantic anomalies in CHECK constraints applied to columns defined as DATE or TIMESTAMP (without time zone). It flags constraints that incorporate time zone conversion logic (e.g., using AT TIME ZONE). Since these data types store "naive" values devoid of time zone offsets, attempting to apply time zone logic makes the constraint's outcome dependent on the current session or server configuration. This non-deterministic behavior is a design flaw, as data validity should be intrinsic and immutable, not dependent on the environment. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
976 Base table columns with the same name have different types This query identifies semantic inconsistencies across the database schema by finding base table columns that share the same identifier (name) but are defined with differing data types. According to standard data modeling principles, a shared attribute name implies a shared domain concept (e.g., status_code should consistently be an SMALLINT or a CHAR). Discrepancies in data types for homonymous columns (e.g., is_active being BOOLEAN in one table and SMALLINT in another) hinder interoperability, complicate join logic, and confuse developers. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
977 Textual code columns lacking specific pattern validation This query identifies semantic validation gaps in textual columns intended to store structured codes. It targets non-foreign key columns whose identifiers imply a specific format (e.g., containing the word "code"), but which lack adequate constraints to enforce that format. Specifically, it flags columns that have either no CHECK constraints at all, or only trivial constraints that prohibit empty/whitespace strings. Since "codes" typically adhere to a strict pattern (e.g., fixed length, specific character set), relying solely on a non-empty check is considered insufficient for data integrity. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
978 Do not leave out the referential constraints (based on classifiers) This query identifies short text columns in base tables that are not part of any primary or foreign key, but whose names closely match an existing table in the database. This pattern suggests that the similarly named table might be a classifier (reference) table, and the flagged column should ideally have a foreign key constraint referencing it. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
979 Unnecessary NULL checks in single-column constraints This query identifies single-column CHECK constraints (applied either directly to a base table or through a domain) that explicitly check for NULL values. Constraint definitions should be kept as simple as possible. Because a NULL value causes a logical condition to evaluate to UNKNOWN, and CHECK constraints inherently allow rows that evaluate to either TRUE or UNKNOWN, there is no need to explicitly allow missing values. For instance, instead of writing CHECK (price > 0 OR price IS NULL), the constraint should simply be written as CHECK (price > 0). Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
980 Data type mismatch in check constraints This query identifies single-column CHECK constraints where the validation logic utilizes operators or functions that are incompatible with the column's native data type. It detects cases where the database must perform implicit casting to evaluate the expression (e.g., performing arithmetic on a TEXT column or string manipulation on a DATE column). Relying on implicit coercion in constraints involves unnecessary computational overhead and frequently indicates a fundamental error in data modeling or constraint formulation. Problem detection system catalog base tables only MIT (opens in new tab) View