1. 12 2月, 2016 7 次提交
    • H
      Misc header file cleanup · 442c105e
      Heikki Linnakangas 提交于
      Remove unnecessary #includes, add #includes that are actually needed by
      some headers.
      442c105e
    • H
      Remove unnecessary MemoryContext arguments from cdbpartition functions. · d1765734
      Heikki Linnakangas 提交于
      We always passed CurrentMemoryContext for them, so might as well remove
      the parameter, making the code more readable, and always allocate the
      return values in CurrentMemoryContext.
      d1765734
    • H
      Remove unnecessary __cplusplus guards from C files. · 48e60c81
      Heikki Linnakangas 提交于
      These are always compiled directly with C compiler. There's no prospect
      of including these in a C++ file.
      48e60c81
    • H
      Clean up postgres.h usage. · e9b2e84a
      Heikki Linnakangas 提交于
      The correct way is that:
      
      * Every .c file does '#include "postgres.h"', before anything else. After
        that, you can include any system header files (e.g. unistd.h). And after
        that, any other PostgreSQL/GPDB header files.
      
      * Header files should not contain '#include "postgres.h"', as that's done
        in the .c files.
      e9b2e84a
    • H
      Remove unnecessary #includes. · 9aa7a22f
      Heikki Linnakangas 提交于
      In cdbcat.h, include only the header files that are actually needed for
      the single function prototype in that file. And don't include cdbcat.h
      unnecessarily. A couple of .c files were including cdbcat.h to get
      GpPolicy, but that's actually defined in catalog/gp_policy.h, so #include
      that directly instead where needed.
      9aa7a22f
    • H
      Replace "uint" type with uint32 or unsigned int. · ce33af22
      Heikki Linnakangas 提交于
      "uint" is not a standard C type, so it might not be available on all
      platforms. Indeed, we had a typedef for WIN32 for that. But there's no reason
      to use "uint", might as well just use the C standard "unsigned int", or the
      PostgreSQL-specific uint32. Makes the intention more clear too, IMHO.
      ce33af22
    • H
      Remove unnecessary cdbanalyze.h and cdblogsync.h header files. · b6230cab
      Heikki Linnakangas 提交于
      None of the functions declared in cdblogsync exist, nor are used for
      anything. cdbanalyze.h didn't contain any prototypes, it just #included
      two other headers, so better to #include those directly where needed.
      b6230cab
  2. 11 2月, 2016 7 次提交
    • G
      Fixed segspace ICG test to work with new optimizer. · b7e0335f
      George Caragea 提交于
      Closes #299.
      b7e0335f
    • D
      Merge upto 'eecbb332' from PostgreSQL 8.3 · 7e7ffa8d
      Daniel Gustafsson 提交于
      All patches in this set were either doc commits or already merged except
      the moving of the fsync macros from xlog.c to xlogdefs.h. GPDB had already
      moved parts to xlog.h so revert these changes and sync with how the macros
      are defined upstream.
      
       Conflicts:
      	doc/TODO
      	doc/src/FAQ/TODO.html
      	doc/src/sgml/func.sgml
      	doc/src/sgml/indices.sgml
      	src/backend/access/transam/xlog.c
      	src/backend/executor/execAmi.c
      	src/backend/executor/nodeResult.c
      	src/backend/utils/adt/formatting.c
      	src/include/executor/nodeResult.h
      	src/test/regress/expected/xml.out
      	src/test/regress/expected/xml_1.out
      	src/test/regress/sql/xml.sql
      	src/tools/fsync/test_fsync.c
      	src/tools/msvc/Solution.pm
      	src/tools/msvc/config.pl
      7e7ffa8d
    • D
      Fix regression in pathkey reconstruction from EC merge · 54c72196
      Daniel Gustafsson 提交于
      Finding the tle is a case for breaking the loop early but not finding
      isn't a failure case. This elog() breaks the following query in the
      gp_dqa testcase when found is properly initiated to false before the
      loop.
      
      select count(distinct c), count(distinct dt), i from dqa_t1 group by i;
      
      When not initiated at all the variable was likely to not be false
      from randomness and the test didnt fail.
      54c72196
    • D
      Fix a set of compiler warnings in gpopt · 074446fc
      Daniel Gustafsson 提交于
      Without altering functionality, fix a set of compiler warnings in
      gpopt: Properly return in non-void function, remove non-function
      invocation of variable and use the right formatter for ULLONG when
      printing.
      074446fc
    • D
      Merge upto '5c63829f' from PostgreSQL 8.3 · d562d826
      Daniel Gustafsson 提交于
      This commit merges a large rewrite of the foreign-key mechanism to properly
      enforce the equality check. Instead of selecting an operator named "=" the
      equality operator will now be selected from the opfamily of the unique
      index that the foreign key depends on. Given how GPDB handles foreign keys
      and referential integrity this isn't introducing changes but rather brings
      in a good scaffolding for future work.
      
      Other patches are minor spelling fixes on GUCs and some doc changes.
      
       Conflicts:
      	doc/TODO
      	doc/src/FAQ/TODO.html
      	doc/src/sgml/catalogs.sgml
      	doc/src/sgml/trigger.sgml
      	src/backend/catalog/aclchk.c
      	src/backend/catalog/dependency.c
      	src/backend/catalog/index.c
      	src/backend/catalog/namespace.c
      	src/backend/catalog/pg_constraint.c
      	src/backend/catalog/pg_conversion.c
      	src/backend/commands/conversioncmds.c
      	src/backend/commands/tablecmds.c
      	src/backend/commands/trigger.c
      	src/backend/commands/typecmds.c
      	src/backend/tcop/utility.c
      	src/backend/utils/adt/ri_triggers.c
      	src/backend/utils/adt/ruleutils.c
      	src/backend/utils/cache/syscache.c
      	src/bin/pg_dump/pg_dump.c
      	src/bin/psql/describe.c
      	src/include/catalog/catversion.h
      	src/include/catalog/pg_constraint.h
      	src/include/utils/rel.h
      	src/include/utils/syscache.h
      	src/test/regress/expected/alter_table.out
      	src/test/regress/expected/foreign_key.out
      	src/test/regress/sql/alter_table.sql
      d562d826
    • H
      Fix planner bug introduced by the equivalence classes merge. · adc71b9c
      Heikki Linnakangas 提交于
      A typo caused the planner to not always recognize that the distribution
      keys of an outer join match. That would not lead to incorrect results, but
      it did lead to unnecessary Motion nodes in some cases.
      
      Fixes issue #340. Thanks @liruto!
      adc71b9c
    • A
      Check EOF values for AO/CO before updating aoseg table. · 422df5ea
      Ashwin Agrawal 提交于
      For AO/CO tables due to functional nature, new EOF value to be updated
      must always be greater than current value. Currently, this check is
      performed on persistent table update but it happens as part of Commit-Prepared.
      So its super too late to take any action, even if we detect it can only PANIC
      the system and already resulted in data corruption for reads as aoseg has been
      updated and transaction commited. Hence moving the check while updating the
      aoseg table, when such case is detected now transaction can be aborted without
      impacting the system or already loaded data in table.
      422df5ea
  3. 10 2月, 2016 4 次提交
    • H
      Speed up gpinitsystem slightly. · a19e0e7e
      Heikki Linnakangas 提交于
      * Remove an unnecessary sleep 2
      * Perform the lookup of master hostname only once
      a19e0e7e
    • H
      Use upstream ANALYZE code. · f995c59f
      Heikki Linnakangas 提交于
      This replaces most of the Greenplum code used to ANALYZE a relation with
      the upstream implementation.
      
      I did not adopt the upstream block-sampling method of collecting the
      sample, however. That would difficult to make work with GPDB, because the
      upstream code won't work as is with Append-only tables, and we would also
      need to somehow dispatch the block-sampling to all the segments. So the
      simplistic "SELECT ... WHERE random() < threshold" method is still used to
      collect the sample. However, it's now just a straightforward read-only
      query, we no longer create a table to hold the sample, which makes it a lot
      cheaper for small tables.
      
      This should make merging with upstream easier. This should also speed up
      ANALYZE considerably, as we now collect the sample of rows in one query,
      and calculate the stats for each column in-memory, instead of issuing
      separate queries for each column.
      f995c59f
    • H
      Simplify InitPlan elimination test case, and make its output more stable. · 17ed5d4d
      Heikki Linnakangas 提交于
      The test query used system tables pg_class and gp_configuration, which is
      fine, except that the cost of scanning pg_class can vary widely, depending
      on previous regression tests and the amount of relations created in them.
      That made the output of the case a bit unstable; the planner might swap
      the inner and outer sides of the nestloop join between pg_class and
      gp_configuration, depending on the circumstances. That has been stable
      so far, but started to cause grief on another patch I'm working on, which
      changes the way ANALYZE works, because apparently it changed the statistics
      collected for pg_class sligthly.
      
      To fix, replace pg_class and gp_configuration in the test query with regular
      tables, created specifically for the test case. While we're at it, simplify
      the query a little bit, and also add a comment explaining what the purpose
      of the test is. There doesn't actually seem to be any need to do EXPLAIN
      here, the query produces wrong results if the bug is present, so get rid
      of that too.
      
      I tested this by reverting the changes that fixed the original bug this test
      query was added for, and verifying that the new query also produces wrong
      results with that.
      17ed5d4d
    • C
      Fix gptransfer tests for partition tables · b7c7b7bd
      Chumki Roy 提交于
      b7c7b7bd
  4. 09 2月, 2016 9 次提交
    • H
      Clean up the Vacuum and Analyze related structs. · b1b8cbde
      Heikki Linnakangas 提交于
      Revert the VacAttrStats struct to look the same as in upstream. As a
      consequence, we have to also revert the GPDB-specific changes to PostGIS
      typanalyze functions. VacAttrStats is part of the public API for
      type-specific typanalyze functions, so it's nice to revert that back the
      way it is in the upstream, to make custom datatypes written for PostgreSQL
      more easily portable to GPDB.
      
      To my surprise, the VacAttrStats struct isn't currently used for anything,
      so the changes to it were quite superfluous to begin with. That is to say,
      we don't currently use type-specific typanalyze functions at all. That's
      about to change, as part of a separate patch I'm working on to revert most
      of analyze.c to use upstream code.
      
      Also remove the unused VPgStatisticsStats struct, and the unnecessary
      abstraction where VUpdateStats can be either VPgClassStats or
      VPgStatisticsStats.
      b1b8cbde
    • A
      Fix crash-recovery of B-tree split records. · 06c10110
      Ashwin Agrawal 提交于
      Merge of upstream B-tree split WAL-logging changes, broke the recovery
      incase of Btree split. The MirroredLock needs to held while manipulating
      buffer.
      06c10110
    • H
      Fix error-handling in dumpDatabaseDefinitions[ToDDBoost]() functions · 2156a304
      Heikki Linnakangas 提交于
      Coverity pointed out that pszBackupFileName is referenced after free() in
      the error path, in dumpDatabaseDefinition(). Testing shows that the
      following fprintf() call will also segfault if the file could not be
      created. In general, we should not try to continue running if one of these
      files could not be created, so add exit_nicely() calls to the error paths.
      2156a304
    • A
      Fix race condition while preparing transaction instead of serializing prepares. · 75b2d55d
      Ashwin Agrawal 提交于
      Removed the locking and some more cleanups.
      Avoid looping again in FinishPrepared Transaction. prepare_lsn to commit
      the transaction can be found using gxact which we have locked, seems
      pointless to loop around again to scan the list.
      
      This is modified patch for GPDB based on postgres patch:
      https://github.com/postgres/postgres/commit/bb38fb0d43c8d7ff54072bfd8bd63154e536b384#diff-3ed77c70e54e7f56eff48f6157aba91e
      Original Patch commit message:
      To lock a prepared transaction's shared memory entry, we used to mark it
      with the XID of the backend. When the XID was no longer active according
      to the proc array, the entry was implicitly considered as not locked
      anymore. However, when preparing a transaction, the backend's proc array
      entry was cleared before transfering the locks (and some other state) to
      the prepared transaction's dummy PGPROC entry, so there was a window where
      another backend could finish the transaction before it was in fact fully
      prepared.
      
      To fix, rewrite the locking mechanism of global transaction entries. Instead
      of an XID, just have simple locked-or-not flag in each entry (we store the
      locking backend's backend id rather than a simple boolean, but that's just
      for debugging purposes). The backend is responsible for explicitly unlocking
      the entry, and to make sure that that happens, install a callback to unlock
      it on abort or process exit.
      75b2d55d
    • C
      Change gptransfer tests due to catalog changes · fe8907f6
      Chumki Roy 提交于
      fe8907f6
    • H
      Improve the logging of SPLIT_R records. · 8789df0f
      Heikki Linnakangas 提交于
      Not sure why the upstream version didn't print all the same block number
      information for B-tree SPLIT_R records that it did for SPLIT_L records,
      but seems like an oversight.
      8789df0f
    • H
      Fix xlogdump to work with Greenplum. · 536d9bb9
      Heikki Linnakangas 提交于
      536d9bb9
    • H
      Import latest version of xlogdump from upstream project. · 1ecf4ab6
      Heikki Linnakangas 提交于
      https://github.com/snaga/xlogdump.git, commit id
      f534a9f6f70ffb691129a9e9ad0b9a85fdef403c
      1ecf4ab6
    • H
      Fix change-tracking of B-tree split records. · 3d62577a
      Heikki Linnakangas 提交于
      This was intentionally left broken by the merge of upstream B-tree split
      WAL-logging changes. Should work now.
      3d62577a
  5. 08 2月, 2016 8 次提交
    • H
      Fix crash if a distribution hash expression contains a subplan. · 21f2dd49
      Heikki Linnakangas 提交于
      We explicitly checked if the subplan was projection-capable, and added
      the hash expression ot the subplan's target list if it was. But projecting
      the hash expression is not optional, you get a crash if you don't do it. So
      instead of doing it only when the subplan is projection-capable, insert a
      Result node if needed.
      21f2dd49
    • H
      Update GPORCA to version 1.621. · 8e7a7a1f
      Heikki Linnakangas 提交于
      This version changes the spelling of the error message of violating a NOT
      NULL-constraint, to match the message of the same error in the executor, so
      those differences in regression test expected output can now be reverted.
      8e7a7a1f
    • D
      Merge upto '65e2f550' from PostgreSQL 8.3 · bb8fe443
      Daniel Gustafsson 提交于
      Most of the patches in this merge were already cherry-picked into GPDB, the
      changes merged are a fix for disallowing committing prepared transactions
      cross database, followup fixes for the Makefile =/:= patches, an infinite
      recursion fix in plan tree dumps and some documentation fixes.
      
       Conflicts:
      	contrib/fuzzystrmatch/fuzzystrmatch.c
      	doc/TODO
      	doc/src/FAQ/TODO.html
      	src/Makefile.shlib
      	src/backend/libpq/pqcomm.c
      	src/backend/optimizer/README
      	src/backend/optimizer/geqo/geqo_eval.c
      	src/backend/optimizer/path/joinrels.c
      	src/backend/optimizer/plan/initsplan.c
      	src/backend/postmaster/postmaster.c
      	src/backend/utils/adt/formatting.c
      	src/backend/utils/adt/xml.c
      	src/backend/utils/error/elog.c
      	src/bin/scripts/clusterdb.c
      	src/bin/scripts/reindexdb.c
      	src/bin/scripts/vacuumdb.c
      	src/include/utils/xml.h
      	src/interfaces/ecpg/ecpglib/execute.c
      	src/port/open.c
      	src/tools/msvc/Solution.pm
      	src/tools/msvc/clean.bat
      	src/tools/msvc/install.pl
      	src/tools/msvc/mkvcbuild.pl
      	src/tools/msvc/vcregress.bat
      bb8fe443
    • D
      abs() on an unsigned variable has no effect · 451e8a35
      Daniel Gustafsson 提交于
      Remove the abs() call since ackTime is unsigned (newRTT is as well)
      and thus can't be negative.
      
      Also took the liberty of removing comments that doesn't provide any
      value to the reader of the code, seems like dead code rather than
      documentation.
      451e8a35
    • D
      Remove unused functions · 2762d8ce
      Daniel Gustafsson 提交于
      2762d8ce
    • D
      Avoid using unitialized values in debug printing · 220aa193
      Daniel Gustafsson 提交于
      oldPersistentSerialNum and segmentFileNum are only initalized in the
      subsequent loop and printing them before the loop doesn't make any
      sense.
      220aa193
    • D
      Fix warning for unitialized use of variable · 992ec380
      Daniel Gustafsson 提交于
      This is preceeded by an elog(ERROR ..); call but the compiler will
      warn for a potential unitialized use so initialize to InvalidOid
      since it is the correct init value anyways.
      992ec380
    • D
      Fix misplaced right paren bugs in pgstatfuncs.c · 27e5a99e
      Daniel Gustafsson 提交于
      This is a cherry-pick (with slight massage) of the commit referenced below
      which would come eventually in the merge but was trivial enough to fix now.
      
        commit b2d80147d5a3d0a5815c5b8e63a6fd9cef17f4a7
        Author: Kevin Grittner <kgrittn@postgresql.org>
        Date:   Fri Dec 27 15:41:46 2013 -0600
      
            Fix misplaced right paren bugs in pgstatfuncs.c.
      
            The bug would only show up if the C sockaddr structure contained
            zero in the first byte for a valid address; otherwise it would
            fail to fail, which is probably why it went unnoticed for so long.
      
            Patch submitted by Joel Jacobson after seeing an article by Andrey
            Karpov in which he reports finding this through static code
            analysis using PVS-Studio.  While I was at it I moved a definition
            of a local variable referenced in the buggy code to a more local
            context.
      
            Backpatch to all supported branches.
      27e5a99e
  6. 06 2月, 2016 5 次提交