Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 46d7ae7

Browse files
committed
Add intended Array.java file that accidentally was patched into the
wrong directory.
1 parent d39ec83 commit 46d7ae7

File tree

2 files changed

+57
-59
lines changed

2 files changed

+57
-59
lines changed

src/backend/libpq/md5.c

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
* PRIVATE FUNCTIONS
2525
*/
2626

27-
typedef unsigned char unsigned8;
28-
typedef unsigned int unsigned32;
29-
typedef unsigned long unsigned64;
30-
3127
#ifdef FRONTEND
3228
#undef palloc
3329
#define palloc malloc
@@ -39,50 +35,52 @@ typedef unsigned long unsigned64;
3935
* The returned array is allocated using malloc. the caller should free it
4036
* when it is no longer needed.
4137
*/
42-
static unsigned8 *
43-
createPaddedCopyWithLength(unsigned8 *b, unsigned32 *l)
38+
static uint8 *
39+
createPaddedCopyWithLength(uint8 *b, uint32 *l)
4440
{
45-
unsigned8 *ret;
46-
unsigned32 q;
47-
unsigned32 len, newLen448;
48-
unsigned64 len64;
41+
uint8 *ret;
42+
uint32 q;
43+
uint32 len, newLen448;
44+
uint32 len_high, len_low; /* 64-bit value split into 32-bit sections */
4945

5046
len = ((b == NULL) ? 0 : *l);
5147
newLen448 = len + 64 - (len % 64) - 8;
5248
if (newLen448 <= len)
5349
newLen448 += 64;
5450

5551
*l = newLen448 + 8;
56-
if ((ret = (unsigned8 *) malloc(sizeof(unsigned8) * *l)) == NULL)
52+
if ((ret = (uint8 *) malloc(sizeof(uint8) * *l)) == NULL)
5753
return NULL;
5854

5955
if (b != NULL)
60-
memcpy(ret, b, sizeof(unsigned8) * len);
56+
memcpy(ret, b, sizeof(uint8) * len);
6157

6258
/* pad */
6359
ret[len] = 0x80;
6460
for (q = len + 1; q < newLen448; q++)
6561
ret[q] = 0x00;
6662

6763
/* append length as a 64 bit bitcount */
68-
len64 = len;
69-
len64 <<= 3;
64+
len_low = len;
65+
/* split into two 32-bit values */
66+
/* we only look at the bottom 32-bits */
67+
len_high = len >> 29;
68+
len_low <<= 3;
7069
q = newLen448;
71-
ret[q++] = (len64 & 0xFF);
72-
len64 >>= 8;
73-
ret[q++] = (len64 & 0xFF);
74-
len64 >>= 8;
75-
ret[q++] = (len64 & 0xFF);
76-
len64 >>= 8;
77-
ret[q++] = (len64 & 0xFF);
78-
len64 >>= 8;
79-
ret[q++] = (len64 & 0xFF);
80-
len64 >>= 8;
81-
ret[q++] = (len64 & 0xFF);
82-
len64 >>= 8;
83-
ret[q++] = (len64 & 0xFF);
84-
len64 >>= 8;
85-
ret[q] = (len64 & 0xFF);
70+
ret[q++] = (len_low & 0xff);
71+
len_low >>= 8;
72+
ret[q++] = (len_low & 0xff);
73+
len_low >>= 8;
74+
ret[q++] = (len_low & 0xff);
75+
len_low >>= 8;
76+
ret[q++] = (len_low & 0xff);
77+
ret[q++] = (len_high & 0xff);
78+
len_high >>= 8;
79+
ret[q++] = (len_high & 0xff);
80+
len_high >>= 8;
81+
ret[q++] = (len_high & 0xff);
82+
len_high >>= 8;
83+
ret[q] = (len_high & 0xff);
8684

8785
return ret;
8886
}
@@ -94,9 +92,9 @@ createPaddedCopyWithLength(unsigned8 *b, unsigned32 *l)
9492
#define ROT_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
9593

9694
static void
97-
doTheRounds(unsigned32 X[16], unsigned32 state[4])
95+
doTheRounds(uint32 X[16], uint32 state[4])
9896
{
99-
unsigned32 a, b, c, d;
97+
uint32 a, b, c, d;
10098

10199
a = state[0];
102100
b = state[1];
@@ -182,13 +180,13 @@ doTheRounds(unsigned32 X[16], unsigned32 state[4])
182180
}
183181

184182
static int
185-
calculateDigestFromBuffer(unsigned8 *b, unsigned32 len, unsigned8 sum[16])
183+
calculateDigestFromBuffer(uint8 *b, uint32 len, uint8 sum[16])
186184
{
187-
register unsigned32 i, j, k, newI;
188-
unsigned32 l;
189-
unsigned8 *input;
190-
register unsigned32 *wbp;
191-
unsigned32 workBuff[16], state[4];
185+
register uint32 i, j, k, newI;
186+
uint32 l;
187+
uint8 *input;
188+
register uint32 *wbp;
189+
uint32 workBuff[16], state[4];
192190

193191
l = len;
194192

@@ -223,19 +221,19 @@ calculateDigestFromBuffer(unsigned8 *b, unsigned32 len, unsigned8 sum[16])
223221
j = 0;
224222
for (i = 0; i < 4; i++) {
225223
k = state[i];
226-
sum[j++] = (k & 0xFF);
224+
sum[j++] = (k & 0xff);
227225
k >>= 8;
228-
sum[j++] = (k & 0xFF);
226+
sum[j++] = (k & 0xff);
229227
k >>= 8;
230-
sum[j++] = (k & 0xFF);
228+
sum[j++] = (k & 0xff);
231229
k >>= 8;
232-
sum[j++] = (k & 0xFF);
230+
sum[j++] = (k & 0xff);
233231
}
234232
return 1;
235233
}
236234

237235
static void
238-
bytesToHex(unsigned8 b[16], char *s)
236+
bytesToHex(uint8 b[16], char *s)
239237
{
240238
static char *hex = "0123456789abcdef";
241239
int q, w;
@@ -280,9 +278,9 @@ bytesToHex(unsigned8 b[16], char *s)
280278
bool
281279
md5_hash(const void *buff, size_t len, char *hexsum)
282280
{
283-
unsigned8 sum[16];
281+
uint8 sum[16];
284282

285-
if (!calculateDigestFromBuffer((unsigned8 *) buff, len, sum))
283+
if (!calculateDigestFromBuffer((uint8 *) buff, len, sum))
286284
return false;
287285

288286
bytesToHex(sum, hexsum);

src/interfaces/jdbc/org/postgresql/jdbc2/Array.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,11 @@ public Object getArray(long index, int count, Map map) throws SQLException {
169169
}
170170

171171
public int getBaseType() throws SQLException {
172-
return conn.getSQLType(getBaseTypeName());
172+
return Field.getSQLType( getBaseTypeName() );
173173
}
174174

175175
public String getBaseTypeName() throws SQLException {
176-
String fType = field.getPGType();
176+
String fType = field.getTypeName();
177177
if( fType.charAt(0) == '_' )
178178
fType = fType.substring(1);
179179
return fType;
@@ -195,24 +195,24 @@ public java.sql.ResultSet getResultSet(long index, int count, java.util.Map map)
195195
Object array = getArray( index, count, map );
196196
Vector rows = new Vector();
197197
Field[] fields = new Field[2];
198-
fields[0] = new Field(conn, "INDEX", conn.getOID("int2"), 2);
198+
fields[0] = new Field(conn, "INDEX", field.getOID("int2"), 2);
199199
switch ( getBaseType() )
200200
{
201201
case Types.BIT:
202202
boolean[] booleanArray = (boolean[]) array;
203-
fields[1] = new Field(conn, "VALUE", conn.getOID("bool"), 1);
203+
fields[1] = new Field(conn, "VALUE", field.getOID("bool"), 1);
204204
for( int i=0; i<booleanArray.length; i++ ) {
205205
byte[][] tuple = new byte[2][0];
206206
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index+i) ); // Index
207207
tuple[1] = conn.getEncoding().encode( (booleanArray[i]?"YES":"NO") ); // Value
208208
rows.addElement(tuple);
209209
}
210210
case Types.SMALLINT:
211-
fields[1] = new Field(conn, "VALUE", conn.getOID("int2"), 2);
211+
fields[1] = new Field(conn, "VALUE", field.getOID("int2"), 2);
212212
case Types.INTEGER:
213213
int[] intArray = (int[]) array;
214214
if( fields[1] == null )
215-
fields[1] = new Field(conn, "VALUE", conn.getOID("int4"), 4);
215+
fields[1] = new Field(conn, "VALUE", field.getOID("int4"), 4);
216216
for( int i=0; i<intArray.length; i++ ) {
217217
byte[][] tuple = new byte[2][0];
218218
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index+i) ); // Index
@@ -222,7 +222,7 @@ public java.sql.ResultSet getResultSet(long index, int count, java.util.Map map)
222222
break;
223223
case Types.BIGINT:
224224
long[] longArray = (long[]) array;
225-
fields[1] = new Field(conn, "VALUE", conn.getOID("int8"), 8);
225+
fields[1] = new Field(conn, "VALUE", field.getOID("int8"), 8);
226226
for( int i=0; i<longArray.length; i++ ) {
227227
byte[][] tuple = new byte[2][0];
228228
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index+i) ); // Index
@@ -232,7 +232,7 @@ public java.sql.ResultSet getResultSet(long index, int count, java.util.Map map)
232232
break;
233233
case Types.NUMERIC:
234234
BigDecimal[] bdArray = (BigDecimal[]) array;
235-
fields[1] = new Field(conn, "VALUE", conn.getOID("numeric"), -1);
235+
fields[1] = new Field(conn, "VALUE", field.getOID("numeric"), -1);
236236
for( int i=0; i<bdArray.length; i++ ) {
237237
byte[][] tuple = new byte[2][0];
238238
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index+i) ); // Index
@@ -242,7 +242,7 @@ public java.sql.ResultSet getResultSet(long index, int count, java.util.Map map)
242242
break;
243243
case Types.REAL:
244244
float[] floatArray = (float[]) array;
245-
fields[1] = new Field(conn, "VALUE", conn.getOID("float4"), 4);
245+
fields[1] = new Field(conn, "VALUE", field.getOID("float4"), 4);
246246
for( int i=0; i<floatArray.length; i++ ) {
247247
byte[][] tuple = new byte[2][0];
248248
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index+i) ); // Index
@@ -252,7 +252,7 @@ public java.sql.ResultSet getResultSet(long index, int count, java.util.Map map)
252252
break;
253253
case Types.DOUBLE:
254254
double[] doubleArray = (double[]) array;
255-
fields[1] = new Field(conn, "VALUE", conn.getOID("float8"), 8);
255+
fields[1] = new Field(conn, "VALUE", field.getOID("float8"), 8);
256256
for( int i=0; i<doubleArray.length; i++ ) {
257257
byte[][] tuple = new byte[2][0];
258258
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index+i) ); // Index
@@ -261,11 +261,11 @@ public java.sql.ResultSet getResultSet(long index, int count, java.util.Map map)
261261
}
262262
break;
263263
case Types.CHAR:
264-
fields[1] = new Field(conn, "VALUE", conn.getOID("char"), 1);
264+
fields[1] = new Field(conn, "VALUE", field.getOID("char"), 1);
265265
case Types.VARCHAR:
266266
String[] strArray = (String[]) array;
267267
if( fields[1] == null )
268-
fields[1] = new Field(conn, "VALUE", conn.getOID("varchar"), -1);
268+
fields[1] = new Field(conn, "VALUE", field.getOID("varchar"), -1);
269269
for( int i=0; i<strArray.length; i++ ) {
270270
byte[][] tuple = new byte[2][0];
271271
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index+i) ); // Index
@@ -275,7 +275,7 @@ public java.sql.ResultSet getResultSet(long index, int count, java.util.Map map)
275275
break;
276276
case Types.DATE:
277277
java.sql.Date[] dateArray = (java.sql.Date[]) array;
278-
fields[1] = new Field(conn, "VALUE", conn.getOID("date"), 4);
278+
fields[1] = new Field(conn, "VALUE", field.getOID("date"), 4);
279279
for( int i=0; i<dateArray.length; i++ ) {
280280
byte[][] tuple = new byte[2][0];
281281
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index+i) ); // Index
@@ -285,7 +285,7 @@ public java.sql.ResultSet getResultSet(long index, int count, java.util.Map map)
285285
break;
286286
case Types.TIME:
287287
java.sql.Time[] timeArray = (java.sql.Time[]) array;
288-
fields[1] = new Field(conn, "VALUE", conn.getOID("time"), 8);
288+
fields[1] = new Field(conn, "VALUE", field.getOID("time"), 8);
289289
for( int i=0; i<timeArray.length; i++ ) {
290290
byte[][] tuple = new byte[2][0];
291291
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index+i) ); // Index
@@ -295,7 +295,7 @@ public java.sql.ResultSet getResultSet(long index, int count, java.util.Map map)
295295
break;
296296
case Types.TIMESTAMP:
297297
java.sql.Timestamp[] timestampArray = (java.sql.Timestamp[]) array;
298-
fields[1] = new Field(conn, "VALUE", conn.getOID("timestamp"), 8);
298+
fields[1] = new Field(conn, "VALUE", field.getOID("timestamp"), 8);
299299
for( int i=0; i<timestampArray.length; i++ ) {
300300
byte[][] tuple = new byte[2][0];
301301
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index+i) ); // Index

0 commit comments

Comments
 (0)