Devices and methods for generating a query execution plan based on a query

EP4710239A1Pending Publication Date: 2026-03-18HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
EP · EP
Patent Type
Applications
Current Assignee / Owner
Filing Date
2023-05-15
Publication Date
2026-03-18

AI Technical Summary

Technical Problem

Current solutions, such as web application firewalls (WAFs), face limitations in detecting and preventing query tautology injections due to parsing latency, inferior parsing capabilities, and vulnerability to internal attacks, necessitating a more effective mechanism within the database to control access and detect malicious queries.

Method used

A data processing apparatus and method that generates a query execution tree for SQL queries, determining if conditional expressions are always true or false, allowing for the detection of tautology injections and implementing countermeasures, such as preventing query execution or issuing alerts, while optimizing the query plan and operating in conjunction with existing database components.

Benefits of technology

This approach provides a robust, computationally inexpensive detection and prevention scheme that effectively identifies and mitigates tautology SQL injections, is resistant to internal attacks, and supports analysis of stored procedures, operating in parallel with other security solutions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure EP2023063009_21112024_PF_FP_ABST
    Figure EP2023063009_21112024_PF_FP_ABST
Patent Text Reader

Abstract

A data processing apparatus (120) is disclosed for generating and executing a query execution plan for a database (125a). The data processing apparatus is configured to generate a query execution tree based on a query in a query language, for instance, a SQL query, and is configured to determine whether the query execution tree includes at least one conditional expression being always true or always false rendering the query execution tree always true or always false irrespective of query input data. In case the query execution tree does not include at least one conditional expression being always true or always false rendering the query execution tree always true or always false irrespective of the query input data, the data processing apparatus is configured to execute the query execution plan. Moreover, a corresponding data processing method is disclosed. The disclosed data processing apparatus and method allow detecting query tautology injections.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] DEVICES AND METHODS FOR GENERATING A QUERY EXECUTION PLAN BASED ON A QUERY

[0002] TECHNICAL FIELD

[0003] The present disclosure relates to database technology. More specifically, the present disclosure relates to devices and methods for generating a query execution plan based on a query in a query language and thereby controlling access to a database.

[0004] BACKGROUND

[0005] Remote data storage is becoming more and more popular, because it allows user devices, which can usually store only a limited amount of data, to save data and files in one or more remote databases that can be accessed either through the public internet or a dedicated private network connection. For instance, a cloud storage provider may host, secure, manage, and maintain remote databases and associated infrastructure and enable the access of the user devices to the data stored in the databases. Since remote databases may also store security sensitive data, remote databases may be targeted by different types of attacks, such as SQL injection attacks trying to exploit a web application vulnerability, insider attacks, credential theft attacks and the like. For instance, a tautology-based SQL injection attack (also referred to as query tautology injection) usually tries to bypass user authentication and extract data by inserting a tautology in the "WHERE" clause of an SQL query. The SQL query transforms the original condition into a tautology that causes, for example, all the rows in a database table to be open to an unauthorized user.

[0006] Generally, there are two approaches for handling query tautology injections, namely detection and prevention. Detecting a query tautology injection may involve issuing a warning message, i.e. a passive handling of the query tautology injection, while preventing may involve proactively preventing a query from being executed, i.e. an active handling of the query tautology injection. SQL injection attacks may be detected, for instance, using a web application firewall (WAF). A WAF operating in front of one or more web servers may monitor the traffic which goes in and out of the web servers and may identify patterns that constitute a threat. Thus, a WAF is essentially a barrier between a web application and the Internet and, thus, between a database and the Internet. A WAF may operate by means of defined customizable web security rules. Every rule may contain a configuration whether to allow or block web requests that appear to contain malicious SQL code, and one or more SQL injection match conditions, such as specific text patterns to look for. A SQL injection match condition may identify the part of queries. These sets of policies may inform the WAF what weaknesses and traffic behaviour it should search for.

[0007] In some scenarios a solution embedded in the database is required because of at least three disadvantages of using a WAF. A first weakness is that in order to find tautologies a WAF needs to parse the query, i.e. implement a database parser, resulting in an additional latency, because each query is parsed both in the WAF and in the database server. A second weakness is that a WAF parser usually cannot compete with an original database parser in parsing ability, i.e. it cannot parse all possible input that the original database parser can. And the third weakness is related to the fact the internal users may find a way to bypass the WAF server by sending queries directly to the database and thereby bypassing the WAF server.

[0008] SUMMARY

[0009] It is an objective of the present disclosure to provide improved devices and methods for generating a query execution plan based on a query in a query language , wherein the improved devices and methods implement a security mechanism for analysing the query execution plan and thereby for controlling access to a database storing potentially security sensitive data.

[0010] The foregoing and other objectives are achieved by the subject matter of the independent claims. Further implementation forms are apparent from the dependent claims, the description, and the figures.

[0011] According to a first aspect a data processing apparatus for generating and executing a query execution plan for a database is provided. The data processing apparatus is configured to generate a query execution tree (also referred to as query execution graph) based on a query in a query language. Moreover, the data processing apparatus is configured to generate a query execution plan based on the query execution tree. The data processing apparatus is configured to determine whether the query execution tree includes at least one conditional expression being always logically true or always logically false rendering the query execution tree always logically true or always logically false irrespective of the query input data, i.e. the database data the query is operating on. In case the query execution tree does not include at least one conditional expression being always logically true or always logically false rendering the query execution tree always logically true or always logically false irrespective of the query input data, the data processing apparatus is configured to execute the query execution plan. Thus, the data processing apparatus according to the first aspect allows detecting query tautology injections and perform suitable counter measures.

[0012] In a further possible implementation form, the query is a SQL query.

[0013] In a further possible implementation form, the data processing apparatus is configured to receive an original SQL query and to generate the query execution tree based on the original SQL query and one or more SQL stored procedures.

[0014] In a further possible implementation form, the data processing apparatus is configured to determine whether the query execution tree includes at least one conditional expression being always true or always false rendering the query execution tree always true or always false irrespective of the input data within a WHERE or SELECT clause of the query.

[0015] In a further possible implementation form, the data processing apparatus is configured to determine whether the query execution tree includes at least one conditional expression being always true or always false rendering the query execution tree always true or always false irrespective of the input data at a root of the query execution tree.

[0016] In a further possible implementation form, the data processing apparatus is configured to recursively evaluate the query execution tree from one or more leaves of the query execution tree to the root of the query execution tree for determining whether the query execution tree includes at least one conditional expression being always true or always false rendering the query execution tree always true or always false irrespective of the input data at the root of the query execution tree.

[0017] In a further possible implementation form, the data processing apparatus is configured to prevent execution of the query plan and / or issue an alert message, for instance to a user, in case the query execution tree does include at least one conditional expression being always true or always false rendering the query execution tree always true or always false irrespective of the input data. In a further possible implementation form, the data processing apparatus is further configured to optimize the query execution plan based on the query execution tree.

[0018] In a further possible implementation form, the data processing apparatus is a database server further comprising the database or a web server in communication with the database.

[0019] In a further possible implementation form, the database is a relational database and / or a database supporting SQL, e.g. a SQL interface.

[0020] According to a second aspect a computer-implemented data processing method for generating and executing a query execution plan for a database is provided. The data processing method comprises the steps of: generating a query execution tree based on a query in a query language; generating a query execution plan based on the query execution tree; determining whether the query execution tree includes at least one conditional expression being always true or always false rendering the query execution tree always true or always false irrespective of the input data; in case the query execution tree does not include at least one conditional expression being always true or always false rendering the query execution tree always true or always false irrespective of the input data, executing the query execution plan.

[0021] The data processing method according to the second aspect of the present disclosure can be performed by the data processing apparatus according to the first aspect of the present disclosure. Thus, further features of the method according to the second aspect of the present disclosure result directly from the functionality of the apparatus according to the first aspect of the present disclosure as well as its different implementation forms described above and below.

[0022] According to a third aspect, a computer program product comprising a non-transitory computer-readable storage medium for storing program code which causes a computer or a processor to perform the data processing method according to the second aspect, when the program code is executed by the computer or the processor, is provided. The data processing apparatus according to the first aspect and the data processing method according to the second aspect provide a detection and prevention scheme for identifying real tautology SQL injections with a high rate of success. The detection and prevention scheme implemented by the data processing apparatus according to the first aspect and the data processing method according to the second aspect cannot be bypassed and is bulletproof against internal attacks. Moreover, the detection and prevention scheme implemented by the data processing apparatus according to the first aspect and the data processing method according to the second aspect support analysis of database stored procedures and thereby protect against second order attacks. The detection and prevention scheme implemented by the data processing apparatus according to the first aspect and the data processing method according to the second aspect is computationally inexpensive and may operate in parallel with other security solutions.

[0023] Details of one or more embodiments are set forth in the accompanying drawings and the description below. Other features, objects, and advantages will be apparent from the description, drawings, and claims.

[0024] BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In the following, embodiments of the present disclosure are described in more detail with reference to the attached figures and drawings, in which:

[0026] Fig. 1 is a schematic diagram illustrating a data storage system according to an embodiment, including a plurality of user entities and a data processing apparatus according to an embodiment for generating and executing a query execution plan for retrieving data from a database;

[0027] Figs. 2a-c show tables with exemplary data stored in a database for illustrating a query tautology injection attack;

[0028] Fig. 3 shows a signalling diagram illustrating processing steps implemented by a data processing apparatus for generating and executing a query execution plan according to an embodiment based on a query from a user entity; Fig. 4 shows a flow diagram illustrating processing steps implemented by a data processing apparatus for generating and executing a query execution plan according to an embodiment using a query execution tree;

[0029] Fig. 5 shows a schematic diagram illustrating different processing stages implemented by a data processing apparatus for generating and executing a query execution plan according to an embodiment; and

[0030] Fig. 6 is a flow diagram illustrating a data processing method according to an embodiment for generating and executing a query execution plan.

[0031] In the following, identical reference signs refer to identical or at least functionally equivalent features.

[0032] DETAILED DESCRIPTION OF THE EMBODIMENTS

[0033] In the following description, reference is made to the accompanying figures, which form part of the disclosure, and which show, by way of illustration, specific aspects of embodiments of the present disclosure or specific aspects in which embodiments of the present disclosure may be used. It is understood that embodiments of the present disclosure may be used in other aspects and comprise structural or logical changes not depicted in the figures. The following detailed description, therefore, is not to be taken in a limiting sense, and the scope of the present disclosure is defined by the appended claims.

[0034] For instance, it is to be understood that a disclosure in connection with a described method may also hold true for a corresponding device or system configured to perform the method and vice versa. For example, if one or a plurality of specific method steps are described, a corresponding device may include one or a plurality of units, e.g. functional units, to perform the described one or plurality of method steps (e.g. one unit performing the one or plurality of steps, or a plurality of units each performing one or more of the plurality of steps), even if such one or more units are not explicitly described or illustrated in the figures. On the other hand, for example, if a specific apparatus is described based on one or a plurality of units, e.g. functional units, a corresponding method may include one step to perform the functionality of the one or plurality of units (e.g. one step performing the functionality of the one or plurality of units, or a plurality of steps each performing the functionality of one or more of the plurality of units), even if such one or plurality of steps are not explicitly described or illustrated in the figures. Further, it is understood that the features of the various exemplary embodiments and / or aspects described herein may be combined with each other, unless specifically noted otherwise.

[0035] Figure 1 is a schematic diagram illustrating a data storage system 100 according to an embodiment. As will be described in more detail below, the data storage system 100 may comprise a plurality of user entities 110, such as for example smart phones, smart watches, tablet computers, laptop computers, desktop computers or other types of loT devices, and one or more remote data processing apparatuses, for instance, data storage servers or web servers 120 including a database 125a or in communication with a database 125a. The database 125a may be implemented as a relational database, for instance, a SQL based relational database.

[0036] As illustrated in figure 1, the data processing apparatus 120 may comprise a memory 125, for example a disk memory 125 for implementing the non-relational database 125a and the user entity 110 may be configured to communicate therewith. Although in the embodiment of figure 1, the database 125a is illustrated as a component of the data processing apparatus 120, in further embodiments the data processing apparatus 120 and the database 125a may both be stand-alone entities. As further illustrated in figure 1, the plurality of user entities 110 and the data processing apparatus 120 may be configured to communicate with each other via a wireless, e.g. cellular and / or wired communication network 140, for instance, the Internet 140.

[0037] The user entity 110 may comprise a processor 111 for processing and generating data, a communication interface 113, including, for instance, an antenna, for exchanging data with the other components of the data storage system 100, and a non-transitory memory 115 for storing data. The processor 111 of the user entity 110 may be implemented in hardware and / or software. The hardware may comprise digital circuitry, or both analog and digital circuitry. Digital circuitry may comprise components such as application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), or general-purpose processors. The non-transitory memory 115 may store data, such as an executable program code which, when executed by the processor 111, causes the user entity 110 to perform the functions, operations and methods described herein. The communication interface 113 may comprise a wired or wireless communication interface 113. Likewise, the data processing apparatus 120 may comprise a processor 121 for processing and generating data, a communication interface 123 for exchanging data with the other components of the data storage system 100 as well as a memory 125 for storing data such as an executable program code which, when executed by the processor 121, causes the data processing apparatus 120 to perform the functions, operations and methods described herein.

[0038] As schematically illustrated in figure 1, the data processing apparatus 120 is configured to receive from the user entity 110 a query 130 in a database query language, such as a SQL query 130, for data from the database 125a. As will be described in more detail below, the data processing apparatus 120 is configured to detect query tautology injections and perform suitable counter measures. Before describing detailed embodiments of the data processing apparatus 120 some common general knowledge concerning query tautology injection attacks is described in the context of figures 2a-c.

[0039] For accessing the services of a web server, such as the data processing apparatus 120 according to an embodiment, a user via its user entity 110 may have to provide a username and a password. An attacker might try to attack the login process into such a web server having username and password fields. In case the login name is “MsWhite” with the password “x6yhjk”, the web server may send a query to the database in the following form:

[0040] SELECT Name, Address, CC FROM users WHERE Login= MsWhite ’ AND Pass= ’x6yhjk

[0041] In the database the users may be stored in the exemplary table shown in figure 2a. In response to the successful login query the user “MsWhite” gains access to her personal data, such as a pin, name, address and further data, as illustrated in the table shown in figure 2b.

[0042] In the case of a query tautology injection attack an attacker may submit a pattern, such as ” or 1=1; — for the login input field. The input submitted for the other fields becomes irrelevant. The resulting query is:

[0043] SELECT Name, Address, CC FROM users WHERE Login= ” or 1=1; — ’ AND Pass= ’ ’ AND Pin=;

[0044] Thus, the general goal of a query tautology injection attack is to inject code in one or more conditional statements of the query so that these conditional statements always evaluate to logically TRUE (or FALSE). In other words, for this type of injection attack an attacker exploits an injectable field that is used in a query’s WHERE conditional. However, because the conditional is a tautology, the query evaluates to TRUE for each row in the table and returns all of the rows of the database. Thus, if the web server executes the following exemplary corrupted SQL query (part of original query may get disabled):

[0045] SELECT Name, Address, CC FROM users WHERE login= ” or 1=1; — ’AND pass= the attacker may gain access to the personal information of all the users, i.e. all the exemplary data shown in the table of figure 2c. Thus, SQL injection attacks pose a serious security threat. This is because a successful SQL injection attack may result in confidential data being deleted, lost or stolen, websites being defaced, unauthorized access to systems or accounts and, ultimately, compromise of individual machines or entire networks.

[0046] As already mentioned above, the data processing apparatus 120 is configured to receive from the user entity 110 a query 130 in a database query language, such as SQL, for data from the database 125a and to detect if the query 130 is a query tautology injection and, if this is the case, perform suitable counter measures. More specifically, as will be described in the following under further reference to figures 3, 4 and 5, in a stage 301 shown in figure 3 the data processing apparatus 120, in particular the communication interface 123 thereof may receive a query 130 as part of a login request from the user entity 110 of a user. In a stage 303 the data processing apparatus 120, in particular the processing circuitry 121 thereof runs the query 130 to obtain the data requested by the user entity 110, which may involve the following stages 305, 307, 309 and 311 of figure 3 performed by the data processing apparatus 120 and / or the database 125a.

[0047] In the stage 305 of figure 3 the data processing apparatus 120 and the database 125a parse the query 130 and generate a query execution tree (also referred to as query execution graph) on the basis of the query 130. This may be done using a native database parser configured to “understand” the SQL query. In an embodiment, the data processing apparatus 120 is configured to receive the SQL query 130 and to generate the query execution tree based on the SQL query 130 and one or more SQL stored procedures.

[0048] In the stage 307 of figure 3 the data processing apparatus 120 and the database 125a are configured to analyse the query execution tree and to generate a query execution plan based on the query execution tree. In the stage 309 of figure 3 the data processing apparatus 120 and the database 125a are configured to determine whether the query execution tree includes one or more conditional expressions being always logically true or always logically false that render the whole query execution tree to be always logically true or always logically false irrespective of the query input data, such as a constant expression being compared to another constant expression. In other words, in the stage 309 of figure 3 the data processing apparatus 120 searches the query execution true for conditional expressions that are always logically true or false, such as the expression ” or 1=1; — mentioned in the example above. As illustrated in figure 3, the data processing apparatus 120 and the database 125a may be configured to determine whether the query execution tree includes one or more conditional expressions being always logically true or always logically false as part of generating and optimizing the query execution plan based on the query execution tree. In an embodiment, the query may be optimized such that for executing the query execution plan as little database resources as possible are used.

[0049] In an embodiment, the data processing apparatus 120 is configured to determine whether the query execution tree includes at least one conditional expression being always true or always false rendering the query execution tree always true or always false irrespective of the input data within a WHERE or SELECT clause of the query 130. In an embodiment, the data processing apparatus 120 is configured to determine whether the query execution tree includes at least one conditional expression being always true or always false rendering the query execution tree always true or always false irrespective of the input data at a root of the query execution tree. In a further embodiment, the data processing apparatus 120 is configured to recursively evaluate the query execution tree from one or more leaves of the query execution tree to the root of the query execution tree for determining whether the query execution tree includes at least one conditional expression being always true or always false rendering the query execution tree always true or always false irrespective of the input data at the root of the query execution tree.

[0050] In stage 311 of figure 3, the data processing apparatus 120 and the database 125a are configured to execute the optimized query execution plan, if the query execution tree does not include at least one conditional expression being always logically true or always logically false rendering the query execution tree always logically true or always logically false irrespective of the query input data. Otherwise, i.e. if the query execution tree does include at least one conditional expression being always logically true or always logically false rendering the query execution tree always logically true or always logically false irrespective of the query input data, the query 130 may be a query injection tautology injection and the data process apparatus 120 may perform appropriate counter measures, such as issuing an alert message and / or preventing the query execution plan from being executed.

[0051] In stage 313 of figure 3, the database 125a returns the results of the successfully verified query 130 to the data processing apparatus 120. If the query 130 has been successfully verified by the data processing apparatus 120 and the database 125a, the communication interface 123 of the data processing apparatus 120 may in stage 315 of figure 3 approve the login request of the user 110 and return the query results to the user 110.

[0052] A more detailed embodiment of stage 309 of figure 3 is illustrated in more detail in the flow diagram of figure 4. In an embodiment, for determining whether the query execution tree includes one or more conditional expressions being always logically true or always logically false that render the whole query execution tree to be always logically true or always logically false irrespective of the query input data the data processing apparatus 120 is configured to analyse “FromExpression” or “JoinExpression” data structures of the query execution tree in a processing block 401 of figure 4. In a processing block 403 of figure 4 the data processing apparatus 10 is configured to evaluate and simplify expression-type nodes of the query execution tree: in case of a constant / variable node the process may continue with block 403 (block 405); in case of an operator / case node the data processing apparatus 120 may evaluate and simplify the expression (block 407); and in case of a function node the data processing apparatus 120 may evaluate and simplify the expression as well (block 409). In block 411 of figure 11 the data processing apparatus 120 is configured to determine whether the evaluated and simplified expressions provided by the blocks 407 and 409 are always logically true (or always logically false). If this is the case, the data processing apparatus 120 may replace the currently processed node of the query execution tree with a constant node (block 413). Otherwise, the data processing apparatus 120 may be configured to continue analysing the next node of the query execution tree.

[0053] Figure 5 shows a schematic diagram illustrating different processing stages implemented by the data processing apparatus 120 for generating and executing a query execution plan according to an embodiment for a specific database implementation. Figure 5 illustrates a parsing stage 501 of the SQL query 130, a detection stage 503, a verification stage 505 and a notification stage 507. Thus, during SQL query processing the query 130 is parsed, planned, optimized and executed. During these stages a planner, an executer and / or an optimizer implemented by the data processing apparatus 120 and / or the database 125a may be invoked multiple times and in a recursive manner, as illustrated in figure 5. During the parsing stage 501 each component may utilize or process its own meta-data structure i.e. planner tree and execution plan. During these stages 501 and 503 the data about a possible query tautology injection attack (referred to as sqli in figure 5) is accumulated and, once the process has been completed, before the actual execution and data retrieval stage 507 verifies whether a query tautology injection attack was detected in the upstream stages. If this is the case an alert message is issued in stage 507, for instance to a message centre.

[0054] Figure 6 is a flow diagram illustrating steps of a computer-implemented data processing method 600 for generating and executing a query execution plan for the database 125a. The data processing method 600 comprises a step 601 of generating a query execution tree based on a query 130 in a query language, such as a SQL query 130. Moreover, the method 600 comprises a step 603 of generating a query execution plan based on the query execution tree. The method 600 further comprises a step 605 of determining whether the query execution tree includes at least one conditional expression being always true or always false rendering the query execution tree always true or always false irrespective of query input data. Moreover, the method 600 comprises a step 607 of executing the query execution plan, if the query execution tree does not include at least one conditional expression being always true or always false rendering the query execution tree always true or always false irrespective of the query input data.

[0055] As already mentioned above, the method 600 can be performed by the data processing apparatus 120. Thus, further features of the method 600 result directly from the functionality of the apparatus 120 as well as its different embodiments described above and below.

[0056] Embodiments disclosed herein allow detecting a query tautology injection attack with almost zero overhead, as the embodiments disclosed herein make beneficial use of already existing database components, such as a planner, executor, and or optimizer). Thus, embodiments of the data processing apparatus 120 and the data processing method 600 disclosed herein provide an efficient detection and prevention scheme for identifying real tautology SQL injections with a high rate of success. The detection and prevention scheme implemented by embodiments disclosed herein cannot be bypassed and is bulletproof against internal attacks. Moreover, the detection and prevention scheme supports analysis of database stored procedures and thereby protect against second order attacks. Furthermore, the detection and prevention scheme is computationally inexpensive and may operate in parallel with other security solutions.

[0057] The person skilled in the art will understand that the "blocks" ("units") of the various figures (method and apparatus) represent or describe functionalities of embodiments of the present disclosure (rather than necessarily individual "units" in hardware or software) and thus describe equally functions or features of apparatus embodiments as well as method embodiments (unit = step).

[0058] In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus, and method may be implemented in other manners. For example, the described embodiment of an apparatus is merely exemplary. For example, the unit division is merely logical function division and may be another division in an actual implementation. For example, a plurality of units or components may be combined or integrated into another system, or some features may be ignored or not performed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections may be implemented by using some interfaces. The indirect couplings or communication connections between the apparatuses or units may be implemented in electronic, mechanical, or other forms.

[0059] The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one position, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.

[0060] In addition, functional units in the embodiments of the invention may be integrated into one processing unit, or each of the units may exist alone physically, or two or more units are integrated into one unit.

Claims

CLAIMS1. A data processing apparatus (120) for generating and executing a query execution plan for a database (125a), wherein the data processing apparatus (120) is configured to: generate a query execution tree based on a query (130) in a query language; generate a query execution plan based on the query execution tree; determine whether the query execution tree includes at least one conditional expression being always true or always false rendering the query execution tree always true or always false irrespective of query input data; in case the query execution tree does not include at least one conditional expression being always true or always false rendering the query execution true always true or always false irrespective of the query input data, execute the query execution plan.

2. The data processing apparatus (120) of claim 1, wherein the query (130) is a SQL query (130).

3. The data processing apparatus (120) of claim 2, wherein the data processing apparatus (120) is configured to receive an original query and to generate the query execution tree based on the original query and one or more SQL stored procedures.

4. The data processing apparatus (120) of claim 2 or 3, wherein the data processing apparatus (120) is configured to determine whether the query execution tree includes at least one conditional expression being always true or always false rendering the query execution tree always true or always false irrespective of the query input data within a WHERE or SELECT clause of the query (130).

5. The data processing apparatus (120) of any one of the preceding claims, wherein the data processing apparatus (120) is configured to determine whether the query execution tree includes at least one conditional expression being always true or always false rendering the query execution tree always true or always false irrespective of the query input data at a root of the query execution tree.

6. The data processing apparatus (120) of claim 5, wherein the data processing apparatus(120) is configured to recursively evaluate the query execution tree from one or more leavesof the query execution tree to the root of the query execution tree for determining whether the query execution tree includes at least one conditional expression being always true or always false rendering the query execution tree always true or always false irrespective of the query input data at the root of the query execution tree.

7. The data processing apparatus (120) of any one of the preceding claims, wherein the data processing apparatus (120) is configured to prevent execution of the query plan and / or issue an alert message, in case the query execution tree does include at least one conditional expression being always true or always false rendering the query execution tree always true or always false irrespective of the query input data.

8. The data processing apparatus (120) of any one of the preceding claims, wherein the data processing apparatus (120) is further configured to optimize the query execution plan based on the query execution tree.

9. The data processing apparatus (120) of any one of the preceding claims, wherein the data processing apparatus (120) is a database server (120) including the database (125a) or a web server in communication with the database.

10. The data processing apparatus (120) of any one of the preceding claims, wherein the database (125a) is a relational database (125a) or a database (125a) supporting SQL.

11. A data processing method (600) for generating and executing a query execution plan for a database (125a), wherein the data processing method (600) comprises: generating (601) a query execution tree based on a query (130) in a query language; generating (603) a query execution plan based on the query execution tree; determining (605) whether the query execution tree includes at least one conditional expression being always true or always false rendering the query execution tree always true or always false irrespective of query input data; executing (607) the query execution plan, in case the query execution tree does not include at least one conditional expression being always true or always false rendering the query execution tree always true or always false irrespective of the query input data.

12. A computer program product comprising a computer-readable storage medium for storing program code which causes a computer or a processor to perform the data processing method (600) of claim 11, when the program code is executed by the computer or the processor.