Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
3 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# Copyright (c) 2022-2026, PostgreSQL Global Development Group
 
common_sources = files(
  'archive.c',
  'base64.c',
  'binaryheap.c',
  'blkreftable.c',
  'checksum_helper.c',
  'compression.c',
  'controldata_utils.c',
  'encnames.c',
  'exec.c',
  'file_perm.c',
  'file_utils.c',
  'hashfn.c',
  'instr_time.c',
  'ip.c',
  'jsonapi.c',
  'keywords.c',
  'kwlookup.c',
  'link-canary.c',
  'md5_common.c',
  'parse_manifest.c',
  'percentrepl.c',
  'pg_get_line.c',
  'pg_lzcompress.c',
  'pg_prng.c',
  'pgfnames.c',
  'psprintf.c',
  'relpath.c',
  'rmtree.c',
  'saslprep.c',
  'scram-common.c',
  'string.c',
  'stringinfo.c',
  'unicode_case.c',
  'unicode_category.c',
  'unicode_norm.c',
  'username.c',
  'wait_error.c',
  'wchar.c',
)
 
# [PG_CUSTOM: CFS] Frontend-safe CFS on-disk format lexicon: compiled
# unconditionally in every build (frontend tools built without CFS use it to
# recognize and refuse/skip the sidecar files); carries no feature logic.
common_sources += files(
  'cfs_filename.c',
)
 
if ssl.found()
  common_sources += files(
    'cryptohash_openssl.c',
    'hmac_openssl.c',
  )
else
  common_sources += files(
    'cryptohash.c',
    'hmac.c',
    'md5.c',
    'sha1.c',
    'sha2.c',
  )
endif
 
common_kwlist = custom_target('kwlist',
  input: files('../include/parser/kwlist.h'),
  output: 'kwlist_d.h',
  depend_files: gen_kwlist_deps,
  command: [gen_kwlist_cmd, '--extern'])
generated_sources += common_kwlist
common_sources += common_kwlist
 
# The code imported from Ryu gets a pass on declaration-after-statement,
# in order to keep it more closely aligned with its upstream.
ryu_sources = files(
  'd2s.c',
  'f2s.c',
)
ryu_cflags = []
 
ryu_cflags += cflags_no_decl_after_statement
 
config_info_sources = files('config_info.c',)
config_info_cflags = [
  '-DVAL_CC="@0@"'.format(var_cc),
  '-DVAL_CPPFLAGS="@0@"'.format(var_cppflags),
  '-DVAL_CFLAGS="@0@"'.format(var_cflags),
  '-DVAL_CFLAGS_SL="@0@"'.format(var_cflags_sl),
  '-DVAL_LDFLAGS="@0@"'.format(var_ldflags),
  '-DVAL_LDFLAGS_EX="@0@"'.format(var_ldflags_ex),
  '-DVAL_LDFLAGS_SL="@0@"'.format(var_ldflags_sl),
  '-DVAL_LIBS="@0@"'.format(var_libs),
]
 
# Some files need to be built with different cflags. The different sets are
# defined here.
common_cflags = {
  'ryu': ryu_cflags,
  'config_info': config_info_cflags,
}
common_sources_cflags = {
  'ryu': ryu_sources,
  'config_info': config_info_sources
}
 
 
# A few files are currently only built for frontend, not server.
# logging.c is excluded from OBJS_FRONTEND_SHLIB (shared library) as
# a matter of policy, because it is not appropriate for general purpose
# libraries such as libpq to report errors directly.  fe_memutils.c is
# excluded because libpq must not exit() on allocation failure.
#
# The excluded files for _shlib builds are pulled into their own static
# library, for the benefit of test programs that need not follow the
# shlib rules.
 
common_sources_frontend_shlib = common_sources
common_sources_frontend_shlib += files(
  'restricted_token.c',
  'sprompt.c',
)
 
common_sources_excluded_shlib = files(
  'fe_memutils.c',
  'logging.c',
)
 
common_sources_frontend_static = [
  common_sources_frontend_shlib,
  common_sources_excluded_shlib,
]
 
# Build pgcommon once for backend, once for use in frontend binaries, and
# once for use in shared libraries
#
# XXX: in most environments we could probably link_whole pgcommon_shlib
# against pgcommon_static, instead of compiling twice.
#
# For the server build of pgcommon, depend on lwlocknames_h and because at
# least cryptohash_openssl.c, hmac_openssl.c depend on it.
# controldata_utils.c depends on wait_event_types_h. That's arguably a
# layering violation, but ...
pgcommon = {}
pgcommon_variants = {
  '_srv': internal_lib_args + {
    'sources': common_sources + [lwlocknames_h] + [wait_event_types_h],
    'dependencies': [backend_common_code],
  },
  '': default_lib_args + {
    'sources': common_sources_frontend_static,
    'dependencies': [frontend_common_code],
    # Files in libpgcommon.a should use/export the "xxx_private" versions
    # of pg_char_to_encoding() and friends.
    'c_args': ['-DUSE_PRIVATE_ENCODING_FUNCS'],
  },
  '_shlib': default_lib_args + {
    'pic': true,
    'sources': common_sources_frontend_shlib,
    'dependencies': [frontend_common_code],
    # The JSON API normally exits on out-of-memory; disable that behavior for
    # shared library builds. This requires libpq's pqexpbuffer.h.
    'c_args': ['-DJSONAPI_USE_PQEXPBUFFER'],
    'include_directories': include_directories('../interfaces/libpq'),
  },
}
 
foreach name, opts : pgcommon_variants
 
  # Build internal static libraries for sets of files that need to be built
  # with different cflags
  cflag_libs = []
  foreach cflagname, sources : common_sources_cflags
    if sources.length() == 0
      continue
    endif
    c_args = opts.get('c_args', []) + common_cflags[cflagname]
    cflag_libs += static_library('libpgcommon@0@_@1@'.format(name, cflagname),
      c_pch: pch_c_h,
      kwargs: opts + {
        'include_directories': [
          include_directories('.'),
          opts.get('include_directories', []),
        ],
        'sources': sources,
        'c_args': c_args,
        'build_by_default': false,
        'install': false,
      },
    )
  endforeach
 
  lib = static_library('libpgcommon@0@'.format(name),
      link_with: cflag_libs,
      link_whole: cflag_libs,
      c_pch: pch_c_h,
      kwargs: opts + {
        'include_directories': [
          include_directories('.'),
          opts.get('include_directories', []),
        ],
        'dependencies': opts['dependencies'] + [ssl],
        'install': install_internal_static_lib and name != '_srv',
      }
    )
  pgcommon += {name: lib}
endforeach
 
common_srv = pgcommon['_srv']
common_shlib = pgcommon['_shlib']
common_static = pgcommon['']
 
common_excluded_shlib = static_library('libpgcommon_excluded_shlib',
  sources: common_sources_excluded_shlib,
  dependencies: [frontend_common_code],
  build_by_default: false,
  kwargs: default_lib_args + {
    'install': false,
  },
)
 
subdir('unicode')