Обсуждение: Can I test Extended Query in core test framework

Поиск
Список
Период
Сортировка

Can I test Extended Query in core test framework

От
Andy Fan
Дата:
I want to write some test cases with extended query in core test system. basically it looks like 

PreparedStatement preparedStatement  = conn.prepareStatement("select * from bigtable");
preparedStatement.setFetchSize(4);
ResultSet rs = preparedStatement.executeQuery();
while(rs.next())
{
System.out.println(rs.getInt(1));
// conn.commit();
conn.rollback();
}

However I don't find a way to do that after checking the example in src/test/xxx/t/xxx.pl 
where most often used object is PostgresNode, which don't have such abilities. 

Can I do that in core system, I tried grep '\->prepare'  and  '\->execute' and get nothing.
am I miss something? 


--
Best Regards
Andy Fan

Re: Can I test Extended Query in core test framework

От
Ashutosh Bapat
Дата:
You could run PREPARE and EXECUTE as SQL commands from psql. Please
take a look at the documentation of those two commands. I haven't
looked at TAP infrastructure, but you could open a psql session to a
running server and send an arbitrary number of SQL queries through it.

Said that a server starts caching plan only after it sees a certain
number of EXECUTEs. So if you are testing cached plans, that's
something to worry about.

On Tue, Aug 11, 2020 at 8:13 AM Andy Fan <zhihui.fan1213@gmail.com> wrote:
>
> I want to write some test cases with extended query in core test system. basically it looks like
>
> PreparedStatement preparedStatement  = conn.prepareStatement("select * from bigtable");
> preparedStatement.setFetchSize(4);
> ResultSet rs = preparedStatement.executeQuery();
> while(rs.next())
> {
>     System.out.println(rs.getInt(1));
>     // conn.commit();
>     conn.rollback();
> }
>
>
> However I don't find a way to do that after checking the example in src/test/xxx/t/xxx.pl
> where most often used object is PostgresNode, which don't have such abilities.
>
> Can I do that in core system, I tried grep '\->prepare'  and  '\->execute' and get nothing.
> am I miss something?
>
>
> --
> Best Regards
> Andy Fan



-- 
Best Wishes,
Ashutosh Bapat



Re: Can I test Extended Query in core test framework

От
Tom Lane
Дата:
Andy Fan <zhihui.fan1213@gmail.com> writes:
> I want to write some test cases with extended query in core test system.

Why?  (That is, what is it you need to test exactly?)

psql has no ability to issue extended queries AFAIR, so the normal
regression test scripts can't exercise this.  We haven't built anything
for it in the TAP infrastructure either.  We do have test coverage
via pgbench and ecpg, though I concede that's pretty indirect.

I recall someone (Andres, possibly) speculating about building a tool
specifically to exercise low-level protocol issues, but that hasn't
been done either.

None of these are necessarily germane to any particular test requirement,
which is why I'm wondering.  The JDBC fragment you show seems like it's
something that should be tested by, well, JDBC.  What's interesting about
it for any other client?

            regards, tom lane



Re: Can I test Extended Query in core test framework

От
Andres Freund
Дата:
Hi,

On 2020-08-11 11:22:49 -0400, Tom Lane wrote:
> I recall someone (Andres, possibly) speculating about building a tool
> specifically to exercise low-level protocol issues, but that hasn't
> been done either.

Yea, I mentioned the possibility, but didn't plan to work on it. I am
not a perl person by any stretch (even though that's where I
started...).  But we can (and do iirc) have tests that just use libpq,
so it should be possible to test things like this at a bit higher cost.

Greetings,

Andres Freund



Re: Can I test Extended Query in core test framework

От
Andy Fan
Дата:
Thank you Ashutosh for your reply. 

On Tue, Aug 11, 2020 at 9:06 PM Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> wrote:
You could run PREPARE and EXECUTE as SQL commands from psql. Please
take a look at the documentation of those two commands. I haven't
looked at TAP infrastructure, but you could open a psql session to a
running server and send an arbitrary number of SQL queries through it.


PREPARE & EXECUTE doesn't go with the extended query way.  it is 
still exec_simple_query.    What I did is I hacked some exec_bind_message
[1]  logic, that's why I want to test extended queries. 
 

--
Best Regards
Andy Fan

Re: Can I test Extended Query in core test framework

От
Andy Fan
Дата:


On Tue, Aug 11, 2020 at 11:22 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Andy Fan <zhihui.fan1213@gmail.com> writes:
> I want to write some test cases with extended query in core test system.

Why?  (That is, what is it you need to test exactly?)

 
Thanks for your attention.  The background is I hacked exec_bind_message[1],
then I want to add some test cases  to make sure the logic can be tested automatically
in the core system.  I can't distinguish if the logic might be so straight or not so it
doesn't deserve the test in practice. 

psql has no ability to issue extended queries AFAIR, so the normal
regression test scripts can't exercise this.  We haven't built anything
for it in the TAP infrastructure either.  We do have test coverage
via pgbench and ecpg, though I concede that's pretty indirect.

I recall someone (Andres, possibly) speculating about building a tool
specifically to exercise low-level protocol issues, but that hasn't
been done either.

Thanks for this information.  and Thanks Andres for the idea and practice.
 

None of these are necessarily germane to any particular test requirement,
which is why I'm wondering.  The JDBC fragment you show seems like it's
something that should be tested by, well, JDBC.  What's interesting about
it for any other client?


The main purpose is I want to test it in core without other infrastructure involved.
I have added a python script to do that now.   So the issue is not so blocking.
but what I am working on[1] is still challenging for me:(


--
Best Regards
Andy Fan

RE: Can I test Extended Query in core test framework

От
"tsunakawa.takay@fujitsu.com"
Дата:

Tatsuo Ishii san, a committer, proposed this to test extended query protocol.  Can it be included in Postgres core?

 

A toool to test programs by issuing frontend/backend protocol messages

https://github.com/tatsuo-ishii/pgproto

 

 

Regards

Takayuki Tsunakawa