/* concatenate prefix and column name */
varname = psprintf("%s%s", pset.gset_prefix, colname);
+ if (VariableHasHook(pset.vars, varname))
+ {
+ psql_error("attempt to \\gset into specially treated variable \"%s\" ignored\n",
+ varname);
+ continue;
+ }
+
if (!PQgetisnull(result, 0, i))
value = PQgetvalue(result, 0, i);
else
return true;
}
+/*
+ * Return true iff the named variable has an assign hook function.
+ */
+bool
+VariableHasHook(VariableSpace space, const char *name)
+{
+ struct _variable *current;
+
+ Assert(space);
+ Assert(name);
+
+ for (current = space->next; current; current = current->next)
+ if (strcmp(current->name, name) == 0)
+ return current->assign_hook != NULL;
+
+ return false;
+}
+
bool
SetVariableBool(VariableSpace space, const char *name)
{
bool SetVariable(VariableSpace space, const char *name, const char *value);
bool SetVariableAssignHook(VariableSpace space, const char *name, VariableAssignHook hook);
+bool VariableHasHook(VariableSpace space, const char *name);
bool SetVariableBool(VariableSpace space, const char *name);
bool DeleteVariable(VariableSpace space, const char *name);
select 10 as "bad name"
\gset
could not set variable "bad name"
+select 'terse' as "OSITY", 'ok' as _foo \gset VERB
+attempt to \gset into specially treated variable "VERBOSITY" ignored
+\echo :VERB_foo :VERBOSITY
+ok default
-- multiple backslash commands in one line
select 1 as x, 2 as y \gset pref01_ \\ \echo :pref01_x
1
select 10 as "bad name"
\gset
+select 'terse' as "OSITY", 'ok' as _foo \gset VERB
+\echo :VERB_foo :VERBOSITY
+
-- multiple backslash commands in one line
select 1 as x, 2 as y \gset pref01_ \\ \echo :pref01_x
select 3 as x, 4 as y \gset pref01_ \echo :pref01_x \echo :pref01_y