JP3501303B2 - Compiler method for database query statements - Google Patents

Compiler method for database query statements

Info

Publication number
JP3501303B2
JP3501303B2 JP14289294A JP14289294A JP3501303B2 JP 3501303 B2 JP3501303 B2 JP 3501303B2 JP 14289294 A JP14289294 A JP 14289294A JP 14289294 A JP14289294 A JP 14289294A JP 3501303 B2 JP3501303 B2 JP 3501303B2
Authority
JP
Japan
Prior art keywords
language
processing
dbms
sql
compiler
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Lifetime
Application number
JP14289294A
Other languages
Japanese (ja)
Other versions
JPH0816438A (en
Inventor
浩樹 赤間
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nippon Telegraph and Telephone Corp
Original Assignee
Nippon Telegraph and Telephone Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nippon Telegraph and Telephone Corp filed Critical Nippon Telegraph and Telephone Corp
Priority to JP14289294A priority Critical patent/JP3501303B2/en
Publication of JPH0816438A publication Critical patent/JPH0816438A/en
Application granted granted Critical
Publication of JP3501303B2 publication Critical patent/JP3501303B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Description

【発明の詳細な説明】 【0001】 【産業上の利用分野】本発明は、高速な実行を必要とす
るデータベースの問い合わせに用いる埋め込みデータベ
ース問い合わせ文をコンパイル処理するデータベース問
合せ文のコンパイラ方式に関する。 【0002】 【従来の技術】本発明の説明では、以下の略号を用い
る。 DB:リレーショナル型データベース DBMS:リレーショナル型データベース処理システム AP:アプリケーション・プログラム UP:ユーティリティ・プログラム AL:リレーショナル型DBにおけるアクセスのロジッ
ク また、本発明の対象は、リレーショナル型データベース
であるため、以下のデータベースの説明では、「リレー
ショナル型」を省略する。 【0003】データベースの問い合わせ言語とは、デー
タベースに対してデータの追加、削除、更新、検索等を
行うためのデータ操作言語である。JISによって標準
化されたSQLは代表的なデータベース問い合わせ言語
である。データベースの問い合わせ言語を単に問い合わ
せ言語と呼ぶ。 【0004】一般に、問い合わせの処理方法は複数存在
する。例えば、あるカラムにインデックスが付与されて
いる場合、そのインデックスを使用する検索方法と、イ
ンデックスを使用しない検索方法がある。そこで、どの
インデックスをどのように使用して問い合わせを処理す
るかといった情報をアクセスパス情報と呼ぶことにす
る。 【0005】通常の問い合わせ言語(例えばSQL)に
は、アクセスパス情報が含まれていない。これはデータ
ベースの利用者がアクセスパスを意識しなくても検索で
きるようにするためである。 【0006】問い合わせ言語はデータベース利用者が対
話的にデータベースを操作するために使用する場合と、
データベースシステムのプログラムの一部としてプログ
ラム中に埋め込んで使用する場合がある。後者において
プログラム中に埋め込んだ問い合わせ言語を埋め込みデ
ータベース問い合わせ言語、または単に埋め込み言語と
呼び、埋め込むもとになるプログラム言語をホスト言語
と呼ぶことにする。ホスト言語としては、FORTRAN,COBO
L,Pascal,PL/I,C,C++ などの汎用プログラミング言語が
用いられる。以下では、本発明に直接関係する埋め込み
データベース問い合わせ言語について説明する。 【0007】ホスト言語中に埋め込まれた埋め込み問い
合わせ言語は、ホスト言語がホスト言語のコンパイラに
よって翻訳される前に、DBMSの機能またはDBMS
の提供するプリプロセッサのようなUPによって前処理
が行われる。これをデータベース問い合わせ言語処理用
前処理、または単にプリプロセスと呼ぶ。 【0008】SQLなどのようなアクセスパスを含まな
い問い合わせ言語は、その問い合わせ実行の際に非常に
複雑なDBアクセス制御を必要とする。これをDBMS
アクセス制御部の提供する基本機能を使ってどのような
方法で解決するかを記述したものをアクセスロジック
(以下、AL)と呼ぶ。具体的にはALは以下のような
制御や情報を指す。 ・アクセスパス(どのインデックスを使うか?使わない
か?)、 ・問い合わせ結果が複数ロ−の場合のカーソル処理や繰
り返し処理、 ・結合(JOIN)やソートやマージの処理方法、(ネ
ステッドループ結合法か、マージ結合法か、いつソート
を行うのかなど) ・副問い合わせなどの処理、 ・複数テーブル処理に対するアクセス順序制御、 ・一時作業域の利用方法、(ソートや副問い合わせの結
果の保持方法など) ・算術関数や集合関数の演算処理、 ・ホスト変数やカラムへの算術処理、 ・ホスト言語とカラムとのインタフェース処理、(ホス
ト変数−カラム間データ転送、エラー処理) DBMSが問い合わせ言語の処理をインタプリタ方式で
行う場合は、図8に示すようなプリプロセスと図9に示
すような実行時処理が行われる。なお、図において、実
線の矢印は処理の流れを示し、点線の矢印はデータの流
れを示し、一重枠のボックスは処理/プログラムを示
し、二重枠のボックスはデータを示している。 【0009】また、DBMSが問い合わせ言語の処理を
コンパイラ方式で行う場合には、図10に示すようなプ
リプロセスと図11に示すような実行時処理が行われ
る。なお、この例では、プリプロセスの処理がSQLプ
リプロセッサ(C200)とDBMS(C300)に分
かれているが、これらは1つのプログラムであっても一
向に構わない。 【0010】インタプリタ方式はAP実行時に問い合わ
せの翻訳処理を行うため、問い合わせが端末から与えら
れる場合やコンパイルするほどの必要性がない処理(例
えばSQL言語のCOMMIT WORKなどの構文が
簡単なSQL文)に有効である。逆に、コンパイラ方式
はAP実行時の問い合わせ翻訳処理が不要なため、構文
が複雑な問い合わせや高速性が要求される基幹業務での
定型問い合わせなどの処理で有効である。 【0011】以下では、インタプリタ方式とコンパイラ
方式によるDBMSの問い合わせ言語処理を、代表的な
問い合わせ言語であるSQLを例として説明する。 【0012】図2はデータの検索プログラムの例であ
る。この例ではホスト言語はC言語であり、埋め込みデ
ータベース問い合わせ言語はSQL言語である。 【0013】SQL言語をC言語に埋め込む場合、SQ
L言語とC言語を区別するための識別子を付与する。こ
の例ではEXEC SQLと;によって埋め込み問い合
わせ文を囲うことで識別している。 【0014】G103はSQL言語によるデータベース
への問い合わせ文、G101,G102,G104はC
言語の文である。 【0015】まず、従来のインタプリタ方式の説明を行
う。インタプリタ方式におけるプリプロセスの場合、図
2で与えられたプログラムを図8のように処理する。 【0016】(1)A100が図2に対応するとする。
A101に対応する埋め込みSQL文はG104からG
109,G110,G111,G112,G113,G
114の6文である。 【0017】(2)DBMSの提供するプリプロセッサ
(A200)はA100を入力として受け取り、上の6
つのSQL文に対し、SQL文の切り出し(A20
1)、SQL文を引数としたDBMSのSQLインタプ
リタ呼出コード(H110からH112,H114,H
116,H118,H120,H122)の展開(A2
02)を行い、その結果(A300)を出力する。この
ときA300は図12に対応する。 【0018】(3)A300をC言語のコンパイラ(A
400)でコンパイルする。その結果、実行可能なAP
(A500)が生成される。その後、このAPの実行は
図9のように行う。 【0019】(4)AP(B100)はAP(A50
0)に対応する。 【0020】(5)AP(B100)を実行すると、D
BMSのSQLインタプリタ呼出命令(dbmsinterpri
t SQL )が実行され、パラメータ(SQL文の文字
列)を持ってDBMS(B200)に制御が移る。 【0021】(6)DBMS(B200)ではパラメー
タで指定されたSQL文の翻訳(B201)とDBアク
セスの実行(B202)を行い、データ(B401)を
アクセスする。 【0022】なお、SQL文の翻訳時にはスキーマ情報
(B301)を参照する。 【0023】インタプリタ方式では、スキーマの参照を
AP実行時にのみ行うため、スキーマの一貫性保証など
の問題は発生しない。 【0024】次に、従来のコンパイラ方式の説明を行
う。コンパイラ方式におけるプリプロセスの場合、図2
で与えられたプログラムを図10のように処理する。 【0025】(1)C100が図2に対応する。C10
1に対応する埋め込みSQL文はG104からG10
9,G110,G111,G112,G113,G11
4の6文である。 【0026】(2)DBMSの提供するプリプロセッサ
(C200)はC100を入力として受け取り、SQL
文の切り出しを行い(C201)、SQL文のコンパイ
ルを行う(C202)。このSQLのコンパイル過程で
は、切り出したSQL文の構文解析(C301)、スキ
ーマ情報をもとに行う意味解析(C302)、ALの生
成(C303)、ALのAL格納域への登録(C30
4)を行う。なお、ALを登録するときALのIDが付
与されるものとする。ここでは、ALのIDは G104からG109・・・宣言文のためALはG11
0に統合される。 G110・・・352 G111・・・353 G112・・・354 G113・・・355 G114・・・356 であったとする。このALの生成(C303)は更に図
13に示す手順で行われる。このとき、AL内で、ロ−
ID域、中間変数域、カーソル域を必要とする場合に
は、DBMSが管理する領域内に確保するロジックの生
成を行い(C801,C802,C803)、さらに、
SQL文種によって生成される個別ALに対しても、D
BMSが管理する領域内資源を用いて処理を行うロジッ
クが生成(C804−C806)される。 【0027】(3)上述した過程で得たALのIDをも
とにAL呼出実行コードを展開する(C203)。これ
をC100中の全SQL文について行い(I104,I
111,I113,I115,I117,I119)、
その結果(C600)を出力する。このときC600は
図14に対応する。 【0028】(4)C600をC言語のコンパイラ(C
700)でコンパイルする。その結果、実行可能なAP
(C800)が生成される。その後、このAPの実行は
図11のように行う。 【0029】(5)AP(D100)はAP(C80
0)に対応するとする。 【0030】(6)AP(D100)を実行すると、A
L呼出実行命令が実行され、パラメータ(ALのID)
を持ってDBMS(D200)に制御が移る。 【0031】(7)DBMS(D200)ではパラメー
タで指定されたALのIDによってAL格納域内のAL
を特定し(D201)、ALを読み込み(D202)、
AL内のタイムスタンプ情報とスキーマを読み込み(D
202)、ALの実行を行い(D203)、データ(D
401)をアクセスする。 【0032】コンパイラ方式のDBMSは実行時に構文
解析、スキーマ情報の参照、アクセスパス決定などを行
わないため、インタプリタ方式のDBMSに比べDBへ
の高速なアクセスが可能である。 【0033】 【発明が解決しようとする課題】従来のコンパイラ方式
のDBMSにおけるAP実行過程のALに関する処理で
は、 ・ALをDBMS管理下に配置する(C500)、 ・AL中の中間変数、ロ−ID変数、カーソル域はDB
MS管理下に生成する(C801−C803)、 ・AL中の問い合わせ制御処理はDBMS管理下のAL
管理域に生成する(C804−C807)、 ・スキーマの一貫性は、AL管理域中のALのタイムス
タンプと、DBMSのスキーマのバージョンチェックで
保証する(D203)を行うため、 ・AL実行時にALの検索処理や読み込み処理などを行
うため遅い。 ・APとALが全く独立なモジュールとして扱われ、統
合ができない。 ・スキーマの一貫制約が厳しく、分散開発環境に向かな
い。 などの問題があった。 【0034】本発明は、上記に鑑みてなされたもので、
その目的とするところは、ALの高速なアクセス、AP
とALの統合された最適化、および分散開発が可能とな
るデータベース問合せ文のコンパイラ方式を提供するこ
とにある。 【0035】 【課題を解決するための手段】上記目的を達成するた
め、本発明のデータベース問合せ文のコンパイラ方式
は、リレーショナル型データベース問い合わせ文のプリ
コンパイル過程において、アクセスロジック処理中の中
間変数、ロ−ID変数、カーソル域をホスト言語中に確
保し、結合処理、副照会処理中のif,for,whi
le,gotoを含む制御処理をホスト言語中に生成
し、プリコンパイル対象のアクセスロジック中で実際に
使用しているスキーマ値とデータベース管理システム内
のスキーマ値の一致をチェックする処理を、アクセスロ
ジックを最初に実行する部分の直前に生成することを要
旨とする。 【0036】 【作用】本発明のデータベース問合せ文のコンパイラ方
式では、埋め込み問い合わせ文のコンパイルにおいて、
AL処理中の中間変数、ロ−ID変数、カーソル域をホ
スト言語中に生成し、結合処理、副照会処理中のif,
for,while,gotoを含む制御処理をホスト
言語中に生成することによって、ALの検索、ロードが
不要になり、ALの高速な実行が可能になるとともに、
APとALの統合された最適化(ロジック最適化、算術
演算最適化、変数のレジスタ割当)が可能になり、また
プリコンパイル対象のAL中で実際に使用しているスキ
ーマ値とDBMS内のスキーマ値の一致をチェックする
処理を、ALを最初に実行する部分の直前に生成するに
よって、スキーマをDBMSから分離し、分散開発が可
能になる(スキーマがあれば、DBMSなしでもプリコ
ンパイルが可能になる)とともに、スキーマの変更があ
っても、そのAPに影響しない部分の変更であれば、A
Pを変更せずに実行できる。 【0037】 【実施例】以下図面を用いて、本発明の実施例を説明す
る。図1は、本発明の一実施例に係わるデータベース問
合せ文のコンパイラ方式であるプリコンパイル過程を説
明するための図である。図2に示すデータ検索プログラ
ムを参照して本発明の実施例を説明する。 【0038】まず、プリプロセス過程は図1のように行
われる。 【0039】(1)図1のE100が図2に対応すると
する。E101に対応する埋め込みSQL文はG104
からG109,G110,G111,G112,G11
3,G114の6文である。 【0040】(2)DBMSの提供するプリプロセッサ
(E200)はE100を入力として受け取り、SQL
文の切り出しを行い(E201)、SQL文のコンパイ
ルを行う(E202)。このSQLのコンパイル過程で
は、切り出したSQL文の構文解析(E301)、スキ
ーマ情報をもとに行う意味解析(E302)、ALの生
成(E303)、スキーマチェックコードの生成(E3
04)を行う。このALの生成(E303)は更に図3
に示す手順で行われる。この時、AL内で、ロ−ID
域、中間変数域、カーソル域を必要とする場合には、A
P内に確保するロジックの生成をホスト言語で行い(E
801,E802,E803)、更に、SQL文種によ
って生成される個別ALに対しても、AP内に確保する
領域資源を用いて処理を行うロジックが生成(E804
−E806)される。 【0041】(3)上述した過程で得たALをホスト言
語による記述として生成し(E203)、スキーマチェ
ックコードをアクセスロジックの最初に実行する部分の
直前に生成し(E204)、その結果(E500)を出
力する。このときE500は図5,6,7に対応し、E
501はJ104に対応する。 【0042】(4)E500をC言語のコンパイラ(E
600)でコンパイルする。その結果、実行可能なAP
(E700)が生成される。その後、このプログラムの
実行は図4のように行う。 【0043】(5)AP(F100)はAP(E70
0)に対応するとする。 【0044】(6)AP(F100)を実行すると、A
Lが実行され(F101)、その中に記述されたロジッ
クによってDBをアクセスする。 【0045】 【発明の効果】以上説明したように、本発明によれば、
埋め込みデータベース問い合わせ言語のコンパイル処理
において、ALをDBMS管理域から検索、ロードする
過程が不要になることから、高速なアクセス実行が可能
になり、またAPとALのロジック、算術演算、変数の
レジスタ割り当てなどの統合された最適化が可能になる
ことで、高速なアクセス実行が可能になる。更に、スキ
ーマをDBMSから分離することが可能になり、分散開
発が容易になる(スキーマ情報があれば、DBMSなし
でもプリコンパイルが可能になる)。また、スキーマの
変更があっても、そのAPに影響しない部分の変更であ
れば、APを変更せずに実行できるという可用性が向上
する。
Description: BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a database query statement compiler for compiling an embedded database query statement used for querying a database requiring high-speed execution. [0002] In the description of the present invention, the following abbreviations are used. DB: relational database DBMS: relational database processing system AP: application program UP: utility program AL: access logic in relational DB Further, since the object of the present invention is a relational database, the following databases In the description, “relational type” is omitted. [0003] The query language of the database is a data operation language for performing addition, deletion, update, search, etc. of data to the database. SQL standardized by JIS is a typical database query language. The query language of the database is simply called the query language. Generally, there are a plurality of query processing methods. For example, when an index is assigned to a certain column, there are a search method using the index and a search method not using the index. Therefore, information such as which index is used and how to process an inquiry will be referred to as access path information. [0005] A normal inquiry language (eg, SQL) does not include access path information. This is so that the database user can search without having to be aware of the access path. The query language is used when a database user interactively operates a database.
It may be embedded in a program as part of a database system program. In the latter, a query language embedded in a program is called an embedded database query language, or simply an embedded language, and a programming language from which embedding is performed is called a host language. FORTRAN, COBO as host language
General-purpose programming languages such as L, Pascal, PL / I, C, and C ++ are used. The following describes an embedded database query language directly related to the present invention. [0007] The embedded query language embedded in the host language is a function of the DBMS or DBMS before the host language is translated by the host language compiler.
The pre-processing is performed by an UP such as a preprocessor provided by. This is called preprocessing for database query language processing, or simply preprocessing. A query language that does not include an access path, such as SQL, requires a very complicated DB access control when executing the query. This is DBMS
What describes how to solve the problem using the basic function provided by the access control unit is called an access logic (hereinafter, AL). Specifically, AL indicates the following control and information. -Access path (which index to use or not to use?)-Cursor processing and repetition processing when the query result is multiple rows-Processing method of join (JOIN), sort and merge, (Nested loop join method , Merge join method, when to sort, etc.)-Processing such as subqueries,-Access order control for multiple table processing,-Usage of temporary work area, (Method of storing results of sorting and subqueries, etc.) -Arithmetic processing of arithmetic functions and set functions-Arithmetic processing of host variables and columns-Interface processing between host language and columns (host variable-column data transfer, error processing) DBMS interprets query language processing In the case of using the method, a pre-process as shown in FIG. 8 and a runtime process as shown in FIG. 9 are performed. In the drawing, solid arrows indicate the flow of processing, dotted arrows indicate the flow of data, boxes with single frames indicate processing / programs, and boxes with double frames indicate data. When the DBMS performs the processing of the query language by the compiler method, a pre-process as shown in FIG. 10 and a run-time processing as shown in FIG. 11 are performed. In this example, the pre-processing is divided into the SQL preprocessor (C200) and the DBMS (C300), but these may be a single program. In the interpreter system, a query is translated at the time of execution of an AP, so that the query is given from a terminal or is not necessary to compile (for example, an SQL statement having a simple syntax such as COMMIT WORK in the SQL language). It is effective for Conversely, since the compiler method does not require query translation processing at the time of AP execution, it is effective for processing such as queries with complicated syntax and routine queries in mission-critical business requiring high speed. In the following, the query language processing of the DBMS by the interpreter method and the compiler method will be described using SQL as a typical query language as an example. FIG. 2 shows an example of a data search program. In this example, the host language is C and the embedded database query language is SQL. When embedding the SQL language in the C language,
An identifier for distinguishing between the L language and the C language is given. In this example, the embedded inquiry sentence is identified by EXEC SQL ;. G103 is a query sentence to the database in the SQL language, and G101, G102 and G104 are C
This is a language statement. First, a conventional interpreter system will be described. In the case of the preprocess in the interpreter system, the program given in FIG. 2 is processed as shown in FIG. (1) Assume that A100 corresponds to FIG.
The embedded SQL sentence corresponding to A101 is from G104 to G
109, G110, G111, G112, G113, G
There are 6 sentences of 114. (2) The preprocessor (A200) provided by the DBMS receives A100 as an input and
For one SQL sentence, cut out the SQL sentence (A20
1), DBMS SQL interpreter call codes (H110 to H112, H114, H
116, H118, H120, H122) (A2
02), and outputs the result (A300). At this time, A300 corresponds to FIG. (3) Convert A300 to a C language compiler (A
Compile with 400). As a result, executable AP
(A500) is generated. Thereafter, the execution of this AP is performed as shown in FIG. (4) AP (B100) is replaced by AP (A50)
0). (5) When AP (B100) is executed, D
BMS SQL interpreter call instruction (dbms - interpri
t - SQL) is executed, and control is transferred to the DBMS (B200) with the parameter (character string of the SQL statement). (6) The DBMS (B200) translates the SQL sentence specified by the parameter (B201) and executes the DB access (B202) to access the data (B401). When the SQL sentence is translated, the schema information (B301) is referred to. In the interpreter method, since the schema is referred only when the AP is executed, there is no problem such as guarantee of schema consistency. Next, the conventional compiler system will be described. In the case of preprocessing in the compiler system, FIG. 2
Is processed as shown in FIG. (1) C100 corresponds to FIG. C10
The embedded SQL sentence corresponding to 1 is from G104 to G10
9, G110, G111, G112, G113, G11
This is 6 sentences of 4. (2) The preprocessor (C200) provided by the DBMS receives C100 as an input, and
The statement is cut out (C201), and the SQL statement is compiled (C202). In the process of compiling the SQL, syntax analysis of the extracted SQL statement (C301), semantic analysis based on schema information (C302), generation of AL (C303), registration of AL in the AL storage area (C30)
Perform 4). It is assumed that an AL ID is given when an AL is registered. Here, the ID of the AL is G104 to G109...
0. G110 ... 352 G111 ... 353 G112 ... 354 G113 ... 355 G114 ... 356. The generation of this AL (C303) is further performed according to the procedure shown in FIG. At this time,
When an ID area, an intermediate variable area, and a cursor area are required, a logic to be secured in an area managed by the DBMS is generated (C801, C802, C803).
D for individual AL generated by SQL sentence
Logic that performs processing using resources in the area managed by the BMS is generated (C804-C806). (3) The AL call execution code is expanded based on the AL ID obtained in the above process (C203). This is performed for all SQL statements in C100 (I104, I104
111, I113, I115, I117, I119),
The result (C600) is output. At this time, C600 corresponds to FIG. (4) Convert C600 to a C language compiler (C
Compile with 700). As a result, executable AP
(C800) is generated. Thereafter, the execution of this AP is performed as shown in FIG. (5) AP (D100) is replaced by AP (C80)
0). (6) When AP (D100) is executed, A
The L call execution instruction is executed and the parameter (AL ID)
Control is transferred to the DBMS (D200). (7) In the DBMS (D200), the AL ID in the AL storage area is determined by the ID of the AL specified by the parameter.
Is specified (D201), AL is read (D202),
Read the time stamp information and schema in AL (D
202), execute AL (D203), and execute data (D
(401) is accessed. Since the DBMS of the compiler system does not perform syntax analysis, reference to schema information, and determination of an access path at the time of execution, it is possible to access the DB at a higher speed than the DBMS of the interpreter system. [0033] In the processing related to the AL in the AP execution process in the conventional DBMS of the compiler system, the following are arranged:-The AL is placed under the control of the DBMS (C500);-The intermediate variables in the AL; ID variable, cursor area is DB
It is generated under MS management (C801-C803).-Inquiry control processing in AL is performed under AL managed by DBMS.
Generated in the management area (C804-C807). To ensure the consistency of the schema by checking the time stamp of the AL in the AL management area and the version check of the schema of the DBMS (D203). It is slow because it performs search processing and read processing. -AP and AL are treated as completely independent modules and cannot be integrated. -Consistent constraints on the schema are severe, making it unsuitable for a distributed development environment. There was such a problem. The present invention has been made in view of the above,
The purpose is to access AL at high speed, AP
An object of the present invention is to provide a database query statement compiler method that enables integrated optimization and distributed development. In order to achieve the above object, a database query statement compiler system according to the present invention uses an intermediate variable during access logic processing in a precompile process of a relational database query statement. -ID variables and cursor areas are secured in the host language, and if, for, and during join processing and subquery processing
The control processing including le and goto is generated in the host language, and the processing of checking whether the schema value actually used in the access logic to be precompiled matches the schema value in the database management system is performed by the access logic. The gist is to generate it immediately before the part to be executed first. According to the database query statement compiler method of the present invention, in compiling an embedded query statement,
Intermediate variables, row-ID variables, and cursor areas during AL processing are generated in the host language, and if, sub-query processing during if,
By generating control processing including for, while, and goto in the host language, it is not necessary to search and load the AL, and the AL can be executed at high speed.
Enables integrated optimization of AP and AL (logic optimization, arithmetic optimization, register allocation of variables), and schema values actually used in precompiled AL and schema in DBMS By generating the process of checking the value match immediately before the first execution of the AL, the schema can be separated from the DBMS and distributed development becomes possible. (If there is a schema, it is possible to precompile without the DBMS. A), and if there is a change in the schema that does not affect the AP, A
Can be executed without changing P. Embodiments of the present invention will be described below with reference to the drawings. FIG. 1 is a diagram for explaining a precompilation process which is a compiler method of a database query sentence according to an embodiment of the present invention. An embodiment of the present invention will be described with reference to the data search program shown in FIG. First, the pre-process is performed as shown in FIG. (1) Assume that E100 in FIG. 1 corresponds to FIG. The embedded SQL sentence corresponding to E101 is G104
From G109, G110, G111, G112, G11
3, G114. (2) The preprocessor (E200) provided by the DBMS receives E100 as an input, and
The statement is cut out (E201), and the SQL statement is compiled (E202). In the process of compiling the SQL, the syntax analysis of the extracted SQL statement (E301), the semantic analysis performed based on the schema information (E302), the generation of the AL (E303), and the generation of the schema check code (E3)
04). The generation of this AL (E303) is further described in FIG.
The procedure is as follows. At this time, in the AL,
If you need an area, an intermediate variable area, and a cursor area, use A
The logic to be secured in P is generated in the host language (E
801, E 802, and E 803), and a logic for processing the individual AL generated by the SQL sentence using the area resources secured in the AP is generated (E 804).
-E806). (3) The AL obtained in the above process is generated as a description in the host language (E203), and the schema check code is generated immediately before the first execution part of the access logic (E204), and the result (E500) ) Is output. At this time, E500 corresponds to FIGS.
501 corresponds to J104. (4) Convert E500 to a C language compiler (E
Compile at 600). As a result, executable AP
(E700) is generated. Thereafter, the execution of this program is performed as shown in FIG. (5) AP (F100) is replaced by AP (E70)
0). (6) When the AP (F100) is executed, A
L is executed (F101), and the DB is accessed by the logic described therein. As described above, according to the present invention,
In the compilation process of the embedded database query language, the process of retrieving and loading AL from the DBMS management area is not required, so that high-speed access can be performed. AP and AL logic, arithmetic operation, and variable register allocation By performing integrated optimization such as the above, high-speed access execution becomes possible. Furthermore, the schema can be separated from the DBMS, and distributed development can be facilitated (if there is schema information, precompilation can be performed without the DBMS). Further, even if there is a change in the schema, if the change does not affect the AP, the change can be executed without changing the AP, thereby improving the availability.

【図面の簡単な説明】 【図1】本発明の一実施例に係わるデータベース問合せ
文のコンパイラ方式であるプリプロセス過程を説明する
ための図である。 【図2】図1の実施例および従来の例のためのデータ操
作プログラムの例を示す図である。 【図3】本発明のプリプロセス過程(コンパイラ方式)
におけるAL生成過程を説明する図である。 【図4】本発明のAP実行時過程(コンパイラ方式)を
説明するための図である。 【図5】図6および図7とともに、実施例におけるプリ
プロセス後のデータ検索プログラム(コンパイラ方式の
場合)を示す図である。 【図6】図5および図7とともに、実施例におけるプリ
プロセス後のデータ検索プログラム(コンパイラ方式の
場合)を示す図である。 【図7】図5および図6とともに、実施例におけるプリ
プロセス後のデータ検索プログラム(コンパイラ方式の
場合)を示す図である。 【図8】従来のプリプロセス過程(インタプリタ方式)
を説明するための図である。 【図9】従来のAP実行時過程(インタプリタ方式)を
説明するための図である。 【図10】従来のプリプロセス過程(コンパイラ方式)
を説明するための図である。 【図11】従来のAP実行時過程(コンパイラ方式)を
説明するための図である。 【図12】従来のプリプロセス後のデータ検索プログラ
ム(インタプリタ方式の場合)を示す図である。 【図13】従来のAPプリプロセス過程(コンパイラ方
式)におけるAL生成過程を説明する図である。 【図14】従来のプリプロセス後のデータ検索プログラ
ム(コンパイラ方式の場合)を説明する図である。
BRIEF DESCRIPTION OF THE DRAWINGS FIG. 1 is a view for explaining a pre-processing process which is a compiler method of a database query sentence according to an embodiment of the present invention. FIG. 2 is a diagram showing an example of a data operation program for the embodiment of FIG. 1 and a conventional example. FIG. 3 is a diagram showing a pre-processing step (compiler method) of the present invention
FIG. 4 is a diagram illustrating an AL generation process in FIG. FIG. 4 is a diagram for explaining a process (compiler method) when executing an AP according to the present invention. FIG. 5 is a diagram showing a data retrieval program (in the case of a compiler system) after preprocessing in the embodiment, together with FIGS. 6 and 7; 6 is a diagram showing a data search program (in the case of a compiler system) after preprocessing in the embodiment, together with FIGS. 5 and 7. FIG. FIG. 7 is a diagram showing a data search program (in the case of a compiler system) after preprocessing in the embodiment, along with FIGS. 5 and 6; FIG. 8 shows a conventional preprocessing process (interpreter method).
FIG. FIG. 9 is a diagram for explaining a conventional AP execution process (interpreter method). FIG. 10 shows a conventional preprocessing process (compiler method).
FIG. FIG. 11 is a diagram for explaining a conventional AP execution process (compiler method). FIG. 12 is a diagram showing a conventional data search program after preprocessing (in the case of an interpreter system). FIG. 13 is a diagram illustrating an AL generation process in a conventional AP preprocessing process (compiler method). FIG. 14 is a diagram illustrating a conventional data search program after preprocessing (in the case of a compiler method).

Claims (1)

(57)【特許請求の範囲】 【請求項1】 リレーショナル型データベース問い合わ
せ文のプリコンパイル過程において、 アクセスロジック処理中の中間変数、ロ−ID変数、カ
ーソル域をホスト言語中に確保し、 結合処理、副照会処理中のif,for,while,
gotoを含む制御処理をホスト言語中に生成し、 プリコンパイル対象のアクセスロジック中で実際に使用
しているスキーマ値とデータベース管理システム内のス
キーマ値の一致をチェックする処理を、アクセスロジッ
クを最初に実行する部分の直前に生成することを特徴と
するデータベース問合せ文のコンパイラ方式。
(57) [Claims] [Claim 1] In a precompile process of a relational database query statement, an intermediate variable, a row-ID variable, and a cursor area during access logic processing are secured in a host language, and a linking process is performed. , If, for, while,
A control process including "goto" is generated in the host language, and the process of checking whether the schema value actually used in the access logic to be precompiled matches the schema value in the database management system is first performed by the access logic. A database query statement compiler method characterized by being generated immediately before a part to be executed.
JP14289294A 1994-06-24 1994-06-24 Compiler method for database query statements Expired - Lifetime JP3501303B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP14289294A JP3501303B2 (en) 1994-06-24 1994-06-24 Compiler method for database query statements

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP14289294A JP3501303B2 (en) 1994-06-24 1994-06-24 Compiler method for database query statements

Publications (2)

Publication Number Publication Date
JPH0816438A JPH0816438A (en) 1996-01-19
JP3501303B2 true JP3501303B2 (en) 2004-03-02

Family

ID=15326027

Family Applications (1)

Application Number Title Priority Date Filing Date
JP14289294A Expired - Lifetime JP3501303B2 (en) 1994-06-24 1994-06-24 Compiler method for database query statements

Country Status (1)

Country Link
JP (1) JP3501303B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8898203B2 (en) 2005-12-27 2014-11-25 International Business Machines Corporation Generating a separable query design object and database schema through visual view editing

Also Published As

Publication number Publication date
JPH0816438A (en) 1996-01-19

Similar Documents

Publication Publication Date Title
Manegold et al. Database architecture evolution: Mammals flourished long before dinosaurs became extinct
US5778354A (en) Database management system with improved indexed accessing
US6304867B1 (en) System and method for enhanced performance of a relational database management system through the use of application-specific memory-resident data
CN111309757B (en) SQL interpreter and optimization method of HBase
Stonebraker Retrospection on a database system
US5819282A (en) Database generator
US5432930A (en) System for accessing cobol data files by generating a dictionary of NF.sup.2
Rompf et al. Functional pearl: a SQL to C compiler in 500 lines of code
JPH10232875A (en) Data base managing method and parallel data base managing system
US6353819B1 (en) Method and system for using dynamically generated code to perform record management layer functions in a relational database manager
CN115794874A (en) Method for accelerating GPU operator execution in heterogeneous database system and application
US7174553B1 (en) Increasing parallelism of function evaluation in a database
JP3808941B2 (en) Parallel database system communication frequency reduction method
Rosenthal et al. Querying relational views of networks
JP3501303B2 (en) Compiler method for database query statements
Rompf et al. A SQL to C compiler in 500 lines of code
US7974968B2 (en) Direct call threaded code
Jarke et al. Introduction to query processing
Płodzień et al. Object query optimization in the stack-based approach
US6438536B1 (en) Method and system for dynamically generating code to enhance the performance of a relational database manager that provides access to a relational database
US20240095249A1 (en) Producing natively compiled query plans by recompiling existing c code through partial evaluation
von Bultzingsloewen et al. Kardamom—a dataflow database machine for real-time applications
Katz Performance enhancement for relational systems through query compilation
JPH07244601A (en) Method and device for accessing relational data base
Essertel Improving Performance of Data-Centric Systems Through Fine-Grained Code Generation

Legal Events

Date Code Title Description
RD01 Notification of change of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7426

Effective date: 20031127

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20031127

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20071212

Year of fee payment: 4

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20081212

Year of fee payment: 5

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20091212

Year of fee payment: 6

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20101212

Year of fee payment: 7

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20101212

Year of fee payment: 7

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20111212

Year of fee payment: 8

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20111212

Year of fee payment: 8

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20121212

Year of fee payment: 9

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20121212

Year of fee payment: 9

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20131212

Year of fee payment: 10

S531 Written request for registration of change of domicile

Free format text: JAPANESE INTERMEDIATE CODE: R313531

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

EXPY Cancellation because of completion of term