C++ -> C : Module for converting the WHERE clause to the canonical form with PostgreSQL

22 views
Skip to first unread message

St Valentine

unread,
Jan 13, 2006, 5:52:57 AM1/13/06
to
Help me, please,
i have a module, which converts the WHERE clause to a canonical form, i.e. converting a logical clause to a conjuntional or dicjuntional clauses. For example:

(ves > 100 or bbbb = 10) AND (bbbb = aaa + 1 OR (aaaa AND caa))

will be converted to dicjuntional form:

ves>100 AND bbbb=10 AND bbbb=aaa+1 OR вес>100 AND bbbb=10 AND aaaa OR ves>100
AND bbbb=10 AND caa

That module is writen in the C++ langguage, how can i connect it to the PostgreSQL sources? In our project we must to compare queries. Beacause of the same query can be writen in different forms, so to compare queries we must to convert them to the same form of presentation.

--
stvalentine


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Tom Lane

unread,
Jan 13, 2006, 10:24:30 AM1/13/06
to
"St Valentine" <valen...@ukr.net> writes:
> That module is writen in the C++ langguage, how can i connect it to
> the PostgreSQL sources?

Convert it to C ;-) Seriously, I think this would be a major pain in
the neck to do --- there are various gotchas like the system headers not
being C++-clean. Why don't you just resurrect the qual canonicalization
logic that existed in src/backend/optimizer/prep/prepqual.c not too long
ago?

> In our project we must to compare
> queries. Beacause of the same query can be writen in different forms,
> so to compare queries we must to convert them to the same form of
> presentation.

I find this argument fairly dubious, though, as there are plenty of ways
to write the same query differently. Forcing the condition into CNF or
DNF will fix only some of them.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majo...@postgresql.org so that your
message can get through to the mailing list cleanly

Reply all
Reply to author
Forward
0 new messages