Re: basic question about runtime query parsing

Antoun Kanawati <antounk@comcast.net>
12 Jul 2005 05:13:02 -0400

          From comp.compilers

Related articles
basic question about runtime query parsing shahbazc@gmail.com (falcon) (2005-07-11)
Re: basic question about runtime query parsing antounk@comcast.net (Antoun Kanawati) (2005-07-12)
Re: basic question about runtime query parsing skandgoe@gwdg.de (Skandinavisches Seminar) (2005-07-12)
Re: basic question about runtime query parsing wyrmwif@tsoft.org (SM Ryan) (2005-07-12)
Re: basic question about runtime query parsing gneuner2@comcast.net (George Neuner) (2005-07-12)
Re: basic question about runtime query parsing kers@hpl.hp.com (Chris Dollin) (2005-07-17)
Re: basic question about runtime query parsing lfinsto1@gwdg.de (Laurence Finston) (2005-07-22)
Re: basic question about runtime query parsing shahbazc@gmail.com (falcon) (2005-07-22)
[6 later articles]
| List of all articles for this month |
From: Antoun Kanawati <antounk@comcast.net>
Newsgroups: comp.compilers
Date: 12 Jul 2005 05:13:02 -0400
Organization: Compilers Central
References: 05-07-045
Keywords: SQL, design
Posted-Date: 12 Jul 2005 05:13:02 EDT

falcon wrote:
> Say I have a c library which implements various database functions and
> contains relevant data structures. For effeciency, I keep 'records' of
> a 'table' in a nativ c struct (so 4 'columns' in a table will show up
> as 4 attributes of a struct). I can understand how this will work if
> all someone wants to do is do queries. But what is usually done for
> 'create table' command issued by a user?
>
> By that I mean, if someone issues 'create table(x int, y int, z int),'
> I parse it and figure out I need a struct{int x, int y, int z} (this
> struct will then be passed all over the code). How do I create this
> struct during runtime? One way I can think of is to output the struct
> definition to a file, compile it on the fly and use it. There has to
> be a better way since there are a HUGE number of langauges which use
> compile down to C and they must run into this issue regularly. I'm
> afraid the solution is stupidly simple...but somehow I've missed it.
> Any ideas?


The typical SQL client library provides methods which describe the
column count of a query, and the data types of each column. For
extracting results, the typical SQL client provides for extracting
the data one column at a time.


With the above information, a programmer can define a dynamic aggregate
to describe a row. The mechanism will vary depending on the programming
language, and the interfaces promised by the database-client wrapper.


When the queries are predefined, it is convenient to map them to more
efficient statically defined aggregates, such as a C struct. However,
that is only a special case, not the general case.


--
A. Kanawati
NO.antounk.SPAM@comcast.net


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.