diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index 179c162..04277ae 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -928,7 +928,10 @@ SendQuery(const char *query) if (pset.timing) INSTR_TIME_SET_CURRENT(before); - results = PQexec(pset.db, query); + if (pset.use_extended_protocol) + results = PQexecParams(pset.db, query, 0, NULL, NULL, NULL, NULL, 0); + else + results = PQexec(pset.db, query); /* these operations are included in the timing result: */ ResetCancelConn(); diff --git a/src/bin/psql/settings.h b/src/bin/psql/settings.h index c907fa0..c811734 100644 --- a/src/bin/psql/settings.h +++ b/src/bin/psql/settings.h @@ -111,6 +111,7 @@ typedef struct _psqlSettings const char *prompt1; const char *prompt2; const char *prompt3; + bool use_extended_protocol; PGVerbosity verbosity; /* current error verbosity level */ } PsqlSettings; diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c index 1fcc47f..bd9384a 100644 --- a/src/bin/psql/startup.c +++ b/src/bin/psql/startup.c @@ -143,6 +143,7 @@ main(int argc, char *argv[]) /* Default values for variables */ SetVariableBool(pset.vars, "AUTOCOMMIT"); + SetVariable(pset.vars, "PROTOCOL", "simple"); SetVariable(pset.vars, "VERBOSITY", "default"); SetVariable(pset.vars, "PROMPT1", DEFAULT_PROMPT1); SetVariable(pset.vars, "PROMPT2", DEFAULT_PROMPT2); @@ -790,6 +791,19 @@ prompt3_hook(const char *newval) } static void +protocol_hook(const char *newval) +{ + if (newval == NULL) + pset.use_extended_protocol = false; + else if (strcmp(newval, "simple") == 0) + pset.use_extended_protocol = false; + else if (strcmp(newval, "extended") == 0) + pset.use_extended_protocol = true; + else + pset.use_extended_protocol = false; +} + +static void verbosity_hook(const char *newval) { if (newval == NULL) @@ -826,5 +840,6 @@ EstablishVariableSpace(void) SetVariableAssignHook(pset.vars, "PROMPT1", prompt1_hook); SetVariableAssignHook(pset.vars, "PROMPT2", prompt2_hook); SetVariableAssignHook(pset.vars, "PROMPT3", prompt3_hook); + SetVariableAssignHook(pset.vars, "PROTOCOL", protocol_hook); SetVariableAssignHook(pset.vars, "VERBOSITY", verbosity_hook); }