Skip to content

Commit

Permalink
List TDS types explicitly instead of using "default"
Browse files Browse the repository at this point in the history
New types will trigger new warnings.
Also handle some additional types in dbpivot function.

Signed-off-by: Frediano Ziglio <[email protected]>
  • Loading branch information
freddy77 committed Jan 8, 2025
1 parent 31a7195 commit 691e98d
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 7 deletions.
32 changes: 31 additions & 1 deletion src/ctlib/ct.c
Original file line number Diff line number Diff line change
Expand Up @@ -2180,7 +2180,37 @@ _ct_get_client_type(const TDSCOLUMN *col, bool describe)
case SYBMSDATETIME2:
case SYBMSDATETIMEOFFSET:
break;
default: /* SYBNTEXT, etc. */

/* nullable types should not occur here... */
case SYBBITN:
case SYBINTN:
case SYBDATETIMN:
case SYBFLTN:
case SYBMONEYN:
case SYBUINTN:
case SYBTIMEN:
case SYBDATEN:

/* handled by tds_get_conversion_type */
case SYB5INT8:
assert(0);

/* TODO... */
case SYBVOID:
case SYBNVARCHAR:
case XSYBVARCHAR:
case XSYBNVARCHAR:
case XSYBNCHAR:
case XSYBVARBINARY:
case XSYBBINARY:
case SYBMSUDT:
case SYBMSXML:
case SYBMSTABLE:
case SYBINTERVAL:
case SYBSINT1:
case SYBUNITEXT:
case SYBXML:
case SYBNTEXT:
break;
}

Expand Down
73 changes: 67 additions & 6 deletions src/dblib/dbpivot.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,14 @@ col_equal(const struct col_t *pc1, const struct col_t *pc2)
return false;
return strncmp(pc1->s, pc2->s, pc1->len) == 0;
case SYBINT1:
case SYBUINT1:
case SYBSINT1:
return pc1->data.ti == pc2->data.ti;
case SYBINT2:
case SYBUINT2:
return pc1->data.si == pc2->data.si;
case SYBINT4:
case SYBUINT4:
return pc1->data.i == pc2->data.i;
case SYBFLT8:
return pc1->data.f == pc2->data.f;
Expand All @@ -173,11 +177,38 @@ col_equal(const struct col_t *pc1, const struct col_t *pc2)
case SYBMONEYN:
case SYBDATETIMN:
case SYBMSTABLE:
case SYBNVARCHAR:
case SYBINT8:
case XSYBCHAR:
case XSYBVARCHAR:
case XSYBNVARCHAR:
case XSYBNCHAR:
case XSYBVARBINARY:
case XSYBBINARY:
case SYBUNIQUE:
case SYBVARIANT:
case SYBMSUDT:
case SYBMSXML:
case SYBMSDATE:
case SYBMSTIME:
case SYBMSDATETIME2:
case SYBMSDATETIMEOFFSET:
case SYBLONGBINARY:
case SYBUINT8:
case SYBDATE:
case SYBDATEN:
case SYB5INT8:
case SYBINTERVAL:
case SYBTIME:
case SYBTIMEN:
case SYBUINTN:
case SYBUNITEXT:
case SYBXML:
case SYB5BIGDATETIME:
case SYB5BIGTIME:

assert( false && pc1->type );
break;

default:
return false;
}
return false;
}
Expand All @@ -191,10 +222,14 @@ col_buffer(struct col_t *pcol)
case SYBVARCHAR:
return pcol->s;
case SYBINT1:
case SYBUINT1:
case SYBSINT1:
return &pcol->data.ti;
case SYBINT2:
case SYBUINT2:
return &pcol->data.si;
case SYBINT4:
case SYBUINT4:
return &pcol->data.i;
case SYBFLT8:
return &pcol->data.f;
Expand All @@ -220,11 +255,37 @@ col_buffer(struct col_t *pcol)
case SYBMONEYN:
case SYBDATETIMN:
case SYBMSTABLE:
case SYBNVARCHAR:
case SYBINT8:
case XSYBCHAR:
case XSYBVARCHAR:
case XSYBNVARCHAR:
case XSYBNCHAR:
case XSYBVARBINARY:
case XSYBBINARY:
case SYBUNIQUE:
case SYBVARIANT:
case SYBMSUDT:
case SYBMSXML:
case SYBMSDATE:
case SYBMSTIME:
case SYBMSDATETIME2:
case SYBMSDATETIMEOFFSET:
case SYBLONGBINARY:
case SYBUINT8:
case SYBDATE:
case SYBDATEN:
case SYB5INT8:
case SYBINTERVAL:
case SYBTIME:
case SYBTIMEN:
case SYBUINTN:
case SYBUNITEXT:
case SYBXML:
case SYB5BIGDATETIME:
case SYB5BIGTIME:
assert( false && pcol->type );
break;

default:
return NULL;
}
return NULL;

Expand Down

0 comments on commit 691e98d

Please sign in to comment.