Skip to content

Commit 1e0d220

Browse files
committed
Feat: Adapt gp_url_tools for Cloudberry and fix UTF-16 surrogate decoding
1 parent 81aeab7 commit 1e0d220

11 files changed

Lines changed: 229 additions & 310 deletions

File tree

.github/workflows/build-cloudberry-rocky8.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ jobs:
319319
"make_configs":["gpcontrib/orafce:installcheck",
320320
"gpcontrib/zstd:installcheck",
321321
"gpcontrib/gp_sparse_vector:installcheck",
322-
"gpcontrib/gp_toolkit:installcheck"]
322+
"gpcontrib/gp_toolkit:installcheck",
323+
"gpcontrib/gp_url_tools:installcheck"]
323324
},
324325
{"test":"gpcontrib-gp-stats-collector",
325326
"make_configs":["gpcontrib/gp_stats_collector:installcheck"],

.github/workflows/build-cloudberry.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,8 @@ jobs:
318318
"gpcontrib/gp_sparse_vector:installcheck",
319319
"gpcontrib/gp_toolkit:installcheck",
320320
"gpcontrib/gp_exttable_fdw:installcheck",
321-
"gpcontrib/gp_internal_tools:installcheck"]
321+
"gpcontrib/gp_internal_tools:installcheck",
322+
"gpcontrib/gp_url_tools:installcheck"]
322323
},
323324
{"test":"ic-diskquota",
324325
"make_configs":["gpcontrib/diskquota:installcheck"],

gpcontrib/gp_url_tools/.clang-format

Lines changed: 0 additions & 192 deletions
This file was deleted.

gpcontrib/gp_url_tools/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ TESTS = $(wildcard test/sql/*.sql)
66
REGRESS = $(patsubst test/sql/%.sql,%,$(TESTS))
77
REGRESS_OPTS = --inputdir=test
88

9+
ifdef USE_PGXS
910
PG_CONFIG = pg_config
1011
PGXS := $(shell $(PG_CONFIG) --pgxs)
1112
include $(PGXS)
13+
else
14+
top_builddir = ../..
15+
include $(top_builddir)/src/Makefile.global
16+
include $(top_srcdir)/contrib/contrib-global.mk
17+
endif

gpcontrib/gp_url_tools/README.md

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,75 @@
1-
# gp_url_tools: Greenplum extension providing functionality for working with URL addresses
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
# gp_url_tools: Cloudberry extension providing functionality for working with URL addresses
221

322
### Features
4-
gp_url_tools is an extension for the Greenplum database that gives implementation
23+
`gp_url_tools` is an extension for the Cloudberry database that gives implementation
524
for functions that encode/decode url/uri.
625

7-
### Installation
8-
Install from source:
9-
```
10-
git clone https://github.com/open-gpdb/gp_url_tools.git
11-
cd gp_url_tools
12-
# Build it. Building would require GP installed nearby and sourcing greenplum_path.sh
13-
source <path_to_gp>/greenplum_path.sh
14-
make && make install
15-
```
26+
### Functions
27+
The extension creates the `url_tools_schema` schema and adds four SQL functions:
28+
29+
- `url_tools_schema.encode_url`/`.encode_uri`
30+
Encodes a text value for use as a URL/URI component by replacing reserved characters with percent-encoded sequences.
31+
32+
- `url_tools_schema.decode_url`/`.decode_uri`
33+
Decodes percent-encoded sequences in a URL/URI-encoded text value back to their original characters (human-readable).
1634

1735
### Usage
36+
```sql
37+
CREATE EXTENSION gp_url_tools;
1838
```
19-
=# create extension gp_url_tools;
20-
21-
=# select url_tools_schema.encode_url('Hello World');
39+
```sql
40+
SELECT url_tools_schema.encode_url('Hello World');
41+
```
42+
```bash
2243
encode_url
2344
───────────────
2445
Hello%20World
2546
(1 row)
26-
27-
=# select url_tools_schema.decode_url('Hello%20World');
47+
```
48+
```sql
49+
SELECT url_tools_schema.decode_url('Hello%20World');
50+
```
51+
```bash
2852
decode_url
2953
─────────────
3054
Hello World
3155
(1 row)
32-
33-
=# select url_tools_schema.encode_uri('https://ru.wikipedia.org/wiki/Greenplum_(компания)');
56+
```
57+
```sql
58+
SELECT url_tools_schema.encode_uri('https://ru.wikipedia.org/wiki/Greenplum_(компания)');
59+
```
60+
```bash
3461
encode_uri
3562
────────────────────────────────────────────────────────────────────────────────────────────
3663
https://ru.wikipedia.org/wiki/Greenplum_(%D0%BA%D0%BE%D0%BC%D0%BF%D0%B0%D0%BD%D0%B8%D1%8F)
37-
38-
=# select url_tools_schema.decode_uri('https://ru.wikipedia.org/wiki/Greenplum_(%D0%BA%D0%BE%D0%BC%D0%BF%D0%B0%D0%BD%D0%B8%D1%8F)');
64+
```
65+
```sql
66+
SELECT url_tools_schema.decode_uri('https://ru.wikipedia.org/wiki/Greenplum_(%D0%BA%D0%BE%D0%BC%D0%BF%D0%B0%D0%BD%D0%B8%D1%8F)');
67+
```
68+
```bash
3969
decode_uri
4070
────────────────────────────────────────────────────
4171
https://ru.wikipedia.org/wiki/Greenplum_(компания)
4272
```
4373

4474
### Acknowledgments
45-
Thank you very much for the extension for postgrsql: https://github.com/okbob/url_encode, its sources were very useful.
75+
Thank you very much for the extension for PostgreSQL: https://github.com/okbob/url_encode, its sources were very useful.

gpcontrib/gp_url_tools/gp_url_tools.control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# gp_url_tools extension
2-
comment = 'Greenplum extension providing functionality for working with URL addresses'
2+
comment = 'Functions for working with URL-s'
33
default_version = '1.0'
44
module_pathname = '$libdir/gp_url_tools'
55
relocatable = true

gpcontrib/gp_url_tools/sql/gp_url_tools--1.0.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
\echo Use "CREATE EXTENSION gp_url_tools" to load this file. \quit
55

66
CREATE SCHEMA IF NOT EXISTS url_tools_schema;
7+
GRANT USAGE ON SCHEMA url_tools_schema TO public;
78

89
CREATE FUNCTION url_tools_schema.encode_url(text)
910
RETURNS text
@@ -24,4 +25,3 @@ CREATE FUNCTION url_tools_schema.decode_uri(text)
2425
RETURNS text
2526
AS 'MODULE_PATHNAME', 'decode_uri'
2627
LANGUAGE C IMMUTABLE STRICT;
27-

0 commit comments

Comments
 (0)