Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Enable DROP TABLE statement for Presto #43

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

tomz
Copy link

@tomz tomz commented Nov 10, 2015

No description provided.

@@ -1825,7 +1831,7 @@ PRESTOGRES_DEST prestogres_send_to_where(Node *node)
* CREATE TABLE
* CREATE TABLE ... AS SELECT
*/
if (IsA(node, SelectStmt) || IsA(node, InsertStmt) || IsA(node, CreateStmt) || IsA(node, CreateTableAsStmt))
if (IsA(node, SelectStmt) || IsA(node, InsertStmt) || IsA(node, CreateStmt) || IsA(node, CreateTableAsStmt) || IsA(node, DropStmt))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomz Nice 👍
Setting NULL directly prestogres_system_catalog_relcache seems leaking memory. And I found prestogres_discard_system_catalog function which is called at https://github.com/tomz/prestogres/blob/master/src/protocol/pool_proto_modules.c#L1638-L1645
So probably the best place to discard system catalog is right after the if block as following:

 if (IsA(node, CreateStmt))
 {
     CreateStmt *create_table_stmt = (CreateStmt *)node;
     if (create_table_stmt->relation->relpersistence)
         discard_temp_table_relcache();
     /* prestogres: discard system catalog to recreate them next time at prestogres_init_system_catalog */
     prestogres_discard_system_catalog();
 }
+ else if (IsA(node, DropStmt))
+ {
+     /* prestogres: discard system catalog to recreate them next time at prestogres_init_system_catalog */
+     prestogres_discard_system_catalog();
+ }

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks, will do that instead.

tomz and others added 13 commits November 13, 2015 21:03
Presto queries may result in outputs that contain multiple
\0 or NULL characters.  As a result, a single error
message or notice may contain multiple \0 delimited
strings which would get read at once on invocation to
per_node_error_log(), which then attempts to 'unread'
the contents it just read.  However, the pool_unread invocation
ends up unreading up to the first \0 character, and it
does not unread the full message, causing subsequent
calls to getting the postgres message kind to fail
as the kind ends up being a \0 character.
This change allows JDBCv2 clients to work by allowing SET TRANSACTION
statements such as SET SESSION CHARACTERISTIC as well as
multistatement queries containing SET to route to psql rather than
Presto.
Merge in SET passthrough to presto, remove code that improperly calls pool_unread
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants