pax_global_header00006660000000000000000000000064141134414020014504gustar00rootroot0000000000000052 comment=1d978524ec0881f2dd128a828e0dcf65854b729e pgsql-asn1oid-upstream-1.4/000077500000000000000000000000001411344140200156705ustar00rootroot00000000000000pgsql-asn1oid-upstream-1.4/.gitignore000066400000000000000000000000111411344140200176500ustar00rootroot00000000000000*.o *.so pgsql-asn1oid-upstream-1.4/.travis.yml000066400000000000000000000014211411344140200177770ustar00rootroot00000000000000# run the testsuite on travis-ci.com --- # versions to run on env: - PG_SUPPORTED_VERSIONS=9.2 - PG_SUPPORTED_VERSIONS=9.3 - PG_SUPPORTED_VERSIONS=9.4 - PG_SUPPORTED_VERSIONS=9.5 - PG_SUPPORTED_VERSIONS=9.6 - PG_SUPPORTED_VERSIONS=10 - PG_SUPPORTED_VERSIONS=11 - PG_SUPPORTED_VERSIONS=12 - PG_SUPPORTED_VERSIONS=13 language: C dist: xenial arch: - AMD64 - ppc64le before_install: - sudo apt-get update -qq install: # upgrade postgresql-common for new apt.postgresql.org.sh - sudo apt-get install -y postgresql-common - sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -p -v $PG_SUPPORTED_VERSIONS -i script: - make - sudo make install - pg_virtualenv make installcheck - if test -s regression.diffs; then cat regression.diffs; fi pgsql-asn1oid-upstream-1.4/Makefile000066400000000000000000000002411411344140200173250ustar00rootroot00000000000000MODULES = asn1oid EXTENSION = asn1oid DATA = asn1oid--1.sql REGRESS = init asn1oid PG_CONFIG := pg_config PGXS := $(shell $(PG_CONFIG) --pgxs) include $(PGXS) pgsql-asn1oid-upstream-1.4/README.md000066400000000000000000000017461411344140200171570ustar00rootroot00000000000000asn1oid Type for PostgreSQL =========================== [![Build Status](https://travis-ci.org/df7cb/pgsql-asn1oid.svg?branch=master)](https://travis-ci.org/df7cb/pgsql-asn1oid) The asn1oid extension provides a datatype for ASN.1 OIDs in PostgreSQL. ``` CREATE EXTENSION asn1oid; # SELECT '1.3.6.1.4.1'::asn1oid; asn1oid ───────────── 1.3.6.1.4.1 ``` Author, Copyright and License ----------------------------- Simon Richter Copyright (C) 2010 Simon Richter This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. pgsql-asn1oid-upstream-1.4/asn1oid--1.sql000066400000000000000000000052721411344140200201700ustar00rootroot00000000000000CREATE TYPE asn1oid; CREATE FUNCTION asn1oid_input (cstring) RETURNS asn1oid IMMUTABLE STRICT LANGUAGE C AS 'asn1oid.so','asn1oid_input'; CREATE FUNCTION asn1oid_output (asn1oid) RETURNS cstring IMMUTABLE STRICT LANGUAGE C AS 'asn1oid.so','asn1oid_output'; CREATE TYPE asn1oid ( INPUT = asn1oid_input, OUTPUT = asn1oid_output); CREATE FUNCTION asn1oid_eq (asn1oid, asn1oid) RETURNS bool IMMUTABLE STRICT LANGUAGE C AS 'asn1oid.so','asn1oid_eq'; CREATE FUNCTION asn1oid_ne (asn1oid, asn1oid) RETURNS bool IMMUTABLE STRICT LANGUAGE C AS 'asn1oid.so','asn1oid_ne'; CREATE FUNCTION asn1oid_lt (asn1oid, asn1oid) RETURNS bool IMMUTABLE STRICT LANGUAGE C AS 'asn1oid.so','asn1oid_lt'; CREATE FUNCTION asn1oid_gt (asn1oid, asn1oid) RETURNS bool IMMUTABLE STRICT LANGUAGE C AS 'asn1oid.so','asn1oid_gt'; CREATE FUNCTION asn1oid_le (asn1oid, asn1oid) RETURNS bool IMMUTABLE STRICT LANGUAGE C AS 'asn1oid.so','asn1oid_le'; CREATE FUNCTION asn1oid_ge (asn1oid, asn1oid) RETURNS bool IMMUTABLE STRICT LANGUAGE C AS 'asn1oid.so','asn1oid_ge'; CREATE FUNCTION asn1oid_cmp (asn1oid, asn1oid) RETURNS int4 IMMUTABLE STRICT AS 'asn1oid.so','asn1oid_cmp' LANGUAGE C; CREATE OPERATOR = ( LEFTARG = asn1oid, RIGHTARG = asn1oid, PROCEDURE = asn1oid_eq, COMMUTATOR = '=', NEGATOR = '<>', RESTRICT = eqsel, JOIN = eqjoinsel, HASHES, MERGES); CREATE OPERATOR < ( LEFTARG = asn1oid, RIGHTARG = asn1oid, PROCEDURE = asn1oid_lt, COMMUTATOR = '>', NEGATOR = '>=', RESTRICT = scalarltsel, JOIN = scalarltjoinsel); CREATE OPERATOR > ( LEFTARG = asn1oid, RIGHTARG = asn1oid, PROCEDURE = asn1oid_gt, COMMUTATOR = '<', NEGATOR = '<=', RESTRICT = scalargtsel, JOIN = scalargtjoinsel); CREATE OPERATOR <= ( LEFTARG = asn1oid, RIGHTARG = asn1oid, PROCEDURE = asn1oid_le, COMMUTATOR = '>=', NEGATOR = '>', RESTRICT = scalarltsel, JOIN = scalarltjoinsel); CREATE OPERATOR >= ( LEFTARG = asn1oid, RIGHTARG = asn1oid, PROCEDURE = asn1oid_ge, COMMUTATOR = '<=', NEGATOR = '<', RESTRICT = scalargtsel, JOIN = scalargtjoinsel); CREATE OPERATOR <> ( LEFTARG = asn1oid, RIGHTARG = asn1oid, PROCEDURE = asn1oid_ne, COMMUTATOR = '<>', NEGATOR = '=', RESTRICT = neqsel, JOIN = neqjoinsel); CREATE OPERATOR CLASS asn1oid_ops DEFAULT FOR TYPE asn1oid USING btree AS OPERATOR 1 <, OPERATOR 2 <=, OPERATOR 3 =, OPERATOR 4 >=, OPERATOR 5 >, FUNCTION 1 asn1oid_cmp(asn1oid, asn1oid); pgsql-asn1oid-upstream-1.4/asn1oid.c000066400000000000000000000154651411344140200174050ustar00rootroot00000000000000#ifdef HAVE_CONFIG_H #include #endif #include #include PG_MODULE_MAGIC; Datum asn1oid_input(PG_FUNCTION_ARGS); Datum asn1oid_output(PG_FUNCTION_ARGS); Datum asn1oid_eq(PG_FUNCTION_ARGS); Datum asn1oid_ne(PG_FUNCTION_ARGS); Datum asn1oid_lt(PG_FUNCTION_ARGS); Datum asn1oid_gt(PG_FUNCTION_ARGS); Datum asn1oid_le(PG_FUNCTION_ARGS); Datum asn1oid_ge(PG_FUNCTION_ARGS); Datum asn1oid_cmp(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(asn1oid_input); PG_FUNCTION_INFO_V1(asn1oid_output); PG_FUNCTION_INFO_V1(asn1oid_eq); PG_FUNCTION_INFO_V1(asn1oid_ne); PG_FUNCTION_INFO_V1(asn1oid_lt); PG_FUNCTION_INFO_V1(asn1oid_gt); PG_FUNCTION_INFO_V1(asn1oid_le); PG_FUNCTION_INFO_V1(asn1oid_ge); PG_FUNCTION_INFO_V1(asn1oid_cmp); struct asn1oid { int32 vl_len_; uint32 data[1]; }; typedef struct asn1oid asn1oid; static unsigned int size(asn1oid const *oid) { return (VARSIZE(oid) - offsetof(asn1oid, data)) / sizeof(uint32); } #define PG_GETARG_ASN1OID(x) (asn1oid *)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x))) Datum asn1oid_input(PG_FUNCTION_ARGS) { char *str = PG_GETARG_CSTRING(0); uint32 tmp[64]; unsigned int i, j; char const *c; unsigned int size; asn1oid *ret; i = 0; tmp[i] = 0; for(c = str; *c; ++c) { switch(*c) { case '0': tmp[i] *= 10; break; case '1': tmp[i] *= 10; tmp[i] += 1; break; case '2': tmp[i] *= 10; tmp[i] += 2; break; case '3': tmp[i] *= 10; tmp[i] += 3; break; case '4': tmp[i] *= 10; tmp[i] += 4; break; case '5': tmp[i] *= 10; tmp[i] += 5; break; case '6': tmp[i] *= 10; tmp[i] += 6; break; case '7': tmp[i] *= 10; tmp[i] += 7; break; case '8': tmp[i] *= 10; tmp[i] += 8; break; case '9': tmp[i] *= 10; tmp[i] += 9; break; case '.': if(c == str) { if (c[1]) { /* Skip over first dot */ break; } ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), errmsg("invalid input syntax for type asn1oid: \"%s\"", str))); } ++i; if(i >= 64) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), errmsg("invalid input syntax for type asn1oid: \"%s\"", str))); tmp[i] = 0; break; default: ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), errmsg("invalid input syntax for type asn1oid: \"%s\"", str))); } } if(c == str || c[-1] == '.') ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), errmsg("invalid input syntax for type asn1oid: \"%s\"", str))); ++i; size = offsetof(asn1oid, data) + sizeof(uint32) * i; ret = palloc(size); SET_VARSIZE(ret, size); for(j = 0; j < i; ++j) ret->data[j] = tmp[j]; PG_RETURN_POINTER(ret); } Datum asn1oid_output(PG_FUNCTION_ARGS) { asn1oid *oid = PG_GETARG_ASN1OID(0); unsigned int len = size(oid); unsigned int size = 0; unsigned int i; char *ret, *j; if(len == 0) PG_RETURN_NULL(); for(i = 0; i < len; ++i) { uint32 t = oid->data[i]; if(t < 10) size += 2; else if(t < 100) size += 3; else if(t < 1000) size += 4; else if(t < 10000) size += 5; else if(t < 100000) size += 6; else if(t < 1000000) size += 7; else if(t < 10000000) size += 8; else if(t < 100000000) size += 9; else if(t < 1000000000) size += 10; else size += 11; } ret = palloc(size); j = ret; for(i = 0; i < len; ++i) { uint32 t = oid->data[i]; char *b = j; char *r; do { *j++ = '0' + t % 10; t /= 10; } while(t); r = j; for(--r; b < r; ++b, --r) { char t = *r; *r = *b; *b = t; } *j++ = '.'; } j[-1] = 0; PG_FREE_IF_COPY(oid, 0); PG_RETURN_CSTRING(ret); } static int cmp(asn1oid const *lhs, asn1oid const *rhs) { unsigned int lhs_size = size(lhs); unsigned int rhs_size = size(rhs); unsigned int size = (lhs_size < rhs_size)?lhs_size:rhs_size; unsigned int i; for(i = 0; i < size; ++i) { uint32 l = lhs->data[i]; uint32 r = rhs->data[i]; if(l < r) return -1; if(l > r) return 1; } if(lhs_size < rhs_size) return -1; if(lhs_size > rhs_size) return 1; return 0; } Datum asn1oid_eq(PG_FUNCTION_ARGS) { asn1oid *lhs = PG_GETARG_ASN1OID(0); asn1oid *rhs = PG_GETARG_ASN1OID(1); int res = cmp(lhs, rhs); PG_FREE_IF_COPY(lhs, 0); PG_FREE_IF_COPY(rhs, 1); PG_RETURN_BOOL(res == 0); } Datum asn1oid_ne(PG_FUNCTION_ARGS) { asn1oid *lhs = PG_GETARG_ASN1OID(0); asn1oid *rhs = PG_GETARG_ASN1OID(1); int res = cmp(lhs, rhs); PG_FREE_IF_COPY(lhs, 0); PG_FREE_IF_COPY(rhs, 1); PG_RETURN_BOOL(res != 0); } Datum asn1oid_lt(PG_FUNCTION_ARGS) { asn1oid *lhs = PG_GETARG_ASN1OID(0); asn1oid *rhs = PG_GETARG_ASN1OID(1); int res = cmp(lhs, rhs); PG_FREE_IF_COPY(lhs, 0); PG_FREE_IF_COPY(rhs, 1); PG_RETURN_BOOL(res < 0); } Datum asn1oid_gt(PG_FUNCTION_ARGS) { asn1oid *lhs = PG_GETARG_ASN1OID(0); asn1oid *rhs = PG_GETARG_ASN1OID(1); int res = cmp(lhs, rhs); PG_FREE_IF_COPY(lhs, 0); PG_FREE_IF_COPY(rhs, 1); PG_RETURN_BOOL(res > 0); } Datum asn1oid_le(PG_FUNCTION_ARGS) { asn1oid *lhs = PG_GETARG_ASN1OID(0); asn1oid *rhs = PG_GETARG_ASN1OID(1); int res = cmp(lhs, rhs); PG_FREE_IF_COPY(lhs, 0); PG_FREE_IF_COPY(rhs, 1); PG_RETURN_BOOL(res <= 0); } Datum asn1oid_ge(PG_FUNCTION_ARGS) { asn1oid *lhs = PG_GETARG_ASN1OID(0); asn1oid *rhs = PG_GETARG_ASN1OID(1); int res = cmp(lhs, rhs); PG_FREE_IF_COPY(lhs, 0); PG_FREE_IF_COPY(rhs, 1); PG_RETURN_BOOL(res >= 0); } Datum asn1oid_cmp(PG_FUNCTION_ARGS) { asn1oid *lhs = PG_GETARG_ASN1OID(0); asn1oid *rhs = PG_GETARG_ASN1OID(1); int res = cmp(lhs, rhs); PG_FREE_IF_COPY(lhs, 0); PG_FREE_IF_COPY(rhs, 1); PG_RETURN_INT32(res); } pgsql-asn1oid-upstream-1.4/asn1oid.control000066400000000000000000000001071411344140200206260ustar00rootroot00000000000000default_version = '1' comment = 'asn1oid extension' relocatable = true pgsql-asn1oid-upstream-1.4/debian/000077500000000000000000000000001411344140200171125ustar00rootroot00000000000000pgsql-asn1oid-upstream-1.4/debian/changelog000066400000000000000000000056731411344140200207770ustar00rootroot00000000000000pgsql-asn1oid (1.4-1) unstable; urgency=medium * Update Debian package URLs. -- Christoph Berg Tue, 31 Aug 2021 16:53:12 +0200 pgsql-asn1oid (1.3-1) unstable; urgency=medium [ Debian Janitor ] * Trim trailing whitespace. * Upgrade to newer source format. * Update standards version to 4.4.1, no changes needed. [ Christoph Berg ] * Upload for PostgreSQL 13. * Use dh --with pgxs. * R³: no. * DH 13. * debian/tests: Use 'make' instead of postgresql-server-dev-all. -- Christoph Berg Mon, 19 Oct 2020 14:16:04 +0200 pgsql-asn1oid (1.2-3) unstable; urgency=medium * Upload for PostgreSQL 12. -- Christoph Berg Wed, 30 Oct 2019 11:40:16 +0100 pgsql-asn1oid (1.2-2) unstable; urgency=medium * Upload for PostgreSQL 11. * Retire Simon from Uploaders, thanks for your work! -- Christoph Berg Fri, 12 Oct 2018 20:12:21 +0200 pgsql-asn1oid (1.2-1) unstable; urgency=medium * Team upload. * More testsuite cases by Herwin Weststrate, thanks! * Add homepage and Vcs fields. -- Christoph Berg Mon, 02 Oct 2017 10:13:29 +0200 pgsql-asn1oid (1.1) unstable; urgency=medium * Import Debian patches into a new upstream version. * Upload for PostgreSQL 10. * Convert to a proper PostgreSQL extension. -- Christoph Berg Sun, 24 Sep 2017 11:40:05 +0200 pgsql-asn1oid (0.0.20100818-3.5) unstable; urgency=medium * Non-maintainer upload. * Add patch by Herwin Weststrate to fix crash on invalid asn1oid input, thanks! (Closes: 822935) -- Christoph Berg Thu, 26 Jan 2017 17:32:57 +0100 pgsql-asn1oid (0.0.20100818-3.4) unstable; urgency=medium * Non-maintainer upload. * Upload with 9.6 support. -- Christoph Berg Sat, 24 Sep 2016 22:03:41 +0200 pgsql-asn1oid (0.0.20100818-3.2) unstable; urgency=medium * Non-maintainer upload. * Upload with 9.5 support. (Closes: #810560) * Fix testsuite to cope with changed \set ECHO semantics, patch by Martin Pitt. (Closes: #777521) -- Christoph Berg Thu, 21 Jan 2016 19:47:52 +0100 pgsql-asn1oid (0.0.20100818-3.1) unstable; urgency=medium * Non-maintainer upload. * Port to use pg_buildext and move to PostgreSQL 9.4 for jessie. (Closes: #757392) * Rename binary package to postgresql-9.4-asn1oid. * Add regression tests. -- Christoph Berg Sun, 07 Sep 2014 16:44:53 +0200 pgsql-asn1oid (0.0.20100818-3) unstable; urgency=low * Update to PostgreSQL 9.3 (Closes: #731913) -- Simon Richter Wed, 11 Dec 2013 10:35:24 +0100 pgsql-asn1oid (0.0.20100818-2) unstable; urgency=low * Upgrade to policy 3.9.3 * Upgrade to PostgreSQL 9.1 -- Simon Richter Sun, 29 Jul 2012 21:19:12 +0200 pgsql-asn1oid (0.0.20100818-1) unstable; urgency=low * Initial release -- Simon Richter Wed, 18 Aug 2010 17:26:27 +0200 pgsql-asn1oid-upstream-1.4/debian/control000066400000000000000000000013711411344140200205170ustar00rootroot00000000000000Source: pgsql-asn1oid Section: database Priority: optional Maintainer: Debian PostgreSQL Maintainers Uploaders: Christoph Berg Build-Depends: debhelper-compat (= 13), postgresql-all (>= 217~) Standards-Version: 4.6.0 Rules-Requires-Root: no Homepage: https://github.com/df7cb/pgsql-asn1oid Vcs-Browser: https://github.com/df7cb/pgsql-asn1oid Vcs-Git: https://github.com/df7cb/pgsql-asn1oid.git Package: postgresql-13-asn1oid Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, postgresql-13 Description: ASN.1 OID data type for PostgreSQL This plugin provides the necessary support functions to store ASN.1 OIDs in a PostgreSQL database. . This package has been compiled for PostgreSQL 13. pgsql-asn1oid-upstream-1.4/debian/control.in000066400000000000000000000014161411344140200211240ustar00rootroot00000000000000Source: pgsql-asn1oid Section: database Priority: optional Maintainer: Debian PostgreSQL Maintainers Uploaders: Christoph Berg Build-Depends: debhelper-compat (= 13), postgresql-all (>= 217~) Standards-Version: 4.6.0 Rules-Requires-Root: no Homepage: https://github.com/df7cb/pgsql-asn1oid Vcs-Browser: https://github.com/df7cb/pgsql-asn1oid Vcs-Git: https://github.com/df7cb/pgsql-asn1oid.git Package: postgresql-PGVERSION-asn1oid Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, postgresql-PGVERSION Description: ASN.1 OID data type for PostgreSQL This plugin provides the necessary support functions to store ASN.1 OIDs in a PostgreSQL database. . This package has been compiled for PostgreSQL PGVERSION. pgsql-asn1oid-upstream-1.4/debian/copyright000066400000000000000000000022771411344140200210550ustar00rootroot00000000000000This work was packaged for Debian by: Simon Richter on Wed, 18 Aug 2010 17:26:27 +0200 It was downloaded from: http://www.hogyros.de/download/ Upstream Author: Simon Richter Copyright: Copyright (C) 2010 Simon Richter License: This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . On Debian systems, the complete text of the GNU General Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". The Debian packaging is: Copyright (C) 2010 Simon Richter and is licensed under the GPL version 3, see above. pgsql-asn1oid-upstream-1.4/debian/pgversions000066400000000000000000000000041411344140200212260ustar00rootroot00000000000000all pgsql-asn1oid-upstream-1.4/debian/rules000077500000000000000000000000521411344140200201670ustar00rootroot00000000000000#!/usr/bin/make -f %: dh $@ --with pgxs pgsql-asn1oid-upstream-1.4/debian/source/000077500000000000000000000000001411344140200204125ustar00rootroot00000000000000pgsql-asn1oid-upstream-1.4/debian/source/format000066400000000000000000000000141411344140200216200ustar00rootroot000000000000003.0 (quilt) pgsql-asn1oid-upstream-1.4/debian/tests/000077500000000000000000000000001411344140200202545ustar00rootroot00000000000000pgsql-asn1oid-upstream-1.4/debian/tests/control000066400000000000000000000001001411344140200216460ustar00rootroot00000000000000Depends: @, make Tests: installcheck Restrictions: allow-stderr pgsql-asn1oid-upstream-1.4/debian/tests/installcheck000077500000000000000000000000431411344140200226430ustar00rootroot00000000000000#!/bin/sh pg_buildext installcheck pgsql-asn1oid-upstream-1.4/debian/watch000066400000000000000000000001241411344140200201400ustar00rootroot00000000000000version=4 https://github.com/df7cb/pgsql-asn1oid/releases .*/upstream/(.*)\.tar\.gz pgsql-asn1oid-upstream-1.4/expected/000077500000000000000000000000001411344140200174715ustar00rootroot00000000000000pgsql-asn1oid-upstream-1.4/expected/asn1oid.out000066400000000000000000000006361411344140200215650ustar00rootroot00000000000000SELECT '1.2.3'::asn1oid; asn1oid --------- 1.2.3 (1 row) SELECT '.1.2.3'::asn1oid; asn1oid --------- 1.2.3 (1 row) SELECT null::asn1oid; asn1oid --------- (1 row) SELECT 'foo'::asn1oid; ERROR: invalid input syntax for type asn1oid: "foo" LINE 1: SELECT 'foo'::asn1oid; ^ SELECT 123::asn1oid; ERROR: cannot cast type integer to asn1oid LINE 1: SELECT 123::asn1oid; ^ pgsql-asn1oid-upstream-1.4/expected/init.out000066400000000000000000000000321411344140200211600ustar00rootroot00000000000000CREATE EXTENSION asn1oid; pgsql-asn1oid-upstream-1.4/sql/000077500000000000000000000000001411344140200164675ustar00rootroot00000000000000pgsql-asn1oid-upstream-1.4/sql/asn1oid.sql000066400000000000000000000001651411344140200205500ustar00rootroot00000000000000SELECT '1.2.3'::asn1oid; SELECT '.1.2.3'::asn1oid; SELECT null::asn1oid; SELECT 'foo'::asn1oid; SELECT 123::asn1oid; pgsql-asn1oid-upstream-1.4/sql/init.sql000066400000000000000000000000321411344140200201460ustar00rootroot00000000000000CREATE EXTENSION asn1oid;