Skip to content

Conversation

@khustup2
Copy link
Contributor

🚀 🚀 Pull Request

Impact

  • Bug fix (non-breaking change which fixes expected existing functionality)
  • Enhancement/New feature (adds functionality without impacting existing logic)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

Things to be aware of

Things to worry about

Additional Context

@claude
Copy link

claude bot commented Jan 31, 2026

Claude finished @khustup2's task in 1m 16s —— View job


PR Review Complete

Found 4 critical issues that need attention:

  1. Domain type logic bug (extension_init.cpp:808, table_storage.cpp:767) - The case BYTEAOID: won't match domain types since domains have distinct OIDs. Need to check base type first.
  2. Potential null pointer dereference (nd_utils.hpp:330) - Missing null check before dereferencing get_type() result.
  3. Case sensitivity issue (utils.hpp:132) - Domain name comparison should be case-insensitive to match PostgreSQL identifier behavior.

These issues could prevent the feature from working correctly or cause crashes.


case BYTEAOID:
case BYTEAOID: {
// Check for special domain types over BYTEA
if (pg::utils::is_file_domain_type(attr->atttypid)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Domain type check is applied to wrong OID - should check base type, not the domain OID itself. Domain types inherit from BYTEA (base type), but attr->atttypid holds the domain OID. When checking is_file_domain_type(attr->atttypid), it will match correctly, but the parent case BYTEAOID: will never trigger for domain types because PostgreSQL doesn't set atttypid to BYTEAOID for domains.

Fix: Need to either check the base type of the domain first, or restructure to check domain types before the base type switch. Consider:

// Before the switch statement, check for domains over BYTEA
Oid baseType = getBaseType(attr->atttypid);
if (baseType == BYTEAOID) {
    if (pg::utils::is_file_domain_type(attr->atttypid)) { ... }
    // etc.
}

case BYTEAOID:
case BYTEAOID: {
// Check for special domain types over BYTEA
if (pg::utils::is_file_domain_type(attr->atttypid)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as extension_init.cpp:808 - domain type check won't work correctly because the case BYTEAOID: won't match domain types. Domain types have their own OID distinct from BYTEAOID.

Fix: Check the base type before entering the switch, or restructure to handle domains properly.


Form_pg_type typTup = (Form_pg_type)GETSTRUCT(tup);

bool is_match = (typTup->typtype == TYPTYPE_DOMAIN && strcmp(NameStr(typTup->typname), domain_name) == 0);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Case-sensitive string comparison may cause issues if domains are created with different casing (e.g., "FILE" vs "file"). PostgreSQL identifiers are case-insensitive by default but stored in lowercase unless quoted.

Recommended fix: Use case-insensitive comparison or clarify that domains must be lowercase:

Suggested change
bool is_match = (typTup->typtype == TYPTYPE_DOMAIN && strcmp(NameStr(typTup->typname), domain_name) == 0);
bool is_match = (typTup->typtype == TYPTYPE_DOMAIN && pg_strcasecmp(NameStr(typTup->typname), domain_name) == 0);

case deeplake_core::type_kind::link: {
// Check if link contains bytes (file type) vs other types
auto inner = t.as_link().get_type();
if (inner->is_generic() && inner->data_type().get_dtype() == nd::dtype::byte) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential null pointer dereference if get_type() returns nullptr. Should add null check before dereferencing.

Fix:

Suggested change
if (inner->is_generic() && inner->data_type().get_dtype() == nd::dtype::byte) {
auto inner = t.as_link().get_type();
if (inner && inner->is_generic() && inner->data_type().get_dtype() == nd::dtype::byte) {

@sonarqubecloud
Copy link

@khustup2 khustup2 merged commit 873afdc into main Jan 31, 2026
9 of 11 checks passed
@khustup2 khustup2 deleted the domain-types branch January 31, 2026 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants