1 /*
2  * Copyright (C) 2008 - 2011 Vivien Malerba <malerba@gnome-db.org>
3  * Copyright (C) 2009 Murray Cumming <murrayc@murrayc.com>
4  * Copyright (C) 2011 Daniel Espinosa <despinosa@src.gnome.org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19  * Boston, MA  02110-1301, USA.
20  */
21 
22 #ifndef _GDA_STATEMENT_STRUCT_COMPOUND_H_
23 #define _GDA_STATEMENT_STRUCT_COMPOUND_H_
24 
25 #include <glib.h>
26 #include <glib-object.h>
27 #include <sql-parser/gda-statement-struct-decl.h>
28 #include <sql-parser/gda-statement-struct-select.h>
29 
30 G_BEGIN_DECLS
31 
32 /*
33  * Kinds
34  */
35 /**
36  * GdaSqlStatementCompoundType:
37  * @GDA_SQL_STATEMENT_COMPOUND_UNION:
38  * @GDA_SQL_STATEMENT_COMPOUND_UNION_ALL:
39  * @GDA_SQL_STATEMENT_COMPOUND_INTERSECT:
40  * @GDA_SQL_STATEMENT_COMPOUND_INTERSECT_ALL:
41  * @GDA_SQL_STATEMENT_COMPOUND_EXCEPT:
42  * @GDA_SQL_STATEMENT_COMPOUND_EXCEPT_ALL:
43  */
44 typedef enum {
45 	GDA_SQL_STATEMENT_COMPOUND_UNION,
46 	GDA_SQL_STATEMENT_COMPOUND_UNION_ALL,
47 	GDA_SQL_STATEMENT_COMPOUND_INTERSECT,
48 	GDA_SQL_STATEMENT_COMPOUND_INTERSECT_ALL,
49 	GDA_SQL_STATEMENT_COMPOUND_EXCEPT,
50 	GDA_SQL_STATEMENT_COMPOUND_EXCEPT_ALL
51 } GdaSqlStatementCompoundType;
52 
53 /*
54  * Structure definition
55  */
56 /**
57  * GdaSqlStatementCompound: (skip)
58  * @any:
59  * @compound_type:
60  * @stmt_list:
61  */
62 struct _GdaSqlStatementCompound {
63 	GdaSqlAnyPart                any;
64 	GdaSqlStatementCompoundType  compound_type;
65 	GSList                      *stmt_list; /* list of SELECT or COMPOUND statements */
66 
67 	/*< private >*/
68 	/* Padding for future expansion */
69 	gpointer         _gda_reserved1;
70 	gpointer         _gda_reserved2;
71 };
72 
73 /*
74  * Common operations
75  */
76 gpointer  _gda_sql_statement_compound_copy (gpointer src);
77 void      _gda_sql_statement_compound_free (gpointer stmt);
78 gchar    *_gda_sql_statement_compound_serialize (gpointer stmt);
79 GdaSqlStatementContentsInfo *_gda_sql_statement_compound_get_infos (void);
80 
81 /*
82  * compound specific operations
83  */
84 gint      _gda_sql_statement_compound_get_n_cols (GdaSqlStatementCompound *compound, GError **error);
85 GdaSqlAnyPart * _gda_sql_statement_compound_reduce (GdaSqlAnyPart *compound_or_select);
86 
87 /*
88  * Functions used by the parser
89  */
90 void gda_sql_statement_compound_set_type (GdaSqlStatement *stmt, GdaSqlStatementCompoundType type);
91 void gda_sql_statement_compound_take_stmt (GdaSqlStatement *stmt, GdaSqlStatement *s);
92 
93 G_END_DECLS
94 
95 #endif
96