internals.ps
上传用户:blenddy
上传日期:2007-01-07
资源大小:6495k
文件大小:626k
- y(char)h(*result;)318 3131 y(if)g((complex)g(==)h(NULL))f
- (return(NULL);)318 3190 y(result)g(=)h((char)f(*))h(palloc(60);)
- 318 3250 y(sprintf(result,)e("( 45g, 45g)",)h(complex->x,)f
- (complex->y);)318 3310 y(return(result);)258 3370
- y(})p eop
- %%Page: 38 38
- 38 37 bop 270 60 a Ft(38)310 b Fm(CHAPTER)14 b(2.)25
- b(POSTGRESQL)13 b(FR)n(OM)f(THE)i(USER'S)e(POINT)g(OF)g(VIEW)270
- 234 y Ft(Note)h(that)g(the)g(functions)g(de 02ned)g(abo)o(v)o(e)h
- (operate)f(on)g(types)g(that)g(require)g Fp(pass)g(by)h(r)n(efer)n
- (ence)p Ft(.)20 b(The)270 294 y(functions)c(take)h(a)g(pointer)f(to)h
- (the)g(data)g(as)h(ar)o(gument)e(and)h(return)f(a)i(pointer)e(to)h(the)
- g(deri)o(v)o(ed)f(data)270 354 y(instead)h(of)g(passing)g(and)g
- (returning)e(the)i(data)g(itself.)29 b(That')m(s)18 b(why)e(we)h(ha)o
- (v)o(e)g(to)g(reserv)o(e)g(memory)270 413 y(using)f Fr(palloc)f
- Ft(within)g(the)h(functions.)26 b((If)14 b(we)i(would)f(just)h
- (de 02ne)f(a)h(local)g(v)o(ariable)f(and)h(return)270
- 473 y(the)e(addresses)h(of)f(these)h(v)o(ariables)f(the)g(system)h
- (would)e(fail,)i(because)g(the)f(memory)f(used)i(by)f(local)270
- 533 y(v)o(ariables)e(is)h(freed)e(when)i(the)f(function)g(de 02ning)f
- (these)i(v)o(ariables)f(completes.))345 593 y(The)e(ne)o(xt)g(step)g
- (is)g(to)g(compile)f(the)h(C-functions)f(and)h(create)f(the)h(shared)g
- (library)f Fr(complex.so)p Ft(.)270 653 y(This)h(is)g(done)f(in)g(the)h
- (way)f(described)g(in)h(the)f(pre)o(vious)g(section)g
- Fp(Pr)n(ogr)o(amming)h(Language)e(Functions)270 712 y
- Ft(and)j(depends)g(on)g(the)g(system)h(you)f(are)g(using.)k(On)c(a)g
- (Linux)g(ELF)h(system)g(using)f Fr(gcc)f Ft(it)h(would)f(look)270
- 772 y(like)i(this:)330 868 y Fr($)30 b(gcc)f(-I$PGROOT/include)f(-fpic)
- h(-c)60 b(complex.c)29 b(-o)h(complex.o)330 928 y($)g(gcc)f(-shared)g
- (-o)h(complex.so)f(complex.o)270 1023 y Ft(No)o(w)11
- b(we)h(are)f(ready)g(to)g(de 02ne)h(the)f(ne)o(w)g(datatype)g(b)o(ut)g
- (before)g(that)g(we)h(ha)o(v)o(e)g(to)f(make)g(the)g
- Fp(input)g Ft(and)270 1083 y Fp(output)h(function)g Ft(kno)o(wn)f(to)i
- (PostgreSQL:)330 1179 y Fr(testdb=>)29 b(create)g(function)g
- (complex_in(opaque))330 1238 y(testdb->)g(returns)g(complex)330
- 1298 y(testdb->)g(as)g('/<where_ever_you_put_it>/complex.so)o(')330
- 1358 y(testdb->)g(language)g('c';)330 1418 y(NOTICE:)59
- b(ProcedureCreate:)28 b(type)h('complex')g(is)h(not)599
- 1477 y(yet)f(defined)330 1537 y(CREATE)330 1597 y(testdb=>)g(create)g
- (function)g(complex_out(opaque))330 1657 y(testdb->)g(returns)g
- (opaque)330 1717 y(testdb->)g(as)g
- ('/<where_ever_you_put_it>/complex.so)o(')330 1776 y(testdb->)g
- (language)g('c';)330 1836 y(CREATE)330 1896 y(testdb=>)g(create)g(type)
- g(complex)h(()330 1956 y(testdb->)f(internallength)f(=)i(16,)330
- 2015 y(testdb->)f(input)g(=)h(complex_in,)330 2075 y(testdb->)f(output)
- g(=)h(complex_out)330 2135 y(testdb->)f();)330 2195
- y(CREATE)330 2255 y(testdb=>)270 2350 y Ft(Note)37 b(that)f(the)h(ar)o
- (gument)f(type)h(gi)o(v)o(en)f(in)h(the)f(de 02nition)g(of)h
- Fr(complex)p 1798 2350 15 2 v 17 w(out())f Ft(and)270
- 2410 y Fr(complex)p 483 2410 V 17 w(in())28 b Ft(-)g
- Fr(opaque)f Ft(-)h(is)h(needed)f(by)g(PostgreSQL)g(to)g(be)g(able)g(to)
- g(pro)o(vide)g(an)270 2470 y(uniform)14 b(mechanism)i(for)f(the)h
- (de 02nition)e(of)i(the)f Fp(input)h Ft(and)f Fp(output)g(functions)h
- Ft(needed)g(by)f(a)h(ne)o(w)270 2530 y(data)k(type.)40
- b(It)20 b(is)h(not)f(necessary)h(to)f(specify)h(the)f(e)o(xact)h(type)f
- (of)g(the)h(ar)o(guments)f(gi)o(v)o(en)g(to)g(the)270
- 2589 y(functions.)34 b(The)19 b Fp(input)f(function)g
- Ft(is)h(ne)o(v)o(er)f(called)g(e)o(xplicitly)g(and)h(when)g(it)f(is)h
- (called)f(implicitly)270 2649 y((e.g.)24 b(by)15 b(a)g(statement)h
- (like)e Fr(insert)29 b(into)p Ft())15 b(it)f(is)i(clear)f(that)g(a)g
- (character)g(string)f((i.e.)25 b(a)15 b(part)g(of)270
- 2709 y(the)h Fp(insert)h Ft(query))e(will)g(be)i(passed)g(to)f(it.)26
- b(The)17 b Fp(output)e(function)h Ft(is)g(only)g(called)g(()g(by)g(an)
- g(internal)270 2769 y(mechanism)h(of)g(PostgreSQL))g(when)g(data)g(of)
- g(the)g(corresponding)g(user)g(de 02ned)g(type)g(has)h(to)f(be)270
- 2828 y(displayed.)32 b(In)18 b(this)g(case)h(it)e(is)h(also)h(clear)e
- (that)h(the)g(input)f(is)i(of)e(the)h(type)g(used)g(for)f(the)h
- (internal)270 2888 y(representation)12 b((e.g.)k Fr(complex)p
- Ft().)e(The)f(output)f(is)h(of)f(type)g(character)g(string.)270
- 3008 y(The)h(ne)o(w)f(type)g(can)h(no)o(w)f(be)g(used)h(as)g(if)f(it)g
- (were)g(another)g(base)h(type:)330 3103 y Fr(testdb=>)29
- b(create)g(table)g(complex_test)330 3163 y(testdb->)g((val)g
- (complex);)330 3223 y(CREATE)330 3283 y(testdb=>)g(insert)g(into)g
- (complex_test)330 3342 y(testdb->)g((val))g(values)g(('(1,2)');)
- 330 3402 y(INSERT)59 b(155872)29 b(1)p eop
- %%Page: 39 39
- 39 38 bop 198 60 a Fm(2.5.)29 b(SOME)12 b(OF)h(POSTGRESQL)-5
- b('S)12 b(SPECIAL)h(FEA)-6 b(TURES)14 b(IN)e(DET)-5 b(AIL)340
- b Ft(39)258 234 y Fr(testdb=>)29 b(insert)g(into)g(complex_test)258
- 294 y(testdb->)g((val))g(values)g(('(3,4)');)258
- 354 y(INSERT)59 b(155873)29 b(1)258 413 y(testdb=>)g(insert)g(into)g
- (complex_test)258 473 y(testdb->)g((val))g(values)g(('(5,6)');)
- 258 533 y(INSERT)59 b(155874)29 b(1)258 653 y(testdb=>)g(select)g(*)h
- (from)f(complex_test;)318 712 y(val)258 772 y(-----)258
- 832 y((1,2))258 892 y((3,4))258 951 y((5,6))258
- 1011 y((3)g(rows))258 1131 y(testdb=>)198 1272 y Fh(2.5.4)59
- b(Extending)15 b(Operators)198 1365 y Ft(So)i(far)g(we)g(are)h(able)f
- (to)h(de 02ne)f(a)h(ne)o(w)f(type,)i(create)f(tables)f(that)h(use)g
- (the)f(ne)o(w)g(type)h(for)e(one)i((or)198 1425 y(more))13
- b(attrib)o(ute(s))g(and)g(populate)h(the)g(ne)o(w)g(tables)g(with)f
- (data.)21 b(W)l(e)14 b(are)g(also)g(able)g(to)g(retrie)o(v)o(e)f(data)
- 198 1485 y(from)d(those)h(tables)h(as)g(long)e(as)i(we)f(do)g(not)g
- (use)h(the)f(ne)o(w)g(data)g(types)h(within)e(the)h(quali 02cation)f
- (of)h(the)198 1544 y(query)m(.)23 b(If)14 b(we)h(want)f(to)h(use)g(the)
- g(ne)o(w)g(data)g(types)g(in)g(the)g Fr(where)f Ft(clause)i(we)f(ha)o
- (v)o(e)g(to)g(adapt)g(some)198 1604 y((or)d(all))f(of)h(the)h
- (operators.)198 1718 y Fn(Example)g(2.9)25 b Ft(W)l(e)10
- b(sho)o(w)h(ho)o(w)f(the)g(operator)g('=')g(can)g(be)h(adapted)f(for)g
- (the)g(usage)h(on)f(the)h Fr(complex)198 1778 y Ft(data)17
- b(type)g(de 02ned)g(in)f(section)i(2.5.3)f Fp(User)h(De 02ned)f(T)l
- (ypes)p Ft(.)31 b(W)l(e)17 b(need)g(a)g(user)g(de 02ned)g(function)198
- 1838 y Fr(complex)p 411 1838 15 2 v 17 w(cmp(complex,complex))10
- b Ft(that)j(returns)f Fr(true)g Ft(if)g(the)g(comple)o(x)g(numbers)g
- (gi)o(v)o(en)198 1898 y(as)g(ar)o(guments)g(are)g(equal)f(and)h
- Fr(false)g Ft(otherwise.)j(This)d(function)f(is)h(de 02ned)g(as)g
- (described)g(in)g(sec-)198 1957 y(tion)h(2.5.2)i Fp(User)f(De 02ned)g
- (Functions)p Ft(.)20 b(In)13 b(our)g(case)h(there)g(are)f(already)g
- (two)g(functions)g(present)h(for)198 2017 y(the)f(usage)h(of)f(type)h
- Fr(complex)e Ft(-the)h Fp(input)g Ft(and)h Fp(output)f(function)f
- Ft(de 02ned)i(in)f(e)o(xample)g(2.8.)20 b(So)13 b(we)198
- 2077 y(can)k(add)f(the)h(ne)o(w)f(function)f Fr(complex)p
- 943 2077 V 18 w(cmp(complex,complex))f Ft(by)i(simply)g(appending)198
- 2137 y(the)c(follo)o(wing)f(lines)i(to)f(the)g( 02le)g
- Fr(complex.c)g Ft(gi)o(v)o(en)g(in)g(e)o(xample)h(2.8:)258
- 2229 y Fr(/*)29 b(Comparison)g(Function)g(*/)258 2289
- y(/*)g(returns)h(true)f(if)h(arg1)f(and)h(arg2)f(are)h(equal)f(*/)258
- 2348 y(bool)g(complex_cmp(Complex)f(*arg1,)h(Complex)g(*arg2))258
- 2408 y({)318 2468 y(if((arg1->x)f(==)i(arg2->x))f(&&)407
- 2528 y((arg1->y)g(==)h(arg2->y)))318 2588 y({)377
- 2647 y(return)g(true;)318 2707 y(})318 2767 y(else)318
- 2827 y({)377 2886 y(return)g(false;)318 2946 y(})258
- 3006 y(})198 3098 y Ft(No)o(w)12 b(we)h(create)f(the)g(shared)h
- (library)e(again:)258 3190 y Fr($)30 b(gcc)f(-I$PGROOT/include)f(-fpic)
- h(-c)60 b(complex.c)29 b(-o)h(complex.o)258 3250 y($)g(gcc)f(-shared)g
- (-o)h(complex.so)f(complex.o)198 3342 y Ft(Note)10 b(that)f(all)h(the)f
- (functions)h(de 02ned)f(in)h Fr(complex.c)e Ft(()p
- Fr(complex)p 1428 3342 V 17 w(in(),)29 b(complex)p
- 1834 3342 V 18 w(out())198 3402 y Ft(and)12 b Fr(complex)p
- 495 3402 V 18 w(cmp())p Ft())f(are)h(no)o(w)g(contained)g(in)h(the)f
- (shared)g(library)g Fr(complex.so)p Ft(.)p eop
- %%Page: 40 40
- 40 39 bop 270 60 a Ft(40)307 b Fm(CHAPTER)14 b(2.)28
- b(POSTGRESQL)13 b(FR)n(OM)f(THE)i(USER'S)e(POINT)g(OF)g(VIEW)270
- 234 y Ft(No)o(w)k(we)h(make)g(the)f(ne)o(w)h(function)f(kno)o(wn)g(to)h
- (PostgreSQL)f(and)h(after)f(that)h(we)g(de 02ne)f(the)h(ne)o(w)270
- 294 y(operator)11 b('=')h(for)g(the)g Fr(complex)g Ft(type:)330
- 394 y Fr(testdb=>)29 b(create)g(function)g
- (complex_cmp(complex,complex))330 454 y(testdb->)g(returns)g(complex)
- 330 513 y(testdb->)g(as)g('/<where_ever_you_put_it>/complex.so)o(')330
- 573 y(testdb->)g(language)g('c';)330 633 y(CREATE)330
- 693 y(testdb=>)g(create)g(operator)g(=)h(()330 753 y(testdb->)f
- (leftarg)g(=)h(complex,)330 812 y(testdb->)f(rightarg)g(=)h(complex,)
- 330 872 y(testdb->)f(procedure)g(=)g(complex_cmp,)330
- 932 y(testdb->)g(commutator)g(=)g(=)330 992 y(testdb->)g();)330
- 1051 y(CREATE)330 1111 y(testdb=>)270 1211 y Ft(From)12
- b(no)o(w)h(on)h(we)f(are)h(able)f(to)g(perform)f(comparisons)i(between)
- f(comple)o(x)g(numbers)g(in)h(a)f(query')m(s)270 1271
- y(quali 02cation)f((W)l(e)g(use)h(the)f(table)g Fr(complex)p
- 1100 1271 15 2 v 17 w(test)g Ft(as)h(de 02ned)f(in)h(e)o(xample)f
- (2.8):)330 1371 y Fr(testdb=>)29 b(select)g(*)h(from)f(complex_test)
- 330 1431 y(testdb->)g(where)g(val)h(=)f('(1,2)';)390
- 1491 y(val)330 1550 y(-----)330 1610 y((1,2))330 1670
- y((1)g(row))330 1789 y(testdb=>)g(select)g(*)h(from)f(complex_test)
- 330 1849 y(testdb->)g(where)g(val)h(=)f('(7,8)';)390
- 1909 y(val)330 1969 y(-----)330 2029 y((0)g(rows))330
- 2148 y(testdb=>)270 2291 y Fh(2.5.5)59 b(Extending)15
- b(Aggr)o(egates)270 2385 y Ft(If)e(we)i(want)e(to)h(use)h(aggre)o(gate)
- f(functions)f(on)h(attrib)o(utes)g(of)g(a)g(user)g(de 02ned)g(type,)h
- (we)g(ha)o(v)o(e)f(to)g(add)270 2445 y(aggre)o(gate)19
- b(functions)f(designed)h(to)g(work)f(on)h(the)g(ne)o(w)f(type.)36
- b(Aggre)o(gates)19 b(in)g(PostgreSQL)f(are)270 2504 y(realized)12
- b(using)h(three)f(functions:)345 2604 y Fo( 17)25 b
- Fr(sfunc1)13 b Ft((state)i(function)e(one):)19 b(is)c(called)g(for)e
- (e)o(v)o(ery)i(tuple)f(of)g(the)g(current)g(group)g(and)g(the)395
- 2664 y(appropriate)d(attrib)o(ute')m(s)h(v)o(alue)h(of)f(the)h(current)
- f(tuple)g(is)h(passed)h(to)e(the)h(function.)j(The)d(gi)o(v)o(en)395
- 2724 y(ar)o(gument)f(is)h(used)h(to)e(change)i(the)f(internal)f(state)h
- (of)g(the)g(function)f(in)h(the)g(way)f(gi)o(v)o(en)h(by)g(the)395
- 2784 y(body)f(of)h(the)g(function.)k(F)o(or)c(e)o(xample)g
- Fr(sfunc1)g Ft(of)g(the)g(aggre)o(gate)f(function)h Fr(sum)g
- Ft(is)g(called)395 2843 y(for)f(e)o(v)o(ery)h(tuple)g(of)g(the)h
- (current)e(group.)19 b(The)14 b(v)o(alue)f(of)g(the)g(attrib)o(ute)g
- (the)g(sum)h(is)g(b)o(uilt)e(on)i(is)395 2903 y(taken)d(from)h(the)g
- (current)g(tuple)g(and)g(added)g(to)h(the)f(internal)g(sum)g(state)h
- (of)f Fr(sfunc1)p Ft(.)345 3003 y Fo( 17)25 b Fr(sfunc2)12
- b Ft(is)h(also)g(called)g(for)g(e)o(v)o(ery)f(tuple)h(of)f(the)h(group)
- g(b)o(ut)f(it)h(does)g(not)g(use)h(an)o(y)f(ar)o(gument)395
- 3063 y(from)g(outside)h(to)g(manipulate)g(its)h(state.)22
- b(It)13 b(just)i(keeps)f(track)g(of)g(the)g(o)o(wn)g(internal)g(state.)
- 22 b(A)395 3123 y(typical)10 b(application)g(for)g Fr(sfunc2)h
- Ft(is)g(a)g(counter)f(that)h(is)g(incremented)f(for)g(e)o(v)o(ery)h
- (tuple)g(of)f(the)395 3183 y(group)h(that)h(has)h(been)g(processed.)345
- 3283 y Fo( 17)25 b Fr(finalfunc)14 b Ft(is)i(called)f(after)g(all)g
- (tuples)g(of)g(the)g(current)g(group)f(ha)o(v)o(e)i(been)f(processed.)
- 26 b(It)395 3342 y(takes)10 b(the)f(internal)h(state)g(of)g
- Fr(sfunc1)f Ft(and)h(the)g(state)h(of)e Fr(sfunc2)h Ft(as)g(ar)o
- (guments)g(and)g(deri)o(v)o(es)395 3402 y(the)h(result)h(of)f(the)h
- (aggre)o(gate)g(function)f(from)f(the)i(two)f(gi)o(v)o(en)h(ar)o
- (guments.)j(F)o(or)d(e)o(xample)f(with)p eop
- %%Page: 41 41
- 41 40 bop 198 60 a Fm(2.5.)29 b(SOME)12 b(OF)h(POSTGRESQL)-5
- b('S)12 b(SPECIAL)h(FEA)-6 b(TURES)14 b(IN)e(DET)-5 b(AIL)340
- b Ft(41)323 234 y(the)9 b(aggre)o(gate)h(function)f Fr(average)p
- Ft(,)h Fr(sfunc1)f Ft(sums)h(up)g(the)f(attrib)o(ute)g(v)o(alues)h(of)f
- (each)h(tuple)323 294 y(in)j(the)g(group,)g Fr(sfunc2)f
- Ft(counts)i(the)f(tuples)g(in)g(the)g(group.)18 b Fr(finalfunc)12
- b Ft(di)o(vides)h(the)g Fp(sum)323 354 y Ft(by)f(the)g
- Fp(count)g Ft(to)g(deri)o(v)o(e)g(the)h(a)o(v)o(erage.)198
- 462 y(If)e(we)g(de 02ne)g(an)g(aggre)o(gate)g(using)h(only)f
- Fr(sfunc1)f Ft(we)i(get)f(an)g(aggre)o(gate)g(that)g(computes)h(a)f
- (running)198 522 y(function)h(of)h(the)g(attrib)o(ute)f(v)o(alues)h
- (from)f(each)i(tuple.)j Fr(sum)c Ft(is)h(an)f(e)o(xample)g(for)f(this)h
- (kind)g(of)g(aggre-)198 582 y(gate.)18 b(On)13 b(the)g(other)g(hand,)h
- (if)e(we)h(create)h(an)f(aggre)o(gate)g(function)f(using)h(only)g
- Fr(sfunc2)g Ft(we)g(get)g(an)198 642 y(aggre)o(gate)i(that)g(is)g
- (independent)g(of)g(the)g(attrib)o(ute)f(v)o(alues)h(from)g(each)g
- (tuple.)24 b Fr(count)15 b Ft(is)g(a)g(typical)198 702
- y(e)o(xample)d(of)g(this)h(kind)f(of)g(aggre)o(gate.)198
- 840 y Fn(Example)h(2.10)25 b Ft(Here)h(we)g(want)g(to)g(realize)g(the)g
- (aggre)o(gate)g(functions)g Fr(complex)p 1796 840 15
- 2 v 17 w(sum)g Ft(and)198 899 y Fr(complex)p 411 899
- V 17 w(avg)12 b Ft(for)g(the)g(user)h(de 02ned)f(type)g
- Fr(complex)g Ft((see)g(e)o(xample)h(2.8).)198 1019
- y(First)53 b(we)h(ha)o(v)o(e)g(to)f(create)g(the)h(user)f(de 02ned)h
- (functions)f Fr(complex)p 1769 1019 V 17 w(add)g Ft(and)198
- 1079 y Fr(complex)p 411 1079 V 17 w(scalar)p 608 1079
- V 17 w(div)p Ft(.)34 b(W)l(e)19 b(can)g(append)f(these)h(two)f
- (functions)g(to)g(the)h( 02le)f Fr(complex.c)198 1138
- y Ft(from)11 b(e)o(xample)i(2.8)f(again)h((as)f(we)h(did)f(with)g
- Fr(complex)p 1214 1138 V 17 w(cmp)p Ft():)258 1250 y
- Fr(/*)29 b(Add)h(Complex)f(numbers)g(*/)258 1310 y(Complex)g(*)258
- 1370 y(complex_add(Complex)f(*arg1,)h(Complex)g(*arg2))258
- 1430 y({)318 1489 y(Complex)g(*result;)318 1609 y(result)g(=)h
- ((Complex)f(*)palloc(sizeof(Complex));)318 1669
- y(result->x)f(=)i(arg1->x)f(+)h(arg2->x;)318 1729 y(result->y)e(=)i
- (arg1->y)f(+)h(arg2->y;)318 1788 y(return(result);)258
- 1848 y(})258 1968 y(/*)f(Final)h(function)f(for)g(complex)g(average)h
- (*/)258 2027 y(/*)f(Transform)g(arg1)h(to)f(polar)h(coordinate)f(form)
- 288 2087 y(*)g(R)h(*)g(e210(j*phi))f(and)g(divide)h(R)f(by)h(arg2.)
- 288 2147 y(*)f(Transform)g(the)h(new)f(result)h(back)f(to)h(cartesian)
- 288 2207 y(*)f(coordinates)g(*/)258 2267 y(Complex)g(*)258
- 2326 y(complex_scalar_div(Complex)e(*sum,)i(int)h(count))258
- 2386 y({)318 2446 y(Complex)f(*result;)318 2506 y(double)g(R,)g(phi;)
- 318 2625 y(result)g(=)h((Complex)f(*)palloc(sizeof(Complex));)318
- 2745 y(/*)g(transform)g(to)h(polar)f(coordinates)g(*/)318
- 2804 y(R)g(=)h(hypot(sum->x,sum->y);)318 2864 y(phi)f(=)h
- (atan(sum->y)f(/)g(sum->x);)318 2984 y(/*)g(divide)g(by)h(the)g
- (scalar)f(count)g(*/)318 3044 y(R)g(=)h(R)g(/)g(count;)318
- 3163 y(/*)f(transform)g(back)h(to)f(cartesian)g(coordinates)g(*/)318
- 3223 y(result->x)f(=)i(R)g(*)g(cos(phi);)318 3283 y(result->y)e(=)i
- (R)g(*)g(sin(phi);)318 3342 y(return(result);)258
- 3402 y(})p eop
- %%Page: 42 42
- 42 41 bop 270 60 a Ft(42)307 b Fm(CHAPTER)14 b(2.)28
- b(POSTGRESQL)13 b(FR)n(OM)f(THE)i(USER'S)e(POINT)g(OF)g(VIEW)270
- 234 y Ft(Ne)o(xt)23 b(we)h(create)f(the)h(shared)f(library)f
- Fr(complex.so)g Ft(again,)27 b(which)c(will)g(contain)g(all)g(func-)270
- 294 y(tions)16 b(de 02ned)g(in)h(the)f(pre)o(vious)g(e)o(xamples)g(as)
- h(well)g(as)g(the)f(ne)o(w)g(functions)g Fr(complex)p
- 1878 294 15 2 v 17 w(add)g Ft(and)270 354 y Fr(complex)p
- 483 354 V 17 w(scalar)p 680 354 V 17 w(div)p Ft(:)330
- 538 y Fr($)30 b(gcc)f(-I$PGROOT/include)f(-fpic)h(-c)60
- b(complex.c)29 b(-o)h(complex.o)330 598 y($)g(gcc)f(-shared)g(-o)h
- (complex.so)f(complex.o)270 761 y Ft(No)o(w)13 b(we)g(ha)o(v)o(e)h(to)f
- (make)g(the)g(functions)g(needed)g(by)h(the)f(ne)o(w)g(aggre)o(gates)g
- (kno)o(wn)g(to)g(PostgreSQL.)270 821 y(After)f(that)g(we)h(de 02ne)g
- (the)f(two)g(ne)o(w)h(aggre)o(gate)f(functions)g Fr(complex)p
- 1552 821 V 17 w(sum)h Ft(and)f Fr(complex)p 1966 821
- V 17 w(avg)270 881 y Ft(that)g(make)g(use)h(of)f(the)g(functions)g
- Fr(complex)p 1094 881 V 17 w(add)g Ft(and)h Fr(complex)p
- 1508 881 V 17 w(scalar)p 1705 881 V 17 w(div)p Ft(:)330
- 1066 y Fr(testdb=>)29 b(create)g(function)g
- (complex_add(complex,complex))330 1125 y(testdb->)g(returns)g
- (complex)330 1185 y(testdb->)g(as)g
- ('/<where_ever_you_put_it>/complex.so)o(')330 1245 y(testdb->)g
- (language)g('c';)330 1305 y(CREATE)330 1365 y(testdb=>)g(create)g
- (function)g(complex_scalar_div(complex,int))330 1424
- y(testdb->)g(returns)g(complex)330 1484 y(testdb->)g(as)g
- ('/<where_ever_you_put_it>/complex.so)o(')330 1544 y(testdb->)g
- (language)g('c';)330 1604 y(CREATE)330 1663 y(testdb=>)g(create)g
- (aggregate)g(complex_sum)g(()330 1723 y(testdb->)g(sfunc1)g(=)h
- (complex_add,)330 1783 y(testdb->)f(basetype)g(=)h(complex,)330
- 1843 y(testdb->)f(stype1)g(=)h(complex,)330 1903 y(testdb->)f
- (initcond1)g(=)g('(0,0)')330 1962 y(testdb->)g();)330
- 2022 y(CREATE)330 2082 y(testdb=>)g(create)g(aggregate)g(complex_avg)g
- (()330 2142 y(testdb->)g(sfunc1)g(=)h(complex_add,)330
- 2201 y(testdb->)f(basetype)g(=)h(complex,)330 2261 y(testdb->)f(stype1)
- g(=)h(complex,)330 2321 y(testdb->)f(sfunc2)g(=)h(int4inc,)330
- 2381 y(testdb->)f(stype2)g(=)h(int4,)330 2441 y(testdb->)f(finalfunc)g
- (=)g(complex_scalar_div,)330 2500 y(testdb->)g(initcond1)g(=)g
- ('(0,0)',)330 2560 y(testdb->)g(initcond2)g(=)g('0')330
- 2620 y(testdb->)g();)330 2680 y(CREATE)270 2843 y Ft(The)20
- b(aggre)o(gate)e(function)g Fr(complex)p 976 2843 V 17
- w(sum)h Ft(is)g(de 02ned)g(using)g(only)g Fr(sfunc1)p
- Ft(.)35 b Fr(basetype)18 b Ft(is)270 2903 y(the)e(type)g(of)g(the)h
- (result)f(of)g(the)g(aggre)o(gate)g(function.)27 b(The)17
- b(function)e Fr(complex)p 1751 2903 V 17 w(add)h Ft(is)h(used)g(as)270
- 2963 y Fr(sfunc1)d Ft(and)h Fr(stype1)e Ft(de 02nes)i(the)g(type)f
- Fr(sfunc1)g Ft(will)g(operate)g(on.)23 b Fr(initcond1)13
- b Ft(gi)o(v)o(es)i(the)270 3022 y(initial)d(v)o(alue)g(of)g(the)g
- (internal)g(state)g(of)g Fr(sfunc1)p Ft(.)270 3103 y(If)20
- b(we)h(look)f(at)g(the)h(de 02nition)e(of)i(the)f(aggre)o(gate)g
- (function)g Fr(complex)p 1618 3103 V 17 w(avg)h Ft(we)f(can)h(see)g
- (that)270 3163 y(the)k(part)f(concerning)h Fr(sfunc1)f
- Ft(is)i(identical)e(to)h(the)g(corresponding)f(part)h(of)f(the)h
- (de 02nition)270 3223 y(of)e Fr(complex)p 548 3223 V
- 17 w(sum)p Ft(.)49 b(The)25 b(only)e(dif)o(ference)f(is)i(the)f
- (additional)g(de 02nition)g(of)g Fr(sfunc2)g Ft(and)270
- 3283 y Fr(finalfunc)p Ft(.)34 b(The)19 b(b)o(uilt)f(in)g(function)g
- Fr(int4inc)g Ft(is)h(used)g(as)g Fr(sfunc2)f Ft(and)h(increments)f(the)
- 270 3342 y(internal)c(state)i(of)e Fr(sfunc2)g Ft(for)h(e)o(v)o(ery)f
- (tuple)h(processed.)24 b(After)14 b(all)h(tuples)g(ha)o(v)o(e)g(been)h
- (processed)270 3402 y Fr(complex)p 483 3402 V 17 w(scalar)p
- 680 3402 V 17 w(div)d Ft(is)f(used)h(as)g Fr(finalfunc)e
- Ft(to)i(create)f(the)g(a)o(v)o(erage.)p eop
- %%Page: 43 43
- 43 42 bop 198 60 a Fm(2.5.)29 b(SOME)12 b(OF)h(POSTGRESQL)-5
- b('S)12 b(SPECIAL)h(FEA)-6 b(TURES)14 b(IN)e(DET)-5 b(AIL)340
- b Ft(43)198 234 y(From)11 b(no)o(w)h(on)h(we)f(can)h(use)g(the)f(ne)o
- (w)g(aggre)o(gate)g(functions:)258 334 y Fr(testdb=>)29
- b(select)g(*)h(from)f(complex_test;)318 394 y(val)258
- 454 y(-----)258 514 y((1,2))258 573 y((3,4))258 633
- y((5,6))258 693 y((3)g(rows))258 813 y(testdb=>)g(select)g
- (complex_sum(val))f(from)i(complex_test;)347 872 y(val)258
- 932 y(------)258 992 y((9,12))258 1052 y((1)f(row))258
- 1171 y(testdb=>)g(select)g(complex_avg(val))f(from)i(complex_test;)
- 318 1231 y(val)258 1291 y(-----)258 1351 y((3,4))258
- 1410 y((1)f(row))258 1530 y(testdb=>)198 1673 y Fh(2.5.6)59
- b(T)l(riggers)198 1767 y Ft(PostgreSQL)14 b(supports)h(the)f(calling)g
- (of)g(C)h(functions)f(as)h(trigger)f(actions.)22 b(T)n(riggers)15
- b(are)g(not)f(a)h(fea-)198 1827 y(ture)d(that)h(is)g(only)f(present)h
- (in)f(PostgreSQL.)h(In)f(fact)g(most)h(modern)f(RDMSs)h(support)g
- (triggers.)j(W)l(e)198 1887 y(describe)g(them)g(here)g(because)i(the)e
- (pre)o(vious)f(sections)i(are)g(necessary)g(to)f(understand)g(the)g
- (imple-)198 1946 y(mentation)c(chosen.)273 2006 y(At)g(the)h(moment)f
- (it)g(is)h(possible)g(to)f(de 02ne)h(trigger)e(actions)i(that)f(are)h
- (e)o(x)o(ecuted)g Fp(befor)n(e)g Ft(and)g Fp(after)198
- 2066 y Ft(the)k(SQL)h(commands)f Fr(insert,)29 b(update)17
- b Ft(or)g Fr(delete)g Ft(for)g(a)g(tuple.)31 b(T)n(riggers)18
- b(can)f(be)h(used)198 2126 y(to)e(ensure)g(data)g(inte)o(grity)m(.)26
- b(F)o(or)15 b(e)o(xample)h(we)h(can)f(de 02ne)g(a)g(trigger)f(action)h
- (that)g(returns)f(an)h(error)198 2186 y(whene)o(v)o(er)11
- b(somebody)g(wants)f(to)h(insert)g((or)f(update))h(a)g(tuple)g(with)f
- (a)h(ne)o(gati)o(v)o(e)g(supplier)g(id)g Fr(sno)f Ft(into)198
- 2245 y(table)i Fr(supplier)g Ft(de 02ned)g(in)g( 02gure)g(1.1.)273
- 2305 y(The)36 b(system)g(stores)h(information)d(about)h(when)h(a)g
- (trigger)f(action)h(has)g(to)g(be)g(per)o(-)198 2365
- y(formed.)75 b(Whene)o(v)o(er)33 b(a)g(command)f(triggering)f(an)i
- (action)f(is)h(detected,)38 b(the)33 b Fr(trigger)198
- 2425 y(manager)g Ft(is)h(called)f(within)g(PostgreSQL,)h(which)f
- (initializes)g(a)h(global)f(data)h(structure)198 2485
- y Fr(TriggerData)29 b(*CurrentTriggerData)10 b Ft(and)i(calls)h(the)f
- (appropriate)g(trigger)f(function.)198 2604 y(A)44 b(central)f(role)h
- (in)f(the)h(de 02nition)f(of)h(trigger)e(functions)i(plays)g(the)g
- (global)f(data)198 2664 y(structure)84 b Fr(TriggerData)29
- b(*CurrentTriggerData)83 b Ft((The)h(global)h(pointer)198
- 2724 y Fr(CurrentTriggerData)10 b Ft(can)j(be)g(accessed)g(from)e
- (within)h(e)o(v)o(ery)g(trigger)g(function):)258 2824
- y Fr(typedef)29 b(struct)g(TriggerData)258 2884 y({)318
- 2944 y(TriggerEvent)118 b(tg_event;)318 3003 y(Relation)238
- b(tg_relation;)318 3063 y(HeapTuple)208 b(tg_trigtuple;)318
- 3123 y(HeapTuple)g(tg_newtuple;)318 3183 y(Trigger)268
- b(*tg_trigger;)258 3242 y(})30 b(TriggerData;)198 3342
- y Ft(No)o(w)12 b(we)g(gi)o(v)o(e)g(a)g(short)g(description)f(of)h(the)f
- (structure')m(s)h(contents)g(rele)o(v)o(ant)f(for)g(the)h(e)o(xample)g
- (belo)o(w)m(.)198 3402 y(F)o(or)g(a)g(detailed)h(description)e(of)h
- (this)h(and)f(other)g(structures)g(and)h(functions)e(refer)h(to)g
- ([LOCK98]:)p eop
- %%Page: 44 44
- 44 43 bop 270 60 a Ft(44)307 b Fm(CHAPTER)14 b(2.)28
- b(POSTGRESQL)13 b(FR)n(OM)f(THE)i(USER'S)e(POINT)g(OF)g(VIEW)345
- 234 y Fo( 17)25 b Fr(tg)p 458 234 15 2 v 17 w(event)p
- Ft(:)j(Describes)19 b(the)f(e)o(v)o(ent)h(the)f(function)g(is)h(called)
- g(for)m(.)34 b(Contains)19 b(information)395 294 y(about)11
- b(when)g(the)g(function)g(was)g(called)h(()p Fp(befor)n(e)f
- Ft(or)g Fp(after)23 b Ft(the)11 b(command)g(e)o(x)o(ecution))h(and)f
- (for)395 354 y(which)h(command)g(it)g(was)g(called)h(()p
- Fr(insert,)28 b(update)12 b Ft(or)g Fr(delete)p Ft().)345
- 450 y Fo( 17)25 b Fr(tg)p 458 450 V 17 w(relation)p
- Ft(:)87 b(Is)49 b(a)g(pointer)e(to)i(a)g(structure)f(describing)g(the)g
- (relation.)395 510 y Fr(tg)p 458 510 V 17 w(relation-)p
- Fk(>)p Fr(rd)p 844 510 V 17 w(att)12 b Ft(is)g(of)g(special)h(interest)
- f(for)g(us)h(because)g(it)f(can)g(be)h(gi)o(v)o(en)f(as)h(an)395
- 570 y(ar)o(gument)e(to)h(the)h(function)e Fr(SPI)p 990
- 570 V 18 w(getbinval())g Ft(described)h(later)m(.)345
- 667 y Fo( 17)25 b Fr(tg)p 458 667 V 17 w(trigtuple)p
- Ft(:)16 b(Is)e(a)f(pointer)g(to)g(the)g(tuple)g(for)g(which)g(the)g
- (trigger)f(is)i( 02red.)k(If)12 b(the)i(com-)395 726
- y(mand)e(is)g Fr(insert)g Ft(or)g Fr(delete)g Ft(this)g(is)h(the)f
- (tuple)g(to)h(be)f(returned)f(by)i(the)f(trigger)f(function.)345
- 823 y Fo( 17)25 b Fr(tg)p 458 823 V 17 w(newtuple)p
- Ft(:)18 b(If)c(the)g(command)g(is)g Fr(update)g Ft(this)g(is)g(a)h
- (pointer)e(to)h(the)g(ne)o(w)g(v)o(ersion)h(of)395 883
- y(tuple)d(and)g(NULL)h(otherwise.)i(This)e(is)g(what)f(has)h(to)f(be)g
- (returned)g(by)g(the)g(trigger)f(function)h(if)395 942
- y(the)g(command)g(is)g Fr(update)p Ft(.)270 1058 y Fn(Example)h(2.11)25
- b Ft(W)l(e)16 b(de 02ne)g(a)h(trigger)e(function)g(called)i
- Fr(trigf())e Ft(that)h(is)h(designed)f(to)h(pre)o(v)o(ent)270
- 1117 y(inserting)12 b((updating))f(tuples)h(with)g(a)h(ne)o(gati)o(v)
- o(e)f(supplier)g(id)g Fr(sno)g Ft(into)g(table)h Fr(supplier)p
- Ft(.)270 1237 y(First)26 b(we)g(ha)o(v)o(e)h(to)f(de 02ne)g(the)h
- (function)e Fr(trigf())h Ft(using)g(C)h(and)f(therefore)f(we)i
- (create)f(a)270 1297 y(ne)o(w)14 b( 02le)g Fr(trigger.c)p
- Ft(.)20 b(The)15 b(function)e(de 02nition)h(is)g(done)g(in)g(e)o
- (xactly)h(the)f(same)g(way)g(as)h(for)e(the)270 1356
- y(de 02nition)e(of)h(user)h(de 02ned)f(functions)g((see)g(section)h
- (2.5.2).)270 1476 y(Here)f(are)h(the)f(contents)g(of)g
- Fr(trigger.c)p Ft(:)270 1570 y Fr(#include)29 b(<executor/spi.h>)270
- 1629 y(#include)g(<commands/trigger.h>)270 1749 y(HeapTuple)270
- 1809 y(trigf())270 1868 y({)h(TupleDesc)208 b(tupdesc;)330
- 1928 y(HeapTuple)g(rettuple;)330 1988 y(bool)358 b(isnull;)330
- 2048 y(int)388 b(val;)330 2167 y(if)29 b((!CurrentTriggerData))390
- 2227 y(elog(ERROR,)f("trigf:)h(triggers)g(are)h(not)f(initialized");)
- 330 2347 y(/*)g(tuple)h(to)f(return)h(to)f(Executor)g(*/)330
- 2406 y(if)g((TRIGGER_FIRED_BY_UPDATE(CurrentTrig)o(gerData->)o
- (tg_event)o()))390 2466 y(rettuple)g(=)g
- (CurrentTriggerData->tg_newtuple;)330 2526 y(else)390
- 2586 y(rettuple)g(=)g(CurrentTriggerData->tg_trigtuple;)330
- 2705 y(tupdesc)g(=)h(CurrentTriggerData->tg_relati)o(on->rd_at)o(t;)330
- 2765 y(CurrentTriggerData)e(=)h(NULL;)330 2885 y(/*)g(get)h(the)g
- (value)f(of)h(attribute)e(1)i(of)g(the)f(current)h(tuple)f(*/)330
- 2944 y(val)g(=)h(SPI_getbinval(rettuple,)d(tupdesc,)i(1,)h(&isnull);)
- 330 3064 y(/*)f(if)h(the)g(value)f(is)h(NULL)f(or)h(<)g(0)f(return)h
- (an)f(error)h(*/)330 3124 y(if)f((isnull)h(||)f(val)h(<)g(0))f({)419
- 3184 y(elog(ERROR,"insert/update:)e(sno)j(must)f(be)h(a)g(value)f(>)h
- (0");)330 3243 y(})330 3303 y(return)f((rettuple);)270
- 3363 y(})p eop
- %%Page: 45 45
- 45 44 bop 198 60 a Fm(2.5.)29 b(SOME)12 b(OF)h(POSTGRESQL)-5
- b('S)12 b(SPECIAL)h(FEA)-6 b(TURES)14 b(IN)e(DET)-5 b(AIL)340
- b Ft(45)198 234 y(The)20 b(function)e Fr(SPI)p 573 234
- 15 2 v 18 w(getbinval)g Ft(is)i(part)e(of)h(the)g Fp(Server)i(Pr)n(ogr)
- o(amming)e(Interface)g((SPI))f Ft(de-)198 294 y(scribed)13
- b(in)g(section)g(2.5.7.)19 b(It)13 b(takes)g(the)g(current)f(tuple,)h
- (the)g(description)g(of)g(the)g(relation,)g(the)g(num-)198
- 354 y(ber)k(of)g(the)h(attrib)o(ute)f(and)g(the)h(address)g(of)f(a)h(v)
- o(ariable)f Fr(isnull)g Ft(as)h(ar)o(guments)f(and)h(returns)f(the)198
- 413 y(binary)c(v)o(alue)h(of)f(the)h(gi)o(v)o(en)f(attrib)o(ute)g(from)
- g(the)h(current)f(tuple.)20 b(If)13 b(the)g(attrib)o(ute')m(s)h(v)o
- (alue)f(is)h(NULL)198 473 y Fr(isnull)e Ft(is)g(set)h(to)f
- Fr(true)g Ft(otherwise)h(to)f Fr(false)p Ft(.)273 533
- y Fr(trigf())23 b Ft( 02rst)g(checks)h(whether)f(it)h(was)f(called)h
- (by)f(an)h Fr(update)f Ft(command)g(or)g(by)h(an)198
- 593 y Fr(insert)19 b Ft(and)g(sets)h Fr(rettuple)e Ft(accordingly)m(.)
- 36 b(Then)19 b(it)g(gets)h(the)f(v)o(alue)g(of)g(the)g( 02rst)g
- (attrib)o(ute)198 653 y(of)e(the)g(current)g(tuple)g((remember)f
- Fr(sno)i Ft(is)f(the)h( 02rst)f(attrib)o(ute)f(in)i(the)f(relation)g
- Fr(supplier)p Ft().)30 b(If)198 712 y(the)14 b(v)o(alue)h(is)f
- (greater)g(than)g(zero)h(the)f(current)g(tuple)g(is)h(returned)e((and)
- h(inserted)h(or)f(updated)g(by)g(the)198 772 y(e)o(x)o(ecutor)e(of)f
- (PostgreSQL))g(otherwise)h(an)g(error)f(is)h(returned)f(()p
- Fr(elog(ERROR,)p Fk(:)d(:)g(:)n Fr())k Ft(logs)g(an)g(error)198
- 832 y(and)g(aborts)h(processing))f(and)g(the)g(table)h
- Fr(supplier)e Ft(won')o(t)g(be)i(af)o(fected.)198 951
- y(T)l(o)g(create)f(a)h(shared)f(library)f(out)i(of)f
- Fr(trigger.c)f Ft(we)h(use)h(the)g(commands:)258 1035
- y Fr($)30 b(gcc)f(-I$PGROOT/include)f(-I$PGSRC/include/)g(-fpic)h(\)
- 258 1095 y(>)h(-c)f(trigger.c)g(-o)h(trigger.o)258 1155
- y($)g(gcc)f(-shared)g(-o)h(trigger.so)f(trigger.o)198
- 1238 y Ft(Note)24 b(that)f(for)g(the)g(compilation)g(of)g(trigger)g
- (functions)g(the)h(source)f(code)h(of)g(PostgreSQL)f(is)198
- 1298 y(necessary)m(.)16 b Fr($PGSRC)c Ft(points)g(to)h(the)f(place)g
- (where)h(the)f(sources)h(are)f(installed.)198 1418 y(Ne)o(xt)20
- b(we)h(ha)o(v)o(e)g(to)f(make)f(the)i(function)e Fr(trigf())h
- Ft(kno)o(wn)f(to)h(PostgreSQL)g(by)g(the)h Fr(create)198
- 1477 y(function)13 b Ft(command)h(in)f(the)h(same)h(way)e(we)h(did)g
- (for)f(the)h(functions)g(in)f(the)h(pre)o(vious)g(e)o(xamples)198
- 1537 y((e.g.)19 b(e)o(xample)14 b(2.8).)k(After)13
- b(that)g(we)h(can)f(de 02ne)g(the)h(trigger)e Fr(tbefore)p
- Ft(.)18 b(The)c(de 02nition)f(ensures)198 1597 y(that)e(function)g
- Fr(trigf())g Ft(gi)o(v)o(en)g(as)i(the)e(trigger)g(action)g(will)g
- (be)h(e)o(x)o(ecuted)g Fr(before)f Ft(the)h(e)o(x)o(ecution)198
- 1657 y(of)24 b(the)g(commands)g Fr(insert)g Ft(and)g
- Fr(update)g Ft(af)o(fecting)f(the)h(table)g Fr(supplier)p
- Ft(.)51 b(Note)24 b(that)198 1717 y Fr(insert)17 b Ft(and)h
- Fr(update)f Ft(commands)h(e)o(x)o(ecuted)g(against)g(tables)g(other)g
- (than)f Fr(supplier)g Ft(won')o(t)198 1776 y(cause)c(the)f(e)o(x)o
- (ecution)h(of)f(function)f Fr(trigf())p Ft(.)258 1860
- y Fr(testdb=>)29 b(create)g(function)g(trigf())g(returns)g(opaque)258
- 1920 y(testdb->)g(as)g('/<where_ever_you_put_it/trigger.so')258
- 1980 y(testdb->)g(language)g('c';)258 2039 y(CREATE)258
- 2099 y(testdb=>)g(create)g(trigger)g(tbefore)258 2159
- y(testdb->)g(before)g(insert)g(or)h(update)f(on)h(supplier)258
- 2219 y(testdb->)f(for)g(each)h(row)f(execute)g(procedure)g(trigf();)
- 258 2278 y(CREATE)258 2338 y(testdb=>)198 2422 y Ft(No)o(w)14
- b(we)g(can)g(check)g(if)g(the)g(trigger)f(is)h(working)f(correctly)m(.)
- 20 b(If)13 b(the)h(v)o(alue)g(for)f Fr(sno)g Ft(is)i(greater)e(than)198
- 2482 y(zero)f(the)h Fr(insert)e Ft(and)i Fr(update)e
- Ft(commands)i(against)f(table)g Fr(supplier)g Ft(are)g(not)g(af)o
- (fected.)258 2565 y Fr(testdb=>)29 b(insert)g(into)g(supplier)258
- 2625 y(testdb->)g((sno,)g(sname,)g(city))258 2685 y(testdb->)g
- (values(5,)g('Miles',)g('Berlin');)258 2745 y(INSERT)g(156064)g(1)258
- 2864 y(testdb=>)g(insert)g(into)g(supplier)258 2924 y(testdb->)g
- ((sno,)g(sname,)g(city))258 2984 y(testdb->)g(values(-2,)g('Huber',)
- g('Munich');)258 3044 y(ERROR:)59 b(insert/update:)28
- b(sno)i(must)f(be)h(a)g(value)f(>)h(0)258 3163 y(testdb=>)f(update)g
- (supplier)258 3223 y(testdb->)g(set)g(sno)h(=)g(-2)258
- 3283 y(testdb->)f(where)g(sname)g(=)h('Adams';)258 3342
- y(ERROR:)59 b(insert/update:)28 b(sno)i(must)f(be)h(a)g(value)f(>)h(0)
- 258 3402 y(testdb=>)p eop
- %%Page: 46 46
- 46 45 bop 270 60 a Ft(46)307 b Fm(CHAPTER)14 b(2.)28
- b(POSTGRESQL)13 b(FR)n(OM)f(THE)i(USER'S)e(POINT)g(OF)g(VIEW)270
- 234 y Fh(2.5.7)59 b(Ser)o(v)o(er)14 b(Pr)o(ogramming)f(Interface)g
- ((SPI))270 328 y Ft(The)20 b Fp(Server)g(Pr)n(ogr)o(amming)g
- (Interface)f((SPI))g Ft(gi)o(v)o(es)g(the)h(user)f(the)h(ability)e
- (to)i(run)f(SQL)g(queries)270 387 y(from)10 b(inside)i(user)f
- (de 02ned)h(functions.)j(SPI)10 b(is)i(just)f(a)h(set)g(of)f(nati)o(v)
- o(e)g(interface)g(functions)g(to)g(simplify)270 447 y(the)29
- b(access)h(to)f(the)g Fr(query)g(parser,)g(planner,)g(optimizer)f
- Ft(and)h Fr(executor)g Ft(of)270 507 y(PostgreSQL)12
- b((refer)f(to)h(chapter)g(3)h Fp(P)l(ostgr)n(eSQL)g(fr)n(om)f(the)g
- (Pr)n(ogr)o(ammer')n(s)i(P)l(oint)e(of)g(V)l(ie)o(w)p
- Ft().)270 626 y(The)h(set)g(of)f(functions)g(of)f(SPI)h(can)g(be)h(di)
- o(vided)f(into)g(the)g(follo)o(wing)f(parts:)345 724
- y Fo( 17)25 b Ft(Interface)11 b(Functions:)17 b(These)d(functions)e
- (are)h(used)h(to)f(establish)h(a)f(connection)g(to)g(a)g(running)395
- 784 y(backend.)i(Whene)o(v)o(er)c(you)h(want)g(to)f(e)o(x)o(ecute)i(a)f
- (SQL)g(query)g(within)f(a)h(user)g(de 02ned)g(function)395
- 844 y(you)g(will)g(ha)o(v)o(e)g(to)h(connect)f(to)g(a)h(backend)f(by)g
- Fr(SPI)p 1314 844 15 2 v 18 w(connect())p Ft(.)454
- 943 y Fn(226)25 b Fr(SPI)p 597 943 V 18 w(connect())11
- b Ft(opens)i(a)f(connection)g(to)h(the)f(PostgreSQL)g(backend.)454
- 1022 y Fn(226)25 b Fr(SPI)p 597 1022 V 18 w(finish())11
- b Ft(closes)i(a)g(connection)f(to)g(the)h(PostgreSQL)f(backend.)454
- 1101 y Fn(226)25 b Fr(SPI)p 597 1101 V 18 w(exec())15
- b Ft(takes)g(a)h(character)f(string)h(containing)f(a)g(SQL)h(query)f
- (and)h(a)g(number)504 1160 y Fr(tcount)11 b Ft(as)h(ar)o(guments)f(and)
- g(e)o(x)o(ecutes)h(the)g(query)m(.)i(The)e(result)f(can)h(be)f
- (obtained)g(from)504 1220 y(the)17 b(global)g(data)g(structure)f
- Fr(SPI)p 1108 1220 V 18 w(tuptable)g Ft(which)h(is)g(set)h(by)f
- Fr(SPI)p 1801 1220 V 18 w(exec())p Ft(.)29 b(If)504
- 1280 y Fr(tcount)12 b Ft(is)i(zero)e(then)h(the)g(query)f(is)i(e)o(x)o
- (ecuted)f(for)f(all)h(tuples)g(returned)f(by)h(the)g(query)504
- 1340 y(scan.)27 b(Using)16 b Fr(tcount)f Fk(>)h Ft(0)g(restricts)g(the)
- f(number)h(of)f(tuples)h(for)f(which)h(the)g(query)504
- 1399 y(will)d(be)h(e)o(x)o(ecuted.)21 b(This)14 b(function)f(should)g
- (only)h(be)g(called)f(after)g Fr(SPI)p 1786 1399 V 18
- w(connect())504 1459 y Ft(has)g(been)f(processed)h(and)g(a)f
- (connection)g(has)h(been)g(established.)454 1538 y Fn(226)25
- b Fr(SPI)p 597 1538 V 18 w(prepare())85 b Ft(creates)h(and)g(returns)
- f(an)h(e)o(x)o(ecution)g(plan)504 1598 y((parser+planner+optimizer))
- 23 b(b)o(ut)j(doesn')o(t)g(e)o(x)o(ecute)g(the)g(query)m(.)56
- b((The)26 b(function)504 1658 y(performs)15 b(the)i(same)f(steps)h(as)
- g Fr(SPI)p 1163 1658 V 18 w(exec())f Ft(e)o(xcept)g(that)g(it)g(does)
- h(not)f(e)o(x)o(ecute)h(the)504 1717 y(plan.)f(Should)11
- b(only)h(be)h(called)f(after)g(a)h(connection)f(has)g(been)h
- (established.)454 1796 y Fn(226)25 b Fr(SPI)p 597 1796
- V 18 w(saveplan())10 b Ft(stores)h(a)g(plan)g(prepared)f(by)h
- Fr(SPI)p 1518 1796 V 18 w(prepare())f Ft(in)h(safe)g(mem-)504
- 1856 y(ory)h(protected)g(from)f(freeing)h(by)g Fr(SPI)p
- 1199 1856 V 17 w(finish())p Ft(.)454 1935 y Fn(226)25
- b Fr(SPI)p 597 1935 V 18 w(execp())12 b Ft(e)o(x)o(ecutes)h(a)g(plan)
- f(prepared)g(by)g Fr(SPI)p 1491 1935 V 18 w(prepare())g
- Ft(or)g(returned)f(by)504 1995 y Fr(SPI)p 597 1995 V
- 18 w(saveplan())p Ft(.)345 2094 y Fo( 17)25 b Ft(Interface)8
- b(Support)i(Functions:)j(These)f(functions)e(can)g(be)h(used)g(from)e
- (within)h(a)g(connected)h(or)395 2153 y(within)g(an)g(unconnected)h
- (user)f(de 02ned)h(function.)j(An)c(e)o(xample)h(for)f(the)g(use)h
- (from)f(within)g(an)395 2213 y(unconnected)k(function)g(was)h(gi)o(v)o
- (en)g(in)f(e)o(xample)h(2.11)g(where)g Fr(SPI)p 1634
- 2213 V 17 w(getbinval())f Ft(was)395 2273 y(used)h(to)g(deli)o(v)o
- (er)g(the)g(v)o(alue)g(of)g(attrib)o(ute)g Fr(sno)g Ft(from)f(the)h(ne)
- o(w)g((to)g(be)g(inserted))g(tuple.)27 b(An)395 2333
- y(e)o(xample)12 b(for)f(the)h(use)g(from)f(within)g(a)h(connected)g
- (function)f(will)h(be)g(gi)o(v)o(en)g(in)f(e)o(xample)h(2.12.)454
- 2432 y Fn(226)25 b Fr(SPI)p 597 2432 V 18 w(copytuple())11
- b Ft(makes)h(a)h(copy)f(of)f(the)i(tuple)f(gi)o(v)o(en)g(as)h(ar)o
- (gument.)454 2510 y Fn(226)25 b Fr(SPI)p 597 2510 V
- 18 w(modifytuple())j Ft(modi 02es)i(one)g(or)f(more)h(attrib)o(utes)
- f(of)h(a)g(gi)o(v)o(en)g(tu-)504 2570 y(ple.)73 b(The)32
- b(ne)o(w)g(v)o(alues)f(for)g(the)g(attrib)o(utes)g(to)g(be)h(changed)g
- (are)f(passed)h(to)504 2630 y Fr(SPI)p 597 2630 V 18
- w(modifytuple())11 b Ft(as)i(ar)o(guments.)454 2709
- y Fn(226)25 b Fr(SPI)p 597 2709 V 18 w(fnumber())11
- b Ft(takes)h(the)g(description)g(of)g(a)g(tuple)g(and)g(the)h
- Fp(name)f Ft(of)g(an)g(attrib)o(ute)504 2769 y(as)h(ar)o(guments)f(and)
- h(returns)e(the)i Fp(number)f Ft(of)g(the)h(attrib)o(ute.)454
- 2848 y Fn(226)25 b Fr(SPI)p 597 2848 V 18 w(fname())13
- b Ft(takes)g(the)g(description)g(of)h(a)f(tuple)g(and)h(the)f
- Fp(number)h Ft(of)f(an)h(attrib)o(ute)504 2907 y(as)f(ar)o(guments)f
- (and)h(returns)e(the)i Fp(name)f Ft(of)g(the)g(attrib)o(ute.)454
- 2986 y Fn(226)25 b Fr(SPI)p 597 2986 V 18 w(getvalue())13
- b Ft(takes)g(the)h(description)g(of)f(a)h(tuple,)h(the)e(tuple)h(and)g
- (the)g(number)504 3046 y(of)k(an)g(attrib)o(ute)f(as)i(ar)o(guments)e
- (and)i(returns)e(a)h Fp(string)h(r)n(epr)n(esentation)g
- Ft(of)e(the)h(gi)o(v)o(en)504 3106 y(attrib)o(ute')m(s)12
- b(v)o(alue.)454 3185 y Fn(226)25 b Fr(SPI)p 597 3185
- V 18 w(getbinval())10 b Ft(takes)h(the)g(description)g(of)f(a)i
- (tuple,)f(the)h(tuple)e(and)i(the)f(number)504 3244 y(of)h(an)h(attrib)
- o(ute)e(as)i(ar)o(guments)f(and)g(returns)g(the)h(binary)e(v)o(alue)h
- (of)g(the)h(gi)o(v)o(en)f(attrib)o(ute.)454 3323 y Fn(226)25
- b Fr(SPI)p 597 3323 V 18 w(gettype())11 b Ft(returns)h(a)h(copy)e(of)
- h(the)h(type)f(name)g(for)g(the)g(speci 02ed)h(attrib)o(ute.)454
- 3402 y Fn(226)25 b Fr(SPI)p 597 3402 V 18 w(gettypeid())11
- b Ft(returns)h(the)g(type)g(OID)g(for)g(the)g(speci 02ed)h(attrib)o
- (ute.)p eop
- %%Page: 47 47
- 47 46 bop 198 60 a Fm(2.5.)26 b(SOME)12 b(OF)h(POSTGRESQL)-5
- b('S)12 b(SPECIAL)h(FEA)-6 b(TURES)14 b(IN)e(DET)-5 b(AIL)343
- b Ft(47)382 234 y Fn(226)25 b Fr(SPI)p 525 234 15 2
- v 18 w(getrelname())11 b Ft(returns)h(the)g(name)g(of)g(the)h
- (speci 02ed)f(relation.)382 315 y Fn(226)25 b Fr(SPI)p
- 525 315 V 18 w(palloc())e Ft(allocates)i(memory)m(.)50
- b(In)23 b(contrast)h(to)g Fr(malloc())g Ft((normally)432
- 375 y(used))15 b(it)g(allocates)h(memory)e(in)h(such)h(a)f(way)g(that)
- g(it)g(can)g(be)g(freed)g(automatically)f(by)432 434
- y Fr(SPI)p 525 434 V 18 w(finish())p Ft(.)382 515 y
- Fn(226)25 b Fr(SPI)p 525 515 V 18 w(repalloc())12
- b Ft(reallocates)i(memory)f(that)h(has)g(originally)f(been)g(allocated)
- h(us-)432 575 y(ing)e Fr(SPI)p 601 575 V 18 w(palloc())p
- Ft(.)382 656 y Fn(226)25 b Fr(SPI)p 525 656 V 18 w(pfree())11
- b Ft(frees)i(memory)e(allocated)h(by)h Fr(SPI)p 1397
- 656 V 17 w(palloc())p Ft(.)198 778 y Fn(Example)g(2.12)25
- b Ft(W)l(e)14 b(want)g(PostgreSQL)f(to)h(automatically)g(generate)g(a)g
- (v)o(alue)g(for)f(the)i(supplier)e(id)198 838 y Fr(sno)e
- Ft(whene)o(v)o(er)g(a)g(ne)o(w)h(tuple)f(is)g(inserted)g(into)g(table)g
- Fr(supplier)p Ft(.)k(Therefore)c(we)g(de 02ne)g(a)h
- Fp(trigger)198 898 y(function)k Fr(trigf)p 531 898 V
- 17 w(sno())g Ft(that)g(is)g(called)h(before)e(the)i(e)o(x)o(ecution)f
- (of)g(e)o(v)o(ery)g Fr(insert)g Ft(statement.)198 958
- y Fr(trigf)p 351 958 V 17 w(sno())c Ft(has)h(to)f(perform)f(the)i
- (follo)o(wing)d(steps:)273 1059 y Fo( 17)25 b Ft(establish)12
- b(a)h(connection)f(to)g(the)g(PostgreSQL)g(backend)g(using)h
- Fr(SPI)p 1547 1059 V 17 w(connect())273 1161 y Fo( 17)25
- b Ft(get)12 b(the)g(greatest)h(supplier)f(id)g Fr(sno)g
- Ft(contained)g(in)g(table)g Fr(supplier)g Ft(using)g
- Fr(SPI)p 1794 1161 V 18 w(exec())273 1262 y Fo( 17)25
- b Ft(modify)13 b(attrib)o(ute)h Fr(sno)h Ft(of)g(the)f(tuple)h(to)g(be)
- g(inserted)f(to)h(contain)g(the)g(ne)o(xt)g(greater)f(number)323
- 1322 y(using)e Fr(SPI)p 536 1322 V 18 w(modifytuple())273
- 1424 y Fo( 17)25 b Ft(disconnect)12 b(from)f(the)i(backend)f(using)g
- Fr(SPI)p 1122 1424 V 18 w(finish())273 1526 y Fo( 17)25
- b Ft(return)11 b(the)h(modi 02ed)g(tuple)198 1627 y(Here)26
- b(are)h(the)f(contents)h(of)f(function)g Fr(trigf)p 1103
- 1627 V 17 w(sno())g Ft(that)h(can)f(be)h(appended)f(to)h(the)f
- ( 02le)198 1687 y Fr(trigger.c)11 b Ft(from)h(e)o(xample)g(2.11:)258
- 1788 y Fr(HeapTuple)258 1848 y(trigf_sno())258 1908
- y({)30 b(HeapTuple)208 b(rettuple;)318 1968 y(bool)358
- b(isnull;)318 2027 y(int)388 b(ret,)29 b(max;)318 2087
- y(int)388 b(atts_to_be_changed[1];)318 2147 y(Datum)328
- b(new_value[1];)318 2207 y(char)358 b(nulls;)318 2326
- y(if)29 b((!CurrentTriggerData))377 2386 y(elog(ERROR,)527
- 2446 y("trigf:)g(triggers)g(are)g(not)h(initialized");)318
- 2565 y(/*)f(This)h(is)f(the)h(tuple)f(to)h(be)g(inserted)f(*/)318
- 2625 y(rettuple)g(=)g(CurrentTriggerData->tg_trigtuple;)318
- 2745 y(/*)g(Connect)g(to)h(backend)f(*/)318 2804 y(if)g(((ret)h(=)f
- (SPI_connect()))g(<)g(0))377 2864 y(elog(ERROR,)527
- 2924 y("trigf_sno:)f(SPI_connect)h(returned)g( 45d",ret);)318
- 3044 y(/*)g(Get)h(greatest)f(sno)g(in)h(relation)f(supplier)g(*/)318
- 3103 y(/*)g(Execute)g(the)h(query)f(*/)318 3163 y(ret)g(=)h
- (SPI_exec("select)e(max(sno))h(from)g(supplier",0);)318
- 3223 y(if)g((ret)h(<)f(0))407 3283 y(elog(ERROR,)557
- 3342 y("trigf_sno:)f(SPI_exec)h(returned)g( 45d",ret);)p
- eop
- %%Page: 48 48
- 48 47 bop 270 60 a Ft(48)307 b Fm(CHAPTER)14 b(2.)28
- b(POSTGRESQL)13 b(FR)n(OM)f(THE)i(USER'S)e(POINT)g(OF)g(VIEW)390
- 234 y Fr(/*)29 b(extract)g(the)h(number)f(from)h(the)f(result)419
- 294 y(*)h(returned)f(by)h(the)f(query.)h(SPI_exec())e(puts)419
- 354 y(*)i(the)g(result)f(into)g(the)h(global)f(structure)419
- 413 y(*)h(SPI_tuptable)f(*/)390 473 y(max)g(=)h
- (SPI_getbinval(SPI_tuptable->val)o(s[0],)987 533 y
- (SPI_tuptable->tupdesc,)e(1,)987 593 y(&isnull);)390
- 712 y(/*)h(disconnect)g(from)g(backend)h(*/)390 772 y(SPI_finish();)
- 390 892 y(/*)f(array)h(containing)e(the)i(numbers)f(of)h(attributes)419
- 951 y(*)g(to)g(be)g(changed:)f(sno)g(has)h(attno)f(1)h(*/)390
- 1011 y(atts_to_be_changed[0])d(=)j(1;)390 1131 y(/*)f(new)h(values)f
- (for)h(attributes)e(to)i(be)g(changed:)419 1191 y(*)g(the)g(next)f
- (number)g(for)h(sno)g(is)f(max+1)h(*/)390 1250 y(new_value[0])e(=)i
- ((max+1);)390 1370 y(/*)f(modify)g(the)h(tuple)f(to)h(be)g(inserted)f
- (to)g(contain)419 1430 y(*)h(max+1)g(as)f(sno)h(*/)390
- 1489 y(rettuple)f(=)449 1549 y(SPI_modifytuple(CurrentTriggerData-)o
- (>tg_relat)o(ion,)928 1609 y(rettuple,)928 1669 y(1,)928
- 1729 y(atts_to_be_changed,)928 1788 y(new_value,)928
- 1848 y(&nulls);)390 1968 y(if)g((rettuple)g(==)h(NULL))479
- 2027 y(elog(ERROR,)629 2087 y("trigf_sno:)e(SPI_modifytuple)h
- (failed");)390 2207 y(CurrentTriggerData)e(=)j(NULL;)390
- 2267 y(return)f((rettuple);)330 2326 y(})270 2456 y
- Ft(W)l(e)13 b(again)f(create)g(the)g(shared)h(library)e
- Fr(trigger.so)g Ft(out)i(of)e Fr(trigger.c)p Ft(:)330
- 2595 y Fr($)30 b(gcc)f(-I$PGROOT/include)f(-I$PGSRC/include/)g(-fpic)h
- (\)330 2655 y(>)h(-c)f(trigger.c)g(-o)h(trigger.o)330
- 2714 y($)g(gcc)f(-shared)g(-o)h(trigger.so)f(trigger.o)270
- 2844 y Ft(Ne)o(xt)16 b(we)g(ha)o(v)o(e)h(to)f(make)f(the)h(function)f
- Fr(trigf)p 1155 2844 15 2 v 18 w(sno())g Ft(kno)o(wn)g(to)h
- (PostgreSQL)g(and)g(after)f(that)270 2904 y(we)j(can)f(de 02ne)h(the)f
- (trigger)g Fr(sno)p 894 2904 V 17 w(before)g Ft(which)h(is)f(called)h
- (before)f(an)g Fr(insert)g Ft(to)h(the)f(table)270 2963
- y Fr(supplier)p Ft(.)30 b(The)18 b(trigger)e(function)g(ensures)i(that)
- f(the)h(ne)o(xt)f(greater)g(number)f(for)h Fr(sno)g Ft(will)g(be)270
- 3023 y(used.)330 3162 y Fr(testdb=>)29 b(create)g(function)g
- (trigf_sno())g(returns)g(opaque)330 3222 y(testdb->)g(as)g
- ('/<where_ever_you_put_it>/trigger.so)o(')330 3282 y(testdb->)g
- (language)g('c';)330 3342 y(CREATE)p eop
- %%Page: 49 49
- 49 48 bop 198 60 a Fm(2.5.)29 b(SOME)12 b(OF)h(POSTGRESQL)-5
- b('S)12 b(SPECIAL)h(FEA)-6 b(TURES)14 b(IN)e(DET)-5 b(AIL)340
- b Ft(49)258 234 y Fr(testdb=>)29 b(create)g(trigger)g(sno_before)258
- 294 y(testdb->)g(before)g(insert)g(on)h(supplier)258
- 354 y(testdb->)f(for)g(each)h(row)f(execute)g(procedure)g
- (trigf_sno();)258 413 y(CREATE)258 473 y(testdb=>)198
- 585 y Ft(Ev)o(ery)12 b(time)f(a)h(ne)o(w)g(tuple)f(is)h(inserted)f(to)h
- (the)f(table)h Fr(supplier)f Ft(a)h(ne)o(w)f Fr(sno)h
- Ft(is)g(assigned)g(automat-)198 645 y(ically)g(re)o(gardless)h(of)e
- (the)i(v)o(alue)f(gi)o(v)o(en)g(in)g(the)h Fr(insert)e
- Ft(statement:)258 747 y Fr(testdb=>)29 b(select)g(*)h(from)f(supplier;)
- 258 806 y(sno|sname)g(|city)258 866 y(---+------+------)318
- 926 y(1|Smith)g(|London)318 986 y(2|Jones)g(|Paris)318
- 1046 y(3|Adams)g(|Vienna)318 1105 y(4|Blake)g(|Rome)258
- 1165 y((4)g(rows))258 1285 y(testdb=>)g(insert)g(into)g(supplier)258
- 1344 y(testdb->)g((sno,)g(sname,)g(city))258 1404 y(testdb->)g
- (values)g((200,'Cook',)g('Boston');)258 1464 y(INSERT)g(15606)g(1)258
- 1584 y(testdb=>)g(select)g(*)h(from)f(supplier;)258 1643
- y(sno|sname)g(|city)258 1703 y(---+------+------)318
- 1763 y(1|Smith)g(|London)318 1823 y(2|Jones)g(|Paris)318
- 1882 y(3|Adams)g(|Vienna)318 1942 y(4|Blake)g(|Rome)318
- 2002 y(5|Cook)59 b(|Boston)258 2062 y((5)29 b(rows))258
- 2181 y(testdb=>)198 2327 y Fh(2.5.8)59 b(Rules)15 b(in)g(P)o(ostgr)o
- (eSQL)198 2421 y Ft(PostgreSQL)f(supports)f(a)i(po)o(werful)d
- Fp(rule)j(system)p Ft(.)21 b(The)15 b(user)f(can)g(de 02ne)g(a)g(rule)
- f(and)h(connect)g(it)g(to)198 2481 y(an)g(e)o(v)o(ent.)19
- b(Whene)o(v)o(er)13 b(the)h(e)o(v)o(ent)f(occurs)h(the)g(rule)f(body)g
- (is)h(e)o(x)o(ecuted)g(in)f(addition)g(to)h(or)f(instead)h(of)198
- 2541 y(the)e(commands)h(of)f(the)g(e)o(v)o(ent.)198 2661
- y(A)g(rule)g(is)h(created)f(using)h(the)f(follo)o(wing)f(SQL)h
- (statement:)258 2762 y Fr(create)29 b(rule)g(rule_name)258
- 2822 y(as)g(on)h(event)258 2882 y(to)f(object)h([where)f(clause])258
- 2942 y(do)g([instead])258 3002 y([action)g(|)h(nothing)f(|)h
- ([actions...]])198 3103 y Ft(where)20 b Fr(event)f Ft(is)h(one)g(of)f
- Fr(select,)29 b(update,)g(delete)19 b Ft(or)h Fr(insert)p
- Ft(.)39 b Fr(object)19 b Ft(is)h(the)198 3163 y(name)14
- b(of)g(a)h Fp(table)f Ft(or)f Fp(table)o(.column)p Ft(.)22
- b(The)15 b Fr(where)f Ft(clause,)i(and)e(the)g Fr(action)g
- Ft(are)g(a)g(normal)g(SQL)198 3222 y Fr(where)e Ft(clause)h(and)f
- (collection)g(of)g(SQL)h(commands.)273 3283 y(One)k(application)g(of)h
- (rules)f(is)h(the)g(implementation)e(of)h Fp(vie)o(ws)i
- Ft(in)e(PostgreSQL.)h(A)g Fp(vie)o(w)g Ft(is)g(a)198
- 3342 y Fp(virtual)e Ft(table)g(that)g(does)g(not)g(physically)g(e)o
- (xist)g(within)g(the)g(database)g(b)o(ut)g(looks)g(to)g(the)g(user)g
- (as)h(if)198 3402 y(it)f(did.)28 b(T)l(o)17 b(realize)f(a)h
- Fp(vie)o(w)g Ft(we)g(can)f(create)h(an)f(empty)g(table)h(with)f(the)g
- (name)h(of)f(the)g Fp(vie)o(w)p Ft(.)29 b(Then)p eop
- %%Page: 50 50
- 50 49 bop 270 60 a Ft(50)307 b Fm(CHAPTER)14 b(2.)28
- b(POSTGRESQL)13 b(FR)n(OM)f(THE)i(USER'S)e(POINT)g(OF)g(VIEW)270
- 234 y Ft(we)h(de 02ne)g(a)g(rule)g(that)f(is)i( 02red)e(e)o(v)o(ery)h
- (time)f(the)h(ne)o(w)g(table)g(is)g(accessed.)19 b(Instead)13
- b(of)g(retrie)o(ving)e(the)270 294 y(data)k(from)e(the)i
- Fp(virtual)f Ft(table)h(the)f(rule)g(body)g(is)h(e)o(x)o(ecuted)g
- (retrie)o(ving)e(the)i(data)g(from)e(one)i(or)f(more)270
- 354 y(physically)e(stored)g(tables.)270 473 y Fn(Example)h(2.13)25
- b Ft(W)l(e)15 b(want)g(to)g(sho)o(w)g(ho)o(w)g(a)g(vie)o(w)g(could)g
- (be)h(realized)f(in)g(PostgreSQL.)g(Note)g(that)270 533
- y(there)d(is)i(of)e(course)h(an)g(o)o(wn)f(command)g(to)h(create)g
- Fp(vie)o(ws)h Fr(create)29 b(view)12 b Ft(in)h(PostgreSQL)f(which)270
- 593 y(performs)f(the)i(steps)g(of)f(our)f(e)o(xample)i(internally)m(.)
- 270 712 y(First)f(we)g(create)h(a)f(ne)o(w)m(,)h(empty)f(table)g
- Fr(my)p 1023 712 15 2 v 18 w(view)p Ft(:)330 812 y Fr(testdb=>)29
- b(create)g(table)g(my_view)g(()330 872 y(testdb->)g(sname)g
- (varchar(20),)330 932 y(testdb->)g(pname)g(varchar(20))330
- 991 y(testdb->)g();)270 1091 y Ft(Ne)o(xt)14 b(we)g(create)g(the)g
- (rule)f(that)h(will)f(be)h( 02red)f(whene)o(v)o(er)h(a)g
- Fr(select)f Ft(against)h(the)g(table)g Fr(my)p 1936 1091
- V 17 w(view)270 1151 y Ft(sho)o(ws)f(up:)330 1250 y Fr(testdb=>)29
- b(create)g(rule)g(my_view_rule)330 1310 y(testdb->)g(as)g(on)h(select)f
- (to)h(my_view)330 1370 y(testdb->)f(do)g(instead)h(select)f(s.sname,)g
- (p.pname)330 1430 y(testdb->)g(from)g(supplier)g(s,)h(part)f(p,)h
- (sells)f(se)330 1489 y(testdb->)g(where)g(s.sno=se.sno)g(and)g
- (p.pno=se.pno;)330 1549 y(CREATE)330 1609 y(testdb=>)270
- 1709 y Ft(No)o(w)12 b(we)h(can)f(use)h(the)f(table)h
- Fr(my)p 855 1709 V 17 w(view)f Ft(as)h(if)f(it)g(were)h(populated)e
- (with)i(tuples:)330 1808 y Fr(testdb=>)29 b(select)g(*)h(from)f
- (my_view;)330 1868 y(sname)g(|pname)330 1928 y(------+-----)330
- 1988 y(Smith)g(|Screw)330 2047 y(Smith)g(|Nut)330 2107
- y(Jones)g(|Cam)330 2167 y(Adams)g(|Screw)330 2227 y(Adams)g(|Bolt)330
- 2286 y(Blake)g(|Nut)330 2346 y(Blake)g(|Bolt)330 2406
- y(Blake)g(|Cam)330 2466 y((8)g(rows))330 2585 y(testdb=>)g(select)g
- (*)h(from)f(my_view)330 2645 y(testdb->)g(where)g(sname)g(=)h('Blake';)
- 330 2705 y(sname)f(|pname)330 2765 y(------+-----)330
- 2824 y(Blake)g(|Nut)330 2884 y(Blake)g(|Bolt)330 2944
- y(Blake)g(|Cam)330 3004 y((3)g(rows))330 3123 y(testdb=>)p
- eop
- %%Page: 51 51
- 51 50 bop 198 608 a Fj(Chapter)26 b(3)198 857 y Fq(P)n(ostgr)n(eSQL)k
- (fr)n(om)i(the)198 1006 y(Pr)n(ogrammer')-5 b(s)32 b(P)n(oint)f(of)g(V)
- -5 b(iew)198 1265 y Ft(This)10 b(chapter)f(gi)o(v)o(es)h(an)f(o)o(v)o
- (ervie)o(w)g(of)g(the)h(internal)e(structure)h(of)g(the)g(backend)g(of)
- g(PostgreSQL.)h(After)198 1325 y(ha)o(ving)15 b(read)g(the)h(follo)o
- (wing)e(sections)i(you)f(should)g(ha)o(v)o(e)h(an)f(idea)h(of)f(ho)o(w)
- g(a)h(query)e(is)i(processed.)198 1385 y(Don')o(t)g(e)o(xpect)g(a)h
- (detailed)f(description)g(here)g((I)g(think)g(such)g(a)h(description)f
- (dealing)g(with)g(all)g(data)198 1445 y(structures)11
- b(and)h(functions)f(used)h(within)f(PostgreSQL)g(would)g(e)o(xceed)h
- (1000)f(pages!).)k(This)d(chapter)198 1504 y(is)f(intended)f(to)g
- (help)g(understanding)g(the)g(general)h(control)e(and)i(data)f( 03o)o
- (w)g(within)g(the)g(backend)g(from)198 1564 y(recei)o(ving)i(a)g(query)
- g(to)g(sending)h(the)f(results.)198 1729 y Fi(3.1)71
- b(The)18 b(W)-5 b(ay)18 b(of)f(a)h(Query)198 1841 y Ft(Here)12
- b(we)h(gi)o(v)o(e)f(a)h(short)f(o)o(v)o(ervie)o(w)g(of)g(the)g(stages)h
- (a)g(query)f(has)g(to)h(pass)g(in)f(order)g(to)g(obtain)g(a)g(result:)
- 273 1927 y Fo( 17)25 b Ft(First)14 b(a)h(connection)f(from)g(an)h
- (application)f(program)g(to)g(the)h(PostgreSQL)f(serv)o(er)h(has)g(to)g
- (be)323 1987 y(established.)g(The)d(application)f(program)f(transmits)i
- (a)f(query)g(to)g(the)h(serv)o(er)f(and)g(recei)o(v)o(es)h(the)323
- 2047 y(results)g(sent)h(back)f(by)h(the)f(serv)o(er)m(.)273
- 2140 y Fo( 17)25 b Ft(The)17 b Fp(parser)g(stage)f Ft(checks)i(the)e
- (query)h(transmitted)f(by)h(the)f(application)h(program)e((client))
- 323 2200 y(for)c(correct)h(syntax)g(and)h(creates)f(a)h
- Fp(query)g(tr)n(ee)p Ft(.)273 2293 y Fo( 17)25 b Ft(The)18
- b Fp(r)n(e)o(write)h(system)f Ft(takes)f(the)h Fp(query)g(tr)n(ee)g
- Ft(created)g(by)f(the)h Fp(parser)g(stage)f Ft(looks)g(for)g(an)o(y)323
- 2352 y Fp(rules)11 b Ft((stored)g(in)g(the)g Fp(system)h(catalogs)p
- Ft())e(to)h(apply)f(to)h(the)g Fp(querytr)n(ee)i Ft(and)e(performs)f
- (the)h(trans-)323 2412 y(formations)j(gi)o(v)o(en)g(in)h(the)g
- Fp(rule)h(bodies)p Ft(.)24 b(One)15 b(application)g(of)f(the)h
- Fp(r)n(e)o(write)i(system)f Ft(is)f(gi)o(v)o(en)323 2472
- y(in)f(the)g(realization)f(of)h Fp(vie)o(ws)p Ft(.)23
- b(Whene)o(v)o(er)14 b(a)g(query)g(against)g(a)g Fp(vie)o(w)h
- Ft((i.e.)22 b(a)14 b Fp(virtual)g(table)p Ft())g(is)323
- 2532 y(made,)h(the)f Fp(r)n(e)o(write)h(system)g Ft(re)o(writes)f(the)g
- (user')m(s)h(query)e(to)h(a)h(query)f(that)g(accesses)i(the)e
- Fp(base)323 2592 y(tables)e Ft(gi)o(v)o(en)g(in)g(the)h
- Fp(vie)o(w)g(de 02nition)e Ft(instead.)273 2685 y Fo( 17)25
- b Ft(The)17 b Fp(planner/optimizer)f Ft(takes)h(the)g(()p
- Fp(r)n(e)o(written)p Ft())f Fp(querytr)n(ee)i Ft(and)f(creates)g(a)g
- Fp(queryplan)f Ft(that)323 2744 y(will)10 b(be)i(the)f(input)f(to)h
- (the)g Fp(e)o(xecutor)p Ft(.)16 b(It)11 b(does)h(so)f(by)g( 02rst)g
- (creating)g(all)g(possible)g Fp(paths)g Ft(leading)323
- 2804 y(to)16 b(the)g(same)h(result.)29 b(()16 b(F)o(or)g(e)o(xample)h
- (if)f(there)g(is)h(an)f(inde)o(x)h(on)f(a)h(relation)f(to)g(be)h
- (scanned,)323 2864 y(there)c(are)g(two)g Fp(paths)h Ft(for)f(the)g
- (scan.)20 b(One)14 b(possibility)f(is)h(a)g(simple)g(sequential)f(scan)
- i(and)e(the)323 2924 y(other)g(possibility)g(is)h(to)f(use)h(the)g
- (inde)o(x.))19 b(Ne)o(xt)14 b(the)f(cost)h(for)f(the)h(e)o(x)o
- (ecution)f(of)h(each)g Fp(plan)f Ft(is)323 2984 y(estimated)f(and)g
- (the)h(cheapest)g Fp(plan)f Ft(is)g(chosen)h(and)f(handed)h(back.)273
- 3077 y Fo( 17)25 b Ft(The)14 b Fp(e)o(xecutor)h Ft(recursi)o(v)o(ely)f
- (steps)h(through)e(the)h Fp(plan)g(tr)n(ee)h Ft(and)f(retrie)o(v)o(es)g
- (tuples)g(in)g(the)h(way)323 3136 y(represented)f(by)g(the)g
- Fp(plan)p Ft(.)21 b(The)15 b Fp(e)o(xecutor)g Ft(makes)f(use)h(of)f
- (the)g Fp(stor)o(age)h(system)g Ft(while)f(scan-)323
- 3196 y(ning)i(relations,)j(performs)d Fp(sorts)i Ft(and)f
- Fp(joins)p Ft(,)i(e)o(v)o(aluates)e Fp(quali 02cations)g
- Ft(and)g( 02nally)g(hands)323 3256 y(back)12 b(the)g(tuples)h(deri)o
- (v)o(ed.)198 3342 y(In)j(the)g(follo)o(wing)g(sections)h(we)f(will)g
- (co)o(v)o(er)h(e)o(v)o(ery)f(of)g(the)h(abo)o(v)o(e)g(listed)f(items)h
- (in)f(more)g(detail)g(to)198 3402 y(gi)o(v)o(e)c(a)h(better)f
- (understanding)f(on)i(PostgreSQL)-5 b(')m(s)12 b(internal)g(control)f
- (and)i(data)f(structures.)1073 3552 y(51)p eop
- %%Page: 52 52
- 52 51 bop 270 60 a Ft(52)82 b Fm(CHAPTER)14 b(3.)28 b(POSTGRESQL)13
- b(FR)n(OM)f(THE)i(PR)n(OGRAMMER'S)f(POINT)f(OF)g(VIEW)270
- 234 y Fi(3.2)71 b(Ho)o(w)18 b(Connections)f(ar)o(e)g(Established)270
- 370 y Ft(PostgreSQL)c(is)g(implemented)f(using)h(a)g(simple)g
- (224process)h(per)o(-user224)e(client/serv)o(er)h(model.)k(In)c(this)
- 270 430 y(model)k(there)f(is)h(one)g Fp(client)g(pr)n(ocess)h
- Ft(connected)f(to)f(e)o(xactly)i(one)e Fp(server)j(pr)n(ocess)p
- Ft(.)30 b(As)18 b(we)f(don')o(t)270 490 y(kno)o(w)f Fp(per)h(se)g
- Ft(ho)o(w)f(man)o(y)h(connections)g(will)f(be)g(made,)j(we)d(ha)o(v)o
- (e)h(to)g(use)g(a)f Fp(master)i(pr)n(ocess)f Ft(that)270
- 549 y(spa)o(wns)h(a)e(ne)o(w)h Fp(server)h(pr)n(ocess)f
- Ft(e)o(v)o(ery)f(time)h(a)f(connection)h(is)f(requested.)29
- b(This)17 b Fp(master)g(pr)n(ocess)270 609 y Ft(is)f(called)g
- Fr(postmaster)e Ft(and)i(listens)g(at)f(a)h(speci 02ed)g(TCP/IP)f
- (port)g(for)g(incoming)g(connections.)270 669 y(Whene)o(v)o(er)e(a)h
- (request)f(for)f(a)i(connection)f(is)h(detected)f(the)g
- Fr(postmaster)g Ft(process)g(spa)o(wns)i(a)e(ne)o(w)270
- 729 y Fp(server)i(pr)n(ocess)f Ft(called)g Fr(postgres)p
- Ft(.)j(The)d(serv)o(er)g(tasks)g(()p Fr(postgres)e Ft(processes))i
- (communicate)270 788 y(with)k(each)g(other)f(using)h
- Fp(semaphor)n(es)h Ft(and)f Fp(shar)n(ed)h(memory)g Ft(to)e(ensure)h
- (data)g(inte)o(grity)f(through-)270 848 y(out)j(concurrent)e(data)i
- (access.)40 b(Figure)19 b(3.1)h(illustrates)f(the)h(interaction)f(of)g
- (the)h(master)g(process)270 908 y Fr(postmaster)11 b
- Ft(the)i(serv)o(er)f(process)h Fr(postgres)e Ft(and)i(a)f(client)h
- (application.)345 981 y(The)e(client)g(process)g(can)h(either)e(be)h
- (the)g Fr(psql)g Ft(frontend)f((for)f Fp(inter)o(active)j
- Ft(SQL)f(queries))f(or)h(an)o(y)270 1041 y(user)f(application)f
- (implemented)g(using)h(the)f Fr(libpg)h Ft(library)m(.)j(Note)d(that)f
- (applications)h(implemented)270 1100 y(using)i Fr(ecpq)g
- Ft((i.e.)k(the)d(postgres)f(embedded)g(C)h(compiler))e(also)i(use)g
- (this)f(library)m(.)345 1173 y(Once)e(a)g(connection)f(is)i
- (established)f(the)g(client)f(process)i(can)f(send)g(a)g(query)f(to)h
- (the)g Fp(bac)o(kend)p Ft(.)15 b(The)270 1233 y(query)f(is)h
- (transmitted)e(using)i Fp(plain)f(te)o(xt)p Ft(,)h(i.e.)23
- b(there)14 b(is)h(no)f(parsing)g(done)h(in)f(the)h Fp(fr)n(ontend)f
- Ft((client).)270 1293 y(The)i(serv)o(er)g Fp(parses)g
- Ft(the)g(query)m(,)g(creates)g(an)g Fp(e)o(xecution)f(plan)p
- Ft(,)i(e)o(x)o(ecutes)g(the)e Fp(plan)g Ft(and)h(returns)f(the)270
- 1352 y(retrie)o(v)o(ed)c(tuples)i(to)f(the)g(client)h(by)f
- (transmitting)f(them)h(o)o(v)o(er)h(the)f(established)h(connection.)543
- 2309 y @beginspecial 180 @llx 310 @lly 431 @urx 482 @ury
- 2510 @rwi @setspecial
- %%BeginDocument: figures/connection.ps
- %Magnification: 1.05
- /$F2psDict 200 dict def
- $F2psDict begin
- $F2psDict /mtrx matrix put
- /col-1 {0 setgray} bind def
- /col0 {0.000 0.000 0.000 srgb} bind def
- /col1 {0.000 0.000 1.000 srgb} bind def
- /col2 {0.000 1.000 0.000 srgb} bind def
- /col3 {0.000 1.000 1.000 srgb} bind def
- /col4 {1.000 0.000 0.000 srgb} bind def
- /col5 {1.000 0.000 1.000 srgb} bind def
- /col6 {1.000 1.000 0.000 srgb} bind def
- /col7 {1.000 1.000 1.000 srgb} bind def
- /col8 {0.000 0.000 0.560 srgb} bind def
- /col9 {0.000 0.000 0.690 srgb} bind def
- /col10 {0.000 0.000 0.820 srgb} bind def
- /col11 {0.530 0.810 1.000 srgb} bind def
- /col12 {0.000 0.560 0.000 srgb} bind def
- /col13 {0.000 0.690 0.000 srgb} bind def
- /col14 {0.000 0.820 0.000 srgb} bind def
- /col15 {0.000 0.560 0.560 srgb} bind def
- /col16 {0.000 0.690 0.690 srgb} bind def
- /col17 {0.000 0.820 0.820 srgb} bind def
- /col18 {0.560 0.000 0.000 srgb} bind def
- /col19 {0.690 0.000 0.000 srgb} bind def
- /col20 {0.820 0.000 0.000 srgb} bind def
- /col21 {0.560 0.000 0.560 srgb} bind def
- /col22 {0.690 0.000 0.690 srgb} bind def
- /col23 {0.820 0.000 0.820 srgb} bind def
- /col24 {0.500 0.190 0.000 srgb} bind def
- /col25 {0.630 0.250 0.000 srgb} bind def
- /col26 {0.750 0.380 0.000 srgb} bind def
- /col27 {1.000 0.500 0.500 srgb} bind def
- /col28 {1.000 0.630 0.630 srgb} bind def
- /col29 {1.000 0.750 0.750 srgb} bind def
- /col30 {1.000 0.880 0.880 srgb} bind def
- /col31 {1.000 0.840 0.000 srgb} bind def
- end
- save
- 175.5 498.0 translate
- 1 -1 scale
- /cp {closepath} bind def
- /ef {eofill} bind def
- /gr {grestore} bind def
- /gs {gsave} bind def
- /sa {save} bind def
- /rs {restore} bind def
- /l {lineto} bind def
- /m {moveto} bind def
- /rm {rmoveto} bind def
- /n {newpath} bind def
- /s {stroke} bind def
- /sh {show} bind def
- /slc {setlinecap} bind def
- /slj {setlinejoin} bind def
- /slw {setlinewidth} bind def
- /srgb {setrgbcolor} bind def
- /rot {rotate} bind def
- /sc {scale} bind def
- /sd {setdash} bind def
- /ff {findfont} bind def
- /sf {setfont} bind def
- /scf {scalefont} bind def
- /sw {stringwidth} bind def
- /tr {translate} bind def
- /tnt {dup dup currentrgbcolor
- 4 -2 roll dup 1 exch sub 3 -1 roll mul add
- 4 -2 roll dup 1 exch sub 3 -1 roll mul add
- 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
- bind def
- /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
- 4 -2 roll mul srgb} bind def
- /DrawEllipse {
- /endangle exch def
- /startangle exch def
- /yrad exch def
- /xrad exch def
- /y exch def
- /x exch def
- /savematrix mtrx currentmatrix def
- x y tr xrad yrad sc 0 0 1 startangle endangle arc
- closepath
- savematrix setmatrix
- } def
- /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
- /$F2psEnd {$F2psEnteredState restore end} def
- $F2psBegin
- 10 setmiterlimit
- n 0 792 m 0 0 l 612 0 l 612 792 l cp clip
- 0.06299 0.06299 sc
- 7.500 slw
- % Polyline
- n 2835 1980 m 3645 1980 l 3645 2250 l 2835 2250 l cp gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 2925 2160 m
- gs 1 -1 sc (Postmaster) col-1 sh gr
- % Polyline
- n 2790 540 m 3600 540 l 3600 810 l 2790 810 l cp gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 2880 720 m
- gs 1 -1 sc (Postmaster) col-1 sh gr
- % Ellipse
- n 3240 2385 810 585 0 360 DrawEllipse gs col-1 s gr
- % Ellipse
- n 2520 2115 45 45 0 360 DrawEllipse gs col-1 s gr
- % Ellipse
- n 900 2206 765 495 0 360 DrawEllipse gs col-1 s gr
- % Ellipse
- n 3195 945 810 585 0 360 DrawEllipse gs col-1 s gr
- % Ellipse
- n 2475 675 45 45 0 360 DrawEllipse gs col-1 s gr
- % Ellipse
- n 855 766 765 495 0 360 DrawEllipse gs col-1 s gr
- % Polyline
- gs clippath
- 2704 2493 m 2809 2556 l 2686 2550 l 2840 2598 l 2858 2541 l cp clip
- n 1395 2115 m 2835 2565 l gs col-1 s gr gr
- % arrowhead
- n 2704 2493 m 2809 2556 l 2686 2550 l 2695 2521 l 2704 2493 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- n 2565 2115 m 2835 2115 l gs col-1 s gr
- % Polyline
- n 855 1890 m 855 2340 l gs col-1 s gr
- % Polyline
- n 405 1890 m 1395 1890 l 1395 2340 l 405 2340 l cp gs col-1 s gr
- % Polyline
- n 2835 2430 m 3645 2430 l 3645 2700 l 2835 2700 l cp gs col-1 s gr
- % Polyline
- gs clippath
- 2283 645 m 2403 675 l 2283 705 l 2445 705 l 2445 645 l cp clip
- n 1350 675 m 2430 675 l gs col-1 s gr gr
- % arrowhead
- n 2283 645 m 2403 675 l 2283 705 l 2283 675 l 2283 645 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- n 2520 675 m 2790 675 l gs col-1 s gr
- % Polyline
- n 810 450 m 810 900 l gs col-1 s gr
- % Polyline
- n 360 450 m 1350 450 l 1350 900 l 360 900 l cp gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 2880 2880 m
- gs 1 -1 sc (Server Host) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 495 2070 m
- gs 1 -1 sc (User ) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 495 2265 m
- gs 1 -1 sc (App) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 900 2160 m
- gs 1 -1 sc (LIBPQ) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 585 2610 m
- gs 1 -1 sc (Client Host) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 3015 2610 m
- gs 1 -1 sc (Postgres) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 2835 1440 m
- gs 1 -1 sc (Server Host) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 450 630 m
- gs 1 -1 sc (User ) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 450 825 m
- gs 1 -1 sc (App) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 855 720 m
- gs 1 -1 sc (LIBPQ) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 540 1170 m
- gs 1 -1 sc (Client Host) col-1 sh gr
- showpage
- $F2psEnd
- rs
- %%EndDocument
- @endspecial 733 2418 a(Figure)e(3.1:)16 b(Ho)o(w)c(a)g(connection)g
- (is)h(established)270 2780 y Fi(3.3)71 b(The)18 b(P)o(arser)f(Stage)270
- 2916 y Ft(The)c Fp(parser)g(stage)f Ft(consists)h(of)f(two)f(parts:)345
- 3055 y Fo( 17)25 b Ft(The)17 b Fp(parser)g Ft(de 02ned)g(in)f
- Fr(gram.y)h Ft(and)f Fr(scan.l)h Ft(is)g(b)o(uilt)f(using)h(the)f(UNIX)
- h(tools)f Fr(yacc)395 3115 y Ft(and)c Fr(lex)p Ft(.)345
- 3266 y Fo( 17)25 b Ft(The)11 b Fp(tr)o(ansformation)g(pr)n(ocess)h
- Ft(does)f(some)g(necessary)h(transformation)d(to)i(the)g(data)g
- (structure)395 3326 y(returned)g(by)h(the)h Fp(parser)p
- Ft(.)p eop
- %%Page: 53 53
- 53 52 bop 198 60 a Fm(3.3.)29 b(THE)13 b(P)-5 b(ARSER)13
- b(ST)-5 b(A)n(GE)1189 b Ft(53)198 234 y Fh(3.3.1)59 b(P)o(arser)198
- 328 y Ft(The)14 b Fp(parser)g Ft(has)g(to)f(check)h(the)f(query)g
- (string)g((which)g(arri)o(v)o(es)g(as)h Fp(plain)f(ASCII)h(te)o(xt)p
- Ft())f(for)f(v)o(alid)h(syn-)198 388 y(tax.)22 b(If)14
- b(the)g(syntax)h(is)g(correct)e(a)i Fp(parse)g(tr)n(ee)g
- Ft(is)g(b)o(uilt)f(up)g(and)h(handed)f(back)h(otherwise)f(an)g(error)g
- (is)198 448 y(returned.)h(F)o(or)d(the)g(implementation)f(the)i(well)f
- (kno)o(wn)g(UNIX)g(tools)g Fr(lex)g Ft(and)g Fr(yacc)g
- Ft(are)h(used.)273 508 y(The)i Fp(le)o(xer)g Ft(is)g(de 02ned)f(in)h
- (the)f( 02le)g Fr(scan.l)g Ft(and)h(is)g(responsible)f(for)g
- (recognizing)g Fp(identi 02ers)p Ft(,)198 567 y(the)h
- Fp(SQL)g(ke)o(ywor)n(ds)h Ft(etc.)24 b(F)o(or)15 b(e)o(v)o(ery)g
- Fp(ke)o(ywor)n(d)g Ft(or)g Fp(identi 02er)g Ft(that)g(is)h(found,)g(a)
- f Fp(token)g Ft(is)g(generated)198 627 y(and)d(handed)h(to)f(the)g
- Fp(parser)p Ft(.)273 687 y(The)k Fp(parser)g Ft(is)g(de 02ned)f(in)g
- (the)h( 02le)f Fr(gram.y)g Ft(and)g(consists)i(of)e(a)h(set)g(of)f
- Fp(gr)o(ammar)h(rules)g Ft(and)198 747 y Fp(actions)10
- b Ft(that)g(are)g(e)o(x)o(ecuted)h(whene)o(v)o(er)f(a)h(rule)f(is)g
- ( 02red.)15 b(The)10 b(code)h(of)f(the)g Fp(actions)g
- Ft((which)g(is)g(actually)198 807 y(C-code))i(is)h(used)f(to)h(b)o
- (uild)e(up)i(the)f Fp(parse)h(tr)n(ee)p Ft(.)273 867
- y(The)h( 02le)g Fr(scan.l)f Ft(is)h(transformed)f(to)g(the)h(C-source)
- g( 02le)g Fr(scan.c)f Ft(using)h(the)g(program)e Fr(lex)198
- 927 y Ft(and)17 b Fr(gram.y)g Ft(is)h(transformed)e(to)h
- Fr(gram.c)g Ft(using)g Fr(yacc)p Ft(.)30 b(After)17 b(these)h
- (transformations)e(ha)o(v)o(e)198 987 y(taken)11 b(place)g(a)g(normal)f
- (C-compiler)g(can)h(be)h(used)f(to)g(create)g(the)g Fp(parser)p
- Ft(.)16 b(Ne)o(v)o(er)11 b(make)f(an)o(y)i(changes)198
- 1046 y(to)j(the)g(generated)g(C- 02les)g(as)h(the)o(y)f(will)g(be)h(o)
- o(v)o(erwritten)e(the)h(ne)o(xt)h(time)e Fr(lex)h Ft(or)g
- Fr(yacc)g Ft(is)h(called.)198 1106 y((Note)g(that)h(the)g(mentioned)f
- (transformations)g(and)h(compilations)f(are)h(normally)f(done)h
- (automati-)198 1166 y(cally)12 b(using)h(the)f Fr(makefiles)f
- Ft(shipped)i(with)f(the)g(PostgreSQL)g(source)h(distrib)o(ution.))273
- 1226 y(A)20 b(detailed)g(description)g(of)g Fr(yacc)g
- Ft(or)f(the)i Fp(gr)o(ammar)g(rules)g Ft(gi)o(v)o(en)f(in)g
- Fr(gram.y)g Ft(would)f(be)198 1286 y(be)o(yond)c(the)h(scope)g(of)f
- (this)h(paper)m(.)25 b(There)16 b(are)f(man)o(y)g(books)h(and)g
- (documents)f(dealing)g(with)g Fr(lex)198 1345 y Ft(and)c
- Fr(yacc)p Ft(.)k(Y)-5 b(ou)11 b(should)g(be)h(familiar)d(with)i
- Fr(yacc)p Ft(,)h(before)e(you)h(start)g(to)h(study)f(the)g(grammar)f
- (gi)o(v)o(en)198 1405 y(in)i Fr(gram.y)g Ft(otherwise)g(you)g(won')o(t)
- g(understand)g(what)g(happens)h(there.)198 1525 y(F)o(or)27
- b(a)h(better)f(understanding)g(of)g(the)g(data)h(structures)f(used)h
- (in)g(PostgreSQL)f(for)g(the)g(pro-)198 1585 y(cessing)12
- b(of)e(a)h(query)g(we)g(use)g(an)g(e)o(xample)h(to)e(illustrate)h(the)g
- (changes)g(made)g(to)g(these)g(data)g(structures)198
- 1644 y(in)h(e)o(v)o(ery)g(stage.)198 1766 y Fn(Example)h(3.1)25
- b Ft(This)10 b(e)o(xample)g(contains)f(the)h(follo)o(wing)e(simple)h
- (query)g(that)h(will)f(be)g(used)h(in)g(v)o(arious)198
- 1825 y(descriptions)18 b(and)g( 02gures)g(throughout)f(the)h(follo)o
- (wing)e(sections.)34 b(The)18 b(query)g(assumes)h(that)f(the)198
- 1885 y(tables)13 b(gi)o(v)o(en)f(in)g(e)o(xample)g(1.1)h(ha)o(v)o(e)g
- (already)f(been)h(de 02ned.)258 1986 y Fr(select)29
- b(s.sname,)g(se.pno)258 2046 y(from)g(supplier)g(s,)h(sells)f(se)258
- 2106 y(where)g(s.sno)g(>)h(2)g(and)437 2165 y(s.sno)f(=)h(se.sno;)198
- 2266 y Ft(Figure)13 b(3.2)h(sho)o(ws)h(the)e Fp(parse)i(tr)n(ee)f
- Ft(b)o(uilt)g(by)f(the)h Fp(gr)o(ammar)h(rules)f Ft(and)g
- Fp(actions)g Ft(gi)o(v)o(en)g(in)g Fr(gram.y)198 2326
- y Ft(for)g(the)h(query)f(gi)o(v)o(en)h(in)f(e)o(xample)h(3.1)g
- ((without)f(the)h Fp(oper)o(ator)g(tr)n(ee)h Ft(for)e(the)g
- Fp(wher)n(e)i(clause)f Ft(which)198 2385 y(is)f(sho)o(wn)f(in)h
- ( 02gure)f(3.3)h(because)g(there)f(was)h(not)f(enough)h(space)g(to)f
- (sho)o(w)h(both)f(data)h(structures)f(in)198 2445 y(one)f( 02gure).)
- 273 2505 y(The)f(top)g(node)g(of)f(the)h(tree)g(is)g(a)g
- Fr(SelectStmt)f Ft(node.)15 b(F)o(or)10 b(e)o(v)o(ery)h(entry)f
- (appearing)h(in)f(the)h Fp(fr)n(om)198 2565 y(clause)k
- Ft(of)f(the)h(SQL)g(query)f(a)h Fr(RangeVar)e Ft(node)i(is)g(created)f
- (holding)g(the)h(name)g(of)f(the)g Fp(alias)h Ft(and)198
- 2625 y(a)e(pointer)f(to)h(a)g Fr(RelExpr)f Ft(node)h(holding)f(the)h
- (name)g(of)f(the)h Fp(r)n(elation)p Ft(.)k(All)c Fr(RangeVar)f
- Ft(nodes)h(are)198 2685 y(collected)f(in)g(a)h(list)f(which)h(is)f
- (attached)h(to)f(the)g( 02eld)g Fr(fromClause)g Ft(of)g(the)g
- Fr(SelectStmt)f Ft(node.)273 2745 y(F)o(or)19 b(e)o(v)o(ery)g(entry)h
- (appearing)f(in)g(the)h Fp(select)g(list)g Ft(of)g(the)f(SQL)h(query)f
- (a)h Fr(ResTarget)f Ft(node)198 2804 y(is)e(created)g(holding)f(a)h
- (pointer)f(to)h(an)g Fr(Attr)g Ft(node.)29 b(The)17 b
- Fr(Attr)g Ft(node)f(holds)h(the)g Fp(r)n(elation)g(name)198
- 2864 y Ft(of)22 b(the)g(entry)g(and)h(a)f(pointer)g(to)g(a)h
- Fr(Value)f Ft(node)g(holding)g(the)g(name)g(of)g(the)h
- Fp(attrib)o(ute)p Ft(.)45 b(All)198 2924 y Fr(ResTarget)11
- b Ft(nodes)h(are)g(collected)g(to)f(a)h(list)g(which)g(is)g(connected)g
- (to)f(the)h( 02eld)g Fr(targetList)f Ft(of)198 2984
- y(the)h Fr(SelectStmt)g Ft(node.)198 3103 y(Figure)28
- b(3.3)i(sho)o(ws)f(the)g Fp(oper)o(ator)h(tr)n(ee)g Ft(b)o(uilt)e(for)g
- (the)h Fp(wher)n(e)h(clause)g Ft(of)e(the)h(SQL)h(query)198
- 3163 y(gi)o(v)o(en)13 b(in)g(e)o(xample)h(3.1)f(which)g(is)h(attached)f
- (to)g(the)h( 02eld)f Fr(qual)g Ft(of)g(the)g Fr(SelectStmt)f
- Ft(node.)19 b(The)198 3223 y(top)f(node)g(of)g(the)g
- Fp(oper)o(ator)h(tr)n(ee)g Ft(is)g(an)f Fr(A)p 970 3223
- 15 2 v 18 w(Expr)g Ft(node)g(representing)f(an)i Fr(AND)f
- Ft(operation.)32 b(This)198 3283 y(node)14 b(has)g(two)f(successors)i
- (called)e Fr(lexpr)h Ft(and)f Fr(rexpr)h Ft(pointing)e(to)i(two)f
- Fp(subtr)n(ees)p Ft(.)21 b(The)14 b Fp(subtr)n(ee)198
- 3342 y Ft(attached)g(to)f Fr(lexpr)g Ft(represents)h(the)g
- (quali 02cation)e Fk(s:sno)17 b(>)f Fl(2)e Ft(and)f(the)h(one)f
- (attached)h(to)g Fr(rexpr)198 3402 y Ft(represents)f
- Fk(s:sno)i Fl(=)f Fk(se:sno)p Ft(.)j(F)o(or)c(e)o(v)o(ery)f
- Fp(attrib)o(ute)g Ft(an)h Fr(Attr)f Ft(node)h(is)g(created)g(holding)e
- (the)i(name)p eop
- %%Page: 54 54
- 54 53 bop 270 60 a Ft(54)82 b Fm(CHAPTER)14 b(3.)28 b(POSTGRESQL)13
- b(FR)n(OM)f(THE)i(PR)n(OGRAMMER'S)f(POINT)f(OF)g(VIEW)270
- 234 y Ft(of)j(the)f Fp(r)n(elation)h Ft(and)g(a)g(pointer)g(to)f(a)i
- Fr(Value)e Ft(node)h(holding)f(the)h(name)g(of)g(the)f
- Fp(attrib)o(ute)p Ft(.)24 b(F)o(or)14 b(the)270 294 y
- Fp(constant)e Ft(appearing)g(in)g(the)h(query)f(a)g Fr(Const)g
- Ft(node)g(is)h(created)f(holding)g(the)g(v)o(alue.)363
- 2301 y @beginspecial 144 @llx 201 @lly 467 @urx 590 @ury
- 3230 @rwi @setspecial
- %%BeginDocument: figures/parsetree.ps
- %Magnification: 1.05
- /$F2psDict 200 dict def
- $F2psDict begin
- $F2psDict /mtrx matrix put
- /col-1 {0 setgray} bind def
- /col0 {0.000 0.000 0.000 srgb} bind def
- /col1 {0.000 0.000 1.000 srgb} bind def
- /col2 {0.000 1.000 0.000 srgb} bind def
- /col3 {0.000 1.000 1.000 srgb} bind def
- /col4 {1.000 0.000 0.000 srgb} bind def
- /col5 {1.000 0.000 1.000 srgb} bind def
- /col6 {1.000 1.000 0.000 srgb} bind def
- /col7 {1.000 1.000 1.000 srgb} bind def
- /col8 {0.000 0.000 0.560 srgb} bind def
- /col9 {0.000 0.000 0.690 srgb} bind def
- /col10 {0.000 0.000 0.820 srgb} bind def
- /col11 {0.530 0.810 1.000 srgb} bind def
- /col12 {0.000 0.560 0.000 srgb} bind def
- /col13 {0.000 0.690 0.000 srgb} bind def
- /col14 {0.000 0.820 0.000 srgb} bind def
- /col15 {0.000 0.560 0.560 srgb} bind def
- /col16 {0.000 0.690 0.690 srgb} bind def
- /col17 {0.000 0.820 0.820 srgb} bind def
- /col18 {0.560 0.000 0.000 srgb} bind def
- /col19 {0.690 0.000 0.000 srgb} bind def
- /col20 {0.820 0.000 0.000 srgb} bind def
- /col21 {0.560 0.000 0.560 srgb} bind def
- /col22 {0.690 0.000 0.690 srgb} bind def
- /col23 {0.820 0.000 0.820 srgb} bind def
- /col24 {0.500 0.190 0.000 srgb} bind def
- /col25 {0.630 0.250 0.000 srgb} bind def
- /col26 {0.750 0.380 0.000 srgb} bind def
- /col27 {1.000 0.500 0.500 srgb} bind def
- /col28 {1.000 0.630 0.630 srgb} bind def
- /col29 {1.000 0.750 0.750 srgb} bind def
- /col30 {1.000 0.880 0.880 srgb} bind def
- /col31 {1.000 0.840 0.000 srgb} bind def
- end
- save
- 131.5 603.5 translate
- 1 -1 scale
- /cp {closepath} bind def
- /ef {eofill} bind def
- /gr {grestore} bind def
- /gs {gsave} bind def
- /sa {save} bind def
- /rs {restore} bind def
- /l {lineto} bind def
- /m {moveto} bind def
- /rm {rmoveto} bind def
- /n {newpath} bind def
- /s {stroke} bind def
- /sh {show} bind def
- /slc {setlinecap} bind def
- /slj {setlinejoin} bind def
- /slw {setlinewidth} bind def
- /srgb {setrgbcolor} bind def
- /rot {rotate} bind def
- /sc {scale} bind def
- /sd {setdash} bind def
- /ff {findfont} bind def
- /sf {setfont} bind def
- /scf {scalefont} bind def
- /sw {stringwidth} bind def
- /tr {translate} bind def
- /tnt {dup dup currentrgbcolor
- 4 -2 roll dup 1 exch sub 3 -1 roll mul add
- 4 -2 roll dup 1 exch sub 3 -1 roll mul add
- 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
- bind def
- /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
- 4 -2 roll mul srgb} bind def
- /DrawSplineSection {
- /y3 exch def
- /x3 exch def
- /y2 exch def
- /x2 exch def
- /y1 exch def
- /x1 exch def
- /xa x1 x2 x1 sub 0.666667 mul add def
- /ya y1 y2 y1 sub 0.666667 mul add def
- /xb x3 x2 x3 sub 0.666667 mul add def
- /yb y3 y2 y3 sub 0.666667 mul add def
- x1 y1 lineto
- xa ya xb yb x3 y3 curveto
- } def
- /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
- /$F2psEnd {$F2psEnteredState restore end} def
- $F2psBegin
- 10 setmiterlimit
- n 0 792 m 0 0 l 612 0 l 612 792 l cp clip
- 0.06299 0.06299 sc
- 7.500 slw
- % Polyline
- n 1215 450 m 1485 720 l gs col-1 s gr
- % Polyline
- n 1485 450 m 1215 720 l gs col-1 s gr
- % Polyline
- n 1215 1800 m 1485 2070 l gs col-1 s gr
- % Polyline
- n 1485 1800 m 1215 2070 l gs col-1 s gr
- % Polyline
- n 1215 2070 m 1485 2340 l gs col-1 s gr
- % Polyline
- n 1485 2070 m 1215 2340 l gs col-1 s gr
- % Polyline
- n 1215 2340 m 1485 2610 l gs col-1 s gr
- % Polyline
- n 1485 2340 m 1215 2610 l gs col-1 s gr
- % Polyline
- n 2430 450 m 3240 450 l gs col-1 s gr
- % Polyline
- n 2430 225 m 3240 225 l 3240 720 l 2430 720 l cp gs col-1 s gr
- % Polyline
- n 2970 450 m 2970 720 l gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 2520 630 m
- gs 1 -1 sc (val) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 2520 405 m
- gs 1 -1 sc (ResTarget) col-1 sh gr
- % Polyline
- n 3510 450 m 4410 450 l gs col-1 s gr
- % Polyline
- n 3510 720 m 4410 720 l gs col-1 s gr
- % Polyline
- n 3510 225 m 4410 225 l 4410 990 l 3510 990 l cp gs col-1 s gr
- % Polyline
- n 4140 450 m 4140 990 l gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 3825 405 m
- gs 1 -1 sc (Attr) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 3600 900 m
- gs 1 -1 sc (attrs) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 3600 630 m
- gs 1 -1 sc (relname) col-1 sh gr
- % Polyline
- n 4635 720 m 5175 720 l 5175 990 l 4635 990 l cp gs col-1 s gr
- % Polyline
- n 4905 720 m 4905 990 l gs col-1 s gr
- % Polyline
- n 4905 720 m 5175 990 l gs col-1 s gr
- % Polyline
- n 5175 720 m 4905 990 l gs col-1 s gr
- % Polyline
- n 4365 1215 m 5175 1215 l 5175 1710 l 4365 1710 l cp gs col-1 s gr
- % Polyline
- n 4365 1440 m 5175 1440 l gs col-1 s gr
- % Polyline
- n 4905 1440 m 4905 1710 l gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 4590 1395 m
- gs 1 -1 sc (Value) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 4455 1620 m
- gs 1 -1 sc (val.str) col-1 sh gr
- % Polyline
- n 2430 5265 m 3330 5265 l gs col-1 s gr
- % Polyline
- n 2430 5535 m 3330 5535 l gs col-1 s gr
- % Polyline
- n 2430 5040 m 3330 5040 l 3330 5805 l 2430 5805 l cp gs col-1 s gr
- % Polyline
- n 3060 5265 m 3060 5805 l gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 2520 5715 m
- gs 1 -1 sc (relExpr) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 2520 5445 m
- gs 1 -1 sc (name) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 2565 5220 m
- gs 1 -1 sc (RangeVar) col-1 sh gr
- % Polyline
- n 3600 5670 m 4500 5670 l gs col-1 s gr
- % Polyline
- n 3600 5445 m 4500 5445 l 4500 5940 l 3600 5940 l cp gs col-1 s gr
- % Polyline
- n 4230 5670 m 4230 5940 l gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 3690 5850 m
- gs 1 -1 sc (relname) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 3690 5625 m
- gs 1 -1 sc (RelExpr) col-1 sh gr
- % Polyline
- gs clippath
- 3453 5640 m 3573 5670 l 3453 5700 l 3615 5700 l 3615 5640 l cp clip
- n 3195 5670 m 3600 5670 l gs col-1 s gr gr
- % arrowhead
- n 3453 5640 m 3573 5670 l 3453 5700 l 3453 5670 l 3453 5640 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 4395 6018 m 4365 6138 l 4335 6018 l 4335 6180 l 4395 6180 l cp clip
- n 4365 5805 m 4365 6165 l gs col-1 s gr gr
- % arrowhead
- n 4395 6018 m 4365 6138 l 4335 6018 l 4365 6018 l 4395 6018 l cp gs 0.00 setgray ef gr col-1 s
- % Open spline
- gs clippath
- 3588 5190 m 3708 5220 l 3588 5250 l 3750 5250 l 3750 5190 l cp clip
- n 3240.0 5400.0 m 3375.0 5400.0 l
- 3375.0 5400.0 3510.0 5400.0 3510.0 5310.0 DrawSplineSection
- 3510.0 5310.0 3510.0 5220.0 3622.5 5220.0 DrawSplineSection
- 3735.0 5220.0 l gs col-1 s gr
- gr
- % arrowhead
- n 3588 5190 m 3708 5220 l 3588 5250 l 3588 5220 l 3588 5190 l cp gs 0.00 setgray ef gr col-1 s
- /Times-Roman ff 150.00 scf sf
- 3825 5265 m
- gs 1 -1 sc ("se") col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 4185 6345 m
- gs 1 -1 sc ("sells") col-1 sh gr
- % Polyline
- n 1935 855 m 1935 315 l 2205 315 l 2205 855 l cp gs col-1 s gr
- % Polyline
- n 1935 585 m 2205 585 l gs col-1 s gr
- % Polyline
- n 2205 2115 m 2205 2655 l 1935 2655 l 1935 2115 l cp gs col-1 s gr
- % Polyline
- n 2205 2385 m 1935 2385 l gs col-1 s gr
- % Polyline
- n 2205 2385 m 1935 2655 l gs col-1 s gr
- % Polyline
- n 2205 2655 m 1935 2385 l gs col-1 s gr
- % Polyline
- gs clippath
- 2283 420 m 2403 450 l 2283 480 l 2445 480 l 2445 420 l cp clip
- n 2070 450 m 2430 450 l gs col-1 s gr gr
- % arrowhead
- n 2283 420 m 2403 450 l 2283 480 l 2283 450 l 2283 420 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 2283 2220 m 2403 2250 l 2283 2280 l 2445 2280 l 2445 2220 l cp clip
- n 2070 2250 m 2430 2250 l gs col-1 s gr gr
- % arrowhead
- n 2283 2220 m 2403 2250 l 2283 2280 l 2283 2250 l 2283 2220 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 2100 1968 m 2070 2088 l 2040 1968 l 2040 2130 l 2100 2130 l cp clip
- n 2070 720 m 2070 2115 l gs col-1 s gr gr
- % arrowhead
- n 2100 1968 m 2070 2088 l 2040 1968 l 2070 1968 l 2100 1968 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- n 1935 4455 m 1935 3915 l 2205 3915 l 2205 4455 l cp gs col-1 s gr
- % Polyline
- n 1935 4185 m 2205 4185 l gs col-1 s gr
- % Polyline
- n 2205 5265 m 2205 5805 l 1935 5805 l 1935 5265 l cp gs col-1 s gr
- % Polyline
- n 2205 5535 m 1935 5535 l gs col-1 s gr
- % Polyline
- n 2205 5535 m 1935 5805 l gs col-1 s gr
- % Polyline
- n 2205 5805 m 1935 5535 l gs col-1 s gr
- % Polyline
- n 2430 3915 m 3330 3915 l gs col-1 s gr
- % Polyline
- n 2430 4185 m 3330 4185 l gs col-1 s gr
- % Polyline
- n 2430 3690 m 3330 3690 l 3330 4455 l 2430 4455 l cp gs col-1 s gr
- % Polyline
- n 3060 3915 m 3060 4455 l gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 2520 4365 m
- gs 1 -1 sc (relExpr) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 2520 4095 m
- gs 1 -1 sc (name) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 2565 3870 m
- gs 1 -1 sc (RangeVar) col-1 sh gr
- % Polyline
- n 3600 4320 m 4500 4320 l gs col-1 s gr
- % Polyline
- n 3600 4095 m 4500 4095 l 4500 4590 l 3600 4590 l cp gs col-1 s gr
- % Polyline
- n 4230 4320 m 4230 4590 l gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 3690 4500 m
- gs 1 -1 sc (relname) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 3690 4275 m
- gs 1 -1 sc (RelExpr) col-1 sh gr
- % Polyline
- n 2430 2250 m 3240 2250 l gs col-1 s gr
- % Polyline
- n 2430 2025 m 3240 2025 l 3240 2520 l 2430 2520 l cp gs col-1 s gr
- % Polyline
- n 2970 2250 m 2970 2520 l gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 2520 2430 m
- gs 1 -1 sc (val) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 2520 2205 m
- gs 1 -1 sc (ResTarget) col-1 sh gr
- % Polyline
- n 3510 2250 m 4410 2250 l gs col-1 s gr
- % Polyline
- n 3510 2520 m 4410 2520 l gs col-1 s gr
- % Polyline
- n 3510 2025 m 4410 2025 l 4410 2790 l 3510 2790 l cp gs col-1 s gr
- % Polyline
- n 4140 2250 m 4140 2790 l gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 3825 2205 m
- gs 1 -1 sc (Attr) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 3600 2700 m
- gs 1 -1 sc (attrs) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 3600 2430 m
- gs 1 -1 sc (relname) col-1 sh gr
- % Polyline
- n 4635 2520 m 5175 2520 l 5175 2790 l 4635 2790 l cp gs col-1 s gr
- % Polyline
- n 4905 2520 m 4905 2790 l gs col-1 s gr
- % Polyline
- n 4905 2520 m 5175 2790 l gs col-1 s gr
- % Polyline
- n 5175 2520 m 4905 2790 l gs col-1 s gr
- % Polyline
- n 4365 3015 m 5175 3015 l 5175 3510 l 4365 3510 l cp gs col-1 s gr
- % Polyline
- n 4365 3240 m 5175 3240 l gs col-1 s gr
- % Polyline
- n 4905 3240 m 4905 3510 l gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 4590 3195 m
- gs 1 -1 sc (Value) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 4455 3420 m
- gs 1 -1 sc (val.str) col-1 sh gr
- % Polyline
- n 225 450 m 1485 450 l gs col-1 s gr
- % Polyline
- n 1215 990 m 1215 2610 l gs col-1 s gr
- % Polyline
- n 225 720 m 1485 720 l gs col-1 s gr
- % Polyline
- n 225 990 m 1485 990 l gs col-1 s gr
- % Polyline
- n 225 1260 m 1485 1260 l gs col-1 s gr
- % Polyline
- n 225 1530 m 1485 1530 l gs col-1 s gr
- % Polyline
- n 225 1800 m 1485 1800 l gs col-1 s gr
- % Polyline
- n 225 2070 m 1485 2070 l gs col-1 s gr
- % Polyline
- n 225 225 m 1485 225 l 1485 2610 l 225 2610 l cp gs col-1 s gr
- % Polyline
- n 225 2340 m 1485 2340 l gs col-1 s gr
- % Polyline
- n 1215 450 m 1215 720 l gs col-1 s gr
- % Polyline
- gs clippath
- 3363 555 m 3483 585 l 3363 615 l 3525 615 l 3525 555 l cp clip
- n 3105 585 m 3510 585 l gs col-1 s gr gr
- % arrowhead
- n 3363 555 m 3483 585 l 3363 615 l 3363 585 l 3363 555 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 4488 555 m 4608 585 l 4488 615 l 4650 615 l 4650 555 l cp clip
- n 4275 585 m 4635 585 l gs col-1 s gr gr
- % arrowhead
- n 4488 555 m 4608 585 l 4488 615 l 4488 585 l 4488 555 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 4488 825 m 4608 855 l 4488 885 l 4650 885 l 4650 825 l cp clip
- n 4275 855 m 4635 855 l gs col-1 s gr gr
- % arrowhead
- n 4488 825 m 4608 855 l 4488 885 l 4488 855 l 4488 825 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 4800 1068 m 4770 1188 l 4740 1068 l 4740 1230 l 4800 1230 l cp clip
- n 4770 855 m 4770 1215 l gs col-1 s gr gr
- % arrowhead
- n 4800 1068 m 4770 1188 l 4740 1068 l 4770 1068 l 4800 1068 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 5070 1788 m 5040 1908 l 5010 1788 l 5010 1950 l 5070 1950 l cp clip
- n 5040 1575 m 5040 1935 l gs col-1 s gr gr
- % arrowhead
- n 5070 1788 m 5040 1908 l 5010 1788 l 5040 1788 l 5070 1788 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 2283 4020 m 2403 4050 l 2283 4080 l 2445 4080 l 2445 4020 l cp clip
- n 2070 4050 m 2430 4050 l gs col-1 s gr gr
- % arrowhead
- n 2283 4020 m 2403 4050 l 2283 4080 l 2283 4050 l 2283 4020 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 2100 5118 m 2070 5238 l 2040 5118 l 2040 5280 l 2100 5280 l cp clip
- n 2070 4320 m 2070 5265 l gs col-1 s gr gr
- % arrowhead
- n 2100 5118 m 2070 5238 l 2040 5118 l 2070 5118 l 2100 5118 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 2283 5370 m 2403 5400 l 2283 5430 l 2445 5430 l 2445 5370 l cp clip
- n 2070 5400 m 2430 5400 l gs col-1 s gr gr
- % arrowhead
- n 2283 5370 m 2403 5400 l 2283 5430 l 2283 5400 l 2283 5370 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 3453 4290 m 3573 4320 l 3453 4350 l 3615 4350 l 3615 4290 l cp clip
- n 3195 4320 m 3600 4320 l gs col-1 s gr gr
- % arrowhead
- n 3453 4290 m 3573 4320 l 3453 4350 l 3453 4320 l 3453 4290 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 4395 4668 m 4365 4788 l 4335 4668 l 4335 4830 l 4395 4830 l cp clip
- n 4365 4455 m 4365 4815 l gs col-1 s gr gr
- % arrowhead
- n 4395 4668 m 4365 4788 l 4335 4668 l 4365 4668 l 4395 4668 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 3363 2355 m 3483 2385 l 3363 2415 l 3525 2415 l 3525 2355 l cp clip
- n 3105 2385 m 3510 2385 l gs col-1 s gr gr
- % arrowhead
- n 3363 2355 m 3483 2385 l 3363 2415 l 3363 2385 l 3363 2355 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 4488 2355 m 4608 2385 l 4488 2415 l 4650 2415 l 4650 2355 l cp clip
- n 4275 2385 m 4635 2385 l gs col-1 s gr gr
- % arrowhead
- n 4488 2355 m 4608 2385 l 4488 2415 l 4488 2385 l 4488 2355 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 4488 2625 m 4608 2655 l 4488 2685 l 4650 2685 l 4650 2625 l cp clip
- n 4275 2655 m 4635 2655 l gs col-1 s gr gr
- % arrowhead
- n 4488 2625 m 4608 2655 l 4488 2685 l 4488 2655 l 4488 2625 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 4800 2868 m 4770 2988 l 4740 2868 l 4740 3030 l 4800 3030 l cp clip
- n 4770 2655 m 4770 3015 l gs col-1 s gr gr
- % arrowhead
- n 4800 2868 m 4770 2988 l 4740 2868 l 4770 2868 l 4800 2868 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 5070 3588 m 5040 3708 l 5010 3588 l 5010 3750 l 5070 3750 l cp clip
- n 5040 3375 m 5040 3735 l gs col-1 s gr gr
- % arrowhead
- n 5070 3588 m 5040 3708 l 5010 3588 l 5040 3588 l 5070 3588 l cp gs 0.00 setgray ef gr col-1 s
- % Open spline
- gs clippath
- 1788 555 m 1908 585 l 1788 615 l 1950 615 l 1950 555 l cp clip
- n 1350.0 1125.0 m 1530.0 1125.0 l
- 1530.0 1125.0 1710.0 1125.0 1687.5 855.0 DrawSplineSection
- 1687.5 855.0 1665.0 585.0 1800.0 585.0 DrawSplineSection
- 1935.0 585.0 l gs col-1 s gr
- gr
- % arrowhead
- n 1788 555 m 1908 585 l 1788 615 l 1788 585 l 1788 555 l cp gs 0.00 setgray ef gr col-1 s
- % Open spline
- gs clippath
- 2100 3768 m 2070 3888 l 2040 3768 l 2040 3930 l 2100 3930 l cp clip
- n 1350.0 1395.0 m 1620.0 1395.0 l
- 1620.0 1395.0 1890.0 1395.0 1845.0 2272.5 DrawSplineSection
- 1845.0 2272.5 1800.0 3150.0 1935.0 3285.0 DrawSplineSection
- 1935.0 3285.0 2070.0 3420.0 2070.0 3667.5 DrawSplineSection
- 2070.0 3915.0 l gs col-1 s gr
- gr
- % arrowhead
- n 2100 3768 m 2070 3888 l 2040 3768 l 2070 3768 l 2100 3768 l cp gs 0.00 setgray ef gr col-1 s
- % Open spline
- gs clippath
- 1155 3228 m 1125 3348 l 1095 3228 l 1095 3390 l 1155 3390 l cp clip
- n 1350.0 1665.0 m 1507.5 1665.0 l
- 1507.5 1665.0 1665.0 1665.0 1665.0 2340.0 DrawSplineSection
- 1665.0 2340.0 1665.0 3015.0 1395.0 3015.0 DrawSplineSection
- 1395.0 3015.0 1125.0 3015.0 1125.0 3195.0 DrawSplineSection
- 1125.0 3375.0 l gs col-1 s gr
- gr
- % arrowhead
- n 1155 3228 m 1125 3348 l 1095 3228 l 1125 3228 l 1155 3228 l cp gs 0.00 setgray ef gr col-1 s
- % Open spline
- gs clippath
- 3543 3840 m 3663 3870 l 3543 3900 l 3705 3900 l 3705 3840 l cp clip
- n 3195.0 4050.0 m 3330.0 4050.0 l
- 3330.0 4050.0 3465.0 4050.0 3465.0 3960.0 DrawSplineSection
- 3465.0 3960.0 3465.0 3870.0 3577.5 3870.0 DrawSplineSection
- 3690.0 3870.0 l gs col-1 s gr
- gr
- % arrowhead
- n 3543 3840 m 3663 3870 l 3543 3900 l 3543 3870 l 3543 3840 l cp gs 0.00 setgray ef gr col-1 s
- /Times-Roman ff 150.00 scf sf
- 315 900 m
- gs 1 -1 sc (unionall: false) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 540 405 m
- gs 1 -1 sc (SelectStmt) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 315 630 m
- gs 1 -1 sc (unique) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 315 1170 m
- gs 1 -1 sc (targetList) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 315 1440 m
- gs 1 -1 sc (fromClause) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 315 1710 m
- gs 1 -1 sc (whereClause) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 315 1980 m
- gs 1 -1 sc (groupClause) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 315 2250 m
- gs 1 -1 sc (havingClause) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 315 2520 m
- gs 1 -1 sc (sortClause) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 4815 2115 m
- gs 1 -1 sc ("sname") col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 4725 630 m
- gs 1 -1 sc ("s") col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 720 3600 m
- gs 1 -1 sc (Operator Tree) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 765 3795 m
- gs 1 -1 sc (representing ) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 630 3990 m
- gs 1 -1 sc (the qualifications) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 3780 3915 m
- gs 1 -1 sc ("s") col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 4095 4995 m
- gs 1 -1 sc ("supplier") col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 4725 2430 m
- gs 1 -1 sc ("se") col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 4905 3915 m
- gs 1 -1 sc ("sno") col-1 sh gr
- showpage
- $F2psEnd
- rs
- %%EndDocument
- @endspecial 561 2411 a(Figure)g(3.2:)j Fp(T)-5 b(ar)n(getList)12
- b Ft(and)h Fp(F)m(r)n(omList)g Ft(for)e(query)h(of)g(e)o(xample)h(3.1)
- 270 2651 y Fh(3.3.2)59 b(T)l(ransf)o(ormation)13 b(Pr)o(ocess)270
- 2745 y Ft(The)18 b Fp(tr)o(ansformation)f(pr)n(ocess)i
- Ft(takes)e(the)g Fp(tr)n(ee)h Ft(handed)f(back)g(by)h(the)f
- Fp(parser)h Ft(as)f(input)g(and)g(steps)270 2804 y(recursi)o(v)o(ely)g
- (through)f(it.)31 b(If)17 b(a)h Fr(SelectStmt)e Ft(node)i(is)g(found,)g
- (it)f(is)h(transformed)f(to)g(a)h Fr(Query)270 2864 y
- Ft(node)g(which)g(will)g(be)g(the)h(top)f(most)g(node)g(of)g(the)g(ne)o
- (w)g(data)h(structure.)32 b(Figure)18 b(3.4)g(sho)o(ws)h(the)270
- 2924 y(transformed)12 b(data)h(structure)f((the)g(part)h(for)f(the)g
- (transformed)g Fp(wher)n(e)i(clause)f Ft(is)g(gi)o(v)o(en)g(in)g
- ( 02gure)f(3.5)270 2984 y(because)h(there)f(was)h(not)f(enough)g
- (space)h(to)f(sho)o(w)g(all)h(parts)f(in)g(one)h( 02gure).)345
- 3044 y(No)o(w)i(a)i(check)f(is)g(made,)i(if)d(the)h Fp(r)n(elation)g
- (names)g Ft(in)g(the)g Fp(fr)n(omClause)h Ft(are)e(kno)o(wn)h(to)g(the)
- g(sys-)270 3103 y(tem.)21 b(F)o(or)14 b(e)o(v)o(ery)f
- Fp(r)n(elation)h(name)h Ft(that)e(is)i(present)f(in)g(the)g
- Fp(system)h(catalogs)f Ft(a)g Fr(RTE)g Ft(node)g(is)g(created)270
- 3163 y(containing)e(the)g Fp(r)n(elation)g(name)p Ft(,)h(the)f
- Fp(alias)g(name)g Ft(and)h(the)f Fp(r)n(elation)g(id)p
- Ft(.)k(From)11 b(no)o(w)h(on)g(the)g Fp(r)n(elation)270
- 3223 y(ids)h Ft(are)g(used)h(to)f(refer)f(to)h(the)g
- Fp(r)n(elations)g Ft(gi)o(v)o(en)g(in)g(the)g(query)m(.)k(All)c
- Fr(RTE)g Ft(nodes)g(are)g(collected)g(in)g(the)270 3283
- y Fp(r)o(ange)k(table)f(entry)h(list)g Ft(which)g(is)g(connected)g(to)f
- (the)h( 02eld)f Fr(rtable)h Ft(of)f(the)h Fr(Query)f
- Ft(node.)29 b(If)16 b(a)270 3342 y(name)d(of)f(a)i Fp(r)n(elation)f
- Ft(that)f(is)i(not)e(kno)o(wn)h(to)g(the)g(system)g(is)g(detected)g(in)
- g(the)g(query)f(an)i(error)d(will)i(be)270 3402 y(returned)e(and)i(the)
- f Fp(query)h(pr)n(ocessing)g Ft(will)f(be)h(aborted.)p
- eop
- %%Page: 55 55
- 55 54 bop 198 60 a Fm(3.3.)29 b(THE)13 b(P)-5 b(ARSER)13
- b(ST)-5 b(A)n(GE)1189 b Ft(55)276 2863 y @beginspecial
- 141 @llx 165 @lly 470 @urx 627 @ury 3290 @rwi @setspecial
- %%BeginDocument: figures/where_clause.ps
- %Magnification: 1.05
- /$F2psDict 200 dict def
- $F2psDict begin
- $F2psDict /mtrx matrix put
- /col-1 {0 setgray} bind def
- /col0 {0.000 0.000 0.000 srgb} bind def
- /col1 {0.000 0.000 1.000 srgb} bind def
- /col2 {0.000 1.000 0.000 srgb} bind def
- /col3 {0.000 1.000 1.000 srgb} bind def
- /col4 {1.000 0.000 0.000 srgb} bind def
- /col5 {1.000 0.000 1.000 srgb} bind def
- /col6 {1.000 1.000 0.000 srgb} bind def
- /col7 {1.000 1.000 1.000 srgb} bind def
- /col8 {0.000 0.000 0.560 srgb} bind def
- /col9 {0.000 0.000 0.690 srgb} bind def
- /col10 {0.000 0.000 0.820 srgb} bind def
- /col11 {0.530 0.810 1.000 srgb} bind def
- /col12 {0.000 0.560 0.000 srgb} bind def
- /col13 {0.000 0.690 0.000 srgb} bind def
- /col14 {0.000 0.820 0.000 srgb} bind def
- /col15 {0.000 0.560 0.560 srgb} bind def
- /col16 {0.000 0.690 0.690 srgb} bind def
- /col17 {0.000 0.820 0.820 srgb} bind def
- /col18 {0.560 0.000 0.000 srgb} bind def
- /col19 {0.690 0.000 0.000 srgb} bind def
- /col20 {0.820 0.000 0.000 srgb} bind def
- /col21 {0.560 0.000 0.560 srgb} bind def
- /col22 {0.690 0.000 0.690 srgb} bind def
- /col23 {0.820 0.000 0.820 srgb} bind def
- /col24 {0.500 0.190 0.000 srgb} bind def
- /col25 {0.630 0.250 0.000 srgb} bind def
- /col26 {0.750 0.380 0.000 srgb} bind def
- /col27 {1.000 0.500 0.500 srgb} bind def
- /col28 {1.000 0.630 0.630 srgb} bind def
- /col29 {1.000 0.750 0.750 srgb} bind def
- /col30 {1.000 0.880 0.880 srgb} bind def
- /col31 {1.000 0.840 0.000 srgb} bind def
- end
- save
- 128.5 640.0 translate
- 1 -1 scale
- /cp {closepath} bind def
- /ef {eofill} bind def
- /gr {grestore} bind def
- /gs {gsave} bind def
- /sa {save} bind def
- /rs {restore} bind def
- /l {lineto} bind def
- /m {moveto} bind def
- /rm {rmoveto} bind def
- /n {newpath} bind def
- /s {stroke} bind def
- /sh {show} bind def
- /slc {setlinecap} bind def
- /slj {setlinejoin} bind def
- /slw {setlinewidth} bind def
- /srgb {setrgbcolor} bind def
- /rot {rotate} bind def
- /sc {scale} bind def
- /sd {setdash} bind def
- /ff {findfont} bind def
- /sf {setfont} bind def
- /scf {scalefont} bind def
- /sw {stringwidth} bind def
- /tr {translate} bind def
- /tnt {dup dup currentrgbcolor
- 4 -2 roll dup 1 exch sub 3 -1 roll mul add
- 4 -2 roll dup 1 exch sub 3 -1 roll mul add
- 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
- bind def
- /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
- 4 -2 roll mul srgb} bind def
- /DrawSplineSection {
- /y3 exch def
- /x3 exch def
- /y2 exch def
- /x2 exch def
- /y1 exch def
- /x1 exch def
- /xa x1 x2 x1 sub 0.666667 mul add def
- /ya y1 y2 y1 sub 0.666667 mul add def
- /xb x3 x2 x3 sub 0.666667 mul add def
- /yb y3 y2 y3 sub 0.666667 mul add def
- x1 y1 lineto
- xa ya xb yb x3 y3 curveto
- } def
- /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
- /$F2psEnd {$F2psEnteredState restore end} def
- $F2psBegin
- 10 setmiterlimit
- n 0 792 m 0 0 l 612 0 l 612 792 l cp clip
- 0.06299 0.06299 sc
- 7.500 slw
- % Polyline
- n 1215 450 m 1485 720 l gs col-1 s gr
- % Polyline
- n 1485 450 m 1215 720 l gs col-1 s gr
- % Polyline
- n 1215 1800 m 1485 2070 l gs col-1 s gr
- % Polyline
- n 1485 1800 m 1215 2070 l gs col-1 s gr
- % Polyline
- n 1215 2070 m 1485 2340 l gs col-1 s gr
- % Polyline
- n 1485 2070 m 1215 2340 l gs col-1 s gr
- % Polyline
- n 1215 2340 m 1485 2610 l gs col-1 s gr
- % Polyline
- n 1485 2340 m 1215 2610 l gs col-1 s gr
- % Polyline
- n 2790 1260 m 1800 1260 l gs col-1 s gr
- % Polyline
- n 1800 1530 m 2790 1530 l gs col-1 s gr
- % Polyline
- n 1800 1800 m 2790 1800 l gs col-1 s gr
- % Polyline
- n 1800 2070 m 2790 2070 l gs col-1 s gr
- % Polyline
- n 1800 1035 m 2790 1035 l 2790 2340 l 1800 2340 l cp gs col-1 s gr
- % Polyline
- n 2520 1800 m 2520 2340 l gs col-1 s gr
- % Polyline
- n 2520 1260 m 2520 1530 l gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 2070 1215 m
- gs 1 -1 sc (A_Expr) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 1890 1710 m
- gs 1 -1 sc (oper) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 1890 1440 m
- gs 1 -1 sc (opname) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 1890 1980 m
- gs 1 -1 sc (rexpr) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 1890 2250 m
- gs 1 -1 sc (lexpr) col-1 sh gr
- % Polyline
- n 2520 1260 m 2790 1530 l gs col-1 s gr
- % Polyline
- n 2790 1260 m 2520 1530 l gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 2385 1710 m
- gs 1 -1 sc (AND) col-1 sh gr
- % Polyline
- n 1350 6120 m 1890 6120 l 1890 6390 l 1350 6390 l cp gs col-1 s gr
- % Polyline
- n 1620 6120 m 1620 6390 l gs col-1 s gr
- % Polyline
- n 1620 6120 m 1890 6390 l gs col-1 s gr
- % Polyline
- n 1890 6120 m 1620 6390 l gs col-1 s gr
- % Polyline
- n 1080 6615 m 1890 6615 l 1890 7110 l 1080 7110 l cp gs col-1 s gr
- % Polyline
- n 1080 6840 m 1890 6840 l gs col-1 s gr
- % Polyline
- n 1620 6840 m 1620 7110 l gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 1305 6795 m
- gs 1 -1 sc (Value) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 1170 7020 m
- gs 1 -1 sc (val.str) col-1 sh gr
- % Polyline
- n 225 5850 m 1125 5850 l gs col-1 s gr
- % Polyline
- n 225 6120 m 1125 6120 l gs col-1 s gr
- % Polyline
- n 225 5625 m 1125 5625 l 1125 6390 l 225 6390 l cp gs col-1 s gr
- % Polyline
- n 855 5850 m 855 6390 l gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 540 5805 m
- gs 1 -1 sc (Attr) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 315 6300 m
- gs 1 -1 sc (attrs) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 315 6030 m
- gs 1 -1 sc (relname) col-1 sh gr
- % Polyline
- gs clippath
- 1785 7188 m 1755 7308 l 1725 7188 l 1725 7350 l 1785 7350 l cp clip
- n 1755 6975 m 1755 7335 l gs col-1 s gr gr
- % arrowhead
- n 1785 7188 m 1755 7308 l 1725 7188 l 1755 7188 l 1785 7188 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 1203 5955 m 1323 5985 l 1203 6015 l 1365 6015 l 1365 5955 l cp clip
- n 990 5985 m 1350 5985 l gs col-1 s gr gr
- % arrowhead
- n 1203 5955 m 1323 5985 l 1203 6015 l 1203 5985 l 1203 5955 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 1203 6225 m 1323 6255 l 1203 6285 l 1365 6285 l 1365 6225 l cp clip
- n 990 6255 m 1350 6255 l gs col-1 s gr gr
- % arrowhead
- n 1203 6225 m 1323 6255 l 1203 6285 l 1203 6255 l 1203 6225 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 1515 6468 m 1485 6588 l 1455 6468 l 1455 6630 l 1515 6630 l cp clip
- n 1485 6255 m 1485 6615 l gs col-1 s gr gr
- % arrowhead
- n 1515 6468 m 1485 6588 l 1455 6468 l 1485 6468 l 1515 6468 l cp gs 0.00 setgray ef gr col-1 s
- /Times-Roman ff 150.00 scf sf
- 1620 7515 m
- gs 1 -1 sc ("sno") col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 1440 6030 m
- gs 1 -1 sc ("s") col-1 sh gr
- % Polyline
- n 1350 5130 m 2340 5130 l gs col-1 s gr
- % Polyline
- n 1350 4905 m 2340 4905 l 2340 5400 l 1350 5400 l cp gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 1440 5310 m
- gs 1 -1 sc (val.val.ival: 2) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 1575 5085 m
- gs 1 -1 sc (A_Const) col-1 sh gr
- % Polyline
- n 2475 5850 m 3375 5850 l gs col-1 s gr
- % Polyline
- n 2475 6120 m 3375 6120 l gs col-1 s gr
- % Polyline
- n 2475 5625 m 3375 5625 l 3375 6390 l 2475 6390 l cp gs col-1 s gr
- % Polyline
- n 3105 5850 m 3105 6390 l gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 2790 5805 m
- gs 1 -1 sc (Attr) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 2565 6300 m
- gs 1 -1 sc (attrs) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 2565 6030 m
- gs 1 -1 sc (relname) col-1 sh gr
- % Polyline
- n 3600 6120 m 4140 6120 l 4140 6390 l 3600 6390 l cp gs col-1 s gr
- % Polyline
- n 3870 6120 m 3870 6390 l gs col-1 s gr
- % Polyline
- n 3870 6120 m 4140 6390 l gs col-1 s gr
- % Polyline
- n 4140 6120 m 3870 6390 l gs col-1 s gr
- % Polyline
- n 3330 6615 m 4140 6615 l 4140 7110 l 3330 7110 l cp gs col-1 s gr
- % Polyline
- n 3330 6840 m 4140 6840 l gs col-1 s gr
- % Polyline
- n 3870 6840 m 3870 7110 l gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 3555 6795 m
- gs 1 -1 sc (Value) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 3420 7020 m
- gs 1 -1 sc (val.str) col-1 sh gr
- % Polyline
- gs clippath
- 3453 5955 m 3573 5985 l 3453 6015 l 3615 6015 l 3615 5955 l cp clip
- n 3240 5985 m 3600 5985 l gs col-1 s gr gr
- % arrowhead
- n 3453 5955 m 3573 5985 l 3453 6015 l 3453 5985 l 3453 5955 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 3453 6225 m 3573 6255 l 3453 6285 l 3615 6285 l 3615 6225 l cp clip
- n 3240 6255 m 3600 6255 l gs col-1 s gr gr
- % arrowhead
- n 3453 6225 m 3573 6255 l 3453 6285 l 3453 6255 l 3453 6225 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 3765 6468 m 3735 6588 l 3705 6468 l 3705 6630 l 3765 6630 l cp clip
- n 3735 6255 m 3735 6615 l gs col-1 s gr gr
- % arrowhead
- n 3765 6468 m 3735 6588 l 3705 6468 l 3735 6468 l 3765 6468 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 4035 7188 m 4005 7308 l 3975 7188 l 3975 7350 l 4035 7350 l cp clip
- n 4005 6975 m 4005 7335 l gs col-1 s gr gr
- % arrowhead
- n 4035 7188 m 4005 7308 l 3975 7188 l 4005 7188 l 4035 7188 l cp gs 0.00 setgray ef gr col-1 s
- /Times-Roman ff 150.00 scf sf
- 3690 6030 m
- gs 1 -1 sc ("s") col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 3870 7515 m
- gs 1 -1 sc ("sno") col-1 sh gr
- % Polyline
- n 3690 5130 m 4590 5130 l gs col-1 s gr
- % Polyline
- n 3690 5400 m 4590 5400 l gs col-1 s gr
- % Polyline
- n 3690 4905 m 4590 4905 l 4590 5670 l 3690 5670 l cp gs col-1 s gr
- % Polyline
- n 4320 5130 m 4320 5670 l gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 4005 5085 m
- gs 1 -1 sc (Attr) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 3780 5580 m
- gs 1 -1 sc (attrs) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 3780 5310 m
- gs 1 -1 sc (relname) col-1 sh gr
- % Polyline
- n 4815 5400 m 5355 5400 l 5355 5670 l 4815 5670 l cp gs col-1 s gr
- % Polyline
- n 5085 5400 m 5085 5670 l gs col-1 s gr
- % Polyline
- n 5085 5400 m 5355 5670 l gs col-1 s gr
- % Polyline
- n 5355 5400 m 5085 5670 l gs col-1 s gr
- % Polyline
- n 4545 5895 m 5355 5895 l 5355 6390 l 4545 6390 l cp gs col-1 s gr
- % Polyline
- n 4545 6120 m 5355 6120 l gs col-1 s gr
- % Polyline
- n 5085 6120 m 5085 6390 l gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 4770 6075 m
- gs 1 -1 sc (Value) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 4635 6300 m
- gs 1 -1 sc (val.str) col-1 sh gr
- % Polyline
- gs clippath
- 4668 5235 m 4788 5265 l 4668 5295 l 4830 5295 l 4830 5235 l cp clip
- n 4455 5265 m 4815 5265 l gs col-1 s gr gr
- % arrowhead
- n 4668 5235 m 4788 5265 l 4668 5295 l 4668 5265 l 4668 5235 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 4668 5505 m 4788 5535 l 4668 5565 l 4830 5565 l 4830 5505 l cp clip
- n 4455 5535 m 4815 5535 l gs col-1 s gr gr
- % arrowhead
- n 4668 5505 m 4788 5535 l 4668 5565 l 4668 5535 l 4668 5505 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 4980 5748 m 4950 5868 l 4920 5748 l 4920 5910 l 4980 5910 l cp clip
- n 4950 5535 m 4950 5895 l gs col-1 s gr gr
- % arrowhead
- n 4980 5748 m 4950 5868 l 4920 5748 l 4950 5748 l 4980 5748 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 5250 6468 m 5220 6588 l 5190 6468 l 5190 6630 l 5250 6630 l cp clip
- n 5220 6255 m 5220 6615 l gs col-1 s gr gr
- % arrowhead
- n 5250 6468 m 5220 6588 l 5190 6468 l 5220 6468 l 5250 6468 l cp gs 0.00 setgray ef gr col-1 s
- /Times-Roman ff 150.00 scf sf
- 4905 5310 m
- gs 1 -1 sc ("se") col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 5085 6795 m
- gs 1 -1 sc ("sno") col-1 sh gr
- % Polyline
- n 3465 3375 m 2475 3375 l gs col-1 s gr
- % Polyline
- n 2475 3645 m 3465 3645 l gs col-1 s gr
- % Polyline
- n 2475 3915 m 3465 3915 l gs col-1 s gr
- % Polyline
- n 2475 4185 m 3465 4185 l gs col-1 s gr
- % Polyline
- n 2475 3150 m 3465 3150 l 3465 4455 l 2475 4455 l cp gs col-1 s gr
- % Polyline
- n 3195 3915 m 3195 4455 l gs col-1 s gr
- % Polyline
- n 3195 3375 m 3195 3645 l gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 2745 3330 m
- gs 1 -1 sc (A_Expr) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 2565 3825 m
- gs 1 -1 sc (oper) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 2565 3555 m
- gs 1 -1 sc (opname) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 2565 4095 m
- gs 1 -1 sc (rexpr) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 2565 4365 m
- gs 1 -1 sc (lexpr) col-1 sh gr
- % Polyline
- n 225 450 m 1485 450 l gs col-1 s gr
- % Polyline
- n 1215 990 m 1215 2610 l gs col-1 s gr
- % Polyline
- n 225 720 m 1485 720 l gs col-1 s gr
- % Polyline
- n 225 990 m 1485 990 l gs col-1 s gr
- % Polyline
- n 225 1260 m 1485 1260 l gs col-1 s gr
- % Polyline
- n 225 1530 m 1485 1530 l gs col-1 s gr
- % Polyline
- n 225 1800 m 1485 1800 l gs col-1 s gr
- % Polyline
- n 225 2070 m 1485 2070 l gs col-1 s gr
- % Polyline
- n 225 225 m 1485 225 l 1485 2610 l 225 2610 l cp gs col-1 s gr
- % Polyline
- n 225 2340 m 1485 2340 l gs col-1 s gr
- % Polyline
- n 1215 450 m 1215 720 l gs col-1 s gr
- % Polyline
- gs clippath
- 1653 1635 m 1773 1665 l 1653 1695 l 1815 1695 l 1815 1635 l cp clip
- n 1350 1665 m 1800 1665 l gs col-1 s gr gr
- % arrowhead
- n 1653 1635 m 1773 1665 l 1653 1695 l 1653 1665 l 1653 1635 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 1293 3480 m 1413 3510 l 1293 3540 l 1455 3540 l 1455 3480 l cp clip
- n 1080 3510 m 1440 3510 l gs col-1 s gr gr
- % arrowhead
- n 1293 3480 m 1413 3510 l 1293 3540 l 1293 3510 l 1293 3480 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- n 1215 3375 m 225 3375 l gs col-1 s gr
- % Polyline
- n 225 3645 m 1215 3645 l gs col-1 s gr
- % Polyline
- n 225 3915 m 1215 3915 l gs col-1 s gr
- % Polyline
- n 225 4185 m 1215 4185 l gs col-1 s gr
- % Polyline
- n 225 3150 m 1215 3150 l 1215 4455 l 225 4455 l cp gs col-1 s gr
- % Polyline
- n 945 3915 m 945 4455 l gs col-1 s gr
- % Polyline
- n 945 3375 m 945 3645 l gs col-1 s gr
- % Polyline
- gs clippath
- 3543 3480 m 3663 3510 l 3543 3540 l 3705 3540 l 3705 3480 l cp clip
- n 3330 3510 m 3690 3510 l gs col-1 s gr gr
- % arrowhead
- n 3543 3480 m 3663 3510 l 3543 3540 l 3543 3510 l 3543 3480 l cp gs 0.00 setgray ef gr col-1 s
- % Open spline
- gs clippath
- 705 5478 m 675 5598 l 645 5478 l 645 5640 l 705 5640 l cp clip
- n 1080.0 4320.0 m 1237.5 4320.0 l
- 1237.5 4320.0 1395.0 4320.0 1395.0 4522.5 DrawSplineSection
- 1395.0 4522.5 1395.0 4725.0 1035.0 4725.0 DrawSplineSection
- 1035.0 4725.0 675.0 4725.0 675.0 5175.0 DrawSplineSection
- 675.0 5625.0 l gs col-1 s gr
- gr
- % arrowhead
- n 705 5478 m 675 5598 l 645 5478 l 675 5478 l 705 5478 l cp gs 0.00 setgray ef gr col-1 s
- % Open spline
- gs clippath
- 1875 4758 m 1845 4878 l 1815 4758 l 1815 4920 l 1875 4920 l cp clip
- n 1080.0 4050.0 m 1282.5 4050.0 l
- 1282.5 4050.0 1485.0 4050.0 1665.0 4095.0 DrawSplineSection
- 1665.0 4095.0 1845.0 4140.0 1845.0 4522.5 DrawSplineSection
- 1845.0 4905.0 l gs col-1 s gr
- gr
- % arrowhead
- n 1875 4758 m 1845 4878 l 1815 4758 l 1845 4758 l 1875 4758 l cp gs 0.00 setgray ef gr col-1 s
- % Open spline
- gs clippath
- 823 3041 m 734 3127 l 772 3009 l 687 3147 l 737 3179 l cp clip
- n 2655.0 2205.0 m 2835.0 2205.0 l
- 2835.0 2205.0 3015.0 2205.0 3015.0 2452.5 DrawSplineSection
- 3015.0 2452.5 3015.0 2700.0 1980.0 2745.0 DrawSplineSection
- 1980.0 2745.0 945.0 2790.0 832.5 2970.0 DrawSplineSection
- 720.0 3150.0 l gs col-1 s gr
- gr
- % arrowhead
- n 823 3041 m 734 3127 l 772 3009 l 798 3025 l 823 3041 l cp gs 0.00 setgray ef gr col-1 s
- % Open spline
- gs clippath
- 2955 5478 m 2925 5598 l 2895 5478 l 2895 5640 l 2955 5640 l cp clip
- n 3330.0 4320.0 m 3487.5 4320.0 l
- 3487.5 4320.0 3645.0 4320.0 3645.0 4522.5 DrawSplineSection
- 3645.0 4522.5 3645.0 4725.0 3285.0 4725.0 DrawSplineSection
- 3285.0 4725.0 2925.0 4725.0 2925.0 5175.0 DrawSplineSection
- 2925.0 5625.0 l gs col-1 s gr
- gr
- % arrowhead
- n 2955 5478 m 2925 5598 l 2895 5478 l 2925 5478 l 2955 5478 l cp gs 0.00 setgray ef gr col-1 s
- % Open spline
- gs clippath
- 4170 4758 m 4140 4878 l 4110 4758 l 4110 4920 l 4170 4920 l cp clip
- n 3330.0 4050.0 m 3577.5 4050.0 l
- 3577.5 4050.0 3825.0 4050.0 3982.5 4162.5 DrawSplineSection
- 3982.5 4162.5 4140.0 4275.0 4140.0 4590.0 DrawSplineSection
- 4140.0 4905.0 l gs col-1 s gr
- gr
- % arrowhead
- n 4170 4758 m 4140 4878 l 4110 4758 l 4140 4758 l 4170 4758 l cp gs 0.00 setgray ef gr col-1 s
- % Open spline
- gs clippath
- 3000 3003 m 2970 3123 l 2940 3003 l 2940 3165 l 3000 3165 l cp clip
- n 2655.0 1935.0 m 3015.0 1935.0 l
- 3015.0 1935.0 3375.0 1935.0 3375.0 2272.5 DrawSplineSection
- 3375.0 2272.5 3375.0 2610.0 3172.5 2700.0 DrawSplineSection
- 3172.5 2700.0 2970.0 2790.0 2970.0 2970.0 DrawSplineSection
- 2970.0 3150.0 l gs col-1 s gr
- gr
- % arrowhead
- n 3000 3003 m 2970 3123 l 2940 3003 l 2970 3003 l 3000 3003 l cp gs 0.00 setgray ef gr col-1 s
- % Open spline
- gs clippath
- 1833 375 m 1953 405 l 1833 435 l 1995 435 l 1995 375 l cp clip
- n 1350.0 1125.0 m 1485.0 1125.0 l
- 1485.0 1125.0 1620.0 1125.0 1597.5 765.0 DrawSplineSection
- 1597.5 765.0 1575.0 405.0 1777.5 405.0 DrawSplineSection
- 1980.0 405.0 l gs col-1 s gr
- gr
- % arrowhead
- n 1833 375 m 1953 405 l 1833 435 l 1833 405 l 1833 375 l cp gs 0.00 setgray ef gr col-1 s
- % Open spline
- gs clippath
- 1833 735 m 1953 765 l 1833 795 l 1995 795 l 1995 735 l cp clip
- n 1350.0 1395.0 m 1530.0 1395.0 l
- 1530.0 1395.0 1710.0 1395.0 1687.5 1080.0 DrawSplineSection
- 1687.5 1080.0 1665.0 765.0 1822.5 765.0 DrawSplineSection
- 1980.0 765.0 l gs col-1 s gr
- gr
- % arrowhead
- n 1833 735 m 1953 765 l 1833 795 l 1833 765 l 1833 735 l cp gs 0.00 setgray ef gr col-1 s
- /Times-Roman ff 150.00 scf sf
- 315 900 m
- gs 1 -1 sc (unionall: false) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 540 405 m
- gs 1 -1 sc (SelectStmt) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 315 630 m
- gs 1 -1 sc (unique) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 315 1170 m
- gs 1 -1 sc (targetList) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 315 1440 m
- gs 1 -1 sc (fromClause) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 315 1710 m
- gs 1 -1 sc (whereClause) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 315 1980 m
- gs 1 -1 sc (groupClause) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 315 2250 m
- gs 1 -1 sc (havingClause) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 315 2520 m
- gs 1 -1 sc (sortClause) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 2025 450 m
- gs 1 -1 sc (TargetList) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 2025 810 m
- gs 1 -1 sc (FromList) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 900 3825 m
- gs 1 -1 sc (OP) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 1485 3555 m
- gs 1 -1 sc (">") col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 495 3330 m
- gs 1 -1 sc (A_Expr) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 315 3825 m
- gs 1 -1 sc (oper) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 315 3555 m
- gs 1 -1 sc (opname) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 315 4095 m
- gs 1 -1 sc (rexpr) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 315 4365 m
- gs 1 -1 sc (lexpr) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 3105 3825 m
- gs 1 -1 sc (OP) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 3735 3555 m
- gs 1 -1 sc ("=") col-1 sh gr
- showpage
- $F2psEnd
- rs
- %%EndDocument
- @endspecial 595 2973 a(Figure)11 b(3.3:)16 b Fp(Wher)n(eClause)e
- Ft(for)e(query)f(of)h(e)o(xample)h(3.1)p eop
- %%Page: 56 56
- 56 55 bop 270 60 a Ft(56)82 b Fm(CHAPTER)14 b(3.)28 b(POSTGRESQL)13
- b(FR)n(OM)f(THE)i(PR)n(OGRAMMER'S)f(POINT)f(OF)g(VIEW)270
- 234 y Ft(Ne)o(xt)k(it)h(is)f(checked)g(if)g(the)g Fp(attrib)o(ute)g
- (names)h Ft(used)g(are)f(contained)g(in)g(the)g Fp(r)n(elations)h
- Ft(gi)o(v)o(en)f(in)g(the)270 294 y(query)m(.)39 b(F)o(or)19
- b(e)o(v)o(ery)h Fp(attrib)o(ute)g Ft(that)g(is)h(found)e(a)i
- Fr(TLE)f Ft(node)g(is)g(created)g(holding)g(a)g(pointer)g(to)g(a)270
- 354 y Fr(Resdom)13 b Ft(node)h((which)f(holds)h(the)g(name)g(of)f(the)
- h(column))f(and)h(a)g(pointer)f(to)h(a)g Fr(VAR)g Ft(node.)20
- b(There)270 413 y(are)c(two)g(important)f(numbers)h(in)h(the)f
- Fr(VAR)g Ft(node.)28 b(The)17 b( 02eld)f Fr(varno)g
- Ft(gi)o(v)o(es)h(the)f(position)g(of)g(the)270 473 y
- Fp(r)n(elation)h Ft(containing)f(the)h(current)f Fp(attrib)o(ute)h
- Ft(in)f(the)h Fp(r)o(ange)g(table)g(entry)g(list)g Ft(created)g(abo)o
- (v)o(e.)30 b(The)270 533 y( 02eld)14 b Fr(varattno)g
- Ft(gi)o(v)o(es)h(the)f(position)h(of)f(the)g Fp(attrib)o(ute)h
- Ft(within)f(the)g Fp(r)n(elation)p Ft(.)23 b(If)14 b(the)g(name)h(of)f
- (an)270 593 y Fp(attrib)o(ute)c Ft(cannot)g(be)g(found)f(an)i(error)e
- (will)g(be)i(returned)e(and)h(the)g Fp(query)g(pr)n(ocessing)h
- Ft(will)f(be)g(aborted.)310 2392 y @beginspecial 134
- @llx 230 @lly 478 @urx 561 @ury 3440 @rwi @setspecial
- %%BeginDocument: figures/transform.ps
- %Magnification: 1.05
- /$F2psDict 200 dict def
- $F2psDict begin
- $F2psDict /mtrx matrix put
- /col-1 {0 setgray} bind def
- /col0 {0.000 0.000 0.000 srgb} bind def
- /col1 {0.000 0.000 1.000 srgb} bind def
- /col2 {0.000 1.000 0.000 srgb} bind def
- /col3 {0.000 1.000 1.000 srgb} bind def
- /col4 {1.000 0.000 0.000 srgb} bind def
- /col5 {1.000 0.000 1.000 srgb} bind def
- /col6 {1.000 1.000 0.000 srgb} bind def
- /col7 {1.000 1.000 1.000 srgb} bind def
- /col8 {0.000 0.000 0.560 srgb} bind def
- /col9 {0.000 0.000 0.690 srgb} bind def
- /col10 {0.000 0.000 0.820 srgb} bind def
- /col11 {0.530 0.810 1.000 srgb} bind def
- /col12 {0.000 0.560 0.000 srgb} bind def
- /col13 {0.000 0.690 0.000 srgb} bind def
- /col14 {0.000 0.820 0.000 srgb} bind def
- /col15 {0.000 0.560 0.560 srgb} bind def
- /col16 {0.000 0.690 0.690 srgb} bind def
- /col17 {0.000 0.820 0.820 srgb} bind def
- /col18 {0.560 0.000 0.000 srgb} bind def
- /col19 {0.690 0.000 0.000 srgb} bind def
- /col20 {0.820 0.000 0.000 srgb} bind def
- /col21 {0.560 0.000 0.560 srgb} bind def
- /col22 {0.690 0.000 0.690 srgb} bind def
- /col23 {0.820 0.000 0.820 srgb} bind def
- /col24 {0.500 0.190 0.000 srgb} bind def
- /col25 {0.630 0.250 0.000 srgb} bind def
- /col26 {0.750 0.380 0.000 srgb} bind def
- /col27 {1.000 0.500 0.500 srgb} bind def
- /col28 {1.000 0.630 0.630 srgb} bind def
- /col29 {1.000 0.750 0.750 srgb} bind def
- /col30 {1.000 0.880 0.880 srgb} bind def
- /col31 {1.000 0.840 0.000 srgb} bind def
- end
- save
- 107.0 574.5 translate
- 1 -1 scale
- /cp {closepath} bind def
- /ef {eofill} bind def
- /gr {grestore} bind def
- /gs {gsave} bind def
- /sa {save} bind def
- /rs {restore} bind def
- /l {lineto} bind def
- /m {moveto} bind def
- /rm {rmoveto} bind def
- /n {newpath} bind def
- /s {stroke} bind def
- /sh {show} bind def
- /slc {setlinecap} bind def
- /slj {setlinejoin} bind def
- /slw {setlinewidth} bind def
- /srgb {setrgbcolor} bind def
- /rot {rotate} bind def
- /sc {scale} bind def
- /sd {setdash} bind def
- /ff {findfont} bind def
- /sf {setfont} bind def
- /scf {scalefont} bind def
- /sw {stringwidth} bind def
- /tr {translate} bind def
- /tnt {dup dup currentrgbcolor
- 4 -2 roll dup 1 exch sub 3 -1 roll mul add
- 4 -2 roll dup 1 exch sub 3 -1 roll mul add
- 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
- bind def
- /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
- 4 -2 roll mul srgb} bind def
- /DrawSplineSection {
- /y3 exch def
- /x3 exch def
- /y2 exch def
- /x2 exch def
- /y1 exch def
- /x1 exch def
- /xa x1 x2 x1 sub 0.666667 mul add def
- /ya y1 y2 y1 sub 0.666667 mul add def
- /xb x3 x2 x3 sub 0.666667 mul add def
- /yb y3 y2 y3 sub 0.666667 mul add def
- x1 y1 lineto
- xa ya xb yb x3 y3 curveto
- } def
- /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
- /$F2psEnd {$F2psEnteredState restore end} def
- $F2psBegin
- 10 setmiterlimit
- n 0 792 m 0 0 l 612 0 l 612 792 l cp clip
- 0.06299 0.06299 sc
- 7.500 slw
- % Polyline
- n 1530 5040 m 1800 5310 l gs col-1 s gr
- % Polyline
- n 1800 5040 m 1530 5310 l gs col-1 s gr
- % Polyline
- n 1530 4770 m 1800 5040 l gs col-1 s gr
- % Polyline
- n 1800 4770 m 1530 5040 l gs col-1 s gr
- % Polyline
- n 1530 3960 m 1800 4230 l gs col-1 s gr
- % Polyline
- n 1800 3960 m 1530 4230 l gs col-1 s gr
- % Polyline
- n 1530 3690 m 1800 3960 l gs col-1 s gr
- % Polyline
- n 1800 3690 m 1530 3960 l gs col-1 s gr
- % Polyline
- n 1530 2340 m 1800 2610 l gs col-1 s gr
- % Polyline
- n 1800 2340 m 1530 2610 l gs col-1 s gr
- % Polyline
- n 1530 1260 m 1800 1530 l gs col-1 s gr
- % Polyline
- n 1800 1260 m 1530 1530 l gs col-1 s gr
- % Polyline
- n 1530 720 m 1800 990 l gs col-1 s gr
- % Polyline
- n 1800 720 m 1530 990 l gs col-1 s gr
- % Polyline
- n 2250 945 m 3150 945 l gs col-1 s gr
- % Polyline
- n 2250 1215 m 3150 1215 l gs col-1 s gr
- % Polyline
- n 2250 1485 m 3150 1485 l gs col-1 s gr
- % Polyline
- n 2250 720 m 3150 720 l 3150 1755 l 2250 1755 l cp gs col-1 s gr
- % Polyline
- n 2880 945 m 2880 1485 l gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 2340 1395 m
- gs 1 -1 sc (refname) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 2565 900 m
- gs 1 -1 sc (RTE) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 2340 1125 m
- gs 1 -1 sc (relname) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 2340 1665 m
- gs 1 -1 sc (relid: 18208) col-1 sh gr
- % Polyline
- n 2835 225 m 2835 495 l gs col-1 s gr
- % Polyline
- n 2565 225 m 3105 225 l 3105 495 l 2565 495 l cp gs col-1 s gr
- % Polyline
- n 4860 225 m 4860 495 l gs col-1 s gr
- % Polyline
- n 4590 225 m 5130 225 l 5130 495 l 4590 495 l cp gs col-1 s gr
- % Polyline
- n 4860 225 m 5130 495 l gs col-1 s gr
- % Polyline
- n 5130 225 m 4860 495 l gs col-1 s gr
- % Polyline
- gs clippath
- 2730 573 m 2700 693 l 2670 573 l 2670 735 l 2730 735 l cp clip
- n 2700 360 m 2700 720 l gs col-1 s gr gr
- % arrowhead
- n 2730 573 m 2700 693 l 2670 573 l 2700 573 l 2730 573 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 4443 330 m 4563 360 l 4443 390 l 4605 390 l 4605 330 l cp clip
- n 2970 360 m 4590 360 l gs col-1 s gr gr
- % arrowhead
- n 4443 330 m 4563 360 l 4443 390 l 4443 360 l 4443 330 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 4755 573 m 4725 693 l 4695 573 l 4695 735 l 4755 735 l cp clip
- n 4725 360 m 4725 720 l gs col-1 s gr gr
- % arrowhead
- n 4755 573 m 4725 693 l 4695 573 l 4725 573 l 4755 573 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- n 2250 2745 m 3150 2745 l gs col-1 s gr
- % Polyline
- n 2250 3015 m 3150 3015 l gs col-1 s gr
- % Polyline
- n 2250 2520 m 3150 2520 l 3150 3285 l 2250 3285 l cp gs col-1 s gr
- % Polyline
- n 2880 2745 m 2880 3285 l gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 2565 2700 m
- gs 1 -1 sc (TLE) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 2340 2925 m
- gs 1 -1 sc (resdom) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 2340 3195 m
- gs 1 -1 sc (expr) col-1 sh gr
- % Polyline
- n 4275 2745 m 5175 2745 l gs col-1 s gr
- % Polyline
- n 4275 3015 m 5175 3015 l gs col-1 s gr
- % Polyline
- n 4275 2520 m 5175 2520 l 5175 3285 l 4275 3285 l cp gs col-1 s gr
- % Polyline
- n 4905 2745 m 4905 3285 l gs col-1 s gr
- /Times-Roman ff 150.00 scf sf
- 4590 2700 m
- gs 1 -1 sc (TLE) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 4365 2925 m
- gs 1 -1 sc (resdom) col-1 sh gr
- /Times-Roman ff 150.00 scf sf
- 4365 3195 m
- gs 1 -1 sc (expr) col-1 sh gr
- % Polyline
- n 2835 2025 m 2835 2295 l gs col-1 s gr
- % Polyline
- n 2565 2025 m 3105 2025 l 3105 2295 l 2565 2295 l cp gs col-1 s gr
- % Polyline
- n 4860 2025 m 4860 2295 l gs col-1 s gr
- % Polyline
- n 4590 2025 m 5130 2025 l 5130 2295 l 4590 2295 l cp gs col-1 s gr
- % Polyline
- n 4860 2025 m 5130 2295 l gs col-1 s gr
- % Polyline
- n 5130 2025 m 4860 2295 l gs col-1 s gr
- % Polyline
- n 450 450 m 1800 450 l gs col-1 s gr
- % Polyline
- n 450 720 m 1800 720 l gs col-1 s gr
- % Polyline
- n 450 990 m 1800 990 l gs col-1 s gr
- % Polyline
- n 450 1260 m 1800 1260 l gs col-1 s gr
- % Polyline
- n 450 1530 m 1800 1530 l gs col-1 s gr
- % Polyline
- n 450 1800 m 1800 1800 l gs col-1 s gr
- % Polyline
- n 450 2070 m 1800 2070 l gs col-1 s gr
- % Polyline
- n 450 2340 m 1800 2340 l gs col-1 s gr
- % Polyline
- n 450 2610 m 1800 2610 l gs col-1 s gr
- % Polyline
- n 450 2880 m 1800 2880 l gs col-1 s gr
- % Polyline
- n 450 3150 m 1800 3150 l gs col-1 s gr
- % Polyline
- n 450 3690 m 1800 3690 l gs col-1 s gr
- % Polyline
- n 450 3960 m 1800 3960 l gs col-1 s gr
- % Polyline
- n 450 4230 m 1800 4230 l gs col-1 s gr
- % Polyline
- n 450 3420 m 1800 3420 l gs col-1 s gr
- % Polyline
- n 450 4500 m 1800 4500 l gs col-1 s gr
- % Polyline
- n 450 4770 m 1800 4770 l gs col-1 s gr
- % Polyline
- n 450 5040 m 1800 5040 l gs col-1 s gr
- % Polyline
- n 450 225 m 1800 225 l 1800 5310 l 450 5310 l cp gs col-1 s gr
- % Polyline
- n 1530 4770 m 1530 5310 l gs col-1 s gr
- % Polyline
- n 1530 4230 m 1530 2880 l gs col-1 s gr
- % Polyline
- n 1530 2340 m 1530 2610 l gs col-1 s gr
- % Polyline
- n 1530 720 m 1530 990 l gs col-1 s gr
- % Polyline
- n 1530 1260 m 1530 1530 l gs col-1 s gr
- % Polyline
- n 1530 2610 m 1530 2880 l gs col-1 s gr
- % Polyline
- n 1530 2610 m 1800 2880 l gs col-1 s gr
- % Polyline
- n 1800 2610 m 1530 2880 l gs col-1 s gr
- % Polyline
- gs clippath
- 3228 1050 m 3348 1080 l 3228 1110 l 3390 1110 l 3390 1050 l cp clip
- n 3015 1080 m 3375 1080 l gs col-1 s gr gr
- % arrowhead
- n 3228 1050 m 3348 1080 l 3228 1110 l 3228 1080 l 3228 1050 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 3228 1320 m 3348 1350 l 3228 1380 l 3390 1380 l 3390 1320 l cp clip
- n 3015 1350 m 3375 1350 l gs col-1 s gr gr
- % arrowhead
- n 3228 1320 m 3348 1350 l 3228 1380 l 3228 1350 l 3228 1320 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 5253 1050 m 5373 1080 l 5253 1110 l 5415 1110 l 5415 1050 l cp clip
- n 5040 1080 m 5400 1080 l gs col-1 s gr gr
- % arrowhead
- n 5253 1050 m 5373 1080 l 5253 1110 l 5253 1080 l 5253 1050 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 5253 1320 m 5373 1350 l 5253 1380 l 5415 1380 l 5415 1320 l cp clip
- n 5040 1350 m 5400 1350 l gs col-1 s gr gr
- % arrowhead
- n 5253 1320 m 5373 1350 l 5253 1380 l 5253 1350 l 5253 1320 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- n 4275 945 m 5175 945 l gs col-1 s gr
- % Polyline
- n 4275 1215 m 5175 1215 l gs col-1 s gr
- % Polyline
- n 4275 1485 m 5175 1485 l gs col-1 s gr
- % Polyline
- n 4275 720 m 5175 720 l 5175 1755 l 4275 1755 l cp gs col-1 s gr
- % Polyline
- n 4905 945 m 4905 1485 l gs col-1 s gr
- % Polyline
- gs clippath
- 2730 2373 m 2700 2493 l 2670 2373 l 2670 2535 l 2730 2535 l cp clip
- n 2700 2160 m 2700 2520 l gs col-1 s gr gr
- % arrowhead
- n 2730 2373 m 2700 2493 l 2670 2373 l 2700 2373 l 2730 2373 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 4443 2130 m 4563 2160 l 4443 2190 l 4605 2190 l 4605 2130 l cp clip
- n 2970 2160 m 4590 2160 l gs col-1 s gr gr
- % arrowhead
- n 4443 2130 m 4563 2160 l 4443 2190 l 4443 2160 l 4443 2130 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 4755 2373 m 4725 2493 l 4695 2373 l 4695 2535 l 4755 2535 l cp clip
- n 4725 2160 m 4725 2520 l gs col-1 s gr gr
- % arrowhead
- n 4755 2373 m 4725 2493 l 4695 2373 l 4725 2373 l 4755 2373 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 3228 4200 m 3348 4230 l 3228 4260 l 3390 4260 l 3390 4200 l cp clip
- n 3015 4230 m 3375 4230 l gs col-1 s gr gr
- % arrowhead
- n 3228 4200 m 3348 4230 l 3228 4260 l 3228 4230 l 3228 4200 l cp gs 0.00 setgray ef gr col-1 s
- % Polyline
- gs clippath
- 5253 4200 m 5373 4230 l 5253 4260 l 5415 4260 l 5415 4200 l cp clip
- n 5040 4230 m 5400 4230 l gs col-1 s gr gr