Issue while calling new PostgreSQL command from a Java Application

From: Ashoke <s(dot)ashoke(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Issue while calling new PostgreSQL command from a Java Application
Date: 2014-07-04 05:13:12
Message-ID: CALpszJPXFBb+0w-thEk=6vNP-ZRgqn1i+PX8xonp=cZ_DqNJRA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

------------------------------

I have defined a new command my_command in PostgreSQL. This command takes
the path of ANALYZE and inside analyze.c, I have a function to do some
operations if its my_command.This command takes the input arguments: table
name, column name and an input string.

my_command nation (n_nationkey) 'input string';

When I run this command from command line psql, it works as expected. But
when I call the same command from a java application, the variable that
stores the input string is NULL.

I printed the value of the input string in gram.y file where I have defined
my_command.
fprintf (stderr, "I am inside gram.y %s\n",n->inp_str); and the input
string is printed correctly.

But when I print stmt->inp_str in the function standard_ProcessUtility() of
utility.c for the case T_VacuumStmt, I get the value as NULL. This is as
far as I could trace back from analyze.c.

I am not sure how executing the same command from an application can make a
difference.

gram.y content gist:
------------------------------

MyStmt:
my_keyword qualified_name name_list my_inp_str
{
VacuumStmt *n = makeNode(VacuumStmt);
n->options = VACOPT_ANALYZE;
n->freeze_min_age = -1;
n->freeze_table_age = -1;
n->relation = $2;
n->va_cols = $3;
n->inp_str = $4;
fprintf (stderr, "I am inside gram.y %s\n",n->inp_str);

$$ = (Node *)n;
};

char *inp_str is added to the struct VacuumStmt in parsenodes.h

---------------------------

Only the newly added char *inp_str(that is different from ANALYZE) value is
NULL. I was able to retrieve the column name from va_cols.

Any help is appreciated. Thanks!
--
Regards,
Ashoke

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip kumar 2014-07-04 05:15:06 Re: TODO : Allow parallel cores to be used by vacuumdb [ WIP ]
Previous Message Rushabh Lathia 2014-07-04 04:36:06 Re: "RETURNING PRIMARY KEY" syntax extension