User Quota Implementation

From: "Jonah H(dot) Harris" <jharris(at)tvi(dot)edu>
To: pgsql-hackers(at)postgresql(dot)org
Subject: User Quota Implementation
Date: 2004-07-08 21:27:34
Message-ID: 40EDBC46.9060606@tvi.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

All,

Out of necessity, I've implemented user quotas in 7.4.3. What would the
process be for having this reviewed and combined? I have a patch for
7.4.3 ready, but wanted to know if you suggest that I patch the latest
cvs instead. Below if some information on the implementation.

=======================================================================
-- FACTS --------------------------------------------------------------
=======================================================================

1. Only a superuser can modify user quotas.
2. The minimum quota size is 1K.
3. The maximum quota size is (currently) the maximum of int4*1024 bytes.
4. Altering a user's quota does not make a change to their current data.
5. If you modify a user's quota to smaller than their current amount,
they will be unable to add any more data... but their current schema is
not truncated.

=======================================================================
-- SQL CHANGES --------------------------------------------------------
=======================================================================

COMMAND: ALTER USER

*** NEW SYNTAX ***

ALTER USER name [ [ WITH ] option [ ... ] ]

where option can be:

[ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password'
| CREATEDB | NOCREATEDB
| CREATEUSER | NOCREATEUSER
| VALID UNTIL 'abstime'
| QUOTA file_size | NOQUOTA

where file_size is:

integer[K | M | G]

K = Kilobytes
M = Megabytes
G = Gigabytes

=======================================================================
-- USAGE EXAMPLES -----------------------------------------------------
=======================================================================

*** VARIATIONS OF QUOTA SIZES ***
ALTER USER someuser QUOTA 50M;
ALTER USER someuser QUOTA 1G;
ALTER USER someuser QUOTA 500K;

*** GIVE USER AN UNLIMITED QUOTA ***
ALTER USER someuser NOQUOTA;

=======================================================================
-- INTERNAL CHANGES ---------------------------------------------------
=======================================================================

pg_shadow has added attribute userquota of type int4
pg_user view has added attribute (pg_shadow.userquota) to selection.

ADDED KEYWORDS

QUOTA
NOQUOTA

--
Jonah H. Harris, UNIX Administrator | phone: 505.224.4814
Albuquerque TVI | fax: 505.224.3014
525 Buena Vista SE | jharris(at)tvi(dot)edu
Albuquerque, New Mexico 87106 | http://w3.tvi.edu/~jharris/

"All great truths begin as blasphemies."
-- George Bernard Shaw

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Rod Taylor 2004-07-08 21:41:22 Re: [subxacts] Aborting a function
Previous Message Alvaro Herrera 2004-07-08 21:08:51 Re: [subxacts] Aborting a function