Posts by Topic: code

Disambiguating variables, or a “this” keyword, for plpgsql

Derry Hamilton - 07/11/2019

Some names, like account_number, or customer_id crop up in a lot of places, and when you’re juggling tables inside a plpgsql function, it can be a bit of a pain. Postgres allows you to disambiguate names by qualifying them with the function name, or the block name. CREATE FUNCTION app.a_long_function_name(id integer) RETURNS...

Why does Postgres call Rows Tuples?

Derry Hamilton - 21/11/2018

Postgres isn’t alone in referring to rows as tuples; it’s a term from mathematics, specifically it’s used in relational algebra which technically underpins the relational model. But there are other reasons… Postgres was (re)built from the ground up as an Object-Relational Database. So while the most common place people...

Changing Postgres Foreign Data Wrappers

Derry Hamilton - 28/09/2017

Migrating from a commercial server to Postgres meant that we needed to change the underlying connection type for the Foreign Data Wrappers. At this time, there’s no ALTER SERVER command that will do the job, but it’s possible to update the system tables instead. UPDATE pg_foreign_server SET srvfdw = (select oid...