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

📄 isql.e

📁 firebird源代码
💻 E
📖 第 1 页 / 共 5 页
字号:
	{	sprintf (Print_buffer, "ISQL_get_character_set: charset %d collation %d not found.\n", char_set_id, collation);	STDERROUT (Print_buffer, 1);	}#endif    }else if (!V33)    {    FOR FIRST 1 CST IN RDB$CHARACTER_SETS WITH	CST.RDB$CHARACTER_SET_ID EQ char_set_id	SORTED BY CST.RDB$CHARACTER_SET_NAME#ifdef DEV_BUILD	found = TRUE;#endif	ISQL_blankterm (CST.RDB$CHARACTER_SET_NAME);	sprintf (string, " CHARACTER SET %s", CST.RDB$CHARACTER_SET_NAME);    END_FOR	ON_ERROR	    ISQL_errmsg (isc_status);	    return;	END_ERROR;#ifdef DEV_BUILD    if (!found)	{	sprintf (Print_buffer, "ISQL_get_character_set: charset %d not found.\n", char_set_id);	STDERROUT (Print_buffer, 1);	}#endif    }}void ISQL_get_default_source (    TEXT	*rel_name,    TEXT	*field_name,    ISC_QUAD	*blob_id){/************************************** * *	I S Q L _ g e t _ d e f a u l t _ s o u r c e * ************************************** * *	Retrieve the default source of a field. *	Relation_fields takes precedence over fields if both *	are present * *	For a domain, a NULL is passed for rel_name **************************************/ISQL_blankterm (field_name);*blob_id = isc_blob_null;/* 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 (rel_name)    {    /* This is default for a column of a table */    FOR FLD IN RDB$FIELDS CROSS	RFR IN RDB$RELATION_FIELDS WITH	RFR.RDB$FIELD_SOURCE EQ FLD.RDB$FIELD_NAME AND	RFR.RDB$RELATION_NAME EQ rel_name AND	FLD.RDB$FIELD_NAME EQ field_name 	if (!RFR.RDB$DEFAULT_SOURCE.NULL)	    *blob_id = RFR.RDB$DEFAULT_SOURCE;	else if (!FLD.RDB$DEFAULT_SOURCE.NULL)	    *blob_id = FLD.RDB$DEFAULT_SOURCE;    END_FOR	ON_ERROR	    ISQL_errmsg (isc_status);	    return;	END_ERROR;    }else /* default for a domain */    {    FOR FLD IN RDB$FIELDS WITH 	FLD.RDB$FIELD_NAME EQ field_name 	if (!FLD.RDB$DEFAULT_SOURCE.NULL)	    *blob_id = FLD.RDB$DEFAULT_SOURCE;    END_FOR	ON_ERROR	    ISQL_errmsg (isc_status);	    return;	END_ERROR;    }}SSHORT ISQL_get_index_segments (    TEXT	*segs,    TEXT	*indexname,    BOOLEAN	delimited_yes){/************************************** * *	I S Q L _ g e t _ i n d e x _ s e g m e n t s * ************************************** * * Functional description *	returns the list of columns in an index. * **************************************/SSHORT	n = 0;TEXT	SQL_identifier[BUFFER_LENGTH128];*segs = '\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 0;	};/* Query to get column names */FOR SEG IN RDB$INDEX_SEGMENTS WITH	SEG.RDB$INDEX_NAME EQ indexname	SORTED BY SEG.RDB$FIELD_POSITION    n++;    /* Place a comma and a blank between each segment column name */    ISQL_blankterm (SEG.RDB$FIELD_NAME);    if (db_SQL_dialect > SQL_DIALECT_V6_TRANSITION && delimited_yes)	{	ISQL_copy_SQL_id (SEG.RDB$FIELD_NAME, SQL_identifier, DBL_QUOTE);	}    else	strcpy (SQL_identifier, SEG.RDB$FIELD_NAME);    if (n == 1)	sprintf (segs + strlen (segs), "%s", SQL_identifier);    else	sprintf (segs + strlen (segs),", %s", SQL_identifier);END_FOR    ON_ERROR	ISQL_errmsg (isc_status);	ROLLBACK;	return 0;    END_ERROR;return (n);}BOOLEAN ISQL_get_base_column_null_flag (    TEXT	*view_name,    SSHORT	view_context,    TEXT	*base_field){/************************************** * *	I S Q L _ g e t _ b a s e _ c o l u m n _ n u l l _ f l a g * ************************************** * *	Determine if a field on which view column is based *	is nullable. We are passed the view_name *	view_context and the base_field of the view column. * **************************************/BOOLEAN	null_flag;BOOLEAN done = FALSE;BOOLEAN error = FALSE;SSHORT	save_view_context;BASED_ON RDB$RELATION_FIELDS.RDB$RELATION_NAME save_view_name, save_base_field;strcpy (save_view_name, view_name);strcpy (save_base_field, base_field);save_view_context = view_context;null_flag = TRUE;/* 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 FALSE;	};/*    Using view_name and view_context get the relation name from    RDB$VIEW_RELATIONS which contains the base_field for this view column.    Get row corresponding to this base field and relation from    rdb$field_relations. This will contain info on field's nullability unless   it is a view column itself, in which case repeat this procedure till   we get to a "real" column. */ while (!done && !error)    {    ISQL_blankterm (save_view_name);    ISQL_blankterm (save_base_field);    FOR FIRST 1 	  VR IN RDB$VIEW_RELATIONS    	  CROSS    	  NEWRFR IN RDB$RELATION_FIELDS 		WITH		VR.RDB$VIEW_NAME EQ save_view_name AND		VR.RDB$VIEW_CONTEXT EQ save_view_context AND		NEWRFR.RDB$RELATION_NAME = VR.RDB$RELATION_NAME AND		NEWRFR.RDB$FIELD_NAME = save_base_field	if (NEWRFR.RDB$BASE_FIELD.NULL)	    {	    if (NEWRFR.RDB$NULL_FLAG == 1)		null_flag = FALSE;	    done = TRUE;	    }    	else	    {	    strcpy (save_view_name, NEWRFR.RDB$RELATION_NAME);	    save_view_context = NEWRFR.RDB$VIEW_CONTEXT;	    strcpy (save_base_field, NEWRFR.RDB$BASE_FIELD); 	    }	    END_FOR	ON_ERROR	    error = TRUE;	END_ERROR;    }return null_flag;}BOOLEAN ISQL_get_null_flag (    TEXT	*rel_name,    TEXT	*field_name){/************************************** * *	I S Q L _ g e t _ n u l l _ f l a g * ************************************** * *	Determine if a field has the null flag set. *	Look for either rdb$relation_fields or rdb$fields to be  *	Set to 1 (NOT NULL), then this field cannot be null *	We are passed the relation name and the relation_field name *  	For domains, the relation name is null. **************************************/BOOLEAN	null_flag;ISQL_blankterm (field_name);null_flag = TRUE;/* 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 FALSE;	};if (rel_name)    {    FOR FLD IN RDB$FIELDS CROSS	RFR IN RDB$RELATION_FIELDS WITH	RFR.RDB$FIELD_SOURCE EQ FLD.RDB$FIELD_NAME AND	RFR.RDB$RELATION_NAME EQ rel_name AND	RFR.RDB$FIELD_NAME EQ field_name 	if (FLD.RDB$NULL_FLAG == 1) 	    null_flag = FALSE;	else		    {	    /* If RDB$BASE_FIELD is not null then it is a view column */	    if (RFR.RDB$BASE_FIELD.NULL)		{		/* Simple column. Did user define it not null?  */		if (RFR.RDB$NULL_FLAG == 1)		    null_flag = FALSE;		}	    else		null_flag = ISQL_get_base_column_null_flag (rel_name, 				RFR.RDB$VIEW_CONTEXT, RFR.RDB$BASE_FIELD);	    }    END_FOR	ON_ERROR	    ISQL_errmsg (isc_status);	    return null_flag;	END_ERROR;    }else    {    /* Domains have only field entries to worry about */    FOR FLD IN RDB$FIELDS WITH	FLD.RDB$FIELD_NAME EQ field_name	if (FLD.RDB$NULL_FLAG == 1)	    null_flag = FALSE;    END_FOR	ON_ERROR	    ISQL_errmsg (isc_status);	    return null_flag;	END_ERROR;    }return null_flag;}#ifdef GUI_TOOLSSSHORT ISQL_init (    IB_FILE	*inputfile,    IB_FILE	*outputfile){/************************************** * *	I S Q L _ i n i t * ************************************** * * Functional description *	Open database and initialize input and output files for later *	access from Windows ISQL. * **************************************/SSHORT	ret;int	lgth;/* Initialize all pertinent stuff, start db and start transaction, and   set up the input and output files */Out 		= outputfile;Ifp 		= inputfile;Diag 		= Out;Help 		= Out;Merge_stderr  	= FALSE;Quiet 		= FALSE;List 		= FALSE;Docount 	= FALSE;Plan 		= FALSE;Planonly 	= FALSE;Doblob		= 1;Time_display	= FALSE;Sqlda_display	= FALSE;Abort_flag 	= 0;Echo 		= FALSE;Interactive 	= FALSE;Input_file	= FALSE;Pagelength 	= 20;Stats 		= FALSE;Autocommit 	= TRUE;Autofetch	= TRUE;/* Reset global user and password so that the user has o resupply them */Password[0]     = NULL;global_psw      = FALSE;User[0]         = NULL;global_usr      = FALSE;Role[0]         = NULL;global_role     = FALSE;Numbufs[0] = 0;global_numbufs=FALSE;lgth = strlen (DEFCHARSET);if (lgth <= MAXCHARSET_LENGTH)     strcpy (ISQL_charset, DEFCHARSET);else    strncpy (ISQL_charset, DEFCHARSET, MAXCHARSET_LENGTH);Termlen 	= strlen (DEFTERM);if (Termlen <= MAXTERM_LENGTH)    strcpy (Term, DEFTERM);else   {   Termlen = MAXTERM_LENGTH;   strncpy (Term, DEFTERM, MAXTERM_LENGTH);   }D__trans 	= NULL;M__trans 	= NULL;gds__trans 	= NULL;DB 		= NULL;Stmt 		= NULL;signal (SIGINT, query_abort);sqlda = (XSQLDA*) ISQL_ALLOC ((SLONG) (XSQLDA_LENGTH (20)));sqlda->version 	= SQLDA_VERSION1;sqlda->sqln 	= 20;sqldap 	= &sqlda;return 0;}#endif#ifdef GUI_TOOLSvoid ISQL_reset_settings (){/************************************** * *	I S Q L _ r e s e t _ s e t t i n g s * ************************************** * * Functional description *	Called after a script is executed in  *	Windows ISQL to reset the ISQL session  * 	settings. * **************************************/int	lgth;Merge_stderr  	= FALSE;Quiet 		= FALSE;List 		= FALSE;Stats 		= FALSE;Autocommit     	= TRUE;Autofetch	= TRUE;Docount 	= FALSE;Plan 		= FALSE;Planonly 	= FALSE;Doblob		= 1;Time_display	= FALSE;Sqlda_display	= FALSE;Echo 		= FALSE;Pagelength 	= 20;Abort_flag 	= 0;Interactive 	= FALSE;Input_file	= FALSE;lgth = strlen (DEFCHARSET);if (lgth <= MAXCHARSET_LENGTH)     strcpy (ISQL_charset, DEFCHARSET);else    strncpy (ISQL_charset, DEFCHARSET, MAXCHARSET_LENGTH);Termlen 	= strlen (DEFTERM);if (Termlen <= MAXTERM_LENGTH)    strcpy (Term, DEFTERM);else   {   Termlen = MAXTERM_LENGTH;   strncpy (Term, DEFTERM, MAXTERM_LENGTH);   }/* Reset global user and password so that the user has o resupply them */Password[0]     = NULL;global_psw      = FALSE;User[0]         = NULL;global_usr      = FALSE;Role[0]         = NULL;global_role     = FALSE;Numbufs[0] = 0;global_numbufs=FALSE;return;}#endifvoid  ISQL_disconnect_database (     int nQuietMode)	{/************************************** * *	I S Q L _ d i s c o n n e c t _ d a t a b a s e  * ************************************** * * Functional description *	Disconnect from the current database.  First commit work and then  *	call isc_detach_database to detach from the database and the zero *	out the DB handle. * **************************************/extern	SSHORT		Quiet;/* Ignore error msgs during disconnect */Quiet = nQuietMode;/* If we were in a database, commit before proceding */if (DB && (M__trans || D__trans))    end_trans();  /* * 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 (DB && gds__trans)    isc_rollback_transaction (isc_status, &gds__trans);/* If there is  current user statement, free it   I think option 2 is the right one (DSQL_drop), but who knows */if (Stmt)    isc_dsql_free_statement (isc_status, &Stmt, DSQL_drop);/* Detach from old database */if (DB)	isc_detach_database (isc_status, &DB);/* Enable error msgs */Quiet = FALSE;/* Zero database handle and transaction handles */Stmt	    = NULL;DB 	    = NULL;Db_name[0]  = '\0';D__trans    = NULL;M__trans    = NULL;gds__trans  = NULL;return;}BOOLEAN ISQL_is_domain (    TEXT	*field_name){/************************************** * *	I S Q L _ i s _ d o m a i n * ************************************** * *	Determine if a field in rdb$fields is a domain, * **************************************/BOOLEAN	is_domain = FALSE;/* 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);

⌨️ 快捷键说明

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