8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-27 18:03:04 +01:00
firebird-mirror/src/qli/exe.h

385 lines
11 KiB
C
Raw Normal View History

2001-05-23 15:26:42 +02:00
/*
* PROGRAM: JRD Command Oriented Query Language
* MODULE: exe.h
* DESCRIPTION: Execution struct definitions
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef QLI_EXE_H
#define QLI_EXE_H
2001-05-23 15:26:42 +02:00
2004-03-07 08:58:55 +01:00
// Request Language Block -- used for BLR, DYN, SDL, etc.
2001-05-23 15:26:42 +02:00
2004-02-02 12:02:12 +01:00
struct qli_rlb {
2003-09-19 12:26:46 +02:00
blk rlb_header;
2004-03-07 08:58:55 +01:00
UCHAR *rlb_data; // Pointer to end of BLR/DYN/SDL
UCHAR *rlb_base; // Pointer to start of buffer
UCHAR *rlb_limit; // Upper limit of string
USHORT rlb_length; // Length of string
2004-02-02 12:02:12 +01:00
};
2001-05-23 15:26:42 +02:00
2004-03-07 08:58:55 +01:00
// RLB manipulation macros
2001-05-23 15:26:42 +02:00
#define RLB_BUFFER_SIZE 2048
#define RLB_SAFETY_MARGIN 48
#define CHECK_RLB(in) (!in || (in->rlb_data > in->rlb_limit)) ? (in = GEN_rlb_extend (in)) : in;
2004-02-02 12:02:12 +01:00
/* Would need gener_proto.h visible here to use this macro.
inline qli_rlb* CHECK_RLB(qli_rlb*& in)
{
if (!in || (in->rlb_data > in->rlb_limit))
in = GEN_rlb_extend(in);
return in;
}
*/
2003-10-16 10:51:06 +02:00
// If used to replace the macro shown above, this function should be declared
// in gener_proto.h and defined in gener.cpp or declared and defined in gener_proto.h
// if "inline" is preserved.
//static inline rlb* check_rlb(rlb*& in)
//{
// if (!in || (in->rlb_data > in->rlb_limit))
// in = GEN_rlb_extend(in);
// return in;
//}
2001-05-23 15:26:42 +02:00
#define RELEASE_RLB GEN_rlb_release (rlb);
#define STUFF(blr) *rlb->rlb_data++ = blr
#define STUFF_WORD(blr) {STUFF (blr); STUFF (blr >> 8);}
2004-03-07 08:58:55 +01:00
// Request block
2001-05-23 15:26:42 +02:00
2004-02-02 12:02:12 +01:00
struct qli_req {
blk req_header;
2004-03-07 08:58:55 +01:00
qli_req* req_next; // Next request in statement
dbb* req_database; // Database for request
FRBRD* req_handle; // Database request handle
2004-02-02 12:02:12 +01:00
qli_rlb* req_blr;
2004-03-07 08:58:55 +01:00
struct qli_msg* req_messages; // Messages associated with request
struct qli_msg* req_receive; // Current receive message, if any
struct qli_msg* req_send; // Current send message, if any
struct qli_msg* req_continue; // Message to continue FOR loop after optional actions
USHORT req_flags; // Flags for state of request compilation, etc.
USHORT req_context; // Next available context
USHORT req_msg_number; // Next available message number
USHORT req_label; // Next available label
2004-02-02 12:02:12 +01:00
};
2001-05-23 15:26:42 +02:00
#define REQ_rse_compiled 1
2004-03-07 08:58:55 +01:00
#define REQ_project 2 // Set during generation of project clause
#define REQ_group_by 4 // Set during generation of group by clause
2001-05-23 15:26:42 +02:00
struct qli_nod;
2004-03-07 08:58:55 +01:00
// Context node
2001-05-23 15:26:42 +02:00
typedef enum {
CTX_RELATION,
CTX_VARIABLE,
CTX_AGGREGATE,
CTX_UNION,
CTX_STREAM
} CTX_T;
2004-02-02 12:02:12 +01:00
struct qli_ctx {
blk ctx_header;
2004-03-07 08:58:55 +01:00
CTX_T ctx_type; // Type of context
qli_ctx* ctx_source; // Source context for MODIFY
qli_ctx* ctx_primary; // Primary context
qli_symbol* ctx_symbol; // Context symbol, if any
struct qli_rel* ctx_relation; // Relation of context
qli_nod* ctx_stream; // Stream of context
struct qli_fld* ctx_variable; // Variable reference
qli_req* ctx_request; // Request block
struct qli_msg* ctx_message; // Message for data
qli_nod* ctx_rse; // RSE node for root context
qli_nod* ctx_sub_rse; // RSE node aggregate
qli_ctx* ctx_parent; // Parent context for map
struct qli_map* ctx_map; // Map items, if any
USHORT ctx_context; // Context in request
2004-02-02 12:02:12 +01:00
};
2001-05-23 15:26:42 +02:00
2004-03-07 08:58:55 +01:00
// Aggregate/union map block
2001-05-23 15:26:42 +02:00
2004-02-02 12:02:12 +01:00
struct qli_map {
blk map_header;
2004-03-07 08:58:55 +01:00
qli_map* map_next; // Next map in item
qli_nod* map_node; // Value for map item
USHORT map_position; // Position in map
2004-02-02 12:02:12 +01:00
};
2001-05-23 15:26:42 +02:00
2004-03-07 08:58:55 +01:00
// Message block
2001-05-23 15:26:42 +02:00
2004-02-02 12:02:12 +01:00
struct qli_msg {
blk msg_header;
2004-03-07 08:58:55 +01:00
qli_req* msg_request; // Parent request
qli_ctx* msg_context; // Contexts in message
struct qli_msg* msg_next; // Next message in request
struct qli_par* msg_parameters; // Field instances
USHORT msg_number; // Message number
USHORT msg_length; // Message length
USHORT msg_parameter; // Next parameter number
UCHAR* msg_buffer; // Message buffer
2004-02-02 12:02:12 +01:00
};
2004-03-07 08:58:55 +01:00
// Parameter block
2004-02-02 12:02:12 +01:00
struct qli_par {
blk par_header;
2004-03-07 08:58:55 +01:00
dsc par_desc; // Value descriptor
qli_par* par_next; // Next par block in context
qli_msg* par_message; // Parent message
qli_nod* par_value; // Value
USHORT par_parameter; // Parameter number
USHORT par_offset; // Offset of parameter in message
qli_par* par_missing; // Parameter block for missing value
2004-02-02 12:02:12 +01:00
};
2001-05-23 15:26:42 +02:00
2004-03-07 08:58:55 +01:00
// Print item block
2001-05-23 15:26:42 +02:00
2003-08-22 12:56:55 +02:00
typedef enum itm_t
2001-05-23 15:26:42 +02:00
{
item_value,
item_skip,
item_column,
item_tab,
item_space,
item_new_page,
item_column_header,
item_report_header
} ITM_T;
2004-02-02 12:02:12 +01:00
struct qli_print_item {
blk itm_header;
qli_nod* itm_value;
const TEXT* itm_edit_string;
2004-03-07 08:58:55 +01:00
struct pics* itm_picture; // picture string block
const TEXT* itm_query_header;
ITM_T itm_type;
2004-03-07 08:58:55 +01:00
USHORT itm_flags; // Misc flags and crud
UCHAR itm_dtype;
UCHAR itm_sub_type;
USHORT itm_print_offset;
USHORT itm_print_length;
USHORT itm_header_offset;
USHORT itm_header_length;
USHORT itm_header_segments;
2004-03-07 08:58:55 +01:00
USHORT itm_count; // Number of lines to skip
USHORT itm_column; // Logical column number
FRBRD* itm_stream;
2004-03-07 08:58:55 +01:00
USHORT itm_kanji_fragment; // JPN: last kanji on line border
ISC_STATUS itm_blob_status; // JPN: status of the last blob fetch
2004-02-02 12:02:12 +01:00
};
2001-05-23 15:26:42 +02:00
2004-03-07 08:58:55 +01:00
#define ITM_overlapped 1 // Overlapped by another item
2001-05-23 15:26:42 +02:00
2004-03-07 08:58:55 +01:00
// Print Control Block
2001-05-23 15:26:42 +02:00
2004-02-02 12:02:12 +01:00
struct qli_prt {
2003-09-19 12:26:46 +02:00
blk prt_header;
2004-03-07 08:58:55 +01:00
struct file* prt_file; // IB_FILE pointer
struct qli_rpt* prt_report; // Report block (if report)
void (*prt_new_page)(qli_prt*, bool); // New page routine, if any
2001-05-23 15:26:42 +02:00
USHORT prt_lines_per_page;
SSHORT prt_lines_remaining;
USHORT prt_page_number;
2004-02-02 12:02:12 +01:00
};
2001-05-23 15:26:42 +02:00
2004-03-07 08:58:55 +01:00
// General node blocks
2001-05-23 15:26:42 +02:00
2004-02-02 12:02:12 +01:00
struct qli_nod {
blk nod_header;
2004-03-07 08:58:55 +01:00
NOD_T nod_type; // Type of node
dsc nod_desc; // Descriptor
qli_par* nod_import; // To pass random value
qli_par* nod_export; // To pass random value
SSHORT nod_count; // Number of arguments
2004-02-02 12:02:12 +01:00
UCHAR nod_flags;
2004-03-07 08:58:55 +01:00
qli_nod* nod_arg[1]; // If you change this change blk.h too
2004-02-02 12:02:12 +01:00
};
2001-05-23 15:26:42 +02:00
2004-03-07 08:58:55 +01:00
#define NOD_local 1 // locally computed expression
2001-05-23 15:26:42 +02:00
#define NOD_remote 2
2004-03-07 08:58:55 +01:00
#define NOD_parameter2 4 // generate a parameter2 if field
2001-05-23 15:26:42 +02:00
#define nod_partial 8
#define nod_comparison 16
2004-03-07 08:58:55 +01:00
#define nod_date 32 // node is a date operation, regardless
2001-05-23 15:26:42 +02:00
2004-03-07 08:58:55 +01:00
// Execution node positions
2001-05-23 15:26:42 +02:00
2004-03-07 08:58:55 +01:00
#define e_fld_field 0 // field block
#define e_fld_context 1 // context for field
#define e_fld_reference 2 // points to parameter
#define e_fld_subs 3 // subscripts
2001-05-23 15:26:42 +02:00
#define e_fld_count 4
2004-03-07 08:58:55 +01:00
#define e_for_request 0 // Request to be started
#define e_for_send 1 // Message to be sent
#define e_for_receive 2 // Message to be received
#define e_for_eof 3 // End of file parameter
2001-05-23 15:26:42 +02:00
#define e_for_rse 4
#define e_for_statement 5
#define e_for_count 6
2004-03-07 08:58:55 +01:00
#define e_itm_value 0 // Value of print item
#define e_itm_edit_string 1 // Edit string, if any
#define e_itm_header 2 // Query header, if any
2001-05-23 15:26:42 +02:00
#define e_itm_count 3
2004-03-07 08:58:55 +01:00
#define e_rse_first 0 // FIRST clause, if any
#define e_rse_boolean 1 // Boolean clause, if any
#define e_rse_sort 2 // Sort clause, if any
#define e_rse_reduced 3 // Reduced clause, if any
#define e_rse_context 4 // Context block
2001-05-23 15:26:42 +02:00
#define e_rse_group_by 5
#define e_rse_having 6
#define e_rse_join_type 7
#ifdef PC_ENGINE
#define e_rse_index 8
#endif
#define e_rse_count 9
2004-03-07 08:58:55 +01:00
#define e_prt_list 0 // List of print items
#define e_prt_file_name 1 // Output file name
#define e_prt_output 2 // Output file
#define e_prt_header 3 // Header to be printed, if any
2001-05-23 15:26:42 +02:00
#define e_prt_count 4
2004-03-07 08:58:55 +01:00
#define e_prm_prompt 0 // Prompt string, if any
#define e_prm_string 1 // String node for data
#define e_prm_next 2 // Next prompt in statement
#define e_prm_field 3 // Prototype field, if known
2001-05-23 15:26:42 +02:00
#define e_prm_count 4
#define e_sto_context 0
#define e_sto_statement 1
#define e_sto_request 2
#define e_sto_send 3
#define e_sto_count 4
#define e_asn_to 0
#define e_asn_from 1
#define e_asn_initial 2
2004-03-07 08:58:55 +01:00
#define e_asn_valid 3 // Always second-to-last
2001-05-23 15:26:42 +02:00
#define e_asn_count 4
#define e_mod_send 0
2004-03-07 08:58:55 +01:00
#define e_mod_statement 1 // Sub-statement
#define e_mod_request 2 // Parent request for statement
2001-05-23 15:26:42 +02:00
#define e_mod_count 3
#define e_era_context 0
2004-03-07 08:58:55 +01:00
#define e_era_request 1 // Parent request for erase
#define e_era_message 2 // Message to be sent, if any
2001-05-23 15:26:42 +02:00
#define e_era_count 3
2004-03-07 08:58:55 +01:00
#define e_any_request 0 // Request to be started
#define e_any_send 1 // Message to be sent
#define e_any_receive 2 // Message to be received
2001-05-23 15:26:42 +02:00
#define e_any_rse 3
#define e_any_count 4
#define e_rpt_value 0
#define e_rpt_statement 1
#define e_rpt_count 2
#define e_if_boolean 0
#define e_if_true 1
#define e_if_false 2
#define e_if_count 3
#define e_edt_input 0
#define e_edt_dbb 1
#define e_edt_id1 2
#define e_edt_id2 3
#define e_edt_name 4
#define e_edt_count 5
#define e_out_statement 0
#define e_out_file 1
#define e_out_pipe 2
#define e_out_print 3
#define e_out_count 4
#define e_fmt_value 0
#define e_fmt_edit 1
#define e_fmt_picture 2
#define e_fmt_count 3
2004-03-07 08:58:55 +01:00
// Statistical expression
2001-05-23 15:26:42 +02:00
#define e_stt_rse 0
#define e_stt_value 1
#define e_stt_default 2
2004-03-07 08:58:55 +01:00
#define e_stt_request 3 // Request to be started
#define e_stt_send 4 // Message to be sent
#define e_stt_receive 5 // Message to be received
2001-05-23 15:26:42 +02:00
#define e_stt_count 6
#define e_map_context 0
#define e_map_map 1
#define e_map_count 2
#define e_ffr_form 0
#define e_ffr_statement 1
#define e_ffr_count 2
#define e_fup_form 0
#define e_fup_fields 1
#define e_fup_tag 2
#define e_fup_count 3
#define e_ffl_form 0
#define e_ffl_field 1
#define e_ffl_string 2
#define e_ffl_count 3
#define e_men_statements 0
#define e_men_labels 1
#define e_men_string 2
#define e_men_menu 4
#define e_men_count 5
#define e_fun_args 0
#define e_fun_function 1
2004-03-07 08:58:55 +01:00
#define e_fun_request 2 // Request to be started
#define e_fun_send 3 // Message to be sent
#define e_fun_receive 4 // Message to be received
2001-05-23 15:26:42 +02:00
#define e_fun_count 5
#define e_syn_statement 0
#define e_syn_send 1
#define e_syn_count 2
2004-03-07 08:58:55 +01:00
// A Program global or two
2001-05-23 15:26:42 +02:00
#ifdef REQUESTS_MAIN
#define EXTERN
#else
#define EXTERN extern
#endif
2004-03-07 08:58:55 +01:00
EXTERN qli_req* QLI_requests; // Requests in statement
2001-05-23 15:26:42 +02:00
#undef EXTERN
2004-02-02 12:02:12 +01:00
#endif // QLI_EXE_H