@@ -805,6 +805,7 @@ func (c *SyncedCluster) NodeURL(
805805 serviceMode ServiceMode ,
806806 auth PGAuthMode ,
807807 database string ,
808+ disallowUnsafeInternals bool ,
808809) string {
809810 var u url.URL
810811 u .Scheme = "postgres"
@@ -836,7 +837,11 @@ func (c *SyncedCluster) NodeURL(
836837 v .Add ("sslmode" , "disable" )
837838 }
838839
839- v .Add ("allow_unsafe_internals" , "true" )
840+ // We usually want to allow unsafe internals for testing environments,
841+ // but allow an escape hatch to disallow it, e.g. if we are using psql.
842+ if ! disallowUnsafeInternals {
843+ v .Add ("allow_unsafe_internals" , "true" )
844+ }
840845 // We only want to pass an explicit `cluster` name if the user provided one.
841846 if virtualClusterName != "" {
842847 // We can only pass the cluster parameter for shared processes, as SQL server
@@ -894,7 +899,7 @@ func (c *SyncedCluster) ExecOrInteractiveSQL(
894899 if err != nil {
895900 return err
896901 }
897- url := c .NodeURL ("localhost" , desc .Port , virtualClusterName , desc .ServiceMode , authMode , database )
902+ url := c .NodeURL ("localhost" , desc .Port , virtualClusterName , desc .ServiceMode , authMode , database , false /* disallowUnsafeInternals */ )
898903 binary := cockroachNodeBinary (c , c .Nodes [0 ])
899904 allArgs := []string {binary , "sql" , "--url" , url }
900905 allArgs = append (allArgs , ssh .Escape (args ))
@@ -926,7 +931,7 @@ func (c *SyncedCluster) ExecSQL(
926931 cmd = fmt .Sprintf (`cd %s ; ` , c .localVMDir (node ))
927932 }
928933 cmd += SuppressMetamorphicConstantsEnvVar () + " " + cockroachNodeBinary (c , node ) + " sql --url " +
929- c .NodeURL ("localhost" , desc .Port , virtualClusterName , desc .ServiceMode , authMode , database ) + " " +
934+ c .NodeURL ("localhost" , desc .Port , virtualClusterName , desc .ServiceMode , authMode , database , false /* disallowUnsafeInternals */ ) + " " +
930935 ssh .Escape (args )
931936 return c .runCmdOnSingleNode (ctx , l , node , cmd , defaultCmdOpts ("run-sql" ))
932937 })
@@ -1562,7 +1567,7 @@ func (c *SyncedCluster) generateClusterSettingCmd(
15621567 if err != nil {
15631568 return "" , err
15641569 }
1565- url := c .NodeURL ("localhost" , port , SystemInterfaceName /* virtualClusterName */ , ServiceModeShared , AuthRootCert , "" /* database */ )
1570+ url := c .NodeURL ("localhost" , port , SystemInterfaceName /* virtualClusterName */ , ServiceModeShared , AuthRootCert , "" /* database */ , false /* disallowUnsafeInternals */ )
15661571
15671572 // We use `mkdir -p` here since the directory may not exist if an in-memory
15681573 // store is used.
@@ -1584,7 +1589,7 @@ func (c *SyncedCluster) generateInitCmd(ctx context.Context, node Node) (string,
15841589 if err != nil {
15851590 return "" , err
15861591 }
1587- url := c .NodeURL ("localhost" , port , SystemInterfaceName /* virtualClusterName */ , ServiceModeShared , AuthRootCert , "" /* database */ )
1592+ url := c .NodeURL ("localhost" , port , SystemInterfaceName /* virtualClusterName */ , ServiceModeShared , AuthRootCert , "" /* database */ , false /* disallowUnsafeInternals */ )
15881593 binary := cockroachNodeBinary (c , node )
15891594 initCmd += fmt .Sprintf (`
15901595 if ! test -e %[1]s ; then
@@ -1802,7 +1807,7 @@ func (c *SyncedCluster) createFixedBackupSchedule(
18021807 serviceMode = ServiceModeExternal
18031808 }
18041809
1805- url := c .NodeURL ("localhost" , port , startOpts .VirtualClusterName , serviceMode , AuthRootCert , "" /* database */ )
1810+ url := c .NodeURL ("localhost" , port , startOpts .VirtualClusterName , serviceMode , AuthRootCert , "" /* database */ , false /* disallowUnsafeInternals */ )
18061811 fullCmd := fmt .Sprintf (`%s COCKROACH_CONNECT_TIMEOUT=%d %s sql --url %s -e %q` ,
18071812 SuppressMetamorphicConstantsEnvVar (), startSQLTimeout , binary , url , createScheduleCmd )
18081813 // Instead of using `c.ExecSQL()`, use `c.runCmdOnSingleNode()`, which allows us to
0 commit comments