Re: basic question about runtime query parsing

SM Ryan <wyrmwif@tsoft.org>
12 Jul 2005 05:15:52 -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)
Re: basic question about runtime query parsing kers@hpl.hp.com (Chris Dollin) (2005-07-26)
Re: basic question about runtime query parsing lfinsto1@gwdg.de (Laurence Finston) (2005-07-28)
[4 later articles]
| List of all articles for this month |

From: SM Ryan <wyrmwif@tsoft.org>
Newsgroups: comp.compilers
Date: 12 Jul 2005 05:15:52 -0400
Organization: Quick STOP Groceries
References: 05-07-045
Keywords: SQL, parse, code
Posted-Date: 12 Jul 2005 05:15:52 EDT

"falcon" <shahbazc@gmail.com> wrote:


# 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?


Databases like MySQL store the row contents as a sequence of character
strings, and convert to/from character representation and internal
representation on demand.


You can use something like
typedef union {
int i;
long l;
float f;
...
} Union;
typedef Union *Row;
and then create a row with
Row r = malloc((numberOfFields)*sizeof(Union));
r[0].i = intvalue;
r[0].l = longvalue;
r[0].f = floatvalue;
...


--
SM Ryan http://www.rawbw.com/~wyrmwif/
God's a skeeball fanatic.


Post a followup to this message

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