MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / makeDialect1

Method makeDialect1

src/dsql/ExprNodes.cpp:769–1020  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

767}
768
769void ArithmeticNode::makeDialect1(dsc* desc, dsc& desc1, dsc& desc2)
770{
771 USHORT dtype, dtype1, dtype2;
772
773 switch (blrOp)
774 {
775 case blr_add:
776 case blr_subtract:
777 dtype1 = desc1.dsc_dtype;
778 if (dtype_int64 == dtype1 || DTYPE_IS_TEXT(dtype1))
779 dtype1 = dtype_double;
780
781 dtype2 = desc2.dsc_dtype;
782 if (dtype_int64 == dtype2 || DTYPE_IS_TEXT(dtype2))
783 dtype2 = dtype_double;
784
785 dtype = MAX(dtype1, dtype2);
786
787 if (DTYPE_IS_BLOB(dtype))
788 {
789 ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) <<
790 Arg::Gds(isc_dsql_no_blob_array));
791 }
792
793 desc->dsc_flags = (desc1.dsc_flags | desc2.dsc_flags) & DSC_nullable;
794
795 switch (dtype)
796 {
797 case dtype_ex_time_tz:
798 case dtype_ex_timestamp_tz:
799 fb_assert(false);
800 ERRD_post(Arg::Gds(isc_expression_eval_err));
801
802 case dtype_sql_time:
803 case dtype_sql_time_tz:
804 case dtype_sql_date:
805 // CVC: I don't see how this case can happen since dialect 1 doesn't accept
806 // DATE or TIME
807 // Forbid <date/time> +- <string>
808 if (DTYPE_IS_TEXT(desc1.dsc_dtype) || DTYPE_IS_TEXT(desc2.dsc_dtype))
809 {
810 ERRD_post(Arg::Gds(isc_expression_eval_err) <<
811 Arg::Gds(isc_dsql_nodateortime_pm_string));
812 }
813 // fall into
814
815 case dtype_timestamp:
816 case dtype_timestamp_tz:
817
818 // Allow <timestamp> +- <string> (historical)
819 if (couldBeDate(desc1) && couldBeDate(desc2))
820 {
821 if (blrOp == blr_subtract)
822 {
823 // <any date> - <any date>
824
825 // Legal permutations are:
826 // <timestamp> - <timestamp>

Callers

nothing calls this directly

Calls 15

DTYPE_IS_TEXTFunction · 0.85
DTYPE_IS_BLOBFunction · 0.85
ERRD_postFunction · 0.85
GdsClass · 0.85
NumClass · 0.85
couldBeDateFunction · 0.85
isDateAndTimeFunction · 0.85
DTYPE_IS_DATEFunction · 0.85
setDecDescFunction · 0.85
setFixedSubTypeFunction · 0.85
NUMERIC_SCALEFunction · 0.85
DTYPE_IS_DECFLOATFunction · 0.85

Tested by

no test coverage detected