132 files added
103 files modified
| New file |
| | |
| | | # Reference point for ABI compliance checks |
| | | # |
| | | # This file lists commits on the current branch that break ABI compatibility in |
| | | # ways that have been deemed acceptable (e.g., removing an extern function with |
| | | # no third-party uses). The primary intent of this file is to control the ABI |
| | | # compliance checks on the buildfarm, but it also serves as a central location |
| | | # to document the justification for each. |
| | | # |
| | | # In general, entries should be added reactively after an abi-compliance-check |
| | | # buildfarm failure. It is important to verify the details of the breakage |
| | | # match expectations, as the first entry listed will become the updated ABI |
| | | # baseline point. |
| | | # |
| | | # Add new entries by adding the output of the following to the top of the file: |
| | | # |
| | | # $ git log --pretty=format:"%H%n#%n# %s%n# %cd%n#%n# <ADD JUSTIFICATION HERE>" $ABIBREAKGITHASH -1 --date=iso |
| | | # |
| | | # Be sure to replace "<ADD JUSTIFICATION HERE>" with details of your change and |
| | | # why it is deemed acceptable. |
| | | |
| | | 33e3de6d77e87d6c3c6f8f878dd8de42d37c3b8f |
| | | # |
| | | # Add file_extend_method=posix_fallocate,write_zeros. |
| | | # 2026-02-06 17:38:39 +1300 |
| | | # |
| | | # Modifying GUC tables isn't really an ABI break: the relevant object has |
| | | # incomplete type so its layout is unknown to other C translation units. |
| | | # |
| | | # Discussion: https://www.postgresql.org/message-id/flat/e1f0cd3b-0164-45f5-9705-e922e59df90f%40dunslane.net#8a350b54012c0042f9869d288e978cfe |
| | | |
| | | 492a69e1407029f8c673484f44aa719a63323d77 |
| | | # |
| | | # Reject ADD CONSTRAINT NOT NULL if name mismatches existing constraint |
| | | # 2026-02-03 12:33:29 +0100 |
| | | # |
| | | # This commit added the constraint name as a parameter to |
| | | # AdjustNotNullInheritance(), which it needed to verify that the new name |
| | | # matches the existing one. PGXN contained no calls to that function. |
| | | |
| | | c6ce4dcf9d3b7a8a89aca386124c473f98fc329e |
| | | # |
| | | # Fix trigger transition table capture for MERGE in CTE queries. |
| | | # 2026-01-24 11:30:48 +0000 |
| | | # |
| | | # This commit changed the TransitionCaptureState structure, replacing |
| | | # the "tcs_private" field with 3 separate fields. This structure can |
| | | # only be built using MakeTransitionCaptureState(), and PGXN contained |
| | | # no calls to MakeTransitionCaptureState() or uses of the |
| | | # TransitionCaptureState structure. |
| | | |
| | | bae8ca82fd00603ebafa0658640d6e4dfe20af92 |
| | | # |
| | | # Revisit cosmetics of "For inplace update, send nontransactional invalidations." |
| | | # 2025-12-15 12:19:53 -0800 |
| | | # |
| | | # This removed a CacheInvalidateHeapTupleInplace() parameter. PGXN contained |
| | | # no calls to that function. |
| | | |
| | | 00eb646ea43410e5df77fed96f4a981e66811796 |
| | | # |
| | | # Check for CREATE privilege on the schema in CREATE STATISTICS. |
| | | # 2025-11-10 09:00:00 -0600 |
| | | # |
| | | # This commit added a parameter to CreateStatistics(). We are unaware of any |
| | | # impacted third-party code. |
| | | |
| | | c8af5019bee5c57502db830f8005a01cba60fee0 |
| | | # |
| | | # Fix lookups in pg_{clear,restore}_{attribute,relation}_stats(). |
| | | # 2025-10-15 12:47:33 -0500 |
| | | # |
| | | # This commit replaced two functions related to lookups/privilege checks for |
| | | # the new stats stuff in v18 with RangeVarGetRelidExtended(). These functions |
| | | # were not intended for use elsewhere, exist in exactly one release (18.0), and |
| | | # do not have any known third-party callers. |
| | | |
| | | 9bbcec6030a2744d83311370ec92213fbd76e514 |
| | | # |
| | | # Translation updates |
| | | # 2025-09-22 14:18:56 +0200 |
| | | # |
| | | # This is the original ABI baseline point for REL_18_STABLE. |
| New file |
| | |
| | | """Additional CI configuration, using the starlark language. See |
| | | https://cirrus-ci.org/guide/programming-tasks/#introduction-into-starlark |
| | | |
| | | See also the starlark specification at |
| | | https://github.com/bazelbuild/starlark/blob/master/spec.md |
| | | |
| | | See also .cirrus.yml and src/tools/ci/README |
| | | """ |
| | | |
| | | load("cirrus", "env", "fs", "re", "yaml") |
| | | |
| | | |
| | | def main(): |
| | | """The main function is executed by cirrus-ci after loading .cirrus.yml and can |
| | | extend the CI definition further. |
| | | |
| | | As documented in .cirrus.yml, the final CI configuration is composed of |
| | | |
| | | 1) the contents of .cirrus.yml |
| | | |
| | | 2) computed environment variables |
| | | |
| | | 3) if defined, the contents of the file referenced by the, repository |
| | | level, REPO_CI_CONFIG_GIT_URL variable (see |
| | | https://cirrus-ci.org/guide/programming-tasks/#fs for the accepted |
| | | format) |
| | | |
| | | 4) .cirrus.tasks.yml |
| | | """ |
| | | |
| | | output = "" |
| | | |
| | | # 1) is evaluated implicitly |
| | | |
| | | |
| | | # Add 2) |
| | | additional_env = compute_environment_vars() |
| | | env_fmt = """ |
| | | ### |
| | | # Computed environment variables start here |
| | | ### |
| | | {0} |
| | | ### |
| | | # Computed environment variables end here |
| | | ### |
| | | """ |
| | | output += env_fmt.format(yaml.dumps({'env': additional_env})) |
| | | |
| | | |
| | | # Add 3) |
| | | repo_config_url = env.get("REPO_CI_CONFIG_GIT_URL") |
| | | if repo_config_url != None: |
| | | print("loading additional configuration from \"{}\"".format(repo_config_url)) |
| | | output += config_from(repo_config_url) |
| | | else: |
| | | output += "\n# REPO_CI_CONFIG_URL was not set\n" |
| | | |
| | | |
| | | # Add 4) |
| | | output += config_from(".cirrus.tasks.yml") |
| | | |
| | | |
| | | return output |
| | | |
| | | |
| | | def compute_environment_vars(): |
| | | cenv = {} |
| | | |
| | | ### |
| | | # Some tasks are manually triggered by default because they might use too |
| | | # many resources for users of free Cirrus credits, but they can be |
| | | # triggered automatically by naming them in an environment variable e.g. |
| | | # REPO_CI_AUTOMATIC_TRIGGER_TASKS="task_name other_task" under "Repository |
| | | # Settings" on Cirrus CI's website. |
| | | |
| | | default_manual_trigger_tasks = ['mingw', 'netbsd', 'openbsd'] |
| | | |
| | | repo_ci_automatic_trigger_tasks = env.get('REPO_CI_AUTOMATIC_TRIGGER_TASKS', '') |
| | | for task in default_manual_trigger_tasks: |
| | | name = 'CI_TRIGGER_TYPE_' + task.upper() |
| | | if repo_ci_automatic_trigger_tasks.find(task) != -1: |
| | | value = 'automatic' |
| | | else: |
| | | value = 'manual' |
| | | cenv[name] = value |
| | | ### |
| | | |
| | | ### |
| | | # Parse "ci-os-only:" tag in commit message and set |
| | | # CI_{$OS}_ENABLED variable for each OS |
| | | |
| | | # We want to disable SanityCheck if testing just a specific OS. This |
| | | # shortens push-wait-for-ci cycle time a bit when debugging operating |
| | | # system specific failures. Just treating it as an OS in that case |
| | | # suffices. |
| | | |
| | | operating_systems = [ |
| | | 'compilerwarnings', |
| | | 'freebsd', |
| | | 'linux', |
| | | 'macos', |
| | | 'mingw', |
| | | 'netbsd', |
| | | 'openbsd', |
| | | 'sanitycheck', |
| | | 'windows', |
| | | ] |
| | | commit_message = env.get('CIRRUS_CHANGE_MESSAGE') |
| | | match_re = r"(^|.*\n)ci-os-only: ([^\n]+)($|\n.*)" |
| | | |
| | | # re.match() returns an array with a tuple of (matched-string, match_1, ...) |
| | | m = re.match(match_re, commit_message) |
| | | if m and len(m) > 0: |
| | | os_only = m[0][2] |
| | | os_only_list = re.split(r'[, ]+', os_only) |
| | | else: |
| | | os_only_list = operating_systems |
| | | |
| | | for os in operating_systems: |
| | | os_enabled = os in os_only_list |
| | | cenv['CI_{0}_ENABLED'.format(os.upper())] = os_enabled |
| | | ### |
| | | |
| | | return cenv |
| | | |
| | | |
| | | def config_from(config_src): |
| | | """return contents of config file `config_src`, surrounded by markers |
| | | indicating start / end of the included file |
| | | """ |
| | | |
| | | config_contents = fs.read(config_src) |
| | | config_fmt = """ |
| | | |
| | | ### |
| | | # contents of config file `{0}` start here |
| | | ### |
| | | {1} |
| | | ### |
| | | # contents of config file `{0}` end here |
| | | ### |
| | | """ |
| | | return config_fmt.format(config_src, config_contents) |
| New file |
| | |
| | | # CI configuration file for CI utilizing cirrus-ci.org |
| | | # |
| | | # For instructions on how to enable the CI integration in a repository and |
| | | # further details, see src/tools/ci/README |
| | | # |
| | | # |
| | | # NB: Different tasks intentionally test with different, non-default, |
| | | # configurations, to increase the chance of catching problems. Each task with |
| | | # non-obvious non-default documents their oddity at the top of the task, |
| | | # prefixed by "SPECIAL:". |
| | | |
| | | |
| | | env: |
| | | # The lower depth accelerates git clone. Use a bit of depth so that |
| | | # concurrent tasks and retrying older jobs have a chance of working. |
| | | CIRRUS_CLONE_DEPTH: 500 |
| | | # Useful to be able to analyse what in a script takes long |
| | | CIRRUS_LOG_TIMESTAMP: true |
| | | |
| | | CCACHE_MAXSIZE: "250M" |
| | | |
| | | # target to test, for all but windows |
| | | CHECK: check-world PROVE_FLAGS=$PROVE_FLAGS |
| | | CHECKFLAGS: -Otarget |
| | | PROVE_FLAGS: --timer |
| | | # Build test dependencies as part of the build step, to see compiler |
| | | # errors/warnings in one place. |
| | | MBUILD_TARGET: all testprep |
| | | MTEST_ARGS: --print-errorlogs --no-rebuild -C build |
| | | PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests |
| | | TEMP_CONFIG: ${CIRRUS_WORKING_DIR}/src/tools/ci/pg_ci_base.conf |
| | | PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth |
| | | |
| | | |
| | | # What files to preserve in case tests fail |
| | | on_failure_ac: &on_failure_ac |
| | | log_artifacts: |
| | | paths: |
| | | - "**/*.log" |
| | | - "**/*.diffs" |
| | | - "**/regress_log_*" |
| | | type: text/plain |
| | | |
| | | on_failure_meson: &on_failure_meson |
| | | testrun_artifacts: |
| | | paths: |
| | | - "build*/testrun/**/*.log" |
| | | - "build*/testrun/**/*.diffs" |
| | | - "build*/testrun/**/regress_log_*" |
| | | type: text/plain |
| | | |
| | | # In theory it'd be nice to upload the junit files meson generates, so that |
| | | # cirrus will nicely annotate the commit. Unfortunately the files don't |
| | | # contain identifiable file + line numbers right now, so the annotations |
| | | # don't end up useful. We could probably improve on that with a some custom |
| | | # conversion script, but ... |
| | | meson_log_artifacts: |
| | | path: "build*/meson-logs/*.txt" |
| | | type: text/plain |
| | | |
| | | |
| | | # To avoid unnecessarily spinning up a lot of VMs / containers for entirely |
| | | # broken commits, have a minimal task that all others depend on. |
| | | # |
| | | # SPECIAL: |
| | | # - Builds with --auto-features=disabled and thus almost no enabled |
| | | # dependencies |
| | | task: |
| | | name: SanityCheck |
| | | |
| | | # If a specific OS is requested, don't run the sanity check. This shortens |
| | | # push-wait-for-ci cycle time a bit when debugging operating system specific |
| | | # failures. Uses skip instead of only_if, as cirrus otherwise warns about |
| | | # only_if conditions not matching. |
| | | skip: $CI_SANITYCHECK_ENABLED == false |
| | | |
| | | env: |
| | | CPUS: 4 |
| | | BUILD_JOBS: 8 |
| | | TEST_JOBS: 8 |
| | | IMAGE_FAMILY: pg-ci-trixie |
| | | CCACHE_DIR: ${CIRRUS_WORKING_DIR}/ccache_dir |
| | | # no options enabled, should be small |
| | | CCACHE_MAXSIZE: "150M" |
| | | |
| | | # While containers would start up a bit quicker, building is a bit |
| | | # slower. This way we don't have to maintain a container image. |
| | | <<: *linux_task_template |
| | | |
| | | ccache_cache: |
| | | folder: $CCACHE_DIR |
| | | |
| | | create_user_script: | |
| | | useradd -m postgres |
| | | chown -R postgres:postgres . |
| | | mkdir -p ${CCACHE_DIR} |
| | | chown -R postgres:postgres ${CCACHE_DIR} |
| | | echo '* - memlock 134217728' > /etc/security/limits.d/postgres.conf |
| | | su postgres -c "ulimit -l -H && ulimit -l -S" |
| | | # Can't change container's kernel.core_pattern. Postgres user can't write |
| | | # to / normally. Change that. |
| | | chown root:postgres / |
| | | chmod g+rwx / |
| | | |
| | | configure_script: | |
| | | su postgres <<-EOF |
| | | set -e |
| | | meson setup \ |
| | | --buildtype=debug \ |
| | | --auto-features=disabled \ |
| | | -Dtap_tests=enabled \ |
| | | build |
| | | EOF |
| | | build_script: | |
| | | su postgres <<-EOF |
| | | set -e |
| | | ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} |
| | | EOF |
| | | upload_caches: ccache |
| | | |
| | | # Run a minimal set of tests. The main regression tests take too long for |
| | | # this purpose. For now this is a random quick pg_regress style test, and a |
| | | # tap test that exercises both a frontend binary and the backend. |
| | | test_minimal_script: | |
| | | su postgres <<-EOF |
| | | set -e |
| | | ulimit -c unlimited |
| | | meson test $MTEST_ARGS --suite setup |
| | | meson test $MTEST_ARGS --num-processes ${TEST_JOBS} \ |
| | | cube/regress pg_ctl/001_start_stop |
| | | EOF |
| | | |
| | | on_failure: |
| | | <<: *on_failure_meson |
| | | cores_script: | |
| | | mkdir -m 770 /tmp/cores |
| | | find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; |
| | | src/tools/ci/cores_backtrace.sh linux /tmp/cores |
| | | |
| | | |
| | | # SPECIAL: |
| | | # - Uses postgres specific CPPFLAGS that increase test coverage |
| | | # - Specifies configuration options that test reading/writing/copying of node trees |
| | | # - Specifies debug_parallel_query=regress, to catch related issues during CI |
| | | # - Also runs tests against a running postgres instance, see test_running_script |
| | | task: |
| | | name: FreeBSD - Meson |
| | | |
| | | env: |
| | | CPUS: 4 |
| | | BUILD_JOBS: 4 |
| | | TEST_JOBS: 8 |
| | | IMAGE_FAMILY: pg-ci-freebsd |
| | | DISK_SIZE: 50 |
| | | |
| | | CCACHE_DIR: /tmp/ccache_dir |
| | | CPPFLAGS: -DRELCACHE_FORCE_RELEASE -DENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS |
| | | CFLAGS: -Og -ggdb |
| | | |
| | | # Several buildfarm animals enable these options. Without testing them |
| | | # during CI, it would be easy to cause breakage on the buildfarm with CI |
| | | # passing. |
| | | PG_TEST_INITDB_EXTRA_OPTS: >- |
| | | -c debug_copy_parse_plan_trees=on |
| | | -c debug_write_read_parse_plan_trees=on |
| | | -c debug_raw_expression_coverage_test=on |
| | | -c debug_parallel_query=regress |
| | | PG_TEST_PG_UPGRADE_MODE: --link |
| | | |
| | | <<: *freebsd_task_template |
| | | |
| | | depends_on: SanityCheck |
| | | only_if: $CI_FREEBSD_ENABLED |
| | | |
| | | sysinfo_script: | |
| | | id |
| | | uname -a |
| | | ulimit -a -H && ulimit -a -S |
| | | export |
| | | |
| | | ccache_cache: |
| | | folder: $CCACHE_DIR |
| | | setup_ram_disk_script: src/tools/ci/gcp_ram_disk.sh |
| | | create_user_script: | |
| | | pw useradd postgres |
| | | chown -R postgres:postgres . |
| | | mkdir -p ${CCACHE_DIR} |
| | | chown -R postgres:postgres ${CCACHE_DIR} |
| | | setup_core_files_script: | |
| | | mkdir -m 770 /tmp/cores |
| | | chown root:postgres /tmp/cores |
| | | sysctl kern.corefile='/tmp/cores/%N.%P.core' |
| | | setup_additional_packages_script: | |
| | | #pkg install -y ... |
| | | |
| | | # NB: Intentionally build without -Dllvm. The freebsd image size is already |
| | | # large enough to make VM startup slow, and even without llvm freebsd |
| | | # already takes longer than other platforms except for windows. |
| | | configure_script: | |
| | | su postgres <<-EOF |
| | | set -e |
| | | meson setup \ |
| | | --buildtype=debug \ |
| | | -Dcassert=true -Dinjection_points=true \ |
| | | -Duuid=bsd -Dtcl_version=tcl86 -Ddtrace=auto \ |
| | | -Dextra_lib_dirs=/usr/local/lib -Dextra_include_dirs=/usr/local/include/ \ |
| | | build |
| | | EOF |
| | | build_script: su postgres -c 'ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET}' |
| | | upload_caches: ccache |
| | | |
| | | test_world_script: | |
| | | su postgres <<-EOF |
| | | set -e |
| | | ulimit -c unlimited |
| | | meson test $MTEST_ARGS --num-processes ${TEST_JOBS} |
| | | EOF |
| | | |
| | | # test runningcheck, freebsd chosen because it's currently fast enough |
| | | test_running_script: | |
| | | su postgres <<-EOF |
| | | set -e |
| | | ulimit -c unlimited |
| | | meson test $MTEST_ARGS --quiet --suite setup |
| | | export LD_LIBRARY_PATH="$(pwd)/build/tmp_install/usr/local/pgsql/lib/:$LD_LIBRARY_PATH" |
| | | mkdir -p build/testrun |
| | | build/tmp_install/usr/local/pgsql/bin/initdb -N build/runningcheck --no-instructions -A trust |
| | | echo "include '$(pwd)/src/tools/ci/pg_ci_base.conf'" >> build/runningcheck/postgresql.conf |
| | | build/tmp_install/usr/local/pgsql/bin/pg_ctl -c -o '-c fsync=off' -D build/runningcheck -l build/testrun/runningcheck.log start |
| | | meson test $MTEST_ARGS --num-processes ${TEST_JOBS} --setup running |
| | | build/tmp_install/usr/local/pgsql/bin/pg_ctl -D build/runningcheck stop |
| | | EOF |
| | | |
| | | on_failure: |
| | | # if the server continues running, it often causes cirrus-ci to fail |
| | | # during upload, as it doesn't expect artifacts to change size |
| | | stop_running_script: | |
| | | su postgres <<-EOF |
| | | set -e |
| | | build/tmp_install/usr/local/pgsql/bin/pg_ctl -D build/runningcheck stop || true |
| | | EOF |
| | | <<: *on_failure_meson |
| | | cores_script: src/tools/ci/cores_backtrace.sh freebsd /tmp/cores |
| | | |
| | | |
| | | task: |
| | | depends_on: SanityCheck |
| | | |
| | | env: |
| | | # Below are experimentally derived to be a decent choice. |
| | | CPUS: 4 |
| | | BUILD_JOBS: 8 |
| | | TEST_JOBS: 8 |
| | | |
| | | # Default working directory is /tmp, but its total size (1.2 GB) is not |
| | | # enough, so different working and cache directory are set. |
| | | CIRRUS_WORKING_DIR: /home/postgres/postgres |
| | | CCACHE_DIR: /home/postgres/cache |
| | | |
| | | PATH: /usr/sbin:$PATH |
| | | CORE_DUMP_DIR: /var/crash |
| | | |
| | | matrix: |
| | | - name: NetBSD - Meson |
| | | # See REPO_CI_AUTOMATIC_TRIGGER_TASKS in .cirrus.star |
| | | trigger_type: $CI_TRIGGER_TYPE_NETBSD |
| | | only_if: $CI_NETBSD_ENABLED |
| | | env: |
| | | OS_NAME: netbsd |
| | | IMAGE_FAMILY: pg-ci-netbsd-postgres |
| | | PKGCONFIG_PATH: '/usr/lib/pkgconfig:/usr/pkg/lib/pkgconfig' |
| | | # initdb fails with: 'invalid locale settings' error on NetBSD. |
| | | # Force 'LANG' and 'LC_*' variables to be 'C'. |
| | | # See https://postgr.es/m/2490325.1734471752%40sss.pgh.pa.us |
| | | LANG: "C" |
| | | LC_ALL: "C" |
| | | # -Duuid is not set for the NetBSD, see the comment below, above |
| | | # configure_script, for more information. |
| | | setup_additional_packages_script: | |
| | | #pkgin -y install ... |
| | | <<: *netbsd_task_template |
| | | |
| | | - name: OpenBSD - Meson |
| | | # See REPO_CI_AUTOMATIC_TRIGGER_TASKS in .cirrus.star |
| | | trigger_type: $CI_TRIGGER_TYPE_OPENBSD |
| | | only_if: $CI_OPENBSD_ENABLED |
| | | env: |
| | | OS_NAME: openbsd |
| | | IMAGE_FAMILY: pg-ci-openbsd-postgres |
| | | PKGCONFIG_PATH: '/usr/lib/pkgconfig:/usr/local/lib/pkgconfig' |
| | | UUID: -Duuid=e2fs |
| | | TCL: -Dtcl_version=tcl86 |
| | | CORE_DUMP_EXECUTABLE_DIR: $CIRRUS_WORKING_DIR/build/tmp_install/usr/local/pgsql/bin |
| | | setup_additional_packages_script: | |
| | | #pkg_add -I ... |
| | | # Always core dump to ${CORE_DUMP_DIR} |
| | | set_core_dump_script: sysctl -w kern.nosuidcoredump=2 |
| | | <<: *openbsd_task_template |
| | | |
| | | sysinfo_script: | |
| | | locale |
| | | id |
| | | uname -a |
| | | ulimit -a -H && ulimit -a -S |
| | | env |
| | | |
| | | ccache_cache: |
| | | folder: $CCACHE_DIR |
| | | setup_ram_disk_script: src/tools/ci/gcp_ram_disk.sh |
| | | create_user_script: | |
| | | useradd postgres |
| | | chown -R postgres:users /home/postgres |
| | | mkdir -p ${CCACHE_DIR} |
| | | chown -R postgres:users ${CCACHE_DIR} |
| | | setup_core_files_script: | |
| | | mkdir -p ${CORE_DUMP_DIR} |
| | | chmod -R 770 ${CORE_DUMP_DIR} |
| | | chown -R postgres:users ${CORE_DUMP_DIR} |
| | | |
| | | # -Duuid=bsd is not set since 'bsd' uuid option |
| | | # is not working on NetBSD & OpenBSD. See |
| | | # https://www.postgresql.org/message-id/17358-89806e7420797025@postgresql.org |
| | | # And other uuid options are not available on NetBSD. |
| | | configure_script: | |
| | | su postgres <<-EOF |
| | | set -e |
| | | meson setup \ |
| | | --buildtype=debugoptimized \ |
| | | --pkg-config-path ${PKGCONFIG_PATH} \ |
| | | -Dcassert=true -Dinjection_points=true \ |
| | | -Dssl=openssl ${UUID} ${TCL} \ |
| | | -DPG_TEST_EXTRA="$PG_TEST_EXTRA" \ |
| | | build |
| | | EOF |
| | | |
| | | build_script: su postgres -c 'ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET}' |
| | | upload_caches: ccache |
| | | |
| | | test_world_script: | |
| | | su postgres <<-EOF |
| | | set -e |
| | | ulimit -c unlimited |
| | | meson test $MTEST_ARGS --num-processes ${TEST_JOBS} |
| | | EOF |
| | | |
| | | on_failure: |
| | | <<: *on_failure_meson |
| | | cores_script: | |
| | | # Although we try to configure the OS to core dump inside |
| | | # ${CORE_DUMP_DIR}, they may not obey this. So, move core files to the |
| | | # ${CORE_DUMP_DIR} directory. |
| | | find build/ -type f -name '*.core' -exec mv '{}' ${CORE_DUMP_DIR} \; |
| | | src/tools/ci/cores_backtrace.sh ${OS_NAME} ${CORE_DUMP_DIR} ${CORE_DUMP_EXECUTABLE_DIR} |
| | | |
| | | |
| | | # configure feature flags, shared between the task running the linux tests and |
| | | # the CompilerWarnings task |
| | | LINUX_CONFIGURE_FEATURES: &LINUX_CONFIGURE_FEATURES >- |
| | | --with-gssapi |
| | | --with-icu |
| | | --with-ldap |
| | | --with-libcurl |
| | | --with-libxml |
| | | --with-libxslt |
| | | --with-llvm |
| | | --with-lz4 |
| | | --with-pam |
| | | --with-perl |
| | | --with-python |
| | | --with-selinux |
| | | --with-ssl=openssl |
| | | --with-systemd |
| | | --with-tcl --with-tclconfig=/usr/lib/tcl8.6/ |
| | | --with-uuid=ossp |
| | | --with-zstd |
| | | |
| | | LINUX_MESON_FEATURES: &LINUX_MESON_FEATURES >- |
| | | -Dllvm=enabled |
| | | -Duuid=e2fs |
| | | |
| | | |
| | | # Check SPECIAL in the matrix: below |
| | | task: |
| | | env: |
| | | CPUS: 4 |
| | | BUILD_JOBS: 4 |
| | | TEST_JOBS: 8 # experimentally derived to be a decent choice |
| | | IMAGE_FAMILY: pg-ci-trixie |
| | | |
| | | CCACHE_DIR: /tmp/ccache_dir |
| | | DEBUGINFOD_URLS: "https://debuginfod.debian.net" |
| | | |
| | | # Enable a reasonable set of sanitizers. Use the linux task for that, as |
| | | # it's one of the fastest tasks (without sanitizers). Also several of the |
| | | # sanitizers work best on linux. |
| | | # |
| | | # The overhead of alignment sanitizer is low, undefined behaviour has |
| | | # moderate overhead. Test alignment sanitizer in the meson task, as it |
| | | # does both 32 and 64 bit builds and is thus more likely to expose |
| | | # alignment bugs. |
| | | # |
| | | # Address sanitizer in contrast is somewhat expensive. Enable it in the |
| | | # autoconf task, as the meson task tests both 32 and 64bit. |
| | | # |
| | | # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes |
| | | # print_stacktraces=1,verbosity=2, duh |
| | | # detect_leaks=0: too many uninteresting leak errors in short-lived binaries |
| | | UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 |
| | | ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 |
| | | |
| | | # SANITIZER_FLAGS is set in the tasks below |
| | | CFLAGS: -Og -ggdb -fno-sanitize-recover=all $SANITIZER_FLAGS |
| | | CXXFLAGS: $CFLAGS |
| | | LDFLAGS: $SANITIZER_FLAGS |
| | | CC: ccache gcc |
| | | CXX: ccache g++ |
| | | |
| | | LINUX_CONFIGURE_FEATURES: *LINUX_CONFIGURE_FEATURES |
| | | LINUX_MESON_FEATURES: *LINUX_MESON_FEATURES |
| | | |
| | | <<: *linux_task_template |
| | | |
| | | depends_on: SanityCheck |
| | | only_if: $CI_LINUX_ENABLED |
| | | |
| | | ccache_cache: |
| | | folder: ${CCACHE_DIR} |
| | | |
| | | sysinfo_script: | |
| | | id |
| | | uname -a |
| | | cat /proc/cmdline |
| | | ulimit -a -H && ulimit -a -S |
| | | export |
| | | create_user_script: | |
| | | useradd -m postgres |
| | | chown -R postgres:postgres . |
| | | mkdir -p ${CCACHE_DIR} |
| | | chown -R postgres:postgres ${CCACHE_DIR} |
| | | echo '* - memlock 134217728' > /etc/security/limits.d/postgres.conf |
| | | su postgres -c "ulimit -l -H && ulimit -l -S" |
| | | setup_core_files_script: | |
| | | mkdir -m 770 /tmp/cores |
| | | chown root:postgres /tmp/cores |
| | | sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' |
| | | |
| | | setup_hosts_file_script: | |
| | | cat >> /etc/hosts <<-EOF |
| | | 127.0.0.1 pg-loadbalancetest |
| | | 127.0.0.2 pg-loadbalancetest |
| | | 127.0.0.3 pg-loadbalancetest |
| | | EOF |
| | | |
| | | setup_additional_packages_script: | |
| | | #apt-get update |
| | | #DEBIAN_FRONTEND=noninteractive apt-get -y install ... |
| | | |
| | | matrix: |
| | | # SPECIAL: |
| | | # - Uses address sanitizer, sanitizer failures are typically printed in |
| | | # the server log |
| | | # - Configures postgres with a small segment size |
| | | - name: Linux - Debian Trixie - Autoconf |
| | | |
| | | env: |
| | | SANITIZER_FLAGS: -fsanitize=address |
| | | PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range |
| | | |
| | | # Normally, the "relation segment" code basically has no coverage in our |
| | | # tests, because we (quite reasonably) don't generate tables large |
| | | # enough in tests. We've had plenty bugs that we didn't notice due the |
| | | # code not being exercised much. Thus specify a very small segment size |
| | | # here. Use a non-power-of-two segment size, given we currently allow |
| | | # that. |
| | | configure_script: | |
| | | su postgres <<-EOF |
| | | set -e |
| | | ./configure \ |
| | | --enable-cassert --enable-injection-points --enable-debug \ |
| | | --enable-tap-tests --enable-nls \ |
| | | --with-segsize-blocks=6 \ |
| | | --with-libnuma \ |
| | | --with-liburing \ |
| | | \ |
| | | ${LINUX_CONFIGURE_FEATURES} \ |
| | | \ |
| | | CLANG="ccache clang" |
| | | EOF |
| | | build_script: su postgres -c "make -s -j${BUILD_JOBS} world-bin" |
| | | upload_caches: ccache |
| | | |
| | | test_world_script: | |
| | | su postgres <<-EOF |
| | | set -e |
| | | ulimit -c unlimited # default is 0 |
| | | make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} |
| | | EOF |
| | | |
| | | on_failure: |
| | | <<: *on_failure_ac |
| | | |
| | | # SPECIAL: |
| | | # - Uses undefined behaviour and alignment sanitizers, sanitizer failures |
| | | # are typically printed in the server log |
| | | # - Test both 64bit and 32 bit builds |
| | | # - uses io_method=io_uring |
| | | - name: Linux - Debian Trixie - Meson |
| | | |
| | | env: |
| | | CCACHE_MAXSIZE: "400M" # tests two different builds |
| | | SANITIZER_FLAGS: -fsanitize=alignment,undefined |
| | | PG_TEST_INITDB_EXTRA_OPTS: >- |
| | | -c io_method=io_uring |
| | | |
| | | configure_script: | |
| | | su postgres <<-EOF |
| | | set -e |
| | | meson setup \ |
| | | --buildtype=debug \ |
| | | -Dcassert=true -Dinjection_points=true \ |
| | | ${LINUX_MESON_FEATURES} \ |
| | | build |
| | | EOF |
| | | |
| | | # Also build & test in a 32bit build - it's gotten rare to test that |
| | | # locally. |
| | | configure_32_script: | |
| | | su postgres <<-EOF |
| | | set -e |
| | | export CC='ccache gcc -m32' |
| | | meson setup \ |
| | | --buildtype=debug \ |
| | | -Dcassert=true -Dinjection_points=true \ |
| | | ${LINUX_MESON_FEATURES} \ |
| | | -Dllvm=disabled \ |
| | | --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ |
| | | -DPERL=perl5.40-i386-linux-gnu \ |
| | | -Dlibnuma=disabled \ |
| | | build-32 |
| | | EOF |
| | | |
| | | build_script: | |
| | | su postgres <<-EOF |
| | | set -e |
| | | ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} |
| | | ninja -C build -t missingdeps |
| | | EOF |
| | | |
| | | build_32_script: | |
| | | su postgres <<-EOF |
| | | set -e |
| | | ninja -C build-32 -j${BUILD_JOBS} ${MBUILD_TARGET} |
| | | ninja -C build -t missingdeps |
| | | EOF |
| | | |
| | | upload_caches: ccache |
| | | |
| | | test_world_script: | |
| | | su postgres <<-EOF |
| | | set -e |
| | | ulimit -c unlimited |
| | | meson test $MTEST_ARGS --num-processes ${TEST_JOBS} |
| | | EOF |
| | | # so that we don't upload 64bit logs if 32bit fails |
| | | rm -rf build/ |
| | | |
| | | # There's currently no coverage of icu with LANG=C in the buildfarm. We |
| | | # can easily provide some here by running one of the sets of tests that |
| | | # way. Newer versions of python insist on changing the LC_CTYPE away |
| | | # from C, prevent that with PYTHONCOERCECLOCALE. |
| | | test_world_32_script: | |
| | | su postgres <<-EOF |
| | | set -e |
| | | ulimit -c unlimited |
| | | PYTHONCOERCECLOCALE=0 LANG=C meson test $MTEST_ARGS -C build-32 --num-processes ${TEST_JOBS} |
| | | EOF |
| | | |
| | | on_failure: |
| | | <<: *on_failure_meson |
| | | |
| | | on_failure: |
| | | cores_script: src/tools/ci/cores_backtrace.sh linux /tmp/cores |
| | | |
| | | |
| | | # NB: macOS is by far the most expensive OS to run CI for, therefore no |
| | | # expensive additional checks should be added. |
| | | # |
| | | # SPECIAL: |
| | | # - Enables --clone for pg_upgrade and pg_combinebackup |
| | | task: |
| | | name: macOS - Sequoia - Meson |
| | | |
| | | env: |
| | | CPUS: 4 # always get that much for cirrusci macOS instances |
| | | BUILD_JOBS: $CPUS |
| | | # Test performance regresses noticeably when using all cores. 8 seems to |
| | | # work OK. See |
| | | # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de |
| | | TEST_JOBS: 8 |
| | | IMAGE: ghcr.io/cirruslabs/macos-runner:sequoia |
| | | |
| | | CIRRUS_WORKING_DIR: ${HOME}/pgsql/ |
| | | CCACHE_DIR: ${HOME}/ccache |
| | | MACPORTS_CACHE: ${HOME}/macports-cache |
| | | |
| | | MACOS_PACKAGE_LIST: >- |
| | | ccache |
| | | icu |
| | | kerberos5 |
| | | lz4 |
| | | meson |
| | | openldap |
| | | openssl |
| | | p5.34-io-tty |
| | | p5.34-ipc-run |
| | | python312 |
| | | tcl |
| | | zstd |
| | | |
| | | CC: ccache cc |
| | | CXX: ccache c++ |
| | | CFLAGS: -Og -ggdb |
| | | CXXFLAGS: -Og -ggdb |
| | | |
| | | PG_TEST_PG_UPGRADE_MODE: --clone |
| | | PG_TEST_PG_COMBINEBACKUP_MODE: --clone |
| | | |
| | | <<: *macos_task_template |
| | | |
| | | depends_on: SanityCheck |
| | | only_if: $CI_MACOS_ENABLED |
| | | |
| | | sysinfo_script: | |
| | | id |
| | | uname -a |
| | | ulimit -a -H && ulimit -a -S |
| | | export |
| | | |
| | | setup_core_files_script: |
| | | - mkdir ${HOME}/cores |
| | | - sudo sysctl kern.corefile="${HOME}/cores/core.%P" |
| | | |
| | | # Use macports, even though homebrew is installed. The installation |
| | | # of the additional packages we need would take quite a while with |
| | | # homebrew, even if we cache the downloads. We can't cache all of |
| | | # homebrew, because it's already large. So we use macports. To cache |
| | | # the installation we create a .dmg file that we mount if it already |
| | | # exists. |
| | | # XXX: The reason for the direct p5.34* references is that we'd need |
| | | # the large macport tree around to figure out that p5-io-tty is |
| | | # actually p5.34-io-tty. Using the unversioned name works, but |
| | | # updates macports every time. |
| | | macports_cache: |
| | | folder: ${MACPORTS_CACHE} |
| | | fingerprint_script: | |
| | | # Reinstall packages if the OS major version, the list of the packages |
| | | # to install or the MacPorts install script changes. |
| | | sw_vers -productVersion | sed 's/\..*//' |
| | | echo $MACOS_PACKAGE_LIST |
| | | md5 src/tools/ci/ci_macports_packages.sh |
| | | reupload_on_changes: true |
| | | setup_additional_packages_script: | |
| | | sh src/tools/ci/ci_macports_packages.sh $MACOS_PACKAGE_LIST |
| | | # system python doesn't provide headers |
| | | sudo /opt/local/bin/port select python3 python312 |
| | | # Make macports install visible for subsequent steps |
| | | echo PATH=/opt/local/sbin/:/opt/local/bin/:$PATH >> $CIRRUS_ENV |
| | | upload_caches: macports |
| | | |
| | | ccache_cache: |
| | | folder: $CCACHE_DIR |
| | | configure_script: | |
| | | export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" |
| | | meson setup \ |
| | | --buildtype=debug \ |
| | | -Dextra_include_dirs=/opt/local/include \ |
| | | -Dextra_lib_dirs=/opt/local/lib \ |
| | | -Dcassert=true -Dinjection_points=true \ |
| | | -Duuid=e2fs -Ddtrace=auto \ |
| | | build |
| | | |
| | | build_script: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} |
| | | upload_caches: ccache |
| | | |
| | | test_world_script: | |
| | | ulimit -c unlimited # default is 0 |
| | | ulimit -n 1024 # default is 256, pretty low |
| | | meson test $MTEST_ARGS --num-processes ${TEST_JOBS} |
| | | |
| | | on_failure: |
| | | <<: *on_failure_meson |
| | | cores_script: src/tools/ci/cores_backtrace.sh macos "${HOME}/cores" |
| | | |
| | | |
| | | WINDOWS_ENVIRONMENT_BASE: &WINDOWS_ENVIRONMENT_BASE |
| | | env: |
| | | # Half the allowed per-user CPU cores |
| | | CPUS: 4 |
| | | |
| | | # The default cirrus working dir is in a directory msbuild complains about |
| | | CIRRUS_WORKING_DIR: "c:/cirrus" |
| | | # git's tar doesn't deal with drive letters, see |
| | | # https://postgr.es/m/b6782dc3-a7b0-ed56-175f-f8f54cb08d67%40dunslane.net |
| | | TAR: "c:/windows/system32/tar.exe" |
| | | # Avoids port conflicts between concurrent tap test runs |
| | | PG_TEST_USE_UNIX_SOCKETS: 1 |
| | | PG_REGRESS_SOCK_DIR: "c:/cirrus/" |
| | | DISK_SIZE: 50 |
| | | IMAGE_FAMILY: pg-ci-windows-ci |
| | | |
| | | sysinfo_script: | |
| | | chcp |
| | | systeminfo |
| | | powershell -Command get-psdrive -psprovider filesystem |
| | | set |
| | | |
| | | |
| | | task: |
| | | name: Windows - Server 2022, VS 2019 - Meson & ninja |
| | | << : *WINDOWS_ENVIRONMENT_BASE |
| | | |
| | | env: |
| | | TEST_JOBS: 8 # wild guess, data based value welcome |
| | | |
| | | # Cirrus defaults to SetErrorMode(SEM_NOGPFAULTERRORBOX | ...). That |
| | | # prevents crash reporting from working unless binaries do SetErrorMode() |
| | | # themselves. Furthermore, it appears that either python or, more likely, |
| | | # the C runtime has a bug where SEM_NOGPFAULTERRORBOX can very |
| | | # occasionally *trigger* a crash on process exit - which is hard to debug, |
| | | # given that it explicitly prevents crash dumps from working... |
| | | # 0x8001 is SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX |
| | | CIRRUS_WINDOWS_ERROR_MODE: 0x8001 |
| | | |
| | | <<: *windows_task_template |
| | | |
| | | depends_on: SanityCheck |
| | | only_if: $CI_WINDOWS_ENABLED |
| | | |
| | | setup_additional_packages_script: | |
| | | REM choco install -y --no-progress ... |
| | | |
| | | setup_hosts_file_script: | |
| | | echo 127.0.0.1 pg-loadbalancetest >> c:\Windows\System32\Drivers\etc\hosts |
| | | echo 127.0.0.2 pg-loadbalancetest >> c:\Windows\System32\Drivers\etc\hosts |
| | | echo 127.0.0.3 pg-loadbalancetest >> c:\Windows\System32\Drivers\etc\hosts |
| | | type c:\Windows\System32\Drivers\etc\hosts |
| | | |
| | | configure_script: | |
| | | vcvarsall x64 |
| | | meson setup --backend ninja --buildtype debug -Dcassert=true -Dinjection_points=true -Db_pch=true -Dextra_lib_dirs=c:\openssl\1.1\lib -Dextra_include_dirs=c:\openssl\1.1\include -DTAR=%TAR% build |
| | | |
| | | build_script: | |
| | | vcvarsall x64 |
| | | ninja -C build %MBUILD_TARGET% |
| | | ninja -C build -t missingdeps |
| | | |
| | | check_world_script: | |
| | | vcvarsall x64 |
| | | meson test %MTEST_ARGS% --num-processes %TEST_JOBS% |
| | | |
| | | on_failure: |
| | | <<: *on_failure_meson |
| | | crashlog_artifacts: |
| | | path: "crashlog-*.txt" |
| | | type: text/plain |
| | | |
| | | |
| | | task: |
| | | << : *WINDOWS_ENVIRONMENT_BASE |
| | | name: Windows - Server 2022, MinGW64 - Meson |
| | | |
| | | # See REPO_CI_AUTOMATIC_TRIGGER_TASKS in .cirrus.star. |
| | | trigger_type: $CI_TRIGGER_TYPE_MINGW |
| | | |
| | | depends_on: SanityCheck |
| | | only_if: $CI_MINGW_ENABLED |
| | | |
| | | env: |
| | | TEST_JOBS: 4 # higher concurrency causes occasional failures |
| | | CCACHE_DIR: C:/msys64/ccache |
| | | CCACHE_MAXSIZE: "500M" |
| | | CCACHE_SLOPPINESS: pch_defines,time_macros |
| | | CCACHE_DEPEND: 1 |
| | | # for some reason mingw plpython cannot find its installation without this |
| | | PYTHONHOME: C:/msys64/ucrt64 |
| | | # prevents MSYS bash from resetting error mode |
| | | MSYS: winjitdebug |
| | | # Start bash in current working directory |
| | | CHERE_INVOKING: 1 |
| | | BASH: C:\msys64\usr\bin\bash.exe -l |
| | | |
| | | <<: *windows_task_template |
| | | |
| | | ccache_cache: |
| | | folder: ${CCACHE_DIR} |
| | | |
| | | setup_additional_packages_script: | |
| | | REM C:\msys64\usr\bin\pacman.exe -S --noconfirm ... |
| | | |
| | | mingw_info_script: | |
| | | %BASH% -c "where gcc" |
| | | %BASH% -c "gcc --version" |
| | | %BASH% -c "where perl" |
| | | %BASH% -c "perl --version" |
| | | |
| | | # disable -Dnls as the number of files it creates cause a noticable slowdown |
| | | configure_script: | |
| | | %BASH% -c "meson setup -Ddebug=true -Doptimization=g -Dcassert=true -Dinjection_points=true -Db_pch=true -Dnls=disabled -DTAR=%TAR% build" |
| | | |
| | | build_script: | |
| | | %BASH% -c "ninja -C build ${MBUILD_TARGET}" |
| | | |
| | | upload_caches: ccache |
| | | |
| | | test_world_script: | |
| | | %BASH% -c "meson test %MTEST_ARGS% --num-processes %TEST_JOBS%" |
| | | |
| | | on_failure: |
| | | <<: *on_failure_meson |
| | | crashlog_artifacts: |
| | | path: "crashlog-*.txt" |
| | | type: text/plain |
| | | |
| | | |
| | | task: |
| | | name: CompilerWarnings |
| | | |
| | | # To limit unnecessary work only run this once the SanityCheck |
| | | # succeeds. This is particularly important for this task as we intentionally |
| | | # use always: to continue after failures. |
| | | depends_on: SanityCheck |
| | | only_if: $CI_COMPILERWARNINGS_ENABLED |
| | | |
| | | env: |
| | | CPUS: 4 |
| | | BUILD_JOBS: 4 |
| | | IMAGE_FAMILY: pg-ci-trixie |
| | | |
| | | # Use larger ccache cache, as this task compiles with multiple compilers / |
| | | # flag combinations |
| | | CCACHE_MAXSIZE: "1G" |
| | | CCACHE_DIR: "/tmp/ccache_dir" |
| | | |
| | | LINUX_CONFIGURE_FEATURES: *LINUX_CONFIGURE_FEATURES |
| | | LINUX_MESON_FEATURES: *LINUX_MESON_FEATURES |
| | | |
| | | <<: *linux_task_template |
| | | |
| | | sysinfo_script: | |
| | | id |
| | | uname -a |
| | | cat /proc/cmdline |
| | | ulimit -a -H && ulimit -a -S |
| | | gcc -v |
| | | clang -v |
| | | export |
| | | |
| | | ccache_cache: |
| | | folder: $CCACHE_DIR |
| | | |
| | | setup_additional_packages_script: | |
| | | #apt-get update |
| | | #DEBIAN_FRONTEND=noninteractive apt-get -y install ... |
| | | |
| | | ### |
| | | # Test that code can be built with gcc/clang without warnings |
| | | ### |
| | | |
| | | setup_script: echo "COPT=-Werror" > src/Makefile.custom |
| | | |
| | | # Trace probes have a history of getting accidentally broken. Use the |
| | | # different compilers to build with different combinations of dtrace on/off |
| | | # and cassert on/off. |
| | | |
| | | # gcc, cassert off, dtrace on |
| | | always: |
| | | gcc_warning_script: | |
| | | time ./configure \ |
| | | --cache gcc.cache \ |
| | | --enable-dtrace \ |
| | | ${LINUX_CONFIGURE_FEATURES} \ |
| | | CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" |
| | | make -s -j${BUILD_JOBS} clean |
| | | time make -s -j${BUILD_JOBS} world-bin |
| | | |
| | | # gcc, cassert on, dtrace off |
| | | always: |
| | | gcc_a_warning_script: | |
| | | time ./configure \ |
| | | --cache gcc.cache \ |
| | | --enable-cassert \ |
| | | ${LINUX_CONFIGURE_FEATURES} \ |
| | | CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" |
| | | make -s -j${BUILD_JOBS} clean |
| | | time make -s -j${BUILD_JOBS} world-bin |
| | | |
| | | # clang, cassert off, dtrace off |
| | | always: |
| | | clang_warning_script: | |
| | | time ./configure \ |
| | | --cache clang.cache \ |
| | | ${LINUX_CONFIGURE_FEATURES} \ |
| | | CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" |
| | | make -s -j${BUILD_JOBS} clean |
| | | time make -s -j${BUILD_JOBS} world-bin |
| | | |
| | | # clang, cassert on, dtrace on |
| | | always: |
| | | clang_a_warning_script: | |
| | | time ./configure \ |
| | | --cache clang.cache \ |
| | | --enable-cassert \ |
| | | --enable-dtrace \ |
| | | ${LINUX_CONFIGURE_FEATURES} \ |
| | | CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" |
| | | make -s -j${BUILD_JOBS} clean |
| | | time make -s -j${BUILD_JOBS} world-bin |
| | | |
| | | # cross-compile to windows |
| | | always: |
| | | mingw_cross_warning_script: | |
| | | time ./configure \ |
| | | --host=x86_64-w64-mingw32ucrt \ |
| | | --enable-cassert \ |
| | | --without-icu \ |
| | | CC="ccache x86_64-w64-mingw32ucrt-gcc" \ |
| | | CXX="ccache x86_64-w64-mingw32ucrt-g++" |
| | | make -s -j${BUILD_JOBS} clean |
| | | time make -s -j${BUILD_JOBS} world-bin |
| | | |
| | | ### |
| | | # Verify docs can be built |
| | | ### |
| | | # XXX: Only do this if there have been changes in doc/ since last build |
| | | always: |
| | | docs_build_script: | |
| | | time ./configure \ |
| | | --cache gcc.cache \ |
| | | CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" |
| | | make -s -j${BUILD_JOBS} clean |
| | | time make -s -j${BUILD_JOBS} -C doc |
| | | |
| | | ### |
| | | # Verify headerscheck / cpluspluscheck succeed |
| | | # |
| | | # - Don't use ccache, the files are uncacheable, polluting ccache's |
| | | # cache |
| | | # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose |
| | | ### |
| | | always: |
| | | headers_headerscheck_script: | |
| | | time ./configure \ |
| | | ${LINUX_CONFIGURE_FEATURES} \ |
| | | --quiet \ |
| | | CC="gcc" CXX"=g++" CLANG="clang" |
| | | make -s -j${BUILD_JOBS} clean |
| | | time make -s headerscheck EXTRAFLAGS='-fmax-errors=10' |
| | | headers_cpluspluscheck_script: | |
| | | time make -s cpluspluscheck EXTRAFLAGS='-fmax-errors=10' |
| | | |
| | | always: |
| | | upload_caches: ccache |
| New file |
| | |
| | | # CI configuration file for CI utilizing cirrus-ci.org |
| | | # |
| | | # For instructions on how to enable the CI integration in a repository and |
| | | # further details, see src/tools/ci/README |
| | | # |
| | | # |
| | | # The actual CI tasks are defined in .cirrus.tasks.yml. To make the compute |
| | | # resources for CI configurable on a repository level, the "final" CI |
| | | # configuration is the combination of: |
| | | # |
| | | # 1) the contents of this file |
| | | # |
| | | # 2) computed environment variables |
| | | # |
| | | # Used to enable/disable tasks based on the execution environment. See |
| | | # .cirrus.star: compute_environment_vars() |
| | | # |
| | | # 3) if defined, the contents of the file referenced by the, repository |
| | | # level, REPO_CI_CONFIG_GIT_URL variable (see |
| | | # https://cirrus-ci.org/guide/programming-tasks/#fs for the accepted |
| | | # format) |
| | | # |
| | | # This allows running tasks in a different execution environment than the |
| | | # default, e.g. to have sufficient resources for cfbot. |
| | | # |
| | | # 4) .cirrus.tasks.yml |
| | | # |
| | | # This composition is done by .cirrus.star |
| | | |
| | | |
| | | env: |
| | | # Source of images / containers |
| | | GCP_PROJECT: pg-ci-images |
| | | IMAGE_PROJECT: $GCP_PROJECT |
| | | CONTAINER_REPO: us-docker.pkg.dev/${GCP_PROJECT}/ci |
| | | DISK_SIZE: 25 |
| | | |
| | | |
| | | # Define how to run various types of tasks. |
| | | |
| | | # VMs provided by cirrus-ci. Each user has a limited number of "free" credits |
| | | # for testing. |
| | | cirrus_community_vm_template: &cirrus_community_vm_template |
| | | compute_engine_instance: |
| | | image_project: $IMAGE_PROJECT |
| | | image: family/$IMAGE_FAMILY |
| | | platform: $PLATFORM |
| | | cpu: $CPUS |
| | | disk: $DISK_SIZE |
| | | |
| | | |
| | | default_linux_task_template: &linux_task_template |
| | | env: |
| | | PLATFORM: linux |
| | | <<: *cirrus_community_vm_template |
| | | |
| | | |
| | | default_freebsd_task_template: &freebsd_task_template |
| | | env: |
| | | PLATFORM: freebsd |
| | | <<: *cirrus_community_vm_template |
| | | |
| | | default_netbsd_task_template: &netbsd_task_template |
| | | env: |
| | | PLATFORM: netbsd |
| | | <<: *cirrus_community_vm_template |
| | | |
| | | default_openbsd_task_template: &openbsd_task_template |
| | | env: |
| | | PLATFORM: openbsd |
| | | <<: *cirrus_community_vm_template |
| | | |
| | | |
| | | default_windows_task_template: &windows_task_template |
| | | env: |
| | | PLATFORM: windows |
| | | <<: *cirrus_community_vm_template |
| | | |
| | | |
| | | # macos workers provided by cirrus-ci |
| | | default_macos_task_template: &macos_task_template |
| | | env: |
| | | PLATFORM: macos |
| | | macos_instance: |
| | | image: $IMAGE |
| | | |
| | | |
| | | # Contents of REPO_CI_CONFIG_GIT_URL, if defined, will be inserted here, |
| | | # followed by the contents .cirrus.tasks.yml. This allows |
| | | # REPO_CI_CONFIG_GIT_URL to override how the task types above will be |
| | | # executed, e.g. using a custom compute account or permanent workers. |
| New file |
| | |
| | | ;; see also src/tools/editors/emacs.samples for more complete settings |
| | | |
| | | ((c-mode . ((c-basic-offset . 4) |
| | | (c-file-style . "bsd") |
| | | (fill-column . 78) |
| | | (indent-tabs-mode . t) |
| | | (tab-width . 4))) |
| | | (nxml-mode . ((fill-column . 78) |
| | | (indent-tabs-mode . nil))) |
| | | (perl-mode . ((perl-indent-level . 4) |
| | | (perl-continued-statement-offset . 2) |
| | | (perl-continued-brace-offset . -2) |
| | | (perl-brace-offset . 0) |
| | | (perl-brace-imaginary-offset . 0) |
| | | (perl-label-offset . -2) |
| | | (indent-tabs-mode . t) |
| | | (tab-width . 4))) |
| | | (sgml-mode . ((fill-column . 78) |
| | | (indent-tabs-mode . nil)))) |
| New file |
| | |
| | | root = true |
| | | |
| | | [*] |
| | | indent_size = tab |
| | | |
| | | [*] |
| | | trim_trailing_whitespace = true |
| | | insert_final_newline = true |
| | | indent_style = unset |
| | | tab_width = unset |
| | | |
| | | [*.[chly]] |
| | | trim_trailing_whitespace = true |
| | | insert_final_newline = true |
| | | indent_style = tab |
| | | tab_width = 4 |
| | | |
| | | [*.cpp] |
| | | trim_trailing_whitespace = true |
| | | insert_final_newline = true |
| | | indent_style = tab |
| | | tab_width = 4 |
| | | |
| | | [*.pl] |
| | | trim_trailing_whitespace = true |
| | | insert_final_newline = true |
| | | indent_style = tab |
| | | tab_width = 4 |
| | | |
| | | [*.pm] |
| | | trim_trailing_whitespace = true |
| | | insert_final_newline = true |
| | | indent_style = tab |
| | | tab_width = 4 |
| | | |
| | | [*.po] |
| | | trim_trailing_whitespace = true |
| | | insert_final_newline = unset |
| | | indent_style = space |
| | | tab_width = unset |
| | | |
| | | [*.py] |
| | | trim_trailing_whitespace = true |
| | | insert_final_newline = true |
| | | indent_style = space |
| | | tab_width = unset |
| | | indent_size = 4 |
| | | |
| | | [*.sgml] |
| | | trim_trailing_whitespace = true |
| | | insert_final_newline = true |
| | | indent_style = space |
| | | tab_width = unset |
| | | indent_size = 1 |
| | | |
| | | [*.xml] |
| | | trim_trailing_whitespace = true |
| | | insert_final_newline = true |
| | | indent_style = space |
| | | tab_width = unset |
| | | indent_size = 2 |
| | | |
| | | [*.xsl] |
| | | trim_trailing_whitespace = true |
| | | insert_final_newline = true |
| | | indent_style = space |
| | | tab_width = unset |
| | | indent_size = 1 |
| | | |
| | | [*.data] |
| | | indent_style = unset |
| | | indent_size = unset |
| | | trim_trailing_whitespace = unset |
| | | insert_final_newline = unset |
| | | |
| | | [contrib/pgcrypto/sql/pgp-armor.sql] |
| | | trim_trailing_whitespace = unset |
| | | insert_final_newline = true |
| | | indent_style = unset |
| | | tab_width = unset |
| | | |
| | | [src/backend/catalog/sql_features.txt] |
| | | trim_trailing_whitespace = unset |
| | | insert_final_newline = true |
| | | indent_style = unset |
| | | tab_width = unset |
| | | |
| | | [*.out] |
| | | indent_style = unset |
| | | indent_size = unset |
| | | trim_trailing_whitespace = unset |
| | | insert_final_newline = unset |
| | | |
| | | [src/interfaces/ecpg/test/expected/*] |
| | | indent_style = unset |
| | | indent_size = unset |
| | | trim_trailing_whitespace = unset |
| | | insert_final_newline = unset |
| | | |
| | | [configure] |
| | | indent_style = unset |
| | | indent_size = unset |
| | | trim_trailing_whitespace = unset |
| | | insert_final_newline = unset |
| | | |
| | | [ppport.h] |
| | | indent_style = unset |
| | | indent_size = unset |
| | | trim_trailing_whitespace = unset |
| | | insert_final_newline = unset |
| | | |
| | | [src/backend/jit/llvm/SectionMemoryManager.cpp] |
| | | indent_style = unset |
| | | indent_size = unset |
| | | trim_trailing_whitespace = unset |
| | | insert_final_newline = unset |
| | | |
| | | [src/backend/jit/llvm/SectionMemoryManager.LICENSE] |
| | | indent_style = unset |
| | | indent_size = unset |
| | | trim_trailing_whitespace = unset |
| | | insert_final_newline = unset |
| | | |
| | | [src/backend/regex/COPYRIGHT] |
| | | indent_style = unset |
| | | indent_size = unset |
| | | trim_trailing_whitespace = unset |
| | | insert_final_newline = unset |
| | | |
| | | [src/backend/snowball/libstemmer/*.c] |
| | | indent_style = unset |
| | | indent_size = unset |
| | | trim_trailing_whitespace = unset |
| | | insert_final_newline = unset |
| | | |
| | | [src/backend/utils/mb/Unicode/*-std.txt] |
| | | indent_style = unset |
| | | indent_size = unset |
| | | trim_trailing_whitespace = unset |
| | | insert_final_newline = unset |
| | | |
| | | [src/include/jit/SectionMemoryManager.h] |
| | | indent_style = unset |
| | | indent_size = unset |
| | | trim_trailing_whitespace = unset |
| | | insert_final_newline = unset |
| | | |
| | | [src/include/snowball/libstemmer/*] |
| | | indent_style = unset |
| | | indent_size = unset |
| | | trim_trailing_whitespace = unset |
| | | insert_final_newline = unset |
| | | |
| | | [src/timezone/data/*] |
| | | indent_style = unset |
| | | indent_size = unset |
| | | trim_trailing_whitespace = unset |
| | | insert_final_newline = unset |
| | | |
| | | [src/tools/pg_bsd_indent/*] |
| | | indent_style = unset |
| | | indent_size = unset |
| | | trim_trailing_whitespace = unset |
| | | insert_final_newline = unset |
| | | |
| | | [src/tools/pg_bsd_indent/tests/*] |
| | | indent_style = unset |
| | | indent_size = unset |
| | | trim_trailing_whitespace = unset |
| | | insert_final_newline = unset |
| | | |
| | | [src/tools/pg_bsd_indent/*.[ch]] |
| | | trim_trailing_whitespace = unset |
| | | insert_final_newline = unset |
| | | indent_style = unset |
| | | tab_width = 8 |
| New file |
| | |
| | | # As of git 2.23, git-blame supports ignoring specific commits. This is useful |
| | | # with commits that make bulk formatting changes without truly changing any |
| | | # code. |
| | | # |
| | | # This file lists ignorable pgindent, pgperltidy, and reformat-dat-files |
| | | # related commits only. Please don't add commits that are not in this |
| | | # category. |
| | | # |
| | | # You can use the ignore list file by running: |
| | | # |
| | | # $ git config blame.ignoreRevsFile .git-blame-ignore-revs |
| | | # |
| | | # Add new entries by adding the output of the following to the top of the file: |
| | | # |
| | | # $ git log --pretty=format:"%H # %cd%n# %s" $PGINDENTGITHASH -1 --date=iso |
| | | |
| | | 2795f5a5428fd292996fd155f16a57b0db3df8f4 # 2025-10-21 09:56:26 -0500 |
| | | # Re-pgindent brin.c. |
| | | |
| | | 17a5ca58eb119a33e81e57b72618236538932167 # 2025-09-13 14:50:02 -0500 |
| | | # Re-pgindent nbtpreprocesskeys.c after commit 796962922e. |
| | | |
| | | 07448b3969d55a2081cdafafc23f68df3392f220 # 2025-07-01 15:24:19 +0200 |
| | | # Fix indentation in pg_numa code |
| | | |
| | | b27644bade0348d0dafd3036c47880a349fe9332 # 2025-06-15 13:04:24 -0400 |
| | | # Sync typedefs.list with the buildfarm. |
| | | |
| | | 4672b6223910687b2aab075bcd2dd54ce90d5171 # 2025-06-01 14:55:24 -0400 |
| | | # Run pgindent on the previous commit. |
| | | |
| | | 918e7287ed20eb1fe280ab6c4056ccf94dcd53a8 # 2025-04-30 19:18:30 +1200 |
| | | # Fix broken indentation |
| | | |
| | | e1a8b1ad587112e67fdc5aa7b388631dde4dbdda # 2025-04-04 09:38:22 -0500 |
| | | # Re-pgindent pg_largeobject.c after commit 0d6c477664. |
| | | |
| | | 796bdda484c838313959f65e2b700f14ac7c0e66 # 2025-03-18 09:02:36 -0400 |
| | | # Fix indentation again. |
| | | |
| | | 203c1b4cc49455364b6bcab8034900d1c016b9cd # 2025-03-17 16:06:17 -0400 |
| | | # Fix indentation. |
| | | |
| | | b955df443405e056fd9047ef819a1465654f9d79 # 2025-03-13 12:41:44 +1300 |
| | | # Fix indentation issue |
| | | |
| | | 76aa615943049c04efd36ab4765c06eda89cdfea # 2025-01-31 16:44:24 +0900 |
| | | # Fix bad indentation introduced in commit d47cbf474 |
| | | |
| | | 6e826278f1ebd9967c0f8adda29c8960a812e344 # 2025-01-13 11:27:32 +0900 |
| | | # Fix pgindent damage |
| | | |
| | | 301de6a6f609cb3ad2d9d31fd8db9ae6c71e6dea # 2024-12-25 17:55:42 +0100 |
| | | # Partial pgindent of .l and .y files |
| | | |
| | | 53dcba9be5746cc126bdb949bf81c29ea2cfc24d # 2024-11-21 21:40:17 +0100 |
| | | # pgindent run |
| | | |
| | | a7f2f6adc240a2823c2344b89e90bb630dea8803 # 2024-10-16 12:21:13 -0700 |
| | | # Whitespace fixup from generated unicode tables. |
| | | |
| | | 7f7474a8e4002ac9fd4979cc7b16b50b70b70c28 # 2024-09-27 11:14:31 -0400 |
| | | # Reindent pg_verifybackup.c. |
| | | |
| | | 7229ebe011dff3f418251a4836f6d098923aa1e1 # 2024-08-26 16:16:12 -0700 |
| | | # Fix identation. |
| | | |
| | | 2b03cfeea47834913ff769124f4deba88140f662 # 2024-08-21 09:58:11 -0400 |
| | | # Fix pgindent damage |
| | | |
| | | 97add39c038bbdb9082b416ddf04cd20b0d20bf5 # 2024-08-15 11:41:46 -0400 |
| | | # Clean up indentation and whitespace inconsistencies in ecpg. |
| | | |
| | | 8de5ca1dc9fa809102acd1983ee19159d0bc469f # 2024-08-12 10:57:03 +0300 |
| | | # Fix bad indentation introduced in commit f011e82c2c |
| | | |
| | | c883453cb29cb40c1e59c3c54d159c5e744da8a9 # 2024-07-26 12:00:04 -0400 |
| | | # Fix indentation. |
| | | |
| | | 47ecbfdfcc71e41d7dcc35f0be04f8adbe88397f # 2024-07-15 15:17:04 -0700 |
| | | # Fix bad indentation introduced in 43cd30bcd1c |
| | | |
| | | b48f275f18d7da4f4863888ad047cbd699698880 # 2024-06-28 10:51:05 -0400 |
| | | # pgindent, because I forgot to do that. |
| | | |
| | | da256a4a7fdcca35fe7ca808686ad3de6ee22306 # 2024-05-14 16:34:50 -0400 |
| | | # Pre-beta mechanical code beautification. |
| | | |
| | | 64e401b62b1559d617db5c1e1070d7a05e794c27 # 2024-03-25 14:18:33 +0100 |
| | | # Fix indentation from a11f330b5 |
| | | |
| | | 0984a3b851abe89bec6c3eff51b03038808e1997 # 2024-03-05 11:16:23 -0800 |
| | | # Run pgindent again on the same file. |
| | | |
| | | b406af1806e9fc5c090e58282c7d98f22a4b397f # 2024-03-05 10:58:24 -0800 |
| | | # Run pgindent for commit ef4cfdce0e. |
| | | |
| | | dd7ea37c435e10f9c5aa3fb257a05c08814a4ad2 # 2024-03-04 14:37:35 -0500 |
| | | # Fix pgindent damage. |
| | | |
| | | 3d47b75546d1ef70145f58e162a96f7e0c649389 # 2024-02-22 08:00:58 +0100 |
| | | # pgindent fix |
| | | |
| | | 49e7c6f78ed608c5d5454080ae19c0e7f1b09a04 # 2024-02-09 11:05:01 +0900 |
| | | # Fix indentation of copyto.c |
| | | |
| | | 96c019ffa3f883d139709ea0cfe76dc1bce0f1f8 # 2024-01-13 13:54:11 -0500 |
| | | # Re-pgindent catcache.c after previous commit. |
| | | |
| | | 611806cd726fc92989ac918eac48fd8d684869c7 # 2023-10-26 09:20:54 +0200 |
| | | # Add trailing commas to enum definitions |
| | | |
| | | e9718b4bd3e4234ffd5a4907a903367fc483c843 # 2023-10-16 09:36:31 +0900 |
| | | # Fix code indentation violations in e83d1b0c40cc |
| | | |
| | | 01529c7040088db2718628d0814058598152bd39 # 2023-10-16 13:32:41 +1300 |
| | | # Fix comment from commit 22655aa231. |
| | | |
| | | b6a77c6a6ccf698787201b001cbbbf9c89fe5715 # 2023-10-11 17:14:31 -0400 |
| | | # Reindent comment in GenericXLogFinish(). |
| | | |
| | | bc6041b61f6678d32a5cfb70744653cd8f8d01c0 # 2023-08-30 15:56:22 +0900 |
| | | # Fix code indentation vioaltion introduced in commit 3c662643c4. |
| | | |
| | | 89be0b89ae60c63856fd26d82a104781540e2312 # 2023-08-15 17:45:00 +0900 |
| | | # Fix code indentation vioaltion introduced in commit 9e9931d2b. |
| | | |
| | | 5dc456b7dda4f7d0d7735b066607c190c74d174a # 2023-08-11 20:43:34 +0900 |
| | | # Fix code indentation violations introduced by recent commit |
| | | |
| | | 62e9af4c63fbd36fb9af8450fb44bece76d7766f # 2023-07-25 12:35:58 +0530 |
| | | # Fix code indentation vioaltion introduced in commit d38ad8e31d. |
| | | |
| | | 4e465aac36ce9a9533c68dbdc83e67579880e628 # 2023-07-18 14:04:31 +0900 |
| | | # Fix indentation in twophase.c |
| | | |
| | | 328f492d2565cfbe383f13a69425d751fd79415f # 2023-07-13 22:26:10 +0900 |
| | | # Fix code indentation violation in commit b6e1157e7d |
| | | |
| | | 69a674a170058e63e8178aec8a36a673efce8801 # 2023-07-06 11:49:18 +0530 |
| | | # Fix code indentation vioaltion introduced in commit cc32ec24fd. |
| | | |
| | | a4cfeeca5a97f2b5969c31aa69ba775af95ee5a3 # 2023-07-03 12:47:49 +0200 |
| | | # Fix code indentation violations |
| | | |
| | | b334612b8aee9f9a34378982d8938b201dfad323 # 2023-06-20 09:50:43 -0400 |
| | | # Pre-beta2 mechanical code beautification. |
| | | |
| | | 0245f8db36f375326c2bae0c3420d3c77714e72d # 2023-05-19 17:24:48 -0400 |
| | | # Pre-beta mechanical code beautification. |
| | | |
| | | b6dfee28f2b44e28b123b77a91fb05c47da63501 # 2023-03-09 15:09:45 +0900 |
| | | # Run pgindent on libpq's fe-auth.c, fe-auth-scram.c and fe-connect.c |
| | | |
| | | 250c8ee07ede8a104ae1471f6ebca204d94267dd # 2023-01-13 15:23:17 -0800 |
| | | # Manual cleanup and pgindent of pgstat and bufmgr related code |
| | | |
| | | b2e6e768230be334b12dae536ba4c147fba4e9c9 # 2022-09-08 14:01:13 +0700 |
| | | # Run perltidy over Catalog.pm |
| | | |
| | | 82d0ffae3219e4bc153a1306ce23013d168e04a2 # 2022-06-30 11:03:03 -0400 |
| | | # pgindent run prior to branching v15. |
| | | |
| | | 23e7b38bfe396f919fdb66057174d29e17086418 # 2022-05-12 15:17:30 -0400 |
| | | # Pre-beta mechanical code beautification. |
| | | |
| | | a3a75b982b5bb6fba95ad8b3d48e70439dcd2329 # 2022-03-19 11:42:22 -0700 |
| | | # pgstat: run pgindent on pgstat.c/h. |
| | | |
| | | d231be00cbf29bf24e5b4fc79e587982bbc00ebb # 2022-02-16 09:22:34 +0200 |
| | | # Run pgindent on xlog.c. |
| | | |
| | | e1c1c30f635390b6a3ae4993e8cac213a33e6e3f # 2021-06-28 11:05:54 -0400 |
| | | # Pre branch pgindent / pgperltidy run |
| | | |
| | | def5b065ff22a16a80084587613599fe15627213 # 2021-05-12 13:14:10 -0400 |
| | | # Initial pgindent and pgperltidy run for v14. |
| | | |
| | | ed43677e20369040ca4e50c698010c39d5ac0f47 # 2021-01-19 08:10:13 +0530 |
| | | # pgindent worker.c. |
| | | |
| | | 8b411b8ff41566a1aa601d1f05aeebbebbdb4a54 # 2021-01-13 16:14:38 -0500 |
| | | # Run reformat-dat-files to declutter the catalog data files. |
| | | |
| | | b5d69b7c22ee4c44b8bb99cfa0466ffaf3b5fab9 # 2020-06-07 16:57:08 -0400 |
| | | # pgindent run prior to branching v13. |
| | | |
| | | fa27dd40d5c5f56a1ee837a75c97549e992e32a4 # 2020-05-16 11:54:51 -0400 |
| | | # Run pgindent with new pg_bsd_indent version 2.1.1. |
| | | |
| | | e02ad575d8ab6b44500d2a3fd8c3212345e3aa2b # 2020-05-16 11:49:14 -0400 |
| | | # Final pgindent run with pg_bsd_indent version 2.1. |
| | | |
| | | 5cbfce562f7cd2aab0cdc4694ce298ec3567930e # 2020-05-14 13:06:50 -0400 |
| | | # Initial pgindent and pgperltidy run for v13. |
| | | |
| | | b78542b9e975494bba6db2d2802439c3328d5ef7 # 2020-02-15 14:58:30 -0500 |
| | | # Run "make reformat-dat-files". |
| | | |
| | | c9d29775195922136c09cc980bb1b7091bf3d859 # 2020-01-30 13:42:14 -0300 |
| | | # Clean up newlines following left parentheses |
| | | |
| | | 9e1c9f959422192bbe1b842a2a1ffaf76b080196 # 2019-07-01 12:37:52 -0400 |
| | | # pgindent run prior to branching v12. |
| | | |
| | | db6e2b4c52ade524f3db419d75084728e96e1f9c # 2019-05-22 13:36:19 -0400 |
| | | # Initial pgperltidy run for v12. |
| | | |
| | | 8255c7a5eeba8f1a38b7a431c04909bde4f5e67d # 2019-05-22 13:04:48 -0400 |
| | | # Phase 2 pgindent run for v12. |
| | | |
| | | be76af171cdb3e7465c4ef234af403f97ad79b7b # 2019-05-22 12:55:34 -0400 |
| | | # Initial pgindent run for v12. |
| | | |
| | | d8421390996dcd762383a28e57d1f3f16cc5f76f # 2018-06-30 12:28:55 -0400 |
| | | # perltidy run prior to branching |
| | | |
| | | 1e9c8580904625576871eeb2efec7f04d4c3bc1c # 2018-06-30 12:25:49 -0400 |
| | | # pgindent run prior to branching |
| | | |
| | | bdf46af748d0f15f257c99bf06e9e25aba6a24f9 # 2018-04-26 14:47:16 -0400 |
| | | # Post-feature-freeze pgindent run. |
| | | |
| | | f04d4ac919b9ae9b57e977523e4b40979aa8b951 # 2018-04-25 14:00:19 -0400 |
| | | # Reindent Perl files with perltidy version 20170521. |
| | | |
| | | eaedf0df7197b21182f6c341a44e4fdaa3cd6ea6 # 2017-11-29 09:24:24 -0500 |
| | | # Update typedefs.list and re-run pgindent |
| | | |
| | | 21d304dfedb4f26d0d6587d9ac39b1b5c499bb55 # 2017-08-14 17:29:33 -0400 |
| | | # Final pgindent + perltidy run for v10. |
| | | |
| | | 382ceffdf7f620d8f2d50e451b4167d291ae2348 # 2017-06-21 15:35:54 -0400 |
| | | # Phase 3 of pgindent updates. |
| | | |
| | | c7b8998ebbf310a156aa38022555a24d98fdbfb4 # 2017-06-21 15:19:25 -0400 |
| | | # Phase 2 of pgindent updates. |
| | | |
| | | e3860ffa4dd0dad0dd9eea4be9cc1412373a8c89 # 2017-06-21 14:39:04 -0400 |
| | | # Initial pgindent run with pg_bsd_indent version 2.0. |
| | | |
| | | 9ef2dbefc7fb3ac22e1528bc22a41a5c6c6a9539 # 2017-06-21 14:09:24 -0400 |
| | | # Final pgindent run with old pg_bsd_indent (version 1.3). |
| | | |
| | | 651902deb1551db8b401fdeab9bdb8a61cee7f9f # 2017-06-13 13:05:59 -0400 |
| | | # Re-run pgindent. |
| | | |
| | | ce554810329b9b8e862eade08b598148931eb456 # 2017-05-17 19:01:23 -0400 |
| | | # Post-PG 10 beta1 pgperltidy run |
| | | |
| | | a6fd7b7a5f7bf3a8aa3f3d076cf09d922c1c6dd2 # 2017-05-17 16:31:56 -0400 |
| | | # Post-PG 10 beta1 pgindent run |
| | | |
| | | b5bce6c1ec6061c8a4f730d927e162db7e2ce365 # 2016-08-15 13:42:51 -0400 |
| | | # Final pgindent + perltidy run for 9.6. |
| | | |
| | | 3be0a62ffe58f0753d190cbe22acbeb8b4926b85 # 2016-06-12 04:19:56 -0400 |
| | | # Finish pgindent run for 9.6: Perl files. |
| | | |
| | | 4bc424b968058c7f0aa685821d7039e86faac99c # 2016-06-09 18:02:36 -0400 |
| | | # pgindent run for 9.6 |
| | | |
| | | de94e2af184e25576b13cbda8cf825118835d1cd # 2016-04-06 11:34:02 -0400 |
| | | # Run pgindent on a batch of (mostly-planner-related) source files. |
| | | |
| | | be060cbcd42737693f6fd425db4c139121181cce # 2016-03-09 13:51:11 -0500 |
| | | # Re-pgindent vacuumlazy.c. |
| | | |
| | | 0231f838565d2921a0960407c4240237ba1d56ae # 2016-02-08 15:17:40 -0500 |
| | | # Re-pgindent varlena.c. |
| | | |
| | | d0cd7bda97a626049aa7d247374909c52399c413 # 2016-02-04 22:30:08 -0500 |
| | | # postgres_fdw: pgindent run. |
| | | |
| | | 8d290c8ec6c182a4df1d089c21fe84c7912f01fe # 2016-01-17 19:13:18 -0500 |
| | | # Re-pgindent a few files. |
| | | |
| | | befa3e648ce018d84cd2a0df701927c56fe3da4e # 2015-05-24 21:45:01 -0400 |
| | | # Revert 9.5 pgindent changes to atomics directory files |
| | | |
| | | 807b9e0dff663c5da875af7907a5106c0ff90673 # 2015-05-23 21:35:49 -0400 |
| | | # pgindent run for 9.5 |
| | | |
| | | 785941cdc359c6e595201ffb0df9d28f3f7173a4 # 2015-03-26 14:03:25 -0400 |
| | | # Tweak __attribute__-wrapping macros for better pgindent results. |
| | | |
| | | 7584649a1c58029a83a7a57d74cedcf1af434c97 # 2014-10-17 12:19:05 -0400 |
| | | # Re-pgindent src/bin/pg_dump/*. |
| | | |
| | | 84288a86ac74dbeae486b6ff699c017f7d9517bb # 2014-05-06 20:39:28 -0400 |
| | | # With ecpg exclusion removed, re-run pgindent for 9.4 |
| | | |
| | | 0a7832005792fa6dad171f9cadb8d587fe0dd800 # 2014-05-06 12:12:18 -0400 |
| | | # pgindent run for 9.4 |
| | | |
| | | 9af4159fce6654aa0e081b00d02bca40b978745c # 2013-05-29 16:58:43 -0400 |
| | | # pgindent run for release 9.3 This is the first run of the Perl-based pgindent script. Also update pgindent instructions. |
| | | |
| | | 927d61eeff78363ea3938c818d07e511ebaf75cf # 2012-06-10 15:20:04 -0400 |
| | | # Run pgindent on 9.2 source tree in preparation for first 9.3 commit-fest. |
| | | |
| | | 6560407c7db2c7e32926a46f5fb52175ac10d9e5 # 2011-06-09 14:32:50 -0400 |
| | | # Pgindent run before 9.1 beta2. |
| | | |
| | | bf50caf105a901c4f83ac1df3cdaf910c26694a4 # 2011-04-10 11:42:00 -0400 |
| | | # pgindent run before PG 9.1 beta 1. |
| | | |
| | | 239d769e7e05e0a5ef3bd6828e93e22ef3962780 # 2010-07-06 19:19:02 +0000 |
| | | # pgindent run for 9.0, second run |
| | | |
| | | 65e806cba1f0f154d51caa7478e7192ce58d1056 # 2010-02-26 02:01:40 +0000 |
| | | # pgindent run for 9.0 |
| | | |
| | | d7471402794266078953f1bd113dab4913d631a1 # 2009-06-11 14:49:15 +0000 |
| | | # 8.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef list provided by Andrew. |
| | | |
| | | f6e8730d11ddfc720eda1dde23794d262ad8cc08 # 2007-11-15 22:25:18 +0000 |
| | | # Re-run pgindent with updated list of typedefs. (Updated README should avoid this problem in the future.) |
| | | |
| | | fdf5a5efb7b28c13085fe7313658de8d7b9914f6 # 2007-11-15 21:14:46 +0000 |
| | | # pgindent run for 8.3. |
| | | |
| | | f99a569a2ee3763b4ae174e81250c95ca0fdcbb6 # 2006-10-04 00:30:14 +0000 |
| | | # pgindent run for 8.2. |
| | | |
| | | 436a2956d80db29ac1dff640b631620d856b4f70 # 2005-11-22 18:17:34 +0000 |
| | | # Re-run pgindent, fixing a problem where comment lines after a blank comment line where output as too long, and update typedefs for /lib directory. Also fix case where identifiers were used as variable names in the backend, but as typedefs in ecpg (favor the backend for indenting). |
| | | |
| | | 1dc34982511d91ef8a2b71bdcb870f067c1b3da9 # 2005-10-15 02:49:52 +0000 |
| | | # Standard pgindent run for 8.1. |
| | | |
| | | b3364fc81b78538006da3b3ad5680530d2af8c47 # 2005-09-22 20:44:36 +0000 |
| | | # pgindent new GIST index code, per request from Tom. |
| | | |
| | | 15d3f9f6b7849a70281f151f0def7a6d335767d7 # 2004-08-30 02:54:42 +0000 |
| | | # Another pgindent run with lib typedefs added. |
| | | |
| | | b6b71b85bc45b49005b5aec87cba2c33fc8baf49 # 2004-08-29 05:07:03 +0000 |
| | | # Pgindent run for 8.0. |
| | | |
| | | 46785776c42143af8f5433bb580ff13f2a9f65e1 # 2003-08-08 21:42:59 +0000 |
| | | # Another pgindent run with updated typedefs. |
| | | |
| | | 089003fb462fcce46c02bf47322b429f73c33c50 # 2003-08-04 00:43:34 +0000 |
| | | # pgindent run. |
| | | |
| | | e50f52a074bdf0d6a9dc384840e641c4c0b0bb1a # 2002-09-04 20:31:48 +0000 |
| | | # pgindent run. |
| | | |
| | | ea08e6cd5542cb269ecd3e735f1dfa3bb61fbc4f # 2001-11-05 17:46:40 +0000 |
| | | # New pgindent run with fixes suggested by Tom. Patch manually reviewed, initdb/regression tests pass. |
| | | |
| | | 6783b2372ef13c141649840a836ff0a954ea1d4d # 2001-10-28 06:26:15 +0000 |
| | | # Another pgindent run. Fixes enum indenting, and improves #endif spacing. Also adds space for one-line comments. |
| | | |
| | | b81844b1738c584d92330a5ccd0fbd8b603d2886 # 2001-10-25 05:50:21 +0000 |
| | | # pgindent run on all C files. Java run to follow. initdb/regression tests pass. |
| | | |
| | | 0686d49da0a34ad92f61f791ea1039dec5d20f41 # 2001-03-22 06:16:21 +0000 |
| | | # Remove dashes in comments that don't need them, rewrap with pgindent. |
| | | |
| | | 9e1552607a9dc6bc23e43d46770a9063ade4f3f0 # 2001-03-22 04:01:46 +0000 |
| | | # pgindent run. Make it all clean. |
| | | |
| | | 52f77df613cea1803ce86321c37229626d9f213c # 2000-04-12 17:17:23 +0000 |
| | | # Ye-old pgindent run. Same 4-space tabs. |
| | | |
| | | fcff1cdf4eadbc6dcba4b9a2cd09f38f466ffa31 # 1999-05-25 22:43:53 +0000 |
| | | # Another pgindent run. Sorry folks. |
| | | |
| | | 07842084fe3e11041f83563c851236395f481470 # 1999-05-25 16:15:34 +0000 |
| | | # pgindent run over code. |
| | | |
| | | fa1a8d6a97068295fe30ac646aec7493a6305bc2 # 1998-09-01 04:40:42 +0000 |
| | | # OK, folks, here is the pgindent output. |
| | | |
| | | af74855a608da4cd7ef88ceb2241ec1c75537f39 # 1998-09-01 03:29:17 +0000 |
| | | # Renaming cleanup, no pgindent yet. |
| | | |
| | | a32450a5855eed4bfd756ef292ee45d3c754665b # 1998-02-26 04:46:47 +0000 |
| | | # pgindent run before 6.3 release, with Thomas' requested changes. |
| | | |
| | | 59f6a57e59fe8353f9edaa3703516ea67e06672b # 1997-09-08 21:56:23 +0000 |
| | | # Used modified version of indent that understands over 100 typedefs. |
| | | |
| | | 075cede74858a9a04e97097b1ccd555121516c20 # 1997-09-08 20:59:27 +0000 |
| | | # Add typdefs to pgindent run. |
| | | |
| | | 319dbfa7364721d3343af03a7ce063c2a2c9d385 # 1997-09-08 02:41:22 +0000 |
| | | # Another PGINDENT run that changes variable indenting and case label indenting. Also static variable indenting. |
| | | |
| | | 1ccd423235a48739d6f7a4d7889705b5f9ecc69b # 1997-09-07 05:04:48 +0000 |
| | | # Massive commit to run PGINDENT on all *.c and *.h files. |
| New file |
| | |
| | | # IMPORTANT: After updating this file, also run src/tools/generate_editorconfig.py |
| | | |
| | | * whitespace=space-before-tab,trailing-space |
| | | *.[chly] whitespace=space-before-tab,trailing-space,indent-with-non-tab,tabwidth=4 |
| | | *.cpp whitespace=space-before-tab,trailing-space,indent-with-non-tab,tabwidth=4 |
| | | *.pl whitespace=space-before-tab,trailing-space,tabwidth=4 |
| | | *.pm whitespace=space-before-tab,trailing-space,tabwidth=4 |
| | | *.po whitespace=space-before-tab,trailing-space,tab-in-indent,-blank-at-eof |
| | | *.py whitespace=space-before-tab,trailing-space,tab-in-indent |
| | | *.sgml whitespace=space-before-tab,trailing-space,tab-in-indent |
| | | *.xml whitespace=space-before-tab,trailing-space,tab-in-indent |
| | | *.xsl whitespace=space-before-tab,trailing-space,tab-in-indent |
| | | |
| | | # Avoid confusing ASCII underlines with leftover merge conflict markers |
| | | README conflict-marker-size=48 |
| | | README.* conflict-marker-size=48 |
| | | |
| | | # Certain data files that contain special whitespace, and other special cases |
| | | *.data -whitespace |
| | | contrib/pgcrypto/sql/pgp-armor.sql whitespace=-blank-at-eol |
| | | src/backend/catalog/sql_features.txt whitespace=space-before-tab,blank-at-eof,-blank-at-eol |
| | | |
| | | # Test output files that contain extra whitespace |
| | | *.out -whitespace |
| | | src/interfaces/ecpg/test/expected/* -whitespace |
| | | |
| | | # These files are maintained or generated elsewhere. We take them as is. |
| | | configure -whitespace |
| | | ppport.h -whitespace |
| | | src/backend/jit/llvm/SectionMemoryManager.cpp -whitespace |
| | | src/backend/jit/llvm/SectionMemoryManager.LICENSE -whitespace |
| | | src/backend/regex/COPYRIGHT -whitespace |
| | | src/backend/snowball/libstemmer/*.c -whitespace |
| | | src/backend/utils/mb/Unicode/*-std.txt -whitespace |
| | | src/include/jit/SectionMemoryManager.h -whitespace |
| | | src/include/snowball/libstemmer/* -whitespace |
| | | src/timezone/data/* -whitespace |
| | | src/tools/pg_bsd_indent/* -whitespace |
| | | src/tools/pg_bsd_indent/tests/* -whitespace |
| | | src/tools/pg_bsd_indent/*.[ch] whitespace=-blank-at-eol,-blank-at-eof,tabwidth=8 |
| New file |
| | |
| | | # This file contains ignores for build artifacts from standard builds. |
| | | # Auxiliary files from local workflows, your preferred editor, etc. should |
| | | # be ignored locally using $GIT_DIR/info/exclude or ~/.gitexclude. |
| | | |
| | | # Global excludes across all subdirectories |
| | | *.o |
| | | *.obj |
| | | *.bc |
| | | *.so |
| | | *.so.[0-9] |
| | | *.so.[0-9].[0-9] |
| | | *.so.[0-9].[0-9][0-9] |
| | | *.dylib |
| | | *.dll |
| | | *.exp |
| | | *.a |
| | | *.mo |
| | | *.pot |
| | | objfiles.txt |
| | | .deps/ |
| | | *.gcno |
| | | *.gcda |
| | | *.gcov |
| | | *.gcov.out |
| | | lcov*.info |
| | | coverage/ |
| | | coverage-html-stamp |
| | | *.vcproj |
| | | *.vcxproj |
| | | win32ver.rc |
| | | *.exe |
| | | lib*dll.def |
| | | lib*.pc |
| | | .vscode |
| | | *.su |
| | | |
| | | # Local excludes in root directory |
| | | /GNUmakefile |
| | | /config.cache |
| | | /config.log |
| | | /config.status |
| | | /pgsql.sln |
| | | /pgsql.sln.cache |
| | | /Debug/ |
| | | /Release/ |
| | | /tmp_install/ |
| | | /portlock/ |
| | | build_report.log |
| | | results/ |
| | | tmp_check/ |
| | | tmp_install/ |
| | | *.diffs |
| | | *.log |
| | | regression.out |
| | | hist.txt |
| | | mk_all.sh |
| | | shist.txt |
| | | rudb_data1.tar.gz |
| | | |
| | | # pg_dgrid build artifacts |
| | | /pg_dgrid/client/dgridc |
| | | /pg_dgrid/dgrid.ld.so.conf |
| | | /pg_dgrid/libs/lib/*.so.*.*.* |
| | | /pg_dgrid/server/config/dgridd.service |
| | | /pg_dgrid/server/dgridd |
| | | |
| | | |
| | | .cursorrules |
| New file |
| | |
| | | Álvaro Herrera <alvherre@alvh.no-ip.org> |
| | |
| | | CFLAGS_CRC |
| | | LIBOBJS |
| | | OPENSSL |
| | | PCRE2 |
| | | ZSTD |
| | | LZ4 |
| | | UUID_LIBS |
| | |
| | | STRIP |
| | | LDFLAGS_SL |
| | | LDFLAGS_EX |
| | | PCRE2_LIBS |
| | | PCRE2_CFLAGS |
| | | with_pcre2 |
| | | ZSTD_LIBS |
| | | ZSTD_CFLAGS |
| | | with_zstd |
| | |
| | | with_zlib |
| | | with_lz4 |
| | | with_zstd |
| | | with_pcre2 |
| | | with_ssl |
| | | with_openssl |
| | | enable_largefile |
| | |
| | | LZ4_LIBS |
| | | ZSTD_CFLAGS |
| | | ZSTD_LIBS |
| | | PCRE2_CFLAGS |
| | | PCRE2_LIBS |
| | | LDFLAGS_EX |
| | | LDFLAGS_SL |
| | | PERL |
| | |
| | | --without-zlib do not use Zlib |
| | | --with-lz4 build with LZ4 support |
| | | --with-zstd build with ZSTD support |
| | | --with-pcre2 build with PCRE2 support |
| | | --with-ssl=LIB use LIB for SSL/TLS support (openssl) |
| | | --with-openssl obsolete spelling of --with-ssl=openssl |
| | | |
| | |
| | | LZ4_LIBS linker flags for LZ4, overriding pkg-config |
| | | ZSTD_CFLAGS C compiler flags for ZSTD, overriding pkg-config |
| | | ZSTD_LIBS linker flags for ZSTD, overriding pkg-config |
| | | PCRE2_CFLAGS |
| | | C compiler flags for PCRE2, overriding pkg-config |
| | | PCRE2_LIBS linker flags for PCRE2, overriding pkg-config |
| | | LDFLAGS_EX extra linker flags for linking executables only |
| | | LDFLAGS_SL extra linker flags for linking shared libraries only |
| | | PERL Perl program |
| | |
| | | esac |
| | | done |
| | | fi |
| | | |
| | | # |
| | | # PCRE2 |
| | | # |
| | | { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build with PCRE2 support" >&5 |
| | | $as_echo_n "checking whether to build with PCRE2 support... " >&6; } |
| | | |
| | | |
| | | |
| | | # Check whether --with-pcre2 was given. |
| | | if test "${with_pcre2+set}" = set; then : |
| | | withval=$with_pcre2; |
| | | case $withval in |
| | | yes) |
| | | |
| | | $as_echo "#define USE_PCRE2 1" >>confdefs.h |
| | | |
| | | ;; |
| | | no) |
| | | : |
| | | ;; |
| | | *) |
| | | as_fn_error $? "no argument expected for --with-pcre2 option" "$LINENO" 5 |
| | | ;; |
| | | esac |
| | | |
| | | else |
| | | with_pcre2=no |
| | | |
| | | fi |
| | | |
| | | |
| | | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_pcre2" >&5 |
| | | $as_echo "$with_pcre2" >&6; } |
| | | |
| | | if test "$with_pcre2" = yes; then |
| | | |
| | | pkg_failed=no |
| | | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libpcre2-8" >&5 |
| | | $as_echo_n "checking for libpcre2-8... " >&6; } |
| | | |
| | | if test -n "$PCRE2_CFLAGS"; then |
| | | pkg_cv_PCRE2_CFLAGS="$PCRE2_CFLAGS" |
| | | elif test -n "$PKG_CONFIG"; then |
| | | if test -n "$PKG_CONFIG" && \ |
| | | { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpcre2-8\""; } >&5 |
| | | ($PKG_CONFIG --exists --print-errors "libpcre2-8") 2>&5 |
| | | ac_status=$? |
| | | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 |
| | | test $ac_status = 0; }; then |
| | | pkg_cv_PCRE2_CFLAGS=`$PKG_CONFIG --cflags "libpcre2-8" 2>/dev/null` |
| | | test "x$?" != "x0" && pkg_failed=yes |
| | | else |
| | | pkg_failed=yes |
| | | fi |
| | | else |
| | | pkg_failed=untried |
| | | fi |
| | | if test -n "$PCRE2_LIBS"; then |
| | | pkg_cv_PCRE2_LIBS="$PCRE2_LIBS" |
| | | elif test -n "$PKG_CONFIG"; then |
| | | if test -n "$PKG_CONFIG" && \ |
| | | { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpcre2-8\""; } >&5 |
| | | ($PKG_CONFIG --exists --print-errors "libpcre2-8") 2>&5 |
| | | ac_status=$? |
| | | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 |
| | | test $ac_status = 0; }; then |
| | | pkg_cv_PCRE2_LIBS=`$PKG_CONFIG --libs "libpcre2-8" 2>/dev/null` |
| | | test "x$?" != "x0" && pkg_failed=yes |
| | | else |
| | | pkg_failed=yes |
| | | fi |
| | | else |
| | | pkg_failed=untried |
| | | fi |
| | | |
| | | |
| | | |
| | | if test $pkg_failed = yes; then |
| | | { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 |
| | | $as_echo "no" >&6; } |
| | | |
| | | if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then |
| | | _pkg_short_errors_supported=yes |
| | | else |
| | | _pkg_short_errors_supported=no |
| | | fi |
| | | if test $_pkg_short_errors_supported = yes; then |
| | | PCRE2_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libpcre2-8" 2>&1` |
| | | else |
| | | PCRE2_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libpcre2-8" 2>&1` |
| | | fi |
| | | # Put the nasty error message in config.log where it belongs |
| | | echo "$PCRE2_PKG_ERRORS" >&5 |
| | | |
| | | as_fn_error $? "Package requirements (libpcre2-8) were not met: |
| | | |
| | | $PCRE2_PKG_ERRORS |
| | | |
| | | Consider adjusting the PKG_CONFIG_PATH environment variable if you |
| | | installed software in a non-standard prefix. |
| | | |
| | | Alternatively, you may set the environment variables PCRE2_CFLAGS |
| | | and PCRE2_LIBS to avoid the need to call pkg-config. |
| | | See the pkg-config man page for more details." "$LINENO" 5 |
| | | elif test $pkg_failed = untried; then |
| | | { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 |
| | | $as_echo "no" >&6; } |
| | | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
| | | $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} |
| | | as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it |
| | | is in your PATH or set the PKG_CONFIG environment variable to the full |
| | | path to pkg-config. |
| | | |
| | | Alternatively, you may set the environment variables PCRE2_CFLAGS |
| | | and PCRE2_LIBS to avoid the need to call pkg-config. |
| | | See the pkg-config man page for more details. |
| | | |
| | | To get pkg-config, see <http://pkg-config.freedesktop.org/>. |
| | | See \`config.log' for more details" "$LINENO" 5; } |
| | | else |
| | | PCRE2_CFLAGS=$pkg_cv_PCRE2_CFLAGS |
| | | PCRE2_LIBS=$pkg_cv_PCRE2_LIBS |
| | | { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 |
| | | $as_echo "yes" >&6; } |
| | | |
| | | fi |
| | | # We only care about -I, -D, and -L switches; |
| | | # note that -lpcre2-8 will be added by AC_CHECK_LIB below. |
| | | for pgac_option in $PCRE2_CFLAGS; do |
| | | case $pgac_option in |
| | | -I*|-D*) INCLUDES="$INCLUDES $pgac_option";; |
| | | esac |
| | | done |
| | | INCLUDES="$INCLUDES -DPCRE2_CODE_UNIT_WIDTH=8" |
| | | for pgac_option in $PCRE2_LIBS; do |
| | | case $pgac_option in |
| | | -L*) LIBDIRS="$LIBDIRS $pgac_option";; |
| | | esac |
| | | done |
| | | fi |
| | | |
| | | # |
| | | # Assignments |
| | | # |
| | |
| | | |
| | | fi |
| | | |
| | | if test "$with_pcre2" = yes ; then |
| | | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcre2_compile_8 in -lpcre2-8" >&5 |
| | | $as_echo_n "checking for pcre2_compile_8 in -lpcre2-8... " >&6; } |
| | | if ${ac_cv_lib_pcre2_8_pcre2_compile_8+:} false; then : |
| | | $as_echo_n "(cached) " >&6 |
| | | else |
| | | ac_check_lib_save_LIBS=$LIBS |
| | | LIBS="-lpcre2-8 $LIBS" |
| | | cat confdefs.h - <<_ACEOF >conftest.$ac_ext |
| | | /* end confdefs.h. */ |
| | | |
| | | /* Override any GCC internal prototype to avoid an error. |
| | | Use char because int might match the return type of a GCC |
| | | builtin and then its argument prototype would still apply. */ |
| | | #ifdef __cplusplus |
| | | extern "C" |
| | | #endif |
| | | char pcre2_compile_8 (); |
| | | int |
| | | main () |
| | | { |
| | | return pcre2_compile_8 (); |
| | | ; |
| | | return 0; |
| | | } |
| | | _ACEOF |
| | | if ac_fn_c_try_link "$LINENO"; then : |
| | | ac_cv_lib_pcre2_8_pcre2_compile_8=yes |
| | | else |
| | | ac_cv_lib_pcre2_8_pcre2_compile_8=no |
| | | fi |
| | | rm -f core conftest.err conftest.$ac_objext \ |
| | | conftest$ac_exeext conftest.$ac_ext |
| | | LIBS=$ac_check_lib_save_LIBS |
| | | fi |
| | | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pcre2_8_pcre2_compile_8" >&5 |
| | | $as_echo "$ac_cv_lib_pcre2_8_pcre2_compile_8" >&6; } |
| | | if test "x$ac_cv_lib_pcre2_8_pcre2_compile_8" = xyes; then : |
| | | cat >>confdefs.h <<_ACEOF |
| | | #define HAVE_LIBPCRE2_8 1 |
| | | _ACEOF |
| | | |
| | | LIBS="-lpcre2-8 $LIBS" |
| | | |
| | | else |
| | | as_fn_error $? "library 'pcre2-8' is required for PCRE2 support" "$LINENO" 5 |
| | | fi |
| | | |
| | | fi |
| | | |
| | | # Note: We can test for libldap_r only after we know PTHREAD_LIBS |
| | | if test "$with_ldap" = yes ; then |
| | | _LIBS="$LIBS" |
| | |
| | | |
| | | fi |
| | | |
| | | if test -z "$PCRE2"; then |
| | | for ac_prog in pcre2 |
| | | do |
| | | # Extract the first word of "$ac_prog", so it can be a program name with args. |
| | | set dummy $ac_prog; ac_word=$2 |
| | | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 |
| | | $as_echo_n "checking for $ac_word... " >&6; } |
| | | if ${ac_cv_path_PCRE2+:} false; then : |
| | | $as_echo_n "(cached) " >&6 |
| | | else |
| | | case $PCRE2 in |
| | | [\\/]* | ?:[\\/]*) |
| | | ac_cv_path_PCRE2="$PCRE2" # Let the user override the test with a path. |
| | | ;; |
| | | *) |
| | | as_save_IFS=$IFS; IFS=$PATH_SEPARATOR |
| | | for as_dir in $PATH |
| | | do |
| | | IFS=$as_save_IFS |
| | | test -z "$as_dir" && as_dir=. |
| | | for ac_exec_ext in '' $ac_executable_extensions; do |
| | | if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then |
| | | ac_cv_path_PCRE2="$as_dir/$ac_word$ac_exec_ext" |
| | | $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 |
| | | break 2 |
| | | fi |
| | | done |
| | | done |
| | | IFS=$as_save_IFS |
| | | |
| | | ;; |
| | | esac |
| | | fi |
| | | PCRE2=$ac_cv_path_PCRE2 |
| | | if test -n "$PCRE2"; then |
| | | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PCRE2" >&5 |
| | | $as_echo "$PCRE2" >&6; } |
| | | else |
| | | { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 |
| | | $as_echo "no" >&6; } |
| | | fi |
| | | |
| | | |
| | | test -n "$PCRE2" && break |
| | | done |
| | | |
| | | else |
| | | # Report the value of PCRE2 in configure's output in all cases. |
| | | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PCRE2" >&5 |
| | | $as_echo_n "checking for PCRE2... " >&6; } |
| | | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PCRE2" >&5 |
| | | $as_echo "$PCRE2" >&6; } |
| | | fi |
| | | |
| | | if test "$with_pcre2" = yes; then |
| | | ac_fn_c_check_header_mongrel "$LINENO" "pcre2.h" "ac_cv_header_pcre2_h" "$ac_includes_default" |
| | | if test "x$ac_cv_header_pcre2_h" = xyes; then : |
| | | |
| | | else |
| | | as_fn_error $? "pcre2.h header file is required for PCRE2" "$LINENO" 5 |
| | | fi |
| | | |
| | | |
| | | fi |
| | | |
| | | if test "$with_gssapi" = yes ; then |
| | | for ac_header in gssapi/gssapi.h |
| | | do : |
| | |
| | | esac |
| | | done |
| | | fi |
| | | |
| | | # |
| | | # PCRE2 |
| | | # |
| | | AC_MSG_CHECKING([whether to build with PCRE2 support]) |
| | | PGAC_ARG_BOOL(with, pcre2, no, [build with PCRE2 support], |
| | | [AC_DEFINE([USE_PCRE2], 1, [Define to 1 to build with PCRE2 support (--with-pcre2)])]) |
| | | AC_MSG_RESULT([$with_pcre2]) |
| | | AC_SUBST(with_pcre2) |
| | | if test "$with_pcre2" = yes; then |
| | | PKG_CHECK_MODULES(PCRE2, libpcre2-8) |
| | | # We only care about -I, -D, and -L switches; |
| | | # note that -lpcre2-8 will be added by AC_CHECK_LIB below. |
| | | for pgac_option in $PCRE2_CFLAGS; do |
| | | case $pgac_option in |
| | | -I*|-D*) INCLUDES="$INCLUDES $pgac_option";; |
| | | esac |
| | | done |
| | | INCLUDES="$INCLUDES -DPCRE2_CODE_UNIT_WIDTH=8" |
| | | for pgac_option in $PCRE2_LIBS; do |
| | | case $pgac_option in |
| | | -L*) LIBDIRS="$LIBDIRS $pgac_option";; |
| | | esac |
| | | done |
| | | fi |
| | | |
| | | # |
| | | # Assignments |
| | | # |
| | |
| | | AC_CHECK_LIB(zstd, ZSTD_compress, [], [AC_MSG_ERROR([library 'zstd' is required for ZSTD support])]) |
| | | fi |
| | | |
| | | if test "$with_pcre2" = yes ; then |
| | | AC_CHECK_LIB(pcre2-8, pcre2_compile_8, [], [AC_MSG_ERROR([library 'pcre2-8' is required for PCRE2 support])]) |
| | | fi |
| | | |
| | | # Note: We can test for libldap_r only after we know PTHREAD_LIBS |
| | | if test "$with_ldap" = yes ; then |
| | | _LIBS="$LIBS" |
| | |
| | | AC_CHECK_HEADER(zstd.h, [], [AC_MSG_ERROR([zstd.h header file is required for ZSTD])]) |
| | | fi |
| | | |
| | | PGAC_PATH_PROGS(PCRE2, pcre2) |
| | | if test "$with_pcre2" = yes; then |
| | | AC_CHECK_HEADER(pcre2.h, [], [AC_MSG_ERROR([pcre2.h header file is required for PCRE2])]) |
| | | fi |
| | | |
| | | if test "$with_gssapi" = yes ; then |
| | | AC_CHECK_HEADERS(gssapi/gssapi.h, [], |
| | | [AC_CHECK_HEADERS(gssapi.h, [], [AC_MSG_ERROR([gssapi.h header file is required for GSSAPI])])]) |
| | |
| | | @ECHO OFF |
| | | |
| | | pushd %~dp0 |
| | | |
| | | REM Command file for Sphinx documentation |
| | | |
| | | if "%SPHINXBUILD%" == "" ( |
| | | set SPHINXBUILD=sphinx-build |
| | | ) |
| | | set SOURCEDIR=. |
| | | set BUILDDIR=_build |
| | | |
| | | %SPHINXBUILD% >NUL 2>NUL |
| | | if errorlevel 9009 ( |
| | | echo. |
| | | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx |
| | | echo.installed, then set the SPHINXBUILD environment variable to point |
| | | echo.to the full path of the 'sphinx-build' executable. Alternatively you |
| | | echo.may add the Sphinx directory to PATH. |
| | | echo. |
| | | echo.If you don't have Sphinx installed, grab it from |
| | | echo.https://www.sphinx-doc.org/ |
| | | exit /b 1 |
| | | ) |
| | | |
| | | if "%1" == "" goto help |
| | | |
| | | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% |
| | | goto end |
| | | |
| | | :help |
| | | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% |
| | | |
| | | :end |
| | | popd |
| | | @ECHO OFF
|
| | |
|
| | | pushd %~dp0
|
| | |
|
| | | REM Command file for Sphinx documentation
|
| | |
|
| | | if "%SPHINXBUILD%" == "" (
|
| | | set SPHINXBUILD=sphinx-build
|
| | | )
|
| | | set SOURCEDIR=.
|
| | | set BUILDDIR=_build
|
| | |
|
| | | %SPHINXBUILD% >NUL 2>NUL
|
| | | if errorlevel 9009 (
|
| | | echo.
|
| | | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
| | | echo.installed, then set the SPHINXBUILD environment variable to point
|
| | | echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
| | | echo.may add the Sphinx directory to PATH.
|
| | | echo.
|
| | | echo.If you don't have Sphinx installed, grab it from
|
| | | echo.https://www.sphinx-doc.org/
|
| | | exit /b 1
|
| | | )
|
| | |
|
| | | if "%1" == "" goto help
|
| | |
|
| | | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
| | | goto end
|
| | |
|
| | | :help
|
| | | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
| | |
|
| | | :end
|
| | | popd
|
| | |
| | | create table tab17(c17 integer); |
| | | create table tab18(c18 integer); |
| | | create table tab19(c19 integer); |
| | | |
| | |
|
| | | create index idx0 on tab0 (c0); |
| | | create index idx1 on tab1 (c1); |
| | | create index idx2 on tab2 (c2); |
| | |
| | | create table tab17(c17 integer); |
| | | create table tab18(c18 integer); |
| | | create table tab19(c19 integer); |
| | | |
| | |
|
| | | create index idx0 on tab0 (c0); |
| | | create index idx1 on tab1 (c1); |
| | | create index idx2 on tab2 (c2); |
| | |
| | | pg_query_state is released under the PostgreSQL License, a liberal Open Source license, similar to the BSD or MIT licenses. |
| | | |
| | | Copyright (c) 2016-2025, Postgres Professional |
| | | Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group |
| | | Portions Copyright (c) 1994, The Regents of the University of California |
| | | |
| | | Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies. |
| | | |
| | | IN NO EVENT SHALL POSTGRES PROFESSIONAL BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF POSTGRES PROFESSIONAL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| | | |
| | | POSTGRES PROFESSIONAL SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND POSTGRES PROFESSIONAL HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| | | pg_query_state is released under the PostgreSQL License, a liberal Open Source license, similar to the BSD or MIT licenses.
|
| | |
|
| | | Copyright (c) 2016-2025, Postgres Professional
|
| | | Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
|
| | | Portions Copyright (c) 1994, The Regents of the University of California
|
| | |
|
| | | Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies.
|
| | |
|
| | | IN NO EVENT SHALL POSTGRES PROFESSIONAL BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF POSTGRES PROFESSIONAL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| | |
|
| | | POSTGRES PROFESSIONAL SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND POSTGRES PROFESSIONAL HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
| | |
| | | OBJS = pg_query_state.o signal_handler.o $(WIN32RES) |
| | | EXTENSION = pg_query_state |
| | | EXTVERSION = 1.2 |
| | | DATA = pg_query_state--1.0--1.1.sql \ |
| | | pg_query_state--1.1--1.2.sql |
| | | DATA_built = $(EXTENSION)--$(EXTVERSION).sql |
| | | PGFILEDESC = "pg_query_state - facility to track progress of plan execution" |
| | | |
| | |
| | | |
| | | install_data( |
| | | 'pg_query_state.control', |
| | | 'pg_query_state--1.0--1.1.sql', |
| | | 'pg_query_state--1.1--1.2.sql', |
| | | kwargs: contrib_data_args, |
| | | ) |
| | | |
| | |
| | | pg_wait_sampling is released under the PostgreSQL License, a liberal Open Source license, similar to the BSD or MIT licenses. |
| | | |
| | | Copyright (c) 2015-2025, Postgres Professional |
| | | Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group |
| | | Portions Copyright (c) 1994, The Regents of the University of California |
| | | |
| | | Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies. |
| | | |
| | | IN NO EVENT SHALL POSTGRES PROFESSIONAL BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF POSTGRES PROFESSIONAL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| | | |
| | | POSTGRES PROFESSIONAL SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND POSTGRES PROFESSIONAL HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| | | pg_wait_sampling is released under the PostgreSQL License, a liberal Open Source license, similar to the BSD or MIT licenses.
|
| | |
|
| | | Copyright (c) 2015-2025, Postgres Professional
|
| | | Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
|
| | | Portions Copyright (c) 1994, The Regents of the University of California
|
| | |
|
| | | Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies.
|
| | |
|
| | | IN NO EVENT SHALL POSTGRES PROFESSIONAL BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF POSTGRES PROFESSIONAL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| | |
|
| | | POSTGRES PROFESSIONAL SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND POSTGRES PROFESSIONAL HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
| | |
| | | @online{PostgreSQL2022, |
| | | author = {PostgreSQL}, |
| | | title = {{PostgreSQL 15 - Documentation}}, |
| | | year = 2022, |
| | | url = {https://www.postgresql.org/docs/15/intro-whatis.html}, |
| | | urldate = {2022-12-30} |
| | | } |
| | | |
| | | @online{DotNet2023, |
| | | author = {Microsoft}, |
| | | title = {{What is .Net?}}, |
| | | year = 2023, |
| | | url = {https://dotnet.microsoft.com/en-us/learn/dotnet/what-is-dotnet}, |
| | | urldate = {2023-01-10} |
| | | } |
| | | |
| | | @online{PLJava, |
| | | author = {Tada AB}, |
| | | title = {{PL/Java: stored procedures, triggers, and functions for PostgreSQL}}, |
| | | year = 2023, |
| | | url = {https://tada.github.io/pljava/}, |
| | | urldate = {2023-01-10} |
| | | } |
| | | |
| | | @online{PLLua, |
| | | author = {RhodiumToad}, |
| | | title = {{pllua: Embeds Lua into PostgreSQL as a procedural language module}}, |
| | | year = 2023, |
| | | url = {https://github.com/pllua/pllua}, |
| | | urldate = {2023-01-10} |
| | | } |
| | | |
| | | @online{PLR, |
| | | author = {Joseph E. Conway}, |
| | | title = {{PL/R - R Procedural Language for PostgreSQL}}, |
| | | year = 2023, |
| | | url = {https://github.com/postgres-plr/plr}, |
| | | urldate = {2023-01-10} |
| | | @online{PostgreSQL2022,
|
| | | author = {PostgreSQL},
|
| | | title = {{PostgreSQL 15 - Documentation}},
|
| | | year = 2022,
|
| | | url = {https://www.postgresql.org/docs/15/intro-whatis.html},
|
| | | urldate = {2022-12-30}
|
| | | }
|
| | |
|
| | | @online{DotNet2023,
|
| | | author = {Microsoft},
|
| | | title = {{What is .Net?}},
|
| | | year = 2023,
|
| | | url = {https://dotnet.microsoft.com/en-us/learn/dotnet/what-is-dotnet},
|
| | | urldate = {2023-01-10}
|
| | | }
|
| | |
|
| | | @online{PLJava,
|
| | | author = {Tada AB},
|
| | | title = {{PL/Java: stored procedures, triggers, and functions for PostgreSQL}},
|
| | | year = 2023,
|
| | | url = {https://tada.github.io/pljava/},
|
| | | urldate = {2023-01-10}
|
| | | }
|
| | |
|
| | | @online{PLLua,
|
| | | author = {RhodiumToad},
|
| | | title = {{pllua: Embeds Lua into PostgreSQL as a procedural language module}},
|
| | | year = 2023,
|
| | | url = {https://github.com/pllua/pllua},
|
| | | urldate = {2023-01-10}
|
| | | }
|
| | |
|
| | | @online{PLR,
|
| | | author = {Joseph E. Conway},
|
| | | title = {{PL/R - R Procedural Language for PostgreSQL}},
|
| | | year = 2023,
|
| | | url = {https://github.com/postgres-plr/plr},
|
| | | urldate = {2023-01-10}
|
| | | } |
| | |
| | | <Project Sdk="Microsoft.NET.Sdk"> |
| | | |
| | | <PropertyGroup> |
| | | <Authors>Brick Abode</Authors> |
| | | <Description>PlDotNET.FSharp includes classes and methods for dynamically compiling F# code.</Description> |
| | | <TargetFramework>$(TargetFramework)</TargetFramework> |
| | | <EnableDynamicLoading>true</EnableDynamicLoading> |
| | | <AllowUnsafeBlocks>true</AllowUnsafeBlocks> |
| | | </PropertyGroup> |
| | | |
| | | <ItemGroup> |
| | | <Compile Include="VirtualFileSystem.fs" /> |
| | | <Compile Include="FSharpCompiler.fs" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="FSharp.Compiler.Service" Version="41.0.7" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <ProjectReference Include="..\Common\PlDotNET.Common.csproj" /> |
| | | </ItemGroup> |
| | | |
| | | </Project> |
| | | <Project Sdk="Microsoft.NET.Sdk">
|
| | |
|
| | | <PropertyGroup>
|
| | | <Authors>Brick Abode</Authors>
|
| | | <Description>PlDotNET.FSharp includes classes and methods for dynamically compiling F# code.</Description>
|
| | | <TargetFramework>$(TargetFramework)</TargetFramework>
|
| | | <EnableDynamicLoading>true</EnableDynamicLoading>
|
| | | <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
| | | </PropertyGroup>
|
| | |
|
| | | <ItemGroup>
|
| | | <Compile Include="VirtualFileSystem.fs" />
|
| | | <Compile Include="FSharpCompiler.fs" />
|
| | | </ItemGroup>
|
| | |
|
| | | <ItemGroup>
|
| | | <PackageReference Include="FSharp.Compiler.Service" Version="41.0.7" />
|
| | | </ItemGroup>
|
| | |
|
| | | <ItemGroup>
|
| | | <ProjectReference Include="..\Common\PlDotNET.Common.csproj" />
|
| | | </ItemGroup>
|
| | |
|
| | | </Project>
|
| | |
| | | <Project Sdk="Microsoft.NET.Sdk"> |
| | | |
| | | <PropertyGroup> |
| | | <TargetFramework>$TargetFramework$</TargetFramework> |
| | | <ImplicitUsings>enable</ImplicitUsings> |
| | | <Nullable>enable</Nullable> |
| | | </PropertyGroup> |
| | | |
| | | <ItemGroup> |
| | | <Compile Include="Program.fs" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <Reference Include="PlDotNET.Common"> |
| | | <HintPath>$PlDotNET.Common.dll$</HintPath> |
| | | </Reference> |
| | | <Reference Include="Npgsql"> |
| | | <HintPath>$Npgsql.dll$</HintPath> |
| | | </Reference> |
| | | <Reference Include="NpgsqlTypes"> |
| | | <HintPath>$NpgsqlTypes.dll$</HintPath> |
| | | </Reference> |
| | | </ItemGroup> |
| | | |
| | | <PropertyGroup> |
| | | <CodeAnalysisRuleSet>stylecop.ruleset</CodeAnalysisRuleSet> |
| | | </PropertyGroup> |
| | | |
| | | </Project> |
| | | <Project Sdk="Microsoft.NET.Sdk">
|
| | |
|
| | | <PropertyGroup>
|
| | | <TargetFramework>$TargetFramework$</TargetFramework>
|
| | | <ImplicitUsings>enable</ImplicitUsings>
|
| | | <Nullable>enable</Nullable>
|
| | | </PropertyGroup>
|
| | |
|
| | | <ItemGroup>
|
| | | <Compile Include="Program.fs" />
|
| | | </ItemGroup>
|
| | |
|
| | | <ItemGroup>
|
| | | <Reference Include="PlDotNET.Common">
|
| | | <HintPath>$PlDotNET.Common.dll$</HintPath>
|
| | | </Reference>
|
| | | <Reference Include="Npgsql">
|
| | | <HintPath>$Npgsql.dll$</HintPath>
|
| | | </Reference>
|
| | | <Reference Include="NpgsqlTypes">
|
| | | <HintPath>$NpgsqlTypes.dll$</HintPath>
|
| | | </Reference>
|
| | | </ItemGroup>
|
| | |
|
| | | <PropertyGroup>
|
| | | <CodeAnalysisRuleSet>stylecop.ruleset</CodeAnalysisRuleSet>
|
| | | </PropertyGroup>
|
| | |
|
| | | </Project>
|
| | |
| | | <Project Sdk="Microsoft.NET.Sdk"> |
| | | |
| | | <PropertyGroup> |
| | | <TargetFramework>$(TargetFramework)</TargetFramework> |
| | | <ImplicitUsings>enable</ImplicitUsings> |
| | | <Nullable>enable</Nullable> |
| | | <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> |
| | | </PropertyGroup> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" PrivateAssets="All"> |
| | | <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
| | | <PrivateAssets>all</PrivateAssets> |
| | | </PackageReference> |
| | | </ItemGroup> |
| | | |
| | | <PropertyGroup> |
| | | <CodeAnalysisRuleSet>..\..\..\dotnet_src\stylecop.ruleset</CodeAnalysisRuleSet> |
| | | </PropertyGroup> |
| | | |
| | | <ItemGroup> |
| | | <ProjectReference Include="..\..\..\dotnet_src\npgsql\src\Npgsql\Npgsql.csproj" /> |
| | | </ItemGroup> |
| | | </Project> |
| | | <Project Sdk="Microsoft.NET.Sdk">
|
| | |
|
| | | <PropertyGroup>
|
| | | <TargetFramework>$(TargetFramework)</TargetFramework>
|
| | | <ImplicitUsings>enable</ImplicitUsings>
|
| | | <Nullable>enable</Nullable>
|
| | | <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
| | | </PropertyGroup>
|
| | |
|
| | | <ItemGroup>
|
| | | <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" PrivateAssets="All">
|
| | | <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
| | | <PrivateAssets>all</PrivateAssets>
|
| | | </PackageReference>
|
| | | </ItemGroup>
|
| | |
|
| | | <PropertyGroup>
|
| | | <CodeAnalysisRuleSet>..\..\..\dotnet_src\stylecop.ruleset</CodeAnalysisRuleSet>
|
| | | </PropertyGroup>
|
| | |
|
| | | <ItemGroup>
|
| | | <ProjectReference Include="..\..\..\dotnet_src\npgsql\src\Npgsql\Npgsql.csproj" />
|
| | | </ItemGroup>
|
| | | </Project>
|
| | |
| | | // <copyright file="Program.cs" company="Brick Abode"> |
| | | // |
| | | // PL/.NET (pldotnet) - PostgreSQL support for .NET C# and F# as |
| | | // procedural languages (PL) |
| | | // |
| | | // |
| | | // Copyright (c) 2023 Brick Abode |
| | | // |
| | | // This code is subject to the terms of the PostgreSQL License. |
| | | // The full text of the license can be found in the LICENSE file |
| | | // at the top level of the pldotnet repository. |
| | | // |
| | | // </copyright> |
| | | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Net; |
| | | using System.Net.NetworkInformation; |
| | | using System.Text; |
| | | using NpgsqlTypes; |
| | | |
| | | #pragma warning disable CS8602 |
| | | #pragma warning disable CS8625 |
| | | #pragma warning disable CS8605 |
| | | #pragma warning disable CS8600 |
| | | |
| | | namespace TestDLLFunctions |
| | | { |
| | | public class TestClass |
| | | { |
| | | public static int FlatArray(Array originalArray, ref Array flatArray, int[] auxiliar = null, int contEl = 0, int loc = 1) |
| | | { |
| | | if (contEl >= originalArray.Length) |
| | | { |
| | | return contEl; |
| | | } |
| | | else if (contEl == 0 || auxiliar == null) |
| | | { |
| | | auxiliar = new int[originalArray.Rank]; |
| | | } |
| | | |
| | | int ndim = originalArray.Rank; |
| | | int[] dim = new int[ndim]; |
| | | for (int i = 0; i < ndim; i++) |
| | | { |
| | | dim[i] = originalArray.GetLength(i); |
| | | } |
| | | |
| | | if (loc == 1) |
| | | { |
| | | for (int i = 0; i < dim[ndim - loc]; i++) |
| | | { |
| | | flatArray.SetValue(originalArray.GetValue(auxiliar), contEl++); |
| | | auxiliar[ndim - loc] += 1; |
| | | } |
| | | } |
| | | |
| | | for (int i = 1; i < loc; i++) |
| | | { |
| | | auxiliar[ndim - loc] += 1; |
| | | if (auxiliar[ndim - loc] < dim[ndim - loc]) |
| | | { |
| | | contEl = FlatArray(originalArray, ref flatArray, auxiliar, contEl, i); |
| | | } |
| | | } |
| | | |
| | | auxiliar[ndim - loc] = 0; |
| | | contEl = FlatArray(originalArray, ref flatArray, auxiliar, contEl, ++loc); |
| | | return contEl; |
| | | } |
| | | |
| | | public static BitArray? modifybit(BitArray? a) |
| | | { |
| | | if (a == null) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | a[0] = !a[0]; |
| | | a[^1] = !a[^1]; |
| | | return a; |
| | | } |
| | | |
| | | public static BitArray? modifyvarbit(BitArray? a) |
| | | { |
| | | if (a == null) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | a[0] = !a[0]; |
| | | a[^1] = !a[^1]; |
| | | return a; |
| | | } |
| | | |
| | | public static bool? booleanand(bool? a, bool? b) |
| | | { |
| | | a ??= false; |
| | | b ??= false; |
| | | |
| | | return a & b; |
| | | } |
| | | |
| | | public static byte[]? byteaconversions(byte[]? a, byte[]? b) |
| | | { |
| | | UTF8Encoding utf8_e = new(); |
| | | if (a == null && b == null) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | if (a == null) |
| | | { |
| | | return b; |
| | | } |
| | | |
| | | if (b == null) |
| | | { |
| | | return a; |
| | | } |
| | | |
| | | string s1 = utf8_e.GetString(a, 0, a.Length); |
| | | string s2 = utf8_e.GetString(b, 0, b.Length); |
| | | string result = s1 + " " + s2; |
| | | return utf8_e.GetBytes(result); |
| | | } |
| | | |
| | | public static DateTime? setnewdate(DateTime? orig_timestamp, DateOnly? new_date) |
| | | { |
| | | if (orig_timestamp == null) |
| | | { |
| | | orig_timestamp = new DateTime(2022, 1, 1, 8, 30, 20); |
| | | } |
| | | |
| | | if (new_date == null) |
| | | { |
| | | new_date = new DateOnly(2023, 12, 25); |
| | | } |
| | | |
| | | int new_day = ((DateOnly)new_date).Day; |
| | | int new_month = ((DateOnly)new_date).Month; |
| | | int new_year = ((DateOnly)new_date).Year; |
| | | DateTime new_timestamp = new(new_year, new_month, new_day, ((DateTime)orig_timestamp).Hour, ((DateTime)orig_timestamp).Minute, ((DateTime)orig_timestamp).Second); |
| | | return new_timestamp; |
| | | } |
| | | |
| | | public static double? sumdoublearray(Array doubles) |
| | | { |
| | | Array flatten_doubles = Array.CreateInstance(typeof(object), doubles.Length); |
| | | TestClass.FlatArray(doubles, ref flatten_doubles); |
| | | double double_sum = 0; |
| | | for (int i = 0; i < flatten_doubles.Length; i++) |
| | | { |
| | | if (flatten_doubles.GetValue(i) == null) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | double_sum += (double)flatten_doubles.GetValue(i); |
| | | } |
| | | |
| | | return double_sum; |
| | | } |
| | | |
| | | public static double? sumdouble(double? a, double? b) |
| | | { |
| | | a ??= 0; |
| | | b ??= 0; |
| | | return a + b; |
| | | } |
| | | |
| | | public static short? sum2smallint(short? a, short? b) |
| | | { |
| | | a ??= 0; |
| | | b ??= 0; |
| | | return (short)(a + b); // C# requires short cast |
| | | } |
| | | |
| | | public static int? sum2integer(int? a, int? b) |
| | | { |
| | | a ??= 0; |
| | | b ??= 0; |
| | | return a + b; |
| | | } |
| | | |
| | | public static long? sum2bigint(long? a, long? b) |
| | | { |
| | | a ??= 0; |
| | | b ??= 0; |
| | | return a + b; |
| | | } |
| | | |
| | | public static Array? updatearraypolygonindex(Array values_array, NpgsqlPolygon desired, Array index) |
| | | { |
| | | int[] arrayInteger = index.Cast<int>().ToArray(); |
| | | values_array.SetValue(desired, arrayInteger); |
| | | return values_array; |
| | | } |
| | | |
| | | public static Array? updatejsonarrayindex(Array values_array, string desired, Array index) |
| | | { |
| | | int[] arrayInteger = index.Cast<int>().ToArray(); |
| | | values_array.SetValue(desired, arrayInteger); |
| | | return values_array; |
| | | } |
| | | |
| | | public static Array? increasemoney(Array values_array) |
| | | { |
| | | Array flatten_values = Array.CreateInstance(typeof(object), values_array.Length); |
| | | TestClass.FlatArray(values_array, ref flatten_values); |
| | | for (int i = 0; i < flatten_values.Length; i++) |
| | | { |
| | | if (flatten_values.GetValue(i) == null) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | decimal orig_value = (decimal)flatten_values.GetValue(i); |
| | | decimal new_value = orig_value + 1; |
| | | flatten_values.SetValue((decimal)new_value, i); |
| | | } |
| | | |
| | | return flatten_values; |
| | | } |
| | | |
| | | public static Array? increasemacaddress8(Array values_array) |
| | | { |
| | | Array flatten_values = Array.CreateInstance(typeof(object), values_array.Length); |
| | | TestClass.FlatArray(values_array, ref flatten_values); |
| | | for (int i = 0; i < flatten_values.Length; i++) |
| | | { |
| | | if (flatten_values.GetValue(i) == null) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | PhysicalAddress orig_value = (PhysicalAddress)flatten_values.GetValue(i); |
| | | byte[] bytes = orig_value.GetAddressBytes(); |
| | | bytes[0] += 1; |
| | | PhysicalAddress new_value = new(bytes); |
| | | flatten_values.SetValue((PhysicalAddress)new_value, i); |
| | | } |
| | | |
| | | return flatten_values; |
| | | } |
| | | |
| | | public static Array? increasecidraddress(Array values_array) |
| | | { |
| | | Array flatten_values = Array.CreateInstance(typeof(object), values_array.Length); |
| | | TestClass.FlatArray(values_array, ref flatten_values); |
| | | for (int i = 0; i < flatten_values.Length; i++) |
| | | { |
| | | if (flatten_values.GetValue(i) == null) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | (IPAddress address, int netmask) = ((IPAddress Address, int Netmask))flatten_values.GetValue(i); |
| | | byte[] bytes = address.GetAddressBytes(); |
| | | bytes[0] += 1; |
| | | (IPAddress Address, int Netmask) new_value = (new IPAddress(bytes), netmask); |
| | | flatten_values.SetValue(((IPAddress Address, int Netmask))new_value, i); |
| | | } |
| | | |
| | | return flatten_values; |
| | | } |
| | | |
| | | public static Array? increaseint8ranges(Array values_array) |
| | | { |
| | | Array flatten_values = Array.CreateInstance(typeof(object), values_array.Length); |
| | | TestClass.FlatArray(values_array, ref flatten_values); |
| | | for (int i = 0; i < flatten_values.Length; i++) |
| | | { |
| | | if (flatten_values.GetValue(i) == null) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | NpgsqlRange<long> orig_value = (NpgsqlRange<long>)flatten_values.GetValue(i); |
| | | NpgsqlRange<long> new_value = new(orig_value.LowerBound + 1, orig_value.LowerBoundIsInclusive, orig_value.LowerBoundInfinite, orig_value.UpperBound + 1, orig_value.UpperBoundIsInclusive, orig_value.UpperBoundInfinite); |
| | | flatten_values.SetValue((NpgsqlRange<long>)new_value, i); |
| | | } |
| | | |
| | | return flatten_values; |
| | | } |
| | | |
| | | public static Array? increasedateonlyranges(Array values_array) |
| | | { |
| | | Array flatten_values = Array.CreateInstance(typeof(object), values_array.Length); |
| | | TestClass.FlatArray(values_array, ref flatten_values); |
| | | for (int i = 0; i < flatten_values.Length; i++) |
| | | { |
| | | if (flatten_values.GetValue(i) == null) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | NpgsqlRange<DateOnly> orig_value = (NpgsqlRange<DateOnly>)flatten_values.GetValue(i); |
| | | |
| | | NpgsqlRange<DateOnly> new_value = new(orig_value.LowerBound.AddDays(1), orig_value.LowerBoundIsInclusive, orig_value.LowerBoundInfinite, orig_value.UpperBound.AddDays(1), orig_value.UpperBoundIsInclusive, orig_value.UpperBoundInfinite); |
| | | flatten_values.SetValue((NpgsqlRange<DateOnly>)new_value, i); |
| | | } |
| | | |
| | | return flatten_values; |
| | | } |
| | | |
| | | public static string? concatenatevarchars(string? a, string? b, string? c) |
| | | { |
| | | a ??= string.Empty; |
| | | b ??= string.Empty; |
| | | c ??= string.Empty; |
| | | return (a + " " + b + " " + c).ToUpper(); |
| | | } |
| | | |
| | | public static Guid? combineuuids(Guid? a, Guid? b) |
| | | { |
| | | if (a == null) |
| | | { |
| | | a = new Guid("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11"); |
| | | } |
| | | |
| | | if (b == null) |
| | | { |
| | | b = new Guid("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11"); |
| | | } |
| | | |
| | | string aStr = a.ToString(); |
| | | string bStr = b.ToString(); |
| | | var aList = aStr.Split('-'); |
| | | var bList = bStr.Split('-'); |
| | | string newUuuidStr = aList[0] + aList[1] + aList[2] + bList[3] + bList[4]; |
| | | return new Guid(newUuuidStr); |
| | | } |
| | | } |
| | | } |
| | | |
| | | namespace TestDLLFunctions.OtherTests |
| | | { |
| | | public class TestClass |
| | | { |
| | | public static NpgsqlPoint? middlePointStrict(NpgsqlPoint pointa, NpgsqlPoint pointb) |
| | | { |
| | | double x = (pointa.X + pointb.X) * 0.5; |
| | | double y = (pointa.Y + pointb.Y) * 0.5; |
| | | var new_point = new NpgsqlPoint(x, y); |
| | | |
| | | return new_point; |
| | | } |
| | | |
| | | public static NpgsqlPoint? middlePointDefault(NpgsqlPoint? pointa, NpgsqlPoint? pointb) |
| | | { |
| | | if (pointa == null) |
| | | { |
| | | pointa = new NpgsqlPoint(0, 0); |
| | | } |
| | | |
| | | if (pointb == null) |
| | | { |
| | | pointb = new NpgsqlPoint(0, 0); |
| | | } |
| | | |
| | | double x = (((NpgsqlPoint)pointa).X + ((NpgsqlPoint)pointb).X) * 0.5; |
| | | double y = (((NpgsqlPoint)pointa).Y + ((NpgsqlPoint)pointb).Y) * 0.5; |
| | | var new_point = new NpgsqlPoint(x, y); |
| | | |
| | | return new_point; |
| | | } |
| | | } |
| | | |
| | | public class InoutTests |
| | | { |
| | | public static void inoutBasic0(ref int? argument_0) |
| | | { |
| | | if (argument_0 != 0) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_0 = {argument_0}"); |
| | | } |
| | | |
| | | argument_0 = 1; |
| | | } |
| | | |
| | | public static void inoutBasic1(out int? argument_0) |
| | | { |
| | | argument_0 = 1; |
| | | } |
| | | |
| | | public static void inputNull1(ref int? argument_0) |
| | | { |
| | | if (argument_0 is null) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_0 = {argument_0}"); |
| | | } |
| | | |
| | | argument_0 = null; |
| | | } |
| | | |
| | | public static void inputNull2(ref int? argument_0) |
| | | { |
| | | if (argument_0 != null) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_0 = {argument_0}"); |
| | | } |
| | | |
| | | argument_0 = 3; |
| | | } |
| | | |
| | | public static void inputNull3(out int? argument_0) |
| | | { |
| | | argument_0 = null; |
| | | } |
| | | |
| | | public static void inputNull4(ref int? argument_0, int? argument_1) |
| | | { |
| | | if (argument_0 is null) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_0 = {argument_0}"); |
| | | } |
| | | |
| | | if (argument_1 != 3) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_0 = {argument_0}"); |
| | | } |
| | | |
| | | argument_0 = null; |
| | | } |
| | | |
| | | public static void inputNull5(ref int? argument_0, int? argument_1) |
| | | { |
| | | if (argument_0 != null) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_0 = {argument_0}"); |
| | | } |
| | | |
| | | if (argument_1 != 3) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_0 = {argument_0}"); |
| | | } |
| | | |
| | | argument_0 = 3; |
| | | } |
| | | |
| | | public static void inputNull6(int? argument_0, out int? argument_1) |
| | | { |
| | | if (argument_0 == 1) |
| | | { |
| | | argument_1 = null; |
| | | } |
| | | else if (argument_0 == 2) |
| | | { |
| | | argument_1 = 2; |
| | | } |
| | | else |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_0 = {argument_0}"); |
| | | } |
| | | } |
| | | |
| | | public static void inoutMultiarg1(int? argument_0, ref int? argument_1, int? argument_2, out int? argument_3, out int? argument_4, ref int? argument_5, int? argument_6, out int? argument_7) |
| | | { |
| | | if (argument_0 != 0) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_0 = {argument_0}"); |
| | | } |
| | | |
| | | if (argument_1 != 1) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_1 = {argument_1}"); |
| | | } |
| | | |
| | | argument_1 = 2; |
| | | if (argument_2 != 2) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_2 = {argument_2}"); |
| | | } |
| | | |
| | | argument_3 = 4; |
| | | argument_4 = 5; |
| | | if (argument_5 != null) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_5 = {argument_5}"); |
| | | } |
| | | |
| | | argument_5 = 6; |
| | | if (argument_6 != 6) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_6 = {argument_6}"); |
| | | } |
| | | |
| | | argument_7 = null; |
| | | } |
| | | |
| | | public static void inoutMultiarg2(ref int? argument_0, out int? argument_1, ref int? argument_2, ref int? argument_3, int? argument_4, out int? argument_5, int? argument_6, out int? argument_7) |
| | | { |
| | | if (argument_0 != null) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_0 = {argument_0}"); |
| | | } |
| | | |
| | | argument_0 = 1; |
| | | argument_1 = 2; |
| | | if (argument_2 != 2) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_2 = {argument_2}"); |
| | | } |
| | | |
| | | argument_2 = 3; |
| | | if (argument_3 != 3) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_3 = {argument_3}"); |
| | | } |
| | | |
| | | argument_3 = null; |
| | | if (argument_4 != 4) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_4 = {argument_4}"); |
| | | } |
| | | |
| | | argument_5 = 6; |
| | | if (argument_6 != 6) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_6 = {argument_6}"); |
| | | } |
| | | |
| | | argument_7 = 8; |
| | | } |
| | | |
| | | public static void inoutMultiarg3(out int? argument_0, int? argument_1, int? argument_2, out int? argument_3, ref int? argument_4, out int? argument_5, int? argument_6, ref int? argument_7) |
| | | { |
| | | argument_0 = null; |
| | | if (argument_1 != 1) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_1 = {argument_1}"); |
| | | } |
| | | |
| | | if (argument_2 != 2) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_2 = {argument_2}"); |
| | | } |
| | | |
| | | argument_3 = 4; |
| | | if (argument_4 != 4) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_4 = {argument_4}"); |
| | | } |
| | | |
| | | argument_4 = 5; |
| | | argument_5 = 6; |
| | | if (argument_6 != 6) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_6 = {argument_6}"); |
| | | } |
| | | |
| | | if (argument_7 != 7) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_7 = {argument_7}"); |
| | | } |
| | | |
| | | argument_7 = 8; |
| | | } |
| | | |
| | | public static void inoutMultiarg4(int argument_0, ref int? argument_1, int argument_2, out int? argument_3, out int? argument_4, ref int? argument_5, ref int? argument_6, int argument_7) |
| | | { |
| | | if (argument_0 != 0) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_0 = {argument_0}"); |
| | | } |
| | | |
| | | if (argument_1 != 1) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_1 = {argument_1}"); |
| | | } |
| | | |
| | | argument_1 = 2; |
| | | if (argument_2 != 2) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_2 = {argument_2}"); |
| | | } |
| | | |
| | | argument_3 = 4; |
| | | argument_4 = 5; |
| | | if (argument_5 != 5) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_5 = {argument_5}"); |
| | | } |
| | | |
| | | argument_5 = null; |
| | | if (argument_6 != 6) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_6 = {argument_6}"); |
| | | } |
| | | |
| | | argument_6 = 7; |
| | | if (argument_7 != 7) |
| | | { |
| | | throw new SystemException($"Failed assertion: argument_7 = {argument_7}"); |
| | | } |
| | | } |
| | | |
| | | public static void inoutArray10(ref Array? values_array, out int? nulls) |
| | | { |
| | | Array flatten_values = Array.CreateInstance(typeof(object), values_array.Length); |
| | | TestDLLFunctions.TestClass.FlatArray(values_array, ref flatten_values); |
| | | nulls = 0; |
| | | for (int i = 0; i < flatten_values.Length; i++) |
| | | { |
| | | if (flatten_values.GetValue(i) == null) |
| | | { |
| | | nulls++; |
| | | continue; |
| | | } |
| | | |
| | | PhysicalAddress orig_value = (PhysicalAddress)flatten_values.GetValue(i); |
| | | byte[] bytes = orig_value.GetAddressBytes(); |
| | | bytes[0] += 1; |
| | | PhysicalAddress new_value = new(bytes); |
| | | flatten_values.SetValue((PhysicalAddress)new_value, i); |
| | | } |
| | | |
| | | values_array = flatten_values; |
| | | } |
| | | |
| | | public static void inoutArray11(out Array? values_array, PhysicalAddress address, int count) |
| | | { |
| | | Array output = Array.CreateInstance(typeof(object), count); |
| | | for (int i = 0; i < count; i++) |
| | | { |
| | | output.SetValue((PhysicalAddress)address, i); |
| | | } |
| | | |
| | | values_array = output; |
| | | } |
| | | |
| | | public static void inoutSimple10(out int? checksum, (IPAddress Address, int Netmask) address) |
| | | { |
| | | int i; |
| | | |
| | | // get bytes |
| | | byte[] bytes = address.Address.GetAddressBytes(); |
| | | |
| | | // compute checksum |
| | | checksum = 0; |
| | | for (i = 0; i < bytes.Length; i++) |
| | | { |
| | | checksum += bytes[i]; |
| | | } |
| | | } |
| | | |
| | | public static void inoutSimple20(ref (IPAddress Address, int Netmask)? address, int pos, int delta) |
| | | { |
| | | // compute new address |
| | | (IPAddress address1, int netmask) = address ?? (IPAddress.Parse("1.1.1.1"), 8); |
| | | byte[] bytes = address1.GetAddressBytes(); |
| | | bytes[pos] += (byte)delta; |
| | | address = (new IPAddress(bytes), netmask); |
| | | } |
| | | |
| | | public static void inoutSimple30(out int? checksum, ref (IPAddress Address, int Netmask)? address, int pos, int delta) |
| | | { |
| | | int i; |
| | | |
| | | // compute new address |
| | | (IPAddress address1, int netmask) = address ?? (IPAddress.Parse("1.1.1.1"), 8); |
| | | byte[] bytes = address1.GetAddressBytes(); |
| | | bytes[pos] += (byte)delta; |
| | | address = (new IPAddress(bytes), netmask); |
| | | |
| | | // compute checksum |
| | | checksum = 0; |
| | | for (i = 0; i < bytes.Length; i++) |
| | | { |
| | | checksum += bytes[i]; |
| | | } |
| | | } |
| | | |
| | | public static void inoutObject10(string? a, ref string? b) |
| | | { |
| | | a ??= string.Empty; |
| | | b ??= string.Empty; |
| | | b = a + " " + b; |
| | | } |
| | | |
| | | public static void inoutObject20(string? a, string? b, out string? c) |
| | | { |
| | | a ??= string.Empty; |
| | | b ??= string.Empty; |
| | | c = a + " " + b; |
| | | } |
| | | } |
| | | } |
| | | // <copyright file="Program.cs" company="Brick Abode">
|
| | | //
|
| | | // PL/.NET (pldotnet) - PostgreSQL support for .NET C# and F# as
|
| | | // procedural languages (PL)
|
| | | //
|
| | | //
|
| | | // Copyright (c) 2023 Brick Abode
|
| | | //
|
| | | // This code is subject to the terms of the PostgreSQL License.
|
| | | // The full text of the license can be found in the LICENSE file
|
| | | // at the top level of the pldotnet repository.
|
| | | //
|
| | | // </copyright>
|
| | |
|
| | | using System;
|
| | | using System.Collections;
|
| | | using System.Net;
|
| | | using System.Net.NetworkInformation;
|
| | | using System.Text;
|
| | | using NpgsqlTypes;
|
| | |
|
| | | #pragma warning disable CS8602
|
| | | #pragma warning disable CS8625
|
| | | #pragma warning disable CS8605
|
| | | #pragma warning disable CS8600
|
| | |
|
| | | namespace TestDLLFunctions
|
| | | {
|
| | | public class TestClass
|
| | | {
|
| | | public static int FlatArray(Array originalArray, ref Array flatArray, int[] auxiliar = null, int contEl = 0, int loc = 1)
|
| | | {
|
| | | if (contEl >= originalArray.Length)
|
| | | {
|
| | | return contEl;
|
| | | }
|
| | | else if (contEl == 0 || auxiliar == null)
|
| | | {
|
| | | auxiliar = new int[originalArray.Rank];
|
| | | }
|
| | |
|
| | | int ndim = originalArray.Rank;
|
| | | int[] dim = new int[ndim];
|
| | | for (int i = 0; i < ndim; i++)
|
| | | {
|
| | | dim[i] = originalArray.GetLength(i);
|
| | | }
|
| | |
|
| | | if (loc == 1)
|
| | | {
|
| | | for (int i = 0; i < dim[ndim - loc]; i++)
|
| | | {
|
| | | flatArray.SetValue(originalArray.GetValue(auxiliar), contEl++);
|
| | | auxiliar[ndim - loc] += 1;
|
| | | }
|
| | | }
|
| | |
|
| | | for (int i = 1; i < loc; i++)
|
| | | {
|
| | | auxiliar[ndim - loc] += 1;
|
| | | if (auxiliar[ndim - loc] < dim[ndim - loc])
|
| | | {
|
| | | contEl = FlatArray(originalArray, ref flatArray, auxiliar, contEl, i);
|
| | | }
|
| | | }
|
| | |
|
| | | auxiliar[ndim - loc] = 0;
|
| | | contEl = FlatArray(originalArray, ref flatArray, auxiliar, contEl, ++loc);
|
| | | return contEl;
|
| | | }
|
| | |
|
| | | public static BitArray? modifybit(BitArray? a)
|
| | | {
|
| | | if (a == null)
|
| | | {
|
| | | return null;
|
| | | }
|
| | |
|
| | | a[0] = !a[0];
|
| | | a[^1] = !a[^1];
|
| | | return a;
|
| | | }
|
| | |
|
| | | public static BitArray? modifyvarbit(BitArray? a)
|
| | | {
|
| | | if (a == null)
|
| | | {
|
| | | return null;
|
| | | }
|
| | |
|
| | | a[0] = !a[0];
|
| | | a[^1] = !a[^1];
|
| | | return a;
|
| | | }
|
| | |
|
| | | public static bool? booleanand(bool? a, bool? b)
|
| | | {
|
| | | a ??= false;
|
| | | b ??= false;
|
| | |
|
| | | return a & b;
|
| | | }
|
| | |
|
| | | public static byte[]? byteaconversions(byte[]? a, byte[]? b)
|
| | | {
|
| | | UTF8Encoding utf8_e = new();
|
| | | if (a == null && b == null)
|
| | | {
|
| | | return null;
|
| | | }
|
| | |
|
| | | if (a == null)
|
| | | {
|
| | | return b;
|
| | | }
|
| | |
|
| | | if (b == null)
|
| | | {
|
| | | return a;
|
| | | }
|
| | |
|
| | | string s1 = utf8_e.GetString(a, 0, a.Length);
|
| | | string s2 = utf8_e.GetString(b, 0, b.Length);
|
| | | string result = s1 + " " + s2;
|
| | | return utf8_e.GetBytes(result);
|
| | | }
|
| | |
|
| | | public static DateTime? setnewdate(DateTime? orig_timestamp, DateOnly? new_date)
|
| | | {
|
| | | if (orig_timestamp == null)
|
| | | {
|
| | | orig_timestamp = new DateTime(2022, 1, 1, 8, 30, 20);
|
| | | }
|
| | |
|
| | | if (new_date == null)
|
| | | {
|
| | | new_date = new DateOnly(2023, 12, 25);
|
| | | }
|
| | |
|
| | | int new_day = ((DateOnly)new_date).Day;
|
| | | int new_month = ((DateOnly)new_date).Month;
|
| | | int new_year = ((DateOnly)new_date).Year;
|
| | | DateTime new_timestamp = new(new_year, new_month, new_day, ((DateTime)orig_timestamp).Hour, ((DateTime)orig_timestamp).Minute, ((DateTime)orig_timestamp).Second);
|
| | | return new_timestamp;
|
| | | }
|
| | |
|
| | | public static double? sumdoublearray(Array doubles)
|
| | | {
|
| | | Array flatten_doubles = Array.CreateInstance(typeof(object), doubles.Length);
|
| | | TestClass.FlatArray(doubles, ref flatten_doubles);
|
| | | double double_sum = 0;
|
| | | for (int i = 0; i < flatten_doubles.Length; i++)
|
| | | {
|
| | | if (flatten_doubles.GetValue(i) == null)
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
|
| | | double_sum += (double)flatten_doubles.GetValue(i);
|
| | | }
|
| | |
|
| | | return double_sum;
|
| | | }
|
| | |
|
| | | public static double? sumdouble(double? a, double? b)
|
| | | {
|
| | | a ??= 0;
|
| | | b ??= 0;
|
| | | return a + b;
|
| | | }
|
| | |
|
| | | public static short? sum2smallint(short? a, short? b)
|
| | | {
|
| | | a ??= 0;
|
| | | b ??= 0;
|
| | | return (short)(a + b); // C# requires short cast
|
| | | }
|
| | |
|
| | | public static int? sum2integer(int? a, int? b)
|
| | | {
|
| | | a ??= 0;
|
| | | b ??= 0;
|
| | | return a + b;
|
| | | }
|
| | |
|
| | | public static long? sum2bigint(long? a, long? b)
|
| | | {
|
| | | a ??= 0;
|
| | | b ??= 0;
|
| | | return a + b;
|
| | | }
|
| | |
|
| | | public static Array? updatearraypolygonindex(Array values_array, NpgsqlPolygon desired, Array index)
|
| | | {
|
| | | int[] arrayInteger = index.Cast<int>().ToArray();
|
| | | values_array.SetValue(desired, arrayInteger);
|
| | | return values_array;
|
| | | }
|
| | |
|
| | | public static Array? updatejsonarrayindex(Array values_array, string desired, Array index)
|
| | | {
|
| | | int[] arrayInteger = index.Cast<int>().ToArray();
|
| | | values_array.SetValue(desired, arrayInteger);
|
| | | return values_array;
|
| | | }
|
| | |
|
| | | public static Array? increasemoney(Array values_array)
|
| | | {
|
| | | Array flatten_values = Array.CreateInstance(typeof(object), values_array.Length);
|
| | | TestClass.FlatArray(values_array, ref flatten_values);
|
| | | for (int i = 0; i < flatten_values.Length; i++)
|
| | | {
|
| | | if (flatten_values.GetValue(i) == null)
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
|
| | | decimal orig_value = (decimal)flatten_values.GetValue(i);
|
| | | decimal new_value = orig_value + 1;
|
| | | flatten_values.SetValue((decimal)new_value, i);
|
| | | }
|
| | |
|
| | | return flatten_values;
|
| | | }
|
| | |
|
| | | public static Array? increasemacaddress8(Array values_array)
|
| | | {
|
| | | Array flatten_values = Array.CreateInstance(typeof(object), values_array.Length);
|
| | | TestClass.FlatArray(values_array, ref flatten_values);
|
| | | for (int i = 0; i < flatten_values.Length; i++)
|
| | | {
|
| | | if (flatten_values.GetValue(i) == null)
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
|
| | | PhysicalAddress orig_value = (PhysicalAddress)flatten_values.GetValue(i);
|
| | | byte[] bytes = orig_value.GetAddressBytes();
|
| | | bytes[0] += 1;
|
| | | PhysicalAddress new_value = new(bytes);
|
| | | flatten_values.SetValue((PhysicalAddress)new_value, i);
|
| | | }
|
| | |
|
| | | return flatten_values;
|
| | | }
|
| | |
|
| | | public static Array? increasecidraddress(Array values_array)
|
| | | {
|
| | | Array flatten_values = Array.CreateInstance(typeof(object), values_array.Length);
|
| | | TestClass.FlatArray(values_array, ref flatten_values);
|
| | | for (int i = 0; i < flatten_values.Length; i++)
|
| | | {
|
| | | if (flatten_values.GetValue(i) == null)
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
|
| | | (IPAddress address, int netmask) = ((IPAddress Address, int Netmask))flatten_values.GetValue(i);
|
| | | byte[] bytes = address.GetAddressBytes();
|
| | | bytes[0] += 1;
|
| | | (IPAddress Address, int Netmask) new_value = (new IPAddress(bytes), netmask);
|
| | | flatten_values.SetValue(((IPAddress Address, int Netmask))new_value, i);
|
| | | }
|
| | |
|
| | | return flatten_values;
|
| | | }
|
| | |
|
| | | public static Array? increaseint8ranges(Array values_array)
|
| | | {
|
| | | Array flatten_values = Array.CreateInstance(typeof(object), values_array.Length);
|
| | | TestClass.FlatArray(values_array, ref flatten_values);
|
| | | for (int i = 0; i < flatten_values.Length; i++)
|
| | | {
|
| | | if (flatten_values.GetValue(i) == null)
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
|
| | | NpgsqlRange<long> orig_value = (NpgsqlRange<long>)flatten_values.GetValue(i);
|
| | | NpgsqlRange<long> new_value = new(orig_value.LowerBound + 1, orig_value.LowerBoundIsInclusive, orig_value.LowerBoundInfinite, orig_value.UpperBound + 1, orig_value.UpperBoundIsInclusive, orig_value.UpperBoundInfinite);
|
| | | flatten_values.SetValue((NpgsqlRange<long>)new_value, i);
|
| | | }
|
| | |
|
| | | return flatten_values;
|
| | | }
|
| | |
|
| | | public static Array? increasedateonlyranges(Array values_array)
|
| | | {
|
| | | Array flatten_values = Array.CreateInstance(typeof(object), values_array.Length);
|
| | | TestClass.FlatArray(values_array, ref flatten_values);
|
| | | for (int i = 0; i < flatten_values.Length; i++)
|
| | | {
|
| | | if (flatten_values.GetValue(i) == null)
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
|
| | | NpgsqlRange<DateOnly> orig_value = (NpgsqlRange<DateOnly>)flatten_values.GetValue(i);
|
| | |
|
| | | NpgsqlRange<DateOnly> new_value = new(orig_value.LowerBound.AddDays(1), orig_value.LowerBoundIsInclusive, orig_value.LowerBoundInfinite, orig_value.UpperBound.AddDays(1), orig_value.UpperBoundIsInclusive, orig_value.UpperBoundInfinite);
|
| | | flatten_values.SetValue((NpgsqlRange<DateOnly>)new_value, i);
|
| | | }
|
| | |
|
| | | return flatten_values;
|
| | | }
|
| | |
|
| | | public static string? concatenatevarchars(string? a, string? b, string? c)
|
| | | {
|
| | | a ??= string.Empty;
|
| | | b ??= string.Empty;
|
| | | c ??= string.Empty;
|
| | | return (a + " " + b + " " + c).ToUpper();
|
| | | }
|
| | |
|
| | | public static Guid? combineuuids(Guid? a, Guid? b)
|
| | | {
|
| | | if (a == null)
|
| | | {
|
| | | a = new Guid("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11");
|
| | | }
|
| | |
|
| | | if (b == null)
|
| | | {
|
| | | b = new Guid("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11");
|
| | | }
|
| | |
|
| | | string aStr = a.ToString();
|
| | | string bStr = b.ToString();
|
| | | var aList = aStr.Split('-');
|
| | | var bList = bStr.Split('-');
|
| | | string newUuuidStr = aList[0] + aList[1] + aList[2] + bList[3] + bList[4];
|
| | | return new Guid(newUuuidStr);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | namespace TestDLLFunctions.OtherTests
|
| | | {
|
| | | public class TestClass
|
| | | {
|
| | | public static NpgsqlPoint? middlePointStrict(NpgsqlPoint pointa, NpgsqlPoint pointb)
|
| | | {
|
| | | double x = (pointa.X + pointb.X) * 0.5;
|
| | | double y = (pointa.Y + pointb.Y) * 0.5;
|
| | | var new_point = new NpgsqlPoint(x, y);
|
| | |
|
| | | return new_point;
|
| | | }
|
| | |
|
| | | public static NpgsqlPoint? middlePointDefault(NpgsqlPoint? pointa, NpgsqlPoint? pointb)
|
| | | {
|
| | | if (pointa == null)
|
| | | {
|
| | | pointa = new NpgsqlPoint(0, 0);
|
| | | }
|
| | |
|
| | | if (pointb == null)
|
| | | {
|
| | | pointb = new NpgsqlPoint(0, 0);
|
| | | }
|
| | |
|
| | | double x = (((NpgsqlPoint)pointa).X + ((NpgsqlPoint)pointb).X) * 0.5;
|
| | | double y = (((NpgsqlPoint)pointa).Y + ((NpgsqlPoint)pointb).Y) * 0.5;
|
| | | var new_point = new NpgsqlPoint(x, y);
|
| | |
|
| | | return new_point;
|
| | | }
|
| | | }
|
| | |
|
| | | public class InoutTests
|
| | | {
|
| | | public static void inoutBasic0(ref int? argument_0)
|
| | | {
|
| | | if (argument_0 != 0)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_0 = {argument_0}");
|
| | | }
|
| | |
|
| | | argument_0 = 1;
|
| | | }
|
| | |
|
| | | public static void inoutBasic1(out int? argument_0)
|
| | | {
|
| | | argument_0 = 1;
|
| | | }
|
| | |
|
| | | public static void inputNull1(ref int? argument_0)
|
| | | {
|
| | | if (argument_0 is null)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_0 = {argument_0}");
|
| | | }
|
| | |
|
| | | argument_0 = null;
|
| | | }
|
| | |
|
| | | public static void inputNull2(ref int? argument_0)
|
| | | {
|
| | | if (argument_0 != null)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_0 = {argument_0}");
|
| | | }
|
| | |
|
| | | argument_0 = 3;
|
| | | }
|
| | |
|
| | | public static void inputNull3(out int? argument_0)
|
| | | {
|
| | | argument_0 = null;
|
| | | }
|
| | |
|
| | | public static void inputNull4(ref int? argument_0, int? argument_1)
|
| | | {
|
| | | if (argument_0 is null)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_0 = {argument_0}");
|
| | | }
|
| | |
|
| | | if (argument_1 != 3)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_0 = {argument_0}");
|
| | | }
|
| | |
|
| | | argument_0 = null;
|
| | | }
|
| | |
|
| | | public static void inputNull5(ref int? argument_0, int? argument_1)
|
| | | {
|
| | | if (argument_0 != null)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_0 = {argument_0}");
|
| | | }
|
| | |
|
| | | if (argument_1 != 3)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_0 = {argument_0}");
|
| | | }
|
| | |
|
| | | argument_0 = 3;
|
| | | }
|
| | |
|
| | | public static void inputNull6(int? argument_0, out int? argument_1)
|
| | | {
|
| | | if (argument_0 == 1)
|
| | | {
|
| | | argument_1 = null;
|
| | | }
|
| | | else if (argument_0 == 2)
|
| | | {
|
| | | argument_1 = 2;
|
| | | }
|
| | | else
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_0 = {argument_0}");
|
| | | }
|
| | | }
|
| | |
|
| | | public static void inoutMultiarg1(int? argument_0, ref int? argument_1, int? argument_2, out int? argument_3, out int? argument_4, ref int? argument_5, int? argument_6, out int? argument_7)
|
| | | {
|
| | | if (argument_0 != 0)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_0 = {argument_0}");
|
| | | }
|
| | |
|
| | | if (argument_1 != 1)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_1 = {argument_1}");
|
| | | }
|
| | |
|
| | | argument_1 = 2;
|
| | | if (argument_2 != 2)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_2 = {argument_2}");
|
| | | }
|
| | |
|
| | | argument_3 = 4;
|
| | | argument_4 = 5;
|
| | | if (argument_5 != null)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_5 = {argument_5}");
|
| | | }
|
| | |
|
| | | argument_5 = 6;
|
| | | if (argument_6 != 6)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_6 = {argument_6}");
|
| | | }
|
| | |
|
| | | argument_7 = null;
|
| | | }
|
| | |
|
| | | public static void inoutMultiarg2(ref int? argument_0, out int? argument_1, ref int? argument_2, ref int? argument_3, int? argument_4, out int? argument_5, int? argument_6, out int? argument_7)
|
| | | {
|
| | | if (argument_0 != null)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_0 = {argument_0}");
|
| | | }
|
| | |
|
| | | argument_0 = 1;
|
| | | argument_1 = 2;
|
| | | if (argument_2 != 2)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_2 = {argument_2}");
|
| | | }
|
| | |
|
| | | argument_2 = 3;
|
| | | if (argument_3 != 3)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_3 = {argument_3}");
|
| | | }
|
| | |
|
| | | argument_3 = null;
|
| | | if (argument_4 != 4)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_4 = {argument_4}");
|
| | | }
|
| | |
|
| | | argument_5 = 6;
|
| | | if (argument_6 != 6)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_6 = {argument_6}");
|
| | | }
|
| | |
|
| | | argument_7 = 8;
|
| | | }
|
| | |
|
| | | public static void inoutMultiarg3(out int? argument_0, int? argument_1, int? argument_2, out int? argument_3, ref int? argument_4, out int? argument_5, int? argument_6, ref int? argument_7)
|
| | | {
|
| | | argument_0 = null;
|
| | | if (argument_1 != 1)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_1 = {argument_1}");
|
| | | }
|
| | |
|
| | | if (argument_2 != 2)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_2 = {argument_2}");
|
| | | }
|
| | |
|
| | | argument_3 = 4;
|
| | | if (argument_4 != 4)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_4 = {argument_4}");
|
| | | }
|
| | |
|
| | | argument_4 = 5;
|
| | | argument_5 = 6;
|
| | | if (argument_6 != 6)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_6 = {argument_6}");
|
| | | }
|
| | |
|
| | | if (argument_7 != 7)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_7 = {argument_7}");
|
| | | }
|
| | |
|
| | | argument_7 = 8;
|
| | | }
|
| | |
|
| | | public static void inoutMultiarg4(int argument_0, ref int? argument_1, int argument_2, out int? argument_3, out int? argument_4, ref int? argument_5, ref int? argument_6, int argument_7)
|
| | | {
|
| | | if (argument_0 != 0)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_0 = {argument_0}");
|
| | | }
|
| | |
|
| | | if (argument_1 != 1)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_1 = {argument_1}");
|
| | | }
|
| | |
|
| | | argument_1 = 2;
|
| | | if (argument_2 != 2)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_2 = {argument_2}");
|
| | | }
|
| | |
|
| | | argument_3 = 4;
|
| | | argument_4 = 5;
|
| | | if (argument_5 != 5)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_5 = {argument_5}");
|
| | | }
|
| | |
|
| | | argument_5 = null;
|
| | | if (argument_6 != 6)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_6 = {argument_6}");
|
| | | }
|
| | |
|
| | | argument_6 = 7;
|
| | | if (argument_7 != 7)
|
| | | {
|
| | | throw new SystemException($"Failed assertion: argument_7 = {argument_7}");
|
| | | }
|
| | | }
|
| | |
|
| | | public static void inoutArray10(ref Array? values_array, out int? nulls)
|
| | | {
|
| | | Array flatten_values = Array.CreateInstance(typeof(object), values_array.Length);
|
| | | TestDLLFunctions.TestClass.FlatArray(values_array, ref flatten_values);
|
| | | nulls = 0;
|
| | | for (int i = 0; i < flatten_values.Length; i++)
|
| | | {
|
| | | if (flatten_values.GetValue(i) == null)
|
| | | {
|
| | | nulls++;
|
| | | continue;
|
| | | }
|
| | |
|
| | | PhysicalAddress orig_value = (PhysicalAddress)flatten_values.GetValue(i);
|
| | | byte[] bytes = orig_value.GetAddressBytes();
|
| | | bytes[0] += 1;
|
| | | PhysicalAddress new_value = new(bytes);
|
| | | flatten_values.SetValue((PhysicalAddress)new_value, i);
|
| | | }
|
| | |
|
| | | values_array = flatten_values;
|
| | | }
|
| | |
|
| | | public static void inoutArray11(out Array? values_array, PhysicalAddress address, int count)
|
| | | {
|
| | | Array output = Array.CreateInstance(typeof(object), count);
|
| | | for (int i = 0; i < count; i++)
|
| | | {
|
| | | output.SetValue((PhysicalAddress)address, i);
|
| | | }
|
| | |
|
| | | values_array = output;
|
| | | }
|
| | |
|
| | | public static void inoutSimple10(out int? checksum, (IPAddress Address, int Netmask) address)
|
| | | {
|
| | | int i;
|
| | |
|
| | | // get bytes
|
| | | byte[] bytes = address.Address.GetAddressBytes();
|
| | |
|
| | | // compute checksum
|
| | | checksum = 0;
|
| | | for (i = 0; i < bytes.Length; i++)
|
| | | {
|
| | | checksum += bytes[i];
|
| | | }
|
| | | }
|
| | |
|
| | | public static void inoutSimple20(ref (IPAddress Address, int Netmask)? address, int pos, int delta)
|
| | | {
|
| | | // compute new address
|
| | | (IPAddress address1, int netmask) = address ?? (IPAddress.Parse("1.1.1.1"), 8);
|
| | | byte[] bytes = address1.GetAddressBytes();
|
| | | bytes[pos] += (byte)delta;
|
| | | address = (new IPAddress(bytes), netmask);
|
| | | }
|
| | |
|
| | | public static void inoutSimple30(out int? checksum, ref (IPAddress Address, int Netmask)? address, int pos, int delta)
|
| | | {
|
| | | int i;
|
| | |
|
| | | // compute new address
|
| | | (IPAddress address1, int netmask) = address ?? (IPAddress.Parse("1.1.1.1"), 8);
|
| | | byte[] bytes = address1.GetAddressBytes();
|
| | | bytes[pos] += (byte)delta;
|
| | | address = (new IPAddress(bytes), netmask);
|
| | |
|
| | | // compute checksum
|
| | | checksum = 0;
|
| | | for (i = 0; i < bytes.Length; i++)
|
| | | {
|
| | | checksum += bytes[i];
|
| | | }
|
| | | }
|
| | |
|
| | | public static void inoutObject10(string? a, ref string? b)
|
| | | {
|
| | | a ??= string.Empty;
|
| | | b ??= string.Empty;
|
| | | b = a + " " + b;
|
| | | }
|
| | |
|
| | | public static void inoutObject20(string? a, string? b, out string? c)
|
| | | {
|
| | | a ??= string.Empty;
|
| | | b ??= string.Empty;
|
| | | c = a + " " + b;
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | <Project Sdk="Microsoft.NET.Sdk"> |
| | | |
| | | <PropertyGroup> |
| | | <TargetFramework>$(TargetFramework)</TargetFramework> |
| | | <ImplicitUsings>enable</ImplicitUsings> |
| | | <Nullable>enable</Nullable> |
| | | <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> |
| | | </PropertyGroup> |
| | | |
| | | <ItemGroup> |
| | | <Compile Include="Program.fs" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <ProjectReference Include="..\..\..\dotnet_src\npgsql\src\Npgsql\Npgsql.csproj" /> |
| | | </ItemGroup> |
| | | |
| | | <PropertyGroup> |
| | | <CodeAnalysisRuleSet>stylecop.ruleset</CodeAnalysisRuleSet> |
| | | </PropertyGroup> |
| | | |
| | | </Project> |
| | | <Project Sdk="Microsoft.NET.Sdk">
|
| | |
|
| | | <PropertyGroup>
|
| | | <TargetFramework>$(TargetFramework)</TargetFramework>
|
| | | <ImplicitUsings>enable</ImplicitUsings>
|
| | | <Nullable>enable</Nullable>
|
| | | <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
| | | </PropertyGroup>
|
| | |
|
| | | <ItemGroup>
|
| | | <Compile Include="Program.fs" />
|
| | | </ItemGroup>
|
| | |
|
| | | <ItemGroup>
|
| | | <ProjectReference Include="..\..\..\dotnet_src\npgsql\src\Npgsql\Npgsql.csproj" />
|
| | | </ItemGroup>
|
| | |
|
| | | <PropertyGroup>
|
| | | <CodeAnalysisRuleSet>stylecop.ruleset</CodeAnalysisRuleSet>
|
| | | </PropertyGroup>
|
| | |
|
| | | </Project>
|
| | |
| | | // <copyright file="Program.fs" company="Brick Abode"> |
| | | // |
| | | // PL/.NET (pldotnet) - PostgreSQL support for .NET C# and F# as |
| | | // procedural languages (PL) |
| | | // |
| | | // |
| | | // Copyright (c) 2023 Brick Abode |
| | | // |
| | | // This code is subject to the terms of the PostgreSQL License. |
| | | // The full text of the license can be found in the LICENSE file |
| | | // at the top level of the pldotnet repository. |
| | | // |
| | | // </copyright> |
| | | |
| | | namespace TestFSharpDLLFunctions |
| | | |
| | | open System |
| | | open System.Collections |
| | | open System.Net |
| | | open System.Net.NetworkInformation |
| | | open System.Text |
| | | open NpgsqlTypes |
| | | |
| | | #nowarn "3391" |
| | | |
| | | type TestFSharpClass() = |
| | | static member sum2SmallIntFSharp (a: int16) (b: int16) : Nullable<int16> = |
| | | Nullable (a+b) |
| | | |
| | | static member mult2IntFSharp (a: Nullable<int>) (b: Nullable<int>) : Nullable<int> = |
| | | match (a.HasValue, b.HasValue) with |
| | | | (false, false) -> System.Nullable() |
| | | | (true, false) -> a.Value |
| | | | (false, true) -> b.Value |
| | | | (true, true) -> Nullable (a.Value*b.Value) |
| | | |
| | | static member createDateFSharp (year: Nullable<int>) (month: Nullable<int>) (day: Nullable<int>) : Nullable<DateOnly> = |
| | | match (year.HasValue, month.HasValue, day.HasValue) with |
| | | | (true, true, true) -> new DateOnly(year.Value, month.Value, day.Value) |
| | | | _ -> System.Nullable() |
| | | |
| | | static member addMinutes (time: Nullable<TimeOnly>) (minutes: Nullable<int>) : Nullable<TimeOnly> = |
| | | match (time.HasValue, minutes.HasValue) with |
| | | | (true, true) -> |
| | | (time.Value).AddMinutes(double minutes.Value) |
| | | | (true, false) -> time |
| | | | _ -> |
| | | let auxTime = new TimeOnly(0, 30, 20) |
| | | auxTime.AddMinutes(double minutes.Value) |
| | | |
| | | static member concatenateString (a: string) (b: string) : string = |
| | | match (a = null, b = null) with |
| | | | (false, false) -> a + " " + b |
| | | | (false, true) -> a |
| | | | (true, false) -> b |
| | | | _ -> null |
| | | |
| | | static member modifyStringArray (a: Array) (b: string) : Array = |
| | | let dim = a.Rank |
| | | match dim with |
| | | | 1 -> |
| | | a.SetValue(b, 0) |> ignore |
| | | a |
| | | | 2 -> |
| | | a.SetValue(b, 0, 0) |> ignore |
| | | a |
| | | | 3 -> |
| | | a.SetValue(b, 0, 0, 0) |> ignore |
| | | a |
| | | | _ -> a |
| | | |
| | | static member modifyTimestampArray (a: Array) (b: Nullable<DateTime>) : Array = |
| | | let dim = a.Rank |
| | | let newValue = |
| | | match b.HasValue with |
| | | | true -> b.Value |
| | | | false -> new DateTime(2022, 11, 15, 13, 23, 45) |
| | | |
| | | match dim with |
| | | | 1 -> |
| | | a.SetValue(newValue, 0) |> ignore |
| | | a |
| | | | 2 -> |
| | | a.SetValue(newValue, 0, 0) |> ignore |
| | | a |
| | | | 3 -> |
| | | a.SetValue(newValue, 0, 0, 0) |> ignore |
| | | a |
| | | | _ -> a |
| | | |
| | | static member modifyFloat4ArrayFSharp (a: Array) (b: float32) : Array = |
| | | let dim = a.Rank |
| | | match dim with |
| | | | 1 -> |
| | | a.SetValue(b, 0) |> ignore |
| | | a |
| | | | 2 -> |
| | | a.SetValue(b, 0, 0) |> ignore |
| | | a |
| | | | 3 -> |
| | | a.SetValue(b, 0, 0, 0) |> ignore |
| | | a |
| | | | _ -> a |
| | | |
| | | static member modifyFloat8ArrayFSharp (a: Array) (b: Nullable<float>) : Array = |
| | | let dim = a.Rank |
| | | let newValue = |
| | | match b.HasValue with |
| | | | true -> b.Value |
| | | | false -> 0.0 |
| | | match dim with |
| | | | 1 -> |
| | | a.SetValue(newValue, 0) |> ignore |
| | | a |
| | | | 2 -> |
| | | a.SetValue(newValue, 0, 0) |> ignore |
| | | a |
| | | | 3 -> |
| | | a.SetValue(newValue, 0, 0, 0) |> ignore |
| | | a |
| | | | _ -> a |
| | | |
| | | type InoutTestsFSharpClass() = |
| | | |
| | | static member fsInoutAllthreeS (a: int) (b: int) : Nullable<int> * Nullable<int> = |
| | | Nullable(b+1), Nullable(a+b) |
| | | |
| | | static member fsInoutAllthree (a: Nullable<int>) (b: Nullable<int>) : Nullable<int> * Nullable<int> = |
| | | if a.HasValue && b.HasValue then |
| | | Nullable(a.Value + 1), Nullable(a.Value + b.Value) |
| | | else |
| | | Nullable(), Nullable() |
| | | |
| | | static member fsInoutAllthreearray (a: int) (b: int) : Nullable<int> * Array = |
| | | let c = b + 1 |
| | | let arr = Array.CreateInstance(typeof<int16>, 3, 3) |
| | | arr.SetValue((int16)a, 0, 0) |
| | | arr.SetValue((int16)a, 1, 1) |
| | | arr.SetValue((int16)a, 2, 2) |
| | | Nullable(c), arr |
| | | |
| | | static member inoutMultiarg1FsS (a0: int) (a1: int) (a2: int) (a5: int) (a6: int) : Nullable<int> * Nullable<int> * Nullable<int> * Nullable<int> * Nullable<int> = |
| | | if a0 <> 0 then |
| | | raise <| SystemException("Failed assertion: a0") |
| | | if a1 <> 1 then |
| | | raise <| SystemException("Failed assertion: a1") |
| | | if a2 <> 2 then |
| | | raise <| SystemException("Failed assertion: a2") |
| | | if a5 <> 5 then |
| | | raise <| SystemException("Failed assertion: a5") |
| | | if a6 <> 6 then |
| | | raise <| SystemException("Failed assertion: a6") |
| | | |
| | | (Nullable(2), Nullable(4), Nullable(5), Nullable(6), Nullable(7)) |
| | | |
| | | static member inoutMultiarg1Fs (a0: Nullable<int>) (a1: Nullable<int>) (a2: Nullable<int>) (a5: Nullable<int>) (a6: Nullable<int>) : Nullable<int> * Nullable<int> * Nullable<int> * Nullable<int> * Nullable<int> = |
| | | if a0.HasValue && a0.Value <> 0 then |
| | | raise <| SystemException("Failed assertion: a0") |
| | | if a1.HasValue && a1.Value <> 1 then |
| | | raise <| SystemException("Failed assertion: a1") |
| | | if a2.HasValue && a2.Value <> 2 then |
| | | raise <| SystemException("Failed assertion: a2") |
| | | if a5.HasValue then |
| | | raise <| SystemException("Failed assertion: a5") |
| | | if a6.HasValue && a6.Value <> 6 then |
| | | raise <| SystemException("Failed assertion: a6") |
| | | |
| | | (Nullable(2), Nullable(4), Nullable(5), Nullable(6), Nullable()) |
| | | |
| | | static member inoutMrray10FsS (input_array: Array) : Array = |
| | | let count = input_array.Length |
| | | let output = Array.CreateInstance(typeof<obj>, count) |
| | | for i = 0 to count - 1 do |
| | | output.SetValue(input_array.GetValue(i), i) |
| | | if count > 3 then |
| | | output.SetValue(Nullable() :> obj, 3) |
| | | output |
| | | |
| | | static member inoutMrray11FsS (address: PhysicalAddress) (count: int) : Array = |
| | | let output = Array.CreateInstance(typeof<obj>, count) |
| | | for i = 0 to count - 1 do |
| | | output.SetValue(address :> obj, i) |
| | | if count > 3 then |
| | | output.SetValue(Nullable() :> obj, 3) |
| | | output |
| | | |
| | | static member inoutMbject10Fs (a: string) (b: string) : string = |
| | | a + " " + b; |
| | | |
| | | static member inoutMbject20Fs (a: string) (b: string) : string = |
| | | // <copyright file="Program.fs" company="Brick Abode">
|
| | | //
|
| | | // PL/.NET (pldotnet) - PostgreSQL support for .NET C# and F# as
|
| | | // procedural languages (PL)
|
| | | //
|
| | | //
|
| | | // Copyright (c) 2023 Brick Abode
|
| | | //
|
| | | // This code is subject to the terms of the PostgreSQL License.
|
| | | // The full text of the license can be found in the LICENSE file
|
| | | // at the top level of the pldotnet repository.
|
| | | //
|
| | | // </copyright>
|
| | |
|
| | | namespace TestFSharpDLLFunctions
|
| | |
|
| | | open System
|
| | | open System.Collections
|
| | | open System.Net
|
| | | open System.Net.NetworkInformation
|
| | | open System.Text
|
| | | open NpgsqlTypes
|
| | |
|
| | | #nowarn "3391"
|
| | |
|
| | | type TestFSharpClass() =
|
| | | static member sum2SmallIntFSharp (a: int16) (b: int16) : Nullable<int16> =
|
| | | Nullable (a+b)
|
| | |
|
| | | static member mult2IntFSharp (a: Nullable<int>) (b: Nullable<int>) : Nullable<int> =
|
| | | match (a.HasValue, b.HasValue) with
|
| | | | (false, false) -> System.Nullable()
|
| | | | (true, false) -> a.Value
|
| | | | (false, true) -> b.Value
|
| | | | (true, true) -> Nullable (a.Value*b.Value)
|
| | |
|
| | | static member createDateFSharp (year: Nullable<int>) (month: Nullable<int>) (day: Nullable<int>) : Nullable<DateOnly> =
|
| | | match (year.HasValue, month.HasValue, day.HasValue) with
|
| | | | (true, true, true) -> new DateOnly(year.Value, month.Value, day.Value)
|
| | | | _ -> System.Nullable()
|
| | |
|
| | | static member addMinutes (time: Nullable<TimeOnly>) (minutes: Nullable<int>) : Nullable<TimeOnly> =
|
| | | match (time.HasValue, minutes.HasValue) with
|
| | | | (true, true) ->
|
| | | (time.Value).AddMinutes(double minutes.Value)
|
| | | | (true, false) -> time
|
| | | | _ ->
|
| | | let auxTime = new TimeOnly(0, 30, 20)
|
| | | auxTime.AddMinutes(double minutes.Value)
|
| | |
|
| | | static member concatenateString (a: string) (b: string) : string =
|
| | | match (a = null, b = null) with
|
| | | | (false, false) -> a + " " + b
|
| | | | (false, true) -> a
|
| | | | (true, false) -> b
|
| | | | _ -> null
|
| | |
|
| | | static member modifyStringArray (a: Array) (b: string) : Array =
|
| | | let dim = a.Rank
|
| | | match dim with
|
| | | | 1 ->
|
| | | a.SetValue(b, 0) |> ignore
|
| | | a
|
| | | | 2 ->
|
| | | a.SetValue(b, 0, 0) |> ignore
|
| | | a
|
| | | | 3 ->
|
| | | a.SetValue(b, 0, 0, 0) |> ignore
|
| | | a
|
| | | | _ -> a
|
| | |
|
| | | static member modifyTimestampArray (a: Array) (b: Nullable<DateTime>) : Array =
|
| | | let dim = a.Rank
|
| | | let newValue =
|
| | | match b.HasValue with
|
| | | | true -> b.Value
|
| | | | false -> new DateTime(2022, 11, 15, 13, 23, 45)
|
| | |
|
| | | match dim with
|
| | | | 1 ->
|
| | | a.SetValue(newValue, 0) |> ignore
|
| | | a
|
| | | | 2 ->
|
| | | a.SetValue(newValue, 0, 0) |> ignore
|
| | | a
|
| | | | 3 ->
|
| | | a.SetValue(newValue, 0, 0, 0) |> ignore
|
| | | a
|
| | | | _ -> a
|
| | |
|
| | | static member modifyFloat4ArrayFSharp (a: Array) (b: float32) : Array =
|
| | | let dim = a.Rank
|
| | | match dim with
|
| | | | 1 ->
|
| | | a.SetValue(b, 0) |> ignore
|
| | | a
|
| | | | 2 ->
|
| | | a.SetValue(b, 0, 0) |> ignore
|
| | | a
|
| | | | 3 ->
|
| | | a.SetValue(b, 0, 0, 0) |> ignore
|
| | | a
|
| | | | _ -> a
|
| | |
|
| | | static member modifyFloat8ArrayFSharp (a: Array) (b: Nullable<float>) : Array =
|
| | | let dim = a.Rank
|
| | | let newValue =
|
| | | match b.HasValue with
|
| | | | true -> b.Value
|
| | | | false -> 0.0
|
| | | match dim with
|
| | | | 1 ->
|
| | | a.SetValue(newValue, 0) |> ignore
|
| | | a
|
| | | | 2 ->
|
| | | a.SetValue(newValue, 0, 0) |> ignore
|
| | | a
|
| | | | 3 ->
|
| | | a.SetValue(newValue, 0, 0, 0) |> ignore
|
| | | a
|
| | | | _ -> a
|
| | |
|
| | | type InoutTestsFSharpClass() =
|
| | | |
| | | static member fsInoutAllthreeS (a: int) (b: int) : Nullable<int> * Nullable<int> = |
| | | Nullable(b+1), Nullable(a+b)
|
| | |
|
| | | static member fsInoutAllthree (a: Nullable<int>) (b: Nullable<int>) : Nullable<int> * Nullable<int> = |
| | | if a.HasValue && b.HasValue then
|
| | | Nullable(a.Value + 1), Nullable(a.Value + b.Value)
|
| | | else
|
| | | Nullable(), Nullable()
|
| | |
|
| | | static member fsInoutAllthreearray (a: int) (b: int) : Nullable<int> * Array = |
| | | let c = b + 1
|
| | | let arr = Array.CreateInstance(typeof<int16>, 3, 3)
|
| | | arr.SetValue((int16)a, 0, 0)
|
| | | arr.SetValue((int16)a, 1, 1)
|
| | | arr.SetValue((int16)a, 2, 2)
|
| | | Nullable(c), arr
|
| | |
|
| | | static member inoutMultiarg1FsS (a0: int) (a1: int) (a2: int) (a5: int) (a6: int) : Nullable<int> * Nullable<int> * Nullable<int> * Nullable<int> * Nullable<int> = |
| | | if a0 <> 0 then
|
| | | raise <| SystemException("Failed assertion: a0")
|
| | | if a1 <> 1 then
|
| | | raise <| SystemException("Failed assertion: a1")
|
| | | if a2 <> 2 then
|
| | | raise <| SystemException("Failed assertion: a2")
|
| | | if a5 <> 5 then
|
| | | raise <| SystemException("Failed assertion: a5")
|
| | | if a6 <> 6 then
|
| | | raise <| SystemException("Failed assertion: a6")
|
| | |
|
| | | (Nullable(2), Nullable(4), Nullable(5), Nullable(6), Nullable(7))
|
| | |
|
| | | static member inoutMultiarg1Fs (a0: Nullable<int>) (a1: Nullable<int>) (a2: Nullable<int>) (a5: Nullable<int>) (a6: Nullable<int>) : Nullable<int> * Nullable<int> * Nullable<int> * Nullable<int> * Nullable<int> = |
| | | if a0.HasValue && a0.Value <> 0 then
|
| | | raise <| SystemException("Failed assertion: a0")
|
| | | if a1.HasValue && a1.Value <> 1 then
|
| | | raise <| SystemException("Failed assertion: a1")
|
| | | if a2.HasValue && a2.Value <> 2 then
|
| | | raise <| SystemException("Failed assertion: a2")
|
| | | if a5.HasValue then
|
| | | raise <| SystemException("Failed assertion: a5")
|
| | | if a6.HasValue && a6.Value <> 6 then
|
| | | raise <| SystemException("Failed assertion: a6")
|
| | |
|
| | | (Nullable(2), Nullable(4), Nullable(5), Nullable(6), Nullable())
|
| | |
|
| | | static member inoutMrray10FsS (input_array: Array) : Array = |
| | | let count = input_array.Length
|
| | | let output = Array.CreateInstance(typeof<obj>, count)
|
| | | for i = 0 to count - 1 do
|
| | | output.SetValue(input_array.GetValue(i), i)
|
| | | if count > 3 then
|
| | | output.SetValue(Nullable() :> obj, 3)
|
| | | output
|
| | | |
| | | static member inoutMrray11FsS (address: PhysicalAddress) (count: int) : Array = |
| | | let output = Array.CreateInstance(typeof<obj>, count)
|
| | | for i = 0 to count - 1 do
|
| | | output.SetValue(address :> obj, i)
|
| | | if count > 3 then
|
| | | output.SetValue(Nullable() :> obj, 3)
|
| | | output
|
| | |
|
| | | static member inoutMbject10Fs (a: string) (b: string) : string = |
| | | a + " " + b;
|
| | | |
| | | static member inoutMbject20Fs (a: string) (b: string) : string = |
| | | a + " " + b; |
| | |
| | | using DotNetEnv; |
| | | using Npgsql; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using Xunit; |
| | | |
| | | [Collection("Sequential")] |
| | | public class PlDotNetTest |
| | | { |
| | | protected SqlFunctionInfo? FunctionInfo; |
| | | |
| | | string DatabaseConnectionString = |
| | | Environment.GetEnvironmentVariable("DATABASE_CONNECTION_STRING") + ";Include Error Detail=true" |
| | | ?? throw new InvalidOperationException("DATABASE_CONNECTION_STRING not set."); |
| | | |
| | | int TestCount = 0; |
| | | |
| | | public enum LanguageType |
| | | { |
| | | PlcSharp, |
| | | PlfSharp, |
| | | PlPython, |
| | | PlR, |
| | | PlPgSQL, |
| | | PlV8, |
| | | PlTCL, |
| | | PlLua, |
| | | PlPerl |
| | | } |
| | | |
| | | public enum SqlTestType |
| | | { |
| | | Function, |
| | | Procedure, |
| | | DoBlock |
| | | } |
| | | |
| | | public Dictionary<SqlTestType, string> TestTypeMap = new Dictionary<SqlTestType, string> |
| | | { |
| | | { SqlTestType.Function, "FUNCTION" }, |
| | | { SqlTestType.Procedure, "PROCEDURE" }, |
| | | { SqlTestType.DoBlock, "DO BLOCK" } |
| | | }; |
| | | |
| | | public class SqlFunctionInfo |
| | | { |
| | | // New properties for dynamic SQL construction |
| | | |
| | | public string CteStatement { get; set; } = string.Empty; |
| | | public string CustomAssertion { get; set; } = string.Empty; // For complex assertion logic |
| | | public string QuerySuffix { get; set; } = string.Empty; // For additional WHERE, LIMIT, etc. |
| | | public SqlTestType TestType { get; set; } = SqlTestType.Function; |
| | | public string Name { get; set; } = string.Empty; |
| | | public List<FunctionArgument> Arguments { get; set; } = new List<FunctionArgument>(); |
| | | public string ReturnType { get; set; } = string.Empty; |
| | | public string Body { get; set; } = string.Empty; |
| | | public LanguageType Language { get; set; } |
| | | public bool IsStrict { get; set; } |
| | | public string FunctionName { get; set; } = string.Empty; |
| | | public string TestName { get; set; } = string.Empty; |
| | | public string FeatureName { get; set; } = string.Empty; |
| | | public string InputStr { get; set; } = string.Empty; |
| | | public string ExpectedResult { get; set; } = string.Empty; |
| | | public string CastFunctionAs { get; set; } = string.Empty; |
| | | |
| | | public int? TestId { get; set; } |
| | | |
| | | public bool FunctionCreatedSuccessfully { get; set; } = false; |
| | | |
| | | public bool TestInsertedSuccessfully { get; set; } = false; |
| | | |
| | | public string SqlFunctionDefinition { get; set; } = string.Empty; |
| | | |
| | | public string SqlFunctionCall { get; set; } = string.Empty; |
| | | |
| | | public string LanguageString |
| | | { |
| | | get |
| | | { |
| | | return Language switch |
| | | { |
| | | LanguageType.PlcSharp => "plcsharp", |
| | | LanguageType.PlfSharp => "plfsharp", |
| | | LanguageType.PlPython => "plpython3u", |
| | | LanguageType.PlR => "plr", |
| | | LanguageType.PlPgSQL => "plpgsql", |
| | | LanguageType.PlV8 => "plv8", |
| | | LanguageType.PlTCL => "pltcl", |
| | | LanguageType.PlLua => "pllua", |
| | | LanguageType.PlPerl => "plperl", |
| | | _ => throw new System.NotImplementedException() |
| | | }; |
| | | } |
| | | } |
| | | |
| | | public SqlFunctionInfo() { } |
| | | } |
| | | |
| | | public class FunctionArgument |
| | | { |
| | | public string Name { get; set; } |
| | | public string Type { get; set; } |
| | | |
| | | public FunctionArgument(string name, string type) |
| | | { |
| | | Name = name; |
| | | Type = type; |
| | | } |
| | | } |
| | | |
| | | public class TestQueryParameters |
| | | { |
| | | public List<(string Name, string Query)> Ctes { get; set; } = |
| | | new List<(string Name, string Query)>(); |
| | | public string TestCategory { get; set; } = string.Empty; |
| | | public string TestName { get; set; } = string.Empty; |
| | | public string Assertion { get; set; } = string.Empty; |
| | | public string FinalSelect { get; set; } = string.Empty; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Constructs and returns the SQL definition of a function based on the provided SqlFunctionInfo. |
| | | /// </summary> |
| | | /// <param name="functionInfo">The information about the SQL function.</param> |
| | | /// <returns>A string representing the SQL definition of the function.</returns> |
| | | /// <remarks> |
| | | /// The method uses the properties of the SqlFunctionInfo object to create a SQL CREATE OR REPLACE FUNCTION statement. |
| | | /// If the IsStrict property of the SqlFunctionInfo object is true, the "STRICT" keyword is added to the SQL definition. |
| | | /// </remarks> |
| | | public virtual string GetFunctionDefinition(SqlFunctionInfo functionInfo) |
| | | { |
| | | var arguments = string.Join( |
| | | ", ", |
| | | functionInfo.Arguments.Select(arg => $"{arg.Name} {arg.Type}") |
| | | ); |
| | | |
| | | string methodKeyword = |
| | | functionInfo.TestType == SqlTestType.Function ? "FUNCTION" : "PROCEDURE"; |
| | | |
| | | string strictKeyword = functionInfo.IsStrict ? "STRICT" : ""; |
| | | |
| | | // Conditionally build the returnTypeString |
| | | string returnTypeString = string.IsNullOrEmpty(functionInfo.ReturnType) |
| | | ? string.Empty |
| | | : $"RETURNS {functionInfo.ReturnType}"; |
| | | |
| | | return $@"CREATE OR REPLACE {methodKeyword} {functionInfo.Name}({arguments}) |
| | | {returnTypeString} AS $$ |
| | | {functionInfo.Body} |
| | | $$ LANGUAGE {functionInfo.LanguageString} {strictKeyword};"; |
| | | } |
| | | |
| | | public virtual string GetFunctionCall(SqlFunctionInfo functionInfo, bool forceCte = false) |
| | | { |
| | | if (functionInfo.TestType == SqlTestType.Procedure) |
| | | { |
| | | return $"CALL {functionInfo.Name}({functionInfo.InputStr});"; |
| | | } |
| | | |
| | | return TestResultStrategyFactory.GetStrategy(functionInfo, forceCte).BuildInsertSql(functionInfo); |
| | | } |
| | | |
| | | public interface ITestResultStrategy |
| | | { |
| | | // AppliesTo determines if the strategy should be used for the given functionInfo |
| | | bool AppliesTo(SqlFunctionInfo functionInfo); |
| | | |
| | | // BuildInsertSql returns the SQL code to insert the test result |
| | | string BuildInsertSql(SqlFunctionInfo functionInfo); |
| | | } |
| | | |
| | | public class DefaultTestResultStrategy : ITestResultStrategy |
| | | { |
| | | public bool AppliesTo(SqlFunctionInfo functionInfo) |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | public string BuildInsertSql(SqlFunctionInfo functionInfo) |
| | | { |
| | | string functionCall = $"{functionInfo.Name}({functionInfo.InputStr})"; |
| | | |
| | | string cast = !string.IsNullOrWhiteSpace(functionInfo.CastFunctionAs) |
| | | ? $"CAST({functionCall} AS {functionInfo.CastFunctionAs})" |
| | | : functionCall; |
| | | |
| | | string nullComparison = |
| | | functionInfo.ExpectedResult == "= null" |
| | | ? "IS NULL" |
| | | : $"{cast} {functionInfo.ExpectedResult}"; |
| | | |
| | | if (string.IsNullOrWhiteSpace(functionInfo.ExpectedResult)) |
| | | { |
| | | nullComparison = "IS NOT NULL"; |
| | | } |
| | | |
| | | string sqlCode = |
| | | $@"INSERT INTO automated_test_results (FEATURE, TEST_NAME, RESULT) |
| | | VALUES ('{functionInfo.FeatureName}', '{functionInfo.TestName}', {nullComparison}) |
| | | RETURNING id;"; |
| | | |
| | | return sqlCode; |
| | | } |
| | | } |
| | | |
| | | // public class CteTestResultStrategy : ITestResultStrategy |
| | | // { |
| | | // public bool AppliesTo(SqlFunctionInfo functionInfo) |
| | | // { |
| | | // // This strategy applies if a CTE statement is defined |
| | | // return !string.IsNullOrWhiteSpace(functionInfo.CteStatement); |
| | | // } |
| | | |
| | | // public string BuildInsertSql(SqlFunctionInfo functionInfo) |
| | | // { |
| | | // // Use the provided CTE statement directly in the SQL command construction |
| | | // string sqlCode = |
| | | // $@" |
| | | // {functionInfo.CteStatement} |
| | | // INSERT INTO automated_test_results (FEATURE, TEST_NAME, RESULT) |
| | | // SELECT '{functionInfo.FeatureName}', '{functionInfo.TestName}', {functionInfo.CustomAssertion} FROM cte {functionInfo.QuerySuffix} RETURNING id;"; |
| | | |
| | | // return sqlCode; |
| | | // } |
| | | // } |
| | | |
| | | // Defines a class CteTestResultStrategy that implements the ITestResultStrategy interface. |
| | | public class CteTestResultStrategy : ITestResultStrategy |
| | | { |
| | | // Determines if the strategy applies to the given SQL function based on the presence of a CTE statement. |
| | | |
| | | public bool AppliesTo(SqlFunctionInfo functionInfo) |
| | | { |
| | | // Returns true if the CteStatement property of functionInfo is not null or whitespace, indicating |
| | | // this strategy should be used for functions with CTEs. |
| | | return !string.IsNullOrWhiteSpace(functionInfo.CteStatement); |
| | | } |
| | | |
| | | // Builds an SQL INSERT statement using the information provided in the SqlFunctionInfo parameter. |
| | | public string BuildInsertSql(SqlFunctionInfo functionInfo) |
| | | { |
| | | // Extracts the name of the CTE from its SQL statement to use in the final query. |
| | | string cteName = ExtractCteName(functionInfo.CteStatement)!; |
| | | |
| | | // Constructs an SQL statement that includes the CTE statement and an INSERT INTO operation. |
| | | // The INSERT operation adds a new row into the automated_test_results table with details from the functionInfo parameter |
| | | // and selects values from the CTE defined earlier, applying any specified query suffix. Finally, it returns the id of the inserted row. |
| | | string sqlCode = |
| | | $@" |
| | | {functionInfo.CteStatement} |
| | | INSERT INTO automated_test_results (FEATURE, TEST_NAME, RESULT) |
| | | SELECT '{functionInfo.FeatureName}', '{functionInfo.TestName}', {functionInfo.CustomAssertion} FROM {cteName} {functionInfo.QuerySuffix} RETURNING id;"; |
| | | |
| | | // Returns the constructed SQL code. |
| | | return sqlCode; |
| | | } |
| | | |
| | | // A private helper method to extract the name of the CTE from its SQL statement. |
| | | private string? ExtractCteName(string cteStatement) |
| | | { |
| | | // Uses a regular expression to find the CTE name in the CTE statement by looking for the pattern |
| | | // that follows "WITH" and precedes "AS". Assumes the CTE name is a single word (\w+). |
| | | var match = System.Text.RegularExpressions.Regex.Match( |
| | | cteStatement, |
| | | @"WITH\s+(\w+)\s+AS" |
| | | ); |
| | | // If the pattern is found, the CTE name is returned. |
| | | if (match.Success) |
| | | { |
| | | return match.Groups[1].Value; |
| | | } |
| | | // If the pattern is not found, returns null indicating no CTE name could be extracted. |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | // public class CteTestResultStrategy : ITestResultStrategy |
| | | // { |
| | | // public bool AppliesTo(SqlFunctionInfo functionInfo) |
| | | // { |
| | | // // This strategy applies if a CTE statement is defined and not empty. |
| | | // return !string.IsNullOrWhiteSpace(functionInfo.CteStatement); |
| | | // } |
| | | |
| | | // public string BuildInsertSql(SqlFunctionInfo functionInfo) |
| | | // { |
| | | // // Directly prepend the CTE statement to the SQL command |
| | | // string sqlCode = |
| | | // $@" |
| | | // {functionInfo.cteStatement} |
| | | // INSERT INTO automated_test_results (FEATURE, TEST_NAME, RESULT) |
| | | // SELECT '{functionInfo.FeatureName}', '{functionInfo.TestName}', {functionInfo.CustomAssertion} RETURNING id;"; |
| | | |
| | | // return sqlCode; |
| | | // } |
| | | // } |
| | | |
| | | public class JsonOrXmlTestResultStrategy : ITestResultStrategy |
| | | { |
| | | public bool AppliesTo(SqlFunctionInfo functionInfo) |
| | | { |
| | | return ( |
| | | functionInfo.ReturnType != null |
| | | && ( |
| | | functionInfo.ReturnType.IndexOf("JSON", StringComparison.OrdinalIgnoreCase) |
| | | >= 0 |
| | | || functionInfo.ReturnType.IndexOf( |
| | | "XML", |
| | | StringComparison.OrdinalIgnoreCase |
| | | ) >= 0 |
| | | ) |
| | | ) |
| | | || ( |
| | | functionInfo.ExpectedResult != null |
| | | && functionInfo.ExpectedResult.IndexOf( |
| | | "::JSON::TEXT", |
| | | StringComparison.OrdinalIgnoreCase |
| | | ) >= 0 |
| | | ); |
| | | } |
| | | |
| | | public string BuildInsertSql(SqlFunctionInfo functionInfo) |
| | | { |
| | | string functionCall = $"{functionInfo.Name}({functionInfo.InputStr})::TEXT"; |
| | | string expectedResult = functionInfo.ExpectedResult + "::TEXT"; |
| | | |
| | | string sqlCode = |
| | | $@" INSERT INTO automated_test_results (FEATURE, TEST_NAME, RESULT) |
| | | VALUES ('{functionInfo.FeatureName}', '{functionInfo.TestName}', {functionCall} {expectedResult}) |
| | | RETURNING id;"; |
| | | return sqlCode; |
| | | } |
| | | } |
| | | |
| | | public class TestResultStrategyFactory |
| | | { |
| | | private static readonly List<ITestResultStrategy> Strategies = new List<ITestResultStrategy> |
| | | { |
| | | new CteTestResultStrategy(), |
| | | new JsonOrXmlTestResultStrategy(), |
| | | new DefaultTestResultStrategy() |
| | | }; |
| | | |
| | | public static ITestResultStrategy GetStrategy( |
| | | SqlFunctionInfo functionInfo, |
| | | bool forceCte = false |
| | | ) |
| | | { |
| | | if (forceCte) |
| | | { |
| | | return Strategies[0]; |
| | | } |
| | | return Strategies.FirstOrDefault(strategy => strategy.AppliesTo(functionInfo)) |
| | | ?? new DefaultTestResultStrategy(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Executes the provided SQL command that is expected to return an integer ID. |
| | | /// This is typically used with SQL INSERT commands that use the RETURNING clause |
| | | /// to return the ID of the newly inserted row. |
| | | /// </summary> |
| | | /// <param name="sqlCode">The SQL code to execute.</param> |
| | | /// <returns>The retrieved integer ID if the command executed successfully and returned a value, |
| | | /// null otherwise.</returns> |
| | | protected int? ExecuteSqlReturnId(string sqlCode) |
| | | { |
| | | StringBuilder messages = new StringBuilder(); |
| | | Exception exception = null!; |
| | | |
| | | try |
| | | { |
| | | using var connection = new NpgsqlConnection(DatabaseConnectionString); |
| | | connection.Open(); |
| | | using DotNetEnv;
|
| | | using Npgsql;
|
| | | using System;
|
| | | using System.Collections;
|
| | | using System.Collections.Generic;
|
| | | using System.Data;
|
| | | using System.Reflection;
|
| | | using System.Text;
|
| | | using Xunit;
|
| | |
|
| | | [Collection("Sequential")]
|
| | | public class PlDotNetTest
|
| | | {
|
| | | protected SqlFunctionInfo? FunctionInfo;
|
| | |
|
| | | string DatabaseConnectionString =
|
| | | Environment.GetEnvironmentVariable("DATABASE_CONNECTION_STRING") + ";Include Error Detail=true"
|
| | | ?? throw new InvalidOperationException("DATABASE_CONNECTION_STRING not set.");
|
| | |
|
| | | int TestCount = 0;
|
| | |
|
| | | public enum LanguageType
|
| | | {
|
| | | PlcSharp,
|
| | | PlfSharp,
|
| | | PlPython,
|
| | | PlR,
|
| | | PlPgSQL,
|
| | | PlV8,
|
| | | PlTCL,
|
| | | PlLua,
|
| | | PlPerl
|
| | | }
|
| | |
|
| | | public enum SqlTestType
|
| | | {
|
| | | Function,
|
| | | Procedure,
|
| | | DoBlock
|
| | | }
|
| | |
|
| | | public Dictionary<SqlTestType, string> TestTypeMap = new Dictionary<SqlTestType, string>
|
| | | {
|
| | | { SqlTestType.Function, "FUNCTION" },
|
| | | { SqlTestType.Procedure, "PROCEDURE" },
|
| | | { SqlTestType.DoBlock, "DO BLOCK" }
|
| | | };
|
| | |
|
| | | public class SqlFunctionInfo
|
| | | {
|
| | | // New properties for dynamic SQL construction
|
| | |
|
| | | public string CteStatement { get; set; } = string.Empty;
|
| | | public string CustomAssertion { get; set; } = string.Empty; // For complex assertion logic
|
| | | public string QuerySuffix { get; set; } = string.Empty; // For additional WHERE, LIMIT, etc.
|
| | | public SqlTestType TestType { get; set; } = SqlTestType.Function;
|
| | | public string Name { get; set; } = string.Empty;
|
| | | public List<FunctionArgument> Arguments { get; set; } = new List<FunctionArgument>();
|
| | | public string ReturnType { get; set; } = string.Empty;
|
| | | public string Body { get; set; } = string.Empty;
|
| | | public LanguageType Language { get; set; }
|
| | | public bool IsStrict { get; set; }
|
| | | public string FunctionName { get; set; } = string.Empty;
|
| | | public string TestName { get; set; } = string.Empty;
|
| | | public string FeatureName { get; set; } = string.Empty;
|
| | | public string InputStr { get; set; } = string.Empty;
|
| | | public string ExpectedResult { get; set; } = string.Empty;
|
| | | public string CastFunctionAs { get; set; } = string.Empty;
|
| | |
|
| | | public int? TestId { get; set; }
|
| | |
|
| | | public bool FunctionCreatedSuccessfully { get; set; } = false;
|
| | |
|
| | | public bool TestInsertedSuccessfully { get; set; } = false;
|
| | |
|
| | | public string SqlFunctionDefinition { get; set; } = string.Empty;
|
| | |
|
| | | public string SqlFunctionCall { get; set; } = string.Empty;
|
| | |
|
| | | public string LanguageString
|
| | | {
|
| | | get
|
| | | {
|
| | | return Language switch
|
| | | {
|
| | | LanguageType.PlcSharp => "plcsharp",
|
| | | LanguageType.PlfSharp => "plfsharp",
|
| | | LanguageType.PlPython => "plpython3u",
|
| | | LanguageType.PlR => "plr",
|
| | | LanguageType.PlPgSQL => "plpgsql",
|
| | | LanguageType.PlV8 => "plv8",
|
| | | LanguageType.PlTCL => "pltcl",
|
| | | LanguageType.PlLua => "pllua",
|
| | | LanguageType.PlPerl => "plperl",
|
| | | _ => throw new System.NotImplementedException()
|
| | | };
|
| | | }
|
| | | }
|
| | |
|
| | | public SqlFunctionInfo() { }
|
| | | }
|
| | |
|
| | | public class FunctionArgument
|
| | | {
|
| | | public string Name { get; set; }
|
| | | public string Type { get; set; }
|
| | |
|
| | | public FunctionArgument(string name, string type)
|
| | | {
|
| | | Name = name;
|
| | | Type = type;
|
| | | }
|
| | | }
|
| | |
|
| | | public class TestQueryParameters
|
| | | {
|
| | | public List<(string Name, string Query)> Ctes { get; set; } =
|
| | | new List<(string Name, string Query)>();
|
| | | public string TestCategory { get; set; } = string.Empty;
|
| | | public string TestName { get; set; } = string.Empty;
|
| | | public string Assertion { get; set; } = string.Empty;
|
| | | public string FinalSelect { get; set; } = string.Empty;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// Constructs and returns the SQL definition of a function based on the provided SqlFunctionInfo.
|
| | | /// </summary>
|
| | | /// <param name="functionInfo">The information about the SQL function.</param>
|
| | | /// <returns>A string representing the SQL definition of the function.</returns>
|
| | | /// <remarks>
|
| | | /// The method uses the properties of the SqlFunctionInfo object to create a SQL CREATE OR REPLACE FUNCTION statement.
|
| | | /// If the IsStrict property of the SqlFunctionInfo object is true, the "STRICT" keyword is added to the SQL definition.
|
| | | /// </remarks>
|
| | | public virtual string GetFunctionDefinition(SqlFunctionInfo functionInfo)
|
| | | {
|
| | | var arguments = string.Join(
|
| | | ", ",
|
| | | functionInfo.Arguments.Select(arg => $"{arg.Name} {arg.Type}")
|
| | | );
|
| | |
|
| | | string methodKeyword =
|
| | | functionInfo.TestType == SqlTestType.Function ? "FUNCTION" : "PROCEDURE";
|
| | |
|
| | | string strictKeyword = functionInfo.IsStrict ? "STRICT" : "";
|
| | |
|
| | | // Conditionally build the returnTypeString
|
| | | string returnTypeString = string.IsNullOrEmpty(functionInfo.ReturnType)
|
| | | ? string.Empty
|
| | | : $"RETURNS {functionInfo.ReturnType}";
|
| | |
|
| | | return $@"CREATE OR REPLACE {methodKeyword} {functionInfo.Name}({arguments})
|
| | | {returnTypeString} AS $$
|
| | | {functionInfo.Body}
|
| | | $$ LANGUAGE {functionInfo.LanguageString} {strictKeyword};";
|
| | | }
|
| | |
|
| | | public virtual string GetFunctionCall(SqlFunctionInfo functionInfo, bool forceCte = false)
|
| | | {
|
| | | if (functionInfo.TestType == SqlTestType.Procedure)
|
| | | {
|
| | | return $"CALL {functionInfo.Name}({functionInfo.InputStr});";
|
| | | }
|
| | |
|
| | | return TestResultStrategyFactory.GetStrategy(functionInfo, forceCte).BuildInsertSql(functionInfo);
|
| | | }
|
| | |
|
| | | public interface ITestResultStrategy
|
| | | {
|
| | | // AppliesTo determines if the strategy should be used for the given functionInfo
|
| | | bool AppliesTo(SqlFunctionInfo functionInfo);
|
| | |
|
| | | // BuildInsertSql returns the SQL code to insert the test result
|
| | | string BuildInsertSql(SqlFunctionInfo functionInfo);
|
| | | }
|
| | |
|
| | | public class DefaultTestResultStrategy : ITestResultStrategy
|
| | | {
|
| | | public bool AppliesTo(SqlFunctionInfo functionInfo)
|
| | | {
|
| | | return true;
|
| | | }
|
| | |
|
| | | public string BuildInsertSql(SqlFunctionInfo functionInfo)
|
| | | {
|
| | | string functionCall = $"{functionInfo.Name}({functionInfo.InputStr})";
|
| | |
|
| | | string cast = !string.IsNullOrWhiteSpace(functionInfo.CastFunctionAs)
|
| | | ? $"CAST({functionCall} AS {functionInfo.CastFunctionAs})"
|
| | | : functionCall;
|
| | |
|
| | | string nullComparison =
|
| | | functionInfo.ExpectedResult == "= null"
|
| | | ? "IS NULL"
|
| | | : $"{cast} {functionInfo.ExpectedResult}";
|
| | |
|
| | | if (string.IsNullOrWhiteSpace(functionInfo.ExpectedResult))
|
| | | {
|
| | | nullComparison = "IS NOT NULL";
|
| | | }
|
| | |
|
| | | string sqlCode =
|
| | | $@"INSERT INTO automated_test_results (FEATURE, TEST_NAME, RESULT)
|
| | | VALUES ('{functionInfo.FeatureName}', '{functionInfo.TestName}', {nullComparison})
|
| | | RETURNING id;";
|
| | |
|
| | | return sqlCode;
|
| | | }
|
| | | }
|
| | |
|
| | | // public class CteTestResultStrategy : ITestResultStrategy
|
| | | // {
|
| | | // public bool AppliesTo(SqlFunctionInfo functionInfo)
|
| | | // {
|
| | | // // This strategy applies if a CTE statement is defined
|
| | | // return !string.IsNullOrWhiteSpace(functionInfo.CteStatement);
|
| | | // }
|
| | |
|
| | | // public string BuildInsertSql(SqlFunctionInfo functionInfo)
|
| | | // {
|
| | | // // Use the provided CTE statement directly in the SQL command construction
|
| | | // string sqlCode =
|
| | | // $@"
|
| | | // {functionInfo.CteStatement}
|
| | | // INSERT INTO automated_test_results (FEATURE, TEST_NAME, RESULT)
|
| | | // SELECT '{functionInfo.FeatureName}', '{functionInfo.TestName}', {functionInfo.CustomAssertion} FROM cte {functionInfo.QuerySuffix} RETURNING id;";
|
| | |
|
| | | // return sqlCode;
|
| | | // }
|
| | | // }
|
| | |
|
| | | // Defines a class CteTestResultStrategy that implements the ITestResultStrategy interface.
|
| | | public class CteTestResultStrategy : ITestResultStrategy
|
| | | {
|
| | | // Determines if the strategy applies to the given SQL function based on the presence of a CTE statement.
|
| | |
|
| | | public bool AppliesTo(SqlFunctionInfo functionInfo)
|
| | | {
|
| | | // Returns true if the CteStatement property of functionInfo is not null or whitespace, indicating
|
| | | // this strategy should be used for functions with CTEs.
|
| | | return !string.IsNullOrWhiteSpace(functionInfo.CteStatement);
|
| | | }
|
| | |
|
| | | // Builds an SQL INSERT statement using the information provided in the SqlFunctionInfo parameter.
|
| | | public string BuildInsertSql(SqlFunctionInfo functionInfo)
|
| | | {
|
| | | // Extracts the name of the CTE from its SQL statement to use in the final query.
|
| | | string cteName = ExtractCteName(functionInfo.CteStatement)!;
|
| | |
|
| | | // Constructs an SQL statement that includes the CTE statement and an INSERT INTO operation.
|
| | | // The INSERT operation adds a new row into the automated_test_results table with details from the functionInfo parameter
|
| | | // and selects values from the CTE defined earlier, applying any specified query suffix. Finally, it returns the id of the inserted row.
|
| | | string sqlCode =
|
| | | $@"
|
| | | {functionInfo.CteStatement}
|
| | | INSERT INTO automated_test_results (FEATURE, TEST_NAME, RESULT)
|
| | | SELECT '{functionInfo.FeatureName}', '{functionInfo.TestName}', {functionInfo.CustomAssertion} FROM {cteName} {functionInfo.QuerySuffix} RETURNING id;";
|
| | |
|
| | | // Returns the constructed SQL code.
|
| | | return sqlCode;
|
| | | }
|
| | |
|
| | | // A private helper method to extract the name of the CTE from its SQL statement.
|
| | | private string? ExtractCteName(string cteStatement)
|
| | | {
|
| | | // Uses a regular expression to find the CTE name in the CTE statement by looking for the pattern
|
| | | // that follows "WITH" and precedes "AS". Assumes the CTE name is a single word (\w+).
|
| | | var match = System.Text.RegularExpressions.Regex.Match(
|
| | | cteStatement,
|
| | | @"WITH\s+(\w+)\s+AS"
|
| | | );
|
| | | // If the pattern is found, the CTE name is returned.
|
| | | if (match.Success)
|
| | | {
|
| | | return match.Groups[1].Value;
|
| | | }
|
| | | // If the pattern is not found, returns null indicating no CTE name could be extracted.
|
| | | return null;
|
| | | }
|
| | | }
|
| | |
|
| | | // public class CteTestResultStrategy : ITestResultStrategy
|
| | | // {
|
| | | // public bool AppliesTo(SqlFunctionInfo functionInfo)
|
| | | // {
|
| | | // // This strategy applies if a CTE statement is defined and not empty.
|
| | | // return !string.IsNullOrWhiteSpace(functionInfo.CteStatement);
|
| | | // }
|
| | |
|
| | | // public string BuildInsertSql(SqlFunctionInfo functionInfo)
|
| | | // {
|
| | | // // Directly prepend the CTE statement to the SQL command
|
| | | // string sqlCode =
|
| | | // $@"
|
| | | // {functionInfo.cteStatement}
|
| | | // INSERT INTO automated_test_results (FEATURE, TEST_NAME, RESULT)
|
| | | // SELECT '{functionInfo.FeatureName}', '{functionInfo.TestName}', {functionInfo.CustomAssertion} RETURNING id;";
|
| | |
|
| | | // return sqlCode;
|
| | | // }
|
| | | // }
|
| | |
|
| | | public class JsonOrXmlTestResultStrategy : ITestResultStrategy
|
| | | {
|
| | | public bool AppliesTo(SqlFunctionInfo functionInfo)
|
| | | {
|
| | | return (
|
| | | functionInfo.ReturnType != null
|
| | | && (
|
| | | functionInfo.ReturnType.IndexOf("JSON", StringComparison.OrdinalIgnoreCase)
|
| | | >= 0
|
| | | || functionInfo.ReturnType.IndexOf(
|
| | | "XML",
|
| | | StringComparison.OrdinalIgnoreCase
|
| | | ) >= 0
|
| | | )
|
| | | )
|
| | | || (
|
| | | functionInfo.ExpectedResult != null
|
| | | && functionInfo.ExpectedResult.IndexOf(
|
| | | "::JSON::TEXT",
|
| | | StringComparison.OrdinalIgnoreCase
|
| | | ) >= 0
|
| | | );
|
| | | }
|
| | |
|
| | | public string BuildInsertSql(SqlFunctionInfo functionInfo)
|
| | | {
|
| | | string functionCall = $"{functionInfo.Name}({functionInfo.InputStr})::TEXT";
|
| | | string expectedResult = functionInfo.ExpectedResult + "::TEXT";
|
| | |
|
| | | string sqlCode =
|
| | | $@" INSERT INTO automated_test_results (FEATURE, TEST_NAME, RESULT)
|
| | | VALUES ('{functionInfo.FeatureName}', '{functionInfo.TestName}', {functionCall} {expectedResult})
|
| | | RETURNING id;";
|
| | | return sqlCode;
|
| | | }
|
| | | }
|
| | |
|
| | | public class TestResultStrategyFactory
|
| | | {
|
| | | private static readonly List<ITestResultStrategy> Strategies = new List<ITestResultStrategy>
|
| | | {
|
| | | new CteTestResultStrategy(),
|
| | | new JsonOrXmlTestResultStrategy(),
|
| | | new DefaultTestResultStrategy()
|
| | | };
|
| | |
|
| | | public static ITestResultStrategy GetStrategy(
|
| | | SqlFunctionInfo functionInfo,
|
| | | bool forceCte = false
|
| | | )
|
| | | {
|
| | | if (forceCte)
|
| | | {
|
| | | return Strategies[0];
|
| | | }
|
| | | return Strategies.FirstOrDefault(strategy => strategy.AppliesTo(functionInfo))
|
| | | ?? new DefaultTestResultStrategy();
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// Executes the provided SQL command that is expected to return an integer ID.
|
| | | /// This is typically used with SQL INSERT commands that use the RETURNING clause
|
| | | /// to return the ID of the newly inserted row.
|
| | | /// </summary>
|
| | | /// <param name="sqlCode">The SQL code to execute.</param>
|
| | | /// <returns>The retrieved integer ID if the command executed successfully and returned a value,
|
| | | /// null otherwise.</returns>
|
| | | protected int? ExecuteSqlReturnId(string sqlCode)
|
| | | {
|
| | | StringBuilder messages = new StringBuilder();
|
| | | Exception exception = null!;
|
| | |
|
| | | try
|
| | | {
|
| | | using var connection = new NpgsqlConnection(DatabaseConnectionString);
|
| | | connection.Open();
|
| | | connection.Notice += (sender, e) => |
| | | { |
| | | messages.AppendLine($"{e.Notice.MessageText}"); |
| | | }; |
| | | using var command = new NpgsqlCommand(sqlCode, connection); |
| | | command.CommandType = CommandType.Text; |
| | | using var reader = command.ExecuteReader(); |
| | | if (reader.Read()) |
| | | { |
| | | return reader.GetInt32(0); |
| | | } |
| | | return null; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | exception = ex; |
| | | return null; |
| | | } |
| | | finally |
| | | { |
| | | LogTestExecutionDetails(exception, messages); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Fetches the test result for the given function info based on its test ID. |
| | | /// </summary> |
| | | /// <param name="functionInfo">Information about the test whose result is to be fetched.</param> |
| | | /// <returns>The test result if found; null otherwise.</returns> |
| | | public bool? FetchTestResult(SqlFunctionInfo functionInfo) |
| | | { |
| | | if (!functionInfo.TestId.HasValue) |
| | | { |
| | | // Console.WriteLine("TestId is not set."); |
| | | return null; |
| | | } |
| | | |
| | | string sqlSelect = |
| | | $@" |
| | | SELECT RESULT |
| | | FROM automated_test_results |
| | | WHERE id = {functionInfo.TestId.Value};"; |
| | | |
| | | object? result = ExecuteSql(sqlSelect); |
| | | |
| | | if (result is bool booleanResult) |
| | | { |
| | | return booleanResult; |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Logs the execution details of a test, including any exception and SQL messages. |
| | | /// </summary> |
| | | /// <param name="exception">The exception that occurred during the test execution.</param> |
| | | /// <param name="elogMessages">The SQL messages generated during the test execution.</param> |
| | | protected void LogTestExecutionDetails(Exception exception, StringBuilder elogMessages) |
| | | { |
| | | if (elogMessages.Length > 0 || exception != null) |
| | | { |
| | | Console.WriteLine($"[START SQL EXECUTION DETAILS - TEST {TestCount}]"); |
| | | if (exception != null) |
| | | { |
| | | Console.WriteLine($"SQL Error:\n{exception.Message}"); |
| | | } |
| | | if (elogMessages.Length > 0) |
| | | { |
| | | Console.WriteLine($"SQL Messages:\n{elogMessages.ToString().Trim()}"); |
| | | } |
| | | Console.WriteLine($"[END SQL EXECUTION DETAILS - TEST {TestCount}]"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Executes the provided SQL command. |
| | | /// It returns true for successful execution |
| | | /// and false for failures. |
| | | /// </summary> |
| | | /// <param name="sqlCode">The SQL code to execute.</param> |
| | | /// <returns>It returns true for successful execution, |
| | | /// and false otherwise.</returns> |
| | | protected bool ExecuteSql(string sqlCode) |
| | | { |
| | | StringBuilder messages = new StringBuilder(); |
| | | Exception exception = null!; |
| | | |
| | | try |
| | | { |
| | | using var connection = new NpgsqlConnection(DatabaseConnectionString); |
| | | connection.Open(); |
| | | {
|
| | | messages.AppendLine($"{e.Notice.MessageText}");
|
| | | };
|
| | | using var command = new NpgsqlCommand(sqlCode, connection);
|
| | | command.CommandType = CommandType.Text;
|
| | | using var reader = command.ExecuteReader();
|
| | | if (reader.Read())
|
| | | {
|
| | | return reader.GetInt32(0);
|
| | | }
|
| | | return null;
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | exception = ex;
|
| | | return null;
|
| | | }
|
| | | finally
|
| | | {
|
| | | LogTestExecutionDetails(exception, messages);
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// Fetches the test result for the given function info based on its test ID.
|
| | | /// </summary>
|
| | | /// <param name="functionInfo">Information about the test whose result is to be fetched.</param>
|
| | | /// <returns>The test result if found; null otherwise.</returns>
|
| | | public bool? FetchTestResult(SqlFunctionInfo functionInfo)
|
| | | {
|
| | | if (!functionInfo.TestId.HasValue)
|
| | | {
|
| | | // Console.WriteLine("TestId is not set.");
|
| | | return null;
|
| | | }
|
| | |
|
| | | string sqlSelect =
|
| | | $@"
|
| | | SELECT RESULT
|
| | | FROM automated_test_results
|
| | | WHERE id = {functionInfo.TestId.Value};";
|
| | |
|
| | | object? result = ExecuteSql(sqlSelect);
|
| | |
|
| | | if (result is bool booleanResult)
|
| | | {
|
| | | return booleanResult;
|
| | | }
|
| | |
|
| | | return null;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// Logs the execution details of a test, including any exception and SQL messages.
|
| | | /// </summary>
|
| | | /// <param name="exception">The exception that occurred during the test execution.</param>
|
| | | /// <param name="elogMessages">The SQL messages generated during the test execution.</param>
|
| | | protected void LogTestExecutionDetails(Exception exception, StringBuilder elogMessages)
|
| | | {
|
| | | if (elogMessages.Length > 0 || exception != null)
|
| | | {
|
| | | Console.WriteLine($"[START SQL EXECUTION DETAILS - TEST {TestCount}]");
|
| | | if (exception != null)
|
| | | {
|
| | | Console.WriteLine($"SQL Error:\n{exception.Message}");
|
| | | }
|
| | | if (elogMessages.Length > 0)
|
| | | {
|
| | | Console.WriteLine($"SQL Messages:\n{elogMessages.ToString().Trim()}");
|
| | | }
|
| | | Console.WriteLine($"[END SQL EXECUTION DETAILS - TEST {TestCount}]");
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// Executes the provided SQL command.
|
| | | /// It returns true for successful execution
|
| | | /// and false for failures.
|
| | | /// </summary>
|
| | | /// <param name="sqlCode">The SQL code to execute.</param>
|
| | | /// <returns>It returns true for successful execution,
|
| | | /// and false otherwise.</returns>
|
| | | protected bool ExecuteSql(string sqlCode)
|
| | | {
|
| | | StringBuilder messages = new StringBuilder();
|
| | | Exception exception = null!;
|
| | |
|
| | | try
|
| | | {
|
| | | using var connection = new NpgsqlConnection(DatabaseConnectionString);
|
| | | connection.Open();
|
| | | connection.Notice += (sender, e) => |
| | | { |
| | | messages.AppendLine($"{e.Notice.MessageText}"); |
| | | }; |
| | | |
| | | using var command = new NpgsqlCommand(sqlCode, connection); |
| | | // command.CommandType = CommandType.Text; |
| | | if (sqlCode.TrimStart().StartsWith("SELECT", StringComparison.OrdinalIgnoreCase)) |
| | | { |
| | | using var reader = command.ExecuteReader(); |
| | | if (reader.Read()) |
| | | { |
| | | object value = reader.GetValue(0); |
| | | if (value is bool booleanValue) |
| | | { |
| | | return booleanValue; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | command.ExecuteNonQuery(); |
| | | return true; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | exception = ex; |
| | | return false; |
| | | } |
| | | finally |
| | | { |
| | | LogTestExecutionDetails(exception, messages); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Executes a generic test for the provided SQL function, logs the test result, and asserts the success of each step. |
| | | /// <para>This method performs the following actions and validations:</para> |
| | | /// <para>1. Sets up the function information based on the provided parameters.</para> |
| | | /// <para>2. Attempts to define the function in the database.</para> |
| | | /// <para>3. Validates (via assertion) that the function was successfully created.</para> |
| | | /// <para>4. Inserts the test result for the defined function into the database.</para> |
| | | /// <para>5. Validates (via assertion) that the test result was successfully inserted.</para> |
| | | /// <para>6. Fetches the test result from the database.</para> |
| | | /// <para>7. Validates (via assertion) that a test result was retrieved.</para> |
| | | /// <para>8. Validates (via assertion) that the retrieved test result matches the expected result.</para> |
| | | /// </summary> |
| | | /// <param name="functionName">Name of the SQL function to test.</param> |
| | | /// <param name="featureName">Feature associated with the test.</param> |
| | | /// <param name="input">Input string for the SQL function.</param> |
| | | /// <param name="expectedResult">Expected result string for the SQL function.</param> |
| | | public void RunGenericTest( |
| | | string featureName, |
| | | string testName, |
| | | string input, |
| | | string expectedResult |
| | | ) |
| | | { |
| | | RunTest( |
| | | featureName: featureName, |
| | | testName: testName, |
| | | input: input, |
| | | expectedResult: expectedResult |
| | | ); |
| | | } |
| | | |
| | | public void RunTestWithSuffix( |
| | | string featureName, |
| | | string testName, |
| | | string cteStatement, |
| | | string customAssertion, |
| | | string querySuffix = null!, |
| | | bool forceCte = false |
| | | ) |
| | | { |
| | | RunTest( |
| | | featureName: featureName, |
| | | testName: testName, |
| | | cteStatement: cteStatement, |
| | | customAssertion: customAssertion, |
| | | querySuffix: querySuffix, |
| | | forceCte: forceCte |
| | | ); |
| | | } |
| | | |
| | | public void RunTest( |
| | | string featureName, |
| | | string testName, |
| | | string input = "", |
| | | string expectedResult = "", |
| | | string cteStatement = "", |
| | | string customAssertion = "", |
| | | string querySuffix = "", |
| | | bool forceCte = false |
| | | ) |
| | | { |
| | | TestCount++; |
| | | Console.WriteLine( |
| | | $"[START TEST {TestCount}] Running test {testName} for feature {featureName}." |
| | | ); |
| | | |
| | | if (FunctionInfo == null) |
| | | { |
| | | Assert.Fail("FunctionInfo is null, test cannot proceed."); |
| | | return; |
| | | } |
| | | |
| | | // Set up the FunctionInfo object with the provided parameters |
| | | FunctionInfo.TestName = testName; |
| | | FunctionInfo.FeatureName = featureName; |
| | | FunctionInfo.InputStr = input; |
| | | FunctionInfo.ExpectedResult = expectedResult; |
| | | FunctionInfo.CteStatement = cteStatement; // Updated to use the full CTE statement |
| | | FunctionInfo.CustomAssertion = customAssertion; |
| | | FunctionInfo.QuerySuffix = querySuffix; |
| | | |
| | | // Combine pieces of FunctionInfo to create SQL codes |
| | | FunctionInfo.SqlFunctionDefinition = GetFunctionDefinition(FunctionInfo); |
| | | FunctionInfo.SqlFunctionCall = GetFunctionCall(FunctionInfo, forceCte); |
| | | Console.WriteLine( |
| | | $"[START SQL FUNCTION - TEST {TestCount}]\n```sql\n{FunctionInfo.SqlFunctionDefinition}\n```\n[END SQL FUNCTION - TEST {TestCount}]\n" |
| | | ); |
| | | Console.WriteLine( |
| | | $"[START SQL CALL FUNCTION - TEST {TestCount}]\n```sql\n{FunctionInfo.SqlFunctionCall}\n```\n[END SQL CALL FUNCTION - TEST {TestCount}]" |
| | | ); |
| | | |
| | | // Create the function in the PostgreSQL database |
| | | FunctionInfo.FunctionCreatedSuccessfully = ExecuteSql(FunctionInfo.SqlFunctionDefinition); |
| | | Assert.True( |
| | | FunctionInfo.FunctionCreatedSuccessfully, |
| | | $"[COMPILATION ERROR] Test {TestCount} failed to create function in the PostgreSQL database." |
| | | ); |
| | | |
| | | if (FunctionInfo.TestType == SqlTestType.Procedure) |
| | | { |
| | | bool? procedureResult = ExecuteSql(FunctionInfo.SqlFunctionCall); |
| | | Assert.True( |
| | | procedureResult.HasValue && procedureResult.Value, |
| | | $"[EXECUTION ERROR] Test {TestCount} failed to execute procedure test." |
| | | ); |
| | | Console.WriteLine($"[END TEST {TestCount}] Test {testName} executed successfully.\n"); |
| | | return; |
| | | } |
| | | |
| | | // Call test and insert the test result into the PostgreSQL table |
| | | FunctionInfo.TestId = ExecuteSqlReturnId(FunctionInfo.SqlFunctionCall); |
| | | |
| | | Assert.True( |
| | | FunctionInfo.TestId.HasValue, |
| | | $"[EXECUTION ERROR] Test {TestCount} failed to execute test and insert test result into table." |
| | | ); |
| | | |
| | | // Fetch the test result from the PostgreSQL table and validate it |
| | | bool? testResult = FetchTestResult(FunctionInfo); |
| | | Assert.True( |
| | | testResult.HasValue, |
| | | $"[UNEXPECTED ERROR] Test {TestCount} failed to get the test result value." |
| | | ); |
| | | Assert.True( |
| | | testResult.Value, |
| | | $"[ASSERTION ERROR] Test {TestCount} returned unexpected result." |
| | | ); |
| | | |
| | | Console.WriteLine($"[END TEST {TestCount}] Test {testName} executed successfully.\n"); |
| | | } |
| | | } |
| | | {
|
| | | messages.AppendLine($"{e.Notice.MessageText}");
|
| | | };
|
| | |
|
| | | using var command = new NpgsqlCommand(sqlCode, connection);
|
| | | // command.CommandType = CommandType.Text;
|
| | | if (sqlCode.TrimStart().StartsWith("SELECT", StringComparison.OrdinalIgnoreCase))
|
| | | {
|
| | | using var reader = command.ExecuteReader();
|
| | | if (reader.Read())
|
| | | {
|
| | | object value = reader.GetValue(0);
|
| | | if (value is bool booleanValue)
|
| | | {
|
| | | return booleanValue;
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | | else
|
| | | {
|
| | | command.ExecuteNonQuery();
|
| | | return true;
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | exception = ex;
|
| | | return false;
|
| | | }
|
| | | finally
|
| | | {
|
| | | LogTestExecutionDetails(exception, messages);
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// Executes a generic test for the provided SQL function, logs the test result, and asserts the success of each step.
|
| | | /// <para>This method performs the following actions and validations:</para>
|
| | | /// <para>1. Sets up the function information based on the provided parameters.</para>
|
| | | /// <para>2. Attempts to define the function in the database.</para>
|
| | | /// <para>3. Validates (via assertion) that the function was successfully created.</para>
|
| | | /// <para>4. Inserts the test result for the defined function into the database.</para>
|
| | | /// <para>5. Validates (via assertion) that the test result was successfully inserted.</para>
|
| | | /// <para>6. Fetches the test result from the database.</para>
|
| | | /// <para>7. Validates (via assertion) that a test result was retrieved.</para>
|
| | | /// <para>8. Validates (via assertion) that the retrieved test result matches the expected result.</para>
|
| | | /// </summary>
|
| | | /// <param name="functionName">Name of the SQL function to test.</param>
|
| | | /// <param name="featureName">Feature associated with the test.</param>
|
| | | /// <param name="input">Input string for the SQL function.</param>
|
| | | /// <param name="expectedResult">Expected result string for the SQL function.</param>
|
| | | public void RunGenericTest(
|
| | | string featureName,
|
| | | string testName,
|
| | | string input,
|
| | | string expectedResult
|
| | | )
|
| | | {
|
| | | RunTest(
|
| | | featureName: featureName,
|
| | | testName: testName,
|
| | | input: input,
|
| | | expectedResult: expectedResult
|
| | | );
|
| | | }
|
| | |
|
| | | public void RunTestWithSuffix(
|
| | | string featureName,
|
| | | string testName,
|
| | | string cteStatement,
|
| | | string customAssertion,
|
| | | string querySuffix = null!,
|
| | | bool forceCte = false
|
| | | )
|
| | | {
|
| | | RunTest(
|
| | | featureName: featureName,
|
| | | testName: testName,
|
| | | cteStatement: cteStatement,
|
| | | customAssertion: customAssertion,
|
| | | querySuffix: querySuffix,
|
| | | forceCte: forceCte
|
| | | );
|
| | | }
|
| | |
|
| | | public void RunTest(
|
| | | string featureName,
|
| | | string testName,
|
| | | string input = "",
|
| | | string expectedResult = "",
|
| | | string cteStatement = "",
|
| | | string customAssertion = "",
|
| | | string querySuffix = "",
|
| | | bool forceCte = false
|
| | | )
|
| | | {
|
| | | TestCount++;
|
| | | Console.WriteLine(
|
| | | $"[START TEST {TestCount}] Running test {testName} for feature {featureName}."
|
| | | );
|
| | |
|
| | | if (FunctionInfo == null)
|
| | | {
|
| | | Assert.Fail("FunctionInfo is null, test cannot proceed.");
|
| | | return;
|
| | | }
|
| | |
|
| | | // Set up the FunctionInfo object with the provided parameters
|
| | | FunctionInfo.TestName = testName;
|
| | | FunctionInfo.FeatureName = featureName;
|
| | | FunctionInfo.InputStr = input;
|
| | | FunctionInfo.ExpectedResult = expectedResult;
|
| | | FunctionInfo.CteStatement = cteStatement; // Updated to use the full CTE statement
|
| | | FunctionInfo.CustomAssertion = customAssertion;
|
| | | FunctionInfo.QuerySuffix = querySuffix;
|
| | |
|
| | | // Combine pieces of FunctionInfo to create SQL codes
|
| | | FunctionInfo.SqlFunctionDefinition = GetFunctionDefinition(FunctionInfo);
|
| | | FunctionInfo.SqlFunctionCall = GetFunctionCall(FunctionInfo, forceCte);
|
| | | Console.WriteLine(
|
| | | $"[START SQL FUNCTION - TEST {TestCount}]\n```sql\n{FunctionInfo.SqlFunctionDefinition}\n```\n[END SQL FUNCTION - TEST {TestCount}]\n"
|
| | | );
|
| | | Console.WriteLine(
|
| | | $"[START SQL CALL FUNCTION - TEST {TestCount}]\n```sql\n{FunctionInfo.SqlFunctionCall}\n```\n[END SQL CALL FUNCTION - TEST {TestCount}]"
|
| | | );
|
| | |
|
| | | // Create the function in the PostgreSQL database
|
| | | FunctionInfo.FunctionCreatedSuccessfully = ExecuteSql(FunctionInfo.SqlFunctionDefinition);
|
| | | Assert.True(
|
| | | FunctionInfo.FunctionCreatedSuccessfully,
|
| | | $"[COMPILATION ERROR] Test {TestCount} failed to create function in the PostgreSQL database."
|
| | | );
|
| | |
|
| | | if (FunctionInfo.TestType == SqlTestType.Procedure)
|
| | | {
|
| | | bool? procedureResult = ExecuteSql(FunctionInfo.SqlFunctionCall);
|
| | | Assert.True(
|
| | | procedureResult.HasValue && procedureResult.Value,
|
| | | $"[EXECUTION ERROR] Test {TestCount} failed to execute procedure test."
|
| | | );
|
| | | Console.WriteLine($"[END TEST {TestCount}] Test {testName} executed successfully.\n");
|
| | | return;
|
| | | }
|
| | |
|
| | | // Call test and insert the test result into the PostgreSQL table
|
| | | FunctionInfo.TestId = ExecuteSqlReturnId(FunctionInfo.SqlFunctionCall);
|
| | |
|
| | | Assert.True(
|
| | | FunctionInfo.TestId.HasValue,
|
| | | $"[EXECUTION ERROR] Test {TestCount} failed to execute test and insert test result into table."
|
| | | );
|
| | |
|
| | | // Fetch the test result from the PostgreSQL table and validate it
|
| | | bool? testResult = FetchTestResult(FunctionInfo);
|
| | | Assert.True(
|
| | | testResult.HasValue,
|
| | | $"[UNEXPECTED ERROR] Test {TestCount} failed to get the test result value."
|
| | | );
|
| | | Assert.True(
|
| | | testResult.Value,
|
| | | $"[ASSERTION ERROR] Test {TestCount} returned unexpected result."
|
| | | );
|
| | |
|
| | | Console.WriteLine($"[END TEST {TestCount}] Test {testName} executed successfully.\n");
|
| | | }
|
| | | }
|
| | |
| | | <Project Sdk="Microsoft.NET.Sdk"> |
| | | |
| | | <PropertyGroup> |
| | | <TargetFramework>$(TargetFramework)</TargetFramework> |
| | | <ImplicitUsings>enable</ImplicitUsings> |
| | | <Nullable>enable</Nullable> |
| | | |
| | | <IsPackable>false</IsPackable> |
| | | </PropertyGroup> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="DotNetEnv" Version="3.1.1" /> |
| | | <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" /> |
| | | <PackageReference Include="Npgsql" Version="9.0.3" /> |
| | | <PackageReference Include="xunit" Version="2.9.3" /> |
| | | <PackageReference Include="xunit.runner.visualstudio" Version="3.1.1"> |
| | | <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
| | | <PrivateAssets>all</PrivateAssets> |
| | | </PackageReference> |
| | | <PackageReference Include="coverlet.collector" Version="6.0.4"> |
| | | <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
| | | <PrivateAssets>all</PrivateAssets> |
| | | </PackageReference> |
| | | </ItemGroup> |
| | | |
| | | </Project> |
| | | <Project Sdk="Microsoft.NET.Sdk">
|
| | |
|
| | | <PropertyGroup>
|
| | | <TargetFramework>$(TargetFramework)</TargetFramework>
|
| | | <ImplicitUsings>enable</ImplicitUsings>
|
| | | <Nullable>enable</Nullable>
|
| | |
|
| | | <IsPackable>false</IsPackable>
|
| | | </PropertyGroup>
|
| | |
|
| | | <ItemGroup>
|
| | | <PackageReference Include="DotNetEnv" Version="3.1.1" />
|
| | | <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
| | | <PackageReference Include="Npgsql" Version="9.0.3" />
|
| | | <PackageReference Include="xunit" Version="2.9.3" />
|
| | | <PackageReference Include="xunit.runner.visualstudio" Version="3.1.1">
|
| | | <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
| | | <PrivateAssets>all</PrivateAssets>
|
| | | </PackageReference>
|
| | | <PackageReference Include="coverlet.collector" Version="6.0.4">
|
| | | <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
| | | <PrivateAssets>all</PrivateAssets>
|
| | | </PackageReference>
|
| | | </ItemGroup>
|
| | |
|
| | | </Project>
|
| | |
| | | unknwn |
| | | nin |
| | | msdos |
| | | Koordinates |
| | | Pease |
| | |
| | | 2026-02-09 Regina Obe <lr@pcorp.us> |
| | | 2025-11-13 Paul Ramsey <pramsey@cleverelephant.ca> |
| | | |
| | | * doc/release_notes.xml: Fix missing </para> |
| | | * .gitignore, NEWS, README.postgis, Version.config, |
| | | doc/release_notes.xml, extensions/upgradeable_versions.mk: Prepare |
| | | for 3.6.1 release |
| | | |
| | | 2026-02-09 Regina Obe <lr@pcorp.us> |
| | | 2025-11-12 Regina Obe <lr@pcorp.us> |
| | | |
| | | * NEWS, README.postgis, Version.config, doc/release_notes.xml, |
| | | extensions/upgradeable_versions.mk: Prep for PostGIS 3.6.2 release |
| | | * NEWS, doc/extras_topology.xml, topology/Makefile.in, |
| | | topology/sql/manage/FixCorruptTopoGeometryColumn.sql.in, |
| | | topology/test/regress/fix_topogeometry_columns.sql, |
| | | topology/test/regress/fix_topogeometry_columns_expected, |
| | | topology/test/regress/hooks/hook-after-upgrade-topology.sql, |
| | | topology/test/tests.mk, topology/topology.sql.in: |
| | | topology.FixCorruptTopoGeometryColumn to fix corruption caused by |
| | | 3.6.0 upgrade - Add function - Add tests - Add docs - Add NEWS References #5983 for PostGIS 3.6.1 |
| | | |
| | | 2026-02-09 Regina Obe <lr@pcorp.us> |
| | | 2025-11-10 Regina Obe <lr@pcorp.us> |
| | | |
| | | * .cirrus.yml: FIXES TO CIRRUS CI - Get rid of $NCPU and put in a 2 instead and lower the ram. |
| | | References #6047 for PostGIS 3.6.2 - Change FreeBSD to 14.3, 14.2 is no longer available |
| | | |
| | | 2026-02-09 Regina Obe <lr@pcorp.us> |
| | | |
| | | * extensions/postgis_extension_helper.sql.in, |
| | | extensions/postgis_extension_helper_uninstall.sql, |
| | | * NEWS, doc/installation.xml, |
| | | extensions/postgis_tiger_geocoder/Makefile.in, |
| | | extensions/postgis_tiger_geocoder/sql_bits/remove_from_extension.sq |
| | | l.in, extensions/postgis_topology/Makefile.in, |
| | | extensions/postgis_topology/sql_bits/remove_from_extension.sql.in: |
| | | Remove postgis_extension_remove_objects Closes #5853 for PostGIS |
| | | 3.6.2 Fix postgis_tiger_geocoder upgrade for PostgreSQL < 16 Closes #6032 |
| | | for PostGIS 3.6.2 |
| | | extras/tiger_geocoder/tiger_loader_2025.sql: Revise |
| | | postgis_tiger_geocoder to use tiger 2025 data Closes #6013 for |
| | | PostGIS 3.6.1 |
| | | |
| | | 2026-02-02 Maksim Korotkov <m.korotkov@postgrespro.ru> |
| | | 2025-11-07 Paul Ramsey <pramsey@cleverelephant.ca> |
| | | |
| | | * postgis/flatgeobuf.c: Fix memory allocation size for arrays in |
| | | flatgeobuf_decode_row The original code incorrectly allocated memory |
| | | for pointers instead of the actual types, potentially causing buffer |
| | | overflows or memory corruption since it was allocating insufficient |
| | | memory (size of pointer instead of size of Datum/bool). Found by PostgesPro. Fixes: 3ae2c5844 ("FlatGeobuf format |
| | | input/output") Signed-off-by: Maksim Korotkov |
| | | <m.korotkov@postgrespro.ru> |
| | | * NEWS: News entry for #6012 |
| | | |
| | | 2026-01-27 Paul Ramsey <pramsey@cleverelephant.ca> |
| | | 2025-11-07 Paul Ramsey <pramsey@cleverelephant.ca> |
| | | |
| | | * postgis/gserialized_typmod.c: Fix mixed declarations mistake |
| | | * liblwgeom/lwcircstring.c: fix memory leak, references #6012 |
| | | |
| | | 2026-01-27 bdreiss <bd_reiss@gmx.at> |
| | | 2025-11-07 Darafei Praliaskouski <me@komzpa.net> |
| | | |
| | | * postgis/gserialized_typmod.c: The geodetic flag was queried after |
| | | gser has been freed ################################################### BUG REPORT |
| | | ################################################## ### DESCRITPION ### The geodetic flag was queried after gser has been freed in line 143, |
| | | leading to a use-after-free bug. This means the behaviour is |
| | | undefined and it is not clear, which branch will be taken (and |
| | | therefor, whether geometry or geography is returned). Below you find |
| | | the output from gdb can be seen, that confirms that a) the point is |
| | | indeed inserted with the wrong flag and b) also after selecting the |
| | | point from the table remains unset. Issues when using SQL could not |
| | | be produced. ### SETUP IN PG ### CREATE EXTENSION postgis; CREATE TABLE test_geog (id SERIAL PRIMARY |
| | | KEY, geog geography(POINT, 4326)); INSERT INTO test_geog (geog) |
| | | VALUES (ST_GeogFromText('SRID=4326;POINT(-77.0092 38.889588)')); ### GDB OUPUT AND STEPS TO REPRODUCE ### postgres@localhost:~$ gdb --args /usr/local/pgsql/bin/postgres |
| | | --single -D $PGDATA postgres (gdb) break gserialized_typmod.c:143 (gdb) break gserialized_typmod.c:150 (gdb) break geography_out (gdb) run backend> INSERT INTO test_geog (geog) VALUES |
| | | (ST_GeogFromText('SRID=4326;MULTIPOINT EMPTY')); Breakpoint 1, |
| | | postgis_valid_typmod (gser=0x58f991a3f378, typmod=1107460) at |
| | | gserialized_typmod.c:143 143 gserialized_typmod.c: No such file |
| | | or directory. (gdb) call gserialized_is_geodetic(gser) $1 = 1 (gdb) c Continuing. Breakpoint 2, postgis_valid_typmod (gser=0x58f991a8e150, |
| | | typmod=1107460) at gserialized_typmod.c:151 151 in |
| | | gserialized_typmod.c (gdb) call gserialized_is_geodetic(gser) $2 = 0 (gdb) c Continuing. backend> backend> INSERT INTO test_geog (geog) |
| | | VALUES (ST_GeogFromText('SRID=4326;POINT(-77.0092 38.889588)')); Breakpoint 2, postgis_valid_typmod (gser=0x58f991a3dca8, |
| | | typmod=1107460) at gserialized_typmod.c:151 151 in |
| | | gserialized_typmod.c (gdb) call gserialized_is_geodetic(gser) $4 = 1 (gdb) c Continuing. backend> backend> select geog from test_geog |
| | | where id=1; 1: geog (typeid = 14296, len = -1, typmod = 1107460, byval = |
| | | f) ---- Breakpoint 3, geography_out (fcinfo=0x7ffe871b40e0) at |
| | | /usr/local/pgsql/include/server/postgres.h:319 319 |
| | | return (Pointer) X; (gdb) set $gser = (GSERIALIZED *) pg_detoast_datum((void *) |
| | | fcinfo->args[0].value) (gdb) call gserialized_is_geodetic($gser) $7 = 0 (gdb) c Continuing. 1: geog = |
| | | "0101000020E6100000000000000000F87F000000000000F87F" |
| | | (typeid = 14296, len = -1, typmod = 1107460, byval = f) ---- |
| | | backend> select geog from test_geog where id=2; 1: geog (typeid = 14296, len = -1, typmod = 1107460, |
| | | byval = f) ---- Breakpoint 3, geography_out (fcinfo=0x7ffe871b40e0) at |
| | | /usr/local/pgsql/include/server/postgres.h:319 319 |
| | | return (Pointer) X; (gdb) set $gser = (GSERIALIZED *) pg_detoast_datum((void *) |
| | | fcinfo->args[0].value) (gdb) call gserialized_is_geodetic($gser) $8 = 1 (gdb) c Continuing. 1: geog = |
| | | "0101000020E6100000E3C798BB964053C000750305DE714340" |
| | | (typeid = 14296, len = -1, typmod = 1107460, byval = f) ---- |
| | | backend> ### INFO ### postgres=# SELECT version(); version |
| | | * NEWS: Touch up NEWS Closes #5984 |
| | | |
| | | --------------------------------------------------------------------------------------------------- PostgreSQL 18.1 on x86_64-pc-linux-gnu, compiled by gcc (Debian |
| | | 12.2.0-14+deb12u1) 12.2.0, 64-bit (1 row) postgres=# SELECT postgis_full_version(); |
| | | postgis_full_version |
| | | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| | | --------------------------------------------------------------------------------------------------------------------------------------------------------------- POSTGIS="3.6.1 f533623" [EXTENSION] PGSQL="180" |
| | | GEOS="3.11.1-CAPI-1.17.1" PROJ="9.1.1 NETWORK_ENABLED=OFF |
| | | URL_ENDPOINT=https://cdn.proj.org |
| | | USER_WRITABLE_DIRECTORY=/home/postgres/.loc al/share/proj |
| | | DATABASE_PATH=/usr/share/proj/proj.db" (compiled against PROJ 9.1.1) |
| | | LIBXML="2.9.14" LIBJSON="0.16" LIBPROTOBUF="1.4.1" WAGYU="0.5.0 |
| | | (Internal)" (1 row) COMPILE FLAGS USED: CC=clang ./configure --with-pgconfig=/usr/bin/pg_config CFLAGS="-O0 |
| | | -g -fsanitize=address -fno-omit-frame-pointer" |
| | | LDFLAGS="-fsanitize=address" |
| | | ############################################################################################################### |
| | | 2025-10-30 Darafei Praliaskouski <me@komzpa.net> |
| | | |
| | | 2026-01-26 Maksim Korotkov <m.korotkov@postgrespro.ru> |
| | | * postgis/cunit/cu_tester.c, postgis/gserialized_estimate.c, |
| | | postgis/gserialized_estimate_support.h: Guard against histogram axis |
| | | dimension underflow References #5959 References #5984 |
| | | |
| | | * postgis/geography_centroid.c: Replace check for avoiding NULL |
| | | dereference Fixes: 9726c4770 ("missed file commit for ST_Centroid Geography |
| | | support references #2951") Signed-off-by: Maksim Korotkov <m.korotkov@postgrespro.ru> |
| | | 2025-10-30 Darafei Praliaskouski <me@komzpa.net> |
| | | |
| | | 2026-01-20 Paul Ramsey <pramsey@cleverelephant.ca> |
| | | * NEWS, configure.ac, postgis/cunit/Makefile.in, |
| | | postgis/cunit/cu_tester.c, postgis/gserialized_estimate.c, |
| | | postgis/gserialized_estimate_support.h: Prevent histogram target |
| | | overflow when analysing massive tables Add CUnit tests for overflow scenarios Closes #5959 |
| | | |
| | | * NEWS: News item for 680639af5 |
| | | 2025-10-15 Paul Ramsey <pramsey@cleverelephant.ca> |
| | | |
| | | 2026-01-20 Maksim Korotkov <m.korotkov@postgrespro.ru> |
| | | * NEWS, postgis/postgis.sql.in: ST_ForcePolygonCCW should not flip |
| | | lines, closes #5754 |
| | | |
| | | * extensions/address_standardizer/standard.c: Avoid potential NULL |
| | | dereference in std_free() After check against NULL the pointer std |
| | | -> pagc_p was used unsafely. Found by PostgresPro with Svace Static Analyzer. Fixes: c6091a4bb |
| | | 2025-10-09 Regina Obe <lr@pcorp.us> |
| | | |
| | | * NEWS: Add credits. References #5998 for PostGIS 3.6.1 |
| | | |
| | | 2025-10-07 Regina Obe <lr@pcorp.us> |
| | | |
| | | * extras/tiger_geocoder/geocode_settings.sql, |
| | | extras/tiger_geocoder/pagc_normalize/pagc_tables.sql, |
| | | extras/tiger_geocoder/tiger_loader_2012.sql, |
| | | extras/tiger_geocoder/tiger_loader_2013.sql, |
| | | extras/tiger_geocoder/tiger_loader_2014.sql, |
| | | extras/tiger_geocoder/tiger_loader_2015.sql, |
| | | extras/tiger_geocoder/tiger_loader_2016.sql, |
| | | extras/tiger_geocoder/tiger_loader_2017.sql, |
| | | extras/tiger_geocoder/tiger_loader_2018.sql, |
| | | extras/tiger_geocoder/tiger_loader_2019.sql, |
| | | extras/tiger_geocoder/tiger_loader_2020.sql, |
| | | extras/tiger_geocoder/tiger_loader_2021.sql, |
| | | extras/tiger_geocoder/tiger_loader_2022.sql, |
| | | extras/tiger_geocoder/tiger_loader_2023.sql, |
| | | extras/tiger_geocoder/tiger_loader_2024.sql: TIGER EXTENSION |
| | | SECURITY fix - Ensure tables are created by tiger extension and bale if not. Patch provided by Andrey Borodin (Yandex) - Don't create tiger_data as that gets created on first load of |
| | | data and shouldn't be part of the extension References #5998 for PostGIS 3.6.1 |
| | | |
| | | 2025-10-09 Regina Obe <lr@pcorp.us> |
| | | |
| | | * ci/winnie/package_postgis.sh, ci/winnie/regress_postgis.sh, |
| | | ci/winnie/winnie_common.sh: Cleanup winnie ci building |
| | | |
| | | 2025-10-08 Paul Ramsey <pramsey@cleverelephant.ca> |
| | | |
| | | * liblwgeom/measures.c, liblwgeom/measures.h: Avoid possible null |
| | | pointer dereference. Closes #6000 |
| | | |
| | | 2025-10-08 Paul Ramsey <pramsey@cleverelephant.ca> |
| | | |
| | | * postgis/lwgeom_transform.c: Add in headers for Pg19 build |
| | | |
| | | 2025-09-24 Nikolai B <nikolai-b@users.noreply.github.com> |
| | | |
| | | * doc/introduction.xml, doc/reference_overlay.xml: doc(St_Subdivide) |
| | | mention potential changes in geography Closes |
| | | https://github.com/postgis/postgis/pull/831 for PostGIS 3.6.1 Patch provided by Nikolai Berkoff |
| | | |
| | | 2025-10-07 Maksim Korotkov <m.korotkov@postgrespro.ru> |
| | | |
| | | * extensions/address_standardizer/standard.c: address_standardizer: |
| | | fixed memory leak The memory was not released in case of error |
| | | handling. Found by PostgresPro with Svace static analyzer Fixes: c6091a4bb |
| | | ("Prep to move address_standardizer into extensions folder") |
| | | Signed-off-by: Maksim Korotkov <m.korotkov@postgrespro.ru> |
| | | |
| | | 2026-01-16 Loïc Bartoletti <loic.bartoletti@oslandia.com> |
| | | 2025-10-07 Paul Ramsey <pramsey@cleverelephant.ca> |
| | | |
| | | * sfcgal/regress/sfcgal_v2.sql, sfcgal/regress/sfcgal_v2_expected: |
| | | test(sfcgal): Fix Buffer3D tests against SFCGAL 2.3.0 SFCGAL 2.3.0 improves sphere generation using icosahedron algorithm |
| | | to avoid float issue. The geometry is slightly different and test |
| | | must be adapted accordingly. |
| | | * doc/reference_coverage.xml: Fix definition of ST_CoverageClean |
| | | parameter order |
| | | |
| | | 2026-01-14 Sandro Santilli <strk@kbt.io> |
| | | 2025-10-06 Paul Ramsey <pramsey@cleverelephant.ca> |
| | | |
| | | * .codespell.ignore: Add surnames to spellcheck ignore list |
| | | * NEWS, postgis/lwgeom_geos.c: Consistent clipping of MULTI/POINT |
| | | (Paul Ramsey) References #5962 |
| | | |
| | | 2026-01-14 Sandro Santilli <strk@kbt.io> |
| | | 2025-10-06 Paul Ramsey <pramsey@cleverelephant.ca> |
| | | |
| | | * liblwgeom/lwalgorithm.c: Stop using a tolerance for point-same |
| | | functions References #6023 in 3.6 branch (3.6.2dev) This is partially reverting 80eefad13bd00d1e56d2bec36cd5140f87775ce4 |
| | | * liblwgeom/cunit/cu_measures.c, liblwgeom/lwalgorithm.c: Fix |
| | | raycast for linestrings, references #5989 |
| | | |
| | | 2026-01-13 Sandro Santilli <strk@kbt.io> |
| | | 2025-10-03 Paul Ramsey <pramsey@cleverelephant.ca> |
| | | |
| | | * NEWS: Add missing NEWS item |
| | | |
| | | 2026-01-13 Sandro Santilli <strk@kbt.io> |
| | | |
| | | * liblwgeom/cunit/cu_ptarray.c, liblwgeom/ptarray.c: Fix robustness |
| | | issue in ptarray_contains_point References #6023 in 3.6 branch (3.6.2dev) Includes unit test |
| | | |
| | | 2025-12-22 Sandro Santilli <strk@kbt.io> |
| | | |
| | | * NEWS, doc/developer.md: Fix some spelling typos |
| | | |
| | | 2025-12-22 Sandro Santilli <strk@kbt.io> |
| | | |
| | | * NEWS, topology/sql/cleanup/RemoveUnusedPrimitives.sql.in, |
| | | topology/test/regress/removeunusedprimitives.sql: Fix |
| | | RemoveUnusedPrimitives without "topology" in search_path Includes regression test. References #6027 in stable-3.6 branch (3.6.2dev) |
| | | |
| | | 2025-12-15 Paul Ramsey <pramsey@cleverelephant.ca> |
| | | |
| | | * NEWS, liblwgeom/cunit/cu_gserialized2.c, |
| | | liblwgeom/gserialized2.c, liblwgeom/lwin_wkb.c: Convert |
| | | POLYGON(EMPTY) a polygon with an empty ring into POLYGON EMPTY a |
| | | polygon with no rings, in the WKB input routine. Handle any existing |
| | | POLYGON(EMPTY) in the gserialized_is_empty routine. References #6028 |
| | | |
| | | 2025-11-30 Regina Obe <lr@pcorp.us> |
| | | |
| | | * .drone-1.0.yml, .woodpecker/regress.yml: Get rid of drone and |
| | | refine wood-pecker to include removed drone items |
| | | |
| | | 2025-11-19 Paul Ramsey <pramsey@cleverelephant.ca> |
| | | |
| | | * schema qualify call in ST_MPointFromText, references #6020 |
| | | |
| | | * Restore history to NEWS file |
| | |
| | | |
| | | PostGIS 3.6.2 |
| | | 2026/02/09 |
| | | |
| | | This version requires PostgreSQL 12-18, GEOS 3.8 or higher, and Proj 6.1+. |
| | | To take advantage of all features, GEOS 3.14+ is needed. |
| | | To take advantage of all SFCGAL features, SFCGAL 2.2+ is needed. |
| | | |
| | | If you are upgrading postgis_topology from a version before 3.6.1 and |
| | | have topogeometry columns, make sure to run after the upgrade to fix |
| | | topogeometry corruption: |
| | | |
| | | SELECT topology.FixCorruptTopoGeometryColumn( |
| | | schema_name, table_name, feature_column |
| | | ) FROM topology.layer; |
| | | |
| | | * Fixes * |
| | | |
| | | - #6023, Fix robustness issue in ptarray_contains_point (Sandro Santilli) |
| | | - #6027, Fix RemoveUnusedPrimitives without topology in search_path |
| | | (Sandro Santilli) |
| | | - #6019, make clean does not remove cunit generated files |
| | | (Bas Couwenberg) |
| | | - #6020, schema qualify call in ST_MPointFromText (Paul Ramsey) |
| | | - #6028, crash indexing malformed empty polygon (Paul Ramsey) |
| | | - GH-841, small memory leak in address_standardizer (Maxim Korotkov) |
| | | - #5853, Issue with topology and tiger geocoder upgrade scripts |
| | | (Regina Obe, Spencer Bryson) |
| | | - #6032, Fix postgis_tiger_geocoder upgrade for PostgreSQL < 16 |
| | | (Regina Obe) |
| | | |
| | | |
| | | PostGIS 3.6.1 |
| | | 2025/11/13 |
| | | |
| | |
| | | |
| | | This version requires PostgreSQL 12-16, GEOS 3.6 or higher, and Proj 6.1+. |
| | | To take advantage of all features, GEOS 3.12+ is needed. |
| | | To take advantage of all SFCGAL features, SFCGAL 1.4.1+ is needed. |
| | | To take advantage of all SFCGAL featurs, SFCGAL 1.4.1+ is needed. |
| | | |
| | | Many thanks to our translation teams, in particular: |
| | | |
| | |
| | | we have decided to disable the feature by default |
| | | until we get more user testing |
| | | as to the true impact of real-world queries. |
| | | If you are running PG14+, you can re-enable it by doing |
| | | If you are running PG14+, you can reenable it by doing |
| | | |
| | | ALTER OPERATOR FAMILY gist_geometry_ops_2d USING gist |
| | | ADD FUNCTION 11 (geometry) |
| | |
| | | - #4710, ST_ClusterKMeans now works with 3D geometries (Darafei Praliaskouski) |
| | | - #4801, ST_ClusterKMeans supports weights in POINT[Z]M geometries |
| | | (Darafei Praliaskouski) |
| | | - #4805, _ST_SortableHash exposed to work around parallel sorting performance issue |
| | | - #4805, _ST_SortableHash exposed to work around parallel soring performance issue |
| | | in Postgres. If your table is huge, use ORDER BY _ST_SortableHash(geom) |
| | | instead of ORDER BY geom to make parallel sort faster (Darafei Praliaskouski) |
| | | - #4625, Correlation statistics now calculated. |
| | |
| | | - #4789, Sped up TopoJSON output for areal TopoGeometry with |
| | | many holes (Sandro Santilli) |
| | | - #4758, Improved topology noding robustness (Sandro Santilli) |
| | | - Make ST_Subdivide interruptible (Sandro Santilli) |
| | | - Make ST_Subdivide interruptable (Sandro Santilli) |
| | | - #4660, Changes in double / coordinate printing (Raúl Marín) |
| | | - Use the shortest representation (enough to guarantee roundtrip). |
| | | - Uses scientific notation for absolute numbers smaller than 1e-8. |
| | |
| | | and postgis.backend switch (Darafei Praliaskouski) |
| | | - #4267, Enable Proj 6 deprecated APIs (Darafei Praliaskouski, Raúl Marín) |
| | | - #4268, Bump minimum SFCGAL version to 1.3.1 (Darafei Praliaskouski) |
| | | - #4331, ST_3DMakeBox now returns error instead of a minuscule box (Regina Obe) |
| | | - #4331, ST_3DMakeBox now returns error instead of a miniscule box (Regina Obe) |
| | | - #4342, Removed "versioned" variants of ST_AsGeoJSON and ST_AsKML (Paul Ramsey) |
| | | - #4356, ST_Accum removed. Use array_agg instead. (Darafei Praliaskouski) |
| | | - #4414, Include version number in address_standardizer lib (Raúl Marín) |
| | |
| | | - #2026, ST_Union(raster) now unions all bands of all rasters |
| | | - #2089, liblwgeom: lwgeom_set_handlers replaces lwgeom_init_allocators. |
| | | - #2150, regular_blocking is no longer a constraint. column of same name |
| | | in raster_columns now checks for existence of spatially_unique |
| | | in raster_columns now checks for existance of spatially_unique |
| | | and coverage_tile constraints |
| | | - ST_Intersects(raster, geometry) behaves in the same manner as |
| | | ST_Intersects(geometry, raster). |
| | |
| | | - #2302, ST_Roughness for raster (Nathaniel Clay) |
| | | - #2290, ST_ColorMap(raster) to generate RGBA bands |
| | | - #2254, Add SFCGAL backend support. |
| | | (Backend selection through postgis.backend var) |
| | | Functions available both through GEOS or SFCGAL: |
| | | (Backend selection throught postgis.backend var) |
| | | Functions available both throught GEOS or SFCGAL: |
| | | ST_Intersects, ST_3DIntersects, ST_Intersection, ST_Area, |
| | | ST_Distance, ST_3DDistance |
| | | New functions available only with SFCGAL backend: |
| | |
| | | (eg CREATE TABLE t (g GEOMETRY(Polgyon, 4326))) |
| | | - ST_AsBinary and ST_AsText now return 3D/4D results in ISO SQL/MM |
| | | format when called on 3D/4D features. |
| | | - The "unknown SRID" is now 0, not -1. |
| | | - The "unknonwn SRID" is now 0, not -1. |
| | | (eg ST_SRID(ST_GeomFromText('POINT(0 0)')) returns 0) |
| | | - ST_NumGeometries returns 1 for singletons. ST_GeometryN returns the |
| | | the geometry for singletons. |
| | |
| | | |
| | | PostGIS 1.3.0 |
| | | 2007/08/09 |
| | | - Began migration of functions to the SQL-MM-centric naming convention |
| | | - Began migration of functions to the SQL-MM-centric naming convension |
| | | using the spatial type (SP) prefix |
| | | - Performance enhancements: |
| | | - Created cached and indexed point-in-polygon short-circuits |
| | |
| | | PostGIS 1.1.2 |
| | | 2006/03/30 |
| | | |
| | | - Regress tests can now be run *before* postgis installation |
| | | - Regress tests can now be run *before* postgis intallation |
| | | - BUGFIX in SnapToGrid() computation of output bounding box |
| | | - More portable ./configure script |
| | | - Changed ./run_test script to have more sane default behaviour |
| | |
| | | |
| | | - Bug fixes: |
| | | - Fixed memory leak in polygonize() |
| | | - Fixed bug in lwgeom_as_anytype cast functions |
| | | - Fixed bug in lwgeom_as_anytype cast funcions |
| | | - Fixed USE_GEOS, USE_PROJ and USE_STATS elements |
| | | of postgis_version() output to always reflect |
| | | library state. |
| | |
| | | - Changed Z() function to return NULL if requested |
| | | dimension is not available |
| | | |
| | | - Performance improvements: |
| | | - Peformance improvements: |
| | | - Much faster transform() function, caching proj4 objects |
| | | - Removed automatic call to fix_geometry_columns() in |
| | | AddGeometryColumns() and update_geometry_stats() |
| | |
| | | - NEW -p flag for shp2pgsql |
| | | - BUGFIX in transform() releasing random memory address |
| | | - BUGFIX in force_3dm() allocating less memory then required |
| | | - NEW chapter about OGC compliance enforcement |
| | | - NEW chapter about OGC compliancy enforcement |
| | | - BUGFIX in shp2pgsql escape of values starting with "'" or "\t" |
| | | - NEW autoconf support for JTS lib |
| | | - BUGFIX in estimator testers (support for LWGEOM and schema parsing) |
| | |
| | | - jdbc2: code cleanups, Makefile improvements |
| | | - FLEX & YACC variables set *after* pgsql Makefile.global |
| | | is included and only if the pgsql *stripped* version |
| | | evaluates to the empty string |
| | | evaulates to the empty string |
| | | - added already generated parser in release |
| | | - build scripts refinements |
| | | - MultiLine handling BUG fix in loader and dumper |
| | |
| | | - Objects are all now "lightweight" with a smaller disk |
| | | and index representation. Large databases should see a moderate |
| | | to large performance increase. |
| | | - Objects now have a hexadecimal canonical representation. |
| | | - Objects now have a hexidecimal canonical representation. |
| | | To see a "user friendly" version of the objects use the |
| | | AsText() function. |
| | | - The loader and dumper use the hexadecimal canonical representation, |
| | | - The loader and dumper use the hexidecimal canonical representation, |
| | | so coordinate drift due to floating point string parsing is now |
| | | eliminated. |
| | | - New functions: UpdateGeometrySRID(), AsGML(), SnapToGrid(), |
| | |
| | | - xmin(),ymin(),zmin(),xmax(),ymax(),zmax() functions |
| | | - Bug Fixes |
| | | - transform() more graceful when grid shifts are missing |
| | | - setsrid() made cacheable |
| | | - setsrid() made cachable |
| | | - patches to loader/dumper |
| | | |
| | | |
| | |
| | | - truely_inside() |
| | | - rtree index support functions |
| | | - gist index support functions |
| | | |
| | | |
| | |
| | | PostGIS - Geographic Information Systems Extensions to PostgreSQL |
| | | ================================================================= |
| | | |
| | | :Version: 3.6.2 |
| | | :Date: 2026-02-09 |
| | | :Version: 3.6.1 |
| | | :Date: 2025-11-13 |
| | | :Website: https://postgis.net |
| | | |
| | | This distribution contains a module which implements GIS simple features, ties |
| | |
| | | |
| | | POSTGIS_MAJOR_VERSION=3 |
| | | POSTGIS_MINOR_VERSION=6 |
| | | POSTGIS_MICRO_VERSION=2 |
| | | POSTGIS_MICRO_VERSION=1 |
| | | |
| | | # Liblwgeom interface versioning, reset to 0:0:0 (cur:age:rev) |
| | | # when changing POSTGIS_MINOR_VERSION |
| | |
| | | # Revision of current interface, set to 0 when adding an interface |
| | | # or increment when just changing implementations. |
| | | LIBLWGEOM_IFACE_REV=0 |
| | | |
| | |
| | | |
| | | dnl Extract the linker and include flags |
| | | LIBGDAL_LDFLAGS=`$GDAL_CONFIG --libs` |
| | | dnl LIBGDAL_DEPLIBS_LDFLAGS=`$GDAL_CONFIG --dep-libs` |
| | | LIBGDAL_DEPLIBS_LDFLAGS=`$GDAL_CONFIG --dep-libs` |
| | | LIBGDAL_CFLAGS=`$GDAL_CONFIG --cflags` |
| | | |
| | | CPPFLAGS_SAVE="$CPPFLAGS" |
| | |
| | | fi |
| | | |
| | | LIBS_SAVE="$LIBS" |
| | | LIBS="$LIBGDAL_LDFLAGS" |
| | | LIBS="$LIBGDAL_LDFLAGS $LIBGDAL_DEPLIBS_LDFLAGS" |
| | | |
| | | dnl Check headers file |
| | | AC_CHECK_HEADERS( |
| | | [gdal.h ogr_api.h cpl_conv.h], |
| | | [gdal/gdal.h gdal/ogr_api.h gdal/cpl_conv.h], # <<<diasoft #BUILD_UPDATE>>> |
| | | [], |
| | | [AC_MSG_ERROR([could not find GDAL headers])]) |
| | | |
| | | dnl Ensure we can link against gdal |
| | | AC_SEARCH_LIBS([GDALAllRegister], [gdal], [], [AC_MSG_ERROR([could not find GDAL])], []) |
| | | |
| | | LIBS="$LIBGDAL_LDFLAGS" |
| | | LIBS="$LIBGDAL_LDFLAGS $LIBGDAL_DEPLIBS_LDFLAGS" |
| | | |
| | | dnl Ensure we can link against ogr |
| | | AC_SEARCH_LIBS([OGRRegisterAll], [gdal], [], [AC_MSG_ERROR([could not find OGR])], []) |
| | | |
| | | LIBS="$LIBGDAL_LDFLAGS" |
| | | LIBS="$LIBGDAL_LDFLAGS $LIBGDAL_DEPLIBS_LDFLAGS" |
| | | CPPFLAGS="$CPPFLAGS_SAVE" |
| | | CFLAGS="$CFLAGS_SAVE" |
| | | CC="$CC_SAVE" |
| | |
| | | const T *data(const std::vector<T, Alloc> &v) { |
| | | // Eventually the returned pointer gets passed down to memcpy, so |
| | | // we need it to be non-null to avoid undefined behavior. |
| | | alignas(T) static uint8_t t; |
| | | |
| | | alignas(T) static uint8_t t; /*#<<<DIA_SVACE_MAJOR>>>*/ |
| | | return v.empty() ? reinterpret_cast<const T *>(&t) : &v.front(); |
| | | } |
| | | template<typename T, typename Alloc = std::allocator<T>> |
| | | T *data(std::vector<T, Alloc> &v) { |
| | | // Eventually the returned pointer gets passed down to memcpy, so |
| | | // we need it to be non-null to avoid undefined behavior. |
| | | alignas(T) static uint8_t t; |
| | | |
| | | alignas(T) static uint8_t t; /*#<<<DIA_SVACE_MAJOR>>*/ |
| | | return v.empty() ? reinterpret_cast<T *>(&t) : &v.front(); |
| | | } |
| | | |
| New file |
| | |
| | | postgis version: 3.6.1 |
| | | plpgsql_check_url: https://gitea.osgeo.org/postgis/postgis/src/tag/3.6.1 |
| | | |
| | | # Теги |
| | | -- #BUILD_UPDATE - доработки для сборки в рамках Q.Database |
| | | -- #DIA_LOCALLE_FIX - исправление локализации. Список языков для перевода в LINGUAS синхронизирован с doc/Makefile.in |
| | |
| | | # that we could produce a large number of files (think chunked HTML) |
| | | # |
| | | |
| | | translations = it_IT pt_BR fr es pl ka ko_KR da de ja ru zh_Hans ro sv |
| | | translations = it_IT pt_BR fr es pl ka ko_KR da de ja ru zh_Hans ro sv uk |
| | | |
| | | PACKAGE_TARNAME = @PACKAGE_TARNAME@ |
| | | |
| | |
| | | with a dependency library higher than X? Where X is some version of a dependency library. |
| | | |
| | | Dependency guards need to be put in both the C library files and our test files. |
| | | On some occasions where we need to do something different based on version of PostgreSQL, |
| | | On some occassions where we need to do something different based on version of PostgreSQL, |
| | | you'll see guards in the SQL files as well. |
| | | |
| | | We have guards in place in the code to handle these for dependency libraries |
| | |
| | | but instead of doing something functional, will output an error that the extension needs to be compiled |
| | | with lib xxx or higher. Also the function has to be available in the C lib, as such the guarding is always done |
| | | on the C lib side and very rarely on the sql files. |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| New file |
| | |
| | | it_IT pt_BR fr es pl ka ko_KR da de ja ru zh_Hans ro sv uk # #DIA_LOCALLE_FIX |
| New file |
| | |
| | | include @srcdir@/../Makefile.local |
| | | DBLATEX_EXTRA_OPTIONS = -b xetex |
| | | DOCSUFFIX=-uk |
| | | srcdir=@srcdir@ |
| | |
| | | <appendix xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="release_notes"> |
| | | <title>Appendix</title> |
| | | <subtitle>Release Notes</subtitle> |
| | | <section> |
| | | <title>PostGIS 3.6.2</title> |
| | | <para>2026/02/09</para> |
| | | |
| | | <para>If you are upgrading postgis_topology and have topogeometry columns, make sure to run after the upgrade to fix topogeometry corruption: <code>SELECT topology.FixCorruptTopoGeometryColumn(schema_name, table_name, feature_column) FROM topology.layer</code></para> |
| | | |
| | | <simplesect> |
| | | <title>Fixes</title> |
| | | <para><link xlink:href="https://trac.osgeo.org/postgis/ticket/6023">6023</link>, Fix robustness issue in ptarray_contains_point (Sandro Santilli)</para> |
| | | <para><link xlink:href="https://trac.osgeo.org/postgis/ticket/6027">6027</link>, Fix RemoveUnusedPrimitives without topology in search_path |
| | | (Sandro Santilli)</para> |
| | | <para><link xlink:href="https://trac.osgeo.org/postgis/ticket/6019">6019</link>, make clean does not remove cunit generated files |
| | | (Bas Couwenberg)</para> |
| | | <para><link xlink:href="https://trac.osgeo.org/postgis/ticket/6020">6020</link>, schema qualify call in ST_MPointFromText (Paul Ramsey)</para> |
| | | <para><link xlink:href="https://trac.osgeo.org/postgis/ticket/6028">6028</link>, crash indexing malformed empty polygon (Paul Ramsey)</para> |
| | | <para><link xlink:href="https://github.com/postgis/postgis/pull/841">GH-841</link>, small memory leak in address_standardizer (Maxim Korotkov)</para> |
| | | <para><link xlink:href="https://trac.osgeo.org/postgis/ticket/5853">5853</link>, Issue with topology and tiger geocoder upgrade scripts |
| | | (Regina Obe, Spencer Bryson)</para> |
| | | <para><link xlink:href="https://trac.osgeo.org/postgis/ticket/6032">6032</link>, Fix postgis_tiger_geocoder upgrade for PostgreSQL < 16 |
| | | (Regina Obe)</para> |
| | | </simplesect> |
| | | </section> |
| | | <section> |
| | | <title>PostGIS 3.6.1</title> |
| | | <para>2025/11/13</para> |
| | |
| | | s[uj] = s[ui]; |
| | | uj++; |
| | | } |
| | | if (uj > 0 && isspace(s[uj-1])) uj--; |
| | | s[uj] = '\0'; |
| | | if (uj > 0 && isspace(s[uj-1])) uj--; /*#<<<DIA_SVACE_MAJOR>>>*/ |
| | | s[uj] = '\0'; |
| | | |
| | | /* clean trailing punctuation */ |
| | | (void)clean_trailing_punct(s); |
| | |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | /*#<<<DIA_SVACE_CRITICAL*/ |
| | | void std_free(STANDARDIZER *std) |
| | | { |
| | | if (std == NULL) |
| | |
| | | DBG("Calling free"); |
| | | free(std); |
| | | } |
| | | /*#DIA_SVACE_CRITICAL>>>*/ |
| | | |
| | | |
| | | void stdaddr_free(STDADDR *stdaddr) |
| | |
| | | for (i=0; i<STD_CACHE_ITEMS; i++) { |
| | | StdCacheItem *ci = &STDCache->StdCache[i]; |
| | | if (ci->lextab && !strcmp(ci->lextab, lextab) && |
| | | !strcmp(ci->gaztab, gaztab) && |
| | | !strcmp(ci->rultab, rultab)) |
| | | ci->gaztab && !strcmp(ci->gaztab, gaztab) && |
| | | ci->rultab && !strcmp(ci->rultab, rultab)) |
| | | return STDCache->StdCache[i].std; |
| | | } |
| | | |
| | |
| | | -- This is a suite of SQL helper functions for use during a PostGIS extension install/upgrade |
| | | -- The functions get uninstalled after the extension install/upgrade process |
| | | --------------------------- |
| | | -- postgis_extension_remove_objects: This function removes objects of a particular class from an extension |
| | | -- this is needed because there is no ALTER EXTENSION DROP FUNCTION/AGGREGATE command |
| | | -- and we can't CREATE OR REPLACE functions whose signatures have changed and we can drop them if they are part of an extension |
| | | -- So we use this to remove it from extension first before we drop |
| | | CREATE FUNCTION postgis_extension_remove_objects(param_extension text, param_type text) |
| | | RETURNS boolean AS |
| | | $$ |
| | | DECLARE |
| | | var_sql text := ''; |
| | | var_r record; |
| | | var_result boolean := false; |
| | | var_class text := ''; |
| | | var_is_aggregate boolean := false; |
| | | var_sql_list text := ''; |
| | | var_pgsql_version integer := pg_catalog.current_setting('server_version_num'); |
| | | BEGIN |
| | | var_class := CASE WHEN pg_catalog.lower(param_type) OPERATOR(pg_catalog.=)'function' OR pg_catalog.lower(param_type) OPERATOR(pg_catalog.=) 'aggregate' THEN 'pg_catalog.pg_proc' ELSE '' END; |
| | | var_is_aggregate := CASE WHEN pg_catalog.lower(param_type) OPERATOR(pg_catalog.=) 'aggregate' THEN true ELSE false END; |
| | | |
| | | IF var_pgsql_version OPERATOR(pg_catalog.<) 110000 THEN |
| | | var_sql_list := $sql$SELECT 'ALTER EXTENSION ' OPERATOR(pg_catalog.||) e.extname OPERATOR(pg_catalog.||) ' DROP ' OPERATOR(pg_catalog.||) $3 OPERATOR(pg_catalog.||) ' ' OPERATOR(pg_catalog.||) COALESCE(proc.proname OPERATOR(pg_catalog.||) '(' OPERATOR(pg_catalog.||) oidvectortypes(proc.proargtypes) OPERATOR(pg_catalog.||) ')' ,typ.typname, cd.relname, op.oprname, |
| | | cs.typname OPERATOR(pg_catalog.||) ' AS ' OPERATOR(pg_catalog.||) ct.typname OPERATOR(pg_catalog.||) ') ', opcname, opfname) OPERATOR(pg_catalog.||) ';' AS remove_command |
| | | FROM pg_catalog.pg_depend As d INNER JOIN pg_catalog.pg_extension As e |
| | | ON d.refobjid OPERATOR(pg_catalog.=) e.oid INNER JOIN pg_catalog.pg_class As c ON |
| | | c.oid OPERATOR(pg_catalog.=) d.classid |
| | | LEFT JOIN pg_catalog.pg_proc AS proc ON proc.oid OPERATOR(pg_catalog.=) d.objid |
| | | LEFT JOIN pg_catalog.pg_type AS typ ON typ.oid OPERATOR(pg_catalog.=) d.objid |
| | | LEFT JOIN pg_catalog.pg_class As cd ON cd.oid OPERATOR(pg_catalog.=) d.objid |
| | | LEFT JOIN pg_operator As op ON op.oid OPERATOR(pg_catalog.=) d.objid |
| | | LEFT JOIN pg_catalog.pg_cast AS ca ON ca.oid OPERATOR(pg_catalog.=) d.objid |
| | | LEFT JOIN pg_catalog.pg_type AS cs ON ca.castsource OPERATOR(pg_catalog.=) cs.oid |
| | | LEFT JOIN pg_catalog.pg_type AS ct ON ca.casttarget OPERATOR(pg_catalog.=) ct.oid |
| | | LEFT JOIN pg_opclass As oc ON oc.oid OPERATOR(pg_catalog.=) d.objid |
| | | LEFT JOIN pg_opfamily As ofa ON ofa.oid OPERATOR(pg_catalog.=) d.objid |
| | | WHERE d.deptype OPERATOR(pg_catalog.=) 'e' and e.extname OPERATOR(pg_catalog.=) $1 and c.relname OPERATOR(pg_catalog.=) $2 AND COALESCE(proc.proisagg, false) OPERATOR(pg_catalog.=) $4;$sql$; |
| | | ELSE -- for PostgreSQL 11 and above, they removed proc.proisagg among others and replaced with some func type thing |
| | | var_sql_list := $sql$SELECT 'ALTER EXTENSION ' OPERATOR(pg_catalog.||) e.extname OPERATOR(pg_catalog.||) ' DROP ' OPERATOR(pg_catalog.||) $3 OPERATOR(pg_catalog.||) ' ' OPERATOR(pg_catalog.||) COALESCE(proc.proname OPERATOR(pg_catalog.||) '(' OPERATOR(pg_catalog.||) oidvectortypes(proc.proargtypes) OPERATOR(pg_catalog.||) ')' ,typ.typname, cd.relname, op.oprname, |
| | | cs.typname OPERATOR(pg_catalog.||) ' AS ' OPERATOR(pg_catalog.||) ct.typname OPERATOR(pg_catalog.||) ') ', opcname, opfname) OPERATOR(pg_catalog.||) ';' AS remove_command |
| | | FROM pg_catalog.pg_depend As d INNER JOIN pg_catalog.pg_extension As e |
| | | ON d.refobjid OPERATOR(pg_catalog.=) e.oid INNER JOIN pg_catalog.pg_class As c ON |
| | | c.oid OPERATOR(pg_catalog.=) d.classid |
| | | LEFT JOIN pg_catalog.pg_proc AS proc ON proc.oid OPERATOR(pg_catalog.=) d.objid |
| | | LEFT JOIN pg_catalog.pg_type AS typ ON typ.oid OPERATOR(pg_catalog.=) d.objid |
| | | LEFT JOIN pg_catalog.pg_class As cd ON cd.oid OPERATOR(pg_catalog.=) d.objid |
| | | LEFT JOIN pg_operator As op ON op.oid OPERATOR(pg_catalog.=) d.objid |
| | | LEFT JOIN pg_catalog.pg_cast AS ca ON ca.oid OPERATOR(pg_catalog.=) d.objid |
| | | LEFT JOIN pg_catalog.pg_type AS cs ON ca.castsource OPERATOR(pg_catalog.=) cs.oid |
| | | LEFT JOIN pg_catalog.pg_type AS ct ON ca.casttarget OPERATOR(pg_catalog.=) ct.oid |
| | | LEFT JOIN pg_opclass As oc ON oc.oid OPERATOR(pg_catalog.=) d.objid |
| | | LEFT JOIN pg_opfamily As ofa ON ofa.oid OPERATOR(pg_catalog.=) d.objid |
| | | WHERE d.deptype OPERATOR(pg_catalog.=) 'e' and e.extname OPERATOR(pg_catalog.=) $1 and c.relname OPERATOR(pg_catalog.=) $2 AND (proc.prokind OPERATOR(pg_catalog.=) 'a') OPERATOR(pg_catalog.=) $4;$sql$; |
| | | END IF; |
| | | |
| | | FOR var_r IN EXECUTE var_sql_list USING param_extension, var_class, param_type, var_is_aggregate |
| | | LOOP |
| | | var_sql := var_sql OPERATOR(pg_catalog.||) var_r.remove_command OPERATOR(pg_catalog.||) ';'; |
| | | END LOOP; |
| | | IF var_sql > '' THEN |
| | | EXECUTE var_sql; |
| | | var_result := true; |
| | | END IF; |
| | | |
| | | RETURN var_result; |
| | | END; |
| | | $$ |
| | | LANGUAGE plpgsql VOLATILE; |
| | | |
| | | CREATE FUNCTION postgis_extension_drop_if_exists(param_extension text, param_statement text) |
| | | RETURNS boolean AS |
| | | $$ |
| | |
| | | -- |
| | | -- This drops extension helper functions |
| | | -- and should be called at the end of the extension upgrade file |
| | | DROP FUNCTION postgis_extension_remove_objects(text, text); |
| | | DROP FUNCTION postgis_extension_drop_if_exists(text, text); |
| | | DROP FUNCTION IF EXISTS postgis_extension_AddToSearchPath(varchar); |
| | | DROP FUNCTION IF EXISTS postgis_extension_AddToSearchPath(text); |
| | |
| | | |
| | | REGRESS = test-normalize_address test-upgrade |
| | | REGRESS_OPTS = --load-extension=fuzzystrmatch --load-extension=postgis --load-extension=$(EXTENSION) |
| | | EXTSCHEMA_SUPPORTED = yes |
| | | |
| | | ## PostgreSQL < 16 doesn't understand new @extschema:extname@ syntax, so strip it |
| | | ifeq ($(shell expr "$(POSTGIS_PGSQL_VERSION)" "<" 160),1) |
| | | EXTSCHEMA_SUPPORTED = no |
| | | endif |
| | | |
| | | SQL_BITS = $(wildcard sql_bits/*.sql) |
| | | EXTRA_CLEAN = sql expected ${SQL_BITS} |
| | |
| | | sql: |
| | | mkdir -p $@ |
| | | |
| | | ifeq ($(EXTSCHEMA_SUPPORTED),yes) |
| | | |
| | | ## PostgreSQL < 16 doesn't understand new @extschema:extname@ syntax, so strip it |
| | | ifeq ($(shell expr "$(POSTGIS_PGSQL_VERSION)" "<" 160),1) |
| | | sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).sql | sql |
| | | cp $< $@ |
| | | $(PERL) -lpe "s/\@extschema:[a-z]+\@\./ /g" < $< > $@ |
| | | else |
| | | # PG < 16 doesn't support new @extschema:<extension_name>@ |
| | | # so we need to strip those out |
| | | sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).sql | sql |
| | | $(PERL) -lpe "s/\@extschema:[^@]+\@\./ /g" < $< > $@ |
| | | sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).sql | sql |
| | | cp $< $@ |
| | | endif |
| | | |
| | | expected/test-normalize_address.out: sql_bits/test_tuples_only_unaligned.sql.in ../../extras/tiger_geocoder/regress/normalize_address_regress | expected |
| | |
| | | sql/test-upgrade.sql: | sql |
| | | echo 'ALTER EXTENSION ${EXTENSION} UPDATE TO "ANY"; ALTER EXTENSION ${EXTENSION} UPDATE TO "$(EXTVERSION)"' > $@ |
| | | |
| | | ## no_relocate clause is only available in PostgreSQL 16 and above, so strip it for lower |
| | | ifeq ($(EXTSCHEMA_SUPPORTED),yes) |
| | | ## no_relocate clause is only availabe in PostgreSQL 16 and above, so strip it for lower |
| | | ifeq ($(shell expr "$(POSTGIS_PGSQL_VERSION)" "<" 160),1) |
| | | %.control: %.control.in Makefile |
| | | $(PERL) -lpe 's/^no_relocate.*//g; s/\@EXTVERSION\@/$(EXTVERSION)/g' < "$<" > "$@" |
| | | else |
| | | %.control: %.control.in Makefile |
| | | $(PERL) -lpe "s'@EXTVERSION@'$(EXTVERSION)'g" \ |
| | | < "$<" > "$@" |
| | | else |
| | | %.control: %.control.in Makefile |
| | | $(PERL) -lpe 's/^no_relocate.*//g; s/\@EXTVERSION\@/$(EXTVERSION)/g' < "$<" > "$@" |
| | | endif |
| | | |
| | | expected/test-upgrade.out: sql/test-upgrade.sql | expected |
| | |
| | | | $(PERL) @top_srcdir@/utils/create_or_replace_to_create.pl sql/$(EXTENSION)_pre.sql \ |
| | | > $@ |
| | | |
| | | sql/$(EXTENSION)--ANY--$(EXTVERSION).sql: ../postgis_extension_helper.sql sql/tiger_geocoder_upgrade_minor.sql sql_bits/mark_editable_objects.sql.in | sql |
| | | sql/$(EXTENSION)--ANY--$(EXTVERSION).sql: ../postgis_extension_helper.sql sql_bits/remove_from_extension.sql.in sql/tiger_geocoder_upgrade_minor.sql sql_bits/mark_editable_objects.sql.in | sql |
| | | cat $^ > $@ |
| | | echo "SELECT postgis_extension_drop_if_exists('${EXTENSION}', 'DROP SCHEMA tiger_data');" >> $@ |
| | | cat @srcdir@/../postgis_extension_helper_uninstall.sql >> $@ |
| | |
| | | #aggregates are special |
| | | #they can be dropped but we need to remove |
| | | #them from the extension first |
| | | ifeq ($(EXTSCHEMA_SUPPORTED),yes) |
| | | sql/tiger_geocoder_upgrade_minor.sql: sql/tiger_geocoder_minor.sql.in | sql |
| | | $(PERL) -pe 's/BEGIN\;//g ; s/COMMIT\;//g' $< > $@ |
| | | else |
| | | sql/tiger_geocoder_upgrade_minor.sql: sql/tiger_geocoder_minor.sql.in | sql |
| | | $(PERL) -pe 's/BEGIN\;//g ; s/COMMIT\;//g ; s/\@extschema:[^@]+\@\.//g' $< > $@ |
| | | endif |
| | | |
| | | sed -e 's/BEGIN;//g' -e 's/COMMIT;//g' \ |
| | | $< > $@ |
| | | |
| | | #only extension files |
| | | EXTRA_CLEAN += $(wildcard expected/*--*.out) |
| New file |
| | |
| | | -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| | | -- |
| | | ---- |
| | | -- PostGIS - Spatial Types for PostgreSQL |
| | | -- http://postgis.net |
| | | -- |
| | | -- Copyright (C) 2011 Regina Obe <lr@pcorp.us> |
| | | -- |
| | | -- This is free software; you can redistribute and/or modify it under |
| | | -- the terms of the GNU General Public Licence. See the COPYING file. |
| | | -- |
| | | -- Author: Regina Obe <lr@pcorp.us> |
| | | -- |
| | | -- This drops extension helper functions |
| | | -- and should be called at the end of the extension upgrade file |
| | | -- removes all postgis_topology functions from postgis_topology extension since they will be read |
| | | -- during upgrade |
| | | SELECT postgis_extension_remove_objects('postgis_tiger_geocoder', 'FUNCTION'); |
| | | SELECT postgis_extension_remove_objects('postgis_tiger_geocoder', 'AGGREGATE'); |
| | |
| | | EXTENSION_UPGRADE_SCRIPTS = \ |
| | | extlock.sql \ |
| | | ../postgis_extension_helper.sql \ |
| | | sql_bits/remove_from_extension.sql.in \ |
| | | sql/topology_upgrade.sql \ |
| | | sql_bits/mark_editable_objects.sql.in \ |
| | | ../postgis_extension_helper_uninstall.sql |
| New file |
| | |
| | | -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| | | -- |
| | | ---- |
| | | -- PostGIS - Spatial Types for PostgreSQL |
| | | -- http://postgis.net |
| | | -- |
| | | -- Copyright (C) 2011 Regina Obe <lr@pcorp.us> |
| | | -- |
| | | -- This is free software; you can redistribute and/or modify it under |
| | | -- the terms of the GNU General Public Licence. See the COPYING file. |
| | | -- |
| | | -- Author: Regina Obe <lr@pcorp.us> |
| | | -- |
| | | -- This drops extension helper functions |
| | | -- and should be called at the end of the extension upgrade file |
| | | -- removes all postgis_topology functions from postgis_topology extension since they will be read |
| | | -- during upgrade |
| | | SELECT postgis_extension_remove_objects('postgis_topology', 'FUNCTION'); |
| | | SELECT postgis_extension_remove_objects('postgis_topology', 'AGGREGATE'); |
| | |
| | | 3.0.9 \ |
| | | 3.0.10 \ |
| | | 3.0.11 \ |
| | | 3.0.12 \ |
| | | 3.1.0 \ |
| | | 3.1.1 \ |
| | | 3.1.2 \ |
| | |
| | | 3.1.10 \ |
| | | 3.1.11 \ |
| | | 3.1.12 \ |
| | | 3.1.13 \ |
| | | 3.2.0 \ |
| | | 3.2.1 \ |
| | | 3.2.2 \ |
| | |
| | | 3.2.6 \ |
| | | 3.2.7 \ |
| | | 3.2.8 \ |
| | | 3.2.9 \ |
| | | 3.3.0 \ |
| | | 3.3.1 \ |
| | | 3.3.2 \ |
| | |
| | | 3.3.6 \ |
| | | 3.3.7 \ |
| | | 3.3.8 \ |
| | | 3.3.9 \ |
| | | 3.4.0 \ |
| | | 3.4.1 \ |
| | | 3.4.2 \ |
| | | 3.4.3 \ |
| | | 3.4.4 \ |
| | | 3.4.5 \ |
| | | 3.5.0 \ |
| | | 3.5.1 \ |
| | | 3.5.2 \ |
| | | 3.5.3 \ |
| | | 3.5.4 \ |
| | | 3.5.5 \ |
| | | 3.6.0 \ |
| | | 3.6.1 |
| | | 3.6.1dev |
| | |
| | | { |
| | | int i = 0; |
| | | struct gserialized_empty_cases { |
| | | int ishex; |
| | | const char* txt; |
| | | const char* wkt; |
| | | int isempty; |
| | | }; |
| | | |
| | | struct gserialized_empty_cases cases[] = { |
| | | { 0, "POINT EMPTY", 1 }, |
| | | { 0, "POINT(1 1)", 0 }, |
| | | { 0, "LINESTRING EMPTY", 1 }, |
| | | { 0, "MULTILINESTRING EMPTY", 1 }, |
| | | { 0, "MULTILINESTRING(EMPTY)", 1 }, |
| | | { 0, "MULTILINESTRING(EMPTY,EMPTY)", 1 }, |
| | | { 0, "MULTILINESTRING(EMPTY,(0 0,1 1))", 0 }, |
| | | { 0, "MULTILINESTRING((0 0,1 1),EMPTY)", 0 }, |
| | | { 0, "MULTILINESTRING(EMPTY,(0 0,1 1),EMPTY)", 0 }, |
| | | { 0, "MULTILINESTRING(EMPTY,EMPTY,EMPTY)", 1 }, |
| | | { 0, "MULTIPOLYGON (((9 9, 9 1, 1 1, 2 4, 7 7, 9 9)), EMPTY)", 0 }, |
| | | { 0, "GEOMETRYCOLLECTION(POINT EMPTY,MULTILINESTRING(EMPTY,EMPTY,EMPTY))", 1 }, |
| | | { 0, "GEOMETRYCOLLECTION(POINT EMPTY,MULTILINESTRING(EMPTY),POINT(1 1))", 0 }, |
| | | { 0, "GEOMETRYCOLLECTION(POINT EMPTY,MULTILINESTRING(EMPTY, (0 0)),POINT EMPTY)", 0 }, |
| | | { 0, "GEOMETRYCOLLECTION(POLYGON EMPTY,POINT EMPTY,MULTILINESTRING(EMPTY,EMPTY),POINT EMPTY)", 1 }, |
| | | { 0, "GEOMETRYCOLLECTION(POLYGON EMPTY,GEOMETRYCOLLECTION(POINT EMPTY),MULTILINESTRING(EMPTY,EMPTY),POINT EMPTY)", 1 }, |
| | | { 1, "0101000000000000000000F87F000000000000F87F", 1 }, /* POINT EMPTY */ |
| | | { 1, "010200000000000000", 1 }, /* LINESTRING EMPTY */ |
| | | { 1, "010400000000000000", 1 }, /* MULTIPOINT EMPTY */ |
| | | { 1, "0105000000020000000102000000020000000000000000000000000000000000000000000000000000000000000000000000010200000000000000", 0 }, /* MULTILINESTRING ((0 0, 0 0), EMPTY) */ |
| | | { 1, "0105000000020000000102000000000000000102000000020000000000000000000000000000000000000000000000000000000000000000000000", 0 }, /* MULTILINESTRING (EMPTY,(0 0, 0 0)) */ |
| | | { 1, "010300000000000000", 1 }, /* POLYGON EMPTY */ |
| | | { 1, "01030000000100000000000000", 1 }, /* POLYGON(EMPTY) */ |
| | | { 1, "010300000002000000000000000100000000000000000000000000000000000000", 0 }, /* POLYGON(EMPTY, (0 0)) */ |
| | | { 1, "0107000000030000000102000000000000000103000000020000000000000000000000010200000000000000", 1}, /* GEOMETRYCOLLECTION(LINESTRING EMPTY, POLYGON(EMPTY, EMPTY), LINESTRING EMPTY) */ |
| | | { 1, NULL, 0 } |
| | | { "POINT EMPTY", 1 }, |
| | | { "POINT(1 1)", 0 }, |
| | | { "LINESTRING EMPTY", 1 }, |
| | | { "MULTILINESTRING EMPTY", 1 }, |
| | | { "MULTILINESTRING(EMPTY)", 1 }, |
| | | { "MULTILINESTRING(EMPTY,EMPTY)", 1 }, |
| | | { "MULTILINESTRING(EMPTY,(0 0,1 1))", 0 }, |
| | | { "MULTILINESTRING((0 0,1 1),EMPTY)", 0 }, |
| | | { "MULTILINESTRING(EMPTY,(0 0,1 1),EMPTY)", 0 }, |
| | | { "MULTILINESTRING(EMPTY,EMPTY,EMPTY)", 1 }, |
| | | { "GEOMETRYCOLLECTION(POINT EMPTY,MULTILINESTRING(EMPTY,EMPTY,EMPTY))", 1 }, |
| | | { "GEOMETRYCOLLECTION(POINT EMPTY,MULTILINESTRING(EMPTY),POINT(1 1))", 0 }, |
| | | { "GEOMETRYCOLLECTION(POINT EMPTY,MULTILINESTRING(EMPTY, (0 0)),POINT EMPTY)", 0 }, |
| | | { "GEOMETRYCOLLECTION(POLYGON EMPTY,POINT EMPTY,MULTILINESTRING(EMPTY,EMPTY),POINT EMPTY)", 1 }, |
| | | { "GEOMETRYCOLLECTION(POLYGON EMPTY,GEOMETRYCOLLECTION(POINT EMPTY),MULTILINESTRING(EMPTY,EMPTY),POINT EMPTY)", 1 }, |
| | | { NULL, 0 } |
| | | }; |
| | | |
| | | while( cases[i].txt ) |
| | | while( cases[i].wkt ) |
| | | { |
| | | LWGEOM *lw = NULL; |
| | | if (cases[i].ishex) |
| | | lw = lwgeom_from_hexwkb(cases[i].txt, LW_PARSER_CHECK_NONE); |
| | | else |
| | | lw = lwgeom_from_wkt(cases[i].txt, LW_PARSER_CHECK_NONE); |
| | | |
| | | // i = 11; |
| | | LWGEOM *lw = lwgeom_from_wkt(cases[i].wkt, LW_PARSER_CHECK_NONE); |
| | | GSERIALIZED *g = gserialized2_from_lwgeom(lw, 0); |
| | | int ie = gserialized2_is_empty(g); |
| | | // printf("%s: we say %d, they say %d\n", cases[i].wkt, cases[i].isempty, ie); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | static void test_on_gser2_lwgeom_count_vertices(void) |
| | | { |
| | | LWGEOM *lwgeom; |
| | |
| | | CU_ASSERT_EQUAL(rv, LW_INSIDE); |
| | | |
| | | lwline_free(lwline); |
| | | |
| | | |
| | | /* Test for https://trac.osgeo.org/postgis/ticket/6023 */ |
| | | lwline = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(11.230120879533454 62.84897119848748,11.230120879533905 62.8489711984873,11.23020501303477 62.84900750109812,11.230170431987244 62.84904481447776,11.230117909393426 62.8489943480894,11.230120879533454 62.84897119848748)")); |
| | | pa = lwline->points; |
| | | pt = getPoint2d(lwline->points, 0); |
| | | rv = ptarray_contains_point(pa, &pt); |
| | | ASSERT_INT_EQUAL(rv, LW_BOUNDARY); |
| | | |
| | | |
| | | lwline_free(lwline); |
| | | } |
| | | |
| | | static void test_ptarrayarc_contains_point() |
| | |
| | | static size_t gserialized2_is_empty_recurse(const uint8_t *p, int *isempty); |
| | | static size_t gserialized2_is_empty_recurse(const uint8_t *p, int *isempty) |
| | | { |
| | | uint32_t type = 0, num = 0; |
| | | |
| | | /* Short circuit if we found any non-empty component */ |
| | | if (!*isempty) return 0; |
| | | int i; |
| | | int32_t type, num; |
| | | |
| | | memcpy(&type, p, 4); |
| | | memcpy(&num, p+4, 4); |
| | | |
| | | if (lwtype_is_collection(type)) |
| | | { |
| | | /* Recurse into collections */ |
| | | size_t lz = 8; |
| | | for ( uint32_t i = 0; i < num; i++ ) |
| | | for ( i = 0; i < num; i++ ) |
| | | { |
| | | lz += gserialized2_is_empty_recurse(p+lz, isempty); |
| | | if (!*isempty) |
| | |
| | | } |
| | | else |
| | | { |
| | | size_t lz = 8; |
| | | /* Any non-collection with zero elements is empty */ |
| | | if ( num == 0 ) |
| | | { |
| | | *isempty = LW_TRUE; |
| | | } |
| | | /* |
| | | * Special case to handle polygon with a non-zero |
| | | * set of empty rings |
| | | * https://trac.osgeo.org/postgis/ticket/6028 |
| | | */ |
| | | else if ( num > 0 && type == POLYGONTYPE ) |
| | | { |
| | | for ( uint32_t i = 0; i < num; i++ ) |
| | | { |
| | | uint32_t lrnum; |
| | | memcpy(&lrnum, p+lz, 4); |
| | | lz += 4; |
| | | if ( lrnum > 0 ) |
| | | { |
| | | *isempty = LW_FALSE; |
| | | return lz; |
| | | } |
| | | } |
| | | *isempty = LW_TRUE; |
| | | } |
| | | /* Any other non-collection with more than zero elements is not empty */ |
| | | else |
| | | { |
| | | *isempty = LW_FALSE; |
| | | } |
| | | return lz; |
| | | *isempty = (num == 0 ? LW_TRUE : LW_FALSE); |
| | | return 8; |
| | | } |
| | | } |
| | | |
| | | int gserialized2_is_empty(const GSERIALIZED *g) |
| | | { |
| | | int isempty = LW_TRUE; |
| | | int isempty = 0; |
| | | uint8_t *p = gserialized2_get_geometry_p(g); |
| | | gserialized2_is_empty_recurse(p, &isempty); |
| | | return isempty; |
| | |
| | | int |
| | | p4d_same(const POINT4D *p1, const POINT4D *p2) |
| | | { |
| | | return p1->x == p2->x |
| | | && p1->y == p2->y |
| | | && p1->z == p2->z |
| | | && p1->m == p2->m; |
| | | return FP_EQUALS(p1->x, p2->x) |
| | | && FP_EQUALS(p1->y, p2->y) |
| | | && FP_EQUALS(p1->z, p2->z) |
| | | && FP_EQUALS(p1->m, p2->m); |
| | | } |
| | | |
| | | int |
| | | p3d_same(const POINT3D *p1, const POINT3D *p2) |
| | | { |
| | | return p1->x == p2->x |
| | | && p1->y == p2->y |
| | | && p1->z == p2->z; |
| | | return FP_EQUALS(p1->x, p2->x) |
| | | && FP_EQUALS(p1->y, p2->y) |
| | | && FP_EQUALS(p1->z, p2->z); |
| | | } |
| | | |
| | | int |
| | | p3dz_same(const POINT3DZ *p1, const POINT3DZ *p2) |
| | | { |
| | | return p1->x == p2->x |
| | | && p1->y == p2->y |
| | | && p1->z == p2->z; |
| | | return FP_EQUALS(p1->x, p2->x) |
| | | && FP_EQUALS(p1->y, p2->y) |
| | | && FP_EQUALS(p1->z, p2->z); |
| | | } |
| | | |
| | | int |
| | | p2d_same(const POINT2D *p1, const POINT2D *p2) |
| | | { |
| | | return p1->x == p2->x |
| | | && p1->y == p2->y; |
| | | return FP_EQUALS(p1->x, p2->x) |
| | | && FP_EQUALS(p1->y, p2->y); |
| | | } |
| | | |
| | | /** |
| | |
| | | * For debugging, use LWDEBUG() or LWDEBUGF(). |
| | | * @ingroup logging |
| | | */ |
| | | void lwerror(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); |
| | | |
| | | /*#<<<DIA_SVACE_CRITICAL*/ |
| | | void lwerror(const char *fmt, ...) __attribute__((noreturn)) __attribute__ ((format (printf, 1, 2))); |
| | | /*#DIA_SVACE_CRITICAL>>>*/ |
| | | /** |
| | | * Write a debug message out. |
| | | * Don't call this function directly, use the |
| | |
| | | break; |
| | | } |
| | | |
| | | /*#<<<DIA_SVACE_CRITICAL*/ |
| | | if (has_bbox) |
| | | { |
| | | if (geom) |
| | |
| | | else |
| | | lwerror("unexpected NULL geometry object while bbox is present"); |
| | | } |
| | | /*#DIA_SVACE_CRITICAL>>>*/ |
| | | |
| | | return geom; |
| | | } |
| | |
| | | return NULL; |
| | | } |
| | | |
| | | /* Skip zero-member rings, they add nothing */ |
| | | if ( pa->npoints == 0) |
| | | { |
| | | LWDEBUGF(2, "Skipping empty ring [%d]", i); |
| | | ptarray_free(pa); |
| | | continue; |
| | | } |
| | | |
| | | /* Add ring to polygon */ |
| | | if ( lwpoly_add_ring(poly, pa) == LW_FAILURE ) |
| | | { |
| | |
| | | #line 1 "lwin_wkt_lex.c" |
| | | #line 2 "lwin_wkt_lex.c" |
| | | |
| | | #line 3 "lwin_wkt_lex.c" |
| | | #line 4 "lwin_wkt_lex.c" |
| | | |
| | | #define YY_INT_ALIGNED short int |
| | | |
| | |
| | | #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L |
| | | |
| | | /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, |
| | | * if you want the limit (max/min) macros for int types. |
| | | * if you want the limit (max/min) macros for int types. |
| | | */ |
| | | #ifndef __STDC_LIMIT_MACROS |
| | | #define __STDC_LIMIT_MACROS 1 |
| | |
| | | typedef signed char flex_int8_t; |
| | | typedef short int flex_int16_t; |
| | | typedef int flex_int32_t; |
| | | typedef unsigned char flex_uint8_t; |
| | | typedef unsigned char flex_uint8_t; |
| | | typedef unsigned short int flex_uint16_t; |
| | | typedef unsigned int flex_uint32_t; |
| | | |
| | |
| | | #define EOB_ACT_CONTINUE_SCAN 0 |
| | | #define EOB_ACT_END_OF_FILE 1 |
| | | #define EOB_ACT_LAST_MATCH 2 |
| | | |
| | | |
| | | #define YY_LESS_LINENO(n) |
| | | #define YY_LINENO_REWIND_TO(ptr) |
| | | |
| | | |
| | | /* Return all but the first "n" matched characters back to the input stream. */ |
| | | #define yyless(n) \ |
| | | do \ |
| | |
| | | #define NAN 0.0/0.0 |
| | | #endif |
| | | |
| | | #line 906 "lwin_wkt_lex.c" |
| | | #line 907 "lwin_wkt_lex.c" |
| | | #define YY_NO_INPUT 1 |
| | | /* Suppress the default implementations. */ |
| | | #line 909 "lwin_wkt_lex.c" |
| | | #line 910 "lwin_wkt_lex.c" |
| | | |
| | | #define INITIAL 0 |
| | | |
| | |
| | | #endif |
| | | |
| | | #ifndef YY_NO_UNPUT |
| | | |
| | | |
| | | #endif |
| | | |
| | | #ifndef yytext_ptr |
| | |
| | | yy_state_type yy_current_state; |
| | | char *yy_cp, *yy_bp; |
| | | int yy_act; |
| | | |
| | | |
| | | if ( !(yy_init) ) |
| | | { |
| | | (yy_init) = 1; |
| | |
| | | #line 60 "lwin_wkt_lex.l" |
| | | |
| | | |
| | | #line 1127 "lwin_wkt_lex.c" |
| | | #line 1128 "lwin_wkt_lex.c" |
| | | |
| | | while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ |
| | | { |
| | |
| | | #line 118 "lwin_wkt_lex.l" |
| | | ECHO; |
| | | YY_BREAK |
| | | #line 1340 "lwin_wkt_lex.c" |
| | | #line 1341 "lwin_wkt_lex.c" |
| | | case YY_STATE_EOF(INITIAL): |
| | | yyterminate(); |
| | | |
| | |
| | | { |
| | | yy_state_type yy_current_state; |
| | | char *yy_cp; |
| | | |
| | | |
| | | yy_current_state = (yy_start); |
| | | |
| | | for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) |
| | |
| | | |
| | | { |
| | | int c; |
| | | |
| | | |
| | | *(yy_c_buf_p) = (yy_hold_char); |
| | | |
| | | if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) |
| | |
| | | |
| | | /** Immediately switch to a different input stream. |
| | | * @param input_file A readable stream. |
| | | * |
| | | * |
| | | * @note This function does not reset the start condition to @c INITIAL . |
| | | */ |
| | | void yyrestart (FILE * input_file ) |
| | | { |
| | | |
| | | |
| | | if ( ! YY_CURRENT_BUFFER ){ |
| | | yyensure_buffer_stack (); |
| | | YY_CURRENT_BUFFER_LVALUE = |
| | |
| | | |
| | | /** Switch to a different input buffer. |
| | | * @param new_buffer The new input buffer. |
| | | * |
| | | * |
| | | */ |
| | | void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) |
| | | { |
| | | |
| | | |
| | | /* TODO. We should be able to replace this entire function body |
| | | * with |
| | | * yypop_buffer_state(); |
| | |
| | | /** Allocate and initialize an input buffer state. |
| | | * @param file A readable stream. |
| | | * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. |
| | | * |
| | | * |
| | | * @return the allocated buffer state. |
| | | */ |
| | | YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) |
| | | { |
| | | YY_BUFFER_STATE b; |
| | | |
| | | |
| | | b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); |
| | | if ( ! b ) |
| | | YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); |
| | |
| | | |
| | | /** Destroy the buffer. |
| | | * @param b a buffer created with yy_create_buffer() |
| | | * |
| | | * |
| | | */ |
| | | void yy_delete_buffer (YY_BUFFER_STATE b ) |
| | | { |
| | | |
| | | |
| | | if ( ! b ) |
| | | return; |
| | | |
| | |
| | | |
| | | { |
| | | int oerrno = errno; |
| | | |
| | | |
| | | yy_flush_buffer( b ); |
| | | |
| | | b->yy_input_file = file; |
| | |
| | | } |
| | | |
| | | b->yy_is_interactive = 0; |
| | | |
| | | |
| | | errno = oerrno; |
| | | } |
| | | |
| | | /** Discard all buffered characters. On the next scan, YY_INPUT will be called. |
| | | * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. |
| | | * |
| | | * |
| | | */ |
| | | void yy_flush_buffer (YY_BUFFER_STATE b ) |
| | | { |
| | |
| | | * the current state. This function will allocate the stack |
| | | * if necessary. |
| | | * @param new_buffer The new state. |
| | | * |
| | | * |
| | | */ |
| | | void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) |
| | | { |
| | |
| | | |
| | | /** Removes and deletes the top of the stack, if present. |
| | | * The next element becomes the new top. |
| | | * |
| | | * |
| | | */ |
| | | void yypop_buffer_state (void) |
| | | { |
| | |
| | | static void yyensure_buffer_stack (void) |
| | | { |
| | | yy_size_t num_to_alloc; |
| | | |
| | | |
| | | if (!(yy_buffer_stack)) { |
| | | |
| | | /* First allocation is just for 2 elements, since we don't know if this |
| | |
| | | /** Setup the input buffer state to scan directly from a user-specified character buffer. |
| | | * @param base the character buffer |
| | | * @param size the size in bytes of the character buffer |
| | | * |
| | | * |
| | | * @return the newly allocated buffer state object. |
| | | */ |
| | | YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) |
| | | { |
| | | YY_BUFFER_STATE b; |
| | | |
| | | |
| | | if ( size < 2 || |
| | | base[size-2] != YY_END_OF_BUFFER_CHAR || |
| | | base[size-1] != YY_END_OF_BUFFER_CHAR ) |
| | |
| | | /** Setup the input buffer state to scan a string. The next call to yylex() will |
| | | * scan from a @e copy of @a str. |
| | | * @param yystr a NUL-terminated string to scan |
| | | * |
| | | * |
| | | * @return the newly allocated buffer state object. |
| | | * @note If you want to scan bytes that may contain NUL values, then use |
| | | * yy_scan_bytes() instead. |
| | | */ |
| | | YY_BUFFER_STATE yy_scan_string (const char * yystr ) |
| | | { |
| | | |
| | | |
| | | return yy_scan_bytes( yystr, (int) strlen(yystr) ); |
| | | } |
| | | |
| | |
| | | * scan from a @e copy of @a bytes. |
| | | * @param yybytes the byte buffer to scan |
| | | * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. |
| | | * |
| | | * |
| | | * @return the newly allocated buffer state object. |
| | | */ |
| | | YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) |
| | |
| | | char *buf; |
| | | yy_size_t n; |
| | | int i; |
| | | |
| | | |
| | | /* Get memory for full buffer, including space for trailing EOB's. */ |
| | | n = (yy_size_t) (_yybytes_len + 2); |
| | | buf = (char *) yyalloc( n ); |
| | |
| | | /* Accessor methods (get/set functions) to struct members. */ |
| | | |
| | | /** Get the current line number. |
| | | * |
| | | * |
| | | */ |
| | | int yyget_lineno (void) |
| | | { |
| | | |
| | | |
| | | return yylineno; |
| | | } |
| | | |
| | | /** Get the input stream. |
| | | * |
| | | * |
| | | */ |
| | | FILE *yyget_in (void) |
| | | { |
| | |
| | | } |
| | | |
| | | /** Get the output stream. |
| | | * |
| | | * |
| | | */ |
| | | FILE *yyget_out (void) |
| | | { |
| | |
| | | } |
| | | |
| | | /** Get the length of the current token. |
| | | * |
| | | * |
| | | */ |
| | | int yyget_leng (void) |
| | | { |
| | |
| | | } |
| | | |
| | | /** Get the current token. |
| | | * |
| | | * |
| | | */ |
| | | |
| | | char *yyget_text (void) |
| | |
| | | |
| | | /** Set the current line number. |
| | | * @param _line_number line number |
| | | * |
| | | * |
| | | */ |
| | | void yyset_lineno (int _line_number ) |
| | | { |
| | | |
| | | |
| | | yylineno = _line_number; |
| | | } |
| | | |
| | | /** Set the input stream. This does not discard the current |
| | | * input buffer. |
| | | * @param _in_str A readable stream. |
| | | * |
| | | * |
| | | * @see yy_switch_to_buffer |
| | | */ |
| | | void yyset_in (FILE * _in_str ) |
| | |
| | | /* yylex_destroy is for both reentrant and non-reentrant scanners. */ |
| | | int yylex_destroy (void) |
| | | { |
| | | |
| | | |
| | | /* Pop the buffer stack, destroying each element. */ |
| | | while(YY_CURRENT_BUFFER){ |
| | | yy_delete_buffer( YY_CURRENT_BUFFER ); |
| | |
| | | #ifndef yytext_ptr |
| | | static void yy_flex_strncpy (char* s1, const char * s2, int n ) |
| | | { |
| | | |
| | | |
| | | int i; |
| | | for ( i = 0; i < n; ++i ) |
| | | s1[i] = s2[i]; |
| | |
| | | { |
| | | wkt_yy_delete_buffer(wkt_yy_buf_state); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /*#<<<DIA_SVACE_CRITICAL*/ |
| | | static void |
| | | __attribute__((noreturn)) |
| | | default_errorreporter(const char *fmt, va_list ap) |
| | |
| | | va_end(ap); |
| | | exit(1); |
| | | } |
| | | /*#DIA_SVACE_CRITICAL>>>*/ |
| | | |
| | | /** |
| | | * This function is called by programs which want to set up custom handling |
| | |
| | | va_end(ap); |
| | | } |
| | | |
| | | /*#<<<DIA_SVACE_CRITICAL*/ |
| | | void |
| | | __attribute__((noreturn)) |
| | | lwerror(const char *fmt, ...) |
| | |
| | | |
| | | __builtin_unreachable(); |
| | | } |
| | | /*#DIA_SVACE_CRITICAL>>>*/ |
| | | |
| | | void |
| | | lwdebug(int level, const char *fmt, ...) |
| | |
| | | |
| | | seg2 = getPoint2d_cp(pa, i); |
| | | |
| | | /* This is required for robustness, see #6023 */ |
| | | if (p2d_same(seg1, pt)) |
| | | { |
| | | return LW_BOUNDARY; |
| | | } |
| | | |
| | | /* Zero length segments are ignored. */ |
| | | if (p2d_same(seg1, seg2)) |
| | | { |
| | |
| | | /* Append last point */ |
| | | kept_it++; |
| | | if (kept_it != last_it) |
| | | /*#<<<DIA_SVACE_CRITICAL*/ |
| | | memmove(pa->serialized_pointlist + pt_size * kept_it, |
| | | pa->serialized_pointlist + pt_size * last_it, |
| | | pt_size); |
| | | /*#DIA_SVACE_CRITICAL>>>*/ |
| | | pa->npoints = kept_it + 1; |
| | | } |
| | | |
| | |
| | | { |
| | | /* If there are 2 points remaining, it has to be first and last as |
| | | * we added those at the start */ |
| | | /*#<<<DIA_SVACE_CRITICAL*/ |
| | | memmove(pa->serialized_pointlist + pt_size * kept_it, |
| | | pa->serialized_pointlist + pt_size * (pa->npoints - 1), |
| | | pt_size); |
| | | /*#DIA_SVACE_CRITICAL>>>*/ |
| | | } |
| | | else if (pa->npoints != keptn) /* We don't need to move any points if we are keeping them all */ |
| | | { |
| | |
| | | pfree(ptr); |
| | | } |
| | | |
| | | pg_noreturn |
| | | static void |
| | | static void pg_error(const char *fmt, va_list ap) __attribute__ (( format(printf, 1, 0) )); |
| | | |
| | | /*#<<<DIA_SVACE_CRITICAL*/ |
| | | pg_noreturn static void |
| | | pg_error(const char *fmt, va_list ap) |
| | | { |
| | | char errmsg[PGC_ERRMSG_MAXLEN+1]; |
| | |
| | | va_end(ap); |
| | | ereport(ERROR, (errmsg_internal("%s", errmsg))); |
| | | } |
| | | /*#DIA_SVACE_CRITICAL>>>*/ |
| | | |
| | | static void pg_warning(const char *fmt, va_list ap) __attribute__ (( format(printf, 1, 0) )); |
| | | |
| | |
| | | va_end(ap); |
| | | } |
| | | |
| | | pg_noreturn |
| | | void |
| | | // pg_attribute_noreturn() |
| | | /*#<<<DIA_SVACE_CRITICAL*/ |
| | | pg_noreturn void |
| | | lwpgerror(const char *fmt, ...) |
| | | { |
| | | va_list ap; |
| | |
| | | |
| | | pg_unreachable(); |
| | | } |
| | | |
| | | /*#DIA_SVACE_CRITICAL>>>*/ |
| | | |
| | | /* |
| | | * the bare comparison function for GUC names |
| | |
| | | Datum LWGEOM_addBBOX(PG_FUNCTION_ARGS); |
| | | Datum LWGEOM_dropBBOX(PG_FUNCTION_ARGS); |
| | | |
| | | pg_noreturn void lwpgerror(const char *fmt, ...); // pg_attribute_noreturn(); |
| | | /*#<<<DIA_SVACE_CRITICAL*/ |
| | | pg_noreturn void lwpgerror(const char *fmt, ...) __attribute (( format(printf, 1, 2) )); |
| | | /*#DIA_SVACE_CRITICAL>>>*/ |
| | | void lwpgnotice(const char *fmt, ...) __attribute (( format(printf, 1, 2) )); |
| | | void lwpgwarning(const char *fmt, ...) __attribute (( format(printf, 1, 2) )); |
| | | |
| | |
| | | { |
| | | snprintf(state->message, SHPDUMPERMSGLEN, _("Error parsing HEXEWKB for record %d"), state->currow); |
| | | PQclear(state->fetchres); |
| | | /*#<<<DIA_SVACE_MAJOR*/ |
| | | if (hexewkb) free(hexewkb); |
| | | if (hexewkb_binary) PQfreemem(hexewkb_binary); |
| | | /*#DIA_SVACE_MAJOR>>>*/ |
| | | return SHPDUMPERERR; |
| | | } |
| | | |
| | |
| | | snprintf(state->message, SHPDUMPERMSGLEN, _("Unknown WKB type (%d) for record %d"), lwgeom->type, state->currow); |
| | | PQclear(state->fetchres); |
| | | SHPDestroyObject(obj); |
| | | /*#<<<DIA_SVACE_MAJOR*/ |
| | | if (hexewkb) free(hexewkb); |
| | | if (hexewkb_binary) PQfreemem(hexewkb_binary); |
| | | /*#DIA_SVACE_MAJOR>>>*/ |
| | | return SHPDUMPERERR; |
| | | } |
| | | |
| | |
| | | snprintf(state->message, SHPDUMPERMSGLEN, _("Error writing shape %d"), state->currow); |
| | | PQclear(state->fetchres); |
| | | SHPDestroyObject(obj); |
| | | /*#<<<DIA_SVACE_MAJOR*/ |
| | | if (hexewkb) free(hexewkb); |
| | | if (hexewkb_binary) PQfreemem(hexewkb_binary); |
| | | /*#DIA_SVACE_MAJOR>>>*/ |
| | | return SHPDUMPERERR; |
| | | } |
| | | |
| | |
| | | state->curresrow++; |
| | | state->currow++; |
| | | |
| | | /*#<<<DIA_SVACE_MAJOR*/ |
| | | if (hexewkb) free(hexewkb); |
| | | if (hexewkb_binary) PQfreemem(hexewkb_binary); |
| | | /*#DIA_SVACE_MAJOR>>>*/ |
| | | return SHPDUMPEROK; |
| | | } |
| | | |
| | |
| | | /* Error out if the dbffieldname is > 10 chars */ |
| | | if (strlen(map->dbffieldnames[curmapsize]) > 10) |
| | | {{ |
| | | fclose(fptr); /*#<<<DIA_SVACE_MAJOR>>>*/ |
| | | int ret = snprintf(errbuf, errbuflen, |
| | | _("ERROR: column map file specifies a DBF field name \"%s\" which is longer than 10 characters"), |
| | | map->dbffieldnames[curmapsize]); |
| | |
| | | distclean: clean |
| | | rm -f Makefile |
| | | rm -f sqldefines.h |
| | | if [ -e "cunit/Makefile" ]; then make -C cunit distclean; fi |
| | | |
| | | check-unit: |
| | | |
| | |
| | | { |
| | | HeapTuple heapTuple; |
| | | uint32_t natts = ctx->tupdesc->natts; |
| | | |
| | | /*#<<<DIA_SVACE_CRITICAL*/ |
| | | Datum *values = (Datum *) palloc0(natts * sizeof(Datum)); |
| | | bool *isnull = (bool *) palloc0(natts * sizeof(bool)); |
| | | |
| | | /*#DIA_SVACE_CRITICAL>>>*/ |
| | | values[0] = Int32GetDatum(ctx->fid); |
| | | |
| | | if (flatgeobuf_decode_feature(ctx->ctx)) |
| | |
| | | SPHEROID s; |
| | | |
| | | /* Get our geometry object loaded into memory. */ |
| | | if (!PG_ARGISNULL(0)) |
| | | g = PG_GETARG_GSERIALIZED_P(0); |
| | | else |
| | | /*#<<<DIA_SVACE_MAJOR*/ |
| | | if (PG_ARGISNULL(0)) |
| | | PG_RETURN_NULL(); |
| | | /*#DIA_SVACE_MAJOR>>>*/ |
| | | |
| | | lwgeom = lwgeom_from_gserialized(g); |
| | | g = PG_GETARG_GSERIALIZED_P(0); |
| | | lwgeom = lwgeom_from_gserialized(g); |
| | | |
| | | srid = lwgeom_get_srid(lwgeom); |
| | | |
| | | /* on empty input, return empty output */ |
| | |
| | | if ( typmod_type == POINTTYPE && geom_type == MULTIPOINTTYPE && |
| | | gserialized_is_empty(gser) ) |
| | | { |
| | | bool is_geodetic = gserialized_is_geodetic(gser); |
| | | LWPOINT *empty_point = lwpoint_construct_empty(geom_srid, geom_z, geom_m); |
| | | geom_type = POINTTYPE; |
| | | pfree(gser); |
| | | if ( is_geodetic ) |
| | | if ( gserialized_is_geodetic(gser) ) |
| | | gser = geography_serialize(lwpoint_as_lwgeom(empty_point)); |
| | | else |
| | | gser = geometry_serialize(lwpoint_as_lwgeom(empty_point)); |
| | |
| | | PG_RETURN_INT32(0); |
| | | PG_RETURN_INT32(TYPMOD_GET_SRID(typmod)); |
| | | } |
| | | |
| | |
| | | preserve_collapsed = PG_GETARG_BOOL(2); |
| | | |
| | | in = lwgeom_from_gserialized(geom); |
| | | /*#<<<DIA_SVACE_MAJOR*/ |
| | | if (!in || lwgeom_is_empty(in)) |
| | | PG_RETURN_NULL(); |
| | | |
| | | /*#DIA_SVACE_MAJOR>>>*/ |
| | | modified = lwgeom_simplify_in_place(in, dist, preserve_collapsed); |
| | | if (!modified) |
| | | PG_RETURN_POINTER(geom); |
| | |
| | | Datum box2d_from_geohash(PG_FUNCTION_ARGS); |
| | | Datum point_from_geohash(PG_FUNCTION_ARGS); |
| | | |
| | | pg_noreturn |
| | | static void |
| | | // pg_attribute_noreturn() |
| | | geohash_lwpgerror(char *msg, __attribute__((__unused__)) int error_code) |
| | | /*#<<<DIA_SVACE_CRITICAL*/ |
| | | pg_noreturn static void geohash_lwpgerror(char *msg, __attribute__((__unused__)) int error_code) |
| | | { |
| | | POSTGIS_DEBUGF(3, "ST_Box2dFromGeoHash ERROR %i", error_code); |
| | | lwpgerror("%s", msg); |
| | | pg_unreachable(); |
| | | } |
| | | /*#DIA_SVACE_CRITICAL>>>*/ |
| | | |
| | | static GBOX* |
| | | parse_geohash(char *geohash, int precision) |
| | |
| | | #define GML_NS ((char *) "http://www.opengis.net/gml") |
| | | #define GML32_NS ((char *) "http://www.opengis.net/gml/3.2") |
| | | |
| | | pg_noreturn |
| | | static void |
| | | // pg_attribute_noreturn() |
| | | gml_lwpgerror(char *msg, __attribute__((__unused__)) int error_code) |
| | | |
| | | /*#<<<DIA_SVACE_CRITICAL*/ |
| | | pg_noreturn static void gml_lwpgerror(char *msg, __attribute__((__unused__)) int error_code) |
| | | { |
| | | POSTGIS_DEBUGF(3, "ST_GeomFromGML ERROR %i", error_code); |
| | | lwpgerror("%s", msg); |
| | | pg_unreachable(); |
| | | POSTGIS_DEBUGF(3, "ST_GeomFromGML ERROR %i", error_code); |
| | | lwpgerror("%s", msg); |
| | | pg_unreachable(); |
| | | } |
| | | /*#DIA_SVACE_CRITICAL>>>*/ |
| | | |
| | | /** |
| | | * Ability to parse GML geometry fragment and to return an LWGEOM |
| | |
| | | xmlFree(interpolation); |
| | | } |
| | | |
| | | /*#<<<DIA_SVACE_CRITICAL*/ |
| | | if (lss > 0) ppa = (POINTARRAY**) lwrealloc(ppa, |
| | | sizeof(POINTARRAY*) * (lss + 1)); |
| | | |
| | | /*#DIA_SVACE_CRITICAL>>>*/ |
| | | ppa[lss] = parse_gml_data(xa->children, hasz, root_srid); |
| | | npoints += ppa[lss]->npoints; |
| | | if (ppa[lss]->npoints < 2) |
| | |
| | | if (!is_gml_namespace(xb, false)) continue; |
| | | if (!is_gml_element(xb, "LinearRing")) continue; |
| | | |
| | | /*#<<<DIA_SVACE_CRITICAL*/ |
| | | ppa = (POINTARRAY**) lwrealloc(ppa, |
| | | sizeof(POINTARRAY*) * (ring + 1)); |
| | | /*#DIA_SVACE_CRITICAL>>>*/ |
| | | ppa[ring] = parse_gml_data(xb->children, hasz, root_srid); |
| | | |
| | | if (ppa[ring]->npoints < 4 |
| | |
| | | if (xb->type != XML_ELEMENT_NODE) continue; |
| | | if (!is_gml_element(xb, "LinearRing")) continue; |
| | | |
| | | /*#<<<DIA_SVACE_CRITICAL*/ |
| | | ppa = (POINTARRAY**) lwrealloc(ppa, |
| | | sizeof(POINTARRAY*) * (ring + 1)); |
| | | /*#DIA_SVACE_CRITICAL>>>*/ |
| | | ppa[ring] = parse_gml_data(xb->children, hasz, root_srid); |
| | | |
| | | if (ppa[ring]->npoints < 4 |
| | |
| | | { |
| | | /* Roll forward to semi-colon */ |
| | | char *tmp = str; |
| | | while ( *tmp && *tmp != ';' ) |
| | | while ( *tmp && *tmp != ';' ) /*#<<<DIA_SVACE_MAJOR>>>*/ |
| | | tmp++; |
| | | |
| | | /* Check next character to see if we have WKB */ |
| | | if ( *tmp == ';' && *(tmp+1) == '0' ) |
| | | if ( *tmp == ';' && *(tmp+1) == '0' ) /*#<<<DIA_SVACE_MAJOR>>>*/ |
| | | { |
| | | /* Null terminate the SRID= string */ |
| | | *tmp = '\0'; |
| | |
| | | } |
| | | |
| | | /* Zero features => empty bytea output */ |
| | | if (ctx->layer && ctx->layer->n_features == 0) |
| | | if (ctx->layer && ctx->layer->n_features == 0) /*#<<<DIA_SVACE_MAJOR>>>*/ |
| | | { |
| | | bytea* ba_empty = palloc(VARHDRSZ); |
| | | SET_VARSIZE(ba_empty, VARHDRSZ); |
| | |
| | | RETURNS geometry |
| | | AS ' |
| | | SELECT CASE WHEN @extschema@.ST_GeometryType(@extschema@.ST_GeomFromText($1, $2)) = ''ST_MultiPoint'' |
| | | THEN @extschema@.ST_GeomFromText($1, $2) |
| | | THEN ST_GeomFromText($1, $2) |
| | | ELSE NULL END |
| | | ' |
| | | LANGUAGE 'sql' IMMUTABLE STRICT PARALLEL SAFE |
| | |
| | | /* specify SRID */ |
| | | lwgeom_set_srid(mpoly, rt_raster_get_srid(raster)); |
| | | |
| | | /*#<<<DIA_SVACE_MAJOR*/ |
| | | /* convert to multi */ |
| | | if (!lwgeom_is_collection(mpoly)) { |
| | | tmp = mpoly; |
| | | |
| | | #if POSTGIS_DEBUG_LEVEL > 3 |
| | | { |
| | | char *wkt = lwgeom_to_wkt(mpoly, WKT_ISO, DBL_DIG, NULL); |
| | | RASTER_DEBUGF(4, "before multi = %s", wkt); |
| | | rtdealloc(wkt); |
| | | } |
| | | { |
| | | char *wkt = lwgeom_to_wkt(mpoly, WKT_ISO, DBL_DIG, NULL); |
| | | RASTER_DEBUGF(4, "before multi = %s", wkt); |
| | | rtdealloc(wkt); |
| | | } |
| | | #endif |
| | | |
| | | RASTER_DEBUGF(4, "mpoly @ %p", mpoly); |
| | | RASTER_DEBUGF(4, "mpoly @ %p", mpoly); |
| | | |
| | | /* |
| | | lwgeom_as_multi() only does a shallow clone internally |
| | | so input and output geometries may share memory |
| | | hence the deep clone of the output geometry for returning |
| | | is the only way to guarantee the memory isn't shared |
| | | */ |
| | | mpoly = lwgeom_as_multi(tmp); |
| | | clone = lwgeom_clone_deep(mpoly); |
| | | lwgeom_free(tmp); |
| | | lwgeom_free(mpoly); |
| | | mpoly = clone; |
| | | /* |
| | | lwgeom_as_multi() only does a shallow clone internally |
| | | so input and output geometries may share memory |
| | | hence the deep clone of the output geometry for returning |
| | | is the only way to guarantee the memory isn't shared |
| | | */ |
| | | mpoly = lwgeom_as_multi(tmp); |
| | | clone = lwgeom_clone_deep(mpoly); |
| | | lwgeom_free(tmp); |
| | | lwgeom_free(mpoly); |
| | | mpoly = clone; |
| | | |
| | | RASTER_DEBUGF(4, "mpoly @ %p", mpoly); |
| | | RASTER_DEBUGF(4, "mpoly @ %p", mpoly); |
| | | |
| | | #if POSTGIS_DEBUG_LEVEL > 3 |
| | | { |
| | | char *wkt = lwgeom_to_wkt(mpoly, WKT_ISO, DBL_DIG, NULL); |
| | | RASTER_DEBUGF(4, "after multi = %s", wkt); |
| | | rtdealloc(wkt); |
| | | } |
| | | #endif |
| | | } |
| | | |
| | | #if POSTGIS_DEBUG_LEVEL > 3 |
| | | { |
| | | char *wkt = lwgeom_to_wkt(mpoly, WKT_ISO, DBL_DIG, NULL); |
| | | RASTER_DEBUGF(4, "after multi = %s", wkt); |
| | | RASTER_DEBUGF(4, "returning geometry = %s", wkt); |
| | | rtdealloc(wkt); |
| | | } |
| | | #endif |
| | | } |
| | | |
| | | #if POSTGIS_DEBUG_LEVEL > 3 |
| | | { |
| | | char *wkt = lwgeom_to_wkt(mpoly, WKT_ISO, DBL_DIG, NULL); |
| | | RASTER_DEBUGF(4, "returning geometry = %s", wkt); |
| | | rtdealloc(wkt); |
| | | } |
| | | #endif |
| | | *surface = lwgeom_as_lwmpoly(mpoly); |
| | | return ES_NONE; |
| | | /*#DIA_SVACE_MAJOR>>>*/ |
| | | |
| | | *surface = lwgeom_as_lwmpoly(mpoly); |
| | | return ES_NONE; |
| | | } |
| | | |
| | |
| | | assert(NULL != torast); |
| | | assert(NULL != fromrast); |
| | | |
| | | /*#<<<DIA_SVACE_CRITICAL*/ |
| | | /* Check raster dimensions */ |
| | | if (!torast || torast->height != fromrast->height || torast->width != fromrast->width) { |
| | | rtwarn("rt_raster_copy_band: Attempting to add a band with different width or height"); |
| | | return -1; |
| | | } |
| | | |
| | | /*#DIA_SVACE_CRITICAL>>>*/ |
| | | /* Check bands limits */ |
| | | if (fromrast->numBands < 1) { |
| | | rtwarn("rt_raster_copy_band: Second raster has no band"); |
| | |
| | | |
| | | /* insert */ |
| | | /* OPTIMIZATION: check to see if value exceeds last value */ |
| | | if (NULL != qll->tail && (value > qll->tail->value || FLT_EQ(value, qll->tail->value))) { |
| | | if (value > qll->tail->value || FLT_EQ(value, qll->tail->value)) { /*#<<<DIA_SVACE_MAJOR>>>*/ |
| | | idx = qll->count; |
| | | qle = quantile_llist_insert(qll->tail, value, &idx); |
| | | } |
| | |
| | | /* insert value */ |
| | | RASTER_DEBUGF(4, "adding %f to list", value); |
| | | /* OPTIMIZATION: check to see if value exceeds last value */ |
| | | if (value > qll->tail->value || FLT_EQ(value, qll->tail->value)) { |
| | | if (value > qll->tail->value || FLT_EQ(value, qll->tail->value)) { /*#<<<DIA_SVACE_MAJOR>>>*/ |
| | | idx = qll->count; |
| | | qle = quantile_llist_insert(qll->tail, value, &idx); |
| | | } |
| | |
| | | /* insert value */ |
| | | RASTER_DEBUGF(4, "adding %f to list", value); |
| | | /* OPTIMIZATION: check to see if value exceeds last value */ |
| | | if (value > qll->tail->value || FLT_EQ(value, qll->tail->value)) { |
| | | if (NULL != qll->tail && (value > qll->tail->value || FLT_EQ(value, qll->tail->value))) { |
| | | idx = qll->count; |
| | | qle = quantile_llist_insert(qll->tail, value, &idx); |
| | | } |
| | |
| | | } |
| | | |
| | | /* This is an on-disk band */ |
| | | sz = (uint32_t)width * height * pixbytes; |
| | | sz = (size_t)width * height * pixbytes; |
| | | if (((*ptr) + sz) > end) { |
| | | rterror("rt_band_from_wkb: Premature end of WKB on band data reading (%s:%d)", |
| | | __FILE__, __LINE__); |
| | |
| | | } |
| | | |
| | | flipme = band->data.mem; |
| | | sz = (uint32_t)width * height; |
| | | sz = (size_t)width * height; |
| | | for (v = 0; v < sz; ++v) { |
| | | flipper(flipme); |
| | | flipme += pixbytes; |
| | |
| | | uint8_t maxVal = band->pixtype == PT_1BB ? 1 : (band->pixtype == PT_2BUI ? 3 : 15); |
| | | uint8_t val; |
| | | |
| | | sz = (uint32_t)width * height; |
| | | sz = (size_t)width*height; |
| | | for (v = 0; v < sz; ++v) { |
| | | val = ((uint8_t*) band->data.mem)[v]; |
| | | if (val > maxVal) { |
| | |
| | | funcctx->user_fctx = arg1; |
| | | |
| | | /* total number of tuples to be returned */ |
| | | funcctx->max_calls = ((uint64_t) arg1->tile.nx * (uint64_t) arg1->tile.ny); |
| | | funcctx->max_calls = ((uint64_t) arg1->tile.nx * (uint64_t) arg1->tile.ny); /*#<<<DIA_SVACE_MAJOR>>>*/ |
| | | |
| | | MemoryContextSwitchTo(oldcontext); |
| | | } |
| | | |
| | | /*#<<<DIA_SVACE_MAJOR*/ |
| | | if (funcctx->max_calls > INT32_MAX) |
| | | elog(ERROR, "RASTER_tile: Overflow while working with raster points."); |
| | | /*#DIA_SVACE_MAJOR>>>*/ |
| | | |
| | | /* stuff done on every call of the function */ |
| | | funcctx = SRF_PERCALL_SETUP(); |
| | |
| | | break; |
| | | } |
| | | |
| | | /*#<<<DIA_SVACE_CRITICAL*/ |
| | | if (option && strlen(option)) { |
| | | options[j] = (char *) palloc(sizeof(char) * (strlen(option) + 1)); |
| | | strcpy(options[j], option); |
| | | j++; |
| | | } |
| | | /*#DIA_SVACE_CRITICAL>>>*/ |
| | | } |
| | | |
| | | if (j > 0) { |
| | |
| | | break; |
| | | } |
| | | |
| | | /*#<<<DIA_SVACE_CRITICAL*/ |
| | | if (pixeltype && strlen(pixeltype)) { |
| | | pixtype = rt_pixtype_index_from_name(pixeltype); |
| | | if (pixtype == PT_END) { |
| | |
| | | pixtypes[j] = pixtype; |
| | | j++; |
| | | } |
| | | /*#DIA_SVACE_CRITICAL>>>*/ |
| | | } |
| | | |
| | | if (j > 0) { |
| | |
| | | options_len++; |
| | | options = (char **) repalloc(options, sizeof(char *) * options_len); |
| | | } |
| | | |
| | | /*#<<<DIA_SVACE_CRITICAL*/ |
| | | options[options_len - 1] = (char *) palloc(sizeof(char) * (strlen("ALL_TOUCHED=TRUE") + 1)); |
| | | /*#DIA_SVACE_CRITICAL>>>*/ |
| | | strcpy(options[options_len - 1], "ALL_TOUCHED=TRUE"); |
| | | } |
| | | |
| | |
| | | while ((tmp = strstr(tmp, oldstr)) != NULL && found != limit) |
| | | found++, tmp += oldlen; |
| | | |
| | | length = strlen(str) + found * (newlen - oldlen); |
| | | length = (int64_t) strlen(str) + found * ((int64_t) newlen - (int64_t) oldlen); /*#<<<DIA_SVACE_MAJOR>>>*/ |
| | | if ((result = (char *) palloc(length + 1)) == NULL) { |
| | | fprintf(stderr, "Not enough memory\n"); |
| | | found = -1; |
| | |
| | | select ST_AsText(ST_SnapToGrid(the_geom,0.00000001), 8) from loadedshp; |
| | | |
| | |
| | | select ST_AsText(ST_SnapToGrid(the_geom::geometry,0.00000001), 8) from loadedshp; |
| | | |
| | |
| | | SELECT 'CG_Translate', ST_AsText(CG_Translate('LINESTRING(1 1, 2 2)', 1, -1), 0); |
| | | SELECT 'CG_3DTranslate', ST_AsText(CG_3DTranslate('POINT(1 1 1)', 1, -1, 2), 0); |
| | | SELECT 'CG_StraightSkeletonPartition', ST_AsText(ST_Collect(dmp.geom), 2) FROM ST_Dump(CG_StraightSkeletonPartition('POLYGON((0 0, 4 0, 2 2, 0 0))', true)) as dmp; |
| | | SELECT 'CG_3DBuffer', ST_GeometryType(CG_3DBuffer('POINT(0 0 0)', 1, 8, 0)); |
| | | SELECT 'CG_3DBuffer', ST_AsText(CG_3DBuffer('POINT(0 0 0)', 1, 8, 0), 2); |
| | | SELECT 'CG_Rotate', ST_AsText(ST_ReducePrecision(CG_Rotate('LINESTRING EMPTY', pi()/2), 0.1)); |
| | | SELECT 'CG_2DRotate', ST_AsText(CG_2DRotate('POINT EMPTY', pi()/2, 1, 1), 0); |
| | | SELECT 'CG_3DRotate', ST_AsText(ST_ReducePrecision(CG_3DRotate('POINT EMPTY', pi()/2, 0, 0, 1), 0.1)); |
| | |
| | | CG_Translate|LINESTRING(2 0,3 1) |
| | | CG_3DTranslate|POINT Z (2 0 3) |
| | | CG_StraightSkeletonPartition|MULTIPOLYGON(((0 0,2 0.83,2 2)),((4 0,2 0.83,0 0)),((2 2,2 0.83,4 0))) |
| | | CG_3DBuffer|ST_PolyhedralSurface |
| | | CG_3DBuffer|POLYHEDRALSURFACE Z (((0 0 1,0.5 -0.5 0.71,0 -0.71 0.71,0 0 1)),((0 0 1,0.71 -4.33e-17 0.71,0.5 -0.5 0.71,0 0 1)),((0 0 1,0.5 0.5 0.71,0.71 -4.33e-17 0.71,0 0 1)),((0 0 1,8.66e-17 0.71 0.71,0.5 0.5 0.71,0 0 1)),((0 0 1,-0.5 0.5 0.71,8.66e-17 0.71 0.71,0 0 1)),((0 0 1,-0.71 1.3e-16 0.71,-0.5 0.5 0.71,0 0 1)),((0 0 1,-0.5 -0.5 0.71,-0.71 1.3e-16 0.71,0 0 1)),((0 0 1,0 -0.71 0.71,-0.5 -0.5 0.71,0 0 1)),((0 -0.71 0.71,0.5 -0.5 0.71,0.71 -0.71 6.12e-17,0 -0.71 0.71)),((0 -0.71 0.71,0.71 -0.71 6.12e-17,0 -1 6.12e-17,0 -0.71 0.71)),((0.5 -0.5 0.71,0.71 -4.33e-17 0.71,1 -6.12e-17 6.12e-17,0.5 -0.5 0.71)),((0.5 -0.5 0.71,1 -6.12e-17 6.12e-17,0.71 -0.71 6.12e-17,0.5 -0.5 0.71)),((0.71 -4.33e-17 0.71,0.5 0.5 0.71,0.71 0.71 6.12e-17,0.71 -4.33e-17 0.71)),((0.71 -4.33e-17 0.71,0.71 0.71 6.12e-17,1 -6.12e-17 6.12e-17,0.71 -4.33e-17 0.71)),((0.5 0.5 0.71,8.66e-17 0.71 0.71,1.22e-16 1 6.12e-17,0.5 0.5 0.71)),((0.5 0.5 0.71,1.22e-16 1 6.12e-17,0.71 0.71 6.12e-17,0.5 0.5 0.71)),((8.66e-17 0.71 0.71,-0.5 0.5 0.71,-0.71 0.71 6.12e-17,8.66e-17 0.71 0.71)),((8.66e-17 0.71 0.71,-0.71 0.71 6.12e-17,1.22e-16 1 6.12e-17,8.66e-17 0.71 0.71)),((-0.5 0.5 0.71,-0.71 1.3e-16 0.71,-1 1.84e-16 6.12e-17,-0.5 0.5 0.71)),((-0.5 0.5 0.71,-1 1.84e-16 6.12e-17,-0.71 0.71 6.12e-17,-0.5 0.5 0.71)),((-0.71 1.3e-16 0.71,-0.5 -0.5 0.71,-0.71 -0.71 6.12e-17,-0.71 1.3e-16 0.71)),((-0.71 1.3e-16 0.71,-0.71 -0.71 6.12e-17,-1 1.84e-16 6.12e-17,-0.71 1.3e-16 0.71)),((-0.5 -0.5 0.71,0 -0.71 0.71,0 -1 6.12e-17,-0.5 -0.5 0.71)),((-0.5 -0.5 0.71,0 -1 6.12e-17,-0.71 -0.71 6.12e-17,-0.5 -0.5 0.71)),((0 -1 6.12e-17,0.71 -0.71 6.12e-17,0.5 -0.5 -0.71,0 -1 6.12e-17)),((0 -1 6.12e-17,0.5 -0.5 -0.71,0 -0.71 -0.71,0 -1 6.12e-17)),((0.71 -0.71 6.12e-17,1 -6.12e-17 6.12e-17,0.71 -4.33e-17 -0.71,0.71 -0.71 6.12e-17)),((0.71 -0.71 6.12e-17,0.71 -4.33e-17 -0.71,0.5 -0.5 -0.71,0.71 -0.71 6.12e-17)),((1 -6.12e-17 6.12e-17,0.71 0.71 6.12e-17,0.5 0.5 -0.71,1 -6.12e-17 6.12e-17)),((1 -6.12e-17 6.12e-17,0.5 0.5 -0.71,0.71 -4.33e-17 -0.71,1 -6.12e-17 6.12e-17)),((0.71 0.71 6.12e-17,1.22e-16 1 6.12e-17,8.66e-17 0.71 -0.71,0.71 0.71 6.12e-17)),((0.71 0.71 6.12e-17,8.66e-17 0.71 -0.71,0.5 0.5 -0.71,0.71 0.71 6.12e-17)),((1.22e-16 1 6.12e-17,-0.71 0.71 6.12e-17,-0.5 0.5 -0.71,1.22e-16 1 6.12e-17)),((1.22e-16 1 6.12e-17,-0.5 0.5 -0.71,8.66e-17 0.71 -0.71,1.22e-16 1 6.12e-17)),((-0.71 0.71 6.12e-17,-1 1.84e-16 6.12e-17,-0.71 1.3e-16 -0.71,-0.71 0.71 6.12e-17)),((-0.71 0.71 6.12e-17,-0.71 1.3e-16 -0.71,-0.5 0.5 -0.71,-0.71 0.71 6.12e-17)),((-1 1.84e-16 6.12e-17,-0.71 -0.71 6.12e-17,-0.5 -0.5 -0.71,-1 1.84e-16 6.12e-17)),((-1 1.84e-16 6.12e-17,-0.5 -0.5 -0.71,-0.71 1.3e-16 -0.71,-1 1.84e-16 6.12e-17)),((-0.71 -0.71 6.12e-17,0 -1 6.12e-17,0 -0.71 -0.71,-0.71 -0.71 6.12e-17)),((-0.71 -0.71 6.12e-17,0 -0.71 -0.71,-0.5 -0.5 -0.71,-0.71 -0.71 6.12e-17)),((0 0 -1,0 -0.71 -0.71,0.5 -0.5 -0.71,0 0 -1)),((0 0 -1,0.5 -0.5 -0.71,0.71 -4.33e-17 -0.71,0 0 -1)),((0 0 -1,0.71 -4.33e-17 -0.71,0.5 0.5 -0.71,0 0 -1)),((0 0 -1,0.5 0.5 -0.71,8.66e-17 0.71 -0.71,0 0 -1)),((0 0 -1,8.66e-17 0.71 -0.71,-0.5 0.5 -0.71,0 0 -1)),((0 0 -1,-0.5 0.5 -0.71,-0.71 1.3e-16 -0.71,0 0 -1)),((0 0 -1,-0.71 1.3e-16 -0.71,-0.5 -0.5 -0.71,0 0 -1)),((0 0 -1,-0.5 -0.5 -0.71,0 -0.71 -0.71,0 0 -1))) |
| | | CG_Rotate|LINESTRING EMPTY |
| | | CG_2DRotate|POINT EMPTY |
| | | CG_3DRotate|POINT Z EMPTY |
| | |
| | | moreMergedFaces BIGINT[]; |
| | | BEGIN |
| | | |
| | | topo := topology.findTopology(atopology); |
| | | topo := findTopology(atopology); |
| | | IF topo.id IS NULL THEN |
| | | RAISE EXCEPTION 'Could not find topology "%"', atopology; |
| | | END IF; |
| | |
| | | RETURN deletedEdges + deletedNodes + deletedNodesDeg2; |
| | | END; |
| | | $BODY$ LANGUAGE 'plpgsql' VOLATILE; |
| | | |
| | |
| | | \i ../more_features.sql |
| | | \i ../hierarchy.sql |
| | | SELECT topology.FixCorruptTopoGeometryColumn(schema_name, table_name, feature_column) |
| | | FROM topology.layer |
| | | ORDER BY schema_name, table_name, feature_column; |
| | | FROM topology.layer; |
| | | |
| | | SELECT topology.DropTopology('city_data'); |
| | | DROP SCHEMA features CASCADE; |
| | |
| | | 0 rows updated for features.big_parcels.feature column to bigint id type |
| | | 0 rows updated for features.big_signs.feature column to bigint id type |
| | | 0 rows updated for features.big_streets.feature column to bigint id type |
| | | 0 rows updated for features.city_streets.feature column to bigint id type |
| | | 0 rows updated for features.land_parcels.feature column to bigint id type |
| | | 0 rows updated for features.traffic_signs.feature column to bigint id type |
| | | 0 rows updated for features.city_streets.feature column to bigint id type |
| | | 0 rows updated for features.big_parcels.feature column to bigint id type |
| | | 0 rows updated for features.big_streets.feature column to bigint id type |
| | | 0 rows updated for features.big_signs.feature column to bigint id type |
| | | Topology 'city_data' dropped |
| | |
| | | set client_min_messages to WARNING; |
| | | set search_path to public,pg_catalog; |
| | | |
| | | \i :top_builddir/topology/test/load_topology.sql |
| | | \i ../load_features.sql |
| | |
| | | DELETE FROM features.city_streets WHERE feature_name IN ( 'R1' ) |
| | | RETURNING feature |
| | | ), clear AS ( |
| | | SELECT topology.clearTopoGeom(feature) FROM deleted |
| | | SELECT clearTopoGeom(feature) FROM deleted |
| | | ) SELECT NULL FROM clear; |
| | | |
| | | --set client_min_messages to DEBUG; |
| | |
| | | DELETE FROM features.traffic_signs WHERE feature_name IN ( 'S3' ) |
| | | RETURNING feature |
| | | ), clear AS ( |
| | | SELECT topology.clearTopoGeom(feature) FROM deleted |
| | | SELECT clearTopoGeom(feature) FROM deleted |
| | | ) SELECT NULL FROM clear; |
| | | |
| | | --set client_min_messages to DEBUG; |
| | |
| | | DELETE FROM features.traffic_signs WHERE feature_name IN ( 'S4' ) |
| | | RETURNING feature |
| | | ), clear AS ( |
| | | SELECT topology.clearTopoGeom(feature) FROM deleted |
| | | SELECT clearTopoGeom(feature) FROM deleted |
| | | ) SELECT NULL FROM clear; |
| | | |
| | | --set client_min_messages to DEBUG; |
| | |
| | | FROM deleted |
| | | ), |
| | | clear AS ( |
| | | SELECT sp, topology.clearTopoGeom(feature) |
| | | SELECT sp, clearTopoGeom(feature) |
| | | FROM start_point |
| | | ) |
| | | INSERT INTO features.traffic_signs ( feature_name, feature ) |
| | | SELECT |
| | | 'TS1', |
| | | topology.toTopoGeom( |
| | | toTopoGeom( |
| | | sp, |
| | | 'city_data', |
| | | layer_id(topology.findLayer('features', 'traffic_signs', 'feature')), |
| | | layer_id(findLayer('features', 'traffic_signs', 'feature')), |
| | | 0 |
| | | ) |
| | | FROM clear; |
| | |
| | | FROM features.traffic_signs WHERE feature_name = 'S1' |
| | | ), |
| | | triangle_right AS ( |
| | | SELECT topology.TopoGeo_addLineString( 'city_data', |
| | | SELECT TopoGeo_addLineString( 'city_data', |
| | | features.triangle(g, 4, 4) |
| | | ) FROM node |
| | | ), |
| | | triangle_left AS ( |
| | | SELECT topology.TopoGeo_addLineString( 'city_data', |
| | | SELECT TopoGeo_addLineString( 'city_data', |
| | | features.triangle(g, -4, 4) |
| | | ) FROM node |
| | | ) |
| | |
| | | RETURNING feature |
| | | ), |
| | | clear AS ( |
| | | SELECT topology.clearTopoGeom(feature) |
| | | SELECT clearTopoGeom(feature) |
| | | FROM deleted |
| | | ) |
| | | SELECT NULL FROM clear; |
| | |
| | | |
| | | -- See https://trac.osgeo.org/postgis/ticket/5289 |
| | | SELECT NULL FROM ( |
| | | SELECT topology.toTopoGeom( |
| | | SELECT toTopoGeom( |
| | | ST_MakeLine( |
| | | ST_EndPoint( ST_GeometryN(feature,1) ), |
| | | ST_StartPoint( ST_GeometryN(feature,1) ) |
| | |
| | | -- being required as endpoint of closed edge 2) while |
| | | -- edges themselves would still be both used by R4 feature. |
| | | UPDATE features.city_streets |
| | | SET feature = topology.TopoGeom_addElement(feature, ARRAY[2, 2]) |
| | | SET feature = TopoGeom_addElement(feature, ARRAY[2, 2]) |
| | | WHERE feature_name = 'R4'; |
| | | UPDATE features.city_streets SET geom = feature::geometry |
| | | WHERE feature_name = 'R4'; |
| | |
| | | -- Cleanup |
| | | -- |
| | | |
| | | SELECT NULL FROM topology.DropTopology('city_data'); |
| | | SELECT NULL FROM DropTopology('city_data'); |
| | | DROP SCHEMA features CASCADE; |
| | | RESET search_path; |
| | |
| | | SELECT oid is not null FROM pg_event_trigger WHERE evtname = 'proc_date_drop_trigger'; |
| | | ?column? |
| | | ---------- |
| | | t |
| | | (1 row) |
| | | |
| | | SELECT oid is not null FROM pg_event_trigger WHERE evtname = 'proc_date_modification_trigger'; |
| | | ?column? |
| | | ---------- |
| | | t |
| | | (1 row) |
| | | |
| | | CREATE FUNCTION test_fn() RETURNS INT AS $$ SELECT 1 $$ LANGUAGE SQL; |
| | | CREATE FUNCTION |
| | | |
| | | SELECT prooid is not null FROM proc_date_modification WHERE name = 'test_fn'; |
| | | ?column? |
| | | ---------- |
| | | t |
| | | (1 row) |
| | | |
| | | SELECT to_char(creation_date, 'YYYY-MM-DD HH24:MI') = (SELECT to_char(current_timestamp, 'YYYY-MM-DD HH24:MI')) |
| | | FROM proc_date_modification |
| | | WHERE name = 'test_fn'; |
| | | ?column? |
| | | ---------- |
| | | t |
| | | (1 row) |
| | | |
| | | ALTER FUNCTION test_fn() RENAME TO test_fn_modified; |
| | | ALTER FUNCTION |
| | | |
| | | SELECT |
| | | (modification_date > creation_date) AS modified, |
| | | name = 'test_fn_modified' AS name_updated |
| | | FROM proc_date_modification |
| | | WHERE prooid = (SELECT oid FROM pg_proc WHERE proname = 'test_fn_modified'); |
| | | modified | name_updated |
| | | ----------+-------------- |
| | | t | t |
| | | (1 row) |
| | | |
| | | DROP FUNCTION test_fn_modified(); |
| | | DROP FUNCTION |
| | | |
| | | SELECT |
| | | prooid = -1 AS marked_deleted, |
| | | deletion_user IS NOT NULL, |
| | | deletion_date IS NOT NULL |
| | | FROM proc_date_modification |
| | | WHERE name = 'test_fn_modified'; |
| | | marked_deleted | ?column? | ?column? |
| | | ----------------+----------+---------- |
| | | t | t | t |
| | | (1 row) |
| | | |
| | | SELECT to_char(deletion_date, 'YYYY-MM-DD HH24:MI') = (SELECT to_char(current_timestamp, 'YYYY-MM-DD HH24:MI')) |
| | | FROM proc_date_modification |
| | | WHERE name = 'test_fn_modified'; |
| | | ?column? |
| | | ---------- |
| | | t |
| | | (1 row) |
| | | |
| | | CREATE PROCEDURE test_proc() AS $$ BEGIN END; $$ LANGUAGE plpgsql; |
| | | CREATE PROCEDURE |
| | | |
| | | SELECT prooid is not null FROM proc_date_modification WHERE name = 'test_proc'; |
| | | ?column? |
| | | ---------- |
| | | t |
| | | (1 row) |
| | | |
| | | SELECT to_char(creation_date, 'YYYY-MM-DD HH24:MI') = (SELECT to_char(current_timestamp, 'YYYY-MM-DD HH24:MI')) |
| | | FROM proc_date_modification |
| | | WHERE name = 'test_proc'; |
| | | ?column? |
| | | ---------- |
| | | t |
| | | (1 row) |
| | | |
| | | ALTER PROCEDURE test_proc() RENAME TO test_proc_modified; |
| | | ALTER PROCEDURE |
| | | |
| | | SELECT |
| | | (modification_date > creation_date) AS modified, |
| | | name = 'test_proc_modified' AS name_updated |
| | | FROM proc_date_modification |
| | | WHERE prooid = (SELECT oid FROM pg_proc WHERE proname = 'test_proc_modified'); |
| | | modified | name_updated |
| | | ----------+-------------- |
| | | t | t |
| | | (1 row) |
| | | |
| | | DROP PROCEDURE test_proc_modified(); |
| | | DROP PROCEDURE |
| | | |
| | | SELECT |
| | | prooid = -1 AS marked_deleted, |
| | | deletion_user IS NOT NULL, |
| | | deletion_date IS NOT NULL |
| | | FROM proc_date_modification |
| | | WHERE name = 'test_proc_modified'; |
| | | marked_deleted | ?column? | ?column? |
| | | ----------------+----------+---------- |
| | | t | t | t |
| | | (1 row) |
| | | |
| | | SELECT to_char(deletion_date, 'YYYY-MM-DD HH24:MI') = (SELECT to_char(current_timestamp, 'YYYY-MM-DD HH24:MI')) |
| | | FROM proc_date_modification |
| | | WHERE name = 'test_proc_modified'; |
| | | ?column? |
| | | ---------- |
| | | t |
| | | (1 row) |
| | | |
| | | CALL proc_date_clear(); |
| | | CALL |
| | | |
| | | SELECT * FROM proc_date_modification WHERE name LIKE 'test_%' AND prooid = -1; |
| | | prooid | name | creation_user | creation_date | modification_user | modification_date | deletion_user | deletion_date |
| | | --------+------+---------------+---------------+-------------------+-------------------+---------------+--------------- |
| | | SELECT oid is not null FROM pg_event_trigger WHERE evtname = 'proc_date_drop_trigger';
|
| | | ?column? |
| | | ----------
|
| | | t
|
| | | (1 row)
|
| | |
|
| | | SELECT oid is not null FROM pg_event_trigger WHERE evtname = 'proc_date_modification_trigger';
|
| | | ?column? |
| | | ----------
|
| | | t
|
| | | (1 row)
|
| | |
|
| | | CREATE FUNCTION test_fn() RETURNS INT AS $$ SELECT 1 $$ LANGUAGE SQL;
|
| | | CREATE FUNCTION
|
| | |
|
| | | SELECT prooid is not null FROM proc_date_modification WHERE name = 'test_fn';
|
| | | ?column? |
| | | ----------
|
| | | t
|
| | | (1 row)
|
| | |
|
| | | SELECT to_char(creation_date, 'YYYY-MM-DD HH24:MI') = (SELECT to_char(current_timestamp, 'YYYY-MM-DD HH24:MI')) |
| | | FROM proc_date_modification
|
| | | WHERE name = 'test_fn';
|
| | | ?column? |
| | | ----------
|
| | | t
|
| | | (1 row)
|
| | |
|
| | | ALTER FUNCTION test_fn() RENAME TO test_fn_modified;
|
| | | ALTER FUNCTION
|
| | |
|
| | | SELECT |
| | | (modification_date > creation_date) AS modified,
|
| | | name = 'test_fn_modified' AS name_updated
|
| | | FROM proc_date_modification |
| | | WHERE prooid = (SELECT oid FROM pg_proc WHERE proname = 'test_fn_modified');
|
| | | modified | name_updated |
| | | ----------+--------------
|
| | | t | t
|
| | | (1 row)
|
| | |
|
| | | DROP FUNCTION test_fn_modified();
|
| | | DROP FUNCTION
|
| | |
|
| | | SELECT |
| | | prooid = -1 AS marked_deleted,
|
| | | deletion_user IS NOT NULL,
|
| | | deletion_date IS NOT NULL
|
| | | FROM proc_date_modification |
| | | WHERE name = 'test_fn_modified';
|
| | | marked_deleted | ?column? | ?column? |
| | | ----------------+----------+----------
|
| | | t | t | t
|
| | | (1 row)
|
| | |
|
| | | SELECT to_char(deletion_date, 'YYYY-MM-DD HH24:MI') = (SELECT to_char(current_timestamp, 'YYYY-MM-DD HH24:MI')) |
| | | FROM proc_date_modification
|
| | | WHERE name = 'test_fn_modified';
|
| | | ?column? |
| | | ----------
|
| | | t
|
| | | (1 row)
|
| | |
|
| | | CREATE PROCEDURE test_proc() AS $$ BEGIN END; $$ LANGUAGE plpgsql;
|
| | | CREATE PROCEDURE
|
| | |
|
| | | SELECT prooid is not null FROM proc_date_modification WHERE name = 'test_proc';
|
| | | ?column? |
| | | ----------
|
| | | t
|
| | | (1 row)
|
| | |
|
| | | SELECT to_char(creation_date, 'YYYY-MM-DD HH24:MI') = (SELECT to_char(current_timestamp, 'YYYY-MM-DD HH24:MI')) |
| | | FROM proc_date_modification
|
| | | WHERE name = 'test_proc';
|
| | | ?column? |
| | | ----------
|
| | | t
|
| | | (1 row)
|
| | |
|
| | | ALTER PROCEDURE test_proc() RENAME TO test_proc_modified;
|
| | | ALTER PROCEDURE
|
| | |
|
| | | SELECT |
| | | (modification_date > creation_date) AS modified,
|
| | | name = 'test_proc_modified' AS name_updated
|
| | | FROM proc_date_modification |
| | | WHERE prooid = (SELECT oid FROM pg_proc WHERE proname = 'test_proc_modified');
|
| | | modified | name_updated |
| | | ----------+--------------
|
| | | t | t
|
| | | (1 row)
|
| | |
|
| | | DROP PROCEDURE test_proc_modified();
|
| | | DROP PROCEDURE
|
| | |
|
| | | SELECT |
| | | prooid = -1 AS marked_deleted,
|
| | | deletion_user IS NOT NULL,
|
| | | deletion_date IS NOT NULL
|
| | | FROM proc_date_modification |
| | | WHERE name = 'test_proc_modified';
|
| | | marked_deleted | ?column? | ?column? |
| | | ----------------+----------+----------
|
| | | t | t | t
|
| | | (1 row)
|
| | |
|
| | | SELECT to_char(deletion_date, 'YYYY-MM-DD HH24:MI') = (SELECT to_char(current_timestamp, 'YYYY-MM-DD HH24:MI'))
|
| | | FROM proc_date_modification
|
| | | WHERE name = 'test_proc_modified';
|
| | | ?column? |
| | | ----------
|
| | | t
|
| | | (1 row)
|
| | |
|
| | | CALL proc_date_clear();
|
| | | CALL
|
| | |
|
| | | SELECT * FROM proc_date_modification WHERE name LIKE 'test_%' AND prooid = -1;
|
| | | prooid | name | creation_user | creation_date | modification_user | modification_date | deletion_user | deletion_date |
| | | --------+------+---------------+---------------+-------------------+-------------------+---------------+---------------
|
| | | (0 rows) |
| | |
| | | -- Проверка созданных объектов |
| | | SELECT oid is not null FROM pg_event_trigger WHERE evtname = 'proc_date_drop_trigger'; |
| | | SELECT oid is not null FROM pg_event_trigger WHERE evtname = 'proc_date_modification_trigger'; |
| | | |
| | | -- Тест 1: Создание функции |
| | | CREATE FUNCTION test_fn() RETURNS INT AS $$ SELECT 1 $$ LANGUAGE SQL; |
| | | |
| | | -- Проверка записи |
| | | SELECT prooid is not null FROM proc_date_modification WHERE name = 'test_fn'; |
| | | |
| | | -- Проверка времени создания |
| | | SELECT to_char(creation_date, 'YYYY-MM-DD HH24:MI') = (SELECT to_char(current_timestamp, 'YYYY-MM-DD HH24:MI')) |
| | | FROM proc_date_modification |
| | | WHERE name = 'test_fn'; |
| | | |
| | | -- Тест 2: Изменение функции |
| | | ALTER FUNCTION test_fn() RENAME TO test_fn_modified; |
| | | |
| | | -- Проверка времени изменений |
| | | SELECT |
| | | (modification_date > creation_date) AS modified, |
| | | name = 'test_fn_modified' AS name_updated |
| | | FROM proc_date_modification |
| | | WHERE prooid = (SELECT oid FROM pg_proc WHERE proname = 'test_fn_modified'); |
| | | |
| | | -- Тест 3: Удаление функции |
| | | DROP FUNCTION test_fn_modified(); |
| | | |
| | | -- Проверка пометки на удаление |
| | | SELECT |
| | | prooid = -1 AS marked_deleted, |
| | | deletion_user IS NOT NULL, |
| | | deletion_date IS NOT NULL |
| | | FROM proc_date_modification |
| | | WHERE name = 'test_fn_modified'; |
| | | |
| | | -- Проверка времени удаления |
| | | SELECT to_char(deletion_date, 'YYYY-MM-DD HH24:MI') = (SELECT to_char(current_timestamp, 'YYYY-MM-DD HH24:MI')) |
| | | FROM proc_date_modification |
| | | WHERE name = 'test_fn_modified'; |
| | | |
| | | -- Тест 4: Создание процедуры |
| | | CREATE PROCEDURE test_proc() AS $$ BEGIN END; $$ LANGUAGE plpgsql; |
| | | |
| | | -- Проверка записи |
| | | SELECT prooid is not null FROM proc_date_modification WHERE name = 'test_proc'; |
| | | |
| | | -- Проверка времени создания |
| | | SELECT to_char(creation_date, 'YYYY-MM-DD HH24:MI') = (SELECT to_char(current_timestamp, 'YYYY-MM-DD HH24:MI')) |
| | | FROM proc_date_modification |
| | | WHERE name = 'test_proc'; |
| | | |
| | | -- Тест 5: Изменение процедуры |
| | | ALTER PROCEDURE test_proc() RENAME TO test_proc_modified; |
| | | |
| | | -- Проверка времени изменений |
| | | SELECT |
| | | (modification_date > creation_date) AS modified, |
| | | name = 'test_proc_modified' AS name_updated |
| | | FROM proc_date_modification |
| | | WHERE prooid = (SELECT oid FROM pg_proc WHERE proname = 'test_proc_modified'); |
| | | |
| | | -- Тест 6: Удаление процедуры |
| | | DROP PROCEDURE test_proc_modified(); |
| | | |
| | | -- Проверка пометки на удаление |
| | | SELECT |
| | | prooid = -1 AS marked_deleted, |
| | | deletion_user IS NOT NULL, |
| | | deletion_date IS NOT NULL |
| | | FROM proc_date_modification |
| | | WHERE name = 'test_proc_modified'; |
| | | |
| | | -- Проверка времени удаления |
| | | SELECT to_char(deletion_date, 'YYYY-MM-DD HH24:MI') = (SELECT to_char(current_timestamp, 'YYYY-MM-DD HH24:MI')) |
| | | FROM proc_date_modification |
| | | WHERE name = 'test_proc_modified'; |
| | | |
| | | -- Тест 7: Очистка удаленных записей |
| | | CALL proc_date_clear(); |
| | | |
| | | -- Проверка отсутствия удаленных объектов |
| | | SELECT * FROM proc_date_modification WHERE name LIKE 'test_%' AND prooid = -1; |
| | | -- Проверка созданных объектов
|
| | | SELECT oid is not null FROM pg_event_trigger WHERE evtname = 'proc_date_drop_trigger';
|
| | | SELECT oid is not null FROM pg_event_trigger WHERE evtname = 'proc_date_modification_trigger';
|
| | |
|
| | | -- Тест 1: Создание функции
|
| | | CREATE FUNCTION test_fn() RETURNS INT AS $$ SELECT 1 $$ LANGUAGE SQL;
|
| | |
|
| | | -- Проверка записи
|
| | | SELECT prooid is not null FROM proc_date_modification WHERE name = 'test_fn';
|
| | |
|
| | | -- Проверка времени создания
|
| | | SELECT to_char(creation_date, 'YYYY-MM-DD HH24:MI') = (SELECT to_char(current_timestamp, 'YYYY-MM-DD HH24:MI')) |
| | | FROM proc_date_modification
|
| | | WHERE name = 'test_fn';
|
| | |
|
| | | -- Тест 2: Изменение функции
|
| | | ALTER FUNCTION test_fn() RENAME TO test_fn_modified;
|
| | |
|
| | | -- Проверка времени изменений
|
| | | SELECT |
| | | (modification_date > creation_date) AS modified,
|
| | | name = 'test_fn_modified' AS name_updated
|
| | | FROM proc_date_modification |
| | | WHERE prooid = (SELECT oid FROM pg_proc WHERE proname = 'test_fn_modified');
|
| | |
|
| | | -- Тест 3: Удаление функции
|
| | | DROP FUNCTION test_fn_modified();
|
| | |
|
| | | -- Проверка пометки на удаление
|
| | | SELECT |
| | | prooid = -1 AS marked_deleted,
|
| | | deletion_user IS NOT NULL,
|
| | | deletion_date IS NOT NULL
|
| | | FROM proc_date_modification |
| | | WHERE name = 'test_fn_modified';
|
| | |
|
| | | -- Проверка времени удаления
|
| | | SELECT to_char(deletion_date, 'YYYY-MM-DD HH24:MI') = (SELECT to_char(current_timestamp, 'YYYY-MM-DD HH24:MI')) |
| | | FROM proc_date_modification
|
| | | WHERE name = 'test_fn_modified';
|
| | |
|
| | | -- Тест 4: Создание процедуры
|
| | | CREATE PROCEDURE test_proc() AS $$ BEGIN END; $$ LANGUAGE plpgsql;
|
| | |
|
| | | -- Проверка записи
|
| | | SELECT prooid is not null FROM proc_date_modification WHERE name = 'test_proc';
|
| | |
|
| | | -- Проверка времени создания
|
| | | SELECT to_char(creation_date, 'YYYY-MM-DD HH24:MI') = (SELECT to_char(current_timestamp, 'YYYY-MM-DD HH24:MI')) |
| | | FROM proc_date_modification
|
| | | WHERE name = 'test_proc';
|
| | |
|
| | | -- Тест 5: Изменение процедуры
|
| | | ALTER PROCEDURE test_proc() RENAME TO test_proc_modified;
|
| | |
|
| | | -- Проверка времени изменений
|
| | | SELECT |
| | | (modification_date > creation_date) AS modified,
|
| | | name = 'test_proc_modified' AS name_updated
|
| | | FROM proc_date_modification |
| | | WHERE prooid = (SELECT oid FROM pg_proc WHERE proname = 'test_proc_modified');
|
| | |
|
| | | -- Тест 6: Удаление процедуры
|
| | | DROP PROCEDURE test_proc_modified();
|
| | |
|
| | | -- Проверка пометки на удаление
|
| | | SELECT |
| | | prooid = -1 AS marked_deleted,
|
| | | deletion_user IS NOT NULL,
|
| | | deletion_date IS NOT NULL
|
| | | FROM proc_date_modification |
| | | WHERE name = 'test_proc_modified';
|
| | |
|
| | | -- Проверка времени удаления
|
| | | SELECT to_char(deletion_date, 'YYYY-MM-DD HH24:MI') = (SELECT to_char(current_timestamp, 'YYYY-MM-DD HH24:MI')) |
| | | FROM proc_date_modification
|
| | | WHERE name = 'test_proc_modified';
|
| | |
|
| | | -- Тест 7: Очистка удаленных записей
|
| | | CALL proc_date_clear();
|
| | |
|
| | | -- Проверка отсутствия удаленных объектов
|
| | | SELECT * FROM proc_date_modification WHERE name LIKE 'test_%' AND prooid = -1;
|
| | |
| | | BIN_PATH="/usr/local/rudb/bin" |
| | | DATA_DIR="/usr/local/rudb/data1" |
| | | PORT=5432 |
| | | DBUSER="postgres" |
| | | DBUSER="${RUDB_DBUSER:-postgres}" |
| | | DBOSUSER="${RUDB_OS_USER:-}" |
| | | LOG_FILE="$DATA_DIR/server.log" |
| | | |
| | | # Получаем ID текущего пользователя |
| | | CUR_UID=$(id -u) |
| | | CUR_GID=$(id -g) |
| | | pick_dbosuser() { |
| | | if [ -n "$DBOSUSER" ] && id "$DBOSUSER" > /dev/null 2>&1; then |
| | | echo "$DBOSUSER" |
| | | return 0 |
| | | fi |
| | | |
| | | echo ">>> Запуск инициализации RUDB для UID: $CUR_UID..." |
| | | for candidate in qdbadmin postgres; do |
| | | if id "$candidate" > /dev/null 2>&1; then |
| | | echo "$candidate" |
| | | return 0 |
| | | fi |
| | | done |
| | | |
| | | if [ -n "${SUDO_USER:-}" ] && id "$SUDO_USER" > /dev/null 2>&1; then |
| | | echo "$SUDO_USER" |
| | | return 0 |
| | | fi |
| | | |
| | | id -un |
| | | } |
| | | |
| | | run_as_dbosuser() { |
| | | if [ "$(id -un)" = "$DBOSUSER" ]; then |
| | | "$@" |
| | | else |
| | | sudo -u "$DBOSUSER" "$@" |
| | | fi |
| | | } |
| | | |
| | | run_as_root() { |
| | | if [ "$(id -u)" -eq 0 ]; then |
| | | "$@" |
| | | else |
| | | sudo "$@" |
| | | fi |
| | | } |
| | | |
| | | DBOSUSER=$(pick_dbosuser) |
| | | CUR_UID=$(id -u "$DBOSUSER") |
| | | CUR_GID=$(id -g "$DBOSUSER") |
| | | |
| | | if systemctl list-unit-files | grep -q rudb.service; then |
| | | managed_by_systemd=true |
| | | else |
| | | managed_by_systemd=false |
| | | fi |
| | | |
| | | start_rudb() { |
| | | if $managed_by_systemd; then |
| | | run_as_root systemctl start rudb.service |
| | | else |
| | | run_as_dbosuser "$BIN_PATH/pg_ctl" -D "$DATA_DIR" -l "$LOG_FILE" start |
| | | sleep 2 |
| | | run_as_dbosuser "$BIN_PATH/pg_ctl" -D "$DATA_DIR" status |
| | | fi |
| | | } |
| | | |
| | | stop_rudb() { |
| | | if $managed_by_systemd; then |
| | | run_as_root systemctl stop rudb.service |
| | | else |
| | | run_as_dbosuser "$BIN_PATH/pg_ctl" -D "$DATA_DIR" stop |
| | | fi |
| | | } |
| | | |
| | | echo ">>> Инициализация RUDB: OS user=$DBOSUSER, DB user=$DBUSER, UID=$CUR_UID" |
| | | |
| | | # 1. Останавливаем старый экземпляр |
| | | $BIN_PATH/pg_ctl -D "$DATA_DIR" stop > /dev/null 2>&1 |
| | | stop_rudb |
| | | |
| | | # 2. Подготавливаем директорию с правильными правами |
| | | if [ -d "$DATA_DIR" ]; then |
| | | sudo rm -rf "$DATA_DIR" |
| | | run_as_root rm -rf "$DATA_DIR" |
| | | fi |
| | | sudo mkdir -p "$DATA_DIR" |
| | | run_as_root mkdir -p "$DATA_DIR" |
| | | |
| | | sudo chown -R $CUR_UID:$CUR_GID "$DATA_DIR" |
| | | sudo chmod 700 "$DATA_DIR" |
| | | run_as_root chown -R "$CUR_UID:$CUR_GID" "$DATA_DIR" |
| | | run_as_root chmod 700 "$DATA_DIR" |
| | | |
| | | # 3. Инициализация |
| | | $BIN_PATH/initdb -D "$DATA_DIR" --locale=ru_RU.UTF-8 --encoding=UTF8 --username=$DBUSER |
| | | run_as_dbosuser "$BIN_PATH/initdb" -D "$DATA_DIR" --locale=ru_RU.UTF-8 --encoding=UTF8 --username="$DBUSER" |
| | | |
| | | if [ $? -ne 0 ]; then |
| | | echo "!!! Ошибка во время initdb. Проверьте права доступа." |
| | |
| | | fi |
| | | |
| | | # 4. Обновление конфигурации |
| | | sed -i "s/^#port =.*/port = $PORT/" "$DATA_DIR/postgresql.conf" |
| | | sed -i "s/^#logging_collector =.*/logging_collector = on/" "$DATA_DIR/postgresql.conf" |
| | | sed -i "s|^#log_directory.*|log_directory = 'log'|" "$DATA_DIR/postgresql.conf" |
| | | run_as_dbosuser sed -i "s/^#port =.*/port = $PORT/" "$DATA_DIR/postgresql.conf" |
| | | run_as_dbosuser sed -i "s/^#logging_collector =.*/logging_collector = on/" "$DATA_DIR/postgresql.conf" |
| | | run_as_dbosuser sed -i "s|^#log_directory.*|log_directory = 'log'|" "$DATA_DIR/postgresql.conf" |
| | | |
| | | # 5. Запуск сервера |
| | | $BIN_PATH/pg_ctl -D "$DATA_DIR" -l "$LOG_FILE" start |
| | | sleep 2 |
| | | $BIN_PATH/pg_ctl -D "$DATA_DIR" status |
| | | start_rudb |
| | | |
| | | # --- БЛОК 5.5: ИНИЦИАЛИЗАЦИЯ TEMPLATE1 --- |
| | | echo ">>> Инициализация template1 из $SQL_INIT_FILE..." |
| | |
| | | |
| | | echo ">>> Применяем init.sql к template1..." |
| | | |
| | | $BIN_PATH/psql -p $PORT -U $DBUSER -d template1 -f "$SQL_INIT_FILE" |
| | | "$BIN_PATH/psql" -p "$PORT" -U "$DBUSER" -d template1 -f "$SQL_INIT_FILE" |
| | | |
| | | if [ $? -ne 0 ]; then |
| | | echo "!!! Ошибка при выполнении init.sql для template1. Прерывание..." |
| | | $BIN_PATH/pg_ctl -D "$DATA_DIR" stop |
| | | stop_rudb |
| | | exit 1 |
| | | fi |
| | | else |
| | |
| | | |
| | | # 6. Создаем БД |
| | | echo ">>> Создание базы данных..." |
| | | $BIN_PATH/createdb -p $PORT -U $DBUSER rudb |
| | | run_as_dbosuser "$BIN_PATH/createdb" -p "$PORT" -U "$DBUSER" rudb |
| | | |
| | | # 7. ОСТАНАВЛИВАЕМ сервер (Обязательно перед созданием архива!) |
| | | echo ">>> Остановка сервера перед архивированием..." |
| | | $BIN_PATH/pg_ctl -D "$DATA_DIR" stop |
| | | stop_rudb |
| | | sleep 2 |
| | | |
| | | # 8. УПАКОВЫВАЕМ АРХИВ |
| | | sudo tar -czf rudb_data1.tar.gz -C "$DATA_DIR" . |
| | | run_as_root tar -czf rudb_data1.tar.gz -C "$DATA_DIR" . |
| | | echo ">>> Архив БД успешно создан!" |
| | | |
| | | # 9. Финальный запуск |
| | | if [ "$STOP_AT_END" -eq 0 ]; then |
| | | echo ">>> Повторный запуск сервера..." |
| | | $BIN_PATH/pg_ctl -D "$DATA_DIR" -l "$LOG_FILE" start |
| | | start_rudb |
| | | else |
| | | echo ">>> Указан ключ --stop. Финальный запуск сервера пропущен." |
| | | fi |
| | | fi |
| | |
| | | ExecStart=$RUDB_PATH/bin/dgridd |
| | | Type=idle |
| | | KillMode=process |
| | | |
| | | |
| | | SyslogIdentifier=DGrid |
| | | SyslogFacility=daemon |
| | | StandardOutput=syslog |
| | |
| | | Environment="LANG=C.UTF-8" |
| | | Environment="LC_MESSAGES=C.UTF-8" |
| | | Environment="LC_ALL=C.UTF-8" |
| | | |
| | | Environment="LD_LIBRARY_PATH=$RUDB_PATH/lib" |
| | | |
| | | Restart=on-failure |
| | | |
| | | |
| | | [Install] |
| | | WantedBy=multi-user.target |
| | | EOF_SYSTEMD |
| | |
| | | Requires: systemd |
| | | Requires(pre): shadow-utils |
| | | Requires: libpq5 |
| | | Requires: libgeos |
| | | Requires: libproj |
| | | Requires: libprotobuf-c1 |
| | | Source1: <RUDB_SERVICE> |
| | | BuildRoot: %{_tmppath}/%{name}-%{version}-root |
| | | |
| | |
| | | mkdir -p rudb_deb_package/rudb/DEBIAN |
| | | # Инициализация переменных для версии ОС (по умолчанию) |
| | | OS_VERSION="astra1.8" |
| | | ADD_DEB=", libboost-system1.74.0, libboost-thread1.74.0, libc6 (>= 2.29)" |
| | | POSTGIS_DEB_RUNTIME=", libgdal32, libgeos-c1v5, libjson-c5, libproj25, libprotobuf-c1, libsfcgal1" |
| | | ADD_DEB=", libboost-system1.74.0, libboost-thread1.74.0, libc6 (>= 2.29), libxml2, libxslt1.1${POSTGIS_DEB_RUNTIME}" |
| | | |
| | | # Обработка аргументов командной строки |
| | | while [[ $# -gt 0 ]]; do |
| | |
| | | RUDB_DB_PATH="$2" |
| | | shift 2 |
| | | ;; |
| | | -rudb_log_path) |
| | | -rudb_log_path) |
| | | LOG_PATH="$2" |
| | | shift 2 |
| | | ;; |
| | | -rudb_version) |
| | | -rudb_version) |
| | | MAJOR_VERSION="$2" |
| | | shift 2 |
| | | ;; |
| | |
| | | case "$2" in |
| | | a17) |
| | | OS_VERSION="astra1.7" |
| | | ADD_DEB=", libboost-system1.67.0, libboost-thread1.67.0, libboost-chrono1.67.0, libboost-date-time1.67.0, libboost-atomic1.67.0, freetds-bin, freetds-common, libc6 (>= 2.28)" |
| | | ADD_DEB=", libboost-system1.67.0, libboost-thread1.67.0, libboost-chrono1.67.0, libboost-date-time1.67.0, libboost-atomic1.67.0, freetds-bin, freetds-common, libc6 (>= 2.28)" |
| | | ;; |
| | | a18) |
| | | OS_VERSION=$OS_VERSION # по умолчанию |
| | |
| | | ;; |
| | | u22) |
| | | OS_VERSION="ubuntu22.04" |
| | | ADD_DEB=", libboost-system1.74.0, libboost-thread1.74.0, freetds-bin, freetds-common, libsybdb5,libc6 (>= 2.34), libicu70, libcurl4, libssl3, zlib1g, libxml2, libxslt1.1, libreadline8, libldap-2.5-0, libkrb5-3, libedit2, libuuid1, libpam0g" |
| | | ADD_DEB=", libboost-system1.74.0, libboost-thread1.74.0, freetds-bin, freetds-common, libsybdb5,libc6 (>= 2.34), libicu70, libcurl4, libssl3, zlib1g, libxml2, libxslt1.1, libreadline8, libldap-2.5-0, libkrb5-3, libedit2, libuuid1, libpam0g${POSTGIS_DEB_RUNTIME}" |
| | | ;; |
| | | u24) |
| | | OS_VERSION="ubuntu24.04" |
| | | ADD_DEB=", libboost-system1.74.0, libboost-thread1.74.0, freetds-bin, freetds-common, libsybdb5,libc6 (>= 2.34), libicu74, libcurl4, libssl3, zlib1g, libxml2, libxslt1.1, libreadline8, libldap2 (>= 2.6), libkrb5-3, libedit2, libuuid1, libpam0g" |
| | | ADD_DEB=", libboost-system1.74.0, libboost-thread1.74.0, freetds-bin, freetds-common, libsybdb5,libc6 (>= 2.34), libicu74, libcurl4, libssl3, zlib1g, libxml2, libxslt1.1, libreadline8, libldap2 (>= 2.6), libkrb5-3, libedit2, libuuid1, libpam0g${POSTGIS_DEB_RUNTIME}" |
| | | ;; |
| | | *) |
| | | echo "Неизвестная версия ОС: $2" |
| | |
| | | fi |
| | | |
| | | # Формирование имени сервиса на базе номера версии RUDB |
| | | RUDB_SERVICE="rudb-$MAJOR_VERSION" |
| | | RUDB_SERVICE="rudb-$MAJOR_VERSION" |
| | | # Получение версии PostgreSQL из команды `psql -V` |
| | | PG_VERSION=$(psql -V | awk '{print $3}') |
| | | |
| | |
| | | |
| | | BIN_PATH="\$RUDB_PATH/bin" |
| | | LINK_PATH="/usr/bin" |
| | | LINK_BACKUP_DIR="\$(dirname "\$RUDB_DB_PATH")/link-backup" |
| | | |
| | | # Проверка: есть ли доступный psql |
| | | if command -v psql >/dev/null 2>&1; then |
| | | NEED_ORIGINAL_LINKS=false |
| | | else |
| | | NEED_ORIGINAL_LINKS=true |
| | | fi |
| | | create_rudb_link() { |
| | | local src="\$1" |
| | | local target="\$2" |
| | | local src_path="\${BIN_PATH}/\${src}" |
| | | local link="\${LINK_PATH}/\${target}" |
| | | local backup_target="\${LINK_BACKUP_DIR}/\${target}.target" |
| | | local missing_marker="\${LINK_BACKUP_DIR}/\${target}.missing" |
| | | local current_target="" |
| | | |
| | | if [ ! -e "\$src_path" ]; then |
| | | echo "Skip \$link: source \$src_path not found" |
| | | return 0 |
| | | fi |
| | | |
| | | mkdir -p "\$LINK_BACKUP_DIR" |
| | | |
| | | if [ -L "\$link" ]; then |
| | | current_target="\$(readlink "\$link")" |
| | | |
| | | if [ "\$current_target" != "\$src_path" ]; then |
| | | if [ ! -e "\$backup_target" ] && [ ! -e "\$missing_marker" ]; then |
| | | printf '%s\n' "\$current_target" > "\$backup_target" |
| | | echo "Backup symlink: \$link -> \$current_target" |
| | | fi |
| | | fi |
| | | |
| | | rm -f "\$link" |
| | | ln -s "\$src_path" "\$link" |
| | | echo "Linked: \$link -> \$src_path" |
| | | return 0 |
| | | fi |
| | | |
| | | if [ ! -e "\$link" ]; then |
| | | if [ ! -e "\$backup_target" ] && [ ! -e "\$missing_marker" ]; then |
| | | touch "\$missing_marker" |
| | | echo "Marked missing command: \$link" |
| | | fi |
| | | |
| | | ln -s "\$src_path" "\$link" |
| | | echo "Linked: \$link -> \$src_path" |
| | | return 0 |
| | | fi |
| | | |
| | | echo "WARNING: \$link exists and is not a symlink. Not replacing it." |
| | | } |
| | | |
| | | for src in "\${!LINKS[@]}"; do |
| | | target="\${LINKS[\$src]}" |
| | | |
| | | # Создаём симлинк |
| | | rm -f "\${LINK_PATH}/\${target}" |
| | | ln -s "\${BIN_PATH}/\${src}" "\${LINK_PATH}/\${target}" |
| | | # echo "Created symlink: \${LINK_PATH}/\${target} -> \${BIN_PATH}/\${src}" |
| | | |
| | | # Если нужно — создаём ещё и оригинальное имя (только если src != target) |
| | | if [[ "\$NEED_ORIGINAL_LINKS" == "true" ]] && [[ "\$src" != "\$target" ]]; then |
| | | rm -f "\${LINK_PATH}/\${src}" |
| | | ln -s "\${BIN_PATH}/\${src}" "\${LINK_PATH}/\${src}" |
| | | # echo "Created original symlink: \${LINK_PATH}/\${src} -> \${BIN_PATH}/\${src}" |
| | | fi |
| | | create_rudb_link "\$src" "\$target" |
| | | done |
| | | |
| | | sudo cp $RUDB_PATH/bin/dgridd.conf /etc/ |
| | | sudo rm /usr/lib/x86_64-linux-gnu/libpq.so.5 |
| | | sudo ln -sf $RUDB_PATH/lib/libpq.so.5.17 /usr/lib/x86_64-linux-gnu/libpq.so.5 |
| | | # Не заменяем системную libpq.so.5: это может сломать системные PostgreSQL-клиенты. |
| | | # RUDB-библиотеки подключаются через отдельный ld.so.conf.d файл. |
| | | echo "$RUDB_PATH/lib" | sudo tee /etc/ld.so.conf.d/rudb.conf |
| | | sudo ldconfig |
| | | |
| | |
| | | ExecStart=$RUDB_PATH/bin/dgridd |
| | | Type=idle |
| | | KillMode=process |
| | | |
| | | |
| | | SyslogIdentifier=DGrid |
| | | SyslogFacility=daemon |
| | | StandardOutput=syslog |
| | | StandardError=syslog |
| | | Environment="LD_LIBRARY_PATH=$RUDB_PATH/lib" |
| | | Restart=on-failure |
| | | |
| | | [Install] |
| | |
| | | # Очищаем состояние "неудачных" сервисов в systemd |
| | | sudo systemctl reset-failed || true |
| | | |
| | | services=("$RUDB_SERVICE" "dgrid") |
| | | |
| | | # Удаление юнит-файлов |
| | | for service in "\${services[@]}"; do |
| | | unit_file="/etc/systemd/system/\${service}" |
| | | unit_file="/etc/systemd/system/\${service}.service" |
| | | if [[ -f "\$unit_file" ]]; then |
| | | echo "Удаление юнит-файла: \$unit_file" |
| | | sudo rm -f "\$unit_file" |
| | |
| | | # Перезагрузка systemd для применения изменений |
| | | sudo systemctl daemon-reload || true |
| | | |
| | | # Удаление системного пользователя $DBADMIN |
| | | if id "$DBADMIN" >/dev/null 2>&1; then |
| | | sudo pkill -u $DBADMIN 2>/dev/null || true |
| | | sleep 1 |
| | | sudo pkill -9 -u $DBADMIN 2>/dev/null || true |
| | | sleep 1 |
| | | sudo deluser --remove-home $DBADMIN || true |
| | | fi |
| | | # Пользователь $DBADMIN может быть создан не этим пакетом и использоваться другими сервисами. |
| | | # Поэтому при удалении пакета его не удаляем. |
| | | |
| | | # Удаление симлинков |
| | | sudo rm -f /usr/local/bin/pg_ctl |
| | | sudo rm -f /usr/local/bin/initdb |
| | | sudo rm -f /usr/local/bin/clusterdb |
| | | sudo rm -f /usr/local/bin/createdb |
| | | sudo rm -f /usr/local/bin/dropdb |
| | | sudo rm -f /usr/local/bin/reindexdb |
| | | sudo rm -f /usr/local/bin/vacuumdb |
| | | sudo rm -f /usr/local/bin/vacuumlo |
| | | sudo rm -f /usr/local/bin/createuser |
| | | sudo rm -f /usr/local/bin/dropuser |
| | | sudo rm -f /usr/local/bin/psql |
| | | sudo rm -f /usr/local/bin/pg_isready |
| | | sudo rm -f /usr/local/bin/pgbench |
| | | sudo rm -f /usr/local/bin/pg_dump |
| | | sudo rm -f /usr/local/bin/pg_dumpall |
| | | sudo rm -f /usr/local/bin/pg_restore |
| | | sudo rm -f /usr/local/bin/pg_basebackup |
| | | sudo rm -f /usr/local/bin/pg_combinebackup |
| | | sudo rm -f /usr/local/bin/pg_verifybackup |
| | | sudo rm -f /usr/local/bin/pg_receivewal |
| | | sudo rm -f /usr/local/bin/pg_recvlogical |
| | | sudo rm -f /usr/local/bin/pg_resetwal |
| | | sudo rm -f /usr/local/bin/pg_rewind |
| | | sudo rm -f /usr/local/bin/pg_waldump |
| | | sudo rm -f /usr/local/bin/pg_walsummary |
| | | sudo rm -f /usr/local/bin/pg_amcheck |
| | | sudo rm -f /usr/local/bin/pg_checksums |
| | | sudo rm -f /usr/local/bin/pg_controldata |
| | | sudo rm -f /usr/local/bin/pg_upgrade |
| | | sudo rm -f /usr/local/bin/pg_test_fsync |
| | | sudo rm -f /usr/local/bin/pg_test_timing |
| | | sudo rm -f /usr/local/bin/ecpg |
| | | sudo rm -f /usr/local/bin/oid2name |
| | | LINK_PATH="/usr/bin" |
| | | RUDB_DB_PATH='$RUDB_DB_PATH' |
| | | LINK_BACKUP_DIR="\$(dirname "\$RUDB_DB_PATH")/link-backup" |
| | | |
| | | tools=( |
| | | pg_ctl initdb clusterdb createdb dropdb reindexdb vacuumdb vacuumlo |
| | | createuser dropuser psql pg_isready pgbench pg_dump pg_dumpall pg_restore |
| | | pg_basebackup pg_combinebackup pg_verifybackup pg_receivewal pg_recvlogical |
| | | pg_resetwal pg_rewind pg_waldump pg_walsummary pg_amcheck pg_checksums |
| | | pg_controldata pg_upgrade pg_test_fsync pg_test_timing ecpg oid2name |
| | | ) |
| | | |
| | | restore_or_remove_rudb_link() { |
| | | local tool="\$1" |
| | | local link="\${LINK_PATH}/\${tool}" |
| | | local rudb_target="\${RUDB_PATH}/bin/\${tool}" |
| | | local backup_target="\${LINK_BACKUP_DIR}/\${tool}.target" |
| | | local missing_marker="\${LINK_BACKUP_DIR}/\${tool}.missing" |
| | | local current_target="" |
| | | local old_target="" |
| | | |
| | | if [ -L "\$link" ]; then |
| | | current_target="\$(readlink "\$link")" |
| | | if [ "\$current_target" = "\$rudb_target" ]; then |
| | | rm -f "\$link" |
| | | echo "Removed RuDB link: \$link" |
| | | else |
| | | echo "Skip \$link: it does not point to RUDB" |
| | | fi |
| | | fi |
| | | |
| | | if [ -f "\$backup_target" ]; then |
| | | old_target="\$(cat "\$backup_target")" |
| | | if [ ! -e "\$link" ] && [ ! -L "\$link" ]; then |
| | | ln -s "\$old_target" "\$link" |
| | | rm -f "\$backup_target" |
| | | echo "Restored symlink: \$link -> \$old_target" |
| | | else |
| | | echo "WARNING: \$link already exists; backup was not restored automatically: \$backup_target" |
| | | fi |
| | | return 0 |
| | | fi |
| | | |
| | | if [ -f "\$missing_marker" ]; then |
| | | rm -f "\$missing_marker" |
| | | echo "No previous command for \$link; left absent" |
| | | fi |
| | | } |
| | | |
| | | for tool in "\${tools[@]}"; do |
| | | restore_or_remove_rudb_link "\$tool" |
| | | done |
| | | |
| | | rmdir "\$LINK_BACKUP_DIR" 2>/dev/null || true |
| | | |
| | | sudo rm -f /etc/ld.so.conf.d/rudb.conf |
| | | sudo ldconfig || true |
| | | |
| | | exit 0 |
| | | EOF |
| | |
| | | mkdir -p rudb_deb_package/rudb/DEBIAN |
| | | # Инициализация переменных для версии ОС (по умолчанию) |
| | | OS_VERSION="ubuntu24.04" |
| | | ADD_DEB=", libboost-system1.74.0, libboost-thread1.74.0, freetds-bin, freetds-common, libsybdb5,libc6 (>= 2.34), libicu74, libcurl4, libssl3, zlib1g, libxml2, libxslt1.1, libreadline8, libldap2 (>= 2.6), libkrb5-3, libedit2, libuuid1, libpam0g" |
| | | |
| | | POSTGIS_DEB_RUNTIME=", libgdal34t64, libgeos-c1t64, libjson-c5, libproj25, libprotobuf-c1, libsfcgal1t64" |
| | | ADD_DEB=", libboost-system1.74.0, libboost-thread1.74.0, freetds-bin, freetds-common, libsybdb5,libc6 (>= 2.34), libicu74, libcurl4, libssl3, zlib1g, libxml2, libxslt1.1, libreadline8, libldap2 (>= 2.6), libkrb5-3, libedit2, libuuid1, libpam0g${POSTGIS_DEB_RUNTIME}, locales" |
| | | |
| | | # Обработка аргументов командной строки |
| | | while [[ $# -gt 0 ]]; do |
| | |
| | | RUDB_DB_PATH="$2" |
| | | shift 2 |
| | | ;; |
| | | -rudb_log_path) |
| | | -rudb_log_path) |
| | | LOG_PATH="$2" |
| | | shift 2 |
| | | ;; |
| | | -rudb_version) |
| | | -rudb_version) |
| | | MAJOR_VERSION="$2" |
| | | shift 2 |
| | | ;; |
| | |
| | | case "$2" in |
| | | a17) |
| | | OS_VERSION="astra1.7" |
| | | ADD_DEB=", libboost-system1.67.0, libboost-thread1.67.0, libboost-chrono1.67.0, libboost-date-time1.67.0, libboost-atomic1.67.0, freetds-bin, freetds-common, libc6 (>= 2.28)" |
| | | ADD_DEB=", libboost-system1.67.0, libboost-thread1.67.0, libboost-chrono1.67.0, libboost-date-time1.67.0, libboost-atomic1.67.0, freetds-bin, freetds-common, libc6 (>= 2.28)" |
| | | ;; |
| | | a18) |
| | | OS_VERSION="astra1.8" |
| | |
| | | ;; |
| | | u22) |
| | | OS_VERSION="ubuntu22.04" |
| | | ADD_DEB=", libboost-system1.74.0, libboost-thread1.74.0, libsybdb5,libc6 (>= 2.34), libicu70, libcurl4, libssl3, zlib1g, libxml2, libxslt1.1, libreadline8, libldap-2.5-0, libkrb5-3, libedit2, libuuid1, libpam0g" |
| | | ADD_DEB=", libboost-system1.74.0, libboost-thread1.74.0, libsybdb5,libc6 (>= 2.34), libicu70, libcurl4, libssl3, zlib1g, libxml2, libxslt1.1, libreadline8, libldap-2.5-0, libkrb5-3, libedit2, libuuid1, libpam0g${POSTGIS_DEB_RUNTIME}" |
| | | ;; |
| | | u24) |
| | | OS_VERSION=$OS_VERSION # по умолчанию |
| | |
| | | fi |
| | | |
| | | # Формирование имени сервиса на базе номера версии RUDB |
| | | RUDB_SERVICE="rudb-$MAJOR_VERSION" |
| | | RUDB_SERVICE="rudb-$MAJOR_VERSION" |
| | | # Получение версии PostgreSQL из команды `psql -V` |
| | | PG_VERSION=$(psql -V | awk '{print $3}') |
| | | |
| | |
| | | LOG_PATH='$LOG_PATH' |
| | | DBADMIN='$DBADMIN' |
| | | |
| | | # Генерация локалей (английской и русской), установка русской - по умолчанию |
| | | if command -v locale-gen >/dev/null 2>&1; then |
| | | echo "Настройка и генерация локалей en_US.UTF-8 и ru_RU.UTF-8..." |
| | | |
| | | # Жестко раскомментируем локали в системном файле Ubuntu |
| | | if [ -f /etc/locale.gen ]; then |
| | | sudo sed -i '/^# *ru_RU.UTF-8 UTF-8/s/^# *//' /etc/locale.gen |
| | | sudo sed -i '/^# *en_US.UTF-8 UTF-8/s/^# *//' /etc/locale.gen |
| | | fi |
| | | |
| | | # Генерируем локали |
| | | sudo locale-gen |
| | | |
| | | # Обновляем глобальные настройки системы |
| | | sudo update-locale LANG=ru_RU.UTF-8 |
| | | echo "Локаль ru_RU.UTF-8 успешно добавлена в систему." |
| | | fi |
| | | |
| | | if [ -z "$RUDB_PATH" ] || [ -z "$RUDB_DB_PATH" ] || [ -z "$LOG_PATH" ]; then |
| | | echo "Ошибка: переменные RUDB_PATH, RUDB_DB_PATH или LOG_PATH не заданы." |
| | | exit 1 |
| | |
| | | |
| | | BIN_PATH="\$RUDB_PATH/bin" |
| | | LINK_PATH="/usr/bin" |
| | | LINK_BACKUP_DIR="\$(dirname "\$RUDB_DB_PATH")/link-backup" |
| | | |
| | | # Проверка: есть ли доступный psql |
| | | if command -v psql >/dev/null 2>&1; then |
| | | NEED_ORIGINAL_LINKS=false |
| | | else |
| | | NEED_ORIGINAL_LINKS=true |
| | | fi |
| | | create_rudb_link() { |
| | | local src="\$1" |
| | | local target="\$2" |
| | | local src_path="\${BIN_PATH}/\${src}" |
| | | local link="\${LINK_PATH}/\${target}" |
| | | local backup_target="\${LINK_BACKUP_DIR}/\${target}.target" |
| | | local missing_marker="\${LINK_BACKUP_DIR}/\${target}.missing" |
| | | local current_target="" |
| | | |
| | | if [ ! -e "\$src_path" ]; then |
| | | echo "Skip \$link: source \$src_path not found" |
| | | return 0 |
| | | fi |
| | | |
| | | mkdir -p "\$LINK_BACKUP_DIR" |
| | | |
| | | if [ -L "\$link" ]; then |
| | | current_target="\$(readlink "\$link")" |
| | | |
| | | if [ "\$current_target" != "\$src_path" ]; then |
| | | if [ ! -e "\$backup_target" ] && [ ! -e "\$missing_marker" ]; then |
| | | printf '%s\n' "\$current_target" > "\$backup_target" |
| | | echo "Backup symlink: \$link -> \$current_target" |
| | | fi |
| | | fi |
| | | |
| | | rm -f "\$link" |
| | | ln -s "\$src_path" "\$link" |
| | | echo "Linked: \$link -> \$src_path" |
| | | return 0 |
| | | fi |
| | | |
| | | if [ ! -e "\$link" ]; then |
| | | if [ ! -e "\$backup_target" ] && [ ! -e "\$missing_marker" ]; then |
| | | touch "\$missing_marker" |
| | | echo "Marked missing command: \$link" |
| | | fi |
| | | |
| | | ln -s "\$src_path" "\$link" |
| | | echo "Linked: \$link -> \$src_path" |
| | | return 0 |
| | | fi |
| | | |
| | | echo "WARNING: \$link exists and is not a symlink. Not replacing it." |
| | | } |
| | | |
| | | for src in "\${!LINKS[@]}"; do |
| | | target="\${LINKS[\$src]}" |
| | | |
| | | # Создаём симлинк |
| | | rm -f "\${LINK_PATH}/\${target}" |
| | | ln -s "\${BIN_PATH}/\${src}" "\${LINK_PATH}/\${target}" |
| | | # echo "Created symlink: \${LINK_PATH}/\${target} -> \${BIN_PATH}/\${src}" |
| | | |
| | | # Если нужно — создаём ещё и оригинальное имя (только если src != target) |
| | | if [[ "\$NEED_ORIGINAL_LINKS" == "true" ]] && [[ "\$src" != "\$target" ]]; then |
| | | rm -f "\${LINK_PATH}/\${src}" |
| | | ln -s "\${BIN_PATH}/\${src}" "\${LINK_PATH}/\${src}" |
| | | # echo "Created original symlink: \${LINK_PATH}/\${src} -> \${BIN_PATH}/\${src}" |
| | | fi |
| | | create_rudb_link "\$src" "\$target" |
| | | done |
| | | |
| | | sudo cp $RUDB_PATH/bin/dgridd.conf /etc/ |
| | | sudo rm /usr/lib/x86_64-linux-gnu/libpq.so.5 |
| | | sudo ln -sf $RUDB_PATH/lib/libpq.so.5.17 /usr/lib/x86_64-linux-gnu/libpq.so.5 |
| | | # Не заменяем системную libpq.so.5: это может сломать системные PostgreSQL-клиенты. |
| | | # RUDB-библиотеки подключаются через отдельный ld.so.conf.d файл. |
| | | echo "$RUDB_PATH/lib" | sudo tee /etc/ld.so.conf.d/rudb.conf |
| | | sudo ldconfig |
| | | |
| | |
| | | ExecStart=$RUDB_PATH/bin/dgridd |
| | | Type=idle |
| | | KillMode=process |
| | | |
| | | |
| | | SyslogIdentifier=DGrid |
| | | SyslogFacility=daemon |
| | | StandardOutput=syslog |
| | | StandardError=syslog |
| | | Environment="LD_LIBRARY_PATH=$RUDB_PATH/lib" |
| | | Restart=on-failure |
| | | |
| | | [Install] |
| | |
| | | # Очищаем состояние "неудачных" сервисов в systemd |
| | | sudo systemctl reset-failed || true |
| | | |
| | | services=("$RUDB_SERVICE" "dgrid") |
| | | |
| | | # Удаление юнит-файлов |
| | | for service in "\${services[@]}"; do |
| | | unit_file="/etc/systemd/system/\${service}" |
| | | unit_file="/etc/systemd/system/\${service}.service" |
| | | if [[ -f "\$unit_file" ]]; then |
| | | echo "Удаление юнит-файла: \$unit_file" |
| | | sudo rm -f "\$unit_file" |
| | |
| | | # Перезагрузка systemd для применения изменений |
| | | sudo systemctl daemon-reload || true |
| | | |
| | | # Удаление системного пользователя $DBADMIN |
| | | if id "$DBADMIN" >/dev/null 2>&1; then |
| | | sudo pkill -u $DBADMIN 2>/dev/null || true |
| | | sleep 1 |
| | | sudo pkill -9 -u $DBADMIN 2>/dev/null || true |
| | | sleep 1 |
| | | sudo deluser --remove-home $DBADMIN || true |
| | | fi |
| | | # Пользователь $DBADMIN может быть создан не этим пакетом и использоваться другими сервисами. |
| | | # Поэтому при удалении пакета его не удаляем. |
| | | |
| | | # Удаление симлинков |
| | | sudo rm -f /usr/local/bin/pg_ctl |
| | | sudo rm -f /usr/local/bin/initdb |
| | | sudo rm -f /usr/local/bin/clusterdb |
| | | sudo rm -f /usr/local/bin/createdb |
| | | sudo rm -f /usr/local/bin/dropdb |
| | | sudo rm -f /usr/local/bin/reindexdb |
| | | sudo rm -f /usr/local/bin/vacuumdb |
| | | sudo rm -f /usr/local/bin/vacuumlo |
| | | sudo rm -f /usr/local/bin/createuser |
| | | sudo rm -f /usr/local/bin/dropuser |
| | | sudo rm -f /usr/local/bin/psql |
| | | sudo rm -f /usr/local/bin/pg_isready |
| | | sudo rm -f /usr/local/bin/pgbench |
| | | sudo rm -f /usr/local/bin/pg_dump |
| | | sudo rm -f /usr/local/bin/pg_dumpall |
| | | sudo rm -f /usr/local/bin/pg_restore |
| | | sudo rm -f /usr/local/bin/pg_basebackup |
| | | sudo rm -f /usr/local/bin/pg_combinebackup |
| | | sudo rm -f /usr/local/bin/pg_verifybackup |
| | | sudo rm -f /usr/local/bin/pg_receivewal |
| | | sudo rm -f /usr/local/bin/pg_recvlogical |
| | | sudo rm -f /usr/local/bin/pg_resetwal |
| | | sudo rm -f /usr/local/bin/pg_rewind |
| | | sudo rm -f /usr/local/bin/pg_waldump |
| | | sudo rm -f /usr/local/bin/pg_walsummary |
| | | sudo rm -f /usr/local/bin/pg_amcheck |
| | | sudo rm -f /usr/local/bin/pg_checksums |
| | | sudo rm -f /usr/local/bin/pg_controldata |
| | | sudo rm -f /usr/local/bin/pg_upgrade |
| | | sudo rm -f /usr/local/bin/pg_test_fsync |
| | | sudo rm -f /usr/local/bin/pg_test_timing |
| | | sudo rm -f /usr/local/bin/ecpg |
| | | sudo rm -f /usr/local/bin/oid2name |
| | | LINK_PATH="/usr/bin" |
| | | RUDB_DB_PATH='$RUDB_DB_PATH' |
| | | LINK_BACKUP_DIR="\$(dirname "\$RUDB_DB_PATH")/link-backup" |
| | | |
| | | tools=( |
| | | pg_ctl initdb clusterdb createdb dropdb reindexdb vacuumdb vacuumlo |
| | | createuser dropuser psql pg_isready pgbench pg_dump pg_dumpall pg_restore |
| | | pg_basebackup pg_combinebackup pg_verifybackup pg_receivewal pg_recvlogical |
| | | pg_resetwal pg_rewind pg_waldump pg_walsummary pg_amcheck pg_checksums |
| | | pg_controldata pg_upgrade pg_test_fsync pg_test_timing ecpg oid2name |
| | | ) |
| | | |
| | | restore_or_remove_rudb_link() { |
| | | local tool="\$1" |
| | | local link="\${LINK_PATH}/\${tool}" |
| | | local rudb_target="\${RUDB_PATH}/bin/\${tool}" |
| | | local backup_target="\${LINK_BACKUP_DIR}/\${tool}.target" |
| | | local missing_marker="\${LINK_BACKUP_DIR}/\${tool}.missing" |
| | | local current_target="" |
| | | local old_target="" |
| | | |
| | | if [ -L "\$link" ]; then |
| | | current_target="\$(readlink "\$link")" |
| | | if [ "\$current_target" = "\$rudb_target" ]; then |
| | | rm -f "\$link" |
| | | echo "Removed RuDB link: \$link" |
| | | else |
| | | echo "Skip \$link: it does not point to RUDB" |
| | | fi |
| | | fi |
| | | |
| | | if [ -f "\$backup_target" ]; then |
| | | old_target="\$(cat "\$backup_target")" |
| | | if [ ! -e "\$link" ] && [ ! -L "\$link" ]; then |
| | | ln -s "\$old_target" "\$link" |
| | | rm -f "\$backup_target" |
| | | echo "Restored symlink: \$link -> \$old_target" |
| | | else |
| | | echo "WARNING: \$link already exists; backup was not restored automatically: \$backup_target" |
| | | fi |
| | | return 0 |
| | | fi |
| | | |
| | | if [ -f "\$missing_marker" ]; then |
| | | rm -f "\$missing_marker" |
| | | echo "No previous command for \$link; left absent" |
| | | fi |
| | | } |
| | | |
| | | for tool in "\${tools[@]}"; do |
| | | restore_or_remove_rudb_link "\$tool" |
| | | done |
| | | |
| | | rmdir "\$LINK_BACKUP_DIR" 2>/dev/null || true |
| | | |
| | | sudo rm -f /etc/ld.so.conf.d/rudb.conf |
| | | sudo ldconfig || true |
| | | |
| | | exit 0 |
| | | EOF |
| | |
| | | |
| | | - Все сценарии сборки запускаются через `prep.sh` |
| | | - Перед сборкой должно быть собрано ядро RuDB |
| | | - Перед упаковкой PostGIS должен быть установлен в тот же префикс, что и RuDB (`/usr/local/rudb` по умолчанию) |
| | | - Рекомендуется выполнять сборку в чистом окружении |
| | | |
| | | ### Зависимости для сборки PostGIS |
| | | |
| | | Для сборки встроенного `contrib/postgis` в окружении сборки должны быть доступны: |
| | | |
| | | - Debian / Ubuntu / Astra: `docbook-xsl-ns`, `gettext`, `libgdal-dev`, `libgeos-dev`, `libjson-c-dev`, `libproj-dev`, `libprotobuf-c-dev`, `libxml2-dev`, `libxml2-utils`, `libxslt1-dev`, `protobuf-c-compiler`, `xsltproc` |
| | | - Debian / Ubuntu / Astra: `libsfcgal-dev` рекомендуется, если нужен `postgis_sfcgal` |
| | | - ALT Linux 11: `gettext-tools`, `libgdal-devel`, `libgeos-devel`, `libproj-devel`, `libprotobuf-c-devel`, `libxml2-devel`, `libxslt-devel`, `protobuf-c-compiler`, `xsltproc` |
| | | |
| | | --- |
| | | |
| | | # DEB пакеты |
| | |
| | | |
| | | - `dpkg-dev`, `debhelper` (для DEB) |
| | | - `rpm-build` (для RPM) |
| | | |
| | |
| | | ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| | | INSTALL_PATH="/usr/local/rudb" |
| | | LOG_FILE="${ROOT_DIR}/build_report.log" |
| | | POSTGIS_PATH="${ROOT_DIR}/contrib/postgis" |
| | | BUILD_JOBS="$(nproc)" |
| | | export PATH="$INSTALL_PATH/bin:$PATH" |
| | | export PG_CONFIG="$INSTALL_PATH/bin/pg_config" |
| | | export OPTIMIZATION=2 |
| | |
| | | echo "$1" >> "$LOG_FILE" |
| | | } |
| | | |
| | | run_logged() { |
| | | "$@" 2>&1 | tee -a "$LOG_FILE" |
| | | return ${PIPESTATUS[0]} |
| | | } |
| | | |
| | | build_postgis() { |
| | | if [ ! -d "$POSTGIS_PATH" ]; then |
| | | echo -e "\e[1;31m[ FAIL ] Не найдена директория $POSTGIS_PATH\e[0m" |
| | | return 1 |
| | | fi |
| | | |
| | | ( |
| | | cd "$POSTGIS_PATH" || exit 1 |
| | | make distclean > /dev/null 2>&1 || true |
| | | |
| | | if [ ! -x ./configure ]; then |
| | | run_logged ./autogen.sh || exit 1 |
| | | fi |
| | | |
| | | run_logged env PATH="$INSTALL_PATH/bin:$PATH" ./configure \ |
| | | --prefix="$INSTALL_PATH" \ |
| | | --with-pgconfig="$INSTALL_PATH/bin/pg_config" || exit 1 |
| | | |
| | | run_logged make USE_PGXS=1 -j"$BUILD_JOBS" || exit 1 |
| | | run_logged sudo env PATH="$INSTALL_PATH/bin:$PATH" make USE_PGXS=1 install || exit 1 |
| | | ) |
| | | } |
| | | |
| | | # 1. КОНФИГУРАЦИЯ |
| | | print_header "Этап 1: Конфигурация ядра" |
| | | |
| | |
| | | |
| | | if [ "$MODE" == "PROD" ]; then |
| | | echo -e "\e[1;36mЗапуск стандартной сборки через contrib/Makefile...\e[0m" |
| | | make -C contrib -j$(nproc) 2>&1 | tee -a "$LOG_FILE" |
| | | make -C contrib -j"$BUILD_JOBS" 2>&1 | tee -a "$LOG_FILE" |
| | | |
| | | if [ ${PIPESTATUS[0]} -eq 0 ]; then |
| | | echo -e "\n\e[1;32m[ OK ] Сборка contrib успешна\e[0m" |
| | |
| | | exit 1 |
| | | fi |
| | | |
| | | print_header "Этап 7: Сборка и установка PostGIS" |
| | | if ! build_postgis; then |
| | | echo -e "\n\e[1;31m[ FAIL ] Сборка или установка PostGIS упала!\e[0m" |
| | | exit 1 |
| | | fi |
| | | |
| | | echo -e "\e[1;33mПропущены:\e[0m ${SKIPPED_LIST:-нет}" >> "$LOG_FILE" |
| | | echo -e "\n\e[1;32m=== ИТОГИ: УСПЕШНАЯ PROD СБОРКА ===\e[0m" |
| | | else |
| | |
| | | continue |
| | | fi |
| | | |
| | | cd "$ext_name" |
| | | if [ "$ext_name" = "postgis" ]; then |
| | | make distclean > /dev/null 2>&1 |
| | | ./configure |
| | | else |
| | | make clean > /dev/null 2>&1 |
| | | if build_postgis; then |
| | | echo -e "\e[1;32m[ OK ] $ext_name успешно собран\e[0m" |
| | | SUCCESS_LIST+="$ext_name " |
| | | DEV_SUMMARY+="--- Сборка $ext_name --- [ \e[1;32mOK\e[0m ]\n" |
| | | else |
| | | echo -e "\e[1;31m[ FAIL ] Ошибка в $ext_name\e[0m" |
| | | FAILED_LIST+="$ext_name " |
| | | DEV_SUMMARY+="--- Сборка $ext_name --- [ \e[1;31mFAIL\e[0m ]\n" |
| | | fi |
| | | continue |
| | | fi |
| | | |
| | | cd "$ext_name" |
| | | make clean > /dev/null 2>&1 |
| | | |
| | | # Сборка и установка |
| | | if make 2>&1 | tee -a "$LOG_FILE" && \ |
| | | if make -j"$BUILD_JOBS" 2>&1 | tee -a "$LOG_FILE" && \ |
| | | sudo env PATH=$INSTALL_PATH/bin:$PATH PG_CONFIG=$INSTALL_PATH/bin/pg_config make install 2>&1 | tee -a "$LOG_FILE"; then |
| | | echo -e "\e[1;32m[ OK ] $ext_name успешно собран\e[0m" |
| | | SUCCESS_LIST+="$ext_name " |
| New file |
| | |
| | | #!/bin/bash |
| | | |
| | | set -Eeuo pipefail |
| | | IFS=$'\n\t' |
| | | |
| | | TEST_NAME="" |
| | | JOBS=4 |
| | | |
| | | usage() { |
| | | cat <<EOF |
| | | Usage: |
| | | ./build_script.sh |
| | | ./build_script.sh --test_name=dbms_tns |
| | | ./build_script.sh --test_name dbms_tns |
| | | ./build_script.sh --test_name="dbms_tns another_test" -j 4 |
| | | |
| | | Options: |
| | | --test_name NAME Optional regression test name or list of tests |
| | | -j, --jobs N Parallel jobs for make, default: 4 |
| | | -h, --help Show this help |
| | | EOF |
| | | } |
| | | |
| | | log() { |
| | | echo |
| | | echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" |
| | | } |
| | | |
| | | fail() { |
| | | echo "ERROR: $*" >&2 |
| | | exit 1 |
| | | } |
| | | |
| | | while [[ $# -gt 0 ]]; do |
| | | case "$1" in |
| | | --test_name=*) |
| | | TEST_NAME="${1#*=}" |
| | | ;; |
| | | --test_name) |
| | | ARG_NAME="$1" |
| | | shift |
| | | [[ $# -gt 0 ]] || fail "После $ARG_NAME нужно указать имя теста" |
| | | TEST_NAME="$1" |
| | | ;; |
| | | -j|--jobs) |
| | | ARG_NAME="$1" |
| | | shift |
| | | [[ $# -gt 0 ]] || fail "После $ARG_NAME нужно указать число потоков" |
| | | JOBS="$1" |
| | | ;; |
| | | --jobs=*) |
| | | JOBS="${1#*=}" |
| | | ;; |
| | | -h|--help) |
| | | usage |
| | | exit 0 |
| | | ;; |
| | | *) |
| | | fail "Неизвестный аргумент: $1" |
| | | ;; |
| | | esac |
| | | shift |
| | | done |
| | | |
| | | [[ "$JOBS" =~ ^[0-9]+$ ]] || fail "jobs должен быть числом: $JOBS" |
| | | |
| | | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| | | cd "$SCRIPT_DIR" |
| | | |
| | | [[ -f "./full_build.sh" ]] || fail "Не найден ./full_build.sh. Запусти скрипт из корня репозитория или положи его туда." |
| | | [[ -f "./db_cr_all.sh" ]] || fail "Не найден ./db_cr_all.sh" |
| | | [[ -d "./src/test/regress" ]] || fail "Не найдена директория ./src/test/regress" |
| | | |
| | | log "Start build pipeline" |
| | | log "Current OS user: $(id -un)" |
| | | log "Repository dir: $SCRIPT_DIR" |
| | | log "Jobs: $JOBS" |
| | | |
| | | if [[ -n "$TEST_NAME" ]]; then |
| | | log "Test name: $TEST_NAME" |
| | | else |
| | | log "Test name not specified: regression tests will be skipped" |
| | | fi |
| | | |
| | | log "1/4 make clean" |
| | | if [[ -f "./GNUmakefile" && -f "./src/Makefile.global" ]]; then |
| | | make clean |
| | | else |
| | | log "Skipping make clean: build tree is not configured yet" |
| | | fi |
| | | |
| | | log "2/4 bash ./full_build.sh --dev" |
| | | bash ./full_build.sh --dev |
| | | |
| | | log "3/4 bash ./db_cr_all.sh" |
| | | bash ./db_cr_all.sh |
| | | |
| | | log "4/4 checking qsql connection" |
| | | qsql -p 5432 -d postgres -U postgres <<'SQL' |
| | | SELECT 1; |
| | | \q |
| | | SQL |
| | | |
| | | if [[ -n "$TEST_NAME" ]]; then |
| | | log "Running regression tests" |
| | | make -C src/test/regress check-tests TESTS="$TEST_NAME" -j"$JOBS" |
| | | else |
| | | log "Skipping regression tests because --test_name was not specified" |
| | | fi |
| | | |
| | | log "Done" |
| | |
| | | dbms_lob_compare(blob1 BLOB, blob2 BLOB, amount number DEFAULT NULL, offset1 number DEFAULT NULL, offset2 number DEFAULT NULL) |
| | | RETURNS number |
| | | LANGUAGE INTERNAL |
| | | CALLED ON NULL INPUT VOLATILE |
| | | CALLED ON NULL INPUT VOLATILE |
| | | AS 'dbms_lob_compare_ovr1'; |
| | | |
| | | CREATE OR REPLACE FUNCTION |
| | | dbms_lob_compare(clob1 CLOB, clob2 CLOB, amount number DEFAULT NULL, offset1 number DEFAULT NULL, offset2 number DEFAULT NULL) |
| | | RETURNS number |
| | | LANGUAGE INTERNAL |
| | | CALLED ON NULL INPUT VOLATILE |
| | | CALLED ON NULL INPUT VOLATILE |
| | | AS 'dbms_lob_compare_ovr2'; |
| | | |
| | | CREATE OR REPLACE FUNCTION |
| | | dbms_lob_loadfromfile(blob1 BLOB, src_file BFILE, amount number, dest_offset number DEFAULT 1, src_offset number DEFAULT 1) |
| | | RETURNS BLOB |
| | | LANGUAGE INTERNAL |
| | | CALLED ON NULL INPUT VOLATILE |
| | | CALLED ON NULL INPUT VOLATILE |
| | | AS 'dbms_lob_loadfromfile_ovr1'; |
| | | |
| | | CREATE OR REPLACE FUNCTION |
| | | dbms_lob_loadfromfile(clob1 CLOB, src_file BFILE, amount number, dest_offset number DEFAULT 1, src_offset number DEFAULT 1) |
| | | RETURNS CLOB |
| | | LANGUAGE INTERNAL |
| | | CALLED ON NULL INPUT VOLATILE |
| | | CALLED ON NULL INPUT VOLATILE |
| | | AS 'dbms_lob_loadfromfile_ovr2'; |
| | | |
| | | CREATE OR REPLACE FUNCTION |
| | | dbms_lob_substr(blob1 BLOB, amount number DEFAULT NULL, offset1 number DEFAULT NULL) |
| | | RETURNS raw |
| | | LANGUAGE INTERNAL |
| | | CALLED ON NULL INPUT VOLATILE |
| | | CALLED ON NULL INPUT VOLATILE |
| | | AS 'dbms_lob_substr_ovr1'; |
| | | |
| | | CREATE OR REPLACE FUNCTION |
| | | dbms_lob_substr(clob1 CLOB, amount number DEFAULT NULL, offset1 number DEFAULT NULL) |
| | | RETURNS varchar2 |
| | | LANGUAGE INTERNAL |
| | | CALLED ON NULL INPUT VOLATILE |
| | | CALLED ON NULL INPUT VOLATILE |
| | | AS 'dbms_lob_substr_ovr2'; |
| | | |
| | | CREATE OR REPLACE FUNCTION |
| | | dbms_lob_instr(clob1 BLOB, raw_pattern RAW, blob_offset number DEFAULT NULL, nch number DEFAULT NULL) |
| | | RETURNS number |
| | | LANGUAGE INTERNAL |
| | | CALLED ON NULL INPUT VOLATILE |
| | | CALLED ON NULL INPUT VOLATILE |
| | | AS 'dbms_lob_instr_ovr1'; |
| | | |
| | | CREATE OR REPLACE FUNCTION |
| | | dbms_lob_instr(clob1 CLOB, text_pattern varchar2, blob_offset number DEFAULT NULL, nch number DEFAULT NULL) |
| | | RETURNS number |
| | | LANGUAGE INTERNAL |
| | | CALLED ON NULL INPUT VOLATILE |
| | | CALLED ON NULL INPUT VOLATILE |
| | | AS 'dbms_lob_instr_ovr2'; |
| | | |
| | | CREATE OR REPLACE FUNCTION |
| | | dbms_assert_enquote_name(name varchar2, capitalize BOOLEAN DEFAULT TRUE) |
| | | RETURNS varchar2 |
| | | LANGUAGE INTERNAL |
| | | CALLED ON NULL INPUT VOLATILE |
| | | CALLED ON NULL INPUT VOLATILE |
| | | AS 'dbms_assert_enquote_name'; |
| | | |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_alert_register(name varchar2, cleanup BOOLEAN DEFAULT TRUE) |
| | | RETURNS void |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_alert_register(name varchar2, cleanup BOOLEAN DEFAULT TRUE) |
| | | RETURNS void |
| | | LANGUAGE internal |
| | | PARALLEL SAFE |
| | | AS 'dbms_alert_register'; |
| | | |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_xmlgen_getxml(ctx number, dtdorschema number DEFAULT 0) |
| | | RETURNS clob |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_warning_add_warning_setting_cat( |
| | | warning_category varchar2, |
| | | warning_value varchar2, |
| | | scope varchar2) |
| | | RETURNS void |
| | | LANGUAGE internal |
| | | VOLATILE |
| | | AS 'dbms_warning_add_warning_setting_cat'; |
| | | |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_warning_add_warning_setting_num( |
| | | warning_number binary_integer, |
| | | warning_value varchar2, |
| | | scope varchar2) |
| | | RETURNS void |
| | | LANGUAGE internal |
| | | VOLATILE |
| | | AS 'dbms_warning_add_warning_setting_num'; |
| | | |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_warning_get_category( |
| | | warning_number binary_integer) |
| | | RETURNS varchar2 |
| | | LANGUAGE internal |
| | | VOLATILE |
| | | AS 'dbms_warning_get_category'; |
| | | |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_warning_get_warning_setting_cat( |
| | | warning_category varchar2) |
| | | RETURNS varchar2 |
| | | LANGUAGE internal |
| | | VOLATILE |
| | | AS 'dbms_warning_get_warning_setting_cat'; |
| | | |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_warning_get_warning_setting_num( |
| | | warning_number binary_integer) |
| | | RETURNS varchar2 |
| | | LANGUAGE internal |
| | | VOLATILE |
| | | AS 'dbms_warning_get_warning_setting_num'; |
| | | |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_warning_get_warning_setting_string() |
| | | RETURNS varchar2 |
| | | LANGUAGE internal |
| | | VOLATILE |
| | | AS 'dbms_warning_get_warning_setting_string'; |
| | | |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_warning_set_warning_setting_string( |
| | | value varchar2, |
| | | scope varchar2) |
| | | RETURNS void |
| | | LANGUAGE internal |
| | | VOLATILE |
| | | AS 'dbms_warning_set_warning_setting_string'; |
| | | |
| | | CREATE OR REPLACE FUNCTION |
| | | dbms_sqlset_create_sqlset_0( |
| | | sqlset_name text DEFAULT NULL, |
| | | description text DEFAULT NULL, |
| | | sqlset_owner text DEFAULT NULL) |
| | | RETURNS varchar2 |
| | | LANGUAGE internal |
| | | VOLATILE |
| | | AS 'dbms_sqlset_create_sqlset'; |
| | | |
| | | CREATE OR REPLACE PROCEDURE |
| | | dbms_sqlset_create_sqlset_1( |
| | | sqlset_name text, |
| | | description text DEFAULT NULL, |
| | | sqlset_owner text DEFAULT NULL) |
| | | LANGUAGE internal |
| | | AS 'dbms_sqlset_create_sqlset_proc'; |
| | | |
| | | CREATE OR REPLACE PROCEDURE |
| | | dbms_sqlset_drop_sqlset( |
| | | sqlset_name text, |
| | | sqlset_owner text DEFAULT NULL) |
| | | LANGUAGE internal |
| | | AS 'dbms_sqlset_drop_sqlset'; |
| | | |
| | | CREATE OR REPLACE PROCEDURE |
| | | dbms_sqlset_load_sqlset( |
| | | sqlset_name text, |
| | | populate_cursor refcursor, |
| | | load_option text DEFAULT 'INSERT', |
| | | update_option text DEFAULT 'REPLACE', |
| | | update_condition text DEFAULT NULL, |
| | | update_attributes text DEFAULT NULL, |
| | | ignore_null bool DEFAULT true, |
| | | commit_rows numeric DEFAULT NULL, |
| | | sqlset_owner text DEFAULT NULL) |
| | | LANGUAGE internal |
| | | AS 'dbms_sqlset_load_sqlset'; |
| | | |
| | | CREATE OR REPLACE FUNCTION |
| | | dbms_sqlset_select_sqlset( |
| | | sqlset_name text, |
| | | basic_filter text DEFAULT NULL, |
| | | object_filter text DEFAULT NULL, |
| | | ranking_measure1 text DEFAULT NULL, |
| | | ranking_measure2 text DEFAULT NULL, |
| | | ranking_measure3 text DEFAULT NULL, |
| | | result_percentage numeric DEFAULT 1, |
| | | result_limit numeric DEFAULT NULL, |
| | | attribute_list text DEFAULT 'TYPICAL', |
| | | plan_filter text DEFAULT NULL, |
| | | sqlset_owner text DEFAULT NULL, |
| | | recursive_sql text DEFAULT 'Y', |
| | | OUT sql_id text, |
| | | OUT force_matching_signature numeric, |
| | | OUT sql_text text, |
| | | OUT parsing_schema_name text, |
| | | OUT module text, |
| | | OUT action text, |
| | | OUT elapsed_time numeric, |
| | | OUT cpu_time numeric, |
| | | OUT buffer_gets numeric, |
| | | OUT disk_reads numeric, |
| | | OUT direct_writes numeric, |
| | | OUT rows_processed numeric, |
| | | OUT fetches numeric, |
| | | OUT executions numeric, |
| | | OUT end_of_fetch_count numeric, |
| | | OUT optimizer_cost numeric, |
| | | OUT optimizer_env bytea, |
| | | OUT priority numeric, |
| | | OUT command_type numeric, |
| | | OUT first_load_time text, |
| | | OUT stat_period numeric, |
| | | OUT active_stat_period numeric, |
| | | OUT other text, |
| | | OUT plan_hash_value numeric, |
| | | OUT con_dbid numeric, |
| | | OUT last_exec_start_time text, |
| | | OUT sharable_mem numeric, |
| | | OUT exact_matching_signature numeric, |
| | | OUT result_cache_executions numeric, |
| | | OUT sql_profile text, |
| | | OUT sql_plan_baseline text, |
| | | OUT sql_patch text, |
| | | OUT avg_hard_parse_time numeric, |
| | | OUT user_io_wait_time numeric, |
| | | OUT io_interconnect_bytes numeric, |
| | | OUT parsing_user_name text) |
| | | RETURNS SETOF record |
| | | LANGUAGE internal |
| | | VOLATILE |
| | | AS 'dbms_sqlset_select_sqlset'; |
| | | |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_xmlgen_getxml(ctx number, dtdorschema number DEFAULT 0) |
| | | RETURNS clob |
| | | LANGUAGE internal |
| | | VOLATILE |
| | | AS 'dbms_xmlgen_getxml_ovr2'; |
| | | |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_json_schema_is_schema_valid2( |
| | | json_data jsonb, |
| | | service_arg int4 |
| | | ) |
| | | RETURNS binary_integer |
| | | LANGUAGE internal |
| | | VOLATILE |
| | | AS 'dbms_json_schema_is_schema_valid2'; |
| | | |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_json_schema_is_valid( |
| | | json_data jsonb, |
| | | json_schema jsonb, |
| | | raise_err binary_integer DEFAULT 0) |
| | | RETURNS binary_integer |
| | | LANGUAGE internal |
| | | VOLATILE |
| | | AS 'dbms_json_schema_is_valid'; |
| | | |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_json_schema_validate_report( |
| | | json_data varchar2, |
| | | json_schema varchar2) |
| | | RETURNS clob |
| | | LANGUAGE internal |
| | | VOLATILE |
| | | AS 'dbms_json_schema_validate_report'; |
| | | |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_json_schema_validate_report( |
| | | json_data jsonb, |
| | | json_schema jsonb) |
| | | RETURNS clob |
| | | LANGUAGE internal |
| | | VOLATILE |
| | | AS 'dbms_json_schema_validate_report'; |
| | | |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_json_build_dataguide( |
| | | json_data jsonb) |
| | | RETURNS jsonb |
| | | LANGUAGE internal |
| | | VOLATILE |
| | | AS 'dbms_json_build_dataguide'; |
| | | |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_json_get_index_dataguide( |
| | | tablename varchar2, |
| | | jcolname varchar2, |
| | | format int4, |
| | | pretty int4 DEFAULT 0) |
| | | RETURNS clob |
| | | LANGUAGE internal |
| | | VOLATILE |
| | | AS 'dbms_json_get_index_dataguide'; |
| | | |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_json_get_view_sql( |
| | | viewname varchar2, |
| | | tablename varchar2, |
| | | jcolname varchar2, |
| | | dataguide jsonb, |
| | | materialize bool DEFAULT false, |
| | | mvrefreshmode int4 DEFAULT 1, |
| | | path varchar2 DEFAULT '$', |
| | | resolvenameconflicts bool DEFAULT true, |
| | | colnameprefix varchar2 DEFAULT NULL, |
| | | mixedcasecolumns bool DEFAULT true) |
| | | RETURNS clob |
| | | LANGUAGE internal |
| | | VOLATILE |
| | | AS 'dbms_json_get_view_sql'; |
| | | |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_json_add_virtual_columns( |
| | | tablename varchar2, |
| | | jcolname varchar2, |
| | | dataguide jsonb, |
| | | resolvenameconflicts bool DEFAULT true, |
| | | colnameprefix varchar2 DEFAULT NULL, |
| | | mixedcasecolumns bool DEFAULT false) |
| | | RETURNS void |
| | | LANGUAGE internal |
| | | AS 'dbms_json_add_virtual_columns'; |
| | | |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_json_create_view( |
| | | viewname varchar2, |
| | | tablename varchar2, |
| | | jcolname varchar2, |
| | | dataguide jsonb, |
| | | resourcepath varchar2 DEFAULT NULL, |
| | | materialize bool DEFAULT false, |
| | | mvrefreshmode int4 DEFAULT 1, |
| | | path varchar2 DEFAULT '$', |
| | | resolvenameconflicts bool DEFAULT true, |
| | | colnameprefix varchar2 DEFAULT NULL, |
| | | mixedcasecolumns bool DEFAULT false) |
| | | RETURNS void |
| | | LANGUAGE internal |
| | | AS 'dbms_json_create_view'; |
| | | |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_json_create_view2( |
| | | viewname varchar2, |
| | | tablename varchar2, |
| | | jcolname varchar2, |
| | | dataguide jsonb, |
| | | resourcepath varchar2, |
| | | materialize bool, |
| | | mvrefreshmode int4, |
| | | path varchar2, |
| | | resolvenameconflicts bool, |
| | | colnameprefix varchar2, |
| | | mixedcasecolumns bool, |
| | | service_arg int4 |
| | | ) |
| | | RETURNS void |
| | | LANGUAGE internal |
| | | AS 'dbms_json_create_view2'; |
| | | |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_json_drop_virtual_columns( |
| | | tablename varchar2, |
| | | jcolname varchar2) |
| | | RETURNS void |
| | | LANGUAGE internal |
| | | AS 'dbms_json_drop_virtual_columns'; |
| | | |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_json_json_type_convertible_check( |
| | | owner varchar2, |
| | | tablename varchar2, |
| | | columnname varchar2, |
| | | statustablename varchar2, |
| | | fastcheck bool DEFAULT false, |
| | | appendstatus bool DEFAULT false) |
| | | RETURNS void |
| | | LANGUAGE internal |
| | | AS 'dbms_json_json_type_convertible_check'; |
| | | |
| | | CREATE OR REPLACE FUNCTION pg_catalog.dbms_json_create_view_on_path( |
| | | viewname varchar2, |
| | | tablename varchar2, |
| | | jcolname varchar2, |
| | | path varchar2, |
| | | frequency int4 DEFAULT 0) |
| | | RETURNS void |
| | | LANGUAGE internal |
| | | AS 'dbms_json_create_view_on_path'; |
| | | |
| | | |
| | | -- UTL_URL_BLOCK |
| | | |
| | | CREATE OR REPLACE FUNCTION |
| | |
| | | max_cookies_per_site int4 DEFAULT 20 |
| | | ) RETURNS int4 LANGUAGE internal AS 'utl_http_create_request_context'; |
| | | |
| | | CREATE OR REPLACE FUNCTION owa_init_cgi_env( |
| | | num_cgi_vars int4 DEFAULT 0, |
| | | param_name text[] DEFAULT NULL, |
| | | param_val text[] DEFAULT NULL |
| | | ) |
| | | RETURNS void |
| | | LANGUAGE internal |
| | | AS 'owa_init_cgi_env'; |
| | | |
| | | CREATE OR REPLACE FUNCTION owa_init_cgi_env2( |
| | | num_cgi_vars int4, |
| | | param_name text[], |
| | | param_val text[], |
| | | service_arg int4 |
| | | ) |
| | | RETURNS void |
| | | LANGUAGE internal |
| | | AS 'owa_init_cgi_env2'; |
| | | |
| | | CREATE OR REPLACE FUNCTION owa_cookie_send( |
| | | name varchar2, |
| | | value varchar2, |
| | | expires timestamptz DEFAULT NULL, |
| | | path varchar2 DEFAULT NULL, |
| | | domain varchar2 DEFAULT NULL, |
| | | secure varchar2 DEFAULT NULL |
| | | ) |
| | | RETURNS void |
| | | LANGUAGE internal |
| | | AS 'owa_cookie_send'; |
| | | |
| | | CREATE OR REPLACE FUNCTION owa_cookie_send2( |
| | | name varchar2, |
| | | value varchar2, |
| | | expires timestamptz, |
| | | path varchar2, |
| | | domain varchar2, |
| | | secure varchar2, |
| | | service_arg int4 |
| | | ) |
| | | RETURNS void |
| | | LANGUAGE internal |
| | | AS 'owa_cookie_send2'; |
| | | |
| | | CREATE OR REPLACE FUNCTION owa_cache_get_etag2( |
| | | service_arg int4 |
| | | ) |
| | | RETURNS varchar2 |
| | | LANGUAGE internal |
| | | AS 'owa_cache_get_etag2'; |
| | | |
| | | CREATE OR REPLACE FUNCTION owa_util_showpage_utils( |
| | | service_arg int4 |
| | | ) |
| | | RETURNS void |
| | | LANGUAGE internal |
| | | AS 'owa_util_showpage_utils'; |
| | | |
| | | -- ==== DEFAULT wrappers for UTL_RAW ==== |
| | | |
| | | -- endianess DEFAULT 1 |
| | |
| | | AS 'utl_tcp_write_text'; |
| | | |
| | | |
| | | -- DBMS HTP Functions |
| | | |
| | | -- HTP_EM |
| | | CREATE OR REPLACE FUNCTION pg_catalog.htp_em( |
| | | ctext VARCHAR2, |
| | | cattributes VARCHAR2 DEFAULT NULL |
| | | ) RETURNS void |
| | | LANGUAGE internal |
| | | AS 'htp_em'; |
| | | |
| | | -- HTP_EMPHASIS |
| | | CREATE OR REPLACE FUNCTION pg_catalog.htp_emphasis( |
| | | ctext VARCHAR2, |
| | | cattributes VARCHAR2 DEFAULT NULL |
| | | ) RETURNS void |
| | | LANGUAGE internal |
| | | AS 'htp_emphasis'; |
| | | |
| | | -- HTP_FRAME |
| | | CREATE OR REPLACE FUNCTION pg_catalog.htp_frame( |
| | | csrc VARCHAR2, |
| | | cname VARCHAR2 DEFAULT NULL, |
| | | cmarginwidth VARCHAR2 DEFAULT NULL, |
| | | cmarginheight VARCHAR2 DEFAULT NULL, |
| | | cscrolling VARCHAR2 DEFAULT NULL, |
| | | cnoresize VARCHAR2 DEFAULT NULL, |
| | | cattributes VARCHAR2 DEFAULT NULL |
| | | ) RETURNS void |
| | | LANGUAGE internal |
| | | AS 'htp_frame'; |
| | | |
| | | -- HTP_HEADER |
| | | CREATE OR REPLACE FUNCTION pg_catalog.htp_header( |
| | | nsize number, |
| | | cheader VARCHAR2, |
| | | calign VARCHAR2 DEFAULT NULL, |
| | | cnowrap VARCHAR2 DEFAULT NULL, |
| | | cclear VARCHAR2 DEFAULT NULL, |
| | | cattributes VARCHAR2 DEFAULT NULL |
| | | ) RETURNS void |
| | | LANGUAGE internal |
| | | AS 'htp_header'; |
| | | |
| | | -- HTP_DLISTTERM |
| | | CREATE OR REPLACE FUNCTION pg_catalog.htp_dlistterm( |
| | | ctext VARCHAR2 DEFAULT NULL, |
| | | cclear VARCHAR2 DEFAULT NULL, |
| | | cattributes VARCHAR2 DEFAULT NULL |
| | | ) RETURNS void |
| | | LANGUAGE internal |
| | | AS 'htp_dlistterm'; |
| | | |
| | | -- OWA_MATCH.MATCH |
| | | CREATE OR REPLACE FUNCTION pg_catalog.owa_match_match( |
| | | p_sting VARCHAR2, |
| | | p_simple_pattern VARCHAR2[] DEFAULT NULL, |
| | | p_complex_pattern VARCHAR2[] DEFAULT NULL, |
| | | p_use_special_chars BOOLEAN DEFAULT TRUE |
| | | ) RETURNS BOOLEAN |
| | | LANGUAGE internal |
| | | AS 'owa_match_match'; |
| | | |
| | | |
| | | -- |
| | | -- The default permissions for functions mean that anyone can execute them. |
| | | -- A number of functions shouldn't be executable by just anyone, but rather |
| | |
| | | useconfig |
| | | FROM pg_shadow; |
| | | |
| | | CREATE VIEW plsql_trace_runs AS |
| | | SELECT |
| | | run_id, |
| | | trace_mask, |
| | | started_at, |
| | | ended_at, |
| | | event_count, |
| | | is_active |
| | | FROM pg_catalog.dbms_trace_plsql_trace_runs() |
| | | AS t(run_id bigint, |
| | | trace_mask integer, |
| | | started_at timestamptz, |
| | | ended_at timestamptz, |
| | | event_count integer, |
| | | is_active boolean); |
| | | |
| | | CREATE VIEW plsql_trace_events AS |
| | | SELECT |
| | | event_type, |
| | | run_id, |
| | | event_seq, |
| | | event_timestamp, |
| | | unit_name, |
| | | subprogram_name, |
| | | nesting_depth, |
| | | line_no, |
| | | sql_text, |
| | | error_code, |
| | | comment |
| | | FROM pg_catalog.dbms_trace_plsql_trace_events() |
| | | AS t(event_type text, |
| | | run_id bigint, |
| | | event_seq bigint, |
| | | event_timestamp timestamptz, |
| | | unit_name text, |
| | | subprogram_name text, |
| | | nesting_depth integer, |
| | | line_no integer, |
| | | sql_text text, |
| | | error_code integer, |
| | | comment text); |
| | | |
| | | CREATE VIEW pg_policies AS |
| | | SELECT |
| | | N.nspname AS schemaname, |
| | |
| | | * parameter. This is mere pedantry, really, but some folks insisted. |
| | | */ |
| | | if (fargnames != NIL && !expand_variadic && nargs > 0 && |
| | | best_candidate->argnumbers != NULL && |
| | | best_candidate->argnumbers[nargs - 1] != nargs - 1) |
| | | return FUNCDETAIL_NOTFOUND; |
| | | |
| | |
| | | top_builddir = ../../.. |
| | | include $(top_builddir)/src/Makefile.global |
| | | |
| | | OBJS = fmgrtab.o |
| | | OBJS = fmgrtab.o coder.o |
| | | SUBDIRS = \ |
| | | activity \ |
| | | adt \ |
| | |
| | | #ifndef STRING_ARRAY_C |
| | | #define STRING_ARRAY_C |
| | | |
| | | #include <stdio.h> |
| | | #include <stdlib.h> |
| | | #include <string.h> |
| | | |
| | | #define MAX_STRINGS 1000 |
| | | |
| | | typedef struct { |
| | | char* strings[MAX_STRINGS]; |
| | | int count; |
| | | int internalIndex; |
| | | } StringArray; |
| | | |
| | | StringArray* initializeStringArray(void); |
| | | void addString(StringArray* array, const char* str, int str_len); |
| | | const char* getStringByIndex(StringArray* array, int index); |
| | | const char* getNextString(StringArray* array); |
| | | void resetInternalIndex(StringArray* array); |
| | | int getCount(StringArray* array); |
| | | void clearStringArray(StringArray* array); |
| | | void logStringArray(StringArray* array); |
| | | void freeStringArray(StringArray* array); |
| | | |
| | | StringArray* initializeStringArray() { |
| | | StringArray* array = (StringArray*)malloc(sizeof(StringArray)); |
| | | if (array == NULL) { |
| | | fprintf(stderr, "Memory allocation failed\n"); |
| | | exit(1); |
| | | } |
| | | array->count = 0; |
| | | array->internalIndex = 0; |
| | | return array; |
| | | } |
| | | |
| | | /* |
| | | addString - функция добавляет константу в список констант |
| | | str_len - количество символов из константы, которое надо использовать, |
| | | если str_len = 0, то все символы |
| | | */ |
| | | void addString(StringArray* array, const char* str, int str_len) { |
| | | if (array->count >= MAX_STRINGS) { |
| | | fprintf(stderr, "Max number of strings reached\n"); |
| | | return; |
| | | } |
| | | if (str_len==0) |
| | | str_len = strlen(str); |
| | | array->strings[array->count] = (char*)malloc(str_len + 1); |
| | | if (array->strings[array->count] == NULL) { |
| | | fprintf(stderr, "Memory allocation failed\n"); |
| | | exit(1); |
| | | } |
| | | strncpy(array->strings[array->count], str, str_len); |
| | | array->strings[array->count][str_len] = '\0'; |
| | | array->count++; |
| | | } |
| | | |
| | | const char* getStringByIndex(StringArray* array, int index) { |
| | | if (index >= array->count || index < 0) { |
| | | fprintf(stderr, "Index out of bounds\n"); |
| | | return NULL; |
| | | } |
| | | return array->strings[index]; |
| | | } |
| | | |
| | | const char* getNextString(StringArray* array) { |
| | | if (array->internalIndex >= array->count) { |
| | | return NULL; |
| | | } |
| | | return array->strings[array->internalIndex++]; |
| | | } |
| | | |
| | | void resetInternalIndex(StringArray* array) { |
| | | array->internalIndex = 0; |
| | | } |
| | | |
| | | int getCount(StringArray* array) { |
| | | return array->count; |
| | | } |
| | | |
| | | void clearStringArray(StringArray* array) { |
| | | for (int i = 0; i < array->count; i++) { |
| | | free(array->strings[i]); |
| | | } |
| | | array->count = 0; |
| | | array->internalIndex = 0; |
| | | } |
| | | |
| | | void freeStringArray(StringArray* array) { |
| | | clearStringArray(array); |
| | | free(array); |
| | | } |
| | | |
| | | #include "utils/elog.h" // Подключаем заголовочный файл для elog |
| | | |
| | | void logStringArray(StringArray* array) { |
| | | if (!array) { |
| | | elog(ERROR, "StringArray is NULL"); |
| | | return; |
| | | } |
| | | |
| | | // Выводим общее количество строк в массиве |
| | | elog(LOG, "StringArray содержит %d строк:", array->count); |
| | | |
| | | // Проходим по всем строкам в массиве |
| | | for (int i = 0; i < array->count; i++) { |
| | | const char* str = array->strings[i]; |
| | | if (str) { |
| | | elog(LOG, " [%d]: '%s'", i, str); |
| | | } else { |
| | | elog(LOG, " [%d]: (null)", i); |
| | | } |
| | | } |
| | | } |
| | | #endif // STRING_ARRAY_C |
| | | #ifndef STRING_ARRAY_C
|
| | | #define STRING_ARRAY_C
|
| | |
|
| | | #include <stdio.h>
|
| | | #include <stdlib.h>
|
| | | #include <string.h>
|
| | |
|
| | | #define MAX_STRINGS 1000
|
| | |
|
| | | typedef struct {
|
| | | char* strings[MAX_STRINGS];
|
| | | int count;
|
| | | int internalIndex;
|
| | | } StringArray;
|
| | |
|
| | | StringArray* initializeStringArray(void);
|
| | | void addString(StringArray* array, const char* str, int str_len);
|
| | | const char* getStringByIndex(StringArray* array, int index);
|
| | | const char* getNextString(StringArray* array);
|
| | | void resetInternalIndex(StringArray* array);
|
| | | int getCount(StringArray* array);
|
| | | void clearStringArray(StringArray* array);
|
| | | void logStringArray(StringArray* array);
|
| | | void freeStringArray(StringArray* array);
|
| | |
|
| | | StringArray* initializeStringArray() {
|
| | | StringArray* array = (StringArray*)malloc(sizeof(StringArray));
|
| | | if (array == NULL) {
|
| | | fprintf(stderr, "Memory allocation failed\n");
|
| | | exit(1);
|
| | | }
|
| | | array->count = 0;
|
| | | array->internalIndex = 0;
|
| | | return array;
|
| | | }
|
| | |
|
| | | /*
|
| | | addString - функция добавляет константу в список констант
|
| | | str_len - количество символов из константы, которое надо использовать,
|
| | | если str_len = 0, то все символы
|
| | | */
|
| | | void addString(StringArray* array, const char* str, int str_len) {
|
| | | if (array->count >= MAX_STRINGS) {
|
| | | fprintf(stderr, "Max number of strings reached\n");
|
| | | return;
|
| | | }
|
| | | if (str_len==0)
|
| | | str_len = strlen(str);
|
| | | array->strings[array->count] = (char*)malloc(str_len + 1);
|
| | | if (array->strings[array->count] == NULL) {
|
| | | fprintf(stderr, "Memory allocation failed\n");
|
| | | exit(1);
|
| | | }
|
| | | strncpy(array->strings[array->count], str, str_len);
|
| | | array->strings[array->count][str_len] = '\0';
|
| | | array->count++;
|
| | | }
|
| | |
|
| | | const char* getStringByIndex(StringArray* array, int index) {
|
| | | if (index >= array->count || index < 0) {
|
| | | fprintf(stderr, "Index out of bounds\n");
|
| | | return NULL;
|
| | | }
|
| | | return array->strings[index];
|
| | | }
|
| | |
|
| | | const char* getNextString(StringArray* array) {
|
| | | if (array->internalIndex >= array->count) {
|
| | | return NULL;
|
| | | }
|
| | | return array->strings[array->internalIndex++];
|
| | | }
|
| | |
|
| | | void resetInternalIndex(StringArray* array) {
|
| | | array->internalIndex = 0;
|
| | | }
|
| | |
|
| | | int getCount(StringArray* array) {
|
| | | return array->count;
|
| | | }
|
| | |
|
| | | void clearStringArray(StringArray* array) {
|
| | | for (int i = 0; i < array->count; i++) {
|
| | | free(array->strings[i]);
|
| | | }
|
| | | array->count = 0;
|
| | | array->internalIndex = 0;
|
| | | }
|
| | |
|
| | | void freeStringArray(StringArray* array) {
|
| | | clearStringArray(array);
|
| | | free(array);
|
| | | }
|
| | |
|
| | | #include "utils/elog.h" // Подключаем заголовочный файл для elog
|
| | |
|
| | | void logStringArray(StringArray* array) {
|
| | | if (!array) {
|
| | | elog(ERROR, "StringArray is NULL");
|
| | | return;
|
| | | }
|
| | |
|
| | | // Выводим общее количество строк в массиве
|
| | | elog(LOG, "StringArray содержит %d строк:", array->count);
|
| | |
|
| | | // Проходим по всем строкам в массиве
|
| | | for (int i = 0; i < array->count; i++) {
|
| | | const char* str = array->strings[i];
|
| | | if (str) {
|
| | | elog(LOG, " [%d]: '%s'", i, str);
|
| | | } else {
|
| | | elog(LOG, " [%d]: (null)", i);
|
| | | }
|
| | | }
|
| | | }
|
| | | #endif // STRING_ARRAY_C
|
| New file |
| | |
| | | #include <string.h> |
| | | #include <stdint.h> |
| | | |
| | | #include "postgres.h" |
| | | |
| | | #include "utils/coder.h" |
| | | |
| | | typedef uint8_t vect[4]; |
| | | |
| | | static uint8_t key[32] = |
| | | { |
| | | 0xff, 0xee, 0xdd, 0xcc, |
| | | 0xbb, 0xaa, 0x99, 0x88, |
| | | 0x77, 0x66, 0x55, 0x44, |
| | | 0x33, 0x22, 0x11, 0x00, |
| | | 0xf0, 0xf1, 0xf2, 0xf3, |
| | | 0xf4, 0xf5, 0xf6, 0xf7, |
| | | 0xf8, 0xf9, 0xfa, 0xfb, |
| | | 0xfc, 0xfd, 0xfe, 0xff |
| | | }; //Ключ шифрования |
| | | |
| | | static unsigned char Pi[8][16]= |
| | | { |
| | | {1,7,14,13,0,5,8,3,4,15,10,6,9,12,11,2}, |
| | | {8,14,2,5,6,9,1,12,15,4,11,0,13,10,3,7}, |
| | | {5,13,15,6,9,2,12,10,11,7,8,1,4,3,14,0}, |
| | | {7,15,5,10,8,1,6,13,0,9,3,14,11,4,2,12}, |
| | | {12,8,2,1,13,4,15,6,7,0,10,5,3,14,9,11}, |
| | | {11,3,5,8,2,15,10,13,14,1,7,4,12,9,6,0}, |
| | | {6,8,2,3,9,10,5,12,1,14,4,7,11,13,0,15}, |
| | | {12,4,6,2,10,5,11,9,14,8,13,7,0,3,15,1} |
| | | }; //Таблица подстановок |
| | | |
| | | |
| | | static void Transform_T(const uint8_t *in_data, uint8_t *out_data) |
| | | { |
| | | uint8_t first_part_byte, sec_part_byte; |
| | | int i; |
| | | for (i = 0; i < 4; i++) |
| | | { |
| | | // Извлекаем первую 4-битную часть байта |
| | | first_part_byte = (in_data[i] & 0xf0) >> 4; |
| | | // Извлекаем вторую 4-битную часть байта |
| | | sec_part_byte = (in_data[i] & 0x0f); |
| | | // Выполняем замену в соответствии с таблицей подстановок |
| | | first_part_byte = Pi[i * 2][first_part_byte]; |
| | | sec_part_byte = Pi[i * 2 + 1][sec_part_byte]; |
| | | // «Склеиваем» обе 4-битные части обратно в байт |
| | | out_data[i] = (first_part_byte << 4) | sec_part_byte; |
| | | } |
| | | } |
| | | |
| | | //Сложение двух двоичных векторов по модулю 2 |
| | | static void Sum_ABS_2(const uint8_t *a, const uint8_t *b, uint8_t *c) |
| | | { |
| | | int i; |
| | | for (i = 0; i < 4; i++) |
| | | c[i] = a[i]^b[i]; |
| | | } |
| | | |
| | | //Сложение двух двоичных векторов по модулю 32 |
| | | static void Sum_ABS_32(const uint8_t *a, const uint8_t *b, uint8_t *c) |
| | | { |
| | | int i; |
| | | unsigned int internal = 0; |
| | | for (i = 3; i >= 0; i--) |
| | | { |
| | | internal = a[i] + b[i] + (internal >> 8); |
| | | c[i] = internal & 0xff; |
| | | } |
| | | } |
| | | |
| | | //Развертывание ключа |
| | | static void Expand_Key(vect* iter_key) |
| | | { |
| | | for(uint8_t i=0; i<8; i++) { |
| | | memcpy(iter_key[i], key + 4*i, 4); |
| | | memcpy(iter_key[i+8], key + 4*i, 4); |
| | | memcpy(iter_key[i+16], key + 4*i, 4); |
| | | memcpy(iter_key[i+24], key + 4*(7-i), 4); |
| | | } |
| | | } |
| | | |
| | | static void Transform_g(const uint8_t *k, const uint8_t *a, uint8_t *out_data) |
| | | { |
| | | uint8_t internal[4]; |
| | | uint32_t out_data_32; |
| | | // Складываем по модулю 32 правую половину блока с итерационным ключом |
| | | Sum_ABS_32(a, k, internal); |
| | | // Производим нелинейное биективное преобразование результата |
| | | Transform_T(internal, internal); |
| | | // Преобразовываем четырехбайтный вектор в одно 32-битное число |
| | | out_data_32 = internal[0]; |
| | | out_data_32 = (out_data_32 << 8) + internal[1]; |
| | | out_data_32 = (out_data_32 << 8) + internal[2]; |
| | | out_data_32 = (out_data_32 << 8) + internal[3]; |
| | | // Циклически сдвигаем все влево на 11 разрядов |
| | | out_data_32 = (out_data_32 << 11)|(out_data_32 >> 21); |
| | | // Преобразовываем 32-битный результат сдвига обратно в 4-байтовый вектор |
| | | out_data[3] = out_data_32; |
| | | out_data[2] = out_data_32 >> 8; |
| | | out_data[1] = out_data_32 >> 16; |
| | | out_data[0] = out_data_32 >> 24; |
| | | } |
| | | |
| | | static void Transform_G(const uint8_t *k, const uint8_t *a, uint8_t *out_data) |
| | | { |
| | | uint8_t a_0[4]; // Правая половина блока |
| | | uint8_t a_1[4]; // Левая половина блока |
| | | uint8_t G[4]; |
| | | |
| | | int i; |
| | | // Делим 64-битный исходный блок на две части |
| | | for(i = 0; i < 4; i++) |
| | | { |
| | | a_0[i] = a[4 + i]; |
| | | a_1[i] = a[i]; |
| | | } |
| | | |
| | | // Производим преобразование g |
| | | Transform_g(k, a_0, G); |
| | | // Ксорим результат преобразования g с левой половиной блока |
| | | Sum_ABS_2(a_1, G, G); |
| | | |
| | | for(i = 0; i < 4; i++) |
| | | { |
| | | a_1[i] = a_0[i]; |
| | | a_0[i] = G[i]; |
| | | } |
| | | |
| | | // Сводим правую и левую части блока в одно целое |
| | | for(i = 0; i < 4; i++) |
| | | { |
| | | out_data[i] = a_1[i]; |
| | | out_data[4 + i] = a_0[i]; |
| | | } |
| | | } |
| | | |
| | | static void Transform_G_Fin(const uint8_t *k, const uint8_t *a, uint8_t *out_data) |
| | | { |
| | | uint8_t a_0[4]; // Правая половина блока |
| | | uint8_t a_1[4]; // Левая половина блока |
| | | uint8_t G[4]; |
| | | |
| | | int i; |
| | | // Делим 64-битный исходный блок на две части |
| | | for(i = 0; i < 4; i++) |
| | | { |
| | | a_0[i] = a[4 + i]; |
| | | a_1[i] = a[i]; |
| | | } |
| | | |
| | | // Производим преобразование g |
| | | Transform_g(k, a_0, G); |
| | | // Ксорим результат преобразования g с левой половиной блока |
| | | Sum_ABS_2(a_1, G, G); |
| | | |
| | | for(i = 0; i < 4; i++) |
| | | a_1[i] = G[i]; |
| | | |
| | | for(i = 0; i < 4; i++) |
| | | { |
| | | out_data[i] = a_1[i]; |
| | | out_data[4 + i] = a_0[i]; |
| | | } |
| | | } |
| | | |
| | | static void Encrypt(const uint8_t *blk, uint8_t *out_blk, vect* iter_key) |
| | | { |
| | | int i; |
| | | Transform_G(iter_key[0], blk, out_blk); |
| | | for(i = 1; i < 31; i++) |
| | | Transform_G(iter_key[i], out_blk, out_blk); |
| | | Transform_G_Fin(iter_key[31], out_blk, out_blk); |
| | | } |
| | | |
| | | static void Decrypt(const uint8_t *blk, uint8_t *out_blk, vect* iter_key) |
| | | { |
| | | int i; |
| | | Transform_G(iter_key[31], blk, out_blk); |
| | | for(i = 30; i > 0; i--) |
| | | Transform_G(iter_key[i], out_blk, out_blk); |
| | | Transform_G_Fin(iter_key[0], out_blk, out_blk); |
| | | } |
| | | |
| | | char* pg_kuzn_encode(const char *str, size_t len) { |
| | | vect iter_key[32]; |
| | | size_t i; |
| | | |
| | | size_t out_len = 8 * ((len + 7) / 8); |
| | | char *out_str = (char*)palloc(out_len + 1); |
| | | |
| | | Expand_Key(iter_key); |
| | | |
| | | for (i = 0; i + 7 < len; i += 8) |
| | | { |
| | | Encrypt((uint8_t*)str + i, (uint8_t*)out_str + i, iter_key); |
| | | } |
| | | if(i < len) |
| | | { |
| | | uint8_t block[8]; |
| | | size_t j = 0; |
| | | while(j + i < len) { |
| | | block[j] = (uint8_t)str[i+j]; |
| | | j++; |
| | | } |
| | | while(j < 8) { |
| | | block[j] = (uint8_t)' '; |
| | | j++; |
| | | } |
| | | Encrypt(block, (uint8_t*)out_str + i, iter_key); |
| | | } |
| | | out_str[out_len] = '\0'; |
| | | return out_str; |
| | | } |
| | | |
| | | char *pg_kuzn_decode(const char *str, size_t len) { |
| | | vect iter_key[32]; |
| | | size_t i; |
| | | |
| | | size_t out_len = 8 * (len / 8); |
| | | char *out_str = (char*)palloc(out_len + 1); |
| | | |
| | | Expand_Key(iter_key); |
| | | |
| | | for (i = 0; i + 7 < len; i += 8) |
| | | { |
| | | Decrypt((uint8_t*)str + i, (uint8_t*)out_str + i, iter_key); |
| | | } |
| | | if(i > 0) |
| | | { |
| | | while (out_str[--i] == ' ') {} |
| | | out_str[i + 1] = '\0'; |
| | | } |
| | | out_str[out_len] = '\0'; |
| | | return out_str; |
| | | } |
| | |
| | | # ANTLR runtime and Oracle parser headers (PlSqlLexer/PlSqlParser). |
| | | # Mirror parser_antlr/Makefile so that dbms helpers can include the same headers. |
| | | override CPPFLAGS := -I. -I$(srcdir) \ |
| | | -I$(top_srcdir)/src/backend/utils/dbms \ |
| | | -I$(top_srcdir)/src/backend/parser_antlr \ |
| | | -I$(top_srcdir)/src/pl/plpgsql/src \ |
| | | -I/usr/include/antlr4-runtime -I/usr/local/include/antlr4-runtime \ |
| | | $(CPPFLAGS) |
| | | |
| | | # C++17 required for dbms_sql and other dbms C++ code (e.g. structured bindings, std::optional). |
| | | override CXXFLAGS += -std=c++17 |
| | | |
| | | ifdef DEBUG |
| | | override CXXFLAGS := -O0 -ggdb3 -DDEBUG $(filter-out -O% -g -D_FORTIFY_SOURCE%, $(CXXFLAGS)) |
| | | override CPPFLAGS += -DDEBUG |
| | | endif |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_alert_SRCS |
| | | DBMS_SRCS_DBMS_ALERT = \ |
| | | dbms_alert/dbms_alert.cpp \ |
| | |
| | | utils/dbms/dbms_describe/dbms_describe.o \ |
| | | # END QDB_DBMS_GEN dbms_describe_OBJS |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_json_schema_SRCS |
| | | DBMS_SRCS_DBMS_JSON_SCHEMA = \ |
| | | dbms_json_schema/dbms_json_schema.cpp \ |
| | | dbms_json_schema/vendor/json-patch.cpp \ |
| | | dbms_json_schema/vendor/json-uri.cpp \ |
| | | dbms_json_schema/vendor/json-validator.cpp \ |
| | | dbms_json_schema/vendor/json-schema-draft7.json.cpp \ |
| | | dbms_json_schema/vendor/string-format-check.cpp \ |
| | | dbms_json_schema/vendor/smtp-address-validator.cpp \ |
| | | # END QDB_DBMS_GEN dbms_json_schema_SRCS |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_json_schema_OBJS |
| | | DBMS_OBJS_DBMS_JSON_SCHEMA = \ |
| | | utils/dbms/dbms_json_schema/dbms_json_schema.o \ |
| | | utils/dbms/dbms_json_schema/vendor/json-patch.o \ |
| | | utils/dbms/dbms_json_schema/vendor/json-uri.o \ |
| | | utils/dbms/dbms_json_schema/vendor/json-validator.o \ |
| | | utils/dbms/dbms_json_schema/vendor/json-schema-draft7.json.o \ |
| | | utils/dbms/dbms_json_schema/vendor/string-format-check.o \ |
| | | utils/dbms/dbms_json_schema/vendor/smtp-address-validator.o \ |
| | | # END QDB_DBMS_GEN dbms_json_schema_OBJS |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_json_SRCS |
| | | DBMS_SRCS_DBMS_JSON = \ |
| | | dbms_json/dbms_json.cpp \ |
| | | # END QDB_DBMS_GEN dbms_json_SRCS |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_json_OBJS |
| | | DBMS_OBJS_DBMS_JSON = \ |
| | | utils/dbms/dbms_json/dbms_json.o \ |
| | | # END QDB_DBMS_GEN dbms_json_OBJS |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_trace_SRCS |
| | | DBMS_SRCS_DBMS_TRACE = \ |
| | | dbms_trace/dbms_trace.cpp \ |
| | | # END QDB_DBMS_GEN dbms_trace_SRCS |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_trace_OBJS |
| | | DBMS_OBJS_DBMS_TRACE = \ |
| | | utils/dbms/dbms_trace/dbms_trace.o \ |
| | | # END QDB_DBMS_GEN dbms_trace_OBJS |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_tns_SRCS |
| | | DBMS_SRCS_DBMS_TNS = \ |
| | | dbms_tns/dbms_tns.cpp \ |
| | | # END QDB_DBMS_GEN dbms_tns_SRCS |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_tns_OBJS |
| | | DBMS_OBJS_DBMS_TNS = \ |
| | | utils/dbms/dbms_tns/dbms_tns.o \ |
| | | # END QDB_DBMS_GEN dbms_tns_OBJS |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_warning_SRCS |
| | | DBMS_SRCS_DBMS_WARNING = \ |
| | | dbms_warning/dbms_warning.cpp \ |
| | | dbms_warning/dbms_warning_errors.cpp \ |
| | | # END QDB_DBMS_GEN dbms_warning_SRCS |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_warning_OBJS |
| | | DBMS_OBJS_DBMS_WARNING = \ |
| | | utils/dbms/dbms_warning/dbms_warning.o \ |
| | | utils/dbms/dbms_warning/dbms_warning_errors.o \ |
| | | # END QDB_DBMS_GEN dbms_warning_OBJS |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_system_SRCS |
| | | DBMS_SRCS_DBMS_SYSTEM = \ |
| | | dbms_system/dbms_system.cpp \ |
| | | # END QDB_DBMS_GEN dbms_system_SRCS |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_system_OBJS |
| | | DBMS_OBJS_DBMS_SYSTEM = \ |
| | | utils/dbms/dbms_system/dbms_system.o \ |
| | | # END QDB_DBMS_GEN dbms_system_OBJS |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_file_transfer_SRCS |
| | | DBMS_SRCS_DBMS_FILE_TRANSFER = \ |
| | | dbms_file_transfer/dbms_file_transfer.cpp \ |
| | | # END QDB_DBMS_GEN dbms_file_transfer_SRCS |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_file_transfer_OBJS |
| | | DBMS_OBJS_DBMS_FILE_TRANSFER = \ |
| | | utils/dbms/dbms_file_transfer/dbms_file_transfer.o \ |
| | | # END QDB_DBMS_GEN dbms_file_transfer_OBJS |
| | | |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_db_version_SRCS |
| | | DBMS_SRCS_DBMS_DB_VERSION = \ |
| | | dbms_db_version/dbms_db_version.cpp \ |
| | | # END QDB_DBMS_GEN dbms_db_version_SRCS |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_db_version_OBJS |
| | | DBMS_OBJS_DBMS_DB_VERSION = \ |
| | | utils/dbms/dbms_db_version/dbms_db_version.o \ |
| | | # END QDB_DBMS_GEN dbms_db_version_OBJS |
| | | |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_random_SRCS |
| | | DBMS_SRCS_DBMS_RANDOM = \ |
| | |
| | | DBMS_OBJS_DBMS_REPORT = \ |
| | | utils/dbms/dbms_report/dbms_report.o \ |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_stat_funcs_SRCS |
| | | DBMS_SRCS_DBMS_STAT_FUNCS = \ |
| | | dbms_stat_funcs/dbms_stat_funcs.cpp \ |
| | | # END QDB_DBMS_GEN dbms_stat_funcs_SRCS |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_stat_funcs_OBJS |
| | | DBMS_OBJS_DBMS_STAT_FUNCS = \ |
| | | utils/dbms/dbms_stat_funcs/dbms_stat_funcs.o \ |
| | | # END QDB_DBMS_GEN dbms_stat_funcs_OBJS |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_sqlset_SRCS |
| | | DBMS_SRCS_DBMS_SQLSET = \ |
| | | dbms_sqlset/dbms_sqlset.cpp \ |
| | | # END QDB_DBMS_GEN dbms_sqlset_SRCS |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_sqlset_OBJS |
| | | DBMS_OBJS_DBMS_SQLSET = \ |
| | | utils/dbms/dbms_sqlset/dbms_sqlset.o \ |
| | | # END QDB_DBMS_GEN dbms_sqlset_OBJS |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_ash_SRCS |
| | | DBMS_SRCS_DBMS_ASH = \ |
| | | dbms_ash/dbms_ash.cpp \ |
| | | # END QDB_DBMS_GEN dbms_ash_SRCS |
| | | |
| | | # BEGIN QDB_DBMS_GEN dbms_ash_OBJS |
| | | DBMS_OBJS_DBMS_ASH = \ |
| | | utils/dbms/dbms_ash/dbms_ash.o \ |
| | | # END QDB_DBMS_GEN dbms_ash_OBJS |
| | | |
| | | # ===== UTL_MAIL ===== |
| | | # BEGIN QDB_DBMS_GEN utl_mail_SRCS |
| | | DBMS_SRCS_UTL_MAIL = \ |
| | |
| | | DBMS_OBJS_UTL_I18N = \ |
| | | utils/dbms/utl_i18n/utl_i18n.o \ |
| | | |
| | | DBMS_SRCS_UTL_GDK = \ |
| | | utl_gdk/utl_gdk.cpp \ |
| | | |
| | | DBMS_OBJS_UTL_GDK = \ |
| | | utils/dbms/utl_gdk/utl_gdk.o \ |
| | | |
| | | DBMS_SRCS_VERSION = \ |
| | | version/version.cpp \ |
| | | |
| | | DBMS_OBJS_VERSION = \ |
| | | utils/dbms/version/version.o \ |
| | | |
| | | # BEGIN QDB_DBMS_GEN htf_SRCS |
| | | DBMS_SRCS_HTF = \ |
| | | htf/htf.cpp \ |
| | | htf/htf_common.cpp \ |
| | | # END QDB_DBMS_GEN htf_SRCS |
| | | |
| | | # BEGIN QDB_DBMS_GEN htf_OBJS |
| | | DBMS_OBJS_HTF = \ |
| | | utils/dbms/htf/htf.o \ |
| | | utils/dbms/htf/htf_common.o \ |
| | | # END QDB_DBMS_GEN htf_OBJS |
| | | |
| | | # BEGIN QDB_DBMS_GEN htp_SRCS |
| | | DBMS_SRCS_HTP = \ |
| | | htp/htp.cpp \ |
| | | # END QDB_DBMS_GEN htp_SRCS |
| | | |
| | | # BEGIN QDB_DBMS_GEN htp_OBJS |
| | | DBMS_OBJS_HTP = \ |
| | | utils/dbms/htp/htp.o \ |
| | | # END QDB_DBMS_GEN htp_OBJS |
| | | |
| | | # BEGIN QDB_DBMS_GEN owa_SRCS |
| | | DBMS_SRCS_OWA = \ |
| | | owa/owa_cookie.cpp \ |
| | | owa/owa_cache.cpp \ |
| | | # END QDB_DBMS_GEN owa_SRCS |
| | | |
| | | # BEGIN QDB_DBMS_GEN owa_OBJS |
| | | DBMS_OBJS_OWA = \ |
| | | utils/dbms/owa/owa_cookie.o \ |
| | | utils/dbms/owa/owa_cache.o \ |
| | | # END QDB_DBMS_GEN owa_OBJS |
| | | |
| | | DBMS_SRCS_DBMS_TRANSACTION = \ |
| | | dbms/dbms_transaction/dbms_transaction.cpp |
| | | |
| | | DBMS_OBJS_DBMS_TRANSACTION = \ |
| | | utils/dbms/dbms_transaction/dbms_transaction.o |
| | | |
| | | DBMS_SRCS_DBMS_DDL = \ |
| | | dbms/dbms_ddl/dbms_ddl.cpp |
| | | |
| | | DBMS_OBJS_DBMS_DDL = \ |
| | | utils/dbms/dbms_ddl/dbms_ddl.o |
| | | |
| | | DBMS_SRCS_OWA_TEXT = \ |
| | | dbms/owa_text/owa_text.cpp |
| | | |
| | | DBMS_OBJS_OWA_TEXT = \ |
| | | utils/dbms/owa_text/owa_text.o |
| | | |
| | | DBMS_SRCS_DBMS_XMLSTORE = \ |
| | | dbms/dbms_xmlstore/dbms_xmlstore.cpp |
| | | |
| | | DBMS_OBJS_DBMS_XMLSTORE = \ |
| | | utils/dbms/dbms_xmlstore/dbms_xmlstore.o |
| | | |
| | | DBMS_SRCS_DBMS_XMLSAVE = \ |
| | | dbms/dbms_xmlsave/dbms_xmlsave.cpp |
| | | |
| | | DBMS_OBJS_DBMS_XMLSAVE = \ |
| | | utils/dbms/dbms_xmlsave/dbms_xmlsave.o |
| | | |
| | | DBMS_SRCS_OWA_PATTERN = \ |
| | | dbms/owa_pattern/owa_pattern.cpp |
| | | |
| | | DBMS_OBJS_OWA_PATTERN = \ |
| | | utils/dbms/owa_pattern/owa_pattern.o |
| | | |
| | | DBMS_SRCS_OWA_MATCH = \ |
| | | dbms/owa_match/owa_match.cpp |
| | | |
| | | DBMS_OBJS_OWA_MATCH = \ |
| | | utils/dbms/owa_match/owa_match.o |
| | | |
| | | DBMS_SRCS_OWA_UTIL = \ |
| | | dbms/owa_util/owa_util.cpp |
| | | |
| | | DBMS_OBJS_OWA_UTIL = \ |
| | | utils/dbms/owa_util/owa_util.o |
| | | |
| | | # Общий список объектов для линковки |
| | | OBJS += $(DBMS_OBJS_DBMS_ALERT) \ |
| | | $(DBMS_OBJS_DBMS_ASSERT) \ |
| | |
| | | $(DBMS_OBJS_DBMS_AQADM) \ |
| | | $(DBMS_OBJS_DBMS_CRYPTO) \ |
| | | $(DBMS_OBJS_DBMS_DESCRIBE) \ |
| | | $(DBMS_OBJS_DBMS_JSON) \ |
| | | $(DBMS_OBJS_DBMS_JSON_SCHEMA) \ |
| | | $(DBMS_OBJS_DBMS_TRACE) \ |
| | | $(DBMS_OBJS_DBMS_TNS) \ |
| | | $(DBMS_OBJS_DBMS_ASH) \ |
| | | $(DBMS_OBJS_DBMS_SQLSET) \ |
| | | $(DBMS_OBJS_DBMS_STAT_FUNCS) \ |
| | | $(DBMS_OBJS_DBMS_WARNING) \ |
| | | $(DBMS_OBJS_DBMS_SYSTEM) \ |
| | | $(DBMS_OBJS_DBMS_FILE_TRANSFER) \ |
| | | $(DBMS_OBJS_DBMS_DB_VERSION) \ |
| | | $(DBMS_OBJS_DBMS_HASH) \ |
| | | $(DBMS_OBJS_DBMS_LOB) \ |
| | | $(DBMS_OBJS_DBMS_ODCI) \ |
| | |
| | | $(DBMS_OBJS_UTL_MAIL) \ |
| | | $(DBMS_OBJS_UTL_REF) \ |
| | | $(DBMS_OBJS_UTL_I18N) \ |
| | | $(DBMS_OBJS_VERSION) |
| | | $(DBMS_OBJS_UTL_GDK) \ |
| | | $(DBMS_OBJS_VERSION) \ |
| | | $(DBMS_OBJS_HTF) \ |
| | | $(DBMS_OBJS_HTP) \ |
| | | $(DBMS_OBJS_OWA) \ |
| | | $(DBMS_OBJS_DBMS_TRANSACTION) \ |
| | | $(DBMS_OBJS_DBMS_DDL) \ |
| | | $(DBMS_OBJS_OWA_TEXT) \ |
| | | $(DBMS_OBJS_DBMS_XMLSTORE) \ |
| | | $(DBMS_OBJS_DBMS_XMLSAVE) \ |
| | | $(DBMS_OBJS_OWA_PATTERN) \ |
| | | $(DBMS_OBJS_OWA_MATCH) \ |
| | | $(DBMS_OBJS_OWA_UTIL) |
| | | #$(DBMS_OBJS_DBMS_ALERT) \ |
| | | # $(DBMS_OBJS_DBMS_APPLICATION_INFO) \ |
| | | # $(DBMS_OBJS_DBMS_ASSERT) \ |
| | |
| | | # $(DBMS_OBJS_DBMS_REPORT) |
| | | |
| | | # Правила компиляции по подпапкам |
| | | |
| | | utils/dbms/dbms_alert/%.o: utils/dbms/dbms_alert/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | |
| | | utils/dbms/dbms_describe/%.o: utils/dbms/dbms_describe/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/dbms_json/%.o: utils/dbms/dbms_json/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | dbms_json/%.o: dbms_json/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | dbms_json.o: dbms_json/dbms_json.o |
| | | |
| | | utils/dbms/dbms_json_schema/%.o: utils/dbms/dbms_json_schema/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/dbms_json_schema/vendor/%.o: utils/dbms/dbms_json_schema/vendor/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/dbms_trace/%.o: utils/dbms/dbms_trace/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/dbms_tns/%.o: utils/dbms/dbms_tns/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/dbms_ash/%.o: utils/dbms/dbms_ash/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/dbms_sqlset/%.o: utils/dbms/dbms_sqlset/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/dbms_stat_funcs/%.o: utils/dbms/dbms_stat_funcs/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/dbms_warning/%.o: utils/dbms/dbms_warning/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/dbms_system/%.o: utils/dbms/dbms_system/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/dbms_file_transfer/%.o: utils/dbms/dbms_file_transfer/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/dbms_db_version/%.o: utils/dbms/dbms_db_version/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/dbms_output/%.o: utils/dbms/dbms_output/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | |
| | | utils/dbms/utl_i18n/%.o: utils/dbms/utl_i18n/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/utl_gdk/%.o: utils/dbms/utl_gdk/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/dbms_odci/dbms_odci.o: utils/dbms/dbms_odci/dbms_odci.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | |
| | | utils/dbms/dbms_report/%.o: utils/dbms/dbms_report/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/version/%.o: utils/dbms/version/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/htf/%.o: utils/dbms/htf/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/htp/%.o: utils/dbms/htp/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/owa/%.o: utils/dbms/owa/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/dbms_transaction/%.o: utils/dbms/dbms_transaction/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/dbms_ddl/%.o: utils/dbms/dbms_ddl/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/owa_text/%.o: utils/dbms/owa_text/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/dbms_xmlstore/%.o: utils/dbms/dbms_xmlstore/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/dbms_xmlsave/%.o: utils/dbms/dbms_xmlsave/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/owa_pattern/%.o: utils/dbms/owa_pattern/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/owa_match/%.o: utils/dbms/owa_match/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | utils/dbms/owa_util/%.o: utils/dbms/owa_util/%.cpp |
| | | $(COMPILE.cc) $(OUTPUT_OPTION) $< |
| | | |
| | | # Clean rule for dbms objects |
| | | .PHONY: clean-dbms |
| | |
| | | $(DBMS_OBJS_DBMS_HASH) \ |
| | | $(DBMS_OBJS_DBMS_LOB) \ |
| | | $(DBMS_OBJS_DBMS_DESCRIBE) \ |
| | | $(DBMS_OBJS_DBMS_JSON) \ |
| | | $(DBMS_OBJS_DBMS_JSON_SCHEMA) \ |
| | | $(DBMS_OBJS_DBMS_TRACE) \ |
| | | $(DBMS_OBJS_DBMS_TNS) \ |
| | | $(DBMS_OBJS_DBMS_ASH) \ |
| | | $(DBMS_OBJS_DBMS_SQLSET) \ |
| | | $(DBMS_OBJS_DBMS_STAT_FUNCS) \ |
| | | $(DBMS_OBJS_DBMS_WARNING) \ |
| | | $(DBMS_OBJS_DBMS_SYSTEM) \ |
| | | $(DBMS_OBJS_DBMS_FILE_TRANSFER) \ |
| | | $(DBMS_OBJS_DBMS_RANDOM) \ |
| | | $(DBMS_OBJS_DBMS_OUTPUT) \ |
| | | $(DBMS_OBJS_DBMS_UTILITY) \ |
| | |
| | | $(DBMS_OBJS_UTL_TCP) \ |
| | | $(DBMS_OBJS_UTL_REF) \ |
| | | $(DBMS_OBJS_UTL_I18N) \ |
| | | $(DBMS_OBJS_UTL_GDK) \ |
| | | $(DBMS_OBJS_DBMS_ODCI) \ |
| | | $(DBMS_OBJS_DBMS_REPORT) \ |
| | | $(DBMS_OBJS_VERSION) |
| | | $(DBMS_OBJS_VERSION) \ |
| | | $(DBMS_OBJS_HTF) \ |
| | | $(DBMS_OBJS_HTP) \ |
| | | $(DBMS_OBJS_OWA) \ |
| | | $(DBMS_OBJS_DBMS_TRANSACTION) \ |
| | | $(DBMS_OBJS_DBMS_DDL) \ |
| | | $(DBMS_OBJS_OWA_TEXT) \ |
| | | $(DBMS_OBJS_DBMS_XMLSTORE) \ |
| | | $(DBMS_OBJS_DBMS_XMLSAVE) \ |
| | | $(DBMS_OBJS_OWA_PATTERN) \ |
| | | $(DBMS_OBJS_OWA_MATCH) \ |
| | | $(DBMS_OBJS_OWA_UTIL) |
| New file |
| | |
| | | #include "dbms_ash.hpp" |
| | | |
| | | extern "C" |
| | | { |
| | | #include "utils/builtins.h" |
| | | #include "utils/elog.h" |
| | | } // extern "C" |
| | | |
| | | extern "C" |
| | | { |
| | | PG_FUNCTION_INFO_V1(dbms_ash_fetch_obj_name); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_fetch_procedure_name); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_fetch_sqltext); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_fetch_user_name); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_getadditionalinfo); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_getawrinfo); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_getcpuinfo); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_getdata); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_getdatahistorical); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_getdatarealtime); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_gethistogramhistorical); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_gethistogramrealtime); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_getsqltext); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_gettimeformat); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_gettimepickerhistorical); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_gettimepickerrealtime); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_getversion); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_get_blocking_session_data); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_incrementdata); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_incrementhistogram); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_incrementtimepicker); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_str_to_ascii); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_get_version); |
| | | PG_FUNCTION_INFO_V1(dbms_ash_mock); |
| | | } // extern "C" |
| | | |
| | | #define RUDB_DBMS_ASH_VERSION "1.0.0" |
| | | |
| | | Datum dbms_ash_fetch_obj_name(PG_FUNCTION_ARGS) |
| | | { |
| | | const int32 p_obj_id = PG_GETARG_INT32(1); |
| | | (void) p_obj_id; |
| | | |
| | | const int32 p_dbid = PG_GETARG_INT32(2); |
| | | (void) p_dbid; |
| | | |
| | | const int32 p_con_dbid = PG_GETARG_INT32(3); |
| | | (void) p_con_dbid; |
| | | |
| | | const text* p_is_local = PG_GETARG_TEXT_PP(4); |
| | | (void) p_is_local; |
| | | |
| | | const text* p_local_type = PG_GETARG_TEXT_PP(5); |
| | | (void) p_local_type; |
| | | |
| | | const text* p_is_old = PG_GETARG_TEXT_PP(6); |
| | | (void) p_is_old; |
| | | |
| | | const text* p_time_limit = PG_GETARG_TEXT_PP(7); |
| | | (void) p_time_limit; |
| | | |
| | | /* |
| | | * ERROR: неподдерживаемый элемент сохранён как заглушка. |
| | | * ERROR: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. |
| | | */ |
| | | ereport(ERROR, (errmsg("функция DBMS_ASH.FETCH_OBJ_NAME не поддерживается: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. Проверьте соответствующую запись в pg_proc.dat."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | Datum dbms_ash_fetch_procedure_name(PG_FUNCTION_ARGS) |
| | | { |
| | | const int32 p_obj_id = PG_GETARG_INT32(1); |
| | | (void) p_obj_id; |
| | | |
| | | const int32 p_subobj_id = PG_GETARG_INT32(2); |
| | | (void) p_subobj_id; |
| | | |
| | | const int32 p_con_dbid = PG_GETARG_INT32(3); |
| | | (void) p_con_dbid; |
| | | |
| | | const text* p_time_limit = PG_GETARG_TEXT_PP(4); |
| | | (void) p_time_limit; |
| | | |
| | | ereport(ERROR, (errmsg("функция DBMS_ASH.FETCH_PROCEDURE_NAME не реализована."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | Datum dbms_ash_fetch_sqltext(PG_FUNCTION_ARGS) |
| | | { |
| | | const text* p_sqlid = PG_GETARG_TEXT_PP(1); |
| | | (void) p_sqlid; |
| | | |
| | | const int32 p_dbid = PG_GETARG_INT32(2); |
| | | (void) p_dbid; |
| | | |
| | | const int32 p_con_dbid = PG_GETARG_INT32(3); |
| | | (void) p_con_dbid; |
| | | |
| | | const text* p_is_local = PG_GETARG_TEXT_PP(4); |
| | | (void) p_is_local; |
| | | |
| | | const text* p_is_pdb = PG_GETARG_TEXT_PP(5); |
| | | (void) p_is_pdb; |
| | | |
| | | const text* p_is_old = PG_GETARG_TEXT_PP(6); |
| | | (void) p_is_old; |
| | | |
| | | const text* p_time_limit = PG_GETARG_TEXT_PP(7); |
| | | (void) p_time_limit; |
| | | |
| | | /* |
| | | * ERROR: неподдерживаемый элемент сохранён как заглушка. |
| | | * ERROR: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. |
| | | */ |
| | | ereport(ERROR, (errmsg("функция DBMS_ASH.FETCH_SQLTEXT не поддерживается: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. Проверьте соответствующую запись в pg_proc.dat."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | Datum dbms_ash_fetch_user_name(PG_FUNCTION_ARGS) |
| | | { |
| | | const int32 p_user_id = PG_GETARG_INT32(1); |
| | | (void) p_user_id; |
| | | |
| | | const int32 p_con_dbid = PG_GETARG_INT32(2); |
| | | (void) p_con_dbid; |
| | | |
| | | const text* p_time_limit = PG_GETARG_TEXT_PP(3); |
| | | (void) p_time_limit; |
| | | |
| | | ereport(ERROR, (errmsg("функция DBMS_ASH.FETCH_USER_NAME не реализована."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | Datum dbms_ash_getadditionalinfo(PG_FUNCTION_ARGS) |
| | | { |
| | | const int32 dbid = PG_GETARG_INT32(1); |
| | | (void) dbid; |
| | | |
| | | const int32 instance_number = PG_GETARG_INT32(2); |
| | | (void) instance_number; |
| | | |
| | | const text* real_time_mode = PG_GETARG_TEXT_PP(3); |
| | | (void) real_time_mode; |
| | | |
| | | const text* show_sql = PG_GETARG_TEXT_PP(4); |
| | | (void) show_sql; |
| | | |
| | | const text* dim_list = PG_GETARG_TEXT_PP(5); |
| | | (void) dim_list; |
| | | |
| | | const text* sqlid_list = PG_GETARG_TEXT_PP(6); |
| | | (void) sqlid_list; |
| | | |
| | | const text* plsql_list = PG_GETARG_TEXT_PP(7); |
| | | (void) plsql_list; |
| | | |
| | | const text* object_list = PG_GETARG_TEXT_PP(8); |
| | | (void) object_list; |
| | | |
| | | const text* user_list = PG_GETARG_TEXT_PP(9); |
| | | (void) user_list; |
| | | |
| | | /* |
| | | * ERROR: неподдерживаемый элемент сохранён как заглушка. |
| | | * ERROR: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. |
| | | */ |
| | | ereport(ERROR, (errmsg("функция DBMS_ASH.GETADDITIONALINFO не поддерживается: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. Проверьте соответствующую запись в pg_proc.dat."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | Datum dbms_ash_getawrinfo(PG_FUNCTION_ARGS) |
| | | { |
| | | const int32 p_dbid = PG_GETARG_INT32(1); |
| | | (void) p_dbid; |
| | | |
| | | const text* p_begin_time_utc = PG_GETARG_TEXT_PP(2); |
| | | (void) p_begin_time_utc; |
| | | |
| | | const text* p_end_time_utc = PG_GETARG_TEXT_PP(3); |
| | | (void) p_end_time_utc; |
| | | |
| | | const int32 p_inst_num = PG_GETARG_INT32(4); |
| | | (void) p_inst_num; |
| | | |
| | | const text* show_sql = PG_GETARG_TEXT_PP(5); |
| | | (void) show_sql; |
| | | |
| | | /* |
| | | * ERROR: неподдерживаемый элемент сохранён как заглушка. |
| | | * ERROR: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. |
| | | */ |
| | | ereport(ERROR, (errmsg("функция DBMS_ASH.GETAWRINFO не поддерживается: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. Проверьте соответствующую запись в pg_proc.dat."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | Datum dbms_ash_getcpuinfo(PG_FUNCTION_ARGS) |
| | | { |
| | | const int32 dbid = PG_GETARG_INT32(1); |
| | | (void) dbid; |
| | | |
| | | const text* observationtime = PG_GETARG_TEXT_PP(2); |
| | | (void) observationtime; |
| | | |
| | | const int32 instance_number = PG_GETARG_INT32(3); |
| | | (void) instance_number; |
| | | |
| | | const text* ignore_cpu_history = PG_GETARG_TEXT_PP(4); |
| | | (void) ignore_cpu_history; |
| | | |
| | | const text* show_sql = PG_GETARG_TEXT_PP(5); |
| | | (void) show_sql; |
| | | |
| | | /* |
| | | * ERROR: неподдерживаемый элемент сохранён как заглушка. |
| | | * ERROR: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. |
| | | */ |
| | | ereport(ERROR, (errmsg("функция DBMS_ASH.GETCPUINFO не поддерживается: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. Проверьте соответствующую запись в pg_proc.dat."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | Datum dbms_ash_getdata(PG_FUNCTION_ARGS) |
| | | { |
| | | const text* data_type = PG_GETARG_TEXT_PP(1); |
| | | (void) data_type; |
| | | |
| | | const text* time_type = PG_GETARG_TEXT_PP(2); |
| | | (void) time_type; |
| | | |
| | | const text* filter_list = PG_GETARG_TEXT_PP(3); |
| | | (void) filter_list; |
| | | |
| | | const text* args = PG_GETARG_TEXT_PP(4); |
| | | (void) args; |
| | | |
| | | /* |
| | | * ERROR: неподдерживаемый элемент сохранён как заглушка. |
| | | * ERROR: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. |
| | | */ |
| | | ereport(ERROR, (errmsg("функция DBMS_ASH.GETDATA не поддерживается: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. Проверьте соответствующую запись в pg_proc.dat."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | Datum dbms_ash_getdatahistorical(PG_FUNCTION_ARGS) |
| | | { |
| | | const int32 dbid = PG_GETARG_INT32(1); |
| | | (void) dbid; |
| | | |
| | | const text* filter_list = PG_GETARG_TEXT_PP(2); |
| | | (void) filter_list; |
| | | |
| | | const text* begin_time_utc = PG_GETARG_TEXT_PP(3); |
| | | (void) begin_time_utc; |
| | | |
| | | const text* end_time_utc = PG_GETARG_TEXT_PP(4); |
| | | (void) end_time_utc; |
| | | |
| | | const int32 time_since_sec = PG_GETARG_INT32(5); |
| | | (void) time_since_sec; |
| | | |
| | | const text* show_sql = PG_GETARG_TEXT_PP(6); |
| | | (void) show_sql; |
| | | |
| | | const text* verbose_xml = PG_GETARG_TEXT_PP(7); |
| | | (void) verbose_xml; |
| | | |
| | | const text* include_bg = PG_GETARG_TEXT_PP(8); |
| | | (void) include_bg; |
| | | |
| | | const int32 instance_number = PG_GETARG_INT32(9); |
| | | (void) instance_number; |
| | | |
| | | const text* minimize_cost = PG_GETARG_TEXT_PP(10); |
| | | (void) minimize_cost; |
| | | |
| | | const text* resolution = PG_GETARG_TEXT_PP(11); |
| | | (void) resolution; |
| | | |
| | | const text* monitoring_mode = PG_GETARG_TEXT_PP(12); |
| | | (void) monitoring_mode; |
| | | |
| | | const text* memory_only = PG_GETARG_TEXT_PP(13); |
| | | (void) memory_only; |
| | | |
| | | const text* dimensions = PG_GETARG_TEXT_PP(14); |
| | | (void) dimensions; |
| | | |
| | | /* |
| | | * ERROR: неподдерживаемый элемент сохранён как заглушка. |
| | | * ERROR: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. |
| | | */ |
| | | ereport(ERROR, (errmsg("функция DBMS_ASH.GETDATAHISTORICAL не поддерживается: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. Проверьте соответствующую запись в pg_proc.dat."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | Datum dbms_ash_getdatarealtime(PG_FUNCTION_ARGS) |
| | | { |
| | | const text* filter_list = PG_GETARG_TEXT_PP(1); |
| | | (void) filter_list; |
| | | |
| | | const int32 time_since_sec = PG_GETARG_INT32(2); |
| | | (void) time_since_sec; |
| | | |
| | | const text* show_sql = PG_GETARG_TEXT_PP(3); |
| | | (void) show_sql; |
| | | |
| | | const text* verbose_xml = PG_GETARG_TEXT_PP(4); |
| | | (void) verbose_xml; |
| | | |
| | | const text* include_bg = PG_GETARG_TEXT_PP(5); |
| | | (void) include_bg; |
| | | |
| | | const int32 instance_number = PG_GETARG_INT32(6); |
| | | (void) instance_number; |
| | | |
| | | const text* minimize_cost = PG_GETARG_TEXT_PP(7); |
| | | (void) minimize_cost; |
| | | |
| | | const text* resolution = PG_GETARG_TEXT_PP(8); |
| | | (void) resolution; |
| | | |
| | | const text* monitoring_mode = PG_GETARG_TEXT_PP(9); |
| | | (void) monitoring_mode; |
| | | |
| | | const text* memory_only = PG_GETARG_TEXT_PP(10); |
| | | (void) memory_only; |
| | | |
| | | const text* dimensions = PG_GETARG_TEXT_PP(11); |
| | | (void) dimensions; |
| | | |
| | | /* |
| | | * ERROR: неподдерживаемый элемент сохранён как заглушка. |
| | | * ERROR: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. |
| | | */ |
| | | ereport(ERROR, (errmsg("функция DBMS_ASH.GETDATAREALTIME не поддерживается: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. Проверьте соответствующую запись в pg_proc.dat."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | Datum dbms_ash_gethistogramhistorical(PG_FUNCTION_ARGS) |
| | | { |
| | | const int32 dbid = PG_GETARG_INT32(1); |
| | | (void) dbid; |
| | | |
| | | const text* filter_list = PG_GETARG_TEXT_PP(2); |
| | | (void) filter_list; |
| | | |
| | | const text* begin_time_utc = PG_GETARG_TEXT_PP(3); |
| | | (void) begin_time_utc; |
| | | |
| | | const text* end_time_utc = PG_GETARG_TEXT_PP(4); |
| | | (void) end_time_utc; |
| | | |
| | | const int32 time_since_sec = PG_GETARG_INT32(5); |
| | | (void) time_since_sec; |
| | | |
| | | const text* show_sql = PG_GETARG_TEXT_PP(6); |
| | | (void) show_sql; |
| | | |
| | | const text* verbose_xml = PG_GETARG_TEXT_PP(7); |
| | | (void) verbose_xml; |
| | | |
| | | const text* include_bg = PG_GETARG_TEXT_PP(8); |
| | | (void) include_bg; |
| | | |
| | | const int32 instance_number = PG_GETARG_INT32(9); |
| | | (void) instance_number; |
| | | |
| | | const text* ignore_cpu_history = PG_GETARG_TEXT_PP(10); |
| | | (void) ignore_cpu_history; |
| | | |
| | | const text* resolution = PG_GETARG_TEXT_PP(11); |
| | | (void) resolution; |
| | | |
| | | const text* memory_only = PG_GETARG_TEXT_PP(12); |
| | | (void) memory_only; |
| | | |
| | | /* |
| | | * ERROR: неподдерживаемый элемент сохранён как заглушка. |
| | | * ERROR: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. |
| | | */ |
| | | ereport(ERROR, (errmsg("функция DBMS_ASH.GETHISTOGRAMHISTORICAL не поддерживается: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. Проверьте соответствующую запись в pg_proc.dat."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | Datum dbms_ash_gethistogramrealtime(PG_FUNCTION_ARGS) |
| | | { |
| | | const text* filter_list = PG_GETARG_TEXT_PP(1); |
| | | (void) filter_list; |
| | | |
| | | const int32 time_since_sec = PG_GETARG_INT32(2); |
| | | (void) time_since_sec; |
| | | |
| | | const text* show_sql = PG_GETARG_TEXT_PP(3); |
| | | (void) show_sql; |
| | | |
| | | const text* verbose_xml = PG_GETARG_TEXT_PP(4); |
| | | (void) verbose_xml; |
| | | |
| | | const text* include_bg = PG_GETARG_TEXT_PP(5); |
| | | (void) include_bg; |
| | | |
| | | const int32 instance_number = PG_GETARG_INT32(6); |
| | | (void) instance_number; |
| | | |
| | | const text* ignore_cpu_history = PG_GETARG_TEXT_PP(7); |
| | | (void) ignore_cpu_history; |
| | | |
| | | const text* resolution = PG_GETARG_TEXT_PP(8); |
| | | (void) resolution; |
| | | |
| | | const text* memory_only = PG_GETARG_TEXT_PP(9); |
| | | (void) memory_only; |
| | | |
| | | /* |
| | | * ERROR: неподдерживаемый элемент сохранён как заглушка. |
| | | * ERROR: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. |
| | | */ |
| | | ereport(ERROR, (errmsg("функция DBMS_ASH.GETHISTOGRAMREALTIME не поддерживается: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. Проверьте соответствующую запись в pg_proc.dat."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | Datum dbms_ash_getsqltext(PG_FUNCTION_ARGS) |
| | | { |
| | | const int32 p_dbid = PG_GETARG_INT32(1); |
| | | (void) p_dbid; |
| | | |
| | | const text* p_sql_ids = PG_GETARG_TEXT_PP(2); |
| | | (void) p_sql_ids; |
| | | |
| | | /* |
| | | * ERROR: неподдерживаемый элемент сохранён как заглушка. |
| | | * ERROR: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. |
| | | */ |
| | | ereport(ERROR, (errmsg("функция DBMS_ASH.GETSQLTEXT не поддерживается: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. Проверьте соответствующую запись в pg_proc.dat."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | Datum dbms_ash_gettimeformat(PG_FUNCTION_ARGS) |
| | | { |
| | | ereport(ERROR, (errmsg("функция DBMS_ASH.GETTIMEFORMAT не реализована."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | Datum dbms_ash_gettimepickerhistorical(PG_FUNCTION_ARGS) |
| | | { |
| | | const int32 dbid = PG_GETARG_INT32(1); |
| | | (void) dbid; |
| | | |
| | | const text* begin_time_utc = PG_GETARG_TEXT_PP(2); |
| | | (void) begin_time_utc; |
| | | |
| | | const text* end_time_utc = PG_GETARG_TEXT_PP(3); |
| | | (void) end_time_utc; |
| | | |
| | | const int32 time_since_sec = PG_GETARG_INT32(4); |
| | | (void) time_since_sec; |
| | | |
| | | const text* show_sql = PG_GETARG_TEXT_PP(5); |
| | | (void) show_sql; |
| | | |
| | | const text* verbose_xml = PG_GETARG_TEXT_PP(6); |
| | | (void) verbose_xml; |
| | | |
| | | const int32 instance_number = PG_GETARG_INT32(7); |
| | | (void) instance_number; |
| | | |
| | | const text* awr_info = PG_GETARG_TEXT_PP(8); |
| | | (void) awr_info; |
| | | |
| | | const text* ignore_cpu_history = PG_GETARG_TEXT_PP(9); |
| | | (void) ignore_cpu_history; |
| | | |
| | | const text* resolution = PG_GETARG_TEXT_PP(10); |
| | | (void) resolution; |
| | | |
| | | const text* include_bg = PG_GETARG_TEXT_PP(11); |
| | | (void) include_bg; |
| | | |
| | | const text* memory_only = PG_GETARG_TEXT_PP(12); |
| | | (void) memory_only; |
| | | |
| | | /* |
| | | * ERROR: неподдерживаемый элемент сохранён как заглушка. |
| | | * ERROR: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. |
| | | */ |
| | | ereport(ERROR, (errmsg("функция DBMS_ASH.GETTIMEPICKERHISTORICAL не поддерживается: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. Проверьте соответствующую запись в pg_proc.dat."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | Datum dbms_ash_gettimepickerrealtime(PG_FUNCTION_ARGS) |
| | | { |
| | | const int32 time_since_sec = PG_GETARG_INT32(1); |
| | | (void) time_since_sec; |
| | | |
| | | const text* show_sql = PG_GETARG_TEXT_PP(2); |
| | | (void) show_sql; |
| | | |
| | | const text* verbose_xml = PG_GETARG_TEXT_PP(3); |
| | | (void) verbose_xml; |
| | | |
| | | const int32 instance_number = PG_GETARG_INT32(4); |
| | | (void) instance_number; |
| | | |
| | | const text* awr_info = PG_GETARG_TEXT_PP(5); |
| | | (void) awr_info; |
| | | |
| | | const text* ignore_cpu_history = PG_GETARG_TEXT_PP(6); |
| | | (void) ignore_cpu_history; |
| | | |
| | | const text* resolution = PG_GETARG_TEXT_PP(7); |
| | | (void) resolution; |
| | | |
| | | const text* include_bg = PG_GETARG_TEXT_PP(8); |
| | | (void) include_bg; |
| | | |
| | | const text* memory_only = PG_GETARG_TEXT_PP(9); |
| | | (void) memory_only; |
| | | |
| | | /* |
| | | * ERROR: неподдерживаемый элемент сохранён как заглушка. |
| | | * ERROR: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. |
| | | */ |
| | | ereport(ERROR, (errmsg("функция DBMS_ASH.GETTIMEPICKERREALTIME не поддерживается: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. Проверьте соответствующую запись в pg_proc.dat."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | Datum dbms_ash_getversion(PG_FUNCTION_ARGS) |
| | | { |
| | | ereport(ERROR, (errmsg("функция DBMS_ASH.GETVERSION не реализована."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | Datum dbms_ash_get_blocking_session_data(PG_FUNCTION_ARGS) |
| | | { |
| | | const text* data_type = PG_GETARG_TEXT_PP(1); |
| | | (void) data_type; |
| | | |
| | | const text* source_type = PG_GETARG_TEXT_PP(2); |
| | | (void) source_type; |
| | | |
| | | const text* filter_list = PG_GETARG_TEXT_PP(3); |
| | | (void) filter_list; |
| | | |
| | | const text* begin_time_utc = PG_GETARG_TEXT_PP(4); |
| | | (void) begin_time_utc; |
| | | |
| | | const text* end_time_utc = PG_GETARG_TEXT_PP(5); |
| | | (void) end_time_utc; |
| | | |
| | | const int32 time_since_sec = PG_GETARG_INT32(6); |
| | | (void) time_since_sec; |
| | | |
| | | const text* show_sql = PG_GETARG_TEXT_PP(7); |
| | | (void) show_sql; |
| | | |
| | | const text* filter_common_user = PG_GETARG_TEXT_PP(8); |
| | | (void) filter_common_user; |
| | | |
| | | /* |
| | | * ERROR: неподдерживаемый элемент сохранён как заглушка. |
| | | * ERROR: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. |
| | | */ |
| | | ereport(ERROR, (errmsg("функция DBMS_ASH.GET_BLOCKING_SESSION_DATA не поддерживается: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. Проверьте соответствующую запись в pg_proc.dat."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | Datum dbms_ash_incrementdata(PG_FUNCTION_ARGS) |
| | | { |
| | | const text* filter_list = PG_GETARG_TEXT_PP(1); |
| | | (void) filter_list; |
| | | |
| | | const text* begin_time_utc = PG_GETARG_TEXT_PP(2); |
| | | (void) begin_time_utc; |
| | | |
| | | const int32 bucket_size = PG_GETARG_INT32(3); |
| | | (void) bucket_size; |
| | | |
| | | const text* show_sql = PG_GETARG_TEXT_PP(4); |
| | | (void) show_sql; |
| | | |
| | | const text* verbose_xml = PG_GETARG_TEXT_PP(5); |
| | | (void) verbose_xml; |
| | | |
| | | const text* include_bg = PG_GETARG_TEXT_PP(6); |
| | | (void) include_bg; |
| | | |
| | | const int32 instance_number = PG_GETARG_INT32(7); |
| | | (void) instance_number; |
| | | |
| | | const text* minimize_cost = PG_GETARG_TEXT_PP(8); |
| | | (void) minimize_cost; |
| | | |
| | | const text* resolution = PG_GETARG_TEXT_PP(9); |
| | | (void) resolution; |
| | | |
| | | const text* monitoring_mode = PG_GETARG_TEXT_PP(10); |
| | | (void) monitoring_mode; |
| | | |
| | | const text* memory_only = PG_GETARG_TEXT_PP(11); |
| | | (void) memory_only; |
| | | |
| | | const text* dimensions = PG_GETARG_TEXT_PP(12); |
| | | (void) dimensions; |
| | | |
| | | /* |
| | | * ERROR: неподдерживаемый элемент сохранён как заглушка. |
| | | * ERROR: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. |
| | | */ |
| | | ereport(ERROR, (errmsg("функция DBMS_ASH.INCREMENTDATA не поддерживается: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. Проверьте соответствующую запись в pg_proc.dat."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | Datum dbms_ash_incrementhistogram(PG_FUNCTION_ARGS) |
| | | { |
| | | const text* filter_list = PG_GETARG_TEXT_PP(1); |
| | | (void) filter_list; |
| | | |
| | | const text* begin_time_utc = PG_GETARG_TEXT_PP(2); |
| | | (void) begin_time_utc; |
| | | |
| | | const int32 bucket_size = PG_GETARG_INT32(3); |
| | | (void) bucket_size; |
| | | |
| | | const text* show_sql = PG_GETARG_TEXT_PP(4); |
| | | (void) show_sql; |
| | | |
| | | const text* verbose_xml = PG_GETARG_TEXT_PP(5); |
| | | (void) verbose_xml; |
| | | |
| | | const text* include_bg = PG_GETARG_TEXT_PP(6); |
| | | (void) include_bg; |
| | | |
| | | const int32 instance_number = PG_GETARG_INT32(7); |
| | | (void) instance_number; |
| | | |
| | | const text* resolution = PG_GETARG_TEXT_PP(8); |
| | | (void) resolution; |
| | | |
| | | const text* memory_only = PG_GETARG_TEXT_PP(9); |
| | | (void) memory_only; |
| | | |
| | | /* |
| | | * ERROR: неподдерживаемый элемент сохранён как заглушка. |
| | | * ERROR: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. |
| | | */ |
| | | ereport(ERROR, (errmsg("функция DBMS_ASH.INCREMENTHISTOGRAM не поддерживается: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. Проверьте соответствующую запись в pg_proc.dat."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | Datum dbms_ash_incrementtimepicker(PG_FUNCTION_ARGS) |
| | | { |
| | | const text* begin_time_utc = PG_GETARG_TEXT_PP(1); |
| | | (void) begin_time_utc; |
| | | |
| | | const int32 bucket_size = PG_GETARG_INT32(2); |
| | | (void) bucket_size; |
| | | |
| | | const text* show_sql = PG_GETARG_TEXT_PP(3); |
| | | (void) show_sql; |
| | | |
| | | const text* verbose_xml = PG_GETARG_TEXT_PP(4); |
| | | (void) verbose_xml; |
| | | |
| | | const int32 instance_number = PG_GETARG_INT32(5); |
| | | (void) instance_number; |
| | | |
| | | const text* awr_info = PG_GETARG_TEXT_PP(6); |
| | | (void) awr_info; |
| | | |
| | | const text* resolution = PG_GETARG_TEXT_PP(7); |
| | | (void) resolution; |
| | | |
| | | const text* include_bg = PG_GETARG_TEXT_PP(8); |
| | | (void) include_bg; |
| | | |
| | | const text* memory_only = PG_GETARG_TEXT_PP(9); |
| | | (void) memory_only; |
| | | |
| | | /* |
| | | * ERROR: неподдерживаемый элемент сохранён как заглушка. |
| | | * ERROR: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. |
| | | */ |
| | | ereport(ERROR, (errmsg("функция DBMS_ASH.INCREMENTTIMEPICKER не поддерживается: Неподдерживаемый возвращаемый тип OPAQUE/XMLTYPE; функция сгенерирована как заглушка с catalog return type text. Требуется ручная проверка/реализация. Проверьте соответствующую запись в pg_proc.dat."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | Datum dbms_ash_str_to_ascii(PG_FUNCTION_ARGS) |
| | | { |
| | | const text* s = PG_GETARG_TEXT_PP(1); |
| | | (void) s; |
| | | |
| | | ereport(ERROR, (errmsg("функция DBMS_ASH.STR_TO_ASCII не реализована."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | Datum dbms_ash_get_version(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_TEXT_P(cstring_to_text(RUDB_DBMS_ASH_VERSION)); |
| | | } |
| | | |
| | | Datum dbms_ash_mock(PG_FUNCTION_ARGS) |
| | | { |
| | | /* |
| | | * ERROR: generated package mock stub. |
| | | * ERROR: Эта функция является checkpoint-заглушкой и требует ручной реализации. |
| | | * ERROR: Generated package mock stub: функция DBMS_ASH.MOCK является заглушкой и требует ручной реализации. |
| | | */ |
| | | ereport(ERROR, (errmsg("Сгенерированная функция DBMS_ASH.MOCK является mock stub; требуется ручная реализация."))); |
| | | PG_RETURN_NULL(); |
| | | } |
| New file |
| | |
| | | #ifndef DBMS_ASH_INTERNAL_HPP |
| | | #define DBMS_ASH_INTERNAL_HPP |
| | | |
| | | /** |
| | | * @brief DBMS_ASH: Импортировано из Oracle API inventory: /home/dev/rudb_dbms_gen_output/oracle_inventory/rudb_api_inventory.tsv |
| | | * @details |
| | | * Назначение: |
| | | * Импортировано из Oracle API inventory: |
| | | * /home/dev/rudb_dbms_gen_output/oracle_inventory/rudb_api_inventory.tsv |
| | | */ |
| | | |
| | | extern "C" |
| | | { |
| | | #include "postgres.h" |
| | | #include "fmgr.h" |
| | | } // extern "C" |
| | | |
| | | extern "C" |
| | | { |
| | | /** |
| | | * @brief функция dbms_ash_fetch_obj_name. |
| | | * @details Это заглушка совместимости: SQL-объявление сохранено, но реализация пока не |
| | | * предоставлена. |
| | | * Контракт и типы берутся из inventory/spec, чтобы HPP оставался синхронизированным с |
| | | * SQL-поверхностью. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_fetch_obj_name(:p_obj_id, :p_dbid, :p_con_dbid, :p_is_local, |
| | | * :p_local_type, :p_is_old, :p_time_limit) FROM dual; |
| | | * DECLARE v text; BEGIN v := DBMS_ASH.dbms_ash_fetch_obj_name(42, 42, 42, 'demo_alias', |
| | | * 'demo_alias', 'demo_alias', 'demo_alias'); END; |
| | | * SELECT DBMS_ASH.dbms_ash_fetch_obj_name(0, 0, 0, 'demo_value', 'demo_value', |
| | | * 'demo_value', 'demo_value') FROM dual; |
| | | * @param p_obj_id Аргумент p_obj_id, режим IN, тип number. |
| | | * @param p_dbid Аргумент p_dbid, режим IN, тип number. |
| | | * @param p_con_dbid Аргумент p_con_dbid, режим IN, тип number. |
| | | * @param p_is_local Аргумент p_is_local, режим IN, тип varchar2. |
| | | * @param p_local_type Аргумент p_local_type, режим IN, тип varchar2. |
| | | * @param p_is_old Аргумент p_is_old, режим IN, тип varchar2. |
| | | * @param p_time_limit Аргумент p_time_limit, режим IN, тип varchar2. |
| | | * @return `text`. |
| | | */ |
| | | Datum dbms_ash_fetch_obj_name(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief функция dbms_ash_fetch_procedure_name. |
| | | * @details Это заглушка совместимости: SQL-объявление сохранено, но реализация пока не |
| | | * предоставлена. |
| | | * Контракт и типы берутся из inventory/spec, чтобы HPP оставался синхронизированным с |
| | | * SQL-поверхностью. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_fetch_procedure_name(:p_obj_id, :p_subobj_id, :p_con_dbid, |
| | | * :p_time_limit) FROM dual; |
| | | * DECLARE v varchar2; BEGIN v := DBMS_ASH.dbms_ash_fetch_procedure_name(42, 42, 42, |
| | | * 'demo_alias'); END; |
| | | * SELECT DBMS_ASH.dbms_ash_fetch_procedure_name(0, 0, 0, 'demo_value') FROM dual; |
| | | * @param p_obj_id Аргумент p_obj_id, режим IN, тип number. |
| | | * @param p_subobj_id Аргумент p_subobj_id, режим IN, тип number. |
| | | * @param p_con_dbid Аргумент p_con_dbid, режим IN, тип number. |
| | | * @param p_time_limit Аргумент p_time_limit, режим IN, тип varchar2. |
| | | * @return `varchar2`. |
| | | */ |
| | | Datum dbms_ash_fetch_procedure_name(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief функция dbms_ash_fetch_sqltext. |
| | | * @details Это заглушка совместимости: SQL-объявление сохранено, но реализация пока не |
| | | * предоставлена. |
| | | * Контракт и типы берутся из inventory/spec, чтобы HPP оставался синхронизированным с |
| | | * SQL-поверхностью. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_fetch_sqltext(:p_sqlid, :p_dbid, :p_con_dbid, :p_is_local, |
| | | * :p_is_pdb, :p_is_old, :p_time_limit) FROM dual; |
| | | * DECLARE v text; BEGIN v := DBMS_ASH.dbms_ash_fetch_sqltext('demo_alias', 42, 42, |
| | | * 'demo_alias', 'demo_alias', 'demo_alias', 'demo_alias'); END; |
| | | * SELECT DBMS_ASH.dbms_ash_fetch_sqltext('demo_value', 0, 0, 'demo_value', 'demo_value', |
| | | * 'demo_value', 'demo_value') FROM dual; |
| | | * @param p_sqlid Аргумент p_sqlid, режим IN, тип varchar2. |
| | | * @param p_dbid Аргумент p_dbid, режим IN, тип number. |
| | | * @param p_con_dbid Аргумент p_con_dbid, режим IN, тип number. |
| | | * @param p_is_local Аргумент p_is_local, режим IN, тип varchar2. |
| | | * @param p_is_pdb Аргумент p_is_pdb, режим IN, тип varchar2. |
| | | * @param p_is_old Аргумент p_is_old, режим IN, тип varchar2. |
| | | * @param p_time_limit Аргумент p_time_limit, режим IN, тип varchar2. |
| | | * @return `text`. |
| | | */ |
| | | Datum dbms_ash_fetch_sqltext(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief функция dbms_ash_fetch_user_name. |
| | | * @details Это заглушка совместимости: SQL-объявление сохранено, но реализация пока не |
| | | * предоставлена. |
| | | * Контракт и типы берутся из inventory/spec, чтобы HPP оставался синхронизированным с |
| | | * SQL-поверхностью. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_fetch_user_name(:p_user_id, :p_con_dbid, :p_time_limit) FROM |
| | | * dual; |
| | | * DECLARE v varchar2; BEGIN v := DBMS_ASH.dbms_ash_fetch_user_name(42, 42, 'demo_alias'); |
| | | * END; |
| | | * SELECT DBMS_ASH.dbms_ash_fetch_user_name(0, 0, 'demo_value') FROM dual; |
| | | * @param p_user_id Аргумент p_user_id, режим IN, тип number. |
| | | * @param p_con_dbid Аргумент p_con_dbid, режим IN, тип number. |
| | | * @param p_time_limit Аргумент p_time_limit, режим IN, тип varchar2. |
| | | * @return `varchar2`. |
| | | */ |
| | | Datum dbms_ash_fetch_user_name(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief функция dbms_ash_getadditionalinfo. |
| | | * @details Это заглушка совместимости: SQL-объявление сохранено, но реализация пока не |
| | | * предоставлена. |
| | | * Контракт и типы берутся из inventory/spec, чтобы HPP оставался синхронизированным с |
| | | * SQL-поверхностью. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_getadditionalinfo(:dbid, :instance_number, :real_time_mode, |
| | | * :show_sql, :dim_list, :sqlid_list, :plsql_list, :object_list, :user_list) FROM dual; |
| | | * DECLARE v text; BEGIN v := DBMS_ASH.dbms_ash_getadditionalinfo(42, 42, 'demo_alias', |
| | | * 'demo_alias', 'demo_alias', 'demo_alias', 'demo_alias', 'demo_alias', 'demo_alias'); |
| | | * END; |
| | | * SELECT DBMS_ASH.dbms_ash_getadditionalinfo(0, 0, 'demo_value', 'demo_value', |
| | | * 'demo_value', 'demo_value', 'demo_value', 'demo_value', 'demo_value') FROM dual; |
| | | * @param dbid Аргумент dbid, режим IN, тип number. |
| | | * @param instance_number Аргумент instance_number, режим IN, тип number. |
| | | * @param real_time_mode Аргумент real_time_mode, режим IN, тип varchar2. |
| | | * @param show_sql Аргумент show_sql, режим IN, тип varchar2. |
| | | * @param dim_list Аргумент dim_list, режим IN, тип varchar2. |
| | | * @param sqlid_list Аргумент sqlid_list, режим IN, тип varchar2. |
| | | * @param plsql_list Аргумент plsql_list, режим IN, тип varchar2. |
| | | * @param object_list Аргумент object_list, режим IN, тип varchar2. |
| | | * @param user_list Аргумент user_list, режим IN, тип varchar2. |
| | | * @return `text`. |
| | | */ |
| | | Datum dbms_ash_getadditionalinfo(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief функция dbms_ash_getawrinfo. |
| | | * @details Это заглушка совместимости: SQL-объявление сохранено, но реализация пока не |
| | | * предоставлена. |
| | | * Контракт и типы берутся из inventory/spec, чтобы HPP оставался синхронизированным с |
| | | * SQL-поверхностью. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_getawrinfo(:p_dbid, :p_begin_time_utc, :p_end_time_utc, |
| | | * :p_inst_num, :show_sql) FROM dual; |
| | | * DECLARE v text; BEGIN v := DBMS_ASH.dbms_ash_getawrinfo(42, 'demo_alias', 'demo_alias', |
| | | * 42, 'demo_alias'); END; |
| | | * SELECT DBMS_ASH.dbms_ash_getawrinfo(0, 'demo_value', 'demo_value', 0, 'demo_value') FROM |
| | | * dual; |
| | | * @param p_dbid Аргумент p_dbid, режим IN, тип number. |
| | | * @param p_begin_time_utc Аргумент p_begin_time_utc, режим IN, тип varchar2. |
| | | * @param p_end_time_utc Аргумент p_end_time_utc, режим IN, тип varchar2. |
| | | * @param p_inst_num Аргумент p_inst_num, режим IN, тип number. |
| | | * @param show_sql Аргумент show_sql, режим IN, тип varchar2. |
| | | * @return `text`. |
| | | */ |
| | | Datum dbms_ash_getawrinfo(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief функция dbms_ash_getcpuinfo. |
| | | * @details Это заглушка совместимости: SQL-объявление сохранено, но реализация пока не |
| | | * предоставлена. |
| | | * Контракт и типы берутся из inventory/spec, чтобы HPP оставался синхронизированным с |
| | | * SQL-поверхностью. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_getcpuinfo(:dbid, :observationtime, :instance_number, |
| | | * :ignore_cpu_history, :show_sql) FROM dual; |
| | | * DECLARE v text; BEGIN v := DBMS_ASH.dbms_ash_getcpuinfo(42, 'demo_alias', 42, |
| | | * 'demo_alias', 'demo_alias'); END; |
| | | * SELECT DBMS_ASH.dbms_ash_getcpuinfo(0, 'demo_value', 0, 'demo_value', 'demo_value') FROM |
| | | * dual; |
| | | * @param dbid Аргумент dbid, режим IN, тип number. |
| | | * @param observationtime Аргумент observationtime, режим IN, тип varchar2. |
| | | * @param instance_number Аргумент instance_number, режим IN, тип number. |
| | | * @param ignore_cpu_history Аргумент ignore_cpu_history, режим IN, тип varchar2. |
| | | * @param show_sql Аргумент show_sql, режим IN, тип varchar2. |
| | | * @return `text`. |
| | | */ |
| | | Datum dbms_ash_getcpuinfo(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief функция dbms_ash_getdata. |
| | | * @details Это заглушка совместимости: SQL-объявление сохранено, но реализация пока не |
| | | * предоставлена. |
| | | * Контракт и типы берутся из inventory/spec, чтобы HPP оставался синхронизированным с |
| | | * SQL-поверхностью. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_getdata(:data_type, :time_type, :filter_list, :args) FROM dual; |
| | | * DECLARE v text; BEGIN v := DBMS_ASH.dbms_ash_getdata('demo_alias', 'demo_alias', |
| | | * 'demo_alias', 'demo_alias'); END; |
| | | * SELECT DBMS_ASH.dbms_ash_getdata('demo_value', 'demo_value', 'demo_value', 'demo_value') |
| | | * FROM dual; |
| | | * @param data_type Аргумент data_type, режим IN, тип varchar2. |
| | | * @param time_type Аргумент time_type, режим IN, тип varchar2. |
| | | * @param filter_list Аргумент filter_list, режим IN, тип varchar2. |
| | | * @param args Аргумент args, режим IN, тип varchar2. |
| | | * @return `text`. |
| | | */ |
| | | Datum dbms_ash_getdata(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief функция dbms_ash_getdatahistorical. |
| | | * @details Это заглушка совместимости: SQL-объявление сохранено, но реализация пока не |
| | | * предоставлена. |
| | | * Контракт и типы берутся из inventory/spec, чтобы HPP оставался синхронизированным с |
| | | * SQL-поверхностью. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_getdatahistorical(:dbid, :filter_list, :begin_time_utc, |
| | | * :end_time_utc, :time_since_sec, :show_sql, :verbose_xml, :include_bg, :instance_number, |
| | | * :minimize_cost, :resolution, :monitoring_mode, :memory_only, :dimensions) FROM dual; |
| | | * DECLARE v text; BEGIN v := DBMS_ASH.dbms_ash_getdatahistorical(42, 'demo_alias', |
| | | * 'demo_alias', 'demo_alias', 42, 'demo_alias', 'demo_alias', 'demo_alias', 42, |
| | | * 'demo_alias', 'demo_alias', 'demo_alias', 'demo_alias', 'demo_alias'); END; |
| | | * SELECT DBMS_ASH.dbms_ash_getdatahistorical(0, 'demo_value', 'demo_value', 'demo_value', |
| | | * 0, 'demo_value', 'demo_value', 'demo_value', 0, 'demo_value', 'demo_value', |
| | | * 'demo_value', 'demo_value', 'demo_value') FROM dual; |
| | | * @param dbid Аргумент dbid, режим IN, тип number. |
| | | * @param filter_list Аргумент filter_list, режим IN, тип varchar2. |
| | | * @param begin_time_utc Аргумент begin_time_utc, режим IN, тип varchar2. |
| | | * @param end_time_utc Аргумент end_time_utc, режим IN, тип varchar2. |
| | | * @param time_since_sec Аргумент time_since_sec, режим IN, тип number. |
| | | * @param show_sql Аргумент show_sql, режим IN, тип varchar2. |
| | | * @param verbose_xml Аргумент verbose_xml, режим IN, тип varchar2. |
| | | * @param include_bg Аргумент include_bg, режим IN, тип varchar2. |
| | | * @param instance_number Аргумент instance_number, режим IN, тип number. |
| | | * @param minimize_cost Аргумент minimize_cost, режим IN, тип varchar2. |
| | | * @param resolution Аргумент resolution, режим IN, тип varchar2. |
| | | * @param monitoring_mode Аргумент monitoring_mode, режим IN, тип varchar2. |
| | | * @param memory_only Аргумент memory_only, режим IN, тип varchar2. |
| | | * @param dimensions Аргумент dimensions, режим IN, тип varchar2. |
| | | * @return `text`. |
| | | */ |
| | | Datum dbms_ash_getdatahistorical(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief функция dbms_ash_getdatarealtime. |
| | | * @details Это заглушка совместимости: SQL-объявление сохранено, но реализация пока не |
| | | * предоставлена. |
| | | * Контракт и типы берутся из inventory/spec, чтобы HPP оставался синхронизированным с |
| | | * SQL-поверхностью. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_getdatarealtime(:filter_list, :time_since_sec, :show_sql, |
| | | * :verbose_xml, :include_bg, :instance_number, :minimize_cost, :resolution, |
| | | * :monitoring_mode, :memory_only, :dimensions) FROM dual; |
| | | * DECLARE v text; BEGIN v := DBMS_ASH.dbms_ash_getdatarealtime('demo_alias', 42, |
| | | * 'demo_alias', 'demo_alias', 'demo_alias', 42, 'demo_alias', 'demo_alias', 'demo_alias', |
| | | * 'demo_alias', 'demo_alias'); END; |
| | | * SELECT DBMS_ASH.dbms_ash_getdatarealtime('demo_value', 0, 'demo_value', 'demo_value', |
| | | * 'demo_value', 0, 'demo_value', 'demo_value', 'demo_value', 'demo_value', 'demo_value') |
| | | * FROM dual; |
| | | * @param filter_list Аргумент filter_list, режим IN, тип varchar2. |
| | | * @param time_since_sec Аргумент time_since_sec, режим IN, тип number. |
| | | * @param show_sql Аргумент show_sql, режим IN, тип varchar2. |
| | | * @param verbose_xml Аргумент verbose_xml, режим IN, тип varchar2. |
| | | * @param include_bg Аргумент include_bg, режим IN, тип varchar2. |
| | | * @param instance_number Аргумент instance_number, режим IN, тип number. |
| | | * @param minimize_cost Аргумент minimize_cost, режим IN, тип varchar2. |
| | | * @param resolution Аргумент resolution, режим IN, тип varchar2. |
| | | * @param monitoring_mode Аргумент monitoring_mode, режим IN, тип varchar2. |
| | | * @param memory_only Аргумент memory_only, режим IN, тип varchar2. |
| | | * @param dimensions Аргумент dimensions, режим IN, тип varchar2. |
| | | * @return `text`. |
| | | */ |
| | | Datum dbms_ash_getdatarealtime(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief функция dbms_ash_gethistogramhistorical. |
| | | * @details Это заглушка совместимости: SQL-объявление сохранено, но реализация пока не |
| | | * предоставлена. |
| | | * Контракт и типы берутся из inventory/spec, чтобы HPP оставался синхронизированным с |
| | | * SQL-поверхностью. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_gethistogramhistorical(:dbid, :filter_list, :begin_time_utc, |
| | | * :end_time_utc, :time_since_sec, :show_sql, :verbose_xml, :include_bg, :instance_number, |
| | | * :ignore_cpu_history, :resolution, :memory_only) FROM dual; |
| | | * DECLARE v text; BEGIN v := DBMS_ASH.dbms_ash_gethistogramhistorical(42, 'demo_alias', |
| | | * 'demo_alias', 'demo_alias', 42, 'demo_alias', 'demo_alias', 'demo_alias', 42, |
| | | * 'demo_alias', 'demo_alias', 'demo_alias'); END; |
| | | * SELECT DBMS_ASH.dbms_ash_gethistogramhistorical(0, 'demo_value', 'demo_value', |
| | | * 'demo_value', 0, 'demo_value', 'demo_value', 'demo_value', 0, 'demo_value', |
| | | * 'demo_value', 'demo_value') FROM dual; |
| | | * @param dbid Аргумент dbid, режим IN, тип number. |
| | | * @param filter_list Аргумент filter_list, режим IN, тип varchar2. |
| | | * @param begin_time_utc Аргумент begin_time_utc, режим IN, тип varchar2. |
| | | * @param end_time_utc Аргумент end_time_utc, режим IN, тип varchar2. |
| | | * @param time_since_sec Аргумент time_since_sec, режим IN, тип number. |
| | | * @param show_sql Аргумент show_sql, режим IN, тип varchar2. |
| | | * @param verbose_xml Аргумент verbose_xml, режим IN, тип varchar2. |
| | | * @param include_bg Аргумент include_bg, режим IN, тип varchar2. |
| | | * @param instance_number Аргумент instance_number, режим IN, тип number. |
| | | * @param ignore_cpu_history Аргумент ignore_cpu_history, режим IN, тип varchar2. |
| | | * @param resolution Аргумент resolution, режим IN, тип varchar2. |
| | | * @param memory_only Аргумент memory_only, режим IN, тип varchar2. |
| | | * @return `text`. |
| | | */ |
| | | Datum dbms_ash_gethistogramhistorical(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief функция dbms_ash_gethistogramrealtime. |
| | | * @details Это заглушка совместимости: SQL-объявление сохранено, но реализация пока не |
| | | * предоставлена. |
| | | * Контракт и типы берутся из inventory/spec, чтобы HPP оставался синхронизированным с |
| | | * SQL-поверхностью. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_gethistogramrealtime(:filter_list, :time_since_sec, :show_sql, |
| | | * :verbose_xml, :include_bg, :instance_number, :ignore_cpu_history, :resolution, |
| | | * :memory_only) FROM dual; |
| | | * DECLARE v text; BEGIN v := DBMS_ASH.dbms_ash_gethistogramrealtime('demo_alias', 42, |
| | | * 'demo_alias', 'demo_alias', 'demo_alias', 42, 'demo_alias', 'demo_alias', 'demo_alias'); |
| | | * END; |
| | | * SELECT DBMS_ASH.dbms_ash_gethistogramrealtime('demo_value', 0, 'demo_value', |
| | | * 'demo_value', 'demo_value', 0, 'demo_value', 'demo_value', 'demo_value') FROM dual; |
| | | * @param filter_list Аргумент filter_list, режим IN, тип varchar2. |
| | | * @param time_since_sec Аргумент time_since_sec, режим IN, тип number. |
| | | * @param show_sql Аргумент show_sql, режим IN, тип varchar2. |
| | | * @param verbose_xml Аргумент verbose_xml, режим IN, тип varchar2. |
| | | * @param include_bg Аргумент include_bg, режим IN, тип varchar2. |
| | | * @param instance_number Аргумент instance_number, режим IN, тип number. |
| | | * @param ignore_cpu_history Аргумент ignore_cpu_history, режим IN, тип varchar2. |
| | | * @param resolution Аргумент resolution, режим IN, тип varchar2. |
| | | * @param memory_only Аргумент memory_only, режим IN, тип varchar2. |
| | | * @return `text`. |
| | | */ |
| | | Datum dbms_ash_gethistogramrealtime(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief функция dbms_ash_getsqltext. |
| | | * @details Это заглушка совместимости: SQL-объявление сохранено, но реализация пока не |
| | | * предоставлена. |
| | | * Контракт и типы берутся из inventory/spec, чтобы HPP оставался синхронизированным с |
| | | * SQL-поверхностью. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_getsqltext(:p_dbid, :p_sql_ids) FROM dual; |
| | | * DECLARE v text; BEGIN v := DBMS_ASH.dbms_ash_getsqltext(42, 'demo_alias'); END; |
| | | * SELECT DBMS_ASH.dbms_ash_getsqltext(0, 'demo_value') FROM dual; |
| | | * @param p_dbid Аргумент p_dbid, режим IN, тип number. |
| | | * @param p_sql_ids Аргумент p_sql_ids, режим IN, тип varchar2. |
| | | * @return `text`. |
| | | */ |
| | | Datum dbms_ash_getsqltext(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief функция dbms_ash_gettimeformat. |
| | | * @details Это заглушка совместимости: SQL-объявление сохранено, но реализация пока не |
| | | * предоставлена. |
| | | * Контракт и типы берутся из inventory/spec, чтобы HPP оставался синхронизированным с |
| | | * SQL-поверхностью. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_gettimeformat() FROM dual; |
| | | * DECLARE v varchar2; BEGIN v := DBMS_ASH.dbms_ash_gettimeformat(); END; |
| | | * @return `varchar2`. |
| | | */ |
| | | Datum dbms_ash_gettimeformat(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief функция dbms_ash_gettimepickerhistorical. |
| | | * @details Это заглушка совместимости: SQL-объявление сохранено, но реализация пока не |
| | | * предоставлена. |
| | | * Контракт и типы берутся из inventory/spec, чтобы HPP оставался синхронизированным с |
| | | * SQL-поверхностью. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_gettimepickerhistorical(:dbid, :begin_time_utc, :end_time_utc, |
| | | * :time_since_sec, :show_sql, :verbose_xml, :instance_number, :awr_info, |
| | | * :ignore_cpu_history, :resolution, :include_bg, :memory_only) FROM dual; |
| | | * DECLARE v text; BEGIN v := DBMS_ASH.dbms_ash_gettimepickerhistorical(42, 'demo_alias', |
| | | * 'demo_alias', 42, 'demo_alias', 'demo_alias', 42, 'demo_alias', 'demo_alias', |
| | | * 'demo_alias', 'demo_alias', 'demo_alias'); END; |
| | | * SELECT DBMS_ASH.dbms_ash_gettimepickerhistorical(0, 'demo_value', 'demo_value', 0, |
| | | * 'demo_value', 'demo_value', 0, 'demo_value', 'demo_value', 'demo_value', 'demo_value', |
| | | * 'demo_value') FROM dual; |
| | | * @param dbid Аргумент dbid, режим IN, тип number. |
| | | * @param begin_time_utc Аргумент begin_time_utc, режим IN, тип varchar2. |
| | | * @param end_time_utc Аргумент end_time_utc, режим IN, тип varchar2. |
| | | * @param time_since_sec Аргумент time_since_sec, режим IN, тип number. |
| | | * @param show_sql Аргумент show_sql, режим IN, тип varchar2. |
| | | * @param verbose_xml Аргумент verbose_xml, режим IN, тип varchar2. |
| | | * @param instance_number Аргумент instance_number, режим IN, тип number. |
| | | * @param awr_info Аргумент awr_info, режим IN, тип varchar2. |
| | | * @param ignore_cpu_history Аргумент ignore_cpu_history, режим IN, тип varchar2. |
| | | * @param resolution Аргумент resolution, режим IN, тип varchar2. |
| | | * @param include_bg Аргумент include_bg, режим IN, тип varchar2. |
| | | * @param memory_only Аргумент memory_only, режим IN, тип varchar2. |
| | | * @return `text`. |
| | | */ |
| | | Datum dbms_ash_gettimepickerhistorical(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief функция dbms_ash_gettimepickerrealtime. |
| | | * @details Это заглушка совместимости: SQL-объявление сохранено, но реализация пока не |
| | | * предоставлена. |
| | | * Контракт и типы берутся из inventory/spec, чтобы HPP оставался синхронизированным с |
| | | * SQL-поверхностью. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_gettimepickerrealtime(:time_since_sec, :show_sql, :verbose_xml, |
| | | * :instance_number, :awr_info, :ignore_cpu_history, :resolution, :include_bg, |
| | | * :memory_only) FROM dual; |
| | | * DECLARE v text; BEGIN v := DBMS_ASH.dbms_ash_gettimepickerrealtime(42, 'demo_alias', |
| | | * 'demo_alias', 42, 'demo_alias', 'demo_alias', 'demo_alias', 'demo_alias', 'demo_alias'); |
| | | * END; |
| | | * SELECT DBMS_ASH.dbms_ash_gettimepickerrealtime(0, 'demo_value', 'demo_value', 0, |
| | | * 'demo_value', 'demo_value', 'demo_value', 'demo_value', 'demo_value') FROM dual; |
| | | * @param time_since_sec Аргумент time_since_sec, режим IN, тип number. |
| | | * @param show_sql Аргумент show_sql, режим IN, тип varchar2. |
| | | * @param verbose_xml Аргумент verbose_xml, режим IN, тип varchar2. |
| | | * @param instance_number Аргумент instance_number, режим IN, тип number. |
| | | * @param awr_info Аргумент awr_info, режим IN, тип varchar2. |
| | | * @param ignore_cpu_history Аргумент ignore_cpu_history, режим IN, тип varchar2. |
| | | * @param resolution Аргумент resolution, режим IN, тип varchar2. |
| | | * @param include_bg Аргумент include_bg, режим IN, тип varchar2. |
| | | * @param memory_only Аргумент memory_only, режим IN, тип varchar2. |
| | | * @return `text`. |
| | | */ |
| | | Datum dbms_ash_gettimepickerrealtime(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief функция dbms_ash_getversion. |
| | | * @details Это заглушка совместимости: SQL-объявление сохранено, но реализация пока не |
| | | * предоставлена. |
| | | * Контракт и типы берутся из inventory/spec, чтобы HPP оставался синхронизированным с |
| | | * SQL-поверхностью. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_getversion() FROM dual; |
| | | * DECLARE v varchar2; BEGIN v := DBMS_ASH.dbms_ash_getversion(); END; |
| | | * @return `varchar2`. |
| | | */ |
| | | Datum dbms_ash_getversion(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief функция dbms_ash_get_blocking_session_data. |
| | | * @details Это заглушка совместимости: SQL-объявление сохранено, но реализация пока не |
| | | * предоставлена. |
| | | * Контракт и типы берутся из inventory/spec, чтобы HPP оставался синхронизированным с |
| | | * SQL-поверхностью. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_get_blocking_session_data(:data_type, :source_type, |
| | | * :filter_list, :begin_time_utc, :end_time_utc, :time_since_sec, :show_sql, |
| | | * :filter_common_user) FROM dual; |
| | | * DECLARE v text; BEGIN v := DBMS_ASH.dbms_ash_get_blocking_session_data('demo_alias', |
| | | * 'demo_alias', 'demo_alias', 'demo_alias', 'demo_alias', 42, 'demo_alias', 'demo_alias'); |
| | | * END; |
| | | * SELECT DBMS_ASH.dbms_ash_get_blocking_session_data('demo_value', 'demo_value', |
| | | * 'demo_value', 'demo_value', 'demo_value', 0, 'demo_value', 'demo_value') FROM dual; |
| | | * @param data_type Аргумент data_type, режим IN, тип varchar2. |
| | | * @param source_type Аргумент source_type, режим IN, тип varchar2. |
| | | * @param filter_list Аргумент filter_list, режим IN, тип varchar2. |
| | | * @param begin_time_utc Аргумент begin_time_utc, режим IN, тип varchar2. |
| | | * @param end_time_utc Аргумент end_time_utc, режим IN, тип varchar2. |
| | | * @param time_since_sec Аргумент time_since_sec, режим IN, тип number. |
| | | * @param show_sql Аргумент show_sql, режим IN, тип varchar2. |
| | | * @param filter_common_user Аргумент filter_common_user, режим IN, тип varchar2. |
| | | * @return `text`. |
| | | */ |
| | | Datum dbms_ash_get_blocking_session_data(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief функция dbms_ash_incrementdata. |
| | | * @details Это заглушка совместимости: SQL-объявление сохранено, но реализация пока не |
| | | * предоставлена. |
| | | * Контракт и типы берутся из inventory/spec, чтобы HPP оставался синхронизированным с |
| | | * SQL-поверхностью. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_incrementdata(:filter_list, :begin_time_utc, :bucket_size, |
| | | * :show_sql, :verbose_xml, :include_bg, :instance_number, :minimize_cost, :resolution, |
| | | * :monitoring_mode, :memory_only, :dimensions) FROM dual; |
| | | * DECLARE v text; BEGIN v := DBMS_ASH.dbms_ash_incrementdata('demo_alias', 'demo_alias', |
| | | * 42, 'demo_alias', 'demo_alias', 'demo_alias', 42, 'demo_alias', 'demo_alias', |
| | | * 'demo_alias', 'demo_alias', 'demo_alias'); END; |
| | | * SELECT DBMS_ASH.dbms_ash_incrementdata('demo_value', 'demo_value', 0, 'demo_value', |
| | | * 'demo_value', 'demo_value', 0, 'demo_value', 'demo_value', 'demo_value', 'demo_value', |
| | | * 'demo_value') FROM dual; |
| | | * @param filter_list Аргумент filter_list, режим IN, тип varchar2. |
| | | * @param begin_time_utc Аргумент begin_time_utc, режим IN, тип varchar2. |
| | | * @param bucket_size Аргумент bucket_size, режим IN, тип number. |
| | | * @param show_sql Аргумент show_sql, режим IN, тип varchar2. |
| | | * @param verbose_xml Аргумент verbose_xml, режим IN, тип varchar2. |
| | | * @param include_bg Аргумент include_bg, режим IN, тип varchar2. |
| | | * @param instance_number Аргумент instance_number, режим IN, тип number. |
| | | * @param minimize_cost Аргумент minimize_cost, режим IN, тип varchar2. |
| | | * @param resolution Аргумент resolution, режим IN, тип varchar2. |
| | | * @param monitoring_mode Аргумент monitoring_mode, режим IN, тип varchar2. |
| | | * @param memory_only Аргумент memory_only, режим IN, тип varchar2. |
| | | * @param dimensions Аргумент dimensions, режим IN, тип varchar2. |
| | | * @return `text`. |
| | | */ |
| | | Datum dbms_ash_incrementdata(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief функция dbms_ash_incrementhistogram. |
| | | * @details Это заглушка совместимости: SQL-объявление сохранено, но реализация пока не |
| | | * предоставлена. |
| | | * Контракт и типы берутся из inventory/spec, чтобы HPP оставался синхронизированным с |
| | | * SQL-поверхностью. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_incrementhistogram(:filter_list, :begin_time_utc, :bucket_size, |
| | | * :show_sql, :verbose_xml, :include_bg, :instance_number, :resolution, :memory_only) FROM |
| | | * dual; |
| | | * DECLARE v text; BEGIN v := DBMS_ASH.dbms_ash_incrementhistogram('demo_alias', |
| | | * 'demo_alias', 42, 'demo_alias', 'demo_alias', 'demo_alias', 42, 'demo_alias', |
| | | * 'demo_alias'); END; |
| | | * SELECT DBMS_ASH.dbms_ash_incrementhistogram('demo_value', 'demo_value', 0, 'demo_value', |
| | | * 'demo_value', 'demo_value', 0, 'demo_value', 'demo_value') FROM dual; |
| | | * @param filter_list Аргумент filter_list, режим IN, тип varchar2. |
| | | * @param begin_time_utc Аргумент begin_time_utc, режим IN, тип varchar2. |
| | | * @param bucket_size Аргумент bucket_size, режим IN, тип number. |
| | | * @param show_sql Аргумент show_sql, режим IN, тип varchar2. |
| | | * @param verbose_xml Аргумент verbose_xml, режим IN, тип varchar2. |
| | | * @param include_bg Аргумент include_bg, режим IN, тип varchar2. |
| | | * @param instance_number Аргумент instance_number, режим IN, тип number. |
| | | * @param resolution Аргумент resolution, режим IN, тип varchar2. |
| | | * @param memory_only Аргумент memory_only, режим IN, тип varchar2. |
| | | * @return `text`. |
| | | */ |
| | | Datum dbms_ash_incrementhistogram(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief функция dbms_ash_incrementtimepicker. |
| | | * @details Это заглушка совместимости: SQL-объявление сохранено, но реализация пока не |
| | | * предоставлена. |
| | | * Контракт и типы берутся из inventory/spec, чтобы HPP оставался синхронизированным с |
| | | * SQL-поверхностью. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_incrementtimepicker(:begin_time_utc, :bucket_size, :show_sql, |
| | | * :verbose_xml, :instance_number, :awr_info, :resolution, :include_bg, :memory_only) FROM |
| | | * dual; |
| | | * DECLARE v text; BEGIN v := DBMS_ASH.dbms_ash_incrementtimepicker('demo_alias', 42, |
| | | * 'demo_alias', 'demo_alias', 42, 'demo_alias', 'demo_alias', 'demo_alias', 'demo_alias'); |
| | | * END; |
| | | * SELECT DBMS_ASH.dbms_ash_incrementtimepicker('demo_value', 0, 'demo_value', |
| | | * 'demo_value', 0, 'demo_value', 'demo_value', 'demo_value', 'demo_value') FROM dual; |
| | | * @param begin_time_utc Аргумент begin_time_utc, режим IN, тип varchar2. |
| | | * @param bucket_size Аргумент bucket_size, режим IN, тип number. |
| | | * @param show_sql Аргумент show_sql, режим IN, тип varchar2. |
| | | * @param verbose_xml Аргумент verbose_xml, режим IN, тип varchar2. |
| | | * @param instance_number Аргумент instance_number, режим IN, тип number. |
| | | * @param awr_info Аргумент awr_info, режим IN, тип varchar2. |
| | | * @param resolution Аргумент resolution, режим IN, тип varchar2. |
| | | * @param include_bg Аргумент include_bg, режим IN, тип varchar2. |
| | | * @param memory_only Аргумент memory_only, режим IN, тип varchar2. |
| | | * @return `text`. |
| | | */ |
| | | Datum dbms_ash_incrementtimepicker(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief функция dbms_ash_str_to_ascii. |
| | | * @details Это заглушка совместимости: SQL-объявление сохранено, но реализация пока не |
| | | * предоставлена. |
| | | * Контракт и типы берутся из inventory/spec, чтобы HPP оставался синхронизированным с |
| | | * SQL-поверхностью. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_str_to_ascii(:s) FROM dual; |
| | | * DECLARE v varchar2; BEGIN v := DBMS_ASH.dbms_ash_str_to_ascii('demo_alias'); END; |
| | | * SELECT DBMS_ASH.dbms_ash_str_to_ascii('demo_value') FROM dual; |
| | | * @param s Аргумент s, режим IN, тип varchar2. |
| | | * @return `varchar2`. |
| | | */ |
| | | Datum dbms_ash_str_to_ascii(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief Возвращает версию RUDB пакета DBMS_ASH. |
| | | * @details Version: 1.0.0. |
| | | * Это синтетическая zero-arg SQL function, которую генератор добавляет в каждый новый |
| | | * пакет. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_get_version() FROM dual; |
| | | * DECLARE v text; BEGIN v := DBMS_ASH.dbms_ash_get_version(); END; |
| | | * @return `text`. |
| | | */ |
| | | Datum dbms_ash_get_version(PG_FUNCTION_ARGS); |
| | | /** |
| | | * @brief Generated mock stub для DBMS_ASH.MOCK. |
| | | * @details Это сгенерированная package mock stub для нового пакета. |
| | | * Функция добавляется генератором как checkpoint и должна быть реализована вручную. |
| | | * Примеры: |
| | | * SELECT DBMS_ASH.dbms_ash_mock() FROM dual; |
| | | * DECLARE v text; BEGIN v := DBMS_ASH.dbms_ash_mock(); END; |
| | | * @return `text`. |
| | | */ |
| | | Datum dbms_ash_mock(PG_FUNCTION_ARGS); |
| | | } // extern "C" |
| | | |
| | | #endif // DBMS_ASH_INTERNAL_HPP |
| New file |
| | |
| | | #include "dbms_db_version.hpp" |
| | | |
| | | namespace |
| | | { |
| | | constexpr int32 kDbmsDbVersionVersion = 23; |
| | | constexpr int32 kDbmsDbVersionRelease = 0; |
| | | constexpr char kDbmsDbVersionPackageVersion[] = "1.0.0"; |
| | | |
| | | bool |
| | | dbms_db_version_ver_le_value(const int32 version, const int32 release) |
| | | { |
| | | if (kDbmsDbVersionVersion < version) |
| | | return true; |
| | | if (kDbmsDbVersionVersion > version) |
| | | return false; |
| | | return kDbmsDbVersionRelease <= release; |
| | | } |
| | | } // namespace |
| | | |
| | | extern "C" |
| | | { |
| | | PG_FUNCTION_INFO_V1(dbms_db_version_version); |
| | | PG_FUNCTION_INFO_V1(dbms_db_version_release); |
| | | PG_FUNCTION_INFO_V1(dbms_db_version_get_version); |
| | | PG_FUNCTION_INFO_V1(dbms_db_version_ver_le); |
| | | PG_FUNCTION_INFO_V1(dbms_db_version_ver_le_9_1); |
| | | PG_FUNCTION_INFO_V1(dbms_db_version_ver_le_9_2); |
| | | PG_FUNCTION_INFO_V1(dbms_db_version_ver_le_9); |
| | | PG_FUNCTION_INFO_V1(dbms_db_version_ver_le_10_1); |
| | | PG_FUNCTION_INFO_V1(dbms_db_version_ver_le_10_2); |
| | | PG_FUNCTION_INFO_V1(dbms_db_version_ver_le_10); |
| | | PG_FUNCTION_INFO_V1(dbms_db_version_ver_le_11_1); |
| | | PG_FUNCTION_INFO_V1(dbms_db_version_ver_le_11_2); |
| | | PG_FUNCTION_INFO_V1(dbms_db_version_ver_le_11); |
| | | PG_FUNCTION_INFO_V1(dbms_db_version_ver_le_12_1); |
| | | PG_FUNCTION_INFO_V1(dbms_db_version_ver_le_12_2); |
| | | PG_FUNCTION_INFO_V1(dbms_db_version_ver_le_12); |
| | | PG_FUNCTION_INFO_V1(dbms_db_version_ver_le_18); |
| | | PG_FUNCTION_INFO_V1(dbms_db_version_ver_le_19); |
| | | PG_FUNCTION_INFO_V1(dbms_db_version_ver_le_20); |
| | | PG_FUNCTION_INFO_V1(dbms_db_version_ver_le_21); |
| | | PG_FUNCTION_INFO_V1(dbms_db_version_ver_le_23); |
| | | |
| | | /* |
| | | * @qdb_func: dbms_db_version_version() |
| | | */ |
| | | Datum dbms_db_version_version(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_INT32(kDbmsDbVersionVersion); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_db_version_release() |
| | | */ |
| | | Datum dbms_db_version_release(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_INT32(kDbmsDbVersionRelease); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_db_version_get_version() |
| | | */ |
| | | Datum dbms_db_version_get_version(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_TEXT_P(cstring_to_text(kDbmsDbVersionPackageVersion)); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_db_version_ver_le(int4, int4) |
| | | */ |
| | | Datum dbms_db_version_ver_le(PG_FUNCTION_ARGS) |
| | | { |
| | | if (PG_ARGISNULL(0) || PG_ARGISNULL(1)) |
| | | PG_RETURN_BOOL(false); |
| | | |
| | | const int32 version = PG_GETARG_INT32(0); |
| | | const int32 release = PG_GETARG_INT32(1); |
| | | |
| | | PG_RETURN_BOOL(dbms_db_version_ver_le_value(version, release)); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_db_version_ver_le_9_1() |
| | | */ |
| | | Datum dbms_db_version_ver_le_9_1(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_BOOL(DatumGetBool( |
| | | DirectFunctionCall2(dbms_db_version_ver_le, |
| | | Int32GetDatum(9), |
| | | Int32GetDatum(1)))); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_db_version_ver_le_9_2() |
| | | */ |
| | | Datum dbms_db_version_ver_le_9_2(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_BOOL(DatumGetBool( |
| | | DirectFunctionCall2(dbms_db_version_ver_le, |
| | | Int32GetDatum(9), |
| | | Int32GetDatum(2)))); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_db_version_ver_le_9() |
| | | */ |
| | | Datum dbms_db_version_ver_le_9(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_BOOL(DatumGetBool( |
| | | DirectFunctionCall2(dbms_db_version_ver_le, |
| | | Int32GetDatum(9), |
| | | Int32GetDatum(0)))); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_db_version_ver_le_10_1() |
| | | */ |
| | | Datum dbms_db_version_ver_le_10_1(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_BOOL(DatumGetBool( |
| | | DirectFunctionCall2(dbms_db_version_ver_le, |
| | | Int32GetDatum(10), |
| | | Int32GetDatum(1)))); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_db_version_ver_le_10_2() |
| | | */ |
| | | Datum dbms_db_version_ver_le_10_2(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_BOOL(DatumGetBool( |
| | | DirectFunctionCall2(dbms_db_version_ver_le, |
| | | Int32GetDatum(10), |
| | | Int32GetDatum(2)))); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_db_version_ver_le_10() |
| | | */ |
| | | Datum dbms_db_version_ver_le_10(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_BOOL(DatumGetBool( |
| | | DirectFunctionCall2(dbms_db_version_ver_le, |
| | | Int32GetDatum(10), |
| | | Int32GetDatum(0)))); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_db_version_ver_le_11_1() |
| | | */ |
| | | Datum dbms_db_version_ver_le_11_1(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_BOOL(DatumGetBool( |
| | | DirectFunctionCall2(dbms_db_version_ver_le, |
| | | Int32GetDatum(11), |
| | | Int32GetDatum(1)))); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_db_version_ver_le_11_2() |
| | | */ |
| | | Datum dbms_db_version_ver_le_11_2(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_BOOL(DatumGetBool( |
| | | DirectFunctionCall2(dbms_db_version_ver_le, |
| | | Int32GetDatum(11), |
| | | Int32GetDatum(2)))); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_db_version_ver_le_11() |
| | | */ |
| | | Datum dbms_db_version_ver_le_11(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_BOOL(DatumGetBool( |
| | | DirectFunctionCall2(dbms_db_version_ver_le, |
| | | Int32GetDatum(11), |
| | | Int32GetDatum(0)))); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_db_version_ver_le_12_1() |
| | | */ |
| | | Datum dbms_db_version_ver_le_12_1(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_BOOL(DatumGetBool( |
| | | DirectFunctionCall2(dbms_db_version_ver_le, |
| | | Int32GetDatum(12), |
| | | Int32GetDatum(1)))); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_db_version_ver_le_12_2() |
| | | */ |
| | | Datum dbms_db_version_ver_le_12_2(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_BOOL(DatumGetBool( |
| | | DirectFunctionCall2(dbms_db_version_ver_le, |
| | | Int32GetDatum(12), |
| | | Int32GetDatum(2)))); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_db_version_ver_le_12() |
| | | */ |
| | | Datum dbms_db_version_ver_le_12(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_BOOL(DatumGetBool( |
| | | DirectFunctionCall2(dbms_db_version_ver_le, |
| | | Int32GetDatum(12), |
| | | Int32GetDatum(0)))); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_db_version_ver_le_18() |
| | | */ |
| | | Datum dbms_db_version_ver_le_18(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_BOOL(DatumGetBool( |
| | | DirectFunctionCall2(dbms_db_version_ver_le, |
| | | Int32GetDatum(18), |
| | | Int32GetDatum(0)))); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_db_version_ver_le_19() |
| | | */ |
| | | Datum dbms_db_version_ver_le_19(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_BOOL(DatumGetBool( |
| | | DirectFunctionCall2(dbms_db_version_ver_le, |
| | | Int32GetDatum(19), |
| | | Int32GetDatum(0)))); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_db_version_ver_le_20() |
| | | */ |
| | | Datum dbms_db_version_ver_le_20(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_BOOL(DatumGetBool( |
| | | DirectFunctionCall2(dbms_db_version_ver_le, |
| | | Int32GetDatum(20), |
| | | Int32GetDatum(0)))); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_db_version_ver_le_21() |
| | | */ |
| | | Datum dbms_db_version_ver_le_21(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_BOOL(DatumGetBool( |
| | | DirectFunctionCall2(dbms_db_version_ver_le, |
| | | Int32GetDatum(21), |
| | | Int32GetDatum(0)))); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_db_version_ver_le_23() |
| | | */ |
| | | Datum dbms_db_version_ver_le_23(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_BOOL(DatumGetBool( |
| | | DirectFunctionCall2(dbms_db_version_ver_le, |
| | | Int32GetDatum(23), |
| | | Int32GetDatum(0)))); |
| | | } |
| | | } // extern "C" |
| New file |
| | |
| | | #ifndef DBMS_DB_VERSION_INTERNAL_HPP |
| | | #define DBMS_DB_VERSION_INTERNAL_HPP |
| | | |
| | | /* |
| | | * DBMS_DB_VERSION |
| | | * |
| | | * Назначение: |
| | | * Пакет возвращает номер версии, release и compatibility flags RUDB через |
| | | * callable helpers. |
| | | */ |
| | | |
| | | extern "C" |
| | | { |
| | | #include "postgres.h" |
| | | #include "fmgr.h" |
| | | #include "utils/builtins.h" |
| | | } // extern "C" |
| | | |
| | | extern "C" |
| | | { |
| | | /// @brief Возвращает номер VERSION пакета DBMS_DB_VERSION. |
| | | Datum dbms_db_version_version(PG_FUNCTION_ARGS); |
| | | |
| | | /// @brief Возвращает номер RELEASE пакета DBMS_DB_VERSION. |
| | | Datum dbms_db_version_release(PG_FUNCTION_ARGS); |
| | | |
| | | /** |
| | | * @brief Возвращает версию пакета DBMS_DB_VERSION. |
| | | * @details Возвращает строку версии реализации RUDB для SQL-visible API пакета. |
| | | * Примеры: |
| | | * SELECT DBMS_DB_VERSION.GET_VERSION() FROM dual; |
| | | * SELECT dbms_db_version_get_version(); |
| | | * @return Текст версии пакета. |
| | | */ |
| | | Datum dbms_db_version_get_version(PG_FUNCTION_ARGS); |
| | | |
| | | /** |
| | | * @brief Проверяет, что compatibility version DBMS_DB_VERSION меньше или равна указанной версии. |
| | | * @details Сравнивает compatibility constants пакета `VERSION` и `RELEASE` |
| | | * с переданными значениями. |
| | | * Примеры: |
| | | * SELECT dbms_db_version_ver_le(23, 0); |
| | | * SELECT dbms_db_version_ver_le(21, 0); |
| | | * SELECT dbms_db_version_ver_le(23, 1); |
| | | * @param version Проверяемое значение VERSION. |
| | | * @param release Проверяемое значение RELEASE. |
| | | * @return `true`, если compatibility version пакета не выше указанной. |
| | | */ |
| | | Datum dbms_db_version_ver_le(PG_FUNCTION_ARGS); |
| | | |
| | | /// @brief Возвращает флаг DBMS_DB_VERSION.VER_LE_9_1. |
| | | Datum dbms_db_version_ver_le_9_1(PG_FUNCTION_ARGS); |
| | | |
| | | /// @brief Возвращает флаг DBMS_DB_VERSION.VER_LE_9_2. |
| | | Datum dbms_db_version_ver_le_9_2(PG_FUNCTION_ARGS); |
| | | |
| | | /// @brief Возвращает флаг DBMS_DB_VERSION.VER_LE_9. |
| | | Datum dbms_db_version_ver_le_9(PG_FUNCTION_ARGS); |
| | | |
| | | /// @brief Возвращает флаг DBMS_DB_VERSION.VER_LE_10_1. |
| | | Datum dbms_db_version_ver_le_10_1(PG_FUNCTION_ARGS); |
| | | |
| | | /// @brief Возвращает флаг DBMS_DB_VERSION.VER_LE_10_2. |
| | | Datum dbms_db_version_ver_le_10_2(PG_FUNCTION_ARGS); |
| | | |
| | | /// @brief Возвращает флаг DBMS_DB_VERSION.VER_LE_10. |
| | | Datum dbms_db_version_ver_le_10(PG_FUNCTION_ARGS); |
| | | |
| | | /// @brief Возвращает флаг DBMS_DB_VERSION.VER_LE_11_1. |
| | | Datum dbms_db_version_ver_le_11_1(PG_FUNCTION_ARGS); |
| | | |
| | | /// @brief Возвращает флаг DBMS_DB_VERSION.VER_LE_11_2. |
| | | Datum dbms_db_version_ver_le_11_2(PG_FUNCTION_ARGS); |
| | | |
| | | /// @brief Возвращает флаг DBMS_DB_VERSION.VER_LE_11. |
| | | Datum dbms_db_version_ver_le_11(PG_FUNCTION_ARGS); |
| | | |
| | | /// @brief Возвращает флаг DBMS_DB_VERSION.VER_LE_12_1. |
| | | Datum dbms_db_version_ver_le_12_1(PG_FUNCTION_ARGS); |
| | | |
| | | /// @brief Возвращает флаг DBMS_DB_VERSION.VER_LE_12_2. |
| | | Datum dbms_db_version_ver_le_12_2(PG_FUNCTION_ARGS); |
| | | |
| | | /// @brief Возвращает флаг DBMS_DB_VERSION.VER_LE_12. |
| | | Datum dbms_db_version_ver_le_12(PG_FUNCTION_ARGS); |
| | | |
| | | /// @brief Возвращает флаг DBMS_DB_VERSION.VER_LE_18. |
| | | Datum dbms_db_version_ver_le_18(PG_FUNCTION_ARGS); |
| | | |
| | | /// @brief Возвращает флаг DBMS_DB_VERSION.VER_LE_19. |
| | | Datum dbms_db_version_ver_le_19(PG_FUNCTION_ARGS); |
| | | |
| | | /// @brief Возвращает флаг DBMS_DB_VERSION.VER_LE_20. |
| | | Datum dbms_db_version_ver_le_20(PG_FUNCTION_ARGS); |
| | | |
| | | /// @brief Возвращает флаг DBMS_DB_VERSION.VER_LE_21. |
| | | Datum dbms_db_version_ver_le_21(PG_FUNCTION_ARGS); |
| | | |
| | | /// @brief Возвращает флаг DBMS_DB_VERSION.VER_LE_23. |
| | | Datum dbms_db_version_ver_le_23(PG_FUNCTION_ARGS); |
| | | } // extern "C" |
| | | |
| | | #endif // DBMS_DB_VERSION_INTERNAL_HPP |
| New file |
| | |
| | | #include "dbms_ddl.hpp" |
| | | |
| | | #include <algorithm> |
| | | #include <cctype> |
| | | #include <iomanip> |
| | | #include <optional> |
| | | #include <string> |
| | | #include <sstream> |
| | | |
| | | #include "utils/coder.h" |
| | | |
| | | extern "C" |
| | | { |
| | | #include "utils/builtins.h" |
| | | #include "utils/elog.h" |
| | | #include "common/base64.h" |
| | | #include "port/pg_crc32c.h" |
| | | #include "parser/scanner.h" |
| | | #include "parser/gram.h" |
| | | #include "common/keywords.h" |
| | | } |
| | | |
| | | enum class miniparser_state { |
| | | start, |
| | | create, |
| | | or_, |
| | | replace, |
| | | procedure, |
| | | procedure_ident, |
| | | args, |
| | | args_end, |
| | | language, |
| | | language_ident, |
| | | as, |
| | | end, |
| | | }; |
| | | |
| | | static std::string trim_whitespace(std::string str) { |
| | | auto str_begin_it = std::find_if( |
| | | str.begin(), str.end(), |
| | | [](char ch) { return !std::isspace(ch); }); |
| | | auto str_end_it = std::find_if( |
| | | str.rbegin(), str.rend(), |
| | | [](char ch) { return !std::isspace(ch); }); |
| | | |
| | | std::string::size_type str_begin_pos = str_begin_it - str.begin(); |
| | | std::string::size_type str_end_pos = str.rend() - str_end_it; |
| | | |
| | | return str.substr(str_begin_pos, str_end_pos); |
| | | } |
| | | |
| | | /* FIXME: we are using std::optional to convey the error. |
| | | * This is a poor use of std::optional. std::exceptional would |
| | | * be a much better fit, but it came only in C++23 |
| | | */ |
| | | static std::optional<std::string> wrap_source(std::string source) |
| | | { |
| | | char *source_encrypted_cstr = pg_kuzn_encode(source.c_str(), source.size()); |
| | | std::string source_encrypted = source_encrypted_cstr; |
| | | pfree(source_encrypted_cstr); |
| | | |
| | | std::string source_encoded; |
| | | source_encoded.resize(pg_b64_enc_len(source_encrypted.size())); |
| | | int enc_result = pg_b64_encode( |
| | | reinterpret_cast<const uint8_t*>(source_encrypted.c_str()), |
| | | source_encrypted.size(), |
| | | source_encoded.data(), |
| | | source_encoded.size()); |
| | | |
| | | if (enc_result == -1) |
| | | { |
| | | return std::nullopt; |
| | | } |
| | | |
| | | source_encoded.resize(enc_result); |
| | | |
| | | uint32_t crc; |
| | | INIT_CRC32C(crc); |
| | | COMP_CRC32C(crc, source_encoded.c_str(), source_encoded.size()); |
| | | FIN_CRC32C(crc); |
| | | |
| | | std::ostringstream oss; |
| | | oss << "/* WRAPPEDpgSQL ="; |
| | | oss << source_encoded; |
| | | oss << std::hex << std::setfill('0') << std::setw(8) << std::uppercase << crc; |
| | | oss << "= */"; |
| | | |
| | | return oss.str(); |
| | | } |
| | | |
| | | extern "C" |
| | | { |
| | | |
| | | PG_FUNCTION_INFO_V1(dbms_ddl_alter_compile); |
| | | PG_FUNCTION_INFO_V1(dbms_ddl_alter_table_not_referenceable); |
| | | PG_FUNCTION_INFO_V1(dbms_ddl_alter_table_referenceable); |
| | | PG_FUNCTION_INFO_V1(dbms_ddl_analyze_object); |
| | | PG_FUNCTION_INFO_V1(dbms_ddl_create_wrapped_ovr1); |
| | | PG_FUNCTION_INFO_V1(dbms_ddl_create_wrapped_ovr2); |
| | | PG_FUNCTION_INFO_V1(dbms_ddl_create_wrapped_ovr3); |
| | | PG_FUNCTION_INFO_V1(dbms_ddl_is_trigger_fire_once); |
| | | PG_FUNCTION_INFO_V1(dbms_ddl_is_trigger_fire_once_internal); |
| | | PG_FUNCTION_INFO_V1(dbms_ddl_set_trigger_firing_property_ovr1); |
| | | PG_FUNCTION_INFO_V1(dbms_ddl_set_trigger_firing_property_ovr2); |
| | | PG_FUNCTION_INFO_V1(dbms_ddl_wrap_ovr1); |
| | | PG_FUNCTION_INFO_V1(dbms_ddl_wrap_ovr2); |
| | | PG_FUNCTION_INFO_V1(dbms_ddl_wrap_ovr3); |
| | | PG_FUNCTION_INFO_V1(dbms_ddl_wrap_ovr4); |
| | | |
| | | /** |
| | | * @brief Компилирует указанный объект (процедура/функция/пакет). |
| | | * @details TODO: Добавить детальное описание |
| | | * * Parameters: |
| | | * * @param TYPE (in) VARCHAR2: Тип объекта; должен быть одним из - PROCEDURE, FUNCTION, PACKAGE, PACKAGE BODY или TRIGGER. |
| | | * * @param SCHEMA (in) VARCHAR2: Имя схемы. |
| | | * * @param NAME (in) VARCHAR2: Имя объекта (чувствительно к регистру). |
| | | * * @param REUSE_SETTINGS (in) BOOLEAN: Указывает, следует ли использовать настройки сессии в объектах или использовать текущие настройки сессии. |
| | | * * * * * |
| | | * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/DBMS_DDL.html |
| | | */ |
| | | Datum dbms_ddl_alter_compile(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | /** |
| | | * @brief Изменяет указанную объектную таблицу, чтобы она не была таблицей по умолчанию для ссылок в схеме. |
| | | * @details Эта процедура изменяет указанную объектную таблицу, чтобы она не была таблицей по умолчанию для ссылок в указанной схеме. |
| | | * * Parameters: |
| | | * * @param TABLE_NAME (in) VARCHAR2: Имя таблицы, которую необходимо изменить. |
| | | * * @param TABLE_SCHEMA (in) VARCHAR2: Имя схемы, владельца таблицы, которую необходимо изменить. |
| | | * * @param AFFECTED_SCHEMA (in) VARCHAR2: Имя схемы, на которую повлияет это изменение. |
| | | * * * * * |
| | | * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/DBMS_DDL.html |
| | | */ |
| | | Datum dbms_ddl_alter_table_not_referenceable(PG_FUNCTION_ARGS) |
| | | { |
| | | ereport(NOTICE, (errmsg("Функция dbms_ddl.alter_table_not_referenceable еще не реализована."))); |
| | | |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | /** |
| | | * @brief Изменяет указанную объектную таблицу, чтобы она стала таблицей для ссылок в заданной схеме. |
| | | * @details Эта процедура изменяет указанную объектную таблицу, чтобы она стала таблицей для ссылок в указной схеме. |
| | | * * Parameters: |
| | | * * @param TABLE_NAME (in) VARCHAR2: Имя таблицы, которую необходимо изменить. |
| | | * * @param TABLE_SCHEMA (in) VARCHAR2: Имя схемы, владельца таблицы, которую необходимо изменить. |
| | | * * @param AFFECTED_SCHEMA (in) VARCHAR2: Имя схемы, на которую повлияет это изменение. |
| | | * * * * * |
| | | * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/DBMS_DDL.html |
| | | */ |
| | | Datum dbms_ddl_alter_table_referenceable(PG_FUNCTION_ARGS) |
| | | { |
| | | ereport(NOTICE, (errmsg("Функция dbms_ddl.alter_table_referenceable еще не реализована."))); |
| | | |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | /** |
| | | * @brief Выполняет анализ указанного объекта в базе данных. |
| | | * @details Эта процедура выполняет анализ для улучшения производительности запрашиваемого объекта, помогая оптимизатору при выполнении запросов. |
| | | * * Parameters: |
| | | * * @param TYPE (in) VARCHAR2: Указывает тип объекта для анализа. |
| | | * * @param SCHEMA (in) VARCHAR2: Имя схемы, в которой находится объект. |
| | | * * @param NAME (in) VARCHAR2: Имя объекта, который нужно анализировать. |
| | | * * @param METHOD (in) VARCHAR2: Метод анализа, который будет использован. |
| | | * * @param ESTIMATE_ROWS (in) NUMBER: Оценка количества строк в объекте. |
| | | * * @param ESTIMATE_PERCENT (in) NUMBER: Процент для анализа. |
| | | * * @param METHOD_OPT (in) VARCHAR2: Указывает дополнительные настройки анализа. |
| | | * * @param PARTNAME (in) VARCHAR2: Имя раздела для анализа. |
| | | * * * * * |
| | | * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/DBMS_DDL.html |
| | | */ |
| | | Datum dbms_ddl_analyze_object(PG_FUNCTION_ARGS) |
| | | { |
| | | ereport(NOTICE, (errmsg("Функция dbms_ddl.analyze_object еще не реализована."))); |
| | | |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | /** |
| | | * @brief Создает обертку для указанного SQL DDL. |
| | | * @details Эта процедура создает обертку для указанного DDL, позволяя выполнять его в дальнейшем. |
| | | * * Parameters: |
| | | * * @param DDL (in) VARCHAR2: SQL DDL для создания упаковки. |
| | | * * * * * |
| | | * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/DBMS_DDL.html |
| | | */ |
| | | Datum dbms_ddl_create_wrapped_ovr1(PG_FUNCTION_ARGS) |
| | | { |
| | | text *ddl_txt = PG_GETARG_TEXT_P(0); |
| | | char *ddl = text_to_cstring(ddl_txt); |
| | | |
| | | core_yy_extra_type yyextra; |
| | | core_YYSTYPE yylval; |
| | | YYLTYPE yylloc; |
| | | int token; |
| | | |
| | | miniparser_state state = miniparser_state::start; |
| | | |
| | | core_yyscan_t yyscanner = scanner_init(ddl, &yyextra, |
| | | &ScanKeywords, ScanKeywordTokens); |
| | | |
| | | |
| | | int header_start_loc, header_end_loc; |
| | | std::string body; |
| | | bool is_procedure = true; |
| | | int bracket_count = 0; |
| | | |
| | | |
| | | while ((token = core_yylex(&yylval, &yylloc, yyscanner)) != 0) |
| | | { |
| | | switch (state) |
| | | { |
| | | case miniparser_state::start: |
| | | if (token == CREATE) |
| | | { |
| | | state = miniparser_state::create; |
| | | header_start_loc = yylloc; |
| | | } |
| | | else |
| | | { |
| | | ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("Expected CREATE"))); |
| | | scanner_finish(yyscanner); |
| | | PG_RETURN_VOID(); |
| | | } |
| | | break; |
| | | case miniparser_state::create: |
| | | if (token == OR) |
| | | { |
| | | state = miniparser_state::or_; |
| | | } |
| | | else if (token == FUNCTION || token == PROCEDURE) |
| | | { |
| | | state = miniparser_state::procedure; |
| | | is_procedure = (token == PROCEDURE); |
| | | } |
| | | else |
| | | { |
| | | ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("Expected OR, FUNCTION or PROCEDURE"))); |
| | | scanner_finish(yyscanner); |
| | | PG_RETURN_VOID(); |
| | | } |
| | | break; |
| | | case miniparser_state::or_: |
| | | if (token == REPLACE) |
| | | { |
| | | state = miniparser_state::replace; |
| | | } |
| | | else |
| | | { |
| | | ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("Expected REPLACE"))); |
| | | scanner_finish(yyscanner); |
| | | PG_RETURN_VOID(); |
| | | } |
| | | break; |
| | | case miniparser_state::replace: |
| | | if (token == FUNCTION || token == PROCEDURE) |
| | | { |
| | | is_procedure = (token == PROCEDURE); |
| | | state = miniparser_state::procedure; |
| | | } |
| | | else |
| | | { |
| | | ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("Expected FUNCTION or PROCEDURE"))); |
| | | scanner_finish(yyscanner); |
| | | PG_RETURN_VOID(); |
| | | } |
| | | break; |
| | | case miniparser_state::procedure: |
| | | if (token == IDENT) |
| | | { |
| | | state = miniparser_state::procedure_ident; |
| | | } |
| | | else |
| | | { |
| | | ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("Expected function name"))); |
| | | scanner_finish(yyscanner); |
| | | PG_RETURN_VOID(); |
| | | } |
| | | break; |
| | | case miniparser_state::procedure_ident: |
| | | if (token == '(') |
| | | { |
| | | bracket_count = 1; |
| | | state = miniparser_state::args; |
| | | } |
| | | else |
| | | { |
| | | ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("Expected opening bracket"))); |
| | | scanner_finish(yyscanner); |
| | | PG_RETURN_VOID(); |
| | | } |
| | | break; |
| | | case miniparser_state::args: |
| | | if (token == '(') |
| | | { |
| | | bracket_count++; |
| | | } |
| | | if (token == ')') |
| | | { |
| | | bracket_count--; |
| | | if (bracket_count == 0) |
| | | { |
| | | state = miniparser_state::args_end; |
| | | } |
| | | } |
| | | break; |
| | | case miniparser_state::args_end: |
| | | if (token == LANGUAGE) |
| | | { |
| | | state = miniparser_state::language; |
| | | } |
| | | break; |
| | | case miniparser_state::language: |
| | | if (token == IDENT) |
| | | { |
| | | if (strcasecmp(yylval.str, "plpgsql") == 0) |
| | | { |
| | | state = miniparser_state::language_ident; |
| | | } |
| | | else |
| | | { |
| | | ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("Expected language name"))); |
| | | scanner_finish(yyscanner); |
| | | PG_RETURN_VOID(); |
| | | } |
| | | } |
| | | break; |
| | | case miniparser_state::language_ident: |
| | | if (token == AS) |
| | | { |
| | | state = miniparser_state::as; |
| | | } |
| | | else |
| | | { |
| | | ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("Expected AS"))); |
| | | scanner_finish(yyscanner); |
| | | PG_RETURN_VOID(); |
| | | } |
| | | header_end_loc = yylloc + 2; /* after the end of AS */ |
| | | break; |
| | | case miniparser_state::as: |
| | | if (token == SCONST) |
| | | { |
| | | body = yylval.str; |
| | | state = miniparser_state::end; |
| | | } |
| | | else |
| | | { |
| | | ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("Expected %s body", |
| | | is_procedure? "procedure" : "function"))); |
| | | scanner_finish(yyscanner); |
| | | PG_RETURN_VOID(); |
| | | } |
| | | break; |
| | | case miniparser_state::end: |
| | | ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("Expected end of statement"))); |
| | | scanner_finish(yyscanner); |
| | | PG_RETURN_VOID(); |
| | | } |
| | | } |
| | | |
| | | scanner_finish(yyscanner); |
| | | |
| | | if (state != miniparser_state::end) |
| | | { |
| | | ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("Unexpected end of statement"))); |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | std::string_view header(ddl + header_start_loc, header_end_loc - header_start_loc); |
| | | |
| | | auto wrapped_body_opt = wrap_source(body); |
| | | if (!wrapped_body_opt.has_value()) |
| | | { |
| | | ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("Failed to wrap function body"))); |
| | | } |
| | | std::string wrapped_body = wrapped_body_opt.value(); |
| | | |
| | | std::ostringstream result_ddl; |
| | | result_ddl << header << " $$\n"; |
| | | result_ddl << wrapped_body << "\n"; |
| | | if (is_procedure) |
| | | { |
| | | result_ddl << "BEGIN\n NULL;\nEND;\n$$;"; |
| | | } |
| | | else |
| | | { |
| | | result_ddl << "BEGIN\n RETURN NULL;\nEND;\n$$;"; |
| | | } |
| | | |
| | | ereport(DEBUG1, errmsg_internal("Result DDL: %s", result_ddl.str().c_str())); |
| | | |
| | | SPI_connect(); |
| | | |
| | | int ret = SPI_execute(result_ddl.str().c_str(), false, 0); |
| | | |
| | | if (ret < 0) |
| | | { |
| | | ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("Failed to execute DDL: %d", ret))); |
| | | } |
| | | |
| | | SPI_finish(); |
| | | |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | /** |
| | | * @brief Создает обертку на основе строки DDL и границ. |
| | | * @details Эта процедура создает обертку на основе указанных DDL и границ для дальнейшей обработки. |
| | | * * Parameters: |
| | | * * @param DDL (in) PL/SQL TABLE: Строка DDL для создания упаковки. |
| | | * * @param LB (in) BINARY_INTEGER: Нижняя граница для обработки DDL. |
| | | * * @param UB (in) BINARY_INTEGER: Верхняя граница для обработки DDL. |
| | | * * * * * |
| | | * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/DBMS_DDL.html |
| | | */ |
| | | Datum dbms_ddl_create_wrapped_ovr2(PG_FUNCTION_ARGS) |
| | | { |
| | | ereport(NOTICE, (errmsg("Функция dbms_ddl.create_wrapped еще не реализована."))); |
| | | |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | /** |
| | | * @brief Создает обертку на основе строки DDL и границ. |
| | | * @details Эта процедура создает обертку на основе указанных DDL и границ для дальнейшей обработки. |
| | | * * Parameters: |
| | | * * @param DDL (in) PL/SQL TABLE: Строка DDL для создания упаковки. |
| | | * * @param LB (in) BINARY_INTEGER: Нижняя граница для обработки DDL. |
| | | * * @param UB (in) BINARY_INTEGER: Верхняя граница для обработки DDL. |
| | | * * * * * |
| | | * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/DBMS_DDL.html |
| | | */ |
| | | Datum dbms_ddl_create_wrapped_ovr3(PG_FUNCTION_ARGS) |
| | | { |
| | | ereport(NOTICE, (errmsg("Функция dbms_ddl.create_wrapped еще не реализована."))); |
| | | |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | /** |
| | | * @brief Возвращает TRUE, если указанный DML или DDL триггер настроен на выполнение один раз. |
| | | * @details Эта функция возвращает TRUE, если указанный DML или DDL триггер настроен на выполнение только один раз. В противном случае возвращает FALSE. Триггер, который выполняется один раз, срабатывает в пользовательской сессии, но не применяется в следующих случаях: |
| | | * * Parameters: |
| | | * * @param TRIG_OWNER (in) VARCHAR2: Имя схемы триггера. |
| | | * * @param TRIG_NAME (in) VARCHAR2: Имя триггера. |
| | | * * * * * |
| | | * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/DBMS_DDL.html |
| | | */ |
| | | Datum dbms_ddl_is_trigger_fire_once(PG_FUNCTION_ARGS) |
| | | { |
| | | ereport(NOTICE, (errmsg("Функция dbms_ddl.is_trigger_fire_once еще не реализована."))); |
| | | |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | /** |
| | | * @brief Возвращает TRUE, если указанный триггер настроен на выполнение единожды. |
| | | * @details Эта функция проверяет, активен ли триггер, и возвращает TRUE, если он срабатывает только один раз; иначе возвращает FALSE. |
| | | * * Parameters: |
| | | * * @param TRIG_OWNER (in) VARCHAR2: Схема, в которой расположен триггер. |
| | | * * @param TRIG_NAME (in) VARCHAR2: Имя триггера для проверки. |
| | | * * * * * |
| | | * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/DBMS_DDL.html |
| | | */ |
| | | Datum dbms_ddl_is_trigger_fire_once_internal(PG_FUNCTION_ARGS) |
| | | { |
| | | ereport(NOTICE, (errmsg("Функция dbms_ddl.is_trigger_fire_once_internal еще не реализована."))); |
| | | |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | /** |
| | | * @brief Устанавливает свойства активации для указанного триггера. |
| | | * @details Эта процедура позволяет задавать свойства активации для триггера, устанавливая флаг на выполнение единожды. |
| | | * * Parameters: |
| | | * * @param TRIG_OWNER (in) VARCHAR2: Схема, в которой расположен триггер. |
| | | * * @param TRIG_NAME (in) VARCHAR2: Имя триггера для изменения. |
| | | * * @param FIRE_ONCE (in) BOOLEAN: Указывает, должен ли триггер срабатывать только один раз. |
| | | * * * * * |
| | | * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/DBMS_DDL.html |
| | | */ |
| | | Datum dbms_ddl_set_trigger_firing_property_ovr1(PG_FUNCTION_ARGS) |
| | | { |
| | | ereport(NOTICE, (errmsg("Функция dbms_ddl.set_trigger_firing_property еще не реализована."))); |
| | | |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | /** |
| | | * @brief Устанавливает свойства активации для указанного триггера. |
| | | * @details Эта процедура позволяет задавать свойства активации для триггера, устанавливая флаг на выполнение единожды. |
| | | * * Parameters: |
| | | * * @param TRIG_OWNER (in) VARCHAR2: Схема, в которой расположен триггер. |
| | | * * @param TRIG_NAME (in) VARCHAR2: Имя триггера для изменения. |
| | | * * @param PROPERTY (in) BINARY_INTEGER: TODO: Описание параметра PROPERTY |
| | | * * @param SETTING (in) BOOLEAN: TODO: Описание параметра SETTING |
| | | * * * * * |
| | | * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/DBMS_DDL.html |
| | | */ |
| | | Datum dbms_ddl_set_trigger_firing_property_ovr2(PG_FUNCTION_ARGS) |
| | | { |
| | | ereport(NOTICE, (errmsg("Функция dbms_ddl.set_trigger_firing_property еще не реализована."))); |
| | | |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | /** |
| | | * @brief Создает обертку для указанного SQL DDL. |
| | | * @details Эта функция создает обертку для указанного DDL, позволяя его дальнейшее использование и выполнение. |
| | | * * Parameters: |
| | | * * @param DDL (in) VARCHAR2: SQL DDL, который необходимо завернуть. |
| | | * * * * * |
| | | * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/DBMS_DDL.html |
| | | */ |
| | | Datum dbms_ddl_wrap_ovr1(PG_FUNCTION_ARGS) |
| | | { |
| | | text *source_txt_packed = PG_GETARG_TEXT_P(0); |
| | | text *source_txt = pg_detoast_datum_packed(source_txt_packed); |
| | | std::string source; |
| | | source.resize(VARSIZE_ANY_EXHDR(source_txt)); |
| | | memcpy(source.data(), VARDATA_ANY(source_txt), source.size()); |
| | | |
| | | source = trim_whitespace(source); |
| | | |
| | | auto source_wrapped = wrap_source(source); |
| | | |
| | | if (source_wrapped.has_value()) |
| | | { |
| | | text *result = cstring_to_text(source_wrapped.value().c_str()); |
| | | PG_RETURN_TEXT_P(result); |
| | | } |
| | | else |
| | | { |
| | | ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("Failed to encode source"))); |
| | | PG_RETURN_VOID(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @brief Создает обертку на основе планов DDL и заданных границ. |
| | | * @details Эта функция создает обертку на основе указанных данных DDL и значений границ для дальнейшей обработки. |
| | | * * Parameters: |
| | | * * @param DDL (in) PL/SQL TABLE: Строка DDL для создания упаковки. |
| | | * * @param LB (in) BINARY_INTEGER: Нижняя граница для обработки DDL. |
| | | * * @param UB (in) BINARY_INTEGER: Верхняя граница для обработки DDL. |
| | | * * * * * |
| | | * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/DBMS_DDL.html |
| | | */ |
| | | Datum dbms_ddl_wrap_ovr2(PG_FUNCTION_ARGS) |
| | | { |
| | | Datum ddl = PG_GETARG_DATUM(0); |
| | | PG_RETURN_DATUM(ddl); |
| | | } |
| | | |
| | | /** |
| | | * @brief Создает обертку на основе планов DDL и заданных границ. |
| | | * @details Эта функция создает обертку на основе указанных данных DDL и значений границ для дальнейшей обработки. |
| | | * * Parameters: |
| | | * * @param DDL (in) PL/SQL TABLE: Строка DDL для создания упаковки. |
| | | * * @param LB (in) BINARY_INTEGER: Нижняя граница для обработки DDL. |
| | | * * @param UB (in) BINARY_INTEGER: Верхняя граница для обработки DDL. |
| | | * * * * * |
| | | * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/DBMS_DDL.html |
| | | */ |
| | | Datum dbms_ddl_wrap_ovr3(PG_FUNCTION_ARGS) |
| | | { |
| | | Datum ddl = PG_GETARG_DATUM(0); |
| | | PG_RETURN_DATUM(ddl); |
| | | } |
| | | |
| | | Datum dbms_ddl_wrap_ovr4(PG_FUNCTION_ARGS) |
| | | { |
| | | bytea *ddl_raw = PG_GETARG_BYTEA_P(0); |
| | | |
| | | text *ddl = reinterpret_cast<text*>(ddl_raw); |
| | | |
| | | return DirectFunctionCall1(dbms_ddl_wrap_ovr1, PointerGetDatum(ddl)); |
| | | } |
| | | |
| | | |
| | | } // extern "C" |
| New file |
| | |
| | | #ifndef DBMS_DDL_INTERNAL_HPP |
| | | #define DBMS_DDL_INTERNAL_HPP |
| | | |
| | | extern "C" |
| | | { |
| | | #include "postgres.h" |
| | | #include "fmgr.h" |
| | | #include "utils/builtins.h" |
| | | #include "utils/numeric.h" |
| | | #include "utils/date.h" |
| | | #include "utils/timestamp.h" |
| | | #include "utils/array.h" |
| | | #include "catalog/pg_type.h" |
| | | #include "executor/spi.h" |
| | | } // extern "C" |
| | | |
| | | extern "C" |
| | | { |
| | | Datum dbms_ddl_alter_compile(PG_FUNCTION_ARGS); |
| | | Datum dbms_ddl_alter_table_not_referenceable(PG_FUNCTION_ARGS); |
| | | Datum dbms_ddl_alter_table_referenceable(PG_FUNCTION_ARGS); |
| | | Datum dbms_ddl_analyze_object(PG_FUNCTION_ARGS); |
| | | Datum dbms_ddl_create_wrapped_ovr1(PG_FUNCTION_ARGS); |
| | | Datum dbms_ddl_create_wrapped_ovr2(PG_FUNCTION_ARGS); |
| | | Datum dbms_ddl_create_wrapped_ovr3(PG_FUNCTION_ARGS); |
| | | Datum dbms_ddl_is_trigger_fire_once(PG_FUNCTION_ARGS); |
| | | Datum dbms_ddl_is_trigger_fire_once_internal(PG_FUNCTION_ARGS); |
| | | Datum dbms_ddl_set_trigger_firing_property_ovr1(PG_FUNCTION_ARGS); |
| | | Datum dbms_ddl_set_trigger_firing_property_ovr2(PG_FUNCTION_ARGS); |
| | | Datum dbms_ddl_wrap_ovr1(PG_FUNCTION_ARGS); |
| | | Datum dbms_ddl_wrap_ovr2(PG_FUNCTION_ARGS); |
| | | Datum dbms_ddl_wrap_ovr3(PG_FUNCTION_ARGS); |
| | | Datum dbms_ddl_wrap_ovr4(PG_FUNCTION_ARGS); |
| | | } // extern "C" |
| | | |
| | | #endif // DBMS_DDL_INTERNAL_HPP |
| | | |
| New file |
| | |
| | | #include "dbms_file_transfer.hpp" |
| | | |
| | | #include <cstring> |
| | | #include <string> |
| | | #include <vector> |
| | | |
| | | extern "C" { |
| | | #include <errno.h> |
| | | #include <fcntl.h> |
| | | #include <unistd.h> |
| | | |
| | | #include "executor/spi.h" |
| | | #include "miscadmin.h" |
| | | #include "storage/fd.h" |
| | | #include "utils/builtins.h" |
| | | #include "utils/bytea.h" |
| | | |
| | | PG_FUNCTION_INFO_V1(dbms_file_transfer_copy_file); |
| | | PG_FUNCTION_INFO_V1(dbms_file_transfer_is_safe_filename); |
| | | PG_FUNCTION_INFO_V1(dbms_file_transfer_get_file); |
| | | PG_FUNCTION_INFO_V1(dbms_file_transfer_put_file); |
| | | PG_FUNCTION_INFO_V1(read_file_chunk); |
| | | PG_FUNCTION_INFO_V1(write_file_chunk); |
| | | PG_FUNCTION_INFO_V1(pg_file_unlink_custom); |
| | | PG_FUNCTION_INFO_V1(dbms_file_transfer_get_version); |
| | | |
| | | /// @brief Версия RUDB пакета DBMS_FILE_TRANSFER (Oracle DBMS_FILE_TRANSFER пакет) |
| | | #define RUDB_DBMS_FILE_TRANSFER_VERSION "1.0.0" |
| | | } |
| | | |
| | | namespace { |
| | | |
| | | constexpr std::size_t kCopyBufferSize = 64 * 1024; |
| | | constexpr int32 kRemoteReadChunkSize = 128 * 1024; |
| | | constexpr std::size_t kRemoteWriteChunkSize = 8 * 1024; |
| | | |
| | | bool |
| | | isSafeFilename(const char* const filename) |
| | | { |
| | | if (filename == nullptr || filename[0] == '\0') { |
| | | return false; |
| | | } |
| | | |
| | | if (filename[0] == '/' || filename[0] == '\\') { |
| | | return false; |
| | | } |
| | | |
| | | if (std::strcmp(filename, ".") == 0 || std::strcmp(filename, "..") == 0) { |
| | | return false; |
| | | } |
| | | |
| | | for (const char* ptr = filename; *ptr != '\0'; ++ptr) { |
| | | if (*ptr == '/' || *ptr == '\\') { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return std::strstr(filename, "..") == nullptr; |
| | | } |
| | | |
| | | std::string |
| | | joinPath(const char* const dir, const char* const file) |
| | | { |
| | | return std::string(dir) + "/" + file; |
| | | } |
| | | |
| | | void |
| | | closeTransientFileIfOpened(int& fd) |
| | | { |
| | | if (fd >= 0) { |
| | | CloseTransientFile(fd); |
| | | fd = -1; |
| | | } |
| | | } |
| | | |
| | | } // namespace |
| | | |
| | | /* |
| | | * @qdb_func: dbms_file_transfer_copy_file(text, text, text, text) |
| | | * @ora_func: DBMS_FILE_TRANSFER.COPY_FILE(VARCHAR2, VARCHAR2, VARCHAR2, VARCHAR2) |
| | | */ |
| | | extern "C" Datum |
| | | dbms_file_transfer_copy_file(PG_FUNCTION_ARGS) |
| | | { |
| | | const char* const srcDir = TextDatumGetCString(PG_GETARG_DATUM(0)); |
| | | const char* const srcFile = TextDatumGetCString(PG_GETARG_DATUM(1)); |
| | | const char* const dstDir = TextDatumGetCString(PG_GETARG_DATUM(2)); |
| | | const char* const dstFile = TextDatumGetCString(PG_GETARG_DATUM(3)); |
| | | |
| | | const bool srcSafe = DatumGetBool( |
| | | DirectFunctionCall1(dbms_file_transfer_is_safe_filename, |
| | | CStringGetTextDatum(srcFile))); |
| | | const bool dstSafe = DatumGetBool( |
| | | DirectFunctionCall1(dbms_file_transfer_is_safe_filename, |
| | | CStringGetTextDatum(dstFile))); |
| | | |
| | | if (!srcSafe || !dstSafe) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("DBMS_FILE_TRANSFER: unsafe file name"))); |
| | | } |
| | | |
| | | const std::string fullSrc = joinPath(srcDir, srcFile); |
| | | const std::string fullDst = joinPath(dstDir, dstFile); |
| | | |
| | | int srcFd = -1; |
| | | int dstFd = -1; |
| | | std::vector<char> buffer(kCopyBufferSize); |
| | | bool success = false; |
| | | |
| | | PG_TRY(); |
| | | { |
| | | srcFd = OpenTransientFile(fullSrc.c_str(), O_RDONLY | PG_BINARY); |
| | | if (srcFd < 0) { |
| | | ereport(ERROR, |
| | | (errcode_for_file_access(), |
| | | errmsg("could not open source file \"%s\": %m", fullSrc.c_str()))); |
| | | } |
| | | |
| | | dstFd = OpenTransientFile(fullDst.c_str(), O_WRONLY | O_CREAT | O_TRUNC | PG_BINARY); |
| | | if (dstFd < 0) { |
| | | ereport(ERROR, |
| | | (errcode_for_file_access(), |
| | | errmsg("could not create destination file \"%s\": %m", fullDst.c_str()))); |
| | | } |
| | | |
| | | ssize_t nread = 0; |
| | | while ((nread = read(srcFd, buffer.data(), buffer.size())) > 0) { |
| | | CHECK_FOR_INTERRUPTS(); |
| | | |
| | | if (write(dstFd, buffer.data(), nread) != nread) { |
| | | ereport(ERROR, |
| | | (errcode_for_file_access(), |
| | | errmsg("could not write to file \"%s\": %m", fullDst.c_str()))); |
| | | } |
| | | } |
| | | |
| | | if (nread < 0) { |
| | | ereport(ERROR, |
| | | (errcode_for_file_access(), |
| | | errmsg("could not read from file \"%s\": %m", fullSrc.c_str()))); |
| | | } |
| | | |
| | | if (pg_fsync(dstFd) != 0) { |
| | | ereport(ERROR, |
| | | (errcode_for_file_access(), |
| | | errmsg("could not fsync file \"%s\": %m", fullDst.c_str()))); |
| | | } |
| | | |
| | | closeTransientFileIfOpened(srcFd); |
| | | closeTransientFileIfOpened(dstFd); |
| | | success = true; |
| | | } |
| | | PG_CATCH(); |
| | | { |
| | | closeTransientFileIfOpened(srcFd); |
| | | closeTransientFileIfOpened(dstFd); |
| | | |
| | | if (!success) { |
| | | unlink(fullDst.c_str()); |
| | | } |
| | | |
| | | PG_RE_THROW(); |
| | | } |
| | | PG_END_TRY(); |
| | | |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_file_transfer_is_safe_filename(text) |
| | | */ |
| | | extern "C" Datum |
| | | dbms_file_transfer_is_safe_filename(PG_FUNCTION_ARGS) |
| | | { |
| | | if (PG_ARGISNULL(0)) { |
| | | PG_RETURN_BOOL(false); |
| | | } |
| | | |
| | | const char* const filename = TextDatumGetCString(PG_GETARG_DATUM(0)); |
| | | PG_RETURN_BOOL(isSafeFilename(filename)); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_file_transfer_get_file(text, text, text, text, text) |
| | | * @ora_func: DBMS_FILE_TRANSFER.GET_FILE(VARCHAR2, VARCHAR2, VARCHAR2, VARCHAR2, VARCHAR2) |
| | | */ |
| | | extern "C" Datum |
| | | dbms_file_transfer_get_file(PG_FUNCTION_ARGS) |
| | | { |
| | | const char* const srcDir = TextDatumGetCString(PG_GETARG_DATUM(0)); |
| | | const char* const srcFile = TextDatumGetCString(PG_GETARG_DATUM(1)); |
| | | const char* const connName = TextDatumGetCString(PG_GETARG_DATUM(2)); |
| | | const char* const dstDir = TextDatumGetCString(PG_GETARG_DATUM(3)); |
| | | const char* const dstFile = TextDatumGetCString(PG_GETARG_DATUM(4)); |
| | | |
| | | const bool srcSafe = DatumGetBool( |
| | | DirectFunctionCall1(dbms_file_transfer_is_safe_filename, |
| | | CStringGetTextDatum(srcFile))); |
| | | const bool dstSafe = DatumGetBool( |
| | | DirectFunctionCall1(dbms_file_transfer_is_safe_filename, |
| | | CStringGetTextDatum(dstFile))); |
| | | |
| | | if (!srcSafe || !dstSafe) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("DBMS_FILE_TRANSFER: unsafe file name"))); |
| | | } |
| | | |
| | | const std::string fullDst = joinPath(dstDir, dstFile); |
| | | int dstFd = -1; |
| | | bool success = false; |
| | | |
| | | if (SPI_connect() != SPI_OK_CONNECT) { |
| | | ereport(ERROR, (errmsg("could not connect to SPI"))); |
| | | } |
| | | |
| | | PG_TRY(); |
| | | { |
| | | dstFd = OpenTransientFile(fullDst.c_str(), O_WRONLY | O_CREAT | O_TRUNC | PG_BINARY); |
| | | if (dstFd < 0) { |
| | | ereport(ERROR, |
| | | (errcode_for_file_access(), |
| | | errmsg("could not open destination file \"%s\": %m", fullDst.c_str()))); |
| | | } |
| | | |
| | | int64 offset = 0; |
| | | bool eof = false; |
| | | |
| | | while (!eof) { |
| | | CHECK_FOR_INTERRUPTS(); |
| | | |
| | | char* const sqlReadChunk = psprintf("SELECT read_file_chunk(%s, %s, %lld, %d)", |
| | | quote_literal_cstr(srcDir), |
| | | quote_literal_cstr(srcFile), |
| | | static_cast<long long>(offset), |
| | | kRemoteReadChunkSize); |
| | | |
| | | char* const sql = psprintf( |
| | | "SELECT result FROM dblink(%s, %s) AS t(result bytea)", |
| | | quote_literal_cstr(connName), |
| | | quote_literal_cstr(sqlReadChunk)); |
| | | |
| | | const int res = SPI_execute(sql, true, 1); |
| | | pfree(sql); |
| | | pfree(sqlReadChunk); |
| | | |
| | | if (res != SPI_OK_SELECT || SPI_processed == 0) { |
| | | ereport(ERROR, (errmsg("dblink call failed or returned no data"))); |
| | | } |
| | | |
| | | bool isNull = false; |
| | | const Datum binData = SPI_getbinval(SPI_tuptable->vals[0], |
| | | SPI_tuptable->tupdesc, |
| | | 1, |
| | | &isNull); |
| | | |
| | | if (isNull) { |
| | | eof = true; |
| | | } else { |
| | | const bytea* const chunk = DatumGetByteaP(binData); |
| | | const int len = VARSIZE(chunk) - VARHDRSZ; |
| | | |
| | | if (len == 0) { |
| | | eof = true; |
| | | } else { |
| | | if (write(dstFd, VARDATA(chunk), len) != len) { |
| | | ereport(ERROR, |
| | | (errcode_for_file_access(), |
| | | errmsg("write to destination failed: %m"))); |
| | | } |
| | | |
| | | offset += len; |
| | | } |
| | | } |
| | | |
| | | SPI_freetuptable(SPI_tuptable); |
| | | } |
| | | |
| | | if (pg_fsync(dstFd) != 0) { |
| | | ereport(ERROR, |
| | | (errcode_for_file_access(), |
| | | errmsg("could not fsync file \"%s\": %m", fullDst.c_str()))); |
| | | } |
| | | |
| | | closeTransientFileIfOpened(dstFd); |
| | | success = true; |
| | | } |
| | | PG_CATCH(); |
| | | { |
| | | closeTransientFileIfOpened(dstFd); |
| | | |
| | | if (!success) { |
| | | unlink(fullDst.c_str()); |
| | | } |
| | | |
| | | SPI_finish(); |
| | | PG_RE_THROW(); |
| | | } |
| | | PG_END_TRY(); |
| | | |
| | | SPI_finish(); |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | /* |
| | | * @qdb_func: dbms_file_transfer_put_file(text, text, text, text, text) |
| | | * @ora_func: DBMS_FILE_TRANSFER.PUT_FILE(VARCHAR2, VARCHAR2, VARCHAR2, VARCHAR2, VARCHAR2) |
| | | */ |
| | | extern "C" Datum |
| | | dbms_file_transfer_put_file(PG_FUNCTION_ARGS) |
| | | { |
| | | const char* const srcDir = TextDatumGetCString(PG_GETARG_DATUM(0)); |
| | | const char* const srcFile = TextDatumGetCString(PG_GETARG_DATUM(1)); |
| | | const char* const connName = TextDatumGetCString(PG_GETARG_DATUM(2)); |
| | | const char* const dstDir = TextDatumGetCString(PG_GETARG_DATUM(3)); |
| | | const char* const dstFile = TextDatumGetCString(PG_GETARG_DATUM(4)); |
| | | |
| | | const bool srcSafe = DatumGetBool( |
| | | DirectFunctionCall1(dbms_file_transfer_is_safe_filename, |
| | | CStringGetTextDatum(srcFile))); |
| | | const bool dstSafe = DatumGetBool( |
| | | DirectFunctionCall1(dbms_file_transfer_is_safe_filename, |
| | | CStringGetTextDatum(dstFile))); |
| | | |
| | | if (!srcSafe || !dstSafe) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("DBMS_FILE_TRANSFER: unsafe file name"))); |
| | | } |
| | | |
| | | const std::string fullSrc = joinPath(srcDir, srcFile); |
| | | int srcFd = OpenTransientFile(fullSrc.c_str(), O_RDONLY | PG_BINARY); |
| | | bool success = false; |
| | | |
| | | if (srcFd < 0) { |
| | | ereport(ERROR, (errmsg("could not open source file \"%s\": %m", fullSrc.c_str()))); |
| | | } |
| | | |
| | | if (SPI_connect() != SPI_OK_CONNECT) { |
| | | closeTransientFileIfOpened(srcFd); |
| | | ereport(ERROR, (errmsg("SPI connect failed"))); |
| | | } |
| | | |
| | | char buffer[kRemoteWriteChunkSize]; |
| | | int64 offset = 0; |
| | | |
| | | PG_TRY(); |
| | | { |
| | | ssize_t nread = 0; |
| | | |
| | | while ((nread = read(srcFd, buffer, sizeof(buffer))) > 0) { |
| | | CHECK_FOR_INTERRUPTS(); |
| | | |
| | | const int hexLen = static_cast<int>(nread) * 2; |
| | | char* const hexData = static_cast<char*>(palloc(hexLen + 1)); |
| | | hex_encode(buffer, nread, hexData); |
| | | hexData[hexLen] = '\0'; |
| | | |
| | | char* const remoteSql = psprintf( |
| | | "DO $$ BEGIN PERFORM write_file_chunk(%s, %s, decode('%s', 'hex'), %lld); END $$", |
| | | quote_literal_cstr(dstDir), |
| | | quote_literal_cstr(dstFile), |
| | | hexData, |
| | | static_cast<long long>(offset)); |
| | | |
| | | char* const dblinkSql = psprintf("SELECT dblink_exec(%s, %s)", |
| | | quote_literal_cstr(connName), |
| | | quote_literal_cstr(remoteSql)); |
| | | |
| | | if (SPI_execute(dblinkSql, false, 0) != SPI_OK_SELECT) { |
| | | pfree(dblinkSql); |
| | | pfree(remoteSql); |
| | | pfree(hexData); |
| | | ereport(ERROR, (errmsg("remote write failed via dblink"))); |
| | | } |
| | | |
| | | offset += nread; |
| | | |
| | | pfree(dblinkSql); |
| | | pfree(remoteSql); |
| | | pfree(hexData); |
| | | } |
| | | |
| | | if (nread < 0) { |
| | | ereport(ERROR, |
| | | (errcode_for_file_access(), |
| | | errmsg("could not read from file \"%s\": %m", fullSrc.c_str()))); |
| | | } |
| | | |
| | | closeTransientFileIfOpened(srcFd); |
| | | success = true; |
| | | } |
| | | PG_CATCH(); |
| | | { |
| | | closeTransientFileIfOpened(srcFd); |
| | | |
| | | if (!success) { |
| | | char* const rmSql = psprintf( |
| | | "DO $$ BEGIN PERFORM pg_file_unlink_custom(%s || '/' || %s); EXCEPTION WHEN OTHERS THEN NULL; END $$", |
| | | quote_literal_cstr(dstDir), |
| | | quote_literal_cstr(dstFile)); |
| | | |
| | | char* const dblinkRm = psprintf("SELECT dblink_exec(%s, %s)", |
| | | quote_literal_cstr(connName), |
| | | quote_literal_cstr(rmSql)); |
| | | |
| | | SPI_execute(dblinkRm, false, 0); |
| | | pfree(dblinkRm); |
| | | pfree(rmSql); |
| | | } |
| | | |
| | | SPI_finish(); |
| | | PG_RE_THROW(); |
| | | } |
| | | PG_END_TRY(); |
| | | |
| | | SPI_finish(); |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | extern "C" Datum |
| | | read_file_chunk(PG_FUNCTION_ARGS) |
| | | { |
| | | const char* const dir = TextDatumGetCString(PG_GETARG_DATUM(0)); |
| | | const char* const filename = TextDatumGetCString(PG_GETARG_DATUM(1)); |
| | | const int64 offset = PG_GETARG_INT64(2); |
| | | const int32 limit = PG_GETARG_INT32(3); |
| | | |
| | | if (limit <= 0) { |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | const std::string fullPath = joinPath(dir, filename); |
| | | bytea* result = nullptr; |
| | | int fd = -1; |
| | | |
| | | PG_TRY(); |
| | | { |
| | | fd = OpenTransientFile(fullPath.c_str(), O_RDONLY | PG_BINARY); |
| | | if (fd < 0) { |
| | | ereport(ERROR, |
| | | (errcode_for_file_access(), |
| | | errmsg("could not open file \"%s\": %m", fullPath.c_str()))); |
| | | } |
| | | |
| | | if (lseek(fd, offset, SEEK_SET) < 0) { |
| | | ereport(ERROR, |
| | | (errcode_for_file_access(), |
| | | errmsg("could not seek to offset %lld in file \"%s\": %m", |
| | | static_cast<long long>(offset), |
| | | fullPath.c_str()))); |
| | | } |
| | | |
| | | result = static_cast<bytea*>(palloc(limit + VARHDRSZ)); |
| | | |
| | | const ssize_t nread = read(fd, VARDATA(result), limit); |
| | | if (nread < 0) { |
| | | ereport(ERROR, |
| | | (errcode_for_file_access(), |
| | | errmsg("could not read file \"%s\": %m", fullPath.c_str()))); |
| | | } |
| | | |
| | | SET_VARSIZE(result, static_cast<int>(nread) + VARHDRSZ); |
| | | closeTransientFileIfOpened(fd); |
| | | } |
| | | PG_CATCH(); |
| | | { |
| | | closeTransientFileIfOpened(fd); |
| | | PG_RE_THROW(); |
| | | } |
| | | PG_END_TRY(); |
| | | |
| | | PG_RETURN_BYTEA_P(result); |
| | | } |
| | | |
| | | extern "C" Datum |
| | | write_file_chunk(PG_FUNCTION_ARGS) |
| | | { |
| | | const char* const dir = TextDatumGetCString(PG_GETARG_DATUM(0)); |
| | | const char* const filename = TextDatumGetCString(PG_GETARG_DATUM(1)); |
| | | const bytea* const data = PG_GETARG_BYTEA_PP(2); |
| | | const int64 offset = PG_GETARG_INT64(3); |
| | | |
| | | const std::string fullPath = joinPath(dir, filename); |
| | | const int len = VARSIZE_ANY_EXHDR(data); |
| | | const char* const dataPtr = VARDATA_ANY(data); |
| | | int fd = -1; |
| | | |
| | | PG_TRY(); |
| | | { |
| | | int flags = O_WRONLY | PG_BINARY; |
| | | if (offset == 0) { |
| | | flags |= O_CREAT | O_TRUNC; |
| | | } |
| | | |
| | | fd = OpenTransientFile(fullPath.c_str(), flags); |
| | | if (fd < 0) { |
| | | ereport(ERROR, |
| | | (errcode_for_file_access(), |
| | | errmsg("could not open file \"%s\": %m", fullPath.c_str()))); |
| | | } |
| | | |
| | | if (lseek(fd, offset, SEEK_SET) < 0) { |
| | | ereport(ERROR, |
| | | (errcode_for_file_access(), |
| | | errmsg("seek failed in \"%s\": %m", fullPath.c_str()))); |
| | | } |
| | | |
| | | if (write(fd, dataPtr, len) != len) { |
| | | ereport(ERROR, |
| | | (errcode_for_file_access(), |
| | | errmsg("write failed in \"%s\": %m", fullPath.c_str()))); |
| | | } |
| | | |
| | | closeTransientFileIfOpened(fd); |
| | | } |
| | | PG_CATCH(); |
| | | { |
| | | closeTransientFileIfOpened(fd); |
| | | PG_RE_THROW(); |
| | | } |
| | | PG_END_TRY(); |
| | | |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | extern "C" Datum |
| | | pg_file_unlink_custom(PG_FUNCTION_ARGS) |
| | | { |
| | | const char* const filename = TextDatumGetCString(PG_GETARG_DATUM(0)); |
| | | |
| | | if (unlink(filename) < 0 && errno != ENOENT) { |
| | | ereport(WARNING, (errmsg("could not remove file \"%s\": %m", filename))); |
| | | } |
| | | |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | extern "C" Datum |
| | | dbms_file_transfer_get_version(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_TEXT_P(cstring_to_text(RUDB_DBMS_FILE_TRANSFER_VERSION)); |
| | | } |
| New file |
| | |
| | | #ifndef DBMS_FILE_TRANSFER_HPP |
| | | #define DBMS_FILE_TRANSFER_HPP |
| | | |
| | | extern "C" { |
| | | #include "postgres.h" |
| | | #include "fmgr.h" |
| | | } |
| | | |
| | | /* |
| | | * DBMS_FILE_TRANSFER |
| | | * |
| | | * Назначение: |
| | | * Пакет предоставляет совместимые с Oracle функции копирования файлов |
| | | * между локальными каталогами и удалёнными серверами через dblink, а |
| | | * также вспомогательные функции для чтения и записи файлов по частям. |
| | | */ |
| | | |
| | | extern "C" { |
| | | /** |
| | | * @brief Копирует файл из одной локальной директории в другую. |
| | | * @details Automatic Storage Management (ASM) не поддерживается. |
| | | * Примеры: |
| | | * SELECT DBMS_FILE_TRANSFER.COPY_FILE('/tmp/src', 'a.bin', '/tmp/dst', 'b.bin') FROM dual; |
| | | * SELECT DBMS_FILE_TRANSFER.COPY_FILE('/var/lib/rudb/in', 'one.dat', '/var/lib/rudb/out', 'two.dat') FROM dual; |
| | | * @param source_directory Объект DIRECTORY или путь к исходной директории. |
| | | * @param source_file_name Имя исходного файла. |
| | | * @param destination_directory Объект DIRECTORY или путь к целевой директории. |
| | | * @param destination_file_name Имя целевого файла. |
| | | * @return `void`. |
| | | */ |
| | | Datum dbms_file_transfer_copy_file(PG_FUNCTION_ARGS); |
| | | |
| | | /** |
| | | * @brief Проверяет, что имя файла допустимо для операций передачи файлов. |
| | | * @details Допускаются только непустые относительные имена без разделителей |
| | | * путей и переходов к родительскому каталогу. |
| | | * Примеры: |
| | | * SELECT dbms_file_transfer_is_safe_filename('sample.txt'); |
| | | * SELECT dbms_file_transfer_is_safe_filename('../sample.txt'); |
| | | * SELECT dbms_file_transfer_is_safe_filename('/tmp/sample.txt'); |
| | | * @param filename Имя файла без пути. |
| | | * @return `true`, если имя файла безопасно для передачи. |
| | | */ |
| | | Datum dbms_file_transfer_is_safe_filename(PG_FUNCTION_ARGS); |
| | | |
| | | /** |
| | | * @brief Копирует файл с удалённой базы данных в локальную файловую систему. |
| | | * @details Для удалённой стороны используется уже открытое соединение `dblink`. |
| | | * Automatic Storage Management (ASM) не поддерживается. |
| | | * Примеры: |
| | | * SELECT dblink_connect('my_remote_db', 'host=127.0.0.1 port=5444 user=SYSDBA dbname=qdb'); |
| | | * SELECT DBMS_FILE_TRANSFER.GET_FILE('/tmp/remote_dir', 'source.dat', 'my_remote_db', '/tmp/local_dir', 'copied.dat') FROM dual; |
| | | * SELECT dblink_disconnect('my_remote_db'); |
| | | * @param source_directory Путь к директории на удалённой стороне. |
| | | * @param source_file_name Имя исходного файла на удалённой стороне. |
| | | * @param source_database Имя открытого соединения `dblink`. |
| | | * @param destination_directory Путь к локальной директории назначения. |
| | | * @param destination_file_name Имя локального файла назначения. |
| | | * @return `void`. |
| | | */ |
| | | Datum dbms_file_transfer_get_file(PG_FUNCTION_ARGS); |
| | | |
| | | /** |
| | | * @brief Копирует файл с локальной файловой системы в удалённую базу данных. |
| | | * @details Для удалённой стороны используется уже открытое соединение `dblink`. |
| | | * Automatic Storage Management (ASM) не поддерживается. |
| | | * Примеры: |
| | | * SELECT dblink_connect('my_link', 'host=127.0.0.1 port=5444 user=SYSDBA dbname=qdb'); |
| | | * SELECT DBMS_FILE_TRANSFER.PUT_FILE('/tmp/put_src', 'original.dat', 'my_link', '/tmp/put_dst', 'delivered.dat') FROM dual; |
| | | * SELECT dblink_disconnect('my_link'); |
| | | * @param source_directory Путь к локальной исходной директории. |
| | | * @param source_file_name Имя локального исходного файла. |
| | | * @param destination_database Имя открытого соединения `dblink`. |
| | | * @param destination_directory Путь к директории на удалённой стороне. |
| | | * @param destination_file_name Имя файла назначения на удалённой стороне. |
| | | * @return `void`. |
| | | */ |
| | | Datum dbms_file_transfer_put_file(PG_FUNCTION_ARGS); |
| | | |
| | | /** |
| | | * @brief Считывает часть файла по смещению и размеру. |
| | | * @details Вспомогательная функция для `DBMS_FILE_TRANSFER.GET_FILE`. |
| | | * Примеры: |
| | | * SELECT encode(read_file_chunk('/tmp/src', 'a.bin', 0, 16), 'hex'); |
| | | * SELECT read_file_chunk('/tmp/src', 'a.bin', 0, 0) IS NULL; |
| | | * @param directory Путь к директории с файлом. |
| | | * @param file_name Имя файла. |
| | | * @param offset Смещение от начала файла в байтах. |
| | | * @param limit Максимальное число считываемых байт. |
| | | * @return `bytea`. |
| | | */ |
| | | Datum read_file_chunk(PG_FUNCTION_ARGS); |
| | | |
| | | /** |
| | | * @brief Записывает часть данных в файл по указанному смещению. |
| | | * @details Вспомогательная функция для `DBMS_FILE_TRANSFER.PUT_FILE`. |
| | | * Примеры: |
| | | * SELECT write_file_chunk('/tmp/dst', 'a.bin', decode('0102', 'hex'), 0); |
| | | * SELECT write_file_chunk('/tmp/dst', 'a.bin', decode('0304', 'hex'), 2); |
| | | * @param directory Путь к директории с файлом. |
| | | * @param file_name Имя файла. |
| | | * @param data Блок данных для записи. |
| | | * @param offset Смещение от начала файла в байтах. |
| | | * @return `void`. |
| | | */ |
| | | Datum write_file_chunk(PG_FUNCTION_ARGS); |
| | | |
| | | /** |
| | | * @brief Удаляет файл из файловой системы. |
| | | * @details Вспомогательная функция для очистки частично переданного файла. |
| | | * Примеры: |
| | | * SELECT pg_file_unlink_custom('/tmp/dst/a.bin'); |
| | | * SELECT pg_file_unlink_custom('/tmp/dst/missing.bin'); |
| | | * @param full_path Полный путь к удаляемому файлу. |
| | | * @return `void`. |
| | | */ |
| | | Datum pg_file_unlink_custom(PG_FUNCTION_ARGS); |
| | | |
| | | /** |
| | | * @brief Возвращает версию пакета DBMS_FILE_TRANSFER. |
| | | * @details Возвращает строку версии реализации RUDB для SQL-visible API пакета. |
| | | * Примеры: |
| | | * SELECT DBMS_FILE_TRANSFER.GET_VERSION() FROM dual; |
| | | * SELECT dbms_file_transfer_get_version(); |
| | | * @return Текст версии пакета. |
| | | */ |
| | | Datum dbms_file_transfer_get_version(PG_FUNCTION_ARGS); |
| | | } |
| | | |
| | | #endif // DBMS_FILE_TRANSFER_HPP |
| New file |
| | |
| | | #include "dbms_json.hpp" |
| | | |
| | | extern "C" |
| | | { |
| | | #include "access/htup_details.h" |
| | | #include "catalog/namespace.h" |
| | | #include "executor/spi.h" |
| | | #include "funcapi.h" |
| | | #include "nodes/makefuncs.h" |
| | | #include "nodes/pg_list.h" |
| | | #include "port.h" |
| | | #include "parser/scansup.h" |
| | | #include "utils/builtins.h" |
| | | #include "utils/elog.h" |
| | | #include "utils/jsonb.h" |
| | | #include "utils/lsyscache.h" |
| | | #include "utils/numeric.h" |
| | | #include "utils/regproc.h" |
| | | #include "utils/varlena.h" |
| | | } |
| | | |
| | | #include <cctype> |
| | | #include <cstring> |
| | | #include <set> |
| | | #include <string> |
| | | #include <vector> |
| | | |
| | | extern "C" |
| | | { |
| | | PG_FUNCTION_INFO_V1(dbms_json_build_dataguide); |
| | | PG_FUNCTION_INFO_V1(dbms_json_get_index_dataguide); |
| | | PG_FUNCTION_INFO_V1(dbms_json_get_view_sql); |
| | | PG_FUNCTION_INFO_V1(dbms_json_add_virtual_columns); |
| | | PG_FUNCTION_INFO_V1(dbms_json_create_view); |
| | | PG_FUNCTION_INFO_V1(dbms_json_create_view2); |
| | | PG_FUNCTION_INFO_V1(dbms_json_drop_virtual_columns); |
| | | PG_FUNCTION_INFO_V1(dbms_json_json_type_convertible_check); |
| | | PG_FUNCTION_INFO_V1(dbms_json_rename_column); |
| | | PG_FUNCTION_INFO_V1(dbms_json_create_view_on_path); |
| | | } |
| | | |
| | | #define DBMS_JSON_MV_REFRESH_ON_STATEMENT 1 |
| | | #define DBMS_JSON_TYPE_NULL 1 |
| | | #define DBMS_JSON_TYPE_STRING 2 |
| | | #define DBMS_JSON_TYPE_NUMBER 3 |
| | | #define DBMS_JSON_TYPE_BOOLEAN 4 |
| | | #define DBMS_JSON_TYPE_OBJECT 5 |
| | | #define DBMS_JSON_TYPE_ARRAY 6 |
| | | |
| | | namespace DbmsJson |
| | | { |
| | | struct ColumnSpec |
| | | { |
| | | std::string jsonFieldName_; |
| | | std::string columnName_; |
| | | std::string columnType_; |
| | | }; |
| | | |
| | | struct GuideEntry |
| | | { |
| | | std::string path_; |
| | | std::string jsonType_; |
| | | std::string columnName_; |
| | | std::string columnType_; |
| | | }; |
| | | |
| | | static JsonbValue * |
| | | getobjectfield(JsonbContainer *container, const char *field_name, JsonbValue *value_buffer) |
| | | { |
| | | if (container == nullptr || !JsonContainerIsObject(container)) { |
| | | return nullptr; |
| | | } |
| | | |
| | | return getKeyJsonValueFromContainer(container, |
| | | field_name, |
| | | strlen(field_name), |
| | | value_buffer); |
| | | } |
| | | |
| | | static std::string |
| | | jsonbvaluetostring(const JsonbValue *json_value) |
| | | { |
| | | char *valueCString = nullptr; |
| | | std::string resultValue; |
| | | |
| | | if (json_value == nullptr) { |
| | | return resultValue; |
| | | } |
| | | |
| | | switch (json_value->type) { |
| | | case jbvString: |
| | | return std::string(json_value->val.string.val, json_value->val.string.len); |
| | | case jbvBinary: |
| | | valueCString = JsonbToCString(nullptr, |
| | | json_value->val.binary.data, |
| | | json_value->val.binary.len); |
| | | resultValue = valueCString == nullptr ? "" : std::string(valueCString); |
| | | if (valueCString != nullptr) { |
| | | pfree(valueCString); |
| | | } |
| | | return resultValue; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | return resultValue; |
| | | } |
| | | |
| | | static int32 |
| | | jsonbvaluetoint32(const JsonbValue *json_value, int32 default_value) |
| | | { |
| | | if (json_value == nullptr) { |
| | | return default_value; |
| | | } |
| | | |
| | | if (json_value->type != jbvNumeric) { |
| | | return default_value; |
| | | } |
| | | |
| | | return numeric_int4_opt_error(json_value->val.numeric, nullptr); |
| | | } |
| | | |
| | | static std::string |
| | | normalizesqlidentifier(const std::string &identifier_value, bool mixed_case_columns) |
| | | { |
| | | std::string normalizedValue = identifier_value; |
| | | |
| | | if (mixed_case_columns) { |
| | | return normalizedValue; |
| | | } |
| | | |
| | | for (char ¤tChar : normalizedValue) { |
| | | currentChar = static_cast<char>(pg_tolower(static_cast<unsigned char>(currentChar))); |
| | | } |
| | | |
| | | return normalizedValue; |
| | | } |
| | | |
| | | static std::string |
| | | normalizepath(const std::string &path_value) |
| | | { |
| | | if (path_value.empty() || path_value == "$") { |
| | | return "$[*]"; |
| | | } |
| | | |
| | | if (path_value.size() >= 3 && |
| | | path_value.compare(path_value.size() - 3, 3, "[*]") == 0) { |
| | | return path_value; |
| | | } |
| | | |
| | | return path_value + "[*]"; |
| | | } |
| | | |
| | | static std::string |
| | | trimrootpath(const std::string &path_value) |
| | | { |
| | | if (path_value == "$") { |
| | | return ""; |
| | | } |
| | | |
| | | if (path_value.rfind("$.", 0) == 0) { |
| | | return path_value.substr(2); |
| | | } |
| | | |
| | | return path_value; |
| | | } |
| | | |
| | | static std::string |
| | | joinpath(const std::string &base_path, const std::string &field_name) |
| | | { |
| | | if (base_path.empty()) { |
| | | return "$." + field_name; |
| | | } |
| | | |
| | | return base_path + "." + field_name; |
| | | } |
| | | |
| | | static bool |
| | | ispathunderroot(const std::string &full_path, const std::string &root_path) |
| | | { |
| | | if (root_path == "$" || root_path.empty()) { |
| | | return true; |
| | | } |
| | | |
| | | if (full_path == root_path) { |
| | | return true; |
| | | } |
| | | |
| | | return full_path.rfind(root_path + ".", 0) == 0; |
| | | } |
| | | |
| | | static std::string |
| | | makerelativepath(const std::string &full_path, const std::string &root_path) |
| | | { |
| | | std::string rootPrefix = trimrootpath(root_path); |
| | | std::string fullPrefix = trimrootpath(full_path); |
| | | |
| | | if (rootPrefix.empty()) { |
| | | return fullPrefix; |
| | | } |
| | | |
| | | if (fullPrefix == rootPrefix) { |
| | | return ""; |
| | | } |
| | | |
| | | if (fullPrefix.rfind(rootPrefix + ".", 0) == 0) { |
| | | return fullPrefix.substr(rootPrefix.size() + 1); |
| | | } |
| | | |
| | | return fullPrefix; |
| | | } |
| | | |
| | | static std::string |
| | | buildjsonpathfromrelative(const std::string &relative_path) |
| | | { |
| | | if (relative_path.empty()) { |
| | | return "$"; |
| | | } |
| | | |
| | | return "$." + relative_path; |
| | | } |
| | | |
| | | static std::string |
| | | buildqualifiedname(const std::string &owner_name, const std::string &object_name) |
| | | { |
| | | return std::string(quote_identifier(owner_name.c_str())) + "." + |
| | | quote_identifier(object_name.c_str()); |
| | | } |
| | | |
| | | static std::string |
| | | buildmetadataqualifiedname(const std::string &owner_name) |
| | | { |
| | | return buildqualifiedname(owner_name, "dbms_json_metadata"); |
| | | } |
| | | |
| | | static std::string |
| | | resolveownername() |
| | | { |
| | | List *searchPath = fetch_search_path(false); |
| | | |
| | | if (searchPath != NIL) { |
| | | Oid schemaOid = linitial_oid(searchPath); |
| | | char *schemaName = get_namespace_name(schemaOid); |
| | | |
| | | if (schemaName != nullptr && strcmp(schemaName, "pg_catalog") != 0) { |
| | | return std::string(schemaName); |
| | | } |
| | | } |
| | | |
| | | return "public"; |
| | | } |
| | | |
| | | static std::string |
| | | normalizeidentifierinput(const std::string &identifier_value) |
| | | { |
| | | char *normalizedIdentifier = downcase_identifier(identifier_value.c_str(), |
| | | identifier_value.length(), |
| | | false, |
| | | false); |
| | | std::string normalizedValue = normalizedIdentifier == nullptr |
| | | ? std::string() |
| | | : std::string(normalizedIdentifier); |
| | | |
| | | if (normalizedIdentifier != nullptr) { |
| | | pfree(normalizedIdentifier); |
| | | } |
| | | |
| | | return normalizedValue; |
| | | } |
| | | |
| | | static Oid |
| | | resolvetablerelid(const std::string &table_name) |
| | | { |
| | | text *tableNameText = cstring_to_text(table_name.c_str()); |
| | | List *nameList = textToQualifiedNameList(tableNameText); |
| | | Oid relationOid = InvalidOid; |
| | | |
| | | if (list_length(nameList) == 1) { |
| | | char *relationName = pstrdup(table_name.c_str()); |
| | | List *searchPath = fetch_search_path(false); |
| | | ListCell *searchPathCell; |
| | | |
| | | foreach(searchPathCell, searchPath) { |
| | | Oid namespaceOid = lfirst_oid(searchPathCell); |
| | | |
| | | relationOid = get_relname_relid(relationName, namespaceOid); |
| | | if (relationOid == InvalidOid) { |
| | | char *normalizedRelationName = downcase_identifier(relationName, |
| | | strlen(relationName), |
| | | false, |
| | | false); |
| | | relationOid = get_relname_relid(normalizedRelationName, namespaceOid); |
| | | pfree(normalizedRelationName); |
| | | } |
| | | |
| | | if (relationOid != InvalidOid) { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | list_free(searchPath); |
| | | pfree(relationName); |
| | | } else if (list_length(nameList) == 2) { |
| | | char *schemaName = pstrdup(strVal(linitial(nameList))); |
| | | char *relationName = pstrdup(strVal(lsecond(nameList))); |
| | | Oid namespaceOid = get_namespace_oid(schemaName, true); |
| | | |
| | | if (namespaceOid == InvalidOid) { |
| | | char *normalizedSchemaName = downcase_identifier(schemaName, |
| | | strlen(schemaName), |
| | | false, |
| | | false); |
| | | namespaceOid = get_namespace_oid(normalizedSchemaName, true); |
| | | pfree(normalizedSchemaName); |
| | | } |
| | | |
| | | if (namespaceOid != InvalidOid) { |
| | | relationOid = get_relname_relid(relationName, namespaceOid); |
| | | |
| | | if (relationOid == InvalidOid) { |
| | | char *normalizedRelationName = downcase_identifier(relationName, |
| | | strlen(relationName), |
| | | false, |
| | | false); |
| | | relationOid = get_relname_relid(normalizedRelationName, namespaceOid); |
| | | pfree(normalizedRelationName); |
| | | } |
| | | } |
| | | |
| | | pfree(schemaName); |
| | | pfree(relationName); |
| | | } |
| | | |
| | | pfree(tableNameText); |
| | | list_free_deep(nameList); |
| | | |
| | | if (relationOid == InvalidOid) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_UNDEFINED_TABLE), |
| | | errmsg("relation does not exist"), |
| | | errdetail("tablename=%s", table_name.c_str()))); |
| | | } |
| | | |
| | | return relationOid; |
| | | } |
| | | |
| | | static Oid |
| | | resolvetablerelid(const std::string &owner_name, const std::string &table_name) |
| | | { |
| | | std::string qualifiedName = normalizeidentifierinput(owner_name) + "." + |
| | | normalizeidentifierinput(table_name); |
| | | |
| | | return resolvetablerelid(qualifiedName); |
| | | } |
| | | |
| | | static std::string |
| | | resolverelationownername(Oid relation_oid) |
| | | { |
| | | Oid namespaceOid = get_rel_namespace(relation_oid); |
| | | char *namespaceName = get_namespace_name(namespaceOid); |
| | | |
| | | if (namespaceName == nullptr) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_UNDEFINED_SCHEMA), |
| | | errmsg("relation schema does not exist"), |
| | | errdetail("relation_oid=%u", relation_oid))); |
| | | } |
| | | |
| | | return std::string(namespaceName); |
| | | } |
| | | |
| | | static std::string |
| | | resolverelationname(Oid relation_oid) |
| | | { |
| | | char *relationName = get_rel_name(relation_oid); |
| | | |
| | | if (relationName == nullptr) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_UNDEFINED_TABLE), |
| | | errmsg("relation name does not exist"), |
| | | errdetail("relation_oid=%u", relation_oid))); |
| | | } |
| | | |
| | | return std::string(relationName); |
| | | } |
| | | |
| | | static std::string |
| | | resolvecolumnname(Oid relation_oid, const std::string &column_name) |
| | | { |
| | | AttrNumber attributeNumber = get_attnum(relation_oid, column_name.c_str()); |
| | | char *resolvedName = nullptr; |
| | | |
| | | if (attributeNumber == InvalidAttrNumber) { |
| | | std::string normalizedName = normalizeidentifierinput(column_name); |
| | | |
| | | if (normalizedName != column_name) { |
| | | attributeNumber = get_attnum(relation_oid, normalizedName.c_str()); |
| | | } |
| | | } |
| | | |
| | | if (attributeNumber == InvalidAttrNumber) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_UNDEFINED_COLUMN), |
| | | errmsg("column does not exist"), |
| | | errdetail("column_name=%s", column_name.c_str()))); |
| | | } |
| | | |
| | | resolvedName = get_attname(relation_oid, attributeNumber, false); |
| | | if (resolvedName == nullptr) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_UNDEFINED_COLUMN), |
| | | errmsg("column name does not exist"), |
| | | errdetail("relation_oid=%u, column_name=%s", |
| | | relation_oid, |
| | | column_name.c_str()))); |
| | | } |
| | | |
| | | return std::string(resolvedName); |
| | | } |
| | | |
| | | static std::string |
| | | resolvetableownername(const std::string &table_name) |
| | | { |
| | | Oid relationOid = resolvetablerelid(table_name); |
| | | |
| | | return resolverelationownername(relationOid); |
| | | } |
| | | |
| | | static std::string |
| | | resolvetableownername(const std::string &owner_name, const std::string &table_name) |
| | | { |
| | | Oid relationOid = resolvetablerelid(owner_name, table_name); |
| | | |
| | | return resolverelationownername(relationOid); |
| | | } |
| | | |
| | | static std::string |
| | | resolvetablename(const std::string &table_name) |
| | | { |
| | | Oid relationOid = resolvetablerelid(table_name); |
| | | |
| | | return resolverelationname(relationOid); |
| | | } |
| | | |
| | | static std::string |
| | | resolvetablename(const std::string &owner_name, const std::string &table_name) |
| | | { |
| | | Oid relationOid = resolvetablerelid(owner_name, table_name); |
| | | |
| | | return resolverelationname(relationOid); |
| | | } |
| | | |
| | | static std::string |
| | | resolvejsoncolumnname(const std::string &table_name, const std::string &column_name) |
| | | { |
| | | Oid relationOid = resolvetablerelid(table_name); |
| | | |
| | | return resolvecolumnname(relationOid, column_name); |
| | | } |
| | | |
| | | static std::string |
| | | resolvejsoncolumnname(const std::string &owner_name, |
| | | const std::string &table_name, |
| | | const std::string &column_name) |
| | | { |
| | | Oid relationOid = resolvetablerelid(owner_name, table_name); |
| | | |
| | | return resolvecolumnname(relationOid, column_name); |
| | | } |
| | | |
| | | static std::string |
| | | resolvestatusname(const std::string &status_table_name) |
| | | { |
| | | return normalizeidentifierinput(status_table_name); |
| | | } |
| | | |
| | | static void |
| | | normalizeexistingtableandcolumn(const std::string &table_name, |
| | | const std::string &column_name, |
| | | std::string *owner_name, |
| | | std::string *normalized_table_name, |
| | | std::string *normalized_column_name) |
| | | { |
| | | Oid relationOid = resolvetablerelid(table_name); |
| | | |
| | | *owner_name = resolverelationownername(relationOid); |
| | | *normalized_table_name = resolverelationname(relationOid); |
| | | *normalized_column_name = resolvecolumnname(relationOid, column_name); |
| | | } |
| | | |
| | | static void |
| | | normalizeexistingtableandcolumn(const std::string &owner_name, |
| | | const std::string &table_name, |
| | | const std::string &column_name, |
| | | std::string *normalized_owner_name, |
| | | std::string *normalized_table_name, |
| | | std::string *normalized_column_name) |
| | | { |
| | | Oid relationOid = resolvetablerelid(owner_name, table_name); |
| | | |
| | | *normalized_owner_name = resolverelationownername(relationOid); |
| | | *normalized_table_name = resolverelationname(relationOid); |
| | | *normalized_column_name = resolvecolumnname(relationOid, column_name); |
| | | } |
| | | |
| | | static std::string |
| | | resolvecolumntype(JsonbContainer *column_guide) |
| | | { |
| | | JsonbValue typeBuffer; |
| | | JsonbValue lengthBuffer; |
| | | JsonbValue *typeValue = getobjectfield(column_guide, "type", &typeBuffer); |
| | | JsonbValue *lengthValue = getobjectfield(column_guide, "o:length", &lengthBuffer); |
| | | std::string typeName = jsonbvaluetostring(typeValue); |
| | | int32 columnLength = jsonbvaluetoint32(lengthValue, 0); |
| | | |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON resolve column type"), |
| | | errdetail("json_type=%s, length=%d", |
| | | typeName.c_str(), |
| | | columnLength))); |
| | | |
| | | if (typeName == "number") { |
| | | return "number"; |
| | | } |
| | | |
| | | if (typeName == "string") { |
| | | if (columnLength > 0) { |
| | | return "varchar2(" + std::to_string(columnLength) + ")"; |
| | | } |
| | | |
| | | return "varchar2(4000)"; |
| | | } |
| | | |
| | | if (typeName == "integer") { |
| | | return "number"; |
| | | } |
| | | |
| | | if (typeName == "boolean") { |
| | | return "varchar2(5)"; |
| | | } |
| | | |
| | | if (typeName == "null") { |
| | | return "varchar2(4)"; |
| | | } |
| | | |
| | | return ""; |
| | | } |
| | | |
| | | static std::string |
| | | resolvecolumntypefromname(const std::string &json_type) |
| | | { |
| | | if (json_type == "number" || json_type == "integer") { |
| | | return "numeric"; |
| | | } |
| | | |
| | | if (json_type == "boolean") { |
| | | return "boolean"; |
| | | } |
| | | |
| | | if (json_type == "string" || json_type == "null") { |
| | | return "text"; |
| | | } |
| | | |
| | | return ""; |
| | | } |
| | | |
| | | static bool |
| | | isscalarjsonbvalue(const JsonbValue *json_value) |
| | | { |
| | | if (json_value == nullptr) { |
| | | return false; |
| | | } |
| | | |
| | | switch (json_value->type) { |
| | | case jbvString: |
| | | case jbvNumeric: |
| | | case jbvBool: |
| | | case jbvNull: |
| | | return true; |
| | | default: |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | static std::string |
| | | resolvejsontypename(const JsonbValue *json_value) |
| | | { |
| | | if (json_value == nullptr) { |
| | | return ""; |
| | | } |
| | | |
| | | switch (json_value->type) { |
| | | case jbvString: |
| | | return "string"; |
| | | case jbvNumeric: |
| | | return "number"; |
| | | case jbvBool: |
| | | return "boolean"; |
| | | case jbvNull: |
| | | return "null"; |
| | | default: |
| | | return ""; |
| | | } |
| | | } |
| | | |
| | | static std::string |
| | | resolvejsontypenamefromcode(int32 type_code) |
| | | { |
| | | switch (type_code) { |
| | | case DBMS_JSON_TYPE_NULL: |
| | | return "null"; |
| | | case DBMS_JSON_TYPE_STRING: |
| | | return "string"; |
| | | case DBMS_JSON_TYPE_NUMBER: |
| | | return "number"; |
| | | case DBMS_JSON_TYPE_BOOLEAN: |
| | | return "boolean"; |
| | | case DBMS_JSON_TYPE_OBJECT: |
| | | return "object"; |
| | | case DBMS_JSON_TYPE_ARRAY: |
| | | return "array"; |
| | | default: |
| | | return ""; |
| | | } |
| | | } |
| | | |
| | | static void |
| | | appendguideentry(JsonbParseState **parse_state, |
| | | const std::string &path_value, |
| | | const std::string &json_type, |
| | | const std::string &column_name) |
| | | { |
| | | JsonbValue keyValue; |
| | | JsonbValue valueValue; |
| | | |
| | | (void) pushJsonbValue(parse_state, WJB_BEGIN_OBJECT, nullptr); |
| | | |
| | | keyValue.type = jbvString; |
| | | keyValue.val.string.val = const_cast<char *>("path"); |
| | | keyValue.val.string.len = 4; |
| | | valueValue.type = jbvString; |
| | | valueValue.val.string.val = pstrdup(path_value.c_str()); |
| | | valueValue.val.string.len = path_value.size(); |
| | | (void) pushJsonbValue(parse_state, WJB_KEY, &keyValue); |
| | | (void) pushJsonbValue(parse_state, WJB_VALUE, &valueValue); |
| | | |
| | | keyValue.val.string.val = const_cast<char *>("type"); |
| | | keyValue.val.string.len = 4; |
| | | valueValue.val.string.val = pstrdup(json_type.c_str()); |
| | | valueValue.val.string.len = json_type.size(); |
| | | (void) pushJsonbValue(parse_state, WJB_KEY, &keyValue); |
| | | (void) pushJsonbValue(parse_state, WJB_VALUE, &valueValue); |
| | | |
| | | keyValue.val.string.val = const_cast<char *>("column"); |
| | | keyValue.val.string.len = 6; |
| | | valueValue.val.string.val = pstrdup(column_name.c_str()); |
| | | valueValue.val.string.len = column_name.size(); |
| | | (void) pushJsonbValue(parse_state, WJB_KEY, &keyValue); |
| | | (void) pushJsonbValue(parse_state, WJB_VALUE, &valueValue); |
| | | |
| | | (void) pushJsonbValue(parse_state, WJB_END_OBJECT, nullptr); |
| | | } |
| | | |
| | | static void |
| | | collectguideentries(JsonbContainer *container, |
| | | const std::string &base_path, |
| | | JsonbParseState **parse_state) |
| | | { |
| | | JsonbIterator *iterator = JsonbIteratorInit(container); |
| | | JsonbValue iteratorValue; |
| | | JsonbIteratorToken token; |
| | | std::string currentKey; |
| | | |
| | | while ((token = JsonbIteratorNext(&iterator, &iteratorValue, true)) != WJB_DONE) { |
| | | std::string currentPath; |
| | | std::string currentType; |
| | | |
| | | if (token == WJB_KEY) { |
| | | currentKey.assign(iteratorValue.val.string.val, iteratorValue.val.string.len); |
| | | continue; |
| | | } |
| | | |
| | | if (token != WJB_VALUE) { |
| | | continue; |
| | | } |
| | | |
| | | currentPath = joinpath(base_path, currentKey); |
| | | currentType = resolvejsontypename(&iteratorValue); |
| | | |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON.BUILD_DATAGUIDE inspect node"), |
| | | errdetail("path=%s, type=%s", |
| | | currentPath.c_str(), |
| | | currentType.empty() ? "composite" : currentType.c_str()))); |
| | | |
| | | if (isscalarjsonbvalue(&iteratorValue)) { |
| | | appendguideentry(parse_state, |
| | | currentPath, |
| | | currentType, |
| | | normalizesqlidentifier(currentKey, false)); |
| | | continue; |
| | | } |
| | | |
| | | if (iteratorValue.type == jbvBinary && |
| | | JsonContainerIsObject(iteratorValue.val.binary.data)) { |
| | | collectguideentries(iteratorValue.val.binary.data, currentPath, parse_state); |
| | | } |
| | | } |
| | | } |
| | | |
| | | static Jsonb * |
| | | builddataguide(Jsonb *json_value) |
| | | { |
| | | JsonbValue rootValue; |
| | | JsonbParseState *parseState = nullptr; |
| | | JsonbValue *resultValue = nullptr; |
| | | |
| | | JsonbToJsonbValue(json_value, &rootValue); |
| | | |
| | | if (rootValue.type != jbvBinary || |
| | | !JsonContainerIsObject(rootValue.val.binary.data)) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("DBMS_JSON.BUILD_DATAGUIDE expects root JSON object"))); |
| | | } |
| | | |
| | | (void) pushJsonbValue(&parseState, WJB_BEGIN_ARRAY, nullptr); |
| | | collectguideentries(rootValue.val.binary.data, "$", &parseState); |
| | | resultValue = pushJsonbValue(&parseState, WJB_END_ARRAY, nullptr); |
| | | |
| | | return JsonbValueToJsonb(resultValue); |
| | | } |
| | | |
| | | static void |
| | | appendguideentryifmissing(JsonbParseState **parse_state, |
| | | std::set<std::string> *seen_entries, |
| | | const GuideEntry &entry) |
| | | { |
| | | std::string entryKey = entry.path_ + "|" + entry.jsonType_ + "|" + entry.columnName_ + "|" + |
| | | entry.columnType_; |
| | | |
| | | if (seen_entries->find(entryKey) != seen_entries->end()) { |
| | | return; |
| | | } |
| | | |
| | | seen_entries->insert(entryKey); |
| | | appendguideentry(parse_state, entry.path_, entry.jsonType_, entry.columnName_); |
| | | } |
| | | |
| | | static Jsonb * |
| | | buildguidefromentries(const std::vector<GuideEntry> &entries) |
| | | { |
| | | JsonbParseState *parseState = nullptr; |
| | | JsonbValue *resultValue = nullptr; |
| | | std::set<std::string> seenEntries; |
| | | |
| | | (void) pushJsonbValue(&parseState, WJB_BEGIN_ARRAY, nullptr); |
| | | |
| | | for (const GuideEntry &entry : entries) { |
| | | appendguideentryifmissing(&parseState, &seenEntries, entry); |
| | | } |
| | | |
| | | resultValue = pushJsonbValue(&parseState, WJB_END_ARRAY, nullptr); |
| | | return JsonbValueToJsonb(resultValue); |
| | | } |
| | | |
| | | static void |
| | | ensuremetadatatable(const std::string &owner_name) |
| | | { |
| | | int spiStatus = SPI_OK_CONNECT; |
| | | int executeStatus = SPI_OK_UTILITY; |
| | | std::string createSql = |
| | | "CREATE TABLE IF NOT EXISTS " + buildmetadataqualifiedname(owner_name) + " (" |
| | | "tablename text NOT NULL, " |
| | | "jcolname text NOT NULL, " |
| | | "path text NOT NULL, " |
| | | "json_type text NOT NULL, " |
| | | "preferred_name text NOT NULL, " |
| | | "PRIMARY KEY(tablename, jcolname, path, json_type)" |
| | | ")"; |
| | | |
| | | spiStatus = SPI_connect(); |
| | | if (spiStatus != SPI_OK_CONNECT) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("SPI_connect failed in DBMS_JSON metadata initialization"), |
| | | errdetail("spi_status=%d", spiStatus))); |
| | | } |
| | | |
| | | executeStatus = SPI_execute(createSql.c_str(), false, 0); |
| | | if (executeStatus != SPI_OK_UTILITY) { |
| | | SPI_finish(); |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("DBMS_JSON metadata table initialization failed"), |
| | | errdetail("spi_status=%d", executeStatus))); |
| | | } |
| | | |
| | | SPI_finish(); |
| | | } |
| | | |
| | | static void |
| | | applypreferrednames(const std::string &owner_name, |
| | | const std::string &table_name, |
| | | const std::string &json_column_name, |
| | | std::vector<GuideEntry> *entries) |
| | | { |
| | | Oid argTypes[2] = {TEXTOID, TEXTOID}; |
| | | Datum values[2]; |
| | | const char nulls[2] = {' ', ' '}; |
| | | int spiStatus = SPI_OK_CONNECT; |
| | | int executeStatus = SPI_OK_SELECT; |
| | | std::string selectSql = |
| | | "SELECT path, json_type, preferred_name " |
| | | "FROM " + buildmetadataqualifiedname(owner_name) + |
| | | " WHERE tablename = $1 AND jcolname = $2"; |
| | | |
| | | if (entries->empty()) { |
| | | return; |
| | | } |
| | | |
| | | values[0] = CStringGetTextDatum(table_name.c_str()); |
| | | values[1] = CStringGetTextDatum(json_column_name.c_str()); |
| | | |
| | | spiStatus = SPI_connect(); |
| | | if (spiStatus != SPI_OK_CONNECT) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("SPI_connect failed in DBMS_JSON preferred name lookup"), |
| | | errdetail("spi_status=%d", spiStatus))); |
| | | } |
| | | |
| | | executeStatus = SPI_execute_with_args(selectSql.c_str(), |
| | | 2, |
| | | argTypes, |
| | | values, |
| | | nulls, |
| | | true, |
| | | 0); |
| | | if (executeStatus != SPI_OK_SELECT) { |
| | | SPI_finish(); |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("DBMS_JSON preferred name lookup failed"), |
| | | errdetail("spi_status=%d", executeStatus))); |
| | | } |
| | | |
| | | for (uint64 rowIndex = 0; rowIndex < SPI_processed; ++rowIndex) { |
| | | HeapTuple rowTuple = SPI_tuptable->vals[rowIndex]; |
| | | TupleDesc rowDesc = SPI_tuptable->tupdesc; |
| | | bool isNull = false; |
| | | char *pathCString = TextDatumGetCString(SPI_getbinval(rowTuple, rowDesc, 1, &isNull)); |
| | | char *typeCString = TextDatumGetCString(SPI_getbinval(rowTuple, rowDesc, 2, &isNull)); |
| | | char *preferredCString = TextDatumGetCString(SPI_getbinval(rowTuple, rowDesc, 3, &isNull)); |
| | | |
| | | for (GuideEntry &entry : *entries) { |
| | | if (entry.path_ == pathCString && entry.jsonType_ == typeCString) { |
| | | entry.columnName_ = preferredCString; |
| | | } |
| | | } |
| | | |
| | | pfree(pathCString); |
| | | pfree(typeCString); |
| | | pfree(preferredCString); |
| | | } |
| | | |
| | | SPI_finish(); |
| | | } |
| | | |
| | | static void |
| | | parseguideentriesfromproperties(JsonbContainer *properties_container, |
| | | const std::string &base_path, |
| | | std::vector<GuideEntry> *entries) |
| | | { |
| | | JsonbIterator *iterator = JsonbIteratorInit(properties_container); |
| | | JsonbValue iteratorValue; |
| | | JsonbIteratorToken token; |
| | | std::string currentKey; |
| | | |
| | | while ((token = JsonbIteratorNext(&iterator, &iteratorValue, true)) != WJB_DONE) { |
| | | if (token == WJB_KEY) { |
| | | currentKey.assign(iteratorValue.val.string.val, iteratorValue.val.string.len); |
| | | continue; |
| | | } |
| | | |
| | | if (token != WJB_VALUE || iteratorValue.type != jbvBinary || |
| | | !JsonContainerIsObject(iteratorValue.val.binary.data)) { |
| | | continue; |
| | | } |
| | | |
| | | { |
| | | JsonbContainer *childContainer = iteratorValue.val.binary.data; |
| | | JsonbValue typeBuffer; |
| | | JsonbValue preferredBuffer; |
| | | JsonbValue propertiesBuffer; |
| | | JsonbValue *typeValue = getobjectfield(childContainer, "type", &typeBuffer); |
| | | JsonbValue *preferredValue = |
| | | getobjectfield(childContainer, "o:preferred_column_name", &preferredBuffer); |
| | | JsonbValue *propertiesValue = getobjectfield(childContainer, "properties", &propertiesBuffer); |
| | | std::string currentPath = joinpath(base_path, currentKey); |
| | | std::string jsonType = jsonbvaluetostring(typeValue); |
| | | std::string columnName = preferredValue == nullptr |
| | | ? normalizesqlidentifier(currentKey, true) |
| | | : jsonbvaluetostring(preferredValue); |
| | | std::string columnType = resolvecolumntype(childContainer); |
| | | |
| | | if (!columnType.empty()) { |
| | | entries->push_back({currentPath, jsonType, columnName, columnType}); |
| | | } |
| | | |
| | | if (propertiesValue != nullptr && |
| | | propertiesValue->type == jbvBinary && |
| | | JsonContainerIsObject(propertiesValue->val.binary.data)) { |
| | | parseguideentriesfromproperties(propertiesValue->val.binary.data, currentPath, entries); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | static void |
| | | parseguideentries(Jsonb *guide_jsonb, std::vector<GuideEntry> *entries) |
| | | { |
| | | JsonbValue rootValue; |
| | | JsonbIterator *iterator = JsonbIteratorInit(&guide_jsonb->root); |
| | | JsonbValue iteratorValue; |
| | | JsonbIteratorToken token; |
| | | |
| | | JsonbToJsonbValue(guide_jsonb, &rootValue); |
| | | |
| | | if (rootValue.type == jbvBinary && JsonContainerIsObject(rootValue.val.binary.data)) { |
| | | JsonbValue propertiesBuffer; |
| | | JsonbValue *propertiesValue = |
| | | getobjectfield(rootValue.val.binary.data, "properties", &propertiesBuffer); |
| | | |
| | | if (propertiesValue != nullptr && |
| | | propertiesValue->type == jbvBinary && |
| | | JsonContainerIsObject(propertiesValue->val.binary.data)) { |
| | | parseguideentriesfromproperties(propertiesValue->val.binary.data, "$", entries); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | while ((token = JsonbIteratorNext(&iterator, &iteratorValue, true)) != WJB_DONE) { |
| | | JsonbValue pathBuffer; |
| | | JsonbValue typeBuffer; |
| | | JsonbValue columnBuffer; |
| | | JsonbValue *pathValue = nullptr; |
| | | JsonbValue *typeValue = nullptr; |
| | | JsonbValue *columnValue = nullptr; |
| | | |
| | | if (token != WJB_ELEM || iteratorValue.type != jbvBinary || |
| | | !JsonContainerIsObject(iteratorValue.val.binary.data)) { |
| | | continue; |
| | | } |
| | | |
| | | pathValue = getobjectfield(iteratorValue.val.binary.data, "path", &pathBuffer); |
| | | typeValue = getobjectfield(iteratorValue.val.binary.data, "type", &typeBuffer); |
| | | columnValue = getobjectfield(iteratorValue.val.binary.data, "column", &columnBuffer); |
| | | |
| | | if (pathValue == nullptr || typeValue == nullptr) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("invalid data guide entry"), |
| | | errdetail("guide entry must contain path and type"))); |
| | | } |
| | | |
| | | entries->push_back({jsonbvaluetostring(pathValue), |
| | | jsonbvaluetostring(typeValue), |
| | | columnValue == nullptr ? "" : jsonbvaluetostring(columnValue), |
| | | ""}); |
| | | } |
| | | } |
| | | |
| | | static Jsonb * |
| | | builddataguidefortable(const std::string &owner_name, |
| | | const std::string &table_name, |
| | | const std::string &json_column_name) |
| | | { |
| | | Oid argTypes[0]; |
| | | Datum values[0]; |
| | | const char nulls[1] = {' '}; |
| | | int spiStatus = SPI_OK_CONNECT; |
| | | int executeStatus = SPI_OK_SELECT; |
| | | std::string selectSql = |
| | | "SELECT CASE " |
| | | "WHEN " + std::string(quote_identifier(json_column_name.c_str())) + " IS NULL THEN NULL " |
| | | "ELSE pg_catalog.dbms_json_build_dataguide(" + |
| | | std::string(quote_identifier(json_column_name.c_str())) + ") END " |
| | | "FROM " + buildqualifiedname(owner_name, table_name); |
| | | std::vector<GuideEntry> allEntries; |
| | | |
| | | spiStatus = SPI_connect(); |
| | | if (spiStatus != SPI_OK_CONNECT) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("SPI_connect failed in DBMS_JSON table guide build"), |
| | | errdetail("spi_status=%d", spiStatus))); |
| | | } |
| | | |
| | | executeStatus = SPI_execute_with_args(selectSql.c_str(), |
| | | 0, |
| | | argTypes, |
| | | values, |
| | | nulls, |
| | | true, |
| | | 0); |
| | | if (executeStatus != SPI_OK_SELECT) { |
| | | SPI_finish(); |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("DBMS_JSON failed to build guide from table"), |
| | | errdetail("spi_status=%d", executeStatus))); |
| | | } |
| | | |
| | | for (uint64 rowIndex = 0; rowIndex < SPI_processed; ++rowIndex) { |
| | | bool isNull = false; |
| | | Datum guideDatum = SPI_getbinval(SPI_tuptable->vals[rowIndex], |
| | | SPI_tuptable->tupdesc, |
| | | 1, |
| | | &isNull); |
| | | |
| | | if (!isNull) { |
| | | Jsonb *rowGuideJsonb = DatumGetJsonbP(guideDatum); |
| | | parseguideentries(rowGuideJsonb, &allEntries); |
| | | } |
| | | } |
| | | |
| | | SPI_finish(); |
| | | return buildguidefromentries(allEntries); |
| | | } |
| | | |
| | | static text * |
| | | builddataguidetextforformat(Jsonb *guide_jsonb, int32 format_code, int32 pretty_code) |
| | | { |
| | | text *guideText = nullptr; |
| | | |
| | | if (format_code != 1 && format_code != 2 && format_code != 3) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("DBMS_JSON.GET_INDEX_DATAGUIDE invalid format"), |
| | | errdetail("format=%d", format_code))); |
| | | } |
| | | |
| | | if (pretty_code == 1) { |
| | | guideText = DatumGetTextPP(DirectFunctionCall1(jsonb_pretty, JsonbPGetDatum(guide_jsonb))); |
| | | } else { |
| | | guideText = cstring_to_text(JsonbToCString(nullptr, &guide_jsonb->root, VARSIZE(guide_jsonb))); |
| | | } |
| | | |
| | | return guideText; |
| | | } |
| | | |
| | | static std::string |
| | | buildjsonpatharrayliteral(const std::string &json_path) |
| | | { |
| | | std::string trimmedPath = trimrootpath(json_path); |
| | | std::string resultValue = "{"; |
| | | std::size_t startPos = 0; |
| | | |
| | | while (startPos <= trimmedPath.size()) { |
| | | std::size_t dotPos = trimmedPath.find('.', startPos); |
| | | std::string token = trimmedPath.substr(startPos, dotPos - startPos); |
| | | |
| | | if (!token.empty()) { |
| | | if (resultValue.size() > 1) { |
| | | resultValue += ","; |
| | | } |
| | | |
| | | resultValue += token; |
| | | } |
| | | |
| | | if (dotPos == std::string::npos) { |
| | | break; |
| | | } |
| | | |
| | | startPos = dotPos + 1; |
| | | } |
| | | |
| | | resultValue += "}"; |
| | | return resultValue; |
| | | } |
| | | |
| | | static std::string |
| | | buildvirtualcolumnexpr(const std::string &json_column_name, |
| | | const std::string &json_path, |
| | | const std::string &column_type) |
| | | { |
| | | std::string baseExpr = |
| | | "(" + std::string(quote_identifier(json_column_name.c_str())) + " #>> '" + |
| | | buildjsonpatharrayliteral(json_path) + "')"; |
| | | |
| | | if (column_type == "numeric") { |
| | | return "(" + baseExpr + "::numeric)"; |
| | | } |
| | | |
| | | if (column_type == "boolean") { |
| | | return "(" + baseExpr + "::boolean)"; |
| | | } |
| | | |
| | | return baseExpr; |
| | | } |
| | | |
| | | static void |
| | | buildcolumnsfromguide(const std::vector<GuideEntry> &entries, |
| | | const std::string &root_path, |
| | | const std::string &prefix_value, |
| | | bool resolve_name_conflicts, |
| | | bool mixed_case_columns, |
| | | bool prefer_declared_types, |
| | | std::vector<ColumnSpec> *columns) |
| | | { |
| | | std::set<std::string> usedNames; |
| | | |
| | | for (const GuideEntry &entry : entries) { |
| | | std::string relativePath; |
| | | std::string leafName; |
| | | std::string resolvedName; |
| | | std::string columnType; |
| | | std::size_t dotPos; |
| | | |
| | | if (!ispathunderroot(entry.path_, root_path)) { |
| | | continue; |
| | | } |
| | | |
| | | relativePath = makerelativepath(entry.path_, root_path); |
| | | if (relativePath.empty()) { |
| | | continue; |
| | | } |
| | | |
| | | dotPos = relativePath.rfind('.'); |
| | | leafName = dotPos == std::string::npos ? relativePath : relativePath.substr(dotPos + 1); |
| | | resolvedName = entry.columnName_.empty() ? leafName : entry.columnName_; |
| | | resolvedName = normalizesqlidentifier(prefix_value + resolvedName, mixed_case_columns); |
| | | columnType = prefer_declared_types && !entry.columnType_.empty() |
| | | ? entry.columnType_ |
| | | : resolvecolumntypefromname(entry.jsonType_); |
| | | |
| | | if (columnType.empty()) { |
| | | continue; |
| | | } |
| | | |
| | | if (usedNames.find(resolvedName) != usedNames.end()) { |
| | | if (!resolve_name_conflicts) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_DUPLICATE_COLUMN), |
| | | errmsg("invalid data guide: column name conflict"), |
| | | errdetail("column_name=%s", resolvedName.c_str()))); |
| | | } |
| | | |
| | | int suffixValue = 1; |
| | | std::string uniqueName; |
| | | |
| | | do { |
| | | uniqueName = resolvedName + std::to_string(suffixValue); |
| | | suffixValue++; |
| | | } while (usedNames.find(uniqueName) != usedNames.end()); |
| | | |
| | | resolvedName = uniqueName; |
| | | } |
| | | |
| | | usedNames.insert(resolvedName); |
| | | columns->push_back({relativePath, resolvedName, columnType}); |
| | | } |
| | | } |
| | | |
| | | static std::string |
| | | buildcolumnclause(const std::vector<ColumnSpec> &columns) |
| | | { |
| | | std::string resultValue; |
| | | |
| | | for (std::size_t index = 0; index < columns.size(); ++index) { |
| | | if (index != 0) { |
| | | resultValue += ",\n"; |
| | | } |
| | | |
| | | resultValue += std::string(quote_identifier(columns[index].columnName_.c_str())) + " " + |
| | | columns[index].columnType_ + " path '" + |
| | | buildjsonpathfromrelative(columns[index].jsonFieldName_) + "'"; |
| | | } |
| | | |
| | | return resultValue; |
| | | } |
| | | |
| | | static std::string |
| | | buildselectsql(const std::string &owner_name, |
| | | const std::string &table_name, |
| | | const std::string &json_column_name, |
| | | const std::string &path_value, |
| | | const std::vector<ColumnSpec> &columns, |
| | | bool materialize) |
| | | { |
| | | std::string selectHead = materialize |
| | | ? "SELECT RT.\"ROWID\" ROW_ID, JT.*\n" |
| | | : "SELECT JT.*\n"; |
| | | |
| | | return selectHead + |
| | | "FROM " + buildqualifiedname(owner_name, table_name) + " RT,\n" + |
| | | "JSON_TABLE(" + std::string(quote_identifier(json_column_name.c_str())) + ", '" + |
| | | normalizepath(path_value) + "' COLUMNS (\n" + |
| | | buildcolumnclause(columns) + "))JT"; |
| | | } |
| | | |
| | | static std::string |
| | | buildddl(const std::string &owner_name, |
| | | const std::string &view_name, |
| | | const std::string &select_sql, |
| | | bool materialize, |
| | | int32 mv_refresh_mode) |
| | | { |
| | | if (view_name.empty()) { |
| | | return select_sql; |
| | | } |
| | | |
| | | if (materialize) { |
| | | if (mv_refresh_mode != DBMS_JSON_MV_REFRESH_ON_STATEMENT) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), |
| | | errmsg("unsupported materialized view refresh mode"), |
| | | errdetail("mvrefreshmode=%d", mv_refresh_mode))); |
| | | } |
| | | |
| | | return "CREATE MATERIALIZED VIEW " + buildqualifiedname(owner_name, view_name) + |
| | | " BUILD IMMEDIATE REFRESH FAST ON STATEMENT WITH ROWID\nAS " + select_sql; |
| | | } |
| | | |
| | | return "CREATE OR REPLACE VIEW " + buildqualifiedname(owner_name, view_name) + |
| | | " AS " + select_sql; |
| | | } |
| | | } // namespace DbmsJson |
| | | |
| | | extern "C" Datum |
| | | dbms_json_build_dataguide(PG_FUNCTION_ARGS) |
| | | { |
| | | Jsonb *_jsonValue = PG_GETARG_JSONB_P(0); |
| | | |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON.BUILD_DATAGUIDE call"), |
| | | errdetail("input_size=%d", VARSIZE(_jsonValue)))); |
| | | |
| | | PG_RETURN_JSONB_P(DbmsJson::builddataguide(_jsonValue)); |
| | | } |
| | | |
| | | extern "C" Datum |
| | | dbms_json_get_index_dataguide(PG_FUNCTION_ARGS) |
| | | { |
| | | text *_tableNameText = PG_GETARG_TEXT_PP(0); |
| | | text *_jsonColumnNameText = PG_GETARG_TEXT_PP(1); |
| | | int32 formatCode = PG_GETARG_INT32(2); |
| | | int32 prettyCode = PG_NARGS() > 3 && !PG_ARGISNULL(3) ? PG_GETARG_INT32(3) : 0; |
| | | char *_tableNameCString = text_to_cstring(_tableNameText); |
| | | char *_jsonColumnNameCString = text_to_cstring(_jsonColumnNameText); |
| | | std::string tableOwnerName; |
| | | std::string tableName; |
| | | std::string jsonColumnName; |
| | | std::string metadataOwnerName = DbmsJson::resolveownername(); |
| | | Jsonb *guideJsonb = nullptr; |
| | | text *guideText = nullptr; |
| | | |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON.GET_INDEX_DATAGUIDE call"), |
| | | errdetail("tablename=%s, jcolname=%s, format=%d, pretty=%d", |
| | | _tableNameCString, |
| | | _jsonColumnNameCString, |
| | | formatCode, |
| | | prettyCode))); |
| | | |
| | | DbmsJson::normalizeexistingtableandcolumn(std::string(_tableNameCString), |
| | | std::string(_jsonColumnNameCString), |
| | | &tableOwnerName, |
| | | &tableName, |
| | | &jsonColumnName); |
| | | guideJsonb = DbmsJson::builddataguidefortable(tableOwnerName, |
| | | tableName, |
| | | jsonColumnName); |
| | | DbmsJson::ensuremetadatatable(metadataOwnerName); |
| | | |
| | | { |
| | | std::vector<DbmsJson::GuideEntry> guideEntries; |
| | | DbmsJson::parseguideentries(guideJsonb, &guideEntries); |
| | | DbmsJson::applypreferrednames(metadataOwnerName, |
| | | tableName, |
| | | jsonColumnName, |
| | | &guideEntries); |
| | | guideJsonb = DbmsJson::buildguidefromentries(guideEntries); |
| | | } |
| | | |
| | | guideText = DbmsJson::builddataguidetextforformat(guideJsonb, formatCode, prettyCode); |
| | | |
| | | pfree(_tableNameCString); |
| | | pfree(_jsonColumnNameCString); |
| | | |
| | | PG_RETURN_TEXT_P(guideText); |
| | | } |
| | | |
| | | extern "C" Datum |
| | | dbms_json_get_view_sql(PG_FUNCTION_ARGS) |
| | | { |
| | | text *_viewNameText = PG_ARGISNULL(0) ? nullptr : PG_GETARG_TEXT_PP(0); |
| | | text *_tableNameText = PG_ARGISNULL(1) ? nullptr : PG_GETARG_TEXT_PP(1); |
| | | text *_jsonColumnNameText = PG_ARGISNULL(2) ? nullptr : PG_GETARG_TEXT_PP(2); |
| | | Jsonb *_dataGuideJsonb = PG_ARGISNULL(3) ? nullptr : PG_GETARG_JSONB_P(3); |
| | | bool materialize = PG_ARGISNULL(4) ? false : PG_GETARG_BOOL(4); |
| | | int32 mvRefreshMode = |
| | | PG_ARGISNULL(5) ? DBMS_JSON_MV_REFRESH_ON_STATEMENT : PG_GETARG_INT32(5); |
| | | text *_pathText = PG_ARGISNULL(6) ? nullptr : PG_GETARG_TEXT_PP(6); |
| | | bool resolveNameConflicts = PG_ARGISNULL(7) ? true : PG_GETARG_BOOL(7); |
| | | text *_columnPrefixText = PG_ARGISNULL(8) ? nullptr : PG_GETARG_TEXT_PP(8); |
| | | bool mixedCaseColumns = PG_ARGISNULL(9) ? true : PG_GETARG_BOOL(9); |
| | | char *_viewNameCString = nullptr; |
| | | char *_tableNameCString = nullptr; |
| | | char *_jsonColumnNameCString = nullptr; |
| | | char *_pathCString = nullptr; |
| | | char *_columnPrefixCString = nullptr; |
| | | std::vector<DbmsJson::GuideEntry> guideEntries; |
| | | std::vector<DbmsJson::ColumnSpec> columns; |
| | | std::string viewOwnerName; |
| | | std::string tableOwnerName; |
| | | std::string viewName; |
| | | std::string tableName; |
| | | std::string jsonColumnName; |
| | | std::string pathValue = "$"; |
| | | std::string columnPrefix; |
| | | std::string ddlText; |
| | | bool isViewNameNull = (_viewNameText == nullptr); |
| | | bool isTableNameNull = (_tableNameText == nullptr); |
| | | bool isJsonColumnNameNull = (_jsonColumnNameText == nullptr); |
| | | bool isDataGuideNull = (_dataGuideJsonb == nullptr); |
| | | bool isPathNull = (_pathText == nullptr); |
| | | bool isColumnPrefixNull = (_columnPrefixText == nullptr); |
| | | |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON.GET_VIEW_SQL call"), |
| | | errdetail("viewname_is_null=%s, tablename_is_null=%s, jcolname_is_null=%s, dataguide_is_null=%s, materialize=%s, mvrefreshmode=%d, path_is_null=%s, resolvenameconflicts=%s, colnameprefix_is_null=%s, mixedcasecolumns=%s", |
| | | isViewNameNull ? "true" : "false", |
| | | isTableNameNull ? "true" : "false", |
| | | isJsonColumnNameNull ? "true" : "false", |
| | | isDataGuideNull ? "true" : "false", |
| | | materialize ? "true" : "false", |
| | | mvRefreshMode, |
| | | isPathNull ? "true" : "false", |
| | | resolveNameConflicts ? "true" : "false", |
| | | isColumnPrefixNull ? "true" : "false", |
| | | mixedCaseColumns ? "true" : "false"))); |
| | | |
| | | if (isTableNameNull || isJsonColumnNameNull || isDataGuideNull) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), |
| | | errmsg("DBMS_JSON.GET_VIEW_SQL does not allow NULL required arguments"))); |
| | | } |
| | | |
| | | _viewNameCString = isViewNameNull ? nullptr : text_to_cstring(_viewNameText); |
| | | _tableNameCString = text_to_cstring(_tableNameText); |
| | | _jsonColumnNameCString = text_to_cstring(_jsonColumnNameText); |
| | | _pathCString = isPathNull ? nullptr : text_to_cstring(_pathText); |
| | | _columnPrefixCString = isColumnPrefixNull ? nullptr : text_to_cstring(_columnPrefixText); |
| | | |
| | | viewName = _viewNameCString == nullptr |
| | | ? "" |
| | | : DbmsJson::normalizeidentifierinput(std::string(_viewNameCString)); |
| | | DbmsJson::normalizeexistingtableandcolumn(std::string(_tableNameCString), |
| | | std::string(_jsonColumnNameCString), |
| | | &tableOwnerName, |
| | | &tableName, |
| | | &jsonColumnName); |
| | | pathValue = _pathCString == nullptr ? "$" : std::string(_pathCString); |
| | | columnPrefix = _columnPrefixCString == nullptr ? "" : std::string(_columnPrefixCString); |
| | | viewOwnerName = DbmsJson::resolveownername(); |
| | | |
| | | if (!mixedCaseColumns) { |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON.GET_VIEW_SQL mixed case disabled"), |
| | | errdetail("column names will be normalized to lower case"))); |
| | | } |
| | | |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON.GET_VIEW_SQL normalized arguments"), |
| | | errdetail("view_owner=%s, viewname=%s, tablename=%s, jcolname=%s, path=%s, colnameprefix=%s", |
| | | viewOwnerName.c_str(), |
| | | viewName.empty() ? "<NULL>" : viewName.c_str(), |
| | | tableName.c_str(), |
| | | jsonColumnName.c_str(), |
| | | pathValue.c_str(), |
| | | columnPrefix.empty() ? "<NULL>" : columnPrefix.c_str()))); |
| | | |
| | | DbmsJson::parseguideentries(_dataGuideJsonb, &guideEntries); |
| | | DbmsJson::buildcolumnsfromguide(guideEntries, |
| | | pathValue, |
| | | columnPrefix, |
| | | resolveNameConflicts, |
| | | mixedCaseColumns, |
| | | true, |
| | | &columns); |
| | | |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON.GET_VIEW_SQL columns collected"), |
| | | errdetail("column_count=%zu", columns.size()))); |
| | | |
| | | if (_viewNameCString != nullptr) { |
| | | pfree(_viewNameCString); |
| | | } |
| | | if (_tableNameCString != nullptr) { |
| | | pfree(_tableNameCString); |
| | | } |
| | | if (_jsonColumnNameCString != nullptr) { |
| | | pfree(_jsonColumnNameCString); |
| | | } |
| | | if (_pathCString != nullptr) { |
| | | pfree(_pathCString); |
| | | } |
| | | if (_columnPrefixCString != nullptr) { |
| | | pfree(_columnPrefixCString); |
| | | } |
| | | |
| | | if (columns.empty()) { |
| | | PG_RETURN_TEXT_P(cstring_to_text("")); |
| | | } |
| | | |
| | | ddlText = DbmsJson::buildddl(viewOwnerName, |
| | | viewName, |
| | | DbmsJson::buildselectsql(tableOwnerName, |
| | | tableName, |
| | | jsonColumnName, |
| | | pathValue, |
| | | columns, |
| | | materialize), |
| | | materialize, |
| | | mvRefreshMode); |
| | | |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON.GET_VIEW_SQL result"), |
| | | errdetail("ddl_length=%zu", ddlText.size()))); |
| | | |
| | | PG_RETURN_TEXT_P(cstring_to_text(ddlText.c_str())); |
| | | } |
| | | |
| | | extern "C" Datum |
| | | dbms_json_add_virtual_columns(PG_FUNCTION_ARGS) |
| | | { |
| | | text *_tableNameText = PG_GETARG_TEXT_PP(0); |
| | | text *_jsonColumnNameText = PG_GETARG_TEXT_PP(1); |
| | | Jsonb *_dataGuideJsonb = PG_GETARG_JSONB_P(2); |
| | | bool resolveNameConflicts = PG_NARGS() > 3 && !PG_ARGISNULL(3) ? PG_GETARG_BOOL(3) : true; |
| | | text *_columnPrefixText = PG_NARGS() > 4 && !PG_ARGISNULL(4) ? PG_GETARG_TEXT_PP(4) : nullptr; |
| | | bool mixedCaseColumns = PG_NARGS() > 5 && !PG_ARGISNULL(5) ? PG_GETARG_BOOL(5) : false; |
| | | char *_tableNameCString = text_to_cstring(_tableNameText); |
| | | char *_jsonColumnNameCString = text_to_cstring(_jsonColumnNameText); |
| | | char *_columnPrefixCString = _columnPrefixText == nullptr ? nullptr : text_to_cstring(_columnPrefixText); |
| | | std::string ownerName; |
| | | std::string tableName; |
| | | std::string jsonColumnName; |
| | | std::vector<DbmsJson::GuideEntry> guideEntries; |
| | | std::vector<DbmsJson::ColumnSpec> columns; |
| | | int spiStatus = SPI_OK_CONNECT; |
| | | |
| | | DbmsJson::normalizeexistingtableandcolumn(std::string(_tableNameCString), |
| | | std::string(_jsonColumnNameCString), |
| | | &ownerName, |
| | | &tableName, |
| | | &jsonColumnName); |
| | | DbmsJson::parseguideentries(_dataGuideJsonb, &guideEntries); |
| | | DbmsJson::buildcolumnsfromguide(guideEntries, |
| | | "$", |
| | | _columnPrefixCString == nullptr ? "" : std::string(_columnPrefixCString), |
| | | resolveNameConflicts, |
| | | mixedCaseColumns, |
| | | false, |
| | | &columns); |
| | | |
| | | spiStatus = SPI_connect(); |
| | | if (spiStatus != SPI_OK_CONNECT) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("SPI_connect failed in DBMS_JSON.ADD_VIRTUAL_COLUMNS"), |
| | | errdetail("spi_status=%d", spiStatus))); |
| | | } |
| | | |
| | | for (const DbmsJson::ColumnSpec &columnSpec : columns) { |
| | | std::string alterSql = |
| | | "ALTER TABLE " + DbmsJson::buildqualifiedname(ownerName, tableName) + |
| | | " ADD COLUMN " + std::string(quote_identifier(columnSpec.columnName_.c_str())) + |
| | | " " + columnSpec.columnType_ + " GENERATED ALWAYS AS " + |
| | | DbmsJson::buildvirtualcolumnexpr(jsonColumnName, |
| | | DbmsJson::buildjsonpathfromrelative(columnSpec.jsonFieldName_), |
| | | columnSpec.columnType_) + |
| | | " STORED"; |
| | | |
| | | int executeStatus = SPI_execute(alterSql.c_str(), false, 0); |
| | | if (executeStatus != SPI_OK_UTILITY) { |
| | | SPI_finish(); |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("DBMS_JSON.ADD_VIRTUAL_COLUMNS failed"), |
| | | errdetail("column_name=%s, spi_status=%d", |
| | | columnSpec.columnName_.c_str(), |
| | | executeStatus))); |
| | | } |
| | | } |
| | | |
| | | SPI_finish(); |
| | | |
| | | pfree(_tableNameCString); |
| | | pfree(_jsonColumnNameCString); |
| | | if (_columnPrefixCString != nullptr) { |
| | | pfree(_columnPrefixCString); |
| | | } |
| | | |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | extern "C" Datum |
| | | dbms_json_create_view(PG_FUNCTION_ARGS) |
| | | { |
| | | text *_viewNameText = PG_ARGISNULL(0) ? nullptr : PG_GETARG_TEXT_PP(0); |
| | | text *_tableNameText = PG_ARGISNULL(1) ? nullptr : PG_GETARG_TEXT_PP(1); |
| | | text *_jsonColumnNameText = PG_ARGISNULL(2) ? nullptr : PG_GETARG_TEXT_PP(2); |
| | | Jsonb *_dataGuideJsonb = PG_ARGISNULL(3) ? nullptr : PG_GETARG_JSONB_P(3); |
| | | text *_resourcePathText = PG_ARGISNULL(4) ? nullptr : PG_GETARG_TEXT_PP(4); |
| | | bool materialize = PG_ARGISNULL(5) ? false : PG_GETARG_BOOL(5); |
| | | int32 mvRefreshMode = |
| | | PG_ARGISNULL(6) ? DBMS_JSON_MV_REFRESH_ON_STATEMENT : PG_GETARG_INT32(6); |
| | | text *_pathText = PG_ARGISNULL(7) ? nullptr : PG_GETARG_TEXT_PP(7); |
| | | bool resolveNameConflicts = PG_ARGISNULL(8) ? true : PG_GETARG_BOOL(8); |
| | | text *_columnPrefixText = PG_ARGISNULL(9) ? nullptr : PG_GETARG_TEXT_PP(9); |
| | | bool mixedCaseColumns = PG_ARGISNULL(10) ? false : PG_GETARG_BOOL(10); |
| | | char *_viewNameCString = nullptr; |
| | | char *_tableNameCString = nullptr; |
| | | char *_jsonColumnNameCString = nullptr; |
| | | char *_pathCString = nullptr; |
| | | char *_columnPrefixCString = nullptr; |
| | | char *_guideCString = nullptr; |
| | | int spiStatus = SPI_OK_CONNECT; |
| | | int executeStatus = SPI_OK_UTILITY; |
| | | std::vector<DbmsJson::GuideEntry> guideEntries; |
| | | std::vector<DbmsJson::ColumnSpec> columns; |
| | | std::string viewOwnerName; |
| | | std::string tableOwnerName; |
| | | std::string viewName; |
| | | std::string tableName; |
| | | std::string jsonColumnName; |
| | | std::string pathValue = "$"; |
| | | std::string columnPrefix; |
| | | std::string ddlText; |
| | | |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON.CREATE_VIEW call"), |
| | | errdetail("viewname_is_null=%s, tablename_is_null=%s, jcolname_is_null=%s, dataguide_is_null=%s, resourcepath_is_null=%s, materialize=%s, mvrefreshmode=%d, path_is_null=%s, resolvenameconflicts=%s, colnameprefix_is_null=%s, mixedcasecolumns=%s", |
| | | _viewNameText == nullptr ? "true" : "false", |
| | | _tableNameText == nullptr ? "true" : "false", |
| | | _jsonColumnNameText == nullptr ? "true" : "false", |
| | | _dataGuideJsonb == nullptr ? "true" : "false", |
| | | _resourcePathText == nullptr ? "true" : "false", |
| | | materialize ? "true" : "false", |
| | | mvRefreshMode, |
| | | _pathText == nullptr ? "true" : "false", |
| | | resolveNameConflicts ? "true" : "false", |
| | | _columnPrefixText == nullptr ? "true" : "false", |
| | | mixedCaseColumns ? "true" : "false"))); |
| | | |
| | | if (_viewNameText == nullptr || _tableNameText == nullptr || |
| | | _jsonColumnNameText == nullptr || _dataGuideJsonb == nullptr) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), |
| | | errmsg("DBMS_JSON.CREATE_VIEW does not allow NULL required arguments"))); |
| | | } |
| | | |
| | | if (_resourcePathText != nullptr) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), |
| | | errmsg("DBMS_JSON.CREATE_VIEW resourcepath is not supported"), |
| | | errdetail("resourcepath must be NULL"))); |
| | | } |
| | | |
| | | _viewNameCString = text_to_cstring(_viewNameText); |
| | | _tableNameCString = text_to_cstring(_tableNameText); |
| | | _jsonColumnNameCString = text_to_cstring(_jsonColumnNameText); |
| | | _pathCString = _pathText == nullptr ? nullptr : text_to_cstring(_pathText); |
| | | _columnPrefixCString = _columnPrefixText == nullptr ? nullptr : text_to_cstring(_columnPrefixText); |
| | | |
| | | viewOwnerName = DbmsJson::resolveownername(); |
| | | viewName = DbmsJson::normalizeidentifierinput(std::string(_viewNameCString)); |
| | | DbmsJson::normalizeexistingtableandcolumn(std::string(_tableNameCString), |
| | | std::string(_jsonColumnNameCString), |
| | | &tableOwnerName, |
| | | &tableName, |
| | | &jsonColumnName); |
| | | pathValue = _pathCString == nullptr ? "$" : std::string(_pathCString); |
| | | columnPrefix = _columnPrefixCString == nullptr ? "" : std::string(_columnPrefixCString); |
| | | |
| | | DbmsJson::parseguideentries(_dataGuideJsonb, &guideEntries); |
| | | DbmsJson::buildcolumnsfromguide(guideEntries, |
| | | pathValue, |
| | | columnPrefix, |
| | | resolveNameConflicts, |
| | | mixedCaseColumns, |
| | | true, |
| | | &columns); |
| | | |
| | | if (columns.empty()) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("invalid data guide: no scalar fields found"))); |
| | | } |
| | | |
| | | ddlText = DbmsJson::buildddl(viewOwnerName, |
| | | viewName, |
| | | DbmsJson::buildselectsql(tableOwnerName, |
| | | tableName, |
| | | jsonColumnName, |
| | | pathValue, |
| | | columns, |
| | | materialize), |
| | | materialize, |
| | | mvRefreshMode); |
| | | |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON.CREATE_VIEW ddl"), |
| | | errdetail("ddl=%s", ddlText.c_str()))); |
| | | |
| | | spiStatus = SPI_connect(); |
| | | if (spiStatus != SPI_OK_CONNECT) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("SPI_connect failed in DBMS_JSON.CREATE_VIEW"), |
| | | errdetail("spi_status=%d", spiStatus))); |
| | | } |
| | | |
| | | executeStatus = SPI_execute(ddlText.c_str(), false, 0); |
| | | if (executeStatus != SPI_OK_UTILITY) { |
| | | SPI_finish(); |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("DBMS_JSON.CREATE_VIEW failed to execute DDL"), |
| | | errdetail("spi_status=%d", executeStatus))); |
| | | } |
| | | |
| | | SPI_finish(); |
| | | |
| | | if (_viewNameCString != nullptr) { |
| | | pfree(_viewNameCString); |
| | | } |
| | | if (_tableNameCString != nullptr) { |
| | | pfree(_tableNameCString); |
| | | } |
| | | if (_jsonColumnNameCString != nullptr) { |
| | | pfree(_jsonColumnNameCString); |
| | | } |
| | | if (_pathCString != nullptr) { |
| | | pfree(_pathCString); |
| | | } |
| | | if (_columnPrefixCString != nullptr) { |
| | | pfree(_columnPrefixCString); |
| | | } |
| | | if (_guideCString != nullptr) { |
| | | pfree(_guideCString); |
| | | } |
| | | |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | extern "C" Datum |
| | | dbms_json_create_view2(PG_FUNCTION_ARGS) |
| | | { |
| | | int32 serviceArg = 0; |
| | | |
| | | if (PG_NARGS() != 12) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("DBMS_JSON.CREATE_VIEW2 accepts exactly 12 arguments"))); |
| | | } |
| | | |
| | | if (!PG_ARGISNULL(11)) { |
| | | serviceArg = PG_GETARG_INT32(11); |
| | | } |
| | | (void) serviceArg; |
| | | |
| | | { |
| | | LOCAL_FCINFO(fcinfo2, 11); |
| | | |
| | | InitFunctionCallInfoData(*fcinfo2, nullptr, 11, InvalidOid, nullptr, nullptr); |
| | | fcinfo2->args[0].value = PG_GETARG_DATUM(0); |
| | | fcinfo2->args[0].isnull = PG_ARGISNULL(0); |
| | | fcinfo2->args[1].value = PG_GETARG_DATUM(1); |
| | | fcinfo2->args[1].isnull = PG_ARGISNULL(1); |
| | | fcinfo2->args[2].value = PG_GETARG_DATUM(2); |
| | | fcinfo2->args[2].isnull = PG_ARGISNULL(2); |
| | | fcinfo2->args[3].value = PG_GETARG_DATUM(3); |
| | | fcinfo2->args[3].isnull = PG_ARGISNULL(3); |
| | | fcinfo2->args[4].value = PG_GETARG_DATUM(4); |
| | | fcinfo2->args[4].isnull = PG_ARGISNULL(4); |
| | | fcinfo2->args[5].value = PG_GETARG_DATUM(5); |
| | | fcinfo2->args[5].isnull = PG_ARGISNULL(5); |
| | | fcinfo2->args[6].value = PG_GETARG_DATUM(6); |
| | | fcinfo2->args[6].isnull = PG_ARGISNULL(6); |
| | | fcinfo2->args[7].value = PG_GETARG_DATUM(7); |
| | | fcinfo2->args[7].isnull = PG_ARGISNULL(7); |
| | | fcinfo2->args[8].value = PG_GETARG_DATUM(8); |
| | | fcinfo2->args[8].isnull = PG_ARGISNULL(8); |
| | | fcinfo2->args[9].value = PG_GETARG_DATUM(9); |
| | | fcinfo2->args[9].isnull = PG_ARGISNULL(9); |
| | | fcinfo2->args[10].value = PG_GETARG_DATUM(10); |
| | | fcinfo2->args[10].isnull = PG_ARGISNULL(10); |
| | | |
| | | (void) dbms_json_create_view(fcinfo2); |
| | | } |
| | | |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | extern "C" Datum |
| | | dbms_json_drop_virtual_columns(PG_FUNCTION_ARGS) |
| | | { |
| | | text *_tableNameText = PG_GETARG_TEXT_PP(0); |
| | | text *_jsonColumnNameText = PG_GETARG_TEXT_PP(1); |
| | | char *_tableNameCString = text_to_cstring(_tableNameText); |
| | | char *_jsonColumnNameCString = text_to_cstring(_jsonColumnNameText); |
| | | std::string ownerName; |
| | | std::string tableName; |
| | | std::string jsonColumnName; |
| | | int spiStatus = SPI_OK_CONNECT; |
| | | int executeStatus = SPI_OK_SELECT; |
| | | std::string selectSql; |
| | | std::vector<std::string> columnNames; |
| | | |
| | | DbmsJson::normalizeexistingtableandcolumn(std::string(_tableNameCString), |
| | | std::string(_jsonColumnNameCString), |
| | | &ownerName, |
| | | &tableName, |
| | | &jsonColumnName); |
| | | selectSql = |
| | | "SELECT attname FROM pg_attribute a " |
| | | "JOIN pg_class c ON c.oid = a.attrelid " |
| | | "JOIN pg_namespace n ON n.oid = c.relnamespace " |
| | | "WHERE n.nspname = " + std::string(quote_literal_cstr(ownerName.c_str())) + |
| | | " AND c.relname = " + std::string(quote_literal_cstr(tableName.c_str())) + |
| | | " AND a.attnum > 0 AND NOT a.attisdropped " |
| | | " AND a.attgenerated <> ''"; |
| | | |
| | | spiStatus = SPI_connect(); |
| | | if (spiStatus != SPI_OK_CONNECT) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("SPI_connect failed in DBMS_JSON.DROP_VIRTUAL_COLUMNS"), |
| | | errdetail("spi_status=%d", spiStatus))); |
| | | } |
| | | |
| | | executeStatus = SPI_execute(selectSql.c_str(), true, 0); |
| | | if (executeStatus != SPI_OK_SELECT) { |
| | | SPI_finish(); |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("DBMS_JSON.DROP_VIRTUAL_COLUMNS failed to read columns"), |
| | | errdetail("spi_status=%d", executeStatus))); |
| | | } |
| | | |
| | | for (uint64 rowIndex = 0; rowIndex < SPI_processed; ++rowIndex) { |
| | | HeapTuple rowTuple = SPI_tuptable->vals[rowIndex]; |
| | | TupleDesc rowDesc = SPI_tuptable->tupdesc; |
| | | bool isNull = false; |
| | | Datum columnNameDatum = SPI_getbinval(rowTuple, rowDesc, 1, &isNull); |
| | | char *columnNameCString = pstrdup(NameStr(*DatumGetName(columnNameDatum))); |
| | | |
| | | if (strcmp(columnNameCString, jsonColumnName.c_str()) != 0) { |
| | | columnNames.push_back(std::string(columnNameCString)); |
| | | } |
| | | |
| | | pfree(columnNameCString); |
| | | } |
| | | |
| | | for (const std::string &columnName : columnNames) { |
| | | std::string dropSql = |
| | | "ALTER TABLE " + DbmsJson::buildqualifiedname(ownerName, tableName) + |
| | | " DROP COLUMN IF EXISTS " + std::string(quote_identifier(columnName.c_str())); |
| | | int dropStatus = SPI_execute(dropSql.c_str(), false, 0); |
| | | |
| | | if (dropStatus != SPI_OK_UTILITY) { |
| | | SPI_finish(); |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("DBMS_JSON.DROP_VIRTUAL_COLUMNS failed"), |
| | | errdetail("column_name=%s, spi_status=%d", |
| | | columnName.c_str(), |
| | | dropStatus))); |
| | | } |
| | | } |
| | | |
| | | SPI_finish(); |
| | | pfree(_tableNameCString); |
| | | pfree(_jsonColumnNameCString); |
| | | |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | extern "C" Datum |
| | | dbms_json_json_type_convertible_check(PG_FUNCTION_ARGS) |
| | | { |
| | | text *_ownerText = PG_GETARG_TEXT_PP(0); |
| | | text *_tableNameText = PG_GETARG_TEXT_PP(1); |
| | | text *_columnNameText = PG_GETARG_TEXT_PP(2); |
| | | text *_statusTableNameText = PG_GETARG_TEXT_PP(3); |
| | | bool fastCheck = PG_NARGS() > 4 && !PG_ARGISNULL(4) ? PG_GETARG_BOOL(4) : false; |
| | | bool appendStatus = PG_NARGS() > 5 && !PG_ARGISNULL(5) ? PG_GETARG_BOOL(5) : false; |
| | | char *_ownerCString = text_to_cstring(_ownerText); |
| | | char *_tableNameCString = text_to_cstring(_tableNameText); |
| | | char *_columnNameCString = text_to_cstring(_columnNameText); |
| | | char *_statusTableNameCString = text_to_cstring(_statusTableNameText); |
| | | int spiStatus = SPI_OK_CONNECT; |
| | | int executeStatus = SPI_OK_UTILITY; |
| | | std::string ownerName; |
| | | std::string tableName; |
| | | std::string columnName; |
| | | std::string statusTableName; |
| | | DbmsJson::normalizeexistingtableandcolumn(std::string(_ownerCString), |
| | | std::string(_tableNameCString), |
| | | std::string(_columnNameCString), |
| | | &ownerName, |
| | | &tableName, |
| | | &columnName); |
| | | statusTableName = DbmsJson::resolvestatusname(std::string(_statusTableNameCString)); |
| | | std::string statusQualified = DbmsJson::buildqualifiedname(ownerName, statusTableName); |
| | | std::string createSql = |
| | | "CREATE TABLE IF NOT EXISTS " + statusQualified + |
| | | " (row_no bigint, is_convertible boolean, error_text text)"; |
| | | |
| | | spiStatus = SPI_connect(); |
| | | if (spiStatus != SPI_OK_CONNECT) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("SPI_connect failed in DBMS_JSON.JSON_TYPE_CONVERTIBLE_CHECK"), |
| | | errdetail("spi_status=%d", spiStatus))); |
| | | } |
| | | |
| | | executeStatus = SPI_execute(createSql.c_str(), false, 0); |
| | | if (executeStatus != SPI_OK_UTILITY) { |
| | | SPI_finish(); |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("DBMS_JSON.JSON_TYPE_CONVERTIBLE_CHECK failed to create status table"), |
| | | errdetail("spi_status=%d", executeStatus))); |
| | | } |
| | | |
| | | if (!appendStatus) { |
| | | std::string truncateSql = "TRUNCATE TABLE " + statusQualified; |
| | | executeStatus = SPI_execute(truncateSql.c_str(), false, 0); |
| | | if (executeStatus != SPI_OK_UTILITY) { |
| | | SPI_finish(); |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("DBMS_JSON.JSON_TYPE_CONVERTIBLE_CHECK failed to truncate status table"), |
| | | errdetail("spi_status=%d", executeStatus))); |
| | | } |
| | | } |
| | | |
| | | { |
| | | std::string inputTypeName = fastCheck ? "json" : "jsonb"; |
| | | std::string insertSql = |
| | | "INSERT INTO " + statusQualified + |
| | | " SELECT row_number() OVER (), " |
| | | " pg_input_is_valid((" + std::string(quote_identifier(columnName.c_str())) + ")::text, " + |
| | | std::string(quote_literal_cstr(inputTypeName.c_str())) + "), " |
| | | " CASE " |
| | | " WHEN pg_input_is_valid((" + std::string(quote_identifier(columnName.c_str())) + ")::text, " + |
| | | std::string(quote_literal_cstr(inputTypeName.c_str())) + ") " |
| | | " THEN " + std::string(quote_literal_cstr("ok")) + |
| | | " ELSE (pg_input_error_info((" + std::string(quote_identifier(columnName.c_str())) + ")::text, " + |
| | | std::string(quote_literal_cstr(inputTypeName.c_str())) + ")).message " |
| | | " END " + |
| | | " FROM " + DbmsJson::buildqualifiedname(ownerName, tableName) + |
| | | " WHERE " + std::string(quote_identifier(columnName.c_str())) + " IS NOT NULL"; |
| | | |
| | | executeStatus = SPI_execute(insertSql.c_str(), false, 0); |
| | | if (executeStatus != SPI_OK_INSERT) { |
| | | SPI_finish(); |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("DBMS_JSON.JSON_TYPE_CONVERTIBLE_CHECK failed to populate status table"), |
| | | errdetail("spi_status=%d", executeStatus))); |
| | | } |
| | | } |
| | | |
| | | SPI_finish(); |
| | | pfree(_ownerCString); |
| | | pfree(_tableNameCString); |
| | | pfree(_columnNameCString); |
| | | pfree(_statusTableNameCString); |
| | | |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | extern "C" Datum |
| | | dbms_json_rename_column(PG_FUNCTION_ARGS) |
| | | { |
| | | text *_tableNameText = PG_ARGISNULL(0) ? nullptr : PG_GETARG_TEXT_PP(0); |
| | | text *_jsonColumnNameText = PG_ARGISNULL(1) ? nullptr : PG_GETARG_TEXT_PP(1); |
| | | text *_pathText = PG_ARGISNULL(2) ? nullptr : PG_GETARG_TEXT_PP(2); |
| | | int32 typeCode = PG_ARGISNULL(3) ? 0 : PG_GETARG_INT32(3); |
| | | text *_preferredNameText = PG_ARGISNULL(4) ? nullptr : PG_GETARG_TEXT_PP(4); |
| | | char *_tableNameCString = nullptr; |
| | | char *_jsonColumnNameCString = nullptr; |
| | | char *_pathCString = nullptr; |
| | | char *_preferredNameCString = nullptr; |
| | | Oid argTypes[5] = {TEXTOID, TEXTOID, TEXTOID, TEXTOID, TEXTOID}; |
| | | Datum values[5]; |
| | | const char nulls[5] = {' ', ' ', ' ', ' ', ' '}; |
| | | int spiStatus = SPI_OK_CONNECT; |
| | | int executeStatus = SPI_OK_INSERT; |
| | | std::string metadataOwnerName; |
| | | std::string tableOwnerName; |
| | | std::string tableName; |
| | | std::string jsonColumnName; |
| | | std::string jsonType; |
| | | std::string upsertSql; |
| | | |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON.RENAME_COLUMN call"), |
| | | errdetail("tablename_is_null=%s, jcolname_is_null=%s, path_is_null=%s, type=%d, preferred_name_is_null=%s", |
| | | _tableNameText == nullptr ? "true" : "false", |
| | | _jsonColumnNameText == nullptr ? "true" : "false", |
| | | _pathText == nullptr ? "true" : "false", |
| | | typeCode, |
| | | _preferredNameText == nullptr ? "true" : "false"))); |
| | | |
| | | if (_tableNameText == nullptr || _jsonColumnNameText == nullptr || |
| | | _pathText == nullptr || _preferredNameText == nullptr) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), |
| | | errmsg("DBMS_JSON.RENAME_COLUMN does not allow NULL arguments"))); |
| | | } |
| | | |
| | | jsonType = DbmsJson::resolvejsontypenamefromcode(typeCode); |
| | | if (jsonType.empty()) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("DBMS_JSON.RENAME_COLUMN invalid type code"), |
| | | errdetail("type=%d", typeCode))); |
| | | } |
| | | |
| | | _tableNameCString = text_to_cstring(_tableNameText); |
| | | _jsonColumnNameCString = text_to_cstring(_jsonColumnNameText); |
| | | _pathCString = text_to_cstring(_pathText); |
| | | _preferredNameCString = text_to_cstring(_preferredNameText); |
| | | |
| | | DbmsJson::normalizeexistingtableandcolumn(std::string(_tableNameCString), |
| | | std::string(_jsonColumnNameCString), |
| | | &tableOwnerName, |
| | | &tableName, |
| | | &jsonColumnName); |
| | | metadataOwnerName = DbmsJson::resolveownername(); |
| | | DbmsJson::ensuremetadatatable(metadataOwnerName); |
| | | |
| | | upsertSql = |
| | | "INSERT INTO " + DbmsJson::buildmetadataqualifiedname(metadataOwnerName) + |
| | | " (tablename, jcolname, path, json_type, preferred_name) " |
| | | "VALUES ($1, $2, $3, $4, $5) " |
| | | "ON CONFLICT (tablename, jcolname, path, json_type) " |
| | | "DO UPDATE SET preferred_name = EXCLUDED.preferred_name"; |
| | | |
| | | values[0] = CStringGetTextDatum(tableName.c_str()); |
| | | values[1] = CStringGetTextDatum(jsonColumnName.c_str()); |
| | | values[2] = CStringGetTextDatum(_pathCString); |
| | | values[3] = CStringGetTextDatum(jsonType.c_str()); |
| | | values[4] = CStringGetTextDatum(_preferredNameCString); |
| | | |
| | | spiStatus = SPI_connect(); |
| | | if (spiStatus != SPI_OK_CONNECT) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("SPI_connect failed in DBMS_JSON.RENAME_COLUMN"), |
| | | errdetail("spi_status=%d", spiStatus))); |
| | | } |
| | | |
| | | executeStatus = SPI_execute_with_args(upsertSql.c_str(), |
| | | 5, |
| | | argTypes, |
| | | values, |
| | | nulls, |
| | | false, |
| | | 0); |
| | | if (executeStatus != SPI_OK_INSERT && executeStatus != SPI_OK_UPDATE) { |
| | | SPI_finish(); |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("DBMS_JSON.RENAME_COLUMN failed"), |
| | | errdetail("spi_status=%d", executeStatus))); |
| | | } |
| | | |
| | | SPI_finish(); |
| | | |
| | | if (_tableNameCString != nullptr) { |
| | | pfree(_tableNameCString); |
| | | } |
| | | if (_jsonColumnNameCString != nullptr) { |
| | | pfree(_jsonColumnNameCString); |
| | | } |
| | | if (_pathCString != nullptr) { |
| | | pfree(_pathCString); |
| | | } |
| | | if (_preferredNameCString != nullptr) { |
| | | pfree(_preferredNameCString); |
| | | } |
| | | |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| | | extern "C" Datum |
| | | dbms_json_create_view_on_path(PG_FUNCTION_ARGS) |
| | | { |
| | | text *_viewNameText = PG_ARGISNULL(0) ? nullptr : PG_GETARG_TEXT_PP(0); |
| | | text *_tableNameText = PG_ARGISNULL(1) ? nullptr : PG_GETARG_TEXT_PP(1); |
| | | text *_jsonColumnNameText = PG_ARGISNULL(2) ? nullptr : PG_GETARG_TEXT_PP(2); |
| | | text *_pathText = PG_ARGISNULL(3) ? nullptr : PG_GETARG_TEXT_PP(3); |
| | | int32 frequency = PG_ARGISNULL(4) ? 0 : PG_GETARG_INT32(4); |
| | | char *_viewNameCString = nullptr; |
| | | char *_tableNameCString = nullptr; |
| | | char *_jsonColumnNameCString = nullptr; |
| | | char *_pathCString = nullptr; |
| | | std::string viewOwnerName; |
| | | std::string tableOwnerName; |
| | | std::string metadataOwnerName; |
| | | Jsonb *guideJsonb = nullptr; |
| | | std::vector<DbmsJson::GuideEntry> guideEntries; |
| | | std::vector<DbmsJson::ColumnSpec> columns; |
| | | std::string ddlText; |
| | | int spiStatus = SPI_OK_CONNECT; |
| | | int executeStatus = SPI_OK_UTILITY; |
| | | |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON.CREATE_VIEW_ON_PATH call"), |
| | | errdetail("viewname_is_null=%s, tablename_is_null=%s, jcolname_is_null=%s, path_is_null=%s, frequency=%d", |
| | | _viewNameText == nullptr ? "true" : "false", |
| | | _tableNameText == nullptr ? "true" : "false", |
| | | _jsonColumnNameText == nullptr ? "true" : "false", |
| | | _pathText == nullptr ? "true" : "false", |
| | | frequency))); |
| | | |
| | | if (_viewNameText == nullptr || _tableNameText == nullptr || |
| | | _jsonColumnNameText == nullptr || _pathText == nullptr) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), |
| | | errmsg("DBMS_JSON.CREATE_VIEW_ON_PATH does not allow NULL required arguments"))); |
| | | } |
| | | |
| | | if (frequency != 0) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), |
| | | errmsg("DBMS_JSON.CREATE_VIEW_ON_PATH frequency is not supported in simplified mode"), |
| | | errdetail("frequency=%d", frequency))); |
| | | } |
| | | |
| | | _viewNameCString = text_to_cstring(_viewNameText); |
| | | _tableNameCString = text_to_cstring(_tableNameText); |
| | | _jsonColumnNameCString = text_to_cstring(_jsonColumnNameText); |
| | | _pathCString = text_to_cstring(_pathText); |
| | | |
| | | viewOwnerName = DbmsJson::resolveownername(); |
| | | std::string tableName; |
| | | std::string jsonColumnName; |
| | | DbmsJson::normalizeexistingtableandcolumn(std::string(_tableNameCString), |
| | | std::string(_jsonColumnNameCString), |
| | | &tableOwnerName, |
| | | &tableName, |
| | | &jsonColumnName); |
| | | metadataOwnerName = viewOwnerName; |
| | | DbmsJson::ensuremetadatatable(metadataOwnerName); |
| | | guideJsonb = DbmsJson::builddataguidefortable(tableOwnerName, |
| | | tableName, |
| | | jsonColumnName); |
| | | DbmsJson::parseguideentries(guideJsonb, &guideEntries); |
| | | DbmsJson::applypreferrednames(metadataOwnerName, |
| | | tableName, |
| | | jsonColumnName, |
| | | &guideEntries); |
| | | DbmsJson::buildcolumnsfromguide(guideEntries, |
| | | std::string(_pathCString), |
| | | "", |
| | | true, |
| | | false, |
| | | true, |
| | | &columns); |
| | | |
| | | if (columns.empty()) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("DBMS_JSON.CREATE_VIEW_ON_PATH found no scalar fields"), |
| | | errdetail("path=%s", _pathCString))); |
| | | } |
| | | |
| | | ddlText = DbmsJson::buildddl(viewOwnerName, |
| | | DbmsJson::normalizeidentifierinput(std::string(_viewNameCString)), |
| | | DbmsJson::buildselectsql(tableOwnerName, |
| | | tableName, |
| | | jsonColumnName, |
| | | std::string(_pathCString), |
| | | columns, |
| | | false), |
| | | false, |
| | | DBMS_JSON_MV_REFRESH_ON_STATEMENT); |
| | | |
| | | spiStatus = SPI_connect(); |
| | | if (spiStatus != SPI_OK_CONNECT) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("SPI_connect failed in DBMS_JSON.CREATE_VIEW_ON_PATH"), |
| | | errdetail("spi_status=%d", spiStatus))); |
| | | } |
| | | |
| | | executeStatus = SPI_execute(ddlText.c_str(), false, 0); |
| | | if (executeStatus != SPI_OK_UTILITY) { |
| | | SPI_finish(); |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("DBMS_JSON.CREATE_VIEW_ON_PATH failed"), |
| | | errdetail("spi_status=%d", executeStatus))); |
| | | } |
| | | |
| | | SPI_finish(); |
| | | |
| | | if (_viewNameCString != nullptr) { |
| | | pfree(_viewNameCString); |
| | | } |
| | | if (_tableNameCString != nullptr) { |
| | | pfree(_tableNameCString); |
| | | } |
| | | if (_jsonColumnNameCString != nullptr) { |
| | | pfree(_jsonColumnNameCString); |
| | | } |
| | | if (_pathCString != nullptr) { |
| | | pfree(_pathCString); |
| | | } |
| | | |
| | | PG_RETURN_VOID(); |
| | | } |
| | | |
| New file |
| | |
| | | #ifndef DBMS_JSON_INTERNAL_HPP |
| | | #define DBMS_JSON_INTERNAL_HPP |
| | | |
| | | extern "C" |
| | | { |
| | | #include "postgres.h" |
| | | #include "fmgr.h" |
| | | } |
| | | |
| | | extern "C" |
| | | { |
| | | Datum dbms_json_build_dataguide(PG_FUNCTION_ARGS); |
| | | Datum dbms_json_get_index_dataguide(PG_FUNCTION_ARGS); |
| | | Datum dbms_json_get_view_sql(PG_FUNCTION_ARGS); |
| | | Datum dbms_json_add_virtual_columns(PG_FUNCTION_ARGS); |
| | | Datum dbms_json_create_view(PG_FUNCTION_ARGS); |
| | | Datum dbms_json_create_view2(PG_FUNCTION_ARGS); |
| | | Datum dbms_json_drop_virtual_columns(PG_FUNCTION_ARGS); |
| | | Datum dbms_json_json_type_convertible_check(PG_FUNCTION_ARGS); |
| | | Datum dbms_json_rename_column(PG_FUNCTION_ARGS); |
| | | Datum dbms_json_create_view_on_path(PG_FUNCTION_ARGS); |
| | | } |
| | | |
| | | #endif // DBMS_JSON_INTERNAL_HPP |
| New file |
| | |
| | | -- Тест 1: Элементарный тест (создание простого представления) |
| | | SET SERVEROUTPUT ON |
| | | DECLARE |
| | | v_dg CLOB := '{"type":"object","properties":{"id":{"type":"number","o:length":4,"o:preferred_column_name":"id"}}}'; |
| | | v_res CLOB; |
| | | v_exp CLOB := 'CREATE OR REPLACE VIEW "HR"."V1" AS SELECT JT.* |
| | | FROM "HR"."T1" RT, |
| | | JSON_TABLE("J1", ''$[*]'' COLUMNS |
| | | "id" number path ''$.id'')JT'; |
| | | BEGIN |
| | | DBMS_OUTPUT.PUT_LINE('Expected: ' || v_exp); |
| | | v_res := DBMS_JSON.GET_VIEW_SQL('V1', 'T1', 'J1', v_dg); |
| | | DBMS_OUTPUT.PUT_LINE('Actual: ' || v_res); |
| | | END; |
| | | / |
| | | |
| | | -- Тест 2: Перегрузка с NULL (возвращает только SELECT) |
| | | SET SERVEROUTPUT ON |
| | | DECLARE |
| | | v_dg CLOB := '{"type":"object","properties":{"id":{"type":"number","o:length":4,"o:preferred_column_name":"id"}}}'; |
| | | v_res CLOB; |
| | | v_exp CLOB := 'SELECT JT.* |
| | | FROM "HR"."T1" RT, |
| | | JSON_TABLE("J1", ''$[*]'' COLUMNS |
| | | "id" number path ''$.id'')JT'; |
| | | BEGIN |
| | | DBMS_OUTPUT.PUT_LINE('Expected: ' || v_exp); |
| | | v_res := DBMS_JSON.GET_VIEW_SQL(NULL, 'T1', 'J1', v_dg); |
| | | DBMS_OUTPUT.PUT_LINE('Actual: ' || v_res); |
| | | END; |
| | | / |
| | | |
| | | -- Тест 3: Граничное условие (пустой набор узлов в Data Guide) |
| | | SET SERVEROUTPUT ON |
| | | DECLARE |
| | | v_dg CLOB := '{"type":"object","properties":{}}'; |
| | | v_res CLOB; |
| | | v_exp CLOB := ''; |
| | | BEGIN |
| | | DBMS_OUTPUT.PUT_LINE('Expected: ' || v_exp); |
| | | v_res := DBMS_JSON.GET_VIEW_SQL('V_EMPTY', 'T1', 'J1', v_dg); |
| | | DBMS_OUTPUT.PUT_LINE('Actual: ' || v_res); |
| | | END; |
| | | / |
| | | |
| | | -- Тест 4: Тест посложнее (несколько завершённых узлов) |
| | | SET SERVEROUTPUT ON |
| | | DECLARE |
| | | v_dg CLOB := '{"type":"object","properties":{"a":{"type":"number","o:length":4,"o:preferred_column_name":"a"},"b":{"type":"string","o:length":10,"o:preferred_column_name":"b"}}}'; |
| | | v_res CLOB; |
| | | v_exp CLOB := 'CREATE OR REPLACE VIEW "HR"."V_MULTI" AS SELECT JT.* |
| | | FROM "HR"."T1" RT, |
| | | JSON_TABLE("J1", ''$[*]'' COLUMNS |
| | | "a" number path ''$.a'', |
| | | "b" varchar2(10) path ''$.b'')JT'; |
| | | BEGIN |
| | | DBMS_OUTPUT.PUT_LINE('Expected: ' || v_exp); |
| | | v_res := DBMS_JSON.GET_VIEW_SQL('V_MULTI', 'T1', 'J1', v_dg); |
| | | DBMS_OUTPUT.PUT_LINE('Actual: ' || v_res); |
| | | END; |
| | | / |
| | | |
| | | -- Тест 5: Исправлено (параметр path требует наличия этого пути в структуре Data Guide) |
| | | SET SERVEROUTPUT ON |
| | | DECLARE |
| | | -- Чтобы path => '$.info' сработал, DG должен описывать структуру внутри 'info' |
| | | v_dg CLOB := '{"type":"object","properties":{"info":{"type":"object","properties":{"val":{"type":"number","o:length":4,"o:preferred_column_name":"val"}}}}}'; |
| | | v_res CLOB; |
| | | v_exp CLOB := 'CREATE OR REPLACE VIEW "HR"."V_PATH" AS SELECT JT.* |
| | | FROM "HR"."T1" RT, |
| | | JSON_TABLE("J1", ''$.info[*]'' COLUMNS |
| | | "val" number path ''$.val'')JT'; |
| | | BEGIN |
| | | DBMS_OUTPUT.PUT_LINE('Expected: ' || v_exp); |
| | | v_res := DBMS_JSON.GET_VIEW_SQL('V_PATH', 'T1', 'J1', v_dg, path => '$.info'); |
| | | DBMS_OUTPUT.PUT_LINE('Actual: ' || v_res); |
| | | END; |
| | | / |
| | | |
| | | -- Тест 6: Исправлено (параметр materialize => TRUE с точным соответствием вывода 23ai) |
| | | SET SERVEROUTPUT ON |
| | | DECLARE |
| | | v_dg CLOB := '{"type":"object","properties":{"id":{"type":"number","o:length":4,"o:preferred_column_name":"id"}}}'; |
| | | v_res CLOB; |
| | | -- В упрощенной реализации добавляются опции MV и ROWID. |
| | | v_exp CLOB := 'CREATE MATERIALIZED VIEW "HR"."V_MV" BUILD IMMEDIATE REFRESH FAST ON STATEMENT WITH ROWID |
| | | AS SELECT RT."ROWID" ROW_ID, JT.* |
| | | FROM "HR"."T1" RT, |
| | | JSON_TABLE("J1", ''$[*]'' COLUMNS |
| | | "id" number path ''$.id'')JT'; |
| | | BEGIN |
| | | DBMS_OUTPUT.PUT_LINE('Expected: ' || v_exp); |
| | | v_res := DBMS_JSON.GET_VIEW_SQL('V_MV', 'T1', 'J1', v_dg, materialize => TRUE); |
| | | DBMS_OUTPUT.PUT_LINE('Actual: ' || v_res); |
| | | END; |
| | | / |
| | | |
| | | -- Тест 7: Исключение при ошибке логики (конфликт имен при resolvenameconflicts => FALSE) |
| | | SET SERVEROUTPUT ON |
| | | DECLARE |
| | | v_dg CLOB := '{"type":"object","properties":{"f1":{"type":"number","o:length":4,"o:preferred_column_name":"col"},"f2":{"type":"number","o:length":4,"o:preferred_column_name":"col"}}}'; |
| | | v_res CLOB; |
| | | BEGIN |
| | | DBMS_OUTPUT.PUT_LINE('Expected: Caught exception'); |
| | | v_res := DBMS_JSON.GET_VIEW_SQL('V_ERR', 'T1', 'J1', v_dg, resolvenameconflicts => FALSE); |
| | | DBMS_OUTPUT.PUT_LINE('Actual: ' || v_res); |
| | | EXCEPTION |
| | | WHEN OTHERS THEN |
| | | DBMS_OUTPUT.PUT_LINE('Actual: Caught exception'); |
| | | END; |
| | | / |
| | | |
| | | -- Тест 8: Параметр colnameprefix |
| | | SET SERVEROUTPUT ON |
| | | DECLARE |
| | | v_dg CLOB := '{"type":"object","properties":{"item":{"type":"number","o:length":4,"o:preferred_column_name":"item"}}}'; |
| | | v_res CLOB; |
| | | v_exp CLOB := 'CREATE OR REPLACE VIEW "HR"."V_PRE" AS SELECT JT.* |
| | | FROM "HR"."T1" RT, |
| | | JSON_TABLE("J1", ''$[*]'' COLUMNS |
| | | "P_item" number path ''$.item'')JT'; |
| | | BEGIN |
| | | DBMS_OUTPUT.PUT_LINE('Expected: ' || v_exp); |
| | | v_res := DBMS_JSON.GET_VIEW_SQL('V_PRE', 'T1', 'J1', v_dg, colnameprefix => 'P_'); |
| | | DBMS_OUTPUT.PUT_LINE('Actual: ' || v_res); |
| | | END; |
| | | / |
| New file |
| | |
| | | #include "dbms_json_schema.hpp" |
| | | |
| | | extern "C" |
| | | { |
| | | #include "utils/builtins.h" |
| | | #include "utils/elog.h" |
| | | #include "utils/fmgroids.h" |
| | | #include "utils/jsonb.h" |
| | | #include "funcapi.h" |
| | | } // extern "C" |
| | | |
| | | #include "../nlohmann/json-schema.hpp" |
| | | |
| | | #include <algorithm> |
| | | #include <exception> |
| | | #include <memory> |
| | | #include <set> |
| | | #include <string> |
| | | #include <cstring> |
| | | #include <vector> |
| | | |
| | | extern "C" |
| | | { |
| | | PG_FUNCTION_INFO_V1(dbms_json_schema_is_schema_valid); |
| | | PG_FUNCTION_INFO_V1(dbms_json_schema_is_schema_valid2); |
| | | PG_FUNCTION_INFO_V1(dbms_json_schema_is_valid); |
| | | PG_FUNCTION_INFO_V1(dbms_json_schema_validate_report); |
| | | PG_FUNCTION_INFO_V1(dbms_json_schema_get_version); |
| | | } |
| | | |
| | | #define RUDB_DBMS_JSON_SCHEMA_VERSION "1.0.0" |
| | | #define DBMS_JSON_SCHEMA_VALID 1 |
| | | #define DBMS_JSON_SCHEMA_INVALID 0 |
| | | #define DBMS_JSON_SCHEMA_RAISE_NONE 0 |
| | | #define DBMS_JSON_SCHEMA_RAISE_ERROR 1 |
| | | |
| | | namespace DbmsJsonSchema |
| | | { |
| | | using JsonDocument = nlohmann::json; |
| | | using JsonValidator = nlohmann::json_schema::json_validator; |
| | | |
| | | struct ValidationIssue |
| | | { |
| | | std::string schemaPath_; |
| | | std::string instancePath_; |
| | | std::string code_; |
| | | std::string error_; |
| | | }; |
| | | |
| | | struct ValidationResult |
| | | { |
| | | bool schemaValid_{false}; |
| | | bool dataValid_{false}; |
| | | JsonDocument errorsReport_; |
| | | std::string reportText_; |
| | | }; |
| | | |
| | | class CollectingErrorHandler : public nlohmann::json_schema::error_handler |
| | | { |
| | | public: |
| | | explicit CollectingErrorHandler(const JsonDocument *schema_document) |
| | | : schemaDocument_(schema_document) |
| | | { |
| | | } |
| | | |
| | | std::vector<ValidationIssue> issues_; |
| | | |
| | | void error(const nlohmann::json::json_pointer &ptr, |
| | | const JsonDocument &instance, |
| | | const std::string &message) override |
| | | { |
| | | issues_.push_back(buildIssue(ptr, schemaDocument_, instance, message)); |
| | | } |
| | | |
| | | private: |
| | | const JsonDocument *schemaDocument_{nullptr}; |
| | | |
| | | static bool |
| | | isnumerictoken(const std::string &token) |
| | | { |
| | | return !token.empty() && |
| | | std::all_of(token.begin(), token.end(), [](unsigned char ch) { return std::isdigit(ch) != 0; }); |
| | | } |
| | | |
| | | static std::vector<std::string> |
| | | splitpointertokens(const nlohmann::json::json_pointer &ptr) |
| | | { |
| | | std::vector<std::string> tokens; |
| | | std::string pointerString = ptr.to_string(); |
| | | |
| | | if (pointerString.empty()) { |
| | | return tokens; |
| | | } |
| | | |
| | | std::size_t startPos = 1; |
| | | |
| | | while (startPos <= pointerString.size()) { |
| | | std::size_t slashPos = pointerString.find('/', startPos); |
| | | std::string token = pointerString.substr(startPos, slashPos - startPos); |
| | | |
| | | std::size_t replacePos = 0; |
| | | while ((replacePos = token.find("~1", replacePos)) != std::string::npos) { |
| | | token.replace(replacePos, 2, "/"); |
| | | replacePos += 1; |
| | | } |
| | | |
| | | replacePos = 0; |
| | | while ((replacePos = token.find("~0", replacePos)) != std::string::npos) { |
| | | token.replace(replacePos, 2, "~"); |
| | | replacePos += 1; |
| | | } |
| | | |
| | | tokens.push_back(token); |
| | | |
| | | if (slashPos == std::string::npos) { |
| | | break; |
| | | } |
| | | |
| | | startPos = slashPos + 1; |
| | | } |
| | | |
| | | return tokens; |
| | | } |
| | | |
| | | static std::string |
| | | buildpropertyschemapath(const std::vector<std::string> &tokens, |
| | | bool appendType, |
| | | bool parentOnly) |
| | | { |
| | | std::string schemaPath = "$"; |
| | | std::size_t limit = tokens.size(); |
| | | |
| | | if (parentOnly && limit > 0) { |
| | | limit -= 1; |
| | | } |
| | | |
| | | for (std::size_t index = 0; index < limit; ++index) { |
| | | if (isnumerictoken(tokens[index])) { |
| | | schemaPath += ".items"; |
| | | } else { |
| | | schemaPath += ".properties." + tokens[index]; |
| | | } |
| | | } |
| | | |
| | | if (parentOnly) { |
| | | schemaPath += ".properties"; |
| | | } else if (appendType) { |
| | | schemaPath += ".type"; |
| | | } |
| | | |
| | | return schemaPath; |
| | | } |
| | | |
| | | static std::string |
| | | jsonpointertostring(const nlohmann::json::json_pointer &ptr) |
| | | { |
| | | std::vector<std::string> tokens = splitpointertokens(ptr); |
| | | std::string pointerString = "$"; |
| | | |
| | | for (const std::string &token : tokens) { |
| | | if (isnumerictoken(token)) { |
| | | pointerString += "[" + token + "]"; |
| | | } else { |
| | | pointerString += "." + token; |
| | | } |
| | | } |
| | | |
| | | return pointerString; |
| | | } |
| | | |
| | | static std::string |
| | | jsonvaluetypename(const JsonDocument &value) |
| | | { |
| | | switch (value.type()) { |
| | | case JsonDocument::value_t::null: |
| | | return "null"; |
| | | case JsonDocument::value_t::object: |
| | | return "object"; |
| | | case JsonDocument::value_t::array: |
| | | return "array"; |
| | | case JsonDocument::value_t::string: |
| | | return "string"; |
| | | case JsonDocument::value_t::boolean: |
| | | return "boolean"; |
| | | case JsonDocument::value_t::number_integer: |
| | | case JsonDocument::value_t::number_unsigned: |
| | | case JsonDocument::value_t::number_float: |
| | | return "number"; |
| | | case JsonDocument::value_t::binary: |
| | | return "binary"; |
| | | case JsonDocument::value_t::discarded: |
| | | return "discarded"; |
| | | } |
| | | |
| | | return "unknown"; |
| | | } |
| | | |
| | | static std::string |
| | | resolveexpectedtypefromschema(const JsonDocument *schema_document, |
| | | const std::vector<std::string> &tokens) |
| | | { |
| | | const JsonDocument *currentNode = schema_document; |
| | | |
| | | if (currentNode == nullptr) { |
| | | return ""; |
| | | } |
| | | |
| | | for (const std::string &token : tokens) { |
| | | if (isnumerictoken(token)) { |
| | | if (!currentNode->is_object() || !currentNode->contains("items")) { |
| | | return ""; |
| | | } |
| | | |
| | | currentNode = &(*currentNode)["items"]; |
| | | } else { |
| | | if (!currentNode->is_object() || !currentNode->contains("properties")) { |
| | | return ""; |
| | | } |
| | | |
| | | const JsonDocument &propertiesNode = (*currentNode)["properties"]; |
| | | if (!propertiesNode.is_object() || !propertiesNode.contains(token)) { |
| | | return ""; |
| | | } |
| | | |
| | | currentNode = &propertiesNode[token]; |
| | | } |
| | | } |
| | | |
| | | if (!currentNode->is_object() || !currentNode->contains("type")) { |
| | | return ""; |
| | | } |
| | | |
| | | if ((*currentNode)["type"].is_string()) { |
| | | return (*currentNode)["type"].get<std::string>(); |
| | | } |
| | | |
| | | return ""; |
| | | } |
| | | |
| | | static ValidationIssue |
| | | buildIssue(const nlohmann::json::json_pointer &ptr, |
| | | const JsonDocument *schema_document, |
| | | const JsonDocument &instance, |
| | | const std::string &message) |
| | | { |
| | | ValidationIssue issue; |
| | | std::vector<std::string> tokens = splitpointertokens(ptr); |
| | | |
| | | issue.instancePath_ = jsonpointertostring(ptr); |
| | | issue.schemaPath_ = "$"; |
| | | |
| | | if (message.rfind("unexpected instance type", 0) == 0) { |
| | | std::string expectedType = resolveexpectedtypefromschema(schema_document, tokens); |
| | | |
| | | issue.code_ = "JZN-00503"; |
| | | issue.schemaPath_ = buildpropertyschemapath(tokens, true, false); |
| | | issue.error_ = "invalid type found, actual: " + jsonvaluetypename(instance) + |
| | | ", expected: " + (expectedType.empty() ? "unknown" : expectedType); |
| | | } else if (message.rfind("required property '", 0) == 0) { |
| | | issue.code_ = "JZN-00515"; |
| | | issue.schemaPath_ = "$.required"; |
| | | issue.error_ = message; |
| | | } else if (message.rfind("validation failed for additional property '", 0) == 0) { |
| | | issue.code_ = "JZN-00514"; |
| | | issue.error_ = message; |
| | | } else { |
| | | issue.code_ = "JZN-00501"; |
| | | issue.error_ = message; |
| | | } |
| | | |
| | | return issue; |
| | | } |
| | | }; |
| | | |
| | | static void |
| | | noopFormatCheck(const std::string &format_name, const std::string &format_value) |
| | | { |
| | | (void) format_name; |
| | | (void) format_value; |
| | | } |
| | | |
| | | static void |
| | | noopContentCheck(const std::string &content_encoding, |
| | | const std::string &content_media_type, |
| | | const JsonDocument &instance_value) |
| | | { |
| | | (void) content_encoding; |
| | | (void) content_media_type; |
| | | (void) instance_value; |
| | | } |
| | | |
| | | static char * |
| | | jsonbtocstringcopy(Jsonb *jsonb_value) |
| | | { |
| | | char *jsonCString = JsonbToCString(NULL, &jsonb_value->root, VARSIZE(jsonb_value)); |
| | | |
| | | if (jsonCString == nullptr) |
| | | { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INTERNAL_ERROR), |
| | | errmsg("DBMS_JSON_SCHEMA.IS_SCHEMA_VALID failed to serialize jsonb"))); |
| | | } |
| | | |
| | | return jsonCString; |
| | | } |
| | | |
| | | static JsonDocument |
| | | parsejsondocument(const char *json_data) |
| | | { |
| | | try { |
| | | return JsonDocument::parse(json_data); |
| | | } catch (const std::exception &ex) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), |
| | | errmsg("invalid JSON input"), |
| | | errdetail("%s", ex.what()))); |
| | | } |
| | | |
| | | return JsonDocument(); |
| | | } |
| | | |
| | | static bool |
| | | isschemavaliddocument(const JsonDocument &schemaDocument) |
| | | { |
| | | JsonValidator metaValidator(nullptr, noopFormatCheck, noopContentCheck); |
| | | nlohmann::json_schema::basic_error_handler metaErrorHandler; |
| | | JsonValidator validator(nullptr, noopFormatCheck, noopContentCheck); |
| | | |
| | | metaValidator.set_root_schema(nlohmann::json_schema::draft7_schema_builtin); |
| | | metaValidator.validate(schemaDocument, metaErrorHandler); |
| | | |
| | | if (metaErrorHandler) { |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON_SCHEMA schema meta-validation"), |
| | | errdetail("status=invalid"))); |
| | | return false; |
| | | } |
| | | |
| | | validator.set_root_schema(schemaDocument); |
| | | return true; |
| | | } |
| | | |
| | | static JsonDocument |
| | | builderrorsreport(const CollectingErrorHandler &errorHandler) |
| | | { |
| | | JsonDocument reportDocument = JsonDocument::object(); |
| | | JsonDocument issuesArray = JsonDocument::array(); |
| | | std::set<std::string> invalidProperties; |
| | | |
| | | reportDocument["valid"] = errorHandler.issues_.empty(); |
| | | |
| | | if (!errorHandler.issues_.empty()) { |
| | | JsonDocument rootIssue = JsonDocument::object(); |
| | | rootIssue["schemaPath"] = "$"; |
| | | rootIssue["instancePath"] = "$"; |
| | | rootIssue["code"] = "JZN-00501"; |
| | | rootIssue["error"] = "JSON schema validation failed"; |
| | | issuesArray.push_back(rootIssue); |
| | | } |
| | | |
| | | for (const ValidationIssue &issue : errorHandler.issues_) { |
| | | if (issue.code_ == "JZN-00503" && |
| | | issue.instancePath_.rfind("$.", 0) == 0) { |
| | | invalidProperties.insert(issue.instancePath_.substr(2)); |
| | | } |
| | | } |
| | | |
| | | for (const std::string &invalidProperty : invalidProperties) { |
| | | JsonDocument propertyIssue = JsonDocument::object(); |
| | | propertyIssue["schemaPath"] = "$.properties"; |
| | | propertyIssue["instancePath"] = "$"; |
| | | propertyIssue["code"] = "JZN-00514"; |
| | | propertyIssue["error"] = "invalid properties: ''" + invalidProperty + "''"; |
| | | issuesArray.push_back(propertyIssue); |
| | | } |
| | | |
| | | for (const ValidationIssue &issue : errorHandler.issues_) { |
| | | JsonDocument issueDocument = JsonDocument::object(); |
| | | issueDocument["schemaPath"] = issue.schemaPath_; |
| | | issueDocument["instancePath"] = issue.instancePath_; |
| | | issueDocument["code"] = issue.code_; |
| | | issueDocument["error"] = issue.error_; |
| | | issuesArray.push_back(issueDocument); |
| | | } |
| | | |
| | | reportDocument["errors"] = issuesArray; |
| | | |
| | | return reportDocument; |
| | | } |
| | | |
| | | static std::string |
| | | jsonquotestring(const std::string &value) |
| | | { |
| | | return JsonDocument(value).dump(); |
| | | } |
| | | |
| | | static std::string |
| | | serializereporttext(const CollectingErrorHandler &errorHandler) |
| | | { |
| | | std::string reportText = "{\"valid\":"; |
| | | std::set<std::string> invalidProperties; |
| | | |
| | | reportText += errorHandler.issues_.empty() ? "true" : "false"; |
| | | reportText += ",\"errors\":["; |
| | | |
| | | if (!errorHandler.issues_.empty()) { |
| | | reportText += "{\"schemaPath\":\"$\",\"instancePath\":\"$\",\"code\":\"JZN-00501\",\"error\":\"JSON schema validation failed\"}"; |
| | | } |
| | | |
| | | for (const ValidationIssue &issue : errorHandler.issues_) { |
| | | if (issue.code_ == "JZN-00503" && |
| | | issue.instancePath_.rfind("$.", 0) == 0) { |
| | | invalidProperties.insert(issue.instancePath_.substr(2)); |
| | | } |
| | | } |
| | | |
| | | for (const std::string &invalidProperty : invalidProperties) { |
| | | if (reportText.back() != '[') { |
| | | reportText += ","; |
| | | } |
| | | |
| | | reportText += "{\"schemaPath\":\"$.properties\",\"instancePath\":\"$\",\"code\":\"JZN-00514\",\"error\":"; |
| | | reportText += jsonquotestring("invalid properties:\n'" + invalidProperty + "'"); |
| | | reportText += "}"; |
| | | } |
| | | |
| | | for (const ValidationIssue &issue : errorHandler.issues_) { |
| | | if (reportText.back() != '[') { |
| | | reportText += ","; |
| | | } |
| | | |
| | | reportText += "{\"schemaPath\":"; |
| | | reportText += jsonquotestring(issue.schemaPath_); |
| | | reportText += ",\"instancePath\":"; |
| | | reportText += jsonquotestring(issue.instancePath_); |
| | | reportText += ",\"code\":"; |
| | | reportText += jsonquotestring(issue.code_); |
| | | reportText += ",\"error\":"; |
| | | reportText += jsonquotestring(issue.error_); |
| | | reportText += "}"; |
| | | } |
| | | |
| | | reportText += "]}"; |
| | | return reportText; |
| | | } |
| | | |
| | | static ValidationResult |
| | | validatejsondocument(const JsonDocument &dataDocument, |
| | | const JsonDocument &schemaDocument) |
| | | { |
| | | ValidationResult result; |
| | | JsonValidator validator(nullptr, noopFormatCheck, noopContentCheck); |
| | | CollectingErrorHandler errorHandler(&schemaDocument); |
| | | |
| | | result.schemaValid_ = isschemavaliddocument(schemaDocument); |
| | | |
| | | if (!result.schemaValid_) { |
| | | result.dataValid_ = false; |
| | | result.errorsReport_ = JsonDocument::object({ |
| | | {"valid", false}, |
| | | {"errors", JsonDocument::array()} |
| | | }); |
| | | return result; |
| | | } |
| | | |
| | | validator.set_root_schema(schemaDocument); |
| | | validator.validate(dataDocument, errorHandler); |
| | | |
| | | result.dataValid_ = errorHandler.issues_.empty(); |
| | | result.errorsReport_ = builderrorsreport(errorHandler); |
| | | result.reportText_ = serializereporttext(errorHandler); |
| | | |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON_SCHEMA validation result"), |
| | | errdetail("schema_valid=%s, data_valid=%s, issues=%zu", |
| | | result.schemaValid_ ? "true" : "false", |
| | | result.dataValid_ ? "true" : "false", |
| | | errorHandler.issues_.size()))); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | static ValidationResult |
| | | validatecstringinput(const char *json_data, |
| | | const char *json_schema) |
| | | { |
| | | JsonDocument dataDocument = parsejsondocument(json_data); |
| | | JsonDocument schemaDocument = parsejsondocument(json_schema); |
| | | |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON_SCHEMA validation text input"), |
| | | errdetail("json_length=%zu, schema_length=%zu", |
| | | strlen(json_data), |
| | | strlen(json_schema)))); |
| | | |
| | | return validatejsondocument(dataDocument, schemaDocument); |
| | | } |
| | | |
| | | static Jsonb * |
| | | jsondocumenttojsonb(const JsonDocument &document) |
| | | { |
| | | std::string jsonText = document.dump(); |
| | | Datum jsonbDatum = DirectFunctionCall1(jsonb_in, CStringGetDatum(jsonText.c_str())); |
| | | |
| | | return DatumGetJsonbP(jsonbDatum); |
| | | } |
| | | |
| | | static text * |
| | | jsondocumenttotext(const JsonDocument &document) |
| | | { |
| | | return cstring_to_text(document.dump(-1, ' ', false, JsonDocument::error_handler_t::strict).c_str()); |
| | | } |
| | | |
| | | static bool |
| | | isschemavalidinternal(Jsonb *json_schema) |
| | | { |
| | | char *jsonCString = jsonbtocstringcopy(json_schema); |
| | | JsonDocument schemaDocument; |
| | | bool resultValue = false; |
| | | |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON_SCHEMA.IS_SCHEMA_VALID input"), |
| | | errdetail("schema_length=%zu", strlen(jsonCString)))); |
| | | |
| | | schemaDocument = parsejsondocument(jsonCString); |
| | | resultValue = isschemavaliddocument(schemaDocument); |
| | | |
| | | if (!resultValue) { |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON_SCHEMA.IS_SCHEMA_VALID meta-schema check"), |
| | | errdetail("status=invalid"))); |
| | | } else { |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON_SCHEMA.IS_SCHEMA_VALID result"), |
| | | errdetail("status=valid"))); |
| | | } |
| | | |
| | | if (jsonCString != nullptr) { |
| | | pfree(jsonCString); |
| | | } |
| | | |
| | | return resultValue; |
| | | } |
| | | |
| | | static ValidationResult |
| | | isvalidinternal(Jsonb *json_data, |
| | | Jsonb *json_schema) |
| | | { |
| | | char *dataCString = jsonbtocstringcopy(json_data); |
| | | char *schemaCString = jsonbtocstringcopy(json_schema); |
| | | JsonDocument dataDocument; |
| | | JsonDocument schemaDocument; |
| | | ValidationResult validationResult; |
| | | |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON_SCHEMA.IS_VALID input"), |
| | | errdetail("json_length=%zu, schema_length=%zu", |
| | | strlen(dataCString), |
| | | strlen(schemaCString)))); |
| | | |
| | | dataDocument = parsejsondocument(dataCString); |
| | | schemaDocument = parsejsondocument(schemaCString); |
| | | validationResult = validatejsondocument(dataDocument, schemaDocument); |
| | | |
| | | if (dataCString != nullptr) { |
| | | pfree(dataCString); |
| | | } |
| | | |
| | | if (schemaCString != nullptr) { |
| | | pfree(schemaCString); |
| | | } |
| | | |
| | | return validationResult; |
| | | } |
| | | } // namespace DbmsJsonSchema |
| | | |
| | | /* |
| | | * @qdb_func: dbms_json_schema_is_schema_valid(jsonb) |
| | | * @ora_func: DBMS_JSON_SCHEMA.IS_SCHEMA_VALID(JSON) |
| | | */ |
| | | Datum |
| | | dbms_json_schema_is_schema_valid(PG_FUNCTION_ARGS) |
| | | { |
| | | Jsonb *jsonSchema = nullptr; |
| | | bool isValid = false; |
| | | |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON_SCHEMA.IS_SCHEMA_VALID call"), |
| | | errdetail("nargs=%d, arg0_is_null=%s", |
| | | PG_NARGS(), |
| | | PG_ARGISNULL(0) ? "true" : "false"))); |
| | | |
| | | if (PG_ARGISNULL(0)) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), |
| | | errmsg("ORA-64403: input cannot be NULL"))); |
| | | } |
| | | |
| | | jsonSchema = PG_GETARG_JSONB_P_COPY(0); |
| | | isValid = DbmsJsonSchema::isschemavalidinternal(jsonSchema); |
| | | |
| | | if (jsonSchema != nullptr) { |
| | | pfree(jsonSchema); |
| | | } |
| | | |
| | | PG_RETURN_INT32(isValid ? DBMS_JSON_SCHEMA_VALID : DBMS_JSON_SCHEMA_INVALID); |
| | | } |
| | | |
| | | Datum |
| | | dbms_json_schema_is_schema_valid2(PG_FUNCTION_ARGS) |
| | | { |
| | | int32 serviceArg = 0; |
| | | |
| | | if (PG_NARGS() != 2) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("DBMS_JSON_SCHEMA.IS_SCHEMA_VALID2 accepts exactly 2 arguments"))); |
| | | } |
| | | |
| | | if (!PG_ARGISNULL(1)) { |
| | | serviceArg = PG_GETARG_INT32(1); |
| | | } |
| | | (void) serviceArg; |
| | | |
| | | { |
| | | LOCAL_FCINFO(fcinfo2, 1); |
| | | |
| | | InitFunctionCallInfoData(*fcinfo2, nullptr, 1, InvalidOid, nullptr, nullptr); |
| | | fcinfo2->args[0].value = PG_GETARG_DATUM(0); |
| | | fcinfo2->args[0].isnull = PG_ARGISNULL(0); |
| | | |
| | | return dbms_json_schema_is_schema_valid(fcinfo2); |
| | | } |
| | | } |
| | | |
| | | Datum |
| | | dbms_json_schema_is_valid(PG_FUNCTION_ARGS) |
| | | { |
| | | Jsonb *jsonData = nullptr; |
| | | Jsonb *jsonSchema = nullptr; |
| | | int32 raiseErr = DBMS_JSON_SCHEMA_RAISE_NONE; |
| | | DbmsJsonSchema::ValidationResult validationResult; |
| | | |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON_SCHEMA.IS_VALID function call"), |
| | | errdetail("nargs=%d, arg0_is_null=%s, arg1_is_null=%s, arg2_is_null=%s", |
| | | PG_NARGS(), |
| | | PG_ARGISNULL(0) ? "true" : "false", |
| | | PG_ARGISNULL(1) ? "true" : "false", |
| | | (PG_NARGS() > 2 && PG_ARGISNULL(2)) ? "true" : "false"))); |
| | | |
| | | if (PG_ARGISNULL(0) || PG_ARGISNULL(1)) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), |
| | | errmsg("ORA-64403: input cannot be NULL"))); |
| | | } |
| | | |
| | | if (PG_NARGS() > 2 && !PG_ARGISNULL(2)) { |
| | | raiseErr = PG_GETARG_INT32(2); |
| | | } |
| | | |
| | | if (raiseErr != DBMS_JSON_SCHEMA_RAISE_NONE && |
| | | raiseErr != DBMS_JSON_SCHEMA_RAISE_ERROR) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("DBMS_JSON_SCHEMA.IS_VALID invalid raise_err"), |
| | | errdetail("raise_err=%d", raiseErr))); |
| | | } |
| | | |
| | | jsonData = PG_GETARG_JSONB_P_COPY(0); |
| | | jsonSchema = PG_GETARG_JSONB_P_COPY(1); |
| | | |
| | | validationResult = DbmsJsonSchema::isvalidinternal(jsonData, jsonSchema); |
| | | |
| | | if (jsonData != nullptr) { |
| | | pfree(jsonData); |
| | | } |
| | | |
| | | if (jsonSchema != nullptr) { |
| | | pfree(jsonSchema); |
| | | } |
| | | |
| | | if (!validationResult.schemaValid_ && |
| | | raiseErr == DBMS_JSON_SCHEMA_RAISE_ERROR) { |
| | | ereport(ERROR, |
| | | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| | | errmsg("JSON schema validation failed"), |
| | | errdetail("raise_err=RAISE_ERROR requested exception for invalid schema"))); |
| | | } |
| | | |
| | | PG_RETURN_INT32(validationResult.dataValid_ ? DBMS_JSON_SCHEMA_VALID |
| | | : DBMS_JSON_SCHEMA_INVALID); |
| | | } |
| | | |
| | | Datum |
| | | dbms_json_schema_validate_report(PG_FUNCTION_ARGS) |
| | | { |
| | | char *jsonSchemaCString = nullptr; |
| | | Jsonb *jsonDataJsonb = nullptr; |
| | | Jsonb *jsonSchemaJsonb = nullptr; |
| | | char *jsonDataCString = nullptr; |
| | | DbmsJsonSchema::ValidationResult validationResult; |
| | | bool useJsonbInput = false; |
| | | |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON_SCHEMA.VALIDATE_REPORT call"), |
| | | errdetail("nargs=%d, arg0_is_null=%s, arg1_is_null=%s", |
| | | PG_NARGS(), |
| | | PG_ARGISNULL(0) ? "true" : "false", |
| | | PG_ARGISNULL(1) ? "true" : "false"))); |
| | | |
| | | if (PG_ARGISNULL(0) || PG_ARGISNULL(1)) { |
| | | PG_RETURN_NULL(); |
| | | } |
| | | |
| | | useJsonbInput = |
| | | get_fn_expr_argtype(fcinfo->flinfo, 0) == JSONBOID && |
| | | get_fn_expr_argtype(fcinfo->flinfo, 1) == JSONBOID; |
| | | |
| | | if (useJsonbInput) { |
| | | jsonDataJsonb = PG_GETARG_JSONB_P_COPY(0); |
| | | jsonSchemaJsonb = PG_GETARG_JSONB_P_COPY(1); |
| | | jsonDataCString = DbmsJsonSchema::jsonbtocstringcopy(jsonDataJsonb); |
| | | jsonSchemaCString = DbmsJsonSchema::jsonbtocstringcopy(jsonSchemaJsonb); |
| | | } else { |
| | | text *jsonDataText = PG_GETARG_TEXT_PP(0); |
| | | text *jsonSchemaText = PG_GETARG_TEXT_PP(1); |
| | | jsonDataCString = text_to_cstring(jsonDataText); |
| | | jsonSchemaCString = text_to_cstring(jsonSchemaText); |
| | | } |
| | | |
| | | validationResult = DbmsJsonSchema::validatecstringinput(jsonDataCString, jsonSchemaCString); |
| | | |
| | | ereport(LOG, |
| | | (errmsg("DBMS_JSON_SCHEMA.VALIDATE_REPORT result"), |
| | | errdetail("valid=%s", |
| | | validationResult.dataValid_ ? "true" : "false"))); |
| | | |
| | | if (jsonDataCString != nullptr) { |
| | | pfree(jsonDataCString); |
| | | } |
| | | |
| | | if (jsonSchemaCString != nullptr) { |
| | | pfree(jsonSchemaCString); |
| | | } |
| | | |
| | | if (jsonDataJsonb != nullptr) { |
| | | pfree(jsonDataJsonb); |
| | | } |
| | | |
| | | if (jsonSchemaJsonb != nullptr) { |
| | | pfree(jsonSchemaJsonb); |
| | | } |
| | | |
| | | PG_RETURN_TEXT_P(cstring_to_text(validationResult.reportText_.c_str())); |
| | | } |
| | | |
| | | Datum |
| | | dbms_json_schema_get_version(PG_FUNCTION_ARGS) |
| | | { |
| | | PG_RETURN_TEXT_P(cstring_to_text(RUDB_DBMS_JSON_SCHEMA_VERSION)); |
| | | } |
| New file |
| | |
| | | #ifndef DBMS_JSON_SCHEMA_INTERNAL_HPP |
| | | #define DBMS_JSON_SCHEMA_INTERNAL_HPP |
| | | |
| | | extern "C" |
| | | { |
| | | #include "postgres.h" |
| | | #include "fmgr.h" |
| | | } // extern "C" |
| | | |
| | | extern "C" |
| | | { |
| | | Datum dbms_json_schema_is_schema_valid(PG_FUNCTION_ARGS); |
| | | Datum dbms_json_schema_is_schema_valid2(PG_FUNCTION_ARGS); |
| | | Datum dbms_json_schema_is_valid(PG_FUNCTION_ARGS); |
| | | Datum dbms_json_schema_validate_report(PG_FUNCTION_ARGS); |
| | | Datum dbms_json_schema_get_version(PG_FUNCTION_ARGS); |
| | | } // extern "C" |
| | | |
| | | #endif // DBMS_JSON_SCHEMA_INTERNAL_HPP |
| New file |
| | |
| | | -- ORACLE |
| | | -- Тест 1: Элементарный (Валидная схема типа string) |
| | | SET SERVEROUTPUT ON |
| | | DECLARE |
| | | v_res PLS_INTEGER; |
| | | BEGIN |
| | | DBMS_OUTPUT.PUT_LINE('Expected: 1'); |
| | | v_res := DBMS_JSON_SCHEMA.IS_SCHEMA_VALID(JSON('{"type": "string"}')); |
| | | DBMS_OUTPUT.PUT_LINE('Actual: ' || v_res); |
| | | END; |
| | | / |
| | | |
| | | -- Тест 2: Пустое значение (Проверка ORA-64403 при передаче NULL) |
| | | SET SERVEROUTPUT ON |
| | | DECLARE |
| | | v_res PLS_INTEGER; |
| | | v_input JSON := NULL; |
| | | BEGIN |
| | | DBMS_OUTPUT.PUT_LINE('Expected: Caught exception'); |
| | | BEGIN |
| | | v_res := DBMS_JSON_SCHEMA.IS_SCHEMA_VALID(v_input); |
| | | DBMS_OUTPUT.PUT_LINE('Actual: ' || v_res); |
| | | EXCEPTION |
| | | WHEN OTHERS THEN |
| | | DBMS_OUTPUT.PUT_LINE('Actual: Caught exception'); |
| | | -- ORA-64403: input cannot be NULL |
| | | END; |
| | | END; |
| | | / |
| | | |
| | | -- Тест 3: Граничное условие (Логически неверная схема - неверный тип данных в определении) |
| | | SET SERVEROUTPUT ON |
| | | DECLARE |
| | | v_res PLS_INTEGER; |
| | | BEGIN |
| | | DBMS_OUTPUT.PUT_LINE('Expected: 0'); |
| | | v_res := DBMS_JSON_SCHEMA.IS_SCHEMA_VALID(JSON('{"type": "invalid_type_name"}')); |
| | | DBMS_OUTPUT.PUT_LINE('Actual: ' || v_res); |
| | | END; |
| | | / |
| | | |
| | | -- Тест 4: Сложный JSON (Схема с вложенными узлами и ограничениями) |
| | | SET SERVEROUTPUT ON |
| | | DECLARE |
| | | v_res PLS_INTEGER; |
| | | v_schema JSON := JSON('{ |
| | | "type": "object", |
| | | "properties": { |
| | | "user": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": {"type": "integer"}, |
| | | "name": {"type": "string"} |
| | | }, |
| | | "required": ["id"] |
| | | } |
| | | } |
| | | }'); |
| | | BEGIN |
| | | DBMS_OUTPUT.PUT_LINE('Expected: 1'); |
| | | v_res := DBMS_JSON_SCHEMA.IS_SCHEMA_VALID(v_schema); |
| | | DBMS_OUTPUT.PUT_LINE('Actual: ' || v_res); |
| | | END; |
| | | / |
| | | |
| | | -- Тест 5: Исключение (Передача некорректного JSON синтаксиса в конструктор) |
| | | SET SERVEROUTPUT ON |
| | | DECLARE |
| | | v_res PLS_INTEGER; |
| | | BEGIN |
| | | DBMS_OUTPUT.PUT_LINE('Expected: Caught exception'); |
| | | BEGIN |
| | | v_res := DBMS_JSON_SCHEMA.IS_SCHEMA_VALID(JSON('{ "wrong" : }')); |
| | | DBMS_OUTPUT.PUT_LINE('Actual: ' || v_res); |
| | | EXCEPTION |
| | | WHEN OTHERS THEN |
| | | DBMS_OUTPUT.PUT_LINE('Actual: Caught exception'); |
| | | -- SQLCODE -40441 |
| | | END; |
| | | END; |
| | | / |
| New file |
| | |
| | | -- Test 1: Элементарный тест (Валидный JSON) |
| | | SET SERVEROUTPUT ON |
| | | DECLARE |
| | | v_data VARCHAR2(100) := '{"a": 1}'; |
| | | v_schema VARCHAR2(100) := '{"type": "object", "properties": {"a": {"type": "number"}}}'; |
| | | v_result VARCHAR2(4000); |
| | | BEGIN |
| | | DBMS_OUTPUT.PUT_LINE('Expected: {"valid":true,"errors":[]}'); |
| | | v_result := JSON_SERIALIZE(DBMS_JSON_SCHEMA.VALIDATE_REPORT(v_data, v_schema)); |
| | | DBMS_OUTPUT.PUT_LINE('Actual: ' || v_result); |
| | | END; |
| | | / |
| | | |
| | | -- Test 2: Элементарный тест (Невалидный JSON по схеме) |
| | | SET SERVEROUTPUT ON |
| | | DECLARE |
| | | v_data VARCHAR2(100) := '{"a": "str"}'; |
| | | v_schema VARCHAR2(100) := '{"type": "object", "properties": {"a": {"type": "number"}}}'; |
| | | v_result VARCHAR2(4000); |
| | | BEGIN |
| | | DBMS_OUTPUT.PUT_LINE('Expected: {"valid":false,"errors":[{"schemaPath":"$","instancePath":"$","code":"JZN-00501","error":"JSON schema validation |
| | | failed"},{"schemaPath":"$.properties","instancePath":"$","code":"JZN-00514","error":"invalid properties: |
| | | ''a''"},{"schemaPath":"$.properties.a.type","instancePath":"$.a","code":"JZN-00503","error":"invalid type found, actual: string, expected: number"}]}'); |
| | | v_result := JSON_SERIALIZE(DBMS_JSON_SCHEMA.VALIDATE_REPORT(v_data, v_schema)); |
| | | DBMS_OUTPUT.PUT_LINE('Actual: ' || v_result); |
| | | END; |
| | | / |
| | | |
| | | -- Test 3: Граничные условия (Пустые JSON объекты) |
| | | SET SERVEROUTPUT ON |
| | | DECLARE |
| | | v_data VARCHAR2(100) := '{}'; |
| | | v_schema VARCHAR2(100) := '{}'; |
| | | v_result VARCHAR2(4000); |
| | | BEGIN |
| | | DBMS_OUTPUT.PUT_LINE('Expected: {"valid":true,"errors":[]}'); |
| | | v_result := JSON_SERIALIZE(DBMS_JSON_SCHEMA.VALIDATE_REPORT(v_data, v_schema)); |
| | | DBMS_OUTPUT.PUT_LINE('Actual: ' || v_result); |
| | | END; |
| | | / |
| | | |
| | | -- Test 4: Граничные условия (Передача NULL) |
| | | SET SERVEROUTPUT ON |
| | | DECLARE |
| | | v_data VARCHAR2(100) := NULL; |
| | | v_schema VARCHAR2(100) := NULL; |
| | | v_result VARCHAR2(4000); |
| | | BEGIN |
| | | DBMS_OUTPUT.PUT_LINE('Expected: NULL'); |
| | | v_result := JSON_SERIALIZE(DBMS_JSON_SCHEMA.VALIDATE_REPORT(v_data, v_schema)); |
| | | |
| | | IF v_result IS NULL THEN |
| | | DBMS_OUTPUT.PUT_LINE('Actual: NULL'); |
| | | ELSE |
| | | DBMS_OUTPUT.PUT_LINE('Actual: ' || v_result); |
| | | END IF; |
| | | EXCEPTION |
| | | WHEN OTHERS THEN |
| | | DBMS_OUTPUT.PUT_LINE('Actual: Caught exception'); |
| | | END; |
| | | / |
| | | |
| | | -- Test 5: Тест посложнее (Массивы, вложенные узлы, enum, required) |
| | | SET SERVEROUTPUT ON |
| | | DECLARE |
| | | v_data VARCHAR2(4000) := '{"user":{"id":10,"roles":["admin","user"]},"active":true}'; |
| | | v_schema VARCHAR2(4000) := '{"type":"object","properties":{"user":{"type":"object","properties":{"id":{"type":"integer"},"roles":{"type":"array","items":{"type":"string","enum":["admin","user","guest"]}}},"required":["id","roles"]},"active":{"type":"boolean"}},"required":["user","active"]}'; |
| | | v_result VARCHAR2(4000); |
| | | BEGIN |
| | | DBMS_OUTPUT.PUT_LINE('Expected: {"valid":true,"errors":[]}'); |
| | | v_result := JSON_SERIALIZE(DBMS_JSON_SCHEMA.VALIDATE_REPORT(v_data, v_schema)); |
| | | DBMS_OUTPUT.PUT_LINE('Actual: ' || v_result); |
| | | END; |
| | | / |
| | | |
| | | -- Test 6: Проверка перегрузки (Тип данных JSON вместо VARCHAR2) |
| | | SET SERVEROUTPUT ON |
| | | DECLARE |
| | | v_data JSON := JSON('{"name":"Test"}'); |
| | | v_schema JSON := JSON('{"type":"object","required":["name"]}'); |
| | | v_result VARCHAR2(4000); |
| | | BEGIN |
| | | DBMS_OUTPUT.PUT_LINE('Expected: {"valid":true,"errors":[]}'); |
| | | v_result := JSON_SERIALIZE(DBMS_JSON_SCHEMA.VALIDATE_REPORT(v_data, v_schema)); |
| | | DBMS_OUTPUT.PUT_LINE('Actual: ' || v_result); |
| | | END; |
| | | / |
| | | |
| | | -- Test 7: Исключение (Синтаксическая ошибка в данных JSON) |
| | | SET SERVEROUTPUT ON |
| | | DECLARE |
| | | v_data VARCHAR2(100) := '{invalid_json}'; |
| | | v_schema VARCHAR2(100) := '{"type":"object"}'; |
| | | v_result VARCHAR2(4000); |
| | | BEGIN |
| | | DBMS_OUTPUT.PUT_LINE('Expected: Caught exception'); |
| | | v_result := JSON_SERIALIZE(DBMS_JSON_SCHEMA.VALIDATE_REPORT(v_data, v_schema)); |
| | | DBMS_OUTPUT.PUT_LINE('Actual: ' || v_result); |
| | | EXCEPTION |
| | | WHEN OTHERS THEN |
| | | DBMS_OUTPUT.PUT_LINE('Actual: Caught exception'); |
| | | END; |
| | | / |
| | | |
| | | -- Test 8: Исключение (Синтаксическая ошибка в схеме JSON) |
| | | SET SERVEROUTPUT ON |
| | | DECLARE |
| | | v_data VARCHAR2(100) := '{"a":1}'; |
| | | v_schema VARCHAR2(100) := '{"type": "object", "properties": { invalid } }'; |
| | | v_result VARCHAR2(4000); |
| | | BEGIN |
| | | DBMS_OUTPUT.PUT_LINE('Expected: Caught exception'); |
| | | v_result := JSON_SERIALIZE(DBMS_JSON_SCHEMA.VALIDATE_REPORT(v_data, v_schema)); |
| | | DBMS_OUTPUT.PUT_LINE('Actual: ' || v_result); |
| | | EXCEPTION |
| | | WHEN OTHERS THEN |
| | | DBMS_OUTPUT.PUT_LINE('Actual: Caught exception'); |
| | | END; |
| | | / |
| New file |
| | |
| | | #include "json-patch.hpp" |
| | | |
| | | #include <nlohmann/json-schema.hpp> |
| | | |
| | | namespace |
| | | { |
| | | |
| | | // originally from http://jsonpatch.com/, http://json.schemastore.org/json-patch |
| | | // with fixes |
| | | const nlohmann::json patch_schema = R"patch({ |
| | | "title": "JSON schema for JSONPatch files", |
| | | "$schema": "http://json-schema.org/draft-04/schema#", |
| | | "type": "array", |
| | | |
| | | "items": { |
| | | "oneOf": [ |
| | | { |
| | | "additionalProperties": false, |
| | | "required": [ "value", "op", "path"], |
| | | "properties": { |
| | | "path" : { "$ref": "#/definitions/path" }, |
| | | "op": { |
| | | "description": "The operation to perform.", |
| | | "type": "string", |
| | | "enum": [ "add", "replace", "test" ] |
| | | }, |
| | | "value": { |
| | | "description": "The value to add, replace or test." |
| | | } |
| | | } |
| | | }, |
| | | { |
| | | "additionalProperties": false, |
| | | "required": [ "op", "path"], |
| | | "properties": { |
| | | "path" : { "$ref": "#/definitions/path" }, |
| | | "op": { |
| | | "description": "The operation to perform.", |
| | | "type": "string", |
| | | "enum": [ "remove" ] |
| | | } |
| | | } |
| | | }, |
| | | { |
| | | "additionalProperties": false, |
| | | "required": [ "from", "op", "path" ], |
| | | "properties": { |
| | | "path" : { "$ref": "#/definitions/path" }, |
| | | "op": { |
| | | "description": "The operation to perform.", |
| | | "type": "string", |
| | | "enum": [ "move", "copy" ] |
| | | }, |
| | | "from": { |
| | | "$ref": "#/definitions/path", |
| | | "description": "A JSON Pointer path pointing to the location to move/copy from." |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | }, |
| | | "definitions": { |
| | | "path": { |
| | | "description": "A JSON Pointer path.", |
| | | "type": "string" |
| | | } |
| | | } |
| | | })patch"_json; |
| | | } // namespace |
| | | |
| | | namespace nlohmann |
| | | { |
| | | |
| | | json_patch::json_patch(json &&patch) |
| | | : j_(std::move(patch)) |
| | | { |
| | | validateJsonPatch(j_); |
| | | } |
| | | |
| | | json_patch::json_patch(const json &patch) |
| | | : j_(std::move(patch)) |
| | | { |
| | | validateJsonPatch(j_); |
| | | } |
| | | |
| | | json_patch &json_patch::add(const json::json_pointer &ptr, json value) |
| | | { |
| | | j_.push_back(json{{"op", "add"}, {"path", ptr.to_string()}, {"value", std::move(value)}}); |
| | | return *this; |
| | | } |
| | | |
| | | json_patch &json_patch::replace(const json::json_pointer &ptr, json value) |
| | | { |
| | | j_.push_back(json{{"op", "replace"}, {"path", ptr.to_string()}, {"value", std::move(value)}}); |
| | | return *this; |
| | | } |
| | | |
| | | json_patch &json_patch::remove(const json::json_pointer &ptr) |
| | | { |
| | | j_.push_back(json{{"op", "remove"}, {"path", ptr.to_string()}}); |
| | | return *this; |
| | | } |
| | | |
| | | void json_patch::validateJsonPatch(json const &patch) |
| | | { |
| | | // static put here to have it created at the first usage of validateJsonPatch |
| | | static nlohmann::json_schema::json_validator patch_validator(patch_schema); |
| | | |
| | | patch_validator.validate(patch); |
| | | |
| | | for (auto const &op : patch) |
| | | json::json_pointer(op["path"].get<std::string>()); |
| | | } |
| | | |
| | | } // namespace nlohmann |
| New file |
| | |
| | | #pragma once |
| | | |
| | | #include <nlohmann/json.hpp> |
| | | #include <string> |
| | | |
| | | namespace nlohmann |
| | | { |
| | | class JsonPatchFormatException : public std::exception |
| | | { |
| | | public: |
| | | explicit JsonPatchFormatException(std::string msg) |
| | | : ex_{std::move(msg)} {} |
| | | |
| | | inline const char *what() const noexcept override final { return ex_.c_str(); } |
| | | |
| | | private: |
| | | std::string ex_; |
| | | }; |
| | | |
| | | class json_patch |
| | | { |
| | | public: |
| | | json_patch() = default; |
| | | json_patch(json &&patch); |
| | | json_patch(const json &patch); |
| | | |
| | | json_patch &add(const json::json_pointer &, json value); |
| | | json_patch &replace(const json::json_pointer &, json value); |
| | | json_patch &remove(const json::json_pointer &); |
| | | |
| | | json &get_json() { return j_; } |
| | | const json &get_json() const { return j_; } |
| | | |
| | | operator json() const { return j_; } |
| | | |
| | | private: |
| | | json j_ = nlohmann::json::array(); |
| | | |
| | | static void validateJsonPatch(json const &patch); |
| | | }; |
| | | } // namespace nlohmann |
| New file |
| | |
| | | /* |
| | | * JSON schema validator for JSON for modern C++ |
| | | * |
| | | * Copyright (c) 2016-2019 Patrick Boettcher <p@yai.se>. |
| | | * |
| | | * SPDX-License-Identifier: MIT |
| | | * |
| | | */ |
| | | #include <nlohmann/json.hpp> |
| | | |
| | | namespace nlohmann |
| | | { |
| | | namespace json_schema |
| | | { |
| | | |
| | | json draft7_schema_builtin = R"( { |
| | | "$schema": "http://json-schema.org/draft-07/schema#", |
| | | "$id": "http://json-schema.org/draft-07/schema#", |
| | | "title": "Core schema meta-schema", |
| | | "definitions": { |
| | | "schemaArray": { |
| | | "type": "array", |
| | | "minItems": 1, |
| | | "items": { "$ref": "#" } |
| | | }, |
| | | "nonNegativeInteger": { |
| | | "type": "integer", |
| | | "minimum": 0 |
| | | }, |
| | | "nonNegativeIntegerDefault0": { |
| | | "allOf": [ |
| | | { "$ref": "#/definitions/nonNegativeInteger" }, |
| | | { "default": 0 } |
| | | ] |
| | | }, |
| | | "simpleTypes": { |
| | | "enum": [ |
| | | "array", |
| | | "boolean", |
| | | "integer", |
| | | "null", |
| | | "number", |
| | | "object", |
| | | "string" |
| | | ] |
| | | }, |
| | | "stringArray": { |
| | | "type": "array", |
| | | "items": { "type": "string" }, |
| | | "uniqueItems": true, |
| | | "default": [] |
| | | } |
| | | }, |
| | | "type": ["object", "boolean"], |
| | | "properties": { |
| | | "$id": { |
| | | "type": "string", |
| | | "format": "uri-reference" |
| | | }, |
| | | "$schema": { |
| | | "type": "string", |
| | | "format": "uri" |
| | | }, |
| | | "$ref": { |
| | | "type": "string", |
| | | "format": "uri-reference" |
| | | }, |
| | | "$comment": { |
| | | "type": "string" |
| | | }, |
| | | "title": { |
| | | "type": "string" |
| | | }, |
| | | "description": { |
| | | "type": "string" |
| | | }, |
| | | "default": true, |
| | | "readOnly": { |
| | | "type": "boolean", |
| | | "default": false |
| | | }, |
| | | "examples": { |
| | | "type": "array", |
| | | "items": true |
| | | }, |
| | | "multipleOf": { |
| | | "type": "number", |
| | | "exclusiveMinimum": 0 |
| | | }, |
| | | "maximum": { |
| | | "type": "number" |
| | | }, |
| | | "exclusiveMaximum": { |
| | | "type": "number" |
| | | }, |
| | | "minimum": { |
| | | "type": "number" |
| | | }, |
| | | "exclusiveMinimum": { |
| | | "type": "number" |
| | | }, |
| | | "maxLength": { "$ref": "#/definitions/nonNegativeInteger" }, |
| | | "minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, |
| | | "pattern": { |
| | | "type": "string", |
| | | "format": "regex" |
| | | }, |
| | | "additionalItems": { "$ref": "#" }, |
| | | "items": { |
| | | "anyOf": [ |
| | | { "$ref": "#" }, |
| | | { "$ref": "#/definitions/schemaArray" } |
| | | ], |
| | | "default": true |
| | | }, |
| | | "maxItems": { "$ref": "#/definitions/nonNegativeInteger" }, |
| | | "minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, |
| | | "uniqueItems": { |
| | | "type": "boolean", |
| | | "default": false |
| | | }, |
| | | "contains": { "$ref": "#" }, |
| | | "maxProperties": { "$ref": "#/definitions/nonNegativeInteger" }, |
| | | "minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, |
| | | "required": { "$ref": "#/definitions/stringArray" }, |
| | | "additionalProperties": { "$ref": "#" }, |
| | | "definitions": { |
| | | "type": "object", |
| | | "additionalProperties": { "$ref": "#" }, |
| | | "default": {} |
| | | }, |
| | | "properties": { |
| | | "type": "object", |
| | | "additionalProperties": { "$ref": "#" }, |
| | | "default": {} |
| | | }, |
| | | "patternProperties": { |
| | | "type": "object", |
| | | "additionalProperties": { "$ref": "#" }, |
| | | "propertyNames": { "format": "regex" }, |
| | | "default": {} |
| | | }, |
| | | "dependencies": { |
| | | "type": "object", |
| | | "additionalProperties": { |
| | | "anyOf": [ |
| | | { "$ref": "#" }, |
| | | { "$ref": "#/definitions/stringArray" } |
| | | ] |
| | | } |
| | | }, |
| | | "propertyNames": { "$ref": "#" }, |
| | | "const": true, |
| | | "enum": { |
| | | "type": "array", |
| | | "items": true, |
| | | "minItems": 1, |
| | | "uniqueItems": true |
| | | }, |
| | | "type": { |
| | | "anyOf": [ |
| | | { "$ref": "#/definitions/simpleTypes" }, |
| | | { |
| | | "type": "array", |
| | | "items": { "$ref": "#/definitions/simpleTypes" }, |
| | | "minItems": 1, |
| | | "uniqueItems": true |
| | | } |
| | | ] |
| | | }, |
| | | "format": { "type": "string" }, |
| | | "contentMediaType": { "type": "string" }, |
| | | "contentEncoding": { "type": "string" }, |
| | | "if": { "$ref": "#" }, |
| | | "then": { "$ref": "#" }, |
| | | "else": { "$ref": "#" }, |
| | | "allOf": { "$ref": "#/definitions/schemaArray" }, |
| | | "anyOf": { "$ref": "#/definitions/schemaArray" }, |
| | | "oneOf": { "$ref": "#/definitions/schemaArray" }, |
| | | "not": { "$ref": "#" } |
| | | }, |
| | | "default": true |
| | | } )"_json; |
| | | } |
| | | } // namespace nlohmann |
| New file |
| | |
| | | /* |
| | | * JSON schema validator for JSON for modern C++ |
| | | * |
| | | * Copyright (c) 2016-2019 Patrick Boettcher <p@yai.se>. |
| | | * |
| | | * SPDX-License-Identifier: MIT |
| | | * |
| | | */ |
| | | #include <nlohmann/json-schema.hpp> |
| | | |
| | | #include <sstream> |
| | | |
| | | namespace nlohmann |
| | | { |
| | | |
| | | void json_uri::update(const std::string &uri) |
| | | { |
| | | std::string pointer = ""; // default pointer is document-root |
| | | |
| | | // first split the URI into location and pointer |
| | | auto pointer_separator = uri.find('#'); |
| | | if (pointer_separator != std::string::npos) { // and extract the pointer-string if found |
| | | pointer = uri.substr(pointer_separator + 1); // remove # |
| | | |
| | | // unescape %-values IOW, decode JSON-URI-formatted JSON-pointer |
| | | std::size_t pos = pointer.size() - 1; |
| | | do { |
| | | pos = pointer.rfind('%', pos); |
| | | if (pos == std::string::npos) |
| | | break; |
| | | |
| | | if (pos >= pointer.size() - 2) { |
| | | pos--; |
| | | continue; |
| | | } |
| | | |
| | | std::string hex = pointer.substr(pos + 1, 2); |
| | | char ascii = static_cast<char>(std::strtoul(hex.c_str(), nullptr, 16)); |
| | | pointer.replace(pos, 3, 1, ascii); |
| | | |
| | | pos--; |
| | | } while (1); |
| | | } |
| | | |
| | | auto location = uri.substr(0, pointer_separator); |
| | | |
| | | if (location.size()) { // a location part has been found |
| | | |
| | | // if it is an URN take it as it is |
| | | if (location.find("urn:") == 0) { |
| | | urn_ = location; |
| | | |
| | | // and clear URL members |
| | | scheme_ = ""; |
| | | authority_ = ""; |
| | | path_ = ""; |
| | | |
| | | } else { // it is an URL |
| | | |
| | | // split URL in protocol, hostname and path |
| | | std::size_t pos = 0; |
| | | auto proto = location.find("://", pos); |
| | | if (proto != std::string::npos) { // extract the protocol |
| | | |
| | | urn_ = ""; // clear URN-member if URL is parsed |
| | | |
| | | scheme_ = location.substr(pos, proto - pos); |
| | | pos = 3 + proto; // 3 == "://" |
| | | |
| | | auto authority = location.find("/", pos); |
| | | if (authority != std::string::npos) { // and the hostname (no proto without hostname) |
| | | authority_ = location.substr(pos, authority - pos); |
| | | pos = authority; |
| | | } |
| | | } |
| | | |
| | | auto path = location.substr(pos); |
| | | |
| | | // URNs cannot of have paths |
| | | if (urn_.size() && path.size()) |
| | | throw std::invalid_argument("Cannot add a path (" + path + ") to an URN URI (" + urn_ + ")"); |
| | | |
| | | if (path[0] == '/') // if it starts with a / it is root-path |
| | | path_ = path; |
| | | else if (pos == 0) { // the URL contained only a path and the current path has no / at the end, strip last element until / and append |
| | | auto last_slash = path_.rfind('/'); |
| | | path_ = path_.substr(0, last_slash) + '/' + path; |
| | | } else // otherwise it is a subfolder |
| | | path_.append(path); |
| | | } |
| | | } |
| | | |
| | | pointer_ = ""_json_pointer; |
| | | identifier_ = ""; |
| | | |
| | | if (pointer[0] == '/') |
| | | pointer_ = json::json_pointer(pointer); |
| | | else |
| | | identifier_ = pointer; |
| | | } |
| | | |
| | | std::string json_uri::location() const |
| | | { |
| | | if (urn_.size()) |
| | | return urn_; |
| | | |
| | | std::stringstream s; |
| | | |
| | | if (scheme_.size() > 0) |
| | | s << scheme_ << "://"; |
| | | |
| | | s << authority_ |
| | | << path_; |
| | | |
| | | return s.str(); |
| | | } |
| | | |
| | | std::string json_uri::to_string() const |
| | | { |
| | | std::stringstream s; |
| | | |
| | | s << location() << " # "; |
| | | |
| | | if (identifier_ == "") |
| | | s << pointer_.to_string(); |
| | | else |
| | | s << identifier_; |
| | | |
| | | return s.str(); |
| | | } |
| | | |
| | | std::ostream &operator<<(std::ostream &os, const json_uri &u) |
| | | { |
| | | return os << u.to_string(); |
| | | } |
| | | |
| | | std::string json_uri::escape(const std::string &src) |
| | | { |
| | | std::vector<std::pair<std::string, std::string>> chars = { |
| | | {"~", "~0"}, |
| | | {"/", "~1"}}; |
| | | |
| | | std::string l = src; |
| | | |
| | | for (const auto &c : chars) { |
| | | std::size_t pos = 0; |
| | | do { |
| | | pos = l.find(c.first, pos); |
| | | if (pos == std::string::npos) |
| | | break; |
| | | l.replace(pos, 1, c.second); |
| | | pos += c.second.size(); |
| | | } while (1); |
| | | } |
| | | |
| | | return l; |
| | | } |
| | | |
| | | } // namespace nlohmann |
| New file |
| | |
| | | /* |
| | | * JSON schema validator for JSON for modern C++ |
| | | * |
| | | * Copyright (c) 2016-2019 Patrick Boettcher <p@yai.se>. |
| | | * |
| | | * SPDX-License-Identifier: MIT |
| | | * |
| | | */ |
| | | #include <nlohmann/json-schema.hpp> |
| | | |
| | | #include "json-patch.hpp" |
| | | |
| | | #include <deque> |
| | | #include <memory> |
| | | #include <set> |
| | | #include <sstream> |
| | | #include <string> |
| | | |
| | | using nlohmann::json; |
| | | using nlohmann::json_patch; |
| | | using nlohmann::json_uri; |
| | | using nlohmann::json_schema::root_schema; |
| | | using namespace nlohmann::json_schema; |
| | | |
| | | #ifdef JSON_SCHEMA_BOOST_REGEX |
| | | # include <boost/regex.hpp> |
| | | # define REGEX_NAMESPACE boost |
| | | #elif defined(JSON_SCHEMA_NO_REGEX) |
| | | # define NO_STD_REGEX |
| | | #else |
| | | # include <regex> |
| | | # define REGEX_NAMESPACE std |
| | | #endif |
| | | |
| | | namespace |
| | | { |
| | | |
| | | class schema |
| | | { |
| | | protected: |
| | | root_schema *root_; |
| | | json default_value_ = nullptr; |
| | | |
| | | protected: |
| | | virtual std::shared_ptr<schema> make_for_default_( |
| | | std::shared_ptr<::schema> & /* sch */, |
| | | root_schema * /* root */, |
| | | std::vector<nlohmann::json_uri> & /* uris */, |
| | | nlohmann::json & /* default_value */) const |
| | | { |
| | | return nullptr; |
| | | }; |
| | | |
| | | public: |
| | | virtual ~schema() = default; |
| | | |
| | | schema(root_schema *root) |
| | | : root_(root) {} |
| | | |
| | | virtual void validate(const json::json_pointer &ptr, const json &instance, json_patch &patch, error_handler &e) const = 0; |
| | | |
| | | virtual const json &default_value(const json::json_pointer &, const json &, error_handler &) const |
| | | { |
| | | return default_value_; |
| | | } |
| | | |
| | | void set_default_value(const json &v) { default_value_ = v; } |
| | | |
| | | static std::shared_ptr<schema> make(json &schema, |
| | | root_schema *root, |
| | | const std::vector<std::string> &key, |
| | | std::vector<nlohmann::json_uri> uris); |
| | | }; |
| | | |
| | | class schema_ref : public schema |
| | | { |
| | | const std::string id_; |
| | | std::weak_ptr<schema> target_; |
| | | std::shared_ptr<schema> target_strong_; // for references to references keep also the shared_ptr because |
| | | // no one else might use it after resolving |
| | | |
| | | void validate(const json::json_pointer &ptr, const json &instance, json_patch &patch, error_handler &e) const final |
| | | { |
| | | auto target = target_.lock(); |
| | | |
| | | if (target) |
| | | target->validate(ptr, instance, patch, e); |
| | | else |
| | | e.error(ptr, instance, "unresolved or freed schema-reference " + id_); |
| | | } |
| | | |
| | | const json &default_value(const json::json_pointer &ptr, const json &instance, error_handler &e) const override final |
| | | { |
| | | if (!default_value_.is_null()) |
| | | return default_value_; |
| | | |
| | | auto target = target_.lock(); |
| | | if (target) |
| | | return target->default_value(ptr, instance, e); |
| | | |
| | | e.error(ptr, instance, "unresolved or freed schema-reference " + id_); |
| | | |
| | | return default_value_; |
| | | } |
| | | |
| | | protected: |
| | | virtual std::shared_ptr<schema> make_for_default_( |
| | | std::shared_ptr<::schema> &sch, |
| | | root_schema *root, |
| | | std::vector<nlohmann::json_uri> &uris, |
| | | nlohmann::json &default_value) const override |
| | | { |
| | | // create a new reference schema using the original reference (which will be resolved later) |
| | | // to store this overloaded default value #209 |
| | | auto result = std::make_shared<schema_ref>(uris[0].to_string(), root); |
| | | result->set_target(sch, true); |
| | | result->set_default_value(default_value); |
| | | return result; |
| | | }; |
| | | |
| | | public: |
| | | schema_ref(const std::string &id, root_schema *root) |
| | | : schema(root), id_(id) {} |
| | | |
| | | const std::string &id() const { return id_; } |
| | | |
| | | void set_target(const std::shared_ptr<schema> &target, bool strong = false) |
| | | { |
| | | target_ = target; |
| | | if (strong) |
| | | target_strong_ = target; |
| | | } |
| | | }; |
| | | |
| | | } // namespace |
| | | |
| | | namespace nlohmann |
| | | { |
| | | namespace json_schema |
| | | { |
| | | |
| | | class root_schema |
| | | { |
| | | schema_loader loader_; |
| | | format_checker format_check_; |
| | | content_checker content_check_; |
| | | |
| | | std::shared_ptr<schema> root_; |
| | | |
| | | struct schema_file { |
| | | std::map<std::string, std::shared_ptr<schema>> schemas; |
| | | std::map<std::string, std::shared_ptr<schema_ref>> unresolved; // contains all unresolved references from any other file seen during parsing |
| | | json unknown_keywords; |
| | | }; |
| | | |
| | | // location as key |
| | | std::map<std::string, schema_file> files_; |
| | | |
| | | schema_file &get_or_create_file(const std::string &loc) |
| | | { |
| | | auto file = files_.lower_bound(loc); |
| | | if (file != files_.end() && !(files_.key_comp()(loc, file->first))) |
| | | return file->second; |
| | | else |
| | | return files_.insert(file, {loc, {}})->second; |
| | | } |
| | | |
| | | public: |
| | | root_schema(schema_loader &&loader, |
| | | format_checker &&format, |
| | | content_checker &&content) |
| | | |
| | | : loader_(std::move(loader)), |
| | | format_check_(std::move(format)), |
| | | content_check_(std::move(content)) |
| | | { |
| | | } |
| | | |
| | | format_checker &format_check() { return format_check_; } |
| | | content_checker &content_check() { return content_check_; } |
| | | |
| | | void insert(const json_uri &uri, const std::shared_ptr<schema> &s) |
| | | { |
| | | auto &file = get_or_create_file(uri.location()); |
| | | auto sch = file.schemas.lower_bound(uri.fragment()); |
| | | if (sch != file.schemas.end() && !(file.schemas.key_comp()(uri.fragment(), sch->first))) { |
| | | throw std::invalid_argument("schema with " + uri.to_string() + " already inserted"); |
| | | return; |
| | | } |
| | | |
| | | file.schemas.insert({uri.fragment(), s}); |
| | | |
| | | // was someone referencing this newly inserted schema? |
| | | auto unresolved = file.unresolved.find(uri.fragment()); |
| | | if (unresolved != file.unresolved.end()) { |
| | | unresolved->second->set_target(s); |
| | | file.unresolved.erase(unresolved); |
| | | } |
| | | } |
| | | |
| | | void insert_unknown_keyword(const json_uri &uri, const std::string &key, json &value) |
| | | { |
| | | auto &file = get_or_create_file(uri.location()); |
| | | auto new_uri = uri.append(key); |
| | | auto fragment = new_uri.pointer(); |
| | | |
| | | // is there a reference looking for this unknown-keyword, which is thus no longer a unknown keyword but a schema |
| | | auto unresolved = file.unresolved.find(fragment.to_string()); |
| | | if (unresolved != file.unresolved.end()) |
| | | schema::make(value, this, {}, {{new_uri}}); |
| | | else { // no, nothing ref'd it, keep for later |
| | | |
| | | // need to create an object for each reference-token in the |
| | | // JSON-Pointer When not existing, a stringified integer reference |
| | | // token (e.g. "123") in the middle of the pointer will be |
| | | // interpreted a an array-index and an array will be created. |
| | | |
| | | // json_pointer's reference_tokens is private - get them |
| | | std::deque<std::string> ref_tokens; |
| | | auto uri_pointer = uri.pointer(); |
| | | while (!uri_pointer.empty()) { |
| | | ref_tokens.push_front(uri_pointer.back()); |
| | | uri_pointer.pop_back(); |
| | | } |
| | | |
| | | // for each token create an object, if not already existing |
| | | auto unk_kw = &file.unknown_keywords; |
| | | for (auto &rt : ref_tokens) { |
| | | auto existing_object = unk_kw->find(rt); |
| | | if (existing_object == unk_kw->end()) |
| | | (*unk_kw)[rt] = json::object(); |
| | | unk_kw = &(*unk_kw)[rt]; |
| | | } |
| | | (*unk_kw)[key] = value; |
| | | } |
| | | |
| | | // recursively add possible subschemas of unknown keywords |
| | | if (value.type() == json::value_t::object) |
| | | for (auto &subsch : value.items()) |
| | | insert_unknown_keyword(new_uri, subsch.key(), subsch.value()); |
| | | } |
| | | |
| | | std::shared_ptr<schema> get_or_create_ref(const json_uri &uri) |
| | | { |
| | | auto &file = get_or_create_file(uri.location()); |
| | | |
| | | // existing schema |
| | | auto sch = file.schemas.find(uri.fragment()); |
| | | if (sch != file.schemas.end()) |
| | | return sch->second; |
| | | |
| | | // referencing an unknown keyword, turn it into schema |
| | | // |
| | | // an unknown keyword can only be referenced by a json-pointer, |
| | | // not by a plain name fragment |
| | | if (uri.pointer().to_string() != "") { |
| | | try { |
| | | auto &subschema = file.unknown_keywords.at(uri.pointer()); // null is returned if not existing |
| | | auto s = schema::make(subschema, this, {}, {{uri}}); // A JSON Schema MUST be an object or a boolean. |
| | | if (s) { // nullptr if invalid schema, e.g. null |
| | | file.unknown_keywords.erase(uri.fragment()); |
| | | return s; |
| | | } |
| | | } catch (nlohmann::detail::out_of_range &) { // at() did not find it |
| | | } |
| | | } |
| | | |
| | | // get or create a schema_ref |
| | | auto r = file.unresolved.lower_bound(uri.fragment()); |
| | | if (r != file.unresolved.end() && !(file.unresolved.key_comp()(uri.fragment(), r->first))) { |
| | | return r->second; // unresolved, already seen previously - use existing reference |
| | | } else { |
| | | return file.unresolved.insert(r, |
| | | {uri.fragment(), std::make_shared<schema_ref>(uri.to_string(), this)}) |
| | | ->second; // unresolved, create reference |
| | | } |
| | | } |
| | | |
| | | void set_root_schema(json sch) |
| | | { |
| | | files_.clear(); |
| | | root_ = schema::make(sch, this, {}, {{"#"}}); |
| | | |
| | | // load all files which have not yet been loaded |
| | | do { |
| | | bool new_schema_loaded = false; |
| | | |
| | | // files_ is modified during parsing, iterators are invalidated |
| | | std::vector<std::string> locations; |
| | | for (auto &file : files_) |
| | | locations.push_back(file.first); |
| | | |
| | | for (auto &loc : locations) { |
| | | if (files_[loc].schemas.size() == 0) { // nothing has been loaded for this file |
| | | if (loader_) { |
| | | json loaded_schema; |
| | | |
| | | loader_(loc, loaded_schema); |
| | | |
| | | schema::make(loaded_schema, this, {}, {{loc}}); |
| | | new_schema_loaded = true; |
| | | } else { |
| | | throw std::invalid_argument("external schema reference '" + loc + "' needs loading, but no loader callback given"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!new_schema_loaded) // if no new schema loaded, no need to try again |
| | | break; |
| | | } while (1); |
| | | |
| | | for (const auto &file : files_) { |
| | | if (file.second.unresolved.size() != 0) { |
| | | // Build a representation of the undefined |
| | | // references as a list of comma-separated strings. |
| | | auto n_urefs = file.second.unresolved.size(); |
| | | std::string urefs = "["; |
| | | |
| | | decltype(n_urefs) counter = 0; |
| | | for (const auto &p : file.second.unresolved) { |
| | | urefs += p.first; |
| | | |
| | | if (counter != n_urefs - 1u) { |
| | | urefs += ", "; |
| | | } |
| | | |
| | | ++counter; |
| | | } |
| | | |
| | | urefs += "]"; |
| | | |
| | | throw std::invalid_argument("after all files have been parsed, '" + |
| | | (file.first == "" ? "<root>" : file.first) + |
| | | "' has still the following undefined references: " + urefs); |
| | | } |
| | | } |
| | | } |
| | | |
| | | void validate(const json::json_pointer &ptr, |
| | | const json &instance, |
| | | json_patch &patch, |
| | | error_handler &e, |
| | | const json_uri &initial) const |
| | | { |
| | | if (!root_) { |
| | | e.error(ptr, "", "no root schema has yet been set for validating an instance"); |
| | | return; |
| | | } |
| | | |
| | | auto file_entry = files_.find(initial.location()); |
| | | if (file_entry == files_.end()) { |
| | | e.error(ptr, "", "no file found serving requested root-URI. " + initial.location()); |
| | | return; |
| | | } |
| | | |
| | | auto &file = file_entry->second; |
| | | auto sch = file.schemas.find(initial.fragment()); |
| | | if (sch == file.schemas.end()) { |
| | | e.error(ptr, "", "no schema find for request initial URI: " + initial.to_string()); |
| | | return; |
| | | } |
| | | |
| | | sch->second->validate(ptr, instance, patch, e); |
| | | } |
| | | }; |
| | | |
| | | } // namespace json_schema |
| | | } // namespace nlohmann |
| | | |
| | | namespace |
| | | { |
| | | |
| | | class first_error_handler : public error_handler |
| | | { |
| | | public: |
| | | bool error_{false}; |
| | | json::json_pointer ptr_; |
| | | json instance_; |
| | | std::string message_; |
| | | |
| | | void error(const json::json_pointer &ptr, const json &instance, const std::string &message) override |
| | | { |
| | | if (*this) |
| | | return; |
| | | error_ = true; |
| | | ptr_ = ptr; |
| | | instance_ = instance; |
| | | message_ = message; |
| | | } |
| | | |
| | | operator bool() const { return error_; } |
| | | }; |
| | | |
| | | class logical_not : public schema |
| | | { |
| | | std::shared_ptr<schema> subschema_; |
| | | |
| | | void validate(const json::json_pointer &ptr, const json &instance, json_patch &patch, error_handler &e) const final |
| | | { |
| | | first_error_handler esub; |
| | | subschema_->validate(ptr, instance, patch, esub); |
| | | |
| | | if (!esub) |
| | | e.error(ptr, instance, "the subschema has succeeded, but it is required to not validate"); |
| | | } |
| | | |
| | | const json &default_value(const json::json_pointer &ptr, const json &instance, error_handler &e) const override |
| | | { |
| | | return subschema_->default_value(ptr, instance, e); |
| | | } |
| | | |
| | | public: |
| | | logical_not(json &sch, |
| | | root_schema *root, |
| | | const std::vector<nlohmann::json_uri> &uris) |
| | | : schema(root) |
| | | { |
| | | subschema_ = schema::make(sch, root, {"not"}, uris); |
| | | } |
| | | }; |
| | | |
| | | enum logical_combination_types { |
| | | allOf, |
| | | anyOf, |
| | | oneOf |
| | | }; |
| | | |
| | | template <enum logical_combination_types combine_logic> |
| | | class logical_combination : public schema |
| | | { |
| | | std::vector<std::shared_ptr<schema>> subschemata_; |
| | | |
| | | void validate(const json::json_pointer &ptr, const json &instance, json_patch &patch, error_handler &e) const final |
| | | { |
| | | size_t count = 0; |
| | | |
| | | for (auto &s : subschemata_) { |
| | | first_error_handler esub; |
| | | auto oldPatchSize = patch.get_json().size(); |
| | | s->validate(ptr, instance, patch, esub); |
| | | if (!esub) |
| | | count++; |
| | | else |
| | | patch.get_json().get_ref<nlohmann::json::array_t &>().resize(oldPatchSize); |
| | | |
| | | if (is_validate_complete(instance, ptr, e, esub, count)) |
| | | return; |
| | | } |
| | | |
| | | // could accumulate esub details for anyOf and oneOf, but not clear how to select which subschema failure to report |
| | | // or how to report multiple such failures |
| | | if (count == 0) |
| | | e.error(ptr, instance, "no subschema has succeeded, but one of them is required to validate"); |
| | | } |
| | | |
| | | // specialized for each of the logical_combination_types |
| | | static const std::string key; |
| | | static bool is_validate_complete(const json &, const json::json_pointer &, error_handler &, const first_error_handler &, size_t); |
| | | |
| | | public: |
| | | logical_combination(json &sch, |
| | | root_schema *root, |
| | | const std::vector<nlohmann::json_uri> &uris) |
| | | : schema(root) |
| | | { |
| | | size_t c = 0; |
| | | for (auto &subschema : sch) |
| | | subschemata_.push_back(schema::make(subschema, root, {key, std::to_string(c++)}, uris)); |
| | | |
| | | // value of allOf, anyOf, and oneOf "MUST be a non-empty array" |
| | | // TODO error/throw? when subschemata_.empty() |
| | | } |
| | | }; |
| | | |
| | | template <> |
| | | const std::string logical_combination<allOf>::key = "allOf"; |
| | | template <> |
| | | const std::string logical_combination<anyOf>::key = "anyOf"; |
| | | template <> |
| | | const std::string logical_combination<oneOf>::key = "oneOf"; |
| | | |
| | | template <> |
| | | bool logical_combination<allOf>::is_validate_complete(const json &, const json::json_pointer &, error_handler &e, const first_error_handler &esub, size_t) |
| | | { |
| | | if (esub) |
| | | e.error(esub.ptr_, esub.instance_, "at least one subschema has failed, but all of them are required to validate - " + esub.message_); |
| | | return esub; |
| | | } |
| | | |
| | | template <> |
| | | bool logical_combination<anyOf>::is_validate_complete(const json &, const json::json_pointer &, error_handler &, const first_error_handler &, size_t count) |
| | | { |
| | | return count == 1; |
| | | } |
| | | |
| | | template <> |
| | | bool logical_combination<oneOf>::is_validate_complete(const json &instance, const json::json_pointer &ptr, error_handler &e, const first_error_handler &, size_t count) |
| | | { |
| | | if (count > 1) |
| | | e.error(ptr, instance, "more than one subschema has succeeded, but exactly one of them is required to validate"); |
| | | return count > 1; |
| | | } |
| | | |
| | | class type_schema : public schema |
| | | { |
| | | std::vector<std::shared_ptr<schema>> type_; |
| | | std::pair<bool, json> enum_, const_; |
| | | std::vector<std::shared_ptr<schema>> logic_; |
| | | |
| | | static std::shared_ptr<schema> make(json &schema, |
| | | json::value_t type, |
| | | root_schema *, |
| | | const std::vector<nlohmann::json_uri> &, |
| | | std::set<std::string> &); |
| | | |
| | | std::shared_ptr<schema> if_, then_, else_; |
| | | |
| | | void validate(const json::json_pointer &ptr, const json &instance, json_patch &patch, error_handler &e) const override final |
| | | { |
| | | // depending on the type of instance run the type specific validator - if present |
| | | auto type = type_[static_cast<uint8_t>(instance.type())]; |
| | | |
| | | if (type) |
| | | type->validate(ptr, instance, patch, e); |
| | | else |
| | | e.error(ptr, instance, "unexpected instance type"); |
| | | |
| | | if (enum_.first) { |
| | | bool seen_in_enum = false; |
| | | for (auto &v : enum_.second) |
| | | if (instance == v) { |
| | | seen_in_enum = true; |
| | | break; |
| | | } |
| | | |
| | | if (!seen_in_enum) |
| | | e.error(ptr, instance, "instance not found in required enum"); |
| | | } |
| | | |
| | | if (const_.first && |
| | | const_.second != instance) |
| | | e.error(ptr, instance, "instance not const"); |
| | | |
| | | for (auto l : logic_) |
| | | l->validate(ptr, instance, patch, e); |
| | | |
| | | if (if_) { |
| | | first_error_handler err; |
| | | |
| | | if_->validate(ptr, instance, patch, err); |
| | | if (!err) { |
| | | if (then_) |
| | | then_->validate(ptr, instance, patch, e); |
| | | } else { |
| | | if (else_) |
| | | else_->validate(ptr, instance, patch, e); |
| | | } |
| | | } |
| | | if (instance.is_null()) { |
| | | patch.add(nlohmann::json::json_pointer{}, default_value_); |
| | | } |
| | | } |
| | | |
| | | protected: |
| | | virtual std::shared_ptr<schema> make_for_default_( |
| | | std::shared_ptr<::schema> & /* sch */, |
| | | root_schema * /* root */, |
| | | std::vector<nlohmann::json_uri> & /* uris */, |
| | | nlohmann::json &default_value) const override |
| | | { |
| | | auto result = std::make_shared<type_schema>(*this); |
| | | result->set_default_value(default_value); |
| | | return result; |
| | | }; |
| | | |
| | | public: |
| | | type_schema(json &sch, |
| | | root_schema *root, |
| | | const std::vector<nlohmann::json_uri> &uris) |
| | | : schema(root), type_(static_cast<uint8_t>(json::value_t::discarded) + 1) |
| | | { |
| | | // association between JSON-schema-type and NLohmann-types |
| | | static const std::vector<std::pair<std::string, json::value_t>> schema_types = { |
| | | {"null", json::value_t::null}, |
| | | {"object", json::value_t::object}, |
| | | {"array", json::value_t::array}, |
| | | {"string", json::value_t::string}, |
| | | {"boolean", json::value_t::boolean}, |
| | | {"integer", json::value_t::number_integer}, |
| | | {"number", json::value_t::number_float}, |
| | | }; |
| | | |
| | | std::set<std::string> known_keywords; |
| | | |
| | | auto attr = sch.find("type"); |
| | | if (attr == sch.end()) // no type field means all sub-types possible |
| | | for (auto &t : schema_types) |
| | | type_[static_cast<uint8_t>(t.second)] = type_schema::make(sch, t.second, root, uris, known_keywords); |
| | | else { |
| | | switch (attr.value().type()) { // "type": "type" |
| | | |
| | | case json::value_t::string: { |
| | | auto schema_type = attr.value().get<std::string>(); |
| | | for (auto &t : schema_types) |
| | | if (t.first == schema_type) |
| | | type_[static_cast<uint8_t>(t.second)] = type_schema::make(sch, t.second, root, uris, known_keywords); |
| | | } break; |
| | | |
| | | case json::value_t::array: // "type": ["type1", "type2"] |
| | | for (auto &array_value : attr.value()) { |
| | | auto schema_type = array_value.get<std::string>(); |
| | | for (auto &t : schema_types) |
| | | if (t.first == schema_type) |
| | | type_[static_cast<uint8_t>(t.second)] = type_schema::make(sch, t.second, root, uris, known_keywords); |
| | | } |
| | | break; |
| | | |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | attr = sch.find("default"); |
| | | if (attr != sch.end()) { |
| | | set_default_value(attr.value()); |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | for (auto &key : known_keywords) |
| | | sch.erase(key); |
| | | |
| | | // with nlohmann::json float instance (but number in schema-definition) can be seen as unsigned or integer - |
| | | // reuse the number-validator for integer values as well, if they have not been specified explicitly |
| | | if (type_[static_cast<uint8_t>(json::value_t::number_float)] && !type_[static_cast<uint8_t>(json::value_t::number_integer)]) |
| | | type_[static_cast<uint8_t>(json::value_t::number_integer)] = type_[static_cast<uint8_t>(json::value_t::number_float)]; |
| | | |
| | | // #54: JSON-schema does not differentiate between unsigned and signed integer - nlohmann::json does |
| | | // we stick with JSON-schema: use the integer-validator if instance-value is unsigned |
| | | type_[static_cast<uint8_t>(json::value_t::number_unsigned)] = type_[static_cast<uint8_t>(json::value_t::number_integer)]; |
| | | |
| | | // special for binary types |
| | | if (type_[static_cast<uint8_t>(json::value_t::string)]) { |
| | | type_[static_cast<uint8_t>(json::value_t::binary)] = type_[static_cast<uint8_t>(json::value_t::string)]; |
| | | } |
| | | |
| | | attr = sch.find("enum"); |
| | | if (attr != sch.end()) { |
| | | enum_ = {true, attr.value()}; |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | attr = sch.find("const"); |
| | | if (attr != sch.end()) { |
| | | const_ = {true, attr.value()}; |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | attr = sch.find("not"); |
| | | if (attr != sch.end()) { |
| | | logic_.push_back(std::make_shared<logical_not>(attr.value(), root, uris)); |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | attr = sch.find("allOf"); |
| | | if (attr != sch.end()) { |
| | | logic_.push_back(std::make_shared<logical_combination<allOf>>(attr.value(), root, uris)); |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | attr = sch.find("anyOf"); |
| | | if (attr != sch.end()) { |
| | | logic_.push_back(std::make_shared<logical_combination<anyOf>>(attr.value(), root, uris)); |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | attr = sch.find("oneOf"); |
| | | if (attr != sch.end()) { |
| | | logic_.push_back(std::make_shared<logical_combination<oneOf>>(attr.value(), root, uris)); |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | attr = sch.find("if"); |
| | | if (attr != sch.end()) { |
| | | auto attr_then = sch.find("then"); |
| | | auto attr_else = sch.find("else"); |
| | | |
| | | if (attr_then != sch.end() || attr_else != sch.end()) { |
| | | if_ = schema::make(attr.value(), root, {"if"}, uris); |
| | | |
| | | if (attr_then != sch.end()) { |
| | | then_ = schema::make(attr_then.value(), root, {"then"}, uris); |
| | | sch.erase(attr_then); |
| | | } |
| | | |
| | | if (attr_else != sch.end()) { |
| | | else_ = schema::make(attr_else.value(), root, {"else"}, uris); |
| | | sch.erase(attr_else); |
| | | } |
| | | } |
| | | sch.erase(attr); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | class string : public schema |
| | | { |
| | | std::pair<bool, size_t> maxLength_{false, 0}; |
| | | std::pair<bool, size_t> minLength_{false, 0}; |
| | | |
| | | #ifndef NO_STD_REGEX |
| | | std::pair<bool, REGEX_NAMESPACE::regex> pattern_{false, REGEX_NAMESPACE::regex()}; |
| | | std::string patternString_; |
| | | #endif |
| | | |
| | | std::pair<bool, std::string> format_; |
| | | std::tuple<bool, std::string, std::string> content_{false, "", ""}; |
| | | |
| | | std::size_t utf8_length(const std::string &s) const |
| | | { |
| | | size_t len = 0; |
| | | for (auto c : s) |
| | | if ((c & 0xc0) != 0x80) |
| | | len++; |
| | | return len; |
| | | } |
| | | |
| | | void validate(const json::json_pointer &ptr, const json &instance, json_patch &, error_handler &e) const override |
| | | { |
| | | if (minLength_.first) { |
| | | if (utf8_length(instance.get<std::string>()) < minLength_.second) { |
| | | std::ostringstream s; |
| | | s << "instance is too short as per minLength:" << minLength_.second; |
| | | e.error(ptr, instance, s.str()); |
| | | } |
| | | } |
| | | |
| | | if (maxLength_.first) { |
| | | if (utf8_length(instance.get<std::string>()) > maxLength_.second) { |
| | | std::ostringstream s; |
| | | s << "instance is too long as per maxLength: " << maxLength_.second; |
| | | e.error(ptr, instance, s.str()); |
| | | } |
| | | } |
| | | |
| | | if (std::get<0>(content_)) { |
| | | if (root_->content_check() == nullptr) |
| | | e.error(ptr, instance, std::string("a content checker was not provided but a contentEncoding or contentMediaType for this string have been present: '") + std::get<1>(content_) + "' '" + std::get<2>(content_) + "'"); |
| | | else { |
| | | try { |
| | | root_->content_check()(std::get<1>(content_), std::get<2>(content_), instance); |
| | | } catch (const std::exception &ex) { |
| | | e.error(ptr, instance, std::string("content-checking failed: ") + ex.what()); |
| | | } |
| | | } |
| | | } else if (instance.type() == json::value_t::binary) { |
| | | e.error(ptr, instance, "expected string, but get binary data"); |
| | | } |
| | | |
| | | if (instance.type() != json::value_t::string) { |
| | | return; // next checks only for strings |
| | | } |
| | | |
| | | #ifndef NO_STD_REGEX |
| | | if (pattern_.first && |
| | | !REGEX_NAMESPACE::regex_search(instance.get<std::string>(), pattern_.second)) |
| | | e.error(ptr, instance, "instance does not match regex pattern: " + patternString_); |
| | | #endif |
| | | |
| | | if (format_.first) { |
| | | if (root_->format_check() == nullptr) |
| | | e.error(ptr, instance, std::string("a format checker was not provided but a format keyword for this string is present: ") + format_.second); |
| | | else { |
| | | try { |
| | | root_->format_check()(format_.second, instance.get<std::string>()); |
| | | } catch (const std::exception &ex) { |
| | | e.error(ptr, instance, std::string("format-checking failed: ") + ex.what()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public: |
| | | string(json &sch, root_schema *root) |
| | | : schema(root) |
| | | { |
| | | auto attr = sch.find("maxLength"); |
| | | if (attr != sch.end()) { |
| | | maxLength_ = {true, attr.value().get<size_t>()}; |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | attr = sch.find("minLength"); |
| | | if (attr != sch.end()) { |
| | | minLength_ = {true, attr.value().get<size_t>()}; |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | attr = sch.find("contentEncoding"); |
| | | if (attr != sch.end()) { |
| | | std::get<0>(content_) = true; |
| | | std::get<1>(content_) = attr.value().get<std::string>(); |
| | | |
| | | // special case for nlohmann::json-binary-types |
| | | // |
| | | // https://github.com/pboettch/json-schema-validator/pull/114 |
| | | // |
| | | // We cannot use explicitly in a schema: {"type": "binary"} or |
| | | // "type": ["binary", "number"] we have to be implicit. For a |
| | | // schema where "contentEncoding" is set to "binary", an instance |
| | | // of type json::value_t::binary is accepted. If a |
| | | // contentEncoding-callback has to be provided and is called |
| | | // accordingly. For encoding=binary, no other type validations are done |
| | | |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | attr = sch.find("contentMediaType"); |
| | | if (attr != sch.end()) { |
| | | std::get<0>(content_) = true; |
| | | std::get<2>(content_) = attr.value().get<std::string>(); |
| | | |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | if (std::get<0>(content_) == true && root_->content_check() == nullptr) { |
| | | throw std::invalid_argument{"schema contains contentEncoding/contentMediaType but content checker was not set"}; |
| | | } |
| | | |
| | | #ifndef NO_STD_REGEX |
| | | attr = sch.find("pattern"); |
| | | if (attr != sch.end()) { |
| | | patternString_ = attr.value().get<std::string>(); |
| | | pattern_ = {true, REGEX_NAMESPACE::regex(attr.value().get<std::string>(), |
| | | REGEX_NAMESPACE::regex::ECMAScript)}; |
| | | sch.erase(attr); |
| | | } |
| | | #endif |
| | | |
| | | attr = sch.find("format"); |
| | | if (attr != sch.end()) { |
| | | if (root_->format_check() == nullptr) |
| | | throw std::invalid_argument{"a format checker was not provided but a format keyword for this string is present: " + format_.second}; |
| | | |
| | | format_ = {true, attr.value().get<std::string>()}; |
| | | sch.erase(attr); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | template <typename T> |
| | | class numeric : public schema |
| | | { |
| | | std::pair<bool, T> maximum_{false, 0}; |
| | | std::pair<bool, T> minimum_{false, 0}; |
| | | |
| | | bool exclusiveMaximum_ = false; |
| | | bool exclusiveMinimum_ = false; |
| | | |
| | | std::pair<bool, json::number_float_t> multipleOf_{false, 0}; |
| | | |
| | | // multipleOf - if the remainder of the division is 0 -> OK |
| | | bool violates_multiple_of(T x) const |
| | | { |
| | | double res = std::remainder(x, multipleOf_.second); |
| | | double multiple = std::fabs(x / multipleOf_.second); |
| | | if (multiple > 1) { |
| | | res = res / multiple; |
| | | } |
| | | double eps = std::nextafter(x, 0) - static_cast<double>(x); |
| | | |
| | | return std::fabs(res) > std::fabs(eps); |
| | | } |
| | | |
| | | void validate(const json::json_pointer &ptr, const json &instance, json_patch &, error_handler &e) const override |
| | | { |
| | | T value = instance; // conversion of json to value_type |
| | | |
| | | if (multipleOf_.first && value != 0) // zero is multiple of everything |
| | | if (violates_multiple_of(value)) |
| | | e.error(ptr, instance, "instance is not a multiple of " + std::to_string(multipleOf_.second)); |
| | | |
| | | if (maximum_.first) { |
| | | if (exclusiveMaximum_ && value >= maximum_.second) |
| | | e.error(ptr, instance, "instance exceeds or equals maximum of " + std::to_string(maximum_.second)); |
| | | else if (value > maximum_.second) |
| | | e.error(ptr, instance, "instance exceeds maximum of " + std::to_string(maximum_.second)); |
| | | } |
| | | |
| | | if (minimum_.first) { |
| | | if (exclusiveMinimum_ && value <= minimum_.second) |
| | | e.error(ptr, instance, "instance is below or equals minimum of " + std::to_string(minimum_.second)); |
| | | else if (value < minimum_.second) |
| | | e.error(ptr, instance, "instance is below minimum of " + std::to_string(minimum_.second)); |
| | | } |
| | | } |
| | | |
| | | public: |
| | | numeric(const json &sch, root_schema *root, std::set<std::string> &kw) |
| | | : schema(root) |
| | | { |
| | | auto attr = sch.find("maximum"); |
| | | if (attr != sch.end()) { |
| | | maximum_ = {true, attr.value().get<T>()}; |
| | | kw.insert("maximum"); |
| | | } |
| | | |
| | | attr = sch.find("minimum"); |
| | | if (attr != sch.end()) { |
| | | minimum_ = {true, attr.value().get<T>()}; |
| | | kw.insert("minimum"); |
| | | } |
| | | |
| | | attr = sch.find("exclusiveMaximum"); |
| | | if (attr != sch.end()) { |
| | | exclusiveMaximum_ = true; |
| | | maximum_ = {true, attr.value().get<T>()}; |
| | | kw.insert("exclusiveMaximum"); |
| | | } |
| | | |
| | | attr = sch.find("exclusiveMinimum"); |
| | | if (attr != sch.end()) { |
| | | exclusiveMinimum_ = true; |
| | | minimum_ = {true, attr.value().get<T>()}; |
| | | kw.insert("exclusiveMinimum"); |
| | | } |
| | | |
| | | attr = sch.find("multipleOf"); |
| | | if (attr != sch.end()) { |
| | | multipleOf_ = {true, attr.value().get<json::number_float_t>()}; |
| | | kw.insert("multipleOf"); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | class null : public schema |
| | | { |
| | | void validate(const json::json_pointer &ptr, const json &instance, json_patch &, error_handler &e) const override |
| | | { |
| | | if (!instance.is_null()) |
| | | e.error(ptr, instance, "expected to be null"); |
| | | } |
| | | |
| | | public: |
| | | null(json &, root_schema *root) |
| | | : schema(root) {} |
| | | }; |
| | | |
| | | class boolean_type : public schema |
| | | { |
| | | void validate(const json::json_pointer &, const json &, json_patch &, error_handler &) const override {} |
| | | |
| | | public: |
| | | boolean_type(json &, root_schema *root) |
| | | : schema(root) {} |
| | | }; |
| | | |
| | | class boolean : public schema |
| | | { |
| | | bool true_; |
| | | void validate(const json::json_pointer &ptr, const json &instance, json_patch &, error_handler &e) const override |
| | | { |
| | | if (!true_) { // false schema |
| | | // empty array |
| | | // switch (instance.type()) { |
| | | // case json::value_t::array: |
| | | // if (instance.size() != 0) // valid false-schema |
| | | // e.error(ptr, instance, "false-schema required empty array"); |
| | | // return; |
| | | //} |
| | | |
| | | e.error(ptr, instance, "instance invalid as per false-schema"); |
| | | } |
| | | } |
| | | |
| | | public: |
| | | boolean(json &sch, root_schema *root) |
| | | : schema(root), true_(sch) {} |
| | | }; |
| | | |
| | | class required : public schema |
| | | { |
| | | const std::vector<std::string> required_; |
| | | |
| | | void validate(const json::json_pointer &ptr, const json &instance, json_patch &, error_handler &e) const override final |
| | | { |
| | | for (auto &r : required_) |
| | | if (instance.find(r) == instance.end()) |
| | | e.error(ptr, instance, "required property '" + r + "' not found in object as a dependency"); |
| | | } |
| | | |
| | | public: |
| | | required(const std::vector<std::string> &r, root_schema *root) |
| | | : schema(root), required_(r) {} |
| | | }; |
| | | |
| | | class object : public schema |
| | | { |
| | | std::pair<bool, size_t> maxProperties_{false, 0}; |
| | | std::pair<bool, size_t> minProperties_{false, 0}; |
| | | std::vector<std::string> required_; |
| | | |
| | | std::map<std::string, std::shared_ptr<schema>> properties_; |
| | | #ifndef NO_STD_REGEX |
| | | std::vector<std::pair<REGEX_NAMESPACE::regex, std::shared_ptr<schema>>> patternProperties_; |
| | | #endif |
| | | std::shared_ptr<schema> additionalProperties_; |
| | | |
| | | std::map<std::string, std::shared_ptr<schema>> dependencies_; |
| | | |
| | | std::shared_ptr<schema> propertyNames_; |
| | | |
| | | void validate(const json::json_pointer &ptr, const json &instance, json_patch &patch, error_handler &e) const override |
| | | { |
| | | if (maxProperties_.first && instance.size() > maxProperties_.second) |
| | | e.error(ptr, instance, "too many properties"); |
| | | |
| | | if (minProperties_.first && instance.size() < minProperties_.second) |
| | | e.error(ptr, instance, "too few properties"); |
| | | |
| | | for (auto &r : required_) |
| | | if (instance.find(r) == instance.end()) |
| | | e.error(ptr, instance, "required property '" + r + "' not found in object"); |
| | | |
| | | // for each property in instance |
| | | for (auto &p : instance.items()) { |
| | | if (propertyNames_) |
| | | propertyNames_->validate(ptr, p.key(), patch, e); |
| | | |
| | | bool a_prop_or_pattern_matched = false; |
| | | auto schema_p = properties_.find(p.key()); |
| | | // check if it is in "properties" |
| | | if (schema_p != properties_.end()) { |
| | | a_prop_or_pattern_matched = true; |
| | | schema_p->second->validate(ptr / p.key(), p.value(), patch, e); |
| | | } |
| | | |
| | | #ifndef NO_STD_REGEX |
| | | // check all matching patternProperties |
| | | for (auto &schema_pp : patternProperties_) |
| | | if (REGEX_NAMESPACE::regex_search(p.key(), schema_pp.first)) { |
| | | a_prop_or_pattern_matched = true; |
| | | schema_pp.second->validate(ptr / p.key(), p.value(), patch, e); |
| | | } |
| | | #endif |
| | | |
| | | // check additionalProperties as a last resort |
| | | if (!a_prop_or_pattern_matched && additionalProperties_) { |
| | | first_error_handler additional_prop_err; |
| | | additionalProperties_->validate(ptr / p.key(), p.value(), patch, additional_prop_err); |
| | | if (additional_prop_err) |
| | | e.error(ptr, instance, "validation failed for additional property '" + p.key() + "': " + additional_prop_err.message_); |
| | | } |
| | | } |
| | | |
| | | // reverse search |
| | | for (auto const &prop : properties_) { |
| | | const auto finding = instance.find(prop.first); |
| | | if (instance.end() == finding) { // if the prop is not in the instance |
| | | const auto &default_value = prop.second->default_value(ptr, instance, e); |
| | | if (!default_value.is_null()) { // if default value is available |
| | | patch.add((ptr / prop.first), default_value); |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (auto &dep : dependencies_) { |
| | | auto prop = instance.find(dep.first); |
| | | if (prop != instance.end()) // if dependency-property is present in instance |
| | | dep.second->validate(ptr / dep.first, instance, patch, e); // validate |
| | | } |
| | | } |
| | | |
| | | public: |
| | | object(json &sch, |
| | | root_schema *root, |
| | | const std::vector<nlohmann::json_uri> &uris) |
| | | : schema(root) |
| | | { |
| | | auto attr = sch.find("maxProperties"); |
| | | if (attr != sch.end()) { |
| | | maxProperties_ = {true, attr.value().get<size_t>()}; |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | attr = sch.find("minProperties"); |
| | | if (attr != sch.end()) { |
| | | minProperties_ = {true, attr.value().get<size_t>()}; |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | attr = sch.find("required"); |
| | | if (attr != sch.end()) { |
| | | required_ = attr.value().get<std::vector<std::string>>(); |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | attr = sch.find("properties"); |
| | | if (attr != sch.end()) { |
| | | for (auto prop : attr.value().items()) |
| | | properties_.insert( |
| | | std::make_pair( |
| | | prop.key(), |
| | | schema::make(prop.value(), root, {"properties", prop.key()}, uris))); |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | #ifndef NO_STD_REGEX |
| | | attr = sch.find("patternProperties"); |
| | | if (attr != sch.end()) { |
| | | for (auto prop : attr.value().items()) |
| | | patternProperties_.push_back( |
| | | std::make_pair( |
| | | REGEX_NAMESPACE::regex(prop.key(), REGEX_NAMESPACE::regex::ECMAScript), |
| | | schema::make(prop.value(), root, {prop.key()}, uris))); |
| | | sch.erase(attr); |
| | | } |
| | | #endif |
| | | |
| | | attr = sch.find("additionalProperties"); |
| | | if (attr != sch.end()) { |
| | | additionalProperties_ = schema::make(attr.value(), root, {"additionalProperties"}, uris); |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | attr = sch.find("dependencies"); |
| | | if (attr != sch.end()) { |
| | | for (auto &dep : attr.value().items()) |
| | | switch (dep.value().type()) { |
| | | case json::value_t::array: |
| | | dependencies_.emplace(dep.key(), |
| | | std::make_shared<required>( |
| | | dep.value().get<std::vector<std::string>>(), root)); |
| | | break; |
| | | |
| | | default: |
| | | dependencies_.emplace(dep.key(), |
| | | schema::make(dep.value(), root, {"dependencies", dep.key()}, uris)); |
| | | break; |
| | | } |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | attr = sch.find("propertyNames"); |
| | | if (attr != sch.end()) { |
| | | propertyNames_ = schema::make(attr.value(), root, {"propertyNames"}, uris); |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | attr = sch.find("default"); |
| | | if (attr != sch.end()) { |
| | | set_default_value(*attr); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | class array : public schema |
| | | { |
| | | std::pair<bool, size_t> maxItems_{false, 0}; |
| | | std::pair<bool, size_t> minItems_{false, 0}; |
| | | bool uniqueItems_ = false; |
| | | |
| | | std::shared_ptr<schema> items_schema_; |
| | | |
| | | std::vector<std::shared_ptr<schema>> items_; |
| | | std::shared_ptr<schema> additionalItems_; |
| | | |
| | | std::shared_ptr<schema> contains_; |
| | | |
| | | void validate(const json::json_pointer &ptr, const json &instance, json_patch &patch, error_handler &e) const override |
| | | { |
| | | if (maxItems_.first && instance.size() > maxItems_.second) |
| | | e.error(ptr, instance, "array has too many items"); |
| | | |
| | | if (minItems_.first && instance.size() < minItems_.second) |
| | | e.error(ptr, instance, "array has too few items"); |
| | | |
| | | if (uniqueItems_) { |
| | | for (auto it = instance.cbegin(); it != instance.cend(); ++it) { |
| | | auto v = std::find(it + 1, instance.end(), *it); |
| | | if (v != instance.end()) |
| | | e.error(ptr, instance, "items have to be unique for this array"); |
| | | } |
| | | } |
| | | |
| | | size_t index = 0; |
| | | if (items_schema_) |
| | | for (auto &i : instance) { |
| | | items_schema_->validate(ptr / index, i, patch, e); |
| | | index++; |
| | | } |
| | | else { |
| | | auto item = items_.cbegin(); |
| | | for (auto &i : instance) { |
| | | std::shared_ptr<schema> item_validator; |
| | | if (item == items_.cend()) |
| | | item_validator = additionalItems_; |
| | | else { |
| | | item_validator = *item; |
| | | item++; |
| | | } |
| | | |
| | | if (!item_validator) |
| | | break; |
| | | |
| | | item_validator->validate(ptr / index, i, patch, e); |
| | | } |
| | | } |
| | | |
| | | if (contains_) { |
| | | bool contained = false; |
| | | for (auto &item : instance) { |
| | | first_error_handler local_e; |
| | | contains_->validate(ptr, item, patch, local_e); |
| | | if (!local_e) { |
| | | contained = true; |
| | | break; |
| | | } |
| | | } |
| | | if (!contained) |
| | | e.error(ptr, instance, "array does not contain required element as per 'contains'"); |
| | | } |
| | | } |
| | | |
| | | public: |
| | | array(json &sch, root_schema *root, const std::vector<nlohmann::json_uri> &uris) |
| | | : schema(root) |
| | | { |
| | | auto attr = sch.find("maxItems"); |
| | | if (attr != sch.end()) { |
| | | maxItems_ = {true, attr.value().get<size_t>()}; |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | attr = sch.find("minItems"); |
| | | if (attr != sch.end()) { |
| | | minItems_ = {true, attr.value().get<size_t>()}; |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | attr = sch.find("uniqueItems"); |
| | | if (attr != sch.end()) { |
| | | uniqueItems_ = attr.value().get<bool>(); |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | attr = sch.find("items"); |
| | | if (attr != sch.end()) { |
| | | |
| | | if (attr.value().type() == json::value_t::array) { |
| | | size_t c = 0; |
| | | for (auto &subsch : attr.value()) |
| | | items_.push_back(schema::make(subsch, root, {"items", std::to_string(c++)}, uris)); |
| | | |
| | | auto attr_add = sch.find("additionalItems"); |
| | | if (attr_add != sch.end()) { |
| | | additionalItems_ = schema::make(attr_add.value(), root, {"additionalItems"}, uris); |
| | | sch.erase(attr_add); |
| | | } |
| | | |
| | | } else if (attr.value().type() == json::value_t::object || |
| | | attr.value().type() == json::value_t::boolean) |
| | | items_schema_ = schema::make(attr.value(), root, {"items"}, uris); |
| | | |
| | | sch.erase(attr); |
| | | } |
| | | |
| | | attr = sch.find("contains"); |
| | | if (attr != sch.end()) { |
| | | contains_ = schema::make(attr.value(), root, {"contains"}, uris); |
| | | sch.erase(attr); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | std::shared_ptr<schema> type_schema::make(json &schema, |
| | | json::value_t type, |
| | | root_schema *root, |
| | | const std::vector<nlohmann::json_uri> &uris, |
| | | std::set<std::string> &kw) |
| | | { |
| | | switch (type) { |
| | | case json::value_t::null: |
| | | return std::make_shared<null>(schema, root); |
| | | |
| | | case json::value_t::number_unsigned: |
| | | case json::value_t::number_integer: |
| | | return std::make_shared<numeric<json::number_integer_t>>(schema, root, kw); |
| | | case json::value_t::number_float: |
| | | return std::make_shared<numeric<json::number_float_t>>(schema, root, kw); |
| | | case json::value_t::string: |
| | | return std::make_shared<string>(schema, root); |
| | | case json::value_t::boolean: |
| | | return std::make_shared<boolean_type>(schema, root); |
| | | case json::value_t::object: |
| | | return std::make_shared<object>(schema, root, uris); |
| | | case json::value_t::array: |
| | | return std::make_shared<array>(schema, root, uris); |
| | | |
| | | case json::value_t::discarded: // not a real type - silence please |
| | | break; |
| | | |
| | | case json::value_t::binary: |
| | | break; |
| | | } |
| | | return nullptr; |
| | | } |
| | | } // namespace |
| | | |
| | | namespace |
| | | { |
| | | |
| | | std::shared_ptr<schema> schema::make(json &schema, |
| | | root_schema *root, |
| | | const std::vector<std::string> &keys, |
| | | std::vector<nlohmann::json_uri> uris) |
| | | { |
| | | // remove URIs which contain plain name identifiers, as sub-schemas cannot be referenced |
| | | for (auto uri = uris.begin(); uri != uris.end();) |
| | | if (uri->identifier() != "") |
| | | uri = uris.erase(uri); |
| | | else |
| | | uri++; |
| | | |
| | | // append to all URIs the keys for this sub-schema |
| | | for (auto &key : keys) |
| | | for (auto &uri : uris) |
| | | uri = uri.append(key); |
| | | |
| | | std::shared_ptr<::schema> sch; |
| | | |
| | | // boolean schema |
| | | if (schema.type() == json::value_t::boolean) |
| | | sch = std::make_shared<boolean>(schema, root); |
| | | else if (schema.type() == json::value_t::object) { |
| | | |
| | | auto attr = schema.find("$id"); // if $id is present, this schema can be referenced by this ID |
| | | // as an additional URI |
| | | if (attr != schema.end()) { |
| | | if (std::find(uris.begin(), |
| | | uris.end(), |
| | | attr.value().get<std::string>()) == uris.end()) |
| | | uris.push_back(uris.back().derive(attr.value().get<std::string>())); // so add it to the list if it is not there already |
| | | schema.erase(attr); |
| | | } |
| | | |
| | | attr = schema.find("definitions"); |
| | | if (attr != schema.end()) { |
| | | for (auto &def : attr.value().items()) |
| | | schema::make(def.value(), root, {"definitions", def.key()}, uris); |
| | | schema.erase(attr); |
| | | } |
| | | |
| | | attr = schema.find("$ref"); |
| | | if (attr != schema.end()) { // this schema is a reference |
| | | // the last one on the uri-stack is the last id seen before coming here, |
| | | // so this is the origial URI for this reference, the $ref-value has thus be resolved from it |
| | | auto id = uris.back().derive(attr.value().get<std::string>()); |
| | | sch = root->get_or_create_ref(id); |
| | | |
| | | schema.erase(attr); |
| | | |
| | | // special case where we break draft-7 and allow overriding of properties when a $ref is used |
| | | attr = schema.find("default"); |
| | | if (attr != schema.end()) { |
| | | // copy the referenced schema depending on the underlying type and modify the default value |
| | | if (auto new_sch = sch->make_for_default_(sch, root, uris, attr.value())) { |
| | | sch = new_sch; |
| | | } |
| | | schema.erase(attr); |
| | | } |
| | | } else { |
| | | sch = std::make_shared<type_schema>(schema, root, uris); |
| | | } |
| | | |
| | | schema.erase("$schema"); |
| | | schema.erase("title"); |
| | | schema.erase("description"); |
| | | } else { |
| | | throw std::invalid_argument("invalid JSON-type for a schema for " + uris[0].to_string() + ", expected: boolean or object"); |
| | | } |
| | | |
| | | for (auto &uri : uris) { // for all URIs this schema is referenced by |
| | | root->insert(uri, sch); |
| | | |
| | | if (schema.type() == json::value_t::object) |
| | | for (auto &u : schema.items()) |
| | | root->insert_unknown_keyword(uri, u.key(), u.value()); // insert unknown keywords for later reference |
| | | } |
| | | return sch; |
| | | } |
| | | |
| | | class throwing_error_handler : public error_handler |
| | | { |
| | | void error(const json::json_pointer &ptr, const json &instance, const std::string &message) override |
| | | { |
| | | throw std::invalid_argument(std::string("At ") + ptr.to_string() + " of " + instance.dump() + " - " + message + "\n"); |
| | | } |
| | | }; |
| | | |
| | | } // namespace |
| | | |
| | | namespace nlohmann |
| | | { |
| | | namespace json_schema |
| | | { |
| | | |
| | | json_validator::json_validator(schema_loader loader, |
| | | format_checker format, |
| | | content_checker content) |
| | | : root_(std::unique_ptr<root_schema>(new root_schema(std::move(loader), |
| | | std::move(format), |
| | | std::move(content)))) |
| | | { |
| | | } |
| | | |
| | | json_validator::json_validator(const json &schema, |
| | | schema_loader loader, |
| | | format_checker format, |
| | | content_checker content) |
| | | : json_validator(std::move(loader), |
| | | std::move(format), |
| | | std::move(content)) |
| | | { |
| | | set_root_schema(schema); |
| | | } |
| | | |
| | | json_validator::json_validator(json &&schema, |
| | | schema_loader loader, |
| | | format_checker format, |
| | | content_checker content) |
| | | |
| | | : json_validator(std::move(loader), |
| | | std::move(format), |
| | | std::move(content)) |
| | | { |
| | | set_root_schema(std::move(schema)); |
| | | } |
| | | |
| | | // move constructor, destructor and move assignment operator can be defaulted here |
| | | // where root_schema is a complete type |
| | | json_validator::json_validator(json_validator &&) = default; |
| | | json_validator::~json_validator() = default; |
| | | json_validator &json_validator::operator=(json_validator &&) = default; |
| | | |
| | | void json_validator::set_root_schema(const json &schema) |
| | | { |
| | | root_->set_root_schema(schema); |
| | | } |
| | | |
| | | void json_validator::set_root_schema(json &&schema) |
| | | { |
| | | root_->set_root_schema(std::move(schema)); |
| | | } |
| | | |
| | | json json_validator::validate(const json &instance) const |
| | | { |
| | | throwing_error_handler err; |
| | | return validate(instance, err); |
| | | } |
| | | |
| | | json json_validator::validate(const json &instance, error_handler &err, const json_uri &initial_uri) const |
| | | { |
| | | json::json_pointer ptr; |
| | | json_patch patch; |
| | | root_->validate(ptr, instance, patch, err, initial_uri); |
| | | return patch; |
| | | } |
| | | |
| | | } // namespace json_schema |
| | | } // namespace nlohmann |
| New file |
| | |
| | | /* |
| | | |
| | | Snarfed from <https://github.com/gene-hightower/smtp-address-validator> |
| | | |
| | | <http://opensource.org/licenses/MIT>: |
| | | |
| | | Copyright (c) 2021 Gene Hightower |
| | | |
| | | Permission is hereby granted, free of charge, to any person obtaining a copy of |
| | | this software and associated documentation files (the "Software"), to deal in |
| | | the Software without restriction, including without limitation the rights to |
| | | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies |
| | | of the Software, and to permit persons to whom the Software is furnished to do |
| | | so, subject to the following conditions: |
| | | |
| | | The above copyright notice and this permission notice shall be included in all |
| | | copies or substantial portions of the Software. |
| | | |
| | | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| | | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| | | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| | | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| | | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| | | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| | | SOFTWARE. |
| | | |
| | | */ |
| | | |
| | | #include "smtp-address-validator.hpp" |
| | | |
| | | static const signed char _address_actions[] = { |
| | | 0, 1, 0, 1, 1, 0}; |
| | | |
| | | static const short _address_key_offsets[] = { |
| | | 0, 0, 24, 26, 50, 52, 54, 56, |
| | | 58, 60, 62, 86, 103, 105, 107, 109, |
| | | 111, 113, 115, 117, 134, 150, 161, 168, |
| | | 176, 180, 181, 190, 195, 196, 201, 202, |
| | | 207, 210, 213, 219, 222, 225, 228, 234, |
| | | 237, 240, 243, 249, 252, 261, 270, 282, |
| | | 293, 302, 311, 320, 328, 345, 353, 360, |
| | | 367, 368, 375, 382, 389, 396, 397, 404, |
| | | 411, 418, 425, 426, 433, 440, 447, 454, |
| | | 455, 462, 469, 476, 483, 484, 491, 498, |
| | | 505, 512, 513, 523, 531, 538, 545, 546, |
| | | 552, 559, 566, 573, 581, 589, 597, 608, |
| | | 618, 626, 634, 641, 649, 657, 665, 667, |
| | | 673, 681, 689, 697, 699, 705, 713, 721, |
| | | 729, 731, 737, 745, 753, 761, 763, 769, |
| | | 777, 785, 793, 795, 802, 812, 821, 829, |
| | | 837, 839, 848, 857, 865, 873, 875, 884, |
| | | 893, 901, 909, 911, 920, 929, 937, 945, |
| | | 947, 956, 965, 974, 983, 992, 1004, 1015, |
| | | 1024, 1033, 1042, 1051, 1060, 1072, 1083, 1092, |
| | | 1101, 1109, 1118, 1127, 1136, 1148, 1159, 1168, |
| | | 1177, 1185, 1194, 1203, 1212, 1224, 1235, 1244, |
| | | 1253, 1261, 1270, 1279, 1288, 1300, 1311, 1320, |
| | | 1329, 1337, 1339, 1353, 1355, 1357, 1359, 1361, |
| | | 1363, 1365, 1367, 1368, 1370, 1388, 0}; |
| | | |
| | | static const signed char _address_trans_keys[] = { |
| | | -32, -19, -16, -12, 34, 45, 61, 63, |
| | | -62, -33, -31, -17, -15, -13, 33, 39, |
| | | 42, 43, 47, 57, 65, 90, 94, 126, |
| | | -128, -65, -32, -19, -16, -12, 33, 46, |
| | | 61, 64, -62, -33, -31, -17, -15, -13, |
| | | 35, 39, 42, 43, 45, 57, 63, 90, |
| | | 94, 126, -96, -65, -128, -65, -128, -97, |
| | | -112, -65, -128, -65, -128, -113, -32, -19, |
| | | -16, -12, 33, 45, 61, 63, -62, -33, |
| | | -31, -17, -15, -13, 35, 39, 42, 43, |
| | | 47, 57, 65, 90, 94, 126, -32, -19, |
| | | -16, -12, 91, -62, -33, -31, -17, -15, |
| | | -13, 48, 57, 65, 90, 97, 122, -128, |
| | | -65, -96, -65, -128, -65, -128, -97, -112, |
| | | -65, -128, -65, -128, -113, -32, -19, -16, |
| | | -12, 45, -62, -33, -31, -17, -15, -13, |
| | | 48, 57, 65, 90, 97, 122, -32, -19, |
| | | -16, -12, -62, -33, -31, -17, -15, -13, |
| | | 48, 57, 65, 90, 97, 122, 45, 48, |
| | | 49, 50, 73, 51, 57, 65, 90, 97, |
| | | 122, 45, 48, 57, 65, 90, 97, 122, |
| | | 45, 58, 48, 57, 65, 90, 97, 122, |
| | | 33, 90, 94, 126, 93, 45, 46, 58, |
| | | 48, 57, 65, 90, 97, 122, 48, 49, |
| | | 50, 51, 57, 46, 48, 49, 50, 51, |
| | | 57, 46, 48, 49, 50, 51, 57, 93, |
| | | 48, 57, 93, 48, 57, 53, 93, 48, |
| | | 52, 54, 57, 93, 48, 53, 46, 48, |
| | | 57, 46, 48, 57, 46, 53, 48, 52, |
| | | 54, 57, 46, 48, 53, 46, 48, 57, |
| | | 46, 48, 57, 46, 53, 48, 52, 54, |
| | | 57, 46, 48, 53, 45, 46, 58, 48, |
| | | 57, 65, 90, 97, 122, 45, 46, 58, |
| | | 48, 57, 65, 90, 97, 122, 45, 46, |
| | | 53, 58, 48, 52, 54, 57, 65, 90, |
| | | 97, 122, 45, 46, 58, 48, 53, 54, |
| | | 57, 65, 90, 97, 122, 45, 58, 80, |
| | | 48, 57, 65, 90, 97, 122, 45, 58, |
| | | 118, 48, 57, 65, 90, 97, 122, 45, |
| | | 54, 58, 48, 57, 65, 90, 97, 122, |
| | | 45, 58, 48, 57, 65, 90, 97, 122, |
| | | 58, 33, 47, 48, 57, 59, 64, 65, |
| | | 70, 71, 90, 94, 96, 97, 102, 103, |
| | | 126, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 48, 57, 65, 70, 97, 102, |
| | | 58, 48, 57, 65, 70, 97, 102, 58, |
| | | 58, 48, 57, 65, 70, 97, 102, 58, |
| | | 48, 57, 65, 70, 97, 102, 58, 48, |
| | | 57, 65, 70, 97, 102, 58, 48, 57, |
| | | 65, 70, 97, 102, 58, 58, 48, 57, |
| | | 65, 70, 97, 102, 58, 48, 57, 65, |
| | | 70, 97, 102, 58, 48, 57, 65, 70, |
| | | 97, 102, 58, 48, 57, 65, 70, 97, |
| | | 102, 58, 58, 48, 57, 65, 70, 97, |
| | | 102, 58, 48, 57, 65, 70, 97, 102, |
| | | 58, 48, 57, 65, 70, 97, 102, 58, |
| | | 48, 57, 65, 70, 97, 102, 58, 58, |
| | | 48, 57, 65, 70, 97, 102, 58, 48, |
| | | 57, 65, 70, 97, 102, 58, 48, 57, |
| | | 65, 70, 97, 102, 58, 48, 57, 65, |
| | | 70, 97, 102, 58, 58, 48, 57, 65, |
| | | 70, 97, 102, 58, 48, 57, 65, 70, |
| | | 97, 102, 58, 48, 57, 65, 70, 97, |
| | | 102, 58, 48, 57, 65, 70, 97, 102, |
| | | 58, 48, 49, 50, 58, 51, 57, 65, |
| | | 70, 97, 102, 46, 58, 48, 57, 65, |
| | | 70, 97, 102, 58, 48, 57, 65, 70, |
| | | 97, 102, 58, 48, 57, 65, 70, 97, |
| | | 102, 58, 48, 57, 65, 70, 97, 102, |
| | | 93, 48, 57, 65, 70, 97, 102, 93, |
| | | 48, 57, 65, 70, 97, 102, 93, 48, |
| | | 57, 65, 70, 97, 102, 46, 58, 48, |
| | | 57, 65, 70, 97, 102, 46, 58, 48, |
| | | 57, 65, 70, 97, 102, 46, 58, 48, |
| | | 57, 65, 70, 97, 102, 46, 53, 58, |
| | | 48, 52, 54, 57, 65, 70, 97, 102, |
| | | 46, 58, 48, 53, 54, 57, 65, 70, |
| | | 97, 102, 46, 58, 48, 57, 65, 70, |
| | | 97, 102, 46, 58, 48, 57, 65, 70, |
| | | 97, 102, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 58, 48, 57, 65, 70, |
| | | 97, 102, 48, 49, 50, 93, 51, 57, |
| | | 65, 70, 97, 102, 46, 58, 93, 48, |
| | | 57, 65, 70, 97, 102, 58, 93, 48, |
| | | 57, 65, 70, 97, 102, 58, 93, 48, |
| | | 57, 65, 70, 97, 102, 58, 93, 48, |
| | | 49, 50, 51, 57, 65, 70, 97, 102, |
| | | 46, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 49, 50, 51, 57, |
| | | 65, 70, 97, 102, 46, 58, 93, 48, |
| | | 57, 65, 70, 97, 102, 58, 93, 48, |
| | | 57, 65, 70, 97, 102, 58, 93, 48, |
| | | 57, 65, 70, 97, 102, 58, 93, 48, |
| | | 49, 50, 51, 57, 65, 70, 97, 102, |
| | | 46, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 49, 50, 51, 57, |
| | | 65, 70, 97, 102, 46, 58, 93, 48, |
| | | 57, 65, 70, 97, 102, 46, 58, 93, |
| | | 48, 57, 65, 70, 97, 102, 46, 58, |
| | | 93, 48, 57, 65, 70, 97, 102, 46, |
| | | 58, 93, 48, 57, 65, 70, 97, 102, |
| | | 46, 53, 58, 93, 48, 52, 54, 57, |
| | | 65, 70, 97, 102, 46, 58, 93, 48, |
| | | 53, 54, 57, 65, 70, 97, 102, 46, |
| | | 58, 93, 48, 57, 65, 70, 97, 102, |
| | | 46, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 46, 58, 93, 48, 57, 65, 70, |
| | | 97, 102, 46, 58, 93, 48, 57, 65, |
| | | 70, 97, 102, 46, 58, 93, 48, 57, |
| | | 65, 70, 97, 102, 46, 53, 58, 93, |
| | | 48, 52, 54, 57, 65, 70, 97, 102, |
| | | 46, 58, 93, 48, 53, 54, 57, 65, |
| | | 70, 97, 102, 46, 58, 93, 48, 57, |
| | | 65, 70, 97, 102, 46, 58, 93, 48, |
| | | 57, 65, 70, 97, 102, 58, 93, 48, |
| | | 57, 65, 70, 97, 102, 46, 58, 93, |
| | | 48, 57, 65, 70, 97, 102, 46, 58, |
| | | 93, 48, 57, 65, 70, 97, 102, 46, |
| | | 58, 93, 48, 57, 65, 70, 97, 102, |
| | | 46, 53, 58, 93, 48, 52, 54, 57, |
| | | 65, 70, 97, 102, 46, 58, 93, 48, |
| | | 53, 54, 57, 65, 70, 97, 102, 46, |
| | | 58, 93, 48, 57, 65, 70, 97, 102, |
| | | 46, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 46, 58, 93, 48, 57, 65, 70, |
| | | 97, 102, 46, 58, 93, 48, 57, 65, |
| | | 70, 97, 102, 46, 58, 93, 48, 57, |
| | | 65, 70, 97, 102, 46, 53, 58, 93, |
| | | 48, 52, 54, 57, 65, 70, 97, 102, |
| | | 46, 58, 93, 48, 53, 54, 57, 65, |
| | | 70, 97, 102, 46, 58, 93, 48, 57, |
| | | 65, 70, 97, 102, 46, 58, 93, 48, |
| | | 57, 65, 70, 97, 102, 58, 93, 48, |
| | | 57, 65, 70, 97, 102, 46, 58, 93, |
| | | 48, 57, 65, 70, 97, 102, 46, 58, |
| | | 93, 48, 57, 65, 70, 97, 102, 46, |
| | | 58, 93, 48, 57, 65, 70, 97, 102, |
| | | 46, 53, 58, 93, 48, 52, 54, 57, |
| | | 65, 70, 97, 102, 46, 58, 93, 48, |
| | | 53, 54, 57, 65, 70, 97, 102, 46, |
| | | 58, 93, 48, 57, 65, 70, 97, 102, |
| | | 46, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, 48, 57, 65, 70, 97, |
| | | 102, 58, 93, -32, -19, -16, -12, 34, |
| | | 92, -62, -33, -31, -17, -15, -13, 32, |
| | | 126, -128, -65, -96, -65, -128, -65, -128, |
| | | -97, -112, -65, -128, -65, -128, -113, 64, |
| | | 32, 126, -32, -19, -16, -12, 45, 46, |
| | | -62, -33, -31, -17, -15, -13, 48, 57, |
| | | 65, 90, 97, 122, 0}; |
| | | |
| | | static const signed char _address_single_lengths[] = { |
| | | 0, 8, 0, 8, 0, 0, 0, 0, |
| | | 0, 0, 8, 5, 0, 0, 0, 0, |
| | | 0, 0, 0, 5, 4, 5, 1, 2, |
| | | 0, 1, 3, 3, 1, 3, 1, 3, |
| | | 1, 1, 2, 1, 1, 1, 2, 1, |
| | | 1, 1, 2, 1, 3, 3, 4, 3, |
| | | 3, 3, 3, 2, 1, 2, 1, 1, |
| | | 1, 1, 1, 1, 1, 1, 1, 1, |
| | | 1, 1, 1, 1, 1, 1, 1, 1, |
| | | 1, 1, 1, 1, 1, 1, 1, 1, |
| | | 1, 1, 4, 2, 1, 1, 1, 0, |
| | | 1, 1, 1, 2, 2, 2, 3, 2, |
| | | 2, 2, 1, 2, 2, 2, 2, 0, |
| | | 2, 2, 2, 2, 0, 2, 2, 2, |
| | | 2, 0, 2, 2, 2, 2, 0, 2, |
| | | 2, 2, 2, 1, 4, 3, 2, 2, |
| | | 2, 3, 3, 2, 2, 2, 3, 3, |
| | | 2, 2, 2, 3, 3, 2, 2, 2, |
| | | 3, 3, 3, 3, 3, 4, 3, 3, |
| | | 3, 3, 3, 3, 4, 3, 3, 3, |
| | | 2, 3, 3, 3, 4, 3, 3, 3, |
| | | 2, 3, 3, 3, 4, 3, 3, 3, |
| | | 2, 3, 3, 3, 4, 3, 3, 3, |
| | | 2, 2, 6, 0, 0, 0, 0, 0, |
| | | 0, 0, 1, 0, 6, 0, 0}; |
| | | |
| | | static const signed char _address_range_lengths[] = { |
| | | 0, 8, 1, 8, 1, 1, 1, 1, |
| | | 1, 1, 8, 6, 1, 1, 1, 1, |
| | | 1, 1, 1, 6, 6, 3, 3, 3, |
| | | 2, 0, 3, 1, 0, 1, 0, 1, |
| | | 1, 1, 2, 1, 1, 1, 2, 1, |
| | | 1, 1, 2, 1, 3, 3, 4, 4, |
| | | 3, 3, 3, 3, 8, 3, 3, 3, |
| | | 0, 3, 3, 3, 3, 0, 3, 3, |
| | | 3, 3, 0, 3, 3, 3, 3, 0, |
| | | 3, 3, 3, 3, 0, 3, 3, 3, |
| | | 3, 0, 3, 3, 3, 3, 0, 3, |
| | | 3, 3, 3, 3, 3, 3, 4, 4, |
| | | 3, 3, 3, 3, 3, 3, 0, 3, |
| | | 3, 3, 3, 0, 3, 3, 3, 3, |
| | | 0, 3, 3, 3, 3, 0, 3, 3, |
| | | 3, 3, 0, 3, 3, 3, 3, 3, |
| | | 0, 3, 3, 3, 3, 0, 3, 3, |
| | | 3, 3, 0, 3, 3, 3, 3, 0, |
| | | 3, 3, 3, 3, 3, 4, 4, 3, |
| | | 3, 3, 3, 3, 4, 4, 3, 3, |
| | | 3, 3, 3, 3, 4, 4, 3, 3, |
| | | 3, 3, 3, 3, 4, 4, 3, 3, |
| | | 3, 3, 3, 3, 4, 4, 3, 3, |
| | | 3, 0, 4, 1, 1, 1, 1, 1, |
| | | 1, 1, 0, 1, 6, 0, 0}; |
| | | |
| | | static const short _address_index_offsets[] = { |
| | | 0, 0, 17, 19, 36, 38, 40, 42, |
| | | 44, 46, 48, 65, 77, 79, 81, 83, |
| | | 85, 87, 89, 91, 103, 114, 123, 128, |
| | | 134, 137, 139, 146, 151, 153, 158, 160, |
| | | 165, 168, 171, 176, 179, 182, 185, 190, |
| | | 193, 196, 199, 204, 207, 214, 221, 230, |
| | | 238, 245, 252, 259, 265, 275, 281, 286, |
| | | 291, 293, 298, 303, 308, 313, 315, 320, |
| | | 325, 330, 335, 337, 342, 347, 352, 357, |
| | | 359, 364, 369, 374, 379, 381, 386, 391, |
| | | 396, 401, 403, 411, 417, 422, 427, 429, |
| | | 433, 438, 443, 448, 454, 460, 466, 474, |
| | | 481, 487, 493, 498, 504, 510, 516, 519, |
| | | 523, 529, 535, 541, 544, 548, 554, 560, |
| | | 566, 569, 573, 579, 585, 591, 594, 598, |
| | | 604, 610, 616, 619, 624, 632, 639, 645, |
| | | 651, 654, 661, 668, 674, 680, 683, 690, |
| | | 697, 703, 709, 712, 719, 726, 732, 738, |
| | | 741, 748, 755, 762, 769, 776, 785, 793, |
| | | 800, 807, 814, 821, 828, 837, 845, 852, |
| | | 859, 865, 872, 879, 886, 895, 903, 910, |
| | | 917, 923, 930, 937, 944, 953, 961, 968, |
| | | 975, 981, 988, 995, 1002, 1011, 1019, 1026, |
| | | 1033, 1039, 1042, 1053, 1055, 1057, 1059, 1061, |
| | | 1063, 1065, 1067, 1069, 1071, 1084, 0}; |
| | | |
| | | static const short _address_cond_targs[] = { |
| | | 4, 6, 7, 9, 186, 3, 3, 3, |
| | | 2, 5, 8, 3, 3, 3, 3, 3, |
| | | 0, 3, 0, 4, 6, 7, 9, 3, |
| | | 10, 3, 11, 2, 5, 8, 3, 3, |
| | | 3, 3, 3, 0, 2, 0, 2, 0, |
| | | 2, 0, 5, 0, 5, 0, 5, 0, |
| | | 4, 6, 7, 9, 3, 3, 3, 3, |
| | | 2, 5, 8, 3, 3, 3, 3, 3, |
| | | 0, 13, 15, 16, 18, 21, 12, 14, |
| | | 17, 196, 196, 196, 0, 196, 0, 12, |
| | | 0, 12, 0, 12, 0, 14, 0, 14, |
| | | 0, 14, 0, 13, 15, 16, 18, 19, |
| | | 12, 14, 17, 196, 196, 196, 0, 13, |
| | | 15, 16, 18, 12, 14, 17, 196, 196, |
| | | 196, 0, 22, 26, 44, 46, 48, 45, |
| | | 23, 23, 0, 22, 23, 23, 23, 0, |
| | | 22, 24, 23, 23, 23, 0, 25, 25, |
| | | 0, 197, 0, 22, 27, 24, 23, 23, |
| | | 23, 0, 28, 40, 42, 41, 0, 29, |
| | | 0, 30, 36, 38, 37, 0, 31, 0, |
| | | 25, 32, 34, 33, 0, 197, 33, 0, |
| | | 197, 25, 0, 35, 197, 33, 25, 0, |
| | | 197, 25, 0, 31, 37, 0, 31, 30, |
| | | 0, 31, 39, 37, 30, 0, 31, 30, |
| | | 0, 29, 41, 0, 29, 28, 0, 29, |
| | | 43, 41, 28, 0, 29, 28, 0, 22, |
| | | 27, 24, 45, 23, 23, 0, 22, 27, |
| | | 24, 26, 23, 23, 0, 22, 27, 47, |
| | | 24, 45, 26, 23, 23, 0, 22, 27, |
| | | 24, 26, 23, 23, 23, 0, 22, 24, |
| | | 49, 23, 23, 23, 0, 22, 24, 50, |
| | | 23, 23, 23, 0, 22, 51, 24, 23, |
| | | 23, 23, 0, 22, 52, 23, 23, 23, |
| | | 0, 185, 25, 53, 25, 53, 25, 25, |
| | | 53, 25, 0, 57, 197, 54, 54, 54, |
| | | 0, 57, 55, 55, 55, 0, 57, 56, |
| | | 56, 56, 0, 57, 0, 124, 58, 58, |
| | | 58, 0, 62, 59, 59, 59, 0, 62, |
| | | 60, 60, 60, 0, 62, 61, 61, 61, |
| | | 0, 62, 0, 124, 63, 63, 63, 0, |
| | | 67, 64, 64, 64, 0, 67, 65, 65, |
| | | 65, 0, 67, 66, 66, 66, 0, 67, |
| | | 0, 124, 68, 68, 68, 0, 72, 69, |
| | | 69, 69, 0, 72, 70, 70, 70, 0, |
| | | 72, 71, 71, 71, 0, 72, 0, 124, |
| | | 73, 73, 73, 0, 77, 74, 74, 74, |
| | | 0, 77, 75, 75, 75, 0, 77, 76, |
| | | 76, 76, 0, 77, 0, 98, 78, 78, |
| | | 78, 0, 82, 79, 79, 79, 0, 82, |
| | | 80, 80, 80, 0, 82, 81, 81, 81, |
| | | 0, 82, 0, 83, 91, 94, 98, 97, |
| | | 123, 123, 0, 27, 87, 84, 84, 84, |
| | | 0, 87, 85, 85, 85, 0, 87, 86, |
| | | 86, 86, 0, 87, 0, 88, 88, 88, |
| | | 0, 197, 89, 89, 89, 0, 197, 90, |
| | | 90, 90, 0, 197, 25, 25, 25, 0, |
| | | 27, 87, 92, 84, 84, 0, 27, 87, |
| | | 93, 85, 85, 0, 27, 87, 86, 86, |
| | | 86, 0, 27, 95, 87, 92, 96, 84, |
| | | 84, 0, 27, 87, 93, 85, 85, 85, |
| | | 0, 27, 87, 85, 85, 85, 0, 27, |
| | | 87, 96, 84, 84, 0, 197, 99, 99, |
| | | 99, 0, 103, 197, 100, 100, 100, 0, |
| | | 103, 197, 101, 101, 101, 0, 103, 197, |
| | | 102, 102, 102, 0, 103, 197, 0, 104, |
| | | 104, 104, 0, 108, 197, 105, 105, 105, |
| | | 0, 108, 197, 106, 106, 106, 0, 108, |
| | | 197, 107, 107, 107, 0, 108, 197, 0, |
| | | 109, 109, 109, 0, 113, 197, 110, 110, |
| | | 110, 0, 113, 197, 111, 111, 111, 0, |
| | | 113, 197, 112, 112, 112, 0, 113, 197, |
| | | 0, 114, 114, 114, 0, 118, 197, 115, |
| | | 115, 115, 0, 118, 197, 116, 116, 116, |
| | | 0, 118, 197, 117, 117, 117, 0, 118, |
| | | 197, 0, 119, 119, 119, 0, 87, 197, |
| | | 120, 120, 120, 0, 87, 197, 121, 121, |
| | | 121, 0, 87, 197, 122, 122, 122, 0, |
| | | 87, 197, 0, 87, 84, 84, 84, 0, |
| | | 125, 177, 180, 197, 183, 184, 184, 0, |
| | | 27, 129, 197, 126, 126, 126, 0, 129, |
| | | 197, 127, 127, 127, 0, 129, 197, 128, |
| | | 128, 128, 0, 129, 197, 0, 130, 169, |
| | | 172, 175, 176, 176, 0, 27, 134, 197, |
| | | 131, 131, 131, 0, 134, 197, 132, 132, |
| | | 132, 0, 134, 197, 133, 133, 133, 0, |
| | | 134, 197, 0, 135, 161, 164, 167, 168, |
| | | 168, 0, 27, 139, 197, 136, 136, 136, |
| | | 0, 139, 197, 137, 137, 137, 0, 139, |
| | | 197, 138, 138, 138, 0, 139, 197, 0, |
| | | 140, 153, 156, 159, 160, 160, 0, 27, |
| | | 144, 197, 141, 141, 141, 0, 144, 197, |
| | | 142, 142, 142, 0, 144, 197, 143, 143, |
| | | 143, 0, 144, 197, 0, 145, 146, 149, |
| | | 152, 119, 119, 0, 27, 87, 197, 120, |
| | | 120, 120, 0, 27, 87, 197, 147, 120, |
| | | 120, 0, 27, 87, 197, 148, 121, 121, |
| | | 0, 27, 87, 197, 122, 122, 122, 0, |
| | | 27, 150, 87, 197, 147, 151, 120, 120, |
| | | 0, 27, 87, 197, 148, 121, 121, 121, |
| | | 0, 27, 87, 197, 121, 121, 121, 0, |
| | | 27, 87, 197, 151, 120, 120, 0, 27, |
| | | 144, 197, 154, 141, 141, 0, 27, 144, |
| | | 197, 155, 142, 142, 0, 27, 144, 197, |
| | | 143, 143, 143, 0, 27, 157, 144, 197, |
| | | 154, 158, 141, 141, 0, 27, 144, 197, |
| | | 155, 142, 142, 142, 0, 27, 144, 197, |
| | | 142, 142, 142, 0, 27, 144, 197, 158, |
| | | 141, 141, 0, 144, 197, 141, 141, 141, |
| | | 0, 27, 139, 197, 162, 136, 136, 0, |
| | | 27, 139, 197, 163, 137, 137, 0, 27, |
| | | 139, 197, 138, 138, 138, 0, 27, 165, |
| | | 139, 197, 162, 166, 136, 136, 0, 27, |
| | | 139, 197, 163, 137, 137, 137, 0, 27, |
| | | 139, 197, 137, 137, 137, 0, 27, 139, |
| | | 197, 166, 136, 136, 0, 139, 197, 136, |
| | | 136, 136, 0, 27, 134, 197, 170, 131, |
| | | 131, 0, 27, 134, 197, 171, 132, 132, |
| | | 0, 27, 134, 197, 133, 133, 133, 0, |
| | | 27, 173, 134, 197, 170, 174, 131, 131, |
| | | 0, 27, 134, 197, 171, 132, 132, 132, |
| | | 0, 27, 134, 197, 132, 132, 132, 0, |
| | | 27, 134, 197, 174, 131, 131, 0, 134, |
| | | 197, 131, 131, 131, 0, 27, 129, 197, |
| | | 178, 126, 126, 0, 27, 129, 197, 179, |
| | | 127, 127, 0, 27, 129, 197, 128, 128, |
| | | 128, 0, 27, 181, 129, 197, 178, 182, |
| | | 126, 126, 0, 27, 129, 197, 179, 127, |
| | | 127, 127, 0, 27, 129, 197, 127, 127, |
| | | 127, 0, 27, 129, 197, 182, 126, 126, |
| | | 0, 129, 197, 126, 126, 126, 0, 124, |
| | | 197, 0, 188, 190, 191, 193, 194, 195, |
| | | 187, 189, 192, 186, 0, 186, 0, 187, |
| | | 0, 187, 0, 187, 0, 189, 0, 189, |
| | | 0, 189, 0, 11, 0, 186, 0, 13, |
| | | 15, 16, 18, 19, 20, 12, 14, 17, |
| | | 196, 196, 196, 0, 0, 0, 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, 0}; |
| | | |
| | | static const signed char _address_cond_actions[] = { |
| | | 0, 0, 0, 0, 0, 0, 0, 0, |
| | | 0, 0, 0, 0, 0, 0, 0, 0, |
| | | 3, 0, 3, 0, 0, 0, 0, 0, |
| | | 0, 0, 0, 0, 0, 0, 0, 0, |
| | | 0, 0, 0, 3, 0, 3, 0, 3, |
| | | 0, 3, 0, 3, 0, 3, 0, 3, |
| | | 0, 0, 0, 0, 0, 0, 0, 0, |
| | | 0, 0, 0, 0, 0, 0, 0, 0, |
| | | 3, 0, 0, 0, 0, 0, 0, 0, |
| | | 0, 1, 1, 1, 3, 1, 3, 0, |
| | | 3, 0, 3, 0, 3, 0, 3, 0, |
| | | 3, 0, 3, 0, 0, 0, 0, 0, |
| | | 0, 0, 0, 1, 1, 1, 3, 0, |
| | | 0, 0, 0, 0, 0, 0, 1, 1, |
| | | 1, 3, 0, 0, 0, 0, 0, 0, |
| | | 0, 0, 3, 0, 0, 0, 0, 3, |
| | | 0, 0, 0, 0, 0, 3, 0, 0, |
| | | 3, 1, 3, 0, 0, 0, 0, 0, |
| | | 0, 3, 0, 0, 0, 0, 3, 0, |
| | | 3, 0, 0, 0, 0, 3, 0, 3, |
| | | 0, 0, 0, 0, 3, 1, 0, 3, |
| | | 1, 0, 3, 0, 1, 0, 0, 3, |
| | | 1, 0, 3, 0, 0, 3, 0, 0, |
| | | 3, 0, 0, 0, 0, 3, 0, 0, |
| | | 3, 0, 0, 3, 0, 0, 3, 0, |
| | | 0, 0, 0, 3, 0, 0, 3, 0, |
| | | 0, 0, 0, 0, 0, 3, 0, 0, |
| | | 0, 0, 0, 0, 3, 0, 0, 0, |
| | | 0, 0, 0, 0, 0, 3, 0, 0, |
| | | 0, 0, 0, 0, 0, 3, 0, 0, |
| | | 0, 0, 0, 0, 3, 0, 0, 0, |
| | | 0, 0, 0, 3, 0, 0, 0, 0, |
| | | 0, 0, 3, 0, 0, 0, 0, 0, |
| | | 3, 0, 0, 0, 0, 0, 0, 0, |
| | | 0, 0, 3, 0, 1, 0, 0, 0, |
| | | 3, 0, 0, 0, 0, 3, 0, 0, |
| | | 0, 0, 3, 0, 3, 0, 0, 0, |
| | | 0, 3, 0, 0, 0, 0, 3, 0, |
| | | 0, 0, 0, 3, 0, 0, 0, 0, |
| | | 3, 0, 3, 0, 0, 0, 0, 3, |
| | | 0, 0, 0, 0, 3, 0, 0, 0, |
| | | 0, 3, 0, 0, 0, 0, 3, 0, |
| | | 3, 0, 0, 0, 0, 3, 0, 0, |
| | | 0, 0, 3, 0, 0, 0, 0, 3, |
| | | 0, 0, 0, 0, 3, 0, 3, 0, |
| | | 0, 0, 0, 3, 0, 0, 0, 0, |
| | | 3, 0, 0, 0, 0, 3, 0, 0, |
| | | 0, 0, 3, 0, 3, 0, 0, 0, |
| | | 0, 3, 0, 0, 0, 0, 3, 0, |
| | | 0, 0, 0, 3, 0, 0, 0, 0, |
| | | 3, 0, 3, 0, 0, 0, 0, 0, |
| | | 0, 0, 3, 0, 0, 0, 0, 0, |
| | | 3, 0, 0, 0, 0, 3, 0, 0, |
| | | 0, 0, 3, 0, 3, 0, 0, 0, |
| | | 3, 1, 0, 0, 0, 3, 1, 0, |
| | | 0, 0, 3, 1, 0, 0, 0, 3, |
| | | 0, 0, 0, 0, 0, 3, 0, 0, |
| | | 0, 0, 0, 3, 0, 0, 0, 0, |
| | | 0, 3, 0, 0, 0, 0, 0, 0, |
| | | 0, 3, 0, 0, 0, 0, 0, 0, |
| | | 3, 0, 0, 0, 0, 0, 3, 0, |
| | | 0, 0, 0, 0, 3, 1, 0, 0, |
| | | 0, 3, 0, 1, 0, 0, 0, 3, |
| | | 0, 1, 0, 0, 0, 3, 0, 1, |
| | | 0, 0, 0, 3, 0, 1, 3, 0, |
| | | 0, 0, 3, 0, 1, 0, 0, 0, |
| | | 3, 0, 1, 0, 0, 0, 3, 0, |
| | | 1, 0, 0, 0, 3, 0, 1, 3, |
| | | 0, 0, 0, 3, 0, 1, 0, 0, |
| | | 0, 3, 0, 1, 0, 0, 0, 3, |
| | | 0, 1, 0, 0, 0, 3, 0, 1, |
| | | 3, 0, 0, 0, 3, 0, 1, 0, |
| | | 0, 0, 3, 0, 1, 0, 0, 0, |
| | | 3, 0, 1, 0, 0, 0, 3, 0, |
| | | 1, 3, 0, 0, 0, 3, 0, 1, |
| | | 0, 0, 0, 3, 0, 1, 0, 0, |
| | | 0, 3, 0, 1, 0, 0, 0, 3, |
| | | 0, 1, 3, 0, 0, 0, 0, 3, |
| | | 0, 0, 0, 1, 0, 0, 0, 3, |
| | | 0, 0, 1, 0, 0, 0, 3, 0, |
| | | 1, 0, 0, 0, 3, 0, 1, 0, |
| | | 0, 0, 3, 0, 1, 3, 0, 0, |
| | | 0, 0, 0, 0, 3, 0, 0, 1, |
| | | 0, 0, 0, 3, 0, 1, 0, 0, |
| | | 0, 3, 0, 1, 0, 0, 0, 3, |
| | | 0, 1, 3, 0, 0, 0, 0, 0, |
| | | 0, 3, 0, 0, 1, 0, 0, 0, |
| | | 3, 0, 1, 0, 0, 0, 3, 0, |
| | | 1, 0, 0, 0, 3, 0, 1, 3, |
| | | 0, 0, 0, 0, 0, 0, 3, 0, |
| | | 0, 1, 0, 0, 0, 3, 0, 1, |
| | | 0, 0, 0, 3, 0, 1, 0, 0, |
| | | 0, 3, 0, 1, 3, 0, 0, 0, |
| | | 0, 0, 0, 3, 0, 0, 1, 0, |
| | | 0, 0, 3, 0, 0, 1, 0, 0, |
| | | 0, 3, 0, 0, 1, 0, 0, 0, |
| | | 3, 0, 0, 1, 0, 0, 0, 3, |
| | | 0, 0, 0, 1, 0, 0, 0, 0, |
| | | 3, 0, 0, 1, 0, 0, 0, 0, |
| | | 3, 0, 0, 1, 0, 0, 0, 3, |
| | | 0, 0, 1, 0, 0, 0, 3, 0, |
| | | 0, 1, 0, 0, 0, 3, 0, 0, |
| | | 1, 0, 0, 0, 3, 0, 0, 1, |
| | | 0, 0, 0, 3, 0, 0, 0, 1, |
| | | 0, 0, 0, 0, 3, 0, 0, 1, |
| | | 0, 0, 0, 0, 3, 0, 0, 1, |
| | | 0, 0, 0, 3, 0, 0, 1, 0, |
| | | 0, 0, 3, 0, 1, 0, 0, 0, |
| | | 3, 0, 0, 1, 0, 0, 0, 3, |
| | | 0, 0, 1, 0, 0, 0, 3, 0, |
| | | 0, 1, 0, 0, 0, 3, 0, 0, |
| | | 0, 1, 0, 0, 0, 0, 3, 0, |
| | | 0, 1, 0, 0, 0, 0, 3, 0, |
| | | 0, 1, 0, 0, 0, 3, 0, 0, |
| | | 1, 0, 0, 0, 3, 0, 1, 0, |
| | | 0, 0, 3, 0, 0, 1, 0, 0, |
| | | 0, 3, 0, 0, 1, 0, 0, 0, |
| | | 3, 0, 0, 1, 0, 0, 0, 3, |
| | | 0, 0, 0, 1, 0, 0, 0, 0, |
| | | 3, 0, 0, 1, 0, 0, 0, 0, |
| | | 3, 0, 0, 1, 0, 0, 0, 3, |
| | | 0, 0, 1, 0, 0, 0, 3, 0, |
| | | 1, 0, 0, 0, 3, 0, 0, 1, |
| | | 0, 0, 0, 3, 0, 0, 1, 0, |
| | | 0, 0, 3, 0, 0, 1, 0, 0, |
| | | 0, 3, 0, 0, 0, 1, 0, 0, |
| | | 0, 0, 3, 0, 0, 1, 0, 0, |
| | | 0, 0, 3, 0, 0, 1, 0, 0, |
| | | 0, 3, 0, 0, 1, 0, 0, 0, |
| | | 3, 0, 1, 0, 0, 0, 3, 0, |
| | | 1, 3, 0, 0, 0, 0, 0, 0, |
| | | 0, 0, 0, 0, 3, 0, 3, 0, |
| | | 3, 0, 3, 0, 3, 0, 3, 0, |
| | | 3, 0, 3, 0, 3, 0, 3, 0, |
| | | 0, 0, 0, 0, 0, 0, 0, 0, |
| | | 1, 1, 1, 3, 3, 0, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 3, 3, 3, 3, 3, 3, 3, |
| | | 3, 0, 0, 0}; |
| | | |
| | | static const short _address_eof_trans[] = { |
| | | 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, |
| | | 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, |
| | | 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, |
| | | 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, |
| | | 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, |
| | | 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, |
| | | 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, |
| | | 1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, |
| | | 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, |
| | | 1158, 1159, 1160, 1161, 1162, 1163, 1164, 1165, |
| | | 1166, 1167, 1168, 1169, 1170, 1171, 1172, 1173, |
| | | 1174, 1175, 1176, 1177, 1178, 1179, 1180, 1181, |
| | | 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, |
| | | 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197, |
| | | 1198, 1199, 1200, 1201, 1202, 1203, 1204, 1205, |
| | | 1206, 1207, 1208, 1209, 1210, 1211, 1212, 1213, |
| | | 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, |
| | | 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, |
| | | 1230, 1231, 1232, 1233, 1234, 1235, 1236, 1237, |
| | | 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, |
| | | 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253, |
| | | 1254, 1255, 1256, 1257, 1258, 1259, 1260, 1261, |
| | | 1262, 1263, 1264, 1265, 1266, 1267, 1268, 1269, |
| | | 1270, 1271, 1272, 1273, 1274, 1275, 1276, 1277, |
| | | 1278, 1279, 1280, 1281, 1282, 1283, 0}; |
| | | |
| | | static const int address_start = 1; |
| | | |
| | | bool is_address(const char *p, const char *pe) |
| | | { |
| | | int cs = 0; |
| | | |
| | | const char *eof = pe; |
| | | |
| | | bool result = false; |
| | | |
| | | { |
| | | cs = (int) address_start; |
| | | } |
| | | { |
| | | int _klen; |
| | | unsigned int _trans = 0; |
| | | const signed char *_keys; |
| | | const signed char *_acts; |
| | | unsigned int _nacts; |
| | | _resume : { |
| | | } |
| | | if (p == pe && p != eof) |
| | | goto _out; |
| | | if (p == eof) { |
| | | if (_address_eof_trans[cs] > 0) { |
| | | _trans = (unsigned int) _address_eof_trans[cs] - 1; |
| | | } |
| | | } else { |
| | | _keys = (_address_trans_keys + (_address_key_offsets[cs])); |
| | | _trans = (unsigned int) _address_index_offsets[cs]; |
| | | |
| | | _klen = (int) _address_single_lengths[cs]; |
| | | if (_klen > 0) { |
| | | const signed char *_lower = _keys; |
| | | const signed char *_upper = _keys + _klen - 1; |
| | | const signed char *_mid; |
| | | while (1) { |
| | | if (_upper < _lower) { |
| | | _keys += _klen; |
| | | _trans += (unsigned int) _klen; |
| | | break; |
| | | } |
| | | |
| | | _mid = _lower + ((_upper - _lower) >> 1); |
| | | if (((*(p))) < (*(_mid))) |
| | | _upper = _mid - 1; |
| | | else if (((*(p))) > (*(_mid))) |
| | | _lower = _mid + 1; |
| | | else { |
| | | _trans += (unsigned int) (_mid - _keys); |
| | | goto _match; |
| | | } |
| | | } |
| | | } |
| | | |
| | | _klen = (int) _address_range_lengths[cs]; |
| | | if (_klen > 0) { |
| | | const signed char *_lower = _keys; |
| | | const signed char *_upper = _keys + (_klen << 1) - 2; |
| | | const signed char *_mid; |
| | | while (1) { |
| | | if (_upper < _lower) { |
| | | _trans += (unsigned int) _klen; |
| | | break; |
| | | } |
| | | |
| | | _mid = _lower + (((_upper - _lower) >> 1) & ~1); |
| | | if (((*(p))) < (*(_mid))) |
| | | _upper = _mid - 2; |
| | | else if (((*(p))) > (*(_mid + 1))) |
| | | _lower = _mid + 2; |
| | | else { |
| | | _trans += (unsigned int) ((_mid - _keys) >> 1); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | _match : { |
| | | } |
| | | } |
| | | cs = (int) _address_cond_targs[_trans]; |
| | | |
| | | if (_address_cond_actions[_trans] != 0) { |
| | | |
| | | _acts = (_address_actions + (_address_cond_actions[_trans])); |
| | | _nacts = (unsigned int) (*(_acts)); |
| | | _acts += 1; |
| | | while (_nacts > 0) { |
| | | switch ((*(_acts))) { |
| | | case 0: { |
| | | { |
| | | result = true; |
| | | } |
| | | break; |
| | | } |
| | | case 1: { |
| | | { |
| | | result = false; |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | _nacts -= 1; |
| | | _acts += 1; |
| | | } |
| | | } |
| | | |
| | | if (p == eof) { |
| | | if (cs >= 196) |
| | | goto _out; |
| | | } else { |
| | | if (cs != 0) { |
| | | p += 1; |
| | | goto _resume; |
| | | } |
| | | } |
| | | _out : { |
| | | } |
| | | } |
| | | return result; |
| | | } |
| src/backend/utils/dbms/dbms_json_schema/vendor/smtp-address-validator.hpp
src/backend/utils/dbms/dbms_json_schema/vendor/string-format-check.cpp
src/backend/utils/dbms/dbms_sqlset/dbms_sqlset.cpp
src/backend/utils/dbms/dbms_sqlset/dbms_sqlset.hpp
src/backend/utils/dbms/dbms_stat_funcs/dbms_stat_funcs.cpp
src/backend/utils/dbms/dbms_stat_funcs/dbms_stat_funcs.hpp
src/backend/utils/dbms/dbms_system/dbms_system.cpp
src/backend/utils/dbms/dbms_system/dbms_system.hpp
src/backend/utils/dbms/dbms_tns/dbms_tns.cpp
src/backend/utils/dbms/dbms_tns/dbms_tns.hpp
src/backend/utils/dbms/dbms_trace/dbms_trace.cpp
src/backend/utils/dbms/dbms_trace/dbms_trace.hpp
src/backend/utils/dbms/dbms_transaction/dbms_transaction.cpp
src/backend/utils/dbms/dbms_transaction/dbms_transaction.hpp
src/backend/utils/dbms/dbms_warning/dbms_warning.cpp
src/backend/utils/dbms/dbms_warning/dbms_warning.hpp
src/backend/utils/dbms/dbms_warning/dbms_warning_errors.cpp
src/backend/utils/dbms/dbms_warning/dbms_warning_errors.hpp
src/backend/utils/dbms/dbms_xmlsave/dbms_xmlsave.cpp
src/backend/utils/dbms/dbms_xmlsave/dbms_xmlsave.hpp
src/backend/utils/dbms/dbms_xmlstore/dbms_xmlstore.cpp
src/backend/utils/dbms/dbms_xmlstore/dbms_xmlstore.hpp
src/backend/utils/dbms/htf/htf.cpp
src/backend/utils/dbms/htf/htf.hpp
src/backend/utils/dbms/htf/htf_common.cpp
src/backend/utils/dbms/htf/htf_common.hpp
src/backend/utils/dbms/htp/htp.cpp
src/backend/utils/dbms/nlohmann/json-schema.hpp
src/backend/utils/dbms/nlohmann/json.hpp
src/backend/utils/dbms/owa/owa_cache.cpp
src/backend/utils/dbms/owa/owa_cookie.cpp
src/backend/utils/dbms/owa_match/owa_match.cpp
src/backend/utils/dbms/owa_pattern/owa_pattern.cpp
src/backend/utils/dbms/owa_text/owa_text.cpp
src/backend/utils/dbms/owa_util/owa_util.cpp
src/backend/utils/dbms/owa_util/owa_util.hpp
src/backend/utils/dbms/package_methods_reference.ru.adoc
src/backend/utils/dbms/utl_gdk/utl_gdk.cpp
src/backend/utils/dbms/utl_gdk/utl_gdk.hpp
src/backend/utils/misc/guc_tables.c
src/bin/pg_amcheck/pg_amcheck.c
src/common/coder.cpp
src/include/catalog/pg_proc.dat
src/include/common/coder.hpp
src/include/dbms/htp.h
src/include/dbms/owa.h
src/include/dbms/owa_pattern.h
src/include/dbms/owa_text.h
src/include/pg_config.h.in
src/include/utils/coder.h
src/include/utils/dbms_warning.h
src/pl/plpgsql/src/pl_comp.c
src/test/regress/expected/dbms_db_version.out
src/test/regress/expected/dbms_ddl.out
src/test/regress/expected/dbms_file_transfer.out
src/test/regress/expected/dbms_json.out
src/test/regress/expected/dbms_json_schema.out
src/test/regress/expected/dbms_sqlset.out
src/test/regress/expected/dbms_stat_funcs.out
src/test/regress/expected/dbms_system.out
src/test/regress/expected/dbms_tns.out
src/test/regress/expected/dbms_trace.out
src/test/regress/expected/dbms_warning.out
src/test/regress/expected/dbms_xmlsave.out
src/test/regress/expected/dbms_xmlstore.out
src/test/regress/expected/htf.out
src/test/regress/expected/htp.out
src/test/regress/expected/opr_sanity.out
src/test/regress/expected/owa_cache.out
src/test/regress/expected/owa_cookie.out
src/test/regress/expected/owa_cookie_constraints.out
src/test/regress/expected/owa_pattern.out
src/test/regress/expected/rules.out
src/test/regress/expected/utl_file.out
src/test/regress/expected/utl_gdk.out
src/test/regress/parallel_schedule
src/test/regress/regress.c
src/test/regress/sql/dbms_db_version.sql
src/test/regress/sql/dbms_ddl.sql
src/test/regress/sql/dbms_file_transfer.sql
src/test/regress/sql/dbms_jsno_get_veiw_sql.sql
src/test/regress/sql/dbms_json.sql
src/test/regress/sql/dbms_json_schema.sql
src/test/regress/sql/dbms_sqlset.sql
src/test/regress/sql/dbms_stat_funcs.sql
src/test/regress/sql/dbms_system.sql
src/test/regress/sql/dbms_tns.sql
src/test/regress/sql/dbms_trace.sql
src/test/regress/sql/dbms_warning.sql
src/test/regress/sql/dbms_xmlsave.sql
src/test/regress/sql/dbms_xmlstore.sql
src/test/regress/sql/htf.sql
src/test/regress/sql/htp.sql
src/test/regress/sql/is_valid_function.sql
src/test/regress/sql/is_valid_function_oracle.sql
src/test/regress/sql/owa_cache.sql
src/test/regress/sql/owa_cache_oracle.sql
src/test/regress/sql/owa_cookie.sql
src/test/regress/sql/owa_cookie_constraints.sql
src/test/regress/sql/owa_cookie_constraints_oracle.sql
src/test/regress/sql/owa_cookie_oracle.sql
src/test/regress/sql/owa_pattern.sql
src/test/regress/sql/utl_file.sql
src/test/regress/sql/utl_gdk.sql |