summaryrefslogtreecommitdiff
path: root/openwrt/package/postgresql/patches/500-debian-subset.patch
blob: eb9dca7e31149157525dcea36c517286d23b8704 (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
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
diff -ruN postgresql-7.4.6-orig/contrib/Makefile postgresql-7.4.6-3/contrib/Makefile
--- postgresql-7.4.6-orig/contrib/Makefile	2003-09-11 19:15:27.000000000 +0200
+++ postgresql-7.4.6-3/contrib/Makefile	2005-03-09 15:56:11.000000000 +0100
@@ -22,8 +22,10 @@
 		lo		\
 		ltree		\
 		miscutil	\
+		mysql		\
 		noupdate	\
 		oid2name	\
+		oracle		\
 		pg_autovacuum	\
 		pg_dumplo	\
 		pg_logger	\
@@ -40,7 +42,8 @@
 		tsearch		\
 		tsearch2	\
 		userlock	\
-		vacuumlo
+		vacuumlo	\
+		xml
 
 # Missing:
 #		array		\ (removed all but the README)
@@ -48,13 +51,10 @@
 #		ipc_check	\ (does not have a makefile)
 #		mSQL-interface	\ (requires msql installed)
 #		mac		\ (does not have a makefile)
-#		mysql		\ (does not have a makefile)
-#		oracle		\ (does not have a makefile)
 #		pg_upgrade	\ (does not have a makefile)
 #		reindexdb	\ (does not have a makefile)
 #		start-scripts	\ (does not have a makefile)
 #		tools		\ (does not have a makefile)
-#		xml		\ (non-standard makefile)
 
 
 all install installdirs uninstall clean distclean maintainer-clean check installcheck:
diff -ruN postgresql-7.4.6-orig/contrib/dbase/dbf2pg.c postgresql-7.4.6-3/contrib/dbase/dbf2pg.c
--- postgresql-7.4.6-orig/contrib/dbase/dbf2pg.c	2003-09-28 00:24:49.000000000 +0200
+++ postgresql-7.4.6-3/contrib/dbase/dbf2pg.c	2005-03-09 15:56:11.000000000 +0100
@@ -324,6 +324,10 @@
 			case 'L':
 				strcat(query, " char");
 				break;
+
+			case 'M':
+				strcat(query, " text");
+				break;
 		}
 	}
 
@@ -335,7 +339,10 @@
 		printf("%s\n", query);
 	}
 
-	if ((res = PQexec(conn, query)) == NULL)
+	if ((res = PQexec(conn, query)) == NULL ||
+	    PQresultStatus(res) == PGRES_BAD_RESPONSE ||
+	    PQresultStatus(res) == PGRES_NONFATAL_ERROR ||
+	    PQresultStatus(res) == PGRES_FATAL_ERROR)
 	{
 		fprintf(stderr, "Error creating table!\n");
 		fprintf(stderr, "Detailed report: %s\n", PQerrorMessage(conn));
@@ -429,7 +436,10 @@
 			}
 			sprintf(query, "COPY %s FROM stdin", table);
 			res = PQexec(conn, query);
-			if (res == NULL)
+			if (res == NULL ||
+			    PQresultStatus(res)==PGRES_BAD_RESPONSE ||
+			    PQresultStatus(res)==PGRES_NONFATAL_ERROR ||
+			    PQresultStatus(res)==PGRES_FATAL_ERROR)
 			{
 				fprintf(stderr, "Error starting COPY!\n");
 				fprintf(stderr, "Detailed report: %s\n", PQerrorMessage(conn));
diff -ruN postgresql-7.4.6-orig/contrib/dbmirror/Makefile postgresql-7.4.6-3/contrib/dbmirror/Makefile
--- postgresql-7.4.6-orig/contrib/dbmirror/Makefile	2002-06-23 23:58:07.000000000 +0200
+++ postgresql-7.4.6-3/contrib/dbmirror/Makefile	2005-03-09 15:56:11.000000000 +0100
@@ -5,6 +5,8 @@
 include $(top_builddir)/src/Makefile.global
 
 MODULES = pending
+SCRIPTS = clean_pending.pl DBMirror.pl
+DATA = AddTrigger.sql MirrorSetup.sql slaveDatabase.conf
 DOCS = README.dbmirror
 
 include $(top_srcdir)/contrib/contrib-global.mk
diff -ruN postgresql-7.4.6-orig/contrib/mysql/Makefile postgresql-7.4.6-3/contrib/mysql/Makefile
--- postgresql-7.4.6-orig/contrib/mysql/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ postgresql-7.4.6-3/contrib/mysql/Makefile	2005-03-09 15:56:11.000000000 +0100
@@ -0,0 +1,12 @@
+# mysql conversion Perl scripts
+
+subdir = contrib/mysql
+top_builddir = ../..
+include $(top_builddir)/src/Makefile.global
+
+MODULES =
+SCRIPTS = my2pg.pl  mysql2pgsql
+DOCS = README.mysql
+
+include $(top_srcdir)/contrib/contrib-global.mk
+
diff -ruN postgresql-7.4.6-orig/contrib/mysql/mysql2pgsql postgresql-7.4.6-3/contrib/mysql/mysql2pgsql
--- postgresql-7.4.6-orig/contrib/mysql/mysql2pgsql	2001-01-18 08:16:56.000000000 +0100
+++ postgresql-7.4.6-3/contrib/mysql/mysql2pgsql	2005-03-09 15:56:11.000000000 +0100
@@ -1,4 +1,4 @@
-# -*- perl -*-
+#!/usr/bin/perl -w
 # mysql2pgsql
 # Take a MySQL schema dump and turn it into SQL92 and PostgreSQL form.
 # Thomas Lockhart, (c) 2000, PostgreSQL Inc.
diff -ruN postgresql-7.4.6-orig/contrib/oracle/Makefile postgresql-7.4.6-3/contrib/oracle/Makefile
--- postgresql-7.4.6-orig/contrib/oracle/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ postgresql-7.4.6-3/contrib/oracle/Makefile	2005-03-09 15:56:11.000000000 +0100
@@ -0,0 +1,11 @@
+# oracle conversion Perl scripts
+
+subdir = contrib/oracle
+top_builddir = ../..
+include $(top_builddir)/src/Makefile.global
+
+MODULES =
+SCRIPTS = Ora2Pg.pm ora2pg.pl
+DOCS = README.ora2pg
+
+include $(top_srcdir)/contrib/contrib-global.mk
diff -ruN postgresql-7.4.6-orig/contrib/oracle/ora2pg.pl postgresql-7.4.6-3/contrib/oracle/ora2pg.pl
--- postgresql-7.4.6-orig/contrib/oracle/ora2pg.pl	2003-01-07 23:17:14.000000000 +0100
+++ postgresql-7.4.6-3/contrib/oracle/ora2pg.pl	2005-03-09 15:56:11.000000000 +0100
@@ -17,6 +17,10 @@
 
 use strict;
 
+# allow to put Ora2Pg.pm in the same directory as this script
+use File::Basename;
+use lib dirname($0);
+
 use Ora2Pg;
 
 # Initialyze the database connection
diff -ruN postgresql-7.4.6-orig/contrib/pg_autovacuum/pg_autovacuum.c postgresql-7.4.6-3/contrib/pg_autovacuum/pg_autovacuum.c
--- postgresql-7.4.6-orig/contrib/pg_autovacuum/pg_autovacuum.c	2004-05-26 20:48:36.000000000 +0200
+++ postgresql-7.4.6-3/contrib/pg_autovacuum/pg_autovacuum.c	2005-03-09 15:56:11.000000000 +0100
@@ -5,6 +5,12 @@
  */
 
 #include "pg_autovacuum.h"
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+
 #define TIMEBUFF 256
 FILE	   *LOGOUTPUT;
 char		timebuffer[TIMEBUFF];
@@ -30,6 +36,15 @@
 daemonize()
 {
 	pid_t		pid;
+	int		nullfd;
+	char*		pgdata = getenv("PGDATA");
+
+	/* Check if PGDATA is set. Needed to create pid file. */
+	if (!pgdata)
+	{
+	    fprintf(stderr, "Error: PGDATA not defined. Could not create pid file. Aborting\n");
+	    _exit(1);
+	}
 
 	pid = fork();
 	if (pid == (pid_t) -1)
@@ -40,10 +55,39 @@
 	}
 	else if (pid)
 	{							/* parent */
+#define PIDFILEBUF 1024
+		char databuf[PIDFILEBUF];
+		char *dataptr = databuf;
+		char *pidfilename = "/autovacuum.pid";
+		FILE *PIDFILE;
+
+		/* If we can determine PGDATA, write a PID file there.
+		 * This is a fudge that depends on Debian's setting PGDATA
+		 * before calling pg_autovacuum in the init script.  It
+		 * could do with being cleaned up for submission upstream. */
+		strncpy(dataptr, pgdata, PIDFILEBUF - 1);
+		databuf[PIDFILEBUF - 1] = '\0';
+		if (strlen(dataptr) > 0 && strlen(dataptr) < PIDFILEBUF - strlen(pidfilename - 1)) {
+			strcat(dataptr, pidfilename);
+			/* Don't bother to report errors in opening PIDFILE */
+			if ((PIDFILE = fopen((const char *) dataptr, "w")) != NULL) {
+				fprintf(PIDFILE, "%d\n", pid);
+				fclose(PIDFILE);
+			}
+		}
 		/* Parent should just exit, without doing any atexit cleanup */
 		_exit(0);
 	}
 
+	/* detach from stdin, stdout and stderr 
+	 * (patched by Martin Pitt <mpitt@debian.org> for the Debian package) */
+	nullfd = open("/dev/null", O_RDWR);
+	dup2(nullfd, 0);
+	dup2(nullfd, 1);
+	dup2(nullfd, 2);
+	if (nullfd != 0 && nullfd != 1 && nullfd != 2)
+	    close(nullfd);
+
 /* GH: If there's no setsid(), we hopefully don't need silent mode.
  * Until there's a better solution.  */
 #ifdef HAVE_SETSID
diff -ruN postgresql-7.4.6-orig/contrib/xml/Makefile postgresql-7.4.6-3/contrib/xml/Makefile
--- postgresql-7.4.6-orig/contrib/xml/Makefile	2002-10-22 22:03:09.000000000 +0200
+++ postgresql-7.4.6-3/contrib/xml/Makefile	2005-03-09 15:56:11.000000000 +0100
@@ -4,6 +4,7 @@
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
+CFLAGS += $(shell xml2-config --cflags)
 MODULE_big = pgxml_dom
 OBJS = pgxml_dom.o
 SHLIB_LINK = -lxml2
diff -ruN postgresql-7.4.6-orig/doc/src/sgml/Makefile postgresql-7.4.6-3/doc/src/sgml/Makefile
--- postgresql-7.4.6-orig/doc/src/sgml/Makefile	2004-03-09 21:10:19.000000000 +0100
+++ postgresql-7.4.6-3/doc/src/sgml/Makefile	2005-03-09 15:56:11.000000000 +0100
@@ -66,6 +66,9 @@
 	$(NSGMLS) $(NSGMLS_FLAGS) $< | $(SGMLSPL) $(D2MSCRIPT) --lowercase --section $(DEFAULTSECTION) --date "`date '+%Y-%m-%d'`"
 	$(mkinstalldirs) man1 man$(DEFAULTSECTION)
 	mv *.1 man1/
+	mmv '*.' "#l1.$(DEFAULTSECTION)"
+	mmv '* *.'$(DEFAULTSECTION) "#1_#2.$(DEFAULTSECTION)"
+	mmv '* *.'$(DEFAULTSECTION) "#1_#2.$(DEFAULTSECTION)"
 	mv *.$(DEFAULTSECTION) man$(DEFAULTSECTION)/
 
 
diff -ruN postgresql-7.4.6-orig/doc/src/sgml/ref/initdb.sgml postgresql-7.4.6-3/doc/src/sgml/ref/initdb.sgml
--- postgresql-7.4.6-orig/doc/src/sgml/ref/initdb.sgml	2003-08-31 19:32:23.000000000 +0200
+++ postgresql-7.4.6-3/doc/src/sgml/ref/initdb.sgml	2005-03-09 15:56:11.000000000 +0100
@@ -227,6 +227,24 @@
        </para>
       </listitem>
      </varlistentry>
+
+     <varlistentry>
+      <term><option>--debian-conffile</option></term>
+      <listitem>
+       <para>
+        On Debian systems, this option is used by the package's
+	post-initialisation script when it runs <command>initdb</command> to
+	create a database.
+        It symlinks the configuration files into the <filename>/etc/postgresql</filename>
+        directory, whereas the standard behaviour is to put these files
+        into the database directory.
+       </para>
+       <para>
+        This option disables that behaviour, thus causing <command>initdb</command>
+        to behave as expected.
+       </para>
+      </listitem>
+     </varlistentry>
     </variablelist>
    </para>
 
diff -ruN postgresql-7.4.6-orig/doc/src/sgml/ref/pg_dump.sgml postgresql-7.4.6-3/doc/src/sgml/ref/pg_dump.sgml
--- postgresql-7.4.6-orig/doc/src/sgml/ref/pg_dump.sgml	2004-10-22 00:49:04.000000000 +0200
+++ postgresql-7.4.6-3/doc/src/sgml/ref/pg_dump.sgml	2005-03-09 15:56:11.000000000 +0100
@@ -304,6 +304,18 @@
      </varlistentry>
 
      <varlistentry>
+      <term><option>-N</></term>
+      <term><option>--convert-now</></term>
+      <listitem>
+       <para>
+       In DEFAULT clauses of table column definitions, convert the old
+       <literal>DEFAULT 'now'</literal> syntax (up to PostgreSQL 7.3) to
+       <literal>DEFAULT now()</literal>.
+       </para>
+      </listitem>
+     </varlistentry>
+
+     <varlistentry>
       <term><option>-o</></term>
       <term><option>--oids</></term>
       <listitem>
diff -ruN postgresql-7.4.6-orig/doc/src/sgml/ref/pg_dumpall.sgml postgresql-7.4.6-3/doc/src/sgml/ref/pg_dumpall.sgml
--- postgresql-7.4.6-orig/doc/src/sgml/ref/pg_dumpall.sgml	2003-11-04 10:45:30.000000000 +0100
+++ postgresql-7.4.6-3/doc/src/sgml/ref/pg_dumpall.sgml	2005-03-09 15:56:11.000000000 +0100
@@ -164,6 +164,18 @@
      </varlistentry>
 
      <varlistentry>
+      <term><option>-N</></term>
+      <term><option>--convert-now</></term>
+      <listitem>
+       <para>
+       In DEFAULT clauses of table column definitions, convert the old
+       <literal>DEFAULT 'now'</literal> syntax (up to PostgreSQL 7.3) to
+       <literal>DEFAULT now()</literal>.
+       </para>
+      </listitem>
+     </varlistentry>
+
+     <varlistentry>
       <term><option>-o</></term>
       <term><option>--oids</></term>
       <listitem>
diff -ruN postgresql-7.4.6-orig/doc/src/sgml/ref/psql-ref.sgml postgresql-7.4.6-3/doc/src/sgml/ref/psql-ref.sgml
--- postgresql-7.4.6-orig/doc/src/sgml/ref/psql-ref.sgml	2003-11-01 02:56:29.000000000 +0100
+++ postgresql-7.4.6-3/doc/src/sgml/ref/psql-ref.sgml	2005-03-09 15:56:11.000000000 +0100
@@ -494,7 +494,9 @@
     local host. The default port number is compile-time determined.
     Since the database server uses the same default, you will not have
     to specify the port in most cases. The default user name is your
-    Unix user name, as is the default database name. Note that you can't
+    Unix user name. In standard PostgreSQL, the database name defaults to your
+    username too, but in this Debian version, when called through pg_wrapper,
+    the database must be specified. Note that you can't
     just connect to any database under any user name. Your database
     administrator should have informed you about your access rights. To
     save you some typing you can also set the environment variables
diff -ruN postgresql-7.4.6-orig/ipkg/libpq/CONTROL/control postgresql-7.4.6-3/ipkg/libpq/CONTROL/control
diff -ruN postgresql-7.4.6-orig/ipkg/libpq-dev/CONTROL/control postgresql-7.4.6-3/ipkg/libpq-dev/CONTROL/control
diff -ruN postgresql-7.4.6-orig/ipkg/pgsql-utils/CONTROL/control postgresql-7.4.6-3/ipkg/pgsql-utils/CONTROL/control
diff -ruN postgresql-7.4.6-orig/ipkg/rules postgresql-7.4.6-3/ipkg/rules
diff -ruN postgresql-7.4.6-orig/ipkg/version postgresql-7.4.6-3/ipkg/version
diff -ruN postgresql-7.4.6-orig/src/Makefile.global.in postgresql-7.4.6-3/src/Makefile.global.in
--- postgresql-7.4.6-orig/src/Makefile.global.in	2003-12-20 00:29:29.000000000 +0100
+++ postgresql-7.4.6-3/src/Makefile.global.in	2005-03-09 15:56:11.000000000 +0100
@@ -87,7 +87,7 @@
 pkglibdir = $(libdir)
 ifeq "$(findstring pgsql, $(pkglibdir))" ""
 ifeq "$(findstring postgres, $(pkglibdir))" ""
-override pkglibdir := $(pkglibdir)/postgresql
+override pkglibdir := $(pkglibdir)/postgresql/lib
 endif
 endif
 
diff -ruN postgresql-7.4.6-orig/src/backend/libpq/pg_hba.conf.sample postgresql-7.4.6-3/src/backend/libpq/pg_hba.conf.sample
--- postgresql-7.4.6-orig/src/backend/libpq/pg_hba.conf.sample	2003-09-13 18:43:38.000000000 +0200
+++ postgresql-7.4.6-3/src/backend/libpq/pg_hba.conf.sample	2005-03-09 15:56:11.000000000 +0100
@@ -24,39 +24,77 @@
 # DATABASE can be "all", "sameuser", "samegroup", a database name (or
 # a comma-separated list thereof), or a file name prefixed with "@".
 # USER can be "all", an actual user name or a group name prefixed with
-# "+" or a list containing either.  IP-ADDRESS and IP-MASK specify the
-# set of hosts the record matches.  CIDR-MASK is an integer between 0
-# and 32 (IPv6) or 128(IPv6) inclusive, that specifies the number of
-# significant bits in the mask, so an IPv4 CIDR-MASK of 8 is equivalent
-# to an IP-MASK of 255.0.0.0, and an IPv6 CIDR-MASK of 64 is equivalent
-# to an IP-MASK of ffff:ffff:ffff:ffff::. METHOD can be "trust", "reject",
-# "md5", "crypt", "password", "krb4", "krb5", "ident", or "pam".  Note
-# that "password" uses clear-text passwords; "md5" is preferred for
+# "+", an include file prefixed with "@" or a list containing either.
+# IP-ADDRESS and IP-MASK specify the set of hosts the record matches.
+# CIDR-MASK is an integer between 0 and 32 (IPv6) or 128(IPv6)
+# inclusive, that specifies the number of significant bits in the
+# mask, so an IPv4 CIDR-MASK of 8 is equivalent to an IP-MASK of
+# 255.0.0.0, and an IPv6 CIDR-MASK of 64 is equivalent to an IP-MASK
+# of ffff:ffff:ffff:ffff::. METHOD can be "trust", "reject", "md5",
+# "crypt", "password", "krb5", "ident", or "pam".  Note that
+# "password" uses clear-text passwords; "md5" is preferred for
 # encrypted passwords.  OPTION is the ident map or the name of the PAM
 # service.
 #
+# INCLUDE FILES:
+# If you use include files for users and/or databases (see PostgreSQL
+# documentation, section 19.1), these files must be placed in the
+# database directory. Usually this is /var/lib/postgres/data/, but
+# that can be changed in /etc/postgresql/postmaster.conf with the
+# POSTGRES_DATA variable. Putting them in /etc/postgresql/ will NOT
+# work since the configuration files are only symlinked from
+# POSTGRES_DATA.
+#
 # This file is read on server startup and when the postmaster receives
 # a SIGHUP signal.  If you edit the file on a running system, you have
 # to SIGHUP the postmaster for the changes to take effect, or use
 # "pg_ctl reload".
-
+#
+# Upstream default configuration
+#
+# The following configuration is the upstream default, which allows
+# unrestricted access to amy database by any user on the local machine.
+# 
+# TYPE  DATABASE    USER        IP-ADDRESS        IP-MASK           METHOD
+#
+#local   all         all                                             trust
+# IPv4-style local connections:
+#host    all         all         127.0.0.1         255.255.255.255   trust
+# IPv6-style local connections:
+#
 # Put your actual configuration here
 # ----------------------------------
 #
-# CAUTION: The default configuration allows any local user to connect
-# using any PostgreSQL user name, including the superuser, over either
-# Unix-domain sockets or TCP/IP.  If you are on a multiple-user
-# machine, the default configuration is probably too liberal for you.
-# Change it to use something other than "trust" authentication.
+# This default configuration allows any local user to connect as himself
+# without a password, either through a Unix socket or through TCP/IP; users
+# on other machines are denied access.
 #
 # If you want to allow non-local connections, you need to add more
-# "host" records.  Also, remember TCP/IP connections are only enabled
-# if you enable "tcpip_socket" in postgresql.conf.
-
+# "host" records before the final line that rejects all TCP/IP connections.
+# Also, remember TCP/IP connections are only enabled if you enable
+# "tcpip_socket" in /etc/postgresql/postgresql.conf.
+#
+# DO NOT DISABLE!
+# If you change this first entry you will need to make sure the postgres user
+# can access the database using some other method.  The postgres user needs
+# non-interactive access to all databases during automatic maintenance
+# (see the vacuum command and the /usr/lib/postgresql/bin/do.maintenance
+# script).
+#
 # TYPE  DATABASE    USER        IP-ADDRESS        IP-MASK           METHOD
+# Database administrative login by UNIX sockets
+local   all         postgres                                        ident sameuser
+#
+# All other connections by UNIX sockets
+local   all         all                                             ident sameuser
+#
+# All IPv4 connections from localhost
+host    all         all         127.0.0.1         255.255.255.255   ident sameuser
+#
+# All IPv6 localhost connections
+host    all         all         ::1               ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff        ident sameuser
+host    all         all         ::ffff:127.0.0.1/128                ident sameuser
+#
+# reject all other connection attempts
+host    all         all         0.0.0.0           0.0.0.0           reject
 
-local   all         all                                             trust
-# IPv4-style local connections:
-host    all         all         127.0.0.1         255.255.255.255   trust
-# IPv6-style local connections:
-host    all         all         ::1               ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff        trust
diff -ruN postgresql-7.4.6-orig/src/backend/storage/file/fd.c postgresql-7.4.6-3/src/backend/storage/file/fd.c
--- postgresql-7.4.6-orig/src/backend/storage/file/fd.c	2004-02-24 00:03:43.000000000 +0100
+++ postgresql-7.4.6-3/src/backend/storage/file/fd.c	2005-03-09 15:56:11.000000000 +0100
@@ -50,6 +50,9 @@
 #include "storage/fd.h"
 #include "storage/ipc.h"
 
+#ifdef CHECK_RLIMIT_NOFILE
+#include <sys/resource.h>
+#endif
 
 /* Filename components for OpenTemporaryFile */
 #define PG_TEMP_FILES_DIR "pgsql_tmp"
@@ -272,15 +275,28 @@
 	int			used = 0;
 	int			highestfd = 0;
 	int			j;
+#ifdef CHECK_RLIMIT_NOFILE
+	struct rlimit	    rlim;
+#endif
 
 	size = 1024;
 	fd = (int *) palloc(size * sizeof(int));
 
+#ifdef CHECK_RLIMIT_NOFILE
+	getrlimit(RLIMIT_NOFILE, &rlim);
+#endif
+
 	/* dup until failure ... */
 	for (;;)
 	{
 		int		thisfd;
 
+#ifdef CHECK_RLIMIT_NOFILE
+               /* Don't go beyond RLIMIT_NOFILE */
+		if (highestfd >= rlim.rlim_cur - 1)
+		    break;
+#endif
+
 		thisfd = dup(0);
 		if (thisfd < 0)
 		{
diff -ruN postgresql-7.4.6-orig/src/bin/initdb/initdb.sh postgresql-7.4.6-3/src/bin/initdb/initdb.sh
--- postgresql-7.4.6-orig/src/bin/initdb/initdb.sh	2004-05-05 18:09:56.000000000 +0200
+++ postgresql-7.4.6-3/src/bin/initdb/initdb.sh	2005-03-09 15:56:11.000000000 +0100
@@ -71,7 +71,6 @@
     echo "$ret"
 }
 
-
 CMDNAME=`basename $0`
 
 # Placed here during build
@@ -196,6 +195,7 @@
 debug=
 noclean=
 show_setting=
+debian_conffile=
 
 # Note: There is a single compelling reason that the name of the database
 #       superuser be the same as the Unix user owning the server process:
@@ -318,6 +318,14 @@
         --lc-time=*)
                 PGLC_TIME=`echo $1 | sed 's/^[^=]*=//'`
                 ;;
+# Debian's initdb is going to try to symlink the files from $PGDATA to
+# /etc/postgres... but if you're initialising a database somewhere else,
+# you don't want this behaviour, so tell initdb to not do it.
+	--debian-conffile)
+		debian_conffile=yes
+		echo "use debian conffile location"
+		;;
+
 
 	-*)
 		echo "$CMDNAME: invalid option: $1"
@@ -590,6 +598,8 @@
 #
 # CREATE CONFIG FILES
 
+if [ -z "$debian_conffile" ]
+then
 $ECHO_N "creating configuration files... "$ECHO_C
 
 sed -e "s/^#shared_buffers = 1000/shared_buffers = $nbuffers/" \
@@ -611,6 +621,32 @@
 chmod 0600 "$PGDATA"/pg_hba.conf "$PGDATA"/pg_ident.conf \
 	"$PGDATA"/postgresql.conf
 
+else
+
+# debian-conffile option set:
+# In a Debian primary installation, the config files go to /etc/postgresql/
+# rather than to $PGDATA.
+ln -sf /etc/postgresql/pg_hba.conf $PGDATA/pg_hba.conf          || exit_nicely
+ln -sf /etc/postgresql/pg_ident.conf $PGDATA/pg_ident.conf      || exit_nicely
+ln -sf /etc/postgresql/postgresql.conf $PGDATA/postgresql.conf  || exit_nicely
+
+# Since postgresql.conf is a permanent file, rather than created with the
+# database, it must have the LC_ values replaced rather than just tacked
+# on the end.
+(
+  grep -vE '^LC_(MESSAGES|MONETARY|NUMERIC|TIME) *=' /etc/postgresql/postgresql.conf
+  for cat in MESSAGES MONETARY NUMERIC TIME; do
+    echo "LC_$cat = '`pg_getlocale $cat`'"
+  done
+) >/etc/postgresql/$$ || exit_nicely
+cat /etc/postgresql/$$ >/etc/postgresql/postgresql.conf || exit_nicely
+rm /etc/postgresql/$$
+
+chmod 0600 /etc/postgresql/pg_hba.conf /etc/postgresql/pg_ident.conf
+chmod 0644 /etc/postgresql/postgresql.conf
+
+fi
+
 echo "ok"
 
 ##########################################################################
@@ -1143,13 +1179,9 @@
 # FINISHED
 
 echo
-echo "Success. You can now start the database server using:"
-echo ""
-echo "    $PGPATH/postmaster -D $PGDATA"
-echo "or"
-# (Advertise -l option here, otherwise we have a background
-#  process writing to the terminal.)
-echo "    $PGPATH/pg_ctl -D $PGDATA -l logfile start"
+echo "Success. The database server should be started automatically."
+echo "If not, you can start the database server using:"
 echo
+echo "    /etc/init.d/postgresql start"
 
 exit 0
diff -ruN postgresql-7.4.6-orig/src/bin/pg_ctl/pg_ctl.sh postgresql-7.4.6-3/src/bin/pg_ctl/pg_ctl.sh
--- postgresql-7.4.6-orig/src/bin/pg_ctl/pg_ctl.sh	2004-10-22 02:24:27.000000000 +0200
+++ postgresql-7.4.6-3/src/bin/pg_ctl/pg_ctl.sh	2005-03-09 15:56:11.000000000 +0100
@@ -139,31 +139,72 @@
 	    exit 0
 	    ;;
 	-D)
-	    shift
+	    PGDATA="$2"
+            if [ -z "$PGDATA" -o `echo x$PGDATA | cut -c1-2` = "x-" ]
+            then
+                echo "$CMDNAME: option '-D' specified without a data directory"
+                exit 1
+            fi
 	    # we need to do this so -D datadir shows in ps display
-	    PGDATAOPTS="-D $1"
-	    PGDATA="$1"
+	    PGDATAOPTS="-D $PGDATA"
 	    export PGDATA
+	    shift
 	    ;;
 	-l)
 	    logfile="$2"
+            if [ -z "$logfile" -o `echo x$logfile | cut -c1-2` = "x-" ]
+            then
+                echo "$CMDNAME: option '-l' specified without a logfile"
+                exit 1
+            fi
 	    shift;;
 	-l*)
 	    logfile=`echo "$1" | sed 's/^-l//'`
+            if [ -z "$logfile" -o `echo x$logfile | cut -c1-2` = "x-" ]
+            then
+                echo "$CMDNAME: option '-l' specified without a logfile"
+                exit 1
+            fi
 	    ;;
 	-m)
 	    shutdown_mode="$2"
+            if [ -z "$shutdown_mode" -o `echo x$shutdown_mode | cut -c1-2` = "x-" ]
+            then
+                echo "$CMDNAME: option '-m' specified without a shutdown mode"
+                exit 1
+            fi
 	    shift;;
 	-m*)
 	    shutdown_mode=`echo "$1" | sed 's/^-m//'`
+            if [ -z "$shutdown_mode" -o `echo x$shutdown_mode | cut -c1-2` = "x-" ]
+            then
+                echo "$CMDNAME: option '-m' specified without a shutdown mode"
+                exit 1
+            fi
 	    ;;
 	-o)
+	    POSTOPTS="$2"
+            if [ -z "$POSTOPTS" ]
+            then
+                echo "$CMDNAME: option '-o' specified without any passed options"
+                exit 1
+            fi
+            if [ `echo x$POSTOPTS | cut -c1-2` != x- ]
+            then
+                echo "$CMDNAME: option -o must be followed by one or more further options
+ to pass to the postmaster"
+                exit 1
+            fi
 	    shift
-	    POSTOPTS="$1"
 	    ;;
 	-p)
+	    po_path="$2"
+            if [ -z "$po_path" -o `echo x$po_path | cut -c1-2` = "x-" ]
+            then
+                echo "$CMDNAME: option '-p' specified without a path"
+                exit 1
+            fi
 	    shift
-	    po_path="$1"
 	    ;;
 	-s)
 	    silence_echo=:
diff -ruN postgresql-7.4.6-orig/src/bin/pg_dump/pg_dump.c postgresql-7.4.6-3/src/bin/pg_dump/pg_dump.c
--- postgresql-7.4.6-orig/src/bin/pg_dump/pg_dump.c	2004-05-26 20:27:23.000000000 +0200
+++ postgresql-7.4.6-3/src/bin/pg_dump/pg_dump.c	2005-03-09 15:56:11.000000000 +0100
@@ -135,6 +135,7 @@
 bool		schemaOnly;
 bool		dataOnly;
 bool		aclsSkip;
+bool		convertNow;
 
 /* obsolete as of 7.3: */
 static Oid	g_last_builtin_oid; /* value of the last builtin oid */
@@ -198,6 +199,7 @@
 		{"no-owner", no_argument, NULL, 'O'},
 		{"port", required_argument, NULL, 'p'},
 		{"schema", required_argument, NULL, 'n'},
+		{"convert-now", no_argument, NULL, 'N'},
 		{"schema-only", no_argument, NULL, 's'},
 		{"superuser", required_argument, NULL, 'S'},
 		{"table", required_argument, NULL, 't'},
@@ -233,7 +235,7 @@
 	g_comment_end[0] = '\0';
 	strcpy(g_opaque_type, "opaque");
 
-	dataOnly = schemaOnly = dumpData = attrNames = false;
+	dataOnly = schemaOnly = dumpData = attrNames = convertNow = false;
 
 	progname = get_progname(argv[0]);
 
@@ -258,7 +260,7 @@
 		}
 	}
 
-	while ((c = getopt_long(argc, argv, "abcCdDf:F:h:in:oOp:RsS:t:uU:vWxX:Z:",
+	while ((c = getopt_long(argc, argv, "abcCdDf:F:h:in:NoOp:RsS:t:uU:vWxX:Z:",
 							long_options, &optindex)) != -1)
 	{
 		switch (c)
@@ -310,6 +312,10 @@
 				selectSchemaName = strdup(optarg);
 				break;
 
+			case 'N':			/* convert DEFAULT 'now' to DEFAULT now() */
+				convertNow = true;
+				break;
+
 			case 'o':			/* Dump oids */
 				oids = true;
 				break;
@@ -535,6 +541,13 @@
 			exit_horribly(g_fout, NULL, "could not set extra_float_digits: %s",
 						  PQerrorMessage(g_conn));
 		PQclear(res);
+
+		/* Set datestyle to ISO to ensure portability */
+		res = PQexec(g_conn, "SET DATESTYLE = ISO");
+		if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
+			exit_horribly(g_fout, NULL, "could not set datestyle to ISO: %s",
+						  PQerrorMessage(g_conn));
+		PQclear(res);
 	}
 
 	/* Find the last built-in OID, if needed */
@@ -633,6 +646,7 @@
 	printf(_("  -d, --inserts            dump data as INSERT, rather than COPY, commands\n"));
 	printf(_("  -D, --column-inserts     dump data as INSERT commands with column names\n"));
 	printf(_("  -n, --schema=SCHEMA      dump the named schema only\n"));
+	printf(_("  -N, --convert-now        convert DEFAULT 'now' to DEFAULT now()\n"));
 	printf(_("  -o, --oids               include OIDs in dump\n"));
 	printf(_("  -O, --no-owner           do not output commands to set object ownership\n"
 			 "                           in plain text format\n"));
@@ -665,6 +679,19 @@
 }
 
 /*
+ * handleConvertNow: called on DEFAULT arguments in table column definitions;
+ * if conversion is enabled, returns now() instead of 'now'
+ */
+const char*
+handleConvertNow(const char* value)
+{
+    if( convertNow && !strcmp(value,"'now'"))
+	return "now()";
+    else
+	return value;
+}
+
+/*
  * selectDumpableNamespace: policy-setting subroutine
  *		Mark a namespace as to be dumped or not
  */
@@ -5334,7 +5361,7 @@
 					!tbinfo->inhAttrDef[j] &&
 					!tbinfo->attisserial[j])
 					appendPQExpBuffer(q, " DEFAULT %s",
-									  tbinfo->adef_expr[j]);
+						handleConvertNow( tbinfo->adef_expr[j] ) );
 
 				/*
 				 * Not Null constraint --- suppress if inherited
diff -ruN postgresql-7.4.6-orig/src/bin/pg_dump/pg_dumpall.c postgresql-7.4.6-3/src/bin/pg_dump/pg_dumpall.c
--- postgresql-7.4.6-orig/src/bin/pg_dump/pg_dumpall.c	2004-01-22 20:09:48.000000000 +0100
+++ postgresql-7.4.6-3/src/bin/pg_dump/pg_dumpall.c	2005-03-09 15:56:11.000000000 +0100
@@ -86,6 +86,7 @@
 		{"globals-only", no_argument, NULL, 'g'},
 		{"host", required_argument, NULL, 'h'},
 		{"ignore-version", no_argument, NULL, 'i'},
+		{"convert-now", no_argument, NULL, 'N'},
 		{"oids", no_argument, NULL, 'o'},
 		{"port", required_argument, NULL, 'p'},
 		{"password", no_argument, NULL, 'W'},
@@ -124,7 +125,7 @@
 	pgdumploc = findPgDump(argv[0]);
 	pgdumpopts = createPQExpBuffer();
 
-	while ((c = getopt_long(argc, argv, "acdDgh:iop:sU:vWx", long_options, &optindex)) != -1)
+	while ((c = getopt_long(argc, argv, "acdDgh:iNop:sU:vWx", long_options, &optindex)) != -1)
 	{
 		switch (c)
 		{
@@ -156,6 +157,10 @@
 				appendPQExpBuffer(pgdumpopts, " -%c", c);
 				break;
 
+			case 'N':
+				appendPQExpBuffer(pgdumpopts, " -N");
+				break;
+
 			case 'p':
 				pgport = optarg;
 				appendPQExpBuffer(pgdumpopts, " -p '%s'", pgport);
@@ -243,6 +248,7 @@
 	printf(_("  -g, --globals-only       dump only global objects, no databases\n"));
 	printf(_("  -i, --ignore-version     proceed even when server version mismatches\n"
 			 "                           pg_dumpall version\n"));
+	printf(_("  -N, --convert-now        convert DEFAULT 'now' to DEFAULT now()\n"));
 	printf(_("  -s, --schema-only        dump only the schema, no data\n"));
 	printf(_("  -o, --oids               include OIDs in dump\n"));
 	printf(_("  -v, --verbose            verbose mode\n"));
diff -ruN postgresql-7.4.6-orig/src/include/Makefile postgresql-7.4.6-3/src/include/Makefile
--- postgresql-7.4.6-orig/src/include/Makefile	2003-11-25 20:10:15.000000000 +0100
+++ postgresql-7.4.6-3/src/include/Makefile	2005-03-10 23:38:56.000000000 +0100
@@ -79,8 +79,8 @@
 
 
 uninstall:
-	rm -f $(addprefix $(DESTDIR)$(includedir)/, pg_config.h pg_config_os.h postgres_ext.h libpq/libpq-fs.h)
-	rm -f $(addprefix $(DESTDIR)$(includedir_internal)/, c.h postgres_fe.h lib/dllist.h libpq/pqcomm.h)
+	rm -f $(addprefix $(DESTDIR)$(includedir)/, pg_config.h pg_config_manual.h pg_config_os.h postgres_ext.h libpq/libpq-fs.h)
+	rm -f $(addprefix $(DESTDIR)$(includedir_internal)/, c.h port.h postgres_fe.h lib/dllist.h libpq/pqcomm.h)
 # heuristic...
 	rm -rf $(addprefix $(DESTDIR)$(includedir_server)/, $(SUBDIRS) *.h)
 
diff -ruN postgresql-7.4.6-orig/src/include/pg_config_manual.h postgresql-7.4.6-3/src/include/pg_config_manual.h
--- postgresql-7.4.6-orig/src/include/pg_config_manual.h	2003-09-21 19:57:21.000000000 +0200
+++ postgresql-7.4.6-3/src/include/pg_config_manual.h	2005-03-09 15:56:11.000000000 +0100
@@ -165,7 +165,7 @@
  * here's where to twiddle it.  You can also override this at runtime
  * with the postmaster's -k switch.
  */
-#define DEFAULT_PGSOCKET_DIR  "/tmp"
+#define DEFAULT_PGSOCKET_DIR  "/var/run/postgresql"
 
 /*
  * Defining this will make float4 and float8 operations faster by
diff -ruN postgresql-7.4.6-orig/src/include/port/linux.h postgresql-7.4.6-3/src/include/port/linux.h
--- postgresql-7.4.6-orig/src/include/port/linux.h	2003-10-26 02:41:10.000000000 +0100
+++ postgresql-7.4.6-3/src/include/port/linux.h	2005-03-09 15:56:11.000000000 +0100
@@ -48,4 +48,12 @@
 
 #define HAS_TEST_AND_SET
 
+#elif defined(__hppa__)
+typedef struct
+{
+	int			sema[4];
+} slock_t;
+
+#define HAS_TEST_AND_SET
+
 #endif
diff -ruN postgresql-7.4.6-orig/src/include/storage/s_lock.h postgresql-7.4.6-3/src/include/storage/s_lock.h
--- postgresql-7.4.6-orig/src/include/storage/s_lock.h	2003-11-04 10:43:56.000000000 +0100
+++ postgresql-7.4.6-3/src/include/storage/s_lock.h	2005-03-09 15:56:11.000000000 +0100
@@ -125,7 +125,7 @@
 	__asm__ __volatile__(
 		"	xchg4 	%0=%1,%2	\n"
 :		"=r"(ret), "=m"(*lock)
-:		"r"(1), "1"(*lock)
+:		"r"(1), "m"(*lock)
 :		"memory");
 
 	return (int) ret;
@@ -151,6 +151,29 @@
 
 #endif	 /* __arm__ */
 
+#if defined(__hppa__)
+/*
+ *  * HP PA-RISC Linux
+ *   */
+#define TAS(lock)          tas(lock)
+#define TAS_ACTIVE_WORD(lock)   ((volatile int *) (((long) (lock) + 15) & ~15))
+#define S_UNLOCK(lock)  (*TAS_ACTIVE_WORD(lock) = -1)
+                                                                                
+static __inline__ int
+tas(volatile slock_t *lock)
+{
+	        volatile int *lockword = TAS_ACTIVE_WORD(lock);
+		        register int lockval;
+			                                                                                
+			        __asm__ __volatile__(
+						                "       ldcwx   0(0,%2),%0      \n"
+								:               "=r"(lockval), "=m"(*lockword)
+								:               "r"(lockword));
+				        return (lockval == 0);
+}
+                                                                                
+#endif   /* __hppa__ */
+                                                                                
 
 #if defined(__s390__) && !defined(__s390x__)
 /*
@@ -271,7 +294,7 @@
 		"	tas		%1		\n"
 		"	sne		%0		\n"
 :		"=d"(rv), "=m"(*lock)
-:		"1"(*lock)
+:		"m"(*lock)
 :		"cc");
 
 	return rv;
diff -ruN postgresql-7.4.6-orig/src/interfaces/libpq/Makefile postgresql-7.4.6-3/src/interfaces/libpq/Makefile
--- postgresql-7.4.6-orig/src/interfaces/libpq/Makefile	2003-09-27 17:32:48.000000000 +0200
+++ postgresql-7.4.6-3/src/interfaces/libpq/Makefile	2005-03-09 15:56:11.000000000 +0100
@@ -35,7 +35,7 @@
 SHLIB_LINK += $(filter -lcrypt -ldes -lkrb -lcom_err -lcrypto -lk5crypto -lkrb5 -lssl -lsocket -lnsl -lresolv -lintl, $(LIBS)) $(THREAD_LIBS)
 
 
-all: all-lib
+all: all-lib libpq3-config
 
 # Shared library stuff
 include $(top_srcdir)/src/Makefile.shlib
@@ -61,6 +61,8 @@
 encnames.c wchar.c : % : $(backend_src)/utils/mb/%
 	rm -f $@ && $(LN_S) $< .
 
+libpq3-config:
+	sed -e "s|%LIBRARIES%|$(SHLIB_LINK)|" <libpq3-config.in | sed "s/-L[^ ]\+ //" >libpq3-config
 
 install: all installdirs install-lib
 	$(INSTALL_DATA) $(srcdir)/libpq-fe.h $(DESTDIR)$(includedir)
@@ -76,3 +78,4 @@
 
 clean distclean maintainer-clean: clean-lib
 	rm -f $(OBJS) crypt.c getaddrinfo.c inet_aton.c snprintf.c strerror.c path.c thread.c dllist.c md5.c ip.c encnames.c wchar.c
+	rm -f libpq3-config
diff -ruN postgresql-7.4.6-orig/src/interfaces/libpq/libpq3-config.in postgresql-7.4.6-3/src/interfaces/libpq/libpq3-config.in
--- postgresql-7.4.6-orig/src/interfaces/libpq/libpq3-config.in	1970-01-01 01:00:00.000000000 +0100
+++ postgresql-7.4.6-3/src/interfaces/libpq/libpq3-config.in	2005-03-09 15:56:11.000000000 +0100
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+echo %LIBRARIES%
diff -ruN postgresql-7.4.6-orig/src/makefiles/Makefile.linux postgresql-7.4.6-3/src/makefiles/Makefile.linux
--- postgresql-7.4.6-orig/src/makefiles/Makefile.linux	2003-06-05 18:07:25.000000000 +0200
+++ postgresql-7.4.6-3/src/makefiles/Makefile.linux	2005-03-09 15:56:11.000000000 +0100
@@ -5,11 +5,7 @@
 allow_nonpic_in_shlib = yes
 DLSUFFIX = .so
 
-ifeq "$(findstring sparc,$(host_cpu))" "sparc"
 CFLAGS_SL = -fPIC
-else
-CFLAGS_SL = -fpic
-endif
 
 %.so: %.o
 	$(CC) -shared -o $@ $<
diff -ruN postgresql-7.4.6-orig/src/pl/plperl/GNUmakefile postgresql-7.4.6-3/src/pl/plperl/GNUmakefile
--- postgresql-7.4.6-orig/src/pl/plperl/GNUmakefile	2004-01-21 20:25:11.000000000 +0100
+++ postgresql-7.4.6-3/src/pl/plperl/GNUmakefile	2005-03-09 15:56:11.000000000 +0100
@@ -9,6 +9,9 @@
 shared_libperl = yes
 endif
 
+# Line addded for Debian - needed for any Linux build, I believe
+CFLAGS += -D_GNU_SOURCE
+
 # If we don't have a shared library and the platform doesn't allow it
 # to work without, we have to skip it.
 ifneq (,$(findstring yes, $(shared_libperl)$(allow_nonpic_in_shlib)))
diff -ruN postgresql-7.4.6-orig/src/test/regress/pg_regress.sh postgresql-7.4.6-3/src/test/regress/pg_regress.sh
--- postgresql-7.4.6-orig/src/test/regress/pg_regress.sh	2003-11-02 22:56:15.000000000 +0100
+++ postgresql-7.4.6-3/src/test/regress/pg_regress.sh	2005-03-09 15:56:11.000000000 +0100
@@ -382,6 +382,10 @@
         (exit 2); exit
     fi
 
+ 
+    echo "unix_socket_directory = '/tmp'" >>$PGDATA/postgresql.conf
+    psql_options="$psql_options --host=/tmp"
+
 
     # ----------
     # Start postmaster
diff -ruN postgresql-7.4.6-orig/src/tutorial/Makefile postgresql-7.4.6-3/src/tutorial/Makefile
--- postgresql-7.4.6-orig/src/tutorial/Makefile	2002-09-05 20:28:46.000000000 +0200
+++ postgresql-7.4.6-3/src/tutorial/Makefile	2005-03-09 15:56:11.000000000 +0100
@@ -6,15 +6,15 @@
 # IDENTIFICATION
 #    $Header$
 #
+# Please note that this Makefile was modified for Debian to allow
+# compilation in an arbitrary directory and without the complete
+# PostgreSQL source tree.
 #-------------------------------------------------------------------------
 
-subdir = src/tutorial
-top_builddir = ../..
-include $(top_builddir)/src/Makefile.global
-
-override CFLAGS+= $(CFLAGS_SL)
-SHLIB_LINK = $(BE_DLLLIBS)
-
+DLSUFFIX=.so
+INCLUDES= -I/usr/include/postgresql/ -I/usr/include/postgresql/server/
+CC= gcc $(INCLUDES)
+ 
 #
 # DLOBJS are the dynamically-loaded object files.  The "funcs" queries
 # include CREATE FUNCTIONs that load routines from these files.
@@ -25,6 +25,9 @@
 
 all: $(DLOBJS) $(QUERIES)
 
+%$(DLSUFFIX): %.c
+	$(CC) -shared -o $@ $<
+
 %.sql: %.source
 	rm -f $@; \
 	C=`pwd`; \
@@ -32,3 +35,5 @@
 
 clean distclean maintainer-clean:
 	rm -f $(DLOBJS) $(QUERIES)
+
+.PHONY: clean distclean maintainer-clean
diff -ruN postgresql-7.4.6-orig/src/tutorial/README postgresql-7.4.6-3/src/tutorial/README
--- postgresql-7.4.6-orig/src/tutorial/README	2001-10-26 22:45:33.000000000 +0200
+++ postgresql-7.4.6-3/src/tutorial/README	2005-03-09 15:56:11.000000000 +0100
@@ -2,10 +2,16 @@
 	% make
 to compile all the scripts and C files for the user-defined functions
 and types.  (make needs to be GNU make --- it may be named something
-different on your system, often gmake)
+different on your system, often gmake.) The package postgresql-dev
+must be installed for the tutorials to compile.
 
 Then, run psql with the -s (single-step) flag:
 	% psql -s
 
 From within psql, you can try each individual script file by using
 psql's \i <filename> command.
+
+Please note that you need database superuser privileges to execute the
+examples which load dynamic libraries ('funcs' and 'complex') since
+the language C is usually not 'trusted', i. e. may not be used by
+normal users.