dbTalk Databases Forums  

[BUGS] BUG #2629: libpq - Cannot deallocate prepared statement created with PQprepare()

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] BUG #2629: libpq - Cannot deallocate prepared statement created with PQprepare() in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Andy McCurdy
 
Posts: n/a

Default [BUGS] BUG #2629: libpq - Cannot deallocate prepared statement created with PQprepare() - 09-16-2006 , 07:41 AM







The following bug has been logged online:

Bug reference: 2629
Logged by: Andy McCurdy
Email address: andy.mccurdy (AT) emergent (DOT) net
PostgreSQL version: 8.1.4
Operating system: Windows XP
Description: libpq - Cannot deallocate prepared statement created
with PQprepare()
Details:

According to http://www.postgresql.org/docs/8.1/i...ibpq-exec.html,
the last statement in the PQprepare() function description suggests that a
user can run the statement: "DEALLOCATE [statement name]" with PQexec() to
deallocate a statement prepared with PQprepare(). When trying to do this, I
consistently get the error message:

ERROR: prepared statement "[statement name]" does not exist

Here's a snippet of code that illustrates what I am attempting to do:

int main()
{

PGconn* conn;
PGresult* result;

conn = PQsetdbLogin("localhost", "5432", NULL, NULL, "postgres", "postgres",
"postgres");

result = PQprepare(conn, "MyQuery", "select * from pg_stat_activity", 0,
NULL);

/*
THE FOLLOW PQEXEC() FAILS. Error message says: ERROR: prepared statement
"myquery" does not exist"
*/
result = PQexec(conn, "DEALLOCATE MyQuery");


result = PQexec(conn, "PREPARE MyQuery AS select * from pg_stat_activity");

/*
THIS WORKS
*/
result = PQexec(conn, "DEALLOCATE MyQuery");



return 0;
}

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply With Quote
  #2  
Old   
Michael Fuhr
 
Posts: n/a

Default Re: [BUGS] BUG #2629: libpq - Cannot deallocate prepared statement created with PQprepare() - 09-16-2006 , 08:19 AM






On Fri, Sep 15, 2006 at 07:39:32AM +0000, Andy McCurdy wrote:
Quote:
result = PQprepare(conn, "MyQuery", "select * from pg_stat_activity", 0,
NULL);

/*
THE FOLLOW PQEXEC() FAILS. Error message says: ERROR: prepared statement
"myquery" does not exist"
*/
result = PQexec(conn, "DEALLOCATE MyQuery");
You prepared a mixed-case identifier so you'll need to quote it in
SQL statements to preserve its case. Unquoted identifiers are
folded to lowercase, as the error message shows.

result = PQexec(conn, "DEALLOCATE \"MyQuery\"");

See "Identifiers and Key Words" in the "SQL Syntax" chapter of the
documentation for more information about quoted identifiers.

http://www.postgresql.org/docs/8.1/i...AX-IDENTIFIERS

--
Michael Fuhr

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings


Reply With Quote
  #3  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] BUG #2629: libpq - Cannot deallocate prepared statement created with PQprepare() - 09-16-2006 , 08:33 AM



"Andy McCurdy" <andy.mccurdy (AT) emergent (DOT) net> writes:
Quote:
result = PQprepare(conn, "MyQuery", "select * from pg_stat_activity", 0,
NULL);
I believe the above will result in preparing a statement named "MyQuery",
ie, no case-folding happens on the second argument of PQprepare, because
it never goes through the SQL parser.

Quote:
/*
THE FOLLOW PQEXEC() FAILS. Error message says: ERROR: prepared statement
"myquery" does not exist"
*/
result = PQexec(conn, "DEALLOCATE MyQuery");
I think this would work:

result = PQexec(conn, "DEALLOCATE \"MyQuery\"");

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.