mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 16:43:03 +01:00
Improvement CORE-6239 - Procedures and EXECUTE BLOCK without RETURNS should not be allowed to use SUSPEND.
This commit is contained in:
parent
53e74d2aa4
commit
b2b5f9a87c
@ -435,7 +435,7 @@ CREATE TABLE sales
|
||||
CHECK (order_status in
|
||||
('new', 'open', 'shipped', 'waiting')),
|
||||
order_date TIMESTAMP
|
||||
DEFAULT 'NOW'
|
||||
DEFAULT 'NOW'
|
||||
NOT NULL,
|
||||
ship_date TIMESTAMP
|
||||
CHECK (ship_date >= order_date OR ship_date IS NULL),
|
||||
@ -494,7 +494,7 @@ COMMIT;
|
||||
/****************************************************************************
|
||||
*
|
||||
* Create stored procedures.
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
@ -541,7 +541,6 @@ BEGIN
|
||||
WHEN SQLCODE -530 DO
|
||||
EXCEPTION unknown_emp_id;
|
||||
END
|
||||
SUSPEND;
|
||||
END !!
|
||||
|
||||
|
||||
@ -605,7 +604,6 @@ BEGIN
|
||||
IF (any_sales > 0) THEN
|
||||
BEGIN
|
||||
EXCEPTION reassign_sales;
|
||||
SUSPEND;
|
||||
END
|
||||
|
||||
/*
|
||||
@ -639,8 +637,6 @@ BEGIN
|
||||
*/
|
||||
DELETE FROM employee
|
||||
WHERE emp_no = :emp_num;
|
||||
|
||||
SUSPEND;
|
||||
END !!
|
||||
|
||||
|
||||
@ -841,14 +837,12 @@ BEGIN
|
||||
IF (ord_stat = 'shipped') THEN
|
||||
BEGIN
|
||||
EXCEPTION order_already_shipped;
|
||||
SUSPEND;
|
||||
END
|
||||
|
||||
/* Customer is on hold. */
|
||||
ELSE IF (hold_stat = '*') THEN
|
||||
BEGIN
|
||||
EXCEPTION customer_on_hold;
|
||||
SUSPEND;
|
||||
END
|
||||
|
||||
/*
|
||||
@ -865,12 +859,6 @@ BEGIN
|
||||
DO
|
||||
BEGIN
|
||||
EXCEPTION customer_check;
|
||||
|
||||
UPDATE customer
|
||||
SET on_hold = '*'
|
||||
WHERE cust_no = :cust_no;
|
||||
|
||||
SUSPEND;
|
||||
END
|
||||
|
||||
/*
|
||||
@ -879,8 +867,6 @@ BEGIN
|
||||
UPDATE sales
|
||||
SET order_status = 'shipped', ship_date = 'NOW'
|
||||
WHERE po_number = :po_num;
|
||||
|
||||
SUSPEND;
|
||||
END !!
|
||||
|
||||
|
||||
@ -897,7 +883,7 @@ BEGIN
|
||||
AND (language_req IS NOT NULL))
|
||||
INTO :languages;
|
||||
IF (languages = ' ') THEN /* Prints 'NULL' instead of blanks */
|
||||
languages = 'NULL';
|
||||
languages = 'NULL';
|
||||
i = i +1;
|
||||
SUSPEND;
|
||||
END
|
||||
@ -905,16 +891,16 @@ END!!
|
||||
|
||||
|
||||
|
||||
CREATE PROCEDURE all_langs RETURNS
|
||||
(code VARCHAR(5), grade VARCHAR(5),
|
||||
CREATE PROCEDURE all_langs RETURNS
|
||||
(code VARCHAR(5), grade VARCHAR(5),
|
||||
country VARCHAR(15), LANG VARCHAR(15)) AS
|
||||
BEGIN
|
||||
FOR SELECT job_code, job_grade, job_country FROM job
|
||||
FOR SELECT job_code, job_grade, job_country FROM job
|
||||
INTO :code, :grade, :country
|
||||
|
||||
DO
|
||||
BEGIN
|
||||
FOR SELECT languages FROM show_langs
|
||||
FOR SELECT languages FROM show_langs
|
||||
(:code, :grade, :country) INTO :lang DO
|
||||
SUSPEND;
|
||||
/* Put nice separators between rows */
|
||||
|
@ -47,7 +47,7 @@ CREATE DOMAIN lastname AS VARCHAR(25) COLLATE FR_FR;
|
||||
|
||||
CREATE DOMAIN phonenumber AS VARCHAR(20);
|
||||
|
||||
CREATE DOMAIN countryname AS VARCHAR(15);
|
||||
CREATE DOMAIN countryname AS VARCHAR(15);
|
||||
|
||||
CREATE DOMAIN addressline AS VARCHAR(40);
|
||||
|
||||
@ -441,7 +441,7 @@ CREATE TABLE sales
|
||||
NOT NULL
|
||||
CHECK (order_status in
|
||||
('new', 'open', 'shipped', 'waiting')),
|
||||
order_date TIMESTAMP
|
||||
order_date TIMESTAMP
|
||||
DEFAULT 'NOW'
|
||||
NOT NULL,
|
||||
ship_date TIMESTAMP
|
||||
@ -501,7 +501,7 @@ COMMIT;
|
||||
/****************************************************************************
|
||||
*
|
||||
* Create stored procedures.
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
@ -548,7 +548,6 @@ BEGIN
|
||||
WHEN SQLCODE -530 DO
|
||||
EXCEPTION unknown_emp_id;
|
||||
END
|
||||
SUSPEND;
|
||||
END !!
|
||||
|
||||
|
||||
@ -612,7 +611,6 @@ BEGIN
|
||||
IF (any_sales > 0) THEN
|
||||
BEGIN
|
||||
EXCEPTION reassign_sales;
|
||||
SUSPEND;
|
||||
END
|
||||
|
||||
/*
|
||||
@ -646,8 +644,6 @@ BEGIN
|
||||
*/
|
||||
DELETE FROM employee
|
||||
WHERE emp_no = :emp_num;
|
||||
|
||||
SUSPEND;
|
||||
END !!
|
||||
|
||||
|
||||
@ -848,14 +844,12 @@ BEGIN
|
||||
IF (ord_stat = 'shipped') THEN
|
||||
BEGIN
|
||||
EXCEPTION order_already_shipped;
|
||||
SUSPEND;
|
||||
END
|
||||
|
||||
/* Customer is on hold. */
|
||||
ELSE IF (hold_stat = '*') THEN
|
||||
BEGIN
|
||||
EXCEPTION customer_on_hold;
|
||||
SUSPEND;
|
||||
END
|
||||
|
||||
/*
|
||||
@ -872,22 +866,14 @@ BEGIN
|
||||
DO
|
||||
BEGIN
|
||||
EXCEPTION customer_check;
|
||||
|
||||
UPDATE customer
|
||||
SET on_hold = '*'
|
||||
WHERE cust_no = :cust_no;
|
||||
|
||||
SUSPEND;
|
||||
END
|
||||
|
||||
/*
|
||||
* Ship the order.
|
||||
*/
|
||||
UPDATE sales
|
||||
SET order_status = 'shipped', ship_date = 'NOW'
|
||||
SET order_status = 'shipped', ship_date = 'NOW'
|
||||
WHERE po_number = :po_num;
|
||||
|
||||
SUSPEND;
|
||||
END !!
|
||||
|
||||
|
||||
@ -904,7 +890,7 @@ BEGIN
|
||||
AND (language_req IS NOT NULL))
|
||||
INTO :languages;
|
||||
IF (languages = ' ') THEN /* Prints 'NULL' instead of blanks */
|
||||
languages = 'NULL';
|
||||
languages = 'NULL';
|
||||
i = i +1;
|
||||
SUSPEND;
|
||||
END
|
||||
@ -912,16 +898,16 @@ END!!
|
||||
|
||||
|
||||
|
||||
CREATE PROCEDURE all_langs RETURNS
|
||||
(code VARCHAR(5), grade VARCHAR(5),
|
||||
CREATE PROCEDURE all_langs RETURNS
|
||||
(code VARCHAR(5), grade VARCHAR(5),
|
||||
country VARCHAR(15), LANG VARCHAR(15)) AS
|
||||
BEGIN
|
||||
FOR SELECT job_code, job_grade, job_country FROM job
|
||||
FOR SELECT job_code, job_grade, job_country FROM job
|
||||
INTO :code, :grade, :country
|
||||
|
||||
DO
|
||||
BEGIN
|
||||
FOR SELECT languages FROM show_langs
|
||||
FOR SELECT languages FROM show_langs
|
||||
(:code, :grade, :country) INTO :lang DO
|
||||
SUSPEND;
|
||||
/* Put nice separators between rows */
|
||||
@ -944,7 +930,7 @@ CREATE PROCEDURE FRENCH_CUST_SORT
|
||||
RETURNS (customer VARCHAR(40), city VARCHAR(25), country VARCHAR(15))
|
||||
AS
|
||||
BEGIN
|
||||
FOR SELECT customer, city, country
|
||||
FOR SELECT customer, city, country
|
||||
FROM customer ORDER BY customer
|
||||
INTO :customer, :city, :country
|
||||
DO
|
||||
@ -956,7 +942,7 @@ CREATE PROCEDURE GERMAN_CUST_SORT
|
||||
RETURNS (customer VARCHAR(40), city VARCHAR(25), country VARCHAR(15))
|
||||
AS
|
||||
BEGIN
|
||||
FOR SELECT customer, city, country
|
||||
FOR SELECT customer, city, country
|
||||
FROM customer ORDER BY customer COLLATE DE_DE
|
||||
INTO :customer, :city, :country
|
||||
DO
|
||||
@ -968,7 +954,7 @@ CREATE PROCEDURE NORWAY_CUST_SORT
|
||||
RETURNS (customer VARCHAR(40), city VARCHAR(25), country VARCHAR(15))
|
||||
AS
|
||||
BEGIN
|
||||
FOR SELECT customer, city, country
|
||||
FOR SELECT customer, city, country
|
||||
FROM customer ORDER BY customer COLLATE NO_NO
|
||||
INTO :customer, :city, :country
|
||||
DO
|
||||
|
@ -1940,6 +1940,8 @@ C --
|
||||
PARAMETER (GDS__cannot_read_new_blob = 335545263)
|
||||
INTEGER*4 GDS__dyn_no_create_priv
|
||||
PARAMETER (GDS__dyn_no_create_priv = 335545264)
|
||||
INTEGER*4 GDS__suspend_without_returns
|
||||
PARAMETER (GDS__suspend_without_returns = 335545265)
|
||||
INTEGER*4 GDS__gfix_db_name
|
||||
PARAMETER (GDS__gfix_db_name = 335740929)
|
||||
INTEGER*4 GDS__gfix_invalid_sw
|
||||
|
@ -1935,6 +1935,8 @@ const
|
||||
gds_cannot_read_new_blob = 335545263;
|
||||
isc_dyn_no_create_priv = 335545264;
|
||||
gds_dyn_no_create_priv = 335545264;
|
||||
isc_suspend_without_returns = 335545265;
|
||||
gds_suspend_without_returns = 335545265;
|
||||
isc_gfix_db_name = 335740929;
|
||||
gds_gfix_db_name = 335740929;
|
||||
isc_gfix_invalid_sw = 335740930;
|
||||
|
@ -7956,6 +7956,12 @@ SuspendNode* SuspendNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
|
||||
Arg::Gds(isc_random) << Arg::Str("SUSPEND"));
|
||||
}
|
||||
|
||||
if (dsqlScratch->outputVariables.isEmpty())
|
||||
{
|
||||
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
|
||||
Arg::Gds(isc_suspend_without_returns));
|
||||
}
|
||||
|
||||
if (dsqlScratch->flags & DsqlCompilerScratch::FLAG_IN_AUTO_TRANS_BLOCK) // autonomous transaction
|
||||
{
|
||||
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) <<
|
||||
|
@ -966,6 +966,7 @@ static const struct {
|
||||
{"cannot_update_old_blob", 335545262},
|
||||
{"cannot_read_new_blob", 335545263},
|
||||
{"dyn_no_create_priv", 335545264},
|
||||
{"suspend_without_returns", 335545265},
|
||||
{"gfix_db_name", 335740929},
|
||||
{"gfix_invalid_sw", 335740930},
|
||||
{"gfix_incmp_sw", 335740932},
|
||||
|
@ -1000,6 +1000,7 @@ const ISC_STATUS isc_bind_convert = 335545261L;
|
||||
const ISC_STATUS isc_cannot_update_old_blob = 335545262L;
|
||||
const ISC_STATUS isc_cannot_read_new_blob = 335545263L;
|
||||
const ISC_STATUS isc_dyn_no_create_priv = 335545264L;
|
||||
const ISC_STATUS isc_suspend_without_returns = 335545265L;
|
||||
const ISC_STATUS isc_gfix_db_name = 335740929L;
|
||||
const ISC_STATUS isc_gfix_invalid_sw = 335740930L;
|
||||
const ISC_STATUS isc_gfix_incmp_sw = 335740932L;
|
||||
@ -1490,7 +1491,7 @@ const ISC_STATUS isc_trace_switch_user_only = 337182757L;
|
||||
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 = 1434;
|
||||
const ISC_STATUS isc_err_max = 1435;
|
||||
|
||||
#else /* c definitions */
|
||||
|
||||
@ -2460,6 +2461,7 @@ const ISC_STATUS isc_err_max = 1434;
|
||||
#define isc_cannot_update_old_blob 335545262L
|
||||
#define isc_cannot_read_new_blob 335545263L
|
||||
#define isc_dyn_no_create_priv 335545264L
|
||||
#define isc_suspend_without_returns 335545265L
|
||||
#define isc_gfix_db_name 335740929L
|
||||
#define isc_gfix_invalid_sw 335740930L
|
||||
#define isc_gfix_incmp_sw 335740932L
|
||||
@ -2950,7 +2952,7 @@ const ISC_STATUS isc_err_max = 1434;
|
||||
#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 1434
|
||||
#define isc_err_max 1435
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -969,6 +969,7 @@ Data source : @4"}, /* eds_statement */
|
||||
{335545262, "cannot update old BLOB"}, /* cannot_update_old_blob */
|
||||
{335545263, "cannot read from new BLOB"}, /* cannot_read_new_blob */
|
||||
{335545264, "No permission for CREATE @1 operation"}, /* dyn_no_create_priv */
|
||||
{335545265, "SUSPEND could not be used without RETURNS clause in PROCEDURE or EXECUTE BLOCK"}, /* suspend_without_returns */
|
||||
{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 */
|
||||
|
@ -965,6 +965,7 @@ static const struct {
|
||||
{335545262, -402}, /* 942 cannot_update_old_blob */
|
||||
{335545263, -402}, /* 943 cannot_read_new_blob */
|
||||
{335545264, -901}, /* 944 dyn_no_create_priv */
|
||||
{335545265, -901}, /* 945 suspend_without_returns */
|
||||
{335740929, -901}, /* 1 gfix_db_name */
|
||||
{335740930, -901}, /* 2 gfix_invalid_sw */
|
||||
{335740932, -901}, /* 4 gfix_incmp_sw */
|
||||
|
@ -965,6 +965,7 @@ static const struct {
|
||||
{335545262, "42000"}, // 942 cannot_update_old_blob
|
||||
{335545263, "42000"}, // 943 cannot_read_new_blob
|
||||
{335545264, "42000"}, // 944 dyn_no_create_priv
|
||||
{335545265, "42000"}, // 945 suspend_without_returns
|
||||
{335740929, "00000"}, // 1 gfix_db_name
|
||||
{335740930, "00000"}, // 2 gfix_invalid_sw
|
||||
{335740932, "00000"}, // 4 gfix_incmp_sw
|
||||
|
@ -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 (?, ?, ?, ?);
|
||||
--
|
||||
('2019-12-19 12:10:00', 'JRD', 0, 945)
|
||||
('2020-02-04 12:10:00', 'JRD', 0, 946)
|
||||
('2015-03-17 18:33:00', 'QLI', 1, 533)
|
||||
('2018-03-17 12:00:00', 'GFIX', 3, 136)
|
||||
('1996-11-07 13:39:40', 'GPRE', 4, 1)
|
||||
|
@ -1052,6 +1052,7 @@ Data source : @4', NULL, NULL)
|
||||
('cannot_update_old_blob', 'BLB_put_segment', 'blb.cpp', NULL, 0, 942, NULL, 'cannot update old BLOB', NULL, NULL);
|
||||
('cannot_read_new_blob', 'BLB_get_segment', 'blb.cpp', NULL, 0, 943, NULL, 'cannot read from new BLOB', NULL, NULL);
|
||||
('dyn_no_create_priv', NULL, 'scl.epp', NULL, 0, 944, NULL, 'No permission for CREATE @1 operation', NULL, NULL);
|
||||
('suspend_without_returns', NULL, 'StmtNodes.cpp', NULL, 0, 945, NULL, 'SUSPEND could not be used without RETURNS clause in PROCEDURE or EXECUTE BLOCK', 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);
|
||||
|
@ -951,6 +951,7 @@ set bulk_insert INSERT INTO SYSTEM_ERRORS (SQL_CODE, SQL_CLASS, SQL_SUBCLASS, FA
|
||||
(-402, '42', '000', 0, 942, 'cannot_update_old_blob', NULL, NULL)
|
||||
(-402, '42', '000', 0, 943, 'cannot_read_new_blob', NULL, NULL)
|
||||
(-901, '42', '000', 0, 944, 'dyn_no_create_priv', NULL, NULL)
|
||||
(-901, '42', '000', 0, 945, 'suspend_without_returns', NULL, NULL)
|
||||
-- GFIX
|
||||
(-901, '00', '000', 3, 1, 'gfix_db_name', NULL, NULL)
|
||||
(-901, '00', '000', 3, 2, 'gfix_invalid_sw', NULL, NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user