{"id":303874,"date":"2020-05-19T15:00:55","date_gmt":"2020-05-19T15:00:55","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=303874"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=303874","title":{"rendered":"\u0420\u0435\u0446\u0435\u043f\u0442\u044b PostgreSQL: \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0437\u0430 \u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/502680\/\">\u0414\u043b\u044f \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0437\u0430 \u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f <a href=\"https:\/\/www.postgresql.org\" rel=\"nofollow\">postgres<\/a>. \u041c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <a href=\"https:\/\/hub.docker.com\/r\/rekgrpth\/repmgr\" rel=\"nofollow\">\u0433\u043e\u0442\u043e\u0432\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c<\/a>.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0421\u0440\u0430\u0437\u0443 \u0441\u043f\u0435\u0448\u0443 \u043e\u0433\u043e\u0440\u0447\u0438\u0442\u044c: \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043d\u0430 SQL! \u0425\u043e\u0442\u044f, \u043a\u043e\u043d\u0447\u0435\u043d\u043e, \u0438 \u0442\u0430\u043c \u0435\u0441\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041d\u043e \u043c\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0438 \u043d\u0435\u043a\u0440\u0430\u0441\u0438\u0432\u044b\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u043a\u043e\u0434, \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u044f \u0432\u0441\u0451 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u043d\u0430\u2026 C! \u041f\u0440\u0430\u0432\u0434\u0430, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0435 \u043a\u0430\u043a \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435, \u0430 \u043a\u0430\u043a \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432.<\/p>\n<p>  \u0412\u043e\u0442, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0441\u0430\u043c \u043f\u0430\u0442\u0447 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u043a \u0438\u043c\u0435\u043d\u0430\u043c (\u0434\u043b\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0432\u0435\u0440\u0441\u0438\u0439 2 \u0438 3), \u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438 <\/p>\n<pre><code class=\"diff\">diff --git a\/src\/backend\/access\/common\/printtup.c b\/src\/backend\/access\/common\/printtup.c index 24d6cd0249..6862b69258 100644 --- a\/src\/backend\/access\/common\/printtup.c +++ b\/src\/backend\/access\/common\/printtup.c @@ -22,6 +22,9 @@  #include &quot;utils\/lsyscache.h&quot;  #include &quot;utils\/memdebug.h&quot;  #include &quot;utils\/memutils.h&quot; +#include &quot;utils\/guc.h&quot;        \/\/ \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c +#include &quot;utils\/syscache.h&quot;   \/\/ \u043d\u0443\u0436\u043d\u044b\u0435 +#include &quot;catalog\/pg_type.h&quot;  \/\/ \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438      static void printtup_startup(DestReceiver *self, int operation, @@ -70,6 +73,8 @@ typedef struct  \tMemoryContext tmpcontext;\t\/* Memory context for per-row workspace *\/  } DR_printtup;   +static bool append; \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0438\u043f\u044b \u043a \u0438\u043c\u0435\u043d\u0430\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a? +  \/* ----------------   *\t\tInitialize: create a DestReceiver for printtup   * ---------------- @@ -132,6 +137,7 @@ printtup_startup(DestReceiver *self, int operation, TupleDesc typeinfo)  {  \tDR_printtup *myState = (DR_printtup *) self;  \tPortal\t\tportal = myState-&gt;portal; +\tappend = GetConfigOption(&quot;config.append_type_to_column_name&quot;, true, true) != NULL; \/\/ \u0445\u043e\u0447\u0435\u0442 \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0431\u0430\u0437\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0438\u043f\u044b \u043a \u0438\u043c\u0435\u043d\u0430\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a?    \t\/*  \t * Create I\/O buffer to be used for all messages.  This cannot be inside @@ -236,6 +242,7 @@ SendRowDescriptionCols_3(StringInfo buf, TupleDesc typeinfo, List *targetlist, i  \t * character set overhead.  \t *\/  \tenlargeStringInfo(buf, (NAMEDATALEN * MAX_CONVERSION_GROWTH \/* attname *\/ +\t\t\t\t\t\t\t+ (append ? NAMEDATALEN * MAX_CONVERSION_GROWTH + sizeof(&quot;::&quot;) - 1 : 0) \/\/ \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0438\u043f\u044b \u043a \u0438\u043c\u0435\u043d\u0430\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0449\u0451 \u043c\u0435\u0441\u0442\u0430 \u0434\u043b\u044f \u0438\u0445 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f  \t\t\t\t\t\t\t+ sizeof(Oid)\t\/* resorigtbl *\/  \t\t\t\t\t\t\t+ sizeof(AttrNumber)\t\/* resorigcol *\/  \t\t\t\t\t\t\t+ sizeof(Oid)\t\/* atttypid *\/ @@ -283,6 +290,17 @@ SendRowDescriptionCols_3(StringInfo buf, TupleDesc typeinfo, List *targetlist, i  \t\telse  \t\t\tformat = 0;   +\t\tif (append) { \/\/ \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0438\u043f\u044b \u043a \u0438\u043c\u0435\u043d\u0430\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u0442\u043e +\t\t\tHeapTuple typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(att-&gt;atttypid)); \/\/ \u043f\u043e\u0438\u0449\u0435\u043c \u0442\u0438\u043f \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0432 \u043a\u044d\u0448\u0435 +\t\t\tStringInfoData buf_; \/\/ \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0431\u0443\u0444\u0435\u0440 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f +\t\t\tinitStringInfo(&amp;buf_); \/\/ \u0438\u043d\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e +\t\t\tappendStringInfo(&amp;buf_, &quot;%s::&quot;, NameStr(att-&gt;attname)); \/\/ \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u0432 \u0431\u0443\u0444\u0435\u0440 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438, \u043f\u043e\u0442\u043e\u043c \u0434\u0432\u0430 \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u044f +\t\t\tif (HeapTupleIsValid(typeTuple)) appendStringInfoString(&amp;buf_, NameStr(((Form_pg_type) GETSTRUCT(typeTuple))-&gt;typname)); \/\/ \u0435\u0441\u043b\u0438 \u043d\u0430\u0448\u043b\u0438 \u0442\u0438\u043f \u043a\u043e\u043b\u043e\u043d\u043a\u0438, \u0442\u043e \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u0435\u0433\u043e \u0432 \u0431\u0443\u0444\u0435\u0440 +\t\t\telse appendStringInfo(&amp;buf_, &quot;%i&quot;, att-&gt;atttypid); \/\/ \u0438\u043d\u0430\u0447\u0435 \u0432 \u0431\u0443\u0444\u0435\u0440 \u0437\u0430\u043f\u0438\u0448\u0435\u043c oid +\t\t\tpq_writestring(buf, buf_.data); \/\/ \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0443 +\t\t\tReleaseSysCache(typeTuple); \/\/ \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c \u043a\u044d\u0448 +\t\t\tpfree(buf_.data); \/\/ \u043e\u0447\u0438\u0441\u0442\u0438\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0431\u0443\u0444\u0435\u0440 +\t\t} else \/\/ \u043d\u0443 \u0430 \u0435\u0441\u043b\u0438 \u043d\u0435 \u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0438\u043f\u044b \u043a \u0438\u043c\u0435\u043d\u0430\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u0442\u043e \u0432\u0441\u0451 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043f\u043e-\u0441\u0442\u0430\u0440\u043e\u043c\u0443  \t\tpq_writestring(buf, NameStr(att-&gt;attname));  \t\tpq_writeint32(buf, resorigtbl);  \t\tpq_writeint16(buf, resorigcol); @@ -311,6 +329,17 @@ SendRowDescriptionCols_2(StringInfo buf, TupleDesc typeinfo, List *targetlist, i  \t\t\/* If column is a domain, send the base type and typmod instead *\/  \t\tatttypid = getBaseTypeAndTypmod(atttypid, &amp;atttypmod);   +\t\tif (append) { \/\/ \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0438\u043f\u044b \u043a \u0438\u043c\u0435\u043d\u0430\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u0442\u043e +\t\t\tHeapTuple typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(att-&gt;atttypid)); \/\/ \u043f\u043e\u0438\u0449\u0435\u043c \u0442\u0438\u043f \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0432 \u043a\u044d\u0448\u0435 +\t\t\tStringInfoData buf_; \/\/ \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0431\u0443\u0444\u0435\u0440 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f +\t\t\tinitStringInfo(&amp;buf_); \/\/ \u0438\u043d\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e +\t\t\tappendStringInfo(&amp;buf_, &quot;%s::&quot;, NameStr(att-&gt;attname)); \/\/ \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u0432 \u0431\u0443\u0444\u0435\u0440 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438, \u043f\u043e\u0442\u043e\u043c \u0434\u0432\u0430 \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u044f +\t\t\tif (HeapTupleIsValid(typeTuple)) appendStringInfoString(&amp;buf_, NameStr(((Form_pg_type) GETSTRUCT(typeTuple))-&gt;typname)); \/\/ \u0435\u0441\u043b\u0438 \u043d\u0430\u0448\u043b\u0438 \u0442\u0438\u043f \u043a\u043e\u043b\u043e\u043d\u043a\u0438, \u0442\u043e \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u0435\u0433\u043e \u0432 \u0431\u0443\u0444\u0435\u0440 +\t\t\telse appendStringInfo(&amp;buf_, &quot;%i&quot;, att-&gt;atttypid); \/\/ \u0438\u043d\u0430\u0447\u0435 \u0432 \u0431\u0443\u0444\u0435\u0440 \u0437\u0430\u043f\u0438\u0448\u0435\u043c oid +\t\t\tpq_sendstring(buf, buf_.data); \/\/ \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0443 +\t\t\tReleaseSysCache(typeTuple); \/\/ \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c \u043a\u044d\u0448 +\t\t\tpfree(buf_.data); \/\/ \u043e\u0447\u0438\u0441\u0442\u0438\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0431\u0443\u0444\u0435\u0440 +\t\t} else \/\/ \u043d\u0443 \u0430 \u0435\u0441\u043b\u0438 \u043d\u0435 \u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0438\u043f\u044b \u043a \u0438\u043c\u0435\u043d\u0430\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u0442\u043e \u0432\u0441\u0451 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043f\u043e-\u0441\u0442\u0430\u0440\u043e\u043c\u0443  \t\tpq_sendstring(buf, NameStr(att-&gt;attname));  \t\t\/* column ID only info appears in protocol 3.0 and up *\/  \t\tpq_sendint32(buf, atttypid); diff --git a\/src\/backend\/tcop\/postgres.c b\/src\/backend\/tcop\/postgres.c index 6c2db93573..f23de7f788 100644 --- a\/src\/backend\/tcop\/postgres.c +++ b\/src\/backend\/tcop\/postgres.c @@ -992,6 +992,8 @@ exec_simple_query(const char *query_string)  \tbool\t\tuse_implicit_block;  \tchar\t\tmsec_str[32];   +\tSetConfigOption(&quot;config.append_type_to_column_name&quot;, NULL, PGC_USERSET, PGC_S_SESSION); \/\/ \u043f\u0435\u0440\u0435\u0434 \u043a\u0430\u0436\u0434\u044b\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c SQL-\u043a\u043e\u0434\u0430 \u0437\u0430\u043d\u0443\u043b\u044f\u0435\u043c \u043d\u0430\u0448\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0433 \u0441\u0430\u043c \u0440\u0435\u0448\u0438\u0442\u044c, \u043d\u0443\u0436\u043d\u044b \u043b\u0438 \u0435\u043c\u0443 \u0442\u0438\u043f\u044b \u043a\u043e\u043b\u043e\u043d\u043e\u043a +  \t\/*  \t * Report query to various monitoring facilities.  \t *\/ @@ -1959,6 +1961,8 @@ exec_execute_message(const char *portal_name, long max_rows)  \tbool\t\twas_logged = false;  \tchar\t\tmsec_str[32];   +\tSetConfigOption(&quot;config.append_type_to_column_name&quot;, NULL, PGC_USERSET, PGC_S_SESSION); \/\/ \u043f\u0435\u0440\u0435\u0434 \u043a\u0430\u0436\u0434\u044b\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e SQL-\u043a\u043e\u0434\u0430 \u0437\u0430\u043d\u0443\u043b\u044f\u0435\u043c \u043d\u0430\u0448\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0433 \u0441\u0430\u043c \u0440\u0435\u0448\u0438\u0442\u044c, \u043d\u0443\u0436\u043d\u044b \u043b\u0438 \u0435\u043c\u0443 \u0442\u0438\u043f\u044b \u043a\u043e\u043b\u043e\u043d\u043e\u043a +  \t\/* Adjust destination to tell printtup.c what to do *\/  \tdest = whereToSendOutput;  \tif (dest == DestRemote)<\/code><\/pre>\n<p>  \u041d\u0443 \u0438 \u0431\u043e\u043d\u0443\u0441\u043e\u043c, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u043f\u0430\u0442\u0447 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u043a \u0438\u043c\u0435\u043d\u0430\u043c \u043f\u0440\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u0445 \u0432 json<\/p>\n<pre><code class=\"diff\">diff --git a\/src\/backend\/utils\/adt\/json.c b\/src\/backend\/utils\/adt\/json.c index 26d293709a..fb025adf58 100644 --- a\/src\/backend\/utils\/adt\/json.c +++ b\/src\/backend\/utils\/adt\/json.c @@ -32,6 +32,7 @@  #include &quot;utils\/jsonapi.h&quot;  #include &quot;utils\/typcache.h&quot;  #include &quot;utils\/syscache.h&quot; +#include &quot;utils\/guc.h&quot; \/\/ \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a    \/*   * The context of the parser is maintained by the recursive descent @@ -106,6 +107,8 @@ static void add_json(Datum val, bool is_null, StringInfo result,  \t\t\t\t\t Oid val_type, bool key_scalar);  static text *catenate_stringinfo_string(StringInfo buffer, const char *addon);   +static bool append; \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0438\u043f\u044b \u043a \u0438\u043c\u0435\u043d\u0430\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a? +  \/* the null action object used for pure validation *\/  static JsonSemAction nullSemAction =  { @@ -1789,6 +1792,17 @@ composite_to_json(Datum composite, StringInfo result, bool use_line_feeds)  \t\tneedsep = true;    \t\tattname = NameStr(att-&gt;attname); +\t\tif (append) { \/\/ \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0438\u043f\u044b \u043a \u0438\u043c\u0435\u043d\u0430\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u0442\u043e +\t\t\tHeapTuple typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(att-&gt;atttypid)); \/\/ \u043f\u043e\u0438\u0449\u0435\u043c \u0442\u0438\u043f \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0432 \u043a\u044d\u0448\u0435 +\t\t\tStringInfoData buf; \/\/ \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0431\u0443\u0444\u0435\u0440 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f +\t\t\tinitStringInfo(&amp;buf); \/\/ \u0438\u043d\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e +\t\t\tappendStringInfo(&amp;buf, &quot;%s::&quot;, attname); \/\/ \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u0432 \u0431\u0443\u0444\u0435\u0440 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438, \u043f\u043e\u0442\u043e\u043c \u0434\u0432\u0430 \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u044f +\t\t\tif (HeapTupleIsValid(typeTuple)) appendStringInfoString(&amp;buf, NameStr(((Form_pg_type) GETSTRUCT(typeTuple))-&gt;typname)); \/\/ \u0435\u0441\u043b\u0438 \u043d\u0430\u0448\u043b\u0438 \u0442\u0438\u043f \u043a\u043e\u043b\u043e\u043d\u043a\u0438, \u0442\u043e \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u0435\u0433\u043e \u0432 \u0431\u0443\u0444\u0435\u0440 +\t\t\telse appendStringInfo(&amp;buf, &quot;%i&quot;, att-&gt;atttypid); \/\/ \u0438\u043d\u0430\u0447\u0435 \u0432 \u0431\u0443\u0444\u0435\u0440 \u0437\u0430\u043f\u0438\u0448\u0435\u043c oid +\t\t\tescape_json(result, buf.data); \/\/ \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 +\t\t\tReleaseSysCache(typeTuple); \/\/ \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c \u043a\u044d\u0448 +\t\t\tpfree(buf.data); \/\/ \u043e\u0447\u0438\u0441\u0442\u0438\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0431\u0443\u0444\u0435\u0440 +\t\t} else \/\/ \u043d\u0443 \u0430 \u0435\u0441\u043b\u0438 \u043d\u0435 \u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0438\u043f\u044b \u043a \u0438\u043c\u0435\u043d\u0430\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u0442\u043e \u0432\u0441\u0451 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043f\u043e-\u0441\u0442\u0430\u0440\u043e\u043c\u0443  \t\tescape_json(result, attname);  \t\tappendStringInfoChar(result, ':');   @@ -1848,6 +1862,7 @@ array_to_json(PG_FUNCTION_ARGS)  {  \tDatum\t\tarray = PG_GETARG_DATUM(0);  \tStringInfo\tresult; +\tappend = GetConfigOption(&quot;config.append_type_to_column_name&quot;, true, true) != NULL; \/\/ \u0445\u043e\u0447\u0435\u0442 \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0431\u0430\u0437\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0438\u043f\u044b \u043a \u0438\u043c\u0435\u043d\u0430\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a?    \tresult = makeStringInfo();   @@ -1865,6 +1880,7 @@ array_to_json_pretty(PG_FUNCTION_ARGS)  \tDatum\t\tarray = PG_GETARG_DATUM(0);  \tbool\t\tuse_line_feeds = PG_GETARG_BOOL(1);  \tStringInfo\tresult; +\tappend = GetConfigOption(&quot;config.append_type_to_column_name&quot;, true, true) != NULL; \/\/ \u0445\u043e\u0447\u0435\u0442 \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0431\u0430\u0437\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0438\u043f\u044b \u043a \u0438\u043c\u0435\u043d\u0430\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a?    \tresult = makeStringInfo();   @@ -1881,6 +1897,7 @@ row_to_json(PG_FUNCTION_ARGS)  {  \tDatum\t\tarray = PG_GETARG_DATUM(0);  \tStringInfo\tresult; +\tappend = GetConfigOption(&quot;config.append_type_to_column_name&quot;, true, true) != NULL; \/\/ \u0445\u043e\u0447\u0435\u0442 \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0431\u0430\u0437\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0438\u043f\u044b \u043a \u0438\u043c\u0435\u043d\u0430\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a?    \tresult = makeStringInfo();   @@ -1898,6 +1915,7 @@ row_to_json_pretty(PG_FUNCTION_ARGS)  \tDatum\t\tarray = PG_GETARG_DATUM(0);  \tbool\t\tuse_line_feeds = PG_GETARG_BOOL(1);  \tStringInfo\tresult; +\tappend = GetConfigOption(&quot;config.append_type_to_column_name&quot;, true, true) != NULL; \/\/ \u0445\u043e\u0447\u0435\u0442 \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0431\u0430\u0437\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0438\u043f\u044b \u043a \u0438\u043c\u0435\u043d\u0430\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a?    \tresult = makeStringInfo();   @@ -1917,6 +1935,7 @@ to_json(PG_FUNCTION_ARGS)  \tStringInfo\tresult;  \tJsonTypeCategory tcategory;  \tOid\t\t\toutfuncoid; +\tappend = GetConfigOption(&quot;config.append_type_to_column_name&quot;, true, true) != NULL; \/\/ \u0445\u043e\u0447\u0435\u0442 \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0431\u0430\u0437\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0438\u043f\u044b \u043a \u0438\u043c\u0435\u043d\u0430\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a?    \tif (val_type == InvalidOid)  \t\tereport(ERROR, @@ -1945,6 +1964,7 @@ json_agg_transfn(PG_FUNCTION_ARGS)  \t\t\t\toldcontext;  \tJsonAggState *state;  \tDatum\t\tval; +\tappend = GetConfigOption(&quot;config.append_type_to_column_name&quot;, true, true) != NULL; \/\/ \u0445\u043e\u0447\u0435\u0442 \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0431\u0430\u0437\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0438\u043f\u044b \u043a \u0438\u043c\u0435\u043d\u0430\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a?    \tif (!AggCheckCallContext(fcinfo, &amp;aggcontext))  \t{ @@ -2046,6 +2066,7 @@ json_object_agg_transfn(PG_FUNCTION_ARGS)  \t\t\t\toldcontext;  \tJsonAggState *state;  \tDatum\t\targ; +\tappend = GetConfigOption(&quot;config.append_type_to_column_name&quot;, true, true) != NULL; \/\/ \u0445\u043e\u0447\u0435\u0442 \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0431\u0430\u0437\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0438\u043f\u044b \u043a \u0438\u043c\u0435\u043d\u0430\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a?    \tif (!AggCheckCallContext(fcinfo, &amp;aggcontext))  \t{ <\/code><\/pre>\n<p>  \u041d\u0443 \u0438 \u0437\u0430\u0447\u0435\u043c \u044f \u0432\u0441\u0451 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043b?! <s>\u041f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043c\u043e\u0433\u0443<\/s> \u0445\u043e\u0442\u044f, \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e, \u0435\u0441\u0442\u044c \u0443 \u043c\u0435\u043d\u044f \u043e\u0434\u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0438\u0434\u0435\u044f, \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u043e \u043f\u043e\u043a\u0430 \u0440\u0443\u043a\u0438 \u043d\u0435 \u0434\u043e\u0448\u043b\u0438\u2026<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/502680\/\"> https:\/\/habr.com\/ru\/post\/502680\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/502680\/\">\u0414\u043b\u044f \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0437\u0430 \u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f <a href=\"https:\/\/www.postgresql.org\" rel=\"nofollow\">postgres<\/a>. \u041c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <a href=\"https:\/\/hub.docker.com\/r\/rekgrpth\/repmgr\" rel=\"nofollow\">\u0433\u043e\u0442\u043e\u0432\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c<\/a>.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-303874","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/303874","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=303874"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/303874\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=303874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=303874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=303874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}