@@ -615,24 +615,27 @@ void setParamsInt64(DataTypeUtilBase*, const SysFunction*, int argsCount, dsc**
615615
616616void setParamsSecondInteger (DataTypeUtilBase*, const SysFunction*, int argsCount, dsc** args)
617617{
618- if (argsCount >= 2 )
619- {
620- if (args[1 ]->isUnknown ())
621- args[1 ]->makeLong (0 );
622- }
618+ fb_assert (argsCount >= 2 );
619+
620+ if (args[1 ]->isUnknown ())
621+ args[1 ]->makeLong (0 );
623622}
624623
625624
626625void setParamsAsciiVal (DataTypeUtilBase*, const SysFunction*, int argsCount, dsc** args)
627626{
628- if (argsCount >= 1 && args[0 ]->isUnknown ())
627+ fb_assert (argsCount >= 1 );
628+
629+ if (args[0 ]->isUnknown ())
629630 args[0 ]->makeText (1 , CS_ASCII);
630631}
631632
632633
633634void setParamsBlobAppend (DataTypeUtilBase*, const SysFunction*, int argsCount, dsc** args)
634635{
635- if (argsCount >= 1 && args[0 ]->isUnknown ())
636+ fb_assert (argsCount >= 1 );
637+
638+ if (args[0 ]->isUnknown ())
636639 args[0 ]->makeBlob (isc_blob_text, CS_dynamic);
637640
638641 for (int i = 1 ; i < argsCount; ++i)
@@ -645,14 +648,18 @@ void setParamsBlobAppend(DataTypeUtilBase*, const SysFunction*, int argsCount, d
645648
646649void setParamsCharToUuid (DataTypeUtilBase*, const SysFunction*, int argsCount, dsc** args)
647650{
648- if (argsCount >= 1 && args[0 ]->isUnknown ())
651+ fb_assert (argsCount >= 1 );
652+
653+ if (args[0 ]->isUnknown ())
649654 args[0 ]->makeText (Uuid::STR_LEN, ttype_ascii);
650655}
651656
652657
653658void setParamsDateAdd (DataTypeUtilBase*, const SysFunction*, int argsCount, dsc** args)
654659{
655- if (argsCount >= 1 && args[0 ]->isUnknown ())
660+ fb_assert (argsCount >= 3 );
661+
662+ if (args[0 ]->isUnknown ())
656663 {
657664 if (args[1 ]->dsc_address && // constant
658665 CVT_get_long (args[1 ], 0 , JRD_get_thread_data ()->getAttachment ()->att_dec_status , ERR_post) == blr_extract_millisecond)
@@ -663,31 +670,32 @@ void setParamsDateAdd(DataTypeUtilBase*, const SysFunction*, int argsCount, dsc*
663670 args[0 ]->makeInt64 (0 );
664671 }
665672
666- if (argsCount >= 3 && args[2 ]->isUnknown ())
673+ if (args[2 ]->isUnknown ())
667674 args[2 ]->makeTimestamp ();
668675}
669676
670677
671678void setParamsDateDiff (DataTypeUtilBase*, const SysFunction*, int argsCount, dsc** args)
672679{
673- if (argsCount >= 3 )
680+ fb_assert (argsCount >= 3 );
681+
682+ if (args[1 ]->isUnknown () && args[2 ]->isUnknown ())
674683 {
675- if (args[1 ]->isUnknown () && args[2 ]->isUnknown ())
676- {
677- args[1 ]->makeTimestamp ();
678- args[2 ]->makeTimestamp ();
679- }
680- else if (args[1 ]->isUnknown ())
681- *args[1 ] = *args[2 ];
682- else if (args[2 ]->isUnknown ())
683- *args[2 ] = *args[1 ];
684+ args[1 ]->makeTimestamp ();
685+ args[2 ]->makeTimestamp ();
684686 }
687+ else if (args[1 ]->isUnknown ())
688+ *args[1 ] = *args[2 ];
689+ else if (args[2 ]->isUnknown ())
690+ *args[2 ] = *args[1 ];
685691}
686692
687693
688694void setParamsUnicodeVal (DataTypeUtilBase*, const SysFunction*, int argsCount, dsc** args)
689695{
690- if (argsCount >= 1 && args[0 ]->isUnknown ())
696+ fb_assert (argsCount >= 1 );
697+
698+ if (args[0 ]->isUnknown ())
691699 args[0 ]->makeText (4 , CS_UTF8);
692700}
693701
@@ -823,23 +831,24 @@ void setParamsRsaPublic(DataTypeUtilBase*, const SysFunction*, int argsCount, ds
823831
824832void setParamsFirstLastDay (DataTypeUtilBase*, const SysFunction*, int argsCount, dsc** args)
825833{
826- if (argsCount >= 2 )
827- {
828- if (args[1 ]->isUnknown ())
829- args[1 ]->makeTimestamp ();
830- }
834+ fb_assert (argsCount >= 2 );
835+
836+ if (args[1 ]->isUnknown ())
837+ args[1 ]->makeTimestamp ();
831838}
832839
833840
834841void setParamsGetSetContext (DataTypeUtilBase*, const SysFunction*, int argsCount, dsc** args)
835842{
836- if (argsCount >= 1 && args[0 ]->isUnknown ())
843+ fb_assert (argsCount >= 2 );
844+
845+ if (args[0 ]->isUnknown ())
837846 {
838847 args[0 ]->makeVarying (80 , ttype_none);
839848 args[0 ]->setNullable (true );
840849 }
841850
842- if (argsCount >= 2 && args[1 ]->isUnknown ())
851+ if (args[1 ]->isUnknown ())
843852 {
844853 args[1 ]->makeVarying (80 , ttype_none);
845854 args[1 ]->setNullable (true );
@@ -865,86 +874,84 @@ void setParamsMakeDbkey(DataTypeUtilBase*, const SysFunction*, int argsCount, ds
865874{
866875 // MAKE_DBKEY ( REL_NAME | REL_ID, RECNUM [, DPNUM [, PPNUM] ] )
867876
868- if (argsCount > 1 )
869- {
870- if (args[0 ]->isUnknown ())
871- args[0 ]->makeLong (0 );
877+ fb_assert (argsCount >= 2 );
872878
873- if (args[1 ]->isUnknown ())
874- args[1 ]->makeInt64 (0 );
875- }
879+ if (args[0 ]->isUnknown ())
880+ args[0 ]->makeLong (0 );
876881
877- if (argsCount > 2 && args[2 ]->isUnknown ())
882+ if (args[1 ]->isUnknown ())
883+ args[1 ]->makeInt64 (0 );
884+
885+ if (argsCount >= 3 && args[2 ]->isUnknown ())
878886 args[2 ]->makeInt64 (0 );
879887
880- if (argsCount > 3 && args[3 ]->isUnknown ())
888+ if (argsCount >= 4 && args[3 ]->isUnknown ())
881889 args[3 ]->makeInt64 (0 );
882890}
883891
884892
885893void setParamsOverlay (DataTypeUtilBase*, const SysFunction*, int argsCount, dsc** args)
886894{
887- if (argsCount >= 3 )
895+ fb_assert (argsCount >= 3 );
896+
897+ if (!(args[0 ]->isUnknown () && args[1 ]->isUnknown ()))
888898 {
889- if (!(args[0 ]->isUnknown () && args[1 ]->isUnknown ()))
890- {
891- if (args[1 ]->isUnknown ())
892- *args[1 ] = *args[0 ];
893- else if (args[0 ]->isUnknown ())
894- *args[0 ] = *args[1 ];
895- }
899+ if (args[1 ]->isUnknown ())
900+ *args[1 ] = *args[0 ];
901+ else if (args[0 ]->isUnknown ())
902+ *args[0 ] = *args[1 ];
903+ }
896904
897- if (argsCount >= 4 )
905+ if (argsCount >= 4 )
906+ {
907+ if (args[2 ]->isUnknown () && args[3 ]->isUnknown ())
898908 {
899- if (args[2 ]->isUnknown () && args[3 ]->isUnknown ())
900- {
901- args[2 ]->makeLong (0 );
902- args[3 ]->makeLong (0 );
903- }
904- else if (args[2 ]->isUnknown ())
905- *args[2 ] = *args[3 ];
906- else if (args[3 ]->isUnknown ())
907- *args[3 ] = *args[2 ];
908- }
909-
910- if (args[2 ]->isUnknown ())
911909 args[2 ]->makeLong (0 );
910+ args[3 ]->makeLong (0 );
911+ }
912+ else if (args[2 ]->isUnknown ())
913+ *args[2 ] = *args[3 ];
914+ else if (args[3 ]->isUnknown ())
915+ *args[3 ] = *args[2 ];
912916 }
917+
918+ if (args[2 ]->isUnknown ())
919+ args[2 ]->makeLong (0 );
913920}
914921
915922
916923void setParamsPosition (DataTypeUtilBase*, const SysFunction*, int argsCount, dsc** args)
917924{
918- if (argsCount >= 2 )
919- {
920- if (args[0 ]->isUnknown ())
921- *args[0 ] = *args[1 ];
925+ fb_assert (argsCount >= 2 );
922926
923- if (args[1 ]->isUnknown ())
924- *args[1 ] = *args[0 ];
925- }
927+ if (args[0 ]->isUnknown ())
928+ *args[0 ] = *args[1 ];
929+
930+ if (args[1 ]->isUnknown ())
931+ *args[1 ] = *args[0 ];
926932}
927933
928934
929935void setParamsRoundTrunc (DataTypeUtilBase*, const SysFunction*, int argsCount, dsc** args)
930936{
931- if (argsCount >= 1 )
932- {
933- if (args[0 ]->isUnknown ())
934- args[0 ]->makeDouble ();
937+ fb_assert (argsCount >= 1 );
935938
936- if (argsCount >= 2 )
937- {
938- if (args[1 ]->isUnknown ())
939- args[1 ]->makeLong (0 );
940- }
939+ if (args[0 ]->isUnknown ())
940+ args[0 ]->makeDouble ();
941+
942+ if (argsCount >= 2 )
943+ {
944+ if (args[1 ]->isUnknown ())
945+ args[1 ]->makeLong (0 );
941946 }
942947}
943948
944949
945950void setParamsUuidToChar (DataTypeUtilBase*, const SysFunction*, int argsCount, dsc** args)
946951{
947- if (argsCount >= 1 && args[0 ]->isUnknown ())
952+ fb_assert (argsCount >= 1 );
953+
954+ if (args[0 ]->isUnknown ())
948955 args[0 ]->makeText (16 , ttype_binary);
949956}
950957
@@ -1308,23 +1315,20 @@ void makeBlobAppend(DataTypeUtilBase* dataTypeUtil, const SysFunction* function,
13081315 result->makeBlob (isc_blob_untyped, ttype_binary);
13091316 result->setNullable (true );
13101317
1311- if (argsCount > 0 )
1318+ for ( int i = 0 ; i < argsCount; ++i )
13121319 {
1313- for (int i = 0 ; i < argsCount; ++i)
1314- {
1315- if (makeBlobAppendBlob (result, args[i]))
1316- break ;
1317- }
1320+ if (makeBlobAppendBlob (result, args[i]))
1321+ break ;
1322+ }
13181323
1319- result->setNullable (true );
1324+ result->setNullable (true );
13201325
1321- for (int i = 0 ; i < argsCount; ++i)
1326+ for (int i = 0 ; i < argsCount; ++i)
1327+ {
1328+ if (!args[i]->isNullable ())
13221329 {
1323- if (!args[i]->isNullable ())
1324- {
1325- result->setNullable (false );
1326- break ;
1327- }
1330+ result->setNullable (false );
1331+ break ;
13281332 }
13291333 }
13301334}
@@ -1421,13 +1425,12 @@ void makeFirstLastDayResult(DataTypeUtilBase*, const SysFunction*, dsc* result,
14211425
14221426 result->makeDate ();
14231427
1424- if (argsCount >= 2 )
1425- {
1426- if (args[1 ]->dsc_dtype == dtype_timestamp)
1427- result->makeTimestamp ();
1428- else if (args[1 ]->dsc_dtype == dtype_timestamp_tz)
1429- result->makeTimestampTz ();
1430- }
1428+ fb_assert (argsCount >= 2 );
1429+
1430+ if (args[1 ]->dsc_dtype == dtype_timestamp)
1431+ result->makeTimestamp ();
1432+ else if (args[1 ]->dsc_dtype == dtype_timestamp_tz)
1433+ result->makeTimestampTz ();
14311434
14321435 result->setNullable (isNullable);
14331436}
0 commit comments