The names are going to be foo
and bar
. If they were aliases in the query, then the aliases would be returned, the original names being lost.
Column names in results never include table names.
If they were named tablename.colname
, it would be ambiguous anyway because SELECT 1 as "foo.colname"
is valid and produces a column foo.colname
despite the fact there is no foo
table.
The way to identify the table from which a column originates, when it applies, is to call pqxx::result::column_table(column_number)
which returns the oid
of the table. The table's name is not available directly but could be queried in pg_class
with the oid
.
Also note that column names don't have to be unique within a resultset. SELECT 1 AS a, 2 AS a
is valid and produces two columns with exactly the same name.