summaryrefslogtreecommitdiffstats
path: root/33.patch
blob: 28a7491023850a4c94c0611e08df7e342ccb2bd1 (plain)
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
From b71a5226c19caba947c99500385023fd043f6999 Mon Sep 17 00:00:00 2001
From: Michael Wallner <mike@php.net>
Date: Tue, 18 Jun 2019 12:02:30 +0200
Subject: [PATCH] fix issue #19: Failed test with PgSQL < 9.3

---
 src/php_pqres.c | 102 ++++++++++++++++++++++++++++--------------------
 1 file changed, 60 insertions(+), 42 deletions(-)

diff --git a/src/php_pqres.c b/src/php_pqres.c
index 849f8bf..3427b38 100644
--- a/src/php_pqres.c
+++ b/src/php_pqres.c
@@ -491,65 +491,83 @@ static void php_pqres_object_read_error_message(zval *object, void *o, zval *ret
 	}
 }
 
-static void php_pqres_object_read_diag(zval *object, void *o, zval *return_value)
-{
-	php_pqres_object_t *obj = o;
-	int i;
-	struct {
-		char code;
-		const char *const name;
-	} diag[] = {
-#ifdef PG_DIAG_SEVERITY
-			{PG_DIAG_SEVERITY,			"severity"},
+#ifndef PG_DIAG_SEVERITY
+# define PG_DIAG_SEVERITY 'S'
 #endif
-#ifdef PG_DIAG_SQLSTATE
-			{PG_DIAG_SQLSTATE,			"sqlstate"},
+#ifndef PG_DIAG_SQLSTATE
+# define PG_DIAG_SQLSTATE 'C'
 #endif
-#ifdef PG_DIAG_MESSAGE_PRIMARY
-			{PG_DIAG_MESSAGE_PRIMARY,	"message_primary"},
+#ifndef PG_DIAG_MESSAGE_PRIMARY
+# define PG_DIAG_MESSAGE_PRIMARY 'M'
 #endif
-#ifdef PG_DIAG_MESSAGE_DETAIL
-			{PG_DIAG_MESSAGE_DETAIL,	"message_detail"},
+#ifndef PG_DIAG_MESSAGE_DETAIL
+# define PG_DIAG_MESSAGE_DETAIL 'D'
 #endif
-#ifdef PG_DIAG_MESSAGE_HINT
-			{PG_DIAG_MESSAGE_HINT,		"message_hint"},
+#ifndef PG_DIAG_MESSAGE_HINT
+# define PG_DIAG_MESSAGE_HINT 'H'
 #endif
-#ifdef PG_DIAG_STATEMENT_POSITION
-			{PG_DIAG_STATEMENT_POSITION,"statement_position"},
+#ifndef PG_DIAG_STATEMENT_POSITION
+# define PG_DIAG_STATEMENT_POSITION 'P'
 #endif
-#ifdef PG_DIAG_INTERNAL_POSITION
-			{PG_DIAG_INTERNAL_POSITION,	"internal_position"},
+#ifndef PG_DIAG_INTERNAL_POSITION
+# define PG_DIAG_INTERNAL_POSITION 'p'
 #endif
-#ifdef PG_DIAG_INTERNAL_QUERY
-			{PG_DIAG_INTERNAL_QUERY,	"internal_query"},
+#ifndef PG_DIAG_INTERNAL_QUERY
+# define PG_DIAG_INTERNAL_QUERY 'q'
 #endif
-#ifdef PG_DIAG_CONTEXT
-			{PG_DIAG_CONTEXT,			"context"},
+#ifndef PG_DIAG_CONTEXT
+# define PG_DIAG_CONTEXT 'W'
 #endif
-#ifdef PG_DIAG_SCHEMA_NAME
-			{PG_DIAG_SCHEMA_NAME,		"schema_name"},
+#ifndef PG_DIAG_SCHEMA_NAME
+# define PG_DIAG_SCHEMA_NAME 's'
 #endif
-#ifdef PG_DIAG_TABLE_NAME
-			{PG_DIAG_TABLE_NAME,		"table_name"},
+#ifndef PG_DIAG_TABLE_NAME
+# define PG_DIAG_TABLE_NAME 't'
 #endif
-#ifdef PG_DIAG_COLUMN_NAME
-			{PG_DIAG_COLUMN_NAME,		"column_name"},
+#ifndef PG_DIAG_COLUMN_NAME
+# define PG_DIAG_COLUMN_NAME 'c'
 #endif
-#ifdef PG_DIAG_DATATYPE_NAME
-			{PG_DIAG_DATATYPE_NAME,		"datatype_name"},
+#ifndef PG_DIAG_DATATYPE_NAME
+# define PG_DIAG_DATATYPE_NAME 'd'
 #endif
-#ifdef PG_DIAG_CONSTRAINT_NAME
-			{PG_DIAG_CONSTRAINT_NAME,	"constraint_name"},
+#ifndef PG_DIAG_CONSTRAINT_NAME
+# define PG_DIAG_CONSTRAINT_NAME 'n'
 #endif
-#ifdef PG_DIAG_SOURCE_FILE
-			{PG_DIAG_SOURCE_FILE,		"source_file"},
+#ifndef PG_DIAG_SOURCE_FILE
+# define PG_DIAG_SOURCE_FILE 'F'
 #endif
-#ifdef PG_DIAG_SOURCE_LINE
-			{PG_DIAG_SOURCE_LINE,		"source_line"},
+#ifndef PG_DIAG_SOURCE_LINE
+# define PG_DIAG_SOURCE_LINE 'L'
 #endif
-#ifdef PG_DIAG_SOURCE_FUNCTION
-			{PG_DIAG_SOURCE_FUNCTION,	"source_function"},
+#ifndef PG_DIAG_SOURCE_FUNCTION
+# define PG_DIAG_SOURCE_FUNCTION 'R'
 #endif
+
+static void php_pqres_object_read_diag(zval *object, void *o, zval *return_value)
+{
+	php_pqres_object_t *obj = o;
+	int i;
+	struct {
+		char code;
+		const char *const name;
+	} diag[] = {
+		{PG_DIAG_SEVERITY,			"severity"},
+		{PG_DIAG_SQLSTATE,			"sqlstate"},
+		{PG_DIAG_MESSAGE_PRIMARY,	"message_primary"},
+		{PG_DIAG_MESSAGE_DETAIL,	"message_detail"},
+		{PG_DIAG_MESSAGE_HINT,		"message_hint"},
+		{PG_DIAG_STATEMENT_POSITION,"statement_position"},
+		{PG_DIAG_INTERNAL_POSITION,	"internal_position"},
+		{PG_DIAG_INTERNAL_QUERY,	"internal_query"},
+		{PG_DIAG_CONTEXT,			"context"},
+		{PG_DIAG_SCHEMA_NAME,		"schema_name"},
+		{PG_DIAG_TABLE_NAME,		"table_name"},
+		{PG_DIAG_COLUMN_NAME,		"column_name"},
+		{PG_DIAG_DATATYPE_NAME,		"datatype_name"},
+		{PG_DIAG_CONSTRAINT_NAME,	"constraint_name"},
+		{PG_DIAG_SOURCE_FILE,		"source_file"},
+		{PG_DIAG_SOURCE_LINE,		"source_line"},
+		{PG_DIAG_SOURCE_FUNCTION,	"source_function"},
 	};
 
 	array_init_size(return_value, 32);