RE: Can I test Extended Query in core test framework

2020-08-11 Thread tsunakawa.ta...@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



Re: Can I test Extended Query in core test framework

2020-08-11 Thread Andy Fan
On Tue, Aug 11, 2020 at 11:22 PM Tom Lane  wrote:

> Andy Fan  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:(

[1]
https://www.postgresql.org/message-id/CAKU4AWqvwmo=nlpga_ohxb4f+u4ts1_3yry9m6xtjlt9dkh...@mail.gmail.com


-- 
Best Regards
Andy Fan


Re: Can I test Extended Query in core test framework

2020-08-11 Thread Andy Fan
Thank you Ashutosh for your reply.

On Tue, Aug 11, 2020 at 9:06 PM Ashutosh Bapat 
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.

[1]
https://www.postgresql.org/message-id/CAKU4AWqvwmo=nlpga_ohxb4f+u4ts1_3yry9m6xtjlt9dkh...@mail.gmail.com


-- 
Best Regards
Andy Fan


Re: Can I test Extended Query in core test framework

2020-08-11 Thread 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

2020-08-11 Thread Tom Lane
Andy Fan  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

2020-08-11 Thread 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  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




Can I test Extended Query in core test framework

2020-08-10 Thread 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