-
Notifications
You must be signed in to change notification settings - Fork 175
Compatible with Oracle's sys_guid function #844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ subdir = | |
| top_builddir = . | ||
| include $(top_builddir)/src/Makefile.global | ||
|
|
||
| $(call recurse,all install,src config contrib/ivorysql_ora contrib/ora_btree_gist contrib/ora_btree_gin) | ||
| $(call recurse,all install,src config contrib/ivorysql_ora contrib/uuid-ossp contrib/ora_btree_gist contrib/ora_btree_gin) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you clarify why this file was modified?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, @OreoYang
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's make sense.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello @Carlos-Chong200 @OreoYang Question has raised in the past about UUID function "in-core" or not (on psql-hackers). OSSP was on the topic. It's a bit surprising to have dependency on contrib/extensions for
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, Cedric, In addition to uuid extension, there are other extensions that are created in initdb, like plisql, ivorysql_ora. |
||
|
|
||
| docs: | ||
| $(MAKE) -C doc all | ||
|
|
@@ -45,7 +45,7 @@ $(call recurse,coverage,doc src config contrib) | |
|
|
||
| # clean, distclean, etc should apply to contrib too, even though | ||
| # it's not built by default | ||
| $(call recurse,clean,doc contrib contrib/ivorysql_ora contrib/ora_btree_gist contrib/ora_btree_gin src config) | ||
| $(call recurse,clean,doc contrib contrib/ivorysql_ora contrib/uuid-ossp contrib/ora_btree_gist contrib/ora_btree_gin src config) | ||
| clean: | ||
| rm -rf tmp_install/ portlock/ | ||
| # Garbage from autoconf: | ||
|
|
@@ -95,7 +95,7 @@ GNUmakefile: GNUmakefile.in $(top_builddir)/config.status | |
|
|
||
| $(call recurse,oracle-pg-check-world,src/test,oracle-pg-check) | ||
| #add oracle regression | ||
| $(call recurse,oracle-check-world,src/oracle_test src/pl src/interfaces/ecpg src/interfaces/libpq/ivytest contrib contrib/ivorysql_ora contrib/ora_btree_gist contrib/ora_btree_gin src/bin,oracle-check) | ||
| $(call recurse,oracle-check-world,src/oracle_test src/pl src/interfaces/ecpg src/interfaces/libpq/ivytest contrib contrib/ivorysql_ora contrib/uuid-ossp contrib/ora_btree_gist contrib/ora_btree_gin src/bin,oracle-check) | ||
| $(call recurse,oracle-checkprep, src/oracle_test src/pl src/interfaces/ecpg contrib src/bin) | ||
|
|
||
| $(call recurse,oracle-installcheck-world,src/oracle_test src/pl src/interfaces/ecpg contrib src/bin,oracle-installcheck) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,3 +13,8 @@ CREATE TYPE sys.urowid AS(rowoid OID, rowno bigint); | |
|
|
||
| CREATE CAST (sys.rowid AS sys.urowid) WITH INOUT AS IMPLICIT; | ||
| CREATE CAST (sys.urowid AS sys.rowid) WITH INOUT AS IMPLICIT; | ||
|
|
||
| -- | ||
| -- Plugin uuid-ossp | ||
| -- | ||
| CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; | ||
|
Comment on lines
+16
to
+20
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainDon't CREATE EXTENSION while search_path is set to sys (objects will be installed into sys). At this point search_path=sys; CREATE EXTENSION without SCHEMA will place extension objects (e.g., uuid_generate_*) into sys, not public. That can break lookups/tests expecting these functions on the default path and pollutes the sys schema. Recommend creating the extension with search_path reset to default (public), then restore sys: --
-- Plugin uuid-ossp
--
-CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
+RESET search_path; -- ensure extension installs into public
+CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
+SET search_path TO sys; -- restore Oracle compatibility pathAlternatively (if the extension is relocatable), you can force it into public:
Run to confirm relocatable status and avoid the SCHEMA clause if false, and to ensure default_version is 1.1: 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Locate control file and check 'relocatable' and 'default_version'
fd -a uuid-ossp.control | tee /dev/stderr
if fd -a uuid-ossp.control >/dev/null; then
rg -n "^(relocatable|default_version)\s*=" $(fd -a uuid-ossp.control)
else
echo "uuid-ossp.control not found under contrib/uuid-ossp" >&2
fiLength of output: 157 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Find the uuid-ossp control file
control_file=$(fd -a uuid-ossp.control || true)
if [[ -z "$control_file" ]]; then
echo "uuid-ossp.control not found in the repo" >&2
exit 1
fi
echo "Found control file: $control_file"
# Print relocatable and default_version settings
rg -n "^(relocatable|default_version)\s*=" "$control_file"Length of output: 488 Ensure uuid-ossp Installs into the Public Schema We’ve confirmed from
You can address this in one of two ways: • Reset the --
-- Plugin uuid-ossp
--
- CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
+ RESET search_path; -- ensure objects go into public
+ CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
+ SET search_path TO sys; -- restore Oracle-compat path• Or, since the extension is relocatable, force it into CREATE EXTENSION IF NOT EXISTS "uuid-ossp" SCHEMA public;Pick the approach that best fits your code-style guidelines. 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| DROP EXTENSION IF EXISTS "uuid-ossp" CASCADE; | ||
| CREATE EXTENSION "uuid-ossp"; | ||
|
|
||
| SELECT uuid_nil(); | ||
|
|
@@ -79,3 +80,5 @@ SELECT uuid_version_bits(uuid_generate_v4()), | |
| uuid_reserved_bits(uuid_generate_v4()); | ||
|
|
||
| SELECT uuid_generate_v4() <> uuid_generate_v4(); | ||
|
|
||
| SELECT sys_guid() <> sys_guid(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need also change corresponding expected/ivy_uuid_ossp.out, otherwise the regression test would fail. |
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -102,6 +102,9 @@ do { \ | |||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| #endif /* !HAVE_UUID_OSSP */ | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /** The byte length of the value returned by ora_sys_guid **/ | ||||||||||||||||||||||||||||||||||||||||||||||
| #define SYS_GUID_LENGTH 16 | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| PG_MODULE_MAGIC; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| PG_FUNCTION_INFO_V1(uuid_nil); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -115,7 +118,7 @@ PG_FUNCTION_INFO_V1(uuid_generate_v1mc); | |||||||||||||||||||||||||||||||||||||||||||||
| PG_FUNCTION_INFO_V1(uuid_generate_v3); | ||||||||||||||||||||||||||||||||||||||||||||||
| PG_FUNCTION_INFO_V1(uuid_generate_v4); | ||||||||||||||||||||||||||||||||||||||||||||||
| PG_FUNCTION_INFO_V1(uuid_generate_v5); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| PG_FUNCTION_INFO_V1(ora_sys_guid); | ||||||||||||||||||||||||||||||||||||||||||||||
| #ifdef HAVE_UUID_OSSP | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| static void | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -550,3 +553,37 @@ uuid_generate_v5(PG_FUNCTION_ARGS) | |||||||||||||||||||||||||||||||||||||||||||||
| VARDATA_ANY(name), VARSIZE_ANY_EXHDR(name)); | ||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Datum | ||||||||||||||||||||||||||||||||||||||||||||||
| ora_sys_guid(PG_FUNCTION_ARGS) | ||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||
| bytea *result; | ||||||||||||||||||||||||||||||||||||||||||||||
| result = (bytea *)palloc(VARHDRSZ + SYS_GUID_LENGTH); | ||||||||||||||||||||||||||||||||||||||||||||||
| SET_VARSIZE(result, VARHDRSZ + SYS_GUID_LENGTH); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| #ifdef HAVE_UUID_OSSP | ||||||||||||||||||||||||||||||||||||||||||||||
| uuid_t *uuid; | ||||||||||||||||||||||||||||||||||||||||||||||
| uuid_rc_t rc; | ||||||||||||||||||||||||||||||||||||||||||||||
| uuid = get_cached_uuid_t(0); | ||||||||||||||||||||||||||||||||||||||||||||||
| rc = uuid_make(uuid, UUID_MAKE_V4, NULL, NULL); | ||||||||||||||||||||||||||||||||||||||||||||||
| if (rc != UUID_RC_OK) { | ||||||||||||||||||||||||||||||||||||||||||||||
| pguuid_complain(rc); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| memcpy(VARDATA(result), (unsigned char *)uuid, SYS_GUID_LENGTH); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+565
to
+574
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: OSSP uuid_t is an opaque handle; memcpy does not yield the UUID bytes With OSSP, uuid_t is not a 16-byte binary UUID. You must export the generated UUID to binary via uuid_export; memcpy-ing from the uuid_t object produces invalid results. Apply: #ifdef HAVE_UUID_OSSP
- uuid_t *uuid;
- uuid_rc_t rc;
- uuid = get_cached_uuid_t(0);
- rc = uuid_make(uuid, UUID_MAKE_V4, NULL, NULL);
- if (rc != UUID_RC_OK) {
- pguuid_complain(rc);
- }
- memcpy(VARDATA(result), (unsigned char *)uuid, SYS_GUID_LENGTH);
+ uuid_t *uuid;
+ uuid_rc_t rc;
+ void *ptr = VARDATA(result);
+ size_t len = SYS_GUID_LENGTH;
+
+ uuid = get_cached_uuid_t(0);
+ rc = uuid_make(uuid, UUID_MAKE_V4, NULL, NULL);
+ if (rc != UUID_RC_OK)
+ pguuid_complain(rc);
+ rc = uuid_export(uuid, UUID_FMT_BIN, &ptr, &len);
+ if (rc != UUID_RC_OK || len != SYS_GUID_LENGTH)
+ pguuid_complain(rc);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
| #elif defined(HAVE_UUID_E2FS) | ||||||||||||||||||||||||||||||||||||||||||||||
| uuid_t uu; | ||||||||||||||||||||||||||||||||||||||||||||||
| uuid_generate_random(uu); | ||||||||||||||||||||||||||||||||||||||||||||||
| memcpy(VARDATA(result), uu, SYS_GUID_LENGTH); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| #else /* BSD */ | ||||||||||||||||||||||||||||||||||||||||||||||
| int i; | ||||||||||||||||||||||||||||||||||||||||||||||
| unsigned char byte_array[SYS_GUID_LENGTH]; | ||||||||||||||||||||||||||||||||||||||||||||||
| for (i = 0; i < SYS_GUID_LENGTH; i++) { | ||||||||||||||||||||||||||||||||||||||||||||||
| byte_array[i] = (unsigned char)arc4random(); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| memcpy(VARDATA(result), byte_array, SYS_GUID_LENGTH); | ||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||
| PG_RETURN_BYTEA_P(result); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify no duplicate recursion/builds for contrib/uuid-ossp.
You added contrib/uuid-ossp to top-level recurse targets alongside contrib. If contrib already enumerates uuid-ossp, this could double-build/clean/test. If not, this is fine.
If uuid-ossp is already in contrib’s SUBDIRS, consider removing the explicit contrib/uuid-ossp entries here to avoid duplicate recursion. Otherwise, keep as-is.
Also applies to: 48-48, 98-98
🏁 Script executed:
Length of output: 1067
Remove duplicate recursion for contrib/uuid-ossp
The contrib/Makefile already adds uuid-ossp to SUBDIRS/ALWAYS_SUBDIRS, so having it explicitly in the top‐level recurse call will double-build/clean/test. Please remove the extra entries at lines 11, 48, and 98 in GNUmakefile.in.
📝 Committable suggestion
🤖 Prompt for AI Agents