Because ruleutils.c's get_shard_query_def does not have external linkage, pg_shard copy-pastes ruleutils.c from the appropriate PostgreSQL release—with minimal modifications—to enable deparsing a given query back into one with shard identifiers.
These modifications are not likely to be accepted upstream as-is—they reference a shardId field we've added to deparse_context—but PostgreSQL may be open to exposing get_shard_query_def itself for external use. We'd need to:
Devise a method that permits us to use get_shard_query_def without further modifications
Produce a patch for PostgreSQL to expose get_shard_query_def
Because
ruleutils.c
'sget_shard_query_def
does not have external linkage,pg_shard
copy-pastesruleutils.c
from the appropriate PostgreSQL release—with minimal modifications—to enable deparsing a given query back into one with shard identifiers.These modifications are not likely to be accepted upstream as-is—they reference a
shardId
field we've added todeparse_context
—but PostgreSQL may be open to exposingget_shard_query_def
itself for external use. We'd need to:get_shard_query_def
without further modificationsget_shard_query_def