mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 02:43:03 +01:00
Continue package support in isql.
This commit is contained in:
parent
6307f2d454
commit
79931e1285
@ -82,12 +82,14 @@ static void list_collations();
|
||||
static void list_create_db();
|
||||
static void list_domain_table(const SCHAR*, SSHORT);
|
||||
static void list_domains(SSHORT);
|
||||
static void list_exception();
|
||||
static void list_exceptions();
|
||||
static void list_filters();
|
||||
static void list_foreign();
|
||||
static void list_functions();
|
||||
static void list_generators();
|
||||
static void list_index();
|
||||
static void list_indexes();
|
||||
static void list_package_bodies();
|
||||
static void list_package_headers();
|
||||
static void list_views();
|
||||
|
||||
extern const char* trigger_action(int);
|
||||
@ -185,13 +187,15 @@ int EXTRACT_ddl(LegacyTables flag, const SCHAR* tabname)
|
||||
list_functions();
|
||||
list_generators();
|
||||
list_domains(default_char_set_id);
|
||||
list_package_headers();
|
||||
list_all_tables(flag, default_char_set_id);
|
||||
list_index();
|
||||
list_indexes();
|
||||
list_foreign();
|
||||
list_views();
|
||||
list_check();
|
||||
list_exception();
|
||||
list_exceptions();
|
||||
list_all_procs();
|
||||
list_package_bodies();
|
||||
list_all_triggers();
|
||||
list_all_grants();
|
||||
SHOW_comments(false); // Let's make this an option later.
|
||||
@ -1529,7 +1533,7 @@ static void print_proc_prefix()
|
||||
|
||||
static void print_proc_suffix()
|
||||
{
|
||||
isqlGlob.printf("SET TERM %s %s%s", isqlGlob.global_Term, Procterm, NEWLINE);
|
||||
isqlGlob.printf("%sSET TERM %s %s%s", NEWLINE, isqlGlob.global_Term, Procterm, NEWLINE);
|
||||
isqlGlob.printf("COMMIT WORK %s%s", isqlGlob.global_Term, NEWLINE);
|
||||
isqlGlob.printf("SET AUTODDL ON;%s", NEWLINE);
|
||||
}
|
||||
@ -1654,6 +1658,8 @@ static void list_all_procs_ods12()
|
||||
|
||||
static void list_all_procs_legacy()
|
||||
{
|
||||
fb_assert(isqlGlob.major_ods < ODS_VERSION12);
|
||||
|
||||
bool header = true;
|
||||
static const char* const create_procedure = "CREATE PROCEDURE %s ";
|
||||
static const char* const body_execut_proc = "BEGIN EXIT; END %s%s";
|
||||
@ -2680,11 +2686,11 @@ static void list_domains(SSHORT default_char_set_id)
|
||||
}
|
||||
|
||||
|
||||
static void list_exception()
|
||||
static void list_exceptions()
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
* l i s t _ e x c e p t i o n
|
||||
* l i s t _ e x c e p t i o n s
|
||||
*
|
||||
**************************************
|
||||
*
|
||||
@ -3125,7 +3131,7 @@ static void list_generators()
|
||||
}
|
||||
|
||||
|
||||
static void list_index()
|
||||
static void list_indexes()
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -3200,6 +3206,109 @@ static void list_index()
|
||||
}
|
||||
|
||||
|
||||
static void list_package_bodies()
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
* l i s t _ p a c k a g e _ b o d i e s
|
||||
*
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
* Create body of packages
|
||||
* Use a SQL query to get the info and print it.
|
||||
* Ignore the packages whose body has not been defined yet.
|
||||
*
|
||||
**************************************/
|
||||
|
||||
if (isqlGlob.major_ods < ODS_VERSION12)
|
||||
return;
|
||||
|
||||
FOR PACK IN RDB$PACKAGES WITH
|
||||
(PACK.RDB$SYSTEM_FLAG NE 1 OR PACK.RDB$SYSTEM_FLAG MISSING)
|
||||
AND PACK.RDB$PACKAGE_BODY_SOURCE NOT MISSING
|
||||
SORTED BY PACK.RDB$PACKAGE_NAME
|
||||
|
||||
fb_utils::exact_name(PACK.RDB$PACKAGE_NAME);
|
||||
|
||||
if (isqlGlob.db_SQL_dialect > SQL_DIALECT_V6_TRANSITION)
|
||||
IUTILS_copy_SQL_id (PACK.RDB$PACKAGE_NAME, SQL_identifier, DBL_QUOTE);
|
||||
else
|
||||
strcpy (SQL_identifier, PACK.RDB$PACKAGE_NAME);
|
||||
|
||||
fb_utils::exact_name(PACK.RDB$OWNER_NAME);
|
||||
|
||||
isqlGlob.printf("%s/* Package body: %s, Owner: %s */%s",
|
||||
NEWLINE,
|
||||
PACK.RDB$PACKAGE_NAME,
|
||||
PACK.RDB$OWNER_NAME,
|
||||
NEWLINE);
|
||||
isqlGlob.printf("CREATE PACKAGE BODY %s AS%s", SQL_identifier, NEWLINE);
|
||||
|
||||
SHOW_print_metadata_text_blob (isqlGlob.Out, &PACK.RDB$PACKAGE_BODY_SOURCE);
|
||||
|
||||
isqlGlob.printf("%s%s", isqlGlob.global_Term, NEWLINE);
|
||||
|
||||
END_FOR
|
||||
ON_ERROR
|
||||
ISQL_errmsg(gds_status);
|
||||
return;
|
||||
END_ERROR;
|
||||
}
|
||||
|
||||
|
||||
static void list_package_headers()
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
* l i s t _ p a c k a g e _ h e a d e r s
|
||||
*
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
* Show header of packages
|
||||
* Use a SQL query to get the info and print it.
|
||||
*
|
||||
**************************************/
|
||||
|
||||
if (isqlGlob.major_ods < ODS_VERSION12)
|
||||
return;
|
||||
|
||||
FOR PACK IN RDB$PACKAGES WITH
|
||||
(PACK.RDB$SYSTEM_FLAG NE 1 OR PACK.RDB$SYSTEM_FLAG MISSING)
|
||||
SORTED BY PACK.RDB$PACKAGE_NAME
|
||||
|
||||
fb_utils::exact_name(PACK.RDB$PACKAGE_NAME);
|
||||
|
||||
if (isqlGlob.db_SQL_dialect > SQL_DIALECT_V6_TRANSITION)
|
||||
IUTILS_copy_SQL_id (PACK.RDB$PACKAGE_NAME, SQL_identifier, DBL_QUOTE);
|
||||
else
|
||||
strcpy (SQL_identifier, PACK.RDB$PACKAGE_NAME);
|
||||
|
||||
fb_utils::exact_name(PACK.RDB$OWNER_NAME);
|
||||
|
||||
isqlGlob.printf("%s/* Package header: %s, Owner: %s */%s",
|
||||
NEWLINE,
|
||||
PACK.RDB$PACKAGE_NAME,
|
||||
PACK.RDB$OWNER_NAME,
|
||||
NEWLINE);
|
||||
isqlGlob.printf("CREATE PACKAGE %s AS%s", SQL_identifier, NEWLINE);
|
||||
|
||||
if (!PACK.RDB$PACKAGE_HEADER_SOURCE.NULL)
|
||||
SHOW_print_metadata_text_blob (isqlGlob.Out, &PACK.RDB$PACKAGE_HEADER_SOURCE);
|
||||
else
|
||||
isqlGlob.printf("BEGIN END /* Missing package header info. */");
|
||||
|
||||
isqlGlob.printf("%s%s", isqlGlob.global_Term, NEWLINE);
|
||||
|
||||
END_FOR
|
||||
ON_ERROR
|
||||
ISQL_errmsg(gds_status);
|
||||
return;
|
||||
END_ERROR;
|
||||
}
|
||||
|
||||
|
||||
static void list_views()
|
||||
{
|
||||
/**************************************
|
||||
@ -3209,13 +3318,13 @@ static void list_views()
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
* Show text of views.
|
||||
* Create text of views.
|
||||
* Use a SQL query to get the info and print it.
|
||||
* Note: This should also contain check option
|
||||
*
|
||||
**************************************/
|
||||
|
||||
// If this is a view, use print_blob to print the view text
|
||||
// If this is a view, use print_blob to print the view text
|
||||
|
||||
FOR REL IN RDB$RELATIONS WITH
|
||||
(REL.RDB$SYSTEM_FLAG NE 1 OR REL.RDB$SYSTEM_FLAG MISSING) AND
|
||||
@ -3223,7 +3332,6 @@ static void list_views()
|
||||
REL.RDB$FLAGS = REL_sql
|
||||
SORTED BY REL.RDB$RELATION_ID
|
||||
|
||||
bool first = true;
|
||||
fb_utils::exact_name(REL.RDB$RELATION_NAME);
|
||||
|
||||
if (isqlGlob.db_SQL_dialect > SQL_DIALECT_V6_TRANSITION)
|
||||
@ -3240,6 +3348,7 @@ static void list_views()
|
||||
NEWLINE);
|
||||
isqlGlob.printf("CREATE VIEW %s (", SQL_identifier);
|
||||
|
||||
bool first = true;
|
||||
// Get column list
|
||||
FOR RFR IN RDB$RELATION_FIELDS WITH
|
||||
RFR.RDB$RELATION_NAME = REL.RDB$RELATION_NAME
|
||||
|
@ -2803,7 +2803,6 @@ static processing_state show_dependencies(const char* object)
|
||||
static processing_state show_dependencies(const char* object, int obj_type)
|
||||
{
|
||||
bool missing1 = true;
|
||||
bool target_done = false;
|
||||
|
||||
FOR DEP1 IN RDB$DEPENDENCIES
|
||||
WITH DEP1.RDB$DEPENDED_ON_NAME EQ object AND
|
||||
@ -2828,6 +2827,7 @@ static processing_state show_dependencies(const char* object, int obj_type)
|
||||
return ps_ERR;
|
||||
END_ERROR;
|
||||
|
||||
bool target_done = false;
|
||||
if (!missing1)
|
||||
{
|
||||
const char* type_name = Object_types[obj_type];
|
||||
@ -2870,7 +2870,6 @@ static processing_state show_dependencies(const char* object, int obj_type)
|
||||
return ps_ERR;
|
||||
END_ERROR;
|
||||
|
||||
bool missing3 = true;
|
||||
bool is_table = false;
|
||||
|
||||
FOR REL IN RDB$RELATIONS
|
||||
@ -2884,6 +2883,7 @@ static processing_state show_dependencies(const char* object, int obj_type)
|
||||
return ps_ERR;
|
||||
END_ERROR;
|
||||
|
||||
bool missing3 = true;
|
||||
if (obj_type == obj_relation && is_table || obj_type == obj_view && !is_table)
|
||||
{
|
||||
FOR RFR IN RDB$RELATION_FIELDS
|
||||
@ -3796,7 +3796,7 @@ static processing_state show_packages(const SCHAR* package_name)
|
||||
bool odd = true;
|
||||
// List all package names in columns
|
||||
FOR PACK IN RDB$PACKAGES WITH
|
||||
PACK.RDB$SYSTEM_FLAG NE 1
|
||||
(PACK.RDB$SYSTEM_FLAG NE 1 OR PACK.RDB$SYSTEM_FLAG MISSING)
|
||||
SORTED BY PACK.RDB$PACKAGE_NAME
|
||||
|
||||
first = false;
|
||||
@ -3830,6 +3830,8 @@ static processing_state show_packages(const SCHAR* package_name)
|
||||
SHOW_print_metadata_text_blob (isqlGlob.Out, &PACK.RDB$PACKAGE_HEADER_SOURCE);
|
||||
isqlGlob.printf(NEWLINE);
|
||||
}
|
||||
else
|
||||
isqlGlob.printf("Missing package header source.%s", NEWLINE);
|
||||
|
||||
if (!PACK.RDB$PACKAGE_BODY_SOURCE.NULL)
|
||||
{
|
||||
|
@ -24,7 +24,7 @@ set bulk_insert INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUM
|
||||
--
|
||||
--('1996-11-07 13:38:43', 'GJRN', 16, 241)
|
||||
--
|
||||
('2009-11-12 04:30:19', 'ISQL', 17, 173)
|
||||
('2009-11-13 08:37:53', 'ISQL', 17, 173)
|
||||
('2009-06-25 05:05:43', 'GSEC', 18, 102)
|
||||
('2002-03-05 02:30:12', 'LICENSE', 19, 60)
|
||||
('2002-03-05 02:31:54', 'DOS', 20, 74)
|
||||
|
@ -1252,6 +1252,8 @@ Fetches = !f', NULL, NULL, 'c_pg');
|
||||
(1243, 'asfernandes', '2009-10-20 12:21:00', 0, 503, 'Cannot use an aggregate function in a GROUP BY clause', NULL, NULL, 'c_pg')
|
||||
(1244, 'asfernandes', '2009-10-20 12:21:20', 0, 506, 'Nested aggregate functions are not allowed', NULL, NULL, 'c_pg')
|
||||
(1245, 'cvc', '2009-11-06 08:26:40', 12, 44, 'Expected backup version 1..9. Found @1', NULL, NULL, 'c_pg')
|
||||
(1246, 'cvc', '2009-11-13 05:37:37', 17, 64, ' GENERATOR, GRANT, INDEX, PROCEDURE, ROLE, SQL DIALECT, SYSTEM,', NULL, NULL, 'c_pg')
|
||||
(1247, 'cvc', '2009-11-13 08:37:53', 17, 102, ' TABLE, TRIGGER, VERSION, USERS, VIEW', NULL, NULL, 'c_pg')
|
||||
stop
|
||||
|
||||
COMMIT WORK;
|
||||
|
@ -3002,7 +3002,7 @@ Fetches = !f', NULL, NULL);
|
||||
('HLP_EDIT2', 'help', 'isql.e', NULL, 17, 61, NULL, 'EDIT -- edit current command buffer and execute', NULL, NULL);
|
||||
('HLP_OUTPUT2', 'help', 'isql.e', NULL, 17, 62, NULL, 'OUTput -- return output to stdout', NULL, NULL);
|
||||
('HLP_SETNAMES', 'help', 'isql.e', NULL, 17, 63, NULL, ' SET NAMES <csname> -- set name of runtime character set', NULL, NULL);
|
||||
('HLP_OBJTYPE2', 'help', 'isql.e', NULL, 17, 64, NULL, ' GENERATOR, GRANT, INDEX, PROCEDURE, ROLE, SQL DIALECT, SYSTEM,', NULL, NULL);
|
||||
('HLP_OBJTYPE2', 'help', 'isql.e', NULL, 17, 64, NULL, ' GENERATOR, GRANT, INDEX, PACKAGE, PROCEDURE, ROLE, SQL DIALECT,', NULL, NULL);
|
||||
('HLP_SETBLOB2', 'help', '65', NULL, 17, 65, NULL, ' SET BLOB -- turn off BLOB display', NULL, NULL);
|
||||
('HLP_SET_ROOT', 'help', 'isql.e', NULL, 17, 66, NULL, 'SET <option> -- (Use HELP SET for complete list)', NULL, NULL);
|
||||
('NO_TABLES', 'SHOW_metadata', 'show.e', NULL, 17, 67, NULL, 'There are no tables in this database', NULL, NULL);
|
||||
@ -3041,7 +3041,7 @@ Fetches = !f', NULL, NULL);
|
||||
('NO_GRANT_ON_ROL', 'SHOW_metadata', 'show.e', NULL, 17, 97, NULL, 'There is no membership privilege granted on @1 in this database', NULL, NULL);
|
||||
('UNEXPECTED_EOF', 'do_isql', 'isql.e', NULL, 17, 98, NULL, 'Expected end of statement, encountered EOF', NULL, NULL);
|
||||
('TIME_ERR', 'add_row()', 'isql.e', NULL, 17, 101, NULL, 'Bad TIME: @1', NULL, NULL);
|
||||
('HLP_OBJTYPE3', 'help', 'isql.epp', NULL, 17, 102, NULL, ' TABLE, TRIGGER, VERSION, USERS, VIEW', NULL, NULL);
|
||||
('HLP_OBJTYPE3', 'help', 'isql.epp', NULL, 17, 102, NULL, ' SYSTEM, TABLE, TRIGGER, VERSION, USERS, VIEW', NULL, NULL);
|
||||
(NULL, 'SHOW_metadata', 'show.e', NULL, 17, 103, NULL, 'There is no role @1 in this database', NULL, NULL);
|
||||
('USAGE_BAIL', 'ISQL_main', 'isql.epp', NULL, 17, 104, NULL, ' -b(ail) bail on errors (set bail on)', NULL, NULL);
|
||||
(NULL, 'create_db', 'isql.e', NULL, 17, 105, NULL, 'Incomplete string in @1', NULL, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user