With this commit, PsqlForks ( http://psqlforks.com ) can now fetch credentials from AWS IAM. Read more about Redshift's support for generating database credentials using IAM authentication feature, here.
Since the entire AWS CLI isn't baked into PsqlForks (yet!), you'd need a working copy of AWS CLI installed / working on the host (from where psql is called).
This took a while, since I missed the basic assumption that Redshift enforces SSL and psql doesn't attempt SSLMODE by default in the first try. The fact that CYGWIN wasn't super-smooth with AWS CLI in my test installation, didn't help either.
But as they say, all's well that ends well. There are few obvious additions that are possible (such as expiration validation / re-use unexpired credentials on re-connect etc.) but this should get merged in the forks mainline soon.
I guess it's time to begin thinking of releases, instead of making the mainline jittery with feature additions such as this one.
Yenjoy!
$ psql "sslmode=require host=redshift_cluster port=5439 dbname=redshift2" -U testing1
Password for user testing1:
psql: fe_sendauth: no password supplied
$ psql -I "sslmode=require host=redshift_cluster port=5439 dbname=redshift2" -U testing1
CLI: aws redshift get-cluster-credentials --auto-create --db-user testing1 --cluster-identifier redshift2 # Informational / testing output
psql (client-version:11devel, server-version:8.0.2, engine:redshift)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: on)
Type "help" for help.
redshift2=> select current_user;
current_user
--------------
testing1
(1 row)
redshift2=> \du
List of roles
Role name | Attributes | Member of
-----------+-------------------------------+-----------
redshift2 | Superuser, Create DB +|
| Password valid until infinity |
testing1 | |
redshift2=> \q
$ ./psql --help | grep -i iam
-I, --aws-iam-redshift use temporary database credentials from AWS IAM Service
13 Oct 2017
12 Oct 2017
PsqlForks now recognizes RDS PostgreSQL separately
With this commit, PsqlForks ( http://psqlforks.com ) now recognizes RDS PostgreSQL separately.
This isn't utilized much yet, but the infrastructure is going to be helpful in skipping / avoiding some commands that are defunct / not possible in the RDS PostgreSQL offering.
This isn't utilized much yet, but the infrastructure is going to be helpful in skipping / avoiding some commands that are defunct / not possible in the RDS PostgreSQL offering.
29 Sept 2017
PsqlForks now recognizes PgBouncer
With this commit, PsqlForks knows when it's talking to PgBouncer (and not Postgres).
Down the line, this should pave way for PsqlForks to more cleanly convey why (most of) the given psql shortcut(s) don't work (and what else does).
As always, the psql/README always has the most updated status of any engine support.
$ psql -h localhost -E -p6543 -U postgres pgbouncer
psql (client-version:11devel, server-version:1.7.1/bouncer, engine:pgbouncer)
Type "help" for help.
pgbouncer=# show version;
NOTICE: pgbouncer version 1.7.1
SHOW
pgbouncer=#
Down the line, this should pave way for PsqlForks to more cleanly convey why (most of) the given psql shortcut(s) don't work (and what else does).
As always, the psql/README always has the most updated status of any engine support.
$ psql -h localhost -E -p6543 -U postgres pgbouncer
psql (client-version:11devel, server-version:1.7.1/bouncer, engine:pgbouncer)
Type "help" for help.
pgbouncer=# show version;
NOTICE: pgbouncer version 1.7.1
SHOW
pgbouncer=#
25 Sept 2017
PsqlForks now supports CockroachDB
PsqlForks now supports CockroachDB as much as is currently possible. You can check it's current SQL status here.
$ /opt/postgres/master/bin/psql -h localhost -E -p 26257 -U root
psql (client-version:11devel, server-version:9.5.0, engine:cockroachdb)
Type "help" for help.
root=> select version();
version()
--------------------------------------------------------------------------
CockroachDB CCL v1.0.6 (linux amd64, built 2017/09/14 15:15:48, go1.8.3)
(1 row)
bank=> \l
$ /opt/postgres/master/bin/psql -h localhost -E -p 26257 -U root
psql (client-version:11devel, server-version:9.5.0, engine:cockroachdb)
Type "help" for help.
root=> select version();
version()
--------------------------------------------------------------------------
CockroachDB CCL v1.0.6 (linux amd64, built 2017/09/14 15:15:48, go1.8.3)
(1 row)
bank=> \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
--------------------+-------+-------------------+------------+------------+-------------------
bank | | Not Supported Yet | en_US.utf8 | en_US.utf8 | Not Supported Yet
crdb_internal | | Not Supported Yet | en_US.utf8 | en_US.utf8 | Not Supported Yet
information_schema | | Not Supported Yet | en_US.utf8 | en_US.utf8 | Not Supported Yet
pg_catalog | | Not Supported Yet | en_US.utf8 | en_US.utf8 | Not Supported Yet
system | | Not Supported Yet | en_US.utf8 | en_US.utf8 | Not Supported Yet
(5 rows)
bank=> \dv
List of relations
Schema | Name | Type | Owner
--------+------+------+-------
bank | a | view |
(1 row)
bank=> \di
List of relations
Schema | Name | Type | Owner | Table
--------+-------------------------+-------+-------+------------
bank | primary | index | | accounts
system | jobs_status_created_idx | index | | jobs
system | primary | index | | descriptor
system | primary | index | | eventlog
system | primary | index | | jobs
system | primary | index | | lease
system | primary | index | | namespace
system | primary | index | | rangelog
system | primary | index | | settings
system | primary | index | | ui
system | primary | index | | users
system | primary | index | | zones
(12 rows)
15 Sept 2017
PsqlForks now supports PipelineDB
After working on this PSQL variant that intends to support all Postgres forks, I finally narrowed down to naming it.
Since this was essentially Psql (for) Forks, quite intuitively, I chose to name it PsqlForks.
Considering that until recently this fork just supported Amazon Redshift, this naming didn't make much sense if it wasn't supporting at least 2 forks :) !
Thus, PsqlForks now supports PipelineDB!
$ /opt/postgres/master/bin/psql -U pipeline -p 5434 -h localhost pipeline
psql (client-version:11devel, server-version:9.5.3, engine:pipelinedb)
Type "help" for help.
pipeline=# \q
Since this was essentially Psql (for) Forks, quite intuitively, I chose to name it PsqlForks.
Considering that until recently this fork just supported Amazon Redshift, this naming didn't make much sense if it wasn't supporting at least 2 forks :) !
Thus, PsqlForks now supports PipelineDB!
$ /opt/postgres/master/bin/psql -U pipeline -p 5434 -h localhost pipeline
psql (client-version:11devel, server-version:9.5.3, engine:pipelinedb)
Type "help" for help.
pipeline=# \q
2 Sept 2017
psql \d now supports Interleaved / Compound SORTKEYs (in Redshift)
In continuation of support for Redshift series, now Describe Table (for e.g. \d tbl) shows SORTKEY details. This resolves Issue #6 and shows both COMPOUND / INTERLEAVED variations along with all the column names.
This change was complicated because Redshift doesn't natively support LISTAGG() function on System / Catalog tables, which meant that I had to resort to a pretty verbose workaround. This in-turn meant that this patch shows only the first ten COMPOUND SORTKEYs of a table. Seriously speaking, it would really take an extreme corner-case, for someone to genuinely require a SORTKEY with 10+ columns.
This is not a limitation for INTERLEAVED SORTKEY since it only supports a maximum of 8 Columns.
db=# CREATE TABLE tbl_pk(custkey SMALLINT PRIMARY KEY);
CREATE TABLE
db=# \d tbl_pk
Table "public.tbl_pk"
Column | Type | Encoding | DistKey | SortKey | Preload | Encryption | Collation | Nullable | Default
---------+----------+----------+---------+---------+---------+------------+-----------+----------+---------
custkey | smallint | lzo | f | 0 | f | none | | not null |
Indexes:
PRIMARY KEY, btree (custkey)
db=# CREATE TABLE tbl_compound(
db(# custkey SMALLINT ENCODE delta NOT NULL,
db(# custname INTEGER DEFAULT 10 ENCODE raw NULL,
db(# gender BOOLEAN ENCODE RAW,
db(# address CHAR(5) ENCODE LZO,
db(# city BIGINT identity(0, 1) ENCODE DELTA,
db(# state DOUBLE PRECISION ENCODE Runlength,
db(# zipcode REAL,
db(# tempdel1 DECIMAL ENCODE Mostly16,
db(# tempdel2 BIGINT ENCODE Mostly32,
db(# tempdel3 DATE ENCODE DELTA32k,
db(# tempdel4 TIMESTAMP ENCODE Runlength,
db(# tempdel5 TIMESTAMPTZ ENCODE DELTA,
db(# tempdel6 VARCHAR(MAX) ENCODE text32k,
db(# start_date VARCHAR(10) ENCODE TEXT255
db(# )
db-# DISTSTYLE KEY
db-# DISTKEY (custname)
db-# COMPOUND SORTKEY (custkey, custname, gender, address, city, state, zipcode, tempdel1, tempdel2, tempdel3, tempdel4, tempdel5, start_date);
CREATE TABLE
db=#
db=# \d tbl_compound
Table "public.tbl_compound"
Column | Type | Encoding | DistKey | SortKey | Preload | Encryption | Collation | Nullable | Default
------------+-----------------------------+-----------+---------+---------+---------+------------+-----------+----------+------------------------------------
custkey | smallint | delta | f | 1 | f | none | | not null |
custname | integer | none | t | 2 | f | none | | | 10
gender | boolean | none | f | 3 | f | none | | |
address | character(5) | lzo | f | 4 | f | none | | |
city | bigint | delta | f | 5 | f | none | | | "identity"(494055, 4, '0,1'::text)
state | double precision | runlength | f | 6 | f | none | | |
zipcode | real | none | f | 7 | f | none | | |
tempdel1 | numeric(18,0) | mostly16 | f | 8 | f | none | | |
tempdel2 | bigint | mostly32 | f | 9 | f | none | | |
tempdel3 | date | delta32k | f | 10 | f | none | | |
tempdel4 | timestamp without time zone | runlength | f | 11 | f | none | | |
tempdel5 | timestamp with time zone | delta | f | 12 | f | none | | |
tempdel6 | character varying(65535) | text32k | f | 0 | f | none | | |
start_date | character varying(10) | text255 | f | 13 | f | none | | |
Indexes:
COMPOUND SORTKEY (address,tempdel2,start_date,custkey,zipcode,tempdel4,city,state,tempdel3,custname)
db=# CREATE TABLE tbl_interleaved(custkey SMALLINT) INTERLEAVED SORTKEY (custkey);
CREATE TABLE
db=# \d tbl_interleaved
Table "public.tbl_interleaved"
Column | Type | Encoding | DistKey | SortKey | Preload | Encryption | Collation | Nullable | Default
---------+----------+----------+---------+---------+---------+------------+-----------+----------+---------
custkey | smallint | none | f | 1 | f | none | | |
Indexes:
INTERLEAVED SORTKEY (custkey)
This change was complicated because Redshift doesn't natively support LISTAGG() function on System / Catalog tables, which meant that I had to resort to a pretty verbose workaround. This in-turn meant that this patch shows only the first ten COMPOUND SORTKEYs of a table. Seriously speaking, it would really take an extreme corner-case, for someone to genuinely require a SORTKEY with 10+ columns.
This is not a limitation for INTERLEAVED SORTKEY since it only supports a maximum of 8 Columns.
db=# CREATE TABLE tbl_pk(custkey SMALLINT PRIMARY KEY);
CREATE TABLE
db=# \d tbl_pk
Table "public.tbl_pk"
Column | Type | Encoding | DistKey | SortKey | Preload | Encryption | Collation | Nullable | Default
---------+----------+----------+---------+---------+---------+------------+-----------+----------+---------
custkey | smallint | lzo | f | 0 | f | none | | not null |
Indexes:
PRIMARY KEY, btree (custkey)
db=# CREATE TABLE tbl_compound(
db(# custkey SMALLINT ENCODE delta NOT NULL,
db(# custname INTEGER DEFAULT 10 ENCODE raw NULL,
db(# gender BOOLEAN ENCODE RAW,
db(# address CHAR(5) ENCODE LZO,
db(# city BIGINT identity(0, 1) ENCODE DELTA,
db(# state DOUBLE PRECISION ENCODE Runlength,
db(# zipcode REAL,
db(# tempdel1 DECIMAL ENCODE Mostly16,
db(# tempdel2 BIGINT ENCODE Mostly32,
db(# tempdel3 DATE ENCODE DELTA32k,
db(# tempdel4 TIMESTAMP ENCODE Runlength,
db(# tempdel5 TIMESTAMPTZ ENCODE DELTA,
db(# tempdel6 VARCHAR(MAX) ENCODE text32k,
db(# start_date VARCHAR(10) ENCODE TEXT255
db(# )
db-# DISTSTYLE KEY
db-# DISTKEY (custname)
db-# COMPOUND SORTKEY (custkey, custname, gender, address, city, state, zipcode, tempdel1, tempdel2, tempdel3, tempdel4, tempdel5, start_date);
CREATE TABLE
db=#
db=# \d tbl_compound
Table "public.tbl_compound"
Column | Type | Encoding | DistKey | SortKey | Preload | Encryption | Collation | Nullable | Default
------------+-----------------------------+-----------+---------+---------+---------+------------+-----------+----------+------------------------------------
custkey | smallint | delta | f | 1 | f | none | | not null |
custname | integer | none | t | 2 | f | none | | | 10
gender | boolean | none | f | 3 | f | none | | |
address | character(5) | lzo | f | 4 | f | none | | |
city | bigint | delta | f | 5 | f | none | | | "identity"(494055, 4, '0,1'::text)
state | double precision | runlength | f | 6 | f | none | | |
zipcode | real | none | f | 7 | f | none | | |
tempdel1 | numeric(18,0) | mostly16 | f | 8 | f | none | | |
tempdel2 | bigint | mostly32 | f | 9 | f | none | | |
tempdel3 | date | delta32k | f | 10 | f | none | | |
tempdel4 | timestamp without time zone | runlength | f | 11 | f | none | | |
tempdel5 | timestamp with time zone | delta | f | 12 | f | none | | |
tempdel6 | character varying(65535) | text32k | f | 0 | f | none | | |
start_date | character varying(10) | text255 | f | 13 | f | none | | |
Indexes:
COMPOUND SORTKEY (address,tempdel2,start_date,custkey,zipcode,tempdel4,city,state,tempdel3,custname)
db=# CREATE TABLE tbl_interleaved(custkey SMALLINT) INTERLEAVED SORTKEY (custkey);
CREATE TABLE
db=# \d tbl_interleaved
Table "public.tbl_interleaved"
Column | Type | Encoding | DistKey | SortKey | Preload | Encryption | Collation | Nullable | Default
---------+----------+----------+---------+---------+---------+------------+-----------+----------+---------
custkey | smallint | none | f | 1 | f | none | | |
Indexes:
INTERLEAVED SORTKEY (custkey)
As a side-note, there is a consideration as to whether this should be on a separate section of its own (and not under Indexes, which it clearly isn't). May be another day. Happy Redshifting :) !
Update (15th Sep 2017):
This project has now been named PsqlForks!
Update (15th Sep 2017):
This project has now been named PsqlForks!
31 Aug 2017
psql \d now supports DISTKEY / SORTKEY / ENCODING (in Redshift)
This is in continuation of my work for (my forked version of) psql to better support Redshift (read more here).
Now \d table provides some additional Redshift specific table properties such as:
Now \d table provides some additional Redshift specific table properties such as:
- DISTKEY
- SORTKEY
- COMPRESSION (ENCODING)
- ENCRYPTION
Sample:
t3=# CREATE TABLE customer(
custkey SMALLINT ENCODE delta NOT NULL,
custname INTEGER DEFAULT 10 ENCODE raw NULL,
gender BOOLEAN ENCODE RAW,
address CHAR(5) ENCODE LZO,
city BIGINT identity(0, 1) ENCODE DELTA,
state DOUBLE PRECISION ENCODE Runlength,
zipcode REAL,
tempdel1 DECIMAL ENCODE Mostly16,
tempdel2 BIGINT ENCODE Mostly32,
tempdel3 DATE ENCODE DELTA32k,
tempdel4 TIMESTAMP ENCODE Runlength,
tempdel5 TIMESTAMPTZ ENCODE DELTA,
tempdel6 VARCHAR(MAX) ENCODE text32k,
start_date VARCHAR(10) ENCODE TEXT255
)
DISTSTYLE KEY
DISTKEY (custname)
INTERLEAVED SORTKEY (custkey, custname);
CREATE TABLE
t3=# \d customer
TABLE "public.customer"
Column | Type | Encoding | DistKey | SortKey | Preload | Encryption | Collation | Nullable | Default
------------+-----------------------------+-----------+---------+---------+---------+------------+-----------+----------+------------------------------------
custkey | smallint | delta | f | 1 | f | none | | not null |
custname | integer | none | t | 2 | f | none | | | 10
gender | boolean | none | f | 0 | f | none | | |
address | character(5) | lzo | f | 0 | f | none | | |
city | bigint | delta | f | 0 | f | none | | | "identity"(493983, 4, '0,1'::text)
state | double precision | runlength | f | 0 | f | none | | |
zipcode | real | none | f | 0 | f | none | | |
tempdel1 | numeric(18,0) | mostly16 | f | 0 | f | none | | |
tempdel2 | bigint | mostly32 | f | 0 | f | none | | |
tempdel3 | date | delta32k | f | 0 | f | none | | |
tempdel4 | timestamp without time zone | runlength | f | 0 | f | none | | |
tempdel5 | timestamp with time zone | delta | f | 0 | f | none | | |
tempdel6 | character varying(65535) | text32k | f | 0 | f | none | | |
start_date | character varying(10) | text255 | f | 0 | f | none | | |
Subscribe to:
Posts (Atom)
What's in an empty table?
How much storage does an empty table in Postgres take? This is a post about Postgres tables that store ... well basically ... Nothing . The...

-
(Please scroll down to the read the entire-post to know more) Documents required for Christian Marriage Registration (a.k.a. Documents...
-
My patch (allowing a non-super-user to dump Globals) just got committed to Postgres 10.0. Besides the use mentioned above, this patch al...
-
I am just starting my AI journey, and trying to get Ollama to work on my linux box, was an interesting non-AI experience. I noticed, that ev...