Skip to content

Commit b4967a7

Browse files
committed
Merge branch 'REL9_5_STABLE' into PGPRO9_5
First merge in 9.5.2.2 development cycle
2 parents eed9b3a + ec91ee8 commit b4967a7

File tree

7 files changed

+83
-49
lines changed

7 files changed

+83
-49
lines changed

doc/src/sgml/ref/alter_index.sgml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,6 @@ ALTER INDEX ALL IN TABLESPACE <replaceable class="PARAMETER">name</replaceable>
3939

4040
<variablelist>
4141

42-
<varlistentry>
43-
<term><literal>IF EXISTS</literal></term>
44-
<listitem>
45-
<para>
46-
Do not throw an error if the index does not exist. A notice is issued
47-
in this case.
48-
</para>
49-
</listitem>
50-
</varlistentry>
51-
5242
<varlistentry>
5343
<term><literal>RENAME</literal></term>
5444
<listitem>
@@ -119,6 +109,16 @@ ALTER INDEX ALL IN TABLESPACE <replaceable class="PARAMETER">name</replaceable>
119109

120110
<variablelist>
121111

112+
<varlistentry>
113+
<term><literal>IF EXISTS</literal></term>
114+
<listitem>
115+
<para>
116+
Do not throw an error if the index does not exist. A notice is issued
117+
in this case.
118+
</para>
119+
</listitem>
120+
</varlistentry>
121+
122122
<varlistentry>
123123
<term><replaceable class="PARAMETER">name</replaceable></term>
124124
<listitem>

src/backend/commands/tablespace.c

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -773,13 +773,26 @@ destroy_tablespace_directories(Oid tablespaceoid, bool redo)
773773
remove_symlink:
774774
linkloc = pstrdup(linkloc_with_version_dir);
775775
get_parent_directory(linkloc);
776-
if (lstat(linkloc, &st) == 0 && S_ISDIR(st.st_mode))
776+
if (lstat(linkloc, &st) < 0)
777+
{
778+
int saved_errno = errno;
779+
780+
ereport(redo ? LOG : (saved_errno == ENOENT ? WARNING : ERROR),
781+
(errcode_for_file_access(),
782+
errmsg("could not stat file \"%s\": %m",
783+
linkloc)));
784+
}
785+
else if (S_ISDIR(st.st_mode))
777786
{
778787
if (rmdir(linkloc) < 0)
779-
ereport(redo ? LOG : ERROR,
788+
{
789+
int saved_errno = errno;
790+
791+
ereport(redo ? LOG : (saved_errno == ENOENT ? WARNING : ERROR),
780792
(errcode_for_file_access(),
781793
errmsg("could not remove directory \"%s\": %m",
782794
linkloc)));
795+
}
783796
}
784797
#ifdef S_ISLNK
785798
else if (S_ISLNK(st.st_mode))
@@ -799,7 +812,7 @@ destroy_tablespace_directories(Oid tablespaceoid, bool redo)
799812
{
800813
/* Refuse to remove anything that's not a directory or symlink */
801814
ereport(redo ? LOG : ERROR,
802-
(ERRCODE_SYSTEM_ERROR,
815+
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
803816
errmsg("\"%s\" is not a directory or symbolic link",
804817
linkloc)));
805818
}
@@ -851,7 +864,7 @@ remove_tablespace_symlink(const char *linkloc)
851864
{
852865
struct stat st;
853866

854-
if (lstat(linkloc, &st) != 0)
867+
if (lstat(linkloc, &st) < 0)
855868
{
856869
if (errno == ENOENT)
857870
return;
@@ -863,10 +876,10 @@ remove_tablespace_symlink(const char *linkloc)
863876
if (S_ISDIR(st.st_mode))
864877
{
865878
/*
866-
* This will fail if the directory isn't empty, but not
867-
* if it's a junction point.
879+
* This will fail if the directory isn't empty, but not if it's a
880+
* junction point.
868881
*/
869-
if (rmdir(linkloc) < 0)
882+
if (rmdir(linkloc) < 0 && errno != ENOENT)
870883
ereport(ERROR,
871884
(errcode_for_file_access(),
872885
errmsg("could not remove directory \"%s\": %m",
@@ -878,15 +891,16 @@ remove_tablespace_symlink(const char *linkloc)
878891
if (unlink(linkloc) < 0 && errno != ENOENT)
879892
ereport(ERROR,
880893
(errcode_for_file_access(),
881-
errmsg("could not remove symbolic link \"%s\": %m",
894+
errmsg("could not remove symbolic link \"%s\": %m",
882895
linkloc)));
883896
}
884897
#endif
885898
else
886899
{
887900
/* Refuse to remove anything that's not a directory or symlink */
888901
ereport(ERROR,
889-
(errmsg("\"%s\" is not a directory or symbolic link",
902+
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
903+
errmsg("\"%s\" is not a directory or symbolic link",
890904
linkloc)));
891905
}
892906
}

src/backend/port/win32/signal.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ HANDLE pgwin32_initial_signal_pipe = INVALID_HANDLE_VALUE;
3333
*/
3434
static CRITICAL_SECTION pg_signal_crit_sec;
3535

36+
/* Note that array elements 0 are unused since they correspond to signal 0 */
3637
static pqsigfunc pg_signal_array[PG_SIGNAL_COUNT];
3738
static pqsigfunc pg_signal_defaults[PG_SIGNAL_COUNT];
3839

@@ -105,15 +106,15 @@ pgwin32_signal_initialize(void)
105106
void
106107
pgwin32_dispatch_queued_signals(void)
107108
{
108-
int i;
109+
int exec_mask;
109110

110111
EnterCriticalSection(&pg_signal_crit_sec);
111-
while (UNBLOCKED_SIGNAL_QUEUE())
112+
while ((exec_mask = UNBLOCKED_SIGNAL_QUEUE()) != 0)
112113
{
113114
/* One or more unblocked signals queued for execution */
114-
int exec_mask = UNBLOCKED_SIGNAL_QUEUE();
115+
int i;
115116

116-
for (i = 0; i < PG_SIGNAL_COUNT; i++)
117+
for (i = 1; i < PG_SIGNAL_COUNT; i++)
117118
{
118119
if (exec_mask & sigmask(i))
119120
{

src/backend/tsearch/wparser_def.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2463,6 +2463,8 @@ mark_hl_words(HeadlineParsedText *prs, TSQuery query, int highlight,
24632463
}
24642464
else
24652465
{ /* shorter cover :((( */
2466+
if (i > q)
2467+
i = q;
24662468
for (; curlen > min_words; i--)
24672469
{
24682470
if (!NONWORDTOKEN(prs->words[i].type))

src/backend/utils/misc/guc.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6857,22 +6857,37 @@ AlterSystemSetConfigFile(AlterSystemStmt *altersysstmt)
68576857
errmsg("parameter \"%s\" cannot be changed",
68586858
name)));
68596859

6860+
/*
6861+
* If a value is specified, verify that it's sane.
6862+
*/
68606863
if (value)
68616864
{
68626865
union config_var_val newval;
68636866
void *newextra = NULL;
68646867

6868+
/* Check that it's acceptable for the indicated parameter */
68656869
if (!parse_and_validate_value(record, name, value,
68666870
PGC_S_FILE, ERROR,
68676871
&newval, &newextra))
68686872
ereport(ERROR,
6869-
(errmsg("invalid value for parameter \"%s\": \"%s\"",
6873+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6874+
errmsg("invalid value for parameter \"%s\": \"%s\"",
68706875
name, value)));
68716876

68726877
if (record->vartype == PGC_STRING && newval.stringval != NULL)
68736878
free(newval.stringval);
68746879
if (newextra)
68756880
free(newextra);
6881+
6882+
/*
6883+
* We must also reject values containing newlines, because the
6884+
* grammar for config files doesn't support embedded newlines in
6885+
* string literals.
6886+
*/
6887+
if (strchr(value, '\n'))
6888+
ereport(ERROR,
6889+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6890+
errmsg("parameter value for ALTER SYSTEM must not contain a newline")));
68766891
}
68776892
}
68786893

@@ -6909,13 +6924,15 @@ AlterSystemSetConfigFile(AlterSystemStmt *altersysstmt)
69096924
infile = AllocateFile(AutoConfFileName, "r");
69106925
if (infile == NULL)
69116926
ereport(ERROR,
6912-
(errmsg("could not open file \"%s\": %m",
6927+
(errcode_for_file_access(),
6928+
errmsg("could not open file \"%s\": %m",
69136929
AutoConfFileName)));
69146930

69156931
/* parse it */
69166932
if (!ParseConfigFp(infile, AutoConfFileName, 0, LOG, &head, &tail))
69176933
ereport(ERROR,
6918-
(errmsg("could not parse contents of file \"%s\"",
6934+
(errcode(ERRCODE_CONFIG_FILE_ERROR),
6935+
errmsg("could not parse contents of file \"%s\"",
69196936
AutoConfFileName)));
69206937

69216938
FreeFile(infile);

src/pl/plpython/plpy_elog.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ PyObject *PLy_exc_fatal = NULL;
2121
PyObject *PLy_exc_spi_error = NULL;
2222

2323

24-
static void PLy_traceback(char **xmsg, char **tbmsg, int *tb_depth);
24+
static void PLy_traceback(PyObject *e, PyObject *v, PyObject *tb,
25+
char **xmsg, char **tbmsg, int *tb_depth);
2526
static void PLy_get_spi_error_data(PyObject *exc, int *sqlerrcode, char **detail,
2627
char **hint, char **query, int *position);
2728
static char *get_source_line(const char *src, int lineno);
@@ -53,16 +54,20 @@ PLy_elog(int elevel, const char *fmt,...)
5354
int position = 0;
5455

5556
PyErr_Fetch(&exc, &val, &tb);
57+
5658
if (exc != NULL)
5759
{
60+
PyErr_NormalizeException(&exc, &val, &tb);
61+
5862
if (PyErr_GivenExceptionMatches(val, PLy_exc_spi_error))
5963
PLy_get_spi_error_data(val, &sqlerrcode, &detail, &hint, &query, &position);
6064
else if (PyErr_GivenExceptionMatches(val, PLy_exc_fatal))
6165
elevel = FATAL;
6266
}
63-
PyErr_Restore(exc, val, tb);
6467

65-
PLy_traceback(&xmsg, &tbmsg, &tb_depth);
68+
/* this releases our refcount on tb! */
69+
PLy_traceback(exc, val, tb,
70+
&xmsg, &tbmsg, &tb_depth);
6671

6772
if (fmt)
6873
{
@@ -113,6 +118,9 @@ PLy_elog(int elevel, const char *fmt,...)
113118
pfree(xmsg);
114119
if (tbmsg)
115120
pfree(tbmsg);
121+
Py_XDECREF(exc);
122+
Py_XDECREF(val);
123+
116124
PG_RE_THROW();
117125
}
118126
PG_END_TRY();
@@ -123,21 +131,24 @@ PLy_elog(int elevel, const char *fmt,...)
123131
pfree(xmsg);
124132
if (tbmsg)
125133
pfree(tbmsg);
134+
Py_XDECREF(exc);
135+
Py_XDECREF(val);
126136
}
127137

128138
/*
129-
* Extract a Python traceback from the current exception.
139+
* Extract a Python traceback from the given exception data.
130140
*
131141
* The exception error message is returned in xmsg, the traceback in
132142
* tbmsg (both as palloc'd strings) and the traceback depth in
133143
* tb_depth.
144+
*
145+
* We release refcounts on all the Python objects in the traceback stack,
146+
* but not on e or v.
134147
*/
135148
static void
136-
PLy_traceback(char **xmsg, char **tbmsg, int *tb_depth)
149+
PLy_traceback(PyObject *e, PyObject *v, PyObject *tb,
150+
char **xmsg, char **tbmsg, int *tb_depth)
137151
{
138-
PyObject *e,
139-
*v,
140-
*tb;
141152
PyObject *e_type_o;
142153
PyObject *e_module_o;
143154
char *e_type_s = NULL;
@@ -148,12 +159,7 @@ PLy_traceback(char **xmsg, char **tbmsg, int *tb_depth)
148159
StringInfoData tbstr;
149160

150161
/*
151-
* get the current exception
152-
*/
153-
PyErr_Fetch(&e, &v, &tb);
154-
155-
/*
156-
* oops, no exception, return
162+
* if no exception, return nulls
157163
*/
158164
if (e == NULL)
159165
{
@@ -164,8 +170,6 @@ PLy_traceback(char **xmsg, char **tbmsg, int *tb_depth)
164170
return;
165171
}
166172

167-
PyErr_NormalizeException(&e, &v, &tb);
168-
169173
/*
170174
* Format the exception and its value and put it in xmsg.
171175
*/
@@ -332,8 +336,6 @@ PLy_traceback(char **xmsg, char **tbmsg, int *tb_depth)
332336
Py_XDECREF(e_type_o);
333337
Py_XDECREF(e_module_o);
334338
Py_XDECREF(vob);
335-
Py_XDECREF(v);
336-
Py_DECREF(e);
337339
}
338340

339341
/*
@@ -367,7 +369,7 @@ PLy_get_spi_sqlerrcode(PyObject *exc, int *sqlerrcode)
367369
static void
368370
PLy_get_spi_error_data(PyObject *exc, int *sqlerrcode, char **detail, char **hint, char **query, int *position)
369371
{
370-
PyObject *spidata = NULL;
372+
PyObject *spidata;
371373

372374
spidata = PyObject_GetAttrString(exc, "spidata");
373375

@@ -384,8 +386,6 @@ PLy_get_spi_error_data(PyObject *exc, int *sqlerrcode, char **detail, char **hin
384386
PLy_get_spi_sqlerrcode(exc, sqlerrcode);
385387
}
386388

387-
PyErr_Clear();
388-
/* no elog here, we simply won't report the errhint, errposition etc */
389389
Py_XDECREF(spidata);
390390
}
391391

src/tools/msvc/build.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ BEGIN
5353
if ($buildwhat and $vcver >= 10.00)
5454
{
5555
system(
56-
"msbuild $buildwhat.vcxproj /verbosity:detailed /p:Configuration=$bconf");
56+
"msbuild $buildwhat.vcxproj /verbosity:normal /p:Configuration=$bconf");
5757
}
5858
elsif ($buildwhat)
5959
{
6060
system("vcbuild $buildwhat.vcproj $bconf");
6161
}
6262
else
6363
{
64-
system("msbuild pgsql.sln /verbosity:detailed /p:Configuration=$bconf");
64+
system("msbuild pgsql.sln /verbosity:normal /p:Configuration=$bconf");
6565
}
6666

6767
# report status

0 commit comments

Comments
 (0)