⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 isql.e

📁 firebird源代码
💻 E
📖 第 1 页 / 共 5 页
字号:
    	ISQL_printf (Out, NEWLINE);	}    }else    {     /*      *	Need to remove the users password from connect string.  Step through     *	the string until you see the PASSWORD literal.  Save of the char,     *	NULL terminate the string and print.  Restore the char and move     *	on.     */			    connect_stmt = TRUE;    endpassword       = strstr (string, WISQL_PASSWORD_LITERAL);    if (endpassword)	 {	    	 length	      = strlen (WISQL_PASSWORD_LITERAL);    	 endpassword   = endpassword + length;    	 savechar      = *endpassword;    	 *endpassword  = NULL;	    	    	 /* add command to command history file */    	 ib_fprintf (sf, "%s %s %s%s", 		 string, 		 WISQL_PASSWORD_COMMENT_LITERAL, 		 Term, 		 NEWLINE);    	 ib_fflush (sf);    	 *endpassword   = savechar;	 }    }		ret     = (int) frontend (string);if (ret == SKIP)  ret  = 0;if (!connect_stmt)      ISQL_printf (Out, NEWLINE);return (ret);}#endifSSHORT ISQL_get_default_char_set_id (){/************************************* **	I S Q L _ g e t _ d e f a u l t _ c h a r _ s e t _ i d***************************************** Functional description*	Return the database default character set*	id.**	-1 if the value can not be determined.***************************************/SSHORT	default_char_set_id;/* What is the default character set for this database?   There are three states:   1.	There is no entry available in RDB$DATABASE	Then - NONE   2.   The entry in RDB$DATABASE does not exist in 	RDB$CHARACTER_SETS	Then - -1 to cause all character set defs to show   3.	An entry in RDB$CHARACTER_SETS	Then - RDB$CHARACTER_SET_ID*/default_char_set_id = 0;FOR FIRST 1 EXT IN RDB$DATABASE    WITH EXT.RDB$CHARACTER_SET_NAME NOT MISSING;    default_char_set_id = -1;    FOR FIRST 1 CHI IN RDB$CHARACTER_SETS    WITH CHI.RDB$CHARACTER_SET_NAME = EXT.RDB$CHARACTER_SET_NAME	default_char_set_id = CHI.RDB$CHARACTER_SET_ID;    END_FOR;END_FOR;return (default_char_set_id);}#ifdef GUI_TOOLSint ISQL_extract (    SCHAR	*string,    int  	type,    IB_FILE	*ipf,    IB_FILE	*opf,    IB_FILE	*sf){/************************************** * *	I S Q L _ e x t r a c t * ************************************** * * Functional description *	Process a extract command from Windows ISQL.   This sets up *	the input and output files, and executes the statement. * **************************************/int	ret;isc_tr_handle 	save_trans_handle;Out  	  = opf;Ifp  	  = ipf;Diag 	  = Out;Help 	  = Out;ret  	  = 0;strcpy (Target_db, Db_name);/*  *  Add command to command history file.  There is no way to perform an *  extract from an input script.  Will defer for now * *  ib_fprintf (sf, "%s%s%s \n\r", string, Term, NEWLINE); *  ib_fflush (sf); *//* Save off the transaction handle so we can set it to NULL */save_trans_handle  	= gds__trans;gds__trans 	   	= NULL;if (type == EXTRACT_VIEW)    {    ib_fprintf (sf, "/* Extract View %s%s */%s", string, Term, NEWLINE);    ib_fflush (sf);    ISQL_printf (Out, "/* Extract View ");    ISQL_printf (Out, string);    ISQL_printf (Out, " */");    ISQL_printf (Out, NEWLINE);    EXTRACT_list_view (string);    }else    {    if (type == EXTRACT_TABLE)	{    	ib_fprintf (sf, "/* Extract Table %s%s */%s", string, Term, NEWLINE);    	ib_fflush (sf);    	ISQL_printf (Out, "/* Extract Table ");    	ISQL_printf (Out, string);        ISQL_printf (Out, " */");    	ISQL_printf (Out, NEWLINE);	}    else        {    	ib_fprintf (sf, "/* Extract Database %s%s */%s", Db_name, Term, NEWLINE);    	ib_fflush (sf);    	ISQL_printf (Out, "/* Extract Database ");    	ISQL_printf (Out, Db_name);        ISQL_printf (Out, " */");    	ISQL_printf (Out, NEWLINE);   	}    ret     	= EXTRACT_ddl (type, string);    }if (ret == FINI_OK)    ret = 0;/* * Commit transaction that was started on behalf of the request  * Don't worry about the error if one occurs it will be network related * and caught later.*/if (gds__trans)    isc_rollback_transaction (isc_status, &gds__trans);/* Restore old tranasaction handle */gds__trans 	= save_trans_handle;ISQL_printf (Out, NEWLINE);return (ret);}#endif#ifdef GUI_TOOLSvoid ISQL_build_table_list (    void        **tbl_list,IB_FILE         *ipf,    IB_FILE         *opf,    IB_FILE         *sf){/************************************** * *      I S Q L _ b u i l d _ t a b l e _ l i s t * ************************************** * * Functional description *      Build a list of table names within the connected *      database. * **************************************/isc_tr_handle 	save_trans_handle;Out 		   = opf;Ifp 		   = ipf;Diag 		   = Out;Help 		   = Out;/* Transaction for all frontend commands */if (DB)    {    save_trans_handle  = gds__trans;    gds__trans 	   = NULL;    if (isc_start_transaction (isc_status, &gds__trans, 1, &DB, 0, (SCHAR*) 0))        ISQL_errmsg (isc_status);    else	{        SHOW_build_table_namelist (tbl_list);	/* 	 * Commit transaction that was started on behalf of the request  	 * Don't worry about the error if one occurs it will be network 	 * related and caught later.	 */    	isc_rollback_transaction (isc_status, &gds__trans);    	}    gds__trans = save_trans_handle;    }return;}#endif#ifdef GUI_TOOLSvoid ISQL_query_database (    SSHORT	*db_objects,    IB_FILE        *ipf,    IB_FILE        *opf,    IB_FILE        *sf){/************************************** * *      I S Q L _ q u e r y _ d a t a b a s e  * ************************************** * * Functional description *      Query the database to see if it has any  *	 objects defined. * **************************************/int		tables, views, indices;isc_tr_handle 	save_trans_handle;	Out 		   = opf;Ifp 		   = ipf;Diag 		   = Out;Help 		   = Out;tables             = 0;views              = 0;indices            = 0;ISQL_get_version (FALSE);/* * This should only be executed if we are connected to a V4 * database.  This query will return a list of SQL tables and * views that we use to instantiate our extract table/view list * box.*/if (V4)    {    /* Transaction for all frontend commands */    if (DB)        {    	save_trans_handle  = gds__trans;    	gds__trans         = NULL;        if (isc_start_transaction (isc_status,                                   &gds__trans,                                   1,                                   &DB,                                   0,                                   (SCHAR*) 0))            ISQL_errmsg (isc_status);	else	    {            /* Call SHOW_query_database to determine if the DB is empty */    	    SHOW_query_database (&tables, &views, &indices);	    /* 	     * Commit transaction that was started on behalf of the request  	     * Don't worry about the error if one occurs it will be network 	     * related and caught later.	     */    	    isc_rollback_transaction (isc_status, &gds__trans);    	    gds__trans = save_trans_handle;	    }        }    }/* Set up the flags for Windows ISQL */if (tables)    *db_objects |= TABLE_OBJECTS;else    if (*db_objects & TABLE_OBJECTS)        *db_objects ^= TABLE_OBJECTS;if (views)    *db_objects |= VIEW_OBJECTS;else    if (*db_objects & VIEW_OBJECTS)        *db_objects ^= VIEW_OBJECTS;return;}#endif#ifdef GUI_TOOLSvoid ISQL_build_view_list (    void        **view_list,    IB_FILE         *ipf,    IB_FILE         *opf,    IB_FILE         *sf){/************************************** * *      I S Q L _ b u i l d _ v i e w _ l i s t * ************************************** * * Functional description *      Build a list of view names within the connected *      database. * **************************************/isc_tr_handle 		save_trans_handle;Out 		   = opf;Ifp 		   = ipf;Diag 		   = Out;Help 		   = Out;/* Transaction for all frontend commands */if (DB)    {    save_trans_handle  	= gds__trans;    gds__trans 	   	= NULL;    if (isc_start_transaction (isc_status, &gds__trans, 1, &DB, 0, (SCHAR*) 0))        ISQL_errmsg (isc_status);    else	{    	SHOW_build_view_namelist (view_list);	/* 	 * Commit transaction that was started on behalf of the request  	 * Don't worry about the error if one occurs it will be network 	 * related and caught later.	 */    	isc_rollback_transaction (isc_status, &gds__trans);	}    gds__trans 		= save_trans_handle;    }return;}#endif#ifdef GUI_TOOLSint ISQL_create_database (    SCHAR        *create_stmt,    SCHAR	**database,    SCHAR	 *username,    SCHAR	 *password,	    IB_FILE         *ipf,    IB_FILE         *opf,    IB_FILE         *sf){/************************************** * *      I S Q L _ c r e a t e _ d a t a b a s e  * ************************************** * * Functional description *      Set up the global user & password  *	 fields.  Call frontend to create a database * **************************************/int		ret;Out 	= opf;Ifp 	= ipf;Diag 	= Out;Help 	= Out;/* add command to command history file */ib_fprintf (sf, "%s%s", create_stmt, NEWLINE);ib_fflush (sf);/*  * Set up the username and password for the frontend create * database statement.  Uncomment the following lines if you wish to surface * to the user, a create db statement in which the username and password are * not required.  They are remembered from the connect statement. * * strcpy (Password, password); * global_psw  = TRUE; * strcpy (User, username); * global_usr  = TRUE; */ret         = (int) frontend (create_stmt);/* * Copy the database name to the ISQL parameter block field pszDatabase. * Check for skip because that signifies that create_db processed the * create database statement.*/if (ret == SKIP)    {	    ret  = 0;    strcpy (*database, Db_name);    }		else    *database[0] = NULL;/*  * Reset user name and password so that the user has to re-enter valid ones. * Uncomment the following lines if you wish to allow the user to issue the * create db statement without specifing a username and password. * Password[0] = NULL; * global_psw  = FALSE; * User[0]     = NULL; * global_usr  = FALSE; */return (ret);}#endifSSHORT ISQL_get_field_length (    TEXT	*field_name){/************************************** * *	I S Q L _ g e t _ f i e l d _ l e n g t h * ************************************** * *	Retrieve character or field length of V4 character types. * **************************************/SSHORT l;/* Transaction for all frontend commands */if (DB && !gds__trans)    if (isc_start_transaction (isc_status, &gds__trans, 1, &DB, 0, (SCHAR*) 0))	{	ISQL_errmsg (isc_status);	return 0;	};if (V33)    {    FOR FLD IN RDB$FIELDS WITH	FLD.RDB$FIELD_NAME EQ field_name	l = FLD.RDB$FIELD_LENGTH;    END_FOR	ON_ERROR	    ISQL_errmsg (isc_status);	    return 0;	END_ERROR;    }else    {    FOR FLD IN RDB$FIELDS WITH	FLD.RDB$FIELD_NAME EQ field_name	if (FLD.RDB$CHARACTER_LENGTH.NULL)	    l = FLD.RDB$FIELD_LENGTH;	else 	    l = FLD.RDB$CHARACTER_LENGTH;    END_FOR	ON_ERROR	    ISQL_errmsg (isc_status);	    return 0;	END_ERROR;    }return l;}void ISQL_get_character_sets (    SSHORT	char_set_id,    SSHORT	collation,    USHORT	collate_only,    TEXT	*string){/************************************** * *	I S Q L _ g e t _ c h a r a c t e r _ s e t s * ************************************** * *	Retrieve character set and collation order and format it * **************************************/#ifdef	DEV_BUILDBOOLEAN	found = FALSE;#endifstring [0] = 0;/* Transaction for all frontend commands */if (DB && !gds__trans)    if (isc_start_transaction (isc_status, &gds__trans, 1, &DB, 0, (SCHAR*) 0))	{	ISQL_errmsg (isc_status);	return;	};if (!V33 && collation)    {    FOR FIRST 1 COL IN RDB$COLLATIONS CROSS 	CST IN RDB$CHARACTER_SETS WITH	COL.RDB$CHARACTER_SET_ID EQ CST.RDB$CHARACTER_SET_ID AND	COL.RDB$COLLATION_ID EQ collation AND	CST.RDB$CHARACTER_SET_ID EQ char_set_id	SORTED BY COL.RDB$COLLATION_NAME, CST.RDB$CHARACTER_SET_NAME#ifdef	DEV_BUILD	found = TRUE;#endif	ISQL_blankterm (CST.RDB$CHARACTER_SET_NAME);	ISQL_blankterm (COL.RDB$COLLATION_NAME);	ISQL_blankterm (CST.RDB$DEFAULT_COLLATE_NAME);	/* Is specified collation the default collation for character set? */	if (strcmp (CST.RDB$DEFAULT_COLLATE_NAME, COL.RDB$COLLATION_NAME) == 0)	    {	    if (!collate_only)		sprintf (string, " CHARACTER SET %s", CST.RDB$CHARACTER_SET_NAME);	    }	else if (collate_only)	    sprintf (string, " COLLATE %s", COL.RDB$COLLATION_NAME);	else 	    sprintf (string, " CHARACTER SET %s COLLATE %s",		CST.RDB$CHARACTER_SET_NAME, COL.RDB$COLLATION_NAME);    END_FOR	ON_ERROR	    ISQL_errmsg (isc_status);	    return;	END_ERROR;#ifdef DEV_BUILD    if (!found)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -