8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 21:23:04 +01:00

ALTER EXTERNAL FUNCTION: be able to change the entry_point or the module_name when the UDF cannot be dropped to correct the declaration because it's used in some view, procedure, trigger or check.

This commit is contained in:
robocop 2005-05-22 02:42:17 +00:00
parent c046acc77d
commit b490df3a41
6 changed files with 3142 additions and 3086 deletions

View File

@ -154,6 +154,7 @@ static void modify_privilege(dsql_req*, NOD_TYPE, SSHORT, const UCHAR*,
static SCHAR modify_privileges(dsql_req*, NOD_TYPE, SSHORT, const dsql_nod*, static SCHAR modify_privileges(dsql_req*, NOD_TYPE, SSHORT, const dsql_nod*,
const dsql_nod*, const dsql_nod*); const dsql_nod*, const dsql_nod*);
static void modify_relation(dsql_req*); static void modify_relation(dsql_req*);
static void modify_udf(dsql_req*);
static dsql_par* parameter_reverse_order(dsql_par* parameter, dsql_par* prev); static dsql_par* parameter_reverse_order(dsql_par* parameter, dsql_par* prev);
static void process_role_nm_list(dsql_req*, SSHORT, dsql_nod*, dsql_nod*, NOD_TYPE); static void process_role_nm_list(dsql_req*, SSHORT, dsql_nod*, dsql_nod*, NOD_TYPE);
static void put_descriptor(dsql_req*, const dsc*); static void put_descriptor(dsql_req*, const dsc*);
@ -4385,6 +4386,11 @@ static void generate_dyn( dsql_req* request, dsql_nod* node)
case nod_comment: case nod_comment:
make_comment(request); make_comment(request);
break;
case nod_mod_udf:
modify_udf(request);
break;
default: // CVC: Shouldn't we complain here? default: // CVC: Shouldn't we complain here?
break; break;
@ -4461,9 +4467,9 @@ static void grant_revoke( dsql_req* request)
} }
// ******************************* // ***********************
// m a k e _ c o m m e n t // m a k e _ c o m m e n t
// ******************************* // ***********************
// Set the description blob for objects' self documentation. // Set the description blob for objects' self documentation.
// This query // This query
// select rdb$relation_name from rdb$relation_fields where rdb$field_name = 'RDB$DESCRIPTION'; // select rdb$relation_name from rdb$relation_fields where rdb$field_name = 'RDB$DESCRIPTION';
@ -4922,7 +4928,7 @@ static void modify_domain( dsql_req* request)
{ {
case nod_def_default: case nod_def_default:
check_one_call (repetition_count, 0, "DOMAIN DEFAULT"); check_one_call (repetition_count, 0, "DOMAIN DEFAULT");
/* CVC: So do you want to crash me with ALTER DOMAIN dom SET; ??? */ // CVC: So do you want to crash me with ALTER DOMAIN dom SET; ???
if (!element->nod_arg[e_dft_default]) if (!element->nod_arg[e_dft_default])
{ {
ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -104, ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -104,
@ -5390,6 +5396,35 @@ static void modify_relation( dsql_req* request)
} }
// *******************
// m o d i f y _ u d f
// *******************
// Allow the user to change the entry point or module name.
// Useful when there are dependencies on the udf, so it cannot be dropped.
static void modify_udf(dsql_req* request)
{
const dsql_nod* node = request->req_ddl_node;
fb_assert(node->nod_type == nod_mod_udf);
if (!node->nod_arg[e_mod_udf_entry_pt] && !node->nod_arg[e_mod_udf_module])
ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -104,
isc_arg_gds, isc_command_end_err, // Unexpected end of command
0);
const dsql_str* obj_name = (dsql_str*) node->nod_arg[e_mod_udf_name];
request->append_cstring(isc_dyn_mod_function, obj_name->str_data);
const dsql_str* entry_point_name = (dsql_str*) node->nod_arg[e_mod_udf_entry_pt];
if (entry_point_name)
request->append_cstring(isc_dyn_func_entry_point, entry_point_name->str_data);
const dsql_str* module_name = (dsql_str*) node->nod_arg[e_mod_udf_module];
if (module_name)
request->append_cstring(isc_dyn_func_module_name, module_name->str_data);
request->append_uchar(isc_dyn_end);
}
static dsql_par* parameter_reverse_order(dsql_par* parameter, dsql_par* prev) static dsql_par* parameter_reverse_order(dsql_par* parameter, dsql_par* prev)
{ {
/************************************** /**************************************

View File

@ -2423,32 +2423,6 @@ void DSQL_pretty(const dsql_nod* node, int column)
case nod_file_desc: case nod_file_desc:
verb = "file_desc"; verb = "file_desc";
break; break;
/*
case nod_log_file_desc:
verb = "log_file_desc";
break;
case nod_cache_file_desc:
verb = "cache_file_desc";
break;
case nod_group_commit_wait:
verb = "group_commit_wait";
break;
case nod_check_point_len:
verb = "check_point_len";
break;
case nod_num_log_buffers:
verb = "num_log_buffers";
break;
case nod_log_buffer_size:
verb = "log_buffer_size";
break;
case nod_drop_log:
verb = "drop_log";
break;
case nod_drop_cache:
verb = "drop_cache";
break;
*/
case nod_dfl_charset: case nod_dfl_charset:
verb = "dfl_charset"; verb = "dfl_charset";
break; break;
@ -2740,6 +2714,10 @@ void DSQL_pretty(const dsql_nod* node, int column)
verb = "comment"; verb = "comment";
break; break;
case nod_mod_udf:
verb = "mod_udf";
break;
default: default:
sprintf(s, "unknown type %d", node->nod_type); sprintf(s, "unknown type %d", node->nod_type);
verb = s; verb = s;

View File

@ -225,14 +225,6 @@ enum nod_t
nod_page_size, nod_page_size,
nod_file_length, nod_file_length,
nod_file_desc, nod_file_desc,
//nod_log_file_desc,
//nod_cache_file_desc,
//nod_group_commit_wait,
//nod_check_point_len,
//nod_num_log_buffers,
//nod_log_buffer_size,
//nod_drop_log,
//nod_drop_cache,
nod_dfl_charset, nod_dfl_charset,
// sql connect options support (used for create database) // sql connect options support (used for create database)
nod_password, nod_password,
@ -334,10 +326,11 @@ enum nod_t
nod_param_val, // default value for SP parameters support nod_param_val, // default value for SP parameters support
nod_rows, // ROWS support nod_rows, // ROWS support
nod_query_spec, nod_query_spec,
nod_equiv, nod_equiv, // IS DISTINCT FROM
nod_redef_exception, // RECREATE EXCEPTION nod_redef_exception, // RECREATE EXCEPTION
nod_replace_exception, // CREATE OR ALTER EXCEPTION nod_replace_exception, // CREATE OR ALTER EXCEPTION
nod_comment nod_comment,
nod_mod_udf
}; };
typedef nod_t NOD_TYPE; typedef nod_t NOD_TYPE;
@ -928,7 +921,12 @@ enum node_args {
e_comment_object, e_comment_object,
e_comment_part, e_comment_part,
e_comment_string, e_comment_string,
e_comment_count e_comment_count,
e_mod_udf_name = 0,
e_mod_udf_entry_pt,
e_mod_udf_module,
e_mod_udf_count
}; };
#endif // DSQL_NODE_H #endif // DSQL_NODE_H

File diff suppressed because it is too large Load Diff

View File

@ -1913,10 +1913,11 @@ alter_clause : EXCEPTION alter_exception_clause
{ $$ = make_node (nod_mod_domain, (int) e_alt_count, { $$ = make_node (nod_mod_domain, (int) e_alt_count,
$2, make_list ($3)); } $2, make_list ($3)); }
| INDEX alter_index_clause | INDEX alter_index_clause
{ $$ = make_node (nod_mod_index, { $$ = make_node (nod_mod_index, (int) e_mod_idx_count, $2); }
(int) e_mod_idx_count, $2); }
| SEQUENCE alter_sequence_clause | SEQUENCE alter_sequence_clause
{ $$ = $2; } { $$ = $2; }
| EXTERNAL FUNCTION alter_udf_clause
{ $$ = $3; }
; ;
domain_default_opt2 : DEFAULT begin_trigger default_value domain_default_opt2 : DEFAULT begin_trigger default_value
@ -2071,6 +2072,22 @@ alter_sequence_clause : symbol_generator_name RESTART WITH signed_long_integer
make_node(nod_negate, 1, MAKE_constant((dsql_str*) $5, CONSTANT_SINT64))); } make_node(nod_negate, 1, MAKE_constant((dsql_str*) $5, CONSTANT_SINT64))); }
; ;
alter_udf_clause : symbol_UDF_name entry_op module_op
{ $$ = make_node(nod_mod_udf, e_mod_udf_count, $1, $2, $3); }
;
entry_op : ENTRY_POINT sql_string
{ $$ = $2; }
|
{ $$ = NULL; }
;
module_op : MODULE_NAME sql_string
{ $$ = $2; }
|
{ $$ = NULL; }
;
/* ALTER DATABASE */ /* ALTER DATABASE */

View File

@ -1104,6 +1104,7 @@ dsql_nod* PASS1_statement(dsql_req* request, dsql_nod* input, bool proc_flag)
case nod_del_shadow: case nod_del_shadow:
case nod_set_statistics: case nod_set_statistics:
case nod_comment: case nod_comment:
case nod_mod_udf:
request->req_type = REQ_DDL; request->req_type = REQ_DDL;
return input; return input;