The following is the API for the Greenplum Database custom data access protocol. The example protocol implementation gpextprotocal.c is written in C and shows how the API can be used. For information about accessing a custom data access protocol, see Using a Custom Protocol.

  1. /* ---- Read/Write function API ------*/
  2. CALLED_AS_EXTPROTOCOL(fcinfo)
  3. EXTPROTOCOL_GET_URL(fcinfo)(fcinfo)
  4. EXTPROTOCOL_GET_DATABUF(fcinfo)
  5. EXTPROTOCOL_GET_DATALEN(fcinfo)
  6. EXTPROTOCOL_GET_SCANQUALS(fcinfo)
  7. EXTPROTOCOL_GET_USER_CTX(fcinfo)
  8. EXTPROTOCOL_IS_LAST_CALL(fcinfo)
  9. EXTPROTOCOL_SET_LAST_CALL(fcinfo)
  10. EXTPROTOCOL_SET_USER_CTX(fcinfo, p)
  11. /* ------ Validator function API ------*/
  12. CALLED_AS_EXTPROTOCOL_VALIDATOR(fcinfo)
  13. EXTPROTOCOL_VALIDATOR_GET_URL_LIST(fcinfo)
  14. EXTPROTOCOL_VALIDATOR_GET_NUM_URLS(fcinfo)
  15. EXTPROTOCOL_VALIDATOR_GET_NTH_URL(fcinfo, n)
  16. EXTPROTOCOL_VALIDATOR_GET_DIRECTION(fcinfo)

Notes

The protocol corresponds to the example described in Using a Custom Protocol. The source code file name and shared object are gpextprotocol.c and gpextprotocol.so.

The protocol has the following properties:

  • The name defined for the protocol is myprot.

  • The protocol has the following simple form: the protocol name and a path, separated by ://.

    myprot:// path

  • Three functions are implemented:

    • myprot_import() a read function
    • myprot_export() a write function
    • myprot_validate_urls() a validation function These functions are referenced in the CREATE PROTOCOL statement when the protocol is created and declared in the database.

The example implementation gpextprotocal.c uses fopen() and fread() to simulate a simple protocol that reads local files. In practice, however, the protocol would implement functionality such as a remote connection to some process over the network.

Parent topic: Loading and Unloading Data