8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 20:43:02 +01:00

derived table support

This commit is contained in:
arnobrinkman 2003-08-14 23:34:37 +00:00
parent 2a5b39c50d
commit a19beb8922
4 changed files with 33 additions and 6 deletions

View File

@ -20,7 +20,7 @@
* All Rights Reserved.
* Contributor(s): ______________________________________.
*
* $Id: ddl.cpp,v 1.51 2003-08-06 16:30:38 skidder Exp $
* $Id: ddl.cpp,v 1.52 2003-08-14 23:31:13 arnobrinkman Exp $
* 2001.5.20 Claudio Valderrama: Stop null pointer that leads to a crash,
* caused by incomplete yacc syntax that allows ALTER DOMAIN dom SET;
*
@ -3394,12 +3394,16 @@ static void define_view( DSQL_REQ request, NOD_TYPE op)
/* define the view source relations from the request contexts & union contexts*/
while (request->req_dt_context) {
context = reinterpret_cast<DSQL_CTX>(LLS_POP(&request->req_dt_context));
LLS_PUSH(context, &request->req_context);
}
while (request->req_union_context) {
context = reinterpret_cast<DSQL_CTX>(LLS_POP(&request->req_union_context));
LLS_PUSH(context, &request->req_context);
}
for (temp = request->req_context; temp; temp = temp->lls_next)
{
context = (DSQL_CTX) temp->lls_object;

View File

@ -403,6 +403,7 @@ public:
DsqlMemoryPool* req_pool;
DLLS req_context;
DLLS req_union_context; //!< Save contexts for views of unions
DLLS req_dt_context; //!< Save contexts for views of derived tables
struct sym* req_name; //!< Name of request
struct sym* req_cursor; //!< Cursor symbol, if any
dbb* req_dbb; //!< Database handle
@ -443,6 +444,7 @@ public:
USHORT req_error_handlers; //!< count of active error handlers
USHORT req_flags; //!< generic flag
USHORT req_client_dialect; //!< dialect passed into the API call
USHORT req_in_outer_join; //!< processing inside outer-join part
};
typedef dsql_req* DSQL_REQ;

View File

@ -29,7 +29,7 @@
* 2002.10.29 Nickolay Samofatov: Added support for savepoints
*/
/*
$Id: gen.cpp,v 1.35 2003-08-14 07:11:24 fsg Exp $
$Id: gen.cpp,v 1.36 2003-08-14 23:33:43 arnobrinkman Exp $
*/
#include "firebird.h"
@ -264,6 +264,10 @@ void GEN_expr( DSQL_REQ request, DSQL_NOD node)
gen_rse(request, node);
return;
case nod_derived_table:
gen_rse(request, node->nod_arg[e_derived_table_rse]);
return;
case nod_exists:
STUFF(blr_any);
gen_rse(request, node->nod_arg[0]);
@ -2058,8 +2062,12 @@ static void gen_rse( DSQL_REQ request, DSQL_NOD rse)
ptr++) {
DSQL_NOD node = *ptr;
if (node->nod_type == nod_relation ||
node->nod_type == nod_aggregate || node->nod_type == nod_join)
node->nod_type == nod_aggregate || node->nod_type == nod_join) {
GEN_expr(request, node);
}
else if (node->nod_type == nod_derived_table) {
GEN_expr(request, node->nod_arg[e_derived_table_rse]);
}
}
}
else {
@ -2659,7 +2667,12 @@ static void gen_union( DSQL_REQ request, DSQL_NOD union_node)
// Obtain the context for UNION from the first MAP node
DSQL_NOD items = union_node->nod_arg[e_rse_items];
DSQL_CTX union_context = (DSQL_CTX) items->nod_arg[0]->nod_arg[e_map_context];
DSQL_NOD map_item = items->nod_arg[0];
// AB: First item could be a alias generated by derived table.
if (map_item->nod_type == nod_alias) {
map_item = map_item->nod_arg[e_alias_value];
}
DSQL_CTX union_context = (DSQL_CTX) map_item->nod_arg[e_map_context];
STUFF(union_context->ctx_context);
DSQL_NOD streams = union_node->nod_arg[e_rse_streams];

View File

@ -333,7 +333,8 @@ typedef ENUM nod_t
nod_difference_file,
nod_drop_difference,
nod_begin_backup,
nod_end_backup
nod_end_backup,
nod_derived_table // Derived table support
} NOD_TYPE;
@ -382,6 +383,8 @@ typedef dsql_nod* DSQL_NOD;
#define NOD_READ 4
#define NOD_WRITE 8
#define NOD_DERIVED_TABLE 1 // flag used by nod_alias
#define REF_ACTION_CASCADE 1
#define REF_ACTION_SET_DEFAULT 2
#define REF_ACTION_SET_NULL 4
@ -867,4 +870,9 @@ typedef dsql_nod* DSQL_NOD;
#define e_searched_case_search_conditions 0 /* list boolean expressions */
#define e_searched_case_results 1 /* list including else_result */
#define e_derived_table_rse 0 // Contains select_expr
#define e_derived_table_alias 1 // Alias name for derived table
#define e_derived_table_column_alias 2 // List with alias names from derived table columns
#define e_derived_table_count 3
#endif /* _DSQL_NODE_H_ */