Ensure that maxlen is an integer value in dict_int configuration

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Ensure that maxlen is an integer value in dict_int configuration
Date: 2018-03-27 11:17:20
Message-ID: F39EB4FB-62A7-4F01-93A8-0570CC485F4B@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I recently had a usecase for dict_int, typoed my script and spent longer than
I’d like to admit finding said typo. The attached patch scratches my itch by
ensuring that the maxlen parameter to dict_int is integer, instead of silently
setting it to zero on malformed input. Instead of this:

dg=# alter text search dictionary intdict (maxlen = a, rejectlong = true);
ALTER TEXT SEARCH DICTIONARY
dg=# select ts_lexize('intdict', '12345678');
ts_lexize
-----------
{}
(1 row)

.. the attached will error out with “ERROR: maxlen is out of range, must
be integer”, and be more in line with how we handle DefElem values. A quick
grep around the tree didn’t turn up any other defelems doing this so I think
this is the only callsite.

cheers ./daniel

Attachment Content-Type Size
dict_int_maxlen.patch application/octet-stream 757 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2018-03-27 11:27:31 Re: Parallel safety of binary_upgrade_create_empty_extension
Previous Message Alexander Korotkov 2018-03-27 11:01:21 Re: [HACKERS] GUC for cleanup indexes threshold.