ExtCast.h File Reference

Go to the source code of this file.

Functions

FENNEL_BEGIN_NAMESPACE void castExactToStrA (RegisterRef< char * > *result, RegisterRef< int64_t > *src)
 castA.
void castExactToStrA (RegisterRef< char * > *result, RegisterRef< int64_t > *src, RegisterRef< int32_t > *precision, RegisterRef< int32_t > *scale)
 castA.
void castApproxToStrA (RegisterRef< char * > *result, RegisterRef< double > *src)
 castA.
void castStrtoExactA (RegisterRef< int64_t > *result, RegisterRef< char * > *src)
 castA.
void castStrToExactA (RegisterRef< int64_t > *result, RegisterRef< char * > *src, RegisterRef< int32_t > *precision, RegisterRef< int32_t > *scale)
 castA.
void castStrToApproxA (RegisterRef< double > *result, RegisterRef< char * > *src)
 castA.
void castBooleanToStrA (RegisterRef< char * > *result, RegisterRef< int64_t > *src)
 castA.
void castStrtoBooleanA (RegisterRef< bool > *result, RegisterRef< char * > *src)
 castA.
void castStrToVarCharA (RegisterRef< char * > *result, RegisterRef< char * > *src)
 castA.
void castStrToCharA (RegisterRef< char * > *result, RegisterRef< char * > *src)
 castA.
void ExtCastRegister (ExtendedInstructionTable *eit)


Function Documentation

void castApproxToStrA ( RegisterRef< char * > *  result,
RegisterRef< double > *  src 
)

castA.

Ascii. Char & Varchar

Casts an approximate numeric to an Ascii string.

May throw "22001" data exception - string data, right truncation

Definition at line 95 of file ExtCast.cpp.

References RegisterRef< TMPLT >::isNull(), StandardTypeDescriptor::isTextArray(), RegisterRef< TMPLT >::length(), RegisterRef< TMPLT >::pointer(), STANDARD_TYPE_CHAR, RegisterRef< TMPLT >::storage(), RegisterRef< TMPLT >::toNull(), RegisterReference::type(), and RegisterRef< TMPLT >::value().

00098 {
00099     assert(StandardTypeDescriptor::isTextArray(result->type()));
00100 
00101     if (src->isNull()) {
00102         result->toNull();
00103         result->length(0);
00104     } else {
00105         result->length(
00106             SqlStrCastFromApprox<1,1>(
00107                 result->pointer(),
00108                 result->storage(),
00109                 src->value(),
00110                 false,
00111                 (result->type() == STANDARD_TYPE_CHAR ? true : false)));
00112     }
00113 }

void castBooleanToStrA ( RegisterRef< char * > *  result,
RegisterRef< int64_t > *  src 
)

castA.

Ascii. Char & Varchar

Casts a boolean to an Ascii string.

May throw "22018" data exception - invalid character value for cast

void castExactToStrA ( RegisterRef< char * > *  result,
RegisterRef< int64_t > *  src,
RegisterRef< int32_t > *  precision,
RegisterRef< int32_t > *  scale 
)

castA.

Ascii. Char & Varchar

Casts an exact numeric with precision and scale to an Ascii string.

May throw "22001" data exception - string data, right truncation

Definition at line 50 of file ExtCast.cpp.

References RegisterRef< TMPLT >::isNull(), StandardTypeDescriptor::isTextArray(), RegisterRef< TMPLT >::length(), RegisterRef< TMPLT >::pointer(), STANDARD_TYPE_CHAR, RegisterRef< TMPLT >::storage(), RegisterRef< TMPLT >::toNull(), RegisterReference::type(), and RegisterRef< TMPLT >::value().

00055 {
00056     assert(StandardTypeDescriptor::isTextArray(result->type()));
00057 
00058     if (src->isNull()) {
00059         result->toNull();
00060         result->length(0);
00061     } else {
00062          result->length(
00063              SqlStrCastFromExact<1,1>(
00064                  result->pointer(),
00065                  result->storage(),
00066                  src->value(),
00067                  precision->value(),
00068                  scale->value(),
00069                  (result->type() == STANDARD_TYPE_CHAR ? true : false)));
00070     }
00071 }

FENNEL_BEGIN_NAMESPACE void castExactToStrA ( RegisterRef< char * > *  result,
RegisterRef< int64_t > *  src 
)

castA.

Ascii. Char & Varchar

Casts an exact numeric to an Ascii string.

May throw "22001" data exception - string data, right truncation

Definition at line 30 of file ExtCast.cpp.

References RegisterRef< TMPLT >::isNull(), StandardTypeDescriptor::isTextArray(), RegisterRef< TMPLT >::length(), RegisterRef< TMPLT >::pointer(), STANDARD_TYPE_CHAR, RegisterRef< TMPLT >::storage(), RegisterRef< TMPLT >::toNull(), RegisterReference::type(), and RegisterRef< TMPLT >::value().

00033 {
00034     assert(StandardTypeDescriptor::isTextArray(result->type()));
00035 
00036     if (src->isNull()) {
00037         result->toNull();
00038         result->length(0);
00039     } else {
00040         result->length(
00041             SqlStrCastFromExact<1,1>(
00042                 result->pointer(),
00043                 result->storage(),
00044                 src->value(),
00045                 (result->type() == STANDARD_TYPE_CHAR ? true : false)));
00046     }
00047 }

void castStrToApproxA ( RegisterRef< double > *  result,
RegisterRef< char * > *  src 
)

castA.

Ascii. Char & Varchar

Casts a string to an approximate numeric.

May throw "22018" data exception - invalid character value for cast

Definition at line 155 of file ExtCast.cpp.

References RegisterRef< TMPLT >::isNull(), StandardTypeDescriptor::isTextArray(), RegisterRef< TMPLT >::pointer(), RegisterRef< TMPLT >::stringLength(), RegisterRef< TMPLT >::toNull(), RegisterReference::type(), and RegisterRef< TMPLT >::value().

Referenced by ExtCastRegister().

00158 {
00159     assert(StandardTypeDescriptor::isTextArray(src->type()));
00160 
00161     if (src->isNull()) {
00162         result->toNull();
00163     } else {
00164         result->value(
00165             SqlStrCastToApprox<1,1>(
00166                 src->pointer(),
00167                 src->stringLength()));
00168     }
00169 }

void castStrtoBooleanA ( RegisterRef< bool > *  result,
RegisterRef< char * > *  src 
)

castA.

Ascii. Char & Varchar

Casts a string to an boolean.

May throw "22018" data exception - invalid character value for cast

void castStrToCharA ( RegisterRef< char * > *  result,
RegisterRef< char * > *  src 
)

castA.

Ascii. String to Char

Casts a string to a fixed-length string.

May throw "22001" string data, right truncation

Definition at line 241 of file ExtCast.cpp.

References StandardTypeDescriptor::isArray(), RegisterRef< TMPLT >::isNull(), RegisterRef< TMPLT >::length(), RegisterRef< TMPLT >::pointer(), RegisterRef< TMPLT >::storage(), RegisterRef< TMPLT >::stringLength(), RegisterRef< TMPLT >::toNull(), and RegisterReference::type().

Referenced by ExtCastRegister().

00244 {
00245     assert(StandardTypeDescriptor::isArray(result->type()));
00246     assert(StandardTypeDescriptor::isArray(src->type()));
00247 
00248     if (src->isNull()) {
00249         result->toNull();
00250         result->length(0);
00251     } else {
00252         int rightTruncWarning = 0;
00253         result->length(
00254             SqlStrCastToChar<1,1>(
00255                 result->pointer(),
00256                 result->storage(),
00257                 src->pointer(),
00258                 src->stringLength(),
00259                 &rightTruncWarning));
00260 
00261         if (rightTruncWarning) {
00262             // TODO: throw 22001 as a warning
00263 //            throw "22001";
00264         }
00265     }
00266 }

void castStrToExactA ( RegisterRef< int64_t > *  result,
RegisterRef< char * > *  src,
RegisterRef< int32_t > *  precision,
RegisterRef< int32_t > *  scale 
)

castA.

Ascii. Char & Varchar

Casts a string to an exact numeric with precision and scale.

May throw "22018" data exception - invalid character value for cast May throw "22003" data exception - numeric value out of range

Definition at line 134 of file ExtCast.cpp.

References RegisterRef< TMPLT >::isNull(), StandardTypeDescriptor::isTextArray(), RegisterRef< TMPLT >::pointer(), RegisterRef< TMPLT >::stringLength(), RegisterRef< TMPLT >::toNull(), RegisterReference::type(), and RegisterRef< TMPLT >::value().

00139 {
00140     assert(StandardTypeDescriptor::isTextArray(src->type()));
00141 
00142     if (src->isNull()) {
00143         result->toNull();
00144     } else {
00145         result->value(
00146             SqlStrCastToExact<1,1>(
00147                 src->pointer(),
00148                 src->stringLength(),
00149                 precision->value(),
00150                 scale->value()));
00151     }
00152 }

void castStrtoExactA ( RegisterRef< int64_t > *  result,
RegisterRef< char * > *  src 
)

castA.

Ascii. Char & Varchar

Casts a string to an exact numeric.

May throw "22018" data exception - invalid character value for cast

void castStrToVarCharA ( RegisterRef< char * > *  result,
RegisterRef< char * > *  src 
)

castA.

Ascii. String to Varchar

Casts a string to a variable-length string.

May throw "22001" string data, right truncation

Definition at line 212 of file ExtCast.cpp.

References StandardTypeDescriptor::isArray(), RegisterRef< TMPLT >::isNull(), RegisterRef< TMPLT >::length(), RegisterRef< TMPLT >::pointer(), RegisterRef< TMPLT >::storage(), RegisterRef< TMPLT >::stringLength(), RegisterRef< TMPLT >::toNull(), and RegisterReference::type().

Referenced by ExtCastRegister().

00215 {
00216     assert(StandardTypeDescriptor::isArray(result->type()));
00217     assert(StandardTypeDescriptor::isArray(src->type()));
00218 
00219     if (src->isNull()) {
00220         result->toNull();
00221         result->length(0);
00222     } else {
00223         int rightTruncWarning = 0;
00224         result->length(
00225             SqlStrCastToVarChar<1,1>(
00226                 result->pointer(),
00227                 result->storage(),
00228                 src->pointer(),
00229                 src->stringLength(),
00230                 &rightTruncWarning));
00231         if (rightTruncWarning) {
00232             // TODO: throw 22001 as a warning
00233 //            throw "22001";
00234         }
00235     }
00236 }

void ExtCastRegister ( ExtendedInstructionTable eit  ) 

Definition at line 332 of file ExtCast.cpp.

References ExtendedInstructionTable::add(), castApproxToStrA(), castBooleanToStrA(), castExactToStrA(), castStrToApproxA(), castStrToBinaryA(), castStrToBooleanA(), castStrToCharA(), castStrToExactA(), castStrToVarBinaryA(), castStrToVarCharA(), STANDARD_TYPE_BINARY, STANDARD_TYPE_BOOL, STANDARD_TYPE_CHAR, STANDARD_TYPE_DOUBLE, STANDARD_TYPE_INT_32, STANDARD_TYPE_INT_64, STANDARD_TYPE_REAL, STANDARD_TYPE_VARBINARY, and STANDARD_TYPE_VARCHAR.

Referenced by CalcInit::instance().

00333 {
00334     assert(eit != NULL);
00335 
00336     vector<StandardTypeDescriptorOrdinal> params_1bo_1c;
00337     params_1bo_1c.push_back(STANDARD_TYPE_BOOL);
00338     params_1bo_1c.push_back(STANDARD_TYPE_CHAR);
00339 
00340     vector<StandardTypeDescriptorOrdinal> params_1bo_1vc;
00341     params_1bo_1vc.push_back(STANDARD_TYPE_BOOL);
00342     params_1bo_1vc.push_back(STANDARD_TYPE_VARCHAR);
00343 
00344     vector<StandardTypeDescriptorOrdinal> params_1s8_1c;
00345     params_1s8_1c.push_back(STANDARD_TYPE_INT_64);
00346     params_1s8_1c.push_back(STANDARD_TYPE_CHAR);
00347 
00348     vector<StandardTypeDescriptorOrdinal> params_1s8_1vc;
00349     params_1s8_1vc.push_back(STANDARD_TYPE_INT_64);
00350     params_1s8_1vc.push_back(STANDARD_TYPE_VARCHAR);
00351 
00352     vector<StandardTypeDescriptorOrdinal> params_1s8_1c_PS;
00353     params_1s8_1c_PS.push_back(STANDARD_TYPE_INT_64);
00354     params_1s8_1c_PS.push_back(STANDARD_TYPE_CHAR);
00355     params_1s8_1c_PS.push_back(STANDARD_TYPE_INT_32);
00356     params_1s8_1c_PS.push_back(STANDARD_TYPE_INT_32);
00357 
00358     vector<StandardTypeDescriptorOrdinal> params_1s8_1vc_PS;
00359     params_1s8_1vc_PS.push_back(STANDARD_TYPE_INT_64);
00360     params_1s8_1vc_PS.push_back(STANDARD_TYPE_VARCHAR);
00361     params_1s8_1vc_PS.push_back(STANDARD_TYPE_INT_32);
00362     params_1s8_1vc_PS.push_back(STANDARD_TYPE_INT_32);
00363 
00364     vector<StandardTypeDescriptorOrdinal> params_1d_1c;
00365     params_1d_1c.push_back(STANDARD_TYPE_DOUBLE);
00366     params_1d_1c.push_back(STANDARD_TYPE_CHAR);
00367 
00368     vector<StandardTypeDescriptorOrdinal> params_1d_1vc;
00369     params_1d_1vc.push_back(STANDARD_TYPE_DOUBLE);
00370     params_1d_1vc.push_back(STANDARD_TYPE_VARCHAR);
00371 
00372     vector<StandardTypeDescriptorOrdinal> params_1c_1bo;
00373     params_1c_1bo.push_back(STANDARD_TYPE_CHAR);
00374     params_1c_1bo.push_back(STANDARD_TYPE_BOOL);
00375 
00376     vector<StandardTypeDescriptorOrdinal> params_1vc_1bo;
00377     params_1vc_1bo.push_back(STANDARD_TYPE_VARCHAR);
00378     params_1vc_1bo.push_back(STANDARD_TYPE_BOOL);
00379 
00380     vector<StandardTypeDescriptorOrdinal> params_1c_1s8;
00381     params_1c_1s8.push_back(STANDARD_TYPE_CHAR);
00382     params_1c_1s8.push_back(STANDARD_TYPE_INT_64);
00383 
00384     vector<StandardTypeDescriptorOrdinal> params_1vc_1s8;
00385     params_1vc_1s8.push_back(STANDARD_TYPE_VARCHAR);
00386     params_1vc_1s8.push_back(STANDARD_TYPE_INT_64);
00387 
00388     vector<StandardTypeDescriptorOrdinal> params_1c_1s8_PS;
00389     params_1c_1s8_PS.push_back(STANDARD_TYPE_CHAR);
00390     params_1c_1s8_PS.push_back(STANDARD_TYPE_INT_64);
00391     params_1c_1s8_PS.push_back(STANDARD_TYPE_INT_32);
00392     params_1c_1s8_PS.push_back(STANDARD_TYPE_INT_32);
00393 
00394     vector<StandardTypeDescriptorOrdinal> params_1vc_1s8_PS;
00395     params_1vc_1s8_PS.push_back(STANDARD_TYPE_VARCHAR);
00396     params_1vc_1s8_PS.push_back(STANDARD_TYPE_INT_64);
00397     params_1vc_1s8_PS.push_back(STANDARD_TYPE_INT_32);
00398     params_1vc_1s8_PS.push_back(STANDARD_TYPE_INT_32);
00399 
00400     vector<StandardTypeDescriptorOrdinal> params_1c_1d;
00401     params_1c_1d.push_back(STANDARD_TYPE_CHAR);
00402     params_1c_1d.push_back(STANDARD_TYPE_DOUBLE);
00403 
00404     vector<StandardTypeDescriptorOrdinal> params_1vc_1d;
00405     params_1vc_1d.push_back(STANDARD_TYPE_VARCHAR);
00406     params_1vc_1d.push_back(STANDARD_TYPE_DOUBLE);
00407 
00408     vector<StandardTypeDescriptorOrdinal> params_1c_1r;
00409     params_1c_1r.push_back(STANDARD_TYPE_CHAR);
00410     params_1c_1r.push_back(STANDARD_TYPE_REAL);
00411 
00412     vector<StandardTypeDescriptorOrdinal> params_1vc_1r;
00413     params_1vc_1r.push_back(STANDARD_TYPE_VARCHAR);
00414     params_1vc_1r.push_back(STANDARD_TYPE_REAL);
00415 
00416     vector<StandardTypeDescriptorOrdinal> params_1vc_1c;
00417     params_1vc_1c.push_back(STANDARD_TYPE_VARCHAR);
00418     params_1vc_1c.push_back(STANDARD_TYPE_CHAR);
00419 
00420     vector<StandardTypeDescriptorOrdinal> params_1c_1vc;
00421     params_1c_1vc.push_back(STANDARD_TYPE_CHAR);
00422     params_1c_1vc.push_back(STANDARD_TYPE_VARCHAR);
00423 
00424     vector<StandardTypeDescriptorOrdinal> params_1vc_1vc;
00425     params_1vc_1vc.push_back(STANDARD_TYPE_VARCHAR);
00426     params_1vc_1vc.push_back(STANDARD_TYPE_VARCHAR);
00427 
00428     vector<StandardTypeDescriptorOrdinal> params_1c_1c;
00429     params_1c_1c.push_back(STANDARD_TYPE_CHAR);
00430     params_1c_1c.push_back(STANDARD_TYPE_CHAR);
00431 
00432     vector<StandardTypeDescriptorOrdinal> params_1vb_1b;
00433     params_1vb_1b.push_back(STANDARD_TYPE_VARBINARY);
00434     params_1vb_1b.push_back(STANDARD_TYPE_BINARY);
00435 
00436     vector<StandardTypeDescriptorOrdinal> params_1b_1vb;
00437     params_1b_1vb.push_back(STANDARD_TYPE_BINARY);
00438     params_1b_1vb.push_back(STANDARD_TYPE_VARBINARY);
00439 
00440     vector<StandardTypeDescriptorOrdinal> params_1vb_1vb;
00441     params_1vb_1vb.push_back(STANDARD_TYPE_VARBINARY);
00442     params_1vb_1vb.push_back(STANDARD_TYPE_VARBINARY);
00443 
00444     vector<StandardTypeDescriptorOrdinal> params_1b_1b;
00445     params_1b_1b.push_back(STANDARD_TYPE_BINARY);
00446     params_1b_1b.push_back(STANDARD_TYPE_BINARY);
00447 
00448     eit->add(
00449         "castA", params_1bo_1c,
00450         (ExtendedInstruction2<bool, char*>*) NULL,
00451         &castStrToBooleanA);
00452     eit->add(
00453         "castA", params_1bo_1vc,
00454         (ExtendedInstruction2<bool, char*>*) NULL,
00455         &castStrToBooleanA);
00456 
00457     eit->add(
00458         "castA", params_1s8_1c,
00459         (ExtendedInstruction2<int64_t, char*>*) NULL,
00460         &castStrToExactA);
00461     eit->add(
00462         "castA", params_1s8_1vc,
00463         (ExtendedInstruction2<int64_t, char*>*) NULL,
00464         &castStrToExactA);
00465 
00466     eit->add(
00467         "castA", params_1s8_1c_PS,
00468         (ExtendedInstruction4<int64_t, char*, int32_t, int32_t>*) NULL,
00469         &castStrToExactA);
00470     eit->add(
00471         "castA", params_1s8_1vc_PS,
00472         (ExtendedInstruction4<int64_t, char*, int32_t, int32_t>*) NULL,
00473         &castStrToExactA);
00474 
00475     eit->add(
00476         "castA", params_1d_1c,
00477         (ExtendedInstruction2<double, char*>*) NULL,
00478         &castStrToApproxA);
00479     eit->add(
00480         "castA", params_1d_1vc,
00481         (ExtendedInstruction2<double, char*>*) NULL,
00482         &castStrToApproxA);
00483 
00484     eit->add(
00485         "castA", params_1c_1bo,
00486         (ExtendedInstruction2<char*, bool>*) NULL,
00487         &castBooleanToStrA);
00488     eit->add(
00489         "castA", params_1vc_1bo,
00490         (ExtendedInstruction2<char*, bool>*) NULL,
00491         &castBooleanToStrA);
00492 
00493     eit->add(
00494         "castA", params_1c_1s8,
00495         (ExtendedInstruction2<char*, int64_t>*) NULL,
00496         &castExactToStrA);
00497     eit->add(
00498         "castA", params_1vc_1s8,
00499         (ExtendedInstruction2<char*, int64_t>*) NULL,
00500         &castExactToStrA);
00501 
00502     eit->add(
00503         "castA", params_1c_1s8_PS,
00504         (ExtendedInstruction4<char*, int64_t, int32_t, int32_t>*) NULL,
00505         &castExactToStrA);
00506     eit->add(
00507         "castA", params_1vc_1s8_PS,
00508         (ExtendedInstruction4<char*, int64_t, int32_t, int32_t>*) NULL,
00509         &castExactToStrA);
00510 
00511     eit->add(
00512         "castA", params_1c_1d,
00513         (ExtendedInstruction2<char*, double>*) NULL,
00514         &castApproxToStrA);
00515     eit->add(
00516         "castA", params_1vc_1d,
00517         (ExtendedInstruction2<char*, double>*) NULL,
00518         &castApproxToStrA);
00519 
00520     eit->add(
00521         "castA", params_1c_1r,
00522         (ExtendedInstruction2<char*, float>*) NULL,
00523         &castApproxToStrA);
00524     eit->add(
00525         "castA", params_1vc_1r,
00526         (ExtendedInstruction2<char*, float>*) NULL,
00527         &castApproxToStrA);
00528 
00529     eit->add(
00530         "castA", params_1c_1vc,
00531         (ExtendedInstruction2<char*, char*>*) NULL,
00532         &castStrToCharA);
00533     eit->add(
00534         "castA", params_1c_1c,
00535         (ExtendedInstruction2<char*, char*>*) NULL,
00536         &castStrToCharA);
00537 
00538     eit->add(
00539         "castA", params_1vc_1c,
00540         (ExtendedInstruction2<char*, char*>*) NULL,
00541         &castStrToVarCharA);
00542     eit->add(
00543         "castA", params_1vc_1vc,
00544         (ExtendedInstruction2<char*, char*>*) NULL,
00545         &castStrToVarCharA);
00546 
00547     eit->add(
00548         "castA", params_1b_1vb,
00549         (ExtendedInstruction2<char*, char*>*) NULL,
00550         &castStrToBinaryA);
00551     eit->add(
00552         "castA", params_1b_1b,
00553         (ExtendedInstruction2<char*, char*>*) NULL,
00554         &castStrToBinaryA);
00555 
00556     eit->add(
00557         "castA", params_1vb_1b,
00558         (ExtendedInstruction2<char*, char*>*) NULL,
00559         &castStrToVarBinaryA);
00560     eit->add(
00561         "castA", params_1vb_1vb,
00562         (ExtendedInstruction2<char*, char*>*) NULL,
00563         &castStrToVarBinaryA);
00564 }


Generated on Mon Jun 22 04:00:21 2009 for Fennel by  doxygen 1.5.1