Make changes and bug fixes to let compilation and regression run on smartos
authorPavan Deolasee <[email protected]>
Mon, 11 Apr 2016 05:14:59 +0000 (10:44 +0530)
committerPavan Deolasee <[email protected]>
Mon, 11 Apr 2016 05:14:59 +0000 (10:44 +0530)
We don't yet officially support the platform, given very little testing done so
far on this platform. But we don't stop others to doing it either. So
committing these changes upstream.

Reports, investigation and patches by Patrick SodrĂ©.

12 files changed:
.gitignore
src/backend/executor/nodeAgg.c
src/backend/pgxc/pool/pgxcnode.c
src/backend/pgxc/pool/poolcomm.c
src/backend/utils/adt/dbsize.c
src/backend/utils/sort/tuplesort.c
src/gtm/gtm_ctl/Makefile
src/gtm/main/Makefile
src/gtm/proxy/Makefile
src/interfaces/libpq/fe-auth.c
src/port/getpeereid.c
src/test/regress/resultmap

index 13c4bde5e6c32d3082d26ca3bbf7aaf191b65121..12b9d98152b10ab8e4bc78221db363b2096731ec 100644 (file)
@@ -27,6 +27,7 @@ win32ver.rc
 lib*dll.def
 *~
 lib*.pc
+tags
 
 # Local excludes in root directory
 /GNUmakefile
@@ -41,3 +42,4 @@ lib*.pc
 /cscope*
 /.gitignore
 /tmp_install/
+.tags
index 30d6efacb271517d8ce17eb5d17b8636b9382ce7..6b5dc56a0af9551792a5da0fa1032c5d8f4cda76 100644 (file)
@@ -1117,10 +1117,14 @@ finalize_aggregate(AggState *aggstate,
                         * copy the initial datum since it might get changed inside the
                         * collection function
                         */
-                       fcinfo.arg[0] = datumCopy(peraggstate->initCollectValue,
-                                                            peraggstate->collecttypeByVal,
-                                                            peraggstate->collecttypeLen);
                        fcinfo.argnull[0] = peraggstate->initCollectValueIsNull;
+                       fcinfo.arg[0] = (Datum) NULL;
+                       if (!fcinfo.argnull[0])
+                       {
+                               fcinfo.arg[0] = datumCopy(peraggstate->initCollectValue,
+                                                               peraggstate->collecttypeByVal,
+                                                               peraggstate->collecttypeLen);
+                       }
                        value = FunctionCallInvoke(&fcinfo);
                        isnull = fcinfo.isnull;
                }
index ee8be9b837a280d087c4fda3323de98c2d9b0c65..7b9b7855abf4b755c5fc9cd245438d16e9ddba3d 100644 (file)
 #include "postgres.h"
 #include <poll.h>
 
+#ifdef __sun
+#include <sys/filio.h>
+#endif
+
 #include <sys/time.h>
 #include <sys/types.h>
 #include <sys/ioctl.h>
index 29f88df55dff4c540842254682644384c98aaef2..ddc58b4a9648f7b242d2e680de052c030a462fbe 100644 (file)
  *-------------------------------------------------------------------------
  */
 
+#ifdef __sun
+#define _XOPEN_SOURCE 500
+#define uint uint32_t
+#endif
+
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/uio.h>
index 4021f8fb39ed8b5efbcc34613b1663fae311eda1..50daac1f2b59ee85b9c6875b9c49f31509733225 100644 (file)
@@ -1021,6 +1021,7 @@ pgxc_execute_on_nodes(int numnodes, Oid *nodelist, char *query)
        int64           total_size = 0;
        int64           size = 0;
        Datum                   datum = (Datum) 0;
+       bool            isnull = true;
 
 #ifdef XCP
        EState             *estate;
@@ -1082,13 +1083,27 @@ pgxc_execute_on_nodes(int numnodes, Oid *nodelist, char *query)
        MemoryContextSwitchTo(oldcontext);
 
        result = ExecRemoteQuery(pstate);
-       while (!TupIsNull(result))
+       while (result != NULL && !TupIsNull(result))
        {
-               bool isnull;
                datum = slot_getattr(result, 1, &isnull);
-               size = DatumGetInt64(datum);
-                total_size += size;
                result = ExecRemoteQuery(pstate);
+
+               /* For single node, don't assume the type of datum. It can be bool also. */
+               if (numnodes == 1)
+                       continue;
+               /* We should not cast a null into an int */
+               if (isnull)
+               {
+                       ereport(ERROR,
+                                       (errcode(ERRCODE_INTERNAL_ERROR),
+                                        errmsg("Expected Int64 but got null instead "
+                                               "while executing query '%s'",
+                                               query)));
+                       break;
+               }
+
+               size = DatumGetInt64(datum);
+               total_size += size;
        }
        ExecEndRemoteQuery(pstate);
 #else
@@ -1136,7 +1151,15 @@ pgxc_execute_on_nodes(int numnodes, Oid *nodelist, char *query)
 #endif
 
        if (numnodes == 1)
+       {
+               if (isnull)
+                       ereport(ERROR,
+                                       (errcode(ERRCODE_INTERNAL_ERROR),
+                                        errmsg("Expected datum but got null instead "
+                                               "while executing query '%s'",
+                                               query)));
                PG_RETURN_DATUM(datum);
+       }
        else
                PG_RETURN_INT64(total_size);
 }
index 1810df4e9ec2a9167da5e8396926599dd43f6a09..f9716f58811934a4b22d3e4ceb5771b014db5af9 100644 (file)
@@ -1075,7 +1075,7 @@ tuplesort_begin_merge(TupleDesc tupDesc,
        state->mergenext = (int *) palloc0(combiner->conn_count * sizeof(int));
        state->mergelast = (int *) palloc0(combiner->conn_count * sizeof(int));
        state->mergeavailslots = (int *) palloc0(combiner->conn_count * sizeof(int));
-       state->mergeavailmem = (long *) palloc0(combiner->conn_count * sizeof(long));
+       state->mergeavailmem = (int64 *) palloc0(combiner->conn_count * sizeof(int64));
 
        state->tp_runs = (int *) palloc0(combiner->conn_count * sizeof(int));
        state->tp_dummy = (int *) palloc0(combiner->conn_count * sizeof(int));
index 03bd792a0721f8db6eeddd38fd7cbe53ea415c5c..cece470f919d14d07ab3783c3f9287a55b2da2ca 100644 (file)
@@ -11,14 +11,10 @@ top_builddir=../../..
 include $(top_builddir)/src/Makefile.global
 subdir = src/gtm/gtm_ctl
 
-OBJS=gtm_ctl.o 
+OBJS=gtm_ctl.o
 
 OTHERS=../common/libgtm.a ../libpq/libpqcomm.a ../client/libgtmclient.a ../path/libgtmpath.a
 
-LDFLAGS=-L$(top_builddir)/common -L$(top_builddir)/libpq
-
-
-LIBS=-lpthread
 
 gtm_ctl:$(OBJS)
        $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) $^ $(OTHERS) -o gtm_ctl
index ebd22fc2d89ced786816ce557ec281d2d53ed002..61ceffac2be30106dc0e9f1fc88000ddf5c2dbb0 100644 (file)
@@ -17,11 +17,7 @@ endif
 
 OBJS=main.o gtm_thread.o gtm_txn.o gtm_seq.o gtm_snap.o gtm_standby.o gtm_opt.o gtm_backup.o
 
-OTHERS= ../libpq/libpqcomm.a ../path/libgtmpath.a ../recovery/libgtmrecovery.a ../client/libgtmclient.a ../common/libgtm.a ../../port/libpgport.a 
-
-LDFLAGS=-L$(top_builddir)/common -L$(top_builddir)/libpq
-
-LIBS=-lpthread
+OTHERS= ../libpq/libpqcomm.a ../path/libgtmpath.a ../recovery/libgtmrecovery.a ../client/libgtmclient.a ../common/libgtm.a ../../port/libpgport.a
 
 gtm:$(OBJS)
        $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) $^ $(OTHERS) -o gtm
index ee0aa1cdd8aecec2c27695808367e58768e1b0fc..e03d07ff646a632feb5f8ff2a26703606cbf5fa9 100644 (file)
@@ -19,10 +19,6 @@ OBJS=proxy_main.o proxy_thread.o proxy_utils.o gtm_proxy_opt.o
 
 OTHERS= ../libpq/libpqcomm.a ../path/libgtmpath.a ../client/libgtmclient.a ../common/libgtm.a
 
-LDFLAGS=-L$(top_builddir)/common -L$(top_builddir)/libpq
-
-LIBS=-lpthread
-
 gtm_proxy:$(OBJS)
        $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) $^ $(OTHERS) ../../port/libpgport_srv.a -o gtm_proxy
 
index 5891c75bce2df6786345745668b797aec74026c5..6df4357041d8f4a044a42815622811c6324e4f9b 100644 (file)
@@ -30,6 +30,9 @@
 #include <sys/param.h>                 /* for MAXHOSTNAMELEN on most */
 #include <sys/socket.h>
 #ifdef HAVE_SYS_UCRED_H
+#ifdef __sun
+#include <procfs.h>
+#endif
 #include <sys/ucred.h>
 #endif
 #ifndef  MAXHOSTNAMELEN
index 126b5c6d8df5a04c0e01cf4e8f537f55edd161f8..f592b56b5502e6373ea66bbbedb73bc6b5626222 100644 (file)
@@ -24,6 +24,9 @@
 #include <ucred.h>
 #endif
 #ifdef HAVE_SYS_UCRED_H
+#ifdef __sun
+#include <procfs.h>
+#endif
 #include <sys/ucred.h>
 #endif
 
index 04ba99fe3388d1a4ed0dafe3c0a603ed05045570..2e54ed22460e441cb055a56fe7be71beff301181 100644 (file)
@@ -15,3 +15,4 @@ int8:out:i.86-pc-mingw32=int8-exp-three-digits.out
 int8:out:x86_64-w64-mingw32=int8-exp-three-digits.out
 int8:out:i.86-w64-mingw32=int8-exp-three-digits.out
 int8:out:i.86-pc-win32vc=int8-exp-three-digits.out
+aggregates:out:i386-pc-solaris2.11=aggregates-float-sunos.out