|
From: <di...@us...> - 2014-12-16 19:12:28
|
Revision: 60373
http://sourceforge.net/p/firebird/code/60373
Author: dimitr
Date: 2014-12-16 19:12:18 +0000 (Tue, 16 Dec 2014)
Log Message:
-----------
Fixed CORE-4572: Incorrect error for PSQL function when the number of actual arguments does not match the number of formal arguments.
Modified Paths:
--------------
firebird/trunk/lang_helpers/gds_codes.ftn
firebird/trunk/lang_helpers/gds_codes.pas
firebird/trunk/src/dsql/ExprNodes.cpp
firebird/trunk/src/dsql/StmtNodes.cpp
firebird/trunk/src/dsql/dsql.h
firebird/trunk/src/dsql/metd.epp
firebird/trunk/src/include/gen/codetext.h
firebird/trunk/src/include/gen/iberror.h
firebird/trunk/src/include/gen/msgs.h
firebird/trunk/src/include/gen/sql_code.h
firebird/trunk/src/include/gen/sql_state.h
firebird/trunk/src/msgs/facilities2.sql
firebird/trunk/src/msgs/messages2.sql
firebird/trunk/src/msgs/system_errors2.sql
Modified: firebird/trunk/lang_helpers/gds_codes.ftn
===================================================================
--- firebird/trunk/lang_helpers/gds_codes.ftn 2014-12-16 17:33:28 UTC (rev 60372)
+++ firebird/trunk/lang_helpers/gds_codes.ftn 2014-12-16 19:12:18 UTC (rev 60373)
@@ -1612,6 +1612,8 @@
PARAMETER (GDS__crdb_notable = 335545099)
INTEGER*4 GDS__interface_version_too_old
PARAMETER (GDS__interface_version_too_old = 335545100)
+ INTEGER*4 GDS__fun_param_mismatch
+ PARAMETER (GDS__fun_param_mismatch = 335545101)
INTEGER*4 GDS__gfix_db_name
PARAMETER (GDS__gfix_db_name = 335740929)
INTEGER*4 GDS__gfix_invalid_sw
Modified: firebird/trunk/lang_helpers/gds_codes.pas
===================================================================
--- firebird/trunk/lang_helpers/gds_codes.pas 2014-12-16 17:33:28 UTC (rev 60372)
+++ firebird/trunk/lang_helpers/gds_codes.pas 2014-12-16 19:12:18 UTC (rev 60373)
@@ -813,6 +813,7 @@
gds_crdb_nodb = 335545098;
gds_crdb_notable = 335545099;
gds_interface_version_too_old = 335545100;
+ gds_fun_param_mismatch = 335545101;
gds_gfix_db_name = 335740929;
gds_gfix_invalid_sw = 335740930;
gds_gfix_incmp_sw = 335740932;
Modified: firebird/trunk/src/dsql/ExprNodes.cpp
===================================================================
--- firebird/trunk/src/dsql/ExprNodes.cpp 2014-12-16 17:33:28 UTC (rev 60372)
+++ firebird/trunk/src/dsql/ExprNodes.cpp 2014-12-16 19:12:18 UTC (rev 60373)
@@ -10913,6 +10913,11 @@
Arg::Gds(isc_random) << Arg::Str(name.toString()));
}
+ const USHORT arg_count = node->dsqlFunction->udf_arguments.getCount();
+ const USHORT count = node->args->items.getCount();
+ if (count > arg_count || count < arg_count - node->dsqlFunction->udf_def_count)
+ ERRD_post(Arg::Gds(isc_fun_param_mismatch) << Arg::Str(name.toString()));
+
for (NestConst<ValueExprNode>* ptr = node->args->items.begin();
ptr != node->args->items.end();
++ptr)
Modified: firebird/trunk/src/dsql/StmtNodes.cpp
===================================================================
--- firebird/trunk/src/dsql/StmtNodes.cpp 2014-12-16 17:33:28 UTC (rev 60372)
+++ firebird/trunk/src/dsql/StmtNodes.cpp 2014-12-16 19:12:18 UTC (rev 60373)
@@ -1357,7 +1357,7 @@
USHORT count = subFunc->getInputFormat() ? subFunc->getInputFormat()->fmt_count : 0;
if (subFunc->getInputFields().getCount() * 2 != count)
- PAR_error(csb, Arg::Gds(isc_prcmismat) << name);
+ PAR_error(csb, Arg::Gds(isc_fun_param_mismatch) << name);
for (USHORT i = 0; i < count; i += 2u)
{
Modified: firebird/trunk/src/dsql/dsql.h
===================================================================
--- firebird/trunk/src/dsql/dsql.h 2014-12-16 17:33:28 UTC (rev 60372)
+++ firebird/trunk/src/dsql/dsql.h 2014-12-16 19:12:18 UTC (rev 60373)
@@ -347,6 +347,7 @@
Firebird::QualifiedName udf_name;
Firebird::Array<dsc> udf_arguments;
bool udf_private; // Packaged private function
+ SSHORT udf_def_count; // number of inputs with default values
};
// udf_flags bits
Modified: firebird/trunk/src/dsql/metd.epp
===================================================================
--- firebird/trunk/src/dsql/metd.epp 2014-12-16 17:33:28 UTC (rev 60372)
+++ firebird/trunk/src/dsql/metd.epp 2014-12-16 19:12:18 UTC (rev 60373)
@@ -880,6 +880,8 @@
}
}
+ SSHORT defaults = 0;
+
AutoCacheRequest handle2(tdbb, irq_func_return, IRQ_REQUESTS);
FOR(REQUEST_HANDLE handle2 TRANSACTION_HANDLE transaction)
@@ -971,6 +973,12 @@
d.dsc_flags = DSC_nullable;
}
+ if (!X.RDB$DEFAULT_VALUE.NULL ||
+ (fb_utils::implicit_domain(F.RDB$FIELD_NAME) && !F.RDB$DEFAULT_VALUE.NULL))
+ {
+ defaults++;
+ }
+
userFunc->udf_arguments.add(d);
}
}
@@ -1038,12 +1046,19 @@
d.dsc_flags = DSC_nullable;
}
+ if (!X.RDB$DEFAULT_VALUE.NULL)
+ {
+ defaults++;
+ }
+
userFunc->udf_arguments.add(d);
}
}
}
END_FOR
+ userFunc->udf_def_count = defaults;
+
// Adjust the return type & length of the UDF to account for
// cstring & varying. While a UDF can return CSTRING, we convert it
// to VARCHAR for manipulation as CSTRING is not a SQL type.
Modified: firebird/trunk/src/include/gen/codetext.h
===================================================================
--- firebird/trunk/src/include/gen/codetext.h 2014-12-16 17:33:28 UTC (rev 60372)
+++ firebird/trunk/src/include/gen/codetext.h 2014-12-16 19:12:18 UTC (rev 60373)
@@ -802,6 +802,7 @@
{"crdb_nodb", 335545098},
{"crdb_notable", 335545099},
{"interface_version_too_old", 335545100},
+ {"fun_param_mismatch", 335545101},
{"gfix_db_name", 335740929},
{"gfix_invalid_sw", 335740930},
{"gfix_incmp_sw", 335740932},
Modified: firebird/trunk/src/include/gen/iberror.h
===================================================================
--- firebird/trunk/src/include/gen/iberror.h 2014-12-16 17:33:28 UTC (rev 60372)
+++ firebird/trunk/src/include/gen/iberror.h 2014-12-16 19:12:18 UTC (rev 60373)
@@ -836,6 +836,7 @@
const ISC_STATUS isc_crdb_nodb = 335545098L;
const ISC_STATUS isc_crdb_notable = 335545099L;
const ISC_STATUS isc_interface_version_too_old = 335545100L;
+const ISC_STATUS isc_fun_param_mismatch = 335545101L;
const ISC_STATUS isc_gfix_db_name = 335740929L;
const ISC_STATUS isc_gfix_invalid_sw = 335740930L;
const ISC_STATUS isc_gfix_incmp_sw = 335740932L;
@@ -1294,7 +1295,7 @@
const ISC_STATUS isc_trace_switch_param_miss = 337182758L;
const ISC_STATUS isc_trace_param_act_notcompat = 337182759L;
const ISC_STATUS isc_trace_mandatory_switch_miss = 337182760L;
-const ISC_STATUS isc_err_max = 1238;
+const ISC_STATUS isc_err_max = 1239;
#else /* c definitions */
@@ -2100,6 +2101,7 @@
#define isc_crdb_nodb 335545098L
#define isc_crdb_notable 335545099L
#define isc_interface_version_too_old 335545100L
+#define isc_fun_param_mismatch 335545101L
#define isc_gfix_db_name 335740929L
#define isc_gfix_invalid_sw 335740930L
#define isc_gfix_incmp_sw 335740932L
@@ -2558,7 +2560,7 @@
#define isc_trace_switch_param_miss 337182758L
#define isc_trace_param_act_notcompat 337182759L
#define isc_trace_mandatory_switch_miss 337182760L
-#define isc_err_max 1238
+#define isc_err_max 1239
#endif
Modified: firebird/trunk/src/include/gen/msgs.h
===================================================================
--- firebird/trunk/src/include/gen/msgs.h 2014-12-16 17:33:28 UTC (rev 60372)
+++ firebird/trunk/src/include/gen/msgs.h 2014-12-16 19:12:18 UTC (rev 60373)
@@ -805,6 +805,7 @@
{335545098, "CREATE DATABASE grants check is not possible when database @1 is not present"}, /* crdb_nodb */
{335545099, "CREATE DATABASE grants check is not possible when table RDB$DB_CREATORS is not present in database @1"}, /* crdb_notable */
{335545100, "Interface version too old: expected @1, found @2"}, /* interface_version_too_old */
+ {335545101, "Input parameter mismatch for function @1"}, /* fun_param_mismatch */
{335740929, "data base file name (@1) already given"}, /* gfix_db_name */
{335740930, "invalid switch @1"}, /* gfix_invalid_sw */
{335740932, "incompatible switch combination"}, /* gfix_incmp_sw */
Modified: firebird/trunk/src/include/gen/sql_code.h
===================================================================
--- firebird/trunk/src/include/gen/sql_code.h 2014-12-16 17:33:28 UTC (rev 60372)
+++ firebird/trunk/src/include/gen/sql_code.h 2014-12-16 19:12:18 UTC (rev 60373)
@@ -801,6 +801,7 @@
{335545098, -901}, /* 778 crdb_nodb */
{335545099, -901}, /* 779 crdb_notable */
{335545100, -804}, /* 780 interface_version_too_old */
+ {335545101, -170}, /* 781 fun_param_mismatch */
{335740929, -901}, /* 1 gfix_db_name */
{335740930, -901}, /* 2 gfix_invalid_sw */
{335740932, -901}, /* 4 gfix_incmp_sw */
Modified: firebird/trunk/src/include/gen/sql_state.h
===================================================================
--- firebird/trunk/src/include/gen/sql_state.h 2014-12-16 17:33:28 UTC (rev 60372)
+++ firebird/trunk/src/include/gen/sql_state.h 2014-12-16 19:12:18 UTC (rev 60373)
@@ -801,6 +801,7 @@
{335545098, "0A000"}, // 778 crdb_nodb
{335545099, "0A000"}, // 779 crdb_notable
{335545100, "HY000"}, // 780 interface_version_too_old
+ {335545101, "07001"}, // 781 fun_param_mismatch
{335740929, "00000"}, // 1 gfix_db_name
{335740930, "00000"}, // 2 gfix_invalid_sw
{335740932, "00000"}, // 4 gfix_incmp_sw
Modified: firebird/trunk/src/msgs/facilities2.sql
===================================================================
--- firebird/trunk/src/msgs/facilities2.sql 2014-12-16 17:33:28 UTC (rev 60372)
+++ firebird/trunk/src/msgs/facilities2.sql 2014-12-16 19:12:18 UTC (rev 60373)
@@ -1,7 +1,7 @@
/* MAX_NUMBER is the next number to be used, always one more than the highest message number. */
set bulk_insert INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUMBER) VALUES (?, ?, ?, ?);
--
-('2014-11-06 12:17:00', 'JRD', 0, 781)
+('2014-12-16 21:00:00', 'JRD', 0, 782)
('2012-01-23 20:10:30', 'QLI', 1, 532)
('2014-12-12 20:59:56', 'GFIX', 3, 132)
('1996-11-07 13:39:40', 'GPRE', 4, 1)
Modified: firebird/trunk/src/msgs/messages2.sql
===================================================================
--- firebird/trunk/src/msgs/messages2.sql 2014-12-16 17:33:28 UTC (rev 60372)
+++ firebird/trunk/src/msgs/messages2.sql 2014-12-16 19:12:18 UTC (rev 60373)
@@ -888,6 +888,7 @@
('crdb_nodb', 'DbCreatorsList::getList', 'DbCreators.cpp', NULL, 0, 778, NULL, 'CREATE DATABASE grants check is not possible when database @1 is not present', NULL, NULL);
('crdb_notable', 'DbCreatorsList::getList', 'DbCreators.cpp', NULL, 0, 779, NULL, 'CREATE DATABASE grants check is not possible when table RDB$DB_CREATORS is not present in database @1', NULL, NULL);
('interface_version_too_old', NULL, 'Interface.h', NULL, 0, 780, NULL, 'Interface version too old: expected @1, found @2', NULL, NULL);
+('fun_param_mismatch', 'UdfCallNode::dsqlPass', 'ExprNode.cpp', NULL, 0, 781, NULL, 'Input parameter mismatch for function @1', NULL, NULL);
-- QLI
(NULL, NULL, NULL, NULL, 1, 0, NULL, 'expected type', NULL, NULL);
(NULL, NULL, NULL, NULL, 1, 1, NULL, 'bad block type', NULL, NULL);
Modified: firebird/trunk/src/msgs/system_errors2.sql
===================================================================
--- firebird/trunk/src/msgs/system_errors2.sql 2014-12-16 17:33:28 UTC (rev 60372)
+++ firebird/trunk/src/msgs/system_errors2.sql 2014-12-16 19:12:18 UTC (rev 60373)
@@ -787,6 +787,7 @@
(-901, '0A', '000', 0, 778, 'crdb_nodb', NULL, NULL);
(-901, '0A', '000', 0, 779, 'crdb_notable', NULL, NULL);
(-804, 'HY', '000', 0, 780, 'interface_version_too_old', NULL, NULL)
+(-170, '07', '001', 0, 781, 'fun_param_mismatch', NULL, NULL)
-- GFIX
(-901, '00', '000', 3, 1, 'gfix_db_name', NULL, NULL)
(-901, '00', '000', 3, 2, 'gfix_invalid_sw', NULL, NULL)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|