Skip to content

Commit 2fda3e0

Browse files
authored
Prepare for release 2.1 (#1017)
* Add CHANGELOG entry for the release * Update version number throughout * Update vendored source dependency for parson * Update vendored Postgres sources snprintf, strerror * Update version related tests
1 parent 18a8650 commit 2fda3e0

21 files changed

+423
-121
lines changed

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
### pg_auto_failover v2.1 (November 24, 2022) ###
2+
3+
This release incorporates support for Postgres major version 16, some bug fixes,
4+
documentation updates, and usual code maintenance work.
5+
6+
### Added
7+
* Support for Postgres major version 16. (#1013, #1006, )
8+
* Improve on documentation, Docker images, and tutorials. (#964, #954, #947)
9+
* PGDATABASE as default create node --dbname. (#956)
10+
* Add chapters to the documentation navigation. (#954)
11+
12+
### Fixed
13+
* Makefile .PHONY target is defined throughout where needed. (#1008)
14+
* History file parsing allowing for files longer than 1024 lines. (#995)
15+
* A mistake in setup description (#984)
16+
* Typo in pg_autoctl_do_pgsetup.rst (#961)
17+
* pg_autoctl version Postgres compatibility string. (#951)
18+
* Creating the PGUSER at pg_autoctl create postgres time. (#950)
19+
* Dockerfile compatibility for Citus before 11. (#946)
20+
* Punctuation in README.md. (#945)
21+
22+
### Changed
23+
* Main Makefile is reorganized to split out citus and azure specifics. (#1008)
24+
* Citus version matrix with new Citus releases. (#990)
25+
* Update Citus from 11.1.2 to 11.1.3 in the build system. (#957)
26+
127
### pg_auto_failover v2.0 (October 7, 2022) ###
228

329
This new release includes support for Citus in pg_auto_failover, the usual

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ def __init__(self, **options):
7171
# built documents.
7272
#
7373
# The short X.Y version.
74-
version = "2.0"
74+
version = "2.1"
7575
# The full version, including alpha/beta/rc tags.
76-
release = "2.0"
76+
release = "2.1"
7777

7878
# The language for content autogenerated by Sphinx. Refer to documentation
7979
# for a list of supported languages.

src/bin/lib/parson/.gitignore

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
.DS_Store
2+
test
3+
*.o
14
testcpp
2-
testcpp.*
3-
test.dSYM
5+
tests/test_2_serialized.txt
6+
tests/test_2_serialized_pretty.txt
7+
test_hash_collisions
8+
build/**

src/bin/lib/parson/CMakeLists.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
project(parson C)
3+
4+
include (GNUInstallDirs)
5+
6+
set(PARSON_VERSION 1.5.3)
7+
add_library(parson parson.c)
8+
target_include_directories(parson PUBLIC $<INSTALL_INTERFACE:include>)
9+
10+
set_target_properties(parson PROPERTIES PUBLIC_HEADER "parson.h")
11+
set_target_properties(parson PROPERTIES VERSION ${PARSON_VERSION})
12+
set_target_properties(parson PROPERTIES SOVERSION ${PARSON_VERSION})
13+
14+
install(
15+
TARGETS parson
16+
EXPORT parsonTargets
17+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT shlib
18+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
19+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
20+
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
21+
)
22+
23+
install(
24+
EXPORT parsonTargets
25+
FILE parsonConfig.cmake
26+
NAMESPACE parson::
27+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
28+
)
29+

src/bin/lib/parson/README.md

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
## About
2+
Parson is a lightweight [json](http://json.org) library written in C.
3+
4+
## Features
5+
* Lightweight (only 2 files)
6+
* Simple API
7+
* Addressing json values with dot notation (similar to C structs or objects in most OO languages, e.g. "objectA.objectB.value")
8+
* C89 compatible
9+
* Test suites
10+
11+
## Installation
12+
Run:
13+
```
14+
git clone https://github.com/kgabis/parson.git
15+
```
16+
and copy parson.h and parson.c to you source code tree.
17+
18+
Run ```make test``` to compile and run tests.
19+
20+
## Examples
21+
### Parsing JSON
22+
Here is a function, which prints basic commit info (date, sha and author) from a github repository.
23+
```c
24+
void print_commits_info(const char *username, const char *repo) {
25+
JSON_Value *root_value;
26+
JSON_Array *commits;
27+
JSON_Object *commit;
28+
size_t i;
29+
30+
char curl_command[512];
31+
char cleanup_command[256];
32+
char output_filename[] = "commits.json";
33+
34+
/* it ain't pretty, but it's not a libcurl tutorial */
35+
sprintf(curl_command,
36+
"curl -s \"https://api.github.com/repos/%s/%s/commits\" > %s",
37+
username, repo, output_filename);
38+
sprintf(cleanup_command, "rm -f %s", output_filename);
39+
system(curl_command);
40+
41+
/* parsing json and validating output */
42+
root_value = json_parse_file(output_filename);
43+
if (json_value_get_type(root_value) != JSONArray) {
44+
system(cleanup_command);
45+
return;
46+
}
47+
48+
/* getting array from root value and printing commit info */
49+
commits = json_value_get_array(root_value);
50+
printf("%-10.10s %-10.10s %s\n", "Date", "SHA", "Author");
51+
for (i = 0; i < json_array_get_count(commits); i++) {
52+
commit = json_array_get_object(commits, i);
53+
printf("%.10s %.10s %s\n",
54+
json_object_dotget_string(commit, "commit.author.date"),
55+
json_object_get_string(commit, "sha"),
56+
json_object_dotget_string(commit, "commit.author.name"));
57+
}
58+
59+
/* cleanup code */
60+
json_value_free(root_value);
61+
system(cleanup_command);
62+
}
63+
64+
```
65+
Calling ```print_commits_info("torvalds", "linux");``` prints:
66+
```
67+
Date SHA Author
68+
2012-10-15 dd8e8c4a2c David Rientjes
69+
2012-10-15 3ce9e53e78 Michal Marek
70+
2012-10-14 29bb4cc5e0 Randy Dunlap
71+
2012-10-15 325adeb55e Ralf Baechle
72+
2012-10-14 68687c842c Russell King
73+
2012-10-14 ddffeb8c4d Linus Torvalds
74+
...
75+
```
76+
77+
### Persistence
78+
In this example I'm using parson to save user information to a file and then load it and validate later.
79+
```c
80+
void persistence_example(void) {
81+
JSON_Value *schema = json_parse_string("{\"name\":\"\"}");
82+
JSON_Value *user_data = json_parse_file("user_data.json");
83+
char buf[256];
84+
const char *name = NULL;
85+
if (user_data == NULL || json_validate(schema, user_data) != JSONSuccess) {
86+
puts("Enter your name:");
87+
scanf("%s", buf);
88+
user_data = json_value_init_object();
89+
json_object_set_string(json_object(user_data), "name", buf);
90+
json_serialize_to_file(user_data, "user_data.json");
91+
}
92+
name = json_object_get_string(json_object(user_data), "name");
93+
printf("Hello, %s.", name);
94+
json_value_free(schema);
95+
json_value_free(user_data);
96+
return;
97+
}
98+
```
99+
100+
### Serialization
101+
Creating JSON values is very simple thanks to the dot notation.
102+
Object hierarchy is automatically created when addressing specific fields.
103+
In the following example I create a simple JSON value containing basic information about a person.
104+
```c
105+
void serialization_example(void) {
106+
JSON_Value *root_value = json_value_init_object();
107+
JSON_Object *root_object = json_value_get_object(root_value);
108+
char *serialized_string = NULL;
109+
json_object_set_string(root_object, "name", "John Smith");
110+
json_object_set_number(root_object, "age", 25);
111+
json_object_dotset_string(root_object, "address.city", "Cupertino");
112+
json_object_dotset_value(root_object, "contact.emails", json_parse_string("[\"[email protected]\",\"[email protected]\"]"));
113+
serialized_string = json_serialize_to_string_pretty(root_value);
114+
puts(serialized_string);
115+
json_free_serialized_string(serialized_string);
116+
json_value_free(root_value);
117+
}
118+
119+
```
120+
121+
Output:
122+
```
123+
{
124+
"name": "John Smith",
125+
"age": 25,
126+
"address": {
127+
"city": "Cupertino"
128+
},
129+
"contact": {
130+
"emails": [
131+
132+
133+
]
134+
}
135+
}
136+
```
137+
138+
## Contributing
139+
140+
I will always merge *working* bug fixes. However, if you want to add something new to the API, please create an "issue" on github for this first so we can discuss if it should end up in the library before you start implementing it.
141+
Remember to follow parson's code style and write appropriate tests.
142+
143+
## My other projects
144+
* [ape](https://github.com/kgabis/ape) - simple programming language implemented in C library
145+
* [kgflags](https://github.com/kgabis/kgflags) - easy to use command-line flag parsing library
146+
* [agnes](https://github.com/kgabis/agnes) - header-only NES emulation library
147+
148+
## License
149+
[The MIT License (MIT)](http://opensource.org/licenses/mit-license.php)

src/bin/lib/parson/meson.build

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
project('parson', 'c',
2+
version : '1.5.3',
3+
license : 'MIT',
4+
meson_version : '>=0.46.0',
5+
default_options : [
6+
'c_std=c89', 'optimization=2',
7+
'warning_level=2'
8+
]
9+
)
10+
11+
parson_sources = ['parson.c']
12+
13+
parson_inc = include_directories('.')
14+
15+
parson_lib = library(
16+
meson.project_name(),
17+
sources: parson_sources,
18+
install: true
19+
)
20+
21+
install_headers('parson.h')
22+
23+
parson = declare_dependency(
24+
include_directories : parson_inc,
25+
link_with : parson_lib
26+
)
27+
28+
pkgconfig = import('pkgconfig')
29+
30+
# will create a pkg config
31+
pkgconfig.generate(parson_lib,
32+
version: meson.project_version(),
33+
filebase: meson.project_name(),
34+
name: meson.project_name(),
35+
description: 'Lightweight JSON library written in C.',
36+
)

src/bin/lib/parson/package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "parson",
3+
"version": "1.5.3",
4+
"repo": "kgabis/parson",
5+
"description": "Small json parser and reader",
6+
"keywords": [ "json", "parser" ],
7+
"license": "MIT",
8+
"src": [
9+
"parson.c",
10+
"parson.h"
11+
]
12+
}

0 commit comments

Comments
 (0)