FDW question - how to identify columns to populate in response?

From: Bear Giles <bgiles(at)coyotesong(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: FDW question - how to identify columns to populate in response?
Date: 2015-08-14 18:18:04
Message-ID: CALBNtw4DJE9oka-pSy148wHc1Y-yz+=n7qsPGWkhO2Jyj4K09A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi, I'm working on a FDW for the unix/linux user database - think
/etc/passwd and /etc/group although I'm actually using system calls that
could be quietly redirected to LDAP or other backends. It's easy to create
the FDW and a table associated with it, something like

CREATE TABLE passwd (
name text,
passwd text,
uid int,
...

The problem is the user could decide to reorder or remove columns so I
can't make the assumption that values[0] is always going to be the username.

I have a solution that requires looking at the rel, extracting the atts,
and then doing a loop where I check the attname against all possible values
for each column. Anything that doesn't match is set to null. This isn't too
bad here but it would be a pain if there are many columns.

Is there a cleaner way? I've looked at a number of other FDW
implementations but they are generally mapping columns to columns (so it's
a short bit of lookup code inside the loop), not copying data provided by a
system call.

Thanks,

Bear

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2015-08-14 18:27:49 Re: Management of simple_eval_estate for plpgsql DO blocks
Previous Message Andres Freund 2015-08-14 18:16:47 Re: How to compile, link and use a C++ extension